@almadar/ui 4.50.1 → 4.50.3

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.
@@ -24942,6 +24942,10 @@ function useDataDnd(args) {
24942
24942
  const unregisterZone = React93__namespace.default.useCallback((zoneId2) => {
24943
24943
  zonesRef.current.delete(zoneId2);
24944
24944
  }, []);
24945
+ const [overlayNode, setOverlayNode] = React93__namespace.default.useState(null);
24946
+ const setOverlay = React93__namespace.default.useCallback((node) => {
24947
+ setOverlayNode(node);
24948
+ }, []);
24945
24949
  const zoneId = React93__namespace.default.useId();
24946
24950
  const ownGroup = dragGroup ?? accepts ?? zoneId;
24947
24951
  const meta = React93__namespace.default.useMemo(
@@ -24961,6 +24965,13 @@ function useDataDnd(args) {
24961
24965
  core$1.useSensor(core$1.PointerSensor, { activationConstraint: { distance: 5 } }),
24962
24966
  core$1.useSensor(core$1.KeyboardSensor, { coordinateGetter: sortable.sortableKeyboardCoordinates })
24963
24967
  );
24968
+ const collisionDetection = React93__namespace.default.useCallback((args2) => {
24969
+ const pointerCollisions = core$1.pointerWithin(args2);
24970
+ if (pointerCollisions.length > 0) return pointerCollisions;
24971
+ const rectCollisions = core$1.rectIntersection(args2);
24972
+ if (rectCollisions.length > 0) return rectCollisions;
24973
+ return core$1.closestCorners(args2);
24974
+ }, []);
24964
24975
  const findZoneByItem = React93__namespace.default.useCallback(
24965
24976
  (id) => {
24966
24977
  for (const z of zonesRef.current.values()) {
@@ -25018,6 +25029,7 @@ function useDataDnd(args) {
25018
25029
  },
25019
25030
  [orderedItems, ownGroup, findZoneByItem, findZoneByGroup, eventBus]
25020
25031
  );
25032
+ const overlaySink = isRoot ? setOverlay : parentRoot?.setOverlay;
25021
25033
  const SortableItem = React93__namespace.default.useCallback(
25022
25034
  ({ id, children }) => {
25023
25035
  const {
@@ -25028,6 +25040,11 @@ function useDataDnd(args) {
25028
25040
  transition,
25029
25041
  isDragging
25030
25042
  } = sortable.useSortable({ id, data: { dndGroup: ownGroup } });
25043
+ React93__namespace.default.useEffect(() => {
25044
+ if (!isDragging || !overlaySink) return;
25045
+ overlaySink(children);
25046
+ return () => overlaySink(null);
25047
+ }, [isDragging, children]);
25031
25048
  const style = {
25032
25049
  transform: utilities.CSS.Transform.toString(transform),
25033
25050
  transition,
@@ -25046,7 +25063,7 @@ function useDataDnd(args) {
25046
25063
  }
25047
25064
  );
25048
25065
  },
25049
- [ownGroup, enabled]
25066
+ [ownGroup, enabled, overlaySink]
25050
25067
  );
25051
25068
  const DropZoneShell = ({ children }) => {
25052
25069
  const { setNodeRef, isOver } = core$1.useDroppable({
@@ -25064,27 +25081,59 @@ function useDataDnd(args) {
25064
25081
  );
25065
25082
  };
25066
25083
  const rootContextValue = React93__namespace.default.useMemo(
25067
- () => ({ registerZone, unregisterZone }),
25068
- [registerZone, unregisterZone]
25084
+ () => ({ registerZone, unregisterZone, setOverlay }),
25085
+ [registerZone, unregisterZone, setOverlay]
25069
25086
  );
25070
25087
  const wrapContainer = React93__namespace.default.useCallback(
25071
25088
  (children) => {
25072
25089
  if (!enabled) return children;
25073
25090
  const strategy = layout === "grid" ? sortable.rectSortingStrategy : sortable.verticalListSortingStrategy;
25091
+ const clearOverlay = () => setOverlay(null);
25074
25092
  if (!isZone) {
25075
25093
  if (!isRoot) return children;
25076
- return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.DndContext, { sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, children }) });
25094
+ return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
25095
+ core$1.DndContext,
25096
+ {
25097
+ sensors,
25098
+ collisionDetection,
25099
+ onDragEnd: (e) => {
25100
+ handleDragEnd(e);
25101
+ clearOverlay();
25102
+ },
25103
+ onDragCancel: clearOverlay,
25104
+ children: [
25105
+ children,
25106
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: overlayNode })
25107
+ ]
25108
+ }
25109
+ ) });
25077
25110
  }
25078
25111
  const inner = /* @__PURE__ */ jsxRuntime.jsx(DropZoneShell, { children: /* @__PURE__ */ jsxRuntime.jsx(sortable.SortableContext, { items: itemIds, strategy, children }) });
25079
25112
  if (isRoot) {
25080
- return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.DndContext, { sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, children: inner }) });
25113
+ return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
25114
+ core$1.DndContext,
25115
+ {
25116
+ sensors,
25117
+ collisionDetection,
25118
+ onDragEnd: (e) => {
25119
+ handleDragEnd(e);
25120
+ clearOverlay();
25121
+ },
25122
+ onDragCancel: clearOverlay,
25123
+ children: [
25124
+ inner,
25125
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: overlayNode })
25126
+ ]
25127
+ }
25128
+ ) });
25081
25129
  }
25082
25130
  return inner;
25083
25131
  },
25084
- [enabled, isZone, layout, sensors, handleDragEnd, itemIds, isRoot, rootContextValue]
25132
+ [enabled, isZone, layout, sensors, collisionDetection, handleDragEnd, itemIds, isRoot, rootContextValue, overlayNode, setOverlay]
25085
25133
  );
