@patternfly/react-table 6.0.0-alpha.1 → 6.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +188 -0
- package/README.md +2 -2
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/Table/package.json +1 -1
- package/dist/dynamic/components/Table/utils/decorators/package.json +1 -1
- package/dist/dynamic/components/Table/utils/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/base/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/esm/components/Table/ActionsColumn.d.ts +1 -1
- package/dist/esm/components/Table/ActionsColumn.d.ts.map +1 -1
- package/dist/esm/components/Table/Caption.js +1 -1
- package/dist/esm/components/Table/Caption.js.map +1 -1
- package/dist/esm/components/Table/CollapseColumn.js +1 -1
- package/dist/esm/components/Table/CollapseColumn.js.map +1 -1
- package/dist/esm/components/Table/DraggableRowWrapper.js +2 -2
- package/dist/esm/components/Table/DraggableRowWrapper.js.map +1 -1
- package/dist/esm/components/Table/EditColumn.js +1 -1
- package/dist/esm/components/Table/EditColumn.js.map +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.js +2 -2
- package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/esm/components/Table/EditableTextCell.js +2 -2
- package/dist/esm/components/Table/EditableTextCell.js.map +1 -1
- package/dist/esm/components/Table/ExpandableRowContent.js +1 -1
- package/dist/esm/components/Table/ExpandableRowContent.js.map +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js.map +1 -1
- package/dist/esm/components/Table/InnerScrollContainer.js +1 -1
- package/dist/esm/components/Table/InnerScrollContainer.js.map +1 -1
- package/dist/esm/components/Table/OuterScrollContainer.js +1 -1
- package/dist/esm/components/Table/OuterScrollContainer.js.map +1 -1
- package/dist/esm/components/Table/RowWrapper.d.ts +1 -1
- package/dist/esm/components/Table/SortColumn.js +1 -1
- package/dist/esm/components/Table/SortColumn.js.map +1 -1
- package/dist/esm/components/Table/Table.d.ts +1 -1
- package/dist/esm/components/Table/Table.d.ts.map +1 -1
- package/dist/esm/components/Table/Table.js +5 -5
- package/dist/esm/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Table/TableText.js +1 -1
- package/dist/esm/components/Table/TableText.js.map +1 -1
- package/dist/esm/components/Table/Tbody.d.ts +1 -1
- package/dist/esm/components/Table/Tbody.d.ts.map +1 -1
- package/dist/esm/components/Table/Tbody.js +1 -1
- package/dist/esm/components/Table/Tbody.js.map +1 -1
- package/dist/esm/components/Table/Td.d.ts +1 -1
- package/dist/esm/components/Table/Td.d.ts.map +1 -1
- package/dist/esm/components/Table/Td.js +9 -5
- package/dist/esm/components/Table/Td.js.map +1 -1
- package/dist/esm/components/Table/Th.d.ts +1 -1
- package/dist/esm/components/Table/Th.d.ts.map +1 -1
- package/dist/esm/components/Table/Th.js +6 -3
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/esm/components/Table/Thead.d.ts +1 -1
- package/dist/esm/components/Table/Thead.d.ts.map +1 -1
- package/dist/esm/components/Table/Thead.js +1 -1
- package/dist/esm/components/Table/Thead.js.map +1 -1
- package/dist/esm/components/Table/Tr.d.ts +2 -2
- package/dist/esm/components/Table/Tr.d.ts.map +1 -1
- package/dist/esm/components/Table/Tr.js +2 -2
- package/dist/esm/components/Table/Tr.js.map +1 -1
- package/dist/esm/components/Table/TreeRowWrapper.js +2 -2
- package/dist/esm/components/Table/TreeRowWrapper.js.map +1 -1
- package/dist/esm/components/Table/base/provider.d.ts +8 -8
- package/dist/esm/components/Table/base/types.d.ts +7 -7
- package/dist/esm/components/Table/utils/decorators/cellActions.js +1 -1
- package/dist/esm/components/Table/utils/decorators/cellActions.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/cellWidth.js +1 -1
- package/dist/esm/components/Table/utils/decorators/cellWidth.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/classNames.js +1 -1
- package/dist/esm/components/Table/utils/decorators/classNames.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/compoundExpand.js +1 -1
- package/dist/esm/components/Table/utils/decorators/compoundExpand.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/editable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/editable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/favoritable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/favoritable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/info.js +1 -1
- package/dist/esm/components/Table/utils/decorators/info.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/selectable.js +2 -2
- package/dist/esm/components/Table/utils/decorators/selectable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/treeRow.d.ts +3 -3
- package/dist/esm/components/Table/utils/decorators/treeRow.d.ts.map +1 -1
- package/dist/esm/components/Table/utils/decorators/treeRow.js +5 -5
- package/dist/esm/components/Table/utils/decorators/treeRow.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/wrappable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/wrappable.js.map +1 -1
- package/dist/esm/demos/index.d.ts +2 -0
- package/dist/esm/demos/index.d.ts.map +1 -0
- package/dist/esm/demos/index.js +2 -0
- package/dist/esm/demos/index.js.map +1 -0
- package/dist/esm/demos/sampleData.d.ts +13 -0
- package/dist/esm/demos/sampleData.d.ts.map +1 -0
- package/dist/esm/demos/sampleData.js +764 -0
- package/dist/esm/demos/sampleData.js.map +1 -0
- package/dist/esm/deprecated/components/Table/Body.d.ts +1 -1
- package/dist/esm/deprecated/components/Table/Body.d.ts.map +1 -1
- package/dist/esm/deprecated/components/Table/Table.d.ts +1 -1
- package/dist/esm/deprecated/components/Table/Table.js +1 -1
- package/dist/esm/deprecated/components/Table/Table.js.map +1 -1
- package/dist/esm/deprecated/components/Table/base/body.d.ts +8 -2
- package/dist/esm/deprecated/components/Table/base/body.d.ts.map +1 -1
- package/dist/esm/deprecated/components/Table/base/header.d.ts +1 -1
- package/dist/esm/deprecated/components/Table/base/header.d.ts.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/js/components/Table/ActionsColumn.d.ts +1 -1
- package/dist/js/components/Table/ActionsColumn.d.ts.map +1 -1
- package/dist/js/components/Table/ActionsColumn.js +6 -6
- package/dist/js/components/Table/ActionsColumn.js.map +1 -1
- package/dist/js/components/Table/CollapseColumn.js +2 -2
- package/dist/js/components/Table/CollapseColumn.js.map +1 -1
- package/dist/js/components/Table/DraggableCell.js +2 -2
- package/dist/js/components/Table/DraggableCell.js.map +1 -1
- package/dist/js/components/Table/EditColumn.js +4 -4
- package/dist/js/components/Table/EditColumn.js.map +1 -1
- package/dist/js/components/Table/EditableSelectInputCell.js +1 -1
- package/dist/js/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/js/components/Table/EditableTextCell.js +1 -1
- package/dist/js/components/Table/EditableTextCell.js.map +1 -1
- package/dist/js/components/Table/FavoritesCell.js +2 -2
- package/dist/js/components/Table/FavoritesCell.js.map +1 -1
- package/dist/js/components/Table/HeaderCellInfoWrapper.js +4 -4
- package/dist/js/components/Table/HeaderCellInfoWrapper.js.map +1 -1
- package/dist/js/components/Table/RowWrapper.d.ts +1 -1
- package/dist/js/components/Table/RowWrapper.js +2 -1
- package/dist/js/components/Table/RowWrapper.js.map +1 -1
- package/dist/js/components/Table/SortColumn.js +3 -3
- package/dist/js/components/Table/SortColumn.js.map +1 -1
- package/dist/js/components/Table/Table.d.ts +1 -1
- package/dist/js/components/Table/Table.d.ts.map +1 -1
- package/dist/js/components/Table/Table.js +2 -2
- package/dist/js/components/Table/Table.js.map +1 -1
- package/dist/js/components/Table/TableText.js +1 -1
- package/dist/js/components/Table/TableText.js.map +1 -1
- package/dist/js/components/Table/TableTypes.js +4 -0
- package/dist/js/components/Table/TableTypes.js.map +1 -1
- package/dist/js/components/Table/Tbody.d.ts +1 -1
- package/dist/js/components/Table/Tbody.d.ts.map +1 -1
- package/dist/js/components/Table/Td.d.ts +1 -1
- package/dist/js/components/Table/Td.d.ts.map +1 -1
- package/dist/js/components/Table/Td.js +8 -4
- package/dist/js/components/Table/Td.js.map +1 -1
- package/dist/js/components/Table/Th.d.ts +1 -1
- package/dist/js/components/Table/Th.d.ts.map +1 -1
- package/dist/js/components/Table/Th.js +5 -2
- package/dist/js/components/Table/Th.js.map +1 -1
- package/dist/js/components/Table/Thead.d.ts +1 -1
- package/dist/js/components/Table/Thead.d.ts.map +1 -1
- package/dist/js/components/Table/Tr.d.ts +2 -2
- package/dist/js/components/Table/Tr.d.ts.map +1 -1
- package/dist/js/components/Table/Tr.js +1 -1
- package/dist/js/components/Table/Tr.js.map +1 -1
- package/dist/js/components/Table/base/provider.d.ts +8 -8
- package/dist/js/components/Table/base/types.d.ts +7 -7
- package/dist/js/components/Table/base/types.js +4 -0
- package/dist/js/components/Table/base/types.js.map +1 -1
- package/dist/js/components/Table/utils/decorators/sortable.js +1 -1
- package/dist/js/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/js/components/Table/utils/decorators/treeRow.d.ts +3 -3
- package/dist/js/components/Table/utils/decorators/treeRow.d.ts.map +1 -1
- package/dist/js/components/Table/utils/decorators/treeRow.js +7 -7
- package/dist/js/components/Table/utils/decorators/treeRow.js.map +1 -1
- package/dist/js/demos/index.d.ts +2 -0
- package/dist/js/demos/index.d.ts.map +1 -0
- package/dist/js/demos/index.js +5 -0
- package/dist/js/demos/index.js.map +1 -0
- package/dist/js/demos/sampleData.d.ts +13 -0
- package/dist/js/demos/sampleData.d.ts.map +1 -0
- package/dist/js/demos/sampleData.js +767 -0
- package/dist/js/demos/sampleData.js.map +1 -0
- package/dist/js/deprecated/components/Table/Body.d.ts +1 -1
- package/dist/js/deprecated/components/Table/Body.d.ts.map +1 -1
- package/dist/js/deprecated/components/Table/BodyCell.js +4 -3
- package/dist/js/deprecated/components/Table/BodyCell.js.map +1 -1
- package/dist/js/deprecated/components/Table/Table.d.ts +1 -1
- package/dist/js/deprecated/components/Table/Table.js +1 -1
- package/dist/js/deprecated/components/Table/Table.js.map +1 -1
- package/dist/js/deprecated/components/Table/base/body.d.ts +8 -2
- package/dist/js/deprecated/components/Table/base/body.d.ts.map +1 -1
- package/dist/js/deprecated/components/Table/base/header.d.ts +1 -1
- package/dist/js/deprecated/components/Table/base/header.d.ts.map +1 -1
- package/dist/js/index.d.ts +1 -0
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -0
- package/dist/js/index.js.map +1 -1
- package/dist/umd/react-table.min.js +9 -9
- package/package.json +6 -6
- package/src/components/Table/Table.tsx +2 -2
- package/src/components/Table/Td.tsx +10 -5
- package/src/components/Table/Th.tsx +6 -3
- package/src/components/Table/Tr.tsx +1 -1
- package/src/components/Table/examples/Table.md +3 -0
- package/src/components/Table/examples/TableCompoundExpandable.tsx +2 -1
- package/src/components/Table/examples/TableMisc.tsx +3 -1
- package/src/components/Table/examples/TableNestedHeaders.tsx +4 -3
- package/src/components/Table/examples/TableNestedStickyHeader.tsx +4 -3
- package/src/components/Table/examples/TableStickyColumnsAndHeader.tsx +5 -4
- package/src/components/Table/utils/decorators/treeRow.tsx +3 -3
- package/src/components/Table/utils/transformers.test.tsx +14 -8
- package/src/demos/Table.md +159 -0
- package/src/demos/examples/TableAutomaticPagination.tsx +101 -0
- package/src/{docs/demos/table-demos/BulkSelect.jsx → demos/examples/TableBulkSelect.tsx} +41 -20
- package/src/demos/examples/TableColumnManagement.tsx +486 -0
- package/src/demos/examples/TableColumnManagementWithDraggable.tsx +641 -0
- package/src/{docs/demos/table-demos/Compact.jsx → demos/examples/TableCompact.tsx} +32 -16
- package/src/{docs/demos/table-demos/CompoundExpansion.jsx → demos/examples/TableCompoundExpansion.tsx} +27 -13
- package/src/demos/examples/TableEmptyStateDefault.tsx +60 -0
- package/src/demos/examples/TableEmptyStateError.tsx +53 -0
- package/src/demos/examples/TableEmptyStateLoading.tsx +43 -0
- package/src/{docs/demos/table-demos/ExpandCollapseAll.jsx → demos/examples/TableExpandCollapseAll.tsx} +17 -10
- package/src/demos/examples/TableFilterable.tsx +394 -0
- package/src/{docs/demos/table-demos/SortableResponsive.jsx → demos/examples/TableSortableResponsive.tsx} +30 -29
- package/src/{docs/demos/table-demos/StaticBottomPagination.jsx → demos/examples/TableStaticBottomPagination.tsx} +22 -9
- package/src/{docs/demos/table-demos/StickyFirstColumn.jsx → demos/examples/TableStickyFirstColumn.tsx} +31 -9
- package/src/{docs/demos/table-demos/StickyHeader.jsx → demos/examples/TableStickyHeader.tsx} +3 -3
- package/src/demos/index.ts +1 -0
- package/src/{docs/demos/table-demos/sampleData.js → demos/sampleData.tsx} +88 -77
- package/src/deprecated/components/Table/__tests__/Table.test.tsx +4 -9
- package/src/deprecated/components/Table/examples/LegacyTableCompoundExpandable.tsx +4 -3
- package/src/deprecated/components/Table/examples/LegacyTableMisc.tsx +4 -3
- package/src/deprecated/components/Table/examples/LegacyTableSelectable.tsx +2 -1
- package/src/deprecated/components/Table/examples/LegacyTableStripedCustomTr.tsx +2 -6
- package/src/deprecated/components/Table/examples/Table.md +2 -0
- package/src/index.ts +1 -0
- package/src/docs/demos/Table.md +0 -1622
- package/src/docs/demos/table-demos/ColumnManagement.jsx +0 -471
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.3",
|
|
4
4
|
"description": "This library provides a set of React table components for use with the PatternFly 4",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@patternfly/react-core": "^6.0.0-alpha.
|
|
44
|
-
"@patternfly/react-icons": "^6.0.0-alpha.
|
|
45
|
-
"@patternfly/react-styles": "^6.0.0-alpha.
|
|
46
|
-
"@patternfly/react-tokens": "^6.0.0-alpha.
|
|
43
|
+
"@patternfly/react-core": "^6.0.0-alpha.3",
|
|
44
|
+
"@patternfly/react-icons": "^6.0.0-alpha.3",
|
|
45
|
+
"@patternfly/react-styles": "^6.0.0-alpha.3",
|
|
46
|
+
"@patternfly/react-tokens": "^6.0.0-alpha.3",
|
|
47
47
|
"lodash": "^4.17.19",
|
|
48
48
|
"tslib": "^2.5.0"
|
|
49
49
|
},
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react": "^17 || ^18",
|
|
56
56
|
"react-dom": "^17 || ^18"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "da36134a3effa82a166c47f5b1c2689869a0f52a"
|
|
59
59
|
}
|
|
@@ -159,8 +159,8 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
159
159
|
const handleKeys = (event: KeyboardEvent) => {
|
|
160
160
|
if (
|
|
161
161
|
isNested ||
|
|
162
|
-
!(tableRef && tableRef.current && tableRef.current.classList.contains(
|
|
163
|
-
(tableRef && tableRef.current !== (event.target as HTMLElement).closest(
|
|
162
|
+
!(tableRef && tableRef.current && tableRef.current.classList.contains(stylesTreeView.modifiers.treeView)) || // implements roving tab-index to tree tables only
|
|
163
|
+
(tableRef && tableRef.current !== (event.target as HTMLElement).closest(`.${styles.table}:not(.pf-m-nested)`))
|
|
164
164
|
) {
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { css } from '@patternfly/react-styles';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
4
4
|
import scrollStyles from '@patternfly/react-styles/css/components/Table/table-scrollable';
|
|
5
|
+
import treeViewStyles from '@patternfly/react-styles/css/components/Table/table-tree-view';
|
|
5
6
|
import { BaseCellProps } from './Table';
|
|
6
7
|
import {
|
|
7
8
|
cellActions,
|
|
@@ -28,6 +29,10 @@ import {
|
|
|
28
29
|
TdSelectType,
|
|
29
30
|
TdTreeRowType
|
|
30
31
|
} from './base/types';
|
|
32
|
+
import cssStickyCellMinWidth from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_MinWidth';
|
|
33
|
+
import cssStickyCellLeft from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_Left';
|
|
34
|
+
import cssStickyCellRight from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_Right';
|
|
35
|
+
|
|
31
36
|
export interface TdProps extends BaseCellProps, Omit<React.HTMLProps<HTMLTableDataCellElement>, 'onSelect' | 'width'> {
|
|
32
37
|
/**
|
|
33
38
|
* The column header the cell corresponds to.
|
|
@@ -253,8 +258,8 @@ const TdBase: React.FunctionComponent<TdProps> = ({
|
|
|
253
258
|
} = merged;
|
|
254
259
|
|
|
255
260
|
const treeTableTitleCell =
|
|
256
|
-
(className && className.includes(
|
|
257
|
-
(mergedClassName && mergedClassName.includes(
|
|
261
|
+
(className && className.includes(treeViewStyles.tableTreeViewTitleCell)) ||
|
|
262
|
+
(mergedClassName && mergedClassName.includes(treeViewStyles.tableTreeViewTitleCell));
|
|
258
263
|
|
|
259
264
|
React.useEffect(() => {
|
|
260
265
|
setTruncated(
|
|
@@ -288,9 +293,9 @@ const TdBase: React.FunctionComponent<TdProps> = ({
|
|
|
288
293
|
{...props}
|
|
289
294
|
{...(isStickyColumn && {
|
|
290
295
|
style: {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
296
|
+
[cssStickyCellMinWidth.name]: stickyMinWidth ? stickyMinWidth : undefined,
|
|
297
|
+
[cssStickyCellLeft.name]: stickyLeftOffset ? stickyLeftOffset : 0,
|
|
298
|
+
[cssStickyCellRight.name]: stickyRightOffset ? stickyRightOffset : 0,
|
|
294
299
|
...props.style
|
|
295
300
|
} as React.CSSProperties
|
|
296
301
|
})}
|
|
@@ -9,6 +9,9 @@ import { IVisibility } from './utils/decorators/classNames';
|
|
|
9
9
|
import { Tooltip } from '@patternfly/react-core/dist/esm/components/Tooltip/Tooltip';
|
|
10
10
|
import { BaseCellProps } from './Table';
|
|
11
11
|
import { IFormatterValueType, IColumn } from './TableTypes';
|
|
12
|
+
import cssStickyCellMinWidth from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_MinWidth';
|
|
13
|
+
import cssStickyCellLeft from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_Left';
|
|
14
|
+
import cssStickyCellRight from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_Right';
|
|
12
15
|
|
|
13
16
|
export interface ThProps
|
|
14
17
|
extends BaseCellProps,
|
|
@@ -193,9 +196,9 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
193
196
|
{...props}
|
|
194
197
|
{...(isStickyColumn && {
|
|
195
198
|
style: {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
+
[cssStickyCellMinWidth.name]: stickyMinWidth ? stickyMinWidth : undefined,
|
|
200
|
+
[cssStickyCellLeft.name]: stickyLeftOffset ? stickyLeftOffset : 0,
|
|
201
|
+
[cssStickyCellRight.name]: stickyRightOffset ? stickyRightOffset : 0,
|
|
199
202
|
...props.style
|
|
200
203
|
} as React.CSSProperties
|
|
201
204
|
})}
|
|
@@ -5,7 +5,7 @@ import inlineStyles from '@patternfly/react-styles/css/components/InlineEdit/inl
|
|
|
5
5
|
import { css } from '@patternfly/react-styles';
|
|
6
6
|
import { TableContext } from './Table';
|
|
7
7
|
|
|
8
|
-
export interface TrProps extends React.HTMLProps<HTMLTableRowElement>, OUIAProps {
|
|
8
|
+
export interface TrProps extends Omit<React.HTMLProps<HTMLTableRowElement>, 'onResize'>, OUIAProps {
|
|
9
9
|
/** Content rendered inside the <tr> row */
|
|
10
10
|
children?: React.ReactNode;
|
|
11
11
|
/** Additional classes added to the <tr> row */
|
|
@@ -54,6 +54,9 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico
|
|
|
54
54
|
|
|
55
55
|
import { css } from '@patternfly/react-styles';
|
|
56
56
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
57
|
+
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
|
|
58
|
+
import textStyles from '@patternfly/react-styles/css/utilities/Text/text';
|
|
59
|
+
import global_BackgroundColor_150 from '@patternfly/react-tokens/dist/esm/global_BackgroundColor_150';
|
|
57
60
|
|
|
58
61
|
## Table examples
|
|
59
62
|
|
|
@@ -4,6 +4,7 @@ import { Table, Thead, Tr, Th, Tbody, Td, TdProps, ExpandableRowContent } from '
|
|
|
4
4
|
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
5
5
|
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
|
|
6
6
|
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
7
|
+
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
|
|
7
8
|
|
|
8
9
|
interface Repository {
|
|
9
10
|
name: string;
|
|
@@ -110,7 +111,7 @@ export const TableCompoundExpandable: React.FunctionComponent = () => {
|
|
|
110
111
|
<Tr isExpanded={isRowExpanded}>
|
|
111
112
|
<Td dataLabel={columnNames[expandedCellKey]} noPadding colSpan={6}>
|
|
112
113
|
<ExpandableRowContent>
|
|
113
|
-
<div className=
|
|
114
|
+
<div className={spacing.mMd}>
|
|
114
115
|
Lorem ipsum sit dolor. Lorem ipsum sit dolor. Lorem ipsum sit dolor. Lorem ipsum sit dolor. Lorem
|
|
115
116
|
ipsum sit dolor. Lorem ipsum sit dolor. Lorem ipsum sit dolor. Lorem ipsum sit dolor. Lorem ipsum
|
|
116
117
|
sit dolor. Lorem ipsum sit dolor. Lorem ipsum sit dolor. Lorem ipsum sit dolor. Lorem ipsum sit
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
3
|
+
/* eslint-disable camelcase */
|
|
4
|
+
import global_BackgroundColor_150 from '@patternfly/react-tokens/dist/esm/global_BackgroundColor_150';
|
|
3
5
|
|
|
4
6
|
interface Repository {
|
|
5
7
|
name: string;
|
|
@@ -65,7 +67,7 @@ export const TableMisc: React.FunctionComponent = () => {
|
|
|
65
67
|
{repositories.map((repo, rowIndex) => {
|
|
66
68
|
const isOddRow = (rowIndex + 1) % 2;
|
|
67
69
|
const customStyle = {
|
|
68
|
-
backgroundColor:
|
|
70
|
+
backgroundColor: global_BackgroundColor_150.var
|
|
69
71
|
};
|
|
70
72
|
// Some arbitrary logic to demonstrate that cell styles can be based on anything
|
|
71
73
|
const nameColSpan = repo.branches === null && repo.prs === null ? 3 : 1;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Table, Thead, Tr, Th, Tbody, Td, InnerScrollContainer, ThProps } from '@patternfly/react-table';
|
|
3
3
|
import { Stack, StackItem } from '@patternfly/react-core';
|
|
4
|
+
import textStyles from '@patternfly/react-styles/css/utilities/Text/text';
|
|
4
5
|
|
|
5
6
|
interface PodConnection {
|
|
6
7
|
source: {
|
|
@@ -162,7 +163,7 @@ export const TableNestedHeaders: React.FunctionComponent = () => {
|
|
|
162
163
|
<Td dataLabel={columnNames.datetime}>
|
|
163
164
|
<div>
|
|
164
165
|
<span>{new Date(connection.timestamp).toDateString()}</span>{' '}
|
|
165
|
-
<span className=
|
|
166
|
+
<span className={textStyles.color_200}>{new Date(connection.timestamp).toLocaleTimeString()}</span>
|
|
166
167
|
</div>
|
|
167
168
|
</Td>
|
|
168
169
|
<Td dataLabel={columnNames.source}>
|
|
@@ -171,7 +172,7 @@ export const TableNestedHeaders: React.FunctionComponent = () => {
|
|
|
171
172
|
<span>{connection.source.port.num}</span>
|
|
172
173
|
</StackItem>
|
|
173
174
|
<StackItem>
|
|
174
|
-
<span className=
|
|
175
|
+
<span className={textStyles.color_200}>({connection.source.port.protocol})</span>
|
|
175
176
|
</StackItem>
|
|
176
177
|
</Stack>
|
|
177
178
|
</Td>
|
|
@@ -181,7 +182,7 @@ export const TableNestedHeaders: React.FunctionComponent = () => {
|
|
|
181
182
|
<span>{connection.destination.port.num}</span>
|
|
182
183
|
</StackItem>
|
|
183
184
|
<StackItem>
|
|
184
|
-
<span className=
|
|
185
|
+
<span className={textStyles.color_200}>({connection.destination.port.protocol})</span>
|
|
185
186
|
</StackItem>
|
|
186
187
|
</Stack>
|
|
187
188
|
</Td>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Table, Thead, Tr, Th, Tbody, Td, InnerScrollContainer, ThProps } from '@patternfly/react-table';
|
|
3
3
|
import { Stack, StackItem } from '@patternfly/react-core';
|
|
4
|
+
import textStyles from '@patternfly/react-styles/css/utilities/Text/text';
|
|
4
5
|
|
|
5
6
|
interface PodConnection {
|
|
6
7
|
source: {
|
|
@@ -165,7 +166,7 @@ export const TableNestedHeaders: React.FunctionComponent = () => {
|
|
|
165
166
|
<Td dataLabel={columnNames.datetime}>
|
|
166
167
|
<div>
|
|
167
168
|
<span>{new Date(connection.timestamp).toDateString()}</span>{' '}
|
|
168
|
-
<span className=
|
|
169
|
+
<span className={textStyles.color_200}>{new Date(connection.timestamp).toLocaleTimeString()}</span>
|
|
169
170
|
</div>
|
|
170
171
|
</Td>
|
|
171
172
|
<Td dataLabel={columnNames.source}>
|
|
@@ -174,7 +175,7 @@ export const TableNestedHeaders: React.FunctionComponent = () => {
|
|
|
174
175
|
<span>{connection.source.port.num}</span>
|
|
175
176
|
</StackItem>
|
|
176
177
|
<StackItem>
|
|
177
|
-
<span className=
|
|
178
|
+
<span className={textStyles.color_200}>({connection.source.port.protocol})</span>
|
|
178
179
|
</StackItem>
|
|
179
180
|
</Stack>
|
|
180
181
|
</Td>
|
|
@@ -184,7 +185,7 @@ export const TableNestedHeaders: React.FunctionComponent = () => {
|
|
|
184
185
|
<span>{connection.destination.port.num}</span>
|
|
185
186
|
</StackItem>
|
|
186
187
|
<StackItem>
|
|
187
|
-
<span className=
|
|
188
|
+
<span className={textStyles.color_200}>({connection.destination.port.protocol})</span>
|
|
188
189
|
</StackItem>
|
|
189
190
|
</Stack>
|
|
190
191
|
</Td>
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
Td,
|
|
9
9
|
InnerScrollContainer,
|
|
10
10
|
OuterScrollContainer,
|
|
11
|
-
ThProps
|
|
11
|
+
ThProps,
|
|
12
|
+
ISortBy
|
|
12
13
|
} from '@patternfly/react-table';
|
|
13
14
|
import BlueprintIcon from '@patternfly/react-icons/dist/esm/icons/blueprint-icon';
|
|
14
15
|
|
|
@@ -53,10 +54,10 @@ export const TableStickyColumnsAndHeader: React.FunctionComponent = () => {
|
|
|
53
54
|
// Index of the currently sorted column
|
|
54
55
|
// Note: if you intend to make columns reorderable, you may instead want to use a non-numeric key
|
|
55
56
|
// as the identifier of the sorted column. See the "Compound expandable" example.
|
|
56
|
-
const [activeSortIndex, setActiveSortIndex] = React.useState
|
|
57
|
+
const [activeSortIndex, setActiveSortIndex] = React.useState(-1);
|
|
57
58
|
|
|
58
59
|
// Sort direction of the currently sorted column
|
|
59
|
-
const [activeSortDirection, setActiveSortDirection] = React.useState<'
|
|
60
|
+
const [activeSortDirection, setActiveSortDirection] = React.useState<ISortBy['direction']>();
|
|
60
61
|
|
|
61
62
|
// Since OnSort specifies sorted columns by index, we need sortable values for our object by column index.
|
|
62
63
|
// This example is trivial since our data objects just contain strings, but if the data was more complex
|
|
@@ -69,7 +70,7 @@ export const TableStickyColumnsAndHeader: React.FunctionComponent = () => {
|
|
|
69
70
|
// Note that we perform the sort as part of the component's render logic and not in onSort.
|
|
70
71
|
// We shouldn't store the list of data in state because we don't want to have to sync that with props.
|
|
71
72
|
let sortedFacts = facts;
|
|
72
|
-
if (activeSortIndex
|
|
73
|
+
if (activeSortIndex > -1) {
|
|
73
74
|
sortedFacts = facts.sort((a, b) => {
|
|
74
75
|
const aValue = getSortableRowValues(a)[activeSortIndex];
|
|
75
76
|
const bValue = getSortableRowValues(b)[activeSortIndex];
|
|
@@ -31,7 +31,7 @@ export const treeRow =
|
|
|
31
31
|
{icon}
|
|
32
32
|
</span>
|
|
33
33
|
)}
|
|
34
|
-
<span className=
|
|
34
|
+
<span className={styles.tableText} key="table-text">
|
|
35
35
|
{content as React.ReactNode}
|
|
36
36
|
</span>
|
|
37
37
|
</div>
|
|
@@ -41,7 +41,7 @@ export const treeRow =
|
|
|
41
41
|
};
|
|
42
42
|
return {
|
|
43
43
|
component: 'th',
|
|
44
|
-
className:
|
|
44
|
+
className: stylesTreeView.tableTreeViewTitleCell,
|
|
45
45
|
children:
|
|
46
46
|
level !== undefined ? (
|
|
47
47
|
<div className={css(stylesTreeView.tableTreeViewMain)}>
|
|
@@ -83,7 +83,7 @@ export const treeRow =
|
|
|
83
83
|
onToggleRowDetails && onToggleRowDetails(event, rowIndex, content as React.ReactNode, rowData)
|
|
84
84
|
}
|
|
85
85
|
>
|
|
86
|
-
<span className=
|
|
86
|
+
<span className={`${styles.table}__details-toggle-icon`}>
|
|
87
87
|
<EllipsisHIcon aria-hidden />
|
|
88
88
|
</span>
|
|
89
89
|
</Button>
|
|
@@ -29,6 +29,9 @@ import {
|
|
|
29
29
|
IRowData,
|
|
30
30
|
ISeparator
|
|
31
31
|
} from '../TableTypes';
|
|
32
|
+
import { css } from '@patternfly/react-styles';
|
|
33
|
+
import tableStyles from '@patternfly/react-styles/css/components/Table/table';
|
|
34
|
+
import dropdownStyles from '@patternfly/react-styles/css/components/Dropdown/dropdown';
|
|
32
35
|
|
|
33
36
|
const testCellActions = async ({
|
|
34
37
|
actions,
|
|
@@ -65,7 +68,7 @@ const testCellActions = async ({
|
|
|
65
68
|
actions = actionResolver(rowData, extraData);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
expect(returnedData).toMatchObject({ className:
|
|
71
|
+
expect(returnedData).toMatchObject({ className: tableStyles.tableAction });
|
|
69
72
|
|
|
70
73
|
if (!actions || actions.length === 0) {
|
|
71
74
|
expect(returnedData.children).toBeUndefined();
|
|
@@ -73,7 +76,10 @@ const testCellActions = async ({
|
|
|
73
76
|
const { container } = render(returnedData.children as React.ReactElement<any>);
|
|
74
77
|
await user.click(screen.getAllByRole('button')[0]);
|
|
75
78
|
await waitFor(() =>
|
|
76
|
-
|
|
79
|
+
// eslint-disable-next-line testing-library/no-container
|
|
80
|
+
expect(container.querySelectorAll(`.${dropdownStyles.dropdownMenu} li button`)).toHaveLength(
|
|
81
|
+
expectDisabled ? 0 : 1
|
|
82
|
+
)
|
|
77
83
|
);
|
|
78
84
|
}
|
|
79
85
|
};
|
|
@@ -86,7 +92,7 @@ describe('Transformer functions', () => {
|
|
|
86
92
|
extraParams: { onSelect }
|
|
87
93
|
};
|
|
88
94
|
const returnedData = selectable('', { column, rowData: {} } as IExtra);
|
|
89
|
-
expect(returnedData).toMatchObject({ className:
|
|
95
|
+
expect(returnedData).toMatchObject({ className: tableStyles.tableCheck });
|
|
90
96
|
|
|
91
97
|
const user = userEvent.setup();
|
|
92
98
|
|
|
@@ -103,7 +109,7 @@ describe('Transformer functions', () => {
|
|
|
103
109
|
extraParams: { onSelect }
|
|
104
110
|
};
|
|
105
111
|
const returnedData = selectable('', { column, rowIndex: 0, rowData: { selected: true } } as IExtra);
|
|
106
|
-
expect(returnedData).toMatchObject({ className:
|
|
112
|
+
expect(returnedData).toMatchObject({ className: tableStyles.tableCheck });
|
|
107
113
|
const user = userEvent.setup();
|
|
108
114
|
|
|
109
115
|
render(returnedData.children as React.ReactElement<any>);
|
|
@@ -128,7 +134,7 @@ describe('Transformer functions', () => {
|
|
|
128
134
|
const onSort = jest.fn();
|
|
129
135
|
const column = { extraParams: { sortBy: {}, onSort } };
|
|
130
136
|
const returnedData = sortable('', { column, columnIndex: 0 });
|
|
131
|
-
expect(returnedData).toMatchObject({ className:
|
|
137
|
+
expect(returnedData).toMatchObject({ className: tableStyles.tableSort });
|
|
132
138
|
|
|
133
139
|
const user = userEvent.setup();
|
|
134
140
|
|
|
@@ -154,7 +160,7 @@ describe('Transformer functions', () => {
|
|
|
154
160
|
const onSort = jest.fn();
|
|
155
161
|
const column = { extraParams: { sortBy: { index: 0, direction: 'desc' }, onSort } };
|
|
156
162
|
const returnedData = sortable('', { column, columnIndex: 0 } as IExtra);
|
|
157
|
-
expect(returnedData).toMatchObject({ className:
|
|
163
|
+
expect(returnedData).toMatchObject({ className: css(tableStyles.tableSort, tableStyles.modifiers.selected) });
|
|
158
164
|
|
|
159
165
|
const user = userEvent.setup();
|
|
160
166
|
|
|
@@ -226,7 +232,7 @@ describe('Transformer functions', () => {
|
|
|
226
232
|
extraParams: { onCollapse }
|
|
227
233
|
};
|
|
228
234
|
const returnedData = collapsible('', { rowIndex: 0, rowData, column });
|
|
229
|
-
expect(returnedData).toMatchObject({ className:
|
|
235
|
+
expect(returnedData).toMatchObject({ className: tableStyles.tableToggle });
|
|
230
236
|
|
|
231
237
|
const user = userEvent.setup();
|
|
232
238
|
|
|
@@ -332,7 +338,7 @@ describe('Transformer functions', () => {
|
|
|
332
338
|
extraParams: { onRowEdit }
|
|
333
339
|
};
|
|
334
340
|
const returned = editable('test', { rowIndex: 0, column });
|
|
335
|
-
expect(returned).toMatchObject({ className:
|
|
341
|
+
expect(returned).toMatchObject({ className: tableStyles.tableInlineEditAction });
|
|
336
342
|
});
|
|
337
343
|
|
|
338
344
|
describe('visibility classNames', () => {
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Table
|
|
3
|
+
section: components
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Checkbox,
|
|
8
|
+
Label,
|
|
9
|
+
PageSection,
|
|
10
|
+
ToolbarExpandIconWrapper,
|
|
11
|
+
ToolbarContent,
|
|
12
|
+
Toolbar,
|
|
13
|
+
ToolbarItem,
|
|
14
|
+
SearchInput,
|
|
15
|
+
Masthead,
|
|
16
|
+
MastheadToggle,
|
|
17
|
+
MastheadMain,
|
|
18
|
+
MastheadContent,
|
|
19
|
+
SkipToContent,
|
|
20
|
+
Breadcrumb,
|
|
21
|
+
BreadcrumbItem,
|
|
22
|
+
Page,
|
|
23
|
+
PageSectionVariants,
|
|
24
|
+
TextContent,
|
|
25
|
+
Text,
|
|
26
|
+
Divider } from '@patternfly/react-core';
|
|
27
|
+
import { Table as TableDeprecated, TableHeader, TableBody } from '@patternfly/react-table/deprecated';
|
|
28
|
+
import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon';
|
|
29
|
+
import CloneIcon from '@patternfly/react-icons/dist/esm/icons/clone-icon';
|
|
30
|
+
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
|
|
31
|
+
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
32
|
+
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
33
|
+
import EditIcon from '@patternfly/react-icons/dist/esm/icons/edit-icon';
|
|
34
|
+
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
35
|
+
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
|
|
36
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
37
|
+
import SyncIcon from '@patternfly/react-icons/dist/esm/icons/sync-icon';
|
|
38
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
39
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
40
|
+
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
41
|
+
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
42
|
+
import globalDangerColor200 from '@patternfly/react-tokens/dist/esm/global_danger_color_200';
|
|
43
|
+
import imgBrand from '@patternfly/react-core/src/components/assets/pfLogo.svg';
|
|
44
|
+
import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg';
|
|
45
|
+
import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
|
|
46
|
+
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
|
|
47
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
48
|
+
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
49
|
+
import BlueprintIcon from '@patternfly/react-icons/dist/esm/icons/blueprint-icon';
|
|
50
|
+
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
51
|
+
import { DashboardWrapper } from '@patternfly/react-core/dist/esm/demos/DashboardWrapper';
|
|
52
|
+
import { rows, columns } from '@patternfly/react-table/dist/esm/demos/sampleData';
|
|
53
|
+
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
|
|
54
|
+
|
|
55
|
+
## Demos
|
|
56
|
+
|
|
57
|
+
### Bulk select
|
|
58
|
+
|
|
59
|
+
```js isFullscreen file="./examples/TableBulkSelect.tsx"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Expand/collapse all
|
|
63
|
+
|
|
64
|
+
```js isFullscreen file="./examples/TableExpandCollapseAll.tsx"
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Compact
|
|
69
|
+
|
|
70
|
+
```js isFullscreen file="./examples/TableCompact.tsx"
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Compound expansion
|
|
75
|
+
|
|
76
|
+
```js isFullscreen file="./examples/TableCompoundExpansion.tsx"
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Column management
|
|
81
|
+
|
|
82
|
+
```js isFullscreen file="./examples/TableColumnManagement.tsx"
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Column management with draggable
|
|
87
|
+
|
|
88
|
+
```js isFullscreen file="./examples/TableColumnManagementWithDraggable.tsx"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Filterable
|
|
92
|
+
|
|
93
|
+
```js isFullscreen file="./examples/TableFilterable.tsx"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Sortable - responsive
|
|
97
|
+
|
|
98
|
+
```js isFullscreen file="./examples/TableSortableResponsive.tsx"
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Automatic pagination
|
|
103
|
+
|
|
104
|
+
The below example illustrates the `isLastFullPageShown` prop, which makes the following changes when the user sets the number of items to display per page to an amount that exceeds the remaining amount of data:
|
|
105
|
+
|
|
106
|
+
- The component automatically changes the page back to the last full page of results, rather than defaulting to the final page of results.
|
|
107
|
+
|
|
108
|
+
To demonstrate this, navigate to the last page of data below using the `>>` navigation arrows, then use the dropdown selector to change the view to 5 per page.
|
|
109
|
+
|
|
110
|
+
- The default behavior would show the last page of results, which would only contain the last two rows (rows 11 - 12).
|
|
111
|
+
- The `isLastFullPageShown` prop navigates you back to the previous page which does contain a full page of 5 rows (rows 6 - 10).
|
|
112
|
+
|
|
113
|
+
```js isFullscreen file="./examples/TableAutomaticPagination.tsx"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Static bottom pagination on mobile
|
|
117
|
+
|
|
118
|
+
```ts isFullscreen file="./examples/TableStaticBottomPagination.tsx"
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Sticky header
|
|
123
|
+
|
|
124
|
+
```js isFullscreen file="./examples/TableStickyHeader.tsx"
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Sticky first column
|
|
129
|
+
|
|
130
|
+
```js isFullscreen file="./examples/TableStickyFirstColumn.tsx"
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Sticky columns and header with toolbar
|
|
135
|
+
|
|
136
|
+
A toolbar may be added above a sticky table either inside or outside the `OuterScrollContainer`.
|
|
137
|
+
|
|
138
|
+
```js isFullscreen file="../components/Table/examples/TableStickyColumnsAndHeader.tsx"
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Empty states
|
|
143
|
+
|
|
144
|
+
These examples demonstrate the use of an [Empty State component](/components/empty-state) inside of a [Table](/components/table). Empty states are useful in a table when a filter returns no results, while data is loading, or when any type of error or exception condition occurs.
|
|
145
|
+
|
|
146
|
+
### Empty
|
|
147
|
+
|
|
148
|
+
```js isFullscreen file="./examples/TableEmptyStateDefault.tsx"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Loading
|
|
152
|
+
|
|
153
|
+
```js isFullscreen file="./examples/TableEmptyStateLoading.tsx"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Error
|
|
157
|
+
|
|
158
|
+
```js isFullscreen file="./examples/TableEmptyStateError.tsx"
|
|
159
|
+
```
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pagination } from '@patternfly/react-core';
|
|
3
|
+
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
4
|
+
|
|
5
|
+
export const TableAutomaticPagination: React.FunctionComponent = () => {
|
|
6
|
+
const columns = {
|
|
7
|
+
firstColumn: 'First column',
|
|
8
|
+
secondColumn: 'Second column',
|
|
9
|
+
thirdColumn: 'Third column'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const defaultRows = [
|
|
13
|
+
{ firstColumn: 'Row 1 column 1', secondColumn: 'Row 1 column 2', thirdColumn: 'Row 1 column 3' },
|
|
14
|
+
{ firstColumn: 'Row 2 column 1', secondColumn: 'Row 2 column 2', thirdColumn: 'Row 2 column 3' },
|
|
15
|
+
{ firstColumn: 'Row 3 column 1', secondColumn: 'Row 3 column 2', thirdColumn: 'Row 3 column 3' },
|
|
16
|
+
{ firstColumn: 'Row 4 column 1', secondColumn: 'Row 4 column 2', thirdColumn: 'Row 4 column 3' },
|
|
17
|
+
{ firstColumn: 'Row 5 column 1', secondColumn: 'Row 5 column 2', thirdColumn: 'Row 5 column 3' },
|
|
18
|
+
{ firstColumn: 'Row 6 column 1', secondColumn: 'Row 6 column 2', thirdColumn: 'Row 6 column 3' },
|
|
19
|
+
{ firstColumn: 'Row 7 column 1', secondColumn: 'Row 7 column 2', thirdColumn: 'Row 7 column 3' },
|
|
20
|
+
{ firstColumn: 'Row 8 column 1', secondColumn: 'Row 8 column 2', thirdColumn: 'Row 8 column 3' },
|
|
21
|
+
{ firstColumn: 'Row 9 column 1', secondColumn: 'Row 9 column 2', thirdColumn: 'Row 9 column 3' },
|
|
22
|
+
{ firstColumn: 'Row 10 column 1', secondColumn: 'Row 10 column 2', thirdColumn: 'Row 10 column 3' },
|
|
23
|
+
{ firstColumn: 'Row 11 column 1', secondColumn: 'Row 11 column 2', thirdColumn: 'Row 11 column 3' },
|
|
24
|
+
{ firstColumn: 'Row 12 column 1', secondColumn: 'Row 12 column 2', thirdColumn: 'Row 12 column 3' }
|
|
25
|
+
];
|
|
26
|
+
const defaultPerPage = 10;
|
|
27
|
+
|
|
28
|
+
const [perPage, setPerPage] = React.useState(defaultPerPage);
|
|
29
|
+
const [page, setPage] = React.useState(1);
|
|
30
|
+
const [rows, setRows] = React.useState(defaultRows.slice(0, defaultPerPage));
|
|
31
|
+
|
|
32
|
+
const handleSetPage = (
|
|
33
|
+
_evt: React.MouseEvent | React.KeyboardEvent | MouseEvent,
|
|
34
|
+
newPage: number,
|
|
35
|
+
_perPage: number,
|
|
36
|
+
startIdx: number,
|
|
37
|
+
endIdx: number
|
|
38
|
+
) => {
|
|
39
|
+
setPage(newPage);
|
|
40
|
+
setRows(defaultRows.slice(startIdx, endIdx));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const handlePerPageSelect = (
|
|
44
|
+
_evt: React.MouseEvent | React.KeyboardEvent | MouseEvent,
|
|
45
|
+
newPerPage: number,
|
|
46
|
+
newPage: number,
|
|
47
|
+
startIdx: number,
|
|
48
|
+
endIdx: number
|
|
49
|
+
) => {
|
|
50
|
+
setPerPage(newPerPage);
|
|
51
|
+
setPage(newPage);
|
|
52
|
+
setRows(defaultRows.slice(startIdx, endIdx));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const renderPagination = (variant = 'top') => (
|
|
56
|
+
<Pagination
|
|
57
|
+
isCompact
|
|
58
|
+
itemCount={defaultRows.length}
|
|
59
|
+
page={page}
|
|
60
|
+
perPage={perPage}
|
|
61
|
+
isLastFullPageShown
|
|
62
|
+
onSetPage={handleSetPage}
|
|
63
|
+
onPerPageSelect={handlePerPageSelect}
|
|
64
|
+
perPageOptions={[
|
|
65
|
+
{ title: '3', value: 3 },
|
|
66
|
+
{ title: '5', value: 5 },
|
|
67
|
+
{ title: '12', value: 12 },
|
|
68
|
+
{ title: '20', value: 20 }
|
|
69
|
+
]}
|
|
70
|
+
titles={{
|
|
71
|
+
paginationAriaLabel: `${variant} pagination`
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<React.Fragment>
|
|
78
|
+
{renderPagination()}
|
|
79
|
+
<Table aria-label="Automated Pagination Table Demo">
|
|
80
|
+
<Thead>
|
|
81
|
+
<Tr>
|
|
82
|
+
<Th>{columns.firstColumn}</Th>
|
|
83
|
+
<Th>{columns.secondColumn}</Th>
|
|
84
|
+
<Th>{columns.thirdColumn}</Th>
|
|
85
|
+
</Tr>
|
|
86
|
+
</Thead>
|
|
87
|
+
<Tbody>
|
|
88
|
+
{rows.map((row, rowIndex) => (
|
|
89
|
+
<Tr key={rowIndex}>
|
|
90
|
+
<>
|
|
91
|
+
<Td dataLabel={columns.firstColumn}>{row.firstColumn}</Td>
|
|
92
|
+
<Td dataLabel={columns.secondColumn}>{row.secondColumn}</Td>
|
|
93
|
+
<Td dataLabel={columns.thirdColumn}>{row.thirdColumn}</Td>
|
|
94
|
+
</>
|
|
95
|
+
</Tr>
|
|
96
|
+
))}
|
|
97
|
+
</Tbody>
|
|
98
|
+
</Table>
|
|
99
|
+
</React.Fragment>
|
|
100
|
+
);
|
|
101
|
+
};
|