@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.
- package/dist/components/DnDRootView.d.ts +1 -1
- package/dist/components/DnDRootView.d.ts.map +1 -1
- package/dist/components/DnDRootView.js +76 -6
- package/dist/components/DnDRootView.js.map +1 -1
- package/dist/context/DropContext.d.ts +8 -0
- package/dist/context/DropContext.d.ts.map +1 -1
- package/dist/context/DropContext.js +8 -0
- package/dist/context/DropContext.js.map +1 -1
- package/dist/context/FrameSpaceContext.d.ts +27 -0
- package/dist/context/FrameSpaceContext.d.ts.map +1 -0
- package/dist/context/FrameSpaceContext.js +15 -0
- package/dist/context/FrameSpaceContext.js.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +2 -0
- package/dist/context/index.js.map +1 -1
- package/dist/hooks/useDrop.d.ts.map +1 -1
- package/dist/hooks/useDrop.js +52 -8
- package/dist/hooks/useDrop.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/monitor/Monitor.d.ts +95 -8
- package/dist/monitor/Monitor.d.ts.map +1 -1
- package/dist/monitor/Monitor.js +326 -46
- package/dist/monitor/Monitor.js.map +1 -1
- package/dist/types/index.d.ts +86 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -40,6 +40,41 @@ export interface DnDEvent<DragData extends object, DropData extends object = Dra
|
|
|
40
40
|
data?: DragData | null;
|
|
41
41
|
/** The current coordinates of the drag operation */
|
|
42
42
|
dragCoords?: DragCoords | null;
|
|
43
|
+
/** The frame the drop target belongs to, when frame spaces are in use */
|
|
44
|
+
frameKey?: string | null;
|
|
45
|
+
/** Whether this drag inserts a new item (palette) or moves an existing one */
|
|
46
|
+
kind?: DragKind;
|
|
47
|
+
/** For `kind: 'move'`: the element being moved and where it came from */
|
|
48
|
+
moveSource?: MoveDragSource | null;
|
|
49
|
+
/** Pointer coords at drag start (drop space) — set on DragEnd */
|
|
50
|
+
dragStartCoords?: DragCoords | null;
|
|
51
|
+
/**
|
|
52
|
+
* Set on `DragEnd` when the pointer was released outside every droppable
|
|
53
|
+
* area. The drag is over — reset any drag-time UI — but no drop happened,
|
|
54
|
+
* so nothing should be inserted, moved or reparented.
|
|
55
|
+
*/
|
|
56
|
+
cancelled?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The kind of drag operation: a palette insert, a move of an existing canvas
|
|
60
|
+
* element, or a drag that started outside the app entirely (files dragged in
|
|
61
|
+
* from the OS — no drag element is ever registered for those).
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export type DragKind = 'palette' | 'move' | 'external';
|
|
65
|
+
/**
|
|
66
|
+
* Identifies the element a move-drag started on.
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export interface MoveDragSource {
|
|
70
|
+
/** Monitor drop-element id of the dragged element */
|
|
71
|
+
dropId: number;
|
|
72
|
+
/** Application-level component id (from the drop target's data) */
|
|
73
|
+
componentId: string;
|
|
74
|
+
/** Frame the element lives in, if any */
|
|
75
|
+
frameKey: string | null;
|
|
76
|
+
/** Pointer offset from the element's top-left corner at drag start */
|
|
77
|
+
grabOffset: DragCoords;
|
|
43
78
|
}
|
|
44
79
|
/**
|
|
45
80
|
* Type representing the coordinates of a drag operation.
|
|
@@ -102,6 +137,18 @@ export type DnDRootViewProps<DragData extends object, DropData extends object =
|
|
|
102
137
|
DragElement?: <T>(data: DragItem<T>) => ReactElement;
|
|
103
138
|
/** Callback fired when a drop operation completes */
|
|
104
139
|
onDrop?: (event: DnDEvent<DragData, DropData>, item: DragItem<DragData>) => void;
|
|
140
|
+
/**
|
|
141
|
+
* Converts absolute window pointer coordinates into the coordinate space
|
|
142
|
+
* drop targets are hit-tested in (e.g. an infinite canvas's world space).
|
|
143
|
+
* Drag *sources* keep window-space hit testing regardless. Omit for the
|
|
144
|
+
* default 1:1 window space.
|
|
145
|
+
*
|
|
146
|
+
* Return `null` for points that lie outside that space altogether (over
|
|
147
|
+
* surrounding chrome, say). The drag then counts as being over nothing —
|
|
148
|
+
* hovering there clears the pending drop and releasing there cancels it —
|
|
149
|
+
* rather than mapping onto whatever the space extrapolates to.
|
|
150
|
+
*/
|
|
151
|
+
pointerTransform?: (point: DragCoords) => DragCoords | null;
|
|
105
152
|
};
|
|
106
153
|
/**
|
|
107
154
|
* Props interface for the drop area component.
|
|
@@ -140,6 +187,35 @@ export interface DropTargetLayoutConfig {
|
|
|
140
187
|
export interface DropTargetConfig extends DropTargetLayoutConfig {
|
|
141
188
|
/** Whether this drop target can accept drops */
|
|
142
189
|
canDrop?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* When `false`, the element is not registered with the monitor at all — it
|
|
192
|
+
* takes part in no hit-testing, selection, or drops. Lets a consumer switch
|
|
193
|
+
* an already-mounted tree between editable and inert (e.g. an editor's
|
|
194
|
+
* preview mode) WITHOUT remounting it: registration follows the flag while
|
|
195
|
+
* the component identity — and therefore its rendered subtree — stays put.
|
|
196
|
+
*/
|
|
197
|
+
enabled?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Marks a root-level drop element as the root of a frame coordinate space:
|
|
200
|
+
* its own layout and every descendant's layout are stored relative to the
|
|
201
|
+
* frame origin registered via {@link Monitor.registerFrame}. Hit testing
|
|
202
|
+
* converts world coordinates into that space mathematically, so frame
|
|
203
|
+
* content never needs re-measuring on viewport pan/zoom or frame moves.
|
|
204
|
+
*/
|
|
205
|
+
frameKey?: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* A frame coordinate space: a world-space origin and device-space size.
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
export interface FrameEntry {
|
|
212
|
+
/** World-space position of the frame's top-left corner */
|
|
213
|
+
origin: DragCoords;
|
|
214
|
+
/** Frame size in world units (content may extend below `height`) */
|
|
215
|
+
size: {
|
|
216
|
+
width: number;
|
|
217
|
+
height: number;
|
|
218
|
+
};
|
|
143
219
|
}
|
|
144
220
|
/**
|
|
145
221
|
* Type representing a layout position with required configuration properties.
|
|
@@ -160,6 +236,8 @@ export interface DropItem<T> {
|
|
|
160
236
|
canDrop?: boolean;
|
|
161
237
|
/** Optional data associated with this drop item */
|
|
162
238
|
data?: T;
|
|
239
|
+
/** Frame space this subtree's layouts are relative to (root items only) */
|
|
240
|
+
frameKey?: string;
|
|
163
241
|
}
|
|
164
242
|
/**
|
|
165
243
|
* Type representing a tree structure of drop items.
|
|
@@ -195,6 +273,14 @@ export interface DropTarget<T> {
|
|
|
195
273
|
children?: DropTree<T>;
|
|
196
274
|
/** Optional data associated with this drop target */
|
|
197
275
|
data?: T;
|
|
276
|
+
/** Frame space the layout is relative to, when inside a frame */
|
|
277
|
+
frameKey?: string | null;
|
|
278
|
+
/**
|
|
279
|
+
* The pointer coordinates converted into this target's own coordinate
|
|
280
|
+
* space at hit-test time (frame-local inside frames). Consumers comparing
|
|
281
|
+
* pointer position against `layout` must use these, not raw event coords.
|
|
282
|
+
*/
|
|
283
|
+
hitCoords?: DragCoords;
|
|
198
284
|
}
|
|
199
285
|
/**
|
|
200
286
|
* Type representing a drag element target with layout and item information.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EAAE,OAAO,EAAE,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CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACvB,yCAAyC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mDAAmD;IACnD,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,MAAM,EAAE,cAAc,CAAC;IACvB,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACvB,qDAAqD;IACrD,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,eAAe,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC"}
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB,yCAAyC;IACzC,uCAAuB,CAAA;IACvB,mEAAmE;IACnE,6BAAa,CAAA;IACb,uCAAuC;IACvC,mCAAmB,CAAA;IACnB,2CAA2C;IAC3C,iCAAiB,CAAA;IACjB,+CAA+C;IAC/C,iCAAiB,CAAA;IACjB,qCAAqC;IACrC,uDAAuC,CAAA;AACzC,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB,yCAAyC;IACzC,uCAAuB,CAAA;IACvB,mEAAmE;IACnE,6BAAa,CAAA;IACb,uCAAuC;IACvC,mCAAmB,CAAA;IACnB,2CAA2C;IAC3C,iCAAiB,CAAA;IACjB,+CAA+C;IAC/C,iCAAiB,CAAA;IACjB,qCAAqC;IACrC,uDAAuC,CAAA;AACzC,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAgKD;;;GAGG;AACH,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,+BAA+B;IAC/B,kCAAiB,CAAA;IACjB,8BAA8B;IAC9B,4BAAW,CAAA;AACb,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB"}
|