@redsift/table 12.5.5-alpha.2 → 12.5.5-muiv7
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/BaseComponents.js +1 -1
- package/_internal/BasePopper.js +2453 -0
- package/_internal/BasePopper.js.map +1 -0
- package/_internal/ControlledPagination.js +11977 -0
- package/_internal/ControlledPagination.js.map +1 -0
- package/_internal/DataGrid2.js +74 -95
- package/_internal/DataGrid2.js.map +1 -1
- package/_internal/GridToolbarFilterSemanticField2.js +2 -1339
- package/_internal/GridToolbarFilterSemanticField2.js.map +1 -1
- package/_internal/Pagination.js +1 -1
- package/_internal/Portal.js +6563 -0
- package/_internal/Portal.js.map +1 -0
- package/_internal/StatefulDataGrid.js +1 -1
- package/_internal/StatefulDataGrid2.js +1818 -876
- package/_internal/StatefulDataGrid2.js.map +1 -1
- package/_internal/Toolbar2.js +1 -1
- package/_internal/Toolbar2.js.map +1 -1
- package/_internal/ToolbarWrapper2.js +27 -11
- package/_internal/ToolbarWrapper2.js.map +1 -1
- package/_internal/jsx-runtime.js +1342 -0
- package/_internal/jsx-runtime.js.map +1 -0
- package/_internal/useControlledDatagridState.js +1125 -6
- package/_internal/useControlledDatagridState.js.map +1 -1
- package/index.d.ts +310 -489
- package/index.js +143 -153
- package/index.js.map +1 -1
- package/package.json +10 -9
- package/_internal/BaseIconButton.js +0 -126
- package/_internal/BaseIconButton.js.map +0 -1
- package/_internal/ServerSideControlledPagination.js +0 -324
- package/_internal/ServerSideControlledPagination.js.map +0 -1
package/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { o as operatorList, D as DOES_NOT_CONTAIN, a as DOES_NOT_EQUAL, b as DOES_NOT_START_WITH, c as DOES_NOT_END_WITH, I as IS_ANY_OF, d as IS_NOT_ANY_OF, C as CONTAINS_ANY_OF, e as DOES_NOT_CONTAIN_ANY_OF, S as STARTS_WITH_ANY_OF, f as DOES_NOT_START_WITH_ANY_OF, E as ENDS_WITH_ANY_OF, g as DOES_NOT_END_WITH_ANY_OF, h as IS_BETWEEN, i as IS_WITH_SELECT, j as IS_NOT_WITH_SELECT, k as IS_ANY_OF_WITH_SELECT, l as IS_NOT_ANY_OF_WITH_SELECT, A as ARRAY_IS_EMPTY, m as ARRAY_IS_NOT_EMPTY, H as HAS_WITH_SELECT, n as DOES_NOT_HAVE_WITH_SELECT, p as HAS_ANY_OF_WITH_SELECT, q as HAS_ALL_OF_WITH_SELECT, r as DOES_NOT_HAVE_ANY_OF_WITH_SELECT, s as HAS_ONLY_WITH_SELECT, t as HAS, u as DOES_NOT_HAVE, v as HAS_ANY_OF, w as HAS_ALL_OF, x as DOES_NOT_HAVE_ANY_OF, y as HAS_ONLY } from './_internal/StatefulDataGrid2.js';
|
|
2
|
-
export {
|
|
3
|
-
import { GRID_DETAIL_PANEL_TOGGLE_COL_DEF,
|
|
4
|
-
export { getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-
|
|
1
|
+
import { B as Box, T as TextField, o as operatorList, D as DOES_NOT_CONTAIN, a as DOES_NOT_EQUAL, b as DOES_NOT_START_WITH, c as DOES_NOT_END_WITH, I as IS_ANY_OF, d as IS_NOT_ANY_OF, C as CONTAINS_ANY_OF, e as DOES_NOT_CONTAIN_ANY_OF, S as STARTS_WITH_ANY_OF, f as DOES_NOT_START_WITH_ANY_OF, E as ENDS_WITH_ANY_OF, g as DOES_NOT_END_WITH_ANY_OF, h as IS_BETWEEN, i as IS_WITH_SELECT, j as IS_NOT_WITH_SELECT, k as IS_ANY_OF_WITH_SELECT, l as IS_NOT_ANY_OF_WITH_SELECT, A as ARRAY_IS_EMPTY, m as ARRAY_IS_NOT_EMPTY, H as HAS_WITH_SELECT, n as DOES_NOT_HAVE_WITH_SELECT, p as HAS_ANY_OF_WITH_SELECT, q as HAS_ALL_OF_WITH_SELECT, r as DOES_NOT_HAVE_ANY_OF_WITH_SELECT, s as HAS_ONLY_WITH_SELECT, t as HAS, u as DOES_NOT_HAVE, v as HAS_ANY_OF, w as HAS_ALL_OF, x as DOES_NOT_HAVE_ANY_OF, y as HAS_ONLY } from './_internal/StatefulDataGrid2.js';
|
|
2
|
+
export { A as ARRAY_IS_EMPTY, m as ARRAY_IS_NOT_EMPTY, Y as CATEGORIES, X as COLUMN_ORDER_MODEL_KEY, C as CONTAINS_ANY_OF, W as DENSITY_MODEL_KEY, R as DIMENSION_MODEL_KEY, D as DOES_NOT_CONTAIN, e as DOES_NOT_CONTAIN_ANY_OF, c as DOES_NOT_END_WITH, g as DOES_NOT_END_WITH_ANY_OF, a as DOES_NOT_EQUAL, u as DOES_NOT_HAVE, x as DOES_NOT_HAVE_ANY_OF, r as DOES_NOT_HAVE_ANY_OF_WITH_SELECT, n as DOES_NOT_HAVE_WITH_SELECT, b as DOES_NOT_START_WITH, f as DOES_NOT_START_WITH_ANY_OF, E as ENDS_WITH_ANY_OF, N as FILTER_MODEL_KEY, U as FILTER_SEARCH_KEY, t as HAS, w as HAS_ALL_OF, q as HAS_ALL_OF_WITH_SELECT, v as HAS_ANY_OF, p as HAS_ANY_OF_WITH_SELECT, y as HAS_ONLY, s as HAS_ONLY_WITH_SELECT, H as HAS_WITH_SELECT, F as IS, I as IS_ANY_OF, k as IS_ANY_OF_WITH_SELECT, h as IS_BETWEEN, G as IS_NOT, d as IS_NOT_ANY_OF, l as IS_NOT_ANY_OF_WITH_SELECT, j as IS_NOT_WITH_SELECT, i as IS_WITH_SELECT, P as PAGINATION_MODEL_KEY, Q as PINNED_COLUMNS, O as SORT_MODEL_KEY, S as STARTS_WITH_ANY_OF, az as StatefulDataGrid, V as VISIBILITY_MODEL_KEY, ay as areFilterModelsEquivalent, a6 as areSearchStringsEqual, a5 as buildQueryParamsString, Z as buildStorageKey, $ as clearAllVersionStorage, _ as clearPreviousVersionStorage, a3 as convertFromDisplayFormat, a2 as convertToDisplayFormat, a7 as decodeValue, a8 as encodeValue, as as getColumnOrderFromString, ak as getColumnVisibilityFromString, a4 as getDecodedSearchFromUrl, ap as getDensityFromString, ar as getDensityModel, ae as getFilterModelFromString, av as getFinalSearch, z as getGridNumericOperators, K as getGridStringArrayOperators, L as getGridStringArrayOperatorsWithSelect, M as getGridStringArrayOperatorsWithSelectOnStringArrayColumns, J as getGridStringOperators, aw as getModelsParsedOrUpdateLocalStorage, ai as getPaginationFromString, am as getPinnedColumnsFromString, at as getSearchParamsFromColumnOrder, al as getSearchParamsFromColumnVisibility, aq as getSearchParamsFromDensity, af as getSearchParamsFromFilterModel, aj as getSearchParamsFromPagination, an as getSearchParamsFromPinnedColumns, ah as getSearchParamsFromSorting, ao as getSearchParamsFromTab, au as getSearchParamsFromVersion, ag as getSortingFromString, ac as isOperatorValueValid, ad as isValueValid, ab as numberOperatorDecoder, aa as numberOperatorEncoder, o as operatorList, a1 as resetColumnVisibility, a0 as resetStatefulDataGridState, ax as updateUrl, a9 as urlSearchParamsToString } from './_internal/StatefulDataGrid2.js';
|
|
3
|
+
import { GRID_DETAIL_PANEL_TOGGLE_COL_DEF, getGridDateOperators, getGridStringOperators, getGridNumericOperators } from '@mui/x-data-grid-pro';
|
|
4
|
+
export { getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-pro';
|
|
5
5
|
import { _ as _objectSpread2 } from './_internal/_rollupPluginBabelHelpers.js';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
|
|
8
|
-
import Box from '@mui/material/Box';
|
|
9
|
-
import TextField from '@mui/material/TextField';
|
|
10
8
|
import { Icon } from '@redsift/design-system';
|
|
11
9
|
import { mdiSync } from '@redsift/icons';
|
|
12
10
|
export { D as DEFAULT_OPERATORS, G as GridToolbarFilterSemanticField, g as getCompletion } from './_internal/GridToolbarFilterSemanticField2.js';
|
|
13
|
-
export {
|
|
14
|
-
export { B as BaseButton, a as BaseCheckbox, b as BaseIcon, c as BaseIconButton, m as muiIconToDSIcon } from './_internal/BaseIconButton.js';
|
|
11
|
+
export { B as BaseButton, a as BaseCheckbox, b as BaseIcon, c as BasePopper, m as muiIconToDSIcon } from './_internal/BasePopper.js';
|
|
15
12
|
export { B as BaseTextField } from './_internal/BaseTextField.js';
|
|
16
13
|
export { D as DataGrid } from './_internal/DataGrid2.js';
|
|
14
|
+
export { C as ControlledPagination, S as ServerSideControlledPagination, f as fixServerSideHeaderCheckboxSelection, g as getSelectableRowIdsInPage, o as onServerSideSelectionStatusChange } from './_internal/ControlledPagination.js';
|
|
17
15
|
export { T as TextCell } from './_internal/TextCell2.js';
|
|
18
16
|
export { T as Toolbar } from './_internal/Toolbar2.js';
|
|
19
17
|
export { T as ToolbarWrapper } from './_internal/ToolbarWrapper2.js';
|
|
@@ -22,37 +20,6 @@ export { T as ToolbarWrapper } from './_internal/ToolbarWrapper2.js';
|
|
|
22
20
|
const DETAIL_PANEL_TOGGLE_COL_DEF = GRID_DETAIL_PANEL_TOGGLE_COL_DEF;
|
|
23
21
|
DETAIL_PANEL_TOGGLE_COL_DEF.type = 'actions';
|
|
24
22
|
|
|
25
|
-
const isAnyOfIOperator = {
|
|
26
|
-
label: 'is any of (case-insensitive)',
|
|
27
|
-
value: 'isAnyOfI',
|
|
28
|
-
getApplyFilterFn: filterItem => {
|
|
29
|
-
if (!filterItem.field || !filterItem.value || !filterItem.operator) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const lowerCaseFilterValues = filterItem.value.map(v => String(v).toLowerCase());
|
|
33
|
-
return value => {
|
|
34
|
-
if (filterItem.value.length === 0) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
if (value == null) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const paramValues = Array.isArray(value) ? value : [value];
|
|
41
|
-
for (const paramValue of paramValues) {
|
|
42
|
-
if (lowerCaseFilterValues.includes(String(paramValue).toLowerCase())) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
InputComponent: GridFilterInputMultipleValue
|
|
50
|
-
};
|
|
51
|
-
const IS_ANY_OF_I = isAnyOfIOperator;
|
|
52
|
-
const IS_ANY_OF_I_WITH_SELECT = _objectSpread2(_objectSpread2({}, IS_ANY_OF_I), {}, {
|
|
53
|
-
InputComponent: GridFilterInputMultipleSingleSelect
|
|
54
|
-
});
|
|
55
|
-
|
|
56
23
|
const SUBMIT_FILTER_STROKE_TIME = 500;
|
|
57
24
|
const InputDateInterval = props => {
|
|
58
25
|
var _item$value, _filterValueState$, _filterValueState$2;
|
|
@@ -206,9 +173,8 @@ const wrapCaseInsensitive = operator => {
|
|
|
206
173
|
if (!originalFn) {
|
|
207
174
|
return null;
|
|
208
175
|
}
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
return originalFn(lowercasedValue, row, column, apiRef);
|
|
176
|
+
return value => {
|
|
177
|
+
return originalFn(lowercaseValue(value));
|
|
212
178
|
};
|
|
213
179
|
}
|
|
214
180
|
});
|
|
@@ -296,7 +262,7 @@ const getTagsOperatorsCompact = () => [HAS, DOES_NOT_HAVE, HAS_ANY_OF];
|
|
|
296
262
|
// ---------------------------------------------------------------------------
|
|
297
263
|
|
|
298
264
|
const isOverrideOptions = options => {
|
|
299
|
-
return options && 'operators' in options;
|
|
265
|
+
return options != null && typeof options === 'object' && 'operators' in options;
|
|
300
266
|
};
|
|
301
267
|
const arraySortComparator = (a, b) => {
|
|
302
268
|
const arrA = Array.isArray(a) ? a : [];
|
|
@@ -416,115 +382,6 @@ function getOperatorsForType(type, compact) {
|
|
|
416
382
|
}
|
|
417
383
|
}
|
|
418
384
|
|
|
419
|
-
/**
|
|
420
|
-
* A React Router v5 / connected-react-router adapter for `StatefulDataGrid.useRouter`.
|
|
421
|
-
*
|
|
422
|
-
* Defers `history.replace` via `queueMicrotask` to avoid the
|
|
423
|
-
* "Cannot update during an existing state transition" warning
|
|
424
|
-
* that connected-react-router triggers when the grid synchronises
|
|
425
|
-
* URL state during render.
|
|
426
|
-
*
|
|
427
|
-
* Also coalesces multiple `historyReplace` calls within the same microtask
|
|
428
|
-
* by computing per-call deltas against the captured `search` snapshot and
|
|
429
|
-
* merging them into the live URL. This prevents handler stomping when the
|
|
430
|
-
* grid fires several model-change handlers in the same render (e.g. a
|
|
431
|
-
* pivot change re-emits a synthetic column-visibility change alongside a
|
|
432
|
-
* filter change): without coalescing, each handler would compute a full
|
|
433
|
-
* new search from the same captured snapshot, and the second
|
|
434
|
-
* `history.replace` would clobber the first — dropping any keys (such as
|
|
435
|
-
* the filter just typed) that the second handler didn't know about.
|
|
436
|
-
*
|
|
437
|
-
* @example
|
|
438
|
-
* ```tsx
|
|
439
|
-
* import { createReactRouterV5Adapter } from '@redsift/table';
|
|
440
|
-
*
|
|
441
|
-
* const useRouter = createReactRouterV5Adapter(history);
|
|
442
|
-
*
|
|
443
|
-
* <StatefulDataGrid useRouter={useRouter} … />
|
|
444
|
-
* ```
|
|
445
|
-
*/
|
|
446
|
-
|
|
447
|
-
/** Minimal subset of React Router v5 `history` used by the adapter. */
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* Create a `useRouter` hook compatible with `StatefulDataGrid` from a
|
|
451
|
-
* React Router v5 `history` object.
|
|
452
|
-
*/
|
|
453
|
-
const createReactRouterV5Adapter = history => {
|
|
454
|
-
// Module-instance state shared across all `historyReplace` calls scheduled
|
|
455
|
-
// within the same microtask. Each `useRouter()` invocation captures its own
|
|
456
|
-
// `search` snapshot for delta computation; `pending` accumulates the deltas
|
|
457
|
-
// and is flushed once per microtask onto the live URL.
|
|
458
|
-
let pending = null;
|
|
459
|
-
let flushScheduled = false;
|
|
460
|
-
const scheduleFlush = () => {
|
|
461
|
-
if (flushScheduled) return;
|
|
462
|
-
flushScheduled = true;
|
|
463
|
-
queueMicrotask(() => {
|
|
464
|
-
flushScheduled = false;
|
|
465
|
-
const flush = pending;
|
|
466
|
-
pending = null;
|
|
467
|
-
if (flush === null) return;
|
|
468
|
-
const serialized = flush.toString();
|
|
469
|
-
const nextSearch = serialized ? `?${serialized}` : '';
|
|
470
|
-
if (nextSearch === history.location.search) return;
|
|
471
|
-
history.replace({
|
|
472
|
-
pathname: history.location.pathname,
|
|
473
|
-
search: nextSearch
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
};
|
|
477
|
-
return () => {
|
|
478
|
-
// Capture the search snapshot AT THE TIME useRouter() is called. The
|
|
479
|
-
// grid hands this string to its change handlers, which build a complete
|
|
480
|
-
// new search string from it. Diffing the handler's `newSearch` against
|
|
481
|
-
// this captured snapshot tells us which keys the handler intentionally
|
|
482
|
-
// changed (vs. which are stale passthrough from sibling handlers' models).
|
|
483
|
-
const captured = history.location.search.replace(/^\?/, '');
|
|
484
|
-
const capturedParams = new URLSearchParams(captured);
|
|
485
|
-
const capturedKeys = new Set(capturedParams.keys());
|
|
486
|
-
return {
|
|
487
|
-
pathname: history.location.pathname,
|
|
488
|
-
search: captured,
|
|
489
|
-
historyReplace: newSearch => {
|
|
490
|
-
const newParams = new URLSearchParams(newSearch);
|
|
491
|
-
const newKeys = new Set(newParams.keys());
|
|
492
|
-
|
|
493
|
-
// Lazy-init `pending` from the LIVE URL — not the captured snapshot —
|
|
494
|
-
// so deltas from earlier microtask-scheduled calls (which may have
|
|
495
|
-
// already been flushed, or were scheduled by a previous render and
|
|
496
|
-
// are now reflected in the live URL) are preserved.
|
|
497
|
-
if (pending === null) {
|
|
498
|
-
pending = new URLSearchParams(history.location.search.replace(/^\?/, ''));
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// Apply only keys this handler actually changed. A handler builds a
|
|
502
|
-
// complete new search from a captured snapshot, but only some keys
|
|
503
|
-
// reflect its intent — the rest are passthrough of the snapshot.
|
|
504
|
-
// When two handlers fire in the same render and one was triggered
|
|
505
|
-
// by a model the other doesn't care about, passthrough keys would
|
|
506
|
-
// otherwise stomp pending state from earlier handlers.
|
|
507
|
-
for (const key of newKeys) {
|
|
508
|
-
const newValues = newParams.getAll(key);
|
|
509
|
-
const capturedValues = capturedParams.getAll(key);
|
|
510
|
-
const unchanged = newValues.length === capturedValues.length && newValues.every((v, i) => v === capturedValues[i]);
|
|
511
|
-
if (unchanged) continue;
|
|
512
|
-
pending.delete(key);
|
|
513
|
-
for (const value of newValues) {
|
|
514
|
-
pending.append(key, value);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
// Keys that were in the captured snapshot but absent from newSearch
|
|
518
|
-
// were intentionally removed by this handler.
|
|
519
|
-
for (const key of capturedKeys) {
|
|
520
|
-
if (!newKeys.has(key)) pending.delete(key);
|
|
521
|
-
}
|
|
522
|
-
scheduleFlush();
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
};
|
|
526
|
-
};
|
|
527
|
-
|
|
528
385
|
const EMPTY_FILTER_MODEL = {
|
|
529
386
|
items: []
|
|
530
387
|
};
|
|
@@ -717,5 +574,138 @@ function useLinkedFilterModel() {
|
|
|
717
574
|
}), [filterModel, onFilterModelChange, getSelected, getValue, setMultiSelect, setBoolean, clearField, reset, isFieldExternallyControlled]);
|
|
718
575
|
}
|
|
719
576
|
|
|
720
|
-
|
|
577
|
+
/**
|
|
578
|
+
* A React Router v5 / connected-react-router adapter for `StatefulDataGrid.useRouter`.
|
|
579
|
+
*
|
|
580
|
+
* Defers `history.replace` via `queueMicrotask` to avoid the
|
|
581
|
+
* "Cannot update during an existing state transition" warning
|
|
582
|
+
* that connected-react-router triggers when the grid synchronises
|
|
583
|
+
* URL state during render.
|
|
584
|
+
*
|
|
585
|
+
* Also coalesces multiple `historyReplace` calls within the same microtask
|
|
586
|
+
* by computing per-call deltas against the captured `search` snapshot and
|
|
587
|
+
* merging them into the live URL. This prevents handler stomping when the
|
|
588
|
+
* grid fires several model-change handlers in the same render (e.g. a
|
|
589
|
+
* pivot change re-emits a synthetic column-visibility change alongside a
|
|
590
|
+
* filter change): without coalescing, each handler would compute a full
|
|
591
|
+
* new search from the same captured snapshot, and the second
|
|
592
|
+
* `history.replace` would clobber the first — dropping any keys (such as
|
|
593
|
+
* the filter just typed) that the second handler didn't know about.
|
|
594
|
+
*
|
|
595
|
+
* Callers that need an authoritative full-URL replacement (e.g.
|
|
596
|
+
* `resetStatefulDataGridState`, which must clear grid params even when the
|
|
597
|
+
* parent component's captured search snapshot is stale relative to the live
|
|
598
|
+
* URL) can pass `{ authoritative: true }` as the second argument to
|
|
599
|
+
* `historyReplace`. Authoritative writes bypass the delta logic and write
|
|
600
|
+
* synchronously to the live URL.
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* ```tsx
|
|
604
|
+
* import { createReactRouterV5Adapter } from '@redsift/table';
|
|
605
|
+
*
|
|
606
|
+
* const useRouter = createReactRouterV5Adapter(history);
|
|
607
|
+
*
|
|
608
|
+
* <StatefulDataGrid useRouter={useRouter} … />
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
|
|
612
|
+
/** Minimal subset of React Router v5 `history` used by the adapter. */
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Create a `useRouter` hook compatible with `StatefulDataGrid` from a
|
|
616
|
+
* React Router v5 `history` object.
|
|
617
|
+
*/
|
|
618
|
+
const createReactRouterV5Adapter = history => {
|
|
619
|
+
// Module-instance state shared across all `historyReplace` calls scheduled
|
|
620
|
+
// within the same microtask. Each `useRouter()` invocation captures its own
|
|
621
|
+
// `search` snapshot for delta computation; `pending` accumulates the deltas
|
|
622
|
+
// and is flushed once per microtask onto the live URL.
|
|
623
|
+
let pending = null;
|
|
624
|
+
let flushScheduled = false;
|
|
625
|
+
const scheduleFlush = () => {
|
|
626
|
+
if (flushScheduled) return;
|
|
627
|
+
flushScheduled = true;
|
|
628
|
+
queueMicrotask(() => {
|
|
629
|
+
flushScheduled = false;
|
|
630
|
+
const flush = pending;
|
|
631
|
+
pending = null;
|
|
632
|
+
if (flush === null) return;
|
|
633
|
+
const serialized = flush.toString();
|
|
634
|
+
const nextSearch = serialized ? `?${serialized}` : '';
|
|
635
|
+
if (nextSearch === history.location.search) return;
|
|
636
|
+
history.replace({
|
|
637
|
+
pathname: history.location.pathname,
|
|
638
|
+
search: nextSearch
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
};
|
|
642
|
+
return () => {
|
|
643
|
+
// Capture the search snapshot AT THE TIME useRouter() is called. The
|
|
644
|
+
// grid hands this string to its change handlers, which build a complete
|
|
645
|
+
// new search string from it. Diffing the handler's `newSearch` against
|
|
646
|
+
// this captured snapshot tells us which keys the handler intentionally
|
|
647
|
+
// changed (vs. which are stale passthrough from sibling handlers' models).
|
|
648
|
+
const captured = history.location.search.replace(/^\?/, '');
|
|
649
|
+
const capturedParams = new URLSearchParams(captured);
|
|
650
|
+
const capturedKeys = new Set(capturedParams.keys());
|
|
651
|
+
return {
|
|
652
|
+
pathname: history.location.pathname,
|
|
653
|
+
search: captured,
|
|
654
|
+
historyReplace: (newSearch, options) => {
|
|
655
|
+
// Authoritative writes (e.g. `resetStatefulDataGridState`) bypass the
|
|
656
|
+
// delta-vs-captured-snapshot logic. The caller asserts that `newSearch`
|
|
657
|
+
// is the complete intended query string; write it synchronously and
|
|
658
|
+
// discard any pending coalesced deltas so this write cannot be stomped
|
|
659
|
+
// by a previously-scheduled flush.
|
|
660
|
+
if (options !== null && options !== void 0 && options.authoritative) {
|
|
661
|
+
pending = null;
|
|
662
|
+
flushScheduled = false;
|
|
663
|
+
const trimmed = newSearch.replace(/^\?/, '');
|
|
664
|
+
const nextSearch = trimmed ? `?${trimmed}` : '';
|
|
665
|
+
if (nextSearch === history.location.search) return;
|
|
666
|
+
history.replace({
|
|
667
|
+
pathname: history.location.pathname,
|
|
668
|
+
search: nextSearch
|
|
669
|
+
});
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const newParams = new URLSearchParams(newSearch);
|
|
673
|
+
const newKeys = new Set(newParams.keys());
|
|
674
|
+
|
|
675
|
+
// Lazy-init `pending` from the LIVE URL — not the captured snapshot —
|
|
676
|
+
// so deltas from earlier microtask-scheduled calls (which may have
|
|
677
|
+
// already been flushed, or were scheduled by a previous render and
|
|
678
|
+
// are now reflected in the live URL) are preserved.
|
|
679
|
+
if (pending === null) {
|
|
680
|
+
pending = new URLSearchParams(history.location.search.replace(/^\?/, ''));
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// Apply only keys this handler actually changed. A handler builds a
|
|
684
|
+
// complete new search from a captured snapshot, but only some keys
|
|
685
|
+
// reflect its intent — the rest are passthrough of the snapshot.
|
|
686
|
+
// When two handlers fire in the same render and one was triggered
|
|
687
|
+
// by a model the other doesn't care about, passthrough keys would
|
|
688
|
+
// otherwise stomp pending state from earlier handlers.
|
|
689
|
+
for (const key of newKeys) {
|
|
690
|
+
const newValues = newParams.getAll(key);
|
|
691
|
+
const capturedValues = capturedParams.getAll(key);
|
|
692
|
+
const unchanged = newValues.length === capturedValues.length && newValues.every((v, i) => v === capturedValues[i]);
|
|
693
|
+
if (unchanged) continue;
|
|
694
|
+
pending.delete(key);
|
|
695
|
+
for (const value of newValues) {
|
|
696
|
+
pending.append(key, value);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
// Keys that were in the captured snapshot but absent from newSearch
|
|
700
|
+
// were intentionally removed by this handler.
|
|
701
|
+
for (const key of capturedKeys) {
|
|
702
|
+
if (!newKeys.has(key)) pending.delete(key);
|
|
703
|
+
}
|
|
704
|
+
scheduleFlush();
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
export { DATE_IS_BETWEEN, DETAIL_PANEL_TOGGLE_COL_DEF, createColumn, createReactRouterV5Adapter, customColumnTypes, getGridDateOperatorsExtended, getRsMultipleSelectColumnType, getRsMultipleSelectWithShortOperatorListColumnType, getRsNumberColumnType, getRsSingleSelectColumnType, getRsSingleSelectWithShortOperatorListColumnType, getRsStringColumnType, makeCaseInsensitive, useLinkedFilterModel, wrapCaseInsensitive };
|
|
721
711
|
//# sourceMappingURL=index.js.map
|