@redis-ui/table 2.12.0 → 2.22.0

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 (166) hide show
  1. package/dist/Table/Table.cjs +95 -146
  2. package/dist/Table/Table.context.cjs +16 -1
  3. package/dist/Table/Table.context.d.ts +23 -4
  4. package/dist/Table/Table.context.js +16 -1
  5. package/dist/Table/Table.d.ts +88 -5
  6. package/dist/Table/Table.js +95 -146
  7. package/dist/Table/Table.style.cjs +43 -13
  8. package/dist/Table/Table.style.d.ts +6 -6
  9. package/dist/Table/Table.style.js +43 -13
  10. package/dist/Table/Table.types.d.ts +22 -38
  11. package/dist/Table/components/Compose/Compose.cjs +45 -0
  12. package/dist/Table/components/Compose/Compose.d.ts +13 -0
  13. package/dist/Table/components/Compose/Compose.js +45 -0
  14. package/dist/Table/components/EmptyState/EmptyState.cjs +31 -0
  15. package/dist/Table/components/EmptyState/EmptyState.d.ts +6 -0
  16. package/dist/Table/components/EmptyState/EmptyState.js +31 -0
  17. package/dist/Table/components/ExpandRowButton/ExpandAllRowsButton.cjs +20 -0
  18. package/dist/Table/components/ExpandRowButton/ExpandAllRowsButton.d.ts +8 -0
  19. package/dist/Table/components/ExpandRowButton/ExpandAllRowsButton.js +20 -0
  20. package/dist/Table/components/ExpandRowButton/ExpandAllRowsButton.test.d.ts +1 -0
  21. package/dist/Table/components/ExpandRowButton/useExpanderColumn.cjs +19 -0
  22. package/dist/Table/components/ExpandRowButton/useExpanderColumn.d.ts +6 -0
  23. package/dist/Table/components/ExpandRowButton/useExpanderColumn.js +19 -0
  24. package/dist/Table/components/ExpandRowButton/useExpanderColumn.test.d.ts +1 -0
  25. package/dist/Table/components/HiddenCaption/HiddenCaption.cjs +13 -0
  26. package/dist/Table/components/HiddenCaption/HiddenCaption.d.ts +3 -0
  27. package/dist/Table/components/HiddenCaption/HiddenCaption.js +13 -0
  28. package/dist/Table/components/PluggableTable/PluggableTable.cjs +19 -0
  29. package/dist/Table/components/PluggableTable/PluggableTable.d.ts +10 -0
  30. package/dist/Table/components/PluggableTable/PluggableTable.js +19 -0
  31. package/dist/Table/components/PluggableTable/compositionComponents.cjs +21 -0
  32. package/dist/Table/components/PluggableTable/compositionComponents.d.ts +67 -0
  33. package/dist/Table/components/PluggableTable/compositionComponents.js +21 -0
  34. package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.cjs +1 -0
  35. package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.d.ts +1 -1
  36. package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.js +1 -0
  37. package/dist/Table/components/RowSelection/useRowSelectionColumn.cjs +26 -0
  38. package/dist/Table/components/RowSelection/useRowSelectionColumn.d.ts +8 -0
  39. package/dist/Table/components/RowSelection/useRowSelectionColumn.js +26 -0
  40. package/dist/Table/components/RowSelection/useRowSelectionColumn.test.d.ts +1 -0
  41. package/dist/Table/components/ShowOnRowHover/ShowOnRowHover.style.cjs +3 -1
  42. package/dist/Table/components/ShowOnRowHover/ShowOnRowHover.style.js +3 -1
  43. package/dist/Table/components/TableBody/TableBody.cjs +33 -0
  44. package/dist/Table/components/TableBody/TableBody.d.ts +23 -0
  45. package/dist/Table/components/TableBody/TableBody.js +33 -0
  46. package/dist/Table/components/TableBody/components/Compose/Compose.cjs +8 -0
  47. package/dist/Table/components/TableBody/components/Compose/Compose.d.ts +3 -0
  48. package/dist/Table/components/TableBody/components/Compose/Compose.js +8 -0
  49. package/dist/Table/components/TableBodyCell/TableBodyCell.cjs +18 -0
  50. package/dist/Table/components/TableBodyCell/TableBodyCell.d.ts +9 -0
  51. package/dist/Table/components/TableBodyCell/TableBodyCell.js +18 -0
  52. package/dist/Table/components/TableBodyCell/components/Compose/Compose.cjs +25 -0
  53. package/dist/Table/components/TableBodyCell/components/Compose/Compose.d.ts +9 -0
  54. package/dist/Table/components/TableBodyCell/components/Compose/Compose.js +25 -0
  55. package/dist/Table/components/TableBodyCell/components/Compose/Compose.test.d.ts +1 -0
  56. package/dist/Table/components/TableBodyRow/TableBodyRow.cjs +48 -0
  57. package/dist/Table/components/TableBodyRow/TableBodyRow.d.ts +20 -0
  58. package/dist/Table/components/TableBodyRow/TableBodyRow.js +48 -0
  59. package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.cjs +33 -0
  60. package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.d.ts +2 -0
  61. package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.js +33 -0
  62. package/dist/Table/components/TableBodyRow/components/Compose/Compose.cjs +17 -0
  63. package/dist/Table/components/TableBodyRow/components/Compose/Compose.d.ts +5 -0
  64. package/dist/Table/components/TableBodyRow/components/Compose/Compose.js +17 -0
  65. package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.cjs +3 -4
  66. package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.d.ts +1 -1
  67. package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.js +3 -4
  68. package/dist/Table/components/TableExpandedRow/TableExpandedRow.cjs +9 -4
  69. package/dist/Table/components/TableExpandedRow/TableExpandedRow.d.ts +1 -1
  70. package/dist/Table/components/TableExpandedRow/TableExpandedRow.js +9 -4
  71. package/dist/Table/components/TableExpandedRow/TableExpandedRow.types.d.ts +3 -5
  72. package/dist/Table/components/TableHeader/TableHeader.cjs +28 -0
  73. package/dist/Table/components/TableHeader/TableHeader.d.ts +21 -0
  74. package/dist/Table/components/TableHeader/TableHeader.js +28 -0
  75. package/dist/Table/components/TableHeader/components/Compose/Compose.cjs +5 -0
  76. package/dist/Table/components/TableHeader/components/Compose/Compose.d.ts +3 -0
  77. package/dist/Table/components/TableHeader/components/Compose/Compose.js +5 -0
  78. package/dist/Table/components/TableHeaderCell/SRSortingNotification.cjs +18 -0
  79. package/dist/Table/components/TableHeaderCell/SRSortingNotification.d.ts +1 -0
  80. package/dist/Table/components/TableHeaderCell/SRSortingNotification.js +18 -0
  81. package/dist/Table/components/TableHeaderCell/TableHeaderCell.cjs +15 -33
  82. package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.cjs +15 -0
  83. package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.d.ts +8 -0
  84. package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.js +15 -0
  85. package/dist/Table/components/TableHeaderCell/TableHeaderCell.d.ts +16 -4
  86. package/dist/Table/components/TableHeaderCell/TableHeaderCell.js +15 -33
  87. package/dist/Table/components/TableHeaderCell/TableHeaderCell.test.d.ts +1 -0
  88. package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.cjs +0 -22
  89. package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.d.ts +0 -1
  90. package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.js +1 -23
  91. package/dist/Table/components/TableHeaderCell/components/Compose/Compose.cjs +48 -0
  92. package/dist/Table/components/TableHeaderCell/components/Compose/Compose.d.ts +9 -0
  93. package/dist/Table/components/TableHeaderCell/components/Compose/Compose.js +48 -0
  94. package/dist/Table/components/TableHeaderCell/components/Compose/Compose.test.d.ts +1 -0
  95. package/dist/Table/components/TableHeaderCell/components/Heading/Heading.cjs +35 -0
  96. package/dist/Table/components/TableHeaderCell/components/Heading/Heading.d.ts +5 -0
  97. package/dist/Table/components/TableHeaderCell/components/Heading/Heading.js +35 -0
  98. package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.cjs +16 -0
  99. package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.d.ts +8 -0
  100. package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.js +16 -0
  101. package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.cjs +24 -0
  102. package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.d.ts +5 -0
  103. package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.js +24 -0
  104. package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.cjs +6 -0
  105. package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.d.ts +2 -0
  106. package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.js +6 -0
  107. package/dist/Table/components/TableHeaderRow/TableHeaderRow.cjs +27 -0
  108. package/dist/Table/components/TableHeaderRow/TableHeaderRow.d.ts +12 -0
  109. package/dist/Table/components/TableHeaderRow/TableHeaderRow.js +27 -0
  110. package/dist/Table/components/TableHeaderRow/components/Compose/Compose.cjs +5 -0
  111. package/dist/Table/components/TableHeaderRow/components/Compose/Compose.d.ts +3 -0
  112. package/dist/Table/components/TableHeaderRow/components/Compose/Compose.js +5 -0
  113. package/dist/Table/components/TablePagination/TablePagination.cjs +65 -99
  114. package/dist/Table/components/TablePagination/TablePagination.d.ts +23 -3
  115. package/dist/Table/components/TablePagination/TablePagination.js +66 -100
  116. package/dist/Table/components/TablePagination/TablePagination.style.cjs +70 -50
  117. package/dist/Table/components/TablePagination/TablePagination.style.d.ts +17 -50
  118. package/dist/Table/components/TablePagination/TablePagination.style.js +72 -52
  119. package/dist/Table/components/TablePagination/components/Compose/Compose.cjs +41 -0
  120. package/dist/Table/components/TablePagination/components/Compose/Compose.d.ts +3 -0
  121. package/dist/Table/components/TablePagination/components/Compose/Compose.js +41 -0
  122. package/dist/Table/components/TableRoot/TableRoot.cjs +13 -0
  123. package/dist/Table/components/TableRoot/TableRoot.d.ts +2 -0
  124. package/dist/Table/components/TableRoot/TableRoot.js +13 -0
  125. package/dist/Table/index.d.ts +3 -6
  126. package/dist/Table/plugins/ClickableRowPlugin.cjs +48 -0
  127. package/dist/Table/plugins/ClickableRowPlugin.d.ts +25 -0
  128. package/dist/Table/plugins/ClickableRowPlugin.js +48 -0
  129. package/dist/Table/plugins/ExpandableRowPlugin.cjs +44 -0
  130. package/dist/Table/plugins/ExpandableRowPlugin.d.ts +28 -0
  131. package/dist/Table/plugins/ExpandableRowPlugin.js +44 -0
  132. package/dist/Table/plugins/PaginationPlugin.cjs +45 -0
  133. package/dist/Table/plugins/PaginationPlugin.d.ts +16 -0
  134. package/dist/Table/plugins/PaginationPlugin.js +45 -0
  135. package/dist/Table/plugins/RowNavigationPlugin.cjs +139 -0
  136. package/dist/Table/plugins/RowNavigationPlugin.d.ts +44 -0
  137. package/dist/Table/plugins/RowNavigationPlugin.js +139 -0
  138. package/dist/Table/plugins/RowSelectionPlugin.cjs +28 -0
  139. package/dist/Table/plugins/RowSelectionPlugin.d.ts +12 -0
  140. package/dist/Table/plugins/RowSelectionPlugin.js +28 -0
  141. package/dist/Table/plugins/SortingPlugin.cjs +44 -0
  142. package/dist/Table/plugins/SortingPlugin.d.ts +18 -0
  143. package/dist/Table/plugins/SortingPlugin.js +44 -0
  144. package/dist/Table/tanStackExtendedTypes.d.ts +20 -0
  145. package/dist/Table/utils/plugin.utils.cjs +49 -0
  146. package/dist/Table/utils/plugin.utils.d.ts +17 -0
  147. package/dist/Table/utils/plugin.utils.js +49 -0
  148. package/dist/Table/utils/plugin.utils.test.d.ts +1 -0
  149. package/dist/Table/utils/table.utils.cjs +13 -0
  150. package/dist/Table/utils/table.utils.d.ts +2 -0
  151. package/dist/Table/utils/table.utils.js +13 -0
  152. package/dist/Table/utils/table.utils.test.d.ts +1 -0
  153. package/dist/index.cjs +60 -0
  154. package/dist/index.js +61 -1
  155. package/dist/node_modules/@tanstack/react-table/build/lib/index.cjs +7 -0
  156. package/dist/node_modules/@tanstack/react-table/build/lib/index.js +8 -1
  157. package/dist/node_modules/@tanstack/table-core/build/lib/index.cjs +361 -4
  158. package/dist/node_modules/@tanstack/table-core/build/lib/index.js +361 -4
  159. package/package.json +6 -5
  160. package/dist/Table/components/EmptyStateRow/EmptyStateRow.cjs +0 -16
  161. package/dist/Table/components/EmptyStateRow/EmptyStateRow.d.ts +0 -8
  162. package/dist/Table/components/EmptyStateRow/EmptyStateRow.js +0 -16
  163. package/dist/node_modules/@radix-ui/react-id/dist/index.cjs +0 -32
  164. package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -14
  165. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +0 -24
  166. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -6
