@deadragdoll/reactnu 0.1.30 → 0.1.49

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
@@ -945,6 +945,7 @@ function ListBoxItemViewInner({
945
945
  item,
946
946
  itemId,
947
947
  onActivate,
948
+ onPopupMenu,
948
949
  onDoubleClick,
949
950
  onToggleCheck,
950
951
  registerItemRef,
@@ -963,6 +964,9 @@ function ListBoxItemViewInner({
963
964
  onDoubleClick?.(item, group);
964
965
  }
965
966
  }
967
+ function handleContextMenu(event) {
968
+ onPopupMenu?.(event, item, group, itemId);
969
+ }
966
970
  function handleToggleCheck() {
967
971
  onToggleCheck(itemId);
968
972
  }
@@ -991,6 +995,7 @@ function ListBoxItemViewInner({
991
995
  ].filter(Boolean).join(" "),
992
996
  id: itemId,
993
997
  onClick: handleActivate,
998
+ onContextMenu: onPopupMenu ? handleContextMenu : void 0,
994
999
  onDoubleClick: handleDoubleClick,
995
1000
  ref: (node) => registerItemRef(itemId, node),
996
1001
  role: "option",
@@ -1016,6 +1021,7 @@ function ListBoxGroupView({
1016
1021
  listboxId,
1017
1022
  onActivateItem,
1018
1023
  onDoubleClickItem,
1024
+ onPopupMenuItem,
1019
1025
  onToggleItemCheck,
1020
1026
  registerItemRef,
1021
1027
  resolvedActiveId,
@@ -1047,6 +1053,7 @@ function ListBoxGroupView({
1047
1053
  itemId,
1048
1054
  onActivate: onActivateItem,
1049
1055
  onDoubleClick: onDoubleClickItem,
1056
+ onPopupMenu: onPopupMenuItem,
1050
1057
  onToggleCheck: onToggleItemCheck,
1051
1058
  registerItemRef,
1052
1059
  rightCheckBox,
@@ -1065,6 +1072,7 @@ function ListBoxInner({
1065
1072
  data,
1066
1073
  checkedIds,
1067
1074
  emptyText = "No items",
1075
+ onPopupMenu,
1068
1076
  onItemCheckChange,
1069
1077
  onItemDoubleClick,
1070
1078
  onItemSelect,
@@ -1124,6 +1132,18 @@ function ListBoxInner({
1124
1132
  },
1125
1133
  [activateItem, selectableItems]
1126
1134
  );
1135
+ const handleItemPopupMenu = useCallback2(
1136
+ (event, item, group, itemId) => {
1137
+ if (item.disabled || !onPopupMenu) {
1138
+ return;
1139
+ }
1140
+ event.preventDefault();
1141
+ event.stopPropagation();
1142
+ activateItem(item, group, itemId);
1143
+ onPopupMenu(event, item, group);
1144
+ },
1145
+ [activateItem, onPopupMenu]
1146
+ );
1127
1147
  function moveActive(direction) {
1128
1148
  if (selectableItems.length === 0) {
1129
1149
  return;
@@ -1244,6 +1264,7 @@ function ListBoxInner({
1244
1264
  listboxId,
1245
1265
  onActivateItem: activateItem,
1246
1266
  onDoubleClickItem: onItemDoubleClick,
1267
+ onPopupMenuItem: handleItemPopupMenu,
1247
1268
  onToggleItemCheck: toggleItemCheck,
1248
1269
  registerItemRef,
1249
1270
  resolvedActiveId,
@@ -1933,8 +1954,6 @@ function WindowInner({
1933
1954
  return;
1934
1955
  }
1935
1956
  onActivate?.();
1936
- event.preventDefault();
1937
- event.stopPropagation();
1938
1957
  }
1939
1958
  function handleTitlePointerDown(event) {
1940
1959
  onActivate?.();
@@ -4271,6 +4290,7 @@ function InfoAccent({
4271
4290
 
4272
4291
  // src/components/IconGrid/NuIconGrid.tsx
4273
4292
  import {
4293
+ useEffect as useEffect8,
4274
4294
  useLayoutEffect as useLayoutEffect4,
4275
4295
  useMemo as useMemo8,
4276
4296
  useRef as useRef9,
@@ -4542,6 +4562,7 @@ function useNuIconGridContext() {
4542
4562
  // src/components/IconGrid/NuIconGrid.tsx
4543
4563
  import { Fragment as Fragment5, jsx as jsx35, jsxs as jsxs20 } from "react/jsx-runtime";
4544
4564
  var DRAG_THRESHOLD = 3;
4565
+ var gridRegistrations = /* @__PURE__ */ new Map();
4545
4566
  function clamp2(value, minimum, maximum) {
4546
4567
  return Math.min(Math.max(value, minimum), maximum);
4547
4568
  }
@@ -4551,11 +4572,85 @@ function resolveIconContextMenuItems(source, icon) {
4551
4572
  function resolveGridContextMenuItems(source, manager) {
4552
4573
  return typeof source === "function" ? source(manager) : source ?? [];
4553
4574
  }
4554
- function NuIconGridItem({ gridElement, icon }) {
4575
+ function findGridRegistrationAtPoint(clientX, clientY) {
4576
+ const target = document.elementFromPoint(clientX, clientY);
4577
+ const gridElement = target?.closest(".nu-icon-grid");
4578
+ if (gridElement) {
4579
+ return gridRegistrations.get(gridElement);
4580
+ }
4581
+ if (target?.closest(".nu-window")) {
4582
+ return void 0;
4583
+ }
4584
+ return Array.from(gridRegistrations.values()).reverse().find((registration) => {
4585
+ if (!registration.dropTarget) {
4586
+ return false;
4587
+ }
4588
+ const rect = registration.element.getBoundingClientRect();
4589
+ return clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;
4590
+ });
4591
+ }
4592
+ function getTransferredPosition(targetGrid, iconElement, clientX, clientY) {
4593
+ const targetRect = targetGrid.getBoundingClientRect();
4594
+ const iconRect = iconElement.getBoundingClientRect();
4595
+ return {
4596
+ x: Math.round(
4597
+ clamp2(
4598
+ clientX - targetRect.left - iconRect.width / 2,
4599
+ 0,
4600
+ Math.max(0, targetRect.width - iconRect.width)
4601
+ )
4602
+ ),
4603
+ y: Math.round(
4604
+ clamp2(
4605
+ clientY - targetRect.top - iconRect.height / 2,
4606
+ 0,
4607
+ Math.max(0, targetRect.height - iconRect.height)
4608
+ )
4609
+ )
4610
+ };
4611
+ }
4612
+ function createDragPreview(iconElement) {
4613
+ const rect = iconElement.getBoundingClientRect();
4614
+ const preview = iconElement.cloneNode(true);
4615
+ preview.removeAttribute("id");
4616
+ preview.setAttribute("aria-hidden", "true");
4617
+ preview.setAttribute("disabled", "");
4618
+ preview.setAttribute("tabindex", "-1");
4619
+ Object.assign(preview.style, {
4620
+ height: `${rect.height}px`,
4621
+ left: `${rect.left}px`,
4622
+ margin: "0",
4623
+ opacity: window.getComputedStyle(iconElement).getPropertyValue("--nu-icon-grid-icon-drag-preview-opacity").trim() || "0.85",
4624
+ pointerEvents: "none",
4625
+ position: "fixed",
4626
+ top: `${rect.top}px`,
4627
+ width: `${rect.width}px`,
4628
+ zIndex: "2147483647"
4629
+ });
4630
+ const themeStyle = getThemePortalStyle(iconElement);
4631
+ Object.entries(themeStyle ?? {}).forEach(([property, value]) => {
4632
+ if (value !== void 0) {
4633
+ preview.style.setProperty(property, String(value));
4634
+ }
4635
+ });
4636
+ document.body.append(preview);
4637
+ return preview;
4638
+ }
4639
+ function moveDragPreview(preview, iconElement, clientX, clientY) {
4640
+ const rect = iconElement.getBoundingClientRect();
4641
+ preview.style.left = `${Math.round(clientX - rect.width / 2)}px`;
4642
+ preview.style.top = `${Math.round(clientY - rect.height / 2)}px`;
4643
+ }
4644
+ function NuIconGridItem({
4645
+ gridElement,
4646
+ icon,
4647
+ onIconMoveOut
4648
+ }) {
4555
4649
  const manager = useNuIconGridContext();
4556
4650
  const contextMenu = usePopupMenu();
4557
4651
  const dragStartRef = useRef9(void 0);
4558
4652
  const isDraggingRef = useRef9(false);
4653
+ const dragPreviewRef = useRef9(null);
4559
4654
  const [isDragging, setIsDragging] = useState15(false);
4560
4655
  const suppressClickRef = useRef9(false);
4561
4656
  const latestPositionRef = useRef9(icon.position);
@@ -4563,6 +4658,11 @@ function NuIconGridItem({ gridElement, icon }) {
4563
4658
  icon.contextMenuItems,
4564
4659
  icon
4565
4660
  );
4661
+ function removeDragPreview() {
4662
+ dragPreviewRef.current?.remove();
4663
+ dragPreviewRef.current = null;
4664
+ }
4665
+ useEffect8(() => removeDragPreview, []);
4566
4666
  function handlePointerDown(event) {
4567
4667
  if (event.button !== 0 || icon.disabled) {
4568
4668
  return;
@@ -4588,8 +4688,19 @@ function NuIconGridItem({ gridElement, icon }) {
4588
4688
  if (!isDraggingRef.current && Math.max(Math.abs(deltaX), Math.abs(deltaY)) < DRAG_THRESHOLD) {
4589
4689
  return;
4590
4690
  }
4591
- isDraggingRef.current = true;
4592
- setIsDragging(true);
4691
+ if (!isDraggingRef.current) {
4692
+ isDraggingRef.current = true;
4693
+ setIsDragging(true);
4694
+ dragPreviewRef.current = createDragPreview(event.currentTarget);
4695
+ }
4696
+ if (dragPreviewRef.current) {
4697
+ moveDragPreview(
4698
+ dragPreviewRef.current,
4699
+ event.currentTarget,
4700
+ event.clientX,
4701
+ event.clientY
4702
+ );
4703
+ }
4593
4704
  const gridRect = gridElement.getBoundingClientRect();
4594
4705
  const iconRect = event.currentTarget.getBoundingClientRect();
4595
4706
  const position = {
@@ -4609,7 +4720,6 @@ function NuIconGridItem({ gridElement, icon }) {
4609
4720
  )
4610
4721
  };
4611
4722
  latestPositionRef.current = position;
4612
- manager.moveIcon(icon.id, position);
4613
4723
  }
4614
4724
  function finishDragging(event) {
4615
4725
  const dragStart = dragStartRef.current;
@@ -4620,16 +4730,56 @@ function NuIconGridItem({ gridElement, icon }) {
4620
4730
  event.currentTarget.releasePointerCapture(event.pointerId);
4621
4731
  }
4622
4732
  dragStartRef.current = void 0;
4733
+ removeDragPreview();
4623
4734
  if (!isDraggingRef.current) {
4624
4735
  return;
4625
4736
  }
4626
4737
  suppressClickRef.current = true;
4627
4738
  isDraggingRef.current = false;
4628
4739
  setIsDragging(false);
4629
- icon.onPositionChange?.(latestPositionRef.current, {
4630
- ...icon,
4631
- position: latestPositionRef.current
4632
- });
4740
+ if (event.type === "pointercancel" || !gridElement) {
4741
+ return;
4742
+ }
4743
+ const targetRegistration = findGridRegistrationAtPoint(
4744
+ event.clientX,
4745
+ event.clientY
4746
+ );
4747
+ if (!targetRegistration) {
4748
+ return;
4749
+ }
4750
+ if (targetRegistration.element === gridElement) {
4751
+ manager.moveIcon(icon.id, latestPositionRef.current);
4752
+ icon.onPositionChange?.(latestPositionRef.current, {
4753
+ ...icon,
4754
+ position: latestPositionRef.current
4755
+ });
4756
+ return;
4757
+ }
4758
+ if (!targetRegistration.manager.icons.some(
4759
+ (targetIcon) => targetIcon.id === icon.id
4760
+ )) {
4761
+ const position = getTransferredPosition(
4762
+ targetRegistration.element,
4763
+ event.currentTarget,
4764
+ event.clientX,
4765
+ event.clientY
4766
+ );
4767
+ const transferredIcon = { ...icon, position };
4768
+ const context = {
4769
+ position,
4770
+ source: manager,
4771
+ sourceGrid: gridElement,
4772
+ target: targetRegistration.manager,
4773
+ targetGrid: targetRegistration.element
4774
+ };
4775
+ if (targetRegistration.accepts?.(transferredIcon) !== false && targetRegistration.onIconDrop?.(transferredIcon, context) !== false) {
4776
+ targetRegistration.manager.addIcon(transferredIcon);
4777
+ targetRegistration.manager.selectIcon(transferredIcon.id);
4778
+ manager.removeIcon(icon.id);
4779
+ onIconMoveOut?.(transferredIcon, context);
4780
+ return;
4781
+ }
4782
+ }
4633
4783
  }
4634
4784
  function handleClick(event) {
4635
4785
  if (suppressClickRef.current) {
@@ -4695,9 +4845,13 @@ function NuIconGridItem({ gridElement, icon }) {
4695
4845
  ] });
4696
4846
  }
4697
4847
  function NuIconGrid({
4848
+ accepts,
4698
4849
  className,
4699
4850
  contextMenuItems: contextMenuItemsSource,
4700
4851
  defaultArrangeMode,
4852
+ dropTarget = false,
4853
+ onIconDrop,
4854
+ onIconMoveOut,
4701
4855
  onContextMenu,
4702
4856
  onPointerDown,
4703
4857
  ...props
@@ -4733,6 +4887,21 @@ function NuIconGrid({
4733
4887
  resizeObserver.observe(gridElement);
4734
4888
  return () => resizeObserver.disconnect();
4735
4889
  }, [arrangeIcons, defaultArrangeMode, gridElement, setGridSize]);
4890
+ useLayoutEffect4(() => {
4891
+ if (!gridElement) {
4892
+ return;
4893
+ }
4894
+ gridRegistrations.set(gridElement, {
4895
+ accepts,
4896
+ dropTarget,
4897
+ element: gridElement,
4898
+ manager,
4899
+ onIconDrop
4900
+ });
4901
+ return () => {
4902
+ gridRegistrations.delete(gridElement);
4903
+ };
4904
+ }, [accepts, dropTarget, gridElement, manager, onIconDrop]);
4736
4905
  function handleContextMenu(event) {
4737
4906
  onContextMenu?.(event);
4738
4907
  if (event.defaultPrevented || contextMenuItems.length === 0) {
@@ -4761,7 +4930,15 @@ function NuIconGrid({
4761
4930
  ref: setGridElement,
4762
4931
  role: "group",
4763
4932
  children: [
4764
- manager.icons.map((icon) => /* @__PURE__ */ jsx35(NuIconGridItem, { gridElement, icon }, icon.id)),
4933
+ manager.icons.map((icon) => /* @__PURE__ */ jsx35(
4934
+ NuIconGridItem,
4935
+ {
4936
+ gridElement,
4937
+ icon,
4938
+ onIconMoveOut
4939
+ },
4940
+ icon.id
4941
+ )),
4765
4942
  /* @__PURE__ */ jsx35(
4766
4943
  PopupMenu,
4767
4944
  {
@@ -4936,7 +5113,7 @@ function NuIconProvider({
4936
5113
 
4937
5114
  // src/components/ComboBox/ComboBox.tsx
4938
5115
  import {
4939
- useEffect as useEffect8,
5116
+ useEffect as useEffect9,
4940
5117
  useId as useId5,
4941
5118
  useMemo as useMemo10,
4942
5119
  useRef as useRef11,
@@ -5027,7 +5204,7 @@ function ComboBox({
5027
5204
  );
5028
5205
  const popupRoot = typeof document === "undefined" ? null : resolveComboBoxPortalRoot();
5029
5206
  const [themePortalStyle, setThemePortalStyle] = useState17(() => void 0);
5030
- useEffect8(() => {
5207
+ useEffect9(() => {
5031
5208
  if (!open) {
5032
5209
  return;
5033
5210
  }
@@ -5386,7 +5563,7 @@ function CommandButton({
5386
5563
  }
5387
5564
 
5388
5565
  // src/components/CrtGlitch/CrtGlitch.tsx
5389
- import { useEffect as useEffect9, useId as useId6, useRef as useRef12 } from "react";
5566
+ import { useEffect as useEffect10, useId as useId6, useRef as useRef12 } from "react";
5390
5567
  import { jsx as jsx39, jsxs as jsxs23 } from "react/jsx-runtime";
5391
5568
  var DEFAULT_INTERVAL_MS = 3e3;
5392
5569
  var DEFAULT_DURATION_MS = 2500;
@@ -5419,7 +5596,7 @@ function NuCrtGlitch({
5419
5596
  const bOffsetRef = useRef12(null);
5420
5597
  const rafRef = useRef12(null);
5421
5598
  const targetElRef = useRef12(null);
5422
- useEffect9(() => {
5599
+ useEffect10(() => {
5423
5600
  if (!enabled) {
5424
5601
  return;
5425
5602
  }
@@ -5594,7 +5771,7 @@ function NuCrtGlitch({
5594
5771
  import {
5595
5772
  forwardRef as forwardRef2,
5596
5773
  useCallback as useCallback6,
5597
- useEffect as useEffect10,
5774
+ useEffect as useEffect11,
5598
5775
  useImperativeHandle as useImperativeHandle2,
5599
5776
  useMemo as useMemo11,
5600
5777
  useRef as useRef13,
@@ -5794,7 +5971,7 @@ function ListViewInner({
5794
5971
  );
5795
5972
  return [checkboxColumn, ...dataColumns].filter(Boolean).join(" ");
5796
5973
  }, [columns, showCheckBox]);
5797
- useEffect10(() => {
5974
+ useEffect11(() => {
5798
5975
  if (!resolvedActiveRowId) {
5799
5976
  return;
5800
5977
  }
@@ -5988,7 +6165,7 @@ var ListView = forwardRef2(ListViewInner);
5988
6165
 
5989
6166
  // src/components/MaskedField/MaskedField.tsx
5990
6167
  import {
5991
- useEffect as useEffect11,
6168
+ useEffect as useEffect12,
5992
6169
  useId as useId7,
5993
6170
  useMemo as useMemo12,
5994
6171
  useRef as useRef14,
@@ -6194,7 +6371,7 @@ function MaskedField({
6194
6371
  () => props.inputMode === void 0 ? getTextMaskInputMode(mask) : void 0,
6195
6372
  [mask, props.inputMode]
6196
6373
  );
6197
- useEffect11(() => {
6374
+ useEffect12(() => {
6198
6375
  if (!onDebouncedChange) {
6199
6376
  return;
6200
6377
  }
@@ -7202,7 +7379,7 @@ function ReportCell({
7202
7379
 
7203
7380
  // src/components/SearchBox/SearchBox.tsx
7204
7381
  import {
7205
- useEffect as useEffect12,
7382
+ useEffect as useEffect13,
7206
7383
  useId as useId12,
7207
7384
  useMemo as useMemo15,
7208
7385
  useRef as useRef17,
@@ -7279,7 +7456,7 @@ function SearchBox({
7279
7456
  );
7280
7457
  const popupRoot = typeof document === "undefined" ? null : resolveSearchBoxPortalRoot();
7281
7458
  const [themePortalStyle, setThemePortalStyle] = useState25(() => void 0);
7282
- useEffect12(() => {
7459
+ useEffect13(() => {
7283
7460
  if (disabled) {
7284
7461
  return;
7285
7462
  }
@@ -7311,7 +7488,7 @@ function SearchBox({
7311
7488
  popupRef,
7312
7489
  portalRoot: popupRoot
7313
7490
  });
7314
- useEffect12(() => {
7491
+ useEffect13(() => {
7315
7492
  if (disabled || !open) {
7316
7493
  return;
7317
7494
  }
@@ -7693,7 +7870,7 @@ function SpinBox({
7693
7870
 
7694
7871
  // src/components/Splitter/Splitter.tsx
7695
7872
  import {
7696
- useEffect as useEffect13,
7873
+ useEffect as useEffect14,
7697
7874
  useId as useId14,
7698
7875
  useRef as useRef18,
7699
7876
  useState as useState27
@@ -7742,13 +7919,13 @@ function Splitter({
7742
7919
  );
7743
7920
  const firstPaneId = useId14();
7744
7921
  const secondPaneId = useId14();
7745
- useEffect13(() => {
7922
+ useEffect14(() => {
7746
7923
  if (!storageKey || typeof window === "undefined") {
7747
7924
  return;
7748
7925
  }
7749
7926
  window.localStorage.setItem(storageKey, String(activeValue));
7750
7927
  }, [activeValue, storageKey]);
7751
- useEffect13(() => {
7928
+ useEffect14(() => {
7752
7929
  return () => {
7753
7930
  if (dragFrameRef.current !== null) {
7754
7931
  window.cancelAnimationFrame(dragFrameRef.current);
@@ -7897,7 +8074,7 @@ function Splitter({
7897
8074
 
7898
8075
  // src/components/TickBar/TickBar.tsx
7899
8076
  import {
7900
- useEffect as useEffect14,
8077
+ useEffect as useEffect15,
7901
8078
  useId as useId15,
7902
8079
  useMemo as useMemo17,
7903
8080
  useRef as useRef19,
@@ -7963,7 +8140,7 @@ function TickBar({
7963
8140
  );
7964
8141
  }, [min, safeMax, safeStep, tickCount]);
7965
8142
  const renderedValue = valueRenderer ? valueRenderer(resolvedValue, min, safeMax) : String(resolvedValue);
7966
- useEffect14(() => {
8143
+ useEffect15(() => {
7967
8144
  if (!dragging) {
7968
8145
  return;
7969
8146
  }
@@ -8279,7 +8456,7 @@ function ToolSeparator({ className, ...props }) {
8279
8456
  import {
8280
8457
  forwardRef as forwardRef3,
8281
8458
  useCallback as useCallback7,
8282
- useEffect as useEffect15,
8459
+ useEffect as useEffect16,
8283
8460
  useId as useId16,
8284
8461
  useImperativeHandle as useImperativeHandle3,
8285
8462
  useMemo as useMemo18,
@@ -8648,7 +8825,7 @@ function TreeViewInner({
8648
8825
  const resolvedSelectedId = derivedSelectedId && selectableItems.some((entry) => entry.itemId === derivedSelectedId) ? derivedSelectedId : selectableItems[0]?.itemId ?? null;
8649
8826
  const [activeId, setActiveId] = useState29(resolvedSelectedId);
8650
8827
  const resolvedActiveId = activeId && selectableItems.some((entry) => entry.itemId === activeId) ? activeId : resolvedSelectedId;
8651
- useEffect15(() => {
8828
+ useEffect16(() => {
8652
8829
  if (!resolvedActiveId) {
8653
8830
  return;
8654
8831
  }
@@ -8895,7 +9072,7 @@ var TreeView = forwardRef3(TreeViewInner);
8895
9072
  import {
8896
9073
  forwardRef as forwardRef4,
8897
9074
  useCallback as useCallback8,
8898
- useEffect as useEffect16,
9075
+ useEffect as useEffect17,
8899
9076
  useId as useId17,
8900
9077
  useImperativeHandle as useImperativeHandle4,
8901
9078
  useLayoutEffect as useLayoutEffect5,
@@ -9042,6 +9219,7 @@ function TreeListViewRowInner({
9042
9219
  item,
9043
9220
  onActivateItem,
9044
9221
  onDoubleClickItem,
9222
+ onPopupMenuItem,
9045
9223
  onToggleItemCheck,
9046
9224
  onToggleItemExpanded,
9047
9225
  originOffset,
@@ -9080,6 +9258,17 @@ function TreeListViewRowInner({
9080
9258
  }
9081
9259
  onDoubleClickItem?.(item);
9082
9260
  }
9261
+ function handleContextMenu(event) {
9262
+ if (item.disabled) {
9263
+ return;
9264
+ }
9265
+ onPopupMenuItem?.(event, item, {
9266
+ depth,
9267
+ isLeaf: !hasChildren,
9268
+ item,
9269
+ rowIndex
9270
+ });
9271
+ }
9083
9272
  function handleToggleExpanded(event) {
9084
9273
  event.stopPropagation();
9085
9274
  if (item.disabled || !hasChildren) {
@@ -9113,6 +9302,7 @@ function TreeListViewRowInner({
9113
9302
  ].filter(Boolean).join(" "),
9114
9303
  id: `${treeId}-${itemId}`,
9115
9304
  onClick: handleActivate,
9305
+ onContextMenu: onPopupMenuItem ? handleContextMenu : void 0,
9116
9306
  onDoubleClick: handleDoubleClick,
9117
9307
  ref: (node) => registerItemRef(itemId, node),
9118
9308
  role: "row",
@@ -9261,6 +9451,7 @@ function TreeListViewRowInner({
9261
9451
  item: child,
9262
9452
  onActivateItem,
9263
9453
  onDoubleClickItem,
9454
+ onPopupMenuItem,
9264
9455
  onToggleItemCheck,
9265
9456
  onToggleItemExpanded,
9266
9457
  originOffset: originOffset + leadOffset,
@@ -9282,7 +9473,7 @@ function areTreeListViewRowPropsEqual(previousProps, nextProps) {
9282
9473
  return !didActivePathChange && !didSelectedPathChange && previousProps.checkedIds === nextProps.checkedIds && previousProps.columns === nextProps.columns && previousProps.depth === nextProps.depth && previousProps.expandedIdSet === nextProps.expandedIdSet && previousProps.getCellContent === nextProps.getCellContent && areTreeListGuideArraysEqual(previousProps.guideMask, nextProps.guideMask) && areTreeListGuideArraysEqual(
9283
9474
  previousProps.guideOffsets,
9284
9475
  nextProps.guideOffsets
9285
- ) && previousProps.hasNextSibling === nextProps.hasNextSibling && previousProps.item === nextProps.item && previousProps.onActivateItem === nextProps.onActivateItem && previousProps.onDoubleClickItem === nextProps.onDoubleClickItem && previousProps.onToggleItemCheck === nextProps.onToggleItemCheck && previousProps.onToggleItemExpanded === nextProps.onToggleItemExpanded && previousProps.originOffset === nextProps.originOffset && previousProps.registerItemRef === nextProps.registerItemRef && previousProps.rowIndexMap === nextProps.rowIndexMap && previousProps.templateColumns === nextProps.templateColumns && previousProps.treeColumnId === nextProps.treeColumnId && previousProps.treeId === nextProps.treeId && previousProps.uncheckedShape === nextProps.uncheckedShape;
9476
+ ) && previousProps.hasNextSibling === nextProps.hasNextSibling && previousProps.item === nextProps.item && previousProps.onActivateItem === nextProps.onActivateItem && previousProps.onDoubleClickItem === nextProps.onDoubleClickItem && previousProps.onPopupMenuItem === nextProps.onPopupMenuItem && previousProps.onToggleItemCheck === nextProps.onToggleItemCheck && previousProps.onToggleItemExpanded === nextProps.onToggleItemExpanded && previousProps.originOffset === nextProps.originOffset && previousProps.registerItemRef === nextProps.registerItemRef && previousProps.rowIndexMap === nextProps.rowIndexMap && previousProps.templateColumns === nextProps.templateColumns && previousProps.treeColumnId === nextProps.treeColumnId && previousProps.treeId === nextProps.treeId && previousProps.uncheckedShape === nextProps.uncheckedShape;
9286
9477
  }
9287
9478
  var TreeListViewRow = memo5(
9288
9479
  TreeListViewRowInner,
@@ -9296,6 +9487,7 @@ function TreeListViewInner({
9296
9487
  checkedIds,
9297
9488
  className,
9298
9489
  columns,
9490
+ onPopupMenu,
9299
9491
  data,
9300
9492
  dataVersion,
9301
9493
  defaultActiveItemId,
@@ -9372,7 +9564,7 @@ function TreeListViewInner({
9372
9564
  ),
9373
9565
  [visibleItems]
9374
9566
  );
9375
- useEffect16(() => {
9567
+ useEffect17(() => {
9376
9568
  if (!resolvedActiveItemId) {
9377
9569
  return;
9378
9570
  }
@@ -9426,7 +9618,7 @@ function TreeListViewInner({
9426
9618
  return didChange ? nextWidths : currentWidths;
9427
9619
  });
9428
9620
  }, [columns, userColumnWidths, visibleItems]);
9429
- useEffect16(() => {
9621
+ useEffect17(() => {
9430
9622
  return () => {
9431
9623
  if (resizeFrameRef.current !== null) {
9432
9624
  window.cancelAnimationFrame(resizeFrameRef.current);
@@ -9465,6 +9657,18 @@ function TreeListViewInner({
9465
9657
  },
9466
9658
  [onItemSelect, selectedId, updateActiveItem]
9467
9659
  );
9660
+ const handleItemPopupMenu = useCallback8(
9661
+ (event, item, context) => {
9662
+ if (item.disabled || !onPopupMenu) {
9663
+ return;
9664
+ }
9665
+ event.preventDefault();
9666
+ event.stopPropagation();
9667
+ activateEntry(item, item.id);
9668
+ onPopupMenu(event, item, context);
9669
+ },
9670
+ [activateEntry, onPopupMenu]
9671
+ );
9468
9672
  const activateResolvedItem = useCallback8(
9469
9673
  (itemId) => {
9470
9674
  if (!itemId) {
@@ -9770,6 +9974,7 @@ function TreeListViewInner({
9770
9974
  item,
9771
9975
  onActivateItem: activateEntry,
9772
9976
  onDoubleClickItem: onItemDoubleClick ? handleItemDoubleClick : void 0,
9977
+ onPopupMenuItem: handleItemPopupMenu,
9773
9978
  onToggleItemCheck: handleItemCheckChange,
9774
9979
  onToggleItemExpanded: setExpandedState,
9775
9980
  originOffset: 0,
@@ -9811,10 +10016,12 @@ var classicTheme = {
9811
10016
  panelBackground: "#6262e3",
9812
10017
  panelInsetBackground: "#6262e3",
9813
10018
  titleBackground: "#ffffff",
10019
+ menuBackground: "#ffffff",
9814
10020
  titleText: "#1f36bc",
9815
10021
  textPrimary: "#ffffff",
9816
10022
  textMuted: "#dfe3ff",
9817
10023
  textInverse: "#000000",
10024
+ mainMenuText: "#000000",
9818
10025
  textAccent: "#ffff55",
9819
10026
  textHotkey: "#ff5555",
9820
10027
  buttonFace: "#ffffff",
@@ -9847,10 +10054,12 @@ var amberTheme = {
9847
10054
  panelBackground: "#4b2b00",
9848
10055
  panelInsetBackground: "#382000",
9849
10056
  titleBackground: "#ffd28f",
10057
+ menuBackground: "#ffd28f",
9850
10058
  titleText: "#4b2b00",
9851
10059
  textPrimary: "#ffd28f",
9852
10060
  textMuted: "#d6b57a",
9853
10061
  textInverse: "#201000",
10062
+ mainMenuText: "#201000",
9854
10063
  textAccent: "#fff27a",
9855
10064
  textHotkey: "#ff5f00",
9856
10065
  buttonFace: "#ffd28f",
@@ -9883,10 +10092,12 @@ var phosphorTheme = {
9883
10092
  panelBackground: "#11351a",
9884
10093
  panelInsetBackground: "#0d2813",
9885
10094
  titleBackground: "#b7ffbf",
10095
+ menuBackground: "#b7ffbf",
9886
10096
  titleText: "#0b2310",
9887
10097
  textPrimary: "#b7ffbf",
9888
10098
  textMuted: "#8ed39a",
9889
10099
  textInverse: "#061208",
10100
+ mainMenuText: "#061208",
9890
10101
  textAccent: "#f7ff7a",
9891
10102
  textHotkey: "#ff6f6f",
9892
10103
  buttonFace: "#b7ffbf",
@@ -9919,10 +10130,12 @@ var midnightTheme = {
9919
10130
  panelBackground: "#17273b",
9920
10131
  panelInsetBackground: "#111e2e",
9921
10132
  titleBackground: "#d4dde8",
10133
+ menuBackground: "#d4dde8",
9922
10134
  titleText: "#14233a",
9923
10135
  textPrimary: "#e6edf7",
9924
10136
  textMuted: "#aebdcd",
9925
10137
  textInverse: "#0b1220",
10138
+ mainMenuText: "#0b1220",
9926
10139
  textAccent: "#ffd166",
9927
10140
  textHotkey: "#ff7171",
9928
10141
  buttonFace: "#d4dde8",
@@ -9955,10 +10168,12 @@ var grayscaleTheme = {
9955
10168
  panelBackground: "#3f3f3f",
9956
10169
  panelInsetBackground: "#343434",
9957
10170
  titleBackground: "#262626",
10171
+ menuBackground: "#262626",
9958
10172
  titleText: "#d0d0d0",
9959
10173
  textPrimary: "#c8c8c8",
9960
10174
  textMuted: "#969696",
9961
10175
  textInverse: "#d0d0d0",
10176
+ mainMenuText: "#d0d0d0",
9962
10177
  textAccent: "#e0e0e0",
9963
10178
  textHotkey: "#ffffff",
9964
10179
  buttonFace: "#5b5b5b",
@@ -10002,10 +10217,12 @@ function getNuThemeStyle(theme) {
10002
10217
  "--nu-color-panel": theme.tokens.panelBackground,
10003
10218
  "--nu-color-panel-inset": theme.tokens.panelInsetBackground,
10004
10219
  "--nu-color-title-bg": theme.tokens.titleBackground,
10220
+ "--nu-color-menu": theme.tokens.menuBackground,
10005
10221
  "--nu-color-title-text": theme.tokens.titleText,
10006
10222
  "--nu-text-primary": theme.tokens.textPrimary,
10007
10223
  "--nu-text-muted": theme.tokens.textMuted,
10008
10224
  "--nu-text-inverse": theme.tokens.textInverse,
10225
+ "--nu-main-menu-text": theme.tokens.mainMenuText,
10009
10226
  "--nu-text-accent": theme.tokens.textAccent,
10010
10227
  "--nu-text-hotkey": theme.tokens.textHotkey,
10011
10228
  "--nu-color-button-face": theme.tokens.buttonFace,
@@ -10089,6 +10306,7 @@ function NuThemeProvider({
10089
10306
  onFontFamilyChange,
10090
10307
  onFontSizeChange,
10091
10308
  onThemeChange,
10309
+ style,
10092
10310
  theme
10093
10311
  }) {
10094
10312
  const generatedId = useId18();
@@ -10174,7 +10392,8 @@ function NuThemeProvider({
10174
10392
  ...getNuThemeStyle(resolvedTheme),
10175
10393
  "--nu-font-body": resolvedFontFamily,
10176
10394
  fontFamily: resolvedFontFamily,
10177
- fontSize: `${resolvedFontSize}px`
10395
+ fontSize: `${resolvedFontSize}px`,
10396
+ ...style
10178
10397
  },
10179
10398
  children: [
10180
10399
  crtGlitch ? /* @__PURE__ */ jsx61(NuCrtGlitch, { ...typeof crtGlitch === "object" ? crtGlitch : {} }) : null,