@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.
Files changed (233) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/README.md +2 -2
  3. package/components/package.json +1 -1
  4. package/deprecated/package.json +1 -1
  5. package/dist/dynamic/components/Table/package.json +1 -1
  6. package/dist/dynamic/components/Table/utils/decorators/package.json +1 -1
  7. package/dist/dynamic/components/Table/utils/package.json +1 -1
  8. package/dist/dynamic/deprecated/components/Table/base/package.json +1 -1
  9. package/dist/dynamic/deprecated/components/Table/package.json +1 -1
  10. package/dist/dynamic/deprecated/components/package.json +1 -1
  11. package/dist/esm/components/Table/ActionsColumn.d.ts +1 -1
  12. package/dist/esm/components/Table/ActionsColumn.d.ts.map +1 -1
  13. package/dist/esm/components/Table/Caption.js +1 -1
  14. package/dist/esm/components/Table/Caption.js.map +1 -1
  15. package/dist/esm/components/Table/CollapseColumn.js +1 -1
  16. package/dist/esm/components/Table/CollapseColumn.js.map +1 -1
  17. package/dist/esm/components/Table/DraggableRowWrapper.js +2 -2
  18. package/dist/esm/components/Table/DraggableRowWrapper.js.map +1 -1
  19. package/dist/esm/components/Table/EditColumn.js +1 -1
  20. package/dist/esm/components/Table/EditColumn.js.map +1 -1
  21. package/dist/esm/components/Table/EditableSelectInputCell.js +2 -2
  22. package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
  23. package/dist/esm/components/Table/EditableTextCell.js +2 -2
  24. package/dist/esm/components/Table/EditableTextCell.js.map +1 -1
  25. package/dist/esm/components/Table/ExpandableRowContent.js +1 -1
  26. package/dist/esm/components/Table/ExpandableRowContent.js.map +1 -1
  27. package/dist/esm/components/Table/HeaderCellInfoWrapper.js +1 -1
  28. package/dist/esm/components/Table/HeaderCellInfoWrapper.js.map +1 -1
  29. package/dist/esm/components/Table/InnerScrollContainer.js +1 -1
  30. package/dist/esm/components/Table/InnerScrollContainer.js.map +1 -1
  31. package/dist/esm/components/Table/OuterScrollContainer.js +1 -1
  32. package/dist/esm/components/Table/OuterScrollContainer.js.map +1 -1
  33. package/dist/esm/components/Table/RowWrapper.d.ts +1 -1
  34. package/dist/esm/components/Table/SortColumn.js +1 -1
  35. package/dist/esm/components/Table/SortColumn.js.map +1 -1
  36. package/dist/esm/components/Table/Table.d.ts +1 -1
  37. package/dist/esm/components/Table/Table.d.ts.map +1 -1
  38. package/dist/esm/components/Table/Table.js +5 -5
  39. package/dist/esm/components/Table/Table.js.map +1 -1
  40. package/dist/esm/components/Table/TableText.js +1 -1
  41. package/dist/esm/components/Table/TableText.js.map +1 -1
  42. package/dist/esm/components/Table/Tbody.d.ts +1 -1
  43. package/dist/esm/components/Table/Tbody.d.ts.map +1 -1
  44. package/dist/esm/components/Table/Tbody.js +1 -1
  45. package/dist/esm/components/Table/Tbody.js.map +1 -1
  46. package/dist/esm/components/Table/Td.d.ts +1 -1
  47. package/dist/esm/components/Table/Td.d.ts.map +1 -1
  48. package/dist/esm/components/Table/Td.js +9 -5
  49. package/dist/esm/components/Table/Td.js.map +1 -1
  50. package/dist/esm/components/Table/Th.d.ts +1 -1
  51. package/dist/esm/components/Table/Th.d.ts.map +1 -1
  52. package/dist/esm/components/Table/Th.js +6 -3
  53. package/dist/esm/components/Table/Th.js.map +1 -1
  54. package/dist/esm/components/Table/Thead.d.ts +1 -1
  55. package/dist/esm/components/Table/Thead.d.ts.map +1 -1
  56. package/dist/esm/components/Table/Thead.js +1 -1
  57. package/dist/esm/components/Table/Thead.js.map +1 -1
  58. package/dist/esm/components/Table/Tr.d.ts +2 -2
  59. package/dist/esm/components/Table/Tr.d.ts.map +1 -1
  60. package/dist/esm/components/Table/Tr.js +2 -2
  61. package/dist/esm/components/Table/Tr.js.map +1 -1
  62. package/dist/esm/components/Table/TreeRowWrapper.js +2 -2
  63. package/dist/esm/components/Table/TreeRowWrapper.js.map +1 -1
  64. package/dist/esm/components/Table/base/provider.d.ts +8 -8
  65. package/dist/esm/components/Table/base/types.d.ts +7 -7
  66. package/dist/esm/components/Table/utils/decorators/cellActions.js +1 -1
  67. package/dist/esm/components/Table/utils/decorators/cellActions.js.map +1 -1
  68. package/dist/esm/components/Table/utils/decorators/cellWidth.js +1 -1
  69. package/dist/esm/components/Table/utils/decorators/cellWidth.js.map +1 -1
  70. package/dist/esm/components/Table/utils/decorators/classNames.js +1 -1
  71. package/dist/esm/components/Table/utils/decorators/classNames.js.map +1 -1
  72. package/dist/esm/components/Table/utils/decorators/collapsible.js +1 -1
  73. package/dist/esm/components/Table/utils/decorators/collapsible.js.map +1 -1
  74. package/dist/esm/components/Table/utils/decorators/compoundExpand.js +1 -1
  75. package/dist/esm/components/Table/utils/decorators/compoundExpand.js.map +1 -1
  76. package/dist/esm/components/Table/utils/decorators/editable.js +1 -1
  77. package/dist/esm/components/Table/utils/decorators/editable.js.map +1 -1
  78. package/dist/esm/components/Table/utils/decorators/favoritable.js +1 -1
  79. package/dist/esm/components/Table/utils/decorators/favoritable.js.map +1 -1
  80. package/dist/esm/components/Table/utils/decorators/info.js +1 -1
  81. package/dist/esm/components/Table/utils/decorators/info.js.map +1 -1
  82. package/dist/esm/components/Table/utils/decorators/selectable.js +2 -2
  83. package/dist/esm/components/Table/utils/decorators/selectable.js.map +1 -1
  84. package/dist/esm/components/Table/utils/decorators/sortable.js +1 -1
  85. package/dist/esm/components/Table/utils/decorators/sortable.js.map +1 -1
  86. package/dist/esm/components/Table/utils/decorators/treeRow.d.ts +3 -3
  87. package/dist/esm/components/Table/utils/decorators/treeRow.d.ts.map +1 -1
  88. package/dist/esm/components/Table/utils/decorators/treeRow.js +5 -5
  89. package/dist/esm/components/Table/utils/decorators/treeRow.js.map +1 -1
  90. package/dist/esm/components/Table/utils/decorators/wrappable.js +1 -1
  91. package/dist/esm/components/Table/utils/decorators/wrappable.js.map +1 -1
  92. package/dist/esm/demos/index.d.ts +2 -0
  93. package/dist/esm/demos/index.d.ts.map +1 -0
  94. package/dist/esm/demos/index.js +2 -0
  95. package/dist/esm/demos/index.js.map +1 -0
  96. package/dist/esm/demos/sampleData.d.ts +13 -0
  97. package/dist/esm/demos/sampleData.d.ts.map +1 -0
  98. package/dist/esm/demos/sampleData.js +764 -0
  99. package/dist/esm/demos/sampleData.js.map +1 -0
  100. package/dist/esm/deprecated/components/Table/Body.d.ts +1 -1
  101. package/dist/esm/deprecated/components/Table/Body.d.ts.map +1 -1
  102. package/dist/esm/deprecated/components/Table/Table.d.ts +1 -1
  103. package/dist/esm/deprecated/components/Table/Table.js +1 -1
  104. package/dist/esm/deprecated/components/Table/Table.js.map +1 -1
  105. package/dist/esm/deprecated/components/Table/base/body.d.ts +8 -2
  106. package/dist/esm/deprecated/components/Table/base/body.d.ts.map +1 -1
  107. package/dist/esm/deprecated/components/Table/base/header.d.ts +1 -1
  108. package/dist/esm/deprecated/components/Table/base/header.d.ts.map +1 -1
  109. package/dist/esm/index.d.ts +1 -0
  110. package/dist/esm/index.d.ts.map +1 -1
  111. package/dist/esm/index.js +1 -0
  112. package/dist/esm/index.js.map +1 -1
  113. package/dist/js/components/Table/ActionsColumn.d.ts +1 -1
  114. package/dist/js/components/Table/ActionsColumn.d.ts.map +1 -1
  115. package/dist/js/components/Table/ActionsColumn.js +6 -6
  116. package/dist/js/components/Table/ActionsColumn.js.map +1 -1
  117. package/dist/js/components/Table/CollapseColumn.js +2 -2
  118. package/dist/js/components/Table/CollapseColumn.js.map +1 -1
  119. package/dist/js/components/Table/DraggableCell.js +2 -2
  120. package/dist/js/components/Table/DraggableCell.js.map +1 -1
  121. package/dist/js/components/Table/EditColumn.js +4 -4
  122. package/dist/js/components/Table/EditColumn.js.map +1 -1
  123. package/dist/js/components/Table/EditableSelectInputCell.js +1 -1
  124. package/dist/js/components/Table/EditableSelectInputCell.js.map +1 -1
  125. package/dist/js/components/Table/EditableTextCell.js +1 -1
  126. package/dist/js/components/Table/EditableTextCell.js.map +1 -1
  127. package/dist/js/components/Table/FavoritesCell.js +2 -2
  128. package/dist/js/components/Table/FavoritesCell.js.map +1 -1
  129. package/dist/js/components/Table/HeaderCellInfoWrapper.js +4 -4
  130. package/dist/js/components/Table/HeaderCellInfoWrapper.js.map +1 -1
  131. package/dist/js/components/Table/RowWrapper.d.ts +1 -1
  132. package/dist/js/components/Table/RowWrapper.js +2 -1
  133. package/dist/js/components/Table/RowWrapper.js.map +1 -1
  134. package/dist/js/components/Table/SortColumn.js +3 -3
  135. package/dist/js/components/Table/SortColumn.js.map +1 -1
  136. package/dist/js/components/Table/Table.d.ts +1 -1
  137. package/dist/js/components/Table/Table.d.ts.map +1 -1
  138. package/dist/js/components/Table/Table.js +2 -2
  139. package/dist/js/components/Table/Table.js.map +1 -1
  140. package/dist/js/components/Table/TableText.js +1 -1
  141. package/dist/js/components/Table/TableText.js.map +1 -1
  142. package/dist/js/components/Table/TableTypes.js +4 -0
  143. package/dist/js/components/Table/TableTypes.js.map +1 -1
  144. package/dist/js/components/Table/Tbody.d.ts +1 -1
  145. package/dist/js/components/Table/Tbody.d.ts.map +1 -1
  146. package/dist/js/components/Table/Td.d.ts +1 -1
  147. package/dist/js/components/Table/Td.d.ts.map +1 -1
  148. package/dist/js/components/Table/Td.js +8 -4
  149. package/dist/js/components/Table/Td.js.map +1 -1
  150. package/dist/js/components/Table/Th.d.ts +1 -1
  151. package/dist/js/components/Table/Th.d.ts.map +1 -1
  152. package/dist/js/components/Table/Th.js +5 -2
  153. package/dist/js/components/Table/Th.js.map +1 -1
  154. package/dist/js/components/Table/Thead.d.ts +1 -1
  155. package/dist/js/components/Table/Thead.d.ts.map +1 -1
  156. package/dist/js/components/Table/Tr.d.ts +2 -2
  157. package/dist/js/components/Table/Tr.d.ts.map +1 -1
  158. package/dist/js/components/Table/Tr.js +1 -1
  159. package/dist/js/components/Table/Tr.js.map +1 -1
  160. package/dist/js/components/Table/base/provider.d.ts +8 -8
  161. package/dist/js/components/Table/base/types.d.ts +7 -7
  162. package/dist/js/components/Table/base/types.js +4 -0
  163. package/dist/js/components/Table/base/types.js.map +1 -1
  164. package/dist/js/components/Table/utils/decorators/sortable.js +1 -1
  165. package/dist/js/components/Table/utils/decorators/sortable.js.map +1 -1
  166. package/dist/js/components/Table/utils/decorators/treeRow.d.ts +3 -3
  167. package/dist/js/components/Table/utils/decorators/treeRow.d.ts.map +1 -1
  168. package/dist/js/components/Table/utils/decorators/treeRow.js +7 -7
  169. package/dist/js/components/Table/utils/decorators/treeRow.js.map +1 -1
  170. package/dist/js/demos/index.d.ts +2 -0
  171. package/dist/js/demos/index.d.ts.map +1 -0
  172. package/dist/js/demos/index.js +5 -0
  173. package/dist/js/demos/index.js.map +1 -0
  174. package/dist/js/demos/sampleData.d.ts +13 -0
  175. package/dist/js/demos/sampleData.d.ts.map +1 -0
  176. package/dist/js/demos/sampleData.js +767 -0
  177. package/dist/js/demos/sampleData.js.map +1 -0
  178. package/dist/js/deprecated/components/Table/Body.d.ts +1 -1
  179. package/dist/js/deprecated/components/Table/Body.d.ts.map +1 -1
  180. package/dist/js/deprecated/components/Table/BodyCell.js +4 -3
  181. package/dist/js/deprecated/components/Table/BodyCell.js.map +1 -1
  182. package/dist/js/deprecated/components/Table/Table.d.ts +1 -1
  183. package/dist/js/deprecated/components/Table/Table.js +1 -1
  184. package/dist/js/deprecated/components/Table/Table.js.map +1 -1
  185. package/dist/js/deprecated/components/Table/base/body.d.ts +8 -2
  186. package/dist/js/deprecated/components/Table/base/body.d.ts.map +1 -1
  187. package/dist/js/deprecated/components/Table/base/header.d.ts +1 -1
  188. package/dist/js/deprecated/components/Table/base/header.d.ts.map +1 -1
  189. package/dist/js/index.d.ts +1 -0
  190. package/dist/js/index.d.ts.map +1 -1
  191. package/dist/js/index.js +1 -0
  192. package/dist/js/index.js.map +1 -1
  193. package/dist/umd/react-table.min.js +9 -9
  194. package/package.json +6 -6
  195. package/src/components/Table/Table.tsx +2 -2
  196. package/src/components/Table/Td.tsx +10 -5
  197. package/src/components/Table/Th.tsx +6 -3
  198. package/src/components/Table/Tr.tsx +1 -1
  199. package/src/components/Table/examples/Table.md +3 -0
  200. package/src/components/Table/examples/TableCompoundExpandable.tsx +2 -1
  201. package/src/components/Table/examples/TableMisc.tsx +3 -1
  202. package/src/components/Table/examples/TableNestedHeaders.tsx +4 -3
  203. package/src/components/Table/examples/TableNestedStickyHeader.tsx +4 -3
  204. package/src/components/Table/examples/TableStickyColumnsAndHeader.tsx +5 -4
  205. package/src/components/Table/utils/decorators/treeRow.tsx +3 -3
  206. package/src/components/Table/utils/transformers.test.tsx +14 -8
  207. package/src/demos/Table.md +159 -0
  208. package/src/demos/examples/TableAutomaticPagination.tsx +101 -0
  209. package/src/{docs/demos/table-demos/BulkSelect.jsx → demos/examples/TableBulkSelect.tsx} +41 -20
  210. package/src/demos/examples/TableColumnManagement.tsx +486 -0
  211. package/src/demos/examples/TableColumnManagementWithDraggable.tsx +641 -0
  212. package/src/{docs/demos/table-demos/Compact.jsx → demos/examples/TableCompact.tsx} +32 -16
  213. package/src/{docs/demos/table-demos/CompoundExpansion.jsx → demos/examples/TableCompoundExpansion.tsx} +27 -13
  214. package/src/demos/examples/TableEmptyStateDefault.tsx +60 -0
  215. package/src/demos/examples/TableEmptyStateError.tsx +53 -0
  216. package/src/demos/examples/TableEmptyStateLoading.tsx +43 -0
  217. package/src/{docs/demos/table-demos/ExpandCollapseAll.jsx → demos/examples/TableExpandCollapseAll.tsx} +17 -10
  218. package/src/demos/examples/TableFilterable.tsx +394 -0
  219. package/src/{docs/demos/table-demos/SortableResponsive.jsx → demos/examples/TableSortableResponsive.tsx} +30 -29
  220. package/src/{docs/demos/table-demos/StaticBottomPagination.jsx → demos/examples/TableStaticBottomPagination.tsx} +22 -9
  221. package/src/{docs/demos/table-demos/StickyFirstColumn.jsx → demos/examples/TableStickyFirstColumn.tsx} +31 -9
  222. package/src/{docs/demos/table-demos/StickyHeader.jsx → demos/examples/TableStickyHeader.tsx} +3 -3
  223. package/src/demos/index.ts +1 -0
  224. package/src/{docs/demos/table-demos/sampleData.js → demos/sampleData.tsx} +88 -77
  225. package/src/deprecated/components/Table/__tests__/Table.test.tsx +4 -9
  226. package/src/deprecated/components/Table/examples/LegacyTableCompoundExpandable.tsx +4 -3
  227. package/src/deprecated/components/Table/examples/LegacyTableMisc.tsx +4 -3
  228. package/src/deprecated/components/Table/examples/LegacyTableSelectable.tsx +2 -1
  229. package/src/deprecated/components/Table/examples/LegacyTableStripedCustomTr.tsx +2 -6
  230. package/src/deprecated/components/Table/examples/Table.md +2 -0
  231. package/src/index.ts +1 -0
  232. package/src/docs/demos/Table.md +0 -1622
  233. 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.1",
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.1",
44
- "@patternfly/react-icons": "^6.0.0-alpha.1",
45
- "@patternfly/react-styles": "^6.0.0-alpha.1",
46
- "@patternfly/react-tokens": "^6.0.0-alpha.1",
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": "abccf530a0a642a4d7b4eda6ada09c5822c855b0"
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('pf-m-tree-view')) || // implements roving tab-index to tree tables only
163
- (tableRef && tableRef.current !== (event.target as HTMLElement).closest('.pf-v5-c-table:not(.pf-m-nested)'))
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('pf-v5-c-table__tree-view-title-cell')) ||
257
- (mergedClassName && mergedClassName.includes('pf-v5-c-table__tree-view-title-cell'));
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
- '--pf-v5-c-table__sticky-cell--MinWidth': stickyMinWidth ? stickyMinWidth : undefined,
292
- '--pf-v5-c-table__sticky-cell--Left': stickyLeftOffset ? stickyLeftOffset : 0,
293
- '--pf-v5-c-table__sticky-cell--Right': stickyRightOffset ? stickyRightOffset : 0,
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
- '--pf-v5-c-table__sticky-cell--MinWidth': stickyMinWidth ? stickyMinWidth : undefined,
197
- '--pf-v5-c-table__sticky-cell--Left': stickyLeftOffset ? stickyLeftOffset : 0,
198
- '--pf-v5-c-table__sticky-cell--Right': stickyRightOffset ? stickyRightOffset : 0,
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="pf-v5-u-m-md">
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: 'var(--pf-v5-global--BackgroundColor--150)'
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="pf-v5-u-color-200">{new Date(connection.timestamp).toLocaleTimeString()}</span>
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="pf-v5-u-color-200">({connection.source.port.protocol})</span>
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="pf-v5-u-color-200">({connection.destination.port.protocol})</span>
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="pf-v5-u-color-200">{new Date(connection.timestamp).toLocaleTimeString()}</span>
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="pf-v5-u-color-200">({connection.source.port.protocol})</span>
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="pf-v5-u-color-200">({connection.destination.port.protocol})</span>
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<number | null>(null);
57
+ const [activeSortIndex, setActiveSortIndex] = React.useState(-1);
57
58
 
58
59
  // Sort direction of the currently sorted column
59
- const [activeSortDirection, setActiveSortDirection] = React.useState<'asc' | 'desc' | null>(null);
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 !== null) {
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="pf-v5-c-table__text" key="table-text">
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: 'pf-v5-c-table__tree-view-title-cell',
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="pf-v5-c-table__details-toggle-icon">
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: 'pf-v5-c-table__action' });
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
- expect(container.querySelectorAll('.pf-v5-c-dropdown__menu li button')).toHaveLength(expectDisabled ? 0 : 1)
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: 'pf-v5-c-table__check' });
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: 'pf-v5-c-table__check' });
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: 'pf-v5-c-table__sort' });
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: 'pf-v5-c-table__sort pf-m-selected' });
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: 'pf-v5-c-table__toggle' });
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: 'pf-v5-c-table__inline-edit-action' });
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
+ };