@mapples/dnd 1.1.1 → 1.2.0

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.
@@ -11,6 +11,6 @@ import { DnDRootViewProps } from '../types';
11
11
  * @returns The rendered drag and drop root view
12
12
  * @public
13
13
  */
14
- declare const DnDRootView: <T extends object>({ children, DragElement, onDrop, ...props }: DnDRootViewProps<T>) => import("react").JSX.Element;
14
+ declare const DnDRootView: <T extends object>({ children, DragElement, onDrop, pointerTransform, ...props }: DnDRootViewProps<T>) => import("react").JSX.Element;
15
15
  export default DnDRootView;
16
16
  //# sourceMappingURL=DnDRootView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DnDRootView.d.ts","sourceRoot":"","sources":["../../src/components/DnDRootView.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG1D;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,6CAKpC,gBAAgB,CAAC,CAAC,CAAC,gCAoGrB,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"DnDRootView.d.ts","sourceRoot":"","sources":["../../src/components/DnDRootView.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG1D;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,+DAMpC,gBAAgB,CAAC,CAAC,CAAC,gCAgLrB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { Gesture, GestureDetector, GestureHandlerRootView, } from 'react-native-gesture-handler';
2
+ import { Gesture, GestureDetector, GestureHandlerRootView, PointerType, } from 'react-native-gesture-handler';
3
3
  import { runOnJS, useSharedValue } from 'react-native-reanimated';
4
4
  import { filter } from 'rxjs';
5
5
  import { initialDragCoords, initialOverLayout } from '../constants';
@@ -19,7 +19,7 @@ import { filterEvents } from '../utils';
19
19
  * @returns The rendered drag and drop root view
20
20
  * @public
21
21
  */
