@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.cjs CHANGED
@@ -1186,15 +1186,20 @@ function ListBoxInner({
1186
1186
  },
1187
1187
  [onItemSelect]
1188
1188
  );
1189
- function activateResolvedItem(itemId) {
1190
- if (!itemId) {
1191
- return;
1192
- }
1193
- const nextEntry = selectableItems.find((entry) => entry.itemId === itemId);
1194
- if (nextEntry) {
1195
- activateItem(nextEntry.item, nextEntry.group, nextEntry.itemId);
1196
- }
1197
- }
1189
+ const activateResolvedItem = (0, import_react5.useCallback)(
1190
+ (itemId) => {
1191
+ if (!itemId) {
1192
+ return;
1193
+ }
1194
+ const nextEntry = selectableItems.find(
1195
+ (entry) => entry.itemId === itemId
1196
+ );
1197
+ if (nextEntry) {
1198
+ activateItem(nextEntry.item, nextEntry.group, nextEntry.itemId);
1199
+ }
1200
+ },
1201
+ [activateItem, selectableItems]
1202
+ );
1198
1203
  function moveActive(direction) {
1199
1204
  if (selectableItems.length === 0) {
1200
1205
  return;
@@ -1260,7 +1265,7 @@ function ListBoxInner({
1260
1265
  toggleItemCheck(itemId);
1261
1266
  }
1262
1267
  }),
1263
- [resolvedActiveId, checkedIds, data]
1268
+ [activateResolvedItem, resolvedActiveId, toggleItemCheck]
1264
1269
  );
