@mapples/dnd 1.0.1
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/README.md +390 -0
- package/dist/components/DnDRootView.d.ts +13 -0
- package/dist/components/DnDRootView.d.ts.map +1 -0
- package/dist/components/DnDRootView.js +98 -0
- package/dist/components/DnDRootView.js.map +1 -0
- package/dist/components/DropArea.d.ts +13 -0
- package/dist/components/DropArea.d.ts.map +1 -0
- package/dist/components/DropArea.js +16 -0
- package/dist/components/DropArea.js.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -0
- package/dist/constants/index.d.ts +15 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +16 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/context/DnDContext.d.ts +14 -0
- package/dist/context/DnDContext.d.ts.map +1 -0
- package/dist/context/DnDContext.js +22 -0
- package/dist/context/DnDContext.js.map +1 -0
- package/dist/context/DropContext.d.ts +17 -0
- package/dist/context/DropContext.d.ts.map +1 -0
- package/dist/context/DropContext.js +16 -0
- package/dist/context/DropContext.js.map +1 -0
- package/dist/context/index.d.ts +5 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +5 -0
- package/dist/context/index.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useDnD.d.ts +13 -0
- package/dist/hooks/useDnD.d.ts.map +1 -0
- package/dist/hooks/useDnD.js +16 -0
- package/dist/hooks/useDnD.js.map +1 -0
- package/dist/hooks/useDrag.d.ts +24 -0
- package/dist/hooks/useDrag.d.ts.map +1 -0
- package/dist/hooks/useDrag.js +74 -0
- package/dist/hooks/useDrag.js.map +1 -0
- package/dist/hooks/useDrop.d.ts +31 -0
- package/dist/hooks/useDrop.d.ts.map +1 -0
- package/dist/hooks/useDrop.js +108 -0
- package/dist/hooks/useDrop.js.map +1 -0
- package/dist/hooks/useDropContext.d.ts +12 -0
- package/dist/hooks/useDropContext.d.ts.map +1 -0
- package/dist/hooks/useDropContext.js +14 -0
- package/dist/hooks/useDropContext.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/monitor/Monitor.d.ts +223 -0
- package/dist/monitor/Monitor.d.ts.map +1 -0
- package/dist/monitor/Monitor.js +573 -0
- package/dist/monitor/Monitor.js.map +1 -0
- package/dist/monitor/index.d.ts +3 -0
- package/dist/monitor/index.d.ts.map +1 -0
- package/dist/monitor/index.js +3 -0
- package/dist/monitor/index.js.map +1 -0
- package/dist/types/index.d.ts +208 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +33 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +13 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +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,cAAM,OAAO,CAAC,QAAQ,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,GAAG,QAAQ;IACvE,gDAAgD;IAChD,MAAM,wCAA+C;IAErD,oDAAoD;IACpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IAEr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ACH,QAAQ,CAAC,UAAU,EAAE,UAAU;IAa/B;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAchC;;;OAGG;IACH,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC;IAY7C;;OAEG;IACH,SAAS;IAiBT;;;;;;;OAOG;IACH,mBAAmB,CACjB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,MAAM,CAAC,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE,QAAQ,GACd,MAAM;IAsCT;;;OAGG;IACH,qBAAqB,CAAC,EAAE,EAAE,MAAM;IAShC;;;;;;OAMG;IACH,iBAAiB,CACf,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,eAAe,EACvB,MAAM,CAAC,EAAE,gBAAgB,EACzB,IAAI,CAAC,EAAE,QAAQ;IAuCjB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAwBtB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAqC5B;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAkCpB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAsB5B;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAoCtB;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IA6BxB;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAmD9B;;;;;OAKG;IACH,OAAO,CAAC,aAAa;CActB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import { last, sortBy } from 'lodash';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
import { DnDEventType, FlexDirection, } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Core monitor class that manages drag and drop operations.
|
|
6
|
+
* This class tracks drag elements, drop targets, handles hit detection, and emits events.
|
|
7
|
+
*
|
|
8
|
+
* @template DragData - The type of data being dragged
|
|
9
|
+
* @template DropData - The type of data for drop targets (defaults to DragData)
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
class Monitor {
|
|
13
|
+
/** Observable stream of drag and drop events */
|
|
14
|
+
events = new Subject();
|
|
15
|
+
/** Padding around drop targets for hit detection */
|
|
16
|
+
padding = 0;
|
|
17
|
+
/** Counter for generating unique drag element IDs */
|
|
18
|
+
dragElementIds = 0;
|
|
19
|
+
/** Counter for generating unique drop element IDs */
|
|
20
|
+
dropElementIds = 0;
|
|
21
|
+
/** Map of registered drag elements by ID */
|
|
22
|
+
dragElements = new Map();
|
|
23
|
+
/** Tree structure of registered drop elements */
|
|
24
|
+
dropElementsTree = new Map();
|
|
25
|
+
/** ID of the currently active drag target */
|
|
26
|
+
dragTargetId = null;
|
|
27
|
+
/** Currently active drop target */
|
|
28
|
+
dropTarget = null;
|
|
29
|
+
/** Index position within the current drop target */
|
|
30
|
+
dropTargetIndex = null;
|
|
31
|
+
/** Whether to track drag operations outside the root element */
|
|
32
|
+
trackOutside = false;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new Monitor instance.
|
|
35
|
+
* @param config - Configuration options for the monitor
|
|
36
|
+
*/
|
|
37
|
+
constructor(config) {
|
|
38
|
+
this.padding = config?.padding;
|
|
39
|
+
if (config.trackOutside) {
|
|
40
|
+
this.trackOutside = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets the ID of the currently active drag target.
|
|
45
|
+
* @returns The drag target ID or null if no drag is active
|
|
46
|
+
*/
|
|
47
|
+
getDragTargetId() {
|
|
48
|
+
return this.dragTargetId;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sets the ID of the currently active drag target.
|
|
52
|
+
* @param id - The drag target ID or null
|
|
53
|
+
*/
|
|
54
|
+
setDragTargetId(id) {
|
|
55
|
+
this.dragTargetId = id;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Triggers a force layout update event.
|
|
59
|
+
* This causes all registered elements to recalculate their layout information.
|
|
60
|
+
*/
|
|
61
|
+
triggerForceLayoutUpdate() {
|
|
62
|
+
this.events.next({
|
|
63
|
+
type: DnDEventType.LayoutForceUpdate,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Gets the currently active drop target.
|
|
68
|
+
* @returns The drop target or null if no drop target is active
|
|
69
|
+
*/
|
|
70
|
+
getDropTarget() {
|
|
71
|
+
return this.dropTarget;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Sets the currently active drop target.
|
|
75
|
+
* @param target - The drop target or null
|
|
76
|
+
*/
|
|
77
|
+
setDropTarget(target) {
|
|
78
|
+
this.dropTarget = target;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gets the drag target data for a specific ID.
|
|
82
|
+
* @param id - The drag target ID
|
|
83
|
+
* @returns The drag element target data or undefined if not found
|
|
84
|
+
*/
|
|
85
|
+
getDragTargetData(id) {
|
|
86
|
+
return this.dragElements.get(id);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Sets the index position within the current drop target.
|
|
90
|
+
* @param index - The index position or null
|
|
91
|
+
*/
|
|
92
|
+
setDropTargetIndex(index) {
|
|
93
|
+
this.dropTargetIndex = index;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Gets the index position within the current drop target.
|
|
97
|
+
* @returns The index position or null if no drop target is active
|
|
98
|
+
*/
|
|
99
|
+
getDropTargetIndex() {
|
|
100
|
+
return this.dropTargetIndex;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Registers a new drag element with the monitor.
|
|
104
|
+
* @param layout - The layout rectangle of the drag element
|
|
105
|
+
* @param item - The drag item configuration
|
|
106
|
+
* @returns The unique ID assigned to the drag element
|
|
107
|
+
*/
|
|
108
|
+
registerDragElement(layout, item) {
|
|
109
|
+
this.dragElementIds++;
|
|
110
|
+
this.dragElements.set(this.dragElementIds, { ...layout, item });
|
|
111
|
+
return this.dragElementIds;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Unregisters a drag element from the monitor.
|
|
115
|
+
* @param id - The ID of the drag element to unregister
|
|
116
|
+
*/
|
|
117
|
+
unregisterDragElement(id) {
|
|
118
|
+
this.dragElements.delete(id);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Updates the layout and item data for a registered drag element.
|
|
122
|
+
* @param id - The ID of the drag element
|
|
123
|
+
* @param layout - The new layout rectangle
|
|
124
|
+
* @param item - The new drag item configuration
|
|
125
|
+
*/
|
|
126
|
+
updateDragElement(id, layout, item) {
|
|
127
|
+
const element = this.dragElements.get(id);
|
|
128
|
+
if (!element) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.dragElements.set(id, { ...layout, item });
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Updates only the layout information for a registered drag element.
|
|
135
|
+
* @param id - The ID of the drag element
|
|
136
|
+
* @param layout - The new layout rectangle
|
|
137
|
+
*/
|
|
138
|
+
updateDragElementLayout(id, layout) {
|
|
139
|
+
const element = this.dragElements.get(id);
|
|
140
|
+
if (!element) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.dragElements.set(id, { ...layout, item: element.item });
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Handles the start of a drag operation.
|
|
147
|
+
* @param dragCoords - The coordinates where the drag started
|
|
148
|
+
*/
|
|
149
|
+
onDragStart(dragCoords) {
|
|
150
|
+
const dragTargetId = this.getDragTarget(dragCoords);
|
|
151
|
+
if (!dragTargetId)
|
|
152
|
+
return;
|
|
153
|
+
const dragTarget = this.dragElements.get(dragTargetId);
|
|
154
|
+
this.setDragTargetId(dragTargetId);
|
|
155
|
+
this.events.next({
|
|
156
|
+
type: DnDEventType.DragStart,
|
|
157
|
+
target: this.getDragTargetId(),
|
|
158
|
+
data: dragTarget?.item.data,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Handles drag movement during a drag operation.
|
|
163
|
+
* @param dragCoords - The current coordinates of the drag
|
|
164
|
+
*/
|
|
165
|
+
onDrag(dragCoords) {
|
|
166
|
+
const dragTargetId = this.getDragTargetId();
|
|
167
|
+
if (!dragTargetId)
|
|
168
|
+
return;
|
|
169
|
+
const dropTargets = this.getDropTargets(dragCoords, this.dropElementsTree);
|
|
170
|
+
const shallowTarget = this.getShallowTarget(dropTargets, dragCoords);
|
|
171
|
+
if (!shallowTarget?.canDrop)
|
|
172
|
+
return;
|
|
173
|
+
this.setDropTarget(shallowTarget);
|
|
174
|
+
const dropTargetIndex = this.getDropTargetIndexData(dragCoords, shallowTarget);
|
|
175
|
+
this.setDropTargetIndex(dropTargetIndex);
|
|
176
|
+
this.events.next({
|
|
177
|
+
type: DnDEventType.Drag,
|
|
178
|
+
target: dragTargetId,
|
|
179
|
+
dropTarget: this.getDropTarget(),
|
|
180
|
+
dropTargetIndex: this.getDropTargetIndex(),
|
|
181
|
+
dragCoords: dragCoords,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Handles selection/tap events.
|
|
186
|
+
* @param dragCoords - The coordinates where the selection occurred
|
|
187
|
+
*/
|
|
188
|
+
onSelect(dragCoords) {
|
|
189
|
+
if (!this.isInsideFirstRootElement(dragCoords) && !this.trackOutside)
|
|
190
|
+
return;
|
|
191
|
+
const dropTargets = this.getDropTargets(dragCoords, this.dropElementsTree);
|
|
192
|
+
const shallowTarget = this.getShallowTarget(dropTargets, dragCoords);
|
|
193
|
+
this.events.next({
|
|
194
|
+
type: DnDEventType.Select,
|
|
195
|
+
dropTarget: shallowTarget,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Checks if the given coordinates are inside the first root element.
|
|
200
|
+
* @param dragCoords - The coordinates to check
|
|
201
|
+
* @returns True if inside the first root element
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
isInsideFirstRootElement(dragCoords) {
|
|
205
|
+
const firstRootElement = this.dropElementsTree.entries().next().value;
|
|
206
|
+
if (!firstRootElement)
|
|
207
|
+
return false;
|
|
208
|
+
const [, firstRootTarget] = firstRootElement;
|
|
209
|
+
return (firstRootTarget.layout.x <= dragCoords.x &&
|
|
210
|
+
firstRootTarget.layout.y <= dragCoords.y &&
|
|
211
|
+
firstRootTarget.layout.x + firstRootTarget.layout.width >= dragCoords.x &&
|
|
212
|
+
firstRootTarget.layout.y + firstRootTarget.layout.height >= dragCoords.y);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Handles external selection by data query.
|
|
216
|
+
* @param dataQuery - Partial data to match against drop targets
|
|
217
|
+
*/
|
|
218
|
+
onExternalSelect(dataQuery) {
|
|
219
|
+
const dropTarget = this.findDropTargetByData(dataQuery, this.dropElementsTree);
|
|
220
|
+
this.events.next({
|
|
221
|
+
type: DnDEventType.Select,
|
|
222
|
+
dropTarget: dropTarget,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Handles the end of a drag operation.
|
|
227
|
+
*/
|
|
228
|
+
onDragEnd() {
|
|
229
|
+
const dropTarget = this.getDropTarget();
|
|
230
|
+
if (!dropTarget)
|
|
231
|
+
return;
|
|
232
|
+
this.events.next({
|
|
233
|
+
type: DnDEventType.DragEnd,
|
|
234
|
+
target: this.getDragTargetId(),
|
|
235
|
+
dropTarget: dropTarget,
|
|
236
|
+
dropTargetIndex: this.getDropTargetIndex(),
|
|
237
|
+
});
|
|
238
|
+
this.setDragTargetId(null);
|
|
239
|
+
this.setDropTarget(null);
|
|
240
|
+
this.setDropTargetIndex(null);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Registers a new drop element with the monitor.
|
|
244
|
+
* @param layout - The layout rectangle of the drop element
|
|
245
|
+
* @param parent - The ID of the parent drop element, or null for root level
|
|
246
|
+
* @param config - Optional configuration for the drop target
|
|
247
|
+
* @param data - Optional data associated with the drop target
|
|
248
|
+
* @returns The unique ID assigned to the drop element
|
|
249
|
+
*/
|
|
250
|
+
registerDropElement(layout, parent, config, data) {
|
|
251
|
+
this.dropElementIds++;
|
|
252
|
+
if (!parent) {
|
|
253
|
+
this.dropElementsTree.set(this.dropElementIds, {
|
|
254
|
+
layout: {
|
|
255
|
+
...layout,
|
|
256
|
+
index: config?.index || 0,
|
|
257
|
+
zIndex: config?.zIndex || 0,
|
|
258
|
+
flexDirection: config?.flexDirection || FlexDirection.Column,
|
|
259
|
+
},
|
|
260
|
+
canDrop: config?.canDrop,
|
|
261
|
+
data,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
const parentLayout = this.findDropTarget(parent, this.dropElementsTree);
|
|
266
|
+
if (!parentLayout) {
|
|
267
|
+
throw new Error('Parent element not found');
|
|
268
|
+
}
|
|
269
|
+
if (!parentLayout.children) {
|
|
270
|
+
parentLayout.children = new Map();
|
|
271
|
+
}
|
|
272
|
+
parentLayout.children.set(this.dropElementIds, {
|
|
273
|
+
layout: {
|
|
274
|
+
...layout,
|
|
275
|
+
index: config?.index || 0,
|
|
276
|
+
zIndex: config?.zIndex || parentLayout.layout.zIndex + this.dropElementIds,
|
|
277
|
+
flexDirection: config?.flexDirection || FlexDirection.Column,
|
|
278
|
+
},
|
|
279
|
+
data,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return this.dropElementIds;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Unregisters a drop element from the monitor.
|
|
286
|
+
* @param id - The ID of the drop element to unregister
|
|
287
|
+
*/
|
|
288
|
+
unregisterDropElement(id) {
|
|
289
|
+
if (this.dropElementsTree.has(id)) {
|
|
290
|
+
this.dropElementsTree.delete(id);
|
|
291
|
+
}
|
|
292
|
+
const parent = this.findDropTargetParent(id, this.dropElementsTree);
|
|
293
|
+
parent?.children?.delete(id);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Updates the layout and configuration for a registered drop element.
|
|
297
|
+
* @param id - The ID of the drop element
|
|
298
|
+
* @param layout - The new layout rectangle
|
|
299
|
+
* @param config - Optional new configuration
|
|
300
|
+
* @param data - Optional new data
|
|
301
|
+
*/
|
|
302
|
+
updateDropElement(id, layout, config, data) {
|
|
303
|
+
const target = this.findDropTarget(id, this.dropElementsTree);
|
|
304
|
+
if (target) {
|
|
305
|
+
target.layout.x = layout.x;
|
|
306
|
+
target.layout.y = layout.y;
|
|
307
|
+
target.layout.width = layout.width;
|
|
308
|
+
target.layout.height = layout.height;
|
|
309
|
+
target.layout.index = config?.index || target.layout.index;
|
|
310
|
+
target.layout.zIndex = config?.zIndex || target.layout.zIndex;
|
|
311
|
+
target.layout.flexDirection =
|
|
312
|
+
config?.flexDirection || target.layout.flexDirection;
|
|
313
|
+
target.data = data || target.data;
|
|
314
|
+
target.canDrop = config?.canDrop || target.canDrop;
|
|
315
|
+
if (this.dropElementsTree.has(id)) {
|
|
316
|
+
this.dropElementsTree.set(id, target);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
const parent = this.findDropTargetParent(id, this.dropElementsTree);
|
|
320
|
+
if (parent) {
|
|
321
|
+
parent.children?.set(id, target);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
this.events.next({
|
|
325
|
+
type: DnDEventType.Layout,
|
|
326
|
+
target: id,
|
|
327
|
+
dropTarget: {
|
|
328
|
+
id,
|
|
329
|
+
index: target.layout.index,
|
|
330
|
+
layout: target.layout,
|
|
331
|
+
canDrop: target.canDrop,
|
|
332
|
+
data: target.data,
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Finds a drop target by ID in the tree structure.
|
|
339
|
+
* @param id - The ID to search for
|
|
340
|
+
* @param tree - The tree to search in
|
|
341
|
+
* @returns The drop item or null if not found
|
|
342
|
+
* @private
|
|
343
|
+
*/
|
|
344
|
+
findDropTarget(id, tree) {
|
|
345
|
+
if (!tree) {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
if (tree.has(id)) {
|
|
349
|
+
return tree.get(id) || null;
|
|
350
|
+
}
|
|
351
|
+
for (const [, value] of tree) {
|
|
352
|
+
if (value.children) {
|
|
353
|
+
const target = this.findDropTarget(id, value.children);
|
|
354
|
+
if (target) {
|
|
355
|
+
return target;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Finds a drop target by matching data properties.
|
|
363
|
+
* @param dataQuery - Partial data to match against
|
|
364
|
+
* @param tree - The tree to search in
|
|
365
|
+
* @returns The drop target or null if not found
|
|
366
|
+
* @private
|
|
367
|
+
*/
|
|
368
|
+
findDropTargetByData(dataQuery, tree) {
|
|
369
|
+
if (!tree) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
let index = 0;
|
|
373
|
+
for (const [id, target] of tree) {
|
|
374
|
+
index++;
|
|
375
|
+
if (target.data && this.partialMatch(target.data, dataQuery)) {
|
|
376
|
+
return {
|
|
377
|
+
id,
|
|
378
|
+
layout: target.layout,
|
|
379
|
+
index,
|
|
380
|
+
canDrop: target.canDrop,
|
|
381
|
+
children: target.children,
|
|
382
|
+
data: target.data,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (target.children) {
|
|
386
|
+
const childResult = this.findDropTargetByData(dataQuery, target.children);
|
|
387
|
+
if (childResult) {
|
|
388
|
+
return childResult;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Performs a partial match between target data and query data.
|
|
396
|
+
* @param targetData - The target data to match against
|
|
397
|
+
* @param query - The query data to match
|
|
398
|
+
* @returns True if the query matches the target data
|
|
399
|
+
* @private
|
|
400
|
+
*/
|
|
401
|
+
partialMatch(targetData, query) {
|
|
402
|
+
if (query === targetData) {
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
if (query == null || targetData == null) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
if (typeof query !== 'object' || typeof targetData !== 'object') {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
// Check if all properties in query exist and match in targetData
|
|
412
|
+
const queryKeys = Object.keys(query);
|
|
413
|
+
for (const key of queryKeys) {
|
|
414
|
+
if (!(key in targetData)) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
// Recursively check nested objects
|
|
418
|
+
if (typeof query[key] === 'object' && query[key] != null) {
|
|
419
|
+
if (!this.partialMatch(targetData[key], query[key])) {
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
else if (targetData[key] !== query[key]) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Finds the parent of a drop target by ID.
|
|
431
|
+
* @param id - The ID of the child drop target
|
|
432
|
+
* @param tree - The tree to search in
|
|
433
|
+
* @returns The parent drop item or null if not found
|
|
434
|
+
* @private
|
|
435
|
+
*/
|
|
436
|
+
findDropTargetParent(id, tree) {
|
|
437
|
+
if (!tree) {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
for (const [, value] of tree) {
|
|
441
|
+
if (value.children && value.children.has(id)) {
|
|
442
|
+
return value;
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
const parent = this.findDropTargetParent(id, value.children);
|
|
446
|
+
if (parent) {
|
|
447
|
+
return parent;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Gets all drop targets that contain the given coordinates.
|
|
455
|
+
* @param dropCoords - The coordinates to check
|
|
456
|
+
* @param tree - The tree to search in
|
|
457
|
+
* @returns Array of drop targets or null if none found
|
|
458
|
+
* @private
|
|
459
|
+
*/
|
|
460
|
+
getDropTargets(dropCoords, tree) {
|
|
461
|
+
const targets = [];
|
|
462
|
+
if (!tree) {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
let index = 0;
|
|
466
|
+
for (const [id, target] of tree) {
|
|
467
|
+
index++;
|
|
468
|
+
if (target.layout.x <= dropCoords.x &&
|
|
469
|
+
target.layout.y <= dropCoords.y &&
|
|
470
|
+
target.layout.x + target.layout.width >= dropCoords.x &&
|
|
471
|
+
target.layout.y + target.layout.height >= dropCoords.y) {
|
|
472
|
+
targets.push({
|
|
473
|
+
id,
|
|
474
|
+
layout: target.layout,
|
|
475
|
+
index,
|
|
476
|
+
canDrop: target.canDrop,
|
|
477
|
+
children: target.children,
|
|
478
|
+
data: target.data,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
const childTargets = this.getDropTargets(dropCoords, target.children);
|
|
482
|
+
if (childTargets) {
|
|
483
|
+
targets.push(...childTargets);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return targets;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Gets the shallowest (topmost) drop target from a list of targets.
|
|
490
|
+
* @param targets - Array of drop targets
|
|
491
|
+
* @param dragCoords - The current drag coordinates
|
|
492
|
+
* @returns The shallowest drop target or null
|
|
493
|
+
* @private
|
|
494
|
+
*/
|
|
495
|
+
getShallowTarget(targets, dragCoords) {
|
|
496
|
+
if (!targets) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
const sortedTargets = sortBy(targets, 'layout.zIndex');
|
|
500
|
+
const lastTarget = last(sortedTargets);
|
|
501
|
+
if (!lastTarget) {
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
if (lastTarget.layout.y + this.padding > dragCoords.y ||
|
|
505
|
+
lastTarget.layout.y + lastTarget.layout.height - this.padding <
|
|
506
|
+
dragCoords.y ||
|
|
507
|
+
lastTarget.layout.x + this.padding > dragCoords.x ||
|
|
508
|
+
lastTarget.layout.x + lastTarget.layout.width - this.padding <
|
|
509
|
+
dragCoords.x) {
|
|
510
|
+
return sortedTargets[sortedTargets.length - 2] || lastTarget;
|
|
511
|
+
}
|
|
512
|
+
return lastTarget;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Calculates the drop target index based on drag coordinates and target layout.
|
|
516
|
+
* @param dragCoords - The current drag coordinates
|
|
517
|
+
* @param target - The drop target to calculate index for
|
|
518
|
+
* @returns The calculated index or null
|
|
519
|
+
* @private
|
|
520
|
+
*/
|
|
521
|
+
getDropTargetIndexData(dragCoords, target) {
|
|
522
|
+
if (!target || !target.children)
|
|
523
|
+
return null;
|
|
524
|
+
let nearestId = null;
|
|
525
|
+
let nearestDistance = Infinity;
|
|
526
|
+
for (const [id, child] of target.children) {
|
|
527
|
+
const centerX = child.layout.x + child.layout.width / 2;
|
|
528
|
+
const centerY = child.layout.y + child.layout.height / 2;
|
|
529
|
+
const distance = Math.sqrt(Math.pow(centerX - dragCoords.x, 2) +
|
|
530
|
+
Math.pow(centerY - dragCoords.y, 2));
|
|
531
|
+
if (distance < nearestDistance) {
|
|
532
|
+
nearestDistance = distance;
|
|
533
|
+
nearestId = id;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (!nearestId)
|
|
537
|
+
return null;
|
|
538
|
+
const nearestLayout = target.children.get(nearestId);
|
|
539
|
+
if (!nearestLayout)
|
|
540
|
+
return null;
|
|
541
|
+
const nearestLayoutCenterX = nearestLayout.layout.x + nearestLayout.layout.width / 2;
|
|
542
|
+
const nearestLayoutCenterY = nearestLayout.layout.y + nearestLayout.layout.height / 2;
|
|
543
|
+
const [x, y] = [
|
|
544
|
+
dragCoords.x - nearestLayoutCenterX,
|
|
545
|
+
dragCoords.y - nearestLayoutCenterY,
|
|
546
|
+
];
|
|
547
|
+
if ((target.layout.flexDirection === FlexDirection.Row && x > 0) ||
|
|
548
|
+
(target.layout.flexDirection === FlexDirection.Column && y > 0)) {
|
|
549
|
+
return nearestLayout.layout.index + 1;
|
|
550
|
+
}
|
|
551
|
+
return nearestLayout.layout.index;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Gets the drag target ID for the given coordinates.
|
|
555
|
+
* @param dragCoords - The coordinates to check
|
|
556
|
+
* @returns The drag target ID or null if none found
|
|
557
|
+
* @private
|
|
558
|
+
*/
|
|
559
|
+
getDragTarget(dragCoords) {
|
|
560
|
+
for (const [id, layout] of this.dragElements) {
|
|
561
|
+
if (layout.x <= dragCoords.x &&
|
|
562
|
+
layout.y <= dragCoords.y &&
|
|
563
|
+
layout.x + layout.width >= dragCoords.x &&
|
|
564
|
+
layout.y + layout.height >= dragCoords.y) {
|
|
565
|
+
return id;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
export { Monitor };
|
|
572
|
+
export default Monitor;
|
|
573
|
+
//# sourceMappingURL=Monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Monitor.js","sourceRoot":"","sources":["../../src/monitor/Monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAEL,YAAY,EAQZ,aAAa,GAEd,MAAM,UAAU,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,OAAO;IACX,gDAAgD;IAChD,MAAM,GAAG,IAAI,OAAO,EAAgC,CAAC;IAErD,oDAAoD;IACnC,OAAO,GAAW,CAAC,CAAC;IAErC,qDAAqD;IAC7C,cAAc,GAAG,CAAC,CAAC;IAC3B,qDAAqD;IAC7C,cAAc,GAAG,CAAC,CAAC;IAE3B,4CAA4C;IACpC,YAAY,GAAG,IAAI,GAAG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,"file":"index.js","sourceRoot":"","sources":["../../src/monitor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|