@asymmetric-effort/specifyjs 0.2.156 → 0.2.159
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.
|
@@ -16573,6 +16573,7 @@ function renderProjectContent(card, onOpenProject) {
|
|
|
16573
16573
|
function CardComponent(props) {
|
|
16574
16574
|
const { card, selected = false, onSelect, onMove, onResize, onDelete, dispatch, onOpenProject, onCardContextMenu, onUpdate, onDragStart, onDragEnd, onAnchorDragStart } = props;
|
|
16575
16575
|
const [hovered, setHovered] = useState(false);
|
|
16576
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
16576
16577
|
const [contextMenu, setContextMenu] = useState(null);
|
|
16577
16578
|
const [typeSubmenuOpen, setTypeSubmenuOpen] = useState(false);
|
|
16578
16579
|
const [editingTitle, setEditingTitle] = useState(false);
|
|
@@ -16610,6 +16611,7 @@ function CardComponent(props) {
|
|
|
16610
16611
|
cardY: card.position.y
|
|
16611
16612
|
};
|
|
16612
16613
|
if (onDragStart) onDragStart(card.card_id);
|
|
16614
|
+
setIsDragging(true);
|
|
16613
16615
|
const handleMouseMove = (ev) => {
|
|
16614
16616
|
const mev = ev;
|
|
16615
16617
|
if (!dragStartRef.current) return;
|
|
@@ -16624,6 +16626,7 @@ function CardComponent(props) {
|
|
|
16624
16626
|
};
|
|
16625
16627
|
const handleMouseUp = () => {
|
|
16626
16628
|
dragStartRef.current = null;
|
|
16629
|
+
setIsDragging(false);
|
|
16627
16630
|
if (onDragEnd) onDragEnd(card.card_id);
|
|
16628
16631
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
16629
16632
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
@@ -16828,7 +16831,7 @@ function CardComponent(props) {
|
|
|
16828
16831
|
padding: "8px 10px",
|
|
16829
16832
|
boxSizing: "border-box",
|
|
16830
16833
|
transition: "box-shadow 150ms ease",
|
|
16831
|
-
zIndex: "1"
|
|
16834
|
+
zIndex: isDragging ? "9999" : "1"
|
|
16832
16835
|
};
|
|
16833
16836
|
const titleStyle = {
|
|
16834
16837
|
fontWeight: "600",
|
|
@@ -17179,9 +17182,10 @@ function CardComponent(props) {
|
|
|
17179
17182
|
|
|
17180
17183
|
// ../components/data/board/src/Container.ts
|
|
17181
17184
|
function ContainerComponent(props) {
|
|
17182
|
-
const { container, selected = false, highlighted = false, onSelect, onMove, onResize, onDelete, onDrop, children } = props;
|
|
17185
|
+
const { container, selected = false, highlighted = false, onSelect, onMove, onResize, onDelete, onDrop, onDragStart, onDragEnd, children } = props;
|
|
17183
17186
|
const [dragOver, setDragOver] = useState(false);
|
|
17184
17187
|
const [minimized, setMinimized] = useState(false);
|
|
17188
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
17185
17189
|
const dragStartRef = useRef(null);
|
|
17186
17190
|
const resizeStartRef = useRef(null);
|
|
17187
17191
|
const handleDeleteClick = useCallback((e) => {
|
|
@@ -17197,6 +17201,8 @@ function ContainerComponent(props) {
|
|
|
17197
17201
|
me.preventDefault();
|
|
17198
17202
|
me.stopPropagation();
|
|
17199
17203
|
if (onSelect) onSelect(container.container_id);
|
|
17204
|
+
if (onDragStart) onDragStart(container.container_id);
|
|
17205
|
+
setIsDragging(true);
|
|
17200
17206
|
dragStartRef.current = {
|
|
17201
17207
|
x: me.clientX,
|
|
17202
17208
|
y: me.clientY,
|
|
@@ -17217,12 +17223,14 @@ function ContainerComponent(props) {
|
|
|
17217
17223
|
};
|
|
17218
17224
|
const handleMouseUp = () => {
|
|
17219
17225
|
dragStartRef.current = null;
|
|
17226
|
+
setIsDragging(false);
|
|
17227
|
+
if (onDragEnd) onDragEnd(container.container_id);
|
|
17220
17228
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
17221
17229
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
17222
17230
|
};
|
|
17223
17231
|
document.addEventListener("mousemove", handleMouseMove);
|
|
17224
17232
|
document.addEventListener("mouseup", handleMouseUp);
|
|
17225
|
-
}, [container.container_id, container.position.x, container.position.y, onSelect, onMove]);
|
|
17233
|
+
}, [container.container_id, container.position.x, container.position.y, onSelect, onMove, onDragStart, onDragEnd]);
|
|
17226
17234
|
const handleResizeMouseDown = useCallback((e) => {
|
|
17227
17235
|
const me = e;
|
|
17228
17236
|
me.preventDefault();
|
|
@@ -17285,7 +17293,7 @@ function ContainerComponent(props) {
|
|
|
17285
17293
|
display: "flex",
|
|
17286
17294
|
flexDirection: "column",
|
|
17287
17295
|
overflow: "hidden",
|
|
17288
|
-
zIndex: "0",
|
|
17296
|
+
zIndex: isDragging ? "9999" : "0",
|
|
17289
17297
|
boxSizing: "border-box",
|
|
17290
17298
|
transition: "border 150ms ease, background-color 150ms ease, box-shadow 150ms ease"
|
|
17291
17299
|
};
|
|
@@ -17553,16 +17561,61 @@ var CONTEXT_COLORS = [
|
|
|
17553
17561
|
];
|
|
17554
17562
|
var GRID_SIZE = 20;
|
|
17555
17563
|
var CANVAS_SIZE = 5e3;
|
|
17564
|
+
function collectDescendantContainerIds(collection, containerId) {
|
|
17565
|
+
const ids = /* @__PURE__ */ new Set();
|
|
17566
|
+
const findStack = [...collection];
|
|
17567
|
+
let target = null;
|
|
17568
|
+
while (findStack.length > 0) {
|
|
17569
|
+
const item = findStack.pop();
|
|
17570
|
+
if (isContainer(item) && item.container_id === containerId) {
|
|
17571
|
+
target = item;
|
|
17572
|
+
break;
|
|
17573
|
+
}
|
|
17574
|
+
if (isContainer(item)) {
|
|
17575
|
+
for (let i = 0; i < item.contents.length; i++) findStack.push(item.contents[i]);
|
|
17576
|
+
}
|
|
17577
|
+
}
|
|
17578
|
+
if (!target || !isContainer(target)) return ids;
|
|
17579
|
+
const descStack = [...target.contents];
|
|
17580
|
+
while (descStack.length > 0) {
|
|
17581
|
+
const item = descStack.pop();
|
|
17582
|
+
if (isContainer(item)) {
|
|
17583
|
+
ids.add(item.container_id);
|
|
17584
|
+
for (let i = 0; i < item.contents.length; i++) descStack.push(item.contents[i]);
|
|
17585
|
+
}
|
|
17586
|
+
}
|
|
17587
|
+
return ids;
|
|
17588
|
+
}
|
|
17556
17589
|
function findContainerAtPoint(collection, x, y, excludeId) {
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17590
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
17591
|
+
if (excludeId) {
|
|
17592
|
+
excluded.add(excludeId);
|
|
17593
|
+
const descendants = collectDescendantContainerIds(collection, excludeId);
|
|
17594
|
+
for (const id of descendants) excluded.add(id);
|
|
17595
|
+
}
|
|
17596
|
+
let bestMatch = null;
|
|
17597
|
+
let bestDepth = -1;
|
|
17598
|
+
const stack = [[collection, 0, 0, 0]];
|
|
17599
|
+
while (stack.length > 0) {
|
|
17600
|
+
const [items, offsetX, offsetY, depth] = stack.pop();
|
|
17601
|
+
for (let i = 0; i < items.length; i++) {
|
|
17602
|
+
const item = items[i];
|
|
17603
|
+
if (!isContainer(item)) continue;
|
|
17604
|
+
if (excluded.has(item.container_id)) continue;
|
|
17605
|
+
const absX = item.position.x + offsetX;
|
|
17606
|
+
const absY = item.position.y + offsetY;
|
|
17607
|
+
if (x >= absX && x <= absX + item.size.width && y >= absY && y <= absY + item.size.height) {
|
|
17608
|
+
if (depth > bestDepth) {
|
|
17609
|
+
bestMatch = item.container_id;
|
|
17610
|
+
bestDepth = depth;
|
|
17611
|
+
}
|
|
17612
|
+
if (item.contents.length > 0) {
|
|
17613
|
+
stack.push([item.contents, absX, absY + 30, depth + 1]);
|
|
17614
|
+
}
|
|
17615
|
+
}
|
|
17563
17616
|
}
|
|
17564
17617
|
}
|
|
17565
|
-
return
|
|
17618
|
+
return bestMatch;
|
|
17566
17619
|
}
|
|
17567
17620
|
function snapToGrid(pos, gridSize) {
|
|
17568
17621
|
return {
|
|
@@ -17625,7 +17678,7 @@ function Board(props) {
|
|
|
17625
17678
|
const isPanningRef = useRef(false);
|
|
17626
17679
|
const panStartRef = useRef(null);
|
|
17627
17680
|
const [dropTargetId, setDropTargetId] = useState(null);
|
|
17628
|
-
const [
|
|
17681
|
+
const [draggingItemId, setDraggingItemId] = useState(null);
|
|
17629
17682
|
const [linkDrag, setLinkDrag] = useState(null);
|
|
17630
17683
|
const [cardContextMenu, setCardContextMenu] = useState(null);
|
|
17631
17684
|
const [colorSubmenuOpen, setColorSubmenuOpen] = useState(false);
|
|
@@ -17779,24 +17832,24 @@ function Board(props) {
|
|
|
17779
17832
|
pos = snapToGrid(position, GRID_SIZE);
|
|
17780
17833
|
}
|
|
17781
17834
|
dispatch({ type: "MOVE_ITEM", itemId, position: pos });
|
|
17782
|
-
const currentDragging =
|
|
17835
|
+
const currentDragging = draggingItemIdRef.current;
|
|
17783
17836
|
if (currentDragging === itemId) {
|
|
17784
|
-
let
|
|
17785
|
-
let
|
|
17837
|
+
let itemWidth = 0;
|
|
17838
|
+
let itemHeight = 0;
|
|
17786
17839
|
const searchStack = [...collection];
|
|
17787
17840
|
while (searchStack.length > 0) {
|
|
17788
17841
|
const si = searchStack.pop();
|
|
17789
|
-
if (
|
|
17790
|
-
|
|
17791
|
-
|
|
17842
|
+
if (getItemId(si) === itemId) {
|
|
17843
|
+
itemWidth = si.size.width;
|
|
17844
|
+
itemHeight = si.size.height;
|
|
17792
17845
|
break;
|
|
17793
17846
|
}
|
|
17794
17847
|
if (isContainer(si)) {
|
|
17795
17848
|
for (let k = 0; k < si.contents.length; k++) searchStack.push(si.contents[k]);
|
|
17796
17849
|
}
|
|
17797
17850
|
}
|
|
17798
|
-
const centerX = pos.x +
|
|
17799
|
-
const centerY = pos.y +
|
|
17851
|
+
const centerX = pos.x + itemWidth / 2;
|
|
17852
|
+
const centerY = pos.y + itemHeight / 2;
|
|
17800
17853
|
const containerId = findContainerAtPoint(collection, centerX, centerY, itemId);
|
|
17801
17854
|
setDropTargetId(containerId);
|
|
17802
17855
|
}
|
|
@@ -17811,22 +17864,22 @@ function Board(props) {
|
|
|
17811
17864
|
const handleDropIntoContainer = useCallback((itemId, containerId) => {
|
|
17812
17865
|
dispatch({ type: "NEST_ITEM", itemId, containerId });
|
|
17813
17866
|
}, [dispatch]);
|
|
17814
|
-
const
|
|
17815
|
-
|
|
17816
|
-
|
|
17867
|
+
const handleItemDragStart = useCallback((itemId) => {
|
|
17868
|
+
setDraggingItemId(itemId);
|
|
17869
|
+
draggingItemIdRef.current = itemId;
|
|
17817
17870
|
setDropTargetId(null);
|
|
17818
17871
|
}, []);
|
|
17819
|
-
const
|
|
17820
|
-
|
|
17872
|
+
const draggingItemIdRef = useRef(null);
|
|
17873
|
+
draggingItemIdRef.current = draggingItemId;
|
|
17821
17874
|
const dropTargetIdRef = useRef(null);
|
|
17822
17875
|
dropTargetIdRef.current = dropTargetId;
|
|
17823
|
-
const
|
|
17876
|
+
const handleItemDragEnd = useCallback((itemId) => {
|
|
17824
17877
|
const target = dropTargetIdRef.current;
|
|
17825
17878
|
if (target) {
|
|
17826
|
-
dispatch({ type: "NEST_ITEM", itemId
|
|
17879
|
+
dispatch({ type: "NEST_ITEM", itemId, containerId: target });
|
|
17827
17880
|
}
|
|
17828
|
-
|
|
17829
|
-
|
|
17881
|
+
setDraggingItemId(null);
|
|
17882
|
+
draggingItemIdRef.current = null;
|
|
17830
17883
|
setDropTargetId(null);
|
|
17831
17884
|
}, [dispatch]);
|
|
17832
17885
|
const handleAnchorDragStart = useCallback((cardId, anchor, pos) => {
|
|
@@ -17935,8 +17988,8 @@ function Board(props) {
|
|
|
17935
17988
|
onOpenProject,
|
|
17936
17989
|
onCardContextMenu: handleCardContextMenu,
|
|
17937
17990
|
onUpdate: onUpdateItem,
|
|
17938
|
-
onDragStart:
|
|
17939
|
-
onDragEnd:
|
|
17991
|
+
onDragStart: handleItemDragStart,
|
|
17992
|
+
onDragEnd: handleItemDragEnd,
|
|
17940
17993
|
onAnchorDragStart: handleAnchorDragStart
|
|
17941
17994
|
});
|
|
17942
17995
|
} else {
|
|
@@ -17950,7 +18003,9 @@ function Board(props) {
|
|
|
17950
18003
|
onMove: handleMoveItem,
|
|
17951
18004
|
onResize: handleResizeItem,
|
|
17952
18005
|
onDelete: handleDeleteItem,
|
|
17953
|
-
onDrop: handleDropIntoContainer
|
|
18006
|
+
onDrop: handleDropIntoContainer,
|
|
18007
|
+
onDragStart: handleItemDragStart,
|
|
18008
|
+
onDragEnd: handleItemDragEnd
|
|
17954
18009
|
}, ...childElements);
|
|
17955
18010
|
}
|
|
17956
18011
|
if (isDimmed) {
|