@@ -1,26 +1,22 @@
1
1
  import { j as jsxRuntimeExports } from "../node_modules/react/jsx-runtime.js";
2
- import { useState, useEffect, Fragment } from "react";
3
- import { VisuallyHidden } from "../node_modules/@radix-ui/react-visually-hidden/dist/index.js";
4
- import { useReactTable, flexRender } from "../node_modules/@tanstack/react-table/build/lib/index.js";
5
- import { useControllableState } from "../node_modules/@radix-ui/react-use-controllable-state/dist/index.js";
6
- import TablePagination from "./components/TablePagination/TablePagination.js";
7
2
  import { ExpandRowButton } from "./components/ExpandRowButton/ExpandRowButton.js";
8
3
  import { TableExpandedRow } from "./components/TableExpandedRow/TableExpandedRow.js";
9
4
  import { TableAnimatedExpandedRow } from "./components/TableExpandedRow/TableAnimatedExpandedRow.js";
10
- import { TableContext } from "./Table.context.js";
11
- import { TableHeaderCell } from "./components/TableHeaderCell/TableHeaderCell.js";
12
- import { getTableSortLabel, formatTableSortNotification } from "./components/TableHeaderCell/TableHeaderCell.utils.js";
13
- import { EmptyStateRow } from "./components/EmptyStateRow/EmptyStateRow.js";
14
5
  import { RowSelectionButton } from "./components/RowSelection/RowSelectionButton.js";
