@snack-uikit/table 0.38.5 → 0.38.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/cjs/components/Table/Table.js +33 -22
- package/dist/esm/components/Table/Table.js +49 -25
- package/package.json +3 -3
- package/src/components/Table/Table.tsx +58 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.38.6 (2026-04-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **PDS-3636:** fix persist state ([78c0aad](https://github.com/cloud-ru-tech/snack-uikit/commit/78c0aadffbb178df952848a40e4dc10b0096f7ee))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.38.5 (2026-03-27)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
|
@@ -372,6 +372,38 @@ function Table(_a) {
|
|
|
372
372
|
} = (0, contexts_1.useCellAutoResizeController)(table);
|
|
373
373
|
const showToolbar = !suppressToolbar;
|
|
374
374
|
const showPagination = !infiniteLoading && !suppressPagination;
|
|
375
|
+
const tableToolbarPersistConfig = (0, react_1.useMemo)(() => {
|
|
376
|
+
if (!(savedState === null || savedState === void 0 ? void 0 : savedState.id) || !(savedState === null || savedState === void 0 ? void 0 : savedState.filterQueryKey)) {
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
id: savedState.id,
|
|
381
|
+
filterQueryKey: savedState.filterQueryKey,
|
|
382
|
+
validateData: validatePersistedState,
|
|
383
|
+
state: {
|
|
384
|
+
pagination: (0, mappers_1.mapPaginationToRequestPayload)(pagination),
|
|
385
|
+
ordering: (0, mappers_1.mapSortToRequestPayload)(sorting),
|
|
386
|
+
filter,
|
|
387
|
+
search: globalFilter || ''
|
|
388
|
+
},
|
|
389
|
+
serializer: savedState.serializer,
|
|
390
|
+
parser: savedState.parser,
|
|
391
|
+
onLoad: state => {
|
|
392
|
+
state.pagination && onPaginationChange((0, mappers_1.mapPaginationToTableState)(state.pagination));
|
|
393
|
+
state.search && onGlobalFilterChange(state.search);
|
|
394
|
+
state.ordering && onSortingChange((0, mappers_1.mapSortToTableState)(state.ordering));
|
|
395
|
+
if (state.filter) {
|
|
396
|
+
setFilter(state.filter);
|
|
397
|
+
setFilterVisibility(Object.keys(state.filter));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}, [filter, globalFilter, onGlobalFilterChange, onPaginationChange, onSortingChange, pagination, savedState === null || savedState === void 0 ? void 0 : savedState.filterQueryKey, savedState === null || savedState === void 0 ? void 0 : savedState.id, savedState === null || savedState === void 0 ? void 0 : savedState.parser, savedState === null || savedState === void 0 ? void 0 : savedState.serializer, setFilter, setFilterVisibility, sorting, validatePersistedState]);
|
|
402
|
+
(0, toolbar_1.usePersistState)({
|
|
403
|
+
persist: suppressToolbar ? tableToolbarPersistConfig : undefined,
|
|
404
|
+
filter,
|
|
405
|
+
search: suppressSearch ? undefined : globalFilter
|
|
406
|
+
});
|
|
375
407
|
const {
|
|
376
408
|
checked,
|
|
377
409
|
indeterminate
|
|
@@ -397,28 +429,7 @@ function Table(_a) {
|
|
|
397
429
|
},
|
|
398
430
|
className: styles_module_scss_1.default.toolbar,
|
|
399
431
|
onRefresh: onRefresh ? handleOnRefresh : undefined,
|
|
400
|
-
persist:
|
|
401
|
-
id: savedState.id,
|
|
402
|
-
filterQueryKey: savedState.filterQueryKey,
|
|
403
|
-
validateData: validatePersistedState,
|
|
404
|
-
state: {
|
|
405
|
-
pagination: (0, mappers_1.mapPaginationToRequestPayload)(pagination),
|
|
406
|
-
ordering: (0, mappers_1.mapSortToRequestPayload)(sorting),
|
|
407
|
-
filter,
|
|
408
|
-
search: globalFilter || ''
|
|
409
|
-
},
|
|
410
|
-
serializer: savedState.serializer,
|
|
411
|
-
parser: savedState.parser,
|
|
412
|
-
onLoad: state => {
|
|
413
|
-
state.pagination && onPaginationChange((0, mappers_1.mapPaginationToTableState)(state.pagination));
|
|
414
|
-
state.search && onGlobalFilterChange(state.search);
|
|
415
|
-
state.ordering && onSortingChange((0, mappers_1.mapSortToTableState)(state.ordering));
|
|
416
|
-
if (state.filter) {
|
|
417
|
-
setFilter(state.filter);
|
|
418
|
-
setFilterVisibility(Object.keys(state.filter));
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
} : undefined,
|
|
432
|
+
persist: showToolbar ? tableToolbarPersistConfig : undefined,
|
|
422
433
|
bulkActions: bulkActions,
|
|
423
434
|
selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single',
|
|
424
435
|
checked: checked,
|
|
@@ -17,7 +17,7 @@ import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
|
17
17
|
import { useLocale } from '@snack-uikit/locale';
|
|
18
18
|
import { Scroll } from '@snack-uikit/scroll';
|
|
19
19
|
import { SkeletonContextProvider } from '@snack-uikit/skeleton';
|
|
20
|
-
import { Toolbar } from '@snack-uikit/toolbar';
|
|
20
|
+
import { Toolbar, usePersistState, } from '@snack-uikit/toolbar';
|
|
21
21
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
22
22
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
23
23
|
import { DEFAULT_EXPANDED, DEFAULT_PAGE_SIZE, DEFAULT_ROW_SELECTION, DEFAULT_SORTING, DefaultColumns, TEST_IDS, } from '../../constants';
|
|
@@ -268,6 +268,53 @@ export function Table(_a) {
|
|
|
268
268
|
const { updateCellMap } = useCellAutoResizeController(table);
|
|
269
269
|
const showToolbar = !suppressToolbar;
|
|
270
270
|
const showPagination = !infiniteLoading && !suppressPagination;
|
|
271
|
+
const tableToolbarPersistConfig = useMemo(() => {
|
|
272
|
+
if (!(savedState === null || savedState === void 0 ? void 0 : savedState.id) || !(savedState === null || savedState === void 0 ? void 0 : savedState.filterQueryKey)) {
|
|
273
|
+
return undefined;
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
id: savedState.id,
|
|
277
|
+
filterQueryKey: savedState.filterQueryKey,
|
|
278
|
+
validateData: validatePersistedState,
|
|
279
|
+
state: {
|
|
280
|
+
pagination: mapPaginationToRequestPayload(pagination),
|
|
281
|
+
ordering: mapSortToRequestPayload(sorting),
|
|
282
|
+
filter,
|
|
283
|
+
search: globalFilter || '',
|
|
284
|
+
},
|
|
285
|
+
serializer: savedState.serializer,
|
|
286
|
+
parser: savedState.parser,
|
|
287
|
+
onLoad: state => {
|
|
288
|
+
state.pagination && onPaginationChange(mapPaginationToTableState(state.pagination));
|
|
289
|
+
state.search && onGlobalFilterChange(state.search);
|
|
290
|
+
state.ordering && onSortingChange(mapSortToTableState(state.ordering));
|
|
291
|
+
if (state.filter) {
|
|
292
|
+
setFilter(state.filter);
|
|
293
|
+
setFilterVisibility(Object.keys(state.filter));
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
}, [
|
|
298
|
+
filter,
|
|
299
|
+
globalFilter,
|
|
300
|
+
onGlobalFilterChange,
|
|
301
|
+
onPaginationChange,
|
|
302
|
+
onSortingChange,
|
|
303
|
+
pagination,
|
|
304
|
+
savedState === null || savedState === void 0 ? void 0 : savedState.filterQueryKey,
|
|
305
|
+
savedState === null || savedState === void 0 ? void 0 : savedState.id,
|
|
306
|
+
savedState === null || savedState === void 0 ? void 0 : savedState.parser,
|
|
307
|
+
savedState === null || savedState === void 0 ? void 0 : savedState.serializer,
|
|
308
|
+
setFilter,
|
|
309
|
+
setFilterVisibility,
|
|
310
|
+
sorting,
|
|
311
|
+
validatePersistedState,
|
|
312
|
+
]);
|
|
313
|
+
usePersistState({
|
|
314
|
+
persist: suppressToolbar ? tableToolbarPersistConfig : undefined,
|
|
315
|
+
filter,
|
|
316
|
+
search: suppressSearch ? undefined : globalFilter,
|
|
317
|
+
});
|
|
271
318
|
const { checked, indeterminate } = isAllRowsMode
|
|
272
319
|
? { checked: table.getIsAllRowsSelected(), indeterminate: table.getIsSomeRowsSelected() }
|
|
273
320
|
: { checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected() };
|
|
@@ -278,30 +325,7 @@ export function Table(_a) {
|
|
|
278
325
|
onChange: onGlobalFilterChange,
|
|
279
326
|
loading: search === null || search === void 0 ? void 0 : search.loading,
|
|
280
327
|
placeholder: (search === null || search === void 0 ? void 0 : search.placeholder) || t('searchPlaceholder'),
|
|
281
|
-
}, className: styles.toolbar, onRefresh: onRefresh ? handleOnRefresh : undefined, persist: (
|
|
282
|
-
? {
|
|
283
|
-
id: savedState.id,
|
|
284
|
-
filterQueryKey: savedState.filterQueryKey,
|
|
285
|
-
validateData: validatePersistedState,
|
|
286
|
-
state: {
|
|
287
|
-
pagination: mapPaginationToRequestPayload(pagination),
|
|
288
|
-
ordering: mapSortToRequestPayload(sorting),
|
|
289
|
-
filter,
|
|
290
|
-
search: globalFilter || '',
|
|
291
|
-
},
|
|
292
|
-
serializer: savedState.serializer,
|
|
293
|
-
parser: savedState.parser,
|
|
294
|
-
onLoad: state => {
|
|
295
|
-
state.pagination && onPaginationChange(mapPaginationToTableState(state.pagination));
|
|
296
|
-
state.search && onGlobalFilterChange(state.search);
|
|
297
|
-
state.ordering && onSortingChange(mapSortToTableState(state.ordering));
|
|
298
|
-
if (state.filter) {
|
|
299
|
-
setFilter(state.filter);
|
|
300
|
-
setFilterVisibility(Object.keys(state.filter));
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
}
|
|
304
|
-
: undefined, bulkActions: bulkActions, selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single', checked: checked, indeterminate: indeterminate, onCheck: enableSelection ? handleOnToolbarCheck : undefined, outline: outline, after: toolbarAfter || exportSettings || areColumnsSettingsEnabled ? (_jsxs(_Fragment, { children: [toolbarAfter, exportSettings && (_jsx(ExportButton, { settings: exportSettings, columnDefinitions: columnDefinitions, data: data, topRows: filteredTopRows, centerRows: centerRows })), areColumnsSettingsEnabled && (_jsx(ColumnsSettings, { columnsSettings: columnsSettings, enabledColumns: enabledColumns, setEnabledColumns: setEnabledColumns }))] })) : undefined, moreActions: moreActions, filterRow: patchedFilter, "data-test-id": TEST_IDS.toolbar }) })), _jsxs(Scroll, { size: 's', className: styles.table, ref: scrollContainerRef, "data-outline": outline || undefined, children: [_jsx("div", { className: styles.tableContent, style: columnSizes.vars, children: _jsx(CellAutoResizeContext.Provider, { value: { updateCellMap }, children: _jsx(DndContext, Object.assign({}, dndContextProps, { children: _jsx(TableContext.Provider, { value: { table, getRowBackgroundColor }, children: (!infiniteLoading || !data.length) && loading ? (_jsxs(SkeletonContextProvider, { loading: true, children: [_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder }), loadingTableRows.map(row => (_jsx(BodyRow, { row: row, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id)))] })) : (_jsxs(_Fragment, { children: [centerRows.length || filteredTopRows.length ? (_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag })) : null, filteredTopRows.length ? (_jsx("div", { className: styles.topRowWrapper, children: filteredTopRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: RowAppearance.HideToggler }, row.id))) })) : null, centerRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id))), data.length > 0 && infiniteLoading && loading && !dataError && (_jsx(SkeletonContextProvider, { loading: true, children: loadingTableRows.slice(0, 3).map(row => (_jsx(BodyRow, { row: row, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id))) })), _jsx(TableEmptyState, { emptyStates: emptyStates, dataError: dataError, dataFiltered: dataFiltered || Boolean(table.getState().globalFilter), tableRowsLength: tableRows.length + filteredTopRows.length })] })) }) })) }) }), _jsx("div", { className: styles.scrollStub, ref: scrollRef })] }), showPagination && (_jsx(TablePagination, { table: table, options: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.options, optionsLabel: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.optionsLabel, pageCount: pageCount, optionsRender: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.optionsRender }))] })));
|
|
328
|
+
}, className: styles.toolbar, onRefresh: onRefresh ? handleOnRefresh : undefined, persist: showToolbar ? tableToolbarPersistConfig : undefined, bulkActions: bulkActions, selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single', checked: checked, indeterminate: indeterminate, onCheck: enableSelection ? handleOnToolbarCheck : undefined, outline: outline, after: toolbarAfter || exportSettings || areColumnsSettingsEnabled ? (_jsxs(_Fragment, { children: [toolbarAfter, exportSettings && (_jsx(ExportButton, { settings: exportSettings, columnDefinitions: columnDefinitions, data: data, topRows: filteredTopRows, centerRows: centerRows })), areColumnsSettingsEnabled && (_jsx(ColumnsSettings, { columnsSettings: columnsSettings, enabledColumns: enabledColumns, setEnabledColumns: setEnabledColumns }))] })) : undefined, moreActions: moreActions, filterRow: patchedFilter, "data-test-id": TEST_IDS.toolbar }) })), _jsxs(Scroll, { size: 's', className: styles.table, ref: scrollContainerRef, "data-outline": outline || undefined, children: [_jsx("div", { className: styles.tableContent, style: columnSizes.vars, children: _jsx(CellAutoResizeContext.Provider, { value: { updateCellMap }, children: _jsx(DndContext, Object.assign({}, dndContextProps, { children: _jsx(TableContext.Provider, { value: { table, getRowBackgroundColor }, children: (!infiniteLoading || !data.length) && loading ? (_jsxs(SkeletonContextProvider, { loading: true, children: [_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder }), loadingTableRows.map(row => (_jsx(BodyRow, { row: row, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id)))] })) : (_jsxs(_Fragment, { children: [centerRows.length || filteredTopRows.length ? (_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag })) : null, filteredTopRows.length ? (_jsx("div", { className: styles.topRowWrapper, children: filteredTopRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: RowAppearance.HideToggler }, row.id))) })) : null, centerRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id))), data.length > 0 && infiniteLoading && loading && !dataError && (_jsx(SkeletonContextProvider, { loading: true, children: loadingTableRows.slice(0, 3).map(row => (_jsx(BodyRow, { row: row, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id))) })), _jsx(TableEmptyState, { emptyStates: emptyStates, dataError: dataError, dataFiltered: dataFiltered || Boolean(table.getState().globalFilter), tableRowsLength: tableRows.length + filteredTopRows.length })] })) }) })) }) }), _jsx("div", { className: styles.scrollStub, ref: scrollRef })] }), showPagination && (_jsx(TablePagination, { table: table, options: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.options, optionsLabel: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.optionsLabel, pageCount: pageCount, optionsRender: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.optionsRender }))] })));
|
|
305
329
|
}
|
|
306
330
|
Table.getStatusColumnDef = getStatusColumnDef;
|
|
307
331
|
Table.statusAppearances = STATUS_APPEARANCE;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Table",
|
|
7
|
-
"version": "0.38.
|
|
7
|
+
"version": "0.38.6",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@snack-uikit/scroll": "0.10.8",
|
|
51
51
|
"@snack-uikit/skeleton": "0.6.10",
|
|
52
52
|
"@snack-uikit/toggles": "0.13.26",
|
|
53
|
-
"@snack-uikit/toolbar": "0.14.
|
|
53
|
+
"@snack-uikit/toolbar": "0.14.23",
|
|
54
54
|
"@snack-uikit/truncate-string": "0.7.11",
|
|
55
55
|
"@snack-uikit/typography": "0.8.12",
|
|
56
56
|
"@snack-uikit/utils": "4.0.1",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@snack-uikit/locale": "*"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "eafd443c52a24f8ef917b78df60ff5ce2137a728"
|
|
69
69
|
}
|
|
@@ -21,7 +21,13 @@ import { FiltersState } from '@snack-uikit/chips';
|
|
|
21
21
|
import { useLocale } from '@snack-uikit/locale';
|
|
22
22
|
import { Scroll } from '@snack-uikit/scroll';
|
|
23
23
|
import { SkeletonContextProvider } from '@snack-uikit/skeleton';
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
type PersistedFilterState,
|
|
26
|
+
Toolbar,
|
|
27
|
+
type ToolbarPersistConfig,
|
|
28
|
+
ToolbarProps,
|
|
29
|
+
usePersistState,
|
|
30
|
+
} from '@snack-uikit/toolbar';
|
|
25
31
|
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
26
32
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
27
33
|
|
|
@@ -440,6 +446,56 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
|
|
|
440
446
|
const showToolbar = !suppressToolbar;
|
|
441
447
|
const showPagination = !infiniteLoading && !suppressPagination;
|
|
442
448
|
|
|
449
|
+
const tableToolbarPersistConfig = useMemo((): ToolbarPersistConfig<TFilters> | undefined => {
|
|
450
|
+
if (!savedState?.id || !savedState?.filterQueryKey) {
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return {
|
|
455
|
+
id: savedState.id,
|
|
456
|
+
filterQueryKey: savedState.filterQueryKey,
|
|
457
|
+
validateData: validatePersistedState,
|
|
458
|
+
state: {
|
|
459
|
+
pagination: mapPaginationToRequestPayload(pagination),
|
|
460
|
+
ordering: mapSortToRequestPayload(sorting),
|
|
461
|
+
filter,
|
|
462
|
+
search: globalFilter || '',
|
|
463
|
+
},
|
|
464
|
+
serializer: savedState.serializer,
|
|
465
|
+
parser: savedState.parser,
|
|
466
|
+
onLoad: state => {
|
|
467
|
+
state.pagination && onPaginationChange(mapPaginationToTableState(state.pagination));
|
|
468
|
+
state.search && onGlobalFilterChange(state.search);
|
|
469
|
+
state.ordering && onSortingChange(mapSortToTableState(state.ordering));
|
|
470
|
+
if (state.filter) {
|
|
471
|
+
setFilter(state.filter as TFilters);
|
|
472
|
+
setFilterVisibility(Object.keys(state.filter));
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
};
|
|
476
|
+
}, [
|
|
477
|
+
filter,
|
|
478
|
+
globalFilter,
|
|
479
|
+
onGlobalFilterChange,
|
|
480
|
+
onPaginationChange,
|
|
481
|
+
onSortingChange,
|
|
482
|
+
pagination,
|
|
483
|
+
savedState?.filterQueryKey,
|
|
484
|
+
savedState?.id,
|
|
485
|
+
savedState?.parser,
|
|
486
|
+
savedState?.serializer,
|
|
487
|
+
setFilter,
|
|
488
|
+
setFilterVisibility,
|
|
489
|
+
sorting,
|
|
490
|
+
validatePersistedState,
|
|
491
|
+
]);
|
|
492
|
+
|
|
493
|
+
usePersistState<TFilters>({
|
|
494
|
+
persist: suppressToolbar ? tableToolbarPersistConfig : undefined,
|
|
495
|
+
filter,
|
|
496
|
+
search: suppressSearch ? undefined : globalFilter,
|
|
497
|
+
});
|
|
498
|
+
|
|
443
499
|
const { checked, indeterminate } = isAllRowsMode
|
|
444
500
|
? { checked: table.getIsAllRowsSelected(), indeterminate: table.getIsSomeRowsSelected() }
|
|
445
501
|
: { checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected() };
|
|
@@ -465,32 +521,7 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
|
|
|
465
521
|
}
|
|
466
522
|
className={styles.toolbar}
|
|
467
523
|
onRefresh={onRefresh ? handleOnRefresh : undefined}
|
|
468
|
-
persist={
|
|
469
|
-
savedState?.id && savedState?.filterQueryKey
|
|
470
|
-
? {
|
|
471
|
-
id: savedState.id,
|
|
472
|
-
filterQueryKey: savedState.filterQueryKey,
|
|
473
|
-
validateData: validatePersistedState,
|
|
474
|
-
state: {
|
|
475
|
-
pagination: mapPaginationToRequestPayload(pagination),
|
|
476
|
-
ordering: mapSortToRequestPayload(sorting),
|
|
477
|
-
filter,
|
|
478
|
-
search: globalFilter || '',
|
|
479
|
-
},
|
|
480
|
-
serializer: savedState.serializer,
|
|
481
|
-
parser: savedState.parser,
|
|
482
|
-
onLoad: state => {
|
|
483
|
-
state.pagination && onPaginationChange(mapPaginationToTableState(state.pagination));
|
|
484
|
-
state.search && onGlobalFilterChange(state.search);
|
|
485
|
-
state.ordering && onSortingChange(mapSortToTableState(state.ordering));
|
|
486
|
-
if (state.filter) {
|
|
487
|
-
setFilter(state.filter as TFilters);
|
|
488
|
-
setFilterVisibility(Object.keys(state.filter));
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
}
|
|
492
|
-
: undefined
|
|
493
|
-
}
|
|
524
|
+
persist={showToolbar ? tableToolbarPersistConfig : undefined}
|
|
494
525
|
bulkActions={bulkActions}
|
|
495
526
|
selectionMode={rowSelectionProp?.multiRow ? 'multiple' : 'single'}
|
|
496
527
|
checked={checked}
|