@deadragdoll/reactnu 0.1.10 → 0.1.14

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.
Files changed (3) hide show
  1. package/dist/index.cjs +156 -277
  2. package/dist/index.js +189 -312
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -665,7 +665,7 @@ function toggleMenuCheckedInTree(items, id) {
665
665
  import { useMemo as useMemo4, useState as useState6 } from "react";
666
666
 
667
667
  // src/windowing/internals/MdiWindowPickerDialog.tsx
668
- import { useEffect as useEffect4, useMemo as useMemo3, useState as useState5 } from "react";
668
+ import { useMemo as useMemo3, useState as useState5 } from "react";
669
669
 
670
670
  // src/components/Button/Button.tsx
671
671
  import {
@@ -1110,15 +1110,20 @@ function ListBoxInner({
1110
1110
  },
1111
1111
  [onItemSelect]
1112
1112
  );
1113
- function activateResolvedItem(itemId) {
1114
- if (!itemId) {
1115
- return;
1116
- }
1117
- const nextEntry = selectableItems.find((entry) => entry.itemId === itemId);
1118
- if (nextEntry) {
1119
- activateItem(nextEntry.item, nextEntry.group, nextEntry.itemId);
1120
- }
1121
- }
1113
+ const activateResolvedItem = useCallback2(
1114
+ (itemId) => {
1115
+ if (!itemId) {
1116
+ return;
1117
+ }
1118
+ const nextEntry = selectableItems.find(
1119
+ (entry) => entry.itemId === itemId
1120
+ );
1121
+ if (nextEntry) {
1122
+ activateItem(nextEntry.item, nextEntry.group, nextEntry.itemId);
1123
+ }
1124
+ },
1125
+ [activateItem, selectableItems]
1126
+ );
1122
1127
  function moveActive(direction) {
1123
1128
  if (selectableItems.length === 0) {
1124
1129
  return;
@@ -1184,7 +1189,7 @@ function ListBoxInner({
1184
1189
  toggleItemCheck(itemId);
1185
1190
  }
1186
1191
  }),
1187
- [resolvedActiveId, checkedIds, data]
1192
+ [activateResolvedItem, resolvedActiveId, toggleItemCheck]
1188
1193
  );
1189
1194
  function handleKeyDown(event) {
1190
1195
  switch (event.key) {
@@ -1346,17 +1351,14 @@ function MdiWindowPickerDialog({
1346
1351
  const [selectedId, setSelectedId] = useState5(
1347
1352
  activeWindowId ?? resolvedWindows[0]?.id ?? ""
1348
1353
  );
1349
- useEffect4(() => {
1350
- if (selectedId && resolvedWindows.some((windowEntry) => windowEntry.id === selectedId)) {
1351
- return;
1352
- }
1353
- setSelectedId(activeWindowId ?? resolvedWindows[0]?.id ?? "");
1354
- }, [activeWindowId, resolvedWindows, selectedId]);
1354
+ const resolvedSelectedId = resolvedWindows.some(
1355
+ (windowEntry) => windowEntry.id === selectedId
1356
+ ) ? selectedId : activeWindowId ?? resolvedWindows[0]?.id ?? "";
1355
1357
  function handleActivate() {
1356
- if (!selectedId) {
1358
+ if (!resolvedSelectedId) {
1357
1359
  return;
1358
1360
  }
1359
- onActivateWindow(selectedId);
1361
+ onActivateWindow(resolvedSelectedId);
1360
1362
  onClose();
1361
1363
  }
1362
1364
  return /* @__PURE__ */ jsxs8(Stack, { gap: "md", children: [
@@ -1387,7 +1389,7 @@ function MdiWindowPickerDialog({
1387
1389
  onActivateWindow(item.id);
1388
1390
  onClose();
1389
1391
  },
1390
- selectedId,
1392
+ selectedId: resolvedSelectedId,
1391
1393
  style: {
1392
1394
  maxHeight: "14rem",
1393
1395
  minHeight: "12rem"
@@ -1590,7 +1592,7 @@ import {
1590
1592
  Fragment as Fragment3,
1591
1593
  useCallback as useCallback3,
1592
1594
  useContext as useContext6,
1593
- useEffect as useEffect6,
1595
+ useEffect as useEffect5,
1594
1596
  useMemo as useMemo6,
1595
1597
  useRef as useRef6,
1596
1598
  useState as useState9
@@ -2218,6 +2220,12 @@ function AppBarItem(props) {
2218
2220
  interactive: _interactive2,
2219
2221
  ...buttonProps
2220
2222
  } = props;
2223
+ void _active2;
2224
+ void _alignment2;
2225
+ void _children2;
2226
+ void _className2;
2227
+ void _grow2;
2228
+ void _interactive2;
2221
2229
  return createElement(
2222
2230
  "button",
2223
2231
  {
@@ -2237,6 +2245,12 @@ function AppBarItem(props) {
2237
2245
  interactive: _interactive,
2238
2246
  ...staticProps
2239
2247
  } = props;
2248
+ void _active;
2249
+ void _alignment;
2250
+ void _children;
2251
+ void _className;
2252
+ void _grow;
2253
+ void _interactive;
2240
2254
  return createElement(
2241
2255
  "div",
2242
2256
  {
@@ -2339,7 +2353,7 @@ import { useState as useState8 } from "react";
2339
2353
 
2340
2354
  // src/components/TextField/TextField.tsx
2341
2355
  import {
2342
- useEffect as useEffect5,
2356
+ useEffect as useEffect4,
2343
2357
  useId as useId2,
2344
2358
  useRef as useRef5,
2345
2359
  useState as useState7
@@ -2370,7 +2384,7 @@ function TextField({
2370
2384
  () => defaultValue == null ? "" : String(defaultValue)
2371
2385
  );
2372
2386
  const resolvedValue = isControlled ? value == null ? "" : String(value) : uncontrolledValue;
2373
- useEffect5(() => {
2387
+ useEffect4(() => {
2374
2388
  if (!onDebouncedChange) {
2375
2389
  return;
2376
2390
  }
@@ -2823,31 +2837,6 @@ function findTopmostAppModalIndex(windows) {
2823
2837
  }
2824
2838
  return -1;
2825
2839
  }
2826
- function getIdHandler(cache, id, fn) {
2827
- let handler = cache.get(id);
2828
- if (!handler) {
2829
- handler = (...args) => fn(id, ...args);
2830
- cache.set(id, handler);
2831
- }
2832
- return handler;
2833
- }
2834
- function getWindowControls(cache, id, bringToFront, close, toggleMaximized, toggleMinimized, update) {
2835
- let controls = cache.get(id);
2836
- if (!controls) {
2837
- controls = { bringToFront, close, id, toggleMaximized, toggleMinimized, update };
2838
- cache.set(id, controls);
2839
- }
2840
- return controls;
2841
- }
2842
- function getWindowContent(cache, id, source, controls) {
2843
- const cached = cache.get(id);
2844
- if (cached && cached.source === source) {
2845
- return cached.element;
2846
- }
2847
- const element = typeof source === "function" ? source(controls) : source;
2848
- cache.set(id, { source, element });
2849
- return element;
2850
- }
2851
2840
  function getActivationChain(windows, id) {
2852
2841
  const targetWindow = windows.find((windowEntry) => windowEntry.id === id);
2853
2842
  if (!targetWindow) {
@@ -2873,28 +2862,6 @@ function NuWindowProvider({
2873
2862
  const creationOrderRef = useRef6(0);
2874
2863
  const idRef = useRef6(0);
2875
2864
  const windowBoundsByIdRef = useRef6({});
2876
- const boundsChangeHandlersRef = useRef6(
2877
- /* @__PURE__ */ new Map()
2878
- );
2879
- const windowStyleCacheRef = useRef6(
2880
- /* @__PURE__ */ new Map()
2881
- );
2882
- const closeHandlersRef = useRef6(/* @__PURE__ */ new Map());
2883
- const activateHandlersRef = useRef6(/* @__PURE__ */ new Map());
2884
- const bringToFrontHandlersRef = useRef6(/* @__PURE__ */ new Map());
2885
- const toggleMaximizedHandlersRef = useRef6(/* @__PURE__ */ new Map());
2886
- const toggleMinimizedHandlersRef = useRef6(/* @__PURE__ */ new Map());
2887
- const positionHandlersRef = useRef6(
2888
- /* @__PURE__ */ new Map()
2889
- );
2890
- const sizeHandlersRef = useRef6(/* @__PURE__ */ new Map());
2891
- const updateHandlersRef = useRef6(
2892
- /* @__PURE__ */ new Map()
2893
- );
2894
- const controlsCacheRef = useRef6(/* @__PURE__ */ new Map());
2895
- const contentCacheRef = useRef6(
2896
- /* @__PURE__ */ new Map()
2897
- );
2898
2865
  const [windows, setWindows] = useState9([]);
2899
2866
  const [windowBoundsById, setWindowBoundsById] = useState9({});
2900
2867
  const appHostMenuContext = useContext6(AppHostMenuContext);
@@ -2947,53 +2914,6 @@ function NuWindowProvider({
2947
2914
  },
2948
2915
  []
2949
2916
  );
2950
- const getBoundsChangeHandler = useCallback3(
2951
- (id) => {
2952
- let handler = boundsChangeHandlersRef.current.get(id);
2953
- if (!handler) {
2954
- handler = (bounds) => updateWindowBounds(id, bounds);
2955
- boundsChangeHandlersRef.current.set(id, handler);
2956
- }
2957
- return handler;
2958
- },
2959
- [updateWindowBounds]
2960
- );
2961
- const getWindowStyle = useCallback3(
2962
- (id, source, zIndex) => {
2963
- const cached = windowStyleCacheRef.current.get(id);
2964
- if (cached && cached.source === source && cached.zIndex === zIndex) {
2965
- return cached.merged;
2966
- }
2967
- const merged = { ...source, zIndex };
2968
- windowStyleCacheRef.current.set(id, { source, zIndex, merged });
2969
- return merged;
2970
- },
2971
- []
2972
- );
2973
- useEffect6(() => {
2974
- const liveIds = new Set(windows.map((windowEntry) => windowEntry.id));
2975
- const idKeyedCaches = [
2976
- boundsChangeHandlersRef.current,
2977
- windowStyleCacheRef.current,
2978
- closeHandlersRef.current,
2979
- activateHandlersRef.current,
2980
- bringToFrontHandlersRef.current,
2981
- toggleMaximizedHandlersRef.current,
2982
- toggleMinimizedHandlersRef.current,
2983
- positionHandlersRef.current,
2984
- sizeHandlersRef.current,
2985
- updateHandlersRef.current,
2986
- controlsCacheRef.current,
2987
- contentCacheRef.current
2988
- ];
2989
- for (const cache of idKeyedCaches) {
2990
- for (const id of cache.keys()) {
2991
- if (!liveIds.has(id)) {
2992
- cache.delete(id);
2993
- }
2994
- }
2995
- }
2996
- }, [windows]);
2997
2917
  const bringToFront = useCallback3((id) => {
2998
2918
  setWindows((currentWindows) => {
2999
2919
  const activationChain = getActivationChain(currentWindows, id);
@@ -3335,13 +3255,13 @@ function NuWindowProvider({
3335
3255
  windowsInfo
3336
3256
  ]
3337
3257
  );
3338
- useEffect6(() => {
3258
+ useEffect5(() => {
3339
3259
  if (!appHostMenuContext) {
3340
3260
  return;
3341
3261
  }
3342
3262
  appHostMenuContext.setWindowBridge(mdiBridge);
3343
3263
  }, [appHostMenuContext, mdiBridge]);
3344
- useEffect6(() => {
3264
+ useEffect5(() => {
3345
3265
  if (!appHostMenuContext) {
3346
3266
  return;
3347
3267
  }
@@ -3349,7 +3269,7 @@ function NuWindowProvider({
3349
3269
  appHostMenuContext.setWindowBridge(null);
3350
3270
  };
3351
3271
  }, [appHostMenuContext]);
3352
- useEffect6(() => {
3272
+ useEffect5(() => {
3353
3273
  onAppModalChange?.(hasAppModal);
3354
3274
  }, [hasAppModal, onAppModalChange]);
3355
3275
  return /* @__PURE__ */ jsx26(NuWindowContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs15("div", { className: ["nu-window-host", className].filter(Boolean).join(" "), children: [
@@ -3366,61 +3286,23 @@ function NuWindowProvider({
3366
3286
  width: ownerBounds.width,
3367
3287
  zIndex: stackIndex + 1
3368
3288
  } : null;
3369
- const handleClose = getIdHandler(
3370
- closeHandlersRef.current,
3371
- windowEntry.id,
3372
- closeWindow
3373
- );
3374
- const handleActivate = getIdHandler(
3375
- activateHandlersRef.current,
3376
- windowEntry.id,
3377
- activateWindow
3378
- );
3379
- const handleBringToFront = getIdHandler(
3380
- bringToFrontHandlersRef.current,
3381
- windowEntry.id,
3382
- bringToFront
3383
- );
3384
- const handleToggleMaximized = getIdHandler(
3385
- toggleMaximizedHandlersRef.current,
3386
- windowEntry.id,
3387
- toggleWindowMaximized
3388
- );
3389
- const handleToggleMinimized = getIdHandler(
3390
- toggleMinimizedHandlersRef.current,
3391
- windowEntry.id,
3392
- toggleWindowMinimized
3393
- );
3394
- const handlePositionChange = getIdHandler(
3395
- positionHandlersRef.current,
3396
- windowEntry.id,
3397
- updateWindowPosition
3398
- );
3399
- const handleSizeChange = getIdHandler(
3400
- sizeHandlersRef.current,
3401
- windowEntry.id,
3402
- handleWindowSizeChange
3403
- );
3404
- const handleUpdate = getIdHandler(
3405
- updateHandlersRef.current,
3406
- windowEntry.id,
3407
- updateWindow
3408
- );
3409
- const controls = getWindowControls(
3410
- controlsCacheRef.current,
3411
- windowEntry.id,
3412
- handleBringToFront,
3413
- handleClose,
3414
- handleToggleMaximized,
3415
- handleToggleMinimized,
3416
- handleUpdate
3417
- );
3418
- const content = getWindowContent(
3419
- contentCacheRef.current,
3420
- windowEntry.id,
3421
- windowEntry.content,
3422
- controls
3423
- );
3289
+ const handleClose = () => closeWindow(windowEntry.id);
3290
+ const handleActivate = () => activateWindow(windowEntry.id);
3291
+ const handleBringToFront = () => bringToFront(windowEntry.id);
3292
+ const handleToggleMaximized = () => toggleWindowMaximized(windowEntry.id);
3293
+ const handleToggleMinimized = () => toggleWindowMinimized(windowEntry.id);
3294
+ const handlePositionChange = (position) => updateWindowPosition(windowEntry.id, position);
3295
+ const handleSizeChange = (size) => handleWindowSizeChange(windowEntry.id, size);
3296
+ const handleUpdate = (patch) => updateWindow(windowEntry.id, patch);
3297
+ const controls = {
3298
+ bringToFront: handleBringToFront,
3299
+ close: handleClose,
3300
+ id: windowEntry.id,
3301
+ toggleMaximized: handleToggleMaximized,
3302
+ toggleMinimized: handleToggleMinimized,
3303
+ update: handleUpdate
3304
+ };
3305
+ const content = typeof windowEntry.content === "function" ? windowEntry.content(controls) : windowEntry.content;
3424
3306
  return /* @__PURE__ */ jsxs15(Fragment3, { children: [
3425
3307
  isTopmostAppModal ? /* @__PURE__ */ jsx26(
3426
3308
  "div",
@@ -3450,7 +3332,7 @@ function NuWindowProvider({
3450
3332
  minimized: windowEntry.minimized,
3451
3333
  mode: windowEntry.mode,
3452
3334
  onActivate: handleActivate,
3453
- onBoundsChange: getBoundsChangeHandler(windowEntry.id),
3335
+ onBoundsChange: (bounds) => updateWindowBounds(windowEntry.id, bounds),
3454
3336
  onClose: handleClose,
3455
3337
  onPositionChange: handlePositionChange,
3456
3338
  onSizeChange: handleSizeChange,
@@ -3458,11 +3340,10 @@ function NuWindowProvider({
3458
3340
  onToggleMinimized: handleToggleMinimized,
3459
3341
  resizable: windowEntry.resizable,
3460
3342
  statusBar: windowEntry.statusBar,
3461
- style: getWindowStyle(
3462
- windowEntry.id,
3463
- windowEntry.style,
3464
- isTopmostAppModal && topmostAppModalIndex >= 0 ? visibleWindows.length + 2 : ownerBackdropStyle ? ownerBackdropStyle.zIndex + 1 : (stackIndex ?? 0) + 1
3465
- ),
3343
+ style: {
3344
+ ...windowEntry.style,
3345
+ zIndex: isTopmostAppModal && topmostAppModalIndex >= 0 ? visibleWindows.length + 2 : ownerBackdropStyle ? ownerBackdropStyle.zIndex + 1 : (stackIndex ?? 0) + 1
3346
+ },
3466
3347
  title: windowEntry.title,
3467
3348
  children: content
3468
3349
  }
@@ -3747,7 +3628,7 @@ function CheckBox({
3747
3628
 
3748
3629
  // src/components/Dropdown/Dropdown.tsx
3749
3630
  import {
3750
- useEffect as useEffect7,
3631
+ useEffect as useEffect6,
3751
3632
  useId as useId4,
3752
3633
  useMemo as useMemo7,
3753
3634
  useRef as useRef7,
@@ -3761,6 +3642,7 @@ function ControlOpener(props) {
3761
3642
  const { children, className, glyphClassName, glyphStyle, style } = props;
3762
3643
  if (props.as === "button") {
3763
3644
  const { as: _as2, type = "button", ...buttonProps } = props;
3645
+ void _as2;
3764
3646
  return /* @__PURE__ */ jsx30(
3765
3647
  "button",
3766
3648
  {
@@ -3780,6 +3662,7 @@ function ControlOpener(props) {
3780
3662
  );
3781
3663
  }
3782
3664
  const { ariaHidden = false, as: _as, ...spanProps } = props;
3665
+ void _as;
3783
3666
  return /* @__PURE__ */ jsx30(
3784
3667
  "span",
3785
3668
  {
@@ -3975,7 +3858,7 @@ function Dropdown({
3975
3858
  [options]
3976
3859
  );
3977
3860
  const displayText = selectedOption?.item.name.text ?? placeholder;
3978
- useEffect7(() => {
3861
+ useEffect6(() => {
3979
3862
  if (!open) {
3980
3863
  return;
3981
3864
  }
@@ -4003,7 +3886,7 @@ function Dropdown({
4003
3886
  open,
4004
3887
  popupRef
4005
3888
  });
4006
- useEffect7(() => {
3889
+ useEffect6(() => {
4007
3890
  if (!open) {
4008
3891
  return;
4009
3892
  }
@@ -4388,7 +4271,7 @@ function InfoAccent({
4388
4271
 
4389
4272
  // src/components/ComboBox/ComboBox.tsx
4390
4273
  import {
4391
- useEffect as useEffect8,
4274
+ useEffect as useEffect7,
4392
4275
  useId as useId5,
4393
4276
  useMemo as useMemo8,
4394
4277
  useRef as useRef8,
@@ -4440,7 +4323,7 @@ function findComboBoxOption(options, value) {
4440
4323
  }
4441
4324
  return options.find((option) => option.value === value) ?? null;
4442
4325
  }
4443
- function resolveComboBoxPortalRoot(anchor) {
4326
+ function resolveComboBoxPortalRoot() {
4444
4327
  return document.body;
4445
4328
  }
4446
4329
  function ComboBox({
@@ -4502,8 +4385,9 @@ function ComboBox({
4502
4385
  ),
4503
4386
  [filteredData]
4504
4387
  );
4505
- const popupRoot = typeof document === "undefined" ? null : resolveComboBoxPortalRoot(rootRef.current);
4506
- useEffect8(() => {
4388
+ const popupRoot = typeof document === "undefined" ? null : resolveComboBoxPortalRoot();
4389
+ const [themePortalStyle, setThemePortalStyle] = useState13(() => void 0);
4390
+ useEffect7(() => {
4507
4391
  if (!open) {
4508
4392
  return;
4509
4393
  }
@@ -4552,7 +4436,10 @@ function ComboBox({
4552
4436
  if (disabled) {
4553
4437
  return;
4554
4438
  }
4555
- setOpen((currentOpen) => !currentOpen);
4439
+ if (!open) {
4440
+ setThemePortalStyle(getThemePortalStyle(rootRef.current));
4441
+ }
4442
+ setOpen(!open);
4556
4443
  inputRef.current?.focus();
4557
4444
  }
4558
4445
  function handleInputKeyDown(event) {
@@ -4562,6 +4449,7 @@ function ComboBox({
4562
4449
  switch (event.key) {
4563
4450
  case "ArrowDown":
4564
4451
  event.preventDefault();
4452
+ setThemePortalStyle(getThemePortalStyle(rootRef.current));
4565
4453
  setOpen(true);
4566
4454
  break;
4567
4455
  case "Enter":
@@ -4637,6 +4525,7 @@ function ComboBox({
4637
4525
  id: fieldId,
4638
4526
  onChange: (event) => {
4639
4527
  setResolvedInputValue(event.target.value);
4528
+ setThemePortalStyle(getThemePortalStyle(rootRef.current));
4640
4529
  setOpen(true);
4641
4530
  },
4642
4531
  onKeyDown: handleInputKeyDown,
@@ -4696,7 +4585,7 @@ function ComboBox({
4696
4585
  id: `${fieldId}-popup`,
4697
4586
  ref: popupRef,
4698
4587
  style: mergeSlotStyle(
4699
- getThemePortalStyle(rootRef.current),
4588
+ themePortalStyle,
4700
4589
  slotStyles?.popup
4701
4590
  ),
4702
4591
  children: /* @__PURE__ */ jsx34(
@@ -4741,7 +4630,7 @@ import {
4741
4630
  // src/components/PopupMenu/PopupMenu.tsx
4742
4631
  import {
4743
4632
  useCallback as useCallback4,
4744
- useEffect as useEffect9,
4633
+ useEffect as useEffect8,
4745
4634
  useLayoutEffect as useLayoutEffect3,
4746
4635
  useRef as useRef9,
4747
4636
  useState as useState14
@@ -4770,7 +4659,7 @@ function resolveAnchorPosition(anchor) {
4770
4659
  top: rect.bottom - 1
4771
4660
  };
4772
4661
  }
4773
- function resolvePortalRoot(anchor) {
4662
+ function resolvePortalRoot() {
4774
4663
  if (typeof document === "undefined") {
4775
4664
  return null;
4776
4665
  }
@@ -4793,7 +4682,7 @@ function PopupMenu({
4793
4682
  const [uncontrolledOpen, setUncontrolledOpen] = useState14(defaultOpen);
4794
4683
  const isControlled = open !== void 0;
4795
4684
  const resolvedOpen = isControlled ? open : uncontrolledOpen;
4796
- const portalRoot = resolvePortalRoot(anchor);
4685
+ const portalRoot = resolvePortalRoot();
4797
4686
  const setResolvedOpen = useCallback4(
4798
4687
  (nextOpen) => {
4799
4688
  if (!nextOpen) {
@@ -4806,7 +4695,7 @@ function PopupMenu({
4806
4695
  },
4807
4696
  [isControlled, onOpenChange]
4808
4697
  );
4809
- useEffect9(() => {
4698
+ useEffect8(() => {
4810
4699
  if (!resolvedOpen) {
4811
4700
  return;
4812
4701
  }
@@ -5078,7 +4967,7 @@ function CommandButton({
5078
4967
  }
5079
4968
 
5080
4969
  // src/components/CrtGlitch/CrtGlitch.tsx
5081
- import { useEffect as useEffect10, useId as useId6, useRef as useRef10 } from "react";
4970
+ import { useEffect as useEffect9, useId as useId6, useRef as useRef10 } from "react";
5082
4971
  import { jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
5083
4972
  var DEFAULT_INTERVAL_MS = 3e3;
5084
4973
  var DEFAULT_DURATION_MS = 2500;
@@ -5111,7 +5000,7 @@ function NuCrtGlitch({
5111
5000
  const bOffsetRef = useRef10(null);
5112
5001
  const rafRef = useRef10(null);
5113
5002
  const targetElRef = useRef10(null);
5114
- useEffect10(() => {
5003
+ useEffect9(() => {
5115
5004
  if (!enabled) {
5116
5005
  return;
5117
5006
  }
@@ -5286,7 +5175,7 @@ function NuCrtGlitch({
5286
5175
  import {
5287
5176
  forwardRef as forwardRef2,
5288
5177
  useCallback as useCallback5,
5289
- useEffect as useEffect11,
5178
+ useEffect as useEffect10,
5290
5179
  useImperativeHandle as useImperativeHandle2,
5291
5180
  useMemo as useMemo9,
5292
5181
  useRef as useRef11,
@@ -5486,7 +5375,7 @@ function ListViewInner({
5486
5375
  );
5487
5376
  return [checkboxColumn, ...dataColumns].filter(Boolean).join(" ");
5488
5377
  }, [columns, showCheckBox]);
5489
- useEffect11(() => {
5378
+ useEffect10(() => {
5490
5379
  if (!resolvedActiveRowId) {
5491
5380
  return;
5492
5381
  }
@@ -5582,7 +5471,7 @@ function ListViewInner({
5582
5471
  toggleRowCheck(rowId);
5583
5472
  }
5584
5473
  }),
5585
- [resolvedActiveRowId, showCheckBox, checkedIds, data]
5474
+ [activateRowId, resolvedActiveRowId, toggleRowCheck]
5586
5475
  );
5587
5476
  function handleKeyDown(event) {
5588
5477
  switch (event.key) {
@@ -5680,7 +5569,7 @@ var ListView = forwardRef2(ListViewInner);
5680
5569
 
5681
5570
  // src/components/MaskedField/MaskedField.tsx
5682
5571
  import {
5683
- useEffect as useEffect12,
5572
+ useEffect as useEffect11,
5684
5573
  useId as useId7,
5685
5574
  useMemo as useMemo10,
5686
5575
  useRef as useRef12,
@@ -5886,7 +5775,7 @@ function MaskedField({
5886
5775
  () => props.inputMode === void 0 ? getTextMaskInputMode(mask) : void 0,
5887
5776
  [mask, props.inputMode]
5888
5777
  );
5889
- useEffect12(() => {
5778
+ useEffect11(() => {
5890
5779
  if (!onDebouncedChange) {
5891
5780
  return;
5892
5781
  }
@@ -6276,7 +6165,6 @@ function Panel({
6276
6165
 
6277
6166
  // src/components/PropertyGrid/PropertyGrid.tsx
6278
6167
  import {
6279
- useEffect as useEffect13,
6280
6168
  useId as useId9,
6281
6169
  useMemo as useMemo12,
6282
6170
  useRef as useRef14,
@@ -6395,7 +6283,7 @@ function PropertyGrid({
6395
6283
  const isExpandedControlled = expandedIdsProp !== void 0;
6396
6284
  const isActiveControlled = activeIdProp !== void 0;
6397
6285
  const [uncontrolledExpandedIds, setUncontrolledExpandedIds] = useState20(() => getInitialExpandedIds(entries, defaultExpandedIds));
6398
- const resolvedExpandedIds = isExpandedControlled ? expandedIdsProp ?? [] : uncontrolledExpandedIds;
6286
+ const resolvedExpandedIds = expandedIdsProp ?? uncontrolledExpandedIds;
6399
6287
  const expandedIdSet = useMemo12(
6400
6288
  () => new Set(
6401
6289
  resolvedExpandedIds.filter((expandedId) => groupIds.has(expandedId))
@@ -6408,24 +6296,8 @@ function PropertyGrid({
6408
6296
  );
6409
6297
  const interactiveRows = useMemo12(() => collectInteractiveRows(rows), [rows]);
6410
6298
  const [uncontrolledActiveId, setUncontrolledActiveId] = useState20(() => getInitialActiveId2(interactiveRows, defaultActiveId));
6411
- const resolvedActiveId = isActiveControlled ? activeIdProp : uncontrolledActiveId;
6412
- useEffect13(() => {
6413
- if (interactiveRows.length === 0) {
6414
- return;
6415
- }
6416
- const hasResolvedActiveId = resolvedActiveId && interactiveRows.some((row) => row.id === resolvedActiveId);
6417
- if (hasResolvedActiveId) {
6418
- return;
6419
- }
6420
- const fallbackActiveId = interactiveRows[0]?.id;
6421
- if (!fallbackActiveId) {
6422
- return;
6423
- }
6424
- if (!isActiveControlled) {
6425
- setUncontrolledActiveId(fallbackActiveId);
6426
- }
6427
- onActiveIdChange?.(fallbackActiveId);
6428
- }, [interactiveRows, isActiveControlled, onActiveIdChange, resolvedActiveId]);
6299
+ const requestedActiveId = isActiveControlled ? activeIdProp : uncontrolledActiveId;
6300
+ const resolvedActiveId = requestedActiveId && interactiveRows.some((row) => row.id === requestedActiveId) ? requestedActiveId : interactiveRows[0]?.id;
6429
6301
  function updateExpandedIds(nextExpandedIds) {
6430
6302
  if (!isExpandedControlled) {
6431
6303
  setUncontrolledExpandedIds(nextExpandedIds);
@@ -6497,7 +6369,7 @@ function PropertyGrid({
6497
6369
  event.preventDefault();
6498
6370
  focusBoundaryRow("last");
6499
6371
  return;
6500
- case "ArrowLeft":
6372
+ case "ArrowLeft": {
6501
6373
  event.preventDefault();
6502
6374
  if (row.type === "group" && expandedIdSet.has(row.entry.id)) {
6503
6375
  toggleGroup(row.entry);
@@ -6508,7 +6380,8 @@ function PropertyGrid({
6508
6380
  focusRowButton(parentRowId);
6509
6381
  }
6510
6382
  return;
6511
- case "ArrowRight":
6383
+ }
6384
+ case "ArrowRight": {
6512
6385
  event.preventDefault();
6513
6386
  if (row.type === "group") {
6514
6387
  if (!expandedIdSet.has(row.entry.id)) {
@@ -6520,6 +6393,7 @@ function PropertyGrid({
6520
6393
  }
6521
6394
  activateItemEditor(`${editorIdPrefix}-editor-${row.entry.id}`);
6522
6395
  return;
6396
+ }
6523
6397
  case "Enter":
6524
6398
  case " ":
6525
6399
  event.preventDefault();
@@ -6909,7 +6783,7 @@ function ReportCell({
6909
6783
 
6910
6784
  // src/components/SearchBox/SearchBox.tsx
6911
6785
  import {
6912
- useEffect as useEffect14,
6786
+ useEffect as useEffect12,
6913
6787
  useId as useId12,
6914
6788
  useMemo as useMemo13,
6915
6789
  useRef as useRef15,
@@ -6917,7 +6791,7 @@ import {
6917
6791
  } from "react";
6918
6792
  import { createPortal as createPortal4 } from "react-dom";
6919
6793
  import { jsx as jsx50, jsxs as jsxs32 } from "react/jsx-runtime";
6920
- function resolveSearchBoxPortalRoot(anchor) {
6794
+ function resolveSearchBoxPortalRoot() {
6921
6795
  return document.body;
6922
6796
  }
6923
6797
  function SearchBox({
@@ -6984,12 +6858,10 @@ function SearchBox({
6984
6858
  ],
6985
6859
  [resultOptions]
6986
6860
  );
6987
- const popupRoot = typeof document === "undefined" ? null : resolveSearchBoxPortalRoot(rootRef.current);
6988
- useEffect14(() => {
6861
+ const popupRoot = typeof document === "undefined" ? null : resolveSearchBoxPortalRoot();
6862
+ const [themePortalStyle, setThemePortalStyle] = useState23(() => void 0);
6863
+ useEffect12(() => {
6989
6864
  if (disabled) {
6990
- setOpen(false);
6991
- setResults([]);
6992
- setStatus("idle");
6993
6865
  return;
6994
6866
  }
6995
6867
  if (!open) {
@@ -7020,13 +6892,11 @@ function SearchBox({
7020
6892
  popupRef,
7021
6893
  portalRoot: popupRoot
7022
6894
  });
7023
- useEffect14(() => {
6895
+ useEffect12(() => {
7024
6896
  if (disabled || !open) {
7025
6897
  return;
7026
6898
  }
7027
6899
  if (trimmedQuery.length < minQueryLength) {
7028
- setResults([]);
7029
- setStatus("idle");
7030
6900
  return;
7031
6901
  }
7032
6902
  const nextRequestId = requestIdRef.current + 1;
@@ -7057,6 +6927,10 @@ function SearchBox({
7057
6927
  }
7058
6928
  onQueryChange?.(nextQuery);
7059
6929
  }
6930
+ function openPopup() {
6931
+ setThemePortalStyle(getThemePortalStyle(rootRef.current));
6932
+ setOpen(true);
6933
+ }
7060
6934
  function handleSelectItem(option) {
7061
6935
  setResolvedQuery(getItemText(option.item));
7062
6936
  setSelectedValue(option.value);
@@ -7099,7 +6973,7 @@ function SearchBox({
7099
6973
  switch (event.key) {
7100
6974
  case "ArrowDown":
7101
6975
  event.preventDefault();
7102
- setOpen(true);
6976
+ openPopup();
7103
6977
  break;
7104
6978
  case "Enter":
7105
6979
  if (open && status === "success" && resultOptions[0]) {
@@ -7136,10 +7010,10 @@ function SearchBox({
7136
7010
  id: fieldId,
7137
7011
  onChange: (event) => {
7138
7012
  setResolvedQuery(event.target.value);
7139
- setOpen(true);
7013
+ openPopup();
7140
7014
  setSelectedValue(null);
7141
7015
  },
7142
- onFocus: () => setOpen(true),
7016
+ onFocus: openPopup,
7143
7017
  onKeyDown: handleInputKeyDown,
7144
7018
  placeholder,
7145
7019
  ref: inputRef,
@@ -7157,7 +7031,7 @@ function SearchBox({
7157
7031
  className: "nu-search-box__popup",
7158
7032
  id: `${fieldId}-popup`,
7159
7033
  ref: popupRef,
7160
- style: getThemePortalStyle(rootRef.current),
7034
+ style: themePortalStyle,
7161
7035
  children: renderPopupContent()
7162
7036
  }
7163
7037
  ),
@@ -7170,7 +7044,6 @@ function SearchBox({
7170
7044
 
7171
7045
  // src/components/SpinBox/SpinBox.tsx
7172
7046
  import {
7173
- useEffect as useEffect15,
7174
7047
  useId as useId13,
7175
7048
  useMemo as useMemo14,
7176
7049
  useState as useState24
@@ -7227,18 +7100,16 @@ function SpinBox({
7227
7100
  );
7228
7101
  const [uncontrolledValue, setUncontrolledValue] = useState24(initialNumericValue);
7229
7102
  const numericValue = isControlled ? clampSpinValue(value ?? initialNumericValue, min, max) : uncontrolledValue;
7230
- const [draftValue, setDraftValue] = useState24(
7103
+ const [uncontrolledDraftValue, setUncontrolledDraftValue] = useState24(
7231
7104
  () => formatSpinValue(initialNumericValue)
7232
7105
  );
7233
- useEffect15(() => {
7234
- setDraftValue(formatSpinValue(numericValue));
7235
- }, [numericValue]);
7106
+ const draftValue = isControlled ? formatSpinValue(numericValue) : uncontrolledDraftValue;
7236
7107
  function commitValue(nextValue) {
7237
7108
  const clampedValue = clampSpinValue(nextValue, min, max);
7238
7109
  if (!isControlled) {
7239
7110
  setUncontrolledValue(clampedValue);
7240
7111
  }
7241
- setDraftValue(formatSpinValue(clampedValue));
7112
+ setUncontrolledDraftValue(formatSpinValue(clampedValue));
7242
7113
  onValueChange?.(clampedValue);
7243
7114
  }
7244
7115
  function nudge(direction) {
@@ -7247,7 +7118,9 @@ function SpinBox({
7247
7118
  function handleChange(event) {
7248
7119
  const nextDraftValue = event.target.value;
7249
7120
  const parsedValue = parseSpinDraft(nextDraftValue);
7250
- setDraftValue(nextDraftValue);
7121
+ if (!isControlled) {
7122
+ setUncontrolledDraftValue(nextDraftValue);
7123
+ }
7251
7124
  if (parsedValue !== null) {
7252
7125
  const clampedValue = clampSpinValue(parsedValue, min, max);
7253
7126
  if (!isControlled) {
@@ -7258,7 +7131,7 @@ function SpinBox({
7258
7131
  onChange?.(event);
7259
7132
  }
7260
7133
  function handleBlur(event) {
7261
- setDraftValue(formatSpinValue(numericValue));
7134
+ setUncontrolledDraftValue(formatSpinValue(numericValue));
7262
7135
  onBlur?.(event);
7263
7136
  }
7264
7137
  function handleKeyDown(event) {
@@ -7401,7 +7274,7 @@ function SpinBox({
7401
7274
 
7402
7275
  // src/components/Splitter/Splitter.tsx
7403
7276
  import {
7404
- useEffect as useEffect16,
7277
+ useEffect as useEffect13,
7405
7278
  useId as useId14,
7406
7279
  useRef as useRef16,
7407
7280
  useState as useState25
@@ -7450,13 +7323,13 @@ function Splitter({
7450
7323
  );
7451
7324
  const firstPaneId = useId14();
7452
7325
  const secondPaneId = useId14();
7453
- useEffect16(() => {
7326
+ useEffect13(() => {
7454
7327
  if (!storageKey || typeof window === "undefined") {
7455
7328
  return;
7456
7329
  }
7457
7330
  window.localStorage.setItem(storageKey, String(activeValue));
7458
7331
  }, [activeValue, storageKey]);
7459
- useEffect16(() => {
7332
+ useEffect13(() => {
7460
7333
  return () => {
7461
7334
  if (dragFrameRef.current !== null) {
7462
7335
  window.cancelAnimationFrame(dragFrameRef.current);
@@ -7605,7 +7478,7 @@ function Splitter({
7605
7478
 
7606
7479
  // src/components/TickBar/TickBar.tsx
7607
7480
  import {
7608
- useEffect as useEffect17,
7481
+ useEffect as useEffect14,
7609
7482
  useId as useId15,
7610
7483
  useMemo as useMemo15,
7611
7484
  useRef as useRef17,
@@ -7671,7 +7544,7 @@ function TickBar({
7671
7544
  );
7672
7545
  }, [min, safeMax, safeStep, tickCount]);
7673
7546
  const renderedValue = valueRenderer ? valueRenderer(resolvedValue, min, safeMax) : String(resolvedValue);
7674
- useEffect17(() => {
7547
+ useEffect14(() => {
7675
7548
  if (!dragging) {
7676
7549
  return;
7677
7550
  }
@@ -7987,7 +7860,7 @@ function ToolSeparator({ className, ...props }) {
7987
7860
  import {
7988
7861
  forwardRef as forwardRef3,
7989
7862
  useCallback as useCallback6,
7990
- useEffect as useEffect18,
7863
+ useEffect as useEffect15,
7991
7864
  useId as useId16,
7992
7865
  useImperativeHandle as useImperativeHandle3,
7993
7866
  useMemo as useMemo16,
@@ -8356,7 +8229,7 @@ function TreeViewInner({
8356
8229
  const resolvedSelectedId = derivedSelectedId && selectableItems.some((entry) => entry.itemId === derivedSelectedId) ? derivedSelectedId : selectableItems[0]?.itemId ?? null;
8357
8230
  const [activeId, setActiveId] = useState27(resolvedSelectedId);
8358
8231
  const resolvedActiveId = activeId && selectableItems.some((entry) => entry.itemId === activeId) ? activeId : resolvedSelectedId;
8359
- useEffect18(() => {
8232
+ useEffect15(() => {
8360
8233
  if (!resolvedActiveId) {
8361
8234
  return;
8362
8235
  }
@@ -8393,15 +8266,20 @@ function TreeViewInner({
8393
8266
  },
8394
8267
  [onItemSelect, selectedId]
8395
8268
  );
8396
- function activateResolvedItem(itemId) {
8397
- if (!itemId) {
8398
- return;
8399
- }
8400
- const nextEntry = selectableItems.find((entry) => entry.itemId === itemId);
8401
- if (nextEntry) {
8402
- activateEntry(nextEntry.item, nextEntry.itemId);
8403
- }
8404
- }
8269
+ const activateResolvedItem = useCallback6(
8270
+ (itemId) => {
8271
+ if (!itemId) {
8272
+ return;
8273
+ }
8274
+ const nextEntry = selectableItems.find(
8275
+ (entry) => entry.itemId === itemId
8276
+ );
8277
+ if (nextEntry) {
8278
+ activateEntry(nextEntry.item, nextEntry.itemId);
8279
+ }
8280
+ },
8281
+ [activateEntry, selectableItems]
8282
+ );
8405
8283
  function moveActive(direction) {
8406
8284
  if (selectableItems.length === 0) {
8407
8285
  return;
@@ -8493,7 +8371,7 @@ function TreeViewInner({
8493
8371
  event.preventDefault();
8494
8372
  activateResolvedItem(resolvedActiveId);
8495
8373
  break;
8496
- case " ":
8374
+ case " ": {
8497
8375
  event.preventDefault();
8498
8376
  if (!resolvedActiveId) {
8499
8377
  return;
@@ -8509,6 +8387,7 @@ function TreeViewInner({
8509
8387
  setExpandedState(activeItem, !expandedIdSet.has(activeItem.id));
8510
8388
  }
8511
8389
  break;
8390
+ }
8512
8391
  default:
8513
8392
  break;
8514
8393
  }
@@ -8549,7 +8428,13 @@ function TreeViewInner({
8549
8428
  }
8550
8429
  }
8551
8430
  }),
8552
- [data, resolvedActiveId, resolvedExpandedIds, onItemCheckChange]
8431
+ [
8432
+ activateResolvedItem,
8433
+ data,
8434
+ onItemCheckChange,
8435
+ resolvedActiveId,
8436
+ setExpandedState
8437
+ ]
8553
8438
  );
8554
8439
  return /* @__PURE__ */ jsx56(
8555
8440
  "div",
@@ -8591,7 +8476,7 @@ var TreeView = forwardRef3(TreeViewInner);
8591
8476
  import {
8592
8477
  forwardRef as forwardRef4,
8593
8478
  useCallback as useCallback7,
8594
- useEffect as useEffect19,
8479
+ useEffect as useEffect16,
8595
8480
  useId as useId17,
8596
8481
  useImperativeHandle as useImperativeHandle4,
8597
8482
  useLayoutEffect as useLayoutEffect4,
@@ -8987,18 +8872,6 @@ var TreeListViewRow = memo5(
8987
8872
 
8988
8873
  // src/components/TreeListView/TreeListView.tsx
8989
8874
  import { jsx as jsx58, jsxs as jsxs38 } from "react/jsx-runtime";
8990
- function areTreeListColumnsEqual(previousColumns, nextColumns) {
8991
- if (previousColumns === nextColumns) {
8992
- return true;
8993
- }
8994
- if (previousColumns.length !== nextColumns.length) {
8995
- return false;
8996
- }
8997
- return previousColumns.every((previousColumn, index) => {
8998
- const nextColumn = nextColumns[index];
8999
- return previousColumn.align === nextColumn.align && previousColumn.className === nextColumn.className && previousColumn.field === nextColumn.field && previousColumn.headerAlign === nextColumn.headerAlign && previousColumn.id === nextColumn.id && previousColumn.minWidth === nextColumn.minWidth && previousColumn.renderCell === nextColumn.renderCell && previousColumn.resizable === nextColumn.resizable && previousColumn.title === nextColumn.title && previousColumn.tree === nextColumn.tree && previousColumn.width === nextColumn.width;
9000
- });
9001
- }
9002
8875
  function TreeListViewInner({
9003
8876
  activeItemId: activeItemIdProp,
9004
8877
  checkedIds,
@@ -9023,17 +8896,8 @@ function TreeListViewInner({
9023
8896
  const rootRef = useRef19(null);
9024
8897
  const treeId = useId17();
9025
8898
  const itemRefs = useRef19({});
9026
- const columnsRef = useRef19(columns);
9027
- const getCellContentRef = useRef19(getCellContent);
9028
- const onItemDoubleClickRef = useRef19(onItemDoubleClick);
9029
8899
  const resizeFrameRef = useRef19(null);
9030
8900
  const resizeStateRef = useRef19(null);
9031
- if (!areTreeListColumnsEqual(columnsRef.current, columns)) {
9032
- columnsRef.current = columns;
9033
- }
9034
- getCellContentRef.current = getCellContent;
9035
- onItemDoubleClickRef.current = onItemDoubleClick;
9036
- const resolvedColumns = columnsRef.current;
9037
8901
  const isExpandedControlled = expandedIds !== void 0;
9038
8902
  const [uncontrolledExpandedIds, setUncontrolledExpandedIds] = useState28(() => {
9039
8903
  const expandedFromData = collectExpandedTreeListIds(data);
@@ -9066,30 +8930,30 @@ function TreeListViewInner({
9066
8930
  const resolvedActiveItemId = activeItemId && selectableItems.some((entry) => entry.itemId === activeItemId) ? activeItemId : resolvedSelectedId;
9067
8931
  const minColumnWidthById = useMemo17(
9068
8932
  () => Object.fromEntries(
9069
- resolvedColumns.map(
8933
+ columns.map(
9070
8934
  (column) => [column.id, column.minWidth ?? 0]
9071
8935
  )
9072
8936
  ),
9073
- [resolvedColumns]
8937
+ [columns]
9074
8938
  );
9075
8939
  const templateColumns = useMemo17(
9076
- () => getTreeListTemplateColumns(resolvedColumns, {
8940
+ () => getTreeListTemplateColumns(columns, {
9077
8941
  autoColumnWidths,
9078
8942
  userColumnWidths
9079
8943
  }),
9080
- [autoColumnWidths, resolvedColumns, userColumnWidths]
8944
+ [autoColumnWidths, columns, userColumnWidths]
9081
8945
  );
9082
8946
  const treeColumnId = useMemo17(
9083
- () => getTreeListTreeColumnId(resolvedColumns),
9084
- [resolvedColumns]
8947
+ () => getTreeListTreeColumnId(columns),
8948
+ [columns]
9085
8949
  );
9086
8950
  const rowIndexMap = useMemo17(
9087
8951
  () => new Map(
9088
8952
  visibleItems.map((entry, index) => [entry.itemId, index])
9089
8953
  ),
9090
- [visibleItems, dataVersion]
8954
+ [visibleItems]
9091
8955
  );
9092
- useEffect19(() => {
8956
+ useEffect16(() => {
9093
8957
  if (!resolvedActiveItemId) {
9094
8958
  return;
9095
8959
  }
@@ -9104,12 +8968,13 @@ function TreeListViewInner({
9104
8968
  []
9105
8969
  );
9106
8970
  const resolveCellContent = useCallback7(
9107
- (...args) => getCellContentRef.current?.(...args),
9108
- []
8971
+ (...args) => getCellContent?.(...args),
8972
+ [getCellContent]
8973
+ );
8974
+ const handleItemDoubleClick = useCallback7(
8975
+ (item) => onItemDoubleClick?.(item),
8976
+ [onItemDoubleClick]
9109
8977
  );
9110
- const handleItemDoubleClick = useCallback7((item) => {
9111
- onItemDoubleClickRef.current?.(item);
9112
- }, []);
9113
8978
  useLayoutEffect4(() => {
9114
8979
  const rootNode = rootRef.current;
9115
8980
  if (!rootNode) {
@@ -9118,7 +8983,7 @@ function TreeListViewInner({
9118
8983
  setAutoColumnWidths((currentWidths) => {
9119
8984
  let didChange = false;
9120
8985
  const nextWidths = { ...currentWidths };
9121
- resolvedColumns.forEach((column) => {
8986
+ columns.forEach((column) => {
9122
8987
  if (currentWidths[column.id] !== void 0 || userColumnWidths[column.id] !== void 0 || column.width !== void 0) {
9123
8988
  return;
9124
8989
  }
@@ -9141,8 +9006,8 @@ function TreeListViewInner({
9141
9006
  });
9142
9007
  return didChange ? nextWidths : currentWidths;
9143
9008
  });
9144
- }, [resolvedColumns, userColumnWidths, visibleItems]);
9145
- useEffect19(() => {
9009
+ }, [columns, userColumnWidths, visibleItems]);
9010
+ useEffect16(() => {
9146
9011
  return () => {
9147
9012
  if (resizeFrameRef.current !== null) {
9148
9013
  window.cancelAnimationFrame(resizeFrameRef.current);
@@ -9265,13 +9130,17 @@ function TreeListViewInner({
9265
9130
  function isItemChecked(item) {
9266
9131
  return checkedIds ? checkedIds.includes(item.id) : item.checked === true;
9267
9132
  }
9268
- function toggleItemCheck(itemId) {
9269
- const item = findTreeListItemById(data, itemId);
9270
- if (!item || item.disabled || item.checked === void 0 && checkedIds === void 0) {
9271
- return;
9272
- }
9273
- onItemCheckChange?.(item, !isItemChecked(item));
9274
- }
9133
+ const toggleItemCheck = useCallback7(
9134
+ (itemId) => {
9135
+ const item = findTreeListItemById(data, itemId);
9136
+ if (!item || item.disabled || item.checked === void 0 && checkedIds === void 0) {
9137
+ return;
9138
+ }
9139
+ const checked = checkedIds ? checkedIds.includes(item.id) : item.checked;
9140
+ onItemCheckChange?.(item, !checked);
9141
+ },
9142
+ [checkedIds, data, onItemCheckChange]
9143
+ );
9275
9144
  useImperativeHandle4(
9276
9145
  ref,
9277
9146
  () => ({
@@ -9305,7 +9174,13 @@ function TreeListViewInner({
9305
9174
  toggleItemCheck(itemId);
9306
9175
  }
9307
9176
  }),
9308
- [checkedIds, data, resolvedActiveItemId, resolvedExpandedIds]
9177
+ [
9178
+ activateResolvedItem,
9179
+ data,
9180
+ resolvedActiveItemId,
9181
+ setExpandedState,
9182
+ toggleItemCheck
9183
+ ]
9309
9184
  );
9310
9185
  function handleKeyDown(event) {
9311
9186
  switch (event.key) {
@@ -9337,7 +9212,7 @@ function TreeListViewInner({
9337
9212
  event.preventDefault();
9338
9213
  activateResolvedItem(resolvedActiveItemId);
9339
9214
  break;
9340
- case " ":
9215
+ case " ": {
9341
9216
  event.preventDefault();
9342
9217
  if (!resolvedActiveItemId) {
9343
9218
  return;
@@ -9353,6 +9228,7 @@ function TreeListViewInner({
9353
9228
  setExpandedState(activeItem, !expandedIdSet.has(activeItem.id));
9354
9229
  }
9355
9230
  break;
9231
+ }
9356
9232
  default:
9357
9233
  break;
9358
9234
  }
@@ -9418,6 +9294,7 @@ function TreeListViewInner({
9418
9294
  ...props,
9419
9295
  "aria-activedescendant": resolvedActiveItemId ? `${treeId}-${resolvedActiveItemId}` : void 0,
9420
9296
  className: ["nu-tree-list-view", className].filter(Boolean).join(" "),
9297
+ "data-version": dataVersion,
9421
9298
  onKeyDown: handleKeyDown,
9422
9299
  ref: rootRef,
9423
9300
  role: "treegrid",
@@ -9431,7 +9308,7 @@ function TreeListViewInner({
9431
9308
  style: {
9432
9309
  "--nu-tree-list-view-columns": templateColumns
9433
9310
  },
9434
- children: resolvedColumns.map((column, columnIndex) => /* @__PURE__ */ jsxs38(
9311
+ children: columns.map((column, columnIndex) => /* @__PURE__ */ jsxs38(
9435
9312
  "span",
9436
9313
  {
9437
9314
  className: [
@@ -9464,7 +9341,7 @@ function TreeListViewInner({
9464
9341
  {
9465
9342
  activeItemId: resolvedActiveItemId,
9466
9343
  checkedIds,
9467
- columns: resolvedColumns,
9344
+ columns,
9468
9345
  depth: 0,
9469
9346
  expandedIdSet,
9470
9347
  getCellContent: getCellContent ? resolveCellContent : void 0,