@redsift/table 12.5.3-alpha.0 → 12.5.3-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 +198 -43
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/index.d.ts +39 -6
- package/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { aI as StatefulDataGrid } from './StatefulDataGrid2.js';
|
|
2
2
|
//# sourceMappingURL=StatefulDataGrid.js.map
|
|
@@ -706,7 +706,8 @@ const COLUMN_ORDER_MODEL_KEY = 'columnOrderModel';
|
|
|
706
706
|
const ROW_GROUPING_MODEL_KEY = 'rowGroupingModel';
|
|
707
707
|
const AGGREGATION_MODEL_KEY = 'aggregationModel';
|
|
708
708
|
const PIVOT_MODEL_KEY = 'pivotModel';
|
|
709
|
-
const
|
|
709
|
+
const PIVOT_ACTIVE_KEY = 'pivotActive';
|
|
710
|
+
const CATEGORIES = [PAGINATION_MODEL_KEY, FILTER_MODEL_KEY, SORT_MODEL_KEY, VISIBILITY_MODEL_KEY, DIMENSION_MODEL_KEY, FILTER_SEARCH_KEY, PINNED_COLUMNS, DENSITY_MODEL_KEY, COLUMN_ORDER_MODEL_KEY, ROW_GROUPING_MODEL_KEY, AGGREGATION_MODEL_KEY, PIVOT_MODEL_KEY, PIVOT_ACTIVE_KEY];
|
|
710
711
|
const buildStorageKey = _ref => {
|
|
711
712
|
let {
|
|
712
713
|
id,
|
|
@@ -765,6 +766,10 @@ const clearPreviousVersionStorage = (id, previousLocalStorageVersions) => {
|
|
|
765
766
|
id,
|
|
766
767
|
version,
|
|
767
768
|
category: PIVOT_MODEL_KEY
|
|
769
|
+
}), buildStorageKey({
|
|
770
|
+
id,
|
|
771
|
+
version,
|
|
772
|
+
category: PIVOT_ACTIVE_KEY
|
|
768
773
|
})];
|
|
769
774
|
for (const keyToDelete of keysToDelete) {
|
|
770
775
|
try {
|
|
@@ -776,6 +781,48 @@ const clearPreviousVersionStorage = (id, previousLocalStorageVersions) => {
|
|
|
776
781
|
}
|
|
777
782
|
};
|
|
778
783
|
|
|
784
|
+
/**
|
|
785
|
+
* Clear localStorage keys for all versions from 0 to `maxVersion` (inclusive).
|
|
786
|
+
* Useful when the consumer wants to wipe all persisted grid state regardless of which version is active.
|
|
787
|
+
*/
|
|
788
|
+
const clearAllVersionStorage = (id, maxVersion) => {
|
|
789
|
+
const versions = Array.from({
|
|
790
|
+
length: maxVersion + 1
|
|
791
|
+
}, (_, i) => i);
|
|
792
|
+
clearPreviousVersionStorage(id, versions);
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Fully reset a `StatefulDataGrid` — clear localStorage for the given versions
|
|
797
|
+
* and strip all grid-owned URL params (`_*` and `v=`), preserving any non-grid params.
|
|
798
|
+
*
|
|
799
|
+
* Call from within a component where the router values are available:
|
|
800
|
+
* ```ts
|
|
801
|
+
* const { search, historyReplace } = useMyRouter();
|
|
802
|
+
* resetStatefulDataGridState({ id: 'myGrid', versions: [0, 1, 2], search, historyReplace });
|
|
803
|
+
* ```
|
|
804
|
+
*/
|
|
805
|
+
const resetStatefulDataGridState = _ref2 => {
|
|
806
|
+
let {
|
|
807
|
+
id,
|
|
808
|
+
versions,
|
|
809
|
+
search,
|
|
810
|
+
historyReplace
|
|
811
|
+
} = _ref2;
|
|
812
|
+
clearPreviousVersionStorage(id, versions);
|
|
813
|
+
const params = new URLSearchParams(search);
|
|
814
|
+
const keysToDelete = [];
|
|
815
|
+
params.forEach((_value, key) => {
|
|
816
|
+
if (key.startsWith('_') || key === 'v') {
|
|
817
|
+
keysToDelete.push(key);
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
for (const key of keysToDelete) {
|
|
821
|
+
params.delete(key);
|
|
822
|
+
}
|
|
823
|
+
historyReplace(params.toString());
|
|
824
|
+
};
|
|
825
|
+
|
|
779
826
|
/** Maximum query string length (chars) before compression kicks in. */
|
|
780
827
|
const URL_BUDGET = 2000;
|
|
781
828
|
|
|
@@ -1908,9 +1955,10 @@ const getSearchParamsFromDensity = density => {
|
|
|
1908
1955
|
searchParams.set('_density', density);
|
|
1909
1956
|
return searchParams;
|
|
1910
1957
|
};
|
|
1911
|
-
const getDensityModel = (search, localStorageDensity, setLocalStorageDensity,
|
|
1912
|
-
// Default density
|
|
1913
|
-
const
|
|
1958
|
+
const getDensityModel = (search, localStorageDensity, setLocalStorageDensity, initialState, isNewVersion) => {
|
|
1959
|
+
// Default density: honour initialState.density if valid, otherwise fall back to 'compact'
|
|
1960
|
+
const initialDensity = initialState === null || initialState === void 0 ? void 0 : initialState.density;
|
|
1961
|
+
const defaultValue = initialDensity && VALID_DENSITIES.includes(initialDensity) ? initialDensity : 'compact';
|
|
1914
1962
|
|
|
1915
1963
|
// Persist initialState-derived density to localStorage so all three sources stay in sync
|
|
1916
1964
|
const persistDefaultDensity = () => {
|
|
@@ -2108,6 +2156,22 @@ const getAggregationModel = (search, localStorageAggregation, setLocalStorageAgg
|
|
|
2108
2156
|
|
|
2109
2157
|
/** PIVOT */
|
|
2110
2158
|
|
|
2159
|
+
/** Convert MUI's GridPivotModel → our simplified PivotModel */
|
|
2160
|
+
const fromGridPivotModel = model => ({
|
|
2161
|
+
columns: model.columns.map(c => c.field),
|
|
2162
|
+
rows: model.rows.map(r => r.field),
|
|
2163
|
+
values: model.values.map(_ref2 => {
|
|
2164
|
+
let {
|
|
2165
|
+
field,
|
|
2166
|
+
aggFunc
|
|
2167
|
+
} = _ref2;
|
|
2168
|
+
return {
|
|
2169
|
+
field,
|
|
2170
|
+
aggFunc
|
|
2171
|
+
};
|
|
2172
|
+
})
|
|
2173
|
+
});
|
|
2174
|
+
|
|
2111
2175
|
/**
|
|
2112
2176
|
* Pivot format: `cols:f1,f2;rows:f3;vals:f4.sum,f5.avg`
|
|
2113
2177
|
*/
|
|
@@ -2164,7 +2228,8 @@ const getSearchParamsFromPivot = pivot => {
|
|
|
2164
2228
|
return searchParams;
|
|
2165
2229
|
};
|
|
2166
2230
|
const getPivotModel = (search, localStoragePivot, setLocalStoragePivot, initialState, isNewVersion) => {
|
|
2167
|
-
|
|
2231
|
+
var _initialState$pivotin;
|
|
2232
|
+
const defaultValue = initialState !== null && initialState !== void 0 && (_initialState$pivotin = initialState.pivoting) !== null && _initialState$pivotin !== void 0 && _initialState$pivotin.model ? fromGridPivotModel(initialState.pivoting.model) : {
|
|
2168
2233
|
columns: [],
|
|
2169
2234
|
rows: [],
|
|
2170
2235
|
values: []
|
|
@@ -2196,7 +2261,56 @@ const getPivotModel = (search, localStoragePivot, setLocalStoragePivot, initialS
|
|
|
2196
2261
|
persistDefault();
|
|
2197
2262
|
return defaultValue;
|
|
2198
2263
|
};
|
|
2199
|
-
|
|
2264
|
+
|
|
2265
|
+
/** PIVOT ACTIVE */
|
|
2266
|
+
|
|
2267
|
+
const getPivotActiveFromString = searchString => {
|
|
2268
|
+
if (!searchString) return 'invalid';
|
|
2269
|
+
const searchParams = new URLSearchParams(searchString);
|
|
2270
|
+
const value = searchParams.get('_pivotActive');
|
|
2271
|
+
if (value === 'true') return true;
|
|
2272
|
+
if (value === 'false') return false;
|
|
2273
|
+
return 'invalid';
|
|
2274
|
+
};
|
|
2275
|
+
const getSearchParamsFromPivotActive = active => {
|
|
2276
|
+
const searchParams = new URLSearchParams();
|
|
2277
|
+
// Only write to URL when active — false is the default and omitting keeps URLs clean
|
|
2278
|
+
if (active) {
|
|
2279
|
+
searchParams.set('_pivotActive', 'true');
|
|
2280
|
+
}
|
|
2281
|
+
return searchParams;
|
|
2282
|
+
};
|
|
2283
|
+
const getPivotActive = (search, localStoragePivotActive, setLocalStoragePivotActive, initialState, isNewVersion) => {
|
|
2284
|
+
var _initialState$pivotin2, _initialState$pivotin3;
|
|
2285
|
+
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;
|
|
2286
|
+
const persistDefault = () => {
|
|
2287
|
+
const searchFromDefault = getSearchParamsFromPivotActive(defaultValue);
|
|
2288
|
+
const searchString = urlSearchParamsToString(searchFromDefault);
|
|
2289
|
+
if (searchString !== localStoragePivotActive) {
|
|
2290
|
+
setLocalStoragePivotActive(searchString);
|
|
2291
|
+
}
|
|
2292
|
+
};
|
|
2293
|
+
if (isNewVersion) {
|
|
2294
|
+
persistDefault();
|
|
2295
|
+
return defaultValue;
|
|
2296
|
+
}
|
|
2297
|
+
const fromUrl = getPivotActiveFromString(search);
|
|
2298
|
+
if (fromUrl !== 'invalid') {
|
|
2299
|
+
const searchFromModel = getSearchParamsFromPivotActive(fromUrl);
|
|
2300
|
+
const searchString = urlSearchParamsToString(searchFromModel);
|
|
2301
|
+
if (searchString !== localStoragePivotActive) {
|
|
2302
|
+
setLocalStoragePivotActive(searchString);
|
|
2303
|
+
}
|
|
2304
|
+
return fromUrl;
|
|
2305
|
+
}
|
|
2306
|
+
const fromLocalStorage = getPivotActiveFromString(localStoragePivotActive);
|
|
2307
|
+
if (fromLocalStorage !== 'invalid') {
|
|
2308
|
+
return fromLocalStorage;
|
|
2309
|
+
}
|
|
2310
|
+
persistDefault();
|
|
2311
|
+
return defaultValue;
|
|
2312
|
+
};
|
|
2313
|
+
const getFinalSearch = _ref3 => {
|
|
2200
2314
|
let {
|
|
2201
2315
|
search,
|
|
2202
2316
|
localStorageVersion,
|
|
@@ -2211,8 +2325,9 @@ const getFinalSearch = _ref2 => {
|
|
|
2211
2325
|
rowGroupingModel,
|
|
2212
2326
|
aggregationModel,
|
|
2213
2327
|
pivotModel,
|
|
2328
|
+
pivotActive,
|
|
2214
2329
|
columns
|
|
2215
|
-
} =
|
|
2330
|
+
} = _ref3;
|
|
2216
2331
|
const filterModelSearch = getSearchParamsFromFilterModel(filterModel);
|
|
2217
2332
|
const sortModelSearch = getSearchParamsFromSorting(sortModel);
|
|
2218
2333
|
const paginationModelSearch = getSearchParamsFromPagination(paginationModel);
|
|
@@ -2224,6 +2339,7 @@ const getFinalSearch = _ref2 => {
|
|
|
2224
2339
|
const rowGroupingSearch = getSearchParamsFromRowGrouping(rowGroupingModel);
|
|
2225
2340
|
const aggregationSearch = getSearchParamsFromAggregation(aggregationModel);
|
|
2226
2341
|
const pivotSearch = getSearchParamsFromPivot(pivotModel);
|
|
2342
|
+
const pivotActiveSearch = getSearchParamsFromPivotActive(pivotActive);
|
|
2227
2343
|
const tabSearch = getSearchParamsFromTab(search);
|
|
2228
2344
|
const searchParams = new URLSearchParams();
|
|
2229
2345
|
for (const [key, value] of new URLSearchParams(search)) {
|
|
@@ -2238,7 +2354,7 @@ const getFinalSearch = _ref2 => {
|
|
|
2238
2354
|
// Encode array as JSON string to preserve all values in one param
|
|
2239
2355
|
searchParams.set('_quickFilterValues', encodeURIComponent(JSON.stringify(filterModel.quickFilterValues)));
|
|
2240
2356
|
}
|
|
2241
|
-
return new URLSearchParams([...searchParams, ...filterModelSearch, ...sortModelSearch, ...paginationModelSearch, ...tabSearch, ...pinnedColumnsModelSearch, ...columnVisibilityModelSearch, ...densitySearch, ...columnOrderSearch, ...rowGroupingSearch, ...aggregationSearch, ...pivotSearch]);
|
|
2357
|
+
return new URLSearchParams([...searchParams, ...filterModelSearch, ...sortModelSearch, ...paginationModelSearch, ...tabSearch, ...pinnedColumnsModelSearch, ...columnVisibilityModelSearch, ...densitySearch, ...columnOrderSearch, ...rowGroupingSearch, ...aggregationSearch, ...pivotSearch, ...pivotActiveSearch]);
|
|
2242
2358
|
};
|
|
2243
2359
|
/** Return the state of the table given the URL and the local storage state */
|
|
2244
2360
|
const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, columns, initialState, localStorage) => {
|
|
@@ -2269,7 +2385,9 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2269
2385
|
localStorageAggregation,
|
|
2270
2386
|
setLocalStorageAggregation,
|
|
2271
2387
|
localStoragePivot,
|
|
2272
|
-
setLocalStoragePivot
|
|
2388
|
+
setLocalStoragePivot,
|
|
2389
|
+
localStoragePivotActive,
|
|
2390
|
+
setLocalStoragePivotActive
|
|
2273
2391
|
} = localStorage;
|
|
2274
2392
|
const filterModel = getFilterModel(decodedSearch, columns, localStorageFilters, setLocalStorageFilters, initialState, isNewVersion);
|
|
2275
2393
|
const sortModel = getSortModel(decodedSearch, columns, localStorageSorting, setLocalStorageSorting, initialState, isNewVersion);
|
|
@@ -2281,6 +2399,7 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2281
2399
|
const rowGroupingModel = getRowGroupingModel(decodedSearch, localStorageRowGrouping, setLocalStorageRowGrouping, initialState, isNewVersion);
|
|
2282
2400
|
const aggregationModel = getAggregationModel(decodedSearch, localStorageAggregation, setLocalStorageAggregation, initialState, isNewVersion);
|
|
2283
2401
|
const pivotModel = getPivotModel(decodedSearch, localStoragePivot, setLocalStoragePivot, initialState, isNewVersion);
|
|
2402
|
+
const pivotActive = getPivotActive(decodedSearch, localStoragePivotActive, setLocalStoragePivotActive, initialState, isNewVersion);
|
|
2284
2403
|
const defaultColumnOrder = (_initialState$columns6 = initialState === null || initialState === void 0 ? void 0 : (_initialState$columns7 = initialState.columns) === null || _initialState$columns7 === void 0 ? void 0 : _initialState$columns7.orderedFields) !== null && _initialState$columns6 !== void 0 ? _initialState$columns6 : columns.map(c => c.field);
|
|
2285
2404
|
const finalSearch = getFinalSearch({
|
|
2286
2405
|
localStorageVersion,
|
|
@@ -2296,6 +2415,7 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2296
2415
|
rowGroupingModel,
|
|
2297
2416
|
aggregationModel,
|
|
2298
2417
|
pivotModel,
|
|
2418
|
+
pivotActive,
|
|
2299
2419
|
columns
|
|
2300
2420
|
});
|
|
2301
2421
|
const internalSearchString = urlSearchParamsToString(finalSearch);
|
|
@@ -2319,10 +2439,11 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
2319
2439
|
rowGroupingModel,
|
|
2320
2440
|
aggregationModel,
|
|
2321
2441
|
pivotModel,
|
|
2442
|
+
pivotActive,
|
|
2322
2443
|
pendingSearch
|
|
2323
2444
|
};
|
|
2324
2445
|
};
|
|
2325
|
-
const updateUrl = (
|
|
2446
|
+
const updateUrl = (_ref4, search, localStorageVersion, historyReplace, columns) => {
|
|
2326
2447
|
let {
|
|
2327
2448
|
filterModel,
|
|
2328
2449
|
sortModel,
|
|
@@ -2334,8 +2455,9 @@ const updateUrl = (_ref3, search, localStorageVersion, historyReplace, columns)
|
|
|
2334
2455
|
defaultColumnOrder,
|
|
2335
2456
|
rowGroupingModel,
|
|
2336
2457
|
aggregationModel,
|
|
2337
|
-
pivotModel
|
|
2338
|
-
|
|
2458
|
+
pivotModel,
|
|
2459
|
+
pivotActive
|
|
2460
|
+
} = _ref4;
|
|
2339
2461
|
// Convert from display format to internal format if needed
|
|
2340
2462
|
const decodedSearch = getDecodedSearchFromUrl(search, columns);
|
|
2341
2463
|
const newSearch = getFinalSearch({
|
|
@@ -2352,6 +2474,7 @@ const updateUrl = (_ref3, search, localStorageVersion, historyReplace, columns)
|
|
|
2352
2474
|
rowGroupingModel,
|
|
2353
2475
|
aggregationModel,
|
|
2354
2476
|
pivotModel,
|
|
2477
|
+
pivotActive,
|
|
2355
2478
|
columns
|
|
2356
2479
|
});
|
|
2357
2480
|
const internalSearchString = urlSearchParamsToString(newSearch);
|
|
@@ -2554,6 +2677,11 @@ const useTableStates = (id, version) => {
|
|
|
2554
2677
|
version,
|
|
2555
2678
|
category: PIVOT_MODEL_KEY
|
|
2556
2679
|
}));
|
|
2680
|
+
const [pivotActive, setPivotActive] = useFetchState('', buildStorageKey({
|
|
2681
|
+
id,
|
|
2682
|
+
version,
|
|
2683
|
+
category: PIVOT_ACTIVE_KEY
|
|
2684
|
+
}));
|
|
2557
2685
|
return {
|
|
2558
2686
|
paginationModel,
|
|
2559
2687
|
setPaginationModel,
|
|
@@ -2576,7 +2704,9 @@ const useTableStates = (id, version) => {
|
|
|
2576
2704
|
aggregationModel,
|
|
2577
2705
|
setAggregationModel,
|
|
2578
2706
|
pivotModel,
|
|
2579
|
-
setPivotModel
|
|
2707
|
+
setPivotModel,
|
|
2708
|
+
pivotActive,
|
|
2709
|
+
setPivotActive
|
|
2580
2710
|
};
|
|
2581
2711
|
};
|
|
2582
2712
|
|
|
@@ -2600,22 +2730,6 @@ const toGridPivotModel = model => ({
|
|
|
2600
2730
|
})
|
|
2601
2731
|
});
|
|
2602
2732
|
|
|
2603
|
-
/** Convert MUI's GridPivotModel → our simplified PivotModel */
|
|
2604
|
-
const fromGridPivotModel = model => ({
|
|
2605
|
-
columns: model.columns.map(c => c.field),
|
|
2606
|
-
rows: model.rows.map(r => r.field),
|
|
2607
|
-
values: model.values.map(_ref2 => {
|
|
2608
|
-
let {
|
|
2609
|
-
field,
|
|
2610
|
-
aggFunc
|
|
2611
|
-
} = _ref2;
|
|
2612
|
-
return {
|
|
2613
|
-
field,
|
|
2614
|
-
aggFunc
|
|
2615
|
-
};
|
|
2616
|
-
})
|
|
2617
|
-
});
|
|
2618
|
-
|
|
2619
2733
|
/**
|
|
2620
2734
|
* Deep-equal comparison for plain objects / arrays.
|
|
2621
2735
|
* Used to stabilise parsed model references so that MUI v8 does not
|
|
@@ -2682,16 +2796,18 @@ const useStatefulTable = props => {
|
|
|
2682
2796
|
aggregationModel: localStorageAggregation,
|
|
2683
2797
|
setAggregationModel: setLocalStorageAggregation,
|
|
2684
2798
|
pivotModel: localStoragePivot,
|
|
2685
|
-
setPivotModel: setLocalStoragePivot
|
|
2799
|
+
setPivotModel: setLocalStoragePivot,
|
|
2800
|
+
pivotActive: localStoragePivotActive,
|
|
2801
|
+
setPivotActive: setLocalStoragePivotActive
|
|
2686
2802
|
} = useTableStates(id, localStorageVersion);
|
|
2687
2803
|
|
|
2688
2804
|
// clearing up old version keys, triggering only on first render
|
|
2689
2805
|
useEffect(() => clearPreviousVersionStorage(id, previousLocalStorageVersions), [id, previousLocalStorageVersions]);
|
|
2690
|
-
const onColumnDimensionChange = useCallback(
|
|
2806
|
+
const onColumnDimensionChange = useCallback(_ref2 => {
|
|
2691
2807
|
let {
|
|
2692
2808
|
newWidth,
|
|
2693
2809
|
field
|
|
2694
|
-
} =
|
|
2810
|
+
} = _ref2;
|
|
2695
2811
|
setDimensionModel(_objectSpread2(_objectSpread2({}, dimensionModel), {}, {
|
|
2696
2812
|
[field]: newWidth
|
|
2697
2813
|
}));
|
|
@@ -2707,6 +2823,7 @@ const useStatefulTable = props => {
|
|
|
2707
2823
|
rowGroupingModel: rowGroupingParsed,
|
|
2708
2824
|
aggregationModel: aggregationParsed,
|
|
2709
2825
|
pivotModel: pivotParsed,
|
|
2826
|
+
pivotActive: pivotActiveParsed,
|
|
2710
2827
|
pendingSearch
|
|
2711
2828
|
} = getModelsParsedOrUpdateLocalStorage(search || '', localStorageVersion, propsColumns, initialState, {
|
|
2712
2829
|
localStorageFilters,
|
|
@@ -2728,7 +2845,9 @@ const useStatefulTable = props => {
|
|
|
2728
2845
|
localStorageAggregation,
|
|
2729
2846
|
setLocalStorageAggregation,
|
|
2730
2847
|
localStoragePivot,
|
|
2731
|
-
setLocalStoragePivot
|
|
2848
|
+
setLocalStoragePivot,
|
|
2849
|
+
localStoragePivotActive: localStoragePivotActive,
|
|
2850
|
+
setLocalStoragePivotActive: setLocalStoragePivotActive
|
|
2732
2851
|
});
|
|
2733
2852
|
|
|
2734
2853
|
// Sync URL in an effect rather than during render to comply with React rules
|
|
@@ -2810,12 +2929,13 @@ const useStatefulTable = props => {
|
|
|
2810
2929
|
defaultColumnOrder,
|
|
2811
2930
|
rowGroupingModel: rowGroupingParsed,
|
|
2812
2931
|
aggregationModel: aggregationParsed,
|
|
2813
|
-
pivotModel: pivotParsed
|
|
2932
|
+
pivotModel: pivotParsed,
|
|
2933
|
+
pivotActive: pivotActiveParsed
|
|
2814
2934
|
}, search, localStorageVersion, historyReplace, columns);
|
|
2815
2935
|
}
|
|
2816
2936
|
});
|
|
2817
2937
|
return unsub;
|
|
2818
|
-
}, [apiRef, densityParsed, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, columnOrderParsed, defaultColumnOrder, rowGroupingParsed, aggregationParsed, pivotParsed, search, localStorageVersion, historyReplace, columns]);
|
|
2938
|
+
}, [apiRef, densityParsed, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, columnOrderParsed, defaultColumnOrder, rowGroupingParsed, aggregationParsed, pivotParsed, pivotActiveParsed, search, localStorageVersion, historyReplace, columns]);
|
|
2819
2939
|
|
|
2820
2940
|
// Subscribe to column order changes via columnOrderChange (drag-drop) and columnIndexChange (programmatic setColumnIndex)
|
|
2821
2941
|
useEffect(() => {
|
|
@@ -2835,7 +2955,8 @@ const useStatefulTable = props => {
|
|
|
2835
2955
|
defaultColumnOrder,
|
|
2836
2956
|
rowGroupingModel: rowGroupingParsed,
|
|
2837
2957
|
aggregationModel: aggregationParsed,
|
|
2838
|
-
pivotModel: pivotParsed
|
|
2958
|
+
pivotModel: pivotParsed,
|
|
2959
|
+
pivotActive: pivotActiveParsed
|
|
2839
2960
|
}, search, localStorageVersion, historyReplace, columns);
|
|
2840
2961
|
}
|
|
2841
2962
|
};
|
|
@@ -2845,7 +2966,7 @@ const useStatefulTable = props => {
|
|
|
2845
2966
|
unsub1();
|
|
2846
2967
|
unsub2();
|
|
2847
2968
|
};
|
|
2848
|
-
}, [apiRef, columnOrderParsed, defaultColumnOrder, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, densityParsed, rowGroupingParsed, aggregationParsed, pivotParsed, search, localStorageVersion, historyReplace, columns]);
|
|
2969
|
+
}, [apiRef, columnOrderParsed, defaultColumnOrder, filterParsed, sortModelParsed, paginationModelParsed, pinnedColumnsModel, densityParsed, rowGroupingParsed, aggregationParsed, pivotParsed, pivotActiveParsed, search, localStorageVersion, historyReplace, columns]);
|
|
2849
2970
|
|
|
2850
2971
|
// Helper to build the current DataGridModel for updateUrl calls
|
|
2851
2972
|
const buildModel = function () {
|
|
@@ -2862,9 +2983,21 @@ const useStatefulTable = props => {
|
|
|
2862
2983
|
defaultColumnOrder,
|
|
2863
2984
|
rowGroupingModel: rowGroupingParsed,
|
|
2864
2985
|
aggregationModel: aggregationParsed,
|
|
2865
|
-
pivotModel: pivotParsed
|
|
2986
|
+
pivotModel: pivotParsed,
|
|
2987
|
+
pivotActive: pivotActiveParsed
|
|
2866
2988
|
}, overrides);
|
|
2867
2989
|
};
|
|
2990
|
+
|
|
2991
|
+
// Stable GridPivotModel identity — only recompute when the simplified value changes.
|
|
2992
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2993
|
+
const pivotModelMui = useMemo(() => toGridPivotModel(pivotParsed), [JSON.stringify(pivotParsed)]);
|
|
2994
|
+
|
|
2995
|
+
// Track last emitted values for deep-equal guards to avoid feedback loops.
|
|
2996
|
+
// Initialised from the current parsed values; updated only when we actually fire.
|
|
2997
|
+
const lastEmittedFilterRef = useRef(filterParsed);
|
|
2998
|
+
const lastEmittedSortRef = useRef(sortModelParsed);
|
|
2999
|
+
const lastEmittedPaginationRef = useRef(paginationModelParsed);
|
|
3000
|
+
const lastEmittedPivotRef = useRef(pivotParsed);
|
|
2868
3001
|
return {
|
|
2869
3002
|
apiRef,
|
|
2870
3003
|
columns,
|
|
@@ -2872,7 +3005,8 @@ const useStatefulTable = props => {
|
|
|
2872
3005
|
columnOrderModel: columnOrderParsedRef.current,
|
|
2873
3006
|
rowGroupingModel: rowGroupingParsedRef.current,
|
|
2874
3007
|
aggregationModel: aggregationParsedRef.current,
|
|
2875
|
-
pivotModel:
|
|
3008
|
+
pivotModel: pivotModelMui,
|
|
3009
|
+
pivotActive: pivotActiveParsed,
|
|
2876
3010
|
onFilterModelChange: (model, details) => {
|
|
2877
3011
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
2878
3012
|
items: model.items.map(item => {
|
|
@@ -2883,6 +3017,8 @@ const useStatefulTable = props => {
|
|
|
2883
3017
|
}),
|
|
2884
3018
|
quickFilterValues: model.quickFilterValues || []
|
|
2885
3019
|
});
|
|
3020
|
+
if (isDeepEqual(filterModel, lastEmittedFilterRef.current)) return;
|
|
3021
|
+
lastEmittedFilterRef.current = filterModel;
|
|
2886
3022
|
updateUrl(buildModel({
|
|
2887
3023
|
filterModel
|
|
2888
3024
|
}), search, localStorageVersion, historyReplace, columns);
|
|
@@ -2890,6 +3026,8 @@ const useStatefulTable = props => {
|
|
|
2890
3026
|
},
|
|
2891
3027
|
filterModel: filterParsedRef.current,
|
|
2892
3028
|
onSortModelChange: (model, details) => {
|
|
3029
|
+
if (isDeepEqual(model, lastEmittedSortRef.current)) return;
|
|
3030
|
+
lastEmittedSortRef.current = model;
|
|
2893
3031
|
updateUrl(buildModel({
|
|
2894
3032
|
sortModel: model
|
|
2895
3033
|
}), search, localStorageVersion, historyReplace, columns);
|
|
@@ -2908,6 +3046,8 @@ const useStatefulTable = props => {
|
|
|
2908
3046
|
const paginationModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
2909
3047
|
direction: paginationModelParsed.page < model.page ? 'next' : 'back'
|
|
2910
3048
|
});
|
|
3049
|
+
if (isDeepEqual(paginationModel, lastEmittedPaginationRef.current)) return;
|
|
3050
|
+
lastEmittedPaginationRef.current = paginationModel;
|
|
2911
3051
|
updateUrl(buildModel({
|
|
2912
3052
|
paginationModel
|
|
2913
3053
|
}), search, localStorageVersion, historyReplace, columns);
|
|
@@ -2941,10 +3081,18 @@ const useStatefulTable = props => {
|
|
|
2941
3081
|
},
|
|
2942
3082
|
onPivotModelChange: model => {
|
|
2943
3083
|
const simplified = fromGridPivotModel(model);
|
|
3084
|
+
if (isDeepEqual(simplified, lastEmittedPivotRef.current)) return;
|
|
3085
|
+
lastEmittedPivotRef.current = simplified;
|
|
2944
3086
|
updateUrl(buildModel({
|
|
2945
3087
|
pivotModel: simplified
|
|
2946
3088
|
}), search, localStorageVersion, historyReplace, columns);
|
|
2947
3089
|
propsOnPivotModelChange === null || propsOnPivotModelChange === void 0 ? void 0 : propsOnPivotModelChange(model);
|
|
3090
|
+
},
|
|
3091
|
+
onPivotActiveChange: active => {
|
|
3092
|
+
if (active === pivotActiveParsed) return;
|
|
3093
|
+
updateUrl(buildModel({
|
|
3094
|
+
pivotActive: active
|
|
3095
|
+
}), search, localStorageVersion, historyReplace, columns);
|
|
2948
3096
|
}
|
|
2949
3097
|
};
|
|
2950
3098
|
};
|
|
@@ -3102,9 +3250,11 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3102
3250
|
rowGroupingModel,
|
|
3103
3251
|
aggregationModel,
|
|
3104
3252
|
pivotModel,
|
|
3253
|
+
pivotActive,
|
|
3105
3254
|
onRowGroupingModelChange,
|
|
3106
3255
|
onAggregationModelChange,
|
|
3107
|
-
onPivotModelChange
|
|
3256
|
+
onPivotModelChange,
|
|
3257
|
+
onPivotActiveChange
|
|
3108
3258
|
} = useStatefulTable({
|
|
3109
3259
|
apiRef: apiRef,
|
|
3110
3260
|
initialState,
|
|
@@ -3336,7 +3486,9 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3336
3486
|
aggregationModel: aggregationModel,
|
|
3337
3487
|
onAggregationModelChange: onAggregationModelChange,
|
|
3338
3488
|
pivotModel: pivotModel,
|
|
3339
|
-
onPivotModelChange: onPivotModelChange
|
|
3489
|
+
onPivotModelChange: onPivotModelChange,
|
|
3490
|
+
pivotActive: pivotActive,
|
|
3491
|
+
onPivotActiveChange: onPivotActiveChange
|
|
3340
3492
|
// In dataSource mode: models are uncontrolled (MUI owns them),
|
|
3341
3493
|
// onChange handlers are write-only for URL/localStorage persistence,
|
|
3342
3494
|
// and initialState seeds MUI on mount from the persisted URL state.
|
|
@@ -3357,7 +3509,10 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3357
3509
|
},
|
|
3358
3510
|
pagination: {
|
|
3359
3511
|
paginationModel
|
|
3360
|
-
}
|
|
3512
|
+
},
|
|
3513
|
+
pivoting: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.pivoting), {}, {
|
|
3514
|
+
enabled: pivotActive
|
|
3515
|
+
})
|
|
3361
3516
|
})
|
|
3362
3517
|
} : {
|
|
3363
3518
|
filterModel,
|
|
@@ -3536,5 +3691,5 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3536
3691
|
StatefulDataGrid.className = CLASSNAME;
|
|
3537
3692
|
StatefulDataGrid.displayName = COMPONENT_NAME;
|
|
3538
3693
|
|
|
3539
|
-
export {
|
|
3694
|
+
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, getFinalSearch as aE, getModelsParsedOrUpdateLocalStorage as aF, updateUrl as aG, areFilterModelsEquivalent as aH, StatefulDataGrid as aI, 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 };
|
|
3540
3695
|
//# sourceMappingURL=StatefulDataGrid2.js.map
|