@asymmetric-effort/specifyjs 0.2.160 → 0.2.162
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.
|
@@ -17182,7 +17182,7 @@ function CardComponent(props) {
|
|
|
17182
17182
|
|
|
17183
17183
|
// ../components/data/board/src/Container.ts
|
|
17184
17184
|
function ContainerComponent(props) {
|
|
17185
|
-
const { container, selected = false, highlighted = false, onSelect, onMove, onResize, onDelete, onDrop, onDragStart, onDragEnd, children } = props;
|
|
17185
|
+
const { container, selected = false, highlighted = false, onSelect, onMove, onResize, onDelete, onDrop, onDragStart, onDragEnd, onContainerContextMenu, children } = props;
|
|
17186
17186
|
const [dragOver, setDragOver] = useState(false);
|
|
17187
17187
|
const [minimized, setMinimized] = useState(false);
|
|
17188
17188
|
const [isDragging, setIsDragging] = useState(false);
|
|
@@ -17196,6 +17196,14 @@ function ContainerComponent(props) {
|
|
|
17196
17196
|
e.stopPropagation();
|
|
17197
17197
|
setMinimized((prev) => !prev);
|
|
17198
17198
|
}, []);
|
|
17199
|
+
const handleContextMenu = useCallback((e) => {
|
|
17200
|
+
const me = e;
|
|
17201
|
+
me.preventDefault();
|
|
17202
|
+
me.stopPropagation();
|
|
17203
|
+
if (onContainerContextMenu) {
|
|
17204
|
+
onContainerContextMenu(container.container_id, { x: me.clientX, y: me.clientY });
|
|
17205
|
+
}
|
|
17206
|
+
}, [container.container_id, onContainerContextMenu]);
|
|
17199
17207
|
const handleTitleMouseDown = useCallback((e) => {
|
|
17200
17208
|
const me = e;
|
|
17201
17209
|
me.preventDefault();
|
|
@@ -17336,7 +17344,8 @@ function ContainerComponent(props) {
|
|
|
17336
17344
|
"aria-label": `Container: ${container.name}`,
|
|
17337
17345
|
onDragOver: handleDragOver,
|
|
17338
17346
|
onDragLeave: handleDragLeave,
|
|
17339
|
-
onDrop: handleDrop
|
|
17347
|
+
onDrop: handleDrop,
|
|
17348
|
+
onContextMenu: handleContextMenu
|
|
17340
17349
|
},
|
|
17341
17350
|
createElement(
|
|
17342
17351
|
"div",
|
|
@@ -17623,6 +17632,20 @@ function snapToGrid(pos, gridSize) {
|
|
|
17623
17632
|
y: Math.round(pos.y / gridSize) * gridSize
|
|
17624
17633
|
};
|
|
17625
17634
|
}
|
|
17635
|
+
function findParentContainerId(collection, itemId) {
|
|
17636
|
+
const stack = [[collection, null]];
|
|
17637
|
+
while (stack.length > 0) {
|
|
17638
|
+
const [items, parentId] = stack.pop();
|
|
17639
|
+
for (let i = 0; i < items.length; i++) {
|
|
17640
|
+
const item = items[i];
|
|
17641
|
+
if (getItemId(item) === itemId) return parentId;
|
|
17642
|
+
if (isContainer(item)) {
|
|
17643
|
+
stack.push([item.contents, item.container_id]);
|
|
17644
|
+
}
|
|
17645
|
+
}
|
|
17646
|
+
}
|
|
17647
|
+
return null;
|
|
17648
|
+
}
|
|
17626
17649
|
function screenToCanvas(screenX, screenY, viewport) {
|
|
17627
17650
|
return {
|
|
17628
17651
|
x: (screenX - viewport.panX) / viewport.zoom,
|
|
@@ -17683,6 +17706,7 @@ function Board(props) {
|
|
|
17683
17706
|
const [cardContextMenu, setCardContextMenu] = useState(null);
|
|
17684
17707
|
const [colorSubmenuOpen, setColorSubmenuOpen] = useState(false);
|
|
17685
17708
|
const [typeSubmenuOpen, setTypeSubmenuOpen] = useState(false);
|
|
17709
|
+
const [containerContextMenu, setContainerContextMenu] = useState(null);
|
|
17686
17710
|
const [linkContextMenu, setLinkContextMenu] = useState(null);
|
|
17687
17711
|
const handleCanvasMouseDown = useCallback((e) => {
|
|
17688
17712
|
const me = e;
|
|
@@ -17823,6 +17847,20 @@ function Board(props) {
|
|
|
17823
17847
|
document.addEventListener("click", handleDocumentClick);
|
|
17824
17848
|
return () => document.removeEventListener("click", handleDocumentClick);
|
|
17825
17849
|
}, [linkContextMenu, closeLinkContextMenu]);
|
|
17850
|
+
const handleContainerContextMenu = useCallback((containerId, pos) => {
|
|
17851
|
+
setContainerContextMenu({ containerId, x: pos.x, y: pos.y });
|
|
17852
|
+
closeCardContextMenu();
|
|
17853
|
+
closeLinkContextMenu();
|
|
17854
|
+
}, [closeCardContextMenu, closeLinkContextMenu]);
|
|
17855
|
+
const closeContainerContextMenu = useCallback(() => {
|
|
17856
|
+
setContainerContextMenu(null);
|
|
17857
|
+
}, []);
|
|
17858
|
+
useEffect(() => {
|
|
17859
|
+
if (!containerContextMenu) return;
|
|
17860
|
+
const handleDocumentClick = () => closeContainerContextMenu();
|
|
17861
|
+
document.addEventListener("click", handleDocumentClick);
|
|
17862
|
+
return () => document.removeEventListener("click", handleDocumentClick);
|
|
17863
|
+
}, [containerContextMenu, closeContainerContextMenu]);
|
|
17826
17864
|
const handleSelectItem = useCallback((itemId) => {
|
|
17827
17865
|
if (onSelectItem) onSelectItem(itemId);
|
|
17828
17866
|
}, [onSelectItem]);
|
|
@@ -18005,7 +18043,8 @@ function Board(props) {
|
|
|
18005
18043
|
onDelete: handleDeleteItem,
|
|
18006
18044
|
onDrop: handleDropIntoContainer,
|
|
18007
18045
|
onDragStart: handleItemDragStart,
|
|
18008
|
-
onDragEnd: handleItemDragEnd
|
|
18046
|
+
onDragEnd: handleItemDragEnd,
|
|
18047
|
+
onContainerContextMenu: handleContainerContextMenu
|
|
18009
18048
|
}, ...childElements);
|
|
18010
18049
|
}
|
|
18011
18050
|
if (isDimmed) {
|
|
@@ -18174,6 +18213,21 @@ function Board(props) {
|
|
|
18174
18213
|
)
|
|
18175
18214
|
) : null
|
|
18176
18215
|
),
|
|
18216
|
+
// Detach Card (only shown when card is nested inside a container)
|
|
18217
|
+
(() => {
|
|
18218
|
+
const parentId = findParentContainerId(collection, cardContextMenu.cardId);
|
|
18219
|
+
if (!parentId) return null;
|
|
18220
|
+
return createElement("div", {
|
|
18221
|
+
style: ctxMenuItemStyle,
|
|
18222
|
+
onClick: (e) => {
|
|
18223
|
+
e.stopPropagation();
|
|
18224
|
+
dispatch({ type: "UNNEST_ITEM", itemId: cardContextMenu.cardId, containerId: parentId });
|
|
18225
|
+
closeCardContextMenu();
|
|
18226
|
+
},
|
|
18227
|
+
role: "menuitem",
|
|
18228
|
+
"data-testid": `board-ctx-detach-${cardContextMenu.cardId}`
|
|
18229
|
+
}, "Detach Card");
|
|
18230
|
+
})(),
|
|
18177
18231
|
// Separator
|
|
18178
18232
|
createElement("div", { style: ctxSeparatorStyle, role: "separator" }),
|
|
18179
18233
|
// Delete
|
|
@@ -18189,6 +18243,55 @@ function Board(props) {
|
|
|
18189
18243
|
"data-testid": `board-ctx-delete-${cardContextMenu.cardId}`
|
|
18190
18244
|
}, "Delete")
|
|
18191
18245
|
) : null;
|
|
18246
|
+
const containerContextMenuEl = containerContextMenu ? createElement(
|
|
18247
|
+
"div",
|
|
18248
|
+
{
|
|
18249
|
+
className: "board-container-context-menu",
|
|
18250
|
+
role: "menu",
|
|
18251
|
+
style: {
|
|
18252
|
+
position: "fixed",
|
|
18253
|
+
left: `${containerContextMenu.x}px`,
|
|
18254
|
+
top: `${containerContextMenu.y}px`,
|
|
18255
|
+
backgroundColor: "#ffffff",
|
|
18256
|
+
border: "1px solid #d1d5db",
|
|
18257
|
+
borderRadius: "6px",
|
|
18258
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
18259
|
+
padding: "4px 0",
|
|
18260
|
+
zIndex: "10001",
|
|
18261
|
+
minWidth: "160px"
|
|
18262
|
+
},
|
|
18263
|
+
"data-testid": `board-container-ctx-menu-${containerContextMenu.containerId}`
|
|
18264
|
+
},
|
|
18265
|
+
// Detach Container (only shown when nested inside another container)
|
|
18266
|
+
(() => {
|
|
18267
|
+
const parentId = findParentContainerId(collection, containerContextMenu.containerId);
|
|
18268
|
+
if (!parentId) return null;
|
|
18269
|
+
return createElement("div", {
|
|
18270
|
+
style: ctxMenuItemStyle,
|
|
18271
|
+
onClick: (e) => {
|
|
18272
|
+
e.stopPropagation();
|
|
18273
|
+
dispatch({ type: "UNNEST_ITEM", itemId: containerContextMenu.containerId, containerId: parentId });
|
|
18274
|
+
closeContainerContextMenu();
|
|
18275
|
+
},
|
|
18276
|
+
role: "menuitem",
|
|
18277
|
+
"data-testid": `board-ctx-detach-container-${containerContextMenu.containerId}`
|
|
18278
|
+
}, "Detach Container");
|
|
18279
|
+
})(),
|
|
18280
|
+
// Separator
|
|
18281
|
+
createElement("div", { style: ctxSeparatorStyle, role: "separator" }),
|
|
18282
|
+
// Delete
|
|
18283
|
+
createElement("div", {
|
|
18284
|
+
style: { ...ctxMenuItemStyle, color: "#dc2626" },
|
|
18285
|
+
onClick: (e) => {
|
|
18286
|
+
e.stopPropagation();
|
|
18287
|
+
dispatch({ type: "REMOVE_ITEM", itemId: containerContextMenu.containerId });
|
|
18288
|
+
if (onSelectItem && selectedId === containerContextMenu.containerId) onSelectItem(null);
|
|
18289
|
+
closeContainerContextMenu();
|
|
18290
|
+
},
|
|
18291
|
+
role: "menuitem",
|
|
18292
|
+
"data-testid": `board-ctx-delete-container-${containerContextMenu.containerId}`
|
|
18293
|
+
}, "Delete")
|
|
18294
|
+
) : null;
|
|
18192
18295
|
const EDGE_TYPES = [
|
|
18193
18296
|
"relates to",
|
|
18194
18297
|
"depends on",
|
|
@@ -18356,6 +18459,7 @@ function Board(props) {
|
|
|
18356
18459
|
...itemElements
|
|
18357
18460
|
),
|
|
18358
18461
|
boardContextMenuEl,
|
|
18462
|
+
containerContextMenuEl,
|
|
18359
18463
|
linkContextMenuEl
|
|
18360
18464
|
);
|
|
18361
18465
|
}
|