@asymmetric-effort/specifyjs 0.2.155 → 0.2.158

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,11 +17561,42 @@ 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) {
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
+ }
17557
17596
  for (let i = 0; i < collection.length; i++) {
17558
17597
  const item = collection[i];
17559
17598
  if (!isContainer(item)) continue;
17560
- if (item.container_id === excludeId) continue;
17599
+ if (excluded.has(item.container_id)) continue;
17561
17600
  if (x >= item.position.x && x <= item.position.x + item.size.width && y >= item.position.y && y <= item.position.y + item.size.height) {
17562
17601
  return item.container_id;
17563
17602
  }
@@ -17625,7 +17664,7 @@ function Board(props) {
17625
17664
  const isPanningRef = useRef(false);
17626
17665
  const panStartRef = useRef(null);
17627
17666
  const [dropTargetId, setDropTargetId] = useState(null);
17628
- const [draggingCardId, setDraggingCardId] = useState(null);
17667
+ const [draggingItemId, setDraggingItemId] = useState(null);
17629
17668
  const [linkDrag, setLinkDrag] = useState(null);
17630
17669
  const [cardContextMenu, setCardContextMenu] = useState(null);
17631
17670
  const [colorSubmenuOpen, setColorSubmenuOpen] = useState(false);
@@ -17779,27 +17818,28 @@ function Board(props) {
17779
17818
  pos = snapToGrid(position, GRID_SIZE);
17780
17819
  }
17781
17820
  dispatch({ type: "MOVE_ITEM", itemId, position: pos });
17782
- if (draggingCardId === itemId) {
17783
- let cardWidth = 0;
17784
- let cardHeight = 0;
17821
+ const currentDragging = draggingItemIdRef.current;
17822
+ if (currentDragging === itemId) {
17823
+ let itemWidth = 0;
17824
+ let itemHeight = 0;
17785
17825
  const searchStack = [...collection];
17786
17826
  while (searchStack.length > 0) {
17787
17827
  const si = searchStack.pop();
17788
- if (isCard(si) && si.card_id === itemId) {
17789
- cardWidth = si.size.width;
17790
- cardHeight = si.size.height;
17828
+ if (getItemId(si) === itemId) {
17829
+ itemWidth = si.size.width;
17830
+ itemHeight = si.size.height;
17791
17831
  break;
17792
17832
  }
17793
17833
  if (isContainer(si)) {
17794
17834
  for (let k = 0; k < si.contents.length; k++) searchStack.push(si.contents[k]);
17795
17835
  }
17796
17836
  }
17797
- const centerX = pos.x + cardWidth / 2;
17798
- const centerY = pos.y + cardHeight / 2;
17837
+ const centerX = pos.x + itemWidth / 2;
17838
+ const centerY = pos.y + itemHeight / 2;
17799
17839
  const containerId = findContainerAtPoint(collection, centerX, centerY, itemId);
17800
17840
  setDropTargetId(containerId);
17801
17841
  }
17802
- }, [dispatch, gridEnabled, draggingCardId, collection]);
17842
+ }, [dispatch, gridEnabled, collection]);
17803
17843
  const handleResizeItem = useCallback((itemId, size) => {
17804
17844
  dispatch({ type: "RESIZE_ITEM", itemId, size });
17805
17845
  }, [dispatch]);
@@ -17810,18 +17850,22 @@ function Board(props) {
17810
17850
  const handleDropIntoContainer = useCallback((itemId, containerId) => {
17811
17851
  dispatch({ type: "NEST_ITEM", itemId, containerId });
17812
17852
  }, [dispatch]);
17813
- const handleCardDragStart = useCallback((cardId) => {
17814
- setDraggingCardId(cardId);
17853
+ const handleItemDragStart = useCallback((itemId) => {
17854
+ setDraggingItemId(itemId);
17855
+ draggingItemIdRef.current = itemId;
17815
17856
  setDropTargetId(null);
17816
17857
  }, []);
17858
+ const draggingItemIdRef = useRef(null);
17859
+ draggingItemIdRef.current = draggingItemId;
17817
17860
  const dropTargetIdRef = useRef(null);
17818
17861
  dropTargetIdRef.current = dropTargetId;
17819
- const handleCardDragEnd = useCallback((cardId) => {
17862
+ const handleItemDragEnd = useCallback((itemId) => {
17820
17863
  const target = dropTargetIdRef.current;
17821
17864
  if (target) {
17822
- dispatch({ type: "NEST_ITEM", itemId: cardId, containerId: target });
17865
+ dispatch({ type: "NEST_ITEM", itemId, containerId: target });
17823
17866
  }
17824
- setDraggingCardId(null);
17867
+ setDraggingItemId(null);
17868
+ draggingItemIdRef.current = null;
17825
17869
  setDropTargetId(null);
17826
17870
  }, [dispatch]);
17827
17871
  const handleAnchorDragStart = useCallback((cardId, anchor, pos) => {
@@ -17930,8 +17974,8 @@ function Board(props) {
17930
17974
  onOpenProject,
17931
17975
  onCardContextMenu: handleCardContextMenu,
17932
17976
  onUpdate: onUpdateItem,
17933
- onDragStart: handleCardDragStart,
17934
- onDragEnd: handleCardDragEnd,
17977
+ onDragStart: handleItemDragStart,
17978
+ onDragEnd: handleItemDragEnd,
17935
17979
  onAnchorDragStart: handleAnchorDragStart
17936
17980
  });
17937
17981
  } else {
@@ -17945,7 +17989,9 @@ function Board(props) {
17945
17989
  onMove: handleMoveItem,
17946
17990
  onResize: handleResizeItem,
17947
17991
  onDelete: handleDeleteItem,
17948
- onDrop: handleDropIntoContainer
17992
+ onDrop: handleDropIntoContainer,
17993
+ onDragStart: handleItemDragStart,
17994
+ onDragEnd: handleItemDragEnd
17949
17995
  }, ...childElements);
17950
17996
  }
17951
17997
  if (isDimmed) {