@redsift/table 12.5.4-muiv8-alpha.1 → 12.5.4
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/_internal/StatefulDataGrid2.js +44 -12
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/index.d.ts +10 -0
- package/index.js +81 -11
- package/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -2372,8 +2372,13 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2372
2372
|
const decompressedSearch = decompressSearchParams(search);
|
|
2373
2373
|
// Convert from display format (dot notation) to internal format (bracket notation) if needed
|
|
2374
2374
|
const decodedSearch = getDecodedSearchFromUrl(decompressedSearch, columns);
|
|
2375
|
-
const
|
|
2376
|
-
const
|
|
2375
|
+
const decodedParams = new URLSearchParams(decodedSearch);
|
|
2376
|
+
const currentVersion = decodedParams.get('v');
|
|
2377
|
+
// Only treat as "new version reset" when the URL has params with a stale/missing version.
|
|
2378
|
+
// An empty URL should fall through to the localStorage branch of each getter so persisted
|
|
2379
|
+
// state is restored instead of being clobbered by defaults.
|
|
2380
|
+
const hasUrlState = Array.from(decodedParams.keys()).length > 0;
|
|
2381
|
+
const isNewVersion = hasUrlState && (!currentVersion || Number(currentVersion) !== localStorageVersion);
|
|
2377
2382
|
const {
|
|
2378
2383
|
localStorageFilters,
|
|
2379
2384
|
setLocalStorageFilters,
|
|
@@ -3310,16 +3315,6 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3310
3315
|
// The pagination model to use for display in pagination slots
|
|
3311
3316
|
const activePaginationModel = isDataSourceMode ? dataSourcePaginationModel : paginationModel;
|
|
3312
3317
|
|
|
3313
|
-
// In dataSource mode, pagination changes from our custom pagination slots
|
|
3314
|
-
// (rendered outside MUI's pagination state) must go through apiRef so MUI's
|
|
3315
|
-
// internal page state updates and dataSource.getRows() refetches with the
|
|
3316
|
-
// new params. MUI then fires onPaginationModelChange which updates URL and
|
|
3317
|
-
// local state via the wrapped handler below.
|
|
3318
|
-
const dataSourcePaginationChange = useCallback(model => {
|
|
3319
|
-
var _apiRef$current;
|
|
3320
|
-
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPaginationModel(model);
|
|
3321
|
-
}, [apiRef]);
|
|
3322
|
-
|
|
3323
3318
|
// Wrap onPaginationModelChange to also track state locally in dataSource mode
|
|
3324
3319
|
const wrappedOnPaginationModelChange = useCallback((model, details) => {
|
|
3325
3320
|
if (isDataSourceMode) {
|
|
@@ -3327,6 +3322,43 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3327
3322
|
}
|
|
3328
3323
|
onPaginationModelChange(model, details);
|
|
3329
3324
|
}, [isDataSourceMode, onPaginationModelChange]);
|
|
3325
|
+
|
|
3326
|
+
// In dataSource mode, pagination changes from our custom pagination slots
|
|
3327
|
+
// (rendered outside MUI's pagination state) route through apiRef so MUI's
|
|
3328
|
+
// internal page state updates and dataSource.getRows() refetches with the
|
|
3329
|
+
// new params. The `paginationModelChange` subscription below picks up the
|
|
3330
|
+
// resulting state change and propagates it to URL/localStorage and local
|
|
3331
|
+
// React state via wrappedOnPaginationModelChange.
|
|
3332
|
+
const dataSourcePaginationChange = useCallback(model => {
|
|
3333
|
+
var _apiRef$current;
|
|
3334
|
+
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPaginationModel(model);
|
|
3335
|
+
}, [apiRef]);
|
|
3336
|
+
|
|
3337
|
+
// In dataSource mode, subscribe to MUI's `paginationModelChange` event so
|
|
3338
|
+
// URL state stays in sync with MUI's internal pagination regardless of how
|
|
3339
|
+
// it changed (slot click, apiRef.setPaginationModel from consumer code,
|
|
3340
|
+
// MUI internal updates, etc.). Relying on MUI's `onPaginationModelChange`
|
|
3341
|
+
// prop callback alone is not sufficient: in pivot/GroupedData strategy mode
|
|
3342
|
+
// and with `paginationModel` seeded via `initialState` (rather than as a
|
|
3343
|
+
// controlled prop), the prop callback can be missed under certain
|
|
3344
|
+
// re-render orderings. The event fires reliably whenever the internal
|
|
3345
|
+
// state changes via `setState('setPaginationModel')`, see
|
|
3346
|
+
// `useGridStateInitialization.setState` → `publishEvent(changeEvent, …)`.
|
|
3347
|
+
// The deep-equal guard inside `useStatefulTable.onPaginationModelChange`
|
|
3348
|
+
// dedupes any duplicate emits, so overlap with the prop callback is safe.
|
|
3349
|
+
useEffect(() => {
|
|
3350
|
+
if (!isDataSourceMode) return;
|
|
3351
|
+
const api = apiRef.current;
|
|
3352
|
+
if (!(api !== null && api !== void 0 && api.subscribeEvent)) return;
|
|
3353
|
+
return api.subscribeEvent('paginationModelChange', model => {
|
|
3354
|
+
wrappedOnPaginationModelChange({
|
|
3355
|
+
page: model.page,
|
|
3356
|
+
pageSize: model.pageSize
|
|
3357
|
+
}, {
|
|
3358
|
+
reason: 'paginationModelChange'
|
|
3359
|
+
});
|
|
3360
|
+
});
|
|
3361
|
+
}, [isDataSourceMode, apiRef, wrappedOnPaginationModelChange]);
|
|
3330
3362
|
const [rowSelectionModel, setRowSelectionModel] = useState(() => normalizeRowSelectionModel(propsRowSelectionModel));
|
|
3331
3363
|
useEffect(() => {
|
|
3332
3364
|
setRowSelectionModel(normalizeRowSelectionModel(propsRowSelectionModel));
|