22
- const DnDRootView = ({ children, DragElement, onDrop, ...props }) => {
22
+ const DnDRootView = ({ children, DragElement, onDrop, pointerTransform, ...props }) => {
23
23
  const [isDragging, setIsDragging] = useState(false);
24
24
  // Lazy state init creates the Monitor exactly once and keeps the same
25
25
  // instance for the component's lifetime, without reading refs during render
@@ -28,6 +28,10 @@ const DnDRootView = ({ children, DragElement, onDrop, ...props }) => {
28
28
  const [monitor] = useState(() => new Monitor({ padding: 5 }));
29
29
  const sv = useSharedValue(initialDragCoords);
30
30
  const svOverLayout = useSharedValue(initialOverLayout);
31
+ // Window position of the pointer at touch-down (onBegin). onStart only
32
+ // fires after minDistance, and translationX/Y is measured from ACTIVATION,
33
+ // so the activation event alone cannot recover where the press began.
34
+ const pressSV = useSharedValue(initialDragCoords);
31
35
  useEffect(() => {
32
36
  const subscription = monitor.events
33
37
  .pipe(filter(filterEvents(DnDEventType.DragStart, DnDEventType.DragEnd)))
@@ -39,6 +43,10 @@ const DnDRootView = ({ children, DragElement, onDrop, ...props }) => {
39
43
  if (e.type === DnDEventType.DragEnd) {
40
44
  setIsDragging(false);
41
45
  if (onDrop) {
46
+ // Released outside every drop area — the drag is over, but there
47
+ // is nothing to drop onto.
48
+ if (e.cancelled || !e.dropTarget)
49
+ return;
42
50
  if (!e.target)
43
51
  return;
44
52
  const target = monitor.getDragTargetData(e.target);
@@ -57,26 +65,79 @@ const DnDRootView = ({ children, DragElement, onDrop, ...props }) => {
57
65
  * @param type - The type of pan event (start, end, or drag)
58
66
  * @param e - The gesture event payload
59
67
  */
60
- const handlePanEvents = (type, e) => {
61
- monitor[type]({ x: e.absoluteX, y: e.absoluteY });
68
+ const handlePanEvents = (type, e, pressWindow) => {
69
+ const windowCoords = { x: e.absoluteX, y: e.absoluteY };
70
+ const coords = pointerTransform
71
+ ? pointerTransform(windowCoords)
72
+ : windowCoords;
73
+ if (type === 'onDragStart') {
74
+ // Hit-test at the TOUCH-DOWN point (captured in onBegin), not the
75
+ // activation point. onStart fires only after minDistance, and a fast
76
+ // drag can be far past the pressed element by then — hit-testing there
77
+ // grabbed whatever was under the pointer mid-path (e.g. an element in
78
+ // another frame) instead of what the user pressed.
79
+ const startWindow = pressWindow ?? windowCoords;
80
+ // Drag sources (palette items) are window-space; drop targets may be
81
+ // in a transformed space — the monitor needs both. A null transform is
82
+ // the normal case for a palette press (the palette sits beside the drop
83
+ // space, not on it), so the drag still starts off the window coords.
84
+ monitor.onDragStart(pointerTransform ? pointerTransform(startWindow) : startWindow, startWindow);
85
+ return;
86
+ }
87
+ if (type === 'onDrag') {
88
+ // A null transform means the pointer is off the drop space entirely.
89
+ if (!coords) {
90
+ monitor.onDragOutside();
91
+ return;
92
+ }
93
+ monitor.onDrag(coords);
94
+ return;
95
+ }
96
+ // Release: a pointer-up outside the drop space needs no preceding move
97
+ // to count as a cancel.
98
+ if (!coords)
99
+ monitor.onDragOutside();
100
+ monitor.onDragEnd();
62
101
  };
63
102
  /**
64
103
  * Handles tap gesture events for selection.
65
104
  * @param e - The tap gesture event payload
66
105
  */
67
106
  const handleSelect = (e) => {
68
- monitor.onSelect({ x: e.absoluteX, y: e.absoluteY });
107
+ const windowCoords = { x: e.absoluteX, y: e.absoluteY };
108
+ const coords = pointerTransform
109
+ ? pointerTransform(windowCoords)
110
+ : windowCoords;
111
+ // Tapped outside the drop space (surrounding chrome) — not a selection
112
+ // gesture at all, so it must not hit-test into the space.
113
+ if (!coords)
114
+ return;
115
+ monitor.onSelect(coords);
69
116
  };
70
117
  const tap = Gesture.Tap().onEnd((e) => {
118
+ // Gesture-handler's web KeyboardEventManager treats Enter/Space as
119
+ // "activation keys": a keydown bubbling from any focused element inside
120
+ // this root begins a synthetic press and the keyup completes it — a
121
+ // phantom tap at the element's center. For a focused text field that
122
+ // meant pressing space selected whatever lay under the field (ending an
123
+ // in-place edit mid-word). Selection is a pointer concept here, so
124
+ // keyboard-synthesized taps are ignored outright.
125
+ if (e.pointerType === PointerType.KEY)
126
+ return;
71
127
  runOnJS(handleSelect)(e);
72
128
  });
73
129
  const pan = Gesture.Pan()
130
+ // A few pixels of slack so taps never register as element move-drags.
131
+ .minDistance(4)
132
+ .onBegin((e) => {
133
+ pressSV.set({ x: e.absoluteX, y: e.absoluteY });
134
+ })
74
135
  .onStart((e) => {
75
136
  sv.set({
76
137
  x: e.x,
77
138
  y: e.y,
78
139
  });
79
- runOnJS(handlePanEvents)('onDragStart', e);
140
+ runOnJS(handlePanEvents)('onDragStart', e, pressSV.get());
80
141
  })
81
142
  .onChange((e) => {
82
143
  sv.set({
@@ -88,6 +149,15 @@ const DnDRootView = ({ children, DragElement, onDrop, ...props }) => {
88
149
  .onEnd((e) => {
89
150
  sv.set(initialDragCoords);
90
151
  runOnJS(handlePanEvents)('onDragEnd', e);
152
+ })
153
+ // A gesture cancelled rather than ended (pointer released off-window, or
154
+ // the race lost after activation) never reaches onEnd, which used to
155
+ // strand the drag ghost and highlights on screen. The monitor's onDragEnd
156
+ // is idempotent, so the normal end → finalize pair is a no-op the second
157
+ // time round.
158
+ .onFinalize((e) => {
159
+ sv.set(initialDragCoords);
160
+ runOnJS(handlePanEvents)('onDragEnd', e);
91
161
  });
92
162
  const composed = Gesture.Race(pan, tap);
93
163
  return (<DnDContextProvider value={{
@@ -1 +1 @@
1
- {"version":3,"file":"DnDRootView.js","sourceRoot":"","sources":["../../src/components/DnDRootView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EACL,OAAO,EACP,eAAe,EACf,sBAAsB,GAIvB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EA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AC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEL,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAExC,OAAO,CACL,CAAC,kBAAkB,CACjB,KAAK,CAAC,CAAC;YACL,OAAO;YACP,UAAU;YACV,EAAE;YACF,YAAY;SACb,CAAC,CAEF;MAAA,CAAC,sBAAsB,CAAC,IAAI,KAAK,CAAC,CAChC;QAAA,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,eAAe,CACjE;MAAA,EAAE,sBAAsB,CAC1B;IAAA,EAAE,kBAAkB,CAAC,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -3,6 +3,14 @@
3
3
  * Provides access to the parent drop target ID for establishing parent-child relationships.
4
4
  * @public
5
5
  */
6
+ /**
7
+ * Sentinel `DropArea.forId` value for "my parent has not registered yet".
8
+ * Children under it stay MOUNTED but defer their own registration until the
9
+ * real parent id replaces it — keeping the tree stable (no unmount/remount)
10
+ * across registration gaps, e.g. an editor re-enabling its drop targets when
11
+ * leaving a preview mode. Distinct from `null`, which means a true root.
12
+ */
13
+ export declare const DROP_PARENT_PENDING = -1;
6
14
  declare const DropContext: import("react").Context<{
7
15
  parent: number | null;
8
16
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"DropContext.d.ts","sourceRoot":"","sources":["../../src/context/DropContext.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,QAAA,MAAM,WAAW;YAA2B,MAAM,GAAG,IAAI;EAEvD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;YARY,MAAM,GAAG,IAAI;EAQF,CAAC;AAExD,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"DropContext.d.ts","sourceRoot":"","sources":["../../src/context/DropContext.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AACH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,QAAA,MAAM,WAAW;YAA2B,MAAM,GAAG,IAAI;EAEvD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;YARY,MAAM,GAAG,IAAI;EAQF,CAAC;AAExD,eAAe,WAAW,CAAC"}
@@ -4,6 +4,14 @@ import { createContext } from 'react';
4
4
  * Provides access to the parent drop target ID for establishing parent-child relationships.
5
5
  * @public
6
6
  */
7
+ /**
8
+ * Sentinel `DropArea.forId` value for "my parent has not registered yet".
9
+ * Children under it stay MOUNTED but defer their own registration until the
10
+ * real parent id replaces it — keeping the tree stable (no unmount/remount)
11
+ * across registration gaps, e.g. an editor re-enabling its drop targets when
12
+ * leaving a preview mode. Distinct from `null`, which means a true root.
13
+ */
14
+ export const DROP_PARENT_PENDING = -1;
7
15
  const DropContext = createContext({
8
16
  parent: null,
9
17
  });
@@ -1 +1 @@
1
- {"version":3,"file":"DropContext.js","sourceRoot":"","sources":["../../src/context/DropContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;GAIG;AACH,MAAM,WAAW,GAAG,aAAa,CAA4B;IAC3D,MAAM,EAAE,IAAI;CACb,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,QAAQ,CAAC;AAExD,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"DropContext.js","sourceRoot":"","sources":["../../src/context/DropContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;GAIG;AACH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,CAAC;AAEtC,MAAM,WAAW,GAAG,aAAa,CAA4B;IAC3D,MAAM,EAAE,IAAI;CACb,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,WAAW,CAAC,QAAQ,CAAC;AAExD,eAAe,WAAW,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { FC, PropsWithChildren, RefObject } from 'react';
2
+ import { View } from 'react-native';
3
+ export interface FrameSpaceContextType {
4
+ /** The frame key registered with the monitor via `registerFrame`. */
5
+ frameKey: string;
6
+ /**
7
+ * The view all drop elements in this frame measure against
8
+ * (`measureLayout(frameRoot)`), yielding scale-independent frame-local
9
+ * layout rects.
10
+ */
11
+ frameRootRef: RefObject<View | null>;
12
+ }
13
+ declare const FrameSpaceContext: import("react").Context<FrameSpaceContextType | null>;
14
+ /** The frame coordinate space the current subtree belongs to, if any. */
15
+ export declare const useFrameSpace: () => FrameSpaceContextType | null;
16
+ export interface FrameSpaceProps {
17
+ frameKey: string;
18
+ frameRootRef: RefObject<View | null>;
19
+ }
20
+ /**
21
+ * Declares a frame coordinate space for all `useDrop` registrations beneath
22
+ * it: elements measure relative to `frameRootRef` and register under
23
+ * `frameKey`, making their rects independent of viewport pan/zoom.
24
+ */
25
+ export declare const FrameSpace: FC<PropsWithChildren<FrameSpaceProps>>;
26
+ export default FrameSpaceContext;
27
+ //# sourceMappingURL=FrameSpaceContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameSpaceContext.d.ts","sourceRoot":"","sources":["../../src/context/FrameSpaceContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,EAAE,EACF,iBAAiB,EACjB,SAAS,EAGV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,WAAW,qBAAqB;IACpC,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,YAAY,EAAE,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;CACtC;AAED,QAAA,MAAM,iBAAiB,uDAAoD,CAAC;AAE5E,yEAAyE;AACzE,eAAO,MAAM,aAAa,oCAAsC,CAAC;AAEjE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAW7D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { createContext, useContext, useMemo, } from 'react';
2
+ const FrameSpaceContext = createContext(null);
3
+ /** The frame coordinate space the current subtree belongs to, if any. */
4
+ export const useFrameSpace = () => useContext(FrameSpaceContext);
5
+ /**
6
+ * Declares a frame coordinate space for all `useDrop` registrations beneath
7
+ * it: elements measure relative to `frameRootRef` and register under
8
+ * `frameKey`, making their rects independent of viewport pan/zoom.
9
+ */
10
+ export const FrameSpace = ({ frameKey, frameRootRef, children, }) => {
11
+ const value = useMemo(() => ({ frameKey, frameRootRef }), [frameKey, frameRootRef]);
12
+ return <FrameSpaceContext value={value}>{children}</FrameSpaceContext>;
13
+ };
14
+ export default FrameSpaceContext;
15
+ //# sourceMappingURL=FrameSpaceContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FrameSpaceContext.js","sourceRoot":"","sources":["../../src/context/FrameSpaceContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAIb,UAAU,EACV,OAAO,GACR,MAAM,OAAO,CAAC;AAef,MAAM,iBAAiB,GAAG,aAAa,CAA+B,IAAI,CAAC,CAAC;AAE5E,yEAAyE;AACzE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;AAOjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAA2C,CAAC,EACjE,QAAQ,EACR,YAAY,EACZ,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,EAClC,CAAC,QAAQ,EAAE,YAAY,CAAC,CACzB,CAAC;IAEF,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,CAAC;AACzE,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -2,4 +2,6 @@ export { default as DnDContext } from './DnDContext';
2
2
  export * from './DnDContext';
3
3
  export { default as DropContext } from './DropContext';
4
4
  export * from './DropContext';
5
+ export { default as FrameSpaceContext } from './FrameSpaceContext';
6
+ export * from './FrameSpaceContext';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,cAAc,qBAAqB,CAAC"}
@@ -2,4 +2,6 @@ export { default as DnDContext } from './DnDContext';
2
2
  export * from './DnDContext';
3
3
  export { default as DropContext } from './DropContext';
4
4
  export * from './DropContext';
5
+ export { default as FrameSpaceContext } from './FrameSpaceContext';
6
+ export * from './FrameSpaceContext';
5
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,cAAc,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDrop.d.ts","sourceRoot":"","sources":["../../src/hooks/useDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAwC,IAAI,EAAE,MAAM,cAAc,CAAC;AAG1E,OAAO,EAAgB,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAMtE;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,OAAO,GAAI,QAAQ,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,GAAG,QAAQ,EAC1E,KAAK,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,EAC3B,SAAS,gBAAgB,EACzB,OAAO,QAAQ;IAqGb,wCAAwC;;IAExC,wDAAwD;;IAExD,0CAA0C;;IAE1C,gDAAgD;;IAEhD,qDAAqD;;IAErD,0DAA0D;;CAG7D,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"useDrop.d.ts","sourceRoot":"","sources":["../../src/hooks/useDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAwC,IAAI,EAAE,MAAM,cAAc,CAAC;AAK1E,OAAO,EAAgB,UAAU,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAMtE;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,OAAO,GAAI,QAAQ,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,GAAG,QAAQ,EAC1E,KAAK,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,EAC3B,SAAS,gBAAgB,EACzB,OAAO,QAAQ;IAwJb,wCAAwC;;IAExC,wDAAwD;;IAExD,0CAA0C;;IAE1C,gDAAgD;;IAEhD,qDAAqD;;IAErD,0DAA0D;;CAG7D,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { useCallback, useEffect, useLayoutEffect, useRef, useState, } from 'react';
2
2
  import { useWindowDimensions } from 'react-native';
3
3
  import { filter } from 'rxjs';
4
+ import { DROP_PARENT_PENDING } from '../context/DropContext';
5
+ import { useFrameSpace } from '../context/FrameSpaceContext';
4
6
  import { DnDEventType } from '../types';
5
7
  import { filterEvents } from '../utils';
6
8
  import useDnD from './useDnD';
@@ -21,23 +23,65 @@ const useDrop = (ref, config, data) => {
21
23
  const [dropTarget, setDropTarget] = useState(null);
22
24
  const { monitor, isDragging } = useDnD();
23
25
  const { parent } = useDropContext();
26
+ const frameSpace = useFrameSpace();
24
27
  const { width, height } = useWindowDimensions();
25
28
  const [id, setId] = useState(null);
26
29
  const [isOver, setIsOver] = useState(false);
27
30
  const [dropTargetIndex, setDropTargetIndex] = useState(null);
28
31
  const idRef = useRef(null);
29
32
  const layoutRef = useRef(null);
33
+ /**
34
+ * Measures the element in the active coordinate space. Inside a frame
35
+ * space, rects are measured relative to the frame root (layout-engine
36
+ * values — unaffected by viewport scale/translate on web), so they stay
37
+ * valid across pan/zoom without re-measuring.
38
+ */
39
+ const measure = useCallback((callback) => {
40
+ const node = ref.current;
41
+ if (!node)
42
+ return;
43
+ const frameRoot = frameSpace?.frameRootRef.current;
44
+ if (frameRoot) {
45
+ // measureLayout reads layout-engine offsets (transform-independent on
46
+ // web); measuring the root against itself yields {0, 0, w, h}.
47
+ node.measureLayout?.(frameRoot, (x, y, width, height) => {
48
+ callback({ x, y, width, height });
49
+ });
50
+ return;
51
+ }
52
+ node.measureInWindow?.((x, y, width, height) => {
53
+ callback({ x, y, width, height });
54
+ });
55
+ }, [frameSpace, ref]);
30
56
  useLayoutEffect(() => {
31
- ref.current?.measureInWindow?.((x, y, width, height) => {
32
- layoutRef.current = { x, y, width, height };
57
+ // Disabled — or the parent's own registration hasn't landed yet:
58
+ // withdraw from the monitor entirely (no hit-testing, no drops) while
59
+ // the component — and its subtree — stays mounted. Registering under a
60
+ // pending parent would root the element in the wrong place, and parents
61
+ // are fixed at registration time.
62
+ if (config?.enabled === false || parent === DROP_PARENT_PENDING) {
63
+ if (idRef.current) {
64
+ monitor.unregisterDropElement(idRef.current);
65
+ idRef.current = null;
66
+ setId(null);
67
+ }
68
+ return;
69
+ }
70
+ measure((layout) => {
71
+ layoutRef.current = layout;
72
+ // Only the frame root (no drop parent) carries the frame key; children
73
+ // inherit the space during hit testing.
74
+ const effectiveConfig = frameSpace && !parent
75
+ ? { ...config, frameKey: frameSpace.frameKey }
76
+ : config;
33
77
  if (idRef.current) {
34
- monitor.updateDropElement(idRef.current, layoutRef.current, config, data);
78
+ monitor.updateDropElement(idRef.current, layoutRef.current, effectiveConfig, data);
35
79
  return;
36
80
  }
37
- idRef.current = monitor.registerDropElement(layoutRef.current, parent, config, data);
81
+ idRef.current = monitor.registerDropElement(layoutRef.current, parent, effectiveConfig, data);
38
82
  setId(idRef.current);
39
83
  });
40
- }, [config, data, monitor, parent, ref]);
84
+ }, [config, data, frameSpace, measure, monitor, parent, ref]);
41
85
  useEffect(() => {
42
86
  return () => {
43
87
  if (idRef.current) {
@@ -67,13 +111,13 @@ const useDrop = (ref, config, data) => {
67
111
  * This function should be called when the element's position or size changes.
68
112
  */
69
113
  const updateLayout = useCallback(() => {
70
- ref.current?.measureInWindow?.((x, y, width, height) => {
71
- layoutRef.current = { x, y, width, height };
114
+ measure((layout) => {
115
+ layoutRef.current = layout;
72
116
  if (idRef.current) {
73
117
  monitor.updateDropElement(idRef.current, layoutRef.current);
74
118
  }
75
119
  });
76
- }, [monitor, ref]);
120
+ }, [measure, monitor]);
77
121
  useEffect(() => {
78
122
  const subscription = monitor.events
79
123
  .pipe(filter(filterEvents(DnDEventType.LayoutForceUpdate)))
@@ -1 +1 @@
1
- {"version":3,"file":"useDrop.js","sourceRoot":"","sources":["../../src/hooks/useDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,eAAe,EACf,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAmB,mBAAmB,EAAQ,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAgC,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,GAAG,CACd,GAA2B,EAC3B,MAAyB,EACzB,IAAe,EACf,EAAE;IACF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAC1C,IAAI,CACL,CAAC;IAEF,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,EAAsB,CAAC;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IACpC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAEhD,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAgB,IA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;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './components';
2
+ export * from './context/DropContext';
3
+ export * from './context/FrameSpaceContext';
2
4
  export * from './hooks';
3
5
  export * from './monitor';
4
6
  export * from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './components';
2
+ export * from './context/DropContext';
3
+ export * from './context/FrameSpaceContext';
2
4
  export * from './hooks';
3
5
  export * from './monitor';
4
6
  export * from './types';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { LayoutRectangle } from 'react-native';
2
2
  import { Subject } from 'rxjs';
3
- import { DnDEvent, DragCoords, DragElementTarget, DragItem, DropTarget, DropTargetConfig, MonitorConfig } from '../types';
3
+ import { DnDEvent, DragCoords, DragElementTarget, DragItem, DropTarget, DropTargetConfig, FrameEntry, MonitorConfig } from '../types';
4
4
  /**
5
5
  * Core monitor class that manages drag and drop operations.
6
6
  * This class tracks drag elements, drop targets, handles hit detection, and emits events.
@@ -22,8 +22,15 @@ export declare class Monitor<DragData extends object, DropData extends object =
22
22
  private dragElements;
23
23
  /** Tree structure of registered drop elements */
24
24
  private dropElementsTree;
25
+ /** Registered frame coordinate spaces by key */
26
+ private frames;
25
27
  /** ID of the currently active drag target */
26
28
  private dragTargetId;
29
+ /** Active move-drag source (an existing canvas element being moved) */
30
+ private moveSource;
31
+ /** Pointer coords at drag start / most recent drag tick (drop space) */
32
+ private dragStartCoords;
33
+ private lastDragCoords;
27
34
  /** Currently active drop target */
28
35
  private dropTarget;
29
36
  /** Index position within the current drop target */
@@ -35,6 +42,26 @@ export declare class Monitor<DragData extends object, DropData extends object =
35
42
  * @param config - Configuration options for the monitor
36
43
  */
37
44
  constructor(config: MonitorConfig);
45
+ /**
46
+ * Registers (or replaces) a frame coordinate space. Drop elements whose
47
+ * config carries the same `frameKey` are stored and hit-tested in
48
+ * coordinates relative to this frame's origin.
49
+ */
50
+ registerFrame(frameKey: string, entry: FrameEntry): void;
51
+ /**
52
+ * Moves a frame's world origin. O(1): no element re-measures needed since
53
+ * frame content layouts are origin-relative.
54
+ */
55
+ updateFrameOrigin(frameKey: string, origin: DragCoords): void;
56
+ /** Removes a frame coordinate space. */
57
+ unregisterFrame(frameKey: string): void;
58
+ /** Gets a registered frame space by key. */
59
+ getFrame(frameKey: string): FrameEntry | undefined;
60
+ /**
61
+ * Converts world coordinates into a frame's local space.
62
+ * Falls through unchanged when the frame isn't registered.
63
+ */
64
+ toFrameLocal(coords: DragCoords, frameKey: string): DragCoords;
38
65
  /**
39
66
  * Gets the ID of the currently active drag target.
40
67
  * @returns The drag target ID or null if no drag is active
@@ -103,35 +130,90 @@ export declare class Monitor<DragData extends object, DropData extends object =
103
130
  updateDragElementLayout(id: number, layout: LayoutRectangle): void;
104
131
  /**
105
132
  * Handles the start of a drag operation.
106
- * @param dragCoords - The coordinates where the drag started
133
+ * @param dragCoords - Coordinates in drop-target space (world space when a
134
+ * pointer transform is installed), or `null` when the press began outside
135
+ * that space entirely. A palette press is exactly that case — the palette
136
+ * lives beside the canvas, not on it — so a null here must never abort the
137
+ * drag; it only rules out grabbing an existing element to move.
138
+ * @param windowCoords - Raw window coordinates for drag-*source* hit
139
+ * testing (palette items live outside any frame); defaults to `dragCoords`
107
140
  */
108
- onDragStart(dragCoords: DragCoords): void;
141
+ onDragStart(dragCoords: DragCoords | null, windowCoords?: DragCoords): void;
109
142
  /**
110
143
  * Handles drag movement during a drag operation.
111
144
  * @param dragCoords - The current coordinates of the drag
112
145
  */
113
146
  onDrag(dragCoords: DragCoords): void;
147
+ /**
148
+ * The pointer left the drop coordinate space entirely — reported by the
149
+ * host when its `pointerTransform` cannot place the pointer (e.g. it moved
150
+ * off the canvas viewport onto surrounding chrome). Equivalent to hovering
151
+ * empty space: the pending drop clears, so a release here cancels.
152
+ */
153
+ onDragOutside(): void;
154
+ /**
155
+ * Hit-tests a point in drop space with no drag registered. Drags that start
156
+ * outside the app — files dragged in from the OS — never register a drag
157
+ * element, so they cannot go through {@link onDrag}; this gives them the
158
+ * same target and insert-index resolution the in-app drag path uses.
159
+ * @param dropCoords - The coordinates to hit-test, in drop space
160
+ */
161
+ hitTest(dropCoords: DragCoords): {
162
+ dropTarget: DropTarget<DropData> | null;
163
+ dropTargetIndex: number | null;
164
+ };
165
+ /**
166
+ * Publishes an external drag's current position, so the drop chrome
167
+ * (hover highlight, insert line) tracks a file dragged in from the OS
168
+ * exactly as it tracks an in-app drag. Pass `null` coordinates while the
169
+ * pointer sits outside the drop space — that clears the pending drop the
170
+ * same way hovering off a droppable area does mid-drag.
171
+ * @param dropCoords - The pointer position in drop space, or null
172
+ */
173
+ onExternalDrag(dropCoords: DragCoords | null): void;
174
+ /**
175
+ * Ends an external drag — the files were dropped, or the drag left the
176
+ * window. Always `cancelled`: whatever the drop produces is inserted by
177
+ * the host once its uploads finish, never by the DnD path.
178
+ */
179
+ onExternalDragEnd(): void;
114
180
  /**
115
181
  * Handles selection/tap events.
116
182
  * @param dragCoords - The coordinates where the selection occurred
117
183
  */
118
184
  onSelect(dragCoords: DragCoords): void;
119
185
  /**
120
- * Checks if the given coordinates are inside the first root element.
121
- * @param dragCoords - The coordinates to check
122
- * @returns True if inside the first root element
186
+ * Checks if the given coordinates are inside any root drop element,
187
+ * converting into frame-local space for frame-rooted elements.
123
188
  * @private
124
189
  */
125
- private isInsideFirstRootElement;
190
+ private isInsideAnyRootElement;
191
+ /**
192
+ * Looks up a registered drop target (with its current layout and frame
193
+ * key) by matching data properties — e.g. `{ id: componentId }`.
194
+ *
195
+ * @param frameKey - Restrict the search to one frame's subtree. Required
196
+ * whenever ids are only unique per frame (every page root shares the id
197
+ * `root`, so an unscoped lookup can return another frame's element).
198
+ */
199
+ getDropTargetByData(dataQuery: Partial<DropData>, frameKey?: string): DropTarget<DropData> | null;
126
200
  /**
127
201
  * Handles external selection by data query.
128
202
  * @param dataQuery - Partial data to match against drop targets
129
203
  */
130
204
  onExternalSelect(dataQuery: Partial<DropData>): void;
131
205
  /**
132
- * Handles the end of a drag operation.
206
+ * Handles the end of a drag operation. Releasing the pointer outside every
207
+ * droppable area cancels the drag: `DragEnd` still fires — overlays, the
208
+ * drag ghost and `isDragging` all reset on it — but carries a null
209
+ * `dropTarget` and `cancelled: true`, so nothing is inserted or moved.
133
210
  */
134
211
  onDragEnd(): void;
212
+ /**
213
+ * Clears every piece of per-drag state.
214
+ * @private
215
+ */
216
+ private resetDragState;
135
217
  /**
136
218
  * Registers a new drop element with the monitor.
137
219
  * @param layout - The layout rectangle of the drop element
@@ -154,6 +236,11 @@ export declare class Monitor<DragData extends object, DropData extends object =
154
236
  * @param data - Optional new data
155
237
  */
156
238
  updateDropElement(id: number, layout: LayoutRectangle, config?: DropTargetConfig, data?: DropData): void;
239
+ /**
240
+ * Resolves the frame space an element (or any of its ancestors) belongs to.
241
+ * @private
242
+ */
243
+ private findFrameKeyFor;
157
244
  /**
158
245
  * Finds a drop target by ID in the tree structure.
159
246
  * @param id - The ID to search for
@@ -1 +1 @@
1
- {"version":3,"file":"Monitor.d.ts","sourceRoot":"","sources":["../../src/monitor/Monitor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EACL,QAAQ,EAER,UAAU,EACV,iBAAiB,EACjB,QAAQ,EAER,UAAU,EACV,gBAAgB,EAGhB,aAAa,EACd,MAAM,UAAU,CAAC;AAElB;;;;;;;GAOG;AACH,qBAAa,OAAO,CAClB,QAAQ,SAAS,MAAM,EACvB,QAAQ,SAAS,MAAM,GAAG,QAAQ;IAElC,gDAAgD;IAChD,MAAM,wCAA+C;IAErD,oDAAoD;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IAErC,qDAAqD;IACrD,OAAO,CAAC,cAAc,CAAK;IAC3B,qDAAqD;IACrD,OAAO,CAAC,cAAc,CAAK;IAE3B,4CAA4C;IAC5C,OAAO,CAAC,YAAY,CAAkD;IACtE,iDAAiD;IACjD,OAAO,CAAC,gBAAgB,CAAiC;IAEzD,6CAA6C;IAC7C,OAAO,CAAC,YAAY,CAAuB;IAC3C,mCAAmC;IACnC,OAAO,CAAC,UAAU,CAAqC;IAEvD,oDAAoD;IACpD,OAAO,CAAC,eAAe,CAAuB;IAC9C,gEAAgE;IAChE,OAAO,CAAC,YAAY,CAAkB;IAEtC;;;OAGG;gBACS,MAAM,EAAE,aAAa;IAOjC;;;O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