15
6
  import { HeaderMultiRowSelectionButton } from "./components/RowSelection/HeaderMultiRowSelectionButton.js";
16
- import { TableContainer, Table as Table$1, TableHead, TableHeaderRow, TableBody, TableBodyRow, TableBodyCell } from "./Table.style.js";
17
- import { getCoreRowModel, getSortedRowModel, getExpandedRowModel, getPaginationRowModel } from "../node_modules/@tanstack/table-core/build/lib/index.js";
18
- const getTrue = () => true;
19
- const DEFAULT_PAGINATION = {
20
- pageIndex: 0,
21
- pageSize: 10
22
- };
23
- const DEFAULT_ROW_SELECTION = {};
7
+ import { useRowSelectionPlugin } from "./plugins/RowSelectionPlugin.js";
8
+ import { useExpandableRowPlugin, useExpandableRowContext } from "./plugins/ExpandableRowPlugin.js";
9
+ import { usePaginationPlugin, usePaginationContext } from "./plugins/PaginationPlugin.js";
10
+ import { useSortingPlugin, useSortingContext } from "./plugins/SortingPlugin.js";
11
+ import { useClickableRowPlugin, useClickableRowContext } from "./plugins/ClickableRowPlugin.js";
12
+ import { useTableContext, useComposeContext } from "./Table.context.js";
13
+ import { PluggableTable } from "./components/PluggableTable/PluggableTable.js";
14
+ import { compositionComponents } from "./components/PluggableTable/compositionComponents.js";
15
+ import { useRowNavigationPlugin } from "./plugins/RowNavigationPlugin.js";
16
+ import { ShowOnRowHover } from "./components/ShowOnRowHover/ShowOnRowHover.style.js";
17
+ import { ExpandAllRowsButton } from "./components/ExpandRowButton/ExpandAllRowsButton.js";
18
+ import { useExpanderColumn } from "./components/ExpandRowButton/useExpanderColumn.js";
19
+ import { useRowSelectionColumn } from "./components/RowSelection/useRowSelectionColumn.js";
24
20
  const Table = Object.assign(({
25
21
  columns,
26
22
  caption,
@@ -29,17 +25,21 @@ const Table = Object.assign(({
29
25
  getRowId,
30
26
  emptyState,
31
27
  maxHeight,
28
+ minWidth,
32
29
  stripedRows = false,
33
30
  // sorting
31
+ enableSorting,
34
32
  defaultSorting,
35
33
  onSortingChange,
36
34
  sorting,
37
- manualSorting = false,
35
+ manualSorting,
38
36
  // row expansion
37
+ defaultExpanded,
39
38
  getIsRowExpandable,
40
39
  renderExpandedRow,
41
40
  expandRowOnClick,
42
- expandedRowComponent: ExpandedRow = TableExpandedRow,
41
+ expandedRowComponent,
42
+ getSubRows,
43
43
  // pagination
44
44
  pagination,
45
45
  defaultPagination,
@@ -47,150 +47,99 @@ const Table = Object.assign(({
47
47
  manualPagination,
48
48
  totalRowCount,
49
49
  pageSizes,
50
- paginationEnabled = (pagination || defaultPagination || onPaginationChange || pageSizes) !== void 0 || manualPagination !== void 0,
50
+ paginationEnabled,
51
51
  // row selection
52
52
  rowSelection,
53
53
  defaultRowSelection,
54
54
  onRowSelectionChange,
55
55
  rowSelectionMode,
56
- getRowCanSelect
56
+ getRowCanSelect,
57
+ // row navigation
58
+ enableRowNavigation = false
57
59
  }) => {
58
- const [userSorted, setUserSorted] = useState(false);
59
- const [sortingState, setSortingState] = useControllableState({
60
- prop: sorting,
61
- defaultProp: defaultSorting,
62
- onChange: onSortingChange
63
- });
64
- const [paginationState, setPaginationState] = useControllableState({
65
- prop: pagination,
66
- defaultProp: defaultPagination ?? DEFAULT_PAGINATION,
67
- onChange: onPaginationChange
60
+ const clickableRowPluginData = useClickableRowPlugin({
61
+ onRowClick: onRowClick && ((row) => onRowClick(row.original)),
62
+ shouldClickOnEnter: true
68
63
  });
69
- const [rowSelectionState = DEFAULT_ROW_SELECTION, setRowSelectionState] = useControllableState({
70
- prop: rowSelection,
71
- defaultProp: defaultRowSelection,
72
- onChange: onRowSelectionChange
64
+ const sortingPluginData = useSortingPlugin({
65
+ enableSorting,
66
+ defaultSorting,
67
+ onSortingChange,
68
+ sorting,
69
+ manualSorting
73
70
  });
74
- const isExpandable = !!renderExpandedRow;
75
- const paginationSettings = {
76
- getPaginationRowModel: getPaginationRowModel(),
77
- onPaginationChange: setPaginationState,
71
+ const paginationPluginData = usePaginationPlugin({
72
+ pagination,
73
+ defaultPagination,
74
+ onPaginationChange,
78
75
  manualPagination,
79
- rowCount: totalRowCount,
80
- autoResetPageIndex: false
81
- };
82
- const table = useReactTable({
83
- data,
84
- columns,
85
- getRowId,
86
- getCoreRowModel: getCoreRowModel(),
87
- getSortedRowModel: getSortedRowModel(),
88
- state: {
89
- sorting: sortingState,
90
- ...paginationEnabled && {
91
- pagination: paginationState
92
- },
93
- ...rowSelectionMode && {
94
- rowSelection: rowSelectionState
95
- }
96
- },
97
- manualSorting,
98
- onSortingChange: (value) => {
99
- setSortingState(value);
100
- setUserSorted(true);
101
- },
102
- getExpandedRowModel: isExpandable ? getExpandedRowModel() : void 0,
103
- getRowCanExpand: isExpandable ? getIsRowExpandable && ((row) => getIsRowExpandable(row.original)) || getTrue : void 0,
104
- ...paginationEnabled && paginationSettings,
105
- enableRowSelection: rowSelectionMode && (getRowCanSelect ?? true),
106
- enableMultiRowSelection: rowSelectionMode === "multiple",
107
- onRowSelectionChange: setRowSelectionState
76
+ totalRowCount,
77
+ pageSizes,
78
+ paginationEnabled
108
79
  });
109
- const {
110
- pageIndex
111
- } = table.getState().pagination;
112
- const maxPageIndex = Math.max(table.getPageCount(), 1) - 1;
113
- useEffect(() => {
114
- if (paginationEnabled) table.setPageIndex(Math.min(pageIndex, maxPageIndex));
115
- }, [maxPageIndex, pageIndex, table, paginationEnabled]);
116
- const {
117
- rows
118
- } = table.getRowModel();
119
- return jsxRuntimeExports.jsxs(TableContext.Provider, {
120
- value: {
121
- table
80
+ const expandableRowPluginData = useExpandableRowPlugin({
81
+ defaultExpanded,
82
+ expandRowOnClick,
83
+ getRowCanExpand: getIsRowExpandable && ((row) => {
84
+ var _a;
85
+ return getIsRowExpandable(row.original) && (!getSubRows || !!((_a = getSubRows(row.original, row.index)) == null ? void 0 : _a.length));
86
+ }),
87
+ renderExpandedRow,
88
+ expandedRowComponent,
89
+ getSubRows
90
+ });
91
+ const rowSelectionPluginData = useRowSelectionPlugin({
92
+ rowSelection,
93
+ defaultRowSelection,
94
+ onRowSelectionChange,
95
+ rowSelectionMode,
96
+ getRowCanSelect
97
+ });
98
+ const rowNavigationPluginData = useRowNavigationPlugin({
99
+ enableRowNavigation
100
+ });
101
+ return jsxRuntimeExports.jsx(Table.PluggableTable, {
102
+ ...{
103
+ data,
104
+ columns,
105
+ maxHeight,
106
+ minWidth,
107
+ stripedRows,
108
+ caption,
109
+ emptyStateRender: emptyState
110
+ },
111
+ tableOptions: {
112
+ getRowId
122
113
  },
123
- children: [jsxRuntimeExports.jsxs(TableContainer, {
124
- children: [jsxRuntimeExports.jsxs(Table$1, {
125
- children: [caption && jsxRuntimeExports.jsx(VisuallyHidden, {
126
- asChild: true,
127
- children: jsxRuntimeExports.jsx("caption", {
128
- children: caption
129
- })
130
- }), jsxRuntimeExports.jsx(TableHead, {
131
- children: table.getHeaderGroups().map((headerGroup) => jsxRuntimeExports.jsx(TableHeaderRow, {
132
- children: headerGroup.headers.map((header) => jsxRuntimeExports.jsx(TableHeaderCell, {
133
- header
134
- }, header.id))
135
- }, headerGroup.id))
136
- }), jsxRuntimeExports.jsxs(TableBody, {
137
- maxHeight,
138
- children: [!rows.length ? jsxRuntimeExports.jsx(EmptyStateRow, {
139
- table,
140
- emptyState
141
- }) : null, rows.map((row) => {
142
- const isRowExpandable = isExpandable && row.getCanExpand();
143
- const isRowExpanded = isRowExpandable && row.getIsExpanded();
144
- const handleClick = () => {
145
- isRowExpandable && expandRowOnClick && row.toggleExpanded();
146
- onRowClick == null ? void 0 : onRowClick(row.original);
147
- };
148
- return jsxRuntimeExports.jsxs(Fragment, {
149
- children: [jsxRuntimeExports.jsx(TableBodyRow, {
150
- tabIndex: 0,
151
- "data-row-type": "regular",
152
- ...isRowExpandable ? {
153
- "aria-expanded": isRowExpanded
154
- } : null,
155
- "$stripedRows": stripedRows,
156
- "$hasOnClick": !!onRowClick || isRowExpandable,
157
- onClick: handleClick,
158
- onKeyDown: (event) => {
159
- if (event.key === "Enter" && event.target === event.currentTarget) {
160
- handleClick();
161
- }
162
- },
163
- children: row.getVisibleCells().map((cell) => jsxRuntimeExports.jsx(TableBodyCell, {
164
- style: {
165
- width: cell.column.getSize()
166
- },
167
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
168
- }, cell.id))
169
- }), isRowExpandable && // 2nd row is a custom 1 cell row for expanded part
170
- jsxRuntimeExports.jsx(ExpandedRow, {
171
- "data-row-type": "expanded",
172
- "data-expanded": isRowExpanded,
173
- expanded: isRowExpanded,
174
- row,
175
- renderExpandedRow
176
- })]
177
- }, row.id);
178
- })]
179
- })]
180
- }), jsxRuntimeExports.jsx(TablePagination, {
181
- pageSizes
182
- })]
183
- }), userSorted && jsxRuntimeExports.jsx(VisuallyHidden, {
184
- "aria-live": "polite",
185
- children: getTableSortLabel(table, formatTableSortNotification)
186
- })]
114
+ pluginsData: [clickableRowPluginData, sortingPluginData, paginationPluginData, expandableRowPluginData, rowSelectionPluginData, rowNavigationPluginData]
187
115
  });
188
116
  }, {
189
117
  ExpandRowButton,
118
+ ExpandAllRowsButton,
119
+ useExpanderColumn,
190
120
  ExpandedRow: TableExpandedRow,
191
121
  AnimatedExpandedRow: TableAnimatedExpandedRow,
192
122
  RowSelectionButton,
193
- HeaderMultiRowSelectionButton
123
+ HeaderMultiRowSelectionButton,
124
+ useRowSelectionColumn,
125
+ ShowOnActiveRow: ShowOnRowHover,
126
+ // plugins
127
+ useClickableRowPlugin,
128
+ useSortingPlugin,
129
+ usePaginationPlugin,
130
+ useExpandableRowPlugin,
131
+ useRowSelectionPlugin,
132
+ useRowNavigationPlugin,
133
+ // contexts
134
+ useTableContext,
135
+ useComposeContext,
136
+ useClickableRowContext,
137
+ useExpandableRowContext,
138
+ usePaginationContext,
139
+ useSortingContext,
140
+ // composition components
141
+ PluggableTable,
142
+ ...compositionComponents
194
143
  });
195
144
  export {
196
145
  Table as default
@@ -4,6 +4,7 @@ const _styled = require("styled-components");
4
4
  const redisUiStyles = require("@redislabsdev/redis-ui-styles");
5
5
  const redisUiComponents = require("@redislabsdev/redis-ui-components");
6
6
  const ShowOnRowHover_style = require("./components/ShowOnRowHover/ShowOnRowHover.style.cjs");
7
+ const Table_context = require("./Table.context.cjs");
7
8
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
8
9
  const _styled__default = /* @__PURE__ */ _interopDefault(_styled);
9
10
  const TableContainer = _styled__default.default.div.withConfig({
@@ -13,19 +14,35 @@ const TableContainer = _styled__default.default.div.withConfig({
13
14
  const Table = _styled__default.default.table.withConfig({
14
15
  displayName: "Tablestyle__Table",
15
16
  componentId: "RedisUI__sc-o0xfty-1"
16
- })(["width:100%;border-collapse:collapse;border-spacing:0;overflow-x:auto;display:block;table-layout:fixed;"]);
17
+ })(["width:100%;border-collapse:collapse;border-spacing:0;overflow-x:auto;display:block;table-layout:fixed;", ""], () => {
18
+ const {
19
+ table
20
+ } = Table_context.useTableContext();
21
+ return _styled.css`
22
+ overflow-x: ${table.getRowModel().rows.length ? "auto" : "hidden"};
23
+ `;
24
+ });
17
25
  const TableHead = _styled__default.default.thead.withConfig({
18
26
  displayName: "Tablestyle__TableHead",
19
27
  componentId: "RedisUI__sc-o0xfty-2"
20
- })(["display:table;table-layout:fixed;"]);
28
+ })(["display:table;table-layout:fixed;", ""], () => {
29
+ const {
30
+ minWidth
31
+ } = Table_context.useTableContext();
32
+ return _styled.css`
33
+ min-width: ${minWidth || void 0};
34
+ `;
35
+ });
21
36
  const TableHeaderRow = _styled__default.default.tr.withConfig({
22
37
  displayName: "Tablestyle__TableHeaderRow",
23
38
  componentId: "RedisUI__sc-o0xfty-3"
24
39
  })(["height:5.6rem;display:table;width:100%;table-layout:fixed;"]);
25
- const HeaderCellInnerWrapper = _styled__default.default.button.withConfig({
26
- displayName: "Tablestyle__HeaderCellInnerWrapper",
40
+ const SortableHeadingCompose = _styled__default.default.button.withConfig({
41
+ displayName: "Tablestyle__SortableHeadingCompose",
27
42
  componentId: "RedisUI__sc-o0xfty-4"
28
- })(["all:unset;border-radius:0.03rem;display:flex;align-items:center;justify-content:flex-start;gap:0.8rem;height:100%;width:100%;min-height:35px;max-width:100%;overflow:hidden;", " svg{flex:none;}"], redisUiStyles.getFocusStyle("0.6rem"));
43
+ })(["all:unset;border-radius:0.03rem;display:flex;align-items:center;justify-content:flex-start;gap:0.8rem;height:100%;width:100%;min-height:35px;max-width:100%;overflow:", ";", " svg{flex:none;}"], ({
44
+ $custom
45
+ }) => $custom ? void 0 : "hidden", redisUiStyles.getFocusStyle("0.6rem"));
29
46
  const HeaderTitleWrapper = _styled__default.default(redisUiComponents.Typography.Body).withConfig({
30
47
  displayName: "Tablestyle__HeaderTitleWrapper",
31
48
  componentId: "RedisUI__sc-o0xfty-5"
@@ -39,19 +56,27 @@ const HeaderTitleWrapper = _styled__default.default(redisUiComponents.Typography
39
56
  const TableTh = _styled__default.default.th.withConfig({
40
57
  displayName: "Tablestyle__TableTh",
41
58
  componentId: "RedisUI__sc-o0xfty-6"
42
- })(["padding:1.05rem 1.2rem;color:", ";user-select:none;white-space:nowrap;word-break:break-word;line-height:normal;position:relative;&:not(:last-child)::after{content:'';position:absolute;inset:1.05rem 0 1.05rem auto;border-right:1px solid ", ";}"], () => redisUiStyles.useTheme().components.table.table.tableTh.color, () => redisUiStyles.useTheme().components.table.table.tableTh.borderRight);
59
+ })(["padding:1.05rem 1.2rem;color:", ";user-select:none;white-space:nowrap;word-break:break-word;line-height:normal;position:relative;overflow:hidden;&:not(:last-child)::after{content:'';position:absolute;inset:1.05rem 0 1.05rem auto;border-right:1px solid ", ";}"], () => redisUiStyles.useTheme().components.table.table.tableTh.color, () => redisUiStyles.useTheme().components.table.table.tableTh.borderRight);
43
60
  const TableBody = _styled__default.default.tbody.withConfig({
44
61
  displayName: "Tablestyle__TableBody",
45
62
  componentId: "RedisUI__sc-o0xfty-7"
46
- })(["max-height:", ";overflow-y:auto;overflow-x:hidden;display:inline-block;table-layout:fixed;"], ({
47
- maxHeight
48
- }) => maxHeight);
63
+ })(["", " overflow-y:auto;overflow-x:hidden;display:inline-block;table-layout:fixed;"], () => {
64
+ const {
65
+ maxHeight,
66
+ minWidth,
67
+ table
68
+ } = Table_context.useTableContext();
69
+ return _styled.css`
70
+ max-height: ${maxHeight};
71
+ min-width: ${table.getRowModel().rows.length && minWidth || void 0};
72
+ `;
73
+ });
49
74
  const TableBodyRow = _styled__default.default.tr.withConfig({
50
75
  displayName: "Tablestyle__TableBodyRow",
51
76
  componentId: "RedisUI__sc-o0xfty-8"
52
- })(["border-top:1px solid ", ";height:4.8rem;transition:box-shadow 0.2s ease-in-out;position:relative;&:hover,&:focus{cursor:", ";z-index:1;box-shadow:", ";", "{opacity:1;visibility:visible;}}", " display:table;width:100%;table-layout:fixed;"], () => redisUiStyles.useTheme().components.table.table.tableBodyRow.borderTop, ({
53
- $hasOnClick
54
- }) => $hasOnClick ? "pointer" : "default", () => redisUiStyles.useTheme().components.table.table.tableBodyRow.hoverBoxShadow, ShowOnRowHover_style.ShowOnRowHover, ({
77
+ })(["border-top:1px solid ", ";height:4.8rem;transition:box-shadow 0.2s ease-in-out;position:relative;&:hover,&:focus,&:focus-within{cursor:", ";z-index:1;box-shadow:", ";", "{opacity:1;visibility:visible;}}", " display:table;width:100%;table-layout:fixed;"], () => redisUiStyles.useTheme().components.table.table.tableBodyRow.borderTop, ({
78
+ onClick
79
+ }) => onClick ? "pointer" : "default", () => redisUiStyles.useTheme().components.table.table.tableBodyRow.hoverBoxShadow, ShowOnRowHover_style.ShowOnRowHover, ({
55
80
  $stripedRows
56
81
  }) => $stripedRows && _styled.css`
57
82
  :nth-child(even of [data-row-type='regular']) {
@@ -62,8 +87,13 @@ const TableBodyCell = _styled__default.default.td.withConfig({
62
87
  displayName: "Tablestyle__TableBodyCell",
63
88
  componentId: "RedisUI__sc-o0xfty-9"
64
89
  })(["color:", ";padding:0 1.2rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;"], () => redisUiStyles.useTheme().components.table.table.tableBodyCell.color);
65
- exports.HeaderCellInnerWrapper = HeaderCellInnerWrapper;
90
+ const EmptyStateContainer = _styled__default.default.div.withConfig({
91
+ displayName: "Tablestyle__EmptyStateContainer",
92
+ componentId: "RedisUI__sc-o0xfty-10"
93
+ })(["text-align:center;"]);
94
+ exports.EmptyStateContainer = EmptyStateContainer;
66
95
  exports.HeaderTitleWrapper = HeaderTitleWrapper;
96
+ exports.SortableHeadingCompose = SortableHeadingCompose;
67
97
  exports.Table = Table;
68
98
  exports.TableBody = TableBody;
69
99
  exports.TableBodyCell = TableBodyCell;
@@ -2,16 +2,16 @@ export declare const TableContainer: import("styled-components").StyledComponent
2
2
  export declare const Table: import("styled-components").StyledComponent<"table", any, {}, never>;
3
3
  export declare const TableHead: import("styled-components").StyledComponent<"thead", any, {}, never>;
4
4
  export declare const TableHeaderRow: import("styled-components").StyledComponent<"tr", any, {}, never>;
5
- export declare const HeaderCellInnerWrapper: import("styled-components").StyledComponent<"button", any, {}, never>;
6
- export declare const HeaderTitleWrapper: import("styled-components").StyledComponent<({ size, variant, color, component, ellipsis, ...restProps }: import("@redislabsdev/redis-ui-components/dist/Typography/components/Body/Body.types").BodyProps) => import("react/jsx-runtime").JSX.Element, any, {
5
+ export declare const SortableHeadingCompose: import("styled-components").StyledComponent<"button", any, {
6
+ $custom: boolean;
7
+ }, never>;
8
+ export declare const HeaderTitleWrapper: import("styled-components").StyledComponent<({ size, variant, color, component, ellipsis, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element, any, {
7
9
  $isTextual: boolean;
8
10
  }, never>;
9
11
  export declare const TableTh: import("styled-components").StyledComponent<"th", any, {}, never>;
10
- export declare const TableBody: import("styled-components").StyledComponent<"tbody", any, {
11
- maxHeight?: string | undefined;
12
- }, never>;
12
+ export declare const TableBody: import("styled-components").StyledComponent<"tbody", any, {}, never>;
13
13
  export declare const TableBodyRow: import("styled-components").StyledComponent<"tr", any, {
14
14
  $stripedRows: boolean;
15
- $hasOnClick?: boolean | undefined;
16
15
  }, never>;
17
16
  export declare const TableBodyCell: import("styled-components").StyledComponent<"td", any, {}, never>;
17
+ export declare const EmptyStateContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -2,6 +2,7 @@ import _styled, { css } from "styled-components";
2
2
  import { useTheme, getFocusStyle } from "@redislabsdev/redis-ui-styles";
3
3
  import { Typography } from "@redislabsdev/redis-ui-components";
4
4
  import { ShowOnRowHover } from "./components/ShowOnRowHover/ShowOnRowHover.style.js";
5
+ import { useTableContext } from "./Table.context.js";
5
6
  const TableContainer = _styled.div.withConfig({
6
7
  displayName: "Tablestyle__TableContainer",
7
8
  componentId: "RedisUI__sc-o0xfty-0"
@@ -9,19 +10,35 @@ const TableContainer = _styled.div.withConfig({
9
10
  const Table = _styled.table.withConfig({
10
11
  displayName: "Tablestyle__Table",
11
12
  componentId: "RedisUI__sc-o0xfty-1"
12
- })(["width:100%;border-collapse:collapse;border-spacing:0;overflow-x:auto;display:block;table-layout:fixed;"]);
13
+ })(["width:100%;border-collapse:collapse;border-spacing:0;overflow-x:auto;display:block;table-layout:fixed;", ""], () => {
14
+ const {
15
+ table
16
+ } = useTableContext();
17
+ return css`
18
+ overflow-x: ${table.getRowModel().rows.length ? "auto" : "hidden"};
19
+ `;
20
+ });
13
21
  const TableHead = _styled.thead.withConfig({
14
22
  displayName: "Tablestyle__TableHead",
15
23
  componentId: "RedisUI__sc-o0xfty-2"
16
- })(["display:table;table-layout:fixed;"]);
24
+ })(["display:table;table-layout:fixed;", ""], () => {
25
+ const {
26
+ minWidth
27
+ } = useTableContext();
28
+ return css`
29
+ min-width: ${minWidth || void 0};
30
+ `;
31
+ });
17
32
  const TableHeaderRow = _styled.tr.withConfig({
18
33
  displayName: "Tablestyle__TableHeaderRow",
19
34
  componentId: "RedisUI__sc-o0xfty-3"
20
35
  })(["height:5.6rem;display:table;width:100%;table-layout:fixed;"]);
21
- const HeaderCellInnerWrapper = _styled.button.withConfig({
22
- displayName: "Tablestyle__HeaderCellInnerWrapper",
36
+ const SortableHeadingCompose = _styled.button.withConfig({
37
+ displayName: "Tablestyle__SortableHeadingCompose",
23
38
  componentId: "RedisUI__sc-o0xfty-4"
24
- })(["all:unset;border-radius:0.03rem;display:flex;align-items:center;justify-content:flex-start;gap:0.8rem;height:100%;width:100%;min-height:35px;max-width:100%;overflow:hidden;", " svg{flex:none;}"], getFocusStyle("0.6rem"));
39
+ })(["all:unset;border-radius:0.03rem;display:flex;align-items:center;justify-content:flex-start;gap:0.8rem;height:100%;width:100%;min-height:35px;max-width:100%;overflow:", ";", " svg{flex:none;}"], ({
40
+ $custom
41
+ }) => $custom ? void 0 : "hidden", getFocusStyle("0.6rem"));
25
42
  const HeaderTitleWrapper = _styled(Typography.Body).withConfig({
26
43
  displayName: "Tablestyle__HeaderTitleWrapper",
27
44
  componentId: "RedisUI__sc-o0xfty-5"
@@ -35,19 +52,27 @@ const HeaderTitleWrapper = _styled(Typography.Body).withConfig({
35
52
  const TableTh = _styled.th.withConfig({
36
53
  displayName: "Tablestyle__TableTh",
37
54
  componentId: "RedisUI__sc-o0xfty-6"
38
- })(["padding:1.05rem 1.2rem;color:", ";user-select:none;white-space:nowrap;word-break:break-word;line-height:normal;position:relative;&:not(:last-child)::after{content:'';position:absolute;inset:1.05rem 0 1.05rem auto;border-right:1px solid ", ";}"], () => useTheme().components.table.table.tableTh.color, () => useTheme().components.table.table.tableTh.borderRight);
55
+ })(["padding:1.05rem 1.2rem;color:", ";user-select:none;white-space:nowrap;word-break:break-word;line-height:normal;position:relative;overflow:hidden;&:not(:last-child)::after{content:'';position:absolute;inset:1.05rem 0 1.05rem auto;border-right:1px solid ", ";}"], () => useTheme().components.table.table.tableTh.color, () => useTheme().components.table.table.tableTh.borderRight);
39
56
  const TableBody = _styled.tbody.withConfig({
40
57
  displayName: "Tablestyle__TableBody",
41
58
  componentId: "RedisUI__sc-o0xfty-7"
42
- })(["max-height:", ";overflow-y:auto;overflow-x:hidden;display:inline-block;table-layout:fixed;"], ({
43
- maxHeight
44
- }) => maxHeight);
59
+ })(["", " overflow-y:auto;overflow-x:hidden;display:inline-block;table-layout:fixed;"], () => {
60
+ const {
61
+ maxHeight,
62
+ minWidth,
63
+ table
64
+ } = useTableContext();
65
+ return css`
66
+ max-height: ${maxHeight};
67
+ min-width: ${table.getRowModel().rows.length && minWidth || void 0};
68
+ `;
69
+ });
45
70
  const TableBodyRow = _styled.tr.withConfig({
46
71
  displayName: "Tablestyle__TableBodyRow",
47
72
  componentId: "RedisUI__sc-o0xfty-8"
48
- })(["border-top:1px solid ", ";height:4.8rem;transition:box-shadow 0.2s ease-in-out;position:relative;&:hover,&:focus{cursor:", ";z-index:1;box-shadow:", ";", "{opacity:1;visibility:visible;}}", " display:table;width:100%;table-layout:fixed;"], () => useTheme().components.table.table.tableBodyRow.borderTop, ({
49
- $hasOnClick
50
- }) => $hasOnClick ? "pointer" : "default", () => useTheme().components.table.table.tableBodyRow.hoverBoxShadow, ShowOnRowHover, ({
73
+ })(["border-top:1px solid ", ";height:4.8rem;transition:box-shadow 0.2s ease-in-out;position:relative;&:hover,&:focus,&:focus-within{cursor:", ";z-index:1;box-shadow:", ";", "{opacity:1;visibility:visible;}}", " display:table;width:100%;table-layout:fixed;"], () => useTheme().components.table.table.tableBodyRow.borderTop, ({
74
+ onClick
75
+ }) => onClick ? "pointer" : "default", () => useTheme().components.table.table.tableBodyRow.hoverBoxShadow, ShowOnRowHover, ({
51
76
  $stripedRows
52
77
  }) => $stripedRows && css`
53
78
  :nth-child(even of [data-row-type='regular']) {
@@ -58,9 +83,14 @@ const TableBodyCell = _styled.td.withConfig({
58
83
  displayName: "Tablestyle__TableBodyCell",
59
84
  componentId: "RedisUI__sc-o0xfty-9"
60
85
  })(["color:", ";padding:0 1.2rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;"], () => useTheme().components.table.table.tableBodyCell.color);
86
+ const EmptyStateContainer = _styled.div.withConfig({
87
+ displayName: "Tablestyle__EmptyStateContainer",
88
+ componentId: "RedisUI__sc-o0xfty-10"
89
+ })(["text-align:center;"]);
61
90
  export {
62
- HeaderCellInnerWrapper,
91
+ EmptyStateContainer,
63
92
  HeaderTitleWrapper,
93
+ SortableHeadingCompose,
64
94
  Table,
65
95
  TableBody,
66
96
  TableBodyCell,
@@ -1,48 +1,32 @@
1
- import { ComponentType, ReactNode } from 'react';
2
- import type { CellContext, ColumnDef, PaginationState, Row, RowSelectionState, SortingState } from '@tanstack/react-table';
3
- import type { TableExpandedRowProps } from './components/TableExpandedRow';
4
- import './tableTypes';
1
+ import type { CellContext, ColumnDef, PaginationState, Row, SortingState } from '@tanstack/react-table';
2
+ import { TableExpandableRowParams } from './plugins/ExpandableRowPlugin';
3
+ import { TablePaginationParams } from './plugins/PaginationPlugin';
4
+ import { TableRowSelectionParams } from './plugins/RowSelectionPlugin';
5
+ import { TableSortingParams } from './plugins/SortingPlugin';
6
+ import { EmptyStateProps } from './components/EmptyState/EmptyState';
7
+ import { TableRowNavigationParams } from './plugins/RowNavigationPlugin';
8
+ export * from '@tanstack/react-table';
9
+ /** @deprecated use ColumnDef */
5
10
  export type ColumnDefinition<T extends object> = ColumnDef<T>;
11
+ /** @deprecated use Row */
6
12
  export type RowDefinition<T extends object> = Row<T>;
13
+ /** @deprecated use CellContext */
7
14
  export type CellDefinition<T extends object, D> = CellContext<T, D>;
15
+ /** @deprecated use PaginationState */
8
16
  export type PaginationTypes = PaginationState;
17
+ /** @deprecated use SortingState */
9
18
  export type SortingTypes = SortingState;
10
- export interface TableSortingProps {
11
- defaultSorting?: SortingState;
12
- onSortingChange?: (state: SortingState) => void;
13
- sorting?: SortingState;
14
- manualSorting?: boolean;
15
- }
16
- export interface TableExpandableRowProps<T extends object> {
17
- getIsRowExpandable?: (row: T) => boolean;
18
- renderExpandedRow?: (row: RowDefinition<T>) => ReactNode;
19
- expandRowOnClick?: boolean;
20
- expandedRowComponent?: ComponentType<TableExpandedRowProps<T>>;
21
- }
22
- interface TablePaginationProps {
23
- pagination?: PaginationState;
24
- defaultPagination?: PaginationState;
25
- onPaginationChange?: (state: PaginationState) => void;
26
- manualPagination?: boolean;
27
- totalRowCount?: number;
28
- pageSizes?: number[];
29
- paginationEnabled?: boolean;
30
- }
31
- interface TableRowSelectionState<T extends object> {
32
- rowSelection?: RowSelectionState;
33
- defaultRowSelection?: RowSelectionState;
34
- onRowSelectionChange?: (state: RowSelectionState) => void;
35
- rowSelectionMode?: 'single' | 'multiple';
36
- getRowCanSelect?: (row: Row<T>) => boolean;
37
- }
38
- export interface TableProps<T extends object> extends TableSortingProps, TableExpandableRowProps<T>, TablePaginationProps, TableRowSelectionState<T> {
19
+ type TableExpandableRowProps<T extends object> = Omit<TableExpandableRowParams<T>, 'getRowCanExpand'> & {
20
+ getIsRowExpandable?: (rowData: T) => boolean;
21
+ };
22
+ export interface TableProps<T extends object> extends TableSortingParams, TableExpandableRowProps<T>, TablePaginationParams, TableRowSelectionParams<T>, TableRowNavigationParams {
39
23
  data: T[];
40
- columns: ColumnDefinition<T>[];
41
- getRowId?: (row: T, index: number) => string;
42
- onRowClick?: (row: T) => void;
43
- emptyState?: () => ReactNode;
24
+ columns: ColumnDef<T>[];
25
+ getRowId?: (rowData: T, index: number) => string;
26
+ onRowClick?: (rowData: T) => void;
27
+ emptyState?: EmptyStateProps['emptyStateRender'];
44
28
  maxHeight?: string;
29
+ minWidth?: string;
45
30
  stripedRows?: boolean;
46
31
  caption?: string;
47
32
  }
48
- export {};
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("../../../node_modules/react/jsx-runtime.cjs");
4
+ const index = require("../../../node_modules/@tanstack/react-table/build/lib/index.cjs");
5
+ const plugin_utils = require("../../utils/plugin.utils.cjs");
6
+ const Table_context = require("../../Table.context.cjs");
7
+ const Table_style = require("../../Table.style.cjs");
8
+ const index$1 = require("../../../node_modules/@tanstack/table-core/build/lib/index.cjs");
9
+ const TableCompose = ({
10
+ data,
11
+ columns,
12
+ pluginsData,
13
+ tableOptions,
14
+ components,
15
+ maxHeight,
16
+ minWidth,
17
+ stripedRows,
18
+ ...restProps
19
+ }) => {
20
+ const mergedPluginsData = plugin_utils.mergePluginsData(pluginsData);
21
+ const table = index.useReactTable({
22
+ data,
23
+ columns,
24
+ getCoreRowModel: index$1.getCoreRowModel(),
25
+ enableSorting: false,
26
+ enableColumnResizing: false,
27
+ ...tableOptions,
28
+ ...mergedPluginsData == null ? void 0 : mergedPluginsData.tableOptions
29
+ });
30
+ const tableContext = {
31
+ table,
32
+ plugins: mergedPluginsData.context,
33
+ components,
34
+ stripedRows,
35
+ maxHeight,
36
+ minWidth
37
+ };
38
+ return jsxRuntime.jsxRuntimeExports.jsx(Table_context.TableContextProvider, {
39
+ value: tableContext,
40
+ children: jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableContainer, {
41
+ ...restProps
42
+ })
43
+ });
44
+ };
45
+ exports.TableCompose = TableCompose;
@@ -0,0 +1,13 @@
1
+ import { SetOptional } from 'type-fest';
2
+ import { TableOptions } from '@tanstack/table-core';
3
+ import { ComposeElementProps } from '@redislabsdev/redis-ui-components';
4
+ import { TablePluginData } from '../../utils/plugin.utils';
5
+ import { CompositionContextProps, TableMainContextProps } from '../../Table.context';
6
+ export type OwnTableComposeProps<T extends object> = TableMainContextProps & Pick<TableOptions<T>, 'data' | 'columns'> & {
7
+ tableOptions?: Omit<SetOptional<TableOptions<T>, 'getCoreRowModel'>, 'data' | 'columns'>;
8
+ pluginsData?: TablePluginData<T>[];
9
+ components?: Partial<CompositionContextProps<T>>;
10
+ };
11
+ export type RestTableComposeProps = ComposeElementProps;
12
+ export type TableComposeProps<T extends object> = OwnTableComposeProps<T> & RestTableComposeProps;
13
+ export declare const TableCompose: <T extends object>({ data, columns, pluginsData, tableOptions, components, maxHeight, minWidth, stripedRows, ...restProps }: TableComposeProps<T>) => import("react/jsx-runtime").JSX.Element;