25086
25134
  return {
25087
25135
  enabled,
25136
+ isZone,
25088
25137
  wrapContainer,
25089
25138
  SortableItem,
25090
25139
  orderedItems
@@ -25290,7 +25339,7 @@ function DataGrid({
25290
25339
  const id = itemData.id || String(index);
25291
25340
  const isSelected = selectedIds.has(id);
25292
25341
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
25293
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
25342
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
25294
25343
  if (hasRenderProp) {
25295
25344
  return wrapDnd(
25296
25345
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -25706,7 +25755,7 @@ function DataList({
25706
25755
  const idFieldName = dndItemIdField ?? "id";
25707
25756
  const renderItem = (itemData, index, isLast) => {
25708
25757
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
25709
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
25758
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
25710
25759
  if (hasRenderProp) {
25711
25760
  const id2 = itemData.id || String(index);
25712
25761
  return wrapDnd(
package/dist/avl/index.js CHANGED
@@ -34,7 +34,7 @@ import langToml from 'react-syntax-highlighter/dist/esm/languages/prism/toml.js'
34
34
  import langGo from 'react-syntax-highlighter/dist/esm/languages/prism/go.js';
35
35
  import langGraphql from 'react-syntax-highlighter/dist/esm/languages/prism/graphql.js';
36
36
  import { FieldTypeSchema, isInlineTrait, isEntityCall, schemaToIR, getPage, isCircuitEvent } from '@almadar/core';
37
- import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter, useDroppable } from '@dnd-kit/core';
37
+ import { useSensors, useSensor, PointerSensor, KeyboardSensor, pointerWithin, rectIntersection, closestCorners, DndContext, DragOverlay, useDroppable } from '@dnd-kit/core';
38
38
  import { sortableKeyboardCoordinates, arrayMove, useSortable, SortableContext, rectSortingStrategy, verticalListSortingStrategy } from '@dnd-kit/sortable';
39
39
  import { CSS } from '@dnd-kit/utilities';
40
40
  import { useThree, useFrame, Canvas } from '@react-three/fiber';
@@ -24896,6 +24896,10 @@ function useDataDnd(args) {
24896
24896
  const unregisterZone = React93__default.useCallback((zoneId2) => {
24897
24897
  zonesRef.current.delete(zoneId2);
24898
24898
  }, []);
24899
+ const [overlayNode, setOverlayNode] = React93__default.useState(null);
24900
+ const setOverlay = React93__default.useCallback((node) => {
24901
+ setOverlayNode(node);
24902
+ }, []);
24899
24903
  const zoneId = React93__default.useId();
24900
24904
  const ownGroup = dragGroup ?? accepts ?? zoneId;
24901
24905
  const meta = React93__default.useMemo(
@@ -24915,6 +24919,13 @@ function useDataDnd(args) {
24915
24919
  useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
24916
24920
  useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
24917
24921
  );
24922
+ const collisionDetection = React93__default.useCallback((args2) => {
24923
+ const pointerCollisions = pointerWithin(args2);
24924
+ if (pointerCollisions.length > 0) return pointerCollisions;
24925
+ const rectCollisions = rectIntersection(args2);
24926
+ if (rectCollisions.length > 0) return rectCollisions;
24927
+ return closestCorners(args2);
24928
+ }, []);
24918
24929
  const findZoneByItem = React93__default.useCallback(
24919
24930
  (id) => {
24920
24931
  for (const z of zonesRef.current.values()) {
@@ -24972,6 +24983,7 @@ function useDataDnd(args) {
24972
24983
  },
24973
24984
  [orderedItems, ownGroup, findZoneByItem, findZoneByGroup, eventBus]
24974
24985
  );
24986
+ const overlaySink = isRoot ? setOverlay : parentRoot?.setOverlay;
24975
24987
  const SortableItem = React93__default.useCallback(
24976
24988
  ({ id, children }) => {
24977
24989
  const {
@@ -24982,6 +24994,11 @@ function useDataDnd(args) {
24982
24994
  transition,
24983
24995
  isDragging
24984
24996
  } = useSortable({ id, data: { dndGroup: ownGroup } });
24997
+ React93__default.useEffect(() => {
24998
+ if (!isDragging || !overlaySink) return;
24999
+ overlaySink(children);
25000
+ return () => overlaySink(null);
25001
+ }, [isDragging, children]);
24985
25002
  const style = {
24986
25003
  transform: CSS.Transform.toString(transform),
24987
25004
  transition,
@@ -25000,7 +25017,7 @@ function useDataDnd(args) {
25000
25017
  }
25001
25018
  );
25002
25019
  },
25003
- [ownGroup, enabled]
25020
+ [ownGroup, enabled, overlaySink]
25004
25021
  );
25005
25022
  const DropZoneShell = ({ children }) => {
25006
25023
  const { setNodeRef, isOver } = useDroppable({
@@ -25018,27 +25035,59 @@ function useDataDnd(args) {
25018
25035
  );
25019
25036
  };
25020
25037
  const rootContextValue = React93__default.useMemo(
25021
- () => ({ registerZone, unregisterZone }),
25022
- [registerZone, unregisterZone]
25038
+ () => ({ registerZone, unregisterZone, setOverlay }),
25039
+ [registerZone, unregisterZone, setOverlay]
25023
25040
  );
25024
25041
  const wrapContainer = React93__default.useCallback(
25025
25042
  (children) => {
25026
25043
  if (!enabled) return children;
25027
25044
  const strategy = layout === "grid" ? rectSortingStrategy : verticalListSortingStrategy;
25045
+ const clearOverlay = () => setOverlay(null);
25028
25046
  if (!isZone) {
25029
25047
  if (!isRoot) return children;
25030
- return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children }) });
25048
+ return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxs(
25049
+ DndContext,
25050
+ {
25051
+ sensors,
25052
+ collisionDetection,
25053
+ onDragEnd: (e) => {
25054
+ handleDragEnd(e);
25055
+ clearOverlay();
25056
+ },
25057
+ onDragCancel: clearOverlay,
25058
+ children: [
25059
+ children,
25060
+ /* @__PURE__ */ jsx(DragOverlay, { children: overlayNode })
25061
+ ]
25062
+ }
25063
+ ) });
25031
25064
  }
25032
25065
  const inner = /* @__PURE__ */ jsx(DropZoneShell, { children: /* @__PURE__ */ jsx(SortableContext, { items: itemIds, strategy, children }) });
25033
25066
  if (isRoot) {
25034
- return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: inner }) });
25067
+ return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxs(
25068
+ DndContext,
25069
+ {
25070
+ sensors,
25071
+ collisionDetection,
25072
+ onDragEnd: (e) => {
25073
+ handleDragEnd(e);
25074
+ clearOverlay();
25075
+ },
25076
+ onDragCancel: clearOverlay,
25077
+ children: [
25078
+ inner,
25079
+ /* @__PURE__ */ jsx(DragOverlay, { children: overlayNode })
25080
+ ]
25081
+ }
25082
+ ) });
25035
25083
  }
25036
25084
  return inner;
25037
25085
  },
25038
- [enabled, isZone, layout, sensors, handleDragEnd, itemIds, isRoot, rootContextValue]
25086
+ [enabled, isZone, layout, sensors, collisionDetection, handleDragEnd, itemIds, isRoot, rootContextValue, overlayNode, setOverlay]
25039
25087
  );
25040
25088
  return {
25041
25089
  enabled,
25090
+ isZone,
25042
25091
  wrapContainer,
25043
25092
  SortableItem,
25044
25093
  orderedItems
@@ -25244,7 +25293,7 @@ function DataGrid({
25244
25293
  const id = itemData.id || String(index);
25245
25294
  const isSelected = selectedIds.has(id);
25246
25295
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
25247
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
25296
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
25248
25297
  if (hasRenderProp) {
25249
25298
  return wrapDnd(
25250
25299
  /* @__PURE__ */ jsx(
@@ -25660,7 +25709,7 @@ function DataList({
25660
25709
  const idFieldName = dndItemIdField ?? "id";
25661
25710
  const renderItem = (itemData, index, isLast) => {
25662
25711
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
25663
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
25712
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
25664
25713
  if (hasRenderProp) {
25665
25714
  const id2 = itemData.id || String(index);
25666
25715
  return wrapDnd(
@@ -20109,6 +20109,10 @@ function useDataDnd(args) {
20109
20109
  const unregisterZone = React75__namespace.default.useCallback((zoneId2) => {
20110
20110
  zonesRef.current.delete(zoneId2);
20111
20111
  }, []);
20112
+ const [overlayNode, setOverlayNode] = React75__namespace.default.useState(null);
20113
+ const setOverlay = React75__namespace.default.useCallback((node) => {
20114
+ setOverlayNode(node);
20115
+ }, []);
20112
20116
  const zoneId = React75__namespace.default.useId();
20113
20117
  const ownGroup = dragGroup ?? accepts ?? zoneId;
20114
20118
  const meta = React75__namespace.default.useMemo(
@@ -20128,6 +20132,13 @@ function useDataDnd(args) {
20128
20132
  core$1.useSensor(core$1.PointerSensor, { activationConstraint: { distance: 5 } }),
20129
20133
  core$1.useSensor(core$1.KeyboardSensor, { coordinateGetter: sortable.sortableKeyboardCoordinates })
20130
20134
  );
20135
+ const collisionDetection = React75__namespace.default.useCallback((args2) => {
20136
+ const pointerCollisions = core$1.pointerWithin(args2);
20137
+ if (pointerCollisions.length > 0) return pointerCollisions;
20138
+ const rectCollisions = core$1.rectIntersection(args2);
20139
+ if (rectCollisions.length > 0) return rectCollisions;
20140
+ return core$1.closestCorners(args2);
20141
+ }, []);
20131
20142
  const findZoneByItem = React75__namespace.default.useCallback(
20132
20143
  (id) => {
20133
20144
  for (const z of zonesRef.current.values()) {
@@ -20185,6 +20196,7 @@ function useDataDnd(args) {
20185
20196
  },
20186
20197
  [orderedItems, ownGroup, findZoneByItem, findZoneByGroup, eventBus]
20187
20198
  );
20199
+ const overlaySink = isRoot ? setOverlay : parentRoot?.setOverlay;
20188
20200
  const SortableItem = React75__namespace.default.useCallback(
20189
20201
  ({ id, children }) => {
20190
20202
  const {
@@ -20195,6 +20207,11 @@ function useDataDnd(args) {
20195
20207
  transition,
20196
20208
  isDragging
20197
20209
  } = sortable.useSortable({ id, data: { dndGroup: ownGroup } });
20210
+ React75__namespace.default.useEffect(() => {
20211
+ if (!isDragging || !overlaySink) return;
20212
+ overlaySink(children);
20213
+ return () => overlaySink(null);
20214
+ }, [isDragging, children]);
20198
20215
  const style = {
20199
20216
  transform: utilities.CSS.Transform.toString(transform),
20200
20217
  transition,
@@ -20213,7 +20230,7 @@ function useDataDnd(args) {
20213
20230
  }
20214
20231
  );
20215
20232
  },
20216
- [ownGroup, enabled]
20233
+ [ownGroup, enabled, overlaySink]
20217
20234
  );
20218
20235
  const DropZoneShell = ({ children }) => {
20219
20236
  const { setNodeRef, isOver } = core$1.useDroppable({
@@ -20231,27 +20248,59 @@ function useDataDnd(args) {
20231
20248
  );
20232
20249
  };
20233
20250
  const rootContextValue = React75__namespace.default.useMemo(
20234
- () => ({ registerZone, unregisterZone }),
20235
- [registerZone, unregisterZone]
20251
+ () => ({ registerZone, unregisterZone, setOverlay }),
20252
+ [registerZone, unregisterZone, setOverlay]
20236
20253
  );
20237
20254
  const wrapContainer = React75__namespace.default.useCallback(
20238
20255
  (children) => {
20239
20256
  if (!enabled) return children;
20240
20257
  const strategy = layout === "grid" ? sortable.rectSortingStrategy : sortable.verticalListSortingStrategy;
20258
+ const clearOverlay = () => setOverlay(null);
20241
20259
  if (!isZone) {
20242
20260
  if (!isRoot) return children;
20243
- return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.DndContext, { sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, children }) });
20261
+ return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
20262
+ core$1.DndContext,
20263
+ {
20264
+ sensors,
20265
+ collisionDetection,
20266
+ onDragEnd: (e) => {
20267
+ handleDragEnd(e);
20268
+ clearOverlay();
20269
+ },
20270
+ onDragCancel: clearOverlay,
20271
+ children: [
20272
+ children,
20273
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: overlayNode })
20274
+ ]
20275
+ }
20276
+ ) });
20244
20277
  }
20245
20278
  const inner = /* @__PURE__ */ jsxRuntime.jsx(DropZoneShell, { children: /* @__PURE__ */ jsxRuntime.jsx(sortable.SortableContext, { items: itemIds, strategy, children }) });
20246
20279
  if (isRoot) {
20247
- return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.DndContext, { sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, children: inner }) });
20280
+ return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
20281
+ core$1.DndContext,
20282
+ {
20283
+ sensors,
20284
+ collisionDetection,
20285
+ onDragEnd: (e) => {
20286
+ handleDragEnd(e);
20287
+ clearOverlay();
20288
+ },
20289
+ onDragCancel: clearOverlay,
20290
+ children: [
20291
+ inner,
20292
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: overlayNode })
20293
+ ]
20294
+ }
20295
+ ) });
20248
20296
  }
20249
20297
  return inner;
20250
20298
  },
20251
- [enabled, isZone, layout, sensors, handleDragEnd, itemIds, isRoot, rootContextValue]
20299
+ [enabled, isZone, layout, sensors, collisionDetection, handleDragEnd, itemIds, isRoot, rootContextValue, overlayNode, setOverlay]
20252
20300
  );
20253
20301
  return {
20254
20302
  enabled,
20303
+ isZone,
20255
20304
  wrapContainer,
20256
20305
  SortableItem,
20257
20306
  orderedItems
@@ -20457,7 +20506,7 @@ function DataGrid({
20457
20506
  const id = itemData.id || String(index);
20458
20507
  const isSelected = selectedIds.has(id);
20459
20508
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
20460
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
20509
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
20461
20510
  if (hasRenderProp) {
20462
20511
  return wrapDnd(
20463
20512
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -20873,7 +20922,7 @@ function DataList({
20873
20922
  const idFieldName = dndItemIdField ?? "id";
20874
20923
  const renderItem = (itemData, index, isLast) => {
20875
20924
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
20876
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
20925
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
20877
20926
  if (hasRenderProp) {
20878
20927
  const id2 = itemData.id || String(index);
20879
20928
  return wrapDnd(
@@ -35,7 +35,7 @@ import langToml from 'react-syntax-highlighter/dist/esm/languages/prism/toml.js'
35
35
  import langGo from 'react-syntax-highlighter/dist/esm/languages/prism/go.js';
36
36
  import langGraphql from 'react-syntax-highlighter/dist/esm/languages/prism/graphql.js';
37
37
  import { isInlineTrait } from '@almadar/core';
38
- import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter, useDroppable } from '@dnd-kit/core';
38
+ import { useSensors, useSensor, PointerSensor, KeyboardSensor, pointerWithin, rectIntersection, closestCorners, DndContext, DragOverlay, useDroppable } from '@dnd-kit/core';
39
39
  import { sortableKeyboardCoordinates, arrayMove, useSortable, SortableContext, rectSortingStrategy, verticalListSortingStrategy } from '@dnd-kit/sortable';
40
40
  import { CSS } from '@dnd-kit/utilities';
41
41
  import { Handle, Position } from '@xyflow/react';
@@ -20063,6 +20063,10 @@ function useDataDnd(args) {
20063
20063
  const unregisterZone = React75__default.useCallback((zoneId2) => {
20064
20064
  zonesRef.current.delete(zoneId2);
20065
20065
  }, []);
20066
+ const [overlayNode, setOverlayNode] = React75__default.useState(null);
20067
+ const setOverlay = React75__default.useCallback((node) => {
20068
+ setOverlayNode(node);
20069
+ }, []);
20066
20070
  const zoneId = React75__default.useId();
20067
20071
  const ownGroup = dragGroup ?? accepts ?? zoneId;
20068
20072
  const meta = React75__default.useMemo(
@@ -20082,6 +20086,13 @@ function useDataDnd(args) {
20082
20086
  useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
20083
20087
  useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
20084
20088
  );
20089
+ const collisionDetection = React75__default.useCallback((args2) => {
20090
+ const pointerCollisions = pointerWithin(args2);
20091
+ if (pointerCollisions.length > 0) return pointerCollisions;
20092
+ const rectCollisions = rectIntersection(args2);
20093
+ if (rectCollisions.length > 0) return rectCollisions;
20094
+ return closestCorners(args2);
20095
+ }, []);
20085
20096
  const findZoneByItem = React75__default.useCallback(
20086
20097
  (id) => {
20087
20098
  for (const z of zonesRef.current.values()) {
@@ -20139,6 +20150,7 @@ function useDataDnd(args) {
20139
20150
  },
20140
20151
  [orderedItems, ownGroup, findZoneByItem, findZoneByGroup, eventBus]
20141
20152
  );
20153
+ const overlaySink = isRoot ? setOverlay : parentRoot?.setOverlay;
20142
20154
  const SortableItem = React75__default.useCallback(
20143
20155
  ({ id, children }) => {
20144
20156
  const {
@@ -20149,6 +20161,11 @@ function useDataDnd(args) {
20149
20161
  transition,
20150
20162
  isDragging
20151
20163
  } = useSortable({ id, data: { dndGroup: ownGroup } });
20164
+ React75__default.useEffect(() => {
20165
+ if (!isDragging || !overlaySink) return;
20166
+ overlaySink(children);
20167
+ return () => overlaySink(null);
20168
+ }, [isDragging, children]);
20152
20169
  const style = {
20153
20170
  transform: CSS.Transform.toString(transform),
20154
20171
  transition,
@@ -20167,7 +20184,7 @@ function useDataDnd(args) {
20167
20184
  }
20168
20185
  );
20169
20186
  },
20170
- [ownGroup, enabled]
20187
+ [ownGroup, enabled, overlaySink]
20171
20188
  );
20172
20189
  const DropZoneShell = ({ children }) => {
20173
20190
  const { setNodeRef, isOver } = useDroppable({
@@ -20185,27 +20202,59 @@ function useDataDnd(args) {
20185
20202
  );
20186
20203
  };
20187
20204
  const rootContextValue = React75__default.useMemo(
20188
- () => ({ registerZone, unregisterZone }),
20189
- [registerZone, unregisterZone]
20205
+ () => ({ registerZone, unregisterZone, setOverlay }),
20206
+ [registerZone, unregisterZone, setOverlay]
20190
20207
  );
20191
20208
  const wrapContainer = React75__default.useCallback(
20192
20209
  (children) => {
20193
20210
  if (!enabled) return children;
20194
20211
  const strategy = layout === "grid" ? rectSortingStrategy : verticalListSortingStrategy;
20212
+ const clearOverlay = () => setOverlay(null);
20195
20213
  if (!isZone) {
20196
20214
  if (!isRoot) return children;
20197
- return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children }) });
20215
+ return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxs(
20216
+ DndContext,
20217
+ {
20218
+ sensors,
20219
+ collisionDetection,
20220
+ onDragEnd: (e) => {
20221
+ handleDragEnd(e);
20222
+ clearOverlay();
20223
+ },
20224
+ onDragCancel: clearOverlay,
20225
+ children: [
20226
+ children,
20227
+ /* @__PURE__ */ jsx(DragOverlay, { children: overlayNode })
20228
+ ]
20229
+ }
20230
+ ) });
20198
20231
  }
20199
20232
  const inner = /* @__PURE__ */ jsx(DropZoneShell, { children: /* @__PURE__ */ jsx(SortableContext, { items: itemIds, strategy, children }) });
20200
20233
  if (isRoot) {
20201
- return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: inner }) });
20234
+ return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxs(
20235
+ DndContext,
20236
+ {
20237
+ sensors,
20238
+ collisionDetection,
20239
+ onDragEnd: (e) => {
20240
+ handleDragEnd(e);
20241
+ clearOverlay();
20242
+ },
20243
+ onDragCancel: clearOverlay,
20244
+ children: [
20245
+ inner,
20246
+ /* @__PURE__ */ jsx(DragOverlay, { children: overlayNode })
20247
+ ]
20248
+ }
20249
+ ) });
20202
20250
  }
20203
20251
  return inner;
20204
20252
  },
20205
- [enabled, isZone, layout, sensors, handleDragEnd, itemIds, isRoot, rootContextValue]
20253
+ [enabled, isZone, layout, sensors, collisionDetection, handleDragEnd, itemIds, isRoot, rootContextValue, overlayNode, setOverlay]
20206
20254
  );
20207
20255
  return {
20208
20256
  enabled,
20257
+ isZone,
20209
20258
  wrapContainer,
20210
20259
  SortableItem,
20211
20260
  orderedItems
@@ -20411,7 +20460,7 @@ function DataGrid({
20411
20460
  const id = itemData.id || String(index);
20412
20461
  const isSelected = selectedIds.has(id);
20413
20462
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
20414
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
20463
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
20415
20464
  if (hasRenderProp) {
20416
20465
  return wrapDnd(
20417
20466
  /* @__PURE__ */ jsx(
@@ -20827,7 +20876,7 @@ function DataList({
20827
20876
  const idFieldName = dndItemIdField ?? "id";
20828
20877
  const renderItem = (itemData, index, isLast) => {
20829
20878
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
20830
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
20879
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
20831
20880
  if (hasRenderProp) {
20832
20881
  const id2 = itemData.id || String(index);
20833
20882
  return wrapDnd(
@@ -42,6 +42,8 @@ interface UseDataDndArgs<T extends EntityRow> extends DataDndProps {
42
42
  }
43
43
  interface UseDataDndResult<T extends EntityRow> {
44
44
  enabled: boolean;
45
+ /** True when this container is a sortable zone (own items are draggable). False in dndRoot-only mode. */
46
+ isZone: boolean;
45
47
  wrapContainer: (children: React.ReactNode) => React.ReactNode;
46
48
  SortableItem: React.FC<{
47
49
  id: UniqueIdentifier;
@@ -21354,6 +21354,10 @@ function useDataDnd(args) {
21354
21354
  const unregisterZone = React81__namespace.default.useCallback((zoneId2) => {
21355
21355
  zonesRef.current.delete(zoneId2);
21356
21356
  }, []);
21357
+ const [overlayNode, setOverlayNode] = React81__namespace.default.useState(null);
21358
+ const setOverlay = React81__namespace.default.useCallback((node) => {
21359
+ setOverlayNode(node);
21360
+ }, []);
21357
21361
  const zoneId = React81__namespace.default.useId();
21358
21362
  const ownGroup = dragGroup ?? accepts ?? zoneId;
21359
21363
  const meta = React81__namespace.default.useMemo(
@@ -21373,6 +21377,13 @@ function useDataDnd(args) {
21373
21377
  core$1.useSensor(core$1.PointerSensor, { activationConstraint: { distance: 5 } }),
21374
21378
  core$1.useSensor(core$1.KeyboardSensor, { coordinateGetter: sortable.sortableKeyboardCoordinates })
21375
21379
  );
21380
+ const collisionDetection = React81__namespace.default.useCallback((args2) => {
21381
+ const pointerCollisions = core$1.pointerWithin(args2);
21382
+ if (pointerCollisions.length > 0) return pointerCollisions;
21383
+ const rectCollisions = core$1.rectIntersection(args2);
21384
+ if (rectCollisions.length > 0) return rectCollisions;
21385
+ return core$1.closestCorners(args2);
21386
+ }, []);
21376
21387
  const findZoneByItem = React81__namespace.default.useCallback(
21377
21388
  (id) => {
21378
21389
  for (const z of zonesRef.current.values()) {
@@ -21430,6 +21441,7 @@ function useDataDnd(args) {
21430
21441
  },
21431
21442
  [orderedItems, ownGroup, findZoneByItem, findZoneByGroup, eventBus]
21432
21443
  );
21444
+ const overlaySink = isRoot ? setOverlay : parentRoot?.setOverlay;
21433
21445
  const SortableItem = React81__namespace.default.useCallback(
21434
21446
  ({ id, children }) => {
21435
21447
  const {
@@ -21440,6 +21452,11 @@ function useDataDnd(args) {
21440
21452
  transition,
21441
21453
  isDragging
21442
21454
  } = sortable.useSortable({ id, data: { dndGroup: ownGroup } });
21455
+ React81__namespace.default.useEffect(() => {
21456
+ if (!isDragging || !overlaySink) return;
21457
+ overlaySink(children);
21458
+ return () => overlaySink(null);
21459
+ }, [isDragging, children]);
21443
21460
  const style = {
21444
21461
  transform: utilities.CSS.Transform.toString(transform),
21445
21462
  transition,
@@ -21458,7 +21475,7 @@ function useDataDnd(args) {
21458
21475
  }
21459
21476
  );
21460
21477
  },
21461
- [ownGroup, enabled]
21478
+ [ownGroup, enabled, overlaySink]
21462
21479
  );
21463
21480
  const DropZoneShell = ({ children }) => {
21464
21481
  const { setNodeRef, isOver } = core$1.useDroppable({
@@ -21476,27 +21493,59 @@ function useDataDnd(args) {
21476
21493
  );
21477
21494
  };
21478
21495
  const rootContextValue = React81__namespace.default.useMemo(
21479
- () => ({ registerZone, unregisterZone }),
21480
- [registerZone, unregisterZone]
21496
+ () => ({ registerZone, unregisterZone, setOverlay }),
21497
+ [registerZone, unregisterZone, setOverlay]
21481
21498
  );
21482
21499
  const wrapContainer = React81__namespace.default.useCallback(
21483
21500
  (children) => {
21484
21501
  if (!enabled) return children;
21485
21502
  const strategy = layout === "grid" ? sortable.rectSortingStrategy : sortable.verticalListSortingStrategy;
21503
+ const clearOverlay = () => setOverlay(null);
21486
21504
  if (!isZone) {
21487
21505
  if (!isRoot) return children;
21488
- return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.DndContext, { sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, children }) });
21506
+ return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
21507
+ core$1.DndContext,
21508
+ {
21509
+ sensors,
21510
+ collisionDetection,
21511
+ onDragEnd: (e) => {
21512
+ handleDragEnd(e);
21513
+ clearOverlay();
21514
+ },
21515
+ onDragCancel: clearOverlay,
21516
+ children: [
21517
+ children,
21518
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: overlayNode })
21519
+ ]
21520
+ }
21521
+ ) });
21489
21522
  }
21490
21523
  const inner = /* @__PURE__ */ jsxRuntime.jsx(DropZoneShell, { children: /* @__PURE__ */ jsxRuntime.jsx(sortable.SortableContext, { items: itemIds, strategy, children }) });
21491
21524
  if (isRoot) {
21492
- return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.DndContext, { sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, children: inner }) });
21525
+ return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
21526
+ core$1.DndContext,
21527
+ {
21528
+ sensors,
21529
+ collisionDetection,
21530
+ onDragEnd: (e) => {
21531
+ handleDragEnd(e);
21532
+ clearOverlay();
21533
+ },
21534
+ onDragCancel: clearOverlay,
21535
+ children: [
21536
+ inner,
21537
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: overlayNode })
21538
+ ]
21539
+ }
21540
+ ) });
21493
21541
  }
21494
21542
  return inner;
21495
21543
  },
21496
- [enabled, isZone, layout, sensors, handleDragEnd, itemIds, isRoot, rootContextValue]
21544
+ [enabled, isZone, layout, sensors, collisionDetection, handleDragEnd, itemIds, isRoot, rootContextValue, overlayNode, setOverlay]
21497
21545
  );
21498
21546
  return {
21499
21547
  enabled,
21548
+ isZone,
21500
21549
  wrapContainer,
21501
21550
  SortableItem,
21502
21551
  orderedItems
@@ -21702,7 +21751,7 @@ function DataGrid({
21702
21751
  const id = itemData.id || String(index);
21703
21752
  const isSelected = selectedIds.has(id);
21704
21753
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
21705
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21754
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21706
21755
  if (hasRenderProp) {
21707
21756
  return wrapDnd(
21708
21757
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -22118,7 +22167,7 @@ function DataList({
22118
22167
  const idFieldName = dndItemIdField ?? "id";
22119
22168
  const renderItem = (itemData, index, isLast) => {
22120
22169
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
22121
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
22170
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
22122
22171
  if (hasRenderProp) {
22123
22172
  const id2 = itemData.id || String(index);
22124
22173
  return wrapDnd(
@@ -36,7 +36,7 @@ import langToml from 'react-syntax-highlighter/dist/esm/languages/prism/toml.js'
36
36
  import langGo from 'react-syntax-highlighter/dist/esm/languages/prism/go.js';
37
37
  import langGraphql from 'react-syntax-highlighter/dist/esm/languages/prism/graphql.js';
38
38
  import { isInlineTrait } from '@almadar/core';
39
- import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter, useDroppable } from '@dnd-kit/core';
39
+ import { useSensors, useSensor, PointerSensor, KeyboardSensor, pointerWithin, rectIntersection, closestCorners, DndContext, DragOverlay, useDroppable } from '@dnd-kit/core';
40
40
  import { sortableKeyboardCoordinates, arrayMove, useSortable, SortableContext, rectSortingStrategy, verticalListSortingStrategy } from '@dnd-kit/sortable';
41
41
  import { CSS } from '@dnd-kit/utilities';
42
42
  import { Handle, Position } from '@xyflow/react';
@@ -21308,6 +21308,10 @@ function useDataDnd(args) {
21308
21308
  const unregisterZone = React81__default.useCallback((zoneId2) => {
21309
21309
  zonesRef.current.delete(zoneId2);
21310
21310
  }, []);
21311
+ const [overlayNode, setOverlayNode] = React81__default.useState(null);
21312
+ const setOverlay = React81__default.useCallback((node) => {
21313
+ setOverlayNode(node);
21314
+ }, []);
21311
21315
  const zoneId = React81__default.useId();
21312
21316
  const ownGroup = dragGroup ?? accepts ?? zoneId;
21313
21317
  const meta = React81__default.useMemo(
@@ -21327,6 +21331,13 @@ function useDataDnd(args) {
21327
21331
  useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
21328
21332
  useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
21329
21333
  );
21334
+ const collisionDetection = React81__default.useCallback((args2) => {
21335
+ const pointerCollisions = pointerWithin(args2);
21336
+ if (pointerCollisions.length > 0) return pointerCollisions;
21337
+ const rectCollisions = rectIntersection(args2);
21338
+ if (rectCollisions.length > 0) return rectCollisions;
21339
+ return closestCorners(args2);
21340
+ }, []);
21330
21341
  const findZoneByItem = React81__default.useCallback(
21331
21342
  (id) => {
21332
21343
  for (const z of zonesRef.current.values()) {
@@ -21384,6 +21395,7 @@ function useDataDnd(args) {
21384
21395
  },
21385
21396
  [orderedItems, ownGroup, findZoneByItem, findZoneByGroup, eventBus]
21386
21397
  );
21398
+ const overlaySink = isRoot ? setOverlay : parentRoot?.setOverlay;
21387
21399
  const SortableItem = React81__default.useCallback(
21388
21400
  ({ id, children }) => {
21389
21401
  const {
@@ -21394,6 +21406,11 @@ function useDataDnd(args) {
21394
21406
  transition,
21395
21407
  isDragging
21396
21408
  } = useSortable({ id, data: { dndGroup: ownGroup } });
21409
+ React81__default.useEffect(() => {
21410
+ if (!isDragging || !overlaySink) return;
21411
+ overlaySink(children);
21412
+ return () => overlaySink(null);
21413
+ }, [isDragging, children]);
21397
21414
  const style = {
21398
21415
  transform: CSS.Transform.toString(transform),
21399
21416
  transition,
@@ -21412,7 +21429,7 @@ function useDataDnd(args) {
21412
21429
  }
21413
21430
  );
21414
21431
  },
21415
- [ownGroup, enabled]
21432
+ [ownGroup, enabled, overlaySink]
21416
21433
  );
21417
21434
  const DropZoneShell = ({ children }) => {
21418
21435
  const { setNodeRef, isOver } = useDroppable({
@@ -21430,27 +21447,59 @@ function useDataDnd(args) {
21430
21447
  );
21431
21448
  };
21432
21449
  const rootContextValue = React81__default.useMemo(
21433
- () => ({ registerZone, unregisterZone }),
21434
- [registerZone, unregisterZone]
21450
+ () => ({ registerZone, unregisterZone, setOverlay }),
21451
+ [registerZone, unregisterZone, setOverlay]
21435
21452
  );
21436
21453
  const wrapContainer = React81__default.useCallback(
21437
21454
  (children) => {
21438
21455
  if (!enabled) return children;
21439
21456
  const strategy = layout === "grid" ? rectSortingStrategy : verticalListSortingStrategy;
21457
+ const clearOverlay = () => setOverlay(null);
21440
21458
  if (!isZone) {
21441
21459
  if (!isRoot) return children;
21442
- return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children }) });
21460
+ return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxs(
21461
+ DndContext,
21462
+ {
21463
+ sensors,
21464
+ collisionDetection,
21465
+ onDragEnd: (e) => {
21466
+ handleDragEnd(e);
21467
+ clearOverlay();
21468
+ },
21469
+ onDragCancel: clearOverlay,
21470
+ children: [
21471
+ children,
21472
+ /* @__PURE__ */ jsx(DragOverlay, { children: overlayNode })
21473
+ ]
21474
+ }
21475
+ ) });
21443
21476
  }
21444
21477
  const inner = /* @__PURE__ */ jsx(DropZoneShell, { children: /* @__PURE__ */ jsx(SortableContext, { items: itemIds, strategy, children }) });
21445
21478
  if (isRoot) {
21446
- return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: inner }) });
21479
+ return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxs(
21480
+ DndContext,
21481
+ {
21482
+ sensors,
21483
+ collisionDetection,
21484
+ onDragEnd: (e) => {
21485
+ handleDragEnd(e);
21486
+ clearOverlay();
21487
+ },
21488
+ onDragCancel: clearOverlay,
21489
+ children: [
21490
+ inner,
21491
+ /* @__PURE__ */ jsx(DragOverlay, { children: overlayNode })
21492
+ ]
21493
+ }
21494
+ ) });
21447
21495
  }
21448
21496
  return inner;
21449
21497
  },
21450
- [enabled, isZone, layout, sensors, handleDragEnd, itemIds, isRoot, rootContextValue]
21498
+ [enabled, isZone, layout, sensors, collisionDetection, handleDragEnd, itemIds, isRoot, rootContextValue, overlayNode, setOverlay]
21451
21499
  );
21452
21500
  return {
21453
21501
  enabled,
21502
+ isZone,
21454
21503
  wrapContainer,
21455
21504
  SortableItem,
21456
21505
  orderedItems
@@ -21656,7 +21705,7 @@ function DataGrid({
21656
21705
  const id = itemData.id || String(index);
21657
21706
  const isSelected = selectedIds.has(id);
21658
21707
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
21659
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21708
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21660
21709
  if (hasRenderProp) {
21661
21710
  return wrapDnd(
21662
21711
  /* @__PURE__ */ jsx(
@@ -22072,7 +22121,7 @@ function DataList({
22072
22121
  const idFieldName = dndItemIdField ?? "id";
22073
22122
  const renderItem = (itemData, index, isLast) => {
22074
22123
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
22075
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
22124
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
22076
22125
  if (hasRenderProp) {
22077
22126
  const id2 = itemData.id || String(index);
22078
22127
  return wrapDnd(
@@ -21123,6 +21123,10 @@ function useDataDnd(args) {
21123
21123
  const unregisterZone = React80__namespace.default.useCallback((zoneId2) => {
21124
21124
  zonesRef.current.delete(zoneId2);
21125
21125
  }, []);
21126
+ const [overlayNode, setOverlayNode] = React80__namespace.default.useState(null);
21127
+ const setOverlay = React80__namespace.default.useCallback((node) => {
21128
+ setOverlayNode(node);
21129
+ }, []);
21126
21130
  const zoneId = React80__namespace.default.useId();
21127
21131
  const ownGroup = dragGroup ?? accepts ?? zoneId;
21128
21132
  const meta = React80__namespace.default.useMemo(
@@ -21142,6 +21146,13 @@ function useDataDnd(args) {
21142
21146
  core$1.useSensor(core$1.PointerSensor, { activationConstraint: { distance: 5 } }),
21143
21147
  core$1.useSensor(core$1.KeyboardSensor, { coordinateGetter: sortable.sortableKeyboardCoordinates })
21144
21148
  );
21149
+ const collisionDetection = React80__namespace.default.useCallback((args2) => {
21150
+ const pointerCollisions = core$1.pointerWithin(args2);
21151
+ if (pointerCollisions.length > 0) return pointerCollisions;
21152
+ const rectCollisions = core$1.rectIntersection(args2);
21153
+ if (rectCollisions.length > 0) return rectCollisions;
21154
+ return core$1.closestCorners(args2);
21155
+ }, []);
21145
21156
  const findZoneByItem = React80__namespace.default.useCallback(
21146
21157
  (id) => {
21147
21158
  for (const z of zonesRef.current.values()) {
@@ -21199,6 +21210,7 @@ function useDataDnd(args) {
21199
21210
  },
21200
21211
  [orderedItems, ownGroup, findZoneByItem, findZoneByGroup, eventBus]
21201
21212
  );
21213
+ const overlaySink = isRoot ? setOverlay : parentRoot?.setOverlay;
21202
21214
  const SortableItem = React80__namespace.default.useCallback(
21203
21215
  ({ id, children }) => {
21204
21216
  const {
@@ -21209,6 +21221,11 @@ function useDataDnd(args) {
21209
21221
  transition,
21210
21222
  isDragging
21211
21223
  } = sortable.useSortable({ id, data: { dndGroup: ownGroup } });
21224
+ React80__namespace.default.useEffect(() => {
21225
+ if (!isDragging || !overlaySink) return;
21226
+ overlaySink(children);
21227
+ return () => overlaySink(null);
21228
+ }, [isDragging, children]);
21212
21229
  const style = {
21213
21230
  transform: utilities.CSS.Transform.toString(transform),
21214
21231
  transition,
@@ -21227,7 +21244,7 @@ function useDataDnd(args) {
21227
21244
  }
21228
21245
  );
21229
21246
  },
21230
- [ownGroup, enabled]
21247
+ [ownGroup, enabled, overlaySink]
21231
21248
  );
21232
21249
  const DropZoneShell = ({ children }) => {
21233
21250
  const { setNodeRef, isOver } = core$1.useDroppable({
@@ -21245,27 +21262,59 @@ function useDataDnd(args) {
21245
21262
  );
21246
21263
  };
21247
21264
  const rootContextValue = React80__namespace.default.useMemo(
21248
- () => ({ registerZone, unregisterZone }),
21249
- [registerZone, unregisterZone]
21265
+ () => ({ registerZone, unregisterZone, setOverlay }),
21266
+ [registerZone, unregisterZone, setOverlay]
21250
21267
  );
21251
21268
  const wrapContainer = React80__namespace.default.useCallback(
21252
21269
  (children) => {
21253
21270
  if (!enabled) return children;
21254
21271
  const strategy = layout === "grid" ? sortable.rectSortingStrategy : sortable.verticalListSortingStrategy;
21272
+ const clearOverlay = () => setOverlay(null);
21255
21273
  if (!isZone) {
21256
21274
  if (!isRoot) return children;
21257
- return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.DndContext, { sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, children }) });
21275
+ return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
21276
+ core$1.DndContext,
21277
+ {
21278
+ sensors,
21279
+ collisionDetection,
21280
+ onDragEnd: (e) => {
21281
+ handleDragEnd(e);
21282
+ clearOverlay();
21283
+ },
21284
+ onDragCancel: clearOverlay,
21285
+ children: [
21286
+ children,
21287
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: overlayNode })
21288
+ ]
21289
+ }
21290
+ ) });
21258
21291
  }
21259
21292
  const inner = /* @__PURE__ */ jsxRuntime.jsx(DropZoneShell, { children: /* @__PURE__ */ jsxRuntime.jsx(sortable.SortableContext, { items: itemIds, strategy, children }) });
21260
21293
  if (isRoot) {
21261
- return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.DndContext, { sensors, collisionDetection: core$1.closestCenter, onDragEnd: handleDragEnd, children: inner }) });
21294
+ return /* @__PURE__ */ jsxRuntime.jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
21295
+ core$1.DndContext,
21296
+ {
21297
+ sensors,
21298
+ collisionDetection,
21299
+ onDragEnd: (e) => {
21300
+ handleDragEnd(e);
21301
+ clearOverlay();
21302
+ },
21303
+ onDragCancel: clearOverlay,
21304
+ children: [
21305
+ inner,
21306
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.DragOverlay, { children: overlayNode })
21307
+ ]
21308
+ }
21309
+ ) });
21262
21310
  }
21263
21311
  return inner;
21264
21312
  },
21265
- [enabled, isZone, layout, sensors, handleDragEnd, itemIds, isRoot, rootContextValue]
21313
+ [enabled, isZone, layout, sensors, collisionDetection, handleDragEnd, itemIds, isRoot, rootContextValue, overlayNode, setOverlay]
21266
21314
  );
21267
21315
  return {
21268
21316
  enabled,
21317
+ isZone,
21269
21318
  wrapContainer,
21270
21319
  SortableItem,
21271
21320
  orderedItems
@@ -21471,7 +21520,7 @@ function DataGrid({
21471
21520
  const id = itemData.id || String(index);
21472
21521
  const isSelected = selectedIds.has(id);
21473
21522
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
21474
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21523
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21475
21524
  if (hasRenderProp) {
21476
21525
  return wrapDnd(
21477
21526
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -21887,7 +21936,7 @@ function DataList({
21887
21936
  const idFieldName = dndItemIdField ?? "id";
21888
21937
  const renderItem = (itemData, index, isLast) => {
21889
21938
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
21890
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21939
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsxRuntime.jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21891
21940
  if (hasRenderProp) {
21892
21941
  const id2 = itemData.id || String(index);
21893
21942
  return wrapDnd(
@@ -36,7 +36,7 @@ import langToml from 'react-syntax-highlighter/dist/esm/languages/prism/toml.js'
36
36
  import langGo from 'react-syntax-highlighter/dist/esm/languages/prism/go.js';
37
37
  import langGraphql from 'react-syntax-highlighter/dist/esm/languages/prism/graphql.js';
38
38
  import { isCircuitEvent, schemaToIR, getPage, clearSchemaCache as clearSchemaCache$1, isEntityCall, isInlineTrait } from '@almadar/core';
39
- import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter, useDroppable } from '@dnd-kit/core';
39
+ import { useSensors, useSensor, PointerSensor, KeyboardSensor, pointerWithin, rectIntersection, closestCorners, DndContext, DragOverlay, useDroppable } from '@dnd-kit/core';
40
40
  import { sortableKeyboardCoordinates, arrayMove, useSortable, SortableContext, rectSortingStrategy, verticalListSortingStrategy } from '@dnd-kit/sortable';
41
41
  import { CSS } from '@dnd-kit/utilities';
42
42
  import { Handle, Position } from '@xyflow/react';
@@ -21077,6 +21077,10 @@ function useDataDnd(args) {
21077
21077
  const unregisterZone = React80__default.useCallback((zoneId2) => {
21078
21078
  zonesRef.current.delete(zoneId2);
21079
21079
  }, []);
21080
+ const [overlayNode, setOverlayNode] = React80__default.useState(null);
21081
+ const setOverlay = React80__default.useCallback((node) => {
21082
+ setOverlayNode(node);
21083
+ }, []);
21080
21084
  const zoneId = React80__default.useId();
21081
21085
  const ownGroup = dragGroup ?? accepts ?? zoneId;
21082
21086
  const meta = React80__default.useMemo(
@@ -21096,6 +21100,13 @@ function useDataDnd(args) {
21096
21100
  useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),
21097
21101
  useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates })
21098
21102
  );
21103
+ const collisionDetection = React80__default.useCallback((args2) => {
21104
+ const pointerCollisions = pointerWithin(args2);
21105
+ if (pointerCollisions.length > 0) return pointerCollisions;
21106
+ const rectCollisions = rectIntersection(args2);
21107
+ if (rectCollisions.length > 0) return rectCollisions;
21108
+ return closestCorners(args2);
21109
+ }, []);
21099
21110
  const findZoneByItem = React80__default.useCallback(
21100
21111
  (id) => {
21101
21112
  for (const z of zonesRef.current.values()) {
@@ -21153,6 +21164,7 @@ function useDataDnd(args) {
21153
21164
  },
21154
21165
  [orderedItems, ownGroup, findZoneByItem, findZoneByGroup, eventBus]
21155
21166
  );
21167
+ const overlaySink = isRoot ? setOverlay : parentRoot?.setOverlay;
21156
21168
  const SortableItem = React80__default.useCallback(
21157
21169
  ({ id, children }) => {
21158
21170
  const {
@@ -21163,6 +21175,11 @@ function useDataDnd(args) {
21163
21175
  transition,
21164
21176
  isDragging
21165
21177
  } = useSortable({ id, data: { dndGroup: ownGroup } });
21178
+ React80__default.useEffect(() => {
21179
+ if (!isDragging || !overlaySink) return;
21180
+ overlaySink(children);
21181
+ return () => overlaySink(null);
21182
+ }, [isDragging, children]);
21166
21183
  const style = {
21167
21184
  transform: CSS.Transform.toString(transform),
21168
21185
  transition,
@@ -21181,7 +21198,7 @@ function useDataDnd(args) {
21181
21198
  }
21182
21199
  );
21183
21200
  },
21184
- [ownGroup, enabled]
21201
+ [ownGroup, enabled, overlaySink]
21185
21202
  );
21186
21203
  const DropZoneShell = ({ children }) => {
21187
21204
  const { setNodeRef, isOver } = useDroppable({
@@ -21199,27 +21216,59 @@ function useDataDnd(args) {
21199
21216
  );
21200
21217
  };
21201
21218
  const rootContextValue = React80__default.useMemo(
21202
- () => ({ registerZone, unregisterZone }),
21203
- [registerZone, unregisterZone]
21219
+ () => ({ registerZone, unregisterZone, setOverlay }),
21220
+ [registerZone, unregisterZone, setOverlay]
21204
21221
  );
21205
21222
  const wrapContainer = React80__default.useCallback(
21206
21223
  (children) => {
21207
21224
  if (!enabled) return children;
21208
21225
  const strategy = layout === "grid" ? rectSortingStrategy : verticalListSortingStrategy;
21226
+ const clearOverlay = () => setOverlay(null);
21209
21227
  if (!isZone) {
21210
21228
  if (!isRoot) return children;
21211
- return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children }) });
21229
+ return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxs(
21230
+ DndContext,
21231
+ {
21232
+ sensors,
21233
+ collisionDetection,
21234
+ onDragEnd: (e) => {
21235
+ handleDragEnd(e);
21236
+ clearOverlay();
21237
+ },
21238
+ onDragCancel: clearOverlay,
21239
+ children: [
21240
+ children,
21241
+ /* @__PURE__ */ jsx(DragOverlay, { children: overlayNode })
21242
+ ]
21243
+ }
21244
+ ) });
21212
21245
  }
21213
21246
  const inner = /* @__PURE__ */ jsx(DropZoneShell, { children: /* @__PURE__ */ jsx(SortableContext, { items: itemIds, strategy, children }) });
21214
21247
  if (isRoot) {
21215
- return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: inner }) });
21248
+ return /* @__PURE__ */ jsx(RootCtx.Provider, { value: rootContextValue, children: /* @__PURE__ */ jsxs(
21249
+ DndContext,
21250
+ {
21251
+ sensors,
21252
+ collisionDetection,
21253
+ onDragEnd: (e) => {
21254
+ handleDragEnd(e);
21255
+ clearOverlay();
21256
+ },
21257
+ onDragCancel: clearOverlay,
21258
+ children: [
21259
+ inner,
21260
+ /* @__PURE__ */ jsx(DragOverlay, { children: overlayNode })
21261
+ ]
21262
+ }
21263
+ ) });
21216
21264
  }
21217
21265
  return inner;
21218
21266
  },
21219
- [enabled, isZone, layout, sensors, handleDragEnd, itemIds, isRoot, rootContextValue]
21267
+ [enabled, isZone, layout, sensors, collisionDetection, handleDragEnd, itemIds, isRoot, rootContextValue, overlayNode, setOverlay]
21220
21268
  );
21221
21269
  return {
21222
21270
  enabled,
21271
+ isZone,
21223
21272
  wrapContainer,
21224
21273
  SortableItem,
21225
21274
  orderedItems
@@ -21425,7 +21474,7 @@ function DataGrid({
21425
21474
  const id = itemData.id || String(index);
21426
21475
  const isSelected = selectedIds.has(id);
21427
21476
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
21428
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21477
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21429
21478
  if (hasRenderProp) {
21430
21479
  return wrapDnd(
21431
21480
  /* @__PURE__ */ jsx(
@@ -21841,7 +21890,7 @@ function DataList({
21841
21890
  const idFieldName = dndItemIdField ?? "id";
21842
21891
  const renderItem = (itemData, index, isLast) => {
21843
21892
  const dndId = itemData[idFieldName] ?? `__idx_${index}`;
21844
- const wrapDnd = (node) => dnd.enabled ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21893
+ const wrapDnd = (node) => dnd.isZone ? /* @__PURE__ */ jsx(dnd.SortableItem, { id: dndId, children: node }) : node;
21845
21894
  if (hasRenderProp) {
21846
21895
  const id2 = itemData.id || String(index);
21847
21896
  return wrapDnd(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.50.1",
3
+ "version": "4.50.3",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [