@deadragdoll/reactnu 0.1.24 → 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/components/IconGrid/IconGrid.types.d.ts +9 -0
- package/dist/components/IconGrid/NuIconGrid.d.ts +10 -2
- package/dist/components/ListBox/ListBox.d.ts +3 -2
- package/dist/components/ListBox/internals/ListBoxGroupView.d.ts +3 -1
- package/dist/components/ListBox/internals/ListBoxItemView.d.ts +3 -1
- package/dist/components/PopupMenu/PopupMenu.d.ts +1 -0
- package/dist/components/PopupMenu/usePopupMenu.d.ts +1 -1
- package/dist/components/TreeListView/TreeListView.d.ts +4 -3
- package/dist/components/TreeListView/internals/TreeListViewRow.d.ts +4 -2
- package/dist/index.cjs +275 -19
- package/dist/index.js +297 -40
- package/dist/styles.css +87 -24
- package/dist/theme/NuThemeProvider.d.ts +3 -2
- package/dist/theme/themes.d.ts +3 -0
- package/docs/IconGrid.md +25 -3
- package/docs/ListBox.md +4 -0
- package/docs/NuThemeProvider.md +5 -1
- package/docs/PopupMenu.md +4 -1
- package/docs/TOKEN_CHECKLIST.md +1 -1
- package/docs/TreeListView.md +5 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1024,6 +1024,7 @@ function ListBoxItemViewInner({
|
|
|
1024
1024
|
item,
|
|
1025
1025
|
itemId,
|
|
1026
1026
|
onActivate,
|
|
1027
|
+
onPopupMenu,
|
|
1027
1028
|
onDoubleClick,
|
|
1028
1029
|
onToggleCheck,
|
|
1029
1030
|
registerItemRef,
|
|
@@ -1042,6 +1043,9 @@ function ListBoxItemViewInner({
|
|
|
1042
1043
|
onDoubleClick?.(item, group);
|
|
1043
1044
|
}
|
|
1044
1045
|
}
|
|
1046
|
+
function handleContextMenu(event) {
|
|
1047
|
+
onPopupMenu?.(event, item, group, itemId);
|
|
1048
|
+
}
|
|
1045
1049
|
function handleToggleCheck() {
|
|
1046
1050
|
onToggleCheck(itemId);
|
|
1047
1051
|
}
|
|
@@ -1070,6 +1074,7 @@ function ListBoxItemViewInner({
|
|
|
1070
1074
|
].filter(Boolean).join(" "),
|
|
1071
1075
|
id: itemId,
|
|
1072
1076
|
onClick: handleActivate,
|
|
1077
|
+
onContextMenu: onPopupMenu ? handleContextMenu : void 0,
|
|
1073
1078
|
onDoubleClick: handleDoubleClick,
|
|
1074
1079
|
ref: (node) => registerItemRef(itemId, node),
|
|
1075
1080
|
role: "option",
|
|
@@ -1095,6 +1100,7 @@ function ListBoxGroupView({
|
|
|
1095
1100
|
listboxId,
|
|
1096
1101
|
onActivateItem,
|
|
1097
1102
|
onDoubleClickItem,
|
|
1103
|
+
onPopupMenuItem,
|
|
1098
1104
|
onToggleItemCheck,
|
|
1099
1105
|
registerItemRef,
|
|
1100
1106
|
resolvedActiveId,
|
|
@@ -1126,6 +1132,7 @@ function ListBoxGroupView({
|
|
|
1126
1132
|
itemId,
|
|
1127
1133
|
onActivate: onActivateItem,
|
|
1128
1134
|
onDoubleClick: onDoubleClickItem,
|
|
1135
|
+
onPopupMenu: onPopupMenuItem,
|
|
1129
1136
|
onToggleCheck: onToggleItemCheck,
|
|
1130
1137
|
registerItemRef,
|
|
1131
1138
|
rightCheckBox,
|
|
@@ -1144,6 +1151,7 @@ function ListBoxInner({
|
|
|
1144
1151
|
data,
|
|
1145
1152
|
checkedIds,
|
|
1146
1153
|
emptyText = "No items",
|
|
1154
|
+
onPopupMenu,
|
|
1147
1155
|
onItemCheckChange,
|
|
1148
1156
|
onItemDoubleClick,
|
|
1149
1157
|
onItemSelect,
|
|
@@ -1203,6 +1211,18 @@ function ListBoxInner({
|
|
|
1203
1211
|
},
|
|
1204
1212
|
[activateItem, selectableItems]
|
|
1205
1213
|
);
|
|
1214
|
+
const handleItemPopupMenu = (0, import_react5.useCallback)(
|
|
1215
|
+
(event, item, group, itemId) => {
|
|
1216
|
+
if (item.disabled || !onPopupMenu) {
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
event.preventDefault();
|
|
1220
|
+
event.stopPropagation();
|
|
1221
|
+
activateItem(item, group, itemId);
|
|
1222
|
+
onPopupMenu(event, item, group);
|
|
1223
|
+
},
|
|
1224
|
+
[activateItem, onPopupMenu]
|
|
1225
|
+
);
|
|
1206
1226
|
function moveActive(direction) {
|
|
1207
1227
|
if (selectableItems.length === 0) {
|
|
1208
1228
|
return;
|
|
@@ -1323,6 +1343,7 @@ function ListBoxInner({
|
|
|
1323
1343
|
listboxId,
|
|
1324
1344
|
onActivateItem: activateItem,
|
|
1325
1345
|
onDoubleClickItem: onItemDoubleClick,
|
|
1346
|
+
onPopupMenuItem: handleItemPopupMenu,
|
|
1326
1347
|
onToggleItemCheck: toggleItemCheck,
|
|
1327
1348
|
registerItemRef,
|
|
1328
1349
|
resolvedActiveId,
|
|
@@ -1998,8 +2019,6 @@ function WindowInner({
|
|
|
1998
2019
|
return;
|
|
1999
2020
|
}
|
|
2000
2021
|
onActivate?.();
|
|
2001
|
-
event.preventDefault();
|
|
2002
|
-
event.stopPropagation();
|
|
2003
2022
|
}
|
|
2004
2023
|
function handleTitlePointerDown(event) {
|
|
2005
2024
|
onActivate?.();
|
|
@@ -4495,7 +4514,7 @@ function PopupMenu({
|
|
|
4495
4514
|
ref: rootRef,
|
|
4496
4515
|
style: {
|
|
4497
4516
|
...getThemePortalStyle(
|
|
4498
|
-
anchor
|
|
4517
|
+
anchor.type === "element" ? anchor.element : anchor.themeSource ?? null
|
|
4499
4518
|
),
|
|
4500
4519
|
...styleProp,
|
|
4501
4520
|
left: 0,
|
|
@@ -4528,8 +4547,9 @@ function usePopupMenu() {
|
|
|
4528
4547
|
function close() {
|
|
4529
4548
|
setOpen(false);
|
|
4530
4549
|
}
|
|
4531
|
-
function openAtPoint(x, y) {
|
|
4550
|
+
function openAtPoint(x, y, themeSource) {
|
|
4532
4551
|
setAnchor({
|
|
4552
|
+
themeSource,
|
|
4533
4553
|
type: "point",
|
|
4534
4554
|
x,
|
|
4535
4555
|
y
|
|
@@ -4548,7 +4568,7 @@ function usePopupMenu() {
|
|
|
4548
4568
|
}
|
|
4549
4569
|
function openFromContextMenu(event) {
|
|
4550
4570
|
event.preventDefault();
|
|
4551
|
-
openAtPoint(event.clientX, event.clientY);
|
|
4571
|
+
openAtPoint(event.clientX, event.clientY, event.currentTarget);
|
|
4552
4572
|
}
|
|
4553
4573
|
return {
|
|
4554
4574
|
anchor,
|
|
@@ -4582,6 +4602,7 @@ function useNuIconGridContext() {
|
|
|
4582
4602
|
// src/components/IconGrid/NuIconGrid.tsx
|
|
4583
4603
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
4584
4604
|
var DRAG_THRESHOLD = 3;
|
|
4605
|
+
var gridRegistrations = /* @__PURE__ */ new Map();
|
|
4585
4606
|
function clamp2(value, minimum, maximum) {
|
|
4586
4607
|
return Math.min(Math.max(value, minimum), maximum);
|
|
4587
4608
|
}
|
|
@@ -4591,11 +4612,85 @@ function resolveIconContextMenuItems(source, icon) {
|
|
|
4591
4612
|
function resolveGridContextMenuItems(source, manager) {
|
|
4592
4613
|
return typeof source === "function" ? source(manager) : source ?? [];
|
|
4593
4614
|
}
|
|
4594
|
-
function
|
|
4615
|
+
function findGridRegistrationAtPoint(clientX, clientY) {
|
|
4616
|
+
const target = document.elementFromPoint(clientX, clientY);
|
|
4617
|
+
const gridElement = target?.closest(".nu-icon-grid");
|
|
4618
|
+
if (gridElement) {
|
|
4619
|
+
return gridRegistrations.get(gridElement);
|
|
4620
|
+
}
|
|
4621
|
+
if (target?.closest(".nu-window")) {
|
|
4622
|
+
return void 0;
|
|
4623
|
+
}
|
|
4624
|
+
return Array.from(gridRegistrations.values()).reverse().find((registration) => {
|
|
4625
|
+
if (!registration.dropTarget) {
|
|
4626
|
+
return false;
|
|
4627
|
+
}
|
|
4628
|
+
const rect = registration.element.getBoundingClientRect();
|
|
4629
|
+
return clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;
|
|
4630
|
+
});
|
|
4631
|
+
}
|
|
4632
|
+
function getTransferredPosition(targetGrid, iconElement, clientX, clientY) {
|
|
4633
|
+
const targetRect = targetGrid.getBoundingClientRect();
|
|
4634
|
+
const iconRect = iconElement.getBoundingClientRect();
|
|
4635
|
+
return {
|
|
4636
|
+
x: Math.round(
|
|
4637
|
+
clamp2(
|
|
4638
|
+
clientX - targetRect.left - iconRect.width / 2,
|
|
4639
|
+
0,
|
|
4640
|
+
Math.max(0, targetRect.width - iconRect.width)
|
|
4641
|
+
)
|
|
4642
|
+
),
|
|
4643
|
+
y: Math.round(
|
|
4644
|
+
clamp2(
|
|
4645
|
+
clientY - targetRect.top - iconRect.height / 2,
|
|
4646
|
+
0,
|
|
4647
|
+
Math.max(0, targetRect.height - iconRect.height)
|
|
4648
|
+
)
|
|
4649
|
+
)
|
|
4650
|
+
};
|
|
4651
|
+
}
|
|
4652
|
+
function createDragPreview(iconElement) {
|
|
4653
|
+
const rect = iconElement.getBoundingClientRect();
|
|
4654
|
+
const preview = iconElement.cloneNode(true);
|
|
4655
|
+
preview.removeAttribute("id");
|
|
4656
|
+
preview.setAttribute("aria-hidden", "true");
|
|
4657
|
+
preview.setAttribute("disabled", "");
|
|
4658
|
+
preview.setAttribute("tabindex", "-1");
|
|
4659
|
+
Object.assign(preview.style, {
|
|
4660
|
+
height: `${rect.height}px`,
|
|
4661
|
+
left: `${rect.left}px`,
|
|
4662
|
+
margin: "0",
|
|
4663
|
+
opacity: window.getComputedStyle(iconElement).getPropertyValue("--nu-icon-grid-icon-drag-preview-opacity").trim() || "0.85",
|
|
4664
|
+
pointerEvents: "none",
|
|
4665
|
+
position: "fixed",
|
|
4666
|
+
top: `${rect.top}px`,
|
|
4667
|
+
width: `${rect.width}px`,
|
|
4668
|
+
zIndex: "2147483647"
|
|
4669
|
+
});
|
|
4670
|
+
const themeStyle = getThemePortalStyle(iconElement);
|
|
4671
|
+
Object.entries(themeStyle ?? {}).forEach(([property, value]) => {
|
|
4672
|
+
if (value !== void 0) {
|
|
4673
|
+
preview.style.setProperty(property, String(value));
|
|
4674
|
+
}
|
|
4675
|
+
});
|
|
4676
|
+
document.body.append(preview);
|
|
4677
|
+
return preview;
|
|
4678
|
+
}
|
|
4679
|
+
function moveDragPreview(preview, iconElement, clientX, clientY) {
|
|
4680
|
+
const rect = iconElement.getBoundingClientRect();
|
|
4681
|
+
preview.style.left = `${Math.round(clientX - rect.width / 2)}px`;
|
|
4682
|
+
preview.style.top = `${Math.round(clientY - rect.height / 2)}px`;
|
|
4683
|
+
}
|
|
4684
|
+
function NuIconGridItem({
|
|
4685
|
+
gridElement,
|
|
4686
|
+
icon,
|
|
4687
|
+
onIconMoveOut
|
|
4688
|
+
}) {
|
|
4595
4689
|
const manager = useNuIconGridContext();
|
|
4596
4690
|
const contextMenu = usePopupMenu();
|
|
4597
4691
|
const dragStartRef = (0, import_react25.useRef)(void 0);
|
|
4598
4692
|
const isDraggingRef = (0, import_react25.useRef)(false);
|
|
4693
|
+
const dragPreviewRef = (0, import_react25.useRef)(null);
|
|
4599
4694
|
const [isDragging, setIsDragging] = (0, import_react25.useState)(false);
|
|
4600
4695
|
const suppressClickRef = (0, import_react25.useRef)(false);
|
|
4601
4696
|
const latestPositionRef = (0, import_react25.useRef)(icon.position);
|
|
@@ -4603,6 +4698,11 @@ function NuIconGridItem({ gridElement, icon }) {
|
|
|
4603
4698
|
icon.contextMenuItems,
|
|
4604
4699
|
icon
|
|
4605
4700
|
);
|
|
4701
|
+
function removeDragPreview() {
|
|
4702
|
+
dragPreviewRef.current?.remove();
|
|
4703
|
+
dragPreviewRef.current = null;
|
|
4704
|
+
}
|
|
4705
|
+
(0, import_react25.useEffect)(() => removeDragPreview, []);
|
|
4606
4706
|
function handlePointerDown(event) {
|
|
4607
4707
|
if (event.button !== 0 || icon.disabled) {
|
|
4608
4708
|
return;
|
|
@@ -4628,8 +4728,19 @@ function NuIconGridItem({ gridElement, icon }) {
|
|
|
4628
4728
|
if (!isDraggingRef.current && Math.max(Math.abs(deltaX), Math.abs(deltaY)) < DRAG_THRESHOLD) {
|
|
4629
4729
|
return;
|
|
4630
4730
|
}
|
|
4631
|
-
isDraggingRef.current
|
|
4632
|
-
|
|
4731
|
+
if (!isDraggingRef.current) {
|
|
4732
|
+
isDraggingRef.current = true;
|
|
4733
|
+
setIsDragging(true);
|
|
4734
|
+
dragPreviewRef.current = createDragPreview(event.currentTarget);
|
|
4735
|
+
}
|
|
4736
|
+
if (dragPreviewRef.current) {
|
|
4737
|
+
moveDragPreview(
|
|
4738
|
+
dragPreviewRef.current,
|
|
4739
|
+
event.currentTarget,
|
|
4740
|
+
event.clientX,
|
|
4741
|
+
event.clientY
|
|
4742
|
+
);
|
|
4743
|
+
}
|
|
4633
4744
|
const gridRect = gridElement.getBoundingClientRect();
|
|
4634
4745
|
const iconRect = event.currentTarget.getBoundingClientRect();
|
|
4635
4746
|
const position = {
|
|
@@ -4649,7 +4760,6 @@ function NuIconGridItem({ gridElement, icon }) {
|
|
|
4649
4760
|
)
|
|
4650
4761
|
};
|
|
4651
4762
|
latestPositionRef.current = position;
|
|
4652
|
-
manager.moveIcon(icon.id, position);
|
|
4653
4763
|
}
|
|
4654
4764
|
function finishDragging(event) {
|
|
4655
4765
|
const dragStart = dragStartRef.current;
|
|
@@ -4660,16 +4770,56 @@ function NuIconGridItem({ gridElement, icon }) {
|
|
|
4660
4770
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
4661
4771
|
}
|
|
4662
4772
|
dragStartRef.current = void 0;
|
|
4773
|
+
removeDragPreview();
|
|
4663
4774
|
if (!isDraggingRef.current) {
|
|
4664
4775
|
return;
|
|
4665
4776
|
}
|
|
4666
4777
|
suppressClickRef.current = true;
|
|
4667
4778
|
isDraggingRef.current = false;
|
|
4668
4779
|
setIsDragging(false);
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4780
|
+
if (event.type === "pointercancel" || !gridElement) {
|
|
4781
|
+
return;
|
|
4782
|
+
}
|
|
4783
|
+
const targetRegistration = findGridRegistrationAtPoint(
|
|
4784
|
+
event.clientX,
|
|
4785
|
+
event.clientY
|
|
4786
|
+
);
|
|
4787
|
+
if (!targetRegistration) {
|
|
4788
|
+
return;
|
|
4789
|
+
}
|
|
4790
|
+
if (targetRegistration.element === gridElement) {
|
|
4791
|
+
manager.moveIcon(icon.id, latestPositionRef.current);
|
|
4792
|
+
icon.onPositionChange?.(latestPositionRef.current, {
|
|
4793
|
+
...icon,
|
|
4794
|
+
position: latestPositionRef.current
|
|
4795
|
+
});
|
|
4796
|
+
return;
|
|
4797
|
+
}
|
|
4798
|
+
if (!targetRegistration.manager.icons.some(
|
|
4799
|
+
(targetIcon) => targetIcon.id === icon.id
|
|
4800
|
+
)) {
|
|
4801
|
+
const position = getTransferredPosition(
|
|
4802
|
+
targetRegistration.element,
|
|
4803
|
+
event.currentTarget,
|
|
4804
|
+
event.clientX,
|
|
4805
|
+
event.clientY
|
|
4806
|
+
);
|
|
4807
|
+
const transferredIcon = { ...icon, position };
|
|
4808
|
+
const context = {
|
|
4809
|
+
position,
|
|
4810
|
+
source: manager,
|
|
4811
|
+
sourceGrid: gridElement,
|
|
4812
|
+
target: targetRegistration.manager,
|
|
4813
|
+
targetGrid: targetRegistration.element
|
|
4814
|
+
};
|
|
4815
|
+
if (targetRegistration.accepts?.(transferredIcon) !== false && targetRegistration.onIconDrop?.(transferredIcon, context) !== false) {
|
|
4816
|
+
targetRegistration.manager.addIcon(transferredIcon);
|
|
4817
|
+
targetRegistration.manager.selectIcon(transferredIcon.id);
|
|
4818
|
+
manager.removeIcon(icon.id);
|
|
4819
|
+
onIconMoveOut?.(transferredIcon, context);
|
|
4820
|
+
return;
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4673
4823
|
}
|
|
4674
4824
|
function handleClick(event) {
|
|
4675
4825
|
if (suppressClickRef.current) {
|
|
@@ -4688,7 +4838,7 @@ function NuIconGridItem({ gridElement, icon }) {
|
|
|
4688
4838
|
return;
|
|
4689
4839
|
}
|
|
4690
4840
|
event.preventDefault();
|
|
4691
|
-
contextMenu.openAtPoint(event.clientX, event.clientY);
|
|
4841
|
+
contextMenu.openAtPoint(event.clientX, event.clientY, event.currentTarget);
|
|
4692
4842
|
}
|
|
4693
4843
|
function handleKeyDown(event) {
|
|
4694
4844
|
if (event.key !== "ContextMenu" && !(event.key === "F10" && event.shiftKey) || contextMenuItems.length === 0) {
|
|
@@ -4735,9 +4885,13 @@ function NuIconGridItem({ gridElement, icon }) {
|
|
|
4735
4885
|
] });
|
|
4736
4886
|
}
|
|
4737
4887
|
function NuIconGrid({
|
|
4888
|
+
accepts,
|
|
4738
4889
|
className,
|
|
4739
4890
|
contextMenuItems: contextMenuItemsSource,
|
|
4740
4891
|
defaultArrangeMode,
|
|
4892
|
+
dropTarget = false,
|
|
4893
|
+
onIconDrop,
|
|
4894
|
+
onIconMoveOut,
|
|
4741
4895
|
onContextMenu,
|
|
4742
4896
|
onPointerDown,
|
|
4743
4897
|
...props
|
|
@@ -4773,6 +4927,21 @@ function NuIconGrid({
|
|
|
4773
4927
|
resizeObserver.observe(gridElement);
|
|
4774
4928
|
return () => resizeObserver.disconnect();
|
|
4775
4929
|
}, [arrangeIcons, defaultArrangeMode, gridElement, setGridSize]);
|
|
4930
|
+
(0, import_react25.useLayoutEffect)(() => {
|
|
4931
|
+
if (!gridElement) {
|
|
4932
|
+
return;
|
|
4933
|
+
}
|
|
4934
|
+
gridRegistrations.set(gridElement, {
|
|
4935
|
+
accepts,
|
|
4936
|
+
dropTarget,
|
|
4937
|
+
element: gridElement,
|
|
4938
|
+
manager,
|
|
4939
|
+
onIconDrop
|
|
4940
|
+
});
|
|
4941
|
+
return () => {
|
|
4942
|
+
gridRegistrations.delete(gridElement);
|
|
4943
|
+
};
|
|
4944
|
+
}, [accepts, dropTarget, gridElement, manager, onIconDrop]);
|
|
4776
4945
|
function handleContextMenu(event) {
|
|
4777
4946
|
onContextMenu?.(event);
|
|
4778
4947
|
if (event.defaultPrevented || contextMenuItems.length === 0) {
|
|
@@ -4780,7 +4949,7 @@ function NuIconGrid({
|
|
|
4780
4949
|
}
|
|
4781
4950
|
event.preventDefault();
|
|
4782
4951
|
manager.selectIcon(null);
|
|
4783
|
-
contextMenu.openAtPoint(event.clientX, event.clientY);
|
|
4952
|
+
contextMenu.openAtPoint(event.clientX, event.clientY, event.currentTarget);
|
|
4784
4953
|
}
|
|
4785
4954
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
4786
4955
|
"div",
|
|
@@ -4801,7 +4970,15 @@ function NuIconGrid({
|
|
|
4801
4970
|
ref: setGridElement,
|
|
4802
4971
|
role: "group",
|
|
4803
4972
|
children: [
|
|
4804
|
-
manager.icons.map((icon) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
4973
|
+
manager.icons.map((icon) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
4974
|
+
NuIconGridItem,
|
|
4975
|
+
{
|
|
4976
|
+
gridElement,
|
|
4977
|
+
icon,
|
|
4978
|
+
onIconMoveOut
|
|
4979
|
+
},
|
|
4980
|
+
icon.id
|
|
4981
|
+
)),
|
|
4805
4982
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
4806
4983
|
PopupMenu,
|
|
4807
4984
|
{
|
|
@@ -9003,6 +9180,7 @@ function TreeListViewRowInner({
|
|
|
9003
9180
|
item,
|
|
9004
9181
|
onActivateItem,
|
|
9005
9182
|
onDoubleClickItem,
|
|
9183
|
+
onPopupMenuItem,
|
|
9006
9184
|
onToggleItemCheck,
|
|
9007
9185
|
onToggleItemExpanded,
|
|
9008
9186
|
originOffset,
|
|
@@ -9041,6 +9219,17 @@ function TreeListViewRowInner({
|
|
|
9041
9219
|
}
|
|
9042
9220
|
onDoubleClickItem?.(item);
|
|
9043
9221
|
}
|
|
9222
|
+
function handleContextMenu(event) {
|
|
9223
|
+
if (item.disabled) {
|
|
9224
|
+
return;
|
|
9225
|
+
}
|
|
9226
|
+
onPopupMenuItem?.(event, item, {
|
|
9227
|
+
depth,
|
|
9228
|
+
isLeaf: !hasChildren,
|
|
9229
|
+
item,
|
|
9230
|
+
rowIndex
|
|
9231
|
+
});
|
|
9232
|
+
}
|
|
9044
9233
|
function handleToggleExpanded(event) {
|
|
9045
9234
|
event.stopPropagation();
|
|
9046
9235
|
if (item.disabled || !hasChildren) {
|
|
@@ -9074,6 +9263,7 @@ function TreeListViewRowInner({
|
|
|
9074
9263
|
].filter(Boolean).join(" "),
|
|
9075
9264
|
id: `${treeId}-${itemId}`,
|
|
9076
9265
|
onClick: handleActivate,
|
|
9266
|
+
onContextMenu: onPopupMenuItem ? handleContextMenu : void 0,
|
|
9077
9267
|
onDoubleClick: handleDoubleClick,
|
|
9078
9268
|
ref: (node) => registerItemRef(itemId, node),
|
|
9079
9269
|
role: "row",
|
|
@@ -9222,6 +9412,7 @@ function TreeListViewRowInner({
|
|
|
9222
9412
|
item: child,
|
|
9223
9413
|
onActivateItem,
|
|
9224
9414
|
onDoubleClickItem,
|
|
9415
|
+
onPopupMenuItem,
|
|
9225
9416
|
onToggleItemCheck,
|
|
9226
9417
|
onToggleItemExpanded,
|
|
9227
9418
|
originOffset: originOffset + leadOffset,
|
|
@@ -9243,7 +9434,7 @@ function areTreeListViewRowPropsEqual(previousProps, nextProps) {
|
|
|
9243
9434
|
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(
|
|
9244
9435
|
previousProps.guideOffsets,
|
|
9245
9436
|
nextProps.guideOffsets
|
|
9246
|
-
) && 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;
|
|
9437
|
+
) && 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;
|
|
9247
9438
|
}
|
|
9248
9439
|
var TreeListViewRow = (0, import_react44.memo)(
|
|
9249
9440
|
TreeListViewRowInner,
|
|
@@ -9257,6 +9448,7 @@ function TreeListViewInner({
|
|
|
9257
9448
|
checkedIds,
|
|
9258
9449
|
className,
|
|
9259
9450
|
columns,
|
|
9451
|
+
onPopupMenu,
|
|
9260
9452
|
data,
|
|
9261
9453
|
dataVersion,
|
|
9262
9454
|
defaultActiveItemId,
|
|
@@ -9426,6 +9618,18 @@ function TreeListViewInner({
|
|
|
9426
9618
|
},
|
|
9427
9619
|
[onItemSelect, selectedId, updateActiveItem]
|
|
9428
9620
|
);
|
|
9621
|
+
const handleItemPopupMenu = (0, import_react45.useCallback)(
|
|
9622
|
+
(event, item, context) => {
|
|
9623
|
+
if (item.disabled || !onPopupMenu) {
|
|
9624
|
+
return;
|
|
9625
|
+
}
|
|
9626
|
+
event.preventDefault();
|
|
9627
|
+
event.stopPropagation();
|
|
9628
|
+
activateEntry(item, item.id);
|
|
9629
|
+
onPopupMenu(event, item, context);
|
|
9630
|
+
},
|
|
9631
|
+
[activateEntry, onPopupMenu]
|
|
9632
|
+
);
|
|
9429
9633
|
const activateResolvedItem = (0, import_react45.useCallback)(
|
|
9430
9634
|
(itemId) => {
|
|
9431
9635
|
if (!itemId) {
|
|
@@ -9731,6 +9935,7 @@ function TreeListViewInner({
|
|
|
9731
9935
|
item,
|
|
9732
9936
|
onActivateItem: activateEntry,
|
|
9733
9937
|
onDoubleClickItem: onItemDoubleClick ? handleItemDoubleClick : void 0,
|
|
9938
|
+
onPopupMenuItem: handleItemPopupMenu,
|
|
9734
9939
|
onToggleItemCheck: handleItemCheckChange,
|
|
9735
9940
|
onToggleItemExpanded: setExpandedState,
|
|
9736
9941
|
originOffset: 0,
|
|
@@ -9767,10 +9972,12 @@ var classicTheme = {
|
|
|
9767
9972
|
panelBackground: "#6262e3",
|
|
9768
9973
|
panelInsetBackground: "#6262e3",
|
|
9769
9974
|
titleBackground: "#ffffff",
|
|
9975
|
+
menuBackground: "#ffffff",
|
|
9770
9976
|
titleText: "#1f36bc",
|
|
9771
9977
|
textPrimary: "#ffffff",
|
|
9772
9978
|
textMuted: "#dfe3ff",
|
|
9773
9979
|
textInverse: "#000000",
|
|
9980
|
+
mainMenuText: "#000000",
|
|
9774
9981
|
textAccent: "#ffff55",
|
|
9775
9982
|
textHotkey: "#ff5555",
|
|
9776
9983
|
buttonFace: "#ffffff",
|
|
@@ -9803,10 +10010,12 @@ var amberTheme = {
|
|
|
9803
10010
|
panelBackground: "#4b2b00",
|
|
9804
10011
|
panelInsetBackground: "#382000",
|
|
9805
10012
|
titleBackground: "#ffd28f",
|
|
10013
|
+
menuBackground: "#ffd28f",
|
|
9806
10014
|
titleText: "#4b2b00",
|
|
9807
10015
|
textPrimary: "#ffd28f",
|
|
9808
10016
|
textMuted: "#d6b57a",
|
|
9809
10017
|
textInverse: "#201000",
|
|
10018
|
+
mainMenuText: "#201000",
|
|
9810
10019
|
textAccent: "#fff27a",
|
|
9811
10020
|
textHotkey: "#ff5f00",
|
|
9812
10021
|
buttonFace: "#ffd28f",
|
|
@@ -9839,10 +10048,12 @@ var phosphorTheme = {
|
|
|
9839
10048
|
panelBackground: "#11351a",
|
|
9840
10049
|
panelInsetBackground: "#0d2813",
|
|
9841
10050
|
titleBackground: "#b7ffbf",
|
|
10051
|
+
menuBackground: "#b7ffbf",
|
|
9842
10052
|
titleText: "#0b2310",
|
|
9843
10053
|
textPrimary: "#b7ffbf",
|
|
9844
10054
|
textMuted: "#8ed39a",
|
|
9845
10055
|
textInverse: "#061208",
|
|
10056
|
+
mainMenuText: "#061208",
|
|
9846
10057
|
textAccent: "#f7ff7a",
|
|
9847
10058
|
textHotkey: "#ff6f6f",
|
|
9848
10059
|
buttonFace: "#b7ffbf",
|
|
@@ -9875,10 +10086,12 @@ var midnightTheme = {
|
|
|
9875
10086
|
panelBackground: "#17273b",
|
|
9876
10087
|
panelInsetBackground: "#111e2e",
|
|
9877
10088
|
titleBackground: "#d4dde8",
|
|
10089
|
+
menuBackground: "#d4dde8",
|
|
9878
10090
|
titleText: "#14233a",
|
|
9879
10091
|
textPrimary: "#e6edf7",
|
|
9880
10092
|
textMuted: "#aebdcd",
|
|
9881
10093
|
textInverse: "#0b1220",
|
|
10094
|
+
mainMenuText: "#0b1220",
|
|
9882
10095
|
textAccent: "#ffd166",
|
|
9883
10096
|
textHotkey: "#ff7171",
|
|
9884
10097
|
buttonFace: "#d4dde8",
|
|
@@ -9898,11 +10111,50 @@ var midnightTheme = {
|
|
|
9898
10111
|
windowModalBackdrop: "rgb(7 12 20 / 0.48)"
|
|
9899
10112
|
}
|
|
9900
10113
|
};
|
|
10114
|
+
var grayscaleTheme = {
|
|
10115
|
+
name: "grayscale",
|
|
10116
|
+
label: "Grayscale Monitor",
|
|
10117
|
+
tokens: {
|
|
10118
|
+
desktopBackground: "#808080",
|
|
10119
|
+
desktopPattern: "rgb(0 0 0 / 0.3)",
|
|
10120
|
+
shellBackground: "#202020",
|
|
10121
|
+
appBackground: "#3f3f3f",
|
|
10122
|
+
appBackgroundAlt: "#2b2b2b",
|
|
10123
|
+
chromeBackground: "#727272",
|
|
10124
|
+
panelBackground: "#3f3f3f",
|
|
10125
|
+
panelInsetBackground: "#343434",
|
|
10126
|
+
titleBackground: "#262626",
|
|
10127
|
+
menuBackground: "#262626",
|
|
10128
|
+
titleText: "#d0d0d0",
|
|
10129
|
+
textPrimary: "#c8c8c8",
|
|
10130
|
+
textMuted: "#969696",
|
|
10131
|
+
textInverse: "#d0d0d0",
|
|
10132
|
+
mainMenuText: "#d0d0d0",
|
|
10133
|
+
textAccent: "#e0e0e0",
|
|
10134
|
+
textHotkey: "#ffffff",
|
|
10135
|
+
buttonFace: "#5b5b5b",
|
|
10136
|
+
buttonFaceAlt: "#414141",
|
|
10137
|
+
buttonDanger: "#303030",
|
|
10138
|
+
buttonSuccess: "#6b6b6b",
|
|
10139
|
+
buttonText: "#d0d0d0",
|
|
10140
|
+
fieldBackground: "#0e0e0e",
|
|
10141
|
+
fieldText: "#d8d8d8",
|
|
10142
|
+
borderLight: "#c7c7c7",
|
|
10143
|
+
borderDark: "#000000",
|
|
10144
|
+
borderAccent: "#ffffff",
|
|
10145
|
+
shadowColor: "#000000",
|
|
10146
|
+
panelShadowColor: "rgb(0 0 0 / 0.5)",
|
|
10147
|
+
focusColor: "#ffffff",
|
|
10148
|
+
windowInactiveOverlay: "rgb(0 0 0 / 0.34)",
|
|
10149
|
+
windowModalBackdrop: "rgb(0 0 0 / 0.5)"
|
|
10150
|
+
}
|
|
10151
|
+
};
|
|
9901
10152
|
var nuThemes = {
|
|
9902
10153
|
classic: classicTheme,
|
|
9903
10154
|
amber: amberTheme,
|
|
9904
10155
|
phosphor: phosphorTheme,
|
|
9905
|
-
midnight: midnightTheme
|
|
10156
|
+
midnight: midnightTheme,
|
|
10157
|
+
grayscale: grayscaleTheme
|
|
9906
10158
|
};
|
|
9907
10159
|
function isNuThemeName(value) {
|
|
9908
10160
|
return value in nuThemes;
|
|
@@ -9921,10 +10173,12 @@ function getNuThemeStyle(theme) {
|
|
|
9921
10173
|
"--nu-color-panel": theme.tokens.panelBackground,
|
|
9922
10174
|
"--nu-color-panel-inset": theme.tokens.panelInsetBackground,
|
|
9923
10175
|
"--nu-color-title-bg": theme.tokens.titleBackground,
|
|
10176
|
+
"--nu-color-menu": theme.tokens.menuBackground,
|
|
9924
10177
|
"--nu-color-title-text": theme.tokens.titleText,
|
|
9925
10178
|
"--nu-text-primary": theme.tokens.textPrimary,
|
|
9926
10179
|
"--nu-text-muted": theme.tokens.textMuted,
|
|
9927
10180
|
"--nu-text-inverse": theme.tokens.textInverse,
|
|
10181
|
+
"--nu-main-menu-text": theme.tokens.mainMenuText,
|
|
9928
10182
|
"--nu-text-accent": theme.tokens.textAccent,
|
|
9929
10183
|
"--nu-text-hotkey": theme.tokens.textHotkey,
|
|
9930
10184
|
"--nu-color-button-face": theme.tokens.buttonFace,
|
|
@@ -10008,6 +10262,7 @@ function NuThemeProvider({
|
|
|
10008
10262
|
onFontFamilyChange,
|
|
10009
10263
|
onFontSizeChange,
|
|
10010
10264
|
onThemeChange,
|
|
10265
|
+
style,
|
|
10011
10266
|
theme
|
|
10012
10267
|
}) {
|
|
10013
10268
|
const generatedId = (0, import_react47.useId)();
|
|
@@ -10093,7 +10348,8 @@ function NuThemeProvider({
|
|
|
10093
10348
|
...getNuThemeStyle(resolvedTheme),
|
|
10094
10349
|
"--nu-font-body": resolvedFontFamily,
|
|
10095
10350
|
fontFamily: resolvedFontFamily,
|
|
10096
|
-
fontSize: `${resolvedFontSize}px
|
|
10351
|
+
fontSize: `${resolvedFontSize}px`,
|
|
10352
|
+
...style
|
|
10097
10353
|
},
|
|
10098
10354
|
children: [
|
|
10099
10355
|
crtGlitch ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(NuCrtGlitch, { ...typeof crtGlitch === "object" ? crtGlitch : {} }) : null,
|