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

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
@@ -7,7 +7,7 @@ import {
7
7
  useImperativeHandle as useImperativeHandle3,
8
8
  useMemo as useMemo5,
9
9
  useRef as useRef22,
10
- useState as useState20
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
- import { useRef as useRef14 } from "react";
2547
+ import { useRef as useRef15 } 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,10 +2642,10 @@ 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
2647
  useReducer,
2612
- useRef as useRef11,
2648
+ useRef as useRef12,
2613
2649
  useState as useState10
2614
2650
  } from "react";
2615
2651
  import {
@@ -2621,8 +2657,61 @@ import {
2621
2657
  selectAllState
2622
2658
  } from "@gridkitjs/core";
2623
2659
 
2660
+ // src/DataGrid/menu/useMenuButton.ts
2661
+ import {
2662
+ useLayoutEffect as useLayoutEffect7,
2663
+ useRef as useRef9,
2664
+ useState as useState7
2665
+ } from "react";
2666
+ var CLOSED2 = { kind: "closed" };
2667
+ function useMenuButton({
2668
+ itemCount,
2669
+ gap = () => ANCHOR_GAP
2670
+ }) {
2671
+ const [state, setState] = useState7(CLOSED2);
2672
+ const behaviourRef = useRef9(null);
2673
+ useLayoutEffect7(() => {
2674
+ if (state.kind === "open" && state.focusItem > 0) {
2675
+ behaviourRef.current?.focusItem(state.focusItem);
2676
+ }
2677
+ }, [state]);
2678
+ function open(button, onLast) {
2679
+ setState({
2680
+ kind: "open",
2681
+ anchor: button,
2682
+ themeClassName: overlayThemeClassName(button),
2683
+ gap: gap(button),
2684
+ focusItem: onLast ? itemCount - 1 : 0
2685
+ });
2686
+ }
2687
+ function close() {
2688
+ setState(CLOSED2);
2689
+ }
2690
+ return {
2691
+ state,
2692
+ close,
2693
+ buttonProps: {
2694
+ "aria-haspopup": "menu",
2695
+ "aria-expanded": state.kind === "open",
2696
+ onClick: (event) => {
2697
+ if (state.kind === "closed") {
2698
+ open(event.currentTarget, false);
2699
+ } else {
2700
+ close();
2701
+ }
2702
+ },
2703
+ onKeyDown: (event) => {
2704
+ if ((event.key === "ArrowDown" || event.key === "ArrowUp") && state.kind === "closed") {
2705
+ event.preventDefault();
2706
+ open(event.currentTarget, event.key === "ArrowUp");
2707
+ }
2708
+ }
2709
+ },
2710
+ behaviourRef
2711
+ };
2712
+ }
2713
+
2624
2714
  // src/DataGrid/filterMenu/OperatorMenuButton.tsx
2625
- import { useLayoutEffect as useLayoutEffect6, useRef as useRef8, useState as useState7 } from "react";
2626
2715
  import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
2627
2716
  function gapBeside(button) {
2628
2717
  const dialog = button.closest('[role="dialog"]') ?? button;
@@ -2635,25 +2724,11 @@ function OperatorMenuButton({
2635
2724
  onChoose,
2636
2725
  ref
2637
2726
  }) {
2638
- const [open, setOpen] = useState7(null);
2639
- const menuBehaviourRef = useRef8(null);
2727
+ const { state, close, buttonProps, behaviourRef } = useMenuButton({
2728
+ itemCount: menu.operators.length,
2729
+ gap: gapBeside
2730
+ });
2640
2731
  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
2732
  const entries = menu.operators.map((operator) => ({
2658
2733
  type: "item",
2659
2734
  id: operator,
@@ -2673,21 +2748,7 @@ function OperatorMenuButton({
2673
2748
  ref,
2674
2749
  type: "button",
2675
2750
  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
- },
2751
+ ...buttonProps,
2691
2752
  children: [
2692
2753
  /* @__PURE__ */ jsx16("span", { className: "filter-menu-submenu-icon", "aria-hidden": "true", children: active !== void 0 && /* @__PURE__ */ jsx16(CheckIcon, {}) }),
2693
2754
  label,
@@ -2695,22 +2756,22 @@ function OperatorMenuButton({
2695
2756
  ]
2696
2757
  }
2697
2758
  ),
2698
- open !== null && /* @__PURE__ */ jsx16(
2759
+ state.kind === "open" && /* @__PURE__ */ jsx16(
2699
2760
  Overlay,
2700
2761
  {
2701
- anchor: open.anchor,
2762
+ anchor: state.anchor,
2702
2763
  placement: "right-start",
2703
- gap: open.gap,
2704
- returnFocusTo: open.anchor,
2705
- themeClassName: open.themeClassName,
2764
+ gap: state.gap,
2765
+ returnFocusTo: state.anchor,
2766
+ themeClassName: state.themeClassName,
2706
2767
  onDismiss: close,
2707
2768
  children: /* @__PURE__ */ jsx16(
2708
2769
  GridMenu,
2709
2770
  {
2710
2771
  entries,
2711
2772
  label,
2712
- themeClassName: open.themeClassName,
2713
- behaviourRef: menuBehaviourRef,
2773
+ themeClassName: state.themeClassName,
2774
+ behaviourRef,
2714
2775
  onRun: (item) => {
2715
2776
  item.run();
2716
2777
  },
@@ -2727,8 +2788,8 @@ import {
2727
2788
  Fragment as Fragment5,
2728
2789
  useId,
2729
2790
  useImperativeHandle,
2730
- useLayoutEffect as useLayoutEffect7,
2731
- useRef as useRef9,
2791
+ useLayoutEffect as useLayoutEffect8,
2792
+ useRef as useRef10,
2732
2793
  useState as useState8
2733
2794
  } from "react";
2734
2795
  import {
@@ -2930,7 +2991,7 @@ function SimpleFilterEditor({
2930
2991
  });
2931
2992
  const [draft, setDraft] = useState8(opened.draft);
2932
2993
  const [invalid, setInvalid] = useState8(NO_ROWS);
2933
- const rowElements = useRef9([]);
2994
+ const rowElements = useRef10([]);
2934
2995
  const invalidMessageId = useId();
2935
2996
  const combinatorName = useId();
2936
2997
  function update(next) {
@@ -2966,7 +3027,7 @@ function SimpleFilterEditor({
2966
3027
  return false;
2967
3028
  }
2968
3029
  }));
2969
- useLayoutEffect7(() => {
3030
+ useLayoutEffect8(() => {
2970
3031
  const [first] = invalid;
2971
3032
  if (first !== void 0) {
2972
3033
  rowElements.current[first]?.querySelector('[aria-invalid="true"]')?.focus();
@@ -3018,7 +3079,7 @@ function SimpleFilterEditor({
3018
3079
  }
3019
3080
 
3020
3081
  // src/DataGrid/filterMenu/ValueChecklist.tsx
3021
- import { useLayoutEffect as useLayoutEffect8, useRef as useRef10, useState as useState9 } from "react";
3082
+ import { useLayoutEffect as useLayoutEffect9, useRef as useRef11, useState as useState9 } from "react";
3022
3083
  import {
3023
3084
  attachChecklist,
3024
3085
  createRowVirtualizer
@@ -3038,15 +3099,15 @@ function ValueChecklist({
3038
3099
  label,
3039
3100
  onToggle
3040
3101
  }) {
3041
- const listRef = useRef10(null);
3042
- const checklistRef = useRef10(null);
3102
+ const listRef = useRef11(null);
3103
+ const checklistRef = useRef11(null);
3043
3104
  const [virtualizer, setVirtualizer] = useState9(null);
3044
3105
  const [range, setRange] = useState9(NO_RANGE);
3045
- const latest = useRef10({ items, onToggle });
3046
- useLayoutEffect8(() => {
3106
+ const latest = useRef11({ items, onToggle });
3107
+ useLayoutEffect9(() => {
3047
3108
  latest.current = { items, onToggle };
3048
3109
  });
3049
- useLayoutEffect8(() => {
3110
+ useLayoutEffect9(() => {
3050
3111
  const list = listRef.current;
3051
3112
  if (list === null) {
3052
3113
  return void 0;
@@ -3075,7 +3136,7 @@ function ValueChecklist({
3075
3136
  rows.destroy();
3076
3137
  };
3077
3138
  }, []);
3078
- useLayoutEffect8(() => {
3139
+ useLayoutEffect9(() => {
3079
3140
  virtualizer?.setRowCount(items.length);
3080
3141
  checklistRef.current?.setCount(items.length);
3081
3142
  }, [virtualizer, items.length]);
@@ -3145,11 +3206,11 @@ function ExcelFilterEditor({
3145
3206
  });
3146
3207
  const [draft, dispatch] = useReducer(filterEditorReducer2, opened.draft);
3147
3208
  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);
3209
+ const conditions = useRef12(null);
3210
+ const conditionsFocus = useRef12(null);
3211
+ const operatorButton = useRef12(null);
3212
+ const switched = useRef12(false);
3213
+ const selectAllRef = useRef12(null);
3153
3214
  const selectAll = useMemo4(() => selectAllState(draft), [draft]);
3154
3215
  const checklist = useMemo4(
3155
3216
  () => filterChecklist(draft, {
@@ -3158,12 +3219,12 @@ function ExcelFilterEditor({
3158
3219
  }),
3159
3220
  [draft, menu.valueLimit, messages.filterBlanks]
3160
3221
  );
3161
- useLayoutEffect9(() => {
3222
+ useLayoutEffect10(() => {
3162
3223
  if (selectAllRef.current !== null) {
3163
3224
  selectAllRef.current.indeterminate = selectAll === "mixed";
3164
3225
  }
3165
3226
  });
3166
- useLayoutEffect9(() => {
3227
+ useLayoutEffect10(() => {
3167
3228
  if (switched.current) {
3168
3229
  switched.current = false;
3169
3230
  (operator === null ? operatorButton.current : conditionsFocus.current)?.focus();
@@ -3297,7 +3358,7 @@ function FilterMenu({
3297
3358
  applyFilter,
3298
3359
  columnValues
3299
3360
  }) {
3300
- const editor = useRef12(null);
3361
+ const editor = useRef13(null);
3301
3362
  const column = target.area === "header" ? controller.getView().dataColumns.find((entry) => entry.id === target.columnId) : void 0;
3302
3363
  const menu = column === void 0 ? null : resolveColumnFilterMenu2(controller.getOptions(), column.column);
3303
3364
  useEffect4(() => {
@@ -3402,9 +3463,9 @@ function FilterMenu({
3402
3463
  }
3403
3464
 
3404
3465
  // src/DataGrid/filterMenu/useApplyFilter.ts
3405
- import { useEffect as useEffect5, useRef as useRef13 } from "react";
3466
+ import { useEffect as useEffect5, useRef as useRef14 } from "react";
3406
3467
  function useApplyFilter(controller, messages, announce) {
3407
- const unannounced = useRef13(null);
3468
+ const unannounced = useRef14(null);
3408
3469
  useEffect5(() => {
3409
3470
  if (unannounced.current === controller.getState().filter) {
3410
3471
  unannounced.current = null;
@@ -3454,14 +3515,14 @@ function GridPanels({
3454
3515
  commands,
3455
3516
  messages
3456
3517
  }) {
3457
- const initialFocus = useRef14(null);
3518
+ const initialFocus = useRef15(null);
3458
3519
  const applyFilter = useApplyFilter(
3459
3520
  controller,
3460
3521
  messages,
3461
3522
  commands.host.announce
3462
3523
  );
3463
3524
  const columnValues = useFilterValueCache(controller, messages);
3464
- const { panel, close } = panels;
3525
+ const { panel, close, returnFocusFallback } = panels;
3465
3526
  if (panel === null) {
3466
3527
  return null;
3467
3528
  }
@@ -3474,6 +3535,7 @@ function GridPanels({
3474
3535
  gap: panel.anchor instanceof Element ? ANCHOR_GAP : 0,
3475
3536
  initialFocus,
3476
3537
  returnFocusTo: panel.returnFocusTo,
3538
+ returnFocusFallback,
3477
3539
  ignoreScrollAfterInput: true,
3478
3540
  trapFocus,
3479
3541
  themeClassName: panel.themeClassName,
@@ -3514,7 +3576,7 @@ function panelApi(panels, controller) {
3514
3576
  return true;
3515
3577
  },
3516
3578
  closeFilterMenu: () => {
3517
- if (panels.panel?.kind === "filter") {
3579
+ if (panels.current()?.kind === "filter") {
3518
3580
  panels.close();
3519
3581
  }
3520
3582
  }
@@ -3522,7 +3584,7 @@ function panelApi(panels, controller) {
3522
3584
  }
3523
3585
 
3524
3586
  // src/DataGrid/panels/useGridPanels.ts
3525
- import { useLayoutEffect as useLayoutEffect10, useRef as useRef15, useState as useState12 } from "react";
3587
+ import { useRef as useRef16 } from "react";
3526
3588
  function toolbarItem(root, itemId) {
3527
3589
  const items = root.querySelectorAll(
3528
3590
  ":scope > .gridkit-toolbar > [data-gridkit-toolbar-item]"
@@ -3534,6 +3596,9 @@ function toolbarItem(root, itemId) {
3534
3596
  (item) => item.hasAttribute("data-gridkit-toolbar-more")
3535
3597
  ) ?? null;
3536
3598
  }
3599
+ function panelOf(overlay) {
3600
+ return overlay.kind === "panel" ? overlay.panel : null;
3601
+ }
3537
3602
  function headerCell2(headerTable, columnId) {
3538
3603
  const cells = headerTable?.tHead?.rows[0]?.cells;
3539
3604
  return cells === void 0 ? null : Array.from(cells).find(
@@ -3543,10 +3608,9 @@ function headerCell2(headerTable, columnId) {
3543
3608
  function useGridPanels({
3544
3609
  rootRef,
3545
3610
  headerTableRef,
3546
- nav
3611
+ overlay
3547
3612
  }) {
3548
- const [panel, setPanel] = useState12(null);
3549
- const openings = useRef15(0);
3613
+ const openings = useRef16(0);
3550
3614
  function placeFor(root, target) {
3551
3615
  const element = target.area === "toolbar" ? toolbarItem(root, target.itemId) : target.area === "header" ? headerCell2(headerTableRef.current, target.columnId) : null;
3552
3616
  if (element !== null) {
@@ -3564,38 +3628,35 @@ function useGridPanels({
3564
3628
  returnFocusTo: void 0
3565
3629
  };
3566
3630
  }
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
3631
  return {
3576
- panel,
3632
+ panel: panelOf(overlay.drawn),
3633
+ current: () => panelOf(overlay.current()),
3577
3634
  open: (kind, target) => {
3578
3635
  const root = rootRef.current;
3579
3636
  if (root === null) {
3580
3637
  return;
3581
3638
  }
3582
3639
  openings.current += 1;
3583
- setPanel({
3584
- key: openings.current,
3585
- kind,
3586
- target,
3587
- ...placeFor(root, target),
3588
- themeClassName: overlayThemeClassName(root)
3640
+ overlay.open({
3641
+ kind: "panel",
3642
+ panel: {
3643
+ key: openings.current,
3644
+ kind,
3645
+ target,
3646
+ ...placeFor(root, target),
3647
+ themeClassName: overlayThemeClassName(root)
3648
+ }
3589
3649
  });
3590
3650
  },
3591
3651
  close: () => {
3592
- setPanel(null);
3593
- }
3652
+ overlay.close("panel");
3653
+ },
3654
+ returnFocusFallback: overlay.returnFocusFallback
3594
3655
  };
3595
3656
  }
3596
3657
 
3597
3658
  // src/DataGrid/toolbar/GridToolbar.tsx
3598
- import { useLayoutEffect as useLayoutEffect13, useRef as useRef19 } from "react";
3659
+ import { useLayoutEffect as useLayoutEffect12, useRef as useRef19 } from "react";
3599
3660
  import {
3600
3661
  resolveToolbar,
3601
3662
  splitToolbarItems,
@@ -3604,7 +3665,6 @@ import {
3604
3665
  import { attachToolbar } from "@gridkitjs/dom";
3605
3666
 
3606
3667
  // src/DataGrid/toolbar/ToolbarMenuButton.tsx
3607
- import { useLayoutEffect as useLayoutEffect11, useRef as useRef16, useState as useState13 } from "react";
3608
3668
  import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
3609
3669
  function ToolbarMenuButton({
3610
3670
  itemKey,
@@ -3613,26 +3673,11 @@ function ToolbarMenuButton({
3613
3673
  icon,
3614
3674
  entries,
3615
3675
  more = false,
3616
- onMenuClose
3676
+ returnFocusFallback
3617
3677
  }) {
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
- }
3678
+ const { state, close, buttonProps, behaviourRef } = useMenuButton({
3679
+ itemCount: entries.filter((entry) => entry.type !== "separator").length
3680
+ });
3636
3681
  return /* @__PURE__ */ jsxs17(Fragment8, { children: [
3637
3682
  /* @__PURE__ */ jsxs17(
3638
3683
  "button",
@@ -3642,21 +3687,7 @@ function ToolbarMenuButton({
3642
3687
  className: classNames("toolbar-button", more && "toolbar-more"),
3643
3688
  "data-gridkit-toolbar-item": itemKey,
3644
3689
  ...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
- },
3690
+ ...buttonProps,
3660
3691
  children: [
3661
3692
  icon !== void 0 && /* @__PURE__ */ jsx23("span", { className: "toolbar-button-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx23(MenuIcon, { name: icon }) }),
3662
3693
  label,
@@ -3664,22 +3695,23 @@ function ToolbarMenuButton({
3664
3695
  ]
3665
3696
  }
3666
3697
  ),
3667
- menu !== null && /* @__PURE__ */ jsx23(
3698
+ state.kind === "open" && /* @__PURE__ */ jsx23(
3668
3699
  Overlay,
3669
3700
  {
3670
- anchor: menu.anchor,
3701
+ anchor: state.anchor,
3671
3702
  placement: "bottom-start",
3672
- gap: ANCHOR_GAP,
3673
- returnFocusTo: menu.anchor,
3674
- themeClassName: menu.themeClassName,
3703
+ gap: state.gap,
3704
+ returnFocusTo: state.anchor,
3705
+ returnFocusFallback,
3706
+ themeClassName: state.themeClassName,
3675
3707
  onDismiss: close,
3676
3708
  children: /* @__PURE__ */ jsx23(
3677
3709
  GridMenu,
3678
3710
  {
3679
3711
  entries,
3680
3712
  label,
3681
- themeClassName: menu.themeClassName,
3682
- behaviourRef: menuBehaviourRef,
3713
+ themeClassName: state.themeClassName,
3714
+ behaviourRef,
3683
3715
  onRun: (item) => {
3684
3716
  item.run();
3685
3717
  close();
@@ -3693,7 +3725,7 @@ function ToolbarMenuButton({
3693
3725
  }
3694
3726
 
3695
3727
  // src/DataGrid/toolbar/ToolbarSearch.tsx
3696
- import { useEffect as useEffect6, useRef as useRef17, useState as useState14 } from "react";
3728
+ import { useEffect as useEffect6, useRef as useRef17, useState as useState12 } from "react";
3697
3729
  import {
3698
3730
  searchTextOf,
3699
3731
  setSearchText
@@ -3708,7 +3740,7 @@ function ToolbarSearch({
3708
3740
  announce
3709
3741
  }) {
3710
3742
  const applied = searchTextOf(controller.getState().filter);
3711
- const [draft, setDraft] = useState14(null);
3743
+ const [draft, setDraft] = useState12(null);
3712
3744
  const timer = useRef17(void 0);
3713
3745
  const unannounced = useRef17(null);
3714
3746
  const text = draft !== null && draft.over === applied ? draft.text : applied;
@@ -3768,10 +3800,10 @@ function ToolbarSearch({
3768
3800
  }
3769
3801
 
3770
3802
  // src/DataGrid/toolbar/useToolbarOverflow.ts
3771
- import { useLayoutEffect as useLayoutEffect12, useRef as useRef18, useState as useState15 } from "react";
3803
+ import { useLayoutEffect as useLayoutEffect11, useRef as useRef18, useState as useState13 } from "react";
3772
3804
  import { observeToolbarOverflow } from "@gridkitjs/dom";
3773
3805
  function useToolbarOverflow(toolbarRef, items) {
3774
- const [fit, setFit] = useState15(items.length);
3806
+ const [fit, setFit] = useState13(items.length);
3775
3807
  const overflow = useRef18(null);
3776
3808
  const measuredLayout = useRef18("");
3777
3809
  const layout = JSON.stringify(
@@ -3781,7 +3813,7 @@ function useToolbarOverflow(toolbarRef, items) {
3781
3813
  "label" in item ? item.label : null
3782
3814
  ])
3783
3815
  );
3784
- useLayoutEffect12(() => {
3816
+ useLayoutEffect11(() => {
3785
3817
  const toolbar = toolbarRef.current;
3786
3818
  if (toolbar === null || layout === measuredLayout.current) {
3787
3819
  return;
@@ -3794,7 +3826,7 @@ function useToolbarOverflow(toolbarRef, items) {
3794
3826
  overflow.current.update(options);
3795
3827
  }
3796
3828
  }, [toolbarRef, layout, items]);
3797
- useLayoutEffect12(
3829
+ useLayoutEffect11(
3798
3830
  () => () => {
3799
3831
  overflow.current?.detach();
3800
3832
  overflow.current = null;
@@ -3881,7 +3913,6 @@ function Toolbar({
3881
3913
  announce
3882
3914
  }) {
3883
3915
  const toolbarRef = useRef19(null);
3884
- const menuClosed = useRef19(false);
3885
3916
  const items = resolveToolbar(entries, {
3886
3917
  commands: commands.commands,
3887
3918
  contextFor: commands.contextFor,
@@ -3893,22 +3924,13 @@ function Toolbar({
3893
3924
  );
3894
3925
  const fit = useToolbarOverflow(toolbarRef, items);
3895
3926
  const { shown, overflow } = splitToolbarItems(items, fit);
3896
- useLayoutEffect13(() => {
3927
+ useLayoutEffect12(() => {
3897
3928
  const toolbar = toolbarRef.current;
3898
3929
  return toolbar === null ? void 0 : attachToolbar(toolbar);
3899
3930
  }, []);
3900
- useLayoutEffect13(() => {
3901
- if (!menuClosed.current) {
3902
- return;
3903
- }
3904
- menuClosed.current = false;
3931
+ function toolbarTabStop() {
3905
3932
  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;
3933
+ return toolbar?.querySelector('[tabindex="0"]') ?? toolbar?.querySelector("button, input") ?? null;
3912
3934
  }
3913
3935
  function draw(item) {
3914
3936
  switch (item.type) {
@@ -3950,7 +3972,7 @@ function Toolbar({
3950
3972
  label: item.label,
3951
3973
  icon: item.icon,
3952
3974
  entries: item.items,
3953
- onMenuClose
3975
+ returnFocusFallback: toolbarTabStop
3954
3976
  },
3955
3977
  item.key
3956
3978
  );
@@ -4016,7 +4038,7 @@ function Toolbar({
4016
4038
  label: messages.moreToolbarItems,
4017
4039
  entries: overflow,
4018
4040
  more: true,
4019
- onMenuClose
4041
+ returnFocusFallback: toolbarTabStop
4020
4042
  }
4021
4043
  )
4022
4044
  ]
@@ -4065,7 +4087,7 @@ function useColumnDrag({
4065
4087
 
4066
4088
  // src/DataGrid/useColumnResize.ts
4067
4089
  import {
4068
- useState as useState16
4090
+ useState as useState14
4069
4091
  } from "react";
4070
4092
  import {
4071
4093
  beginColumnResize,
@@ -4079,7 +4101,7 @@ function useColumnResize({
4079
4101
  controller,
4080
4102
  columnSizeDefaults
4081
4103
  }) {
4082
- const [activeColumnId, setActiveColumnId] = useState16(null);
4104
+ const [activeColumnId, setActiveColumnId] = useState14(null);
4083
4105
  const startGesture = useGestureSignal();
4084
4106
  function startResize(entry, event) {
4085
4107
  event.stopPropagation();
@@ -4158,11 +4180,11 @@ function useColumnResize({
4158
4180
  }
4159
4181
 
4160
4182
  // src/DataGrid/useElementWidth.ts
4161
- import { useLayoutEffect as useLayoutEffect14, useState as useState17 } from "react";
4183
+ import { useLayoutEffect as useLayoutEffect13, useState as useState15 } from "react";
4162
4184
  import { observeElementWidth } from "@gridkitjs/dom";
4163
4185
  function useElementWidth(ref, enabled) {
4164
- const [width, setWidth] = useState17(null);
4165
- useLayoutEffect14(() => {
4186
+ const [width, setWidth] = useState15(null);
4187
+ useLayoutEffect13(() => {
4166
4188
  const element = ref.current;
4167
4189
  if (element === null || !enabled) {
4168
4190
  return void 0;
@@ -4173,12 +4195,12 @@ function useElementWidth(ref, enabled) {
4173
4195
  }
4174
4196
 
4175
4197
  // src/DataGrid/useGridController.ts
4176
- import { useState as useState18, useSyncExternalStore as useSyncExternalStore2 } from "react";
4198
+ import { useState as useState16, useSyncExternalStore as useSyncExternalStore2 } from "react";
4177
4199
  import {
4178
4200
  createGridController
4179
4201
  } from "@gridkitjs/core";
4180
4202
  function useGridController(options) {
4181
- const [controller] = useState18(
4203
+ const [controller] = useState16(
4182
4204
  () => createGridController(options)
4183
4205
  );
4184
4206
  controller.setOptions(options);
@@ -4226,11 +4248,11 @@ function useInfiniteScroll({
4226
4248
  }
4227
4249
 
4228
4250
  // src/DataGrid/useLiveAnnouncer.ts
4229
- import { useCallback, useLayoutEffect as useLayoutEffect15, useRef as useRef21 } from "react";
4251
+ import { useCallback as useCallback3, useLayoutEffect as useLayoutEffect14, useRef as useRef21 } from "react";
4230
4252
  import { createLiveAnnouncer } from "@gridkitjs/dom";
4231
4253
  function useLiveAnnouncer(containerRef) {
4232
4254
  const announcer = useRef21(null);
4233
- useLayoutEffect15(() => {
4255
+ useLayoutEffect14(() => {
4234
4256
  const container = containerRef.current;
4235
4257
  if (container === null) {
4236
4258
  return void 0;
@@ -4242,13 +4264,13 @@ function useLiveAnnouncer(containerRef) {
4242
4264
  announcer.current = null;
4243
4265
  };
4244
4266
  }, [containerRef]);
4245
- return useCallback((text) => {
4267
+ return useCallback3((text) => {
4246
4268
  announcer.current?.announce(text);
4247
4269
  }, []);
4248
4270
  }
4249
4271
 
4250
4272
  // src/DataGrid/useRowVirtualizer.ts
4251
- import { useLayoutEffect as useLayoutEffect16, useState as useState19 } from "react";
4273
+ import { useLayoutEffect as useLayoutEffect15, useState as useState17 } from "react";
4252
4274
  import { createRowVirtualizer as createRowVirtualizer2 } from "@gridkitjs/dom";
4253
4275
  var EMPTY_RANGE = {
4254
4276
  startIndex: 0,
@@ -4266,9 +4288,9 @@ function useRowVirtualizer({
4266
4288
  estimatedRowHeight,
4267
4289
  overscan
4268
4290
  }) {
4269
- const [virtualizer, setVirtualizer] = useState19(null);
4270
- const [range, setRange] = useState19(EMPTY_RANGE);
4271
- useLayoutEffect16(() => {
4291
+ const [virtualizer, setVirtualizer] = useState17(null);
4292
+ const [range, setRange] = useState17(EMPTY_RANGE);
4293
+ useLayoutEffect15(() => {
4272
4294
  const element = bodyScrollRef.current;
4273
4295
  if (!enabled || element === null) {
4274
4296
  return void 0;
@@ -4283,7 +4305,7 @@ function useRowVirtualizer({
4283
4305
  created.destroy();
4284
4306
  };
4285
4307
  }, [enabled, bodyScrollRef, estimatedRowHeight, overscan]);
4286
- useLayoutEffect16(() => {
4308
+ useLayoutEffect15(() => {
4287
4309
  virtualizer?.setRowCount(rows.length);
4288
4310
  virtualizer?.resetHeights();
4289
4311
  }, [virtualizer, rows]);
@@ -4358,6 +4380,7 @@ function DataGrid(props) {
4358
4380
  const hoverColumns = hoverable?.columns ?? true;
4359
4381
  const hoverCells = hoverable?.cells ?? true;
4360
4382
  const viewportRef = useRef22(null);
4383
+ const gridRef = useRef22(null);
4361
4384
  const headerTableRef = useRef22(null);
4362
4385
  const bodyTableRef = useRef22(null);
4363
4386
  const bodyScrollRef = useRef22(null);
@@ -4381,8 +4404,8 @@ function DataGrid(props) {
4381
4404
  columnOf
4382
4405
  })
4383
4406
  });
4384
- const [readPagination] = useState20(() => paginationReader(controller));
4385
- const [readSelectedRows] = useState20(() => selectedRowsReader(controller));
4407
+ const [readPagination] = useState18(() => paginationReader(controller));
4408
+ const [readSelectedRows] = useState18(() => selectedRowsReader(controller));
4386
4409
  const virtualizer = useRowVirtualizer({
4387
4410
  enabled: virtualized,
4388
4411
  rows: view.pageRows,
@@ -4427,6 +4450,7 @@ function DataGrid(props) {
4427
4450
  columnSizeDefaults
4428
4451
  });
4429
4452
  const nav = useGridNavigation({
4453
+ gridRef,
4430
4454
  headerTableRef,
4431
4455
  bodyTableRef,
4432
4456
  // `null` when virtualization is off, in which case behavior is
@@ -4449,7 +4473,15 @@ function DataGrid(props) {
4449
4473
  return entry !== void 0 && "kind" in entry && entry.kind === "group-summary";
4450
4474
  }
4451
4475
  });
4452
- const panels = useGridPanels({ rootRef: viewportRef, headerTableRef, nav });
4476
+ const overlay = useGridOverlay({
4477
+ nav,
4478
+ onContextMenuOpenChange: props.onContextMenuOpenChange
4479
+ });
4480
+ const panels = useGridPanels({
4481
+ rootRef: viewportRef,
4482
+ headerTableRef,
4483
+ overlay
4484
+ });
4453
4485
  const commands = useGridCommands({
4454
4486
  controller,
4455
4487
  commands: props.commands,
@@ -4523,7 +4555,7 @@ function DataGrid(props) {
4523
4555
  bodyTableRef,
4524
4556
  bodyScrollRef,
4525
4557
  contextMenu: props.contextMenu,
4526
- onContextMenuOpenChange: props.onContextMenuOpenChange,
4558
+ overlay,
4527
4559
  controller,
4528
4560
  commands,
4529
4561
  nav,
@@ -4676,6 +4708,7 @@ function DataGrid(props) {
4676
4708
  /* @__PURE__ */ jsxs19(
4677
4709
  "div",
4678
4710
  {
4711
+ ref: gridRef,
4679
4712
  id: gridId,
4680
4713
  className: "gridkit-data-grid-tables",
4681
4714
  role: state.groupBy.length > 0 ? "treegrid" : "grid",
@@ -4826,12 +4859,12 @@ function DataGrid(props) {
4826
4859
  import { serializeGridState } from "@gridkitjs/core";
4827
4860
 
4828
4861
  // src/DataGrid/hooks/usePaginationState.ts
4829
- import { useCallback as useCallback3 } from "react";
4862
+ import { useCallback as useCallback5 } from "react";
4830
4863
 
4831
4864
  // src/DataGrid/hooks/useGridSnapshot.ts
4832
- import { useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore3 } from "react";
4865
+ import { useCallback as useCallback4, useSyncExternalStore as useSyncExternalStore3 } from "react";
4833
4866
  function useGridSnapshot(gridRef, getSnapshot, fallback) {
4834
- const subscribe = useCallback2(
4867
+ const subscribe = useCallback4(
4835
4868
  (listener) => {
4836
4869
  const api = gridRef.current;
4837
4870
  if (api === null) {
@@ -4857,12 +4890,12 @@ var FALLBACK_PAGINATION = { pageIndex: 0, pageSize: 0 };
4857
4890
  function usePaginationState(gridRef) {
4858
4891
  const pagination = useGridSnapshot(
4859
4892
  gridRef,
4860
- useCallback3((api) => api.getPagination(), []),
4893
+ useCallback5((api) => api.getPagination(), []),
4861
4894
  FALLBACK_PAGINATION
4862
4895
  );
4863
4896
  const pageCount = useGridSnapshot(
4864
4897
  gridRef,
4865
- useCallback3((api) => api.getPageCount(), []),
4898
+ useCallback5((api) => api.getPageCount(), []),
4866
4899
  0
4867
4900
  );
4868
4901
  return {
@@ -4884,18 +4917,18 @@ function usePaginationState(gridRef) {
4884
4917
  }
4885
4918
 
4886
4919
  // src/DataGrid/hooks/useGroupByState.ts
4887
- import { useCallback as useCallback4 } from "react";
4920
+ import { useCallback as useCallback6 } from "react";
4888
4921
  var FALLBACK_GROUP_BY = [];
4889
4922
  var FALLBACK_EXPANSION = [];
4890
4923
  function useGroupByState(gridRef) {
4891
4924
  const groupBy = useGridSnapshot(
4892
4925
  gridRef,
4893
- useCallback4((api) => api.getGroupBy(), []),
4926
+ useCallback6((api) => api.getGroupBy(), []),
4894
4927
  FALLBACK_GROUP_BY
4895
4928
  );
4896
4929
  const groupExpansion = useGridSnapshot(
4897
4930
  gridRef,
4898
- useCallback4((api) => api.getGroupExpansion(), []),
4931
+ useCallback6((api) => api.getGroupExpansion(), []),
4899
4932
  FALLBACK_EXPANSION
4900
4933
  );
4901
4934
  return {
@@ -4911,34 +4944,34 @@ function useGroupByState(gridRef) {
4911
4944
  }
4912
4945
 
4913
4946
  // src/DataGrid/hooks/useColumnSortState.ts
4914
- import { useCallback as useCallback5 } from "react";
4947
+ import { useCallback as useCallback7 } from "react";
4915
4948
  var FALLBACK_SORT = [];
4916
4949
  function useColumnSortState(gridRef) {
4917
4950
  return useGridSnapshot(
4918
4951
  gridRef,
4919
- useCallback5((api) => api.getColumnSort(), []),
4952
+ useCallback7((api) => api.getColumnSort(), []),
4920
4953
  FALLBACK_SORT
4921
4954
  );
4922
4955
  }
4923
4956
 
4924
4957
  // src/DataGrid/hooks/useSelectionState.ts
4925
- import { useCallback as useCallback6 } from "react";
4958
+ import { useCallback as useCallback8 } from "react";
4926
4959
  var FALLBACK_SELECTION = [];
4927
4960
  var FALLBACK_CELL_SELECTION = null;
4928
4961
  function useSelectionState(gridRef) {
4929
4962
  const rowSelection = useGridSnapshot(
4930
4963
  gridRef,
4931
- useCallback6((api) => api.getRowSelection(), []),
4964
+ useCallback8((api) => api.getRowSelection(), []),
4932
4965
  FALLBACK_SELECTION
4933
4966
  );
4934
4967
  const columnSelection = useGridSnapshot(
4935
4968
  gridRef,
4936
- useCallback6((api) => api.getColumnSelection(), []),
4969
+ useCallback8((api) => api.getColumnSelection(), []),
4937
4970
  FALLBACK_SELECTION
4938
4971
  );
4939
4972
  const cellSelection = useGridSnapshot(
4940
4973
  gridRef,
4941
- useCallback6((api) => api.getCellSelection(), []),
4974
+ useCallback8((api) => api.getCellSelection(), []),
4942
4975
  FALLBACK_CELL_SELECTION
4943
4976
  );
4944
4977
  return {
@@ -4955,56 +4988,56 @@ function useSelectionState(gridRef) {
4955
4988
  }
4956
4989
 
4957
4990
  // src/DataGrid/hooks/useAggregateState.ts
4958
- import { useCallback as useCallback7 } from "react";
4991
+ import { useCallback as useCallback9 } from "react";
4959
4992
  var FALLBACK_AGGREGATES = /* @__PURE__ */ new Map();
4960
4993
  function useAggregateState(gridRef) {
4961
4994
  return useGridSnapshot(
4962
4995
  gridRef,
4963
- useCallback7((api) => api.getAggregates(), []),
4996
+ useCallback9((api) => api.getAggregates(), []),
4964
4997
  FALLBACK_AGGREGATES
4965
4998
  );
4966
4999
  }
4967
5000
 
4968
5001
  // src/DataGrid/hooks/useColumnSizingState.ts
4969
- import { useCallback as useCallback8 } from "react";
5002
+ import { useCallback as useCallback10 } from "react";
4970
5003
  var FALLBACK_SIZING = {};
4971
5004
  function useColumnSizingState(gridRef) {
4972
5005
  return useGridSnapshot(
4973
5006
  gridRef,
4974
- useCallback8((api) => api.getColumnSizing(), []),
5007
+ useCallback10((api) => api.getColumnSizing(), []),
4975
5008
  FALLBACK_SIZING
4976
5009
  );
4977
5010
  }
4978
5011
 
4979
5012
  // src/DataGrid/hooks/useColumnOrderState.ts
4980
- import { useCallback as useCallback9 } from "react";
5013
+ import { useCallback as useCallback11 } from "react";
4981
5014
  var FALLBACK_ORDER = [];
4982
5015
  function useColumnOrderState(gridRef) {
4983
5016
  return useGridSnapshot(
4984
5017
  gridRef,
4985
- useCallback9((api) => api.getColumnOrder(), []),
5018
+ useCallback11((api) => api.getColumnOrder(), []),
4986
5019
  FALLBACK_ORDER
4987
5020
  );
4988
5021
  }
4989
5022
 
4990
5023
  // src/DataGrid/hooks/useColumnVisibilityState.ts
4991
- import { useCallback as useCallback10 } from "react";
5024
+ import { useCallback as useCallback12 } from "react";
4992
5025
  var FALLBACK_VISIBILITY = {};
4993
5026
  function useColumnVisibilityState(gridRef) {
4994
5027
  return useGridSnapshot(
4995
5028
  gridRef,
4996
- useCallback10((api) => api.getColumnVisibility(), []),
5029
+ useCallback12((api) => api.getColumnVisibility(), []),
4997
5030
  FALLBACK_VISIBILITY
4998
5031
  );
4999
5032
  }
5000
5033
 
5001
5034
  // src/DataGrid/hooks/useFilterState.ts
5002
- import { useCallback as useCallback11, useState as useState21 } from "react";
5035
+ import { useCallback as useCallback13, useState as useState19 } from "react";
5003
5036
  function useFilterState(gridRef) {
5004
- const [fallback] = useState21(() => []);
5037
+ const [fallback] = useState19(() => []);
5005
5038
  const filter = useGridSnapshot(
5006
5039
  gridRef,
5007
- useCallback11((api) => api.getFilter(), []),
5040
+ useCallback13((api) => api.getFilter(), []),
5008
5041
  fallback
5009
5042
  );
5010
5043
  return {