Skip to content

Commit

Permalink
[EuiBasicTable][EuiInMemoryTable][EuiDataGrid] Update to use `EuiTabl…
Browse files Browse the repository at this point in the history
…ePagination` component defaults (elastic#6993)
  • Loading branch information
cee-chen committed Aug 3, 2023
1 parent 1067453 commit 72c7e0b
Show file tree
Hide file tree
Showing 51 changed files with 723 additions and 1,569 deletions.
4 changes: 2 additions & 2 deletions src-docs/src/views/datagrid/_snippets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ renderCustomDataGridBody={({ visibleColumns, visibleRowData, Cell }) => (
)}`,
pagination: `pagination={{
pageIndex: 1,
pageSize: 100,
pageSizeOptions: [50, 100, 200],
pageSize: 100, // If not specified, defaults to EuiTablePagination.itemsPerPage
pageSizeOptions: [50, 100, 200], // If not specified, defaults to EuiTablePagination.itemsPerPageOptions
onChangePage: () => {},
onChangeItemsPerPage: () => {},
}}`,
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/advanced/custom_renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default () => {
);

// Pagination
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });
const onChangePage = useCallback<EuiDataGridPaginationProps['onChangePage']>(
(pageIndex) => {
setPagination((pagination) => ({ ...pagination, pageIndex }));
Expand Down Expand Up @@ -294,7 +294,6 @@ export default () => {
inMemory={{ level: 'sorting' }}
pagination={{
...pagination,
pageSizeOptions: [10, 25, 50],
onChangePage: onChangePage,
onChangeItemsPerPage: onChangePageSize,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const inMemorySortingDataGridSource = require('!!raw-loader!./in_memory_sorting'

import {
EuiDataGridColumn,
EuiDataGridPaginationProps,
EuiDataGridSorting,
EuiDataGridInMemory,
EuiDataGridStyle,
Expand All @@ -32,6 +31,7 @@ import {
EuiDataGridCellValueElementProps,
EuiDataGridSchemaDetector,
} from '!!prop-loader!../../../../../src/components/datagrid/data_grid_types';
import { EuiDataGridPaginationProps } from '../basics/_props';

export const DataGridMemoryExample = {
sections: [
Expand Down
1 change: 0 additions & 1 deletion src-docs/src/views/datagrid/advanced/in_memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export default () => {
sorting={{ columns: sortingColumns, onSort }}
pagination={{
...pagination,
pageSizeOptions: [10, 50, 100],
onChangeItemsPerPage: onChangeItemsPerPage,
onChangePage: onChangePage,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export default () => {
sorting={{ columns: sortingColumns, onSort }}
pagination={{
...pagination,
pageSizeOptions: [10, 50, 100],
onChangeItemsPerPage: onChangeItemsPerPage,
onChangePage: onChangePage,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/advanced/in_memory_pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ for (let i = 1; i < 100; i++) {

export default () => {
// Pagination
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });
const onChangeItemsPerPage = useCallback(
(pageSize) =>
setPagination((pagination) => ({
Expand Down Expand Up @@ -115,7 +115,6 @@ export default () => {
sorting={{ columns: sortingColumns, onSort }}
pagination={{
...pagination,
pageSizeOptions: [10, 50, 0],
onChangeItemsPerPage: onChangeItemsPerPage,
onChangePage: onChangePage,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/advanced/in_memory_sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ for (let i = 1; i < 100; i++) {

export default () => {
// Pagination
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });
const onChangeItemsPerPage = useCallback(
(pageSize) =>
setPagination((pagination) => ({
Expand Down Expand Up @@ -101,7 +101,6 @@ export default () => {
sorting={{ columns: sortingColumns, onSort }}
pagination={{
...pagination,
pageSizeOptions: [10, 50, 100],
onChangeItemsPerPage: onChangeItemsPerPage,
onChangePage: onChangePage,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/advanced/ref.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default () => {
);

// Pagination
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 25 });
const [pagination, setPagination] = useState({ pageIndex: 0 });
const onChangePage = useCallback<EuiDataGridPaginationProps['onChangePage']>(
(pageIndex) => {
setPagination((pagination) => ({ ...pagination, pageIndex }));
Expand Down Expand Up @@ -224,7 +224,6 @@ export default () => {
}
pagination={{
...pagination,
pageSizeOptions: [25, 50],
onChangePage: onChangePage,
onChangeItemsPerPage: onChangePageSize,
}}
Expand Down
12 changes: 10 additions & 2 deletions src-docs/src/views/datagrid/basics/_props.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';
import { EuiDataGrid } from '../../../../../src/components';
import React, { FunctionComponent } from 'react';
import {
EuiDataGrid,
EuiDataGridPaginationProps as _EuiDataGridPaginationProps,
} from '../../../../../src/components';

import { DataGridPropsTable } from '../_props_table';
import { gridSnippets } from '../_snippets';
Expand Down Expand Up @@ -41,3 +44,8 @@ export const DataGridTopProps = () => {
/>
);
};

// Loading `EuiDataGridPaginationProps` via !prop-loader doesn't correctly inherit @defaults
export const EuiDataGridPaginationProps: FunctionComponent<
_EuiDataGridPaginationProps
> = () => <div />;
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/basics/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ for (let i = 1; i < 20; i++) {
}

export default () => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });

const [visibleColumns, setVisibleColumns] = useState(
columns.map(({ id }) => id)
Expand Down Expand Up @@ -74,7 +74,6 @@ export default () => {
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/basics/datagrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const trailingControlColumns = [

export default () => {
// Pagination
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });
const onChangeItemsPerPage = useCallback(
(pageSize) =>
setPagination((pagination) => ({
Expand Down Expand Up @@ -419,7 +419,6 @@ export default () => {
sorting={{ columns: sortingColumns, onSort }}
pagination={{
...pagination,
pageSizeOptions: [10, 50, 100],
onChangeItemsPerPage: onChangeItemsPerPage,
onChangePage: onChangePage,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/basics/datagrid_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../../../../../src/components';

import DataGrid from './datagrid';
import { DataGridTopProps } from './_props';
import { DataGridTopProps, EuiDataGridPaginationProps } from './_props';
const dataGridSource = require('!!raw-loader!./datagrid');

import DataGridContainer from './container';
Expand All @@ -28,7 +28,6 @@ const dataGridVirtualizationConstrainedSource = require('!!raw-loader!./virtuali
import {
EuiDataGridColumn,
EuiDataGridColumnCellAction,
EuiDataGridPaginationProps,
EuiDataGridSorting,
EuiDataGridInMemory,
EuiDataGridStyle,
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/basics/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ for (let i = 1; i < 20; i++) {
}

export default () => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });

const [visibleColumns, setVisibleColumns] = useState(
columns.map(({ id }) => id)
Expand Down Expand Up @@ -89,7 +89,6 @@ export default () => {
}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ for (let i = 1; i < 5; i++) {
}

export default () => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });

const [visibleColumns, setVisibleColumns] = useState(
columns.map(({ id }) => id)
Expand Down Expand Up @@ -153,7 +153,6 @@ export default () => {
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/schema_columns/column_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ for (let i = 1; i < 5; i++) {
}

export default () => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 5 });
const [pagination, setPagination] = useState({ pageIndex: 0 });

const [visibleColumns, setVisibleColumns] = useState(
columns.map(({ id }) => id)
Expand Down Expand Up @@ -102,7 +102,6 @@ export default () => {
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/schema_columns/column_widths.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ for (let i = 1; i < 5; i++) {
}

export default () => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 5 });
const [pagination, setPagination] = useState({ pageIndex: 0 });

const [visibleColumns, setVisibleColumns] = useState(
columns.map(({ id }) => id)
Expand Down Expand Up @@ -79,7 +79,6 @@ export default () => {
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,7 @@ const trailingControlColumns = [
];

export default function DataGrid() {
const [pagination, setPagination] = useState({
pageIndex: 0,
pageSize: 15,
});
const [pagination, setPagination] = useState({ pageIndex: 0 });
const setPageIndex = useCallback(
(pageIndex) =>
setPagination((pagination) => ({ ...pagination, pageIndex })),
Expand Down Expand Up @@ -369,7 +366,6 @@ export default function DataGrid() {
renderCellValue={renderCellValue}
pagination={{
...pagination,
pageSizeOptions: [5, 15, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/schema_columns/footer_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const RenderFooterCellValue = ({ columnId, setCellProps }) => {

export default () => {
// Pagination
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });
const onChangeItemsPerPage = useCallback(
(pageSize) =>
setPagination((pagination) => ({
Expand Down Expand Up @@ -177,7 +177,6 @@ export default () => {
}
pagination={{
...pagination,
pageSizeOptions: [10, 15, 20],
onChangeItemsPerPage: onChangeItemsPerPage,
onChangePage: onChangePage,
}}
Expand Down
6 changes: 1 addition & 5 deletions src-docs/src/views/datagrid/styling/styling_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ const DataGridStyle = ({
header = 'underline',
footer = 'overline',
}) => {
const [pagination, setPagination] = useState({
pageIndex: 0,
pageSize: 5,
});
const [pagination, setPagination] = useState({ pageIndex: 0 });
const [visibleColumns, setVisibleColumns] = useState(
columns.map(({ id }) => id)
);
Expand Down Expand Up @@ -111,7 +108,6 @@ const DataGridStyle = ({
renderFooterCellValue={renderFooterCellValue}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
6 changes: 1 addition & 5 deletions src-docs/src/views/datagrid/toolbar/_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ const DataGridStyle = ({
allowHideColumns,
allowOrderingColumns,
}) => {
const [pagination, setPagination] = useState({
pageIndex: 0,
pageSize: 5,
});
const [pagination, setPagination] = useState({ pageIndex: 0 });
const [visibleColumns, setVisibleColumns] = useState(
columns.map(({ id }) => id)
);
Expand Down Expand Up @@ -139,7 +136,6 @@ const DataGridStyle = ({
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/views/datagrid/toolbar/additional_controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ for (let i = 1; i < 20; i++) {
}

export default () => {
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const [pagination, setPagination] = useState({ pageIndex: 0 });
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
const flyoutTitleId = useGeneratedHtmlId({
prefix: 'dataGridAdditionalControlsFlyout',
Expand Down Expand Up @@ -129,7 +129,6 @@ export default () => {
renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]}
pagination={{
...pagination,
pageSizeOptions: [5, 10, 25],
onChangeItemsPerPage: setPageSize,
onChangePage: setPageIndex,
}}
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/tables/basic/basic_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Criteria,
CriteriaWithPagination,
} from '!!prop-loader!../../../../../src/components/basic_table/basic_table';
import { Pagination } from '!!prop-loader!../../../../../src/components/basic_table/pagination_bar';
import { Pagination } from '../paginated/_props';
import {
EuiTableFieldDataColumnType,
EuiTableComputedColumnType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Criteria,
CriteriaWithPagination,
} from '!!prop-loader!../../../../../src/components/basic_table/basic_table';
import { Pagination } from '!!prop-loader!../../../../../src/components/basic_table/pagination_bar';
import { Pagination } from '../paginated/_props';
import {
EuiTableFieldDataColumnType,
EuiTableComputedColumnType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Criteria,
CriteriaWithPagination,
} from '!!prop-loader!../../../../../src/components/basic_table/basic_table';
import { Pagination } from '!!prop-loader!../../../../../src/components/basic_table/pagination_bar';
import { Pagination } from '../paginated/_props';
import {
EuiTableFieldDataColumnType,
EuiTableComputedColumnType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Criteria,
CriteriaWithPagination,
} from '!!prop-loader!../../../../../src/components/basic_table/basic_table';
import { Pagination } from '!!prop-loader!../../../../../src/components/basic_table/pagination_bar';
import { Pagination } from '../paginated/_props';
import {
EuiTableFieldDataColumnType,
EuiTableComputedColumnType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Criteria,
CriteriaWithPagination,
} from '!!prop-loader!../../../../../src/components/basic_table/basic_table';
import { Pagination } from '!!prop-loader!../../../../../src/components/basic_table/pagination_bar';
import { Pagination } from '../paginated/_props';
import {
EuiTableFieldDataColumnType,
EuiTableComputedColumnType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Criteria,
CriteriaWithPagination,
} from '!!prop-loader!../../../../../src/components/basic_table/basic_table';
import { Pagination } from '!!prop-loader!../../../../../src/components/basic_table/pagination_bar';
import { Pagination } from '../paginated/_props';
import {
EuiTableFieldDataColumnType,
EuiTableComputedColumnType,
Expand Down
Loading

0 comments on commit 72c7e0b

Please sign in to comment.