@gridkitjs/react 0.0.0-dev-20261108230616 → 0.0.0-dev-20261108231420

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/dist/index.js CHANGED
@@ -6,8 +6,8 @@ import {
6
6
  useId as useId2,
7
7
  useImperativeHandle as useImperativeHandle3,
8
8
  useMemo as useMemo5,
9
- useRef as useRef22,
10
- useState as useState20
9
+ useRef as useRef21,
10
+ useState as useState18
11
11
  } from "react";
12
12
  import {
13
13
  moveColumnBefore,
@@ -122,6 +122,7 @@ function tabIndexFor(columnIndex, focusedColumnIndex) {
122
122
  return columnIndex === focusedColumnIndex ? 0 : -1;
123
123
  }
124
124
  function useGridNavigation({
125
+ gridRef,
125
126
  headerTableRef,
126
127
  bodyTableRef,
127
128
  rowCount,
@@ -146,7 +147,10 @@ function useGridNavigation({
146
147
  getHeaderRow: () => headerTableRef.current?.tHead?.rows[0] ?? null,
147
148
  getBodyRow: (rowIndex) => findBodyRow(bodyTableRef.current, rowIndex)
148
149
  }));
149
- useLayoutEffect(() => gridFocus.attach(rows), [gridFocus, rows]);
150
+ useLayoutEffect(
151
+ () => gridFocus.attach(rows, gridRef.current),
152
+ [gridFocus, rows, gridRef]
153
+ );
150
154
  useEffect(() => {
151
155
  gridFocus.focusDrawnCell(focus);
152
156
  });
@@ -161,9 +165,10 @@ function useGridNavigation({
161
165
  gridFocus.focusCell(rowIndex, columnIndex);
162
166
  gridFocus.focusDrawnCell(gridFocus.getFocus());
163
167
  },
164
- focusTabStop: () => {
165
- const cells = (focus.rowIndex === HEADER_ROW ? rows.getHeaderRow() : rows.getBodyRow(focus.rowIndex))?.cells;
166
- cells?.[Math.min(focus.columnIndex, cells.length - 1)]?.focus();
168
+ tabStopCell: () => {
169
+ const { rowIndex, columnIndex } = gridFocus.getFocus();
170
+ const cells = (rowIndex === HEADER_ROW ? rows.getHeaderRow() : rows.getBodyRow(rowIndex))?.cells;
171
+ return cells?.[Math.min(columnIndex, cells.length - 1)] ?? null;
167
172
  },
168
173
  onKeyDown: (event) => {
169
174
  if (gridFocus.handleKey(
@@ -236,7 +241,7 @@ function GridHeader({
236
241
  const beforeId = drag.dropTarget?.kind === "column-order" ? drag.dropTarget.beforeId : void 0;
237
242
  const draggedEntry = columns.find((entry) => entry.id === drag.draggedColumnId) ?? null;
238
243
  function toggleFilterMenu(columnId) {
239
- const { panel } = panels;
244
+ const panel = panels.current();
240
245
  if (panel?.kind === "filter" && panel.target.area === "header" && panel.target.columnId === columnId) {
241
246
  panels.close();
242
247
  } else {
@@ -1910,6 +1915,7 @@ function Overlay({
1910
1915
  offset,
1911
1916
  initialFocus,
1912
1917
  returnFocusTo,
1918
+ returnFocusFallback,
1913
1919
  ignoreScrollAfterInput,
1914
1920
  trapFocus,
1915
1921
  themeClassName,
@@ -1918,8 +1924,10 @@ function Overlay({
1918
1924
  }) {
1919
1925
  const panelRef = useRef4(null);
1920
1926
  const onDismissRef = useRef4(onDismiss);
1927
+ const returnFocusFallbackRef = useRef4(returnFocusFallback);
1921
1928
  useLayoutEffect2(() => {
1922
1929
  onDismissRef.current = onDismiss;
1930
+ returnFocusFallbackRef.current = returnFocusFallback;
1923
1931
  });
1924
1932
  useLayoutEffect2(() => {
1925
1933
  const panel = panelRef.current;
@@ -1932,6 +1940,7 @@ function Overlay({
1932
1940
  offset,
1933
1941
  initialFocus: attachedFocus(initialFocus),
1934
1942
  returnFocusTo,
1943
+ returnFocusFallback: () => returnFocusFallbackRef.current?.() ?? null,
1935
1944
  ignoreScrollAfterInput,
1936
1945
  trapFocus,
1937
1946
  onDismiss: (reason) => {
@@ -2125,6 +2134,9 @@ function GridMenu({
2125
2134
  const openEntry = submenu === null ? void 0 : entries.find(
2126
2135
  (entry) => entry.type === "submenu" && entry.id === submenu.id
2127
2136
  );
2137
+ if (submenu !== null && openEntry === void 0) {
2138
+ setSubmenu(null);
2139
+ }
2128
2140
  return /* @__PURE__ */ jsxs9(Fragment2, { children: [
2129
2141
  /* @__PURE__ */ jsx13(
2130
2142
  "div",
@@ -2177,7 +2189,7 @@ import { jsx as jsx14 } from "react/jsx-runtime";
2177
2189
  function GridContextMenu({
2178
2190
  contextMenu
2179
2191
  }) {
2180
- const { menu, run, close } = contextMenu;
2192
+ const { menu, returnFocusFallback, run, close } = contextMenu;
2181
2193
  if (menu === null) {
2182
2194
  return null;
2183
2195
  }
@@ -2187,6 +2199,7 @@ function GridContextMenu({
2187
2199
  anchor: menu.anchor,
2188
2200
  gap: menu.anchor instanceof Element ? ANCHOR_GAP : 0,
2189
2201
  returnFocusTo: menu.cell ?? void 0,
2202
+ returnFocusFallback,
2190
2203
  themeClassName: menu.themeClassName,
2191
2204
  onDismiss: close,
2192
2205
  children: /* @__PURE__ */ jsx14(
@@ -2206,10 +2219,10 @@ function GridContextMenu({
2206
2219
 
2207
2220
  // src/DataGrid/contextMenu/useContextMenu.ts
2208
2221
  import {
2222
+ useCallback,
2209
2223
  useEffect as useEffect3,
2210
2224
  useLayoutEffect as useLayoutEffect4,
2211
- useRef as useRef6,
2212
- useState as useState5
2225
+ useRef as useRef6
2213
2226
  } from "react";
2214
2227
  import {
2215
2228
  contextMenuEntries,
@@ -2358,7 +2371,7 @@ function useContextMenu({
2358
2371
  bodyTableRef,
2359
2372
  bodyScrollRef,
2360
2373
  contextMenu,
2361
- onContextMenuOpenChange,
2374
+ overlay,
2362
2375
  controller,
2363
2376
  commands,
2364
2377
  nav,
@@ -2366,8 +2379,7 @@ function useContextMenu({
2366
2379
  messages,
2367
2380
  columnName
2368
2381
  }) {
2369
- const [menu, setMenu] = useState5(null);
2370
- const current = useRef6(null);
2382
+ const { drawn, close: closeOverlay } = overlay;
2371
2383
  const openings = useRef6(0);
2372
2384
  const enabled = contextMenu !== void 0 && contextMenu !== false;
2373
2385
  function parts() {
@@ -2423,20 +2435,6 @@ function useContextMenu({
2423
2435
  context
2424
2436
  });
2425
2437
  }
2426
- function show(next) {
2427
- const previous = current.current;
2428
- if (previous === next) {
2429
- return;
2430
- }
2431
- current.current = next;
2432
- setMenu(next);
2433
- if (previous !== null) {
2434
- onContextMenuOpenChange?.({ open: false, target: previous.target });
2435
- }
2436
- if (next !== null) {
2437
- onContextMenuOpenChange?.({ open: true, target: next.target });
2438
- }
2439
- }
2440
2438
  function openAt({ target, cell, anchor }, point) {
2441
2439
  let resolved = resolveFor(target);
2442
2440
  if (resolved.length === 0) {
@@ -2450,14 +2448,17 @@ function useContextMenu({
2450
2448
  nav.focusCellNow(cell.rowIndex, cell.columnIndex);
2451
2449
  }
2452
2450
  openings.current += 1;
2453
- show({
2454
- key: openings.current,
2455
- target,
2456
- entries: resolved,
2457
- label: labelOf(target),
2458
- anchor: point ?? anchor,
2459
- cell: cell?.element ?? null,
2460
- themeClassName: overlayThemeClassName(rootRef.current)
2451
+ overlay.open({
2452
+ kind: "contextMenu",
2453
+ menu: {
2454
+ key: openings.current,
2455
+ target,
2456
+ entries: resolved,
2457
+ label: labelOf(target),
2458
+ anchor: point ?? anchor,
2459
+ cell: cell?.element ?? null,
2460
+ themeClassName: overlayThemeClassName(rootRef.current)
2461
+ }
2461
2462
  });
2462
2463
  return true;
2463
2464
  }
@@ -2478,28 +2479,22 @@ function useContextMenu({
2478
2479
  onRequest: (request) => latestRequest.current(request)
2479
2480
  });
2480
2481
  }, [rootRef, enabled]);
2481
- const shown = useRef6(null);
2482
- useLayoutEffect4(() => {
2483
- const closed = shown.current;
2484
- shown.current = menu;
2485
- if (menu === null && closed !== null && closed.cell !== null && !closed.cell.isConnected && document.activeElement === document.body) {
2486
- nav.focusTabStop();
2487
- }
2488
- });
2489
- function close() {
2490
- show(null);
2491
- }
2482
+ const close = useCallback(() => {
2483
+ closeOverlay("contextMenu");
2484
+ }, [closeOverlay]);
2485
+ useEffect3(() => enabled ? close : void 0, [enabled, close]);
2492
2486
  return {
2493
- menu,
2487
+ menu: drawn.kind === "contextMenu" ? drawn.menu : null,
2494
2488
  opens: (area) => hasContextMenu(contextMenu, area),
2495
2489
  open: (target, anchor) => {
2496
2490
  const place = placeOf(target, parts());
2497
2491
  return place !== null && openAt(place, anchor ?? null);
2498
2492
  },
2493
+ returnFocusFallback: overlay.returnFocusFallback,
2499
2494
  run: (item) => {
2500
- const open = current.current;
2501
- if (item.run() && open !== null) {
2502
- commands.report(item.id, open.target, "contextMenu");
2495
+ const open = overlay.current();
2496
+ if (item.run() && open.kind === "contextMenu") {
2497
+ commands.report(item.id, open.menu.target, "contextMenu");
2503
2498
  }
2504
2499
  close();
2505
2500
  },
@@ -2507,11 +2502,52 @@ function useContextMenu({
2507
2502
  };
2508
2503
  }
2509
2504
 
2505
+ // src/DataGrid/overlay/useGridOverlay.ts
2506
+ import { useCallback as useCallback2, useLayoutEffect as useLayoutEffect5, useRef as useRef7, useState as useState5 } from "react";
2507
+ var CLOSED = { kind: "closed" };
2508
+ function useGridOverlay({
2509
+ nav,
2510
+ onContextMenuOpenChange
2511
+ }) {
2512
+ const [drawn, setDrawn] = useState5(CLOSED);
2513
+ const current = useRef7(CLOSED);
2514
+ const reportOpenChange = useRef7(onContextMenuOpenChange);
2515
+ useLayoutEffect5(() => {
2516
+ reportOpenChange.current = onContextMenuOpenChange;
2517
+ });
2518
+ const show = useCallback2((next) => {
2519
+ const previous = current.current;
2520
+ current.current = next;
2521
+ setDrawn(next);
2522
+ if (previous.kind === "contextMenu") {
2523
+ reportOpenChange.current?.({ open: false, target: previous.menu.target });
2524
+ }
2525
+ if (next.kind === "contextMenu") {
2526
+ reportOpenChange.current?.({ open: true, target: next.menu.target });
2527
+ }
2528
+ }, []);
2529
+ const close = useCallback2(
2530
+ (kind) => {
2531
+ if (current.current.kind === kind) {
2532
+ show(CLOSED);
2533
+ }
2534
+ },
2535
+ [show]
2536
+ );
2537
+ return {
2538
+ drawn,
2539
+ current: () => current.current,
2540
+ open: show,
2541
+ close,
2542
+ returnFocusFallback: nav.tabStopCell
2543
+ };
2544
+ }
2545
+
2510
2546
  // src/DataGrid/panels/GridPanels.tsx
2511
2547
  import { useRef as useRef14 } from "react";
2512
2548
 
2513
2549
  // src/DataGrid/columnChooser/ColumnChooser.tsx
2514
- import { useLayoutEffect as useLayoutEffect5, useRef as useRef7, useState as useState6 } from "react";
2550
+ import { useLayoutEffect as useLayoutEffect6, useRef as useRef8, useState as useState6 } from "react";
2515
2551
  import { resolveColumnChooser } from "@gridkitjs/core";
2516
2552
  import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
2517
2553
  function ColumnChooser({
@@ -2519,13 +2555,13 @@ function ColumnChooser({
2519
2555
  messages
2520
2556
  }) {
2521
2557
  const [search, setSearch] = useState6("");
2522
- const showAllRef = useRef7(null);
2558
+ const showAllRef = useRef8(null);
2523
2559
  const { entries, selectAll, toggleAll } = resolveColumnChooser({
2524
2560
  columns: controller.getView().dataColumns,
2525
2561
  visibility: controller.getState().columnVisibility,
2526
2562
  search
2527
2563
  });
2528
- useLayoutEffect5(() => {
2564
+ useLayoutEffect6(() => {
2529
2565
  if (showAllRef.current !== null) {
2530
2566
  showAllRef.current.indeterminate = selectAll === "mixed";
2531
2567
  }
@@ -2596,7 +2632,7 @@ function ColumnChooser({
2596
2632
  }
2597
2633
 
2598
2634
  // src/DataGrid/filterMenu/FilterMenu.tsx
2599
- import { useEffect as useEffect4, useRef as useRef12 } from "react";
2635
+ import { useEffect as useEffect4, useRef as useRef13 } from "react";
2600
2636
  import {
2601
2637
  resolveColumnFilterMenu as resolveColumnFilterMenu2,
2602
2638
  resolveColumnHeaderText,
@@ -2606,23 +2642,102 @@ import {
2606
2642
  // src/DataGrid/filterMenu/ExcelFilterEditor.tsx
2607
2643
  import {
2608
2644
  useImperativeHandle as useImperativeHandle2,
2609
- useLayoutEffect as useLayoutEffect9,
2645
+ useLayoutEffect as useLayoutEffect10,
2610
2646
  useMemo as useMemo4,
2611
- useReducer,
2612
- useRef as useRef11,
2613
- useState as useState10
2647
+ useReducer as useReducer2,
2648
+ useRef as useRef12,
2649
+ useState as useState9
2614
2650
  } from "react";
2615
2651
  import {
2616
- describeColumnFilter as describeColumnFilter2,
2617
2652
  draftToFilter as draftToFilter2,
2618
2653
  filterChecklist,
2619
- filterEditorReducer as filterEditorReducer2,
2620
- initialFilterEditorDraft as initialFilterEditorDraft2,
2654
+ filterDraftChanged as filterDraftChanged3,
2621
2655
  selectAllState
2622
2656
  } from "@gridkitjs/core";
2623
2657
 
2658
+ // src/DataGrid/filterMenu/excelEditorState.ts
2659
+ import {
2660
+ describeColumnFilter,
2661
+ filterDraftChanged,
2662
+ filterEditorReducer,
2663
+ initialFilterEditorDraft
2664
+ } from "@gridkitjs/core";
2665
+ function openValues(filter, columnId, values) {
2666
+ const shape = describeColumnFilter(filter, columnId);
2667
+ return {
2668
+ over: filter,
2669
+ shape,
2670
+ draft: initialFilterEditorDraft(shape, values)
2671
+ };
2672
+ }
2673
+ function initialExcelEditorState(opened) {
2674
+ return { opened, draft: opened.draft };
2675
+ }
2676
+ function showsAlike(a, b) {
2677
+ return a.shape.kind === b.shape.kind && a.draft.options === b.draft.options && !filterDraftChanged(a.draft, b.draft);
2678
+ }
2679
+ function excelEditorReducer(state, action) {
2680
+ if (action.type === "filterChanged") {
2681
+ return showsAlike(state.opened, action.opened) ? { ...state, opened: action.opened } : initialExcelEditorState(action.opened);
2682
+ }
2683
+ return { ...state, draft: filterEditorReducer(state.draft, action) };
2684
+ }
2685
+
2686
+ // src/DataGrid/menu/useMenuButton.ts
2687
+ import {
2688
+ useLayoutEffect as useLayoutEffect7,
2689
+ useRef as useRef9,
2690
+ useState as useState7
2691
+ } from "react";
2692
+ var CLOSED2 = { kind: "closed" };
2693
+ function useMenuButton({
2694
+ itemCount,
2695
+ gap = () => ANCHOR_GAP
2696
+ }) {
2697
+ const [state, setState] = useState7(CLOSED2);
2698
+ const behaviourRef = useRef9(null);
2699
+ useLayoutEffect7(() => {
2700
+ if (state.kind === "open" && state.focusItem > 0) {
2701
+ behaviourRef.current?.focusItem(state.focusItem);
2702
+ }
2703
+ }, [state]);
2704
+ function open(button, onLast) {
2705
+ setState({
2706
+ kind: "open",
2707
+ anchor: button,
2708
+ themeClassName: overlayThemeClassName(button),
2709
+ gap: gap(button),
2710
+ focusItem: onLast ? itemCount - 1 : 0
2711
+ });
2712
+ }
2713
+ function close() {
2714
+ setState(CLOSED2);
2715
+ }
2716
+ return {
2717
+ state,
2718
+ close,
2719
+ buttonProps: {
2720
+ "aria-haspopup": "menu",
2721
+ "aria-expanded": state.kind === "open",
2722
+ onClick: (event) => {
2723
+ if (state.kind === "closed") {
2724
+ open(event.currentTarget, false);
2725
+ } else {
2726
+ close();
2727
+ }
2728
+ },
2729
+ onKeyDown: (event) => {
2730
+ if ((event.key === "ArrowDown" || event.key === "ArrowUp") && state.kind === "closed") {
2731
+ event.preventDefault();
2732
+ open(event.currentTarget, event.key === "ArrowUp");
2733
+ }
2734
+ }
2735
+ },
2736
+ behaviourRef
2737
+ };
2738
+ }
2739
+
2624
2740
  // src/DataGrid/filterMenu/OperatorMenuButton.tsx
2625
- import { useLayoutEffect as useLayoutEffect6, useRef as useRef8, useState as useState7 } from "react";
2626
2741
  import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
2627
2742
  function gapBeside(button) {
2628
2743
  const dialog = button.closest('[role="dialog"]') ?? button;
@@ -2635,25 +2750,11 @@ function OperatorMenuButton({
2635
2750
  onChoose,
2636
2751
  ref
2637
2752
  }) {
2638
- const [open, setOpen] = useState7(null);
2639
- const menuBehaviourRef = useRef8(null);
2753
+ const { state, close, buttonProps, behaviourRef } = useMenuButton({
2754
+ itemCount: menu.operators.length,
2755
+ gap: gapBeside
2756
+ });
2640
2757
  const label = messages.filterOperatorMenu(menu.family);
2641
- useLayoutEffect6(() => {
2642
- if (open !== null && open.focusItem > 0) {
2643
- menuBehaviourRef.current?.focusItem(open.focusItem);
2644
- }
2645
- }, [open]);
2646
- function show(button, onLast = false) {
2647
- setOpen({
2648
- anchor: button,
2649
- themeClassName: overlayThemeClassName(button),
2650
- gap: gapBeside(button),
2651
- focusItem: onLast ? menu.operators.length - 1 : 0
2652
- });
2653
- }
2654
- function close() {
2655
- setOpen(null);
2656
- }
2657
2758
  const entries = menu.operators.map((operator) => ({
2658
2759
  type: "item",
2659
2760
  id: operator,
@@ -2673,21 +2774,7 @@ function OperatorMenuButton({
2673
2774
  ref,
2674
2775
  type: "button",
2675
2776
  className: "filter-menu-submenu",
2676
- "aria-haspopup": "menu",
2677
- "aria-expanded": open !== null,
2678
- onClick: (event) => {
2679
- if (open === null) {
2680
- show(event.currentTarget);
2681
- } else {
2682
- close();
2683
- }
2684
- },
2685
- onKeyDown: (event) => {
2686
- if ((event.key === "ArrowDown" || event.key === "ArrowUp") && open === null) {
2687
- event.preventDefault();
2688
- show(event.currentTarget, event.key === "ArrowUp");
2689
- }
2690
- },
2777
+ ...buttonProps,
2691
2778
  children: [
2692
2779
  /* @__PURE__ */ jsx16("span", { className: "filter-menu-submenu-icon", "aria-hidden": "true", children: active !== void 0 && /* @__PURE__ */ jsx16(CheckIcon, {}) }),
2693
2780
  label,
@@ -2695,22 +2782,22 @@ function OperatorMenuButton({
2695
2782
  ]
2696
2783
  }
2697
2784
  ),
2698
- open !== null && /* @__PURE__ */ jsx16(
2785
+ state.kind === "open" && /* @__PURE__ */ jsx16(
2699
2786
  Overlay,
2700
2787
  {
2701
- anchor: open.anchor,
2788
+ anchor: state.anchor,
2702
2789
  placement: "right-start",
2703
- gap: open.gap,
2704
- returnFocusTo: open.anchor,
2705
- themeClassName: open.themeClassName,
2790
+ gap: state.gap,
2791
+ returnFocusTo: state.anchor,
2792
+ themeClassName: state.themeClassName,
2706
2793
  onDismiss: close,
2707
2794
  children: /* @__PURE__ */ jsx16(
2708
2795
  GridMenu,
2709
2796
  {
2710
2797
  entries,
2711
2798
  label,
2712
- themeClassName: open.themeClassName,
2713
- behaviourRef: menuBehaviourRef,
2799
+ themeClassName: state.themeClassName,
2800
+ behaviourRef,
2714
2801
  onRun: (item) => {
2715
2802
  item.run();
2716
2803
  },
@@ -2727,17 +2814,15 @@ import {
2727
2814
  Fragment as Fragment5,
2728
2815
  useId,
2729
2816
  useImperativeHandle,
2730
- useLayoutEffect as useLayoutEffect7,
2731
- useRef as useRef9,
2732
- useState as useState8
2817
+ useLayoutEffect as useLayoutEffect8,
2818
+ useReducer,
2819
+ useRef as useRef10
2733
2820
  } from "react";
2734
2821
  import {
2735
- conditionRowsFrom,
2736
- conditionsFromRows,
2737
- describeColumnFilter,
2822
+ conditionsFromRows as conditionsFromRows2,
2738
2823
  draftToFilter,
2739
- filterEditorReducer,
2740
- initialFilterEditorDraft
2824
+ filterDraftChanged as filterDraftChanged2,
2825
+ filterEditorReducer as filterEditorReducer3
2741
2826
  } from "@gridkitjs/core";
2742
2827
 
2743
2828
  // src/DataGrid/filterMenu/ConditionRow.tsx
@@ -2858,9 +2943,14 @@ function ConditionRow({
2858
2943
  );
2859
2944
  }
2860
2945
 
2861
- // src/DataGrid/filterMenu/SimpleFilterEditor.tsx
2862
- import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
2863
- var COMBINATORS = ["and", "or"];
2946
+ // src/DataGrid/filterMenu/simpleEditorState.ts
2947
+ import {
2948
+ conditionRowsFrom,
2949
+ conditionsFromRows,
2950
+ describeColumnFilter as describeColumnFilter2,
2951
+ filterEditorReducer as filterEditorReducer2,
2952
+ initialFilterEditorDraft as initialFilterEditorDraft2
2953
+ } from "@gridkitjs/core";
2864
2954
  var NO_ROWS = [];
2865
2955
  var NO_VALUES = {
2866
2956
  options: [],
@@ -2868,6 +2958,77 @@ var NO_VALUES = {
2868
2958
  truncated: false,
2869
2959
  blanks: 0
2870
2960
  };
2961
+ function filterDraftShown(shape, rows, columnId, type) {
2962
+ const draft = initialFilterEditorDraft2(shape, {
2963
+ ...NO_VALUES,
2964
+ columnType: type
2965
+ });
2966
+ if (shape.kind !== "conditions") {
2967
+ return draft;
2968
+ }
2969
+ const shown = conditionsFromRows(rows, columnId, type);
2970
+ return shown.invalid.length > 0 ? draft : filterEditorReducer2(draft, {
2971
+ type: "setConditions",
2972
+ conditions: shown.conditions
2973
+ });
2974
+ }
2975
+ function openConditions(filter, columnId, operators, type, operator) {
2976
+ const shape = describeColumnFilter2(filter, columnId);
2977
+ const rows = conditionRowsFrom(shape, operators, type);
2978
+ return {
2979
+ over: filter,
2980
+ custom: shape.kind === "custom" || shape.kind === "values" && operator === void 0,
2981
+ draft: {
2982
+ // Its typed values kept, as picking the operator in the row keeps them.
2983
+ rows: operator === void 0 ? rows : rows.map(
2984
+ (row, index) => index === 0 ? { ...row, operator } : row
2985
+ ),
2986
+ combinator: shape.kind === "conditions" ? shape.combinator : "and"
2987
+ },
2988
+ filterDraft: filterDraftShown(shape, rows, columnId, type)
2989
+ };
2990
+ }
2991
+ function initialSimpleEditorState(opened) {
2992
+ return { opened, draft: opened.draft, invalid: NO_ROWS };
2993
+ }
2994
+ function sameConditionsDraft(a, b) {
2995
+ return a.combinator === b.combinator && a.rows.length === b.rows.length && a.rows.every((row, index) => {
2996
+ const other = b.rows[index];
2997
+ return other !== void 0 && row.operator === other.operator && row.text === other.text && row.textTo === other.textTo;
2998
+ });
2999
+ }
3000
+ function showsAlike2(a, b) {
3001
+ return a.custom === b.custom && sameConditionsDraft(a.draft, b.draft);
3002
+ }
3003
+ function simpleEditorReducer(state, action) {
3004
+ switch (action.type) {
3005
+ case "editRow":
3006
+ return {
3007
+ ...state,
3008
+ draft: {
3009
+ ...state.draft,
3010
+ rows: state.draft.rows.map(
3011
+ (row, index) => index === action.index ? action.row : row
3012
+ )
3013
+ },
3014
+ invalid: NO_ROWS
3015
+ };
3016
+ case "setCombinator":
3017
+ return {
3018
+ ...state,
3019
+ draft: { ...state.draft, combinator: action.combinator },
3020
+ invalid: NO_ROWS
3021
+ };
3022
+ case "markInvalid":
3023
+ return { ...state, invalid: action.rows };
3024
+ case "filterChanged":
3025
+ return showsAlike2(state.opened, action.opened) ? { ...state, opened: action.opened } : initialSimpleEditorState(action.opened);
3026
+ }
3027
+ }
3028
+
3029
+ // src/DataGrid/filterMenu/SimpleFilterEditor.tsx
3030
+ import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
3031
+ var COMBINATORS = ["and", "or"];
2871
3032
  function holdsUnreadable(row) {
2872
3033
  return Array.from(row?.querySelectorAll("input") ?? []).some(
2873
3034
  (input) => input.validity.badInput
@@ -2913,42 +3074,34 @@ function SimpleFilterEditor({
2913
3074
  ref
2914
3075
  }) {
2915
3076
  const type = column.column.type;
2916
- const [opened] = useState8(() => {
2917
- const shape = describeColumnFilter(controller.getState().filter, column.id);
2918
- const rows = conditionRowsFrom(shape, menu.operators, type);
2919
- const draft2 = {
2920
- // Its typed values kept, as picking the operator in the row keeps them.
2921
- rows: operator === void 0 ? rows : rows.map(
2922
- (row, index) => index === 0 ? { ...row, operator } : row
2923
- ),
2924
- combinator: shape.kind === "conditions" ? shape.combinator : "and"
2925
- };
2926
- return {
2927
- custom: shape.kind === "custom" || shape.kind === "values" && operator === void 0,
2928
- draft: draft2
2929
- };
2930
- });
2931
- const [draft, setDraft] = useState8(opened.draft);
2932
- const [invalid, setInvalid] = useState8(NO_ROWS);
2933
- const rowElements = useRef9([]);
3077
+ const filter = controller.getState().filter;
3078
+ const open = (over) => openConditions(over, column.id, menu.operators, type, operator);
3079
+ const [{ opened, draft, invalid }, dispatch] = useReducer(
3080
+ simpleEditorReducer,
3081
+ filter,
3082
+ (over) => initialSimpleEditorState(open(over))
3083
+ );
3084
+ if (filter !== opened.over) {
3085
+ dispatch({ type: "filterChanged", opened: open(filter) });
3086
+ }
3087
+ const rowElements = useRef10([]);
2934
3088
  const invalidMessageId = useId();
2935
3089
  const combinatorName = useId();
2936
- function update(next) {
2937
- setDraft(next);
2938
- setInvalid(NO_ROWS);
2939
- }
2940
3090
  function applyConditions(conditions) {
2941
- const applied = filterEditorReducer(
2942
- initialFilterEditorDraft({ kind: "none" }, NO_VALUES),
2943
- { type: "setConditions", conditions, combinator: draft.combinator }
2944
- );
2945
- applyFilter(
2946
- draftToFilter(applied, column.id, controller.getState().filter)
2947
- );
3091
+ const applied = filterEditorReducer3(opened.filterDraft, {
3092
+ type: "setConditions",
3093
+ conditions,
3094
+ combinator: draft.combinator
3095
+ });
3096
+ if (filterDraftChanged2(opened.filterDraft, applied)) {
3097
+ applyFilter(
3098
+ draftToFilter(applied, column.id, controller.getState().filter)
3099
+ );
3100
+ }
2948
3101
  }
2949
3102
  useImperativeHandle(ref, () => ({
2950
3103
  apply: () => {
2951
- const parsed = conditionsFromRows(draft.rows, column.id, type);
3104
+ const parsed = conditionsFromRows2(draft.rows, column.id, type);
2952
3105
  const unreadable = draft.rows.map(
2953
3106
  (_, index) => holdsUnreadable(rowElements.current[index])
2954
3107
  );
@@ -2959,14 +3112,14 @@ function SimpleFilterEditor({
2959
3112
  applyConditions(parsed.conditions);
2960
3113
  return true;
2961
3114
  }
2962
- if (draft === opened.draft && !unreadable.includes(true)) {
3115
+ if (sameConditionsDraft(draft, opened.draft) && !unreadable.includes(true)) {
2963
3116
  return true;
2964
3117
  }
2965
- setInvalid(marked);
3118
+ dispatch({ type: "markInvalid", rows: marked });
2966
3119
  return false;
2967
3120
  }
2968
3121
  }));
2969
- useLayoutEffect7(() => {
3122
+ useLayoutEffect8(() => {
2970
3123
  const [first] = invalid;
2971
3124
  if (first !== void 0) {
2972
3125
  rowElements.current[first]?.querySelector('[aria-invalid="true"]')?.focus();
@@ -2984,7 +3137,7 @@ function SimpleFilterEditor({
2984
3137
  combinator: draft.combinator,
2985
3138
  messages,
2986
3139
  onChange: (combinator) => {
2987
- update({ ...draft, combinator });
3140
+ dispatch({ type: "setCombinator", combinator });
2988
3141
  }
2989
3142
  }
2990
3143
  ),
@@ -3002,12 +3155,7 @@ function SimpleFilterEditor({
3002
3155
  invalidMessageId: invalid.includes(index) ? invalidMessageId : void 0,
3003
3156
  focusRef: index === 0 ? initialFocusRef : void 0,
3004
3157
  onChange: (next) => {
3005
- update({
3006
- ...draft,
3007
- rows: draft.rows.map(
3008
- (current, at) => at === index ? next : current
3009
- )
3010
- });
3158
+ dispatch({ type: "editRow", index, row: next });
3011
3159
  }
3012
3160
  }
3013
3161
  )
@@ -3018,7 +3166,7 @@ function SimpleFilterEditor({
3018
3166
  }
3019
3167
 
3020
3168
  // src/DataGrid/filterMenu/ValueChecklist.tsx
3021
- import { useLayoutEffect as useLayoutEffect8, useRef as useRef10, useState as useState9 } from "react";
3169
+ import { useLayoutEffect as useLayoutEffect9, useRef as useRef11, useState as useState8 } from "react";
3022
3170
  import {
3023
3171
  attachChecklist,
3024
3172
  createRowVirtualizer
@@ -3038,15 +3186,15 @@ function ValueChecklist({
3038
3186
  label,
3039
3187
  onToggle
3040
3188
  }) {
3041
- const listRef = useRef10(null);
3042
- const checklistRef = useRef10(null);
3043
- const [virtualizer, setVirtualizer] = useState9(null);
3044
- const [range, setRange] = useState9(NO_RANGE);
3045
- const latest = useRef10({ items, onToggle });
3046
- useLayoutEffect8(() => {
3189
+ const listRef = useRef11(null);
3190
+ const checklistRef = useRef11(null);
3191
+ const [virtualizer, setVirtualizer] = useState8(null);
3192
+ const [range, setRange] = useState8(NO_RANGE);
3193
+ const latest = useRef11({ items, onToggle });
3194
+ useLayoutEffect9(() => {
3047
3195
  latest.current = { items, onToggle };
3048
3196
  });
3049
- useLayoutEffect8(() => {
3197
+ useLayoutEffect9(() => {
3050
3198
  const list = listRef.current;
3051
3199
  if (list === null) {
3052
3200
  return void 0;
@@ -3075,7 +3223,7 @@ function ValueChecklist({
3075
3223
  rows.destroy();
3076
3224
  };
3077
3225
  }, []);
3078
- useLayoutEffect8(() => {
3226
+ useLayoutEffect9(() => {
3079
3227
  virtualizer?.setRowCount(items.length);
3080
3228
  checklistRef.current?.setCount(items.length);
3081
3229
  }, [virtualizer, items.length]);
@@ -3123,6 +3271,10 @@ function ValueChecklist({
3123
3271
 
3124
3272
  // src/DataGrid/filterMenu/ExcelFilterEditor.tsx
3125
3273
  import { Fragment as Fragment7, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
3274
+ var OPENED_ON_VALUES = {
3275
+ kind: "values",
3276
+ focusOnMount: false
3277
+ };
3126
3278
  function toggleOf(item) {
3127
3279
  return item.kind === "blanks" ? { type: "setIncludeBlanks", includeBlanks: !item.checked } : { type: "toggleValue", value: item.value };
3128
3280
  }
@@ -3136,20 +3288,21 @@ function ExcelFilterEditor({
3136
3288
  columnValues,
3137
3289
  ref
3138
3290
  }) {
3139
- const [opened] = useState10(() => {
3140
- const shape2 = describeColumnFilter2(controller.getState().filter, column.id);
3141
- return {
3142
- shape: shape2,
3143
- draft: initialFilterEditorDraft2(shape2, columnValues(column.id))
3144
- };
3145
- });
3146
- const [draft, dispatch] = useReducer(filterEditorReducer2, opened.draft);
3147
- const [operator, setOperator] = useState10(null);
3148
- const conditions = useRef11(null);
3149
- const conditionsFocus = useRef11(null);
3150
- const operatorButton = useRef11(null);
3151
- const switched = useRef11(false);
3152
- const selectAllRef = useRef11(null);
3291
+ const filter = controller.getState().filter;
3292
+ const open = (over) => openValues(over, column.id, columnValues(column.id));
3293
+ const [{ opened, draft }, dispatch] = useReducer2(
3294
+ excelEditorReducer,
3295
+ filter,
3296
+ (over) => initialExcelEditorState(open(over))
3297
+ );
3298
+ if (filter !== opened.over) {
3299
+ dispatch({ type: "filterChanged", opened: open(filter) });
3300
+ }
3301
+ const [mode, setMode] = useState9(OPENED_ON_VALUES);
3302
+ const conditions = useRef12(null);
3303
+ const conditionsFocus = useRef12(null);
3304
+ const operatorButton = useRef12(null);
3305
+ const selectAllRef = useRef12(null);
3153
3306
  const selectAll = useMemo4(() => selectAllState(draft), [draft]);
3154
3307
  const checklist = useMemo4(
3155
3308
  () => filterChecklist(draft, {
@@ -3158,28 +3311,24 @@ function ExcelFilterEditor({
3158
3311
  }),
3159
3312
  [draft, menu.valueLimit, messages.filterBlanks]
3160
3313
  );
3161
- useLayoutEffect9(() => {
3314
+ useLayoutEffect10(() => {
3162
3315
  if (selectAllRef.current !== null) {
3163
3316
  selectAllRef.current.indeterminate = selectAll === "mixed";
3164
3317
  }
3165
3318
  });
3166
- useLayoutEffect9(() => {
3167
- if (switched.current) {
3168
- switched.current = false;
3169
- (operator === null ? operatorButton.current : conditionsFocus.current)?.focus();
3319
+ useLayoutEffect10(() => {
3320
+ if (mode.kind === "condition") {
3321
+ conditionsFocus.current?.focus();
3322
+ } else if (mode.focusOnMount) {
3323
+ operatorButton.current?.focus();
3170
3324
  }
3171
- }, [operator]);
3172
- function switchTo(chosen) {
3173
- switched.current = true;
3174
- setOperator(chosen);
3175
- }
3325
+ }, [mode]);
3176
3326
  useImperativeHandle2(ref, () => ({
3177
3327
  apply: () => {
3178
- if (operator !== null) {
3328
+ if (mode.kind === "condition") {
3179
3329
  return conditions.current?.apply() ?? true;
3180
3330
  }
3181
- const picked = draft.checked !== opened.draft.checked || draft.includeBlanks !== opened.draft.includeBlanks;
3182
- if (picked) {
3331
+ if (filterDraftChanged3(opened.draft, draft)) {
3183
3332
  applyFilter(
3184
3333
  draftToFilter2(draft, column.id, controller.getState().filter)
3185
3334
  );
@@ -3187,7 +3336,7 @@ function ExcelFilterEditor({
3187
3336
  return true;
3188
3337
  }
3189
3338
  }));
3190
- if (operator !== null) {
3339
+ if (mode.kind === "condition") {
3191
3340
  return /* @__PURE__ */ jsxs15(Fragment7, { children: [
3192
3341
  /* @__PURE__ */ jsxs15(
3193
3342
  "button",
@@ -3195,7 +3344,7 @@ function ExcelFilterEditor({
3195
3344
  type: "button",
3196
3345
  className: "filter-menu-back",
3197
3346
  onClick: () => {
3198
- switchTo(null);
3347
+ setMode({ kind: "values", focusOnMount: true });
3199
3348
  },
3200
3349
  children: [
3201
3350
  /* @__PURE__ */ jsx20("span", { className: "filter-menu-back-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx20(ChevronLeftIcon2, {}) }),
@@ -3215,7 +3364,7 @@ function ExcelFilterEditor({
3215
3364
  conditionsFocus.current = element;
3216
3365
  },
3217
3366
  applyFilter,
3218
- operator
3367
+ operator: mode.operator
3219
3368
  }
3220
3369
  )
3221
3370
  ] });
@@ -3229,7 +3378,9 @@ function ExcelFilterEditor({
3229
3378
  menu,
3230
3379
  active: shape.kind === "conditions" ? shape.conditions.map((condition) => condition.operator) : void 0,
3231
3380
  messages,
3232
- onChoose: switchTo
3381
+ onChoose: (operator) => {
3382
+ setMode({ kind: "condition", operator });
3383
+ }
3233
3384
  }
3234
3385
  ),
3235
3386
  (shape.kind === "conditions" || shape.kind === "custom") && /* @__PURE__ */ jsx20("p", { className: "filter-menu-custom", children: shape.kind === "conditions" ? messages.filterByCondition : messages.customFilter }),
@@ -3297,7 +3448,7 @@ function FilterMenu({
3297
3448
  applyFilter,
3298
3449
  columnValues
3299
3450
  }) {
3300
- const editor = useRef12(null);
3451
+ const editor = useRef13(null);
3301
3452
  const column = target.area === "header" ? controller.getView().dataColumns.find((entry) => entry.id === target.columnId) : void 0;
3302
3453
  const menu = column === void 0 ? null : resolveColumnFilterMenu2(controller.getOptions(), column.column);
3303
3454
  useEffect4(() => {
@@ -3401,23 +3552,29 @@ function FilterMenu({
3401
3552
  );
3402
3553
  }
3403
3554
 
3404
- // src/DataGrid/filterMenu/useApplyFilter.ts
3405
- import { useEffect as useEffect5, useRef as useRef13 } from "react";
3406
- function useApplyFilter(controller, messages, announce) {
3407
- const unannounced = useRef13(null);
3555
+ // src/DataGrid/useAnnounceWhenDrawn.ts
3556
+ import { useEffect as useEffect5, useState as useState10 } from "react";
3557
+ function useAnnounceWhenDrawn(announce) {
3558
+ const [requested, setRequested] = useState10(null);
3408
3559
  useEffect5(() => {
3409
- if (unannounced.current === controller.getState().filter) {
3410
- unannounced.current = null;
3411
- announce(
3412
- messages.filterResults(
3413
- controller.getView().rows.length,
3414
- controller.getOptions().dataSource?.length ?? 0
3415
- )
3416
- );
3560
+ if (requested?.drawn() === true) {
3561
+ announce(requested.text());
3417
3562
  }
3418
- });
3563
+ }, [requested, announce]);
3564
+ return setRequested;
3565
+ }
3566
+
3567
+ // src/DataGrid/filterMenu/useApplyFilter.ts
3568
+ function useApplyFilter(controller, messages, announce) {
3569
+ const announceWhenDrawn = useAnnounceWhenDrawn(announce);
3419
3570
  return (filter) => {
3420
- unannounced.current = filter;
3571
+ announceWhenDrawn({
3572
+ drawn: () => controller.getState().filter === filter,
3573
+ text: () => messages.filterResults(
3574
+ controller.getView().rows.length,
3575
+ controller.getOptions().dataSource?.length ?? 0
3576
+ )
3577
+ });
3421
3578
  controller.setFilter(filter);
3422
3579
  };
3423
3580
  }
@@ -3461,7 +3618,7 @@ function GridPanels({
3461
3618
  commands.host.announce
3462
3619
  );
3463
3620
  const columnValues = useFilterValueCache(controller, messages);
3464
- const { panel, close } = panels;
3621
+ const { panel, close, returnFocusFallback } = panels;
3465
3622
  if (panel === null) {
3466
3623
  return null;
3467
3624
  }
@@ -3474,6 +3631,7 @@ function GridPanels({
3474
3631
  gap: panel.anchor instanceof Element ? ANCHOR_GAP : 0,
3475
3632
  initialFocus,
3476
3633
  returnFocusTo: panel.returnFocusTo,
3634
+ returnFocusFallback,
3477
3635
  ignoreScrollAfterInput: true,
3478
3636
  trapFocus,
3479
3637
  themeClassName: panel.themeClassName,
@@ -3514,7 +3672,7 @@ function panelApi(panels, controller) {
3514
3672
  return true;
3515
3673
  },
3516
3674
  closeFilterMenu: () => {
3517
- if (panels.panel?.kind === "filter") {
3675
+ if (panels.current()?.kind === "filter") {
3518
3676
  panels.close();
3519
3677
  }
3520
3678
  }
@@ -3522,7 +3680,7 @@ function panelApi(panels, controller) {
3522
3680
  }
3523
3681
 
3524
3682
  // src/DataGrid/panels/useGridPanels.ts
3525
- import { useLayoutEffect as useLayoutEffect10, useRef as useRef15, useState as useState12 } from "react";
3683
+ import { useRef as useRef15 } from "react";
3526
3684
  function toolbarItem(root, itemId) {
3527
3685
  const items = root.querySelectorAll(
3528
3686
  ":scope > .gridkit-toolbar > [data-gridkit-toolbar-item]"
@@ -3534,6 +3692,9 @@ function toolbarItem(root, itemId) {
3534
3692
  (item) => item.hasAttribute("data-gridkit-toolbar-more")
3535
3693
  ) ?? null;
3536
3694
  }
3695
+ function panelOf(overlay) {
3696
+ return overlay.kind === "panel" ? overlay.panel : null;
3697
+ }
3537
3698
  function headerCell2(headerTable, columnId) {
3538
3699
  const cells = headerTable?.tHead?.rows[0]?.cells;
3539
3700
  return cells === void 0 ? null : Array.from(cells).find(
@@ -3543,9 +3704,8 @@ function headerCell2(headerTable, columnId) {
3543
3704
  function useGridPanels({
3544
3705
  rootRef,
3545
3706
  headerTableRef,
3546
- nav
3707
+ overlay
3547
3708
  }) {
3548
- const [panel, setPanel] = useState12(null);
3549
3709
  const openings = useRef15(0);
3550
3710
  function placeFor(root, target) {
3551
3711
  const element = target.area === "toolbar" ? toolbarItem(root, target.itemId) : target.area === "header" ? headerCell2(headerTableRef.current, target.columnId) : null;
@@ -3564,38 +3724,35 @@ function useGridPanels({
3564
3724
  returnFocusTo: void 0
3565
3725
  };
3566
3726
  }
3567
- const shown = useRef15(null);
3568
- useLayoutEffect10(() => {
3569
- const closed = shown.current;
3570
- shown.current = panel;
3571
- if (panel === null && closed?.returnFocusTo?.isConnected === false && document.activeElement === document.body) {
3572
- nav.focusTabStop();
3573
- }
3574
- });
3575
3727
  return {
3576
- panel,
3728
+ panel: panelOf(overlay.drawn),
3729
+ current: () => panelOf(overlay.current()),
3577
3730
  open: (kind, target) => {
3578
3731
  const root = rootRef.current;
3579
3732
  if (root === null) {
3580
3733
  return;
3581
3734
  }
3582
3735
  openings.current += 1;
3583
- setPanel({
3584
- key: openings.current,
3585
- kind,
3586
- target,
3587
- ...placeFor(root, target),
3588
- themeClassName: overlayThemeClassName(root)
3736
+ overlay.open({
3737
+ kind: "panel",
3738
+ panel: {
3739
+ key: openings.current,
3740
+ kind,
3741
+ target,
3742
+ ...placeFor(root, target),
3743
+ themeClassName: overlayThemeClassName(root)
3744
+ }
3589
3745
  });
3590
3746
  },
3591
3747
  close: () => {
3592
- setPanel(null);
3593
- }
3748
+ overlay.close("panel");
3749
+ },
3750
+ returnFocusFallback: overlay.returnFocusFallback
3594
3751
  };
3595
3752
  }
3596
3753
 
3597
3754
  // src/DataGrid/toolbar/GridToolbar.tsx
3598
- import { useLayoutEffect as useLayoutEffect13, useRef as useRef19 } from "react";
3755
+ import { useLayoutEffect as useLayoutEffect12, useRef as useRef18 } from "react";
3599
3756
  import {
3600
3757
  resolveToolbar,
3601
3758
  splitToolbarItems,
@@ -3604,7 +3761,6 @@ import {
3604
3761
  import { attachToolbar } from "@gridkitjs/dom";
3605
3762
 
3606
3763
  // src/DataGrid/toolbar/ToolbarMenuButton.tsx
3607
- import { useLayoutEffect as useLayoutEffect11, useRef as useRef16, useState as useState13 } from "react";
3608
3764
  import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
3609
3765
  function ToolbarMenuButton({
3610
3766
  itemKey,
@@ -3613,26 +3769,11 @@ function ToolbarMenuButton({
3613
3769
  icon,
3614
3770
  entries,
3615
3771
  more = false,
3616
- onMenuClose
3772
+ returnFocusFallback
3617
3773
  }) {
3618
- const [menu, setMenu] = useState13(null);
3619
- const menuBehaviourRef = useRef16(null);
3620
- useLayoutEffect11(() => {
3621
- if (menu !== null && menu.focusItem > 0) {
3622
- menuBehaviourRef.current?.focusItem(menu.focusItem);
3623
- }
3624
- }, [menu]);
3625
- function open(button, onLast = false) {
3626
- setMenu({
3627
- anchor: button,
3628
- themeClassName: overlayThemeClassName(button),
3629
- focusItem: onLast ? entries.filter((entry) => entry.type !== "separator").length - 1 : 0
3630
- });
3631
- }
3632
- function close() {
3633
- setMenu(null);
3634
- onMenuClose();
3635
- }
3774
+ const { state, close, buttonProps, behaviourRef } = useMenuButton({
3775
+ itemCount: entries.filter((entry) => entry.type !== "separator").length
3776
+ });
3636
3777
  return /* @__PURE__ */ jsxs17(Fragment8, { children: [
3637
3778
  /* @__PURE__ */ jsxs17(
3638
3779
  "button",
@@ -3642,21 +3783,7 @@ function ToolbarMenuButton({
3642
3783
  className: classNames("toolbar-button", more && "toolbar-more"),
3643
3784
  "data-gridkit-toolbar-item": itemKey,
3644
3785
  ...ariaAttr(more, "data-gridkit-toolbar-more", ""),
3645
- "aria-haspopup": "menu",
3646
- "aria-expanded": menu !== null,
3647
- onClick: (event) => {
3648
- if (menu === null) {
3649
- open(event.currentTarget);
3650
- } else {
3651
- close();
3652
- }
3653
- },
3654
- onKeyDown: (event) => {
3655
- if ((event.key === "ArrowDown" || event.key === "ArrowUp") && menu === null) {
3656
- event.preventDefault();
3657
- open(event.currentTarget, event.key === "ArrowUp");
3658
- }
3659
- },
3786
+ ...buttonProps,
3660
3787
  children: [
3661
3788
  icon !== void 0 && /* @__PURE__ */ jsx23("span", { className: "toolbar-button-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx23(MenuIcon, { name: icon }) }),
3662
3789
  label,
@@ -3664,22 +3791,23 @@ function ToolbarMenuButton({
3664
3791
  ]
3665
3792
  }
3666
3793
  ),
3667
- menu !== null && /* @__PURE__ */ jsx23(
3794
+ state.kind === "open" && /* @__PURE__ */ jsx23(
3668
3795
  Overlay,
3669
3796
  {
3670
- anchor: menu.anchor,
3797
+ anchor: state.anchor,
3671
3798
  placement: "bottom-start",
3672
- gap: ANCHOR_GAP,
3673
- returnFocusTo: menu.anchor,
3674
- themeClassName: menu.themeClassName,
3799
+ gap: state.gap,
3800
+ returnFocusTo: state.anchor,
3801
+ returnFocusFallback,
3802
+ themeClassName: state.themeClassName,
3675
3803
  onDismiss: close,
3676
3804
  children: /* @__PURE__ */ jsx23(
3677
3805
  GridMenu,
3678
3806
  {
3679
3807
  entries,
3680
3808
  label,
3681
- themeClassName: menu.themeClassName,
3682
- behaviourRef: menuBehaviourRef,
3809
+ themeClassName: state.themeClassName,
3810
+ behaviourRef,
3683
3811
  onRun: (item) => {
3684
3812
  item.run();
3685
3813
  close();
@@ -3693,7 +3821,7 @@ function ToolbarMenuButton({
3693
3821
  }
3694
3822
 
3695
3823
  // src/DataGrid/toolbar/ToolbarSearch.tsx
3696
- import { useEffect as useEffect6, useRef as useRef17, useState as useState14 } from "react";
3824
+ import { useEffect as useEffect6, useRef as useRef16, useState as useState12 } from "react";
3697
3825
  import {
3698
3826
  searchTextOf,
3699
3827
  setSearchText
@@ -3708,9 +3836,9 @@ function ToolbarSearch({
3708
3836
  announce
3709
3837
  }) {
3710
3838
  const applied = searchTextOf(controller.getState().filter);
3711
- const [draft, setDraft] = useState14(null);
3712
- const timer = useRef17(void 0);
3713
- const unannounced = useRef17(null);
3839
+ const [draft, setDraft] = useState12(null);
3840
+ const timer = useRef16(void 0);
3841
+ const announceWhenDrawn = useAnnounceWhenDrawn(announce);
3714
3842
  const text = draft !== null && draft.over === applied ? draft.text : applied;
3715
3843
  function apply(next, over) {
3716
3844
  clearTimeout(timer.current);
@@ -3721,16 +3849,13 @@ function ToolbarSearch({
3721
3849
  }
3722
3850
  const searched = setSearchText(filter, next);
3723
3851
  if (searched !== filter) {
3724
- unannounced.current = next;
3852
+ announceWhenDrawn({
3853
+ drawn: () => searchTextOf(controller.getState().filter) === next,
3854
+ text: () => messages.searchResults(controller.getView().rows.length)
3855
+ });
3725
3856
  controller.setFilter(searched);
3726
3857
  }
3727
3858
  }
3728
- useEffect6(() => {
3729
- if (unannounced.current === applied) {
3730
- unannounced.current = null;
3731
- announce(messages.searchResults(controller.getView().rows.length));
3732
- }
3733
- });
3734
3859
  useEffect6(
3735
3860
  () => () => {
3736
3861
  clearTimeout(timer.current);
@@ -3768,12 +3893,12 @@ function ToolbarSearch({
3768
3893
  }
3769
3894
 
3770
3895
  // src/DataGrid/toolbar/useToolbarOverflow.ts
3771
- import { useLayoutEffect as useLayoutEffect12, useRef as useRef18, useState as useState15 } from "react";
3896
+ import { useLayoutEffect as useLayoutEffect11, useRef as useRef17, useState as useState13 } from "react";
3772
3897
  import { observeToolbarOverflow } from "@gridkitjs/dom";
3773
3898
  function useToolbarOverflow(toolbarRef, items) {
3774
- const [fit, setFit] = useState15(items.length);
3775
- const overflow = useRef18(null);
3776
- const measuredLayout = useRef18("");
3899
+ const [fit, setFit] = useState13(items.length);
3900
+ const overflow = useRef17(null);
3901
+ const measuredLayout = useRef17("");
3777
3902
  const layout = JSON.stringify(
3778
3903
  items.map((item) => [
3779
3904
  item.type,
@@ -3781,7 +3906,7 @@ function useToolbarOverflow(toolbarRef, items) {
3781
3906
  "label" in item ? item.label : null
3782
3907
  ])
3783
3908
  );
3784
- useLayoutEffect12(() => {
3909
+ useLayoutEffect11(() => {
3785
3910
  const toolbar = toolbarRef.current;
3786
3911
  if (toolbar === null || layout === measuredLayout.current) {
3787
3912
  return;
@@ -3794,7 +3919,7 @@ function useToolbarOverflow(toolbarRef, items) {
3794
3919
  overflow.current.update(options);
3795
3920
  }
3796
3921
  }, [toolbarRef, layout, items]);
3797
- useLayoutEffect12(
3922
+ useLayoutEffect11(
3798
3923
  () => () => {
3799
3924
  overflow.current?.detach();
3800
3925
  overflow.current = null;
@@ -3880,8 +4005,7 @@ function Toolbar({
3880
4005
  messages,
3881
4006
  announce
3882
4007
  }) {
3883
- const toolbarRef = useRef19(null);
3884
- const menuClosed = useRef19(false);
4008
+ const toolbarRef = useRef18(null);
3885
4009
  const items = resolveToolbar(entries, {
3886
4010
  commands: commands.commands,
3887
4011
  contextFor: commands.contextFor,
@@ -3893,22 +4017,13 @@ function Toolbar({
3893
4017
  );
3894
4018
  const fit = useToolbarOverflow(toolbarRef, items);
3895
4019
  const { shown, overflow } = splitToolbarItems(items, fit);
3896
- useLayoutEffect13(() => {
4020
+ useLayoutEffect12(() => {
3897
4021
  const toolbar = toolbarRef.current;
3898
4022
  return toolbar === null ? void 0 : attachToolbar(toolbar);
3899
4023
  }, []);
3900
- useLayoutEffect13(() => {
3901
- if (!menuClosed.current) {
3902
- return;
3903
- }
3904
- menuClosed.current = false;
4024
+ function toolbarTabStop() {
3905
4025
  const toolbar = toolbarRef.current;
3906
- if (toolbar !== null && document.activeElement === document.body) {
3907
- (toolbar.querySelector('[tabindex="0"]') ?? toolbar.querySelector("button, input"))?.focus();
3908
- }
3909
- });
3910
- function onMenuClose() {
3911
- menuClosed.current = true;
4026
+ return toolbar?.querySelector('[tabindex="0"]') ?? toolbar?.querySelector("button, input") ?? null;
3912
4027
  }
3913
4028
  function draw(item) {
3914
4029
  switch (item.type) {
@@ -3950,7 +4065,7 @@ function Toolbar({
3950
4065
  label: item.label,
3951
4066
  icon: item.icon,
3952
4067
  entries: item.items,
3953
- onMenuClose
4068
+ returnFocusFallback: toolbarTabStop
3954
4069
  },
3955
4070
  item.key
3956
4071
  );
@@ -4016,7 +4131,7 @@ function Toolbar({
4016
4131
  label: messages.moreToolbarItems,
4017
4132
  entries: overflow,
4018
4133
  more: true,
4019
- onMenuClose
4134
+ returnFocusFallback: toolbarTabStop
4020
4135
  }
4021
4136
  )
4022
4137
  ]
@@ -4065,7 +4180,7 @@ function useColumnDrag({
4065
4180
 
4066
4181
  // src/DataGrid/useColumnResize.ts
4067
4182
  import {
4068
- useState as useState16
4183
+ useState as useState14
4069
4184
  } from "react";
4070
4185
  import {
4071
4186
  beginColumnResize,
@@ -4079,7 +4194,7 @@ function useColumnResize({
4079
4194
  controller,
4080
4195
  columnSizeDefaults
4081
4196
  }) {
4082
- const [activeColumnId, setActiveColumnId] = useState16(null);
4197
+ const [activeColumnId, setActiveColumnId] = useState14(null);
4083
4198
  const startGesture = useGestureSignal();
4084
4199
  function startResize(entry, event) {
4085
4200
  event.stopPropagation();
@@ -4158,11 +4273,11 @@ function useColumnResize({
4158
4273
  }
4159
4274
 
4160
4275
  // src/DataGrid/useElementWidth.ts
4161
- import { useLayoutEffect as useLayoutEffect14, useState as useState17 } from "react";
4276
+ import { useLayoutEffect as useLayoutEffect13, useState as useState15 } from "react";
4162
4277
  import { observeElementWidth } from "@gridkitjs/dom";
4163
4278
  function useElementWidth(ref, enabled) {
4164
- const [width, setWidth] = useState17(null);
4165
- useLayoutEffect14(() => {
4279
+ const [width, setWidth] = useState15(null);
4280
+ useLayoutEffect13(() => {
4166
4281
  const element = ref.current;
4167
4282
  if (element === null || !enabled) {
4168
4283
  return void 0;
@@ -4173,12 +4288,12 @@ function useElementWidth(ref, enabled) {
4173
4288
  }
4174
4289
 
4175
4290
  // src/DataGrid/useGridController.ts
4176
- import { useState as useState18, useSyncExternalStore as useSyncExternalStore2 } from "react";
4291
+ import { useState as useState16, useSyncExternalStore as useSyncExternalStore2 } from "react";
4177
4292
  import {
4178
4293
  createGridController
4179
4294
  } from "@gridkitjs/core";
4180
4295
  function useGridController(options) {
4181
- const [controller] = useState18(
4296
+ const [controller] = useState16(
4182
4297
  () => createGridController(options)
4183
4298
  );
4184
4299
  controller.setOptions(options);
@@ -4191,14 +4306,14 @@ function useGridController(options) {
4191
4306
  }
4192
4307
 
4193
4308
  // src/DataGrid/useInfiniteScroll.ts
4194
- import { useEffect as useEffect7, useRef as useRef20 } from "react";
4309
+ import { useEffect as useEffect7, useRef as useRef19 } from "react";
4195
4310
  import { attachInfiniteScroll } from "@gridkitjs/dom";
4196
4311
  function useInfiniteScroll({
4197
4312
  rootRef,
4198
4313
  sentinelRef,
4199
4314
  config
4200
4315
  }) {
4201
- const scroll = useRef20(null);
4316
+ const scroll = useRef19(null);
4202
4317
  useEffect7(() => {
4203
4318
  const root = rootRef.current;
4204
4319
  if (root === null) {
@@ -4226,11 +4341,11 @@ function useInfiniteScroll({
4226
4341
  }
4227
4342
 
4228
4343
  // src/DataGrid/useLiveAnnouncer.ts
4229
- import { useCallback, useLayoutEffect as useLayoutEffect15, useRef as useRef21 } from "react";
4344
+ import { useCallback as useCallback3, useLayoutEffect as useLayoutEffect14, useRef as useRef20 } from "react";
4230
4345
  import { createLiveAnnouncer } from "@gridkitjs/dom";
4231
4346
  function useLiveAnnouncer(containerRef) {
4232
- const announcer = useRef21(null);
4233
- useLayoutEffect15(() => {
4347
+ const announcer = useRef20(null);
4348
+ useLayoutEffect14(() => {
4234
4349
  const container = containerRef.current;
4235
4350
  if (container === null) {
4236
4351
  return void 0;
@@ -4242,13 +4357,13 @@ function useLiveAnnouncer(containerRef) {
4242
4357
  announcer.current = null;
4243
4358
  };
4244
4359
  }, [containerRef]);
4245
- return useCallback((text) => {
4360
+ return useCallback3((text) => {
4246
4361
  announcer.current?.announce(text);
4247
4362
  }, []);
4248
4363
  }
4249
4364
 
4250
4365
  // src/DataGrid/useRowVirtualizer.ts
4251
- import { useLayoutEffect as useLayoutEffect16, useState as useState19 } from "react";
4366
+ import { useLayoutEffect as useLayoutEffect15, useState as useState17 } from "react";
4252
4367
  import { createRowVirtualizer as createRowVirtualizer2 } from "@gridkitjs/dom";
4253
4368
  var EMPTY_RANGE = {
4254
4369
  startIndex: 0,
@@ -4266,9 +4381,9 @@ function useRowVirtualizer({
4266
4381
  estimatedRowHeight,
4267
4382
  overscan
4268
4383
  }) {
4269
- const [virtualizer, setVirtualizer] = useState19(null);
4270
- const [range, setRange] = useState19(EMPTY_RANGE);
4271
- useLayoutEffect16(() => {
4384
+ const [virtualizer, setVirtualizer] = useState17(null);
4385
+ const [range, setRange] = useState17(EMPTY_RANGE);
4386
+ useLayoutEffect15(() => {
4272
4387
  const element = bodyScrollRef.current;
4273
4388
  if (!enabled || element === null) {
4274
4389
  return void 0;
@@ -4283,7 +4398,7 @@ function useRowVirtualizer({
4283
4398
  created.destroy();
4284
4399
  };
4285
4400
  }, [enabled, bodyScrollRef, estimatedRowHeight, overscan]);
4286
- useLayoutEffect16(() => {
4401
+ useLayoutEffect15(() => {
4287
4402
  virtualizer?.setRowCount(rows.length);
4288
4403
  virtualizer?.resetHeights();
4289
4404
  }, [virtualizer, rows]);
@@ -4357,13 +4472,14 @@ function DataGrid(props) {
4357
4472
  const hoverRows = hoverable?.rows ?? true;
4358
4473
  const hoverColumns = hoverable?.columns ?? true;
4359
4474
  const hoverCells = hoverable?.cells ?? true;
4360
- const viewportRef = useRef22(null);
4361
- const headerTableRef = useRef22(null);
4362
- const bodyTableRef = useRef22(null);
4363
- const bodyScrollRef = useRef22(null);
4364
- const sentinelRef = useRef22(null);
4475
+ const viewportRef = useRef21(null);
4476
+ const gridRef = useRef21(null);
4477
+ const headerTableRef = useRef21(null);
4478
+ const bodyTableRef = useRef21(null);
4479
+ const bodyScrollRef = useRef21(null);
4480
+ const sentinelRef = useRef21(null);
4365
4481
  const viewportWidth = useElementWidth(viewportRef, resizeMode === "fit");
4366
- const subscribersRef = useRef22(/* @__PURE__ */ new Set());
4482
+ const subscribersRef = useRef21(/* @__PURE__ */ new Set());
4367
4483
  const gridId = useId2();
4368
4484
  const announce = useLiveAnnouncer(viewportRef);
4369
4485
  const messages = useMemo5(
@@ -4381,8 +4497,8 @@ function DataGrid(props) {
4381
4497
  columnOf
4382
4498
  })
4383
4499
  });
4384
- const [readPagination] = useState20(() => paginationReader(controller));
4385
- const [readSelectedRows] = useState20(() => selectedRowsReader(controller));
4500
+ const [readPagination] = useState18(() => paginationReader(controller));
4501
+ const [readSelectedRows] = useState18(() => selectedRowsReader(controller));
4386
4502
  const virtualizer = useRowVirtualizer({
4387
4503
  enabled: virtualized,
4388
4504
  rows: view.pageRows,
@@ -4427,6 +4543,7 @@ function DataGrid(props) {
4427
4543
  columnSizeDefaults
4428
4544
  });
4429
4545
  const nav = useGridNavigation({
4546
+ gridRef,
4430
4547
  headerTableRef,
4431
4548
  bodyTableRef,
4432
4549
  // `null` when virtualization is off, in which case behavior is
@@ -4449,7 +4566,15 @@ function DataGrid(props) {
4449
4566
  return entry !== void 0 && "kind" in entry && entry.kind === "group-summary";
4450
4567
  }
4451
4568
  });
4452
- const panels = useGridPanels({ rootRef: viewportRef, headerTableRef, nav });
4569
+ const overlay = useGridOverlay({
4570
+ nav,
4571
+ onContextMenuOpenChange: props.onContextMenuOpenChange
4572
+ });
4573
+ const panels = useGridPanels({
4574
+ rootRef: viewportRef,
4575
+ headerTableRef,
4576
+ overlay
4577
+ });
4453
4578
  const commands = useGridCommands({
4454
4579
  controller,
4455
4580
  commands: props.commands,
@@ -4523,7 +4648,7 @@ function DataGrid(props) {
4523
4648
  bodyTableRef,
4524
4649
  bodyScrollRef,
4525
4650
  contextMenu: props.contextMenu,
4526
- onContextMenuOpenChange: props.onContextMenuOpenChange,
4651
+ overlay,
4527
4652
  controller,
4528
4653
  commands,
4529
4654
  nav,
@@ -4676,6 +4801,7 @@ function DataGrid(props) {
4676
4801
  /* @__PURE__ */ jsxs19(
4677
4802
  "div",
4678
4803
  {
4804
+ ref: gridRef,
4679
4805
  id: gridId,
4680
4806
  className: "gridkit-data-grid-tables",
4681
4807
  role: state.groupBy.length > 0 ? "treegrid" : "grid",
@@ -4826,12 +4952,12 @@ function DataGrid(props) {
4826
4952
  import { serializeGridState } from "@gridkitjs/core";
4827
4953
 
4828
4954
  // src/DataGrid/hooks/usePaginationState.ts
4829
- import { useCallback as useCallback3 } from "react";
4955
+ import { useCallback as useCallback5 } from "react";
4830
4956
 
4831
4957
  // src/DataGrid/hooks/useGridSnapshot.ts
4832
- import { useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore3 } from "react";
4958
+ import { useCallback as useCallback4, useSyncExternalStore as useSyncExternalStore3 } from "react";
4833
4959
  function useGridSnapshot(gridRef, getSnapshot, fallback) {
4834
- const subscribe = useCallback2(
4960
+ const subscribe = useCallback4(
4835
4961
  (listener) => {
4836
4962
  const api = gridRef.current;
4837
4963
  if (api === null) {
@@ -4857,12 +4983,12 @@ var FALLBACK_PAGINATION = { pageIndex: 0, pageSize: 0 };
4857
4983
  function usePaginationState(gridRef) {
4858
4984
  const pagination = useGridSnapshot(
4859
4985
  gridRef,
4860
- useCallback3((api) => api.getPagination(), []),
4986
+ useCallback5((api) => api.getPagination(), []),
4861
4987
  FALLBACK_PAGINATION
4862
4988
  );
4863
4989
  const pageCount = useGridSnapshot(
4864
4990
  gridRef,
4865
- useCallback3((api) => api.getPageCount(), []),
4991
+ useCallback5((api) => api.getPageCount(), []),
4866
4992
  0
4867
4993
  );
4868
4994
  return {
@@ -4884,18 +5010,18 @@ function usePaginationState(gridRef) {
4884
5010
  }
4885
5011
 
4886
5012
  // src/DataGrid/hooks/useGroupByState.ts
4887
- import { useCallback as useCallback4 } from "react";
5013
+ import { useCallback as useCallback6 } from "react";
4888
5014
  var FALLBACK_GROUP_BY = [];
4889
5015
  var FALLBACK_EXPANSION = [];
4890
5016
  function useGroupByState(gridRef) {
4891
5017
  const groupBy = useGridSnapshot(
4892
5018
  gridRef,
4893
- useCallback4((api) => api.getGroupBy(), []),
5019
+ useCallback6((api) => api.getGroupBy(), []),
4894
5020
  FALLBACK_GROUP_BY
4895
5021
  );
4896
5022
  const groupExpansion = useGridSnapshot(
4897
5023
  gridRef,
4898
- useCallback4((api) => api.getGroupExpansion(), []),
5024
+ useCallback6((api) => api.getGroupExpansion(), []),
4899
5025
  FALLBACK_EXPANSION
4900
5026
  );
4901
5027
  return {
@@ -4911,34 +5037,34 @@ function useGroupByState(gridRef) {
4911
5037
  }
4912
5038
 
4913
5039
  // src/DataGrid/hooks/useColumnSortState.ts
4914
- import { useCallback as useCallback5 } from "react";
5040
+ import { useCallback as useCallback7 } from "react";
4915
5041
  var FALLBACK_SORT = [];
4916
5042
  function useColumnSortState(gridRef) {
4917
5043
  return useGridSnapshot(
4918
5044
  gridRef,
4919
- useCallback5((api) => api.getColumnSort(), []),
5045
+ useCallback7((api) => api.getColumnSort(), []),
4920
5046
  FALLBACK_SORT
4921
5047
  );
4922
5048
  }
4923
5049
 
4924
5050
  // src/DataGrid/hooks/useSelectionState.ts
4925
- import { useCallback as useCallback6 } from "react";
5051
+ import { useCallback as useCallback8 } from "react";
4926
5052
  var FALLBACK_SELECTION = [];
4927
5053
  var FALLBACK_CELL_SELECTION = null;
4928
5054
  function useSelectionState(gridRef) {
4929
5055
  const rowSelection = useGridSnapshot(
4930
5056
  gridRef,
4931
- useCallback6((api) => api.getRowSelection(), []),
5057
+ useCallback8((api) => api.getRowSelection(), []),
4932
5058
  FALLBACK_SELECTION
4933
5059
  );
4934
5060
  const columnSelection = useGridSnapshot(
4935
5061
  gridRef,
4936
- useCallback6((api) => api.getColumnSelection(), []),
5062
+ useCallback8((api) => api.getColumnSelection(), []),
4937
5063
  FALLBACK_SELECTION
4938
5064
  );
4939
5065
  const cellSelection = useGridSnapshot(
4940
5066
  gridRef,
4941
- useCallback6((api) => api.getCellSelection(), []),
5067
+ useCallback8((api) => api.getCellSelection(), []),
4942
5068
  FALLBACK_CELL_SELECTION
4943
5069
  );
4944
5070
  return {
@@ -4955,56 +5081,56 @@ function useSelectionState(gridRef) {
4955
5081
  }
4956
5082
 
4957
5083
  // src/DataGrid/hooks/useAggregateState.ts
4958
- import { useCallback as useCallback7 } from "react";
5084
+ import { useCallback as useCallback9 } from "react";
4959
5085
  var FALLBACK_AGGREGATES = /* @__PURE__ */ new Map();
4960
5086
  function useAggregateState(gridRef) {
4961
5087
  return useGridSnapshot(
4962
5088
  gridRef,
4963
- useCallback7((api) => api.getAggregates(), []),
5089
+ useCallback9((api) => api.getAggregates(), []),
4964
5090
  FALLBACK_AGGREGATES
4965
5091
  );
4966
5092
  }
4967
5093
 
4968
5094
  // src/DataGrid/hooks/useColumnSizingState.ts
4969
- import { useCallback as useCallback8 } from "react";
5095
+ import { useCallback as useCallback10 } from "react";
4970
5096
  var FALLBACK_SIZING = {};
4971
5097
  function useColumnSizingState(gridRef) {
4972
5098
  return useGridSnapshot(
4973
5099
  gridRef,
4974
- useCallback8((api) => api.getColumnSizing(), []),
5100
+ useCallback10((api) => api.getColumnSizing(), []),
4975
5101
  FALLBACK_SIZING
4976
5102
  );
4977
5103
  }
4978
5104
 
4979
5105
  // src/DataGrid/hooks/useColumnOrderState.ts
4980
- import { useCallback as useCallback9 } from "react";
5106
+ import { useCallback as useCallback11 } from "react";
4981
5107
  var FALLBACK_ORDER = [];
4982
5108
  function useColumnOrderState(gridRef) {
4983
5109
  return useGridSnapshot(
4984
5110
  gridRef,
4985
- useCallback9((api) => api.getColumnOrder(), []),
5111
+ useCallback11((api) => api.getColumnOrder(), []),
4986
5112
  FALLBACK_ORDER
4987
5113
  );
4988
5114
  }
4989
5115
 
4990
5116
  // src/DataGrid/hooks/useColumnVisibilityState.ts
4991
- import { useCallback as useCallback10 } from "react";
5117
+ import { useCallback as useCallback12 } from "react";
4992
5118
  var FALLBACK_VISIBILITY = {};
4993
5119
  function useColumnVisibilityState(gridRef) {
4994
5120
  return useGridSnapshot(
4995
5121
  gridRef,
4996
- useCallback10((api) => api.getColumnVisibility(), []),
5122
+ useCallback12((api) => api.getColumnVisibility(), []),
4997
5123
  FALLBACK_VISIBILITY
4998
5124
  );
4999
5125
  }
5000
5126
 
5001
5127
  // src/DataGrid/hooks/useFilterState.ts
5002
- import { useCallback as useCallback11, useState as useState21 } from "react";
5128
+ import { useCallback as useCallback13, useState as useState19 } from "react";
5003
5129
  function useFilterState(gridRef) {
5004
- const [fallback] = useState21(() => []);
5130
+ const [fallback] = useState19(() => []);
5005
5131
  const filter = useGridSnapshot(
5006
5132
  gridRef,
5007
- useCallback11((api) => api.getFilter(), []),
5133
+ useCallback13((api) => api.getFilter(), []),
5008
5134
  fallback
5009
5135
  );
5010
5136
  return {