@deadragdoll/reactnu 0.1.73 → 0.1.75
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/DragDrop/NuDragDropProvider.d.ts +24 -17
- package/dist/components/IconGrid/NuIconGrid.d.ts +9 -5
- package/dist/components/ListBox/ListBox.d.ts +6 -4
- package/dist/components/ListBox/internals/ListBoxGroupView.d.ts +3 -2
- package/dist/components/ListBox/internals/ListBoxItemView.d.ts +3 -2
- package/dist/components/ListView/ListView.d.ts +13 -2
- package/dist/components/ListView/internals/ListViewRow.d.ts +6 -1
- package/dist/components/TreeListView/TreeListView.d.ts +8 -4
- package/dist/components/TreeListView/internals/TreeListViewRow.d.ts +3 -2
- package/dist/index.cjs +393 -382
- package/dist/index.js +653 -636
- package/docs/API_REFERENCE.md +4 -1
- package/docs/GETTING_STARTED.md +1 -1
- package/docs/IconGrid.md +4 -4
- package/docs/ListBox.md +3 -0
- package/docs/ListView.md +10 -0
- package/docs/NuDragDropProvider.md +39 -6
- package/docs/TreeListView.md +8 -0
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -734,10 +734,10 @@ function toggleMenuCheckedInTree(items, id) {
|
|
|
734
734
|
}
|
|
735
735
|
|
|
736
736
|
// src/appHost/NuAppHostProvider.tsx
|
|
737
|
-
import { useMemo as
|
|
737
|
+
import { useMemo as useMemo4, useState as useState7 } from "react";
|
|
738
738
|
|
|
739
739
|
// src/windowing/internals/MdiWindowPickerDialog.tsx
|
|
740
|
-
import { useMemo as
|
|
740
|
+
import { useMemo as useMemo3, useState as useState6 } from "react";
|
|
741
741
|
|
|
742
742
|
// src/components/Button/Button.tsx
|
|
743
743
|
import {
|
|
@@ -897,11 +897,11 @@ function Button({
|
|
|
897
897
|
// src/components/ListBox/ListBox.tsx
|
|
898
898
|
import {
|
|
899
899
|
forwardRef,
|
|
900
|
-
useCallback as
|
|
900
|
+
useCallback as useCallback3,
|
|
901
901
|
useEffect as useEffect4,
|
|
902
902
|
useId,
|
|
903
903
|
useImperativeHandle,
|
|
904
|
-
useMemo as
|
|
904
|
+
useMemo as useMemo2,
|
|
905
905
|
useRef as useRef5,
|
|
906
906
|
useState as useState5
|
|
907
907
|
} from "react";
|
|
@@ -976,232 +976,179 @@ import { memo } from "react";
|
|
|
976
976
|
|
|
977
977
|
// src/components/DragDrop/NuDragDropProvider.tsx
|
|
978
978
|
import {
|
|
979
|
-
|
|
979
|
+
useCallback as useCallback2,
|
|
980
980
|
useContext,
|
|
981
981
|
useEffect as useEffect3,
|
|
982
|
-
useMemo as useMemo2,
|
|
983
982
|
useRef as useRef4
|
|
984
983
|
} from "react";
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
984
|
+
import {
|
|
985
|
+
DndProvider,
|
|
986
|
+
DndContext,
|
|
987
|
+
useDrag,
|
|
988
|
+
useDragDropManager,
|
|
989
|
+
useDragLayer,
|
|
990
|
+
useDrop
|
|
991
|
+
} from "react-dnd";
|
|
992
|
+
import { getEmptyImage, HTML5Backend } from "react-dnd-html5-backend";
|
|
993
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
994
|
+
var NU_DRAG_ITEM_TYPE = "reactnu-shared-item";
|
|
995
|
+
function getDropContext(item, element, type, clientOffset) {
|
|
996
|
+
return {
|
|
997
|
+
clientX: clientOffset?.x ?? 0,
|
|
998
|
+
clientY: clientOffset?.y ?? 0,
|
|
999
|
+
source: {
|
|
1000
|
+
element: item.sourceElement ?? element,
|
|
1001
|
+
type: item.sourceType
|
|
1002
|
+
},
|
|
1003
|
+
target: { element, type }
|
|
1000
1004
|
};
|
|
1001
|
-
for (const propertyName of computed) {
|
|
1002
|
-
if (propertyName.startsWith("--nu-")) {
|
|
1003
|
-
style[propertyName] = computed.getPropertyValue(propertyName).trim();
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
return style;
|
|
1007
1005
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
preview.setAttribute("aria-hidden", "true");
|
|
1017
|
-
Object.assign(preview.style, {
|
|
1018
|
-
height: `${rect.height}px`,
|
|
1019
|
-
left: `${rect.left}px`,
|
|
1020
|
-
margin: "0",
|
|
1021
|
-
opacity: "0.85",
|
|
1022
|
-
pointerEvents: "none",
|
|
1023
|
-
position: "fixed",
|
|
1024
|
-
top: `${rect.top}px`,
|
|
1025
|
-
width: `${rect.width}px`,
|
|
1026
|
-
zIndex: "2147483647"
|
|
1027
|
-
});
|
|
1028
|
-
const themeStyle = getThemePortalStyle(sourceElement);
|
|
1029
|
-
Object.entries(themeStyle ?? {}).forEach(([property, value]) => {
|
|
1030
|
-
if (value !== void 0) {
|
|
1031
|
-
preview.style.setProperty(property, String(value));
|
|
1032
|
-
}
|
|
1033
|
-
});
|
|
1034
|
-
document.body.append(preview);
|
|
1035
|
-
return preview;
|
|
1036
|
-
}
|
|
1037
|
-
function createController() {
|
|
1038
|
-
const targets = /* @__PURE__ */ new Map();
|
|
1039
|
-
let activeDrag = null;
|
|
1040
|
-
function findTarget(clientX, clientY) {
|
|
1041
|
-
const elementAtPoint = document.elementFromPoint(clientX, clientY);
|
|
1042
|
-
let candidate = elementAtPoint;
|
|
1043
|
-
while (candidate) {
|
|
1044
|
-
const target = targets.get(candidate);
|
|
1045
|
-
if (target) {
|
|
1046
|
-
return target;
|
|
1047
|
-
}
|
|
1048
|
-
candidate = candidate.parentElement;
|
|
1049
|
-
}
|
|
1050
|
-
return Array.from(targets.values()).reverse().find((target) => {
|
|
1051
|
-
const rect = target.element.getBoundingClientRect();
|
|
1052
|
-
return clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
function clearActiveDrag() {
|
|
1056
|
-
activeDrag?.preview.remove();
|
|
1057
|
-
activeDrag = null;
|
|
1006
|
+
function NuDragPreviewLayer() {
|
|
1007
|
+
const { isDragging, item, offset } = useDragLayer((monitor) => ({
|
|
1008
|
+
isDragging: monitor.isDragging(),
|
|
1009
|
+
item: monitor.getItem() ?? null,
|
|
1010
|
+
offset: monitor.getClientOffset()
|
|
1011
|
+
}));
|
|
1012
|
+
if (!isDragging || !item?.preview || !offset) {
|
|
1013
|
+
return null;
|
|
1058
1014
|
}
|
|
1059
|
-
return
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
if (!currentDrag) {
|
|
1073
|
-
return false;
|
|
1074
|
-
}
|
|
1075
|
-
const target = findTarget(clientX, clientY);
|
|
1076
|
-
clearActiveDrag();
|
|
1077
|
-
if (!target || target.element === currentDrag.sourceElement) {
|
|
1078
|
-
return false;
|
|
1079
|
-
}
|
|
1080
|
-
if (target.accepts?.(currentDrag.item) === false) {
|
|
1081
|
-
return false;
|
|
1082
|
-
}
|
|
1083
|
-
return target.onDrop(currentDrag.item, {
|
|
1084
|
-
clientX,
|
|
1085
|
-
clientY,
|
|
1086
|
-
source: {
|
|
1087
|
-
element: currentDrag.sourceElement,
|
|
1088
|
-
type: currentDrag.sourceType
|
|
1089
|
-
},
|
|
1090
|
-
target: { element: target.element, type: target.type }
|
|
1091
|
-
}) !== false;
|
|
1092
|
-
},
|
|
1093
|
-
moveDrag(clientX, clientY) {
|
|
1094
|
-
const currentDrag = activeDrag;
|
|
1095
|
-
if (!currentDrag) {
|
|
1096
|
-
return;
|
|
1097
|
-
}
|
|
1098
|
-
const rect = currentDrag.sourceElement.getBoundingClientRect();
|
|
1099
|
-
currentDrag.preview.style.left = `${Math.round(clientX - rect.width / 2)}px`;
|
|
1100
|
-
currentDrag.preview.style.top = `${Math.round(clientY - rect.height / 2)}px`;
|
|
1101
|
-
},
|
|
1102
|
-
registerTarget(element, options) {
|
|
1103
|
-
targets.set(element, { ...options, element });
|
|
1104
|
-
return () => targets.delete(element);
|
|
1015
|
+
return /* @__PURE__ */ jsx10(
|
|
1016
|
+
"div",
|
|
1017
|
+
{
|
|
1018
|
+
"aria-hidden": "true",
|
|
1019
|
+
style: {
|
|
1020
|
+
left: 0,
|
|
1021
|
+
pointerEvents: "none",
|
|
1022
|
+
position: "fixed",
|
|
1023
|
+
top: 0,
|
|
1024
|
+
transform: `translate(${Math.round(offset.x + 12)}px, ${Math.round(offset.y + 12)}px)`,
|
|
1025
|
+
zIndex: 2147483647
|
|
1026
|
+
},
|
|
1027
|
+
children: item.preview
|
|
1105
1028
|
}
|
|
1106
|
-
|
|
1029
|
+
);
|
|
1107
1030
|
}
|
|
1108
|
-
var fallbackController = createController();
|
|
1109
|
-
var NuDragDropContext = createContext(null);
|
|
1110
1031
|
function NuDragDropProvider({ children }) {
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1032
|
+
const { dragDropManager } = useContext(DndContext);
|
|
1033
|
+
if (dragDropManager) {
|
|
1034
|
+
return children;
|
|
1035
|
+
}
|
|
1036
|
+
return /* @__PURE__ */ jsxs6(DndProvider, { backend: HTML5Backend, children: [
|
|
1037
|
+
children,
|
|
1038
|
+
/* @__PURE__ */ jsx10(NuDragPreviewLayer, {})
|
|
1039
|
+
] });
|
|
1113
1040
|
}
|
|
1114
1041
|
function useNuDragDrop() {
|
|
1115
|
-
return
|
|
1042
|
+
return useDragDropManager();
|
|
1116
1043
|
}
|
|
1117
1044
|
function useNuDropTarget(element, options) {
|
|
1118
|
-
const
|
|
1045
|
+
const [{ canDrop, isOver, item }, drop] = useDrop(
|
|
1046
|
+
() => ({
|
|
1047
|
+
accept: NU_DRAG_ITEM_TYPE,
|
|
1048
|
+
canDrop: (dragItem) => options ? options.accepts?.(dragItem) !== false : false,
|
|
1049
|
+
collect: (monitor) => ({
|
|
1050
|
+
canDrop: monitor.canDrop(),
|
|
1051
|
+
isOver: monitor.isOver({ shallow: true }),
|
|
1052
|
+
item: monitor.isOver({ shallow: true }) ? monitor.getItem() ?? null : null
|
|
1053
|
+
}),
|
|
1054
|
+
drop: (dragItem, monitor) => {
|
|
1055
|
+
if (!options || monitor.didDrop()) {
|
|
1056
|
+
return void 0;
|
|
1057
|
+
}
|
|
1058
|
+
const result = options.onDrop(
|
|
1059
|
+
dragItem,
|
|
1060
|
+
getDropContext(
|
|
1061
|
+
dragItem,
|
|
1062
|
+
element ?? dragItem.sourceElement ?? document.body,
|
|
1063
|
+
options.type,
|
|
1064
|
+
monitor.getClientOffset()
|
|
1065
|
+
)
|
|
1066
|
+
);
|
|
1067
|
+
if (result === false) {
|
|
1068
|
+
return { accepted: false };
|
|
1069
|
+
}
|
|
1070
|
+
return {
|
|
1071
|
+
...typeof result === "object" && result ? result : {},
|
|
1072
|
+
accepted: true
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
}),
|
|
1076
|
+
[element, options]
|
|
1077
|
+
);
|
|
1119
1078
|
useEffect3(() => {
|
|
1120
1079
|
if (!element || !options) {
|
|
1080
|
+
drop(null);
|
|
1121
1081
|
return void 0;
|
|
1122
1082
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1083
|
+
drop(element);
|
|
1084
|
+
return () => {
|
|
1085
|
+
drop(null);
|
|
1086
|
+
};
|
|
1087
|
+
}, [drop, element, options]);
|
|
1088
|
+
const previousItemRef = useRef4(null);
|
|
1089
|
+
useEffect3(() => {
|
|
1090
|
+
const previousItem = previousItemRef.current;
|
|
1091
|
+
if (isOver && item && (!previousItem || previousItem !== item)) {
|
|
1092
|
+
options?.onDragEnter?.(item, canDrop);
|
|
1093
|
+
} else if (!isOver && previousItem) {
|
|
1094
|
+
options?.onDragLeave?.(previousItem);
|
|
1095
|
+
}
|
|
1096
|
+
previousItemRef.current = isOver ? item : null;
|
|
1097
|
+
}, [canDrop, isOver, item, options]);
|
|
1098
|
+
return { canDrop, isOver, item };
|
|
1125
1099
|
}
|
|
1126
1100
|
function useNuDragSource({
|
|
1127
1101
|
disabled = false,
|
|
1128
1102
|
getItem,
|
|
1129
1103
|
onDropAccepted,
|
|
1104
|
+
renderPreview,
|
|
1130
1105
|
sourceType
|
|
1131
1106
|
}) {
|
|
1132
|
-
const
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
startY: 0
|
|
1139
|
-
});
|
|
1140
|
-
const state = stateRef.current;
|
|
1141
|
-
function stop(event, shouldDrop) {
|
|
1142
|
-
if (state.pointerId !== event.pointerId) {
|
|
1143
|
-
return;
|
|
1144
|
-
}
|
|
1145
|
-
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
1146
|
-
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
1147
|
-
}
|
|
1148
|
-
state.pointerId = -1;
|
|
1149
|
-
if (state.dragging && shouldDrop && controller.dropAt(event.clientX, event.clientY)) {
|
|
1150
|
-
onDropAccepted?.();
|
|
1151
|
-
} else if (state.dragging) {
|
|
1152
|
-
controller.cancelDrag();
|
|
1153
|
-
}
|
|
1154
|
-
state.dragging = false;
|
|
1155
|
-
state.sourceElement = null;
|
|
1156
|
-
}
|
|
1157
|
-
return {
|
|
1158
|
-
onPointerCancel(event) {
|
|
1159
|
-
stop(event, false);
|
|
1160
|
-
},
|
|
1161
|
-
onPointerDown(event) {
|
|
1162
|
-
if (disabled || event.button !== 0) {
|
|
1163
|
-
return;
|
|
1164
|
-
}
|
|
1165
|
-
if (event.target instanceof HTMLElement && event.target.closest("button, input, select, textarea, a")) {
|
|
1166
|
-
return;
|
|
1167
|
-
}
|
|
1168
|
-
state.dragging = false;
|
|
1169
|
-
state.pointerId = event.pointerId;
|
|
1170
|
-
state.sourceElement = event.currentTarget;
|
|
1171
|
-
state.startX = event.clientX;
|
|
1172
|
-
state.startY = event.clientY;
|
|
1173
|
-
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1174
|
-
},
|
|
1175
|
-
onPointerMove(event) {
|
|
1176
|
-
if (state.pointerId !== event.pointerId || !state.sourceElement) {
|
|
1177
|
-
return;
|
|
1178
|
-
}
|
|
1179
|
-
if (!state.dragging) {
|
|
1180
|
-
const distance = Math.max(
|
|
1181
|
-
Math.abs(event.clientX - state.startX),
|
|
1182
|
-
Math.abs(event.clientY - state.startY)
|
|
1183
|
-
);
|
|
1184
|
-
if (distance < DRAG_THRESHOLD) {
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1107
|
+
const sourceElementRef = useRef4(null);
|
|
1108
|
+
const [{ isDragging }, drag, preview] = useDrag(
|
|
1109
|
+
() => ({
|
|
1110
|
+
type: NU_DRAG_ITEM_TYPE,
|
|
1111
|
+
canDrag: () => !disabled && Boolean(getItem()),
|
|
1112
|
+
item: () => {
|
|
1187
1113
|
const item = getItem();
|
|
1188
1114
|
if (!item) {
|
|
1189
|
-
|
|
1190
|
-
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
1191
|
-
}
|
|
1192
|
-
state.pointerId = -1;
|
|
1193
|
-
state.sourceElement = null;
|
|
1194
|
-
return;
|
|
1115
|
+
throw new Error("getItem must return a drag item when dragging is enabled.");
|
|
1195
1116
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1117
|
+
return {
|
|
1118
|
+
...item,
|
|
1119
|
+
preview: renderPreview?.(item),
|
|
1120
|
+
sourceElement: sourceElementRef.current,
|
|
1121
|
+
sourceType
|
|
1122
|
+
};
|
|
1123
|
+
},
|
|
1124
|
+
end: (_item, monitor) => {
|
|
1125
|
+
const result = monitor.getDropResult();
|
|
1126
|
+
if (monitor.didDrop() && result?.accepted !== false) {
|
|
1127
|
+
onDropAccepted?.(result ?? {});
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
collect: (monitor) => ({ isDragging: monitor.isDragging() })
|
|
1131
|
+
}),
|
|
1132
|
+
[disabled, getItem, onDropAccepted, renderPreview, sourceType]
|
|
1133
|
+
);
|
|
1134
|
+
const dragRef = useCallback2(
|
|
1135
|
+
(element) => {
|
|
1136
|
+
if (disabled) {
|
|
1137
|
+
sourceElementRef.current = null;
|
|
1138
|
+
drag(null);
|
|
1139
|
+
return;
|
|
1198
1140
|
}
|
|
1199
|
-
|
|
1141
|
+
sourceElementRef.current = element;
|
|
1142
|
+
drag(element);
|
|
1200
1143
|
},
|
|
1201
|
-
|
|
1202
|
-
|
|
1144
|
+
[disabled, drag]
|
|
1145
|
+
);
|
|
1146
|
+
useEffect3(() => {
|
|
1147
|
+
if (renderPreview) {
|
|
1148
|
+
preview(getEmptyImage(), { captureDraggingState: true });
|
|
1203
1149
|
}
|
|
1204
|
-
};
|
|
1150
|
+
}, [preview, renderPreview]);
|
|
1151
|
+
return { dragRef, isDragging };
|
|
1205
1152
|
}
|
|
1206
1153
|
|
|
1207
1154
|
// src/components/ListBox/internals/ListBoxCheckControl.tsx
|
|
@@ -1238,7 +1185,7 @@ function ListBoxCheckControl({
|
|
|
1238
1185
|
}
|
|
1239
1186
|
|
|
1240
1187
|
// src/components/ListBox/internals/ListBoxItemView.tsx
|
|
1241
|
-
import { jsx as jsx12, jsxs as
|
|
1188
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1242
1189
|
function ListBoxItemViewInner({
|
|
1243
1190
|
group,
|
|
1244
1191
|
getDragItem,
|
|
@@ -1252,6 +1199,7 @@ function ListBoxItemViewInner({
|
|
|
1252
1199
|
onDoubleClick,
|
|
1253
1200
|
onDragOut,
|
|
1254
1201
|
onToggleCheck,
|
|
1202
|
+
renderDragPreview,
|
|
1255
1203
|
registerItemRef,
|
|
1256
1204
|
rightCheckBox,
|
|
1257
1205
|
uncheckedShape
|
|
@@ -1260,6 +1208,7 @@ function ListBoxItemViewInner({
|
|
|
1260
1208
|
disabled: item.disabled || !getDragItem,
|
|
1261
1209
|
getItem: () => getDragItem?.(item, group) ?? false,
|
|
1262
1210
|
onDropAccepted: () => onDragOut?.(item, group),
|
|
1211
|
+
renderPreview: renderDragPreview ? () => renderDragPreview(item, group) : void 0,
|
|
1263
1212
|
sourceType: "listbox-item"
|
|
1264
1213
|
});
|
|
1265
1214
|
function handleActivate() {
|
|
@@ -1289,7 +1238,7 @@ function ListBoxItemViewInner({
|
|
|
1289
1238
|
uncheckedShape
|
|
1290
1239
|
}
|
|
1291
1240
|
) : null;
|
|
1292
|
-
return /* @__PURE__ */
|
|
1241
|
+
return /* @__PURE__ */ jsxs7(
|
|
1293
1242
|
"div",
|
|
1294
1243
|
{
|
|
1295
1244
|
"aria-disabled": item.disabled || void 0,
|
|
@@ -1307,14 +1256,13 @@ function ListBoxItemViewInner({
|
|
|
1307
1256
|
onClick: handleActivate,
|
|
1308
1257
|
onContextMenu: onPopupMenu ? handleContextMenu : void 0,
|
|
1309
1258
|
onDoubleClick: handleDoubleClick,
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
ref: (node) => registerItemRef(itemId, node),
|
|
1259
|
+
ref: (node) => {
|
|
1260
|
+
registerItemRef(itemId, node);
|
|
1261
|
+
dragSource.dragRef(node);
|
|
1262
|
+
},
|
|
1315
1263
|
role: "option",
|
|
1316
1264
|
children: [
|
|
1317
|
-
/* @__PURE__ */
|
|
1265
|
+
/* @__PURE__ */ jsxs7("span", { className: "nu-listbox__item-main", children: [
|
|
1318
1266
|
rightCheckBox ? null : checkControl,
|
|
1319
1267
|
renderLabel(item.name, "nu-listbox__item-label")
|
|
1320
1268
|
] }),
|
|
@@ -1327,7 +1275,7 @@ function ListBoxItemViewInner({
|
|
|
1327
1275
|
var ListBoxItemView = memo(ListBoxItemViewInner);
|
|
1328
1276
|
|
|
1329
1277
|
// src/components/ListBox/internals/ListBoxGroupView.tsx
|
|
1330
|
-
import { jsx as jsx13, jsxs as
|
|
1278
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1331
1279
|
function ListBoxGroupView({
|
|
1332
1280
|
group,
|
|
1333
1281
|
groupIndex,
|
|
@@ -1337,6 +1285,7 @@ function ListBoxGroupView({
|
|
|
1337
1285
|
onActivateItem,
|
|
1338
1286
|
onDoubleClickItem,
|
|
1339
1287
|
onItemDragOut,
|
|
1288
|
+
renderDragPreview,
|
|
1340
1289
|
onPopupMenuItem,
|
|
1341
1290
|
onToggleItemCheck,
|
|
1342
1291
|
registerItemRef,
|
|
@@ -1345,7 +1294,7 @@ function ListBoxGroupView({
|
|
|
1345
1294
|
selectedId,
|
|
1346
1295
|
uncheckedShape
|
|
1347
1296
|
}) {
|
|
1348
|
-
return /* @__PURE__ */
|
|
1297
|
+
return /* @__PURE__ */ jsxs8("div", { className: "nu-listbox__group", role: "group", children: [
|
|
1349
1298
|
group.category ? /* @__PURE__ */ jsx13(ListBoxCategoryView, { category: group.category }) : null,
|
|
1350
1299
|
group.items.map((item, itemIndex) => {
|
|
1351
1300
|
const itemId = buildListBoxItemId(
|
|
@@ -1371,6 +1320,7 @@ function ListBoxGroupView({
|
|
|
1371
1320
|
onActivate: onActivateItem,
|
|
1372
1321
|
onDoubleClick: onDoubleClickItem,
|
|
1373
1322
|
onDragOut: onItemDragOut,
|
|
1323
|
+
renderDragPreview,
|
|
1374
1324
|
onPopupMenu: onPopupMenuItem,
|
|
1375
1325
|
onToggleCheck: onToggleItemCheck,
|
|
1376
1326
|
registerItemRef,
|
|
@@ -1398,6 +1348,7 @@ function ListBoxInner({
|
|
|
1398
1348
|
onItemDragOut,
|
|
1399
1349
|
onItemSelect,
|
|
1400
1350
|
onDrop,
|
|
1351
|
+
renderDragPreview,
|
|
1401
1352
|
rightCheckBox = false,
|
|
1402
1353
|
selectedId,
|
|
1403
1354
|
uncheckedShape = "box",
|
|
@@ -1408,23 +1359,23 @@ function ListBoxInner({
|
|
|
1408
1359
|
const [rootElement, setRootElement] = useState5(null);
|
|
1409
1360
|
const listboxId = useId();
|
|
1410
1361
|
const itemRefs = useRef5({});
|
|
1411
|
-
const flattenedItems =
|
|
1362
|
+
const flattenedItems = useMemo2(
|
|
1412
1363
|
() => flattenListBoxData(data, listboxId),
|
|
1413
1364
|
[data, listboxId]
|
|
1414
1365
|
);
|
|
1415
|
-
const selectableItems =
|
|
1366
|
+
const selectableItems = useMemo2(
|
|
1416
1367
|
() => flattenedItems.filter(({ item }) => !item.disabled),
|
|
1417
1368
|
[flattenedItems]
|
|
1418
1369
|
);
|
|
1419
1370
|
const [activeId, setActiveId] = useState5(
|
|
1420
1371
|
() => getInitialActiveId(selectableItems, selectedId)
|
|
1421
1372
|
);
|
|
1422
|
-
const dropTargetOptions =
|
|
1373
|
+
const dropTargetOptions = useMemo2(
|
|
1423
1374
|
() => onDrop ? { accepts: acceptsDrop, onDrop, type: "listbox" } : void 0,
|
|
1424
1375
|
[acceptsDrop, onDrop]
|
|
1425
1376
|
);
|
|
1426
1377
|
useNuDropTarget(rootElement, dropTargetOptions);
|
|
1427
|
-
const setRootRef =
|
|
1378
|
+
const setRootRef = useCallback3((node) => {
|
|
1428
1379
|
rootRef.current = node;
|
|
1429
1380
|
setRootElement(node);
|
|
1430
1381
|
}, []);
|
|
@@ -1437,20 +1388,20 @@ function ListBoxInner({
|
|
|
1437
1388
|
block: "nearest"
|
|
1438
1389
|
});
|
|
1439
1390
|
}, [resolvedActiveId]);
|
|
1440
|
-
const registerItemRef =
|
|
1391
|
+
const registerItemRef = useCallback3(
|
|
1441
1392
|
(itemId, node) => {
|
|
1442
1393
|
itemRefs.current[itemId] = node;
|
|
1443
1394
|
},
|
|
1444
1395
|
[]
|
|
1445
1396
|
);
|
|
1446
|
-
const activateItem =
|
|
1397
|
+
const activateItem = useCallback3(
|
|
1447
1398
|
(item, group, itemId) => {
|
|
1448
1399
|
setActiveId(itemId);
|
|
1449
1400
|
onItemSelect?.(item, group);
|
|
1450
1401
|
},
|
|
1451
1402
|
[onItemSelect]
|
|
1452
1403
|
);
|
|
1453
|
-
const activateResolvedItem =
|
|
1404
|
+
const activateResolvedItem = useCallback3(
|
|
1454
1405
|
(itemId) => {
|
|
1455
1406
|
if (!itemId) {
|
|
1456
1407
|
return;
|
|
@@ -1464,7 +1415,7 @@ function ListBoxInner({
|
|
|
1464
1415
|
},
|
|
1465
1416
|
[activateItem, selectableItems]
|
|
1466
1417
|
);
|
|
1467
|
-
const handleItemPopupMenu =
|
|
1418
|
+
const handleItemPopupMenu = useCallback3(
|
|
1468
1419
|
(event, item, group, itemId) => {
|
|
1469
1420
|
if (item.disabled || !onPopupMenu) {
|
|
1470
1421
|
return;
|
|
@@ -1504,7 +1455,7 @@ function ListBoxInner({
|
|
|
1504
1455
|
function isItemChecked(item) {
|
|
1505
1456
|
return getListBoxItemChecked(item, checkedIds);
|
|
1506
1457
|
}
|
|
1507
|
-
const toggleItemCheck =
|
|
1458
|
+
const toggleItemCheck = useCallback3(
|
|
1508
1459
|
(itemId) => {
|
|
1509
1460
|
const activeEntry = flattenedItems.find(
|
|
1510
1461
|
(entry) => entry.itemId === itemId
|
|
@@ -1600,6 +1551,7 @@ function ListBoxInner({
|
|
|
1600
1551
|
onItemDragOut,
|
|
1601
1552
|
onPopupMenuItem: handleItemPopupMenu,
|
|
1602
1553
|
onToggleItemCheck: toggleItemCheck,
|
|
1554
|
+
renderDragPreview,
|
|
1603
1555
|
registerItemRef,
|
|
1604
1556
|
resolvedActiveId,
|
|
1605
1557
|
rightCheckBox,
|
|
@@ -1611,7 +1563,10 @@ function ListBoxInner({
|
|
|
1611
1563
|
}
|
|
1612
1564
|
);
|
|
1613
1565
|
}
|
|
1614
|
-
|
|
1566
|
+
function ListBoxWithDragDrop(props, ref) {
|
|
1567
|
+
return /* @__PURE__ */ jsx14(NuDragDropProvider, { children: ListBoxInner(props, ref) });
|
|
1568
|
+
}
|
|
1569
|
+
var ListBox = forwardRef(ListBoxWithDragDrop);
|
|
1615
1570
|
|
|
1616
1571
|
// src/components/Stack/Stack.tsx
|
|
1617
1572
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
@@ -1663,7 +1618,7 @@ function Stack({
|
|
|
1663
1618
|
}
|
|
1664
1619
|
|
|
1665
1620
|
// src/windowing/internals/MdiWindowPickerDialog.tsx
|
|
1666
|
-
import { jsx as jsx16, jsxs as
|
|
1621
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1667
1622
|
function isPickerEligibleWindow(windowEntry) {
|
|
1668
1623
|
if (windowEntry.mode === "window") {
|
|
1669
1624
|
return true;
|
|
@@ -1697,7 +1652,7 @@ function MdiWindowPickerDialog({
|
|
|
1697
1652
|
onClose,
|
|
1698
1653
|
windows
|
|
1699
1654
|
}) {
|
|
1700
|
-
const resolvedWindows =
|
|
1655
|
+
const resolvedWindows = useMemo3(
|
|
1701
1656
|
() => windows.filter(
|
|
1702
1657
|
(windowEntry) => isPickerEligibleWindow(windowEntry) && (!domain || windowEntry.domain === domain)
|
|
1703
1658
|
),
|
|
@@ -1716,7 +1671,7 @@ function MdiWindowPickerDialog({
|
|
|
1716
1671
|
onActivateWindow(resolvedSelectedId);
|
|
1717
1672
|
onClose();
|
|
1718
1673
|
}
|
|
1719
|
-
return /* @__PURE__ */
|
|
1674
|
+
return /* @__PURE__ */ jsxs9(Stack, { gap: "md", children: [
|
|
1720
1675
|
/* @__PURE__ */ jsx16(
|
|
1721
1676
|
ListBox,
|
|
1722
1677
|
{
|
|
@@ -1752,7 +1707,7 @@ function MdiWindowPickerDialog({
|
|
|
1752
1707
|
}
|
|
1753
1708
|
}
|
|
1754
1709
|
),
|
|
1755
|
-
/* @__PURE__ */
|
|
1710
|
+
/* @__PURE__ */ jsxs9(Stack, { direction: "row", gap: "sm", children: [
|
|
1756
1711
|
/* @__PURE__ */ jsx16(Button, { defaultFocused: true, onClick: handleActivate, children: "Activate" }),
|
|
1757
1712
|
/* @__PURE__ */ jsx16(Button, { onClick: onClose, variant: "secondary", children: "Cancel" })
|
|
1758
1713
|
] })
|
|
@@ -1887,8 +1842,8 @@ function resolveMdiMainMenuItems(items, bridge) {
|
|
|
1887
1842
|
}
|
|
1888
1843
|
|
|
1889
1844
|
// src/appHost/appHostContext.ts
|
|
1890
|
-
import { createContext
|
|
1891
|
-
var AppHostMenuContext =
|
|
1845
|
+
import { createContext, useContext as useContext2 } from "react";
|
|
1846
|
+
var AppHostMenuContext = createContext(
|
|
1892
1847
|
null
|
|
1893
1848
|
);
|
|
1894
1849
|
function useAppHostMenu() {
|
|
@@ -1917,7 +1872,7 @@ function useAppHostMenu() {
|
|
|
1917
1872
|
}
|
|
1918
1873
|
|
|
1919
1874
|
// src/appHost/NuAppHostProvider.tsx
|
|
1920
|
-
import { jsx as jsx18, jsxs as
|
|
1875
|
+
import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1921
1876
|
function NuAppHostProvider({
|
|
1922
1877
|
children,
|
|
1923
1878
|
renderMenu = true
|
|
@@ -1926,11 +1881,11 @@ function NuAppHostProvider({
|
|
|
1926
1881
|
const [windowBridge, setWindowBridge] = useState7(
|
|
1927
1882
|
null
|
|
1928
1883
|
);
|
|
1929
|
-
const resolvedMainMenu =
|
|
1884
|
+
const resolvedMainMenu = useMemo4(
|
|
1930
1885
|
() => resolveMdiMainMenuItems(menuState.mainMenu, windowBridge),
|
|
1931
1886
|
[menuState.mainMenu, windowBridge]
|
|
1932
1887
|
);
|
|
1933
|
-
const contextValue =
|
|
1888
|
+
const contextValue = useMemo4(
|
|
1934
1889
|
() => ({
|
|
1935
1890
|
...menuState,
|
|
1936
1891
|
setWindowBridge,
|
|
@@ -1938,7 +1893,7 @@ function NuAppHostProvider({
|
|
|
1938
1893
|
}),
|
|
1939
1894
|
[menuState, windowBridge]
|
|
1940
1895
|
);
|
|
1941
|
-
return /* @__PURE__ */
|
|
1896
|
+
return /* @__PURE__ */ jsxs10(AppHostMenuContext.Provider, { value: contextValue, children: [
|
|
1942
1897
|
renderMenu && hasVisibleMainMenuItems(resolvedMainMenu) ? /* @__PURE__ */ jsx18(MainMenu, { items: resolvedMainMenu }) : null,
|
|
1943
1898
|
children
|
|
1944
1899
|
] });
|
|
@@ -1947,10 +1902,10 @@ function NuAppHostProvider({
|
|
|
1947
1902
|
// src/windowing/NuWindowProvider.tsx
|
|
1948
1903
|
import {
|
|
1949
1904
|
Fragment as Fragment3,
|
|
1950
|
-
useCallback as
|
|
1905
|
+
useCallback as useCallback4,
|
|
1951
1906
|
useContext as useContext7,
|
|
1952
1907
|
useEffect as useEffect6,
|
|
1953
|
-
useMemo as
|
|
1908
|
+
useMemo as useMemo6,
|
|
1954
1909
|
useRef as useRef8,
|
|
1955
1910
|
useState as useState10
|
|
1956
1911
|
} from "react";
|
|
@@ -1960,7 +1915,7 @@ import {
|
|
|
1960
1915
|
memo as memo2,
|
|
1961
1916
|
useContext as useContext5,
|
|
1962
1917
|
useLayoutEffect as useLayoutEffect2,
|
|
1963
|
-
useMemo as
|
|
1918
|
+
useMemo as useMemo5,
|
|
1964
1919
|
useRef as useRef6
|
|
1965
1920
|
} from "react";
|
|
1966
1921
|
|
|
@@ -1992,7 +1947,7 @@ function StatusBarItem({
|
|
|
1992
1947
|
}
|
|
1993
1948
|
|
|
1994
1949
|
// src/components/Window/internals/WindowStatusBar.tsx
|
|
1995
|
-
import { jsx as jsx20, jsxs as
|
|
1950
|
+
import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1996
1951
|
function WindowStatusBar({
|
|
1997
1952
|
children,
|
|
1998
1953
|
onResizeStart,
|
|
@@ -2003,7 +1958,7 @@ function WindowStatusBar({
|
|
|
2003
1958
|
const hasCustomItems = resolvedChildren.some(
|
|
2004
1959
|
(child) => typeof child !== "string" && typeof child !== "number"
|
|
2005
1960
|
);
|
|
2006
|
-
return /* @__PURE__ */
|
|
1961
|
+
return /* @__PURE__ */ jsxs11(
|
|
2007
1962
|
"footer",
|
|
2008
1963
|
{
|
|
2009
1964
|
className: ["nu-window__status-bar", statusBarClassName].filter(Boolean).join(" "),
|
|
@@ -2077,7 +2032,7 @@ function WindowTitleButton({
|
|
|
2077
2032
|
}
|
|
2078
2033
|
|
|
2079
2034
|
// src/components/Window/internals/WindowTitleBar.tsx
|
|
2080
|
-
import { jsx as jsx22, jsxs as
|
|
2035
|
+
import { jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2081
2036
|
function WindowTitleBar({
|
|
2082
2037
|
draggable,
|
|
2083
2038
|
icon,
|
|
@@ -2086,7 +2041,7 @@ function WindowTitleBar({
|
|
|
2086
2041
|
title
|
|
2087
2042
|
}) {
|
|
2088
2043
|
const controlsWidth = titleButtons.length > 0 ? `calc(${titleButtons.length} * 0.95rem + ${Math.max(0, titleButtons.length - 1) * 0.35}rem + 0.7rem)` : "0.45rem";
|
|
2089
|
-
return /* @__PURE__ */
|
|
2044
|
+
return /* @__PURE__ */ jsxs12(
|
|
2090
2045
|
"header",
|
|
2091
2046
|
{
|
|
2092
2047
|
className: "nu-window__title-bar",
|
|
@@ -2155,8 +2110,8 @@ function useWindowTitleButtons({
|
|
|
2155
2110
|
}
|
|
2156
2111
|
|
|
2157
2112
|
// src/windowing/windowContext.ts
|
|
2158
|
-
import { createContext as
|
|
2159
|
-
var NuWindowContext =
|
|
2113
|
+
import { createContext as createContext2, useContext as useContext3 } from "react";
|
|
2114
|
+
var NuWindowContext = createContext2(null);
|
|
2160
2115
|
function useNuWindowManager() {
|
|
2161
2116
|
const context = useContext3(NuWindowContext);
|
|
2162
2117
|
if (!context) {
|
|
@@ -2168,8 +2123,8 @@ function useNuWindowManager() {
|
|
|
2168
2123
|
}
|
|
2169
2124
|
|
|
2170
2125
|
// src/components/Window/windowMenuContext.ts
|
|
2171
|
-
import { createContext as
|
|
2172
|
-
var WindowMenuContext =
|
|
2126
|
+
import { createContext as createContext3, useContext as useContext4 } from "react";
|
|
2127
|
+
var WindowMenuContext = createContext3(null);
|
|
2173
2128
|
function useWindowMenu() {
|
|
2174
2129
|
const context = useContext4(WindowMenuContext);
|
|
2175
2130
|
if (!context) {
|
|
@@ -2179,7 +2134,7 @@ function useWindowMenu() {
|
|
|
2179
2134
|
}
|
|
2180
2135
|
|
|
2181
2136
|
// src/components/Window/Window.tsx
|
|
2182
|
-
import { jsx as jsx23, jsxs as
|
|
2137
|
+
import { jsx as jsx23, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2183
2138
|
function getWindowLayerBounds(node) {
|
|
2184
2139
|
const parentNode = node.parentElement;
|
|
2185
2140
|
if (!parentNode) {
|
|
@@ -2246,7 +2201,7 @@ function WindowInner({
|
|
|
2246
2201
|
const isMaximizable = resolvedAspectRatio === void 0 && (maximizable ?? mode === "window");
|
|
2247
2202
|
const isMinimizable = minimizable ?? mode === "window";
|
|
2248
2203
|
const isResizable = resizable ?? mode === "window";
|
|
2249
|
-
const mdiBridge =
|
|
2204
|
+
const mdiBridge = useMemo5(
|
|
2250
2205
|
() => ({
|
|
2251
2206
|
activateWindow: windowManager?.activateWindow ?? (() => void 0),
|
|
2252
2207
|
openDialog: windowManager?.openDialog ?? (() => ""),
|
|
@@ -2254,7 +2209,7 @@ function WindowInner({
|
|
|
2254
2209
|
}),
|
|
2255
2210
|
[windowManager?.activateWindow, windowManager?.openDialog, windowManager?.windows]
|
|
2256
2211
|
);
|
|
2257
|
-
const resolvedMainMenu =
|
|
2212
|
+
const resolvedMainMenu = useMemo5(
|
|
2258
2213
|
() => resolveMdiMainMenuItems(menuState.mainMenu, mdiBridge),
|
|
2259
2214
|
[menuState.mainMenu, mdiBridge]
|
|
2260
2215
|
);
|
|
@@ -2465,7 +2420,7 @@ function WindowInner({
|
|
|
2465
2420
|
window.addEventListener("pointermove", handlePointerMove);
|
|
2466
2421
|
window.addEventListener("pointerup", handlePointerUp);
|
|
2467
2422
|
}
|
|
2468
|
-
return /* @__PURE__ */
|
|
2423
|
+
return /* @__PURE__ */ jsxs13(
|
|
2469
2424
|
"section",
|
|
2470
2425
|
{
|
|
2471
2426
|
...props,
|
|
@@ -2496,7 +2451,7 @@ function WindowInner({
|
|
|
2496
2451
|
className: "nu-window__shadow nu-window__shadow--bottom"
|
|
2497
2452
|
}
|
|
2498
2453
|
),
|
|
2499
|
-
/* @__PURE__ */
|
|
2454
|
+
/* @__PURE__ */ jsxs13(WindowMenuContext.Provider, { value: menuState, children: [
|
|
2500
2455
|
/* @__PURE__ */ jsx23(
|
|
2501
2456
|
WindowTitleBar,
|
|
2502
2457
|
{
|
|
@@ -2628,7 +2583,7 @@ function AppBarItem(props) {
|
|
|
2628
2583
|
}
|
|
2629
2584
|
|
|
2630
2585
|
// src/windowing/WindowBar.tsx
|
|
2631
|
-
import { jsx as jsx25, jsxs as
|
|
2586
|
+
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2632
2587
|
function buildWindowBarGroups(items) {
|
|
2633
2588
|
const groups = [];
|
|
2634
2589
|
const groupsByDomain = /* @__PURE__ */ new Map();
|
|
@@ -2711,7 +2666,7 @@ function WindowBar({ items, onActivateWindow }) {
|
|
|
2711
2666
|
}
|
|
2712
2667
|
return /* @__PURE__ */ jsx25("div", { className: "nu-window-bar", role: "group", "aria-label": "Open windows", children: groups.map((group) => {
|
|
2713
2668
|
const icon = getGroupIcon(group);
|
|
2714
|
-
return /* @__PURE__ */
|
|
2669
|
+
return /* @__PURE__ */ jsxs14(
|
|
2715
2670
|
AppBarItem,
|
|
2716
2671
|
{
|
|
2717
2672
|
active: group.active,
|
|
@@ -2738,7 +2693,7 @@ import {
|
|
|
2738
2693
|
useRef as useRef7,
|
|
2739
2694
|
useState as useState8
|
|
2740
2695
|
} from "react";
|
|
2741
|
-
import { jsx as jsx26, jsxs as
|
|
2696
|
+
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2742
2697
|
function TextField({
|
|
2743
2698
|
className,
|
|
2744
2699
|
debounceMs = 0,
|
|
@@ -2789,7 +2744,7 @@ function TextField({
|
|
|
2789
2744
|
}
|
|
2790
2745
|
onChange?.(event);
|
|
2791
2746
|
}
|
|
2792
|
-
return /* @__PURE__ */
|
|
2747
|
+
return /* @__PURE__ */ jsxs15(
|
|
2793
2748
|
"label",
|
|
2794
2749
|
{
|
|
2795
2750
|
className: cx("nu-text-field", slotClassNames?.root, className),
|
|
@@ -2804,7 +2759,7 @@ function TextField({
|
|
|
2804
2759
|
children: renderMnemonicText(label)
|
|
2805
2760
|
}
|
|
2806
2761
|
),
|
|
2807
|
-
/* @__PURE__ */
|
|
2762
|
+
/* @__PURE__ */ jsxs15(
|
|
2808
2763
|
"span",
|
|
2809
2764
|
{
|
|
2810
2765
|
className: cx("nu-text-field__slot", slotClassNames?.slot),
|
|
@@ -2896,7 +2851,7 @@ function NuView({
|
|
|
2896
2851
|
}
|
|
2897
2852
|
|
|
2898
2853
|
// src/windowing/dialogHelpers.tsx
|
|
2899
|
-
import { jsx as jsx28, jsxs as
|
|
2854
|
+
import { jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2900
2855
|
function getPresetButtons(preset) {
|
|
2901
2856
|
switch (preset) {
|
|
2902
2857
|
case "ok-cancel":
|
|
@@ -2999,7 +2954,7 @@ function MessageBoxDialogContent({
|
|
|
2999
2954
|
const bodyStyle = kind === "error" ? {
|
|
3000
2955
|
background: "var(--nu-color-button-danger)"
|
|
3001
2956
|
} : void 0;
|
|
3002
|
-
return /* @__PURE__ */ jsx28(NuView, { padding: "cell", style: bodyStyle, children: /* @__PURE__ */
|
|
2957
|
+
return /* @__PURE__ */ jsx28(NuView, { padding: "cell", style: bodyStyle, children: /* @__PURE__ */ jsxs16(Stack, { gap: "md", children: [
|
|
3003
2958
|
/* @__PURE__ */ jsx28(
|
|
3004
2959
|
"div",
|
|
3005
2960
|
{
|
|
@@ -3009,7 +2964,7 @@ function MessageBoxDialogContent({
|
|
|
3009
2964
|
children: message
|
|
3010
2965
|
}
|
|
3011
2966
|
),
|
|
3012
|
-
/* @__PURE__ */
|
|
2967
|
+
/* @__PURE__ */ jsxs16(Stack, { direction: "row", gap: "sm", justify: "center", children: [
|
|
3013
2968
|
ok ? /* @__PURE__ */ jsx28(
|
|
3014
2969
|
Button,
|
|
3015
2970
|
{
|
|
@@ -3059,7 +3014,7 @@ function InputBoxDialogContent({
|
|
|
3059
3014
|
placeholder
|
|
3060
3015
|
}) {
|
|
3061
3016
|
const [value, setValue] = useState9(defaultValue ?? "");
|
|
3062
|
-
return /* @__PURE__ */ jsx28(NuView, { padding: "cell", children: /* @__PURE__ */
|
|
3017
|
+
return /* @__PURE__ */ jsx28(NuView, { padding: "cell", children: /* @__PURE__ */ jsxs16(Stack, { gap: "md", children: [
|
|
3063
3018
|
/* @__PURE__ */ jsx28(
|
|
3064
3019
|
TextField,
|
|
3065
3020
|
{
|
|
@@ -3071,7 +3026,7 @@ function InputBoxDialogContent({
|
|
|
3071
3026
|
placeholder
|
|
3072
3027
|
}
|
|
3073
3028
|
),
|
|
3074
|
-
/* @__PURE__ */
|
|
3029
|
+
/* @__PURE__ */ jsxs16(Stack, { direction: "row", gap: "sm", justify: "center", children: [
|
|
3075
3030
|
/* @__PURE__ */ jsx28(
|
|
3076
3031
|
Button,
|
|
3077
3032
|
{
|
|
@@ -3095,7 +3050,7 @@ function InputBoxDialogContent({
|
|
|
3095
3050
|
}
|
|
3096
3051
|
|
|
3097
3052
|
// src/windowing/NuWindowProvider.tsx
|
|
3098
|
-
import { jsx as jsx29, jsxs as
|
|
3053
|
+
import { jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3099
3054
|
function getDefaultWindowStyle(mode, index) {
|
|
3100
3055
|
const offset = index * 18;
|
|
3101
3056
|
return {
|
|
@@ -3246,11 +3201,11 @@ function NuWindowProvider({
|
|
|
3246
3201
|
const [windows, setWindows] = useState10([]);
|
|
3247
3202
|
const [windowBoundsById, setWindowBoundsById] = useState10({});
|
|
3248
3203
|
const appHostMenuContext = useContext7(AppHostMenuContext);
|
|
3249
|
-
const nextId =
|
|
3204
|
+
const nextId = useCallback4(() => {
|
|
3250
3205
|
idRef.current += 1;
|
|
3251
3206
|
return `nu-window-${idRef.current}`;
|
|
3252
3207
|
}, []);
|
|
3253
|
-
const closeWindow =
|
|
3208
|
+
const closeWindow = useCallback4((id) => {
|
|
3254
3209
|
setWindows((currentWindows) => {
|
|
3255
3210
|
const closingWindow = currentWindows.find(
|
|
3256
3211
|
(windowEntry) => windowEntry.id === id
|
|
@@ -3278,7 +3233,7 @@ function NuWindowProvider({
|
|
|
3278
3233
|
return nextBounds;
|
|
3279
3234
|
});
|
|
3280
3235
|
}, []);
|
|
3281
|
-
const updateWindowBounds =
|
|
3236
|
+
const updateWindowBounds = useCallback4(
|
|
3282
3237
|
(id, bounds) => {
|
|
3283
3238
|
setWindowBoundsById((currentBounds) => {
|
|
3284
3239
|
const previousBounds = currentBounds[id];
|
|
@@ -3295,7 +3250,7 @@ function NuWindowProvider({
|
|
|
3295
3250
|
},
|
|
3296
3251
|
[]
|
|
3297
3252
|
);
|
|
3298
|
-
const bringToFront =
|
|
3253
|
+
const bringToFront = useCallback4((id) => {
|
|
3299
3254
|
setWindows((currentWindows) => {
|
|
3300
3255
|
const activationChain = getActivationChain(currentWindows, id);
|
|
3301
3256
|
if (activationChain.length === 0) {
|
|
@@ -3311,7 +3266,7 @@ function NuWindowProvider({
|
|
|
3311
3266
|
];
|
|
3312
3267
|
});
|
|
3313
3268
|
}, []);
|
|
3314
|
-
const activateWindow =
|
|
3269
|
+
const activateWindow = useCallback4((id) => {
|
|
3315
3270
|
setWindows((currentWindows) => {
|
|
3316
3271
|
const activationChain = getActivationChain(currentWindows, id);
|
|
3317
3272
|
if (activationChain.length === 0) {
|
|
@@ -3332,7 +3287,7 @@ function NuWindowProvider({
|
|
|
3332
3287
|
];
|
|
3333
3288
|
});
|
|
3334
3289
|
}, []);
|
|
3335
|
-
const updateWindow =
|
|
3290
|
+
const updateWindow = useCallback4(
|
|
3336
3291
|
(id, patch) => {
|
|
3337
3292
|
setWindows(
|
|
3338
3293
|
(currentWindows) => currentWindows.map((windowEntry) => {
|
|
@@ -3352,7 +3307,7 @@ function NuWindowProvider({
|
|
|
3352
3307
|
},
|
|
3353
3308
|
[]
|
|
3354
3309
|
);
|
|
3355
|
-
const updateWindowPosition =
|
|
3310
|
+
const updateWindowPosition = useCallback4(
|
|
3356
3311
|
(id, position) => {
|
|
3357
3312
|
setWindows(
|
|
3358
3313
|
(currentWindows) => currentWindows.map(
|
|
@@ -3370,7 +3325,7 @@ function NuWindowProvider({
|
|
|
3370
3325
|
},
|
|
3371
3326
|
[]
|
|
3372
3327
|
);
|
|
3373
|
-
const updateWindowSize =
|
|
3328
|
+
const updateWindowSize = useCallback4(
|
|
3374
3329
|
(id, width, height) => {
|
|
3375
3330
|
setWindows(
|
|
3376
3331
|
(currentWindows) => currentWindows.map(
|
|
@@ -3388,11 +3343,11 @@ function NuWindowProvider({
|
|
|
3388
3343
|
},
|
|
3389
3344
|
[]
|
|
3390
3345
|
);
|
|
3391
|
-
const handleWindowSizeChange =
|
|
3346
|
+
const handleWindowSizeChange = useCallback4(
|
|
3392
3347
|
(id, size) => updateWindowSize(id, size.width, size.height),
|
|
3393
3348
|
[updateWindowSize]
|
|
3394
3349
|
);
|
|
3395
|
-
const toggleWindowMinimized =
|
|
3350
|
+
const toggleWindowMinimized = useCallback4((id) => {
|
|
3396
3351
|
setWindows(
|
|
3397
3352
|
(currentWindows) => currentWindows.map(
|
|
3398
3353
|
(windowEntry) => windowEntry.id === id ? {
|
|
@@ -3402,7 +3357,7 @@ function NuWindowProvider({
|
|
|
3402
3357
|
)
|
|
3403
3358
|
);
|
|
3404
3359
|
}, []);
|
|
3405
|
-
const toggleWindowMaximized =
|
|
3360
|
+
const toggleWindowMaximized = useCallback4((id) => {
|
|
3406
3361
|
setWindows(
|
|
3407
3362
|
(currentWindows) => currentWindows.map((windowEntry) => {
|
|
3408
3363
|
if (windowEntry.id !== id || !windowEntry.maximizable) {
|
|
@@ -3435,7 +3390,7 @@ function NuWindowProvider({
|
|
|
3435
3390
|
})
|
|
3436
3391
|
);
|
|
3437
3392
|
}, []);
|
|
3438
|
-
const openManagedWindow =
|
|
3393
|
+
const openManagedWindow = useCallback4(
|
|
3439
3394
|
(definition, mode) => {
|
|
3440
3395
|
const id = nextId();
|
|
3441
3396
|
creationOrderRef.current += 1;
|
|
@@ -3456,7 +3411,7 @@ function NuWindowProvider({
|
|
|
3456
3411
|
},
|
|
3457
3412
|
[nextId]
|
|
3458
3413
|
);
|
|
3459
|
-
const closeAll =
|
|
3414
|
+
const closeAll = useCallback4(() => {
|
|
3460
3415
|
setWindows(
|
|
3461
3416
|
(currentWindows) => currentWindows.filter((windowEntry) => {
|
|
3462
3417
|
const canClose = windowEntry.onClose?.(
|
|
@@ -3466,15 +3421,15 @@ function NuWindowProvider({
|
|
|
3466
3421
|
})
|
|
3467
3422
|
);
|
|
3468
3423
|
}, []);
|
|
3469
|
-
const openDialog =
|
|
3424
|
+
const openDialog = useCallback4(
|
|
3470
3425
|
(definition) => openManagedWindow(definition, "dialog"),
|
|
3471
3426
|
[openManagedWindow]
|
|
3472
3427
|
);
|
|
3473
|
-
const openWindow =
|
|
3428
|
+
const openWindow = useCallback4(
|
|
3474
3429
|
(definition) => openManagedWindow(definition, "window"),
|
|
3475
3430
|
[openManagedWindow]
|
|
3476
3431
|
);
|
|
3477
|
-
const showMessageBox =
|
|
3432
|
+
const showMessageBox = useCallback4(
|
|
3478
3433
|
(options) => new Promise((resolve) => {
|
|
3479
3434
|
const buttons = getResolvedMessageBoxButtons(options);
|
|
3480
3435
|
const labels = getResolvedMessageBoxLabels(options);
|
|
@@ -3520,7 +3475,7 @@ function NuWindowProvider({
|
|
|
3520
3475
|
}),
|
|
3521
3476
|
[openDialog]
|
|
3522
3477
|
);
|
|
3523
|
-
const showInputBox =
|
|
3478
|
+
const showInputBox = useCallback4(
|
|
3524
3479
|
(options) => new Promise((resolve) => {
|
|
3525
3480
|
let settled = false;
|
|
3526
3481
|
function resolveOnce(value) {
|
|
@@ -3574,11 +3529,11 @@ function NuWindowProvider({
|
|
|
3574
3529
|
const activeWindow = activeWindowId ? windows.find((windowEntry) => windowEntry.id === activeWindowId) : void 0;
|
|
3575
3530
|
const activeActivationGroup = topmostAppModalIndex >= 0 ? void 0 : activeWindow?.activationGroup;
|
|
3576
3531
|
const hasAppModal = topmostAppModalIndex >= 0;
|
|
3577
|
-
const isWindowActive =
|
|
3532
|
+
const isWindowActive = useCallback4(
|
|
3578
3533
|
(windowEntry) => windowEntry.id === activeWindowId || activeActivationGroup !== void 0 && windowEntry.activationGroup === activeActivationGroup,
|
|
3579
3534
|
[activeActivationGroup, activeWindowId]
|
|
3580
3535
|
);
|
|
3581
|
-
const windowsInfo =
|
|
3536
|
+
const windowsInfo = useMemo6(
|
|
3582
3537
|
() => [...windows].sort(
|
|
3583
3538
|
(leftWindow, rightWindow) => leftWindow.creationOrder - rightWindow.creationOrder
|
|
3584
3539
|
).map((windowEntry) => ({
|
|
@@ -3609,7 +3564,7 @@ function NuWindowProvider({
|
|
|
3609
3564
|
})),
|
|
3610
3565
|
[isWindowActive, windows]
|
|
3611
3566
|
);
|
|
3612
|
-
const mdiBridge =
|
|
3567
|
+
const mdiBridge = useMemo6(
|
|
3613
3568
|
() => ({
|
|
3614
3569
|
activateWindow,
|
|
3615
3570
|
openDialog,
|
|
@@ -3617,7 +3572,7 @@ function NuWindowProvider({
|
|
|
3617
3572
|
}),
|
|
3618
3573
|
[activateWindow, openDialog, windowsInfo]
|
|
3619
3574
|
);
|
|
3620
|
-
const contextValue =
|
|
3575
|
+
const contextValue = useMemo6(
|
|
3621
3576
|
() => ({
|
|
3622
3577
|
activateWindow,
|
|
3623
3578
|
bringToFront,
|
|
@@ -3664,7 +3619,7 @@ function NuWindowProvider({
|
|
|
3664
3619
|
useEffect6(() => {
|
|
3665
3620
|
onAppModalChange?.(hasAppModal);
|
|
3666
3621
|
}, [hasAppModal, onAppModalChange]);
|
|
3667
|
-
return /* @__PURE__ */ jsx29(NuWindowContext.Provider, { value: contextValue, children: /* @__PURE__ */
|
|
3622
|
+
return /* @__PURE__ */ jsx29(NuWindowContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs17("div", { className: ["nu-window-host", className].filter(Boolean).join(" "), children: [
|
|
3668
3623
|
children,
|
|
3669
3624
|
/* @__PURE__ */ jsx29("div", { className: "nu-window-layer", children: renderWindows.map((windowEntry) => {
|
|
3670
3625
|
const isActiveWindow = isWindowActive(windowEntry);
|
|
@@ -3695,7 +3650,7 @@ function NuWindowProvider({
|
|
|
3695
3650
|
update: handleUpdate
|
|
3696
3651
|
};
|
|
3697
3652
|
const content = typeof windowEntry.content === "function" ? windowEntry.content(controls) : windowEntry.content;
|
|
3698
|
-
return /* @__PURE__ */
|
|
3653
|
+
return /* @__PURE__ */ jsxs17(Fragment3, { children: [
|
|
3699
3654
|
isTopmostAppModal ? /* @__PURE__ */ jsx29(
|
|
3700
3655
|
"div",
|
|
3701
3656
|
{
|
|
@@ -3764,9 +3719,9 @@ function NuWindowProvider({
|
|
|
3764
3719
|
}
|
|
3765
3720
|
|
|
3766
3721
|
// src/components/Desktop/Desktop.tsx
|
|
3767
|
-
import { jsx as jsx30, jsxs as
|
|
3722
|
+
import { jsx as jsx30, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3768
3723
|
function DesktopWindowRegion({ appBar, children }) {
|
|
3769
|
-
return /* @__PURE__ */
|
|
3724
|
+
return /* @__PURE__ */ jsxs18(Fragment4, { children: [
|
|
3770
3725
|
/* @__PURE__ */ jsx30("div", { className: "nu-desktop__workspace", children }),
|
|
3771
3726
|
appBar ? /* @__PURE__ */ jsx30("div", { className: "nu-desktop__app-bar", children: appBar }) : null
|
|
3772
3727
|
] });
|
|
@@ -3811,7 +3766,7 @@ function NuDesktopShell({
|
|
|
3811
3766
|
appHostContext.mainMenu,
|
|
3812
3767
|
appHostContext.windowBridge
|
|
3813
3768
|
);
|
|
3814
|
-
return /* @__PURE__ */
|
|
3769
|
+
return /* @__PURE__ */ jsxs18(
|
|
3815
3770
|
"div",
|
|
3816
3771
|
{
|
|
3817
3772
|
...props,
|
|
@@ -3921,7 +3876,7 @@ function Dashboard({
|
|
|
3921
3876
|
|
|
3922
3877
|
// src/components/CheckBox/CheckBox.tsx
|
|
3923
3878
|
import { useId as useId3, useState as useState12 } from "react";
|
|
3924
|
-
import { jsx as jsx32, jsxs as
|
|
3879
|
+
import { jsx as jsx32, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3925
3880
|
function CheckBox({
|
|
3926
3881
|
checked,
|
|
3927
3882
|
className,
|
|
@@ -3948,13 +3903,13 @@ function CheckBox({
|
|
|
3948
3903
|
}
|
|
3949
3904
|
onCheckedChange?.(event.target.checked, event);
|
|
3950
3905
|
}
|
|
3951
|
-
return /* @__PURE__ */
|
|
3906
|
+
return /* @__PURE__ */ jsxs19(
|
|
3952
3907
|
"label",
|
|
3953
3908
|
{
|
|
3954
3909
|
className: cx("nu-check-box", slotClassNames?.root, className),
|
|
3955
3910
|
style: slotStyles?.root,
|
|
3956
3911
|
children: [
|
|
3957
|
-
/* @__PURE__ */
|
|
3912
|
+
/* @__PURE__ */ jsxs19(
|
|
3958
3913
|
"span",
|
|
3959
3914
|
{
|
|
3960
3915
|
className: cx("nu-check-box__main", slotClassNames?.main),
|
|
@@ -4027,7 +3982,7 @@ function CheckBox({
|
|
|
4027
3982
|
import {
|
|
4028
3983
|
useEffect as useEffect7,
|
|
4029
3984
|
useId as useId4,
|
|
4030
|
-
useMemo as
|
|
3985
|
+
useMemo as useMemo7,
|
|
4031
3986
|
useRef as useRef9,
|
|
4032
3987
|
useState as useState13
|
|
4033
3988
|
} from "react";
|
|
@@ -4183,7 +4138,7 @@ function usePopupPosition({
|
|
|
4183
4138
|
}
|
|
4184
4139
|
|
|
4185
4140
|
// src/components/Dropdown/Dropdown.tsx
|
|
4186
|
-
import { jsx as jsx34, jsxs as
|
|
4141
|
+
import { jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4187
4142
|
function flattenDropdownOptions(data) {
|
|
4188
4143
|
const options = [];
|
|
4189
4144
|
data.forEach((group) => {
|
|
@@ -4238,7 +4193,7 @@ function Dropdown({
|
|
|
4238
4193
|
const popupRef = useRef9(null);
|
|
4239
4194
|
const popupListRef = useRef9(null);
|
|
4240
4195
|
const [open, setOpen] = useState13(false);
|
|
4241
|
-
const options =
|
|
4196
|
+
const options = useMemo7(() => flattenDropdownOptions(data), [data]);
|
|
4242
4197
|
const generatedId = useId4();
|
|
4243
4198
|
const fieldId = `${generatedId}-dropdown`;
|
|
4244
4199
|
const labelId = `${fieldId}-label`;
|
|
@@ -4246,11 +4201,11 @@ function Dropdown({
|
|
|
4246
4201
|
const isControlled = value !== void 0;
|
|
4247
4202
|
const [uncontrolledValue, setUncontrolledValue] = useState13(() => getInitialValue(options, defaultValue));
|
|
4248
4203
|
const resolvedValue = isControlled ? value : uncontrolledValue;
|
|
4249
|
-
const selectedOption =
|
|
4204
|
+
const selectedOption = useMemo7(
|
|
4250
4205
|
() => findSelectedOption(options, resolvedValue),
|
|
4251
4206
|
[options, resolvedValue]
|
|
4252
4207
|
);
|
|
4253
|
-
const selectableOptions =
|
|
4208
|
+
const selectableOptions = useMemo7(
|
|
4254
4209
|
() => options.filter((option) => !option.item.disabled),
|
|
4255
4210
|
[options]
|
|
4256
4211
|
);
|
|
@@ -4349,7 +4304,7 @@ function Dropdown({
|
|
|
4349
4304
|
break;
|
|
4350
4305
|
}
|
|
4351
4306
|
}
|
|
4352
|
-
return /* @__PURE__ */
|
|
4307
|
+
return /* @__PURE__ */ jsxs20(
|
|
4353
4308
|
"div",
|
|
4354
4309
|
{
|
|
4355
4310
|
...props,
|
|
@@ -4384,13 +4339,13 @@ function Dropdown({
|
|
|
4384
4339
|
},
|
|
4385
4340
|
style: slotStyles?.trigger,
|
|
4386
4341
|
type: "button",
|
|
4387
|
-
children: /* @__PURE__ */
|
|
4342
|
+
children: /* @__PURE__ */ jsxs20(
|
|
4388
4343
|
"span",
|
|
4389
4344
|
{
|
|
4390
4345
|
className: cx("nu-dropdown__slot", slotClassNames?.slot),
|
|
4391
4346
|
style: slotStyles?.slot,
|
|
4392
4347
|
children: [
|
|
4393
|
-
/* @__PURE__ */
|
|
4348
|
+
/* @__PURE__ */ jsxs20(
|
|
4394
4349
|
"span",
|
|
4395
4350
|
{
|
|
4396
4351
|
className: cx("nu-dropdown__field", slotClassNames?.field),
|
|
@@ -4527,7 +4482,7 @@ function Dropdown({
|
|
|
4527
4482
|
}
|
|
4528
4483
|
|
|
4529
4484
|
// src/components/Frame/Frame.tsx
|
|
4530
|
-
import { jsx as jsx35, jsxs as
|
|
4485
|
+
import { jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4531
4486
|
function Frame({
|
|
4532
4487
|
children,
|
|
4533
4488
|
className,
|
|
@@ -4548,7 +4503,7 @@ function Frame({
|
|
|
4548
4503
|
}) {
|
|
4549
4504
|
const resolvedTitleContent = titleContent ?? (title ? renderMnemonicText(title) : null);
|
|
4550
4505
|
const hasTitleShell = Boolean(titleStart || resolvedTitleContent || titleEnd);
|
|
4551
|
-
return /* @__PURE__ */
|
|
4506
|
+
return /* @__PURE__ */ jsxs21(
|
|
4552
4507
|
"section",
|
|
4553
4508
|
{
|
|
4554
4509
|
...props,
|
|
@@ -4565,7 +4520,7 @@ function Frame({
|
|
|
4565
4520
|
...slotStyles?.root
|
|
4566
4521
|
},
|
|
4567
4522
|
children: [
|
|
4568
|
-
hasTitleShell ? /* @__PURE__ */
|
|
4523
|
+
hasTitleShell ? /* @__PURE__ */ jsxs21(
|
|
4569
4524
|
"span",
|
|
4570
4525
|
{
|
|
4571
4526
|
className: cx("nu-frame__title", slotClassNames?.title),
|
|
@@ -4669,20 +4624,45 @@ function InfoAccent({
|
|
|
4669
4624
|
// src/components/IconGrid/NuIconGrid.tsx
|
|
4670
4625
|
import {
|
|
4671
4626
|
useLayoutEffect as useLayoutEffect5,
|
|
4672
|
-
useMemo as
|
|
4627
|
+
useMemo as useMemo8,
|
|
4673
4628
|
useRef as useRef11,
|
|
4674
4629
|
useState as useState16
|
|
4675
4630
|
} from "react";
|
|
4676
4631
|
|
|
4677
4632
|
// src/components/PopupMenu/PopupMenu.tsx
|
|
4678
4633
|
import {
|
|
4679
|
-
useCallback as
|
|
4634
|
+
useCallback as useCallback5,
|
|
4680
4635
|
useEffect as useEffect8,
|
|
4681
4636
|
useLayoutEffect as useLayoutEffect4,
|
|
4682
4637
|
useRef as useRef10,
|
|
4683
4638
|
useState as useState14
|
|
4684
4639
|
} from "react";
|
|
4685
4640
|
import { createPortal as createPortal2 } from "react-dom";
|
|
4641
|
+
|
|
4642
|
+
// src/components/_shared/themePortal.ts
|
|
4643
|
+
function getThemePortalStyle(anchor) {
|
|
4644
|
+
if (typeof window === "undefined") {
|
|
4645
|
+
return void 0;
|
|
4646
|
+
}
|
|
4647
|
+
const themeRoot = anchor?.closest(".nu-theme-root");
|
|
4648
|
+
if (!themeRoot) {
|
|
4649
|
+
return void 0;
|
|
4650
|
+
}
|
|
4651
|
+
const computed = window.getComputedStyle(themeRoot);
|
|
4652
|
+
const style = {
|
|
4653
|
+
color: computed.color,
|
|
4654
|
+
fontFamily: computed.fontFamily,
|
|
4655
|
+
fontSize: computed.fontSize
|
|
4656
|
+
};
|
|
4657
|
+
for (const propertyName of computed) {
|
|
4658
|
+
if (propertyName.startsWith("--nu-")) {
|
|
4659
|
+
style[propertyName] = computed.getPropertyValue(propertyName).trim();
|
|
4660
|
+
}
|
|
4661
|
+
}
|
|
4662
|
+
return style;
|
|
4663
|
+
}
|
|
4664
|
+
|
|
4665
|
+
// src/components/PopupMenu/PopupMenu.tsx
|
|
4686
4666
|
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
4687
4667
|
function hasVisibleChildren2(item) {
|
|
4688
4668
|
return Boolean(
|
|
@@ -4732,7 +4712,7 @@ function PopupMenu({
|
|
|
4732
4712
|
const isControlled = open !== void 0;
|
|
4733
4713
|
const resolvedOpen = isControlled ? open : uncontrolledOpen;
|
|
4734
4714
|
const portalRoot = resolvePortalRoot();
|
|
4735
|
-
const setResolvedOpen =
|
|
4715
|
+
const setResolvedOpen = useCallback5(
|
|
4736
4716
|
(nextOpen) => {
|
|
4737
4717
|
if (!nextOpen) {
|
|
4738
4718
|
setActivePath([]);
|
|
@@ -4897,8 +4877,8 @@ function usePopupMenu() {
|
|
|
4897
4877
|
}
|
|
4898
4878
|
|
|
4899
4879
|
// src/components/IconGrid/iconContext.ts
|
|
4900
|
-
import { createContext as
|
|
4901
|
-
var NuIconContext =
|
|
4880
|
+
import { createContext as createContext4, useContext as useContext9 } from "react";
|
|
4881
|
+
var NuIconContext = createContext4(null);
|
|
4902
4882
|
function useNuIconContext() {
|
|
4903
4883
|
const context = useContext9(NuIconContext);
|
|
4904
4884
|
if (!context) {
|
|
@@ -4914,8 +4894,7 @@ function useNuIconGridContext() {
|
|
|
4914
4894
|
}
|
|
4915
4895
|
|
|
4916
4896
|
// src/components/IconGrid/NuIconGrid.tsx
|
|
4917
|
-
import { Fragment as Fragment5, jsx as jsx38, jsxs as
|
|
4918
|
-
var DRAG_THRESHOLD2 = 3;
|
|
4897
|
+
import { Fragment as Fragment5, jsx as jsx38, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4919
4898
|
var gridRegistrations = /* @__PURE__ */ new Map();
|
|
4920
4899
|
function clamp2(value, minimum, maximum) {
|
|
4921
4900
|
return Math.min(Math.max(value, minimum), maximum);
|
|
@@ -4926,23 +4905,6 @@ function resolveIconContextMenuItems(source, icon) {
|
|
|
4926
4905
|
function resolveGridContextMenuItems(source, manager) {
|
|
4927
4906
|
return typeof source === "function" ? source(manager) : source ?? [];
|
|
4928
4907
|
}
|
|
4929
|
-
function findGridRegistrationAtPoint(clientX, clientY) {
|
|
4930
|
-
const target = document.elementFromPoint(clientX, clientY);
|
|
4931
|
-
const gridElement = target?.closest(".nu-icon-grid");
|
|
4932
|
-
if (gridElement) {
|
|
4933
|
-
return gridRegistrations.get(gridElement);
|
|
4934
|
-
}
|
|
4935
|
-
if (target?.closest(".nu-window")) {
|
|
4936
|
-
return void 0;
|
|
4937
|
-
}
|
|
4938
|
-
return Array.from(gridRegistrations.values()).reverse().find((registration) => {
|
|
4939
|
-
if (!registration.dropTarget) {
|
|
4940
|
-
return false;
|
|
4941
|
-
}
|
|
4942
|
-
const rect = registration.element.getBoundingClientRect();
|
|
4943
|
-
return clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom;
|
|
4944
|
-
});
|
|
4945
|
-
}
|
|
4946
4908
|
function getTransferredPosition(targetGrid, iconElement, clientX, clientY) {
|
|
4947
4909
|
const targetRect = targetGrid.getBoundingClientRect();
|
|
4948
4910
|
const iconRect = iconElement.getBoundingClientRect();
|
|
@@ -4964,149 +4926,31 @@ function getTransferredPosition(targetGrid, iconElement, clientX, clientY) {
|
|
|
4964
4926
|
};
|
|
4965
4927
|
}
|
|
4966
4928
|
function NuIconGridItem({
|
|
4967
|
-
gridElement,
|
|
4968
4929
|
icon,
|
|
4969
|
-
onDragOut
|
|
4970
|
-
onIconMoveOut
|
|
4930
|
+
onDragOut
|
|
4971
4931
|
}) {
|
|
4972
4932
|
const manager = useNuIconGridContext();
|
|
4973
|
-
const dragDrop = useNuDragDrop();
|
|
4974
4933
|
const contextMenu = usePopupMenu();
|
|
4975
|
-
const dragStartRef = useRef11(void 0);
|
|
4976
|
-
const isDraggingRef = useRef11(false);
|
|
4977
|
-
const [isDragging, setIsDragging] = useState16(false);
|
|
4978
|
-
const suppressClickRef = useRef11(false);
|
|
4979
|
-
const latestPositionRef = useRef11(icon.position);
|
|
4980
4934
|
const contextMenuItems = resolveIconContextMenuItems(
|
|
4981
4935
|
icon.contextMenuItems,
|
|
4982
4936
|
icon
|
|
4983
4937
|
);
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
latestPositionRef.current = icon.position;
|
|
4990
|
-
isDraggingRef.current = false;
|
|
4991
|
-
dragStartRef.current = {
|
|
4992
|
-
clientX: event.clientX,
|
|
4993
|
-
clientY: event.clientY,
|
|
4994
|
-
pointerId: event.pointerId,
|
|
4995
|
-
position: icon.position
|
|
4996
|
-
};
|
|
4997
|
-
event.currentTarget.setPointerCapture(event.pointerId);
|
|
4998
|
-
}
|
|
4999
|
-
function handlePointerMove(event) {
|
|
5000
|
-
const dragStart = dragStartRef.current;
|
|
5001
|
-
if (!dragStart || dragStart.pointerId !== event.pointerId || !gridElement) {
|
|
5002
|
-
return;
|
|
5003
|
-
}
|
|
5004
|
-
const deltaX = event.clientX - dragStart.clientX;
|
|
5005
|
-
const deltaY = event.clientY - dragStart.clientY;
|
|
5006
|
-
if (!isDraggingRef.current && Math.max(Math.abs(deltaX), Math.abs(deltaY)) < DRAG_THRESHOLD2) {
|
|
5007
|
-
return;
|
|
5008
|
-
}
|
|
5009
|
-
if (!isDraggingRef.current) {
|
|
5010
|
-
isDraggingRef.current = true;
|
|
5011
|
-
setIsDragging(true);
|
|
5012
|
-
dragDrop.beginDrag(
|
|
5013
|
-
{ data: icon, id: icon.id, type: "icon" },
|
|
5014
|
-
event.currentTarget,
|
|
5015
|
-
"icon-grid"
|
|
5016
|
-
);
|
|
5017
|
-
}
|
|
5018
|
-
dragDrop.moveDrag(event.clientX, event.clientY);
|
|
5019
|
-
const gridRect = gridElement.getBoundingClientRect();
|
|
5020
|
-
const iconRect = event.currentTarget.getBoundingClientRect();
|
|
5021
|
-
const position = {
|
|
5022
|
-
x: Math.round(
|
|
5023
|
-
clamp2(
|
|
5024
|
-
dragStart.position.x + deltaX,
|
|
5025
|
-
0,
|
|
5026
|
-
Math.max(0, gridRect.width - iconRect.width)
|
|
5027
|
-
)
|
|
5028
|
-
),
|
|
5029
|
-
y: Math.round(
|
|
5030
|
-
clamp2(
|
|
5031
|
-
dragStart.position.y + deltaY,
|
|
5032
|
-
0,
|
|
5033
|
-
Math.max(0, gridRect.height - iconRect.height)
|
|
5034
|
-
)
|
|
5035
|
-
)
|
|
5036
|
-
};
|
|
5037
|
-
latestPositionRef.current = position;
|
|
5038
|
-
}
|
|
5039
|
-
function finishDragging(event) {
|
|
5040
|
-
const dragStart = dragStartRef.current;
|
|
5041
|
-
if (!dragStart || dragStart.pointerId !== event.pointerId) {
|
|
5042
|
-
return;
|
|
5043
|
-
}
|
|
5044
|
-
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
5045
|
-
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
5046
|
-
}
|
|
5047
|
-
dragStartRef.current = void 0;
|
|
5048
|
-
if (!isDraggingRef.current) {
|
|
5049
|
-
return;
|
|
5050
|
-
}
|
|
5051
|
-
suppressClickRef.current = true;
|
|
5052
|
-
isDraggingRef.current = false;
|
|
5053
|
-
setIsDragging(false);
|
|
5054
|
-
if (event.type === "pointercancel" || !gridElement) {
|
|
5055
|
-
dragDrop.cancelDrag();
|
|
5056
|
-
return;
|
|
5057
|
-
}
|
|
5058
|
-
if (dragDrop.dropAt(event.clientX, event.clientY)) {
|
|
5059
|
-
manager.removeIcon(icon.id);
|
|
5060
|
-
onDragOut?.({ data: icon, id: icon.id, type: "icon" });
|
|
5061
|
-
return;
|
|
5062
|
-
}
|
|
5063
|
-
const targetRegistration = findGridRegistrationAtPoint(
|
|
5064
|
-
event.clientX,
|
|
5065
|
-
event.clientY
|
|
5066
|
-
);
|
|
5067
|
-
if (!targetRegistration) {
|
|
5068
|
-
return;
|
|
5069
|
-
}
|
|
5070
|
-
if (targetRegistration.element === gridElement) {
|
|
5071
|
-
manager.moveIcon(icon.id, latestPositionRef.current);
|
|
5072
|
-
icon.onPositionChange?.(latestPositionRef.current, {
|
|
5073
|
-
...icon,
|
|
5074
|
-
position: latestPositionRef.current
|
|
5075
|
-
});
|
|
5076
|
-
return;
|
|
5077
|
-
}
|
|
5078
|
-
if (!targetRegistration.manager.icons.some(
|
|
5079
|
-
(targetIcon) => targetIcon.id === icon.id
|
|
5080
|
-
)) {
|
|
5081
|
-
const position = getTransferredPosition(
|
|
5082
|
-
targetRegistration.element,
|
|
5083
|
-
event.currentTarget,
|
|
5084
|
-
event.clientX,
|
|
5085
|
-
event.clientY
|
|
5086
|
-
);
|
|
5087
|
-
const transferredIcon = { ...icon, position };
|
|
5088
|
-
const context = {
|
|
5089
|
-
position,
|
|
5090
|
-
source: manager,
|
|
5091
|
-
sourceGrid: gridElement,
|
|
5092
|
-
target: targetRegistration.manager,
|
|
5093
|
-
targetGrid: targetRegistration.element
|
|
5094
|
-
};
|
|
5095
|
-
if (targetRegistration.accepts?.(transferredIcon) !== false && targetRegistration.onIconDrop?.(transferredIcon, context) !== false) {
|
|
5096
|
-
targetRegistration.manager.addIcon(transferredIcon);
|
|
5097
|
-
targetRegistration.manager.selectIcon(transferredIcon.id);
|
|
5098
|
-
manager.removeIcon(icon.id);
|
|
5099
|
-
onIconMoveOut?.(transferredIcon, context);
|
|
4938
|
+
const dragSource = useNuDragSource({
|
|
4939
|
+
disabled: icon.disabled,
|
|
4940
|
+
getItem: () => ({ data: icon, id: icon.id, type: "icon" }),
|
|
4941
|
+
onDropAccepted: (result) => {
|
|
4942
|
+
if (result.targetType === "icon-grid") {
|
|
5100
4943
|
return;
|
|
5101
4944
|
}
|
|
5102
|
-
|
|
5103
|
-
|
|
4945
|
+
const dragItem = { data: icon, id: icon.id, type: "icon" };
|
|
4946
|
+
const shouldMove = result.action !== "copy" && onDragOut?.(dragItem, result) !== false;
|
|
4947
|
+
if (shouldMove) {
|
|
4948
|
+
manager.removeIcon(icon.id);
|
|
4949
|
+
}
|
|
4950
|
+
},
|
|
4951
|
+
sourceType: "icon-grid"
|
|
4952
|
+
});
|
|
5104
4953
|
function handleClick(event) {
|
|
5105
|
-
if (suppressClickRef.current) {
|
|
5106
|
-
suppressClickRef.current = false;
|
|
5107
|
-
event.preventDefault();
|
|
5108
|
-
return;
|
|
5109
|
-
}
|
|
5110
4954
|
manager.selectIcon(icon.id);
|
|
5111
4955
|
icon.onClick?.(event);
|
|
5112
4956
|
}
|
|
@@ -5128,23 +4972,20 @@ function NuIconGridItem({
|
|
|
5128
4972
|
manager.selectIcon(icon.id);
|
|
5129
4973
|
contextMenu.openAtElement(event.currentTarget);
|
|
5130
4974
|
}
|
|
5131
|
-
return /* @__PURE__ */
|
|
5132
|
-
/* @__PURE__ */
|
|
4975
|
+
return /* @__PURE__ */ jsxs22(Fragment5, { children: [
|
|
4976
|
+
/* @__PURE__ */ jsxs22(
|
|
5133
4977
|
"button",
|
|
5134
4978
|
{
|
|
5135
4979
|
"aria-haspopup": contextMenuItems.length > 0 ? "menu" : void 0,
|
|
5136
4980
|
className: "nu-icon-grid__icon",
|
|
5137
|
-
"data-dragging": isDragging || void 0,
|
|
4981
|
+
"data-dragging": dragSource.isDragging || void 0,
|
|
5138
4982
|
"data-selected": manager.selectedIconId === icon.id || void 0,
|
|
5139
4983
|
disabled: icon.disabled,
|
|
5140
4984
|
onClick: handleClick,
|
|
5141
4985
|
onContextMenu: handleContextMenu,
|
|
5142
4986
|
onDoubleClick: icon.onDoubleClick,
|
|
5143
4987
|
onKeyDown: handleKeyDown,
|
|
5144
|
-
|
|
5145
|
-
onPointerMove: handlePointerMove,
|
|
5146
|
-
onPointerUp: finishDragging,
|
|
5147
|
-
onPointerCancel: finishDragging,
|
|
4988
|
+
ref: dragSource.dragRef,
|
|
5148
4989
|
style: { left: icon.position.x, top: icon.position.y },
|
|
5149
4990
|
type: "button",
|
|
5150
4991
|
children: [
|
|
@@ -5164,7 +5005,7 @@ function NuIconGridItem({
|
|
|
5164
5005
|
)
|
|
5165
5006
|
] });
|
|
5166
5007
|
}
|
|
5167
|
-
function
|
|
5008
|
+
function NuIconGridContent({
|
|
5168
5009
|
accepts,
|
|
5169
5010
|
acceptsDrop,
|
|
5170
5011
|
className,
|
|
@@ -5185,19 +5026,93 @@ function NuIconGrid({
|
|
|
5185
5026
|
const arrangeIcons = manager.arrangeIcons;
|
|
5186
5027
|
const setGridSize = manager.setGridSize;
|
|
5187
5028
|
const contextMenu = usePopupMenu();
|
|
5188
|
-
const contextMenuItems =
|
|
5029
|
+
const contextMenuItems = useMemo8(
|
|
5189
5030
|
() => resolveGridContextMenuItems(contextMenuItemsSource, manager),
|
|
5190
5031
|
[contextMenuItemsSource, manager]
|
|
5191
5032
|
);
|
|
5192
|
-
const sharedDropTargetOptions =
|
|
5193
|
-
()
|
|
5194
|
-
|
|
5195
|
-
|
|
5033
|
+
const sharedDropTargetOptions = useMemo8(() => {
|
|
5034
|
+
if (!gridElement) {
|
|
5035
|
+
return void 0;
|
|
5036
|
+
}
|
|
5037
|
+
return {
|
|
5038
|
+
accepts: (item) => {
|
|
5039
|
+
if (item.type === "icon") {
|
|
5040
|
+
return accepts?.(item.data) !== false;
|
|
5041
|
+
}
|
|
5042
|
+
return Boolean(onDrop) && acceptsDrop?.(item) !== false;
|
|
5043
|
+
},
|
|
5044
|
+
onDrop: (item, context) => {
|
|
5045
|
+
if (item.type !== "icon") {
|
|
5046
|
+
return onDrop?.(item, context) ?? false;
|
|
5047
|
+
}
|
|
5048
|
+
const sourceGridElement = context.source.element.closest(
|
|
5049
|
+
".nu-icon-grid"
|
|
5050
|
+
);
|
|
5051
|
+
const sourceRegistration = sourceGridElement ? gridRegistrations.get(sourceGridElement) : void 0;
|
|
5052
|
+
if (!sourceRegistration) {
|
|
5053
|
+
return false;
|
|
5054
|
+
}
|
|
5055
|
+
const sourceIcon = item.data;
|
|
5056
|
+
const position = getTransferredPosition(
|
|
5057
|
+
gridElement,
|
|
5058
|
+
context.source.element,
|
|
5059
|
+
context.clientX,
|
|
5060
|
+
context.clientY
|
|
5061
|
+
);
|
|
5062
|
+
if (sourceRegistration.element === gridElement) {
|
|
5063
|
+
manager.moveIcon(sourceIcon.id, position);
|
|
5064
|
+
sourceIcon.onPositionChange?.(position, {
|
|
5065
|
+
...sourceIcon,
|
|
5066
|
+
position
|
|
5067
|
+
});
|
|
5068
|
+
return { action: "move", targetType: "icon-grid" };
|
|
5069
|
+
}
|
|
5070
|
+
if (manager.icons.some((targetIcon) => targetIcon.id === sourceIcon.id)) {
|
|
5071
|
+
return false;
|
|
5072
|
+
}
|
|
5073
|
+
const transferredIcon = { ...sourceIcon, position };
|
|
5074
|
+
const dropContext = {
|
|
5075
|
+
position,
|
|
5076
|
+
source: sourceRegistration.manager,
|
|
5077
|
+
sourceGrid: sourceRegistration.element,
|
|
5078
|
+
target: manager,
|
|
5079
|
+
targetGrid: gridElement
|
|
5080
|
+
};
|
|
5081
|
+
if (onIconDrop?.(transferredIcon, dropContext) === false) {
|
|
5082
|
+
return false;
|
|
5083
|
+
}
|
|
5084
|
+
manager.addIcon(transferredIcon);
|
|
5085
|
+
manager.selectIcon(transferredIcon.id);
|
|
5086
|
+
sourceRegistration.manager.removeIcon(sourceIcon.id);
|
|
5087
|
+
sourceRegistration.onIconMoveOut?.(transferredIcon, dropContext);
|
|
5088
|
+
return { action: "move", targetType: "icon-grid" };
|
|
5089
|
+
},
|
|
5196
5090
|
type: "icon-grid"
|
|
5197
|
-
}
|
|
5198
|
-
|
|
5199
|
-
);
|
|
5091
|
+
};
|
|
5092
|
+
}, [accepts, acceptsDrop, gridElement, manager, onDrop, onIconDrop]);
|
|
5200
5093
|
useNuDropTarget(gridElement, sharedDropTargetOptions);
|
|
5094
|
+
const backgroundDropTargetOptions = useMemo8(() => {
|
|
5095
|
+
if (!dropTarget || !gridElement || !sharedDropTargetOptions) {
|
|
5096
|
+
return void 0;
|
|
5097
|
+
}
|
|
5098
|
+
return {
|
|
5099
|
+
...sharedDropTargetOptions,
|
|
5100
|
+
onDrop: (item, context) => {
|
|
5101
|
+
const rect = gridElement.getBoundingClientRect();
|
|
5102
|
+
if (context.clientX < rect.left || context.clientX > rect.right || context.clientY < rect.top || context.clientY > rect.bottom) {
|
|
5103
|
+
return false;
|
|
5104
|
+
}
|
|
5105
|
+
return sharedDropTargetOptions.onDrop(item, {
|
|
5106
|
+
...context,
|
|
5107
|
+
target: { element: gridElement, type: "icon-grid" }
|
|
5108
|
+
});
|
|
5109
|
+
}
|
|
5110
|
+
};
|
|
5111
|
+
}, [dropTarget, gridElement, sharedDropTargetOptions]);
|
|
5112
|
+
useNuDropTarget(
|
|
5113
|
+
dropTarget && typeof document !== "undefined" ? document.body : null,
|
|
5114
|
+
backgroundDropTargetOptions
|
|
5115
|
+
);
|
|
5201
5116
|
useLayoutEffect5(() => {
|
|
5202
5117
|
if (!gridElement) {
|
|
5203
5118
|
return;
|
|
@@ -5224,16 +5139,15 @@ function NuIconGrid({
|
|
|
5224
5139
|
return;
|
|
5225
5140
|
}
|
|
5226
5141
|
gridRegistrations.set(gridElement, {
|
|
5227
|
-
accepts,
|
|
5228
|
-
dropTarget,
|
|
5229
5142
|
element: gridElement,
|
|
5230
5143
|
manager,
|
|
5231
|
-
onIconDrop
|
|
5144
|
+
onIconDrop,
|
|
5145
|
+
onIconMoveOut
|
|
5232
5146
|
});
|
|
5233
5147
|
return () => {
|
|
5234
5148
|
gridRegistrations.delete(gridElement);
|
|
5235
5149
|
};
|
|
5236
|
-
}, [
|
|
5150
|
+
}, [gridElement, manager, onIconDrop, onIconMoveOut]);
|
|
5237
5151
|
function handleContextMenu(event) {
|
|
5238
5152
|
onContextMenu?.(event);
|
|
5239
5153
|
if (event.defaultPrevented || contextMenuItems.length === 0) {
|
|
@@ -5243,12 +5157,13 @@ function NuIconGrid({
|
|
|
5243
5157
|
manager.selectIcon(null);
|
|
5244
5158
|
contextMenu.openAtPoint(event.clientX, event.clientY, event.currentTarget);
|
|
5245
5159
|
}
|
|
5246
|
-
return /* @__PURE__ */
|
|
5160
|
+
return /* @__PURE__ */ jsxs22(
|
|
5247
5161
|
"div",
|
|
5248
5162
|
{
|
|
5249
5163
|
...props,
|
|
5250
5164
|
"aria-label": props["aria-label"] ?? "Application icons",
|
|
5251
5165
|
className: ["nu-icon-grid", className].filter(Boolean).join(" "),
|
|
5166
|
+
"data-drop-target": dropTarget || void 0,
|
|
5252
5167
|
onContextMenu: handleContextMenu,
|
|
5253
5168
|
onPointerDown: (event) => {
|
|
5254
5169
|
onPointerDown?.(event);
|
|
@@ -5265,10 +5180,8 @@ function NuIconGrid({
|
|
|
5265
5180
|
manager.icons.map((icon) => /* @__PURE__ */ jsx38(
|
|
5266
5181
|
NuIconGridItem,
|
|
5267
5182
|
{
|
|
5268
|
-
gridElement,
|
|
5269
5183
|
icon,
|
|
5270
|
-
onDragOut
|
|
5271
|
-
onIconMoveOut
|
|
5184
|
+
onDragOut
|
|
5272
5185
|
},
|
|
5273
5186
|
icon.id
|
|
5274
5187
|
)),
|
|
@@ -5285,11 +5198,14 @@ function NuIconGrid({
|
|
|
5285
5198
|
}
|
|
5286
5199
|
);
|
|
5287
5200
|
}
|
|
5201
|
+
function NuIconGrid(props) {
|
|
5202
|
+
return /* @__PURE__ */ jsx38(NuDragDropProvider, { children: /* @__PURE__ */ jsx38(NuIconGridContent, { ...props }) });
|
|
5203
|
+
}
|
|
5288
5204
|
|
|
5289
5205
|
// src/components/IconGrid/NuIconProvider.tsx
|
|
5290
5206
|
import {
|
|
5291
|
-
useCallback as
|
|
5292
|
-
useMemo as
|
|
5207
|
+
useCallback as useCallback6,
|
|
5208
|
+
useMemo as useMemo9,
|
|
5293
5209
|
useRef as useRef12,
|
|
5294
5210
|
useState as useState17
|
|
5295
5211
|
} from "react";
|
|
@@ -5364,7 +5280,7 @@ function NuIconProvider({
|
|
|
5364
5280
|
() => getInitialIcons(defaultIcons)
|
|
5365
5281
|
);
|
|
5366
5282
|
const [selectedIconId, setSelectedIconId] = useState17(null);
|
|
5367
|
-
const addIcon =
|
|
5283
|
+
const addIcon = useCallback6((definition) => {
|
|
5368
5284
|
const id = definition.id ?? `nu-icon-${++idRef.current}`;
|
|
5369
5285
|
setIcons((currentIcons) => {
|
|
5370
5286
|
if (currentIcons.some((icon) => icon.id === id)) {
|
|
@@ -5377,18 +5293,18 @@ function NuIconProvider({
|
|
|
5377
5293
|
});
|
|
5378
5294
|
return id;
|
|
5379
5295
|
}, []);
|
|
5380
|
-
const moveIcon =
|
|
5296
|
+
const moveIcon = useCallback6((id, position) => {
|
|
5381
5297
|
setIcons(
|
|
5382
5298
|
(currentIcons) => currentIcons.map(
|
|
5383
5299
|
(icon) => icon.id === id ? { ...icon, position } : icon
|
|
5384
5300
|
)
|
|
5385
5301
|
);
|
|
5386
5302
|
}, []);
|
|
5387
|
-
const removeIcon =
|
|
5303
|
+
const removeIcon = useCallback6((id) => {
|
|
5388
5304
|
setIcons((currentIcons) => currentIcons.filter((icon) => icon.id !== id));
|
|
5389
5305
|
setSelectedIconId((currentId) => currentId === id ? null : currentId);
|
|
5390
5306
|
}, []);
|
|
5391
|
-
const updateIcon =
|
|
5307
|
+
const updateIcon = useCallback6(
|
|
5392
5308
|
(id, patch) => {
|
|
5393
5309
|
setIcons(
|
|
5394
5310
|
(currentIcons) => currentIcons.map(
|
|
@@ -5402,7 +5318,7 @@ function NuIconProvider({
|
|
|
5402
5318
|
},
|
|
5403
5319
|
[]
|
|
5404
5320
|
);
|
|
5405
|
-
const arrangeIcons =
|
|
5321
|
+
const arrangeIcons = useCallback6((mode = "columns") => {
|
|
5406
5322
|
setIcons((currentIcons) => {
|
|
5407
5323
|
const positions = getArrangedPositions(
|
|
5408
5324
|
currentIcons,
|
|
@@ -5415,10 +5331,10 @@ function NuIconProvider({
|
|
|
5415
5331
|
}));
|
|
5416
5332
|
});
|
|
5417
5333
|
}, []);
|
|
5418
|
-
const setGridSize =
|
|
5334
|
+
const setGridSize = useCallback6((size) => {
|
|
5419
5335
|
gridSizeRef.current = size;
|
|
5420
5336
|
}, []);
|
|
5421
|
-
const contextValue =
|
|
5337
|
+
const contextValue = useMemo9(
|
|
5422
5338
|
() => ({
|
|
5423
5339
|
addIcon,
|
|
5424
5340
|
arrangeIcons,
|
|
@@ -5448,12 +5364,12 @@ function NuIconProvider({
|
|
|
5448
5364
|
import {
|
|
5449
5365
|
useEffect as useEffect9,
|
|
5450
5366
|
useId as useId5,
|
|
5451
|
-
useMemo as
|
|
5367
|
+
useMemo as useMemo10,
|
|
5452
5368
|
useRef as useRef13,
|
|
5453
5369
|
useState as useState18
|
|
5454
5370
|
} from "react";
|
|
5455
5371
|
import { createPortal as createPortal3 } from "react-dom";
|
|
5456
|
-
import { jsx as jsx40, jsxs as
|
|
5372
|
+
import { jsx as jsx40, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
5457
5373
|
function flattenComboBoxOptions(data) {
|
|
5458
5374
|
const options = [];
|
|
5459
5375
|
data.forEach((group) => {
|
|
@@ -5503,7 +5419,7 @@ function ComboBox({
|
|
|
5503
5419
|
const labelId = `${fieldId}-label`;
|
|
5504
5420
|
const hintId = hint ? `${fieldId}-hint` : void 0;
|
|
5505
5421
|
const [open, setOpen] = useState18(false);
|
|
5506
|
-
const options =
|
|
5422
|
+
const options = useMemo10(() => flattenComboBoxOptions(data), [data]);
|
|
5507
5423
|
const isValueControlled = value !== void 0;
|
|
5508
5424
|
const isInputControlled = inputValueProp !== void 0;
|
|
5509
5425
|
const [uncontrolledValue, setUncontrolledValue] = useState18(() => defaultValue);
|
|
@@ -5512,13 +5428,13 @@ function ComboBox({
|
|
|
5512
5428
|
() => defaultInputValue ?? initialSelectedOption?.item.name.text ?? ""
|
|
5513
5429
|
);
|
|
5514
5430
|
const resolvedValue = isValueControlled ? value : uncontrolledValue;
|
|
5515
|
-
const selectedOption =
|
|
5431
|
+
const selectedOption = useMemo10(
|
|
5516
5432
|
() => findComboBoxOption(options, resolvedValue),
|
|
5517
5433
|
[options, resolvedValue]
|
|
5518
5434
|
);
|
|
5519
5435
|
const resolvedInputValue = isInputControlled ? inputValueProp ?? "" : uncontrolledInputValue;
|
|
5520
5436
|
const normalizedFilter = resolvedInputValue.trim().toLowerCase();
|
|
5521
|
-
const filteredData =
|
|
5437
|
+
const filteredData = useMemo10(() => {
|
|
5522
5438
|
if (!normalizedFilter) {
|
|
5523
5439
|
return data;
|
|
5524
5440
|
}
|
|
@@ -5529,7 +5445,7 @@ function ComboBox({
|
|
|
5529
5445
|
)
|
|
5530
5446
|
})).filter((group) => group.items.length > 0);
|
|
5531
5447
|
}, [data, normalizedFilter]);
|
|
5532
|
-
const filteredOptions =
|
|
5448
|
+
const filteredOptions = useMemo10(
|
|
5533
5449
|
() => flattenComboBoxOptions(filteredData).filter(
|
|
5534
5450
|
(option) => !option.item.disabled
|
|
5535
5451
|
),
|
|
@@ -5613,7 +5529,7 @@ function ComboBox({
|
|
|
5613
5529
|
break;
|
|
5614
5530
|
}
|
|
5615
5531
|
}
|
|
5616
|
-
return /* @__PURE__ */
|
|
5532
|
+
return /* @__PURE__ */ jsxs23(
|
|
5617
5533
|
"div",
|
|
5618
5534
|
{
|
|
5619
5535
|
...props,
|
|
@@ -5631,13 +5547,13 @@ function ComboBox({
|
|
|
5631
5547
|
children: renderMnemonicText(label)
|
|
5632
5548
|
}
|
|
5633
5549
|
),
|
|
5634
|
-
/* @__PURE__ */
|
|
5550
|
+
/* @__PURE__ */ jsxs23(
|
|
5635
5551
|
"span",
|
|
5636
5552
|
{
|
|
5637
5553
|
className: cx("nu-combo-box__slot", slotClassNames?.slot),
|
|
5638
5554
|
style: slotStyles?.slot,
|
|
5639
5555
|
children: [
|
|
5640
|
-
/* @__PURE__ */
|
|
5556
|
+
/* @__PURE__ */ jsxs23(
|
|
5641
5557
|
"span",
|
|
5642
5558
|
{
|
|
5643
5559
|
className: cx("nu-combo-box__field", slotClassNames?.field),
|
|
@@ -5776,7 +5692,7 @@ function ComboBox({
|
|
|
5776
5692
|
import {
|
|
5777
5693
|
Fragment as Fragment6
|
|
5778
5694
|
} from "react";
|
|
5779
|
-
import { jsx as jsx41, jsxs as
|
|
5695
|
+
import { jsx as jsx41, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
5780
5696
|
var COMMAND_BUTTON_GLYPH_NAMES = /* @__PURE__ */ new Set([
|
|
5781
5697
|
"check-fill",
|
|
5782
5698
|
"check-mark",
|
|
@@ -5825,8 +5741,8 @@ function CommandButton({
|
|
|
5825
5741
|
}
|
|
5826
5742
|
popupMenu.openFromClick(event);
|
|
5827
5743
|
}
|
|
5828
|
-
return /* @__PURE__ */
|
|
5829
|
-
/* @__PURE__ */
|
|
5744
|
+
return /* @__PURE__ */ jsxs24(Fragment6, { children: [
|
|
5745
|
+
/* @__PURE__ */ jsxs24(
|
|
5830
5746
|
"button",
|
|
5831
5747
|
{
|
|
5832
5748
|
...props,
|
|
@@ -5897,7 +5813,7 @@ function CommandButton({
|
|
|
5897
5813
|
|
|
5898
5814
|
// src/components/CrtGlitch/CrtGlitch.tsx
|
|
5899
5815
|
import { useEffect as useEffect10, useId as useId6, useRef as useRef14 } from "react";
|
|
5900
|
-
import { jsx as jsx42, jsxs as
|
|
5816
|
+
import { jsx as jsx42, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5901
5817
|
var DEFAULT_INTERVAL_MS = 3e3;
|
|
5902
5818
|
var DEFAULT_DURATION_MS = 2500;
|
|
5903
5819
|
var DEFAULT_TOP_LEVEL_RATIO = 1 / 3;
|
|
@@ -6031,7 +5947,7 @@ function NuCrtGlitch({
|
|
|
6031
5947
|
}
|
|
6032
5948
|
};
|
|
6033
5949
|
}, [durationMs, enabled, filterId, intervalMs, targetSelector, topLevelRatio]);
|
|
6034
|
-
return /* @__PURE__ */ jsx42("svg", { "aria-hidden": "true", height: "0", style: { position: "absolute" }, width: "0", children: /* @__PURE__ */ jsx42("defs", { children: /* @__PURE__ */
|
|
5950
|
+
return /* @__PURE__ */ jsx42("svg", { "aria-hidden": "true", height: "0", style: { position: "absolute" }, width: "0", children: /* @__PURE__ */ jsx42("defs", { children: /* @__PURE__ */ jsxs25(
|
|
6035
5951
|
"filter",
|
|
6036
5952
|
{
|
|
6037
5953
|
"color-interpolation-filters": "sRGB",
|
|
@@ -6103,10 +6019,10 @@ function NuCrtGlitch({
|
|
|
6103
6019
|
// src/components/ListView/ListView.tsx
|
|
6104
6020
|
import {
|
|
6105
6021
|
forwardRef as forwardRef2,
|
|
6106
|
-
useCallback as
|
|
6022
|
+
useCallback as useCallback7,
|
|
6107
6023
|
useEffect as useEffect11,
|
|
6108
6024
|
useImperativeHandle as useImperativeHandle2,
|
|
6109
|
-
useMemo as
|
|
6025
|
+
useMemo as useMemo11,
|
|
6110
6026
|
useRef as useRef15,
|
|
6111
6027
|
useState as useState19
|
|
6112
6028
|
} from "react";
|
|
@@ -6186,22 +6102,32 @@ function ListViewCheckControl({
|
|
|
6186
6102
|
}
|
|
6187
6103
|
|
|
6188
6104
|
// src/components/ListView/internals/ListViewRow.tsx
|
|
6189
|
-
import { jsx as jsx44, jsxs as
|
|
6105
|
+
import { jsx as jsx44, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6190
6106
|
function ListViewRowInner({
|
|
6191
6107
|
columns,
|
|
6192
6108
|
isActive,
|
|
6193
6109
|
isChecked,
|
|
6194
6110
|
isSelected,
|
|
6111
|
+
getDragItem,
|
|
6195
6112
|
onActivate,
|
|
6196
6113
|
onDoubleClick,
|
|
6114
|
+
onDragOut,
|
|
6197
6115
|
onToggleCheck,
|
|
6198
6116
|
registerRowRef,
|
|
6117
|
+
renderDragPreview,
|
|
6199
6118
|
row,
|
|
6200
6119
|
showCheckBox,
|
|
6201
6120
|
templateColumns,
|
|
6202
6121
|
uncheckedShape
|
|
6203
6122
|
}) {
|
|
6204
6123
|
const rowId = row.id;
|
|
6124
|
+
const dragSource = useNuDragSource({
|
|
6125
|
+
disabled: row.disabled || !getDragItem,
|
|
6126
|
+
getItem: () => getDragItem?.(row) ?? false,
|
|
6127
|
+
onDropAccepted: () => onDragOut?.(row),
|
|
6128
|
+
renderPreview: renderDragPreview ? () => renderDragPreview(row) : void 0,
|
|
6129
|
+
sourceType: "list-view-row"
|
|
6130
|
+
});
|
|
6205
6131
|
function handleActivate() {
|
|
6206
6132
|
if (!row.disabled) {
|
|
6207
6133
|
onActivate(rowId);
|
|
@@ -6217,7 +6143,7 @@ function ListViewRowInner({
|
|
|
6217
6143
|
function handleToggleCheck() {
|
|
6218
6144
|
onToggleCheck(rowId);
|
|
6219
6145
|
}
|
|
6220
|
-
return /* @__PURE__ */
|
|
6146
|
+
return /* @__PURE__ */ jsxs26(
|
|
6221
6147
|
"div",
|
|
6222
6148
|
{
|
|
6223
6149
|
"aria-disabled": row.disabled || void 0,
|
|
@@ -6232,7 +6158,10 @@ function ListViewRowInner({
|
|
|
6232
6158
|
id: rowId,
|
|
6233
6159
|
onClick: handleActivate,
|
|
6234
6160
|
onDoubleClick: handleDoubleClick,
|
|
6235
|
-
ref: (node) =>
|
|
6161
|
+
ref: (node) => {
|
|
6162
|
+
registerRowRef(rowId, node);
|
|
6163
|
+
dragSource.dragRef(node);
|
|
6164
|
+
},
|
|
6236
6165
|
role: "row",
|
|
6237
6166
|
style: {
|
|
6238
6167
|
"--nu-list-view-columns": templateColumns
|
|
@@ -6267,8 +6196,9 @@ function ListViewRowInner({
|
|
|
6267
6196
|
var ListViewRow = memo3(ListViewRowInner);
|
|
6268
6197
|
|
|
6269
6198
|
// src/components/ListView/ListView.tsx
|
|
6270
|
-
import { jsx as jsx45, jsxs as
|
|
6199
|
+
import { jsx as jsx45, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
6271
6200
|
function ListViewInner({
|
|
6201
|
+
acceptsDrop,
|
|
6272
6202
|
activeRowId: activeRowIdProp,
|
|
6273
6203
|
checkedIds,
|
|
6274
6204
|
className,
|
|
@@ -6276,18 +6206,23 @@ function ListViewInner({
|
|
|
6276
6206
|
data,
|
|
6277
6207
|
defaultActiveRowId,
|
|
6278
6208
|
emptyText = "No rows",
|
|
6209
|
+
getDragItem,
|
|
6279
6210
|
onActiveRowChange,
|
|
6280
6211
|
onRowCheckChange,
|
|
6281
6212
|
onRowDoubleClick,
|
|
6213
|
+
onRowDragOut,
|
|
6282
6214
|
onRowSelect,
|
|
6215
|
+
onDrop,
|
|
6216
|
+
renderDragPreview,
|
|
6283
6217
|
selectedId,
|
|
6284
6218
|
showCheckBox = false,
|
|
6285
6219
|
uncheckedShape = "box",
|
|
6286
6220
|
...props
|
|
6287
6221
|
}, ref) {
|
|
6288
6222
|
const rootRef = useRef15(null);
|
|
6223
|
+
const [rootElement, setRootElement] = useState19(null);
|
|
6289
6224
|
const rowRefs = useRef15({});
|
|
6290
|
-
const selectableRows =
|
|
6225
|
+
const selectableRows = useMemo11(
|
|
6291
6226
|
() => data.filter((row) => !row.disabled),
|
|
6292
6227
|
[data]
|
|
6293
6228
|
);
|
|
@@ -6297,13 +6232,22 @@ function ListViewInner({
|
|
|
6297
6232
|
);
|
|
6298
6233
|
const activeRowId = activeRowIdProp !== void 0 ? activeRowIdProp : uncontrolledActiveRowId;
|
|
6299
6234
|
const resolvedActiveRowId = activeRowId && selectableRows.some((row) => row.id === activeRowId) ? activeRowId : getInitialActiveRowId(selectableRows, selectedId);
|
|
6300
|
-
const templateColumns =
|
|
6235
|
+
const templateColumns = useMemo11(() => {
|
|
6301
6236
|
const checkboxColumn = showCheckBox ? "var(--nu-glyph-cell-size)" : null;
|
|
6302
6237
|
const dataColumns = columns.map(
|
|
6303
6238
|
(column) => column.width ?? "minmax(0, 1fr)"
|
|
6304
6239
|
);
|
|
6305
6240
|
return [checkboxColumn, ...dataColumns].filter(Boolean).join(" ");
|
|
6306
6241
|
}, [columns, showCheckBox]);
|
|
6242
|
+
const dropTargetOptions = useMemo11(
|
|
6243
|
+
() => onDrop ? { accepts: acceptsDrop, onDrop, type: "list-view" } : void 0,
|
|
6244
|
+
[acceptsDrop, onDrop]
|
|
6245
|
+
);
|
|
6246
|
+
useNuDropTarget(rootElement, dropTargetOptions);
|
|
6247
|
+
const setRootRef = useCallback7((node) => {
|
|
6248
|
+
rootRef.current = node;
|
|
6249
|
+
setRootElement(node);
|
|
6250
|
+
}, []);
|
|
6307
6251
|
useEffect11(() => {
|
|
6308
6252
|
if (!resolvedActiveRowId) {
|
|
6309
6253
|
return;
|
|
@@ -6312,13 +6256,13 @@ function ListViewInner({
|
|
|
6312
6256
|
block: "nearest"
|
|
6313
6257
|
});
|
|
6314
6258
|
}, [resolvedActiveRowId]);
|
|
6315
|
-
const registerRowRef =
|
|
6259
|
+
const registerRowRef = useCallback7(
|
|
6316
6260
|
(rowId, node) => {
|
|
6317
6261
|
rowRefs.current[rowId] = node;
|
|
6318
6262
|
},
|
|
6319
6263
|
[]
|
|
6320
6264
|
);
|
|
6321
|
-
const updateActiveRow =
|
|
6265
|
+
const updateActiveRow = useCallback7(
|
|
6322
6266
|
(row) => {
|
|
6323
6267
|
if (!isActiveControlled) {
|
|
6324
6268
|
setUncontrolledActiveRowId(row.id);
|
|
@@ -6327,7 +6271,7 @@ function ListViewInner({
|
|
|
6327
6271
|
},
|
|
6328
6272
|
[isActiveControlled, onActiveRowChange]
|
|
6329
6273
|
);
|
|
6330
|
-
const activateRowId =
|
|
6274
|
+
const activateRowId = useCallback7(
|
|
6331
6275
|
(rowId) => {
|
|
6332
6276
|
if (!rowId) {
|
|
6333
6277
|
return;
|
|
@@ -6366,7 +6310,7 @@ function ListViewInner({
|
|
|
6366
6310
|
function isRowChecked(row) {
|
|
6367
6311
|
return getListViewRowChecked(row, checkedIds);
|
|
6368
6312
|
}
|
|
6369
|
-
const toggleRowCheck =
|
|
6313
|
+
const toggleRowCheck = useCallback7(
|
|
6370
6314
|
(rowId) => {
|
|
6371
6315
|
if (!showCheckBox) {
|
|
6372
6316
|
return;
|
|
@@ -6435,18 +6379,18 @@ function ListViewInner({
|
|
|
6435
6379
|
break;
|
|
6436
6380
|
}
|
|
6437
6381
|
}
|
|
6438
|
-
return /* @__PURE__ */
|
|
6382
|
+
return /* @__PURE__ */ jsxs27(
|
|
6439
6383
|
"div",
|
|
6440
6384
|
{
|
|
6441
6385
|
...props,
|
|
6442
6386
|
"aria-activedescendant": resolvedActiveRowId ?? void 0,
|
|
6443
6387
|
className: ["nu-list-view", className].filter(Boolean).join(" "),
|
|
6444
6388
|
onKeyDown: handleKeyDown,
|
|
6445
|
-
ref:
|
|
6389
|
+
ref: setRootRef,
|
|
6446
6390
|
role: "grid",
|
|
6447
6391
|
tabIndex: 0,
|
|
6448
6392
|
children: [
|
|
6449
|
-
/* @__PURE__ */
|
|
6393
|
+
/* @__PURE__ */ jsxs27(
|
|
6450
6394
|
"div",
|
|
6451
6395
|
{
|
|
6452
6396
|
className: "nu-list-view__header",
|
|
@@ -6476,13 +6420,16 @@ function ListViewInner({
|
|
|
6476
6420
|
ListViewRow,
|
|
6477
6421
|
{
|
|
6478
6422
|
columns,
|
|
6423
|
+
getDragItem,
|
|
6479
6424
|
isActive: row.id === resolvedActiveRowId,
|
|
6480
6425
|
isChecked: isRowChecked(row),
|
|
6481
6426
|
isSelected: row.id === selectedId,
|
|
6482
6427
|
onActivate: activateRowId,
|
|
6483
6428
|
onDoubleClick: onRowDoubleClick,
|
|
6429
|
+
onDragOut: onRowDragOut,
|
|
6484
6430
|
onToggleCheck: toggleRowCheck,
|
|
6485
6431
|
registerRowRef,
|
|
6432
|
+
renderDragPreview,
|
|
6486
6433
|
row,
|
|
6487
6434
|
showCheckBox,
|
|
6488
6435
|
templateColumns,
|
|
@@ -6494,13 +6441,16 @@ function ListViewInner({
|
|
|
6494
6441
|
}
|
|
6495
6442
|
);
|
|
6496
6443
|
}
|
|
6497
|
-
|
|
6444
|
+
function ListViewWithDragDrop(props, ref) {
|
|
6445
|
+
return /* @__PURE__ */ jsx45(NuDragDropProvider, { children: ListViewInner(props, ref) });
|
|
6446
|
+
}
|
|
6447
|
+
var ListView = forwardRef2(ListViewWithDragDrop);
|
|
6498
6448
|
|
|
6499
6449
|
// src/components/MaskedField/MaskedField.tsx
|
|
6500
6450
|
import {
|
|
6501
6451
|
useEffect as useEffect12,
|
|
6502
6452
|
useId as useId7,
|
|
6503
|
-
useMemo as
|
|
6453
|
+
useMemo as useMemo12,
|
|
6504
6454
|
useRef as useRef16,
|
|
6505
6455
|
useState as useState20
|
|
6506
6456
|
} from "react";
|
|
@@ -6667,7 +6617,7 @@ function getMaskedFieldState(mask, rawValue) {
|
|
|
6667
6617
|
}
|
|
6668
6618
|
|
|
6669
6619
|
// src/components/MaskedField/MaskedField.tsx
|
|
6670
|
-
import { jsx as jsx46, jsxs as
|
|
6620
|
+
import { jsx as jsx46, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
6671
6621
|
function MaskedField({
|
|
6672
6622
|
"aria-invalid": ariaInvalid,
|
|
6673
6623
|
className,
|
|
@@ -6700,7 +6650,7 @@ function MaskedField({
|
|
|
6700
6650
|
rawResolvedValue
|
|
6701
6651
|
);
|
|
6702
6652
|
const resolvedAriaInvalid = ariaInvalid ?? (isInvalid ? true : void 0);
|
|
6703
|
-
const maskInputMode =
|
|
6653
|
+
const maskInputMode = useMemo12(
|
|
6704
6654
|
() => props.inputMode === void 0 ? getTextMaskInputMode(mask) : void 0,
|
|
6705
6655
|
[mask, props.inputMode]
|
|
6706
6656
|
);
|
|
@@ -6739,7 +6689,7 @@ function MaskedField({
|
|
|
6739
6689
|
}
|
|
6740
6690
|
onChange?.(event);
|
|
6741
6691
|
}
|
|
6742
|
-
return /* @__PURE__ */
|
|
6692
|
+
return /* @__PURE__ */ jsxs28(
|
|
6743
6693
|
"label",
|
|
6744
6694
|
{
|
|
6745
6695
|
className: cx(
|
|
@@ -6759,7 +6709,7 @@ function MaskedField({
|
|
|
6759
6709
|
children: renderMnemonicText(label)
|
|
6760
6710
|
}
|
|
6761
6711
|
),
|
|
6762
|
-
/* @__PURE__ */
|
|
6712
|
+
/* @__PURE__ */ jsxs28(
|
|
6763
6713
|
"span",
|
|
6764
6714
|
{
|
|
6765
6715
|
className: cx("nu-masked-field__slot", slotClassNames?.slot),
|
|
@@ -6889,11 +6839,11 @@ function Memo({
|
|
|
6889
6839
|
// src/components/PageControl/PageControl.tsx
|
|
6890
6840
|
import {
|
|
6891
6841
|
useId as useId8,
|
|
6892
|
-
useMemo as
|
|
6842
|
+
useMemo as useMemo13,
|
|
6893
6843
|
useRef as useRef17,
|
|
6894
6844
|
useState as useState22
|
|
6895
6845
|
} from "react";
|
|
6896
|
-
import { jsx as jsx48, jsxs as
|
|
6846
|
+
import { jsx as jsx48, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
6897
6847
|
function PageControl({
|
|
6898
6848
|
activePageId: activePageIdProp,
|
|
6899
6849
|
className,
|
|
@@ -6912,7 +6862,7 @@ function PageControl({
|
|
|
6912
6862
|
() => defaultActivePageId ?? pages.find((page) => !page.disabled)?.id ?? pages[0]?.id
|
|
6913
6863
|
);
|
|
6914
6864
|
const activePageId = isControlled ? activePageIdProp : uncontrolledActivePageId;
|
|
6915
|
-
const resolvedActivePage =
|
|
6865
|
+
const resolvedActivePage = useMemo13(() => {
|
|
6916
6866
|
const byId = pages.find(
|
|
6917
6867
|
(page) => page.id === activePageId && !page.disabled
|
|
6918
6868
|
);
|
|
@@ -6978,7 +6928,7 @@ function PageControl({
|
|
|
6978
6928
|
break;
|
|
6979
6929
|
}
|
|
6980
6930
|
}
|
|
6981
|
-
return /* @__PURE__ */
|
|
6931
|
+
return /* @__PURE__ */ jsxs29(
|
|
6982
6932
|
"div",
|
|
6983
6933
|
{
|
|
6984
6934
|
...props,
|
|
@@ -7041,7 +6991,7 @@ function PageControl({
|
|
|
7041
6991
|
}
|
|
7042
6992
|
|
|
7043
6993
|
// src/components/Panel/Panel.tsx
|
|
7044
|
-
import { jsx as jsx49, jsxs as
|
|
6994
|
+
import { jsx as jsx49, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
7045
6995
|
function Panel({
|
|
7046
6996
|
children,
|
|
7047
6997
|
className,
|
|
@@ -7052,7 +7002,7 @@ function Panel({
|
|
|
7052
7002
|
title,
|
|
7053
7003
|
...props
|
|
7054
7004
|
}) {
|
|
7055
|
-
return /* @__PURE__ */
|
|
7005
|
+
return /* @__PURE__ */ jsxs30(
|
|
7056
7006
|
"section",
|
|
7057
7007
|
{
|
|
7058
7008
|
...props,
|
|
@@ -7095,11 +7045,11 @@ function Panel({
|
|
|
7095
7045
|
// src/components/PropertyGrid/PropertyGrid.tsx
|
|
7096
7046
|
import {
|
|
7097
7047
|
useId as useId9,
|
|
7098
|
-
useMemo as
|
|
7048
|
+
useMemo as useMemo14,
|
|
7099
7049
|
useRef as useRef18,
|
|
7100
7050
|
useState as useState23
|
|
7101
7051
|
} from "react";
|
|
7102
|
-
import { jsx as jsx50, jsxs as
|
|
7052
|
+
import { jsx as jsx50, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
7103
7053
|
function collectGroupIds(entries) {
|
|
7104
7054
|
const groupIds = /* @__PURE__ */ new Set();
|
|
7105
7055
|
function visit(nextEntries) {
|
|
@@ -7208,22 +7158,22 @@ function PropertyGrid({
|
|
|
7208
7158
|
}) {
|
|
7209
7159
|
const editorIdPrefix = useId9();
|
|
7210
7160
|
const rowButtonRefs = useRef18({});
|
|
7211
|
-
const groupIds =
|
|
7161
|
+
const groupIds = useMemo14(() => collectGroupIds(entries), [entries]);
|
|
7212
7162
|
const isExpandedControlled = expandedIdsProp !== void 0;
|
|
7213
7163
|
const isActiveControlled = activeIdProp !== void 0;
|
|
7214
7164
|
const [uncontrolledExpandedIds, setUncontrolledExpandedIds] = useState23(() => getInitialExpandedIds(entries, defaultExpandedIds));
|
|
7215
7165
|
const resolvedExpandedIds = expandedIdsProp ?? uncontrolledExpandedIds;
|
|
7216
|
-
const expandedIdSet =
|
|
7166
|
+
const expandedIdSet = useMemo14(
|
|
7217
7167
|
() => new Set(
|
|
7218
7168
|
resolvedExpandedIds.filter((expandedId) => groupIds.has(expandedId))
|
|
7219
7169
|
),
|
|
7220
7170
|
[groupIds, resolvedExpandedIds]
|
|
7221
7171
|
);
|
|
7222
|
-
const rows =
|
|
7172
|
+
const rows = useMemo14(
|
|
7223
7173
|
() => collectVisibleRows(entries, expandedIdSet),
|
|
7224
7174
|
[entries, expandedIdSet]
|
|
7225
7175
|
);
|
|
7226
|
-
const interactiveRows =
|
|
7176
|
+
const interactiveRows = useMemo14(() => collectInteractiveRows(rows), [rows]);
|
|
7227
7177
|
const [uncontrolledActiveId, setUncontrolledActiveId] = useState23(() => getInitialActiveId2(interactiveRows, defaultActiveId));
|
|
7228
7178
|
const requestedActiveId = isActiveControlled ? activeIdProp : uncontrolledActiveId;
|
|
7229
7179
|
const resolvedActiveId = requestedActiveId && interactiveRows.some((row) => row.id === requestedActiveId) ? requestedActiveId : interactiveRows[0]?.id;
|
|
@@ -7360,7 +7310,7 @@ function PropertyGrid({
|
|
|
7360
7310
|
}
|
|
7361
7311
|
if (row.type === "group") {
|
|
7362
7312
|
const isExpanded = expandedIdSet.has(row.entry.id);
|
|
7363
|
-
return /* @__PURE__ */
|
|
7313
|
+
return /* @__PURE__ */ jsxs31(
|
|
7364
7314
|
"div",
|
|
7365
7315
|
{
|
|
7366
7316
|
className: "nu-property-grid__row",
|
|
@@ -7389,7 +7339,7 @@ function PropertyGrid({
|
|
|
7389
7339
|
"--nu-property-grid-depth": row.depth
|
|
7390
7340
|
},
|
|
7391
7341
|
type: "button",
|
|
7392
|
-
children: /* @__PURE__ */
|
|
7342
|
+
children: /* @__PURE__ */ jsxs31("span", { className: "nu-property-grid__lead", children: [
|
|
7393
7343
|
/* @__PURE__ */ jsx50("span", { className: "nu-property-grid__expander", children: /* @__PURE__ */ jsx50(
|
|
7394
7344
|
NuGlyph,
|
|
7395
7345
|
{
|
|
@@ -7407,7 +7357,7 @@ function PropertyGrid({
|
|
|
7407
7357
|
);
|
|
7408
7358
|
}
|
|
7409
7359
|
const editorId = `${editorIdPrefix}-editor-${row.entry.id}`;
|
|
7410
|
-
return /* @__PURE__ */
|
|
7360
|
+
return /* @__PURE__ */ jsxs31(
|
|
7411
7361
|
"div",
|
|
7412
7362
|
{
|
|
7413
7363
|
className: "nu-property-grid__row",
|
|
@@ -7434,13 +7384,13 @@ function PropertyGrid({
|
|
|
7434
7384
|
"--nu-property-grid-depth": row.depth
|
|
7435
7385
|
},
|
|
7436
7386
|
type: "button",
|
|
7437
|
-
children: /* @__PURE__ */
|
|
7387
|
+
children: /* @__PURE__ */ jsxs31("span", { className: "nu-property-grid__lead", children: [
|
|
7438
7388
|
/* @__PURE__ */ jsx50("span", { className: "nu-property-grid__expander-placeholder" }),
|
|
7439
7389
|
/* @__PURE__ */ jsx50("span", { className: "nu-property-grid__label-text", children: renderMnemonicText(row.entry.label) })
|
|
7440
7390
|
] })
|
|
7441
7391
|
}
|
|
7442
7392
|
),
|
|
7443
|
-
/* @__PURE__ */
|
|
7393
|
+
/* @__PURE__ */ jsxs31(
|
|
7444
7394
|
"div",
|
|
7445
7395
|
{
|
|
7446
7396
|
className: "nu-property-grid__editor",
|
|
@@ -7462,7 +7412,7 @@ function PropertyGrid({
|
|
|
7462
7412
|
}
|
|
7463
7413
|
|
|
7464
7414
|
// src/components/ProgressBar/ProgressBar.tsx
|
|
7465
|
-
import { jsx as jsx51, jsxs as
|
|
7415
|
+
import { jsx as jsx51, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
7466
7416
|
function clamp3(value, min, max) {
|
|
7467
7417
|
return Math.min(max, Math.max(min, value));
|
|
7468
7418
|
}
|
|
@@ -7486,7 +7436,7 @@ function ProgressBar({
|
|
|
7486
7436
|
const clampedValue = clamp3(value, min, safeMax);
|
|
7487
7437
|
const percent = Math.round((clampedValue - min) / (safeMax - min) * 100);
|
|
7488
7438
|
const renderedValue = valueRenderer ? valueRenderer(percent, clampedValue, min, safeMax) : `${percent}%`;
|
|
7489
|
-
return /* @__PURE__ */
|
|
7439
|
+
return /* @__PURE__ */ jsxs32(
|
|
7490
7440
|
"div",
|
|
7491
7441
|
{
|
|
7492
7442
|
...props,
|
|
@@ -7506,7 +7456,7 @@ function ProgressBar({
|
|
|
7506
7456
|
children: renderMnemonicText(label)
|
|
7507
7457
|
}
|
|
7508
7458
|
) : null,
|
|
7509
|
-
/* @__PURE__ */
|
|
7459
|
+
/* @__PURE__ */ jsxs32(
|
|
7510
7460
|
"div",
|
|
7511
7461
|
{
|
|
7512
7462
|
className: cx("nu-progress-bar__track", slotClassNames?.track),
|
|
@@ -7556,7 +7506,7 @@ function ProgressBar({
|
|
|
7556
7506
|
|
|
7557
7507
|
// src/components/RadioGroup/RadioButton.tsx
|
|
7558
7508
|
import { useId as useId10, useState as useState24 } from "react";
|
|
7559
|
-
import { jsx as jsx52, jsxs as
|
|
7509
|
+
import { jsx as jsx52, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
7560
7510
|
function RadioButton({
|
|
7561
7511
|
checked,
|
|
7562
7512
|
className,
|
|
@@ -7580,8 +7530,8 @@ function RadioButton({
|
|
|
7580
7530
|
}
|
|
7581
7531
|
onCheckedChange?.(event.target.checked, event);
|
|
7582
7532
|
}
|
|
7583
|
-
return /* @__PURE__ */
|
|
7584
|
-
/* @__PURE__ */
|
|
7533
|
+
return /* @__PURE__ */ jsxs33("label", { className: ["nu-radio-button", className].filter(Boolean).join(" "), children: [
|
|
7534
|
+
/* @__PURE__ */ jsxs33("span", { className: "nu-radio-button__main", children: [
|
|
7585
7535
|
/* @__PURE__ */ jsx52(
|
|
7586
7536
|
"input",
|
|
7587
7537
|
{
|
|
@@ -7595,7 +7545,7 @@ function RadioButton({
|
|
|
7595
7545
|
type: "radio"
|
|
7596
7546
|
}
|
|
7597
7547
|
),
|
|
7598
|
-
/* @__PURE__ */ jsx52("span", { "aria-hidden": "true", className: "nu-radio-button__control", children: /* @__PURE__ */
|
|
7548
|
+
/* @__PURE__ */ jsx52("span", { "aria-hidden": "true", className: "nu-radio-button__control", children: /* @__PURE__ */ jsxs33("span", { className: "nu-radio-button__disc", children: [
|
|
7599
7549
|
/* @__PURE__ */ jsx52(NuGlyph, { className: "nu-radio-button__ring", name: "radio-ring" }),
|
|
7600
7550
|
resolvedChecked ? /* @__PURE__ */ jsx52(NuGlyph, { className: "nu-radio-button__fill", name: "radio-fill" }) : null
|
|
7601
7551
|
] }) }),
|
|
@@ -7607,7 +7557,7 @@ function RadioButton({
|
|
|
7607
7557
|
|
|
7608
7558
|
// src/components/RadioGroup/RadioGroup.tsx
|
|
7609
7559
|
import { useId as useId11, useState as useState25 } from "react";
|
|
7610
|
-
import { jsx as jsx53, jsxs as
|
|
7560
|
+
import { jsx as jsx53, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
7611
7561
|
function RadioGroup({
|
|
7612
7562
|
className,
|
|
7613
7563
|
defaultValue,
|
|
@@ -7634,7 +7584,7 @@ function RadioGroup({
|
|
|
7634
7584
|
}
|
|
7635
7585
|
onValueChange?.(nextValue);
|
|
7636
7586
|
}
|
|
7637
|
-
return /* @__PURE__ */
|
|
7587
|
+
return /* @__PURE__ */ jsxs34(
|
|
7638
7588
|
"fieldset",
|
|
7639
7589
|
{
|
|
7640
7590
|
...props,
|
|
@@ -7714,12 +7664,12 @@ function ReportCell({
|
|
|
7714
7664
|
import {
|
|
7715
7665
|
useEffect as useEffect13,
|
|
7716
7666
|
useId as useId12,
|
|
7717
|
-
useMemo as
|
|
7667
|
+
useMemo as useMemo15,
|
|
7718
7668
|
useRef as useRef19,
|
|
7719
7669
|
useState as useState26
|
|
7720
7670
|
} from "react";
|
|
7721
7671
|
import { createPortal as createPortal4 } from "react-dom";
|
|
7722
|
-
import { jsx as jsx55, jsxs as
|
|
7672
|
+
import { jsx as jsx55, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
7723
7673
|
function resolveSearchBoxPortalRoot() {
|
|
7724
7674
|
return document.body;
|
|
7725
7675
|
}
|
|
@@ -7764,7 +7714,7 @@ function SearchBox({
|
|
|
7764
7714
|
const [selectedValue, setSelectedValue] = useState26(null);
|
|
7765
7715
|
const normalizedQuery = (isQueryControlled ? queryProp : uncontrolledQuery) ?? "";
|
|
7766
7716
|
const trimmedQuery = normalizedQuery.trim();
|
|
7767
|
-
const resultOptions =
|
|
7717
|
+
const resultOptions = useMemo15(() => {
|
|
7768
7718
|
return results.map((item, index) => ({
|
|
7769
7719
|
item,
|
|
7770
7720
|
listBoxItem: {
|
|
@@ -7778,7 +7728,7 @@ function SearchBox({
|
|
|
7778
7728
|
value: getItemId(item, index)
|
|
7779
7729
|
}));
|
|
7780
7730
|
}, [getItemDetails, getItemDisabled, getItemId, getItemText, results]);
|
|
7781
|
-
const listBoxData =
|
|
7731
|
+
const listBoxData = useMemo15(
|
|
7782
7732
|
() => [
|
|
7783
7733
|
{
|
|
7784
7734
|
category: null,
|
|
@@ -7914,7 +7864,7 @@ function SearchBox({
|
|
|
7914
7864
|
break;
|
|
7915
7865
|
}
|
|
7916
7866
|
}
|
|
7917
|
-
return /* @__PURE__ */
|
|
7867
|
+
return /* @__PURE__ */ jsxs35(
|
|
7918
7868
|
"div",
|
|
7919
7869
|
{
|
|
7920
7870
|
...props,
|
|
@@ -7923,7 +7873,7 @@ function SearchBox({
|
|
|
7923
7873
|
style,
|
|
7924
7874
|
children: [
|
|
7925
7875
|
/* @__PURE__ */ jsx55("label", { className: "nu-search-box__label", htmlFor: fieldId, id: labelId, children: renderMnemonicText(label) }),
|
|
7926
|
-
/* @__PURE__ */
|
|
7876
|
+
/* @__PURE__ */ jsxs35("span", { className: "nu-search-box__slot", ref: fieldRef, children: [
|
|
7927
7877
|
/* @__PURE__ */ jsx55("span", { "aria-hidden": "true", className: "nu-search-box__bracket", children: "[" }),
|
|
7928
7878
|
/* @__PURE__ */ jsx55("span", { className: "nu-search-box__input-shell", children: /* @__PURE__ */ jsx55(
|
|
7929
7879
|
"input",
|
|
@@ -7974,10 +7924,10 @@ function SearchBox({
|
|
|
7974
7924
|
// src/components/SpinBox/SpinBox.tsx
|
|
7975
7925
|
import {
|
|
7976
7926
|
useId as useId13,
|
|
7977
|
-
useMemo as
|
|
7927
|
+
useMemo as useMemo16,
|
|
7978
7928
|
useState as useState27
|
|
7979
7929
|
} from "react";
|
|
7980
|
-
import { jsx as jsx56, jsxs as
|
|
7930
|
+
import { jsx as jsx56, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
7981
7931
|
function clampSpinValue(value, min, max) {
|
|
7982
7932
|
let nextValue = value;
|
|
7983
7933
|
if (min !== void 0) {
|
|
@@ -8082,15 +8032,15 @@ function SpinBox({
|
|
|
8082
8032
|
}
|
|
8083
8033
|
onKeyDown?.(event);
|
|
8084
8034
|
}
|
|
8085
|
-
const decrementDisabled =
|
|
8035
|
+
const decrementDisabled = useMemo16(
|
|
8086
8036
|
() => disabled || min !== void 0 && numericValue <= min,
|
|
8087
8037
|
[disabled, min, numericValue]
|
|
8088
8038
|
);
|
|
8089
|
-
const incrementDisabled =
|
|
8039
|
+
const incrementDisabled = useMemo16(
|
|
8090
8040
|
() => disabled || max !== void 0 && numericValue >= max,
|
|
8091
8041
|
[disabled, max, numericValue]
|
|
8092
8042
|
);
|
|
8093
|
-
return /* @__PURE__ */
|
|
8043
|
+
return /* @__PURE__ */ jsxs36(
|
|
8094
8044
|
"label",
|
|
8095
8045
|
{
|
|
8096
8046
|
className: cx("nu-spin-box", slotClassNames?.root, className),
|
|
@@ -8105,7 +8055,7 @@ function SpinBox({
|
|
|
8105
8055
|
children: renderMnemonicText(label)
|
|
8106
8056
|
}
|
|
8107
8057
|
),
|
|
8108
|
-
/* @__PURE__ */
|
|
8058
|
+
/* @__PURE__ */ jsxs36(
|
|
8109
8059
|
"span",
|
|
8110
8060
|
{
|
|
8111
8061
|
className: cx("nu-spin-box__slot", slotClassNames?.slot),
|
|
@@ -8153,7 +8103,7 @@ function SpinBox({
|
|
|
8153
8103
|
children: "]"
|
|
8154
8104
|
}
|
|
8155
8105
|
),
|
|
8156
|
-
/* @__PURE__ */
|
|
8106
|
+
/* @__PURE__ */ jsxs36(
|
|
8157
8107
|
"span",
|
|
8158
8108
|
{
|
|
8159
8109
|
className: cx("nu-spin-box__controls", slotClassNames?.controls),
|
|
@@ -8208,7 +8158,7 @@ import {
|
|
|
8208
8158
|
useRef as useRef20,
|
|
8209
8159
|
useState as useState28
|
|
8210
8160
|
} from "react";
|
|
8211
|
-
import { jsx as jsx57, jsxs as
|
|
8161
|
+
import { jsx as jsx57, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
8212
8162
|
function clamp4(value, min, max) {
|
|
8213
8163
|
return Math.min(max, Math.max(min, value));
|
|
8214
8164
|
}
|
|
@@ -8363,7 +8313,7 @@ function Splitter({
|
|
|
8363
8313
|
commitValue(max);
|
|
8364
8314
|
}
|
|
8365
8315
|
}
|
|
8366
|
-
return /* @__PURE__ */
|
|
8316
|
+
return /* @__PURE__ */ jsxs37(
|
|
8367
8317
|
"div",
|
|
8368
8318
|
{
|
|
8369
8319
|
...props,
|
|
@@ -8409,11 +8359,11 @@ function Splitter({
|
|
|
8409
8359
|
import {
|
|
8410
8360
|
useEffect as useEffect15,
|
|
8411
8361
|
useId as useId15,
|
|
8412
|
-
useMemo as
|
|
8362
|
+
useMemo as useMemo17,
|
|
8413
8363
|
useRef as useRef21,
|
|
8414
8364
|
useState as useState29
|
|
8415
8365
|
} from "react";
|
|
8416
|
-
import { jsx as jsx58, jsxs as
|
|
8366
|
+
import { jsx as jsx58, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
8417
8367
|
function clamp5(value, min, max) {
|
|
8418
8368
|
return Math.min(max, Math.max(min, value));
|
|
8419
8369
|
}
|
|
@@ -8463,7 +8413,7 @@ function TickBar({
|
|
|
8463
8413
|
const trackRef = useRef21(null);
|
|
8464
8414
|
const resolvedValue = isControlled ? clamp5(snapToStep(value ?? initialValue, min, safeStep), min, safeMax) : uncontrolledValue;
|
|
8465
8415
|
const ratio = safeMax === min ? 0 : (resolvedValue - min) / (safeMax - min);
|
|
8466
|
-
const derivedTickCount =
|
|
8416
|
+
const derivedTickCount = useMemo17(() => {
|
|
8467
8417
|
if (tickCount !== void 0) {
|
|
8468
8418
|
return Math.max(2, tickCount);
|
|
8469
8419
|
}
|
|
@@ -8549,7 +8499,7 @@ function TickBar({
|
|
|
8549
8499
|
}
|
|
8550
8500
|
onKeyDown?.(event);
|
|
8551
8501
|
}
|
|
8552
|
-
return /* @__PURE__ */
|
|
8502
|
+
return /* @__PURE__ */ jsxs38(
|
|
8553
8503
|
"div",
|
|
8554
8504
|
{
|
|
8555
8505
|
...props,
|
|
@@ -8570,13 +8520,13 @@ function TickBar({
|
|
|
8570
8520
|
children: renderMnemonicText(label)
|
|
8571
8521
|
}
|
|
8572
8522
|
) : null,
|
|
8573
|
-
/* @__PURE__ */
|
|
8523
|
+
/* @__PURE__ */ jsxs38(
|
|
8574
8524
|
"div",
|
|
8575
8525
|
{
|
|
8576
8526
|
className: cx("nu-tick-bar__slot", slotClassNames?.slot),
|
|
8577
8527
|
style: slotStyles?.slot,
|
|
8578
8528
|
children: [
|
|
8579
|
-
/* @__PURE__ */
|
|
8529
|
+
/* @__PURE__ */ jsxs38(
|
|
8580
8530
|
"div",
|
|
8581
8531
|
{
|
|
8582
8532
|
"aria-describedby": hintId,
|
|
@@ -8685,7 +8635,7 @@ function TickBar({
|
|
|
8685
8635
|
}
|
|
8686
8636
|
|
|
8687
8637
|
// src/components/ToolBar/ToolBar.tsx
|
|
8688
|
-
import { jsx as jsx59, jsxs as
|
|
8638
|
+
import { jsx as jsx59, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
8689
8639
|
function ToolBar({
|
|
8690
8640
|
children,
|
|
8691
8641
|
className,
|
|
@@ -8697,7 +8647,7 @@ function ToolBar({
|
|
|
8697
8647
|
wrap = false,
|
|
8698
8648
|
...props
|
|
8699
8649
|
}) {
|
|
8700
|
-
return /* @__PURE__ */
|
|
8650
|
+
return /* @__PURE__ */ jsxs39(
|
|
8701
8651
|
"div",
|
|
8702
8652
|
{
|
|
8703
8653
|
...props,
|
|
@@ -8794,11 +8744,11 @@ function ToolSeparator({ className, ...props }) {
|
|
|
8794
8744
|
// src/components/TreeView/TreeView.tsx
|
|
8795
8745
|
import {
|
|
8796
8746
|
forwardRef as forwardRef3,
|
|
8797
|
-
useCallback as
|
|
8747
|
+
useCallback as useCallback8,
|
|
8798
8748
|
useEffect as useEffect16,
|
|
8799
8749
|
useId as useId16,
|
|
8800
8750
|
useImperativeHandle as useImperativeHandle3,
|
|
8801
|
-
useMemo as
|
|
8751
|
+
useMemo as useMemo18,
|
|
8802
8752
|
useRef as useRef22,
|
|
8803
8753
|
useState as useState30
|
|
8804
8754
|
} from "react";
|
|
@@ -8898,7 +8848,7 @@ function collectVisibleTreeItems(items, expandedIds, depth = 0, guideMask = [],
|
|
|
8898
8848
|
|
|
8899
8849
|
// src/components/TreeView/internals/TreeViewItem.tsx
|
|
8900
8850
|
import { memo as memo4 } from "react";
|
|
8901
|
-
import { jsx as jsx60, jsxs as
|
|
8851
|
+
import { jsx as jsx60, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
8902
8852
|
function areTreeViewGuideArraysEqual(previousArray, nextArray) {
|
|
8903
8853
|
if (previousArray.length !== nextArray.length) {
|
|
8904
8854
|
return false;
|
|
@@ -8972,8 +8922,8 @@ function TreeViewItemInner({
|
|
|
8972
8922
|
handleActivate();
|
|
8973
8923
|
onToggleItemCheck?.(item, !isChecked);
|
|
8974
8924
|
}
|
|
8975
|
-
return /* @__PURE__ */
|
|
8976
|
-
/* @__PURE__ */
|
|
8925
|
+
return /* @__PURE__ */ jsxs40("div", { className: "nu-tree-view__row", role: "none", children: [
|
|
8926
|
+
/* @__PURE__ */ jsxs40(
|
|
8977
8927
|
"div",
|
|
8978
8928
|
{
|
|
8979
8929
|
"aria-checked": isCheckable ? isChecked : void 0,
|
|
@@ -8992,7 +8942,7 @@ function TreeViewItemInner({
|
|
|
8992
8942
|
ref: (node) => registerItemRef(itemId, node),
|
|
8993
8943
|
role: "treeitem",
|
|
8994
8944
|
children: [
|
|
8995
|
-
/* @__PURE__ */
|
|
8945
|
+
/* @__PURE__ */ jsxs40("span", { "aria-hidden": "true", className: "nu-tree-view__prefix", children: [
|
|
8996
8946
|
guideMask.map((hasGuide, guideIndex) => /* @__PURE__ */ jsx60(
|
|
8997
8947
|
"span",
|
|
8998
8948
|
{
|
|
@@ -9004,7 +8954,7 @@ function TreeViewItemInner({
|
|
|
9004
8954
|
},
|
|
9005
8955
|
`${itemId}-guide-${guideIndex}`
|
|
9006
8956
|
)),
|
|
9007
|
-
/* @__PURE__ */
|
|
8957
|
+
/* @__PURE__ */ jsxs40(
|
|
9008
8958
|
"span",
|
|
9009
8959
|
{
|
|
9010
8960
|
className: "nu-tree-view__lead",
|
|
@@ -9052,7 +9002,7 @@ function TreeViewItemInner({
|
|
|
9052
9002
|
}
|
|
9053
9003
|
)
|
|
9054
9004
|
] }),
|
|
9055
|
-
/* @__PURE__ */
|
|
9005
|
+
/* @__PURE__ */ jsxs40("span", { className: "nu-tree-view__content", children: [
|
|
9056
9006
|
isCheckable ? /* @__PURE__ */ jsx60("span", { className: "nu-tree-view__check-slot", children: /* @__PURE__ */ jsx60(
|
|
9057
9007
|
"button",
|
|
9058
9008
|
{
|
|
@@ -9148,15 +9098,15 @@ function TreeViewInner({
|
|
|
9148
9098
|
});
|
|
9149
9099
|
const [uncontrolledSelectedId, setUncontrolledSelectedId] = useState30(null);
|
|
9150
9100
|
const resolvedExpandedIds = isExpandedControlled ? expandedIds : uncontrolledExpandedIds;
|
|
9151
|
-
const expandedIdSet =
|
|
9101
|
+
const expandedIdSet = useMemo18(
|
|
9152
9102
|
() => new Set(resolvedExpandedIds),
|
|
9153
9103
|
[resolvedExpandedIds]
|
|
9154
9104
|
);
|
|
9155
|
-
const visibleItems =
|
|
9105
|
+
const visibleItems = useMemo18(
|
|
9156
9106
|
() => collectVisibleTreeItems(data, expandedIdSet),
|
|
9157
9107
|
[data, expandedIdSet]
|
|
9158
9108
|
);
|
|
9159
|
-
const selectableItems =
|
|
9109
|
+
const selectableItems = useMemo18(
|
|
9160
9110
|
() => visibleItems.filter(({ item }) => !item.disabled),
|
|
9161
9111
|
[visibleItems]
|
|
9162
9112
|
);
|
|
@@ -9172,13 +9122,13 @@ function TreeViewInner({
|
|
|
9172
9122
|
block: "nearest"
|
|
9173
9123
|
});
|
|
9174
9124
|
}, [resolvedActiveId]);
|
|
9175
|
-
const registerItemRef =
|
|
9125
|
+
const registerItemRef = useCallback8(
|
|
9176
9126
|
(itemId, node) => {
|
|
9177
9127
|
itemRefs.current[itemId] = node;
|
|
9178
9128
|
},
|
|
9179
9129
|
[]
|
|
9180
9130
|
);
|
|
9181
|
-
const setExpandedState =
|
|
9131
|
+
const setExpandedState = useCallback8(
|
|
9182
9132
|
(item, nextExpanded) => {
|
|
9183
9133
|
const nextExpandedIds = nextExpanded ? Array.from(/* @__PURE__ */ new Set([...resolvedExpandedIds, item.id])) : resolvedExpandedIds.filter((expandedId) => expandedId !== item.id);
|
|
9184
9134
|
if (!isExpandedControlled) {
|
|
@@ -9188,7 +9138,7 @@ function TreeViewInner({
|
|
|
9188
9138
|
},
|
|
9189
9139
|
[isExpandedControlled, onExpandedIdsChange, resolvedExpandedIds]
|
|
9190
9140
|
);
|
|
9191
|
-
const activateEntry =
|
|
9141
|
+
const activateEntry = useCallback8(
|
|
9192
9142
|
(item, itemId) => {
|
|
9193
9143
|
if (item.disabled) {
|
|
9194
9144
|
return;
|
|
@@ -9201,7 +9151,7 @@ function TreeViewInner({
|
|
|
9201
9151
|
},
|
|
9202
9152
|
[onItemSelect, selectedId]
|
|
9203
9153
|
);
|
|
9204
|
-
const activateResolvedItem =
|
|
9154
|
+
const activateResolvedItem = useCallback8(
|
|
9205
9155
|
(itemId) => {
|
|
9206
9156
|
if (!itemId) {
|
|
9207
9157
|
return;
|
|
@@ -9410,12 +9360,12 @@ var TreeView = forwardRef3(TreeViewInner);
|
|
|
9410
9360
|
// src/components/TreeListView/TreeListView.tsx
|
|
9411
9361
|
import {
|
|
9412
9362
|
forwardRef as forwardRef4,
|
|
9413
|
-
useCallback as
|
|
9363
|
+
useCallback as useCallback9,
|
|
9414
9364
|
useEffect as useEffect17,
|
|
9415
9365
|
useId as useId17,
|
|
9416
9366
|
useImperativeHandle as useImperativeHandle4,
|
|
9417
9367
|
useLayoutEffect as useLayoutEffect6,
|
|
9418
|
-
useMemo as
|
|
9368
|
+
useMemo as useMemo19,
|
|
9419
9369
|
useRef as useRef23,
|
|
9420
9370
|
useState as useState31
|
|
9421
9371
|
} from "react";
|
|
@@ -9508,9 +9458,9 @@ function renderTreeListCellValue(item, column) {
|
|
|
9508
9458
|
|
|
9509
9459
|
// src/components/TreeListView/internals/TreeListViewRow.tsx
|
|
9510
9460
|
import { memo as memo5 } from "react";
|
|
9511
|
-
import { Fragment as Fragment7, jsx as jsx62, jsxs as
|
|
9461
|
+
import { Fragment as Fragment7, jsx as jsx62, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
9512
9462
|
function renderTreeTitleContent(item) {
|
|
9513
|
-
return /* @__PURE__ */
|
|
9463
|
+
return /* @__PURE__ */ jsxs41(Fragment7, { children: [
|
|
9514
9464
|
/* @__PURE__ */ jsx62("span", { className: "nu-tree-list-view__title", children: item.title }),
|
|
9515
9465
|
item.hint ? /* @__PURE__ */ jsx62("span", { className: "nu-tree-list-view__hint", children: item.hint }) : null
|
|
9516
9466
|
] });
|
|
@@ -9560,6 +9510,7 @@ function TreeListViewRowInner({
|
|
|
9560
9510
|
onActivateItem,
|
|
9561
9511
|
onDoubleClickItem,
|
|
9562
9512
|
onItemDragOut,
|
|
9513
|
+
renderDragPreview,
|
|
9563
9514
|
onPopupMenuItem,
|
|
9564
9515
|
onToggleItemCheck,
|
|
9565
9516
|
onToggleItemExpanded,
|
|
@@ -9591,6 +9542,7 @@ function TreeListViewRowInner({
|
|
|
9591
9542
|
disabled: item.disabled || !getDragItem,
|
|
9592
9543
|
getItem: () => getDragItem?.(item, dragContext) ?? false,
|
|
9593
9544
|
onDropAccepted: () => onItemDragOut?.(item, dragContext),
|
|
9545
|
+
renderPreview: renderDragPreview ? () => renderDragPreview(item, dragContext) : void 0,
|
|
9594
9546
|
sourceType: "tree-list-item"
|
|
9595
9547
|
});
|
|
9596
9548
|
function handleActivate() {
|
|
@@ -9638,7 +9590,7 @@ function TreeListViewRowInner({
|
|
|
9638
9590
|
handleActivate();
|
|
9639
9591
|
onToggleItemCheck?.(item, !isChecked);
|
|
9640
9592
|
}
|
|
9641
|
-
return /* @__PURE__ */
|
|
9593
|
+
return /* @__PURE__ */ jsxs41(Fragment7, { children: [
|
|
9642
9594
|
/* @__PURE__ */ jsx62(
|
|
9643
9595
|
"div",
|
|
9644
9596
|
{
|
|
@@ -9657,17 +9609,16 @@ function TreeListViewRowInner({
|
|
|
9657
9609
|
onClick: handleActivate,
|
|
9658
9610
|
onContextMenu: onPopupMenuItem ? handleContextMenu : void 0,
|
|
9659
9611
|
onDoubleClick: handleDoubleClick,
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
ref: (node) => registerItemRef(itemId, node),
|
|
9612
|
+
ref: (node) => {
|
|
9613
|
+
registerItemRef(itemId, node);
|
|
9614
|
+
dragSource.dragRef(node);
|
|
9615
|
+
},
|
|
9665
9616
|
role: "row",
|
|
9666
9617
|
style: {
|
|
9667
9618
|
"--nu-tree-list-view-columns": templateColumns
|
|
9668
9619
|
},
|
|
9669
9620
|
children: columns.map(
|
|
9670
|
-
(column, columnIndex) => column.id === treeColumnId ? /* @__PURE__ */
|
|
9621
|
+
(column, columnIndex) => column.id === treeColumnId ? /* @__PURE__ */ jsxs41(
|
|
9671
9622
|
"span",
|
|
9672
9623
|
{
|
|
9673
9624
|
className: [
|
|
@@ -9679,7 +9630,7 @@ function TreeListViewRowInner({
|
|
|
9679
9630
|
"data-column-id": column.id,
|
|
9680
9631
|
role: "gridcell",
|
|
9681
9632
|
children: [
|
|
9682
|
-
/* @__PURE__ */
|
|
9633
|
+
/* @__PURE__ */ jsxs41("span", { "aria-hidden": "true", className: "nu-tree-list-view__prefix", children: [
|
|
9683
9634
|
guideMask.map((hasGuide, guideIndex) => /* @__PURE__ */ jsx62(
|
|
9684
9635
|
"span",
|
|
9685
9636
|
{
|
|
@@ -9691,7 +9642,7 @@ function TreeListViewRowInner({
|
|
|
9691
9642
|
},
|
|
9692
9643
|
`${itemId}-guide-${guideIndex}`
|
|
9693
9644
|
)),
|
|
9694
|
-
/* @__PURE__ */
|
|
9645
|
+
/* @__PURE__ */ jsxs41(
|
|
9695
9646
|
"span",
|
|
9696
9647
|
{
|
|
9697
9648
|
className: "nu-tree-list-view__lead",
|
|
@@ -9739,7 +9690,7 @@ function TreeListViewRowInner({
|
|
|
9739
9690
|
}
|
|
9740
9691
|
)
|
|
9741
9692
|
] }),
|
|
9742
|
-
/* @__PURE__ */
|
|
9693
|
+
/* @__PURE__ */ jsxs41("span", { className: "nu-tree-list-view__tree-content", children: [
|
|
9743
9694
|
isCheckable ? /* @__PURE__ */ jsx62("span", { className: "nu-tree-list-view__check-slot", children: /* @__PURE__ */ jsx62(
|
|
9744
9695
|
"button",
|
|
9745
9696
|
{
|
|
@@ -9840,12 +9791,43 @@ var TreeListViewRow = memo5(
|
|
|
9840
9791
|
);
|
|
9841
9792
|
|
|
9842
9793
|
// src/components/TreeListView/TreeListView.tsx
|
|
9843
|
-
import { jsx as jsx63, jsxs as
|
|
9794
|
+
import { jsx as jsx63, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
9795
|
+
function getColumnStorageKey(columnStoreKey) {
|
|
9796
|
+
const normalizedKey = columnStoreKey?.trim();
|
|
9797
|
+
return normalizedKey ? `reactnu.${normalizedKey}` : null;
|
|
9798
|
+
}
|
|
9799
|
+
function readStoredColumnWidths(storageKey, columns) {
|
|
9800
|
+
if (!storageKey || typeof window === "undefined") {
|
|
9801
|
+
return {};
|
|
9802
|
+
}
|
|
9803
|
+
try {
|
|
9804
|
+
const rawValue = window.localStorage.getItem(storageKey);
|
|
9805
|
+
if (!rawValue) {
|
|
9806
|
+
return {};
|
|
9807
|
+
}
|
|
9808
|
+
const parsedValue = JSON.parse(rawValue);
|
|
9809
|
+
if (!parsedValue || typeof parsedValue !== "object") {
|
|
9810
|
+
return {};
|
|
9811
|
+
}
|
|
9812
|
+
return Object.fromEntries(
|
|
9813
|
+
columns.flatMap((column) => {
|
|
9814
|
+
const width = parsedValue[column.id];
|
|
9815
|
+
if (typeof width !== "number" || !Number.isFinite(width)) {
|
|
9816
|
+
return [];
|
|
9817
|
+
}
|
|
9818
|
+
return [[column.id, Math.max(width, column.minWidth ?? 0)]];
|
|
9819
|
+
})
|
|
9820
|
+
);
|
|
9821
|
+
} catch {
|
|
9822
|
+
return {};
|
|
9823
|
+
}
|
|
9824
|
+
}
|
|
9844
9825
|
function TreeListViewInner({
|
|
9845
9826
|
acceptsDrop,
|
|
9846
9827
|
activeItemId: activeItemIdProp,
|
|
9847
9828
|
checkedIds,
|
|
9848
9829
|
className,
|
|
9830
|
+
columnStoreKey,
|
|
9849
9831
|
columns,
|
|
9850
9832
|
onPopupMenu,
|
|
9851
9833
|
data,
|
|
@@ -9861,6 +9843,7 @@ function TreeListViewInner({
|
|
|
9861
9843
|
onItemCheckChange,
|
|
9862
9844
|
onItemDoubleClick,
|
|
9863
9845
|
onItemDragOut,
|
|
9846
|
+
renderDragPreview,
|
|
9864
9847
|
onItemSelect,
|
|
9865
9848
|
onDrop,
|
|
9866
9849
|
selectedId,
|
|
@@ -9870,6 +9853,9 @@ function TreeListViewInner({
|
|
|
9870
9853
|
const rootRef = useRef23(null);
|
|
9871
9854
|
const [rootElement, setRootElement] = useState31(null);
|
|
9872
9855
|
const treeId = useId17();
|
|
9856
|
+
const storageKey = getColumnStorageKey(columnStoreKey);
|
|
9857
|
+
const loadedStorageKeyRef = useRef23(storageKey);
|
|
9858
|
+
const shouldPersistColumnWidthsRef = useRef23(false);
|
|
9873
9859
|
const itemRefs = useRef23({});
|
|
9874
9860
|
const resizeFrameRef = useRef23(null);
|
|
9875
9861
|
const resizeStateRef = useRef23(null);
|
|
@@ -9883,18 +9869,18 @@ function TreeListViewInner({
|
|
|
9883
9869
|
});
|
|
9884
9870
|
const [uncontrolledSelectedId, setUncontrolledSelectedId] = useState31(null);
|
|
9885
9871
|
const [autoColumnWidths, setAutoColumnWidths] = useState31({});
|
|
9886
|
-
const [userColumnWidths, setUserColumnWidths] = useState31(
|
|
9872
|
+
const [userColumnWidths, setUserColumnWidths] = useState31(() => readStoredColumnWidths(storageKey, columns));
|
|
9887
9873
|
const isActiveControlled = activeItemIdProp !== void 0;
|
|
9888
9874
|
const resolvedExpandedIds = isExpandedControlled ? expandedIds : uncontrolledExpandedIds;
|
|
9889
|
-
const expandedIdSet =
|
|
9875
|
+
const expandedIdSet = useMemo19(
|
|
9890
9876
|
() => new Set(resolvedExpandedIds),
|
|
9891
9877
|
[resolvedExpandedIds]
|
|
9892
9878
|
);
|
|
9893
|
-
const visibleItems =
|
|
9879
|
+
const visibleItems = useMemo19(
|
|
9894
9880
|
() => collectVisibleTreeListItems(data, expandedIdSet),
|
|
9895
9881
|
[data, expandedIdSet]
|
|
9896
9882
|
);
|
|
9897
|
-
const selectableItems =
|
|
9883
|
+
const selectableItems = useMemo19(
|
|
9898
9884
|
() => visibleItems.filter(({ item }) => !item.disabled),
|
|
9899
9885
|
[visibleItems]
|
|
9900
9886
|
);
|
|
@@ -9903,7 +9889,7 @@ function TreeListViewInner({
|
|
|
9903
9889
|
const [uncontrolledActiveItemId, setUncontrolledActiveItemId] = useState31(() => defaultActiveItemId ?? resolvedSelectedId);
|
|
9904
9890
|
const activeItemId = activeItemIdProp !== void 0 ? activeItemIdProp : uncontrolledActiveItemId;
|
|
9905
9891
|
const resolvedActiveItemId = activeItemId && selectableItems.some((entry) => entry.itemId === activeItemId) ? activeItemId : resolvedSelectedId;
|
|
9906
|
-
const minColumnWidthById =
|
|
9892
|
+
const minColumnWidthById = useMemo19(
|
|
9907
9893
|
() => Object.fromEntries(
|
|
9908
9894
|
columns.map(
|
|
9909
9895
|
(column) => [column.id, column.minWidth ?? 0]
|
|
@@ -9911,29 +9897,29 @@ function TreeListViewInner({
|
|
|
9911
9897
|
),
|
|
9912
9898
|
[columns]
|
|
9913
9899
|
);
|
|
9914
|
-
const templateColumns =
|
|
9900
|
+
const templateColumns = useMemo19(
|
|
9915
9901
|
() => getTreeListTemplateColumns(columns, {
|
|
9916
9902
|
autoColumnWidths,
|
|
9917
9903
|
userColumnWidths
|
|
9918
9904
|
}),
|
|
9919
9905
|
[autoColumnWidths, columns, userColumnWidths]
|
|
9920
9906
|
);
|
|
9921
|
-
const treeColumnId =
|
|
9907
|
+
const treeColumnId = useMemo19(
|
|
9922
9908
|
() => getTreeListTreeColumnId(columns),
|
|
9923
9909
|
[columns]
|
|
9924
9910
|
);
|
|
9925
|
-
const rowIndexMap =
|
|
9911
|
+
const rowIndexMap = useMemo19(
|
|
9926
9912
|
() => new Map(
|
|
9927
9913
|
visibleItems.map((entry, index) => [entry.itemId, index])
|
|
9928
9914
|
),
|
|
9929
9915
|
[visibleItems]
|
|
9930
9916
|
);
|
|
9931
|
-
const dropTargetOptions =
|
|
9917
|
+
const dropTargetOptions = useMemo19(
|
|
9932
9918
|
() => onDrop ? { accepts: acceptsDrop, onDrop, type: "tree-list" } : void 0,
|
|
9933
9919
|
[acceptsDrop, onDrop]
|
|
9934
9920
|
);
|
|
9935
9921
|
useNuDropTarget(rootElement, dropTargetOptions);
|
|
9936
|
-
const setRootRef =
|
|
9922
|
+
const setRootRef = useCallback9((node) => {
|
|
9937
9923
|
rootRef.current = node;
|
|
9938
9924
|
setRootElement(node);
|
|
9939
9925
|
}, []);
|
|
@@ -9945,17 +9931,38 @@ function TreeListViewInner({
|
|
|
9945
9931
|
block: "nearest"
|
|
9946
9932
|
});
|
|
9947
9933
|
}, [resolvedActiveItemId]);
|
|
9948
|
-
|
|
9934
|
+
useEffect17(() => {
|
|
9935
|
+
if (loadedStorageKeyRef.current === storageKey) {
|
|
9936
|
+
return;
|
|
9937
|
+
}
|
|
9938
|
+
loadedStorageKeyRef.current = storageKey;
|
|
9939
|
+
shouldPersistColumnWidthsRef.current = false;
|
|
9940
|
+
setUserColumnWidths(readStoredColumnWidths(storageKey, columns));
|
|
9941
|
+
}, [columns, storageKey]);
|
|
9942
|
+
useEffect17(() => {
|
|
9943
|
+
if (!shouldPersistColumnWidthsRef.current) {
|
|
9944
|
+
return;
|
|
9945
|
+
}
|
|
9946
|
+
shouldPersistColumnWidthsRef.current = false;
|
|
9947
|
+
if (!storageKey || typeof window === "undefined") {
|
|
9948
|
+
return;
|
|
9949
|
+
}
|
|
9950
|
+
try {
|
|
9951
|
+
window.localStorage.setItem(storageKey, JSON.stringify(userColumnWidths));
|
|
9952
|
+
} catch {
|
|
9953
|
+
}
|
|
9954
|
+
}, [storageKey, userColumnWidths]);
|
|
9955
|
+
const registerItemRef = useCallback9(
|
|
9949
9956
|
(itemId, node) => {
|
|
9950
9957
|
itemRefs.current[itemId] = node;
|
|
9951
9958
|
},
|
|
9952
9959
|
[]
|
|
9953
9960
|
);
|
|
9954
|
-
const resolveCellContent =
|
|
9961
|
+
const resolveCellContent = useCallback9(
|
|
9955
9962
|
(...args) => getCellContent?.(...args),
|
|
9956
9963
|
[getCellContent]
|
|
9957
9964
|
);
|
|
9958
|
-
const handleItemDoubleClick =
|
|
9965
|
+
const handleItemDoubleClick = useCallback9(
|
|
9959
9966
|
(item) => onItemDoubleClick?.(item),
|
|
9960
9967
|
[onItemDoubleClick]
|
|
9961
9968
|
);
|
|
@@ -9998,7 +10005,7 @@ function TreeListViewInner({
|
|
|
9998
10005
|
}
|
|
9999
10006
|
};
|
|
10000
10007
|
}, []);
|
|
10001
|
-
const setExpandedState =
|
|
10008
|
+
const setExpandedState = useCallback9(
|
|
10002
10009
|
(item, nextExpanded) => {
|
|
10003
10010
|
const nextExpandedIds = nextExpanded ? Array.from(/* @__PURE__ */ new Set([...resolvedExpandedIds, item.id])) : resolvedExpandedIds.filter((expandedId) => expandedId !== item.id);
|
|
10004
10011
|
if (!isExpandedControlled) {
|
|
@@ -10008,7 +10015,7 @@ function TreeListViewInner({
|
|
|
10008
10015
|
},
|
|
10009
10016
|
[isExpandedControlled, onExpandedIdsChange, resolvedExpandedIds]
|
|
10010
10017
|
);
|
|
10011
|
-
const updateActiveItem =
|
|
10018
|
+
const updateActiveItem = useCallback9(
|
|
10012
10019
|
(item) => {
|
|
10013
10020
|
if (!isActiveControlled) {
|
|
10014
10021
|
setUncontrolledActiveItemId(item.id);
|
|
@@ -10017,7 +10024,7 @@ function TreeListViewInner({
|
|
|
10017
10024
|
},
|
|
10018
10025
|
[isActiveControlled, onActiveItemChange]
|
|
10019
10026
|
);
|
|
10020
|
-
const activateEntry =
|
|
10027
|
+
const activateEntry = useCallback9(
|
|
10021
10028
|
(item, itemId) => {
|
|
10022
10029
|
if (item.disabled) {
|
|
10023
10030
|
return;
|
|
@@ -10030,7 +10037,7 @@ function TreeListViewInner({
|
|
|
10030
10037
|
},
|
|
10031
10038
|
[onItemSelect, selectedId, updateActiveItem]
|
|
10032
10039
|
);
|
|
10033
|
-
const handleItemPopupMenu =
|
|
10040
|
+
const handleItemPopupMenu = useCallback9(
|
|
10034
10041
|
(event, item, context) => {
|
|
10035
10042
|
if (item.disabled || !onPopupMenu) {
|
|
10036
10043
|
return;
|
|
@@ -10042,7 +10049,7 @@ function TreeListViewInner({
|
|
|
10042
10049
|
},
|
|
10043
10050
|
[activateEntry, onPopupMenu]
|
|
10044
10051
|
);
|
|
10045
|
-
const activateResolvedItem =
|
|
10052
|
+
const activateResolvedItem = useCallback9(
|
|
10046
10053
|
(itemId) => {
|
|
10047
10054
|
if (!itemId) {
|
|
10048
10055
|
return;
|
|
@@ -10056,7 +10063,7 @@ function TreeListViewInner({
|
|
|
10056
10063
|
},
|
|
10057
10064
|
[activateEntry, selectableItems]
|
|
10058
10065
|
);
|
|
10059
|
-
const handleItemCheckChange =
|
|
10066
|
+
const handleItemCheckChange = useCallback9(
|
|
10060
10067
|
(item, checked) => {
|
|
10061
10068
|
onItemCheckChange?.(item, checked);
|
|
10062
10069
|
},
|
|
@@ -10126,7 +10133,7 @@ function TreeListViewInner({
|
|
|
10126
10133
|
function isItemChecked(item) {
|
|
10127
10134
|
return checkedIds ? checkedIds.includes(item.id) : item.checked === true;
|
|
10128
10135
|
}
|
|
10129
|
-
const toggleItemCheck =
|
|
10136
|
+
const toggleItemCheck = useCallback9(
|
|
10130
10137
|
(itemId) => {
|
|
10131
10138
|
const item = findTreeListItemById(data, itemId);
|
|
10132
10139
|
if (!item || item.disabled || item.checked === void 0 && checkedIds === void 0) {
|
|
@@ -10235,9 +10242,15 @@ function TreeListViewInner({
|
|
|
10235
10242
|
return;
|
|
10236
10243
|
}
|
|
10237
10244
|
setUserColumnWidths(
|
|
10238
|
-
(currentWidths) =>
|
|
10239
|
-
|
|
10240
|
-
|
|
10245
|
+
(currentWidths) => {
|
|
10246
|
+
if (currentWidths[resizeState.columnId] === resizeState.nextWidth) {
|
|
10247
|
+
return currentWidths;
|
|
10248
|
+
}
|
|
10249
|
+
shouldPersistColumnWidthsRef.current = true;
|
|
10250
|
+
return {
|
|
10251
|
+
...currentWidths,
|
|
10252
|
+
[resizeState.columnId]: resizeState.nextWidth
|
|
10253
|
+
};
|
|
10241
10254
|
}
|
|
10242
10255
|
);
|
|
10243
10256
|
}
|
|
@@ -10284,7 +10297,7 @@ function TreeListViewInner({
|
|
|
10284
10297
|
window.addEventListener("pointermove", handleColumnResizeMove);
|
|
10285
10298
|
window.addEventListener("pointerup", handleColumnResizeEnd);
|
|
10286
10299
|
}
|
|
10287
|
-
return /* @__PURE__ */
|
|
10300
|
+
return /* @__PURE__ */ jsxs42(
|
|
10288
10301
|
"div",
|
|
10289
10302
|
{
|
|
10290
10303
|
...props,
|
|
@@ -10304,7 +10317,7 @@ function TreeListViewInner({
|
|
|
10304
10317
|
style: {
|
|
10305
10318
|
"--nu-tree-list-view-columns": templateColumns
|
|
10306
10319
|
},
|
|
10307
|
-
children: columns.map((column, columnIndex) => /* @__PURE__ */
|
|
10320
|
+
children: columns.map((column, columnIndex) => /* @__PURE__ */ jsxs42(
|
|
10308
10321
|
"span",
|
|
10309
10322
|
{
|
|
10310
10323
|
className: [
|
|
@@ -10349,6 +10362,7 @@ function TreeListViewInner({
|
|
|
10349
10362
|
onActivateItem: activateEntry,
|
|
10350
10363
|
onDoubleClickItem: onItemDoubleClick ? handleItemDoubleClick : void 0,
|
|
10351
10364
|
onItemDragOut,
|
|
10365
|
+
renderDragPreview,
|
|
10352
10366
|
onPopupMenuItem: handleItemPopupMenu,
|
|
10353
10367
|
onToggleItemCheck: handleItemCheckChange,
|
|
10354
10368
|
onToggleItemExpanded: setExpandedState,
|
|
@@ -10367,13 +10381,16 @@ function TreeListViewInner({
|
|
|
10367
10381
|
}
|
|
10368
10382
|
);
|
|
10369
10383
|
}
|
|
10370
|
-
|
|
10384
|
+
function TreeListViewWithDragDrop(props, ref) {
|
|
10385
|
+
return /* @__PURE__ */ jsx63(NuDragDropProvider, { children: TreeListViewInner(props, ref) });
|
|
10386
|
+
}
|
|
10387
|
+
var TreeListView = forwardRef4(TreeListViewWithDragDrop);
|
|
10371
10388
|
|
|
10372
10389
|
// src/theme/NuThemeProvider.tsx
|
|
10373
10390
|
import {
|
|
10374
|
-
useCallback as
|
|
10391
|
+
useCallback as useCallback10,
|
|
10375
10392
|
useId as useId18,
|
|
10376
|
-
useMemo as
|
|
10393
|
+
useMemo as useMemo20,
|
|
10377
10394
|
useState as useState32
|
|
10378
10395
|
} from "react";
|
|
10379
10396
|
|
|
@@ -10656,8 +10673,8 @@ function getNuDesktopPatternStyle(mode) {
|
|
|
10656
10673
|
}
|
|
10657
10674
|
|
|
10658
10675
|
// src/theme/themeContext.ts
|
|
10659
|
-
import { createContext as
|
|
10660
|
-
var NuThemeContext =
|
|
10676
|
+
import { createContext as createContext5, useContext as useContext10 } from "react";
|
|
10677
|
+
var NuThemeContext = createContext5(null);
|
|
10661
10678
|
function useNuTheme() {
|
|
10662
10679
|
const context = useContext10(NuThemeContext);
|
|
10663
10680
|
if (!context) {
|
|
@@ -10667,7 +10684,7 @@ function useNuTheme() {
|
|
|
10667
10684
|
}
|
|
10668
10685
|
|
|
10669
10686
|
// src/theme/NuThemeProvider.tsx
|
|
10670
|
-
import { jsx as jsx64, jsxs as
|
|
10687
|
+
import { jsx as jsx64, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
10671
10688
|
function NuThemeProvider({
|
|
10672
10689
|
children,
|
|
10673
10690
|
className,
|
|
@@ -10697,7 +10714,7 @@ function NuThemeProvider({
|
|
|
10697
10714
|
const resolvedFontSize = fontSize ?? internalFontSize;
|
|
10698
10715
|
const resolvedTheme = resolveNuTheme(currentTheme);
|
|
10699
10716
|
const themeName = typeof currentTheme === "string" ? currentTheme : currentTheme.name;
|
|
10700
|
-
const handleThemeChange =
|
|
10717
|
+
const handleThemeChange = useCallback10(
|
|
10701
10718
|
(nextTheme) => {
|
|
10702
10719
|
if (theme === void 0) {
|
|
10703
10720
|
setInternalTheme(nextTheme);
|
|
@@ -10706,7 +10723,7 @@ function NuThemeProvider({
|
|
|
10706
10723
|
},
|
|
10707
10724
|
[theme, onThemeChange]
|
|
10708
10725
|
);
|
|
10709
|
-
const handleDesktopPatternModeChange =
|
|
10726
|
+
const handleDesktopPatternModeChange = useCallback10(
|
|
10710
10727
|
(nextDesktopPatternMode) => {
|
|
10711
10728
|
if (desktopPatternMode === void 0) {
|
|
10712
10729
|
setInternalDesktopPatternMode(nextDesktopPatternMode);
|
|
@@ -10715,7 +10732,7 @@ function NuThemeProvider({
|
|
|
10715
10732
|
},
|
|
10716
10733
|
[desktopPatternMode, onDesktopPatternModeChange]
|
|
10717
10734
|
);
|
|
10718
|
-
const handleFontFamilyChange =
|
|
10735
|
+
const handleFontFamilyChange = useCallback10(
|
|
10719
10736
|
(nextFontFamily) => {
|
|
10720
10737
|
if (fontFamily === void 0) {
|
|
10721
10738
|
setInternalFontFamily(nextFontFamily);
|
|
@@ -10724,7 +10741,7 @@ function NuThemeProvider({
|
|
|
10724
10741
|
},
|
|
10725
10742
|
[fontFamily, onFontFamilyChange]
|
|
10726
10743
|
);
|
|
10727
|
-
const handleFontSizeChange =
|
|
10744
|
+
const handleFontSizeChange = useCallback10(
|
|
10728
10745
|
(nextFontSize) => {
|
|
10729
10746
|
if (fontSize === void 0) {
|
|
10730
10747
|
setInternalFontSize(nextFontSize);
|
|
@@ -10733,7 +10750,7 @@ function NuThemeProvider({
|
|
|
10733
10750
|
},
|
|
10734
10751
|
[fontSize, onFontSizeChange]
|
|
10735
10752
|
);
|
|
10736
|
-
const contextValue =
|
|
10753
|
+
const contextValue = useMemo20(
|
|
10737
10754
|
() => ({
|
|
10738
10755
|
desktopPatternMode: resolvedDesktopPatternMode,
|
|
10739
10756
|
fontFamily: resolvedFontFamily,
|
|
@@ -10758,7 +10775,7 @@ function NuThemeProvider({
|
|
|
10758
10775
|
handleThemeChange
|
|
10759
10776
|
]
|
|
10760
10777
|
);
|
|
10761
|
-
return /* @__PURE__ */ jsx64(NuThemeContext.Provider, { value: contextValue, children: /* @__PURE__ */
|
|
10778
|
+
return /* @__PURE__ */ jsx64(NuThemeContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs43(
|
|
10762
10779
|
"div",
|
|
10763
10780
|
{
|
|
10764
10781
|
className: ["nu-theme-root", className].filter(Boolean).join(" "),
|