@asymmetric-effort/specifyjs 0.2.158 → 0.2.160

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.
@@ -17593,15 +17593,29 @@ function findContainerAtPoint(collection, x, y, excludeId) {
17593
17593
  const descendants = collectDescendantContainerIds(collection, excludeId);
17594
17594
  for (const id of descendants) excluded.add(id);
17595
17595
  }
17596
- for (let i = 0; i < collection.length; i++) {
17597
- const item = collection[i];
17598
- if (!isContainer(item)) continue;
17599
- if (excluded.has(item.container_id)) continue;
17600
- if (x >= item.position.x && x <= item.position.x + item.size.width && y >= item.position.y && y <= item.position.y + item.size.height) {
17601
- return item.container_id;
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
+ }
17602
17616
  }
17603
17617
  }
17604
- return null;
17618
+ return bestMatch;
17605
17619
  }
17606
17620
  function snapToGrid(pos, gridSize) {
17607
17621
  return {
@@ -19,9 +19,11 @@ export interface BoardProps {
19
19
  }) => void;
20
20
  }
21
21
  /**
22
- * Find the first container whose bounding box contains the given point.
23
- * Excludes the dragged item itself and (if it's a container) all its
24
- * descendants to prevent circular nesting.
22
+ * Find the deepest container whose bounding box contains the given point.
23
+ * Searches the full tree (including nested containers), converting positions
24
+ * to canvas-absolute using accumulated parent offsets.
25
+ * Excludes the dragged item and its descendants to prevent circular nesting.
26
+ * Returns the most deeply nested matching container (most specific target).
25
27
  */
26
28
  export declare function findContainerAtPoint(collection: BoardItem[], x: number, y: number, excludeId?: string): string | null;
27
29
  export declare function snapToGrid(pos: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asymmetric-effort/specifyjs",
3
- "version": "0.2.158",
3
+ "version": "0.2.160",
4
4
  "description": "A declarative TypeScript UI framework built for performance and simplicity",
5
5
  "publishConfig": {
6
6
  "access": "public"