@redsift/table 12.5.4-muiv8-alpha.4 → 12.5.5-alpha.2
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/StatefulDataGrid.js +1 -1
- package/_internal/StatefulDataGrid2.js +84 -22
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/index.d.ts +29 -1
- package/index.js +82 -12
- package/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aJ as StatefulDataGrid } from './StatefulDataGrid2.js';
|
|
2
2
|
//# sourceMappingURL=StatefulDataGrid.js.map
|
|
@@ -2289,6 +2289,29 @@ const getSearchParamsFromPivotActive = active => {
|
|
|
2289
2289
|
searchParams.set('_pivotActive', String(active));
|
|
2290
2290
|
return searchParams;
|
|
2291
2291
|
};
|
|
2292
|
+
|
|
2293
|
+
/**
|
|
2294
|
+
* Builds the `v=<version>` search param the grid uses to detect stale URLs.
|
|
2295
|
+
*
|
|
2296
|
+
* Use this when constructing a deep link or share URL outside the grid (e.g. via
|
|
2297
|
+
* `getSearchParamsFromFilterModel` + `buildQueryParamsString`). The grid itself
|
|
2298
|
+
* always includes `v` in URLs it writes via `getFinalSearch`, but external helpers
|
|
2299
|
+
* do not — include this when you want a stale `localStorageVersion` bump to invalidate
|
|
2300
|
+
* the link. Omitting `v` is also safe: a missing `v` is treated as "current version"
|
|
2301
|
+
* and the URL state is applied as-is.
|
|
2302
|
+
*
|
|
2303
|
+
* @example
|
|
2304
|
+
* const params = new URLSearchParams([
|
|
2305
|
+
* ...getSearchParamsFromFilterModel(filterModel),
|
|
2306
|
+
* ...getSearchParamsFromVersion(1),
|
|
2307
|
+
* ]);
|
|
2308
|
+
* const url = `/my-grid${buildQueryParamsString(urlSearchParamsToString(params))}`;
|
|
2309
|
+
*/
|
|
2310
|
+
const getSearchParamsFromVersion = version => {
|
|
2311
|
+
const searchParams = new URLSearchParams();
|
|
2312
|
+
searchParams.set('v', String(version));
|
|
2313
|
+
return searchParams;
|
|
2314
|
+
};
|
|
2292
2315
|
const getPivotActive = (search, localStoragePivotActive, setLocalStoragePivotActive, initialState, isNewVersion) => {
|
|
2293
2316
|
var _initialState$pivotin2, _initialState$pivotin3;
|
|
2294
2317
|
const defaultValue = (_initialState$pivotin2 = initialState === null || initialState === void 0 ? void 0 : (_initialState$pivotin3 = initialState.pivoting) === null || _initialState$pivotin3 === void 0 ? void 0 : _initialState$pivotin3.enabled) !== null && _initialState$pivotin2 !== void 0 ? _initialState$pivotin2 : false;
|
|
@@ -2372,8 +2395,23 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2372
2395
|
const decompressedSearch = decompressSearchParams(search);
|
|
2373
2396
|
// Convert from display format (dot notation) to internal format (bracket notation) if needed
|
|
2374
2397
|
const decodedSearch = getDecodedSearchFromUrl(decompressedSearch, columns);
|
|
2375
|
-
const
|
|
2376
|
-
const
|
|
2398
|
+
const decodedParams = new URLSearchParams(decodedSearch);
|
|
2399
|
+
const currentVersion = decodedParams.get('v');
|
|
2400
|
+
// Only treat as "new version reset" when the URL carries params AND explicitly declares a
|
|
2401
|
+
// stale version (`v=` present but not matching `localStorageVersion`).
|
|
2402
|
+
//
|
|
2403
|
+
// Two cases that must NOT trigger a reset:
|
|
2404
|
+
// 1. Empty URL — fall through to the localStorage branch of each getter so persisted
|
|
2405
|
+
// preferences are restored instead of being clobbered by defaults.
|
|
2406
|
+
// 2. URL has params but no `v` — externally-constructed deep links / share links built
|
|
2407
|
+
// with `getSearchParamsFromFilterModel`, `buildQueryParamsString`, etc. do not include
|
|
2408
|
+
// `v` by default. Treating a missing `v` as "stale" silently discards the very state
|
|
2409
|
+
// the integrator just encoded into the URL (and wipes localStorage on the way out).
|
|
2410
|
+
// A missing `v` is interpreted as "current" so external URLs work out of the box.
|
|
2411
|
+
// URLs written by the grid itself (`getFinalSearch`) always include `v`, so a stale
|
|
2412
|
+
// bookmark from a previous `localStorageVersion` still resets correctly.
|
|
2413
|
+
const hasUrlState = Array.from(decodedParams.keys()).length > 0;
|
|
2414
|
+
const isNewVersion = hasUrlState && currentVersion != null && Number(currentVersion) !== localStorageVersion;
|
|
2377
2415
|
const {
|
|
2378
2416
|
localStorageFilters,
|
|
2379
2417
|
setLocalStorageFilters,
|
|
@@ -3319,23 +3357,41 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3319
3357
|
}, [isDataSourceMode, onPaginationModelChange]);
|
|
3320
3358
|
|
|
3321
3359
|
// In dataSource mode, pagination changes from our custom pagination slots
|
|
3322
|
-
// (rendered outside MUI's pagination state)
|
|
3323
|
-
//
|
|
3324
|
-
//
|
|
3325
|
-
//
|
|
3326
|
-
//
|
|
3327
|
-
// because in pivot/GroupedData strategy mode (and with paginationModel
|
|
3328
|
-
// passed via initialState rather than as a controlled prop) MUI does
|
|
3329
|
-
// not consistently fire the prop callback. The deep-equal guard in
|
|
3330
|
-
// useStatefulTable.onPaginationModelChange dedupes any re-emit MUI
|
|
3331
|
-
// does fire, so this is safe to call unconditionally.
|
|
3360
|
+
// (rendered outside MUI's pagination state) route through apiRef so MUI's
|
|
3361
|
+
// internal page state updates and dataSource.getRows() refetches with the
|
|
3362
|
+
// new params. The `paginationModelChange` subscription below picks up the
|
|
3363
|
+
// resulting state change and propagates it to URL/localStorage and local
|
|
3364
|
+
// React state via wrappedOnPaginationModelChange.
|
|
3332
3365
|
const dataSourcePaginationChange = useCallback(model => {
|
|
3333
3366
|
var _apiRef$current;
|
|
3334
3367
|
(_apiRef$current = apiRef.current) === null || _apiRef$current === void 0 ? void 0 : _apiRef$current.setPaginationModel(model);
|
|
3335
|
-
|
|
3336
|
-
|
|
3368
|
+
}, [apiRef]);
|
|
3369
|
+
|
|
3370
|
+
// In dataSource mode, subscribe to MUI's `paginationModelChange` event so
|
|
3371
|
+
// URL state stays in sync with MUI's internal pagination regardless of how
|
|
3372
|
+
// it changed (slot click, apiRef.setPaginationModel from consumer code,
|
|
3373
|
+
// MUI internal updates, etc.). Relying on MUI's `onPaginationModelChange`
|
|
3374
|
+
// prop callback alone is not sufficient: in pivot/GroupedData strategy mode
|
|
3375
|
+
// and with `paginationModel` seeded via `initialState` (rather than as a
|
|
3376
|
+
// controlled prop), the prop callback can be missed under certain
|
|
3377
|
+
// re-render orderings. The event fires reliably whenever the internal
|
|
3378
|
+
// state changes via `setState('setPaginationModel')`, see
|
|
3379
|
+
// `useGridStateInitialization.setState` → `publishEvent(changeEvent, …)`.
|
|
3380
|
+
// The deep-equal guard inside `useStatefulTable.onPaginationModelChange`
|
|
3381
|
+
// dedupes any duplicate emits, so overlap with the prop callback is safe.
|
|
3382
|
+
useEffect(() => {
|
|
3383
|
+
if (!isDataSourceMode) return;
|
|
3384
|
+
const api = apiRef.current;
|
|
3385
|
+
if (!(api !== null && api !== void 0 && api.subscribeEvent)) return;
|
|
3386
|
+
return api.subscribeEvent('paginationModelChange', model => {
|
|
3387
|
+
wrappedOnPaginationModelChange({
|
|
3388
|
+
page: model.page,
|
|
3389
|
+
pageSize: model.pageSize
|
|
3390
|
+
}, {
|
|
3391
|
+
reason: 'paginationModelChange'
|
|
3392
|
+
});
|
|
3337
3393
|
});
|
|
3338
|
-
}, [apiRef, wrappedOnPaginationModelChange]);
|
|
3394
|
+
}, [isDataSourceMode, apiRef, wrappedOnPaginationModelChange]);
|
|
3339
3395
|
const [rowSelectionModel, setRowSelectionModel] = useState(() => normalizeRowSelectionModel(propsRowSelectionModel));
|
|
3340
3396
|
useEffect(() => {
|
|
3341
3397
|
setRowSelectionModel(normalizeRowSelectionModel(propsRowSelectionModel));
|
|
@@ -3522,7 +3578,6 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3522
3578
|
onColumnWidthChange: onColumnWidthChange,
|
|
3523
3579
|
onRowGroupingModelChange: onRowGroupingModelChange,
|
|
3524
3580
|
onAggregationModelChange: onAggregationModelChange,
|
|
3525
|
-
pivotModel: pivotModel,
|
|
3526
3581
|
onPivotModelChange: onPivotModelChange,
|
|
3527
3582
|
pivotActive: pivotActive,
|
|
3528
3583
|
onPivotActiveChange: onPivotActiveChange
|
|
@@ -3530,11 +3585,16 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3530
3585
|
// onChange handlers are write-only for URL/localStorage persistence,
|
|
3531
3586
|
// and initialState seeds MUI on mount from the persisted URL state.
|
|
3532
3587
|
// columnVisibilityModel / pinnedColumns / rowGroupingModel /
|
|
3533
|
-
// aggregationModel are also uncontrolled here to
|
|
3534
|
-
// re-render race with consumer-side
|
|
3535
|
-
// updates (otherwise user toggles
|
|
3536
|
-
// the stale controlled value).
|
|
3537
|
-
//
|
|
3588
|
+
// aggregationModel / pivotModel are also uncontrolled here to
|
|
3589
|
+
// avoid a controlled re-render race with consumer-side
|
|
3590
|
+
// microtask-deferred history updates (otherwise user toggles
|
|
3591
|
+
// flip back when MUI re-emits with the stale controlled value).
|
|
3592
|
+
// pivotModel specifically also carries `hidden`/`sort` field
|
|
3593
|
+
// metadata that our simplified URL representation strips — so
|
|
3594
|
+
// controlling it would prevent users from unchecking fields in
|
|
3595
|
+
// the pivot panel (the controlled prop would immediately re-add
|
|
3596
|
+
// them). Consumers needing programmatic changes should use the
|
|
3597
|
+
// apiRef imperative API.
|
|
3538
3598
|
}, isDataSourceMode ? {
|
|
3539
3599
|
onFilterModelChange: onFilterModelChange,
|
|
3540
3600
|
onSortModelChange: onSortModelChange,
|
|
@@ -3562,6 +3622,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3562
3622
|
paginationModel
|
|
3563
3623
|
},
|
|
3564
3624
|
pivoting: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.pivoting), {}, {
|
|
3625
|
+
model: pivotModel,
|
|
3565
3626
|
enabled: pivotActive
|
|
3566
3627
|
})
|
|
3567
3628
|
})
|
|
@@ -3573,6 +3634,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3573
3634
|
filterModel,
|
|
3574
3635
|
sortModel,
|
|
3575
3636
|
paginationModel,
|
|
3637
|
+
pivotModel,
|
|
3576
3638
|
onFilterModelChange: onFilterModelChange,
|
|
3577
3639
|
onSortModelChange: onSortModelChange,
|
|
3578
3640
|
onPaginationModelChange: wrappedOnPaginationModelChange,
|
|
@@ -3753,5 +3815,5 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3753
3815
|
StatefulDataGrid.className = CLASSNAME;
|
|
3754
3816
|
StatefulDataGrid.displayName = COMPONENT_NAME;
|
|
3755
3817
|
|
|
3756
|
-
export { buildStorageKey as $, ARRAY_IS_EMPTY as A, IS as B, CONTAINS_ANY_OF as C, DOES_NOT_CONTAIN as D, ENDS_WITH_ANY_OF as E, IS_NOT as F, getGridStringOperators as G, HAS_WITH_SELECT as H, IS_ANY_OF as I, getGridStringArrayOperators as J, getGridStringArrayOperatorsWithSelect as K, getGridStringArrayOperatorsWithSelectOnStringArrayColumns as L, FILTER_MODEL_KEY as M, SORT_MODEL_KEY as N, PINNED_COLUMNS as O, PAGINATION_MODEL_KEY as P, DIMENSION_MODEL_KEY as Q, FILTER_SEARCH_KEY as R, STARTS_WITH_ANY_OF as S, DENSITY_MODEL_KEY as T, COLUMN_ORDER_MODEL_KEY as U, VISIBILITY_MODEL_KEY as V, ROW_GROUPING_MODEL_KEY as W, AGGREGATION_MODEL_KEY as X, PIVOT_MODEL_KEY as Y, PIVOT_ACTIVE_KEY as Z, CATEGORIES as _, DOES_NOT_EQUAL as a, clearPreviousVersionStorage as a0, clearAllVersionStorage as a1, resetStatefulDataGridState as a2, convertToDisplayFormat as a3, convertFromDisplayFormat as a4, getDecodedSearchFromUrl as a5, buildQueryParamsString as a6, areSearchStringsEqual as a7, decodeValue as a8, encodeValue as a9, getPivotFromString as aA, getSearchParamsFromPivot as aB, getPivotActiveFromString as aC, getSearchParamsFromPivotActive as aD,
|
|
3818
|
+
export { buildStorageKey as $, ARRAY_IS_EMPTY as A, IS as B, CONTAINS_ANY_OF as C, DOES_NOT_CONTAIN as D, ENDS_WITH_ANY_OF as E, IS_NOT as F, getGridStringOperators as G, HAS_WITH_SELECT as H, IS_ANY_OF as I, getGridStringArrayOperators as J, getGridStringArrayOperatorsWithSelect as K, getGridStringArrayOperatorsWithSelectOnStringArrayColumns as L, FILTER_MODEL_KEY as M, SORT_MODEL_KEY as N, PINNED_COLUMNS as O, PAGINATION_MODEL_KEY as P, DIMENSION_MODEL_KEY as Q, FILTER_SEARCH_KEY as R, STARTS_WITH_ANY_OF as S, DENSITY_MODEL_KEY as T, COLUMN_ORDER_MODEL_KEY as U, VISIBILITY_MODEL_KEY as V, ROW_GROUPING_MODEL_KEY as W, AGGREGATION_MODEL_KEY as X, PIVOT_MODEL_KEY as Y, PIVOT_ACTIVE_KEY as Z, CATEGORIES as _, DOES_NOT_EQUAL as a, clearPreviousVersionStorage as a0, clearAllVersionStorage as a1, resetStatefulDataGridState as a2, convertToDisplayFormat as a3, convertFromDisplayFormat as a4, getDecodedSearchFromUrl as a5, buildQueryParamsString as a6, areSearchStringsEqual as a7, decodeValue as a8, encodeValue as a9, getPivotFromString as aA, getSearchParamsFromPivot as aB, getPivotActiveFromString as aC, getSearchParamsFromPivotActive as aD, getSearchParamsFromVersion as aE, getFinalSearch as aF, getModelsParsedOrUpdateLocalStorage as aG, updateUrl as aH, areFilterModelsEquivalent as aI, StatefulDataGrid as aJ, urlSearchParamsToString as aa, numberOperatorEncoder as ab, numberOperatorDecoder as ac, isOperatorValueValid as ad, isValueValid as ae, getFilterModelFromString as af, getSearchParamsFromFilterModel as ag, getSortingFromString as ah, getSearchParamsFromSorting as ai, getPaginationFromString as aj, getSearchParamsFromPagination as ak, getColumnVisibilityFromString as al, getSearchParamsFromColumnVisibility as am, getPinnedColumnsFromString as an, getSearchParamsFromPinnedColumns as ao, getSearchParamsFromTab as ap, getDensityFromString as aq, getSearchParamsFromDensity as ar, getDensityModel as as, getColumnOrderFromString as at, getSearchParamsFromColumnOrder as au, getRowGroupingFromString as av, getSearchParamsFromRowGrouping as aw, getAggregationFromString as ax, getSearchParamsFromAggregation as ay, fromGridPivotModel as az, DOES_NOT_START_WITH as b, DOES_NOT_END_WITH as c, IS_NOT_ANY_OF as d, DOES_NOT_CONTAIN_ANY_OF as e, DOES_NOT_START_WITH_ANY_OF as f, DOES_NOT_END_WITH_ANY_OF as g, IS_BETWEEN as h, IS_WITH_SELECT as i, IS_NOT_WITH_SELECT as j, IS_ANY_OF_WITH_SELECT as k, IS_NOT_ANY_OF_WITH_SELECT as l, ARRAY_IS_NOT_EMPTY as m, DOES_NOT_HAVE_WITH_SELECT as n, operatorList as o, HAS_ANY_OF_WITH_SELECT as p, HAS_ALL_OF_WITH_SELECT as q, DOES_NOT_HAVE_ANY_OF_WITH_SELECT as r, HAS_ONLY_WITH_SELECT as s, HAS as t, DOES_NOT_HAVE as u, HAS_ANY_OF as v, HAS_ALL_OF as w, DOES_NOT_HAVE_ANY_OF as x, HAS_ONLY as y, getGridNumericOperators as z };
|
|
3757
3819
|
//# sourceMappingURL=StatefulDataGrid2.js.map
|