@redis-ui/table 2.4.0 → 2.18.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.
- package/dist/Table/Table.cjs +85 -136
- package/dist/Table/Table.context.cjs +16 -1
- package/dist/Table/Table.context.d.ts +22 -4
- package/dist/Table/Table.context.js +16 -1
- package/dist/Table/Table.d.ts +83 -3
- package/dist/Table/Table.js +86 -137
- package/dist/Table/Table.style.cjs +33 -17
- package/dist/Table/Table.style.d.ts +5 -2
- package/dist/Table/Table.style.js +34 -18
- package/dist/Table/Table.types.d.ts +21 -22
- package/dist/Table/components/Compose/Compose.cjs +42 -0
- package/dist/Table/components/Compose/Compose.d.ts +13 -0
- package/dist/Table/components/Compose/Compose.js +42 -0
- package/dist/Table/components/EmptyState/EmptyState.cjs +31 -0
- package/dist/Table/components/EmptyState/EmptyState.d.ts +6 -0
- package/dist/Table/components/EmptyState/EmptyState.js +31 -0
- package/dist/Table/components/ExpandRowButton/ExpandRowButton.cjs +1 -0
- package/dist/Table/components/ExpandRowButton/ExpandRowButton.js +1 -0
- package/dist/Table/components/HiddenCaption/HiddenCaption.cjs +13 -0
- package/dist/Table/components/HiddenCaption/HiddenCaption.d.ts +3 -0
- package/dist/Table/components/HiddenCaption/HiddenCaption.js +13 -0
- package/dist/Table/components/PluggableTable/PluggableTable.cjs +19 -0
- package/dist/Table/components/PluggableTable/PluggableTable.d.ts +10 -0
- package/dist/Table/components/PluggableTable/PluggableTable.js +19 -0
- package/dist/Table/components/PluggableTable/compositionComponents.cjs +21 -0
- package/dist/Table/components/PluggableTable/compositionComponents.d.ts +67 -0
- package/dist/Table/components/PluggableTable/compositionComponents.js +21 -0
- package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.cjs +29 -0
- package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.d.ts +7 -0
- package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.js +29 -0
- package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.test.d.ts +1 -0
- package/dist/Table/components/RowSelection/RowSelectionButton.cjs +15 -0
- package/dist/Table/components/RowSelection/RowSelectionButton.d.ts +6 -0
- package/dist/Table/components/RowSelection/RowSelectionButton.js +15 -0
- package/dist/Table/components/RowSelection/RowSelectionButton.test.d.ts +1 -0
- package/dist/Table/components/TableBody/TableBody.cjs +33 -0
- package/dist/Table/components/TableBody/TableBody.d.ts +23 -0
- package/dist/Table/components/TableBody/TableBody.js +33 -0
- package/dist/Table/components/TableBody/components/Compose/Compose.cjs +10 -0
- package/dist/Table/components/TableBody/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TableBody/components/Compose/Compose.js +10 -0
- package/dist/Table/components/TableBodyCell/TableBodyCell.cjs +22 -0
- package/dist/Table/components/TableBodyCell/TableBodyCell.d.ts +12 -0
- package/dist/Table/components/TableBodyCell/TableBodyCell.js +22 -0
- package/dist/Table/components/TableBodyCell/components/Compose/Compose.cjs +5 -0
- package/dist/Table/components/TableBodyCell/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TableBodyCell/components/Compose/Compose.js +5 -0
- package/dist/Table/components/TableBodyRow/TableBodyRow.cjs +38 -0
- package/dist/Table/components/TableBodyRow/TableBodyRow.d.ts +20 -0
- package/dist/Table/components/TableBodyRow/TableBodyRow.js +38 -0
- package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.cjs +33 -0
- package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.d.ts +2 -0
- package/dist/Table/components/TableBodyRow/TableBodyRowExpandable.js +33 -0
- package/dist/Table/components/TableBodyRow/components/Compose/Compose.cjs +17 -0
- package/dist/Table/components/TableBodyRow/components/Compose/Compose.d.ts +4 -0
- package/dist/Table/components/TableBodyRow/components/Compose/Compose.js +17 -0
- package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.cjs +3 -4
- package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.d.ts +1 -1
- package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.js +3 -4
- package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.style.cjs +1 -1
- package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.style.js +1 -1
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.cjs +9 -4
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.d.ts +1 -1
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.js +9 -4
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.style.cjs +2 -2
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.style.js +2 -2
- package/dist/Table/components/TableExpandedRow/TableExpandedRow.types.d.ts +3 -5
- package/dist/Table/components/TableHeader/TableHeader.cjs +28 -0
- package/dist/Table/components/TableHeader/TableHeader.d.ts +21 -0
- package/dist/Table/components/TableHeader/TableHeader.js +28 -0
- package/dist/Table/components/TableHeader/components/Compose/Compose.cjs +5 -0
- package/dist/Table/components/TableHeader/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TableHeader/components/Compose/Compose.js +5 -0
- package/dist/Table/components/TableHeaderCell/SRSortingNotification.cjs +19 -0
- package/dist/Table/components/TableHeaderCell/SRSortingNotification.d.ts +1 -0
- package/dist/Table/components/TableHeaderCell/SRSortingNotification.js +19 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.cjs +23 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.cjs +15 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.d.ts +8 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.context.js +15 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.d.ts +16 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.js +23 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.test.d.ts +1 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.types.d.ts +13 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.cjs +79 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.d.ts +10 -0
- package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.js +79 -0
- package/dist/Table/components/TableHeaderCell/components/Compose/Compose.cjs +40 -0
- package/dist/Table/components/TableHeaderCell/components/Compose/Compose.d.ts +9 -0
- package/dist/Table/components/TableHeaderCell/components/Compose/Compose.js +40 -0
- package/dist/Table/components/TableHeaderCell/components/Heading/Heading.cjs +34 -0
- package/dist/Table/components/TableHeaderCell/components/Heading/Heading.d.ts +5 -0
- package/dist/Table/components/TableHeaderCell/components/Heading/Heading.js +34 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.cjs +16 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.d.ts +8 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/SortableHeading.js +16 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.cjs +23 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.d.ts +5 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/Compose/Compose.js +23 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.cjs +6 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.d.ts +2 -0
- package/dist/Table/components/TableHeaderCell/components/SortableHeading/components/SortIndicator/SortIndicator.js +6 -0
- package/dist/Table/components/TableHeaderRow/TableHeaderRow.cjs +27 -0
- package/dist/Table/components/TableHeaderRow/TableHeaderRow.d.ts +12 -0
- package/dist/Table/components/TableHeaderRow/TableHeaderRow.js +27 -0
- package/dist/Table/components/TableHeaderRow/components/Compose/Compose.cjs +5 -0
- package/dist/Table/components/TableHeaderRow/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TableHeaderRow/components/Compose/Compose.js +5 -0
- package/dist/Table/components/TablePagination/TablePagination.cjs +63 -78
- package/dist/Table/components/TablePagination/TablePagination.d.ts +23 -3
- package/dist/Table/components/TablePagination/TablePagination.js +64 -79
- package/dist/Table/components/TablePagination/TablePagination.style.cjs +78 -53
- package/dist/Table/components/TablePagination/TablePagination.style.d.ts +17 -49
- package/dist/Table/components/TablePagination/TablePagination.style.js +80 -55
- package/dist/Table/components/TablePagination/components/Compose/Compose.cjs +41 -0
- package/dist/Table/components/TablePagination/components/Compose/Compose.d.ts +3 -0
- package/dist/Table/components/TablePagination/components/Compose/Compose.js +41 -0
- package/dist/Table/components/TableRoot/TableRoot.cjs +5 -0
- package/dist/Table/components/TableRoot/TableRoot.d.ts +1 -0
- package/dist/Table/components/TableRoot/TableRoot.js +5 -0
- package/dist/Table/index.d.ts +3 -6
- package/dist/Table/plugins/ClickableRowPlugin.cjs +48 -0
- package/dist/Table/plugins/ClickableRowPlugin.d.ts +25 -0
- package/dist/Table/plugins/ClickableRowPlugin.js +48 -0
- package/dist/Table/plugins/ExpandableRowPlugin.cjs +38 -0
- package/dist/Table/plugins/ExpandableRowPlugin.d.ts +22 -0
- package/dist/Table/plugins/ExpandableRowPlugin.js +38 -0
- package/dist/Table/plugins/PaginationPlugin.cjs +45 -0
- package/dist/Table/plugins/PaginationPlugin.d.ts +16 -0
- package/dist/Table/plugins/PaginationPlugin.js +45 -0
- package/dist/Table/plugins/RowSelectionPlugin.cjs +28 -0
- package/dist/Table/plugins/RowSelectionPlugin.d.ts +12 -0
- package/dist/Table/plugins/RowSelectionPlugin.js +28 -0
- package/dist/Table/plugins/SortingPlugin.cjs +44 -0
- package/dist/Table/plugins/SortingPlugin.d.ts +18 -0
- package/dist/Table/plugins/SortingPlugin.js +44 -0
- package/dist/Table/tanStackExtendedTypes.d.ts +11 -0
- package/dist/Table/utils/plugin.utils.cjs +49 -0
- package/dist/Table/utils/plugin.utils.d.ts +17 -0
- package/dist/Table/utils/plugin.utils.js +49 -0
- package/dist/Table/utils/plugin.utils.test.d.ts +1 -0
- package/dist/index.cjs +60 -0
- package/dist/index.js +61 -1
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs +55 -0
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +37 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs +100 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +82 -0
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +51 -0
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +33 -0
- package/dist/node_modules/@tanstack/react-table/build/lib/index.cjs +7 -0
- package/dist/node_modules/@tanstack/react-table/build/lib/index.js +8 -1
- package/dist/node_modules/@tanstack/table-core/build/lib/index.cjs +361 -4
- package/dist/node_modules/@tanstack/table-core/build/lib/index.js +361 -4
- package/package.json +7 -5
package/dist/Table/Table.js
CHANGED
|
@@ -1,172 +1,121 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "../node_modules/react/jsx-runtime.js";
|
|
2
|
-
import { useEffect, Fragment } from "react";
|
|
3
|
-
import { useReactTable, flexRender } from "../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
|
-
import { ArrowUpIcon, ArrowDownIcon } from "@redislabsdev/redis-ui-icons";
|
|
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 {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
5
|
+
import { RowSelectionButton } from "./components/RowSelection/RowSelectionButton.js";
|
|
6
|
+
import { HeaderMultiRowSelectionButton } from "./components/RowSelection/HeaderMultiRowSelectionButton.js";
|
|
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";
|
|
18
15
|
const Table = Object.assign(({
|
|
19
16
|
columns,
|
|
17
|
+
caption,
|
|
20
18
|
onRowClick,
|
|
21
19
|
data,
|
|
22
|
-
|
|
20
|
+
getRowId,
|
|
23
21
|
emptyState,
|
|
24
22
|
maxHeight,
|
|
25
23
|
stripedRows = false,
|
|
24
|
+
// sorting
|
|
25
|
+
enableSorting,
|
|
26
|
+
defaultSorting,
|
|
26
27
|
onSortingChange,
|
|
27
28
|
sorting,
|
|
28
|
-
manualSorting
|
|
29
|
+
manualSorting,
|
|
30
|
+
// row expansion
|
|
29
31
|
getIsRowExpandable,
|
|
30
32
|
renderExpandedRow,
|
|
31
33
|
expandRowOnClick,
|
|
32
|
-
expandedRowComponent
|
|
34
|
+
expandedRowComponent,
|
|
35
|
+
// pagination
|
|
33
36
|
pagination,
|
|
34
37
|
defaultPagination,
|
|
35
38
|
onPaginationChange,
|
|
36
39
|
manualPagination,
|
|
37
40
|
totalRowCount,
|
|
38
41
|
pageSizes,
|
|
39
|
-
paginationEnabled
|
|
42
|
+
paginationEnabled,
|
|
43
|
+
// row selection
|
|
44
|
+
rowSelection,
|
|
45
|
+
defaultRowSelection,
|
|
46
|
+
onRowSelectionChange,
|
|
47
|
+
rowSelectionMode,
|
|
48
|
+
getRowCanSelect
|
|
40
49
|
}) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
onChange: onSortingChange
|
|
50
|
+
const clickableRowPluginData = useClickableRowPlugin({
|
|
51
|
+
onRowClick: onRowClick && ((row) => onRowClick(row.original)),
|
|
52
|
+
shouldClickOnEnter: true
|
|
45
53
|
});
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
const sortingPluginData = useSortingPlugin({
|
|
55
|
+
enableSorting,
|
|
56
|
+
defaultSorting,
|
|
57
|
+
onSortingChange,
|
|
58
|
+
sorting,
|
|
59
|
+
manualSorting
|
|
50
60
|
});
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
onPaginationChange
|
|
61
|
+
const paginationPluginData = usePaginationPlugin({
|
|
62
|
+
pagination,
|
|
63
|
+
defaultPagination,
|
|
64
|
+
onPaginationChange,
|
|
55
65
|
manualPagination,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const table = useReactTable({
|
|
60
|
-
data,
|
|
61
|
-
columns,
|
|
62
|
-
getCoreRowModel: getCoreRowModel(),
|
|
63
|
-
getSortedRowModel: getSortedRowModel(),
|
|
64
|
-
state: {
|
|
65
|
-
sorting: sortingState,
|
|
66
|
-
...paginationEnabled && {
|
|
67
|
-
pagination: paginationState
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
manualSorting,
|
|
71
|
-
onSortingChange: setSortingState,
|
|
72
|
-
getExpandedRowModel: isExpandable ? getExpandedRowModel() : void 0,
|
|
73
|
-
getRowCanExpand: isExpandable ? getIsRowExpandable && ((row) => getIsRowExpandable(row.original)) || getTrue : void 0,
|
|
74
|
-
...paginationEnabled && paginationSettings
|
|
66
|
+
totalRowCount,
|
|
67
|
+
pageSizes,
|
|
68
|
+
paginationEnabled
|
|
75
69
|
});
|
|
76
|
-
const {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
70
|
+
const expandableRowPluginData = useExpandableRowPlugin({
|
|
71
|
+
expandRowOnClick,
|
|
72
|
+
getRowCanExpand: getIsRowExpandable && ((row) => getIsRowExpandable(row.original)),
|
|
73
|
+
renderExpandedRow,
|
|
74
|
+
expandedRowComponent
|
|
75
|
+
});
|
|
76
|
+
const rowSelectionPluginData = useRowSelectionPlugin({
|
|
77
|
+
rowSelection,
|
|
78
|
+
defaultRowSelection,
|
|
79
|
+
onRowSelectionChange,
|
|
80
|
+
rowSelectionMode,
|
|
81
|
+
getRowCanSelect
|
|
82
|
+
});
|
|
83
|
+
return jsxRuntimeExports.jsx(Table.PluggableTable, {
|
|
84
|
+
...{
|
|
85
|
+
data,
|
|
86
|
+
columns,
|
|
87
|
+
maxHeight,
|
|
88
|
+
stripedRows,
|
|
89
|
+
caption,
|
|
90
|
+
emptyStateRender: emptyState
|
|
91
|
+
},
|
|
92
|
+
tableOptions: {
|
|
93
|
+
getRowId
|
|
89
94
|
},
|
|
90
|
-
|
|
91
|
-
children: [jsxRuntimeExports.jsxs(Table$1, {
|
|
92
|
-
children: [jsxRuntimeExports.jsx(TableHead, {
|
|
93
|
-
children: table.getHeaderGroups().map((headerGroup) => jsxRuntimeExports.jsx(TableHeaderRow, {
|
|
94
|
-
children: headerGroup.headers.map((header) => jsxRuntimeExports.jsx(TableTh, {
|
|
95
|
-
onClick: header.column.getToggleSortingHandler(),
|
|
96
|
-
style: {
|
|
97
|
-
width: header.column.getSize()
|
|
98
|
-
},
|
|
99
|
-
children: jsxRuntimeExports.jsxs(HeaderCellInnerWrapper, {
|
|
100
|
-
size: "XS",
|
|
101
|
-
children: [header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()), {
|
|
102
|
-
asc: jsxRuntimeExports.jsx(ArrowUpIcon, {
|
|
103
|
-
size: "S",
|
|
104
|
-
color: "neutral700"
|
|
105
|
-
}),
|
|
106
|
-
desc: jsxRuntimeExports.jsx(ArrowDownIcon, {
|
|
107
|
-
size: "S",
|
|
108
|
-
color: "neutral700"
|
|
109
|
-
})
|
|
110
|
-
}[header.column.getIsSorted()] ?? null]
|
|
111
|
-
})
|
|
112
|
-
}, header.id))
|
|
113
|
-
}, headerGroup.id))
|
|
114
|
-
}), jsxRuntimeExports.jsxs(TableBody, {
|
|
115
|
-
maxHeight,
|
|
116
|
-
children: [!rows.length ? jsxRuntimeExports.jsx(TableBodyRow, {
|
|
117
|
-
"$stripedRows": false,
|
|
118
|
-
children: jsxRuntimeExports.jsx(TableBodyCell, {
|
|
119
|
-
colSpan: columns.length,
|
|
120
|
-
children: emptyState ? emptyState() : "No data to display"
|
|
121
|
-
})
|
|
122
|
-
}) : null, rows.map((row) => {
|
|
123
|
-
const isRowExpandable = isExpandable && row.getCanExpand();
|
|
124
|
-
const isRowExpanded = isRowExpandable && row.getIsExpanded();
|
|
125
|
-
const handleClick = () => {
|
|
126
|
-
isRowExpandable && expandRowOnClick && row.toggleExpanded();
|
|
127
|
-
onRowClick == null ? void 0 : onRowClick(row.original);
|
|
128
|
-
};
|
|
129
|
-
return jsxRuntimeExports.jsxs(Fragment, {
|
|
130
|
-
children: [jsxRuntimeExports.jsx(TableBodyRow, {
|
|
131
|
-
tabIndex: 0,
|
|
132
|
-
"data-row-type": "regular",
|
|
133
|
-
...isRowExpandable ? {
|
|
134
|
-
"aria-expanded": isRowExpanded
|
|
135
|
-
} : null,
|
|
136
|
-
"$stripedRows": stripedRows,
|
|
137
|
-
"$hasOnClick": !!onRowClick || isRowExpandable,
|
|
138
|
-
onClick: handleClick,
|
|
139
|
-
onKeyDown: (event) => {
|
|
140
|
-
if (event.key === "Enter" && event.target === event.currentTarget) {
|
|
141
|
-
handleClick();
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
children: row.getVisibleCells().map((cell) => jsxRuntimeExports.jsx(TableBodyCell, {
|
|
145
|
-
style: {
|
|
146
|
-
width: cell.column.getSize()
|
|
147
|
-
},
|
|
148
|
-
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
149
|
-
}, cell.id))
|
|
150
|
-
}), isRowExpandable && // 2nd row is a custom 1 cell row for expanded part
|
|
151
|
-
jsxRuntimeExports.jsx(ExpandedRow, {
|
|
152
|
-
"data-row-type": "expanded",
|
|
153
|
-
"data-expanded": isRowExpanded,
|
|
154
|
-
expanded: isRowExpanded,
|
|
155
|
-
row,
|
|
156
|
-
renderExpandedRow
|
|
157
|
-
})]
|
|
158
|
-
}, row.id);
|
|
159
|
-
})]
|
|
160
|
-
})]
|
|
161
|
-
}), jsxRuntimeExports.jsx(TablePagination, {
|
|
162
|
-
pageSizes
|
|
163
|
-
})]
|
|
164
|
-
})
|
|
95
|
+
pluginsData: [clickableRowPluginData, sortingPluginData, paginationPluginData, expandableRowPluginData, rowSelectionPluginData]
|
|
165
96
|
});
|
|
166
97
|
}, {
|
|
167
98
|
ExpandRowButton,
|
|
168
99
|
ExpandedRow: TableExpandedRow,
|
|
169
|
-
AnimatedExpandedRow: TableAnimatedExpandedRow
|
|
100
|
+
AnimatedExpandedRow: TableAnimatedExpandedRow,
|
|
101
|
+
RowSelectionButton,
|
|
102
|
+
HeaderMultiRowSelectionButton,
|
|
103
|
+
// plugins
|
|
104
|
+
useClickableRowPlugin,
|
|
105
|
+
useSortingPlugin,
|
|
106
|
+
usePaginationPlugin,
|
|
107
|
+
useExpandableRowPlugin,
|
|
108
|
+
useRowSelectionPlugin,
|
|
109
|
+
// contexts
|
|
110
|
+
useTableContext,
|
|
111
|
+
useComposeContext,
|
|
112
|
+
useClickableRowContext,
|
|
113
|
+
useExpandableRowContext,
|
|
114
|
+
usePaginationContext,
|
|
115
|
+
useSortingContext,
|
|
116
|
+
// composition components
|
|
117
|
+
PluggableTable,
|
|
118
|
+
...compositionComponents
|
|
170
119
|
});
|
|
171
120
|
export {
|
|
172
121
|
Table as default
|
|
@@ -8,40 +8,50 @@ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
|
8
8
|
const _styled__default = /* @__PURE__ */ _interopDefault(_styled);
|
|
9
9
|
const TableContainer = _styled__default.default.div.withConfig({
|
|
10
10
|
displayName: "Tablestyle__TableContainer",
|
|
11
|
-
componentId: "
|
|
11
|
+
componentId: "RedisUI__sc-o0xfty-0"
|
|
12
12
|
})(["width:100%;border-radius:0.8rem;box-shadow:", ";background-color:", ";overflow:hidden;"], () => redisUiStyles.useTheme().components.table.table.tableContainer.boxShadow, () => redisUiStyles.useTheme().components.table.table.tableContainer.backgroundColor);
|
|
13
13
|
const Table = _styled__default.default.table.withConfig({
|
|
14
14
|
displayName: "Tablestyle__Table",
|
|
15
|
-
componentId: "
|
|
16
|
-
})(["width:100%;border-collapse:collapse;border-spacing:0;overflow-x:auto;display:block;table-layout:fixed
|
|
15
|
+
componentId: "RedisUI__sc-o0xfty-1"
|
|
16
|
+
})(["width:100%;border-collapse:collapse;border-spacing:0;overflow-x:auto;display:block;table-layout:fixed;"]);
|
|
17
17
|
const TableHead = _styled__default.default.thead.withConfig({
|
|
18
18
|
displayName: "Tablestyle__TableHead",
|
|
19
|
-
componentId: "
|
|
19
|
+
componentId: "RedisUI__sc-o0xfty-2"
|
|
20
20
|
})(["display:table;table-layout:fixed;"]);
|
|
21
21
|
const TableHeaderRow = _styled__default.default.tr.withConfig({
|
|
22
22
|
displayName: "Tablestyle__TableHeaderRow",
|
|
23
|
-
componentId: "
|
|
23
|
+
componentId: "RedisUI__sc-o0xfty-3"
|
|
24
24
|
})(["height:5.6rem;display:table;width:100%;table-layout:fixed;"]);
|
|
25
|
-
const
|
|
26
|
-
displayName: "
|
|
27
|
-
componentId: "
|
|
28
|
-
})(["display:flex;align-items:center;justify-content:flex-start;height:
|
|
25
|
+
const SortableHeadingCompose = _styled__default.default.button.withConfig({
|
|
26
|
+
displayName: "Tablestyle__SortableHeadingCompose",
|
|
27
|
+
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"));
|
|
29
|
+
const HeaderTitleWrapper = _styled__default.default(redisUiComponents.Typography.Body).withConfig({
|
|
30
|
+
displayName: "Tablestyle__HeaderTitleWrapper",
|
|
31
|
+
componentId: "RedisUI__sc-o0xfty-5"
|
|
32
|
+
})(["flex:0 1 auto;white-space:inherit;text-align:start;", ""], ({
|
|
33
|
+
$isTextual
|
|
34
|
+
}) => $isTextual ? null : _styled.css`
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: flex-start;
|
|
38
|
+
`);
|
|
29
39
|
const TableTh = _styled__default.default.th.withConfig({
|
|
30
40
|
displayName: "Tablestyle__TableTh",
|
|
31
|
-
componentId: "
|
|
32
|
-
})(["padding:1.05rem
|
|
41
|
+
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);
|
|
33
43
|
const TableBody = _styled__default.default.tbody.withConfig({
|
|
34
44
|
displayName: "Tablestyle__TableBody",
|
|
35
|
-
componentId: "
|
|
45
|
+
componentId: "RedisUI__sc-o0xfty-7"
|
|
36
46
|
})(["max-height:", ";overflow-y:auto;overflow-x:hidden;display:inline-block;table-layout:fixed;"], ({
|
|
37
47
|
maxHeight
|
|
38
48
|
}) => maxHeight);
|
|
39
49
|
const TableBodyRow = _styled__default.default.tr.withConfig({
|
|
40
50
|
displayName: "Tablestyle__TableBodyRow",
|
|
41
|
-
componentId: "
|
|
51
|
+
componentId: "RedisUI__sc-o0xfty-8"
|
|
42
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, ({
|
|
43
|
-
|
|
44
|
-
}) =>
|
|
53
|
+
onClick
|
|
54
|
+
}) => onClick ? "pointer" : "default", () => redisUiStyles.useTheme().components.table.table.tableBodyRow.hoverBoxShadow, ShowOnRowHover_style.ShowOnRowHover, ({
|
|
45
55
|
$stripedRows
|
|
46
56
|
}) => $stripedRows && _styled.css`
|
|
47
57
|
:nth-child(even of [data-row-type='regular']) {
|
|
@@ -50,9 +60,15 @@ const TableBodyRow = _styled__default.default.tr.withConfig({
|
|
|
50
60
|
`);
|
|
51
61
|
const TableBodyCell = _styled__default.default.td.withConfig({
|
|
52
62
|
displayName: "Tablestyle__TableBodyCell",
|
|
53
|
-
componentId: "
|
|
63
|
+
componentId: "RedisUI__sc-o0xfty-9"
|
|
54
64
|
})(["color:", ";padding:0 1.2rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;"], () => redisUiStyles.useTheme().components.table.table.tableBodyCell.color);
|
|
55
|
-
|
|
65
|
+
const EmptyStateContainer = _styled__default.default.div.withConfig({
|
|
66
|
+
displayName: "Tablestyle__EmptyStateContainer",
|
|
67
|
+
componentId: "RedisUI__sc-o0xfty-10"
|
|
68
|
+
})(["text-align:center;"]);
|
|
69
|
+
exports.EmptyStateContainer = EmptyStateContainer;
|
|
70
|
+
exports.HeaderTitleWrapper = HeaderTitleWrapper;
|
|
71
|
+
exports.SortableHeadingCompose = SortableHeadingCompose;
|
|
56
72
|
exports.Table = Table;
|
|
57
73
|
exports.TableBody = TableBody;
|
|
58
74
|
exports.TableBodyCell = TableBodyCell;
|
|
@@ -2,13 +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
|
|
5
|
+
export declare const SortableHeadingCompose: 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").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element, any, {
|
|
7
|
+
$isTextual: boolean;
|
|
8
|
+
}, never>;
|
|
6
9
|
export declare const TableTh: import("styled-components").StyledComponent<"th", any, {}, never>;
|
|
7
10
|
export declare const TableBody: import("styled-components").StyledComponent<"tbody", any, {
|
|
8
11
|
maxHeight?: string | undefined;
|
|
9
12
|
}, never>;
|
|
10
13
|
export declare const TableBodyRow: import("styled-components").StyledComponent<"tr", any, {
|
|
11
14
|
$stripedRows: boolean;
|
|
12
|
-
$hasOnClick?: boolean | undefined;
|
|
13
15
|
}, never>;
|
|
14
16
|
export declare const TableBodyCell: import("styled-components").StyledComponent<"td", any, {}, never>;
|
|
17
|
+
export declare const EmptyStateContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,43 +1,53 @@
|
|
|
1
1
|
import _styled, { css } from "styled-components";
|
|
2
|
-
import { useTheme } from "@redislabsdev/redis-ui-styles";
|
|
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
5
|
const TableContainer = _styled.div.withConfig({
|
|
6
6
|
displayName: "Tablestyle__TableContainer",
|
|
7
|
-
componentId: "
|
|
7
|
+
componentId: "RedisUI__sc-o0xfty-0"
|
|
8
8
|
})(["width:100%;border-radius:0.8rem;box-shadow:", ";background-color:", ";overflow:hidden;"], () => useTheme().components.table.table.tableContainer.boxShadow, () => useTheme().components.table.table.tableContainer.backgroundColor);
|
|
9
9
|
const Table = _styled.table.withConfig({
|
|
10
10
|
displayName: "Tablestyle__Table",
|
|
11
|
-
componentId: "
|
|
12
|
-
})(["width:100%;border-collapse:collapse;border-spacing:0;overflow-x:auto;display:block;table-layout:fixed
|
|
11
|
+
componentId: "RedisUI__sc-o0xfty-1"
|
|
12
|
+
})(["width:100%;border-collapse:collapse;border-spacing:0;overflow-x:auto;display:block;table-layout:fixed;"]);
|
|
13
13
|
const TableHead = _styled.thead.withConfig({
|
|
14
14
|
displayName: "Tablestyle__TableHead",
|
|
15
|
-
componentId: "
|
|
15
|
+
componentId: "RedisUI__sc-o0xfty-2"
|
|
16
16
|
})(["display:table;table-layout:fixed;"]);
|
|
17
17
|
const TableHeaderRow = _styled.tr.withConfig({
|
|
18
18
|
displayName: "Tablestyle__TableHeaderRow",
|
|
19
|
-
componentId: "
|
|
19
|
+
componentId: "RedisUI__sc-o0xfty-3"
|
|
20
20
|
})(["height:5.6rem;display:table;width:100%;table-layout:fixed;"]);
|
|
21
|
-
const
|
|
22
|
-
displayName: "
|
|
23
|
-
componentId: "
|
|
24
|
-
})(["display:flex;align-items:center;justify-content:flex-start;height:
|
|
21
|
+
const SortableHeadingCompose = _styled.button.withConfig({
|
|
22
|
+
displayName: "Tablestyle__SortableHeadingCompose",
|
|
23
|
+
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"));
|
|
25
|
+
const HeaderTitleWrapper = _styled(Typography.Body).withConfig({
|
|
26
|
+
displayName: "Tablestyle__HeaderTitleWrapper",
|
|
27
|
+
componentId: "RedisUI__sc-o0xfty-5"
|
|
28
|
+
})(["flex:0 1 auto;white-space:inherit;text-align:start;", ""], ({
|
|
29
|
+
$isTextual
|
|
30
|
+
}) => $isTextual ? null : css`
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: flex-start;
|
|
34
|
+
`);
|
|
25
35
|
const TableTh = _styled.th.withConfig({
|
|
26
36
|
displayName: "Tablestyle__TableTh",
|
|
27
|
-
componentId: "
|
|
28
|
-
})(["padding:1.05rem
|
|
37
|
+
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);
|
|
29
39
|
const TableBody = _styled.tbody.withConfig({
|
|
30
40
|
displayName: "Tablestyle__TableBody",
|
|
31
|
-
componentId: "
|
|
41
|
+
componentId: "RedisUI__sc-o0xfty-7"
|
|
32
42
|
})(["max-height:", ";overflow-y:auto;overflow-x:hidden;display:inline-block;table-layout:fixed;"], ({
|
|
33
43
|
maxHeight
|
|
34
44
|
}) => maxHeight);
|
|
35
45
|
const TableBodyRow = _styled.tr.withConfig({
|
|
36
46
|
displayName: "Tablestyle__TableBodyRow",
|
|
37
|
-
componentId: "
|
|
47
|
+
componentId: "RedisUI__sc-o0xfty-8"
|
|
38
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, ({
|
|
39
|
-
|
|
40
|
-
}) =>
|
|
49
|
+
onClick
|
|
50
|
+
}) => onClick ? "pointer" : "default", () => useTheme().components.table.table.tableBodyRow.hoverBoxShadow, ShowOnRowHover, ({
|
|
41
51
|
$stripedRows
|
|
42
52
|
}) => $stripedRows && css`
|
|
43
53
|
:nth-child(even of [data-row-type='regular']) {
|
|
@@ -46,10 +56,16 @@ const TableBodyRow = _styled.tr.withConfig({
|
|
|
46
56
|
`);
|
|
47
57
|
const TableBodyCell = _styled.td.withConfig({
|
|
48
58
|
displayName: "Tablestyle__TableBodyCell",
|
|
49
|
-
componentId: "
|
|
59
|
+
componentId: "RedisUI__sc-o0xfty-9"
|
|
50
60
|
})(["color:", ";padding:0 1.2rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;"], () => useTheme().components.table.table.tableBodyCell.color);
|
|
61
|
+
const EmptyStateContainer = _styled.div.withConfig({
|
|
62
|
+
displayName: "Tablestyle__EmptyStateContainer",
|
|
63
|
+
componentId: "RedisUI__sc-o0xfty-10"
|
|
64
|
+
})(["text-align:center;"]);
|
|
51
65
|
export {
|
|
52
|
-
|
|
66
|
+
EmptyStateContainer,
|
|
67
|
+
HeaderTitleWrapper,
|
|
68
|
+
SortableHeadingCompose,
|
|
53
69
|
Table,
|
|
54
70
|
TableBody,
|
|
55
71
|
TableBodyCell,
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
+
export * from '@tanstack/react-table';
|
|
8
|
+
/** @deprecated use ColumnDef */
|
|
4
9
|
export type ColumnDefinition<T extends object> = ColumnDef<T>;
|
|
10
|
+
/** @deprecated use Row */
|
|
5
11
|
export type RowDefinition<T extends object> = Row<T>;
|
|
12
|
+
/** @deprecated use CellContext */
|
|
6
13
|
export type CellDefinition<T extends object, D> = CellContext<T, D>;
|
|
14
|
+
/** @deprecated use PaginationState */
|
|
7
15
|
export type PaginationTypes = PaginationState;
|
|
16
|
+
/** @deprecated use SortingState */
|
|
8
17
|
export type SortingTypes = SortingState;
|
|
9
|
-
|
|
18
|
+
type TableExpandableRowProps<T extends object> = Omit<TableExpandableRowParams<T>, 'getRowCanExpand'> & {
|
|
19
|
+
getIsRowExpandable?: (rowData: T) => boolean;
|
|
20
|
+
};
|
|
21
|
+
export interface TableProps<T extends object> extends TableSortingParams, TableExpandableRowProps<T>, TablePaginationParams, TableRowSelectionParams<T> {
|
|
10
22
|
data: T[];
|
|
11
|
-
columns:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
columns: ColumnDef<T>[];
|
|
24
|
+
getRowId?: (rowData: T, index: number) => string;
|
|
25
|
+
onRowClick?: (rowData: T) => void;
|
|
26
|
+
emptyState?: EmptyStateProps['emptyStateRender'];
|
|
15
27
|
maxHeight?: string;
|
|
16
28
|
stripedRows?: boolean;
|
|
17
|
-
|
|
18
|
-
sorting?: SortingState;
|
|
19
|
-
manualSorting?: boolean;
|
|
20
|
-
getIsRowExpandable?: (row: T) => boolean;
|
|
21
|
-
renderExpandedRow?: (row: RowDefinition<T>) => ReactNode;
|
|
22
|
-
expandRowOnClick?: boolean;
|
|
23
|
-
expandedRowComponent?: ComponentType<TableExpandedRowProps<T>>;
|
|
24
|
-
pagination?: PaginationState;
|
|
25
|
-
defaultPagination?: PaginationState;
|
|
26
|
-
onPaginationChange?: (state: PaginationState) => void;
|
|
27
|
-
manualPagination?: boolean;
|
|
28
|
-
totalRowCount?: number;
|
|
29
|
-
pageSizes?: number[];
|
|
30
|
-
paginationEnabled?: boolean;
|
|
29
|
+
caption?: string;
|
|
31
30
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
stripedRows,
|
|
17
|
+
...restProps
|
|
18
|
+
}) => {
|
|
19
|
+
const mergedPluginsData = plugin_utils.mergePluginsData(pluginsData);
|
|
20
|
+
const table = index.useReactTable({
|
|
21
|
+
data,
|
|
22
|
+
columns,
|
|
23
|
+
getCoreRowModel: index$1.getCoreRowModel(),
|
|
24
|
+
enableSorting: false,
|
|
25
|
+
...tableOptions,
|
|
26
|
+
...mergedPluginsData == null ? void 0 : mergedPluginsData.tableOptions
|
|
27
|
+
});
|
|
28
|
+
const tableContext = {
|
|
29
|
+
table,
|
|
30
|
+
plugins: mergedPluginsData.context,
|
|
31
|
+
components,
|
|
32
|
+
stripedRows,
|
|
33
|
+
maxHeight
|
|
34
|
+
};
|
|
35
|
+
return jsxRuntime.jsxRuntimeExports.jsx(Table_context.TableContextProvider, {
|
|
36
|
+
value: tableContext,
|
|
37
|
+
children: jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableContainer, {
|
|
38
|
+
...restProps
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
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, stripedRows, ...restProps }: TableComposeProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "../../../node_modules/react/jsx-runtime.js";
|
|
2
|
+
import { useReactTable } from "../../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
3
|
+
import { mergePluginsData } from "../../utils/plugin.utils.js";
|
|
4
|
+
import { TableContextProvider } from "../../Table.context.js";
|
|
5
|
+
import { TableContainer } from "../../Table.style.js";
|
|
6
|
+
import { getCoreRowModel } from "../../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
7
|
+
const TableCompose = ({
|
|
8
|
+
data,
|
|
9
|
+
columns,
|
|
10
|
+
pluginsData,
|
|
11
|
+
tableOptions,
|
|
12
|
+
components,
|
|
13
|
+
maxHeight,
|
|
14
|
+
stripedRows,
|
|
15
|
+
...restProps
|
|
16
|
+
}) => {
|
|
17
|
+
const mergedPluginsData = mergePluginsData(pluginsData);
|
|
18
|
+
const table = useReactTable({
|
|
19
|
+
data,
|
|
20
|
+
columns,
|
|
21
|
+
getCoreRowModel: getCoreRowModel(),
|
|
22
|
+
enableSorting: false,
|
|
23
|
+
...tableOptions,
|
|
24
|
+
...mergedPluginsData == null ? void 0 : mergedPluginsData.tableOptions
|
|
25
|
+
});
|
|
26
|
+
const tableContext = {
|
|
27
|
+
table,
|
|
28
|
+
plugins: mergedPluginsData.context,
|
|
29
|
+
components,
|
|
30
|
+
stripedRows,
|
|
31
|
+
maxHeight
|
|
32
|
+
};
|
|
33
|
+
return jsxRuntimeExports.jsx(TableContextProvider, {
|
|
34
|
+
value: tableContext,
|
|
35
|
+
children: jsxRuntimeExports.jsx(TableContainer, {
|
|
36
|
+
...restProps
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
TableCompose
|
|
42
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("../../../node_modules/react/jsx-runtime.cjs");
|
|
4
|
+
const Table_context = require("../../Table.context.cjs");
|
|
5
|
+
const TableHeaderCell_utils = require("../TableHeaderCell/TableHeaderCell.utils.cjs");
|
|
6
|
+
const Table_style = require("../../Table.style.cjs");
|
|
7
|
+
const EmptyState = ({
|
|
8
|
+
emptyStateRender,
|
|
9
|
+
...restProps
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
table
|
|
13
|
+
} = Table_context.useTableContext();
|
|
14
|
+
if (table.getRowModel().rows.length) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const content = (typeof emptyStateRender === "function" ? emptyStateRender() : emptyStateRender) ?? "No data to display";
|
|
18
|
+
return jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableBody, {
|
|
19
|
+
...restProps,
|
|
20
|
+
children: jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableBodyRow, {
|
|
21
|
+
"$stripedRows": false,
|
|
22
|
+
children: jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableBodyCell, {
|
|
23
|
+
colSpan: TableHeaderCell_utils.normalizeCellSpan(table.getVisibleLeafColumns().length),
|
|
24
|
+
children: typeof content === "string" ? jsxRuntime.jsxRuntimeExports.jsx(Table_style.EmptyStateContainer, {
|
|
25
|
+
children: content
|
|
26
|
+
}) : content
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.EmptyState = EmptyState;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { ChildFree } from '@redislabsdev/redis-ui-components';
|
|
3
|
+
export interface EmptyStateProps extends ChildFree<HTMLAttributes<HTMLTableSectionElement>> {
|
|
4
|
+
emptyStateRender?: (() => ReactNode) | string;
|
|
5
|
+
}
|
|
6
|
+
export declare const EmptyState: ({ emptyStateRender, ...restProps }: EmptyStateProps) => import("react/jsx-runtime").JSX.Element | null;
|