1265
1270
  function handleKeyDown(event) {
1266
1271
  switch (event.key) {
@@ -1422,17 +1427,14 @@ function MdiWindowPickerDialog({
1422
1427
  const [selectedId, setSelectedId] = (0, import_react6.useState)(
1423
1428
  activeWindowId ?? resolvedWindows[0]?.id ?? ""
1424
1429
  );
1425
- (0, import_react6.useEffect)(() => {
1426
- if (selectedId && resolvedWindows.some((windowEntry) => windowEntry.id === selectedId)) {
1427
- return;
1428
- }
1429
- setSelectedId(activeWindowId ?? resolvedWindows[0]?.id ?? "");
1430
- }, [activeWindowId, resolvedWindows, selectedId]);
1430
+ const resolvedSelectedId = resolvedWindows.some(
1431
+ (windowEntry) => windowEntry.id === selectedId
1432
+ ) ? selectedId : activeWindowId ?? resolvedWindows[0]?.id ?? "";
1431
1433
  function handleActivate() {
1432
- if (!selectedId) {
1434
+ if (!resolvedSelectedId) {
1433
1435
  return;
1434
1436
  }
1435
- onActivateWindow(selectedId);
1437
+ onActivateWindow(resolvedSelectedId);
1436
1438
  onClose();
1437
1439
  }
1438
1440
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Stack, { gap: "md", children: [
@@ -1463,7 +1465,7 @@ function MdiWindowPickerDialog({
1463
1465
  onActivateWindow(item.id);
1464
1466
  onClose();
1465
1467
  },
1466
- selectedId,
1468
+ selectedId: resolvedSelectedId,
1467
1469
  style: {
1468
1470
  maxHeight: "14rem",
1469
1471
  minHeight: "12rem"
@@ -2278,6 +2280,12 @@ function AppBarItem(props) {
2278
2280
  interactive: _interactive2,
2279
2281
  ...buttonProps
2280
2282
  } = props;
2283
+ void _active2;
2284
+ void _alignment2;
2285
+ void _children2;
2286
+ void _className2;
2287
+ void _grow2;
2288
+ void _interactive2;
2281
2289
  return (0, import_react13.createElement)(
2282
2290
  "button",
2283
2291
  {
@@ -2297,6 +2305,12 @@ function AppBarItem(props) {
2297
2305
  interactive: _interactive,
2298
2306
  ...staticProps
2299
2307
  } = props;
2308
+ void _active;
2309
+ void _alignment;
2310
+ void _children;
2311
+ void _className;
2312
+ void _grow;
2313
+ void _interactive;
2300
2314
  return (0, import_react13.createElement)(
2301
2315
  "div",
2302
2316
  {
@@ -2878,31 +2892,6 @@ function findTopmostAppModalIndex(windows) {
2878
2892
  }
2879
2893
  return -1;
2880
2894
  }
2881
- function getIdHandler(cache, id, fn) {
2882
- let handler = cache.get(id);
2883
- if (!handler) {
2884
- handler = (...args) => fn(id, ...args);
2885
- cache.set(id, handler);
2886
- }
2887
- return handler;
2888
- }
2889
- function getWindowControls(cache, id, bringToFront, close, toggleMaximized, toggleMinimized, update) {
2890
- let controls = cache.get(id);
2891
- if (!controls) {
2892
- controls = { bringToFront, close, id, toggleMaximized, toggleMinimized, update };
2893
- cache.set(id, controls);
2894
- }
2895
- return controls;
2896
- }
2897
- function getWindowContent(cache, id, source, controls) {
2898
- const cached = cache.get(id);
2899
- if (cached && cached.source === source) {
2900
- return cached.element;
2901
- }
2902
- const element = typeof source === "function" ? source(controls) : source;
2903
- cache.set(id, { source, element });
2904
- return element;
2905
- }
2906
2895
  function getActivationChain(windows, id) {
2907
2896
  const targetWindow = windows.find((windowEntry) => windowEntry.id === id);
2908
2897
  if (!targetWindow) {
@@ -2928,28 +2917,6 @@ function NuWindowProvider({
2928
2917
  const creationOrderRef = (0, import_react17.useRef)(0);
2929
2918
  const idRef = (0, import_react17.useRef)(0);
2930
2919
  const windowBoundsByIdRef = (0, import_react17.useRef)({});
2931
- const boundsChangeHandlersRef = (0, import_react17.useRef)(
2932
- /* @__PURE__ */ new Map()
2933
- );
2934
- const windowStyleCacheRef = (0, import_react17.useRef)(
2935
- /* @__PURE__ */ new Map()
2936
- );
2937
- const closeHandlersRef = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2938
- const activateHandlersRef = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2939
- const bringToFrontHandlersRef = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2940
- const toggleMaximizedHandlersRef = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2941
- const toggleMinimizedHandlersRef = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2942
- const positionHandlersRef = (0, import_react17.useRef)(
2943
- /* @__PURE__ */ new Map()
2944
- );
2945
- const sizeHandlersRef = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2946
- const updateHandlersRef = (0, import_react17.useRef)(
2947
- /* @__PURE__ */ new Map()
2948
- );
2949
- const controlsCacheRef = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
2950
- const contentCacheRef = (0, import_react17.useRef)(
2951
- /* @__PURE__ */ new Map()
2952
- );
2953
2920
  const [windows, setWindows] = (0, import_react17.useState)([]);
2954
2921
  const [windowBoundsById, setWindowBoundsById] = (0, import_react17.useState)({});
2955
2922
  const appHostMenuContext = (0, import_react17.useContext)(AppHostMenuContext);
@@ -3002,53 +2969,6 @@ function NuWindowProvider({
3002
2969
  },
3003
2970
  []
3004
2971
  );
3005
- const getBoundsChangeHandler = (0, import_react17.useCallback)(
3006
- (id) => {
3007
- let handler = boundsChangeHandlersRef.current.get(id);
3008
- if (!handler) {
3009
- handler = (bounds) => updateWindowBounds(id, bounds);
3010
- boundsChangeHandlersRef.current.set(id, handler);
3011
- }
3012
- return handler;
3013
- },
3014
- [updateWindowBounds]
3015
- );
3016
- const getWindowStyle = (0, import_react17.useCallback)(
3017
- (id, source, zIndex) => {
3018
- const cached = windowStyleCacheRef.current.get(id);
3019
- if (cached && cached.source === source && cached.zIndex === zIndex) {
3020
- return cached.merged;
3021
- }
3022
- const merged = { ...source, zIndex };
3023
- windowStyleCacheRef.current.set(id, { source, zIndex, merged });
3024
- return merged;
3025
- },
3026
- []
3027
- );
3028
- (0, import_react17.useEffect)(() => {
3029
- const liveIds = new Set(windows.map((windowEntry) => windowEntry.id));
3030
- const idKeyedCaches = [
3031
- boundsChangeHandlersRef.current,
3032
- windowStyleCacheRef.current,
3033
- closeHandlersRef.current,
3034
- activateHandlersRef.current,
3035
- bringToFrontHandlersRef.current,
3036
- toggleMaximizedHandlersRef.current,
3037
- toggleMinimizedHandlersRef.current,
3038
- positionHandlersRef.current,
3039
- sizeHandlersRef.current,
3040
- updateHandlersRef.current,
3041
- controlsCacheRef.current,
3042
- contentCacheRef.current
3043
- ];
3044
- for (const cache of idKeyedCaches) {
3045
- for (const id of cache.keys()) {
3046
- if (!liveIds.has(id)) {
3047
- cache.delete(id);
3048
- }
3049
- }
3050
- }
3051
- }, [windows]);
3052
2972
  const bringToFront = (0, import_react17.useCallback)((id) => {
3053
2973
  setWindows((currentWindows) => {
3054
2974
  const activationChain = getActivationChain(currentWindows, id);
@@ -3421,61 +3341,23 @@ function NuWindowProvider({
3421
3341
  width: ownerBounds.width,
3422
3342
  zIndex: stackIndex + 1
3423
3343
  } : null;
3424
- const handleClose = getIdHandler(
3425
- closeHandlersRef.current,
3426
- windowEntry.id,
3427
- closeWindow
3428
- );
3429
- const handleActivate = getIdHandler(
3430
- activateHandlersRef.current,
3431
- windowEntry.id,
3432
- activateWindow
3433
- );
3434
- const handleBringToFront = getIdHandler(
3435
- bringToFrontHandlersRef.current,
3436
- windowEntry.id,
3437
- bringToFront
3438
- );
3439
- const handleToggleMaximized = getIdHandler(
3440
- toggleMaximizedHandlersRef.current,
3441
- windowEntry.id,
3442
- toggleWindowMaximized
3443
- );
3444
- const handleToggleMinimized = getIdHandler(
3445
- toggleMinimizedHandlersRef.current,
3446
- windowEntry.id,
3447
- toggleWindowMinimized
3448
- );
3449
- const handlePositionChange = getIdHandler(
3450
- positionHandlersRef.current,
3451
- windowEntry.id,
3452
- updateWindowPosition
3453
- );
3454
- const handleSizeChange = getIdHandler(
3455
- sizeHandlersRef.current,
3456
- windowEntry.id,
3457
- handleWindowSizeChange
3458
- );
3459
- const handleUpdate = getIdHandler(
3460
- updateHandlersRef.current,
3461
- windowEntry.id,
3462
- updateWindow
3463
- );
3464
- const controls = getWindowControls(
3465
- controlsCacheRef.current,
3466
- windowEntry.id,
3467
- handleBringToFront,
3468
- handleClose,
3469
- handleToggleMaximized,
3470
- handleToggleMinimized,
3471
- handleUpdate
3472
- );
3473
- const content = getWindowContent(
3474
- contentCacheRef.current,
3475
- windowEntry.id,
3476
- windowEntry.content,
3477
- controls
3478
- );
3344
+ const handleClose = () => closeWindow(windowEntry.id);
3345
+ const handleActivate = () => activateWindow(windowEntry.id);
3346
+ const handleBringToFront = () => bringToFront(windowEntry.id);
3347
+ const handleToggleMaximized = () => toggleWindowMaximized(windowEntry.id);
3348
+ const handleToggleMinimized = () => toggleWindowMinimized(windowEntry.id);
3349
+ const handlePositionChange = (position) => updateWindowPosition(windowEntry.id, position);
3350
+ const handleSizeChange = (size) => handleWindowSizeChange(windowEntry.id, size);
3351
+ const handleUpdate = (patch) => updateWindow(windowEntry.id, patch);
3352
+ const controls = {
3353
+ bringToFront: handleBringToFront,
3354
+ close: handleClose,
3355
+ id: windowEntry.id,
3356
+ toggleMaximized: handleToggleMaximized,
3357
+ toggleMinimized: handleToggleMinimized,
3358
+ update: handleUpdate
3359
+ };
3360
+ const content = typeof windowEntry.content === "function" ? windowEntry.content(controls) : windowEntry.content;
3479
3361
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_react17.Fragment, { children: [
3480
3362
  isTopmostAppModal ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3481
3363
  "div",
@@ -3505,7 +3387,7 @@ function NuWindowProvider({
3505
3387
  minimized: windowEntry.minimized,
3506
3388
  mode: windowEntry.mode,
3507
3389
  onActivate: handleActivate,
3508
- onBoundsChange: getBoundsChangeHandler(windowEntry.id),
3390
+ onBoundsChange: (bounds) => updateWindowBounds(windowEntry.id, bounds),
3509
3391
  onClose: handleClose,
3510
3392
  onPositionChange: handlePositionChange,
3511
3393
  onSizeChange: handleSizeChange,
@@ -3513,11 +3395,10 @@ function NuWindowProvider({
3513
3395
  onToggleMinimized: handleToggleMinimized,
3514
3396
  resizable: windowEntry.resizable,
3515
3397
  statusBar: windowEntry.statusBar,
3516
- style: getWindowStyle(
3517
- windowEntry.id,
3518
- windowEntry.style,
3519
- isTopmostAppModal && topmostAppModalIndex >= 0 ? visibleWindows.length + 2 : ownerBackdropStyle ? ownerBackdropStyle.zIndex + 1 : (stackIndex ?? 0) + 1
3520
- ),
3398
+ style: {
3399
+ ...windowEntry.style,
3400
+ zIndex: isTopmostAppModal && topmostAppModalIndex >= 0 ? visibleWindows.length + 2 : ownerBackdropStyle ? ownerBackdropStyle.zIndex + 1 : (stackIndex ?? 0) + 1
3401
+ },
3521
3402
  title: windowEntry.title,
3522
3403
  children: content
3523
3404
  }
@@ -3810,6 +3691,7 @@ function ControlOpener(props) {
3810
3691
  const { children, className, glyphClassName, glyphStyle, style } = props;
3811
3692
  if (props.as === "button") {
3812
3693
  const { as: _as2, type = "button", ...buttonProps } = props;
3694
+ void _as2;
3813
3695
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3814
3696
  "button",
3815
3697
  {
@@ -3829,6 +3711,7 @@ function ControlOpener(props) {
3829
3711
  );
3830
3712
  }
3831
3713
  const { ariaHidden = false, as: _as, ...spanProps } = props;
3714
+ void _as;
3832
3715
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3833
3716
  "span",
3834
3717
  {
@@ -4483,7 +4366,7 @@ function findComboBoxOption(options, value) {
4483
4366
  }
4484
4367
  return options.find((option) => option.value === value) ?? null;
4485
4368
  }
4486
- function resolveComboBoxPortalRoot(anchor) {
4369
+ function resolveComboBoxPortalRoot() {
4487
4370
  return document.body;
4488
4371
  }
4489
4372
  function ComboBox({
@@ -4545,7 +4428,8 @@ function ComboBox({
4545
4428
  ),
4546
4429
  [filteredData]
4547
4430
  );
4548
- const popupRoot = typeof document === "undefined" ? null : resolveComboBoxPortalRoot(rootRef.current);
4431
+ const popupRoot = typeof document === "undefined" ? null : resolveComboBoxPortalRoot();
4432
+ const [themePortalStyle, setThemePortalStyle] = (0, import_react22.useState)(() => void 0);
4549
4433
  (0, import_react22.useEffect)(() => {
4550
4434
  if (!open) {
4551
4435
  return;
@@ -4595,7 +4479,10 @@ function ComboBox({
4595
4479
  if (disabled) {
4596
4480
  return;
4597
4481
  }
4598
- setOpen((currentOpen) => !currentOpen);
4482
+ if (!open) {
4483
+ setThemePortalStyle(getThemePortalStyle(rootRef.current));
4484
+ }
4485
+ setOpen(!open);
4599
4486
  inputRef.current?.focus();
4600
4487
  }
4601
4488
  function handleInputKeyDown(event) {
@@ -4605,6 +4492,7 @@ function ComboBox({
4605
4492
  switch (event.key) {
4606
4493
  case "ArrowDown":
4607
4494
  event.preventDefault();
4495
+ setThemePortalStyle(getThemePortalStyle(rootRef.current));
4608
4496
  setOpen(true);
4609
4497
  break;
4610
4498
  case "Enter":
@@ -4680,6 +4568,7 @@ function ComboBox({
4680
4568
  id: fieldId,
4681
4569
  onChange: (event) => {
4682
4570
  setResolvedInputValue(event.target.value);
4571
+ setThemePortalStyle(getThemePortalStyle(rootRef.current));
4683
4572
  setOpen(true);
4684
4573
  },
4685
4574
  onKeyDown: handleInputKeyDown,
@@ -4739,7 +4628,7 @@ function ComboBox({
4739
4628
  id: `${fieldId}-popup`,
4740
4629
  ref: popupRef,
4741
4630
  style: mergeSlotStyle(
4742
- getThemePortalStyle(rootRef.current),
4631
+ themePortalStyle,
4743
4632
  slotStyles?.popup
4744
4633
  ),
4745
4634
  children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
@@ -4805,7 +4694,7 @@ function resolveAnchorPosition(anchor) {
4805
4694
  top: rect.bottom - 1
4806
4695
  };
4807
4696
  }
4808
- function resolvePortalRoot(anchor) {
4697
+ function resolvePortalRoot() {
4809
4698
  if (typeof document === "undefined") {
4810
4699
  return null;
4811
4700
  }
@@ -4828,7 +4717,7 @@ function PopupMenu({
4828
4717
  const [uncontrolledOpen, setUncontrolledOpen] = (0, import_react23.useState)(defaultOpen);
4829
4718
  const isControlled = open !== void 0;
4830
4719
  const resolvedOpen = isControlled ? open : uncontrolledOpen;
4831
- const portalRoot = resolvePortalRoot(anchor);
4720
+ const portalRoot = resolvePortalRoot();
4832
4721
  const setResolvedOpen = (0, import_react23.useCallback)(
4833
4722
  (nextOpen) => {
4834
4723
  if (!nextOpen) {
@@ -5609,7 +5498,7 @@ function ListViewInner({
5609
5498
  toggleRowCheck(rowId);
5610
5499
  }
5611
5500
  }),
5612
- [resolvedActiveRowId, showCheckBox, checkedIds, data]
5501
+ [activateRowId, resolvedActiveRowId, toggleRowCheck]
5613
5502
  );
5614
5503
  function handleKeyDown(event) {
5615
5504
  switch (event.key) {
@@ -6403,7 +6292,7 @@ function PropertyGrid({
6403
6292
  const isExpandedControlled = expandedIdsProp !== void 0;
6404
6293
  const isActiveControlled = activeIdProp !== void 0;
6405
6294
  const [uncontrolledExpandedIds, setUncontrolledExpandedIds] = (0, import_react32.useState)(() => getInitialExpandedIds(entries, defaultExpandedIds));
6406
- const resolvedExpandedIds = isExpandedControlled ? expandedIdsProp ?? [] : uncontrolledExpandedIds;
6295
+ const resolvedExpandedIds = expandedIdsProp ?? uncontrolledExpandedIds;
6407
6296
  const expandedIdSet = (0, import_react32.useMemo)(
6408
6297
  () => new Set(
6409
6298
  resolvedExpandedIds.filter((expandedId) => groupIds.has(expandedId))
@@ -6416,24 +6305,8 @@ function PropertyGrid({
6416
6305
  );
6417
6306
  const interactiveRows = (0, import_react32.useMemo)(() => collectInteractiveRows(rows), [rows]);
6418
6307
  const [uncontrolledActiveId, setUncontrolledActiveId] = (0, import_react32.useState)(() => getInitialActiveId2(interactiveRows, defaultActiveId));
6419
- const resolvedActiveId = isActiveControlled ? activeIdProp : uncontrolledActiveId;
6420
- (0, import_react32.useEffect)(() => {
6421
- if (interactiveRows.length === 0) {
6422
- return;
6423
- }
6424
- const hasResolvedActiveId = resolvedActiveId && interactiveRows.some((row) => row.id === resolvedActiveId);
6425
- if (hasResolvedActiveId) {
6426
- return;
6427
- }
6428
- const fallbackActiveId = interactiveRows[0]?.id;
6429
- if (!fallbackActiveId) {
6430
- return;
6431
- }
6432
- if (!isActiveControlled) {
6433
- setUncontrolledActiveId(fallbackActiveId);
6434
- }
6435
- onActiveIdChange?.(fallbackActiveId);
6436
- }, [interactiveRows, isActiveControlled, onActiveIdChange, resolvedActiveId]);
6308
+ const requestedActiveId = isActiveControlled ? activeIdProp : uncontrolledActiveId;
6309
+ const resolvedActiveId = requestedActiveId && interactiveRows.some((row) => row.id === requestedActiveId) ? requestedActiveId : interactiveRows[0]?.id;
6437
6310
  function updateExpandedIds(nextExpandedIds) {
6438
6311
  if (!isExpandedControlled) {
6439
6312
  setUncontrolledExpandedIds(nextExpandedIds);
@@ -6505,7 +6378,7 @@ function PropertyGrid({
6505
6378
  event.preventDefault();
6506
6379
  focusBoundaryRow("last");
6507
6380
  return;
6508
- case "ArrowLeft":
6381
+ case "ArrowLeft": {
6509
6382
  event.preventDefault();
6510
6383
  if (row.type === "group" && expandedIdSet.has(row.entry.id)) {
6511
6384
  toggleGroup(row.entry);
@@ -6516,7 +6389,8 @@ function PropertyGrid({
6516
6389
  focusRowButton(parentRowId);
6517
6390
  }
6518
6391
  return;
6519
- case "ArrowRight":
6392
+ }
6393
+ case "ArrowRight": {
6520
6394
  event.preventDefault();
6521
6395
  if (row.type === "group") {
6522
6396
  if (!expandedIdSet.has(row.entry.id)) {
@@ -6528,6 +6402,7 @@ function PropertyGrid({
6528
6402
  }
6529
6403
  activateItemEditor(`${editorIdPrefix}-editor-${row.entry.id}`);
6530
6404
  return;
6405
+ }
6531
6406
  case "Enter":
6532
6407
  case " ":
6533
6408
  event.preventDefault();
@@ -6919,7 +6794,7 @@ function ReportCell({
6919
6794
  var import_react35 = require("react");
6920
6795
  var import_react_dom4 = require("react-dom");
6921
6796
  var import_jsx_runtime50 = require("react/jsx-runtime");
6922
- function resolveSearchBoxPortalRoot(anchor) {
6797
+ function resolveSearchBoxPortalRoot() {
6923
6798
  return document.body;
6924
6799
  }
6925
6800
  function SearchBox({
@@ -6986,12 +6861,10 @@ function SearchBox({
6986
6861
  ],
6987
6862
  [resultOptions]
6988
6863
  );
6989
- const popupRoot = typeof document === "undefined" ? null : resolveSearchBoxPortalRoot(rootRef.current);
6864
+ const popupRoot = typeof document === "undefined" ? null : resolveSearchBoxPortalRoot();
6865
+ const [themePortalStyle, setThemePortalStyle] = (0, import_react35.useState)(() => void 0);
6990
6866
  (0, import_react35.useEffect)(() => {
6991
6867
  if (disabled) {
6992
- setOpen(false);
6993
- setResults([]);
6994
- setStatus("idle");
6995
6868
  return;
6996
6869
  }
6997
6870
  if (!open) {
@@ -7027,8 +6900,6 @@ function SearchBox({
7027
6900
  return;
7028
6901
  }
7029
6902
  if (trimmedQuery.length < minQueryLength) {
7030
- setResults([]);
7031
- setStatus("idle");
7032
6903
  return;
7033
6904
  }
7034
6905
  const nextRequestId = requestIdRef.current + 1;
@@ -7059,6 +6930,10 @@ function SearchBox({
7059
6930
  }
7060
6931
  onQueryChange?.(nextQuery);
7061
6932
  }
6933
+ function openPopup() {
6934
+ setThemePortalStyle(getThemePortalStyle(rootRef.current));
6935
+ setOpen(true);
6936
+ }
7062
6937
  function handleSelectItem(option) {
7063
6938
  setResolvedQuery(getItemText(option.item));
7064
6939
  setSelectedValue(option.value);
@@ -7101,7 +6976,7 @@ function SearchBox({
7101
6976
  switch (event.key) {
7102
6977
  case "ArrowDown":
7103
6978
  event.preventDefault();
7104
- setOpen(true);
6979
+ openPopup();
7105
6980
  break;
7106
6981
  case "Enter":
7107
6982
  if (open && status === "success" && resultOptions[0]) {
@@ -7138,10 +7013,10 @@ function SearchBox({
7138
7013
  id: fieldId,
7139
7014
  onChange: (event) => {
7140
7015
  setResolvedQuery(event.target.value);
7141
- setOpen(true);
7016
+ openPopup();
7142
7017
  setSelectedValue(null);
7143
7018
  },
7144
- onFocus: () => setOpen(true),
7019
+ onFocus: openPopup,
7145
7020
  onKeyDown: handleInputKeyDown,
7146
7021
  placeholder,
7147
7022
  ref: inputRef,
@@ -7159,7 +7034,7 @@ function SearchBox({
7159
7034
  className: "nu-search-box__popup",
7160
7035
  id: `${fieldId}-popup`,
7161
7036
  ref: popupRef,
7162
- style: getThemePortalStyle(rootRef.current),
7037
+ style: themePortalStyle,
7163
7038
  children: renderPopupContent()
7164
7039
  }
7165
7040
  ),
@@ -7224,18 +7099,16 @@ function SpinBox({
7224
7099
  );
7225
7100
  const [uncontrolledValue, setUncontrolledValue] = (0, import_react36.useState)(initialNumericValue);
7226
7101
  const numericValue = isControlled ? clampSpinValue(value ?? initialNumericValue, min, max) : uncontrolledValue;
7227
- const [draftValue, setDraftValue] = (0, import_react36.useState)(
7102
+ const [uncontrolledDraftValue, setUncontrolledDraftValue] = (0, import_react36.useState)(
7228
7103
  () => formatSpinValue(initialNumericValue)
7229
7104
  );
7230
- (0, import_react36.useEffect)(() => {
7231
- setDraftValue(formatSpinValue(numericValue));
7232
- }, [numericValue]);
7105
+ const draftValue = isControlled ? formatSpinValue(numericValue) : uncontrolledDraftValue;
7233
7106
  function commitValue(nextValue) {
7234
7107
  const clampedValue = clampSpinValue(nextValue, min, max);
7235
7108
  if (!isControlled) {
7236
7109
  setUncontrolledValue(clampedValue);
7237
7110
  }
7238
- setDraftValue(formatSpinValue(clampedValue));
7111
+ setUncontrolledDraftValue(formatSpinValue(clampedValue));
7239
7112
  onValueChange?.(clampedValue);
7240
7113
  }
7241
7114
  function nudge(direction) {
@@ -7244,7 +7117,9 @@ function SpinBox({
7244
7117
  function handleChange(event) {
7245
7118
  const nextDraftValue = event.target.value;
7246
7119
  const parsedValue = parseSpinDraft(nextDraftValue);
7247
- setDraftValue(nextDraftValue);
7120
+ if (!isControlled) {
7121
+ setUncontrolledDraftValue(nextDraftValue);
7122
+ }
7248
7123
  if (parsedValue !== null) {
7249
7124
  const clampedValue = clampSpinValue(parsedValue, min, max);
7250
7125
  if (!isControlled) {
@@ -7255,7 +7130,7 @@ function SpinBox({
7255
7130
  onChange?.(event);
7256
7131
  }
7257
7132
  function handleBlur(event) {
7258
- setDraftValue(formatSpinValue(numericValue));
7133
+ setUncontrolledDraftValue(formatSpinValue(numericValue));
7259
7134
  onBlur?.(event);
7260
7135
  }
7261
7136
  function handleKeyDown(event) {
@@ -8370,15 +8245,20 @@ function TreeViewInner({
8370
8245
  },
8371
8246
  [onItemSelect, selectedId]
8372
8247
  );
8373
- function activateResolvedItem(itemId) {
8374
- if (!itemId) {
8375
- return;
8376
- }
8377
- const nextEntry = selectableItems.find((entry) => entry.itemId === itemId);
8378
- if (nextEntry) {
8379
- activateEntry(nextEntry.item, nextEntry.itemId);
8380
- }
8381
- }
8248
+ const activateResolvedItem = (0, import_react40.useCallback)(
8249
+ (itemId) => {
8250
+ if (!itemId) {
8251
+ return;
8252
+ }
8253
+ const nextEntry = selectableItems.find(
8254
+ (entry) => entry.itemId === itemId
8255
+ );
8256
+ if (nextEntry) {
8257
+ activateEntry(nextEntry.item, nextEntry.itemId);
8258
+ }
8259
+ },
8260
+ [activateEntry, selectableItems]
8261
+ );
8382
8262
  function moveActive(direction) {
8383
8263
  if (selectableItems.length === 0) {
8384
8264
  return;
@@ -8470,7 +8350,7 @@ function TreeViewInner({
8470
8350
  event.preventDefault();
8471
8351
  activateResolvedItem(resolvedActiveId);
8472
8352
  break;
8473
- case " ":
8353
+ case " ": {
8474
8354
  event.preventDefault();
8475
8355
  if (!resolvedActiveId) {
8476
8356
  return;
@@ -8486,6 +8366,7 @@ function TreeViewInner({
8486
8366
  setExpandedState(activeItem, !expandedIdSet.has(activeItem.id));
8487
8367
  }
8488
8368
  break;
8369
+ }
8489
8370
  default:
8490
8371
  break;
8491
8372
  }
@@ -8526,7 +8407,13 @@ function TreeViewInner({
8526
8407
  }
8527
8408
  }
8528
8409
  }),
8529
- [data, resolvedActiveId, resolvedExpandedIds, onItemCheckChange]
8410
+ [
8411
+ activateResolvedItem,
8412
+ data,
8413
+ onItemCheckChange,
8414
+ resolvedActiveId,
8415
+ setExpandedState
8416
+ ]
8530
8417
  );
8531
8418
  return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
8532
8419
  "div",
@@ -8954,18 +8841,6 @@ var TreeListViewRow = (0, import_react41.memo)(
8954
8841
 
8955
8842
  // src/components/TreeListView/TreeListView.tsx
8956
8843
  var import_jsx_runtime58 = require("react/jsx-runtime");
8957
- function areTreeListColumnsEqual(previousColumns, nextColumns) {
8958
- if (previousColumns === nextColumns) {
8959
- return true;
8960
- }
8961
- if (previousColumns.length !== nextColumns.length) {
8962
- return false;
8963
- }
8964
- return previousColumns.every((previousColumn, index) => {
8965
- const nextColumn = nextColumns[index];
8966
- 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;
8967
- });
8968
- }
8969
8844
  function TreeListViewInner({
8970
8845
  activeItemId: activeItemIdProp,
8971
8846
  checkedIds,
@@ -8990,17 +8865,8 @@ function TreeListViewInner({
8990
8865
  const rootRef = (0, import_react42.useRef)(null);
8991
8866
  const treeId = (0, import_react42.useId)();
8992
8867
  const itemRefs = (0, import_react42.useRef)({});
8993
- const columnsRef = (0, import_react42.useRef)(columns);
8994
- const getCellContentRef = (0, import_react42.useRef)(getCellContent);
8995
- const onItemDoubleClickRef = (0, import_react42.useRef)(onItemDoubleClick);
8996
8868
  const resizeFrameRef = (0, import_react42.useRef)(null);
8997
8869
  const resizeStateRef = (0, import_react42.useRef)(null);
8998
- if (!areTreeListColumnsEqual(columnsRef.current, columns)) {
8999
- columnsRef.current = columns;
9000
- }
9001
- getCellContentRef.current = getCellContent;
9002
- onItemDoubleClickRef.current = onItemDoubleClick;
9003
- const resolvedColumns = columnsRef.current;
9004
8870
  const isExpandedControlled = expandedIds !== void 0;
9005
8871
  const [uncontrolledExpandedIds, setUncontrolledExpandedIds] = (0, import_react42.useState)(() => {
9006
8872
  const expandedFromData = collectExpandedTreeListIds(data);
@@ -9033,28 +8899,28 @@ function TreeListViewInner({
9033
8899
  const resolvedActiveItemId = activeItemId && selectableItems.some((entry) => entry.itemId === activeItemId) ? activeItemId : resolvedSelectedId;
9034
8900
  const minColumnWidthById = (0, import_react42.useMemo)(
9035
8901
  () => Object.fromEntries(
9036
- resolvedColumns.map(
8902
+ columns.map(
9037
8903
  (column) => [column.id, column.minWidth ?? 0]
9038
8904
  )
9039
8905
  ),
9040
- [resolvedColumns]
8906
+ [columns]
9041
8907
  );
9042
8908
  const templateColumns = (0, import_react42.useMemo)(
9043
- () => getTreeListTemplateColumns(resolvedColumns, {
8909
+ () => getTreeListTemplateColumns(columns, {
9044
8910
  autoColumnWidths,
9045
8911
  userColumnWidths
9046
8912
  }),
9047
- [autoColumnWidths, resolvedColumns, userColumnWidths]
8913
+ [autoColumnWidths, columns, userColumnWidths]
9048
8914
  );
9049
8915
  const treeColumnId = (0, import_react42.useMemo)(
9050
- () => getTreeListTreeColumnId(resolvedColumns),
9051
- [resolvedColumns]
8916
+ () => getTreeListTreeColumnId(columns),
8917
+ [columns]
9052
8918
  );
9053
8919
  const rowIndexMap = (0, import_react42.useMemo)(
9054
8920
  () => new Map(
9055
8921
  visibleItems.map((entry, index) => [entry.itemId, index])
9056
8922
  ),
9057
- [visibleItems, dataVersion]
8923
+ [visibleItems]
9058
8924
  );
9059
8925
  (0, import_react42.useEffect)(() => {
9060
8926
  if (!resolvedActiveItemId) {
@@ -9071,12 +8937,13 @@ function TreeListViewInner({
9071
8937
  []
9072
8938
  );
9073
8939
  const resolveCellContent = (0, import_react42.useCallback)(
9074
- (...args) => getCellContentRef.current?.(...args),
9075
- []
8940
+ (...args) => getCellContent?.(...args),
8941
+ [getCellContent]
8942
+ );
8943
+ const handleItemDoubleClick = (0, import_react42.useCallback)(
8944
+ (item) => onItemDoubleClick?.(item),
8945
+ [onItemDoubleClick]
9076
8946
  );
9077
- const handleItemDoubleClick = (0, import_react42.useCallback)((item) => {
9078
- onItemDoubleClickRef.current?.(item);
9079
- }, []);
9080
8947
  (0, import_react42.useLayoutEffect)(() => {
9081
8948
  const rootNode = rootRef.current;
9082
8949
  if (!rootNode) {
@@ -9085,7 +8952,7 @@ function TreeListViewInner({
9085
8952
  setAutoColumnWidths((currentWidths) => {
9086
8953
  let didChange = false;
9087
8954
  const nextWidths = { ...currentWidths };
9088
- resolvedColumns.forEach((column) => {
8955
+ columns.forEach((column) => {
9089
8956
  if (currentWidths[column.id] !== void 0 || userColumnWidths[column.id] !== void 0 || column.width !== void 0) {
9090
8957
  return;
9091
8958
  }
@@ -9108,7 +8975,7 @@ function TreeListViewInner({
9108
8975
  });
9109
8976
  return didChange ? nextWidths : currentWidths;
9110
8977
  });
9111
- }, [resolvedColumns, userColumnWidths, visibleItems]);
8978
+ }, [columns, userColumnWidths, visibleItems]);
9112
8979
  (0, import_react42.useEffect)(() => {
9113
8980
  return () => {
9114
8981
  if (resizeFrameRef.current !== null) {
@@ -9232,13 +9099,17 @@ function TreeListViewInner({
9232
9099
  function isItemChecked(item) {
9233
9100
  return checkedIds ? checkedIds.includes(item.id) : item.checked === true;
9234
9101
  }
9235
- function toggleItemCheck(itemId) {
9236
- const item = findTreeListItemById(data, itemId);
9237
- if (!item || item.disabled || item.checked === void 0 && checkedIds === void 0) {
9238
- return;
9239
- }
9240
- onItemCheckChange?.(item, !isItemChecked(item));
9241
- }
9102
+ const toggleItemCheck = (0, import_react42.useCallback)(
9103
+ (itemId) => {
9104
+ const item = findTreeListItemById(data, itemId);
9105
+ if (!item || item.disabled || item.checked === void 0 && checkedIds === void 0) {
9106
+ return;
9107
+ }
9108
+ const checked = checkedIds ? checkedIds.includes(item.id) : item.checked;
9109
+ onItemCheckChange?.(item, !checked);
9110
+ },
9111
+ [checkedIds, data, onItemCheckChange]
9112
+ );
9242
9113
  (0, import_react42.useImperativeHandle)(
9243
9114
  ref,
9244
9115
  () => ({
@@ -9272,7 +9143,13 @@ function TreeListViewInner({
9272
9143
  toggleItemCheck(itemId);
9273
9144
  }
9274
9145
  }),
9275
- [checkedIds, data, resolvedActiveItemId, resolvedExpandedIds]
9146
+ [
9147
+ activateResolvedItem,
9148
+ data,
9149
+ resolvedActiveItemId,
9150
+ setExpandedState,
9151
+ toggleItemCheck
9152
+ ]
9276
9153
  );
9277
9154
  function handleKeyDown(event) {
9278
9155
  switch (event.key) {
@@ -9304,7 +9181,7 @@ function TreeListViewInner({
9304
9181
  event.preventDefault();
9305
9182
  activateResolvedItem(resolvedActiveItemId);
9306
9183
  break;
9307
- case " ":
9184
+ case " ": {
9308
9185
  event.preventDefault();
9309
9186
  if (!resolvedActiveItemId) {
9310
9187
  return;
@@ -9320,6 +9197,7 @@ function TreeListViewInner({
9320
9197
  setExpandedState(activeItem, !expandedIdSet.has(activeItem.id));
9321
9198
  }
9322
9199
  break;
9200
+ }
9323
9201
  default:
9324
9202
  break;
9325
9203
  }
@@ -9385,6 +9263,7 @@ function TreeListViewInner({
9385
9263
  ...props,
9386
9264
  "aria-activedescendant": resolvedActiveItemId ? `${treeId}-${resolvedActiveItemId}` : void 0,
9387
9265
  className: ["nu-tree-list-view", className].filter(Boolean).join(" "),
9266
+ "data-version": dataVersion,
9388
9267
  onKeyDown: handleKeyDown,
9389
9268
  ref: rootRef,
9390
9269
  role: "treegrid",
@@ -9398,7 +9277,7 @@ function TreeListViewInner({
9398
9277
  style: {
9399
9278
  "--nu-tree-list-view-columns": templateColumns
9400
9279
  },
9401
- children: resolvedColumns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
9280
+ children: columns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
9402
9281
  "span",
9403
9282
  {
9404
9283
  className: [
@@ -9431,7 +9310,7 @@ function TreeListViewInner({
9431
9310
  {
9432
9311
  activeItemId: resolvedActiveItemId,
9433
9312
  checkedIds,
9434
- columns: resolvedColumns,
9313
+ columns,
9435
9314
  depth: 0,
9436
9315
  expandedIdSet,
9437
9316
  getCellContent: getCellContent ? resolveCellContent : void 0,