@asymmetric-effort/specifyjs 0.2.156 → 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,24 +17818,24 @@ function Board(props) {
17779
17818
  pos = snapToGrid(position, GRID_SIZE);
17780
17819
  }
17781
17820
  dispatch({ type: "MOVE_ITEM", itemId, position: pos });
17782
- const currentDragging = draggingCardIdRef.current;
17821
+ const currentDragging = draggingItemIdRef.current;
17783
17822
  if (currentDragging === itemId) {
17784
- let cardWidth = 0;
17785
- let cardHeight = 0;
17823
+ let itemWidth = 0;
17824
+ let itemHeight = 0;
17786
17825
  const searchStack = [...collection];
17787
17826
  while (searchStack.length > 0) {
17788
17827
  const si = searchStack.pop();
17789
- if (isCard(si) && si.card_id === itemId) {
17790
- cardWidth = si.size.width;
17791
- cardHeight = si.size.height;
17828
+ if (getItemId(si) === itemId) {
17829
+ itemWidth = si.size.width;
17830
+ itemHeight = si.size.height;
17792
17831
  break;
17793
17832
  }
17794
17833
  if (isContainer(si)) {
17795
17834
  for (let k = 0; k < si.contents.length; k++) searchStack.push(si.contents[k]);
17796
17835
  }
17797
17836
  }
17798
- const centerX = pos.x + cardWidth / 2;
17799
- const centerY = pos.y + cardHeight / 2;
17837
+ const centerX = pos.x + itemWidth / 2;
17838
+ const centerY = pos.y + itemHeight / 2;
17800
17839
  const containerId = findContainerAtPoint(collection, centerX, centerY, itemId);
17801
17840
  setDropTargetId(containerId);
17802
17841
  }
@@ -17811,22 +17850,22 @@ function Board(props) {
17811
17850
  const handleDropIntoContainer = useCallback((itemId, containerId) => {
17812
17851
  dispatch({ type: "NEST_ITEM", itemId, containerId });
17813
17852
  }, [dispatch]);
17814
- const handleCardDragStart = useCallback((cardId) => {
17815
- setDraggingCardId(cardId);
17816
- draggingCardIdRef.current = cardId;
17853
+ const handleItemDragStart = useCallback((itemId) => {
17854
+ setDraggingItemId(itemId);
17855
+ draggingItemIdRef.current = itemId;
17817
17856
  setDropTargetId(null);
17818
17857
  }, []);
17819
- const draggingCardIdRef = useRef(null);
17820
- draggingCardIdRef.current = draggingCardId;
17858
+ const draggingItemIdRef = useRef(null);
17859
+ draggingItemIdRef.current = draggingItemId;
17821
17860
  const dropTargetIdRef = useRef(null);
17822
17861
  dropTargetIdRef.current = dropTargetId;
17823
- const handleCardDragEnd = useCallback((cardId) => {
17862
+ const handleItemDragEnd = useCallback((itemId) => {
17824
17863
  const target = dropTargetIdRef.current;
17825
17864
  if (target) {
17826
- dispatch({ type: "NEST_ITEM", itemId: cardId, containerId: target });
17865
+ dispatch({ type: "NEST_ITEM", itemId, containerId: target });
17827
17866
  }
17828
- setDraggingCardId(null);
17829
- draggingCardIdRef.current = null;
17867
+ setDraggingItemId(null);
17868
+ draggingItemIdRef.current = null;
17830
17869
  setDropTargetId(null);
17831
17870
  }, [dispatch]);
17832
17871
  const handleAnchorDragStart = useCallback((cardId, anchor, pos) => {
@@ -17935,8 +17974,8 @@ function Board(props) {
17935
17974
  onOpenProject,
17936
17975
  onCardContextMenu: handleCardContextMenu,
17937
17976
  onUpdate: onUpdateItem,
17938
- onDragStart: handleCardDragStart,
17939
- onDragEnd: handleCardDragEnd,
17977
+ onDragStart: handleItemDragStart,
17978
+ onDragEnd: handleItemDragEnd,
17940
17979
  onAnchorDragStart: handleAnchorDragStart
17941
17980
  });
17942
17981
  } else {
@@ -17950,7 +17989,9 @@ function Board(props) {
17950
17989
  onMove: handleMoveItem,
17951
17990
  onResize: handleResizeItem,
17952
17991
  onDelete: handleDeleteItem,
17953
- onDrop: handleDropIntoContainer
17992
+ onDrop: handleDropIntoContainer,
17993
+ onDragStart: handleItemDragStart,
17994
+ onDragEnd: handleItemDragEnd
17954
17995
  }, ...childElements);
17955
17996
  }
17956
17997
  if (isDimmed) {
@@ -20,7 +20,8 @@ export interface BoardProps {
20
20
  }
21
21
  /**
22
22
  * Find the first container whose bounding box contains the given point.
23
- * Optionally excludes a specific item ID (e.g., the dragged item itself).
23
+ * Excludes the dragged item itself and (if it's a container) all its
24
+ * descendants to prevent circular nesting.
24
25
  */
25
26
  export declare function findContainerAtPoint(collection: BoardItem[], x: number, y: number, excludeId?: string): string | null;
26
27
  export declare function snapToGrid(pos: {
@@ -14,6 +14,8 @@ export interface ContainerComponentProps {
14
14
  }) => void;
15
15
  onDelete?: (containerId: string) => void;
16
16
  onDrop?: (itemId: string, containerId: string) => void;
17
+ onDragStart?: (containerId: string) => void;
18
+ onDragEnd?: (containerId: string) => void;
17
19
  children?: unknown;
18
20
  }
19
21
  export declare function ContainerComponent(props: ContainerComponentProps): import("specifyjs/shared/types").SpecElement<import("specifyjs/shared/types").Props>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asymmetric-effort/specifyjs",
3
- "version": "0.2.156",
3
+ "version": "0.2.158",
4
4
  "description": "A declarative TypeScript UI framework built for performance and simplicity",
5
5
  "publishConfig": {
6
6
  "access": "public"