@redsift/table 12.5.9-muiv7 → 12.5.9

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/index.js CHANGED
@@ -1,17 +1,19 @@
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, aA as StatefulDataGrid, V as VISIBILITY_MODEL_KEY, az 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, at as getColumnOrderFromString, al as getColumnVisibilityFromString, a4 as getDecodedSearchFromUrl, aq as getDensityFromString, as as getDensityModel, ae as getFilterModelFromString, aw as getFinalSearch, z as getGridNumericOperators, K as getGridStringArrayOperators, L as getGridStringArrayOperatorsWithSelect, M as getGridStringArrayOperatorsWithSelectOnStringArrayColumns, J as getGridStringOperators, ax as getModelsParsedOrUpdateLocalStorage, aj as getPaginationFromString, an as getPinnedColumnsFromString, au as getSearchParamsFromColumnOrder, am as getSearchParamsFromColumnVisibility, ar as getSearchParamsFromDensity, ag as getSearchParamsFromFilterModel, ak as getSearchParamsFromPagination, ao as getSearchParamsFromPinnedColumns, ai as getSearchParamsFromSorting, ap as getSearchParamsFromTab, av as getSearchParamsFromVersion, ah as getSortingFromString, ac as isOperatorValueValid, ad as isValueValid, af as normalizeDateValue, ab as numberOperatorDecoder, aa as numberOperatorEncoder, o as operatorList, a1 as resetColumnVisibility, a0 as resetStatefulDataGridState, ay 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';
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 { X as AGGREGATION_MODEL_KEY, A as ARRAY_IS_EMPTY, m as ARRAY_IS_NOT_EMPTY, _ as CATEGORIES, U as COLUMN_ORDER_MODEL_KEY, C as CONTAINS_ANY_OF, T as DENSITY_MODEL_KEY, Q 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, M as FILTER_MODEL_KEY, R 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, B as IS, I as IS_ANY_OF, k as IS_ANY_OF_WITH_SELECT, h as IS_BETWEEN, F 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, O as PINNED_COLUMNS, Z as PIVOT_ACTIVE_KEY, Y as PIVOT_MODEL_KEY, W as ROW_GROUPING_MODEL_KEY, N as SORT_MODEL_KEY, S as STARTS_WITH_ANY_OF, aL as StatefulDataGrid, V as VISIBILITY_MODEL_KEY, aK as areFilterModelsEquivalent, a8 as areSearchStringsEqual, a7 as buildQueryParamsString, $ as buildStorageKey, a1 as clearAllVersionStorage, a0 as clearPreviousVersionStorage, a5 as convertFromDisplayFormat, a4 as convertToDisplayFormat, a9 as decodeValue, aa as encodeValue, aB as fromGridPivotModel, az as getAggregationFromString, av as getColumnOrderFromString, an as getColumnVisibilityFromString, a6 as getDecodedSearchFromUrl, as as getDensityFromString, au as getDensityModel, ag as getFilterModelFromString, aH as getFinalSearch, z as getGridNumericOperators, J as getGridStringArrayOperators, K as getGridStringArrayOperatorsWithSelect, L as getGridStringArrayOperatorsWithSelectOnStringArrayColumns, G as getGridStringOperators, aI as getModelsParsedOrUpdateLocalStorage, al as getPaginationFromString, ap as getPinnedColumnsFromString, aE as getPivotActiveFromString, aC as getPivotFromString, ax as getRowGroupingFromString, aA as getSearchParamsFromAggregation, aw as getSearchParamsFromColumnOrder, ao as getSearchParamsFromColumnVisibility, at as getSearchParamsFromDensity, ai as getSearchParamsFromFilterModel, am as getSearchParamsFromPagination, aq as getSearchParamsFromPinnedColumns, aD as getSearchParamsFromPivot, aF as getSearchParamsFromPivotActive, ay as getSearchParamsFromRowGrouping, ak as getSearchParamsFromSorting, ar as getSearchParamsFromTab, aG as getSearchParamsFromVersion, aj as getSortingFromString, ae as isOperatorValueValid, af as isValueValid, ah as normalizeDateValue, ad as numberOperatorDecoder, ac as numberOperatorEncoder, o as operatorList, a3 as resetColumnVisibility, a2 as resetStatefulDataGridState, aJ as updateUrl, ab as urlSearchParamsToString } from './_internal/StatefulDataGrid2.js';
3
+ import { GRID_DETAIL_PANEL_TOGGLE_COL_DEF, GridFilterInputMultipleValue, GridFilterInputMultipleSingleSelect, getGridDateOperators, getGridStringOperators, getGridNumericOperators } from '@mui/x-data-grid-premium';
4
+ export { getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-premium';
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';
8
10
  import { Icon } from '@redsift/design-system';
9
11
  import { mdiSync } from '@redsift/icons';
10
12
  export { D as DEFAULT_OPERATORS, G as GridToolbarFilterSemanticField, g as getCompletion } from './_internal/GridToolbarFilterSemanticField2.js';
11
- export { B as BaseButton, a as BaseCheckbox, b as BaseIcon, c as BasePopper, m as muiIconToDSIcon } from './_internal/BasePopper.js';
13
+ export { C as ControlledPagination, E as EMPTY_ROW_SELECTION_MODEL, S as ServerSideControlledPagination, c as createRowSelectionModel, f as fixServerSideHeaderCheckboxSelection, b as getSelectableRowIdsInPage, a as getSelectedIds, g as getSelectionCount, i as isRowSelected, n as normalizeRowSelectionModel, o as onServerSideSelectionStatusChange } from './_internal/ServerSideControlledPagination.js';
14
+ export { B as BaseButton, a as BaseCheckbox, b as BaseIcon, c as BaseIconButton, m as muiIconToDSIcon } from './_internal/BaseIconButton.js';
12
15
  export { B as BaseTextField } from './_internal/BaseTextField.js';
13
16
  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/ServerSideControlledPagination.js';
15
17
  export { T as TextCell } from './_internal/TextCell2.js';
16
18
  export { T as Toolbar } from './_internal/Toolbar2.js';
17
19
  export { T as ToolbarWrapper } from './_internal/ToolbarWrapper2.js';
@@ -20,6 +22,37 @@ export { T as ToolbarWrapper } from './_internal/ToolbarWrapper2.js';
20
22
  const DETAIL_PANEL_TOGGLE_COL_DEF = GRID_DETAIL_PANEL_TOGGLE_COL_DEF;
21
23
  DETAIL_PANEL_TOGGLE_COL_DEF.type = 'actions';
22
24
 
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
+
23
56
  const SUBMIT_FILTER_STROKE_TIME = 500;
24
57
  const InputDateInterval = props => {
25
58
  var _item$value, _filterValueState$, _filterValueState$2;
@@ -173,8 +206,9 @@ const wrapCaseInsensitive = operator => {
173
206
  if (!originalFn) {
174
207
  return null;
175
208
  }
176
- return value => {
177
- return originalFn(lowercaseValue(value));
209
+ return (value, row, column, apiRef) => {
210
+ const lowercasedValue = lowercaseValue(value);
211
+ return originalFn(lowercasedValue, row, column, apiRef);
178
212
  };
179
213
  }
180
214
  });
@@ -262,7 +296,7 @@ const getTagsOperatorsCompact = () => [HAS, DOES_NOT_HAVE, HAS_ANY_OF];
262
296
  // ---------------------------------------------------------------------------
263
297
 
264
298
  const isOverrideOptions = options => {
265
- return options != null && typeof options === 'object' && 'operators' in options;
299
+ return options && 'operators' in options;
266
300
  };
267
301
  const arraySortComparator = (a, b) => {
268
302
  const arrA = Array.isArray(a) ? a : [];
@@ -382,6 +416,139 @@ function getOperatorsForType(type, compact) {
382
416
  }
383
417
  }
384
418
 
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
+ * Callers that need an authoritative full-URL replacement (e.g.
438
+ * `resetStatefulDataGridState`, which must clear grid params even when the
439
+ * parent component's captured search snapshot is stale relative to the live
440
+ * URL) can pass `{ authoritative: true }` as the second argument to
441
+ * `historyReplace`. Authoritative writes bypass the delta logic and write
442
+ * synchronously to the live URL.
443
+ *
444
+ * @example
445
+ * ```tsx
446
+ * import { createReactRouterV5Adapter } from '@redsift/table';
447
+ *
448
+ * const useRouter = createReactRouterV5Adapter(history);
449
+ *
450
+ * <StatefulDataGrid useRouter={useRouter} … />
451
+ * ```
452
+ */
453
+
454
+ /** Minimal subset of React Router v5 `history` used by the adapter. */
455
+
456
+ /**
457
+ * Create a `useRouter` hook compatible with `StatefulDataGrid` from a
458
+ * React Router v5 `history` object.
459
+ */
460
+ const createReactRouterV5Adapter = history => {
461
+ // Module-instance state shared across all `historyReplace` calls scheduled
462
+ // within the same microtask. Each `useRouter()` invocation captures its own
463
+ // `search` snapshot for delta computation; `pending` accumulates the deltas
464
+ // and is flushed once per microtask onto the live URL.
465
+ let pending = null;
466
+ let flushScheduled = false;
467
+ const scheduleFlush = () => {
468
+ if (flushScheduled) return;
469
+ flushScheduled = true;
470
+ queueMicrotask(() => {
471
+ flushScheduled = false;
472
+ const flush = pending;
473
+ pending = null;
474
+ if (flush === null) return;
475
+ const serialized = flush.toString();
476
+ const nextSearch = serialized ? `?${serialized}` : '';
477
+ if (nextSearch === history.location.search) return;
478
+ history.replace({
479
+ pathname: history.location.pathname,
480
+ search: nextSearch
481
+ });
482
+ });
483
+ };
484
+ return () => {
485
+ // Capture the search snapshot AT THE TIME useRouter() is called. The
486
+ // grid hands this string to its change handlers, which build a complete
487
+ // new search string from it. Diffing the handler's `newSearch` against
488
+ // this captured snapshot tells us which keys the handler intentionally
489
+ // changed (vs. which are stale passthrough from sibling handlers' models).
490
+ const captured = history.location.search.replace(/^\?/, '');
491
+ const capturedParams = new URLSearchParams(captured);
492
+ const capturedKeys = new Set(capturedParams.keys());
493
+ return {
494
+ pathname: history.location.pathname,
495
+ search: captured,
496
+ historyReplace: (newSearch, options) => {
497
+ // Authoritative writes (e.g. `resetStatefulDataGridState`) bypass the
498
+ // delta-vs-captured-snapshot logic. The caller asserts that `newSearch`
499
+ // is the complete intended query string; write it synchronously and
500
+ // discard any pending coalesced deltas so this write cannot be stomped
501
+ // by a previously-scheduled flush.
502
+ if (options !== null && options !== void 0 && options.authoritative) {
503
+ pending = null;
504
+ flushScheduled = false;
505
+ const trimmed = newSearch.replace(/^\?/, '');
506
+ const nextSearch = trimmed ? `?${trimmed}` : '';
507
+ if (nextSearch === history.location.search) return;
508
+ history.replace({
509
+ pathname: history.location.pathname,
510
+ search: nextSearch
511
+ });
512
+ return;
513
+ }
514
+ const newParams = new URLSearchParams(newSearch);
515
+ const newKeys = new Set(newParams.keys());
516
+
517
+ // Lazy-init `pending` from the LIVE URL — not the captured snapshot —
518
+ // so deltas from earlier microtask-scheduled calls (which may have
519
+ // already been flushed, or were scheduled by a previous render and
520
+ // are now reflected in the live URL) are preserved.
521
+ if (pending === null) {
522
+ pending = new URLSearchParams(history.location.search.replace(/^\?/, ''));
523
+ }
524
+
525
+ // Apply only keys this handler actually changed. A handler builds a
526
+ // complete new search from a captured snapshot, but only some keys
527
+ // reflect its intent — the rest are passthrough of the snapshot.
528
+ // When two handlers fire in the same render and one was triggered
529
+ // by a model the other doesn't care about, passthrough keys would
530
+ // otherwise stomp pending state from earlier handlers.
531
+ for (const key of newKeys) {
532
+ const newValues = newParams.getAll(key);
533
+ const capturedValues = capturedParams.getAll(key);
534
+ const unchanged = newValues.length === capturedValues.length && newValues.every((v, i) => v === capturedValues[i]);
535
+ if (unchanged) continue;
536
+ pending.delete(key);
537
+ for (const value of newValues) {
538
+ pending.append(key, value);
539
+ }
540
+ }
541
+ // Keys that were in the captured snapshot but absent from newSearch
542
+ // were intentionally removed by this handler.
543
+ for (const key of capturedKeys) {
544
+ if (!newKeys.has(key)) pending.delete(key);
545
+ }
546
+ scheduleFlush();
547
+ }
548
+ };
549
+ };
550
+ };
551
+
385
552
  const EMPTY_FILTER_MODEL = {
386
553
  items: []
387
554
  };
@@ -574,138 +741,5 @@ function useLinkedFilterModel() {
574
741
  }), [filterModel, onFilterModelChange, getSelected, getValue, setMultiSelect, setBoolean, clearField, reset, isFieldExternallyControlled]);
575
742
  }
576
743
 
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 };
744
+ export { DATE_IS_BETWEEN, DETAIL_PANEL_TOGGLE_COL_DEF, IS_ANY_OF_I, IS_ANY_OF_I_WITH_SELECT, createColumn, createReactRouterV5Adapter, customColumnTypes, getGridDateOperatorsExtended, getRsMultipleSelectColumnType, getRsMultipleSelectWithShortOperatorListColumnType, getRsNumberColumnType, getRsSingleSelectColumnType, getRsSingleSelectWithShortOperatorListColumnType, getRsStringColumnType, makeCaseInsensitive, useLinkedFilterModel, wrapCaseInsensitive };
711
745
  //# sourceMappingURL=index.js.map