@wonderflow/react-components 14.4.3 → 15.0.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/components/product-card/product-card-kpis/product-card-kpis.d.ts +1 -1
- package/dist/components/product-card/product-card-kpis/product-card-kpis.d.ts.map +1 -1
- package/dist/components/product-card/product-card-kpis/product-card.kpis.test.js +5 -0
- package/dist/components/table/table-cell/index.d.ts +1 -1
- package/dist/components/table/table-cell/index.d.ts.map +1 -1
- package/dist/components/table/table-cell/index.js +2 -2
- package/dist/components/table/table-cell/table-cell.d.ts +1 -0
- package/dist/components/table/table-cell/table-cell.d.ts.map +1 -1
- package/dist/components/table/table-cell/table-cell.js +3 -2
- package/dist/components/table/table-checkbox/table-checkbox.module.css +1 -1
- package/dist/components/table/table-controls/table-controls.test.js +10 -9
- package/dist/components/table/table-controls/toggle-columns.js +7 -7
- package/dist/components/table/table-row/index.d.ts +1 -1
- package/dist/components/table/table-row/index.d.ts.map +1 -1
- package/dist/components/table/table-row/index.js +2 -2
- package/dist/components/table/table-row/table-row.d.ts +14 -3
- package/dist/components/table/table-row/table-row.d.ts.map +1 -1
- package/dist/components/table/table-row/table-row.js +29 -22
- package/dist/components/table/table-row/table-row.test.js +1 -1
- package/dist/components/table/table.d.ts +25 -4
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +177 -92
- package/dist/components/table/table.stories.d.ts +17 -16
- package/dist/components/table/table.stories.d.ts.map +1 -1
- package/dist/components/table/table.stories.js +20 -0
- package/dist/components/table/table.test.d.ts +1 -1
- package/dist/components/table/table.test.d.ts.map +1 -1
- package/dist/components/table/table.test.js +197 -1
- package/dist/components/table/to-tanstack-columns.d.ts +4 -0
- package/dist/components/table/to-tanstack-columns.d.ts.map +1 -0
- package/dist/components/table/to-tanstack-columns.js +62 -0
- package/dist/components/table/to-tanstack-columns.test.d.ts +2 -0
- package/dist/components/table/to-tanstack-columns.test.d.ts.map +1 -0
- package/dist/components/table/to-tanstack-columns.test.js +93 -0
- package/dist/components/table/types.d.ts +55 -5
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/components/table/types.js +1 -1
- package/dist/utils/formatting.d.ts +1 -1
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/formatting.js +29 -4
- package/dist/utils/formatting.test.js +15 -3
- package/package.json +5 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
3
|
* Copyright 2022-2026 Wonderflow Design Team
|
|
4
4
|
*
|
|
@@ -14,26 +14,56 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { createColumnHelper, flexRender, getCoreRowModel, getExpandedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
17
18
|
import { useUpdateEffect } from 'ahooks';
|
|
18
19
|
import clsx from 'clsx';
|
|
19
|
-
import { AnimatePresence,
|
|
20
|
-
import {
|
|
21
|
-
import { useExpanded, usePagination, useRowSelect, useSortBy, useTable, } from 'react-table';
|
|
20
|
+
import { AnimatePresence, domAnimation, LazyMotion, m, } from 'framer-motion';
|
|
21
|
+
import { memo, useCallback, useEffect, useMemo, useState, } from 'react';
|
|
22
22
|
import { useUIDSeed } from 'react-uid';
|
|
23
23
|
import { Skeleton, Stack, Text, ToggleButton, } from '../..';
|
|
24
24
|
import * as styles from './table.module.css';
|
|
25
|
-
import { TableCell } from './table-cell';
|
|
25
|
+
import { MemoTableCell, TableCell } from './table-cell';
|
|
26
26
|
import { TableCheckbox } from './table-checkbox';
|
|
27
27
|
import { ToggleColumnsControl } from './table-controls';
|
|
28
28
|
import { TableExpand } from './table-expand';
|
|
29
29
|
import { TableHeader } from './table-header';
|
|
30
30
|
import { TablePagination } from './table-pagination';
|
|
31
|
-
import { TableRow } from './table-row';
|
|
32
|
-
|
|
31
|
+
import { MemoTableRow, TableRow } from './table-row';
|
|
32
|
+
import { toTanStackColumns } from './to-tanstack-columns';
|
|
33
|
+
/**
|
|
34
|
+
* Owns `row.getVisibleCells().map(cell => flexRender(...))` for a single
|
|
35
|
+
* row. This work must happen *inside* the memo boundary: doing it in the
|
|
36
|
+
* parent's `.map()` (as before) means the ~10 cell renders for every one of
|
|
37
|
+
* the 500 rows still run on every selection change even though the
|
|
38
|
+
* resulting `<MemoTableRow>` bails out of its own re-render — `React.memo`
|
|
39
|
+
* only skips the child's render, it can't stop the parent from doing the
|
|
40
|
+
* work to build that child's props/children in the first place.
|
|
41
|
+
*
|
|
42
|
+
* Wrapping this component itself in `memo` (with a comparator based on
|
|
43
|
+
* `isRowSelected`/`isRowExpanded`, not `row` identity, since v8 hands out a
|
|
44
|
+
* new `row`/cell objects on most re-renders too) means unaffected rows skip
|
|
45
|
+
* `flexRender` entirely, not just the DOM diff.
|
|
46
|
+
*/
|
|
47
|
+
const TableBodyRowComponent = ({ row, expandedRowsKey, expandableRowComponent, isRowSelected: _isRowSelected, isRowExpanded: _isRowExpanded, columnVisibilityKey: _columnVisibilityKey, }) => {
|
|
48
|
+
const canRenderSubRows = row.subRows.length > 0 && row.getIsExpanded() && expandableRowComponent;
|
|
49
|
+
return (_jsxs(_Fragment, { children: [_jsx(MemoTableRow, { expanded: row.getIsExpanded() && !row.subRows.some(subRow => subRow.getIsExpanded() && subRow.getCanExpand()), rowData: row, expandedRowsKey: expandedRowsKey, rowSignature: `${row.id}:${row.getIsSelected() ? 1 : 0}:${row.getIsExpanded() ? 1 : 0}:${_columnVisibilityKey}`, children: row.getVisibleCells().map(cell => (_jsx(MemoTableCell, { collapsed: cell.column.columnDef.meta?.isCollapsed, width: cell.column.columnDef.meta?.minWidth === 0
|
|
50
|
+
? undefined
|
|
51
|
+
: cell.column.columnDef.meta?.minWidth, align: cell.column.columnDef.meta?.align, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }), canRenderSubRows && row.subRows.map(subRow => (_jsx(MemoTableRow, { "data-table-row-expander": true, children: _jsx(MemoTableCell, { padding: false, colSpan: 100, children: _jsx(TableExpand, { data: subRow.original, component: expandableRowComponent }) }) }, subRow.id)))] }));
|
|
52
|
+
};
|
|
53
|
+
const areTableBodyRowPropsEqual = (prevProps, nextProps) => (prevProps.row.id === nextProps.row.id
|
|
54
|
+
&& prevProps.row.original === nextProps.row.original
|
|
55
|
+
&& prevProps.isRowSelected === nextProps.isRowSelected
|
|
56
|
+
&& prevProps.isRowExpanded === nextProps.isRowExpanded
|
|
57
|
+
&& prevProps.expandedRowsKey === nextProps.expandedRowsKey
|
|
58
|
+
&& prevProps.expandableRowComponent === nextProps.expandableRowComponent
|
|
59
|
+
&& prevProps.columnVisibilityKey === nextProps.columnVisibilityKey);
|
|
60
|
+
const TableBodyRow = memo(TableBodyRowComponent, areTableBodyRowPropsEqual);
|
|
61
|
+
const arrayToRowSelection = (ids) => ids.reduce((acc, id) => ({ ...acc, [id]: true }), {});
|
|
62
|
+
export const Table = ({ className, style, columns, data = [], selectableRows, selectedRowIds = [], onSelectedRowsChange, persistSelectionAcrossPages = false, getRowId, stripes, showSeparators = true, title, actions, selectedActions, selectedLabel = selectedRowIds => `Selected items: ${selectedRowIds.length}`, showHeader = false, showTableHead = true, columnsControl = false, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage = 10, totalRows, initialPageIndex = 0, onPaginationChange, onSortChange, pageClusters, initialSortBy = [], onRowExpandChange, selectSubRows = true, ...otherProps }) => {
|
|
33
63
|
const uid = useUIDSeed();
|
|
64
|
+
const columnHelper = useMemo(() => createColumnHelper(), []);
|
|
34
65
|
const hasSomeExpandableRows = useMemo(() => data.some(d => d.subRows), [data]);
|
|
35
66
|
const isManualPaginated = useMemo(() => Boolean(showPagination && onPaginationChange && totalRows), [showPagination, totalRows, onPaginationChange]);
|
|
36
|
-
const manualPaginationPageCount = useMemo(() => ((isManualPaginated && totalRows) ? Math.ceil(totalRows / itemsPerPage) : -1), [isManualPaginated, totalRows, itemsPerPage]);
|
|
37
67
|
const getHiddenColumns = useCallback(() => {
|
|
38
68
|
const hiddenColumns = defaultHiddenColumns ? [...defaultHiddenColumns] : [];
|
|
39
69
|
if (!selectableRows)
|
|
@@ -42,97 +72,151 @@ export const Table = ({ className, style, columns, data = [], selectableRows, se
|
|
|
42
72
|
hiddenColumns.push('expander');
|
|
43
73
|
return hiddenColumns;
|
|
44
74
|
}, [defaultHiddenColumns, selectableRows, hasSomeExpandableRows]);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
75
|
+
const resolvedGetRowId = useCallback((originalRow, relativeIndex, parent) => {
|
|
76
|
+
if (getRowId)
|
|
77
|
+
return getRowId(originalRow, relativeIndex, parent);
|
|
78
|
+
const rowId = originalRow?._id;
|
|
79
|
+
if (rowId != null)
|
|
80
|
+
return rowId;
|
|
81
|
+
if (parent)
|
|
82
|
+
return [parent.id, relativeIndex].join('.');
|
|
83
|
+
return relativeIndex.toString();
|
|
84
|
+
}, [getRowId]);
|
|
85
|
+
const [sorting, setSorting] = useState(() => initialSortBy);
|
|
86
|
+
const [expanded, setExpanded] = useState({});
|
|
87
|
+
const [pagination, setPagination] = useState({
|
|
88
|
+
pageIndex: initialPageIndex,
|
|
89
|
+
pageSize: itemsPerPage,
|
|
90
|
+
});
|
|
91
|
+
const [columnVisibility, setColumnVisibility] = useState(() => getHiddenColumns().reduce((acc, id) => ({ ...acc, [id]: false }), {}));
|
|
92
|
+
const [rowSelection, setRowSelection] = useState(() => arrayToRowSelection(selectedRowIds));
|
|
93
|
+
const manualPaginationPageCount = useMemo(() => ((isManualPaginated && totalRows) ? Math.ceil(totalRows / pagination.pageSize) : -1), [isManualPaginated, totalRows, pagination.pageSize]);
|
|
94
|
+
const convertedColumns = useMemo(() => toTanStackColumns(columns), [columns]);
|
|
95
|
+
const tableColumns = useMemo(() => {
|
|
96
|
+
const selectionColumn = columnHelper.display({
|
|
97
|
+
id: 'selection',
|
|
98
|
+
meta: { isCollapsed: true, isToggable: true },
|
|
99
|
+
header: ({ table }) => (_jsx(TableCheckbox, { checked: table.getIsAllPageRowsSelected(), indeterminate: !table.getIsAllPageRowsSelected() && table.getIsSomePageRowsSelected(), onChange: table.getToggleAllPageRowsSelectedHandler() })),
|
|
100
|
+
cell: ({ row }) => (_jsx(TableCheckbox, { checked: row.getIsSelected(), indeterminate: row.getIsSomeSelected(), disabled: !row.getCanSelect(), onChange: row.getToggleSelectedHandler() })),
|
|
101
|
+
});
|
|
102
|
+
const expanderColumn = columnHelper.display({
|
|
103
|
+
id: 'expander',
|
|
104
|
+
meta: {
|
|
105
|
+
isToggable: true, expander: true, minWidth: 40, align: 'center',
|
|
106
|
+
},
|
|
107
|
+
cell: ({ row }) => (row.getCanExpand()
|
|
108
|
+
? (_jsx(ToggleButton, { kind: "flat", dimension: "small", restingIcon: "chevron-right", pressedIcon: "chevron-down", pressed: row.getIsExpanded(), onClick: () => {
|
|
109
|
+
row.subRows
|
|
110
|
+
.filter(subRow => subRow.getIsExpanded())
|
|
111
|
+
.forEach(subRow => subRow.toggleExpanded(false));
|
|
112
|
+
row.toggleExpanded();
|
|
113
|
+
onRowExpandChange?.(row);
|
|
114
|
+
} }))
|
|
115
|
+
: null),
|
|
116
|
+
});
|
|
117
|
+
return [selectionColumn, expanderColumn, ...convertedColumns];
|
|
118
|
+
}, [columnHelper, convertedColumns, onRowExpandChange]);
|
|
119
|
+
const table = useReactTable({
|
|
49
120
|
data,
|
|
50
|
-
|
|
51
|
-
|
|
121
|
+
columns: tableColumns,
|
|
122
|
+
getRowId: resolvedGetRowId,
|
|
123
|
+
getSubRows: row => row.subRows,
|
|
124
|
+
getCoreRowModel: getCoreRowModel(),
|
|
125
|
+
getSortedRowModel: getSortedRowModel(),
|
|
126
|
+
/**
|
|
127
|
+
* When `expandableRowComponent` is set, `Table` renders sub rows itself
|
|
128
|
+
* (via the dedicated `TableExpand` block below, fed from the
|
|
129
|
+
* pre-expansion row model) instead of letting them flatten into the
|
|
130
|
+
* table's own row list. Only include `getExpandedRowModel` — the thing
|
|
131
|
+
* that makes expanded sub rows flatten into `table.getRowModel().rows`
|
|
132
|
+
* through the *same* columns — when there's no custom renderer.
|
|
133
|
+
*/
|
|
134
|
+
...(expandableRowComponent ? {} : { getExpandedRowModel: getExpandedRowModel() }),
|
|
135
|
+
...(showPagination ? { getPaginationRowModel: getPaginationRowModel() } : {}),
|
|
52
136
|
manualPagination: isManualPaginated,
|
|
53
|
-
pageCount: manualPaginationPageCount,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
autoResetSortBy: false,
|
|
59
|
-
selectSubRows,
|
|
137
|
+
pageCount: isManualPaginated ? manualPaginationPageCount : undefined,
|
|
138
|
+
manualSorting: isManualSorted,
|
|
139
|
+
enableMultiSort: false,
|
|
140
|
+
enableSubRowSelection: selectSubRows,
|
|
141
|
+
autoResetPageIndex: false,
|
|
60
142
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
143
|
+
* Deliberately left at its default (unset): forcing
|
|
144
|
+
* `paginateExpandedRows: false` prevents expanded rows from spilling
|
|
145
|
+
* into the next page, but it also breaks row selection. Do not
|
|
146
|
+
* re-introduce that regression.
|
|
64
147
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
pageIndex: initialPageIndex,
|
|
68
|
-
pageSize: showPagination ? itemsPerPage : computePageSize(),
|
|
69
|
-
hiddenColumns: getHiddenColumns(),
|
|
70
|
-
selectedRowIds: selectedRowIds.reduce((acc, curr) => ({
|
|
71
|
-
...acc,
|
|
72
|
-
[curr]: true,
|
|
73
|
-
}), {}),
|
|
148
|
+
state: {
|
|
149
|
+
sorting, expanded, pagination, columnVisibility, rowSelection,
|
|
74
150
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
Header: ({ getToggleAllPageRowsSelectedProps }) => (_jsx(TableCheckbox, { ...getToggleAllPageRowsSelectedProps() })),
|
|
81
|
-
Cell: ({ row }) => _jsx(TableCheckbox, { ...row.getToggleRowSelectedProps() }),
|
|
82
|
-
}];
|
|
83
|
-
const expanderColumn = [{
|
|
84
|
-
id: 'expander',
|
|
85
|
-
isToggable: true,
|
|
86
|
-
expander: true,
|
|
87
|
-
minWidth: 40,
|
|
88
|
-
align: 'center',
|
|
89
|
-
Cell: ({ row }) => (row.canExpand
|
|
90
|
-
? (_jsx(ToggleButton, { kind: "flat", dimension: "small", restingIcon: "chevron-right", pressedIcon: "chevron-down", ...row.getToggleRowExpandedProps(), pressed: row.isExpanded, onClick: () => {
|
|
91
|
-
const subRowsExpanded = row.subRows.filter(r => r.isExpanded);
|
|
92
|
-
subRowsExpanded.forEach(r => r.toggleRowExpanded(!r.isExpanded));
|
|
93
|
-
row.toggleRowExpanded(!row.isExpanded);
|
|
94
|
-
onRowExpandChange?.(row);
|
|
95
|
-
} }))
|
|
96
|
-
: null),
|
|
97
|
-
}];
|
|
98
|
-
hooks.visibleColumns.push(columns => [
|
|
99
|
-
...checkboxColumn,
|
|
100
|
-
...expanderColumn,
|
|
101
|
-
...columns,
|
|
102
|
-
]);
|
|
151
|
+
onSortingChange: setSorting,
|
|
152
|
+
onExpandedChange: setExpanded,
|
|
153
|
+
onPaginationChange: setPagination,
|
|
154
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
155
|
+
onRowSelectionChange: setRowSelection,
|
|
103
156
|
});
|
|
104
157
|
useUpdateEffect(() => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
158
|
+
setColumnVisibility(getHiddenColumns().reduce((acc, id) => ({ ...acc, [id]: false }), {}));
|
|
159
|
+
}, [getHiddenColumns]);
|
|
160
|
+
const selectedRowIdsKey = useMemo(() => [...selectedRowIds].sort((a, b) => (a < b ? -1 : Number(a > b))).join('\u0000'), [selectedRowIds]);
|
|
161
|
+
/**
|
|
162
|
+
* Honors external changes to `selectedRowIds` made *after* mount (e.g. a
|
|
163
|
+
* "Clear selection" button), independently of `persistSelectionAcrossPages`.
|
|
164
|
+
* `react-table` v7 only ever seeded `selectedRowIds` into `initialState`,
|
|
165
|
+
* silently ignoring later prop updates — this fixes that in both modes.
|
|
166
|
+
*/
|
|
167
|
+
useUpdateEffect(() => {
|
|
168
|
+
setRowSelection(arrayToRowSelection(selectedRowIds));
|
|
169
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
|
+
}, [selectedRowIdsKey]);
|
|
171
|
+
/**
|
|
172
|
+
* Default behavior: clear selection whenever `data` changes (matching
|
|
173
|
+
* `Table`'s historical behavior). Opting into `persistSelectionAcrossPages`
|
|
174
|
+
* skips this, so a consumer-owned superset selection list survives page
|
|
175
|
+
* navigations for manual/server pagination.
|
|
176
|
+
*/
|
|
177
|
+
useUpdateEffect(() => {
|
|
178
|
+
if (persistSelectionAcrossPages)
|
|
179
|
+
return;
|
|
180
|
+
setRowSelection({});
|
|
181
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
182
|
+
}, [data]);
|
|
111
183
|
useUpdateEffect(() => {
|
|
112
|
-
onSelectedRowsChange?.(Object.keys(
|
|
113
|
-
}, [
|
|
114
|
-
selectedRowIdsState,
|
|
115
|
-
onSelectedRowsChange,
|
|
116
|
-
]);
|
|
184
|
+
onSelectedRowsChange?.(Object.keys(rowSelection));
|
|
185
|
+
}, [rowSelection, onSelectedRowsChange]);
|
|
117
186
|
useUpdateEffect(() => {
|
|
118
|
-
onSortChange?.(
|
|
119
|
-
}, [
|
|
187
|
+
onSortChange?.(sorting);
|
|
188
|
+
}, [sorting, onSortChange]);
|
|
120
189
|
useUpdateEffect(() => {
|
|
121
|
-
void onPaginationChange?.({ pageIndex, pageSize });
|
|
122
|
-
}, [onPaginationChange, pageIndex, pageSize]);
|
|
190
|
+
void onPaginationChange?.({ pageIndex: pagination.pageIndex, pageSize: pagination.pageSize });
|
|
191
|
+
}, [onPaginationChange, pagination.pageIndex, pagination.pageSize]);
|
|
192
|
+
const pageCount = table.getPageCount();
|
|
123
193
|
useEffect(() => {
|
|
124
|
-
if (pageIndex >= pageCount) {
|
|
125
|
-
|
|
194
|
+
if (pagination.pageIndex >= pageCount) {
|
|
195
|
+
table.setPageIndex(0);
|
|
126
196
|
}
|
|
127
|
-
}, [pageCount, pageIndex,
|
|
128
|
-
const rowEntries =
|
|
129
|
-
const
|
|
130
|
-
|
|
197
|
+
}, [pageCount, pagination.pageIndex, table]);
|
|
198
|
+
const rowEntries = table.getRowModel().rows;
|
|
199
|
+
const allColumns = table.getAllLeafColumns();
|
|
200
|
+
/**
|
|
201
|
+
* `table` is a new object every render (TanStack memoizes row/column
|
|
202
|
+
* model *computations* internally, not the `table` instance itself), so
|
|
203
|
+
* wrapping these in `useMemo` keyed on `table` would recompute every
|
|
204
|
+
* render anyway — they're cheap array filters, just derive them directly.
|
|
205
|
+
*/
|
|
206
|
+
const filteredVisibleColumns = table.getVisibleLeafColumns()
|
|
207
|
+
.filter(col => !col.columnDef.meta?.isToggable);
|
|
208
|
+
const columnVisibilityKey = table.getVisibleLeafColumns().map(col => col.id).join('|');
|
|
209
|
+
const expandedRowsKey = hasSomeExpandableRows
|
|
210
|
+
? table.getPrePaginationRowModel().rows
|
|
211
|
+
.filter(row => row.getCanExpand() && row.getIsExpanded())
|
|
212
|
+
.map(r => r.id)
|
|
213
|
+
.join('|')
|
|
214
|
+
: '';
|
|
131
215
|
const dynamicStyle = {
|
|
132
216
|
'--table-height': height,
|
|
133
217
|
'--table-background': background,
|
|
134
218
|
};
|
|
135
|
-
return (_jsxs("div", { className: clsx(styles.Table, className), style: { ...dynamicStyle, ...style }, children: [_jsx(AnimatePresence, { children: _jsxs(LazyMotion, { features:
|
|
219
|
+
return (_jsxs("div", { className: clsx(styles.Table, className), style: { ...dynamicStyle, ...style }, children: [_jsx(AnimatePresence, { children: _jsxs(LazyMotion, { features: domAnimation, children: [!!Object.keys(rowSelection).length && selectableRows && (_jsxs(Stack, { as: m.div, className: styles.Toast, direction: "row", hAlign: "space-between", vAlign: "center", hPadding: 16, vPadding: 8, fill: false, columnGap: 16, initial: { y: '-16px', opacity: 0 }, animate: {
|
|
136
220
|
y: 0,
|
|
137
221
|
opacity: 1,
|
|
138
222
|
transition: {
|
|
@@ -140,9 +224,9 @@ export const Table = ({ className, style, columns, data = [], selectableRows, se
|
|
|
140
224
|
stiffness: 700,
|
|
141
225
|
damping: 30,
|
|
142
226
|
},
|
|
143
|
-
}, exit: { y: '-16px', opacity: 0 }, children: [_jsx(Text, { as: "span", variant: "body-1", children: _jsx("b", { children: selectedLabel(Object.keys(
|
|
144
|
-
y: Object.keys(
|
|
145
|
-
opacity: Object.keys(
|
|
227
|
+
}, exit: { y: '-16px', opacity: 0 }, children: [_jsx(Text, { as: "span", variant: "body-1", children: _jsx("b", { children: selectedLabel(Object.keys(rowSelection)) }) }), selectedActions?.(Object.keys(rowSelection))] })), (showHeader || selectableRows) && (_jsx(m.div, { animate: {
|
|
228
|
+
y: Object.keys(rowSelection).length ? 20 : 0,
|
|
229
|
+
opacity: Object.keys(rowSelection).length ? 0 : 1,
|
|
146
230
|
transition: {
|
|
147
231
|
type: 'spring',
|
|
148
232
|
stiffness: 700,
|
|
@@ -151,11 +235,12 @@ export const Table = ({ className, style, columns, data = [], selectableRows, se
|
|
|
151
235
|
}, children: _jsxs(TableHeader, { title: title, children: [(columnsControl && data.length)
|
|
152
236
|
? (_jsx(ToggleColumnsControl, { columns: allColumns, visibleColumns: filteredVisibleColumns }))
|
|
153
237
|
: null, actions] }) }))] }) }), ((data.length || loading) && filteredVisibleColumns.length)
|
|
154
|
-
? (_jsx("div", { className: styles.TableWrapper, "data-table-scrolling": Boolean(height), children: _jsxs("table", { className: styles.TableElement, "data-table-stripes": stripes, "data-table-separators": showSeparators, "data-table-loading": loading, "aria-labelledby": uid('table-title'), ...
|
|
238
|
+
? (_jsx("div", { className: styles.TableWrapper, "data-table-scrolling": Boolean(height), children: _jsxs("table", { className: styles.TableElement, "data-table-stripes": stripes, "data-table-separators": showSeparators, "data-table-loading": loading, "aria-labelledby": uid('table-title'), ...otherProps, children: [showTableHead && (_jsx("thead", { className: styles.THead, children: table.getHeaderGroups().map(headerGroup => (_jsx(TableRow, { children: headerGroup.headers.map(header => (_jsx(TableCell, { as: "th", width: header.column.columnDef.meta?.minWidth === 0
|
|
239
|
+
? undefined
|
|
240
|
+
: header.column.columnDef.meta?.minWidth, collapsed: header.column.columnDef.meta?.isCollapsed, isSorted: Boolean(header.column.getIsSorted()), isSortedDesc: header.column.getIsSorted() === 'desc', align: header.column.columnDef.meta?.align, onClick: header.column.getToggleSortingHandler(), children: header.isPlaceholder
|
|
241
|
+
? null
|
|
242
|
+
: flexRender(header.column.columnDef.header, header.getContext()) }, header.id))) }, headerGroup.id))) })), _jsx("tbody", { children: loading
|
|
155
243
|
? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 100, children: _jsx(Skeleton, { gap: 16, height: 24, count: 10 }) }) }))
|
|
156
|
-
: rowEntries.map((row)
|
|
157
|
-
|
|
158
|
-
return (_jsxs(Fragment, { children: [_jsx(TableRow, { ...row.getRowProps(), expanded: (row.isExpanded && !row.subRows.some(subrow => subrow.isExpanded && subrow.canExpand)), rowData: row, expandedRows: expandedRows, children: row.cells.map((cell) => (_jsx(TableCell, { collapsed: cell.column.isCollapsed, width: cell.column.minWidth === 0 ? undefined : cell.column.minWidth, align: cell.column.align, ...cell.getCellProps(), children: cell.render('Cell') }))) }), (row.subRows && row.isExpanded && expandableRowComponent) && row.subRows.map(subRow => (_jsx(TableRow, { "data-table-row-expander": true, children: _jsx(TableCell, { padding: false, colSpan: 100, children: _jsx(TableExpand, { data: subRow.original, component: expandableRowComponent }) }) }, subRow.id)))] }, row.id));
|
|
159
|
-
}) })] }) }))
|
|
160
|
-
: (_jsx(Stack, { vAlign: "center", hAlign: "center", children: emptyComponent ?? 'No data' })), (showPagination && filteredVisibleColumns.length > 0 && !!rows.length) && (_jsx(TablePagination, { clusters: pageClusters, pageSize: pageSize, totalItems: totalRows ?? rows.length, currentPage: pageIndex, totalPages: pageCount, isManual: Boolean(isManualPaginated && totalRows), onPageSizeChange: setPageSize, onPageClick: selected => gotoPage(selected) }))] }));
|
|
244
|
+
: rowEntries.map(row => (_jsx(TableBodyRow, { row: row, expandedRowsKey: expandedRowsKey, expandableRowComponent: expandableRowComponent, isRowSelected: row.getIsSelected(), isRowExpanded: row.getIsExpanded(), columnVisibilityKey: columnVisibilityKey }, row.id))) })] }) }))
|
|
245
|
+
: (_jsx(Stack, { vAlign: "center", hAlign: "center", children: emptyComponent ?? 'No data' })), (showPagination && filteredVisibleColumns.length > 0 && !!rowEntries.length) && (_jsx(TablePagination, { clusters: pageClusters, pageSize: pagination.pageSize, totalItems: totalRows ?? table.getPrePaginationRowModel().rows.length, currentPage: pagination.pageIndex, totalPages: pageCount, isManual: Boolean(isManualPaginated && totalRows), onPageSizeChange: table.setPageSize, onPageClick: selected => table.setPageIndex(selected) }))] }));
|
|
161
246
|
};
|
|
@@ -3,20 +3,21 @@ import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
|
3
3
|
import { Table } from './table';
|
|
4
4
|
declare const story: ComponentMeta<typeof Table>;
|
|
5
5
|
export default story;
|
|
6
|
-
export declare const Simple: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
7
|
-
export declare const SelectedRows: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
8
|
-
export declare const HidingColumn: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
9
|
-
export declare const defaultHiddenColumns: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
10
|
-
export declare const Scrollable: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
11
|
-
export declare const WithTableActions: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
12
|
-
export declare const CustomExpandable: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
13
|
-
export declare const Pagination: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
14
|
-
export declare const RowActions: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
15
|
-
export declare const NoData: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
16
|
-
export declare const ManualPagination: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
17
|
-
export declare const
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
6
|
+
export declare const Simple: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
7
|
+
export declare const SelectedRows: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
8
|
+
export declare const HidingColumn: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
9
|
+
export declare const defaultHiddenColumns: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
10
|
+
export declare const Scrollable: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
11
|
+
export declare const WithTableActions: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
12
|
+
export declare const CustomExpandable: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
13
|
+
export declare const Pagination: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
14
|
+
export declare const RowActions: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
15
|
+
export declare const NoData: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
16
|
+
export declare const ManualPagination: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
17
|
+
export declare const ManualPaginationWithoutPersistence: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
18
|
+
export declare const Loading: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
19
|
+
export declare const ManualSorting: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
20
|
+
export declare const ManualPaginationFiltering: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
21
|
+
export declare const PreselectedRows: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
22
|
+
export declare const AsyncData: ComponentStory<(<T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, selectedRowIds, onSelectedRowsChange, persistSelectionAcrossPages, getRowId, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, onRowExpandChange, selectSubRows, ...otherProps }: import("./table").TableProps<T>) => JSX.Element)>;
|
|
22
23
|
//# sourceMappingURL=table.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.stories.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.stories.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAWhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAetC,CAAC;AAEF,eAAe,KAAK,CAAC;AAgCrB,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"table.stories.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.stories.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAWhC,QAAA,MAAM,KAAK,EAAE,aAAa,CAAC,OAAO,KAAK,CAetC,CAAC;AAEF,eAAe,KAAK,CAAC;AAgCrB,eAAO,MAAM,MAAM,mnBAAoB,CAAC;AA0BxC,eAAO,MAAM,YAAY,mnBAA6B,CAAC;AAwCvD,eAAO,MAAM,YAAY,mnBAAgC,CAAC;AAM1D,eAAO,MAAM,oBAAoB,mnBAAoB,CAAC;AAOtD,eAAO,MAAM,UAAU,mnBAAoB,CAAC;AAS5C,eAAO,MAAM,gBAAgB,mnBAAoB,CAAC;AAQlD,eAAO,MAAM,gBAAgB,mnBAAoB,CAAC;AAQlD,eAAO,MAAM,UAAU,mnBAA6B,CAAC;AAuDrD,eAAO,MAAM,UAAU,mnBAA8B,CAAC;AAOtD,eAAO,MAAM,MAAM,mnBAAoB,CAAC;AAoDxC,eAAO,MAAM,gBAAgB,mnBAAoC,CAAC;AAgBlE,eAAO,MAAM,kCAAkC,mnBAAoC,CAAC;AAcpF,eAAO,MAAM,OAAO,mnBAAoB,CAAC;AAyDzC,eAAO,MAAM,aAAa,mnBAAiC,CAAC;AAmD5D,eAAO,MAAM,yBAAyB,mnBAA6C,CAAC;AAkCpF,eAAO,MAAM,eAAe,mnBAAmC,CAAC;AAmChE,eAAO,MAAM,SAAS,mnBAA6B,CAAC"}
|
|
@@ -169,6 +169,26 @@ ManualPagination.args = {
|
|
|
169
169
|
selectableRows: true,
|
|
170
170
|
showPagination: true,
|
|
171
171
|
itemsPerPage: 5,
|
|
172
|
+
/**
|
|
173
|
+
* Without this flag, `Table` would clear its selection every time
|
|
174
|
+
* `data` changes (i.e. every page navigation, since this story
|
|
175
|
+
* fetches a fresh slice per page). This story owns a superset
|
|
176
|
+
* `selectedRowIds` list across pages, so it opts in to persistence.
|
|
177
|
+
*/
|
|
178
|
+
persistSelectionAcrossPages: true,
|
|
179
|
+
};
|
|
180
|
+
export const ManualPaginationWithoutPersistence = ManualPaginationTemplate.bind({});
|
|
181
|
+
ManualPaginationWithoutPersistence.args = {
|
|
182
|
+
columnsControl: true,
|
|
183
|
+
showHeader: true,
|
|
184
|
+
selectableRows: true,
|
|
185
|
+
showPagination: true,
|
|
186
|
+
itemsPerPage: 5,
|
|
187
|
+
/**
|
|
188
|
+
* `persistSelectionAcrossPages` is omitted (defaults to `false`): flip
|
|
189
|
+
* to a different page and the selection resets, since `data` changes
|
|
190
|
+
* on every manual page fetch. Contrast with `ManualPagination`.
|
|
191
|
+
*/
|
|
172
192
|
};
|
|
173
193
|
export const Loading = Template.bind({});
|
|
174
194
|
Loading.args = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
2
|
//# sourceMappingURL=table.test.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.test.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.test.tsx"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"table.test.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.test.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|