@lucasols/dnd-kit-core 0.1.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.
Files changed (141) hide show
  1. package/CHANGELOG.md +1101 -0
  2. package/LICENSE +21 -0
  3. package/README.md +17 -0
  4. package/dist/components/Accessibility/Accessibility.d.ts +10 -0
  5. package/dist/components/Accessibility/components/RestoreFocus.d.ts +5 -0
  6. package/dist/components/Accessibility/components/index.d.ts +1 -0
  7. package/dist/components/Accessibility/defaults.d.ts +3 -0
  8. package/dist/components/Accessibility/index.d.ts +4 -0
  9. package/dist/components/Accessibility/types.d.ts +15 -0
  10. package/dist/components/DndContext/DndContext.d.ts +35 -0
  11. package/dist/components/DndContext/defaults.d.ts +13 -0
  12. package/dist/components/DndContext/hooks/index.d.ts +2 -0
  13. package/dist/components/DndContext/hooks/useLayoutShiftScrollCompensation.d.ts +14 -0
  14. package/dist/components/DndContext/hooks/useMeasuringConfiguration.d.ts +3 -0
  15. package/dist/components/DndContext/index.d.ts +3 -0
  16. package/dist/components/DndContext/types.d.ts +16 -0
  17. package/dist/components/DndMonitor/context.d.ts +3 -0
  18. package/dist/components/DndMonitor/index.d.ts +4 -0
  19. package/dist/components/DndMonitor/types.d.ts +14 -0
  20. package/dist/components/DndMonitor/useDndMonitor.d.ts +2 -0
  21. package/dist/components/DndMonitor/useDndMonitorProvider.d.ts +2 -0
  22. package/dist/components/DragOverlay/DragOverlay.d.ts +11 -0
  23. package/dist/components/DragOverlay/components/AnimationManager/AnimationManager.d.ts +8 -0
  24. package/dist/components/DragOverlay/components/AnimationManager/index.d.ts +2 -0
  25. package/dist/components/DragOverlay/components/NullifiedContextProvider/NullifiedContextProvider.d.ts +6 -0
  26. package/dist/components/DragOverlay/components/NullifiedContextProvider/index.d.ts +1 -0
  27. package/dist/components/DragOverlay/components/PositionedOverlay/PositionedOverlay.d.ts +18 -0
  28. package/dist/components/DragOverlay/components/PositionedOverlay/index.d.ts +2 -0
  29. package/dist/components/DragOverlay/components/index.d.ts +5 -0
  30. package/dist/components/DragOverlay/hooks/index.d.ts +3 -0
  31. package/dist/components/DragOverlay/hooks/useDropAnimation.d.ts +65 -0
  32. package/dist/components/DragOverlay/hooks/useKey.d.ts +2 -0
  33. package/dist/components/DragOverlay/index.d.ts +4 -0
  34. package/dist/components/index.d.ts +8 -0
  35. package/dist/dnd-kit-core.cjs.development.js +3924 -0
  36. package/dist/dnd-kit-core.cjs.development.js.map +1 -0
  37. package/dist/dnd-kit-core.cjs.production.min.js +2 -0
  38. package/dist/dnd-kit-core.cjs.production.min.js.map +1 -0
  39. package/dist/dnd-kit-core.esm.js +3903 -0
  40. package/dist/dnd-kit-core.esm.js.map +1 -0
  41. package/dist/hooks/index.d.ts +8 -0
  42. package/dist/hooks/useDndContext.d.ts +4 -0
  43. package/dist/hooks/useDraggable.d.ts +37 -0
  44. package/dist/hooks/useDroppable.d.ts +29 -0
  45. package/dist/hooks/utilities/index.d.ts +21 -0
  46. package/dist/hooks/utilities/useAutoScroller.d.ts +40 -0
  47. package/dist/hooks/utilities/useCachedNode.d.ts +3 -0
  48. package/dist/hooks/utilities/useCombineActivators.d.ts +3 -0
  49. package/dist/hooks/utilities/useDragOverlayMeasuring.d.ts +7 -0
  50. package/dist/hooks/utilities/useDroppableMeasuring.d.ts +27 -0
  51. package/dist/hooks/utilities/useInitialRect.d.ts +2 -0
  52. package/dist/hooks/utilities/useInitialValue.d.ts +3 -0
  53. package/dist/hooks/utilities/useMutationObserver.d.ts +10 -0
  54. package/dist/hooks/utilities/useRect.d.ts +2 -0
  55. package/dist/hooks/utilities/useRectDelta.d.ts +2 -0
  56. package/dist/hooks/utilities/useRects.d.ts +5 -0
  57. package/dist/hooks/utilities/useResizeObserver.d.ts +10 -0
  58. package/dist/hooks/utilities/useScrollIntoViewIfNeeded.d.ts +1 -0
  59. package/dist/hooks/utilities/useScrollOffsets.d.ts +2 -0
  60. package/dist/hooks/utilities/useScrollOffsetsDelta.d.ts +2 -0
  61. package/dist/hooks/utilities/useScrollableAncestors.d.ts +1 -0
  62. package/dist/hooks/utilities/useSensorSetup.d.ts +2 -0
  63. package/dist/hooks/utilities/useSyntheticListeners.d.ts +9 -0
  64. package/dist/hooks/utilities/useWindowRect.d.ts +1 -0
  65. package/dist/index.d.ts +12 -0
  66. package/dist/index.js +8 -0
  67. package/dist/modifiers/applyModifiers.d.ts +3 -0
  68. package/dist/modifiers/index.d.ts +2 -0
  69. package/dist/modifiers/types.d.ts +17 -0
  70. package/dist/sensors/events.d.ts +11 -0
  71. package/dist/sensors/index.d.ts +11 -0
  72. package/dist/sensors/keyboard/KeyboardSensor.d.ts +27 -0
  73. package/dist/sensors/keyboard/defaults.d.ts +3 -0
  74. package/dist/sensors/keyboard/index.d.ts +4 -0
  75. package/dist/sensors/keyboard/types.d.ts +21 -0
  76. package/dist/sensors/mouse/MouseSensor.d.ts +13 -0
  77. package/dist/sensors/mouse/index.d.ts +2 -0
  78. package/dist/sensors/pointer/AbstractPointerSensor.d.ts +48 -0
  79. package/dist/sensors/pointer/PointerSensor.d.ts +13 -0
  80. package/dist/sensors/pointer/index.d.ts +4 -0
  81. package/dist/sensors/touch/TouchSensor.d.ts +14 -0
  82. package/dist/sensors/touch/index.d.ts +2 -0
  83. package/dist/sensors/types.d.ts +60 -0
  84. package/dist/sensors/useSensor.d.ts +2 -0
  85. package/dist/sensors/useSensors.d.ts +2 -0
  86. package/dist/sensors/utilities/Listeners.d.ts +7 -0
  87. package/dist/sensors/utilities/getEventListenerTarget.d.ts +1 -0
  88. package/dist/sensors/utilities/hasExceededDistance.d.ts +2 -0
  89. package/dist/sensors/utilities/index.d.ts +3 -0
  90. package/dist/store/actions.d.ts +36 -0
  91. package/dist/store/constructors.d.ts +10 -0
  92. package/dist/store/context.d.ts +6 -0
  93. package/dist/store/index.d.ts +4 -0
  94. package/dist/store/reducer.d.ts +4 -0
  95. package/dist/store/types.d.ts +98 -0
  96. package/dist/types/coordinates.d.ts +9 -0
  97. package/dist/types/direction.d.ts +4 -0
  98. package/dist/types/events.d.ts +21 -0
  99. package/dist/types/index.d.ts +6 -0
  100. package/dist/types/other.d.ts +1 -0
  101. package/dist/types/react.d.ts +3 -0
  102. package/dist/types/rect.d.ts +8 -0
  103. package/dist/utilities/algorithms/closestCenter.d.ts +6 -0
  104. package/dist/utilities/algorithms/closestCorners.d.ts +6 -0
  105. package/dist/utilities/algorithms/helpers.d.ts +24 -0
  106. package/dist/utilities/algorithms/index.d.ts +6 -0
  107. package/dist/utilities/algorithms/pointerWithin.d.ts +5 -0
  108. package/dist/utilities/algorithms/rectIntersection.d.ts +11 -0
  109. package/dist/utilities/algorithms/types.d.ts +20 -0
  110. package/dist/utilities/coordinates/constants.d.ts +2 -0
  111. package/dist/utilities/coordinates/distanceBetweenPoints.d.ts +5 -0
  112. package/dist/utilities/coordinates/getRelativeTransformOrigin.d.ts +2 -0
  113. package/dist/utilities/coordinates/index.d.ts +3 -0
  114. package/dist/utilities/index.d.ts +6 -0
  115. package/dist/utilities/nodes/getMeasurableNode.d.ts +1 -0
  116. package/dist/utilities/nodes/index.d.ts +1 -0
  117. package/dist/utilities/other/index.d.ts +1 -0
  118. package/dist/utilities/other/noop.d.ts +1 -0
  119. package/dist/utilities/rect/Rect.d.ts +11 -0
  120. package/dist/utilities/rect/adjustScale.d.ts +3 -0
  121. package/dist/utilities/rect/getRect.d.ts +25 -0
  122. package/dist/utilities/rect/getRectDelta.d.ts +2 -0
  123. package/dist/utilities/rect/getWindowClientRect.d.ts +2 -0
  124. package/dist/utilities/rect/index.d.ts +6 -0
  125. package/dist/utilities/rect/rectAdjustment.d.ts +3 -0
  126. package/dist/utilities/scroll/documentScrollingElement.d.ts +1 -0
  127. package/dist/utilities/scroll/getScrollCoordinates.d.ts +4 -0
  128. package/dist/utilities/scroll/getScrollDirectionAndSpeed.d.ts +17 -0
  129. package/dist/utilities/scroll/getScrollElementRect.d.ts +8 -0
  130. package/dist/utilities/scroll/getScrollOffsets.d.ts +4 -0
  131. package/dist/utilities/scroll/getScrollPosition.d.ts +14 -0
  132. package/dist/utilities/scroll/getScrollableAncestors.d.ts +2 -0
  133. package/dist/utilities/scroll/getScrollableElement.d.ts +1 -0
  134. package/dist/utilities/scroll/index.d.ts +10 -0
  135. package/dist/utilities/scroll/isFixed.d.ts +1 -0
  136. package/dist/utilities/scroll/isScrollable.d.ts +1 -0
  137. package/dist/utilities/scroll/scrollIntoViewIfNeeded.d.ts +2 -0
  138. package/dist/utilities/transform/index.d.ts +2 -0
  139. package/dist/utilities/transform/inverseTransform.d.ts +2 -0
  140. package/dist/utilities/transform/parseTransform.d.ts +2 -0
  141. package/package.json +41 -0
@@ -0,0 +1,3924 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var React = require('react');
8
+ var React__default = _interopDefault(React);
9
+ var reactDom = require('react-dom');
10
+ var dndKitUtilities = require('@lucasols/dnd-kit-utilities');
11
+ var dndKitAccessibility = require('@lucasols/dnd-kit-accessibility');
12
+
13
+ const DndMonitorContext = /*#__PURE__*/React.createContext(null);
14
+
15
+ function useDndMonitor(listener) {
16
+ const registerListener = React.useContext(DndMonitorContext);
17
+ React.useEffect(() => {
18
+ if (!registerListener) {
19
+ throw new Error('useDndMonitor must be used within a children of <DndContext>');
20
+ }
21
+
22
+ const unsubscribe = registerListener(listener);
23
+ return unsubscribe;
24
+ }, [listener, registerListener]);
25
+ }
26
+
27
+ function useDndMonitorProvider() {
28
+ const [listeners] = React.useState(() => new Set());
29
+ const registerListener = React.useCallback(listener => {
30
+ listeners.add(listener);
31
+ return () => listeners.delete(listener);
32
+ }, [listeners]);
33
+ const dispatch = React.useCallback(_ref => {
34
+ let {
35
+ type,
36
+ event
37
+ } = _ref;
38
+ listeners.forEach(listener => {
39
+ var _listener$type;
40
+
41
+ return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
42
+ });
43
+ }, [listeners]);
44
+ return [dispatch, registerListener];
45
+ }
46
+
47
+ const defaultScreenReaderInstructions = {
48
+ draggable: "\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "
49
+ };
50
+ const defaultAnnouncements = {
51
+ onDragStart(_ref) {
52
+ let {
53
+ active
54
+ } = _ref;
55
+ return "Picked up draggable item " + active.id + ".";
56
+ },
57
+
58
+ onDragOver(_ref2) {
59
+ let {
60
+ active,
61
+ over
62
+ } = _ref2;
63
+
64
+ if (over) {
65
+ return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
66
+ }
67
+
68
+ return "Draggable item " + active.id + " is no longer over a droppable area.";
69
+ },
70
+
71
+ onDragEnd(_ref3) {
72
+ let {
73
+ active,
74
+ over
75
+ } = _ref3;
76
+
77
+ if (over) {
78
+ return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
79
+ }
80
+
81
+ return "Draggable item " + active.id + " was dropped.";
82
+ },
83
+
84
+ onDragCancel(_ref4) {
85
+ let {
86
+ active
87
+ } = _ref4;
88
+ return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
89
+ }
90
+
91
+ };
92
+
93
+ function Accessibility(_ref) {
94
+ let {
95
+ announcements = defaultAnnouncements,
96
+ container,
97
+ hiddenTextDescribedById,
98
+ screenReaderInstructions = defaultScreenReaderInstructions
99
+ } = _ref;
100
+ const {
101
+ announce,
102
+ announcement
103
+ } = dndKitAccessibility.useAnnouncement();
104
+ const liveRegionId = dndKitUtilities.useUniqueId("DndLiveRegion");
105
+ const [mounted, setMounted] = React.useState(false);
106
+ React.useEffect(() => {
107
+ setMounted(true);
108
+ }, []);
109
+ useDndMonitor(React.useMemo(() => ({
110
+ onDragStart(_ref2) {
111
+ let {
112
+ active
113
+ } = _ref2;
114
+ announce(announcements.onDragStart({
115
+ active
116
+ }));
117
+ },
118
+
119
+ onDragMove(_ref3) {
120
+ let {
121
+ active,
122
+ over
123
+ } = _ref3;
124
+
125
+ if (announcements.onDragMove) {
126
+ announce(announcements.onDragMove({
127
+ active,
128
+ over
129
+ }));
130
+ }
131
+ },
132
+
133
+ onDragOver(_ref4) {
134
+ let {
135
+ active,
136
+ over
137
+ } = _ref4;
138
+ announce(announcements.onDragOver({
139
+ active,
140
+ over
141
+ }));
142
+ },
143
+
144
+ onDragEnd(_ref5) {
145
+ let {
146
+ active,
147
+ over
148
+ } = _ref5;
149
+ announce(announcements.onDragEnd({
150
+ active,
151
+ over
152
+ }));
153
+ },
154
+
155
+ onDragCancel(_ref6) {
156
+ let {
157
+ active,
158
+ over
159
+ } = _ref6;
160
+ announce(announcements.onDragCancel({
161
+ active,
162
+ over
163
+ }));
164
+ }
165
+
166
+ }), [announce, announcements]));
167
+
168
+ if (!mounted) {
169
+ return null;
170
+ }
171
+
172
+ const markup = React__default.createElement(React__default.Fragment, null, React__default.createElement(dndKitAccessibility.HiddenText, {
173
+ id: hiddenTextDescribedById,
174
+ value: screenReaderInstructions.draggable
175
+ }), React__default.createElement(dndKitAccessibility.LiveRegion, {
176
+ id: liveRegionId,
177
+ announcement: announcement
178
+ }));
179
+ return container ? reactDom.createPortal(markup, container) : markup;
180
+ }
181
+
182
+ var Action;
183
+
184
+ (function (Action) {
185
+ Action["DragStart"] = "dragStart";
186
+ Action["DragMove"] = "dragMove";
187
+ Action["DragEnd"] = "dragEnd";
188
+ Action["DragCancel"] = "dragCancel";
189
+ Action["DragOver"] = "dragOver";
190
+ Action["RegisterDroppable"] = "registerDroppable";
191
+ Action["SetDroppableDisabled"] = "setDroppableDisabled";
192
+ Action["UnregisterDroppable"] = "unregisterDroppable";
193
+ })(Action || (Action = {}));
194
+
195
+ function noop() {}
196
+
197
+ function useSensor(sensor, options) {
198
+ return React.useMemo(() => ({
199
+ sensor,
200
+ options: options != null ? options : {}
201
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
202
+ [sensor, options]);
203
+ }
204
+
205
+ function useSensors() {
206
+ for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
207
+ sensors[_key] = arguments[_key];
208
+ }
209
+
210
+ return React.useMemo(() => [...sensors].filter(sensor => sensor != null), // eslint-disable-next-line react-hooks/exhaustive-deps
211
+ [...sensors]);
212
+ }
213
+
214
+ const defaultCoordinates = /*#__PURE__*/Object.freeze({
215
+ x: 0,
216
+ y: 0
217
+ });
218
+
219
+ /**
220
+ * Returns the distance between two points
221
+ */
222
+ function distanceBetween(p1, p2) {
223
+ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
224
+ }
225
+
226
+ function getRelativeTransformOrigin(event, rect) {
227
+ const eventCoordinates = dndKitUtilities.getEventCoordinates(event);
228
+
229
+ if (!eventCoordinates) {
230
+ return '0 0';
231
+ }
232
+
233
+ const transformOrigin = {
234
+ x: (eventCoordinates.x - rect.left) / rect.width * 100,
235
+ y: (eventCoordinates.y - rect.top) / rect.height * 100
236
+ };
237
+ return transformOrigin.x + "% " + transformOrigin.y + "%";
238
+ }
239
+
240
+ /**
241
+ * Sort collisions from smallest to greatest value
242
+ */
243
+ function sortCollisionsAsc(_ref, _ref2) {
244
+ let {
245
+ data: {
246
+ value: a
247
+ }
248
+ } = _ref;
249
+ let {
250
+ data: {
251
+ value: b
252
+ }
253
+ } = _ref2;
254
+ return a - b;
255
+ }
256
+ /**
257
+ * Sort collisions from greatest to smallest value
258
+ */
259
+
260
+ function sortCollisionsDesc(_ref3, _ref4) {
261
+ let {
262
+ data: {
263
+ value: a
264
+ }
265
+ } = _ref3;
266
+ let {
267
+ data: {
268
+ value: b
269
+ }
270
+ } = _ref4;
271
+ return b - a;
272
+ }
273
+ /**
274
+ * Returns the coordinates of the corners of a given rectangle:
275
+ * [TopLeft {x, y}, TopRight {x, y}, BottomLeft {x, y}, BottomRight {x, y}]
276
+ */
277
+
278
+ function cornersOfRectangle(_ref5) {
279
+ let {
280
+ left,
281
+ top,
282
+ height,
283
+ width
284
+ } = _ref5;
285
+ return [{
286
+ x: left,
287
+ y: top
288
+ }, {
289
+ x: left + width,
290
+ y: top
291
+ }, {
292
+ x: left,
293
+ y: top + height
294
+ }, {
295
+ x: left + width,
296
+ y: top + height
297
+ }];
298
+ }
299
+ function getFirstCollision(collisions, property) {
300
+ if (!collisions || collisions.length === 0) {
301
+ return null;
302
+ }
303
+
304
+ const [firstCollision] = collisions;
305
+ return property ? firstCollision[property] : firstCollision;
306
+ }
307
+
308
+ /**
309
+ * Returns the coordinates of the center of a given ClientRect
310
+ */
311
+
312
+ function centerOfRectangle(rect, left, top) {
313
+ if (left === void 0) {
314
+ left = rect.left;
315
+ }
316
+
317
+ if (top === void 0) {
318
+ top = rect.top;
319
+ }
320
+
321
+ return {
322
+ x: left + rect.width * 0.5,
323
+ y: top + rect.height * 0.5
324
+ };
325
+ }
326
+ /**
327
+ * Returns the closest rectangles from an array of rectangles to the center of a given
328
+ * rectangle.
329
+ */
330
+
331
+
332
+ const closestCenter = _ref => {
333
+ let {
334
+ collisionRect,
335
+ droppableRects,
336
+ droppableContainers
337
+ } = _ref;
338
+ const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
339
+ const collisions = [];
340
+
341
+ for (const droppableContainer of droppableContainers) {
342
+ const {
343
+ id
344
+ } = droppableContainer;
345
+ const rect = droppableRects.get(id);
346
+
347
+ if (rect) {
348
+ const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
349
+ collisions.push({
350
+ id,
351
+ data: {
352
+ droppableContainer,
353
+ value: distBetween
354
+ }
355
+ });
356
+ }
357
+ }
358
+
359
+ return collisions.sort(sortCollisionsAsc);
360
+ };
361
+
362
+ /**
363
+ * Returns the closest rectangles from an array of rectangles to the corners of
364
+ * another rectangle.
365
+ */
366
+
367
+ const closestCorners = _ref => {
368
+ let {
369
+ collisionRect,
370
+ droppableRects,
371
+ droppableContainers
372
+ } = _ref;
373
+ const corners = cornersOfRectangle(collisionRect);
374
+ const collisions = [];
375
+
376
+ for (const droppableContainer of droppableContainers) {
377
+ const {
378
+ id
379
+ } = droppableContainer;
380
+ const rect = droppableRects.get(id);
381
+
382
+ if (rect) {
383
+ const rectCorners = cornersOfRectangle(rect);
384
+ const distances = corners.reduce((accumulator, corner, index) => {
385
+ return accumulator + distanceBetween(rectCorners[index], corner);
386
+ }, 0);
387
+ const effectiveDistance = Number((distances / 4).toFixed(4));
388
+ collisions.push({
389
+ id,
390
+ data: {
391
+ droppableContainer,
392
+ value: effectiveDistance
393
+ }
394
+ });
395
+ }
396
+ }
397
+
398
+ return collisions.sort(sortCollisionsAsc);
399
+ };
400
+
401
+ /**
402
+ * Returns the intersecting rectangle area between two rectangles
403
+ */
404
+
405
+ function getIntersectionRatio(entry, target) {
406
+ const top = Math.max(target.top, entry.top);
407
+ const left = Math.max(target.left, entry.left);
408
+ const right = Math.min(target.left + target.width, entry.left + entry.width);
409
+ const bottom = Math.min(target.top + target.height, entry.top + entry.height);
410
+ const width = right - left;
411
+ const height = bottom - top;
412
+
413
+ if (left < right && top < bottom) {
414
+ const targetArea = target.width * target.height;
415
+ const entryArea = entry.width * entry.height;
416
+ const intersectionArea = width * height;
417
+ const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
418
+ return Number(intersectionRatio.toFixed(4));
419
+ } // Rectangles do not overlap, or overlap has an area of zero (edge/corner overlap)
420
+
421
+
422
+ return 0;
423
+ }
424
+ /**
425
+ * Returns the rectangles that has the greatest intersection area with a given
426
+ * rectangle in an array of rectangles.
427
+ */
428
+
429
+ const rectIntersection = _ref => {
430
+ let {
431
+ collisionRect,
432
+ droppableRects,
433
+ droppableContainers
434
+ } = _ref;
435
+ const collisions = [];
436
+
437
+ for (const droppableContainer of droppableContainers) {
438
+ const {
439
+ id
440
+ } = droppableContainer;
441
+ const rect = droppableRects.get(id);
442
+
443
+ if (rect) {
444
+ const intersectionRatio = getIntersectionRatio(rect, collisionRect);
445
+
446
+ if (intersectionRatio > 0) {
447
+ collisions.push({
448
+ id,
449
+ data: {
450
+ droppableContainer,
451
+ value: intersectionRatio
452
+ }
453
+ });
454
+ }
455
+ }
456
+ }
457
+
458
+ return collisions.sort(sortCollisionsDesc);
459
+ };
460
+
461
+ /**
462
+ * Check if a given point is contained within a bounding rectangle
463
+ */
464
+
465
+ function isPointWithinRect(point, rect) {
466
+ const {
467
+ top,
468
+ left,
469
+ bottom,
470
+ right
471
+ } = rect;
472
+ return top <= point.y && point.y <= bottom && left <= point.x && point.x <= right;
473
+ }
474
+ /**
475
+ * Returns the rectangles that the pointer is hovering over
476
+ */
477
+
478
+
479
+ const pointerWithin = _ref => {
480
+ let {
481
+ droppableContainers,
482
+ droppableRects,
483
+ pointerCoordinates
484
+ } = _ref;
485
+
486
+ if (!pointerCoordinates) {
487
+ return [];
488
+ }
489
+
490
+ const collisions = [];
491
+
492
+ for (const droppableContainer of droppableContainers) {
493
+ const {
494
+ id
495
+ } = droppableContainer;
496
+ const rect = droppableRects.get(id);
497
+
498
+ if (rect && isPointWithinRect(pointerCoordinates, rect)) {
499
+ /* There may be more than a single rectangle intersecting
500
+ * with the pointer coordinates. In order to sort the
501
+ * colliding rectangles, we measure the distance between
502
+ * the pointer and the corners of the intersecting rectangle
503
+ */
504
+ const corners = cornersOfRectangle(rect);
505
+ const distances = corners.reduce((accumulator, corner) => {
506
+ return accumulator + distanceBetween(pointerCoordinates, corner);
507
+ }, 0);
508
+ const effectiveDistance = Number((distances / 4).toFixed(4));
509
+ collisions.push({
510
+ id,
511
+ data: {
512
+ droppableContainer,
513
+ value: effectiveDistance
514
+ }
515
+ });
516
+ }
517
+ }
518
+
519
+ return collisions.sort(sortCollisionsAsc);
520
+ };
521
+
522
+ function adjustScale(transform, rect1, rect2) {
523
+ return { ...transform,
524
+ scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
525
+ scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
526
+ };
527
+ }
528
+
529
+ function getRectDelta(rect1, rect2) {
530
+ return rect1 && rect2 ? {
531
+ x: rect1.left - rect2.left,
532
+ y: rect1.top - rect2.top
533
+ } : defaultCoordinates;
534
+ }
535
+
536
+ function createRectAdjustmentFn(modifier) {
537
+ return function adjustClientRect(rect) {
538
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
539
+ adjustments[_key - 1] = arguments[_key];
540
+ }
541
+
542
+ return adjustments.reduce((acc, adjustment) => ({ ...acc,
543
+ top: acc.top + modifier * adjustment.y,
544
+ bottom: acc.bottom + modifier * adjustment.y,
545
+ left: acc.left + modifier * adjustment.x,
546
+ right: acc.right + modifier * adjustment.x
547
+ }), { ...rect
548
+ });
549
+ };
550
+ }
551
+ const getAdjustedRect = /*#__PURE__*/createRectAdjustmentFn(1);
552
+
553
+ function parseTransform(transform) {
554
+ if (transform.startsWith('matrix3d(')) {
555
+ const transformArray = transform.slice(9, -1).split(/, /);
556
+ return {
557
+ x: +transformArray[12],
558
+ y: +transformArray[13],
559
+ scaleX: +transformArray[0],
560
+ scaleY: +transformArray[5]
561
+ };
562
+ } else if (transform.startsWith('matrix(')) {
563
+ const transformArray = transform.slice(7, -1).split(/, /);
564
+ return {
565
+ x: +transformArray[4],
566
+ y: +transformArray[5],
567
+ scaleX: +transformArray[0],
568
+ scaleY: +transformArray[3]
569
+ };
570
+ }
571
+
572
+ return null;
573
+ }
574
+
575
+ function inverseTransform(rect, transform, transformOrigin) {
576
+ const parsedTransform = parseTransform(transform);
577
+
578
+ if (!parsedTransform) {
579
+ return rect;
580
+ }
581
+
582
+ const {
583
+ scaleX,
584
+ scaleY,
585
+ x: translateX,
586
+ y: translateY
587
+ } = parsedTransform;
588
+ const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
589
+ const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(' ') + 1));
590
+ const w = scaleX ? rect.width / scaleX : rect.width;
591
+ const h = scaleY ? rect.height / scaleY : rect.height;
592
+ return {
593
+ width: w,
594
+ height: h,
595
+ top: y,
596
+ right: x + w,
597
+ bottom: y + h,
598
+ left: x
599
+ };
600
+ }
601
+
602
+ const defaultOptions = {
603
+ ignoreTransform: false
604
+ };
605
+ /**
606
+ * Returns the bounding client rect of an element relative to the viewport.
607
+ */
608
+
609
+ function getClientRect(element, options) {
610
+ if (options === void 0) {
611
+ options = defaultOptions;
612
+ }
613
+
614
+ let rect = element.getBoundingClientRect();
615
+
616
+ if (options.ignoreTransform) {
617
+ const {
618
+ transform,
619
+ transformOrigin
620
+ } = dndKitUtilities.getWindow(element).getComputedStyle(element);
621
+
622
+ if (transform) {
623
+ rect = inverseTransform(rect, transform, transformOrigin);
624
+ }
625
+ }
626
+
627
+ const {
628
+ top,
629
+ left,
630
+ width,
631
+ height,
632
+ bottom,
633
+ right
634
+ } = rect;
635
+ return {
636
+ top,
637
+ left,
638
+ width,
639
+ height,
640
+ bottom,
641
+ right
642
+ };
643
+ }
644
+ /**
645
+ * Returns the bounding client rect of an element relative to the viewport.
646
+ *
647
+ * @remarks
648
+ * The ClientRect returned by this method does not take into account transforms
649
+ * applied to the element it measures.
650
+ *
651
+ */
652
+
653
+ function getTransformAgnosticClientRect(element) {
654
+ return getClientRect(element, {
655
+ ignoreTransform: true
656
+ });
657
+ }
658
+
659
+ function getWindowClientRect(element) {
660
+ const width = element.innerWidth;
661
+ const height = element.innerHeight;
662
+ return {
663
+ top: 0,
664
+ left: 0,
665
+ right: width,
666
+ bottom: height,
667
+ width,
668
+ height
669
+ };
670
+ }
671
+
672
+ function isFixed(node, computedStyle) {
673
+ if (computedStyle === void 0) {
674
+ computedStyle = dndKitUtilities.getWindow(node).getComputedStyle(node);
675
+ }
676
+
677
+ return computedStyle.position === 'fixed';
678
+ }
679
+
680
+ function isScrollable(element, computedStyle) {
681
+ if (computedStyle === void 0) {
682
+ computedStyle = dndKitUtilities.getWindow(element).getComputedStyle(element);
683
+ }
684
+
685
+ const overflowRegex = /(auto|scroll|overlay)/;
686
+ const properties = ['overflow', 'overflowX', 'overflowY'];
687
+ return properties.some(property => {
688
+ const value = computedStyle[property];
689
+ return typeof value === 'string' ? overflowRegex.test(value) : false;
690
+ });
691
+ }
692
+
693
+ function getScrollableAncestors(element, limit) {
694
+ const scrollParents = [];
695
+
696
+ function findScrollableAncestors(node) {
697
+ if (limit != null && scrollParents.length >= limit) {
698
+ return scrollParents;
699
+ }
700
+
701
+ if (!node) {
702
+ return scrollParents;
703
+ }
704
+
705
+ if (dndKitUtilities.isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
706
+ scrollParents.push(node.scrollingElement);
707
+ return scrollParents;
708
+ }
709
+
710
+ if (!dndKitUtilities.isHTMLElement(node) || dndKitUtilities.isSVGElement(node)) {
711
+ return scrollParents;
712
+ }
713
+
714
+ if (scrollParents.includes(node)) {
715
+ return scrollParents;
716
+ }
717
+
718
+ const computedStyle = dndKitUtilities.getWindow(element).getComputedStyle(node);
719
+
720
+ if (node !== element) {
721
+ if (isScrollable(node, computedStyle)) {
722
+ scrollParents.push(node);
723
+ }
724
+ }
725
+
726
+ if (isFixed(node, computedStyle)) {
727
+ return scrollParents;
728
+ }
729
+
730
+ return findScrollableAncestors(node.parentNode);
731
+ }
732
+
733
+ if (!element) {
734
+ return scrollParents;
735
+ }
736
+
737
+ return findScrollableAncestors(element);
738
+ }
739
+ function getFirstScrollableAncestor(node) {
740
+ const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
741
+ return firstScrollableAncestor != null ? firstScrollableAncestor : null;
742
+ }
743
+
744
+ function getScrollableElement(element) {
745
+ if (!dndKitUtilities.canUseDOM || !element) {
746
+ return null;
747
+ }
748
+
749
+ if (dndKitUtilities.isWindow(element)) {
750
+ return element;
751
+ }
752
+
753
+ if (!dndKitUtilities.isNode(element)) {
754
+ return null;
755
+ }
756
+
757
+ if (dndKitUtilities.isDocument(element) || element === dndKitUtilities.getOwnerDocument(element).scrollingElement) {
758
+ return window;
759
+ }
760
+
761
+ if (dndKitUtilities.isHTMLElement(element)) {
762
+ return element;
763
+ }
764
+
765
+ return null;
766
+ }
767
+
768
+ function getScrollXCoordinate(element) {
769
+ if (dndKitUtilities.isWindow(element)) {
770
+ return element.scrollX;
771
+ }
772
+
773
+ return element.scrollLeft;
774
+ }
775
+ function getScrollYCoordinate(element) {
776
+ if (dndKitUtilities.isWindow(element)) {
777
+ return element.scrollY;
778
+ }
779
+
780
+ return element.scrollTop;
781
+ }
782
+ function getScrollCoordinates(element) {
783
+ return {
784
+ x: getScrollXCoordinate(element),
785
+ y: getScrollYCoordinate(element)
786
+ };
787
+ }
788
+
789
+ var Direction;
790
+
791
+ (function (Direction) {
792
+ Direction[Direction["Forward"] = 1] = "Forward";
793
+ Direction[Direction["Backward"] = -1] = "Backward";
794
+ })(Direction || (Direction = {}));
795
+
796
+ function isDocumentScrollingElement(element) {
797
+ if (!dndKitUtilities.canUseDOM || !element) {
798
+ return false;
799
+ }
800
+
801
+ return element === document.scrollingElement;
802
+ }
803
+
804
+ function getScrollPosition(scrollingContainer) {
805
+ const minScroll = {
806
+ x: 0,
807
+ y: 0
808
+ };
809
+ const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
810
+ height: window.innerHeight,
811
+ width: window.innerWidth
812
+ } : {
813
+ height: scrollingContainer.clientHeight,
814
+ width: scrollingContainer.clientWidth
815
+ };
816
+ const maxScroll = {
817
+ x: scrollingContainer.scrollWidth - dimensions.width,
818
+ y: scrollingContainer.scrollHeight - dimensions.height
819
+ };
820
+ const isTop = scrollingContainer.scrollTop <= minScroll.y;
821
+ const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
822
+ const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
823
+ const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
824
+ return {
825
+ isTop,
826
+ isLeft,
827
+ isBottom,
828
+ isRight,
829
+ maxScroll,
830
+ minScroll
831
+ };
832
+ }
833
+
834
+ const defaultThreshold = {
835
+ x: 0.2,
836
+ y: 0.2
837
+ };
838
+ function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
839
+ let {
840
+ top,
841
+ left,
842
+ right,
843
+ bottom
844
+ } = _ref;
845
+
846
+ if (acceleration === void 0) {
847
+ acceleration = 10;
848
+ }
849
+
850
+ if (thresholdPercentage === void 0) {
851
+ thresholdPercentage = defaultThreshold;
852
+ }
853
+
854
+ const {
855
+ isTop,
856
+ isBottom,
857
+ isLeft,
858
+ isRight
859
+ } = getScrollPosition(scrollContainer);
860
+ const direction = {
861
+ x: 0,
862
+ y: 0
863
+ };
864
+ const speed = {
865
+ x: 0,
866
+ y: 0
867
+ };
868
+ const threshold = {
869
+ height: scrollContainerRect.height * thresholdPercentage.y,
870
+ width: scrollContainerRect.width * thresholdPercentage.x
871
+ };
872
+
873
+ if (!isTop && top <= scrollContainerRect.top + threshold.height) {
874
+ // Scroll Up
875
+ direction.y = Direction.Backward;
876
+ speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
877
+ } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
878
+ // Scroll Down
879
+ direction.y = Direction.Forward;
880
+ speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
881
+ }
882
+
883
+ if (!isRight && right >= scrollContainerRect.right - threshold.width) {
884
+ // Scroll Right
885
+ direction.x = Direction.Forward;
886
+ speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
887
+ } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
888
+ // Scroll Left
889
+ direction.x = Direction.Backward;
890
+ speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
891
+ }
892
+
893
+ return {
894
+ direction,
895
+ speed
896
+ };
897
+ }
898
+
899
+ function getScrollElementRect(element) {
900
+ if (element === document.scrollingElement) {
901
+ const {
902
+ innerWidth,
903
+ innerHeight
904
+ } = window;
905
+ return {
906
+ top: 0,
907
+ left: 0,
908
+ right: innerWidth,
909
+ bottom: innerHeight,
910
+ width: innerWidth,
911
+ height: innerHeight
912
+ };
913
+ }
914
+
915
+ const {
916
+ top,
917
+ left,
918
+ right,
919
+ bottom
920
+ } = element.getBoundingClientRect();
921
+ return {
922
+ top,
923
+ left,
924
+ right,
925
+ bottom,
926
+ width: element.clientWidth,
927
+ height: element.clientHeight
928
+ };
929
+ }
930
+
931
+ function getScrollOffsets(scrollableAncestors) {
932
+ return scrollableAncestors.reduce((acc, node) => {
933
+ return dndKitUtilities.add(acc, getScrollCoordinates(node));
934
+ }, defaultCoordinates);
935
+ }
936
+ function getScrollXOffset(scrollableAncestors) {
937
+ return scrollableAncestors.reduce((acc, node) => {
938
+ return acc + getScrollXCoordinate(node);
939
+ }, 0);
940
+ }
941
+ function getScrollYOffset(scrollableAncestors) {
942
+ return scrollableAncestors.reduce((acc, node) => {
943
+ return acc + getScrollYCoordinate(node);
944
+ }, 0);
945
+ }
946
+
947
+ function scrollIntoViewIfNeeded(element, measure) {
948
+ if (measure === void 0) {
949
+ measure = getClientRect;
950
+ }
951
+
952
+ if (!element) {
953
+ return;
954
+ }
955
+
956
+ const {
957
+ top,
958
+ left,
959
+ bottom,
960
+ right
961
+ } = measure(element);
962
+ const firstScrollableAncestor = getFirstScrollableAncestor(element);
963
+
964
+ if (!firstScrollableAncestor) {
965
+ return;
966
+ }
967
+
968
+ if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
969
+ element.scrollIntoView({
970
+ block: 'center',
971
+ inline: 'center'
972
+ });
973
+ }
974
+ }
975
+
976
+ const properties = [['x', ['left', 'right'], getScrollXOffset], ['y', ['top', 'bottom'], getScrollYOffset]];
977
+ class Rect {
978
+ constructor(rect, element) {
979
+ this.rect = void 0;
980
+ this.width = void 0;
981
+ this.height = void 0;
982
+ this.top = void 0;
983
+ this.bottom = void 0;
984
+ this.right = void 0;
985
+ this.left = void 0;
986
+ const scrollableAncestors = getScrollableAncestors(element);
987
+ const scrollOffsets = getScrollOffsets(scrollableAncestors);
988
+ this.rect = { ...rect
989
+ };
990
+ this.width = rect.width;
991
+ this.height = rect.height;
992
+
993
+ for (const [axis, keys, getScrollOffset] of properties) {
994
+ for (const key of keys) {
995
+ Object.defineProperty(this, key, {
996
+ get: () => {
997
+ const currentOffsets = getScrollOffset(scrollableAncestors);
998
+ const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
999
+ return this.rect[key] + scrollOffsetsDeltla;
1000
+ },
1001
+ enumerable: true
1002
+ });
1003
+ }
1004
+ }
1005
+
1006
+ Object.defineProperty(this, 'rect', {
1007
+ enumerable: false
1008
+ });
1009
+ }
1010
+
1011
+ }
1012
+
1013
+ class Listeners {
1014
+ constructor(target) {
1015
+ this.target = void 0;
1016
+ this.listeners = [];
1017
+
1018
+ this.removeAll = () => {
1019
+ this.listeners.forEach(listener => {
1020
+ var _this$target;
1021
+
1022
+ return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
1023
+ });
1024
+ };
1025
+
1026
+ this.target = target;
1027
+ }
1028
+
1029
+ add(eventName, handler, options) {
1030
+ var _this$target2;
1031
+
1032
+ (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
1033
+ this.listeners.push([eventName, handler, options]);
1034
+ }
1035
+
1036
+ }
1037
+
1038
+ function getEventListenerTarget(target) {
1039
+ // If the `event.target` element is removed from the document events will still be targeted
1040
+ // at it, and hence won't always bubble up to the window or document anymore.
1041
+ // If there is any risk of an element being removed while it is being dragged,
1042
+ // the best practice is to attach the event listeners directly to the target.
1043
+ // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
1044
+ const {
1045
+ EventTarget
1046
+ } = dndKitUtilities.getWindow(target);
1047
+ return target instanceof EventTarget ? target : dndKitUtilities.getOwnerDocument(target);
1048
+ }
1049
+
1050
+ function hasExceededDistance(delta, measurement) {
1051
+ const dx = Math.abs(delta.x);
1052
+ const dy = Math.abs(delta.y);
1053
+
1054
+ if (typeof measurement === 'number') {
1055
+ return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
1056
+ }
1057
+
1058
+ if ('x' in measurement && 'y' in measurement) {
1059
+ return dx > measurement.x && dy > measurement.y;
1060
+ }
1061
+
1062
+ if ('x' in measurement) {
1063
+ return dx > measurement.x;
1064
+ }
1065
+
1066
+ if ('y' in measurement) {
1067
+ return dy > measurement.y;
1068
+ }
1069
+
1070
+ return false;
1071
+ }
1072
+
1073
+ var EventName;
1074
+
1075
+ (function (EventName) {
1076
+ EventName["Click"] = "click";
1077
+ EventName["DragStart"] = "dragstart";
1078
+ EventName["Keydown"] = "keydown";
1079
+ EventName["ContextMenu"] = "contextmenu";
1080
+ EventName["Resize"] = "resize";
1081
+ EventName["SelectionChange"] = "selectionchange";
1082
+ EventName["VisibilityChange"] = "visibilitychange";
1083
+ })(EventName || (EventName = {}));
1084
+
1085
+ function preventDefault(event) {
1086
+ event.preventDefault();
1087
+ }
1088
+ function stopPropagation(event) {
1089
+ event.stopPropagation();
1090
+ }
1091
+
1092
+ (function (KeyboardCode) {
1093
+ KeyboardCode["Space"] = "Space";
1094
+ KeyboardCode["Down"] = "ArrowDown";
1095
+ KeyboardCode["Right"] = "ArrowRight";
1096
+ KeyboardCode["Left"] = "ArrowLeft";
1097
+ KeyboardCode["Up"] = "ArrowUp";
1098
+ KeyboardCode["Esc"] = "Escape";
1099
+ KeyboardCode["Enter"] = "Enter";
1100
+ })(exports.KeyboardCode || (exports.KeyboardCode = {}));
1101
+
1102
+ const defaultKeyboardCodes = {
1103
+ start: [exports.KeyboardCode.Space, exports.KeyboardCode.Enter],
1104
+ cancel: [exports.KeyboardCode.Esc],
1105
+ end: [exports.KeyboardCode.Space, exports.KeyboardCode.Enter]
1106
+ };
1107
+ const defaultKeyboardCoordinateGetter = (event, _ref) => {
1108
+ let {
1109
+ currentCoordinates
1110
+ } = _ref;
1111
+
1112
+ switch (event.code) {
1113
+ case exports.KeyboardCode.Right:
1114
+ return { ...currentCoordinates,
1115
+ x: currentCoordinates.x + 25
1116
+ };
1117
+
1118
+ case exports.KeyboardCode.Left:
1119
+ return { ...currentCoordinates,
1120
+ x: currentCoordinates.x - 25
1121
+ };
1122
+
1123
+ case exports.KeyboardCode.Down:
1124
+ return { ...currentCoordinates,
1125
+ y: currentCoordinates.y + 25
1126
+ };
1127
+
1128
+ case exports.KeyboardCode.Up:
1129
+ return { ...currentCoordinates,
1130
+ y: currentCoordinates.y - 25
1131
+ };
1132
+ }
1133
+
1134
+ return undefined;
1135
+ };
1136
+
1137
+ class KeyboardSensor {
1138
+ constructor(props) {
1139
+ this.props = void 0;
1140
+ this.autoScrollEnabled = false;
1141
+ this.referenceCoordinates = void 0;
1142
+ this.listeners = void 0;
1143
+ this.windowListeners = void 0;
1144
+ this.props = props;
1145
+ const {
1146
+ event: {
1147
+ target
1148
+ }
1149
+ } = props;
1150
+ this.props = props;
1151
+ this.listeners = new Listeners(dndKitUtilities.getOwnerDocument(target));
1152
+ this.windowListeners = new Listeners(dndKitUtilities.getWindow(target));
1153
+ this.handleKeyDown = this.handleKeyDown.bind(this);
1154
+ this.handleCancel = this.handleCancel.bind(this);
1155
+ this.attach();
1156
+ }
1157
+
1158
+ attach() {
1159
+ this.handleStart();
1160
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
1161
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1162
+ setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
1163
+ }
1164
+
1165
+ handleStart() {
1166
+ const {
1167
+ activeNode,
1168
+ onStart
1169
+ } = this.props;
1170
+ const node = activeNode.node.current;
1171
+
1172
+ if (node) {
1173
+ scrollIntoViewIfNeeded(node);
1174
+ }
1175
+
1176
+ onStart(defaultCoordinates);
1177
+ }
1178
+
1179
+ handleKeyDown(event) {
1180
+ if (dndKitUtilities.isKeyboardEvent(event)) {
1181
+ const {
1182
+ active,
1183
+ context,
1184
+ options
1185
+ } = this.props;
1186
+ const {
1187
+ keyboardCodes = defaultKeyboardCodes,
1188
+ coordinateGetter = defaultKeyboardCoordinateGetter,
1189
+ scrollBehavior = 'smooth'
1190
+ } = options;
1191
+ const {
1192
+ code
1193
+ } = event;
1194
+
1195
+ if (keyboardCodes.end.includes(code)) {
1196
+ this.handleEnd(event);
1197
+ return;
1198
+ }
1199
+
1200
+ if (keyboardCodes.cancel.includes(code)) {
1201
+ this.handleCancel(event);
1202
+ return;
1203
+ }
1204
+
1205
+ const {
1206
+ collisionRect
1207
+ } = context.current;
1208
+ const currentCoordinates = collisionRect ? {
1209
+ x: collisionRect.left,
1210
+ y: collisionRect.top
1211
+ } : defaultCoordinates;
1212
+
1213
+ if (!this.referenceCoordinates) {
1214
+ this.referenceCoordinates = currentCoordinates;
1215
+ }
1216
+
1217
+ const newCoordinates = coordinateGetter(event, {
1218
+ active,
1219
+ context: context.current,
1220
+ currentCoordinates
1221
+ });
1222
+
1223
+ if (newCoordinates) {
1224
+ const coordinatesDelta = dndKitUtilities.subtract(newCoordinates, currentCoordinates);
1225
+ const scrollDelta = {
1226
+ x: 0,
1227
+ y: 0
1228
+ };
1229
+ const {
1230
+ scrollableAncestors
1231
+ } = context.current;
1232
+
1233
+ for (const scrollContainer of scrollableAncestors) {
1234
+ const direction = event.code;
1235
+ const {
1236
+ isTop,
1237
+ isRight,
1238
+ isLeft,
1239
+ isBottom,
1240
+ maxScroll,
1241
+ minScroll
1242
+ } = getScrollPosition(scrollContainer);
1243
+ const scrollElementRect = getScrollElementRect(scrollContainer);
1244
+ const clampedCoordinates = {
1245
+ x: Math.min(direction === exports.KeyboardCode.Right ? scrollElementRect.right - scrollElementRect.width / 2 : scrollElementRect.right, Math.max(direction === exports.KeyboardCode.Right ? scrollElementRect.left : scrollElementRect.left + scrollElementRect.width / 2, newCoordinates.x)),
1246
+ y: Math.min(direction === exports.KeyboardCode.Down ? scrollElementRect.bottom - scrollElementRect.height / 2 : scrollElementRect.bottom, Math.max(direction === exports.KeyboardCode.Down ? scrollElementRect.top : scrollElementRect.top + scrollElementRect.height / 2, newCoordinates.y))
1247
+ };
1248
+ const canScrollX = direction === exports.KeyboardCode.Right && !isRight || direction === exports.KeyboardCode.Left && !isLeft;
1249
+ const canScrollY = direction === exports.KeyboardCode.Down && !isBottom || direction === exports.KeyboardCode.Up && !isTop;
1250
+
1251
+ if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
1252
+ const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
1253
+ const canScrollToNewCoordinates = direction === exports.KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === exports.KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
1254
+
1255
+ if (canScrollToNewCoordinates && !coordinatesDelta.y) {
1256
+ // We don't need to update coordinates, the scroll adjustment alone will trigger
1257
+ // logic to auto-detect the new container we are over
1258
+ scrollContainer.scrollTo({
1259
+ left: newScrollCoordinates,
1260
+ behavior: scrollBehavior
1261
+ });
1262
+ return;
1263
+ }
1264
+
1265
+ if (canScrollToNewCoordinates) {
1266
+ scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
1267
+ } else {
1268
+ scrollDelta.x = direction === exports.KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
1269
+ }
1270
+
1271
+ if (scrollDelta.x) {
1272
+ scrollContainer.scrollBy({
1273
+ left: -scrollDelta.x,
1274
+ behavior: scrollBehavior
1275
+ });
1276
+ }
1277
+
1278
+ break;
1279
+ } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
1280
+ const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
1281
+ const canScrollToNewCoordinates = direction === exports.KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === exports.KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
1282
+
1283
+ if (canScrollToNewCoordinates && !coordinatesDelta.x) {
1284
+ // We don't need to update coordinates, the scroll adjustment alone will trigger
1285
+ // logic to auto-detect the new container we are over
1286
+ scrollContainer.scrollTo({
1287
+ top: newScrollCoordinates,
1288
+ behavior: scrollBehavior
1289
+ });
1290
+ return;
1291
+ }
1292
+
1293
+ if (canScrollToNewCoordinates) {
1294
+ scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
1295
+ } else {
1296
+ scrollDelta.y = direction === exports.KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
1297
+ }
1298
+
1299
+ if (scrollDelta.y) {
1300
+ scrollContainer.scrollBy({
1301
+ top: -scrollDelta.y,
1302
+ behavior: scrollBehavior
1303
+ });
1304
+ }
1305
+
1306
+ break;
1307
+ }
1308
+ }
1309
+
1310
+ this.handleMove(event, dndKitUtilities.add(dndKitUtilities.subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
1311
+ }
1312
+ }
1313
+ }
1314
+
1315
+ handleMove(event, coordinates) {
1316
+ const {
1317
+ onMove
1318
+ } = this.props;
1319
+ event.preventDefault();
1320
+ onMove(coordinates);
1321
+ }
1322
+
1323
+ handleEnd(event) {
1324
+ const {
1325
+ onEnd
1326
+ } = this.props;
1327
+ event.preventDefault();
1328
+ this.detach();
1329
+ onEnd();
1330
+ }
1331
+
1332
+ handleCancel(event) {
1333
+ const {
1334
+ onCancel
1335
+ } = this.props;
1336
+ event.preventDefault();
1337
+ this.detach();
1338
+ onCancel();
1339
+ }
1340
+
1341
+ detach() {
1342
+ this.listeners.removeAll();
1343
+ this.windowListeners.removeAll();
1344
+ }
1345
+
1346
+ }
1347
+ KeyboardSensor.activators = [{
1348
+ eventName: 'onKeyDown',
1349
+ handler: (event, _ref, _ref2) => {
1350
+ let {
1351
+ keyboardCodes = defaultKeyboardCodes,
1352
+ onActivation
1353
+ } = _ref;
1354
+ let {
1355
+ active
1356
+ } = _ref2;
1357
+ const {
1358
+ code
1359
+ } = event.nativeEvent;
1360
+
1361
+ if (keyboardCodes.start.includes(code)) {
1362
+ const activator = active.activatorNode.current;
1363
+
1364
+ if (activator && event.target !== activator) {
1365
+ return false;
1366
+ }
1367
+
1368
+ event.preventDefault();
1369
+ onActivation == null ? void 0 : onActivation({
1370
+ event: event.nativeEvent
1371
+ });
1372
+ return true;
1373
+ }
1374
+
1375
+ return false;
1376
+ }
1377
+ }];
1378
+
1379
+ function isDistanceConstraint(constraint) {
1380
+ return Boolean(constraint && 'distance' in constraint);
1381
+ }
1382
+
1383
+ function isDelayConstraint(constraint) {
1384
+ return Boolean(constraint && 'delay' in constraint);
1385
+ }
1386
+
1387
+ class AbstractPointerSensor {
1388
+ constructor(props, events, listenerTarget) {
1389
+ var _getEventCoordinates;
1390
+
1391
+ if (listenerTarget === void 0) {
1392
+ listenerTarget = getEventListenerTarget(props.event.target);
1393
+ }
1394
+
1395
+ this.props = void 0;
1396
+ this.events = void 0;
1397
+ this.autoScrollEnabled = true;
1398
+ this.document = void 0;
1399
+ this.activated = false;
1400
+ this.initialCoordinates = void 0;
1401
+ this.timeoutId = null;
1402
+ this.listeners = void 0;
1403
+ this.documentListeners = void 0;
1404
+ this.windowListeners = void 0;
1405
+ this.props = props;
1406
+ this.events = events;
1407
+ const {
1408
+ event
1409
+ } = props;
1410
+ const {
1411
+ target
1412
+ } = event;
1413
+ this.props = props;
1414
+ this.events = events;
1415
+ this.document = dndKitUtilities.getOwnerDocument(target);
1416
+ this.documentListeners = new Listeners(this.document);
1417
+ this.listeners = new Listeners(listenerTarget);
1418
+ this.windowListeners = new Listeners(dndKitUtilities.getWindow(target));
1419
+ this.initialCoordinates = (_getEventCoordinates = dndKitUtilities.getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
1420
+ this.handleStart = this.handleStart.bind(this);
1421
+ this.handleMove = this.handleMove.bind(this);
1422
+ this.handleEnd = this.handleEnd.bind(this);
1423
+ this.handleCancel = this.handleCancel.bind(this);
1424
+ this.handleKeydown = this.handleKeydown.bind(this);
1425
+ this.removeTextSelection = this.removeTextSelection.bind(this);
1426
+ this.attach();
1427
+ }
1428
+
1429
+ attach() {
1430
+ const {
1431
+ events,
1432
+ props: {
1433
+ options: {
1434
+ activationConstraint
1435
+ }
1436
+ }
1437
+ } = this;
1438
+ this.listeners.add(events.move.name, this.handleMove, {
1439
+ passive: false
1440
+ });
1441
+ this.listeners.add(events.end.name, this.handleEnd);
1442
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
1443
+ this.windowListeners.add(EventName.DragStart, preventDefault);
1444
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1445
+ this.windowListeners.add(EventName.ContextMenu, preventDefault);
1446
+ this.documentListeners.add(EventName.Keydown, this.handleKeydown);
1447
+
1448
+ if (activationConstraint) {
1449
+ if (isDistanceConstraint(activationConstraint)) {
1450
+ return;
1451
+ }
1452
+
1453
+ if (isDelayConstraint(activationConstraint)) {
1454
+ this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
1455
+ return;
1456
+ }
1457
+ }
1458
+
1459
+ this.handleStart();
1460
+ }
1461
+
1462
+ detach() {
1463
+ this.listeners.removeAll();
1464
+ this.windowListeners.removeAll(); // Wait until the next event loop before removing document listeners
1465
+ // This is necessary because we listen for `click` and `selection` events on the document
1466
+
1467
+ setTimeout(this.documentListeners.removeAll, 50);
1468
+
1469
+ if (this.timeoutId !== null) {
1470
+ clearTimeout(this.timeoutId);
1471
+ this.timeoutId = null;
1472
+ }
1473
+ }
1474
+
1475
+ handleStart() {
1476
+ const {
1477
+ initialCoordinates
1478
+ } = this;
1479
+ const {
1480
+ onStart
1481
+ } = this.props;
1482
+
1483
+ if (initialCoordinates) {
1484
+ this.activated = true; // Stop propagation of click events once activation constraints are met
1485
+
1486
+ this.documentListeners.add(EventName.Click, stopPropagation, {
1487
+ capture: true
1488
+ }); // Remove any text selection from the document
1489
+
1490
+ this.removeTextSelection(); // Prevent further text selection while dragging
1491
+
1492
+ this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
1493
+ onStart(initialCoordinates);
1494
+ }
1495
+ }
1496
+
1497
+ handleMove(event) {
1498
+ var _getEventCoordinates2;
1499
+
1500
+ const {
1501
+ activated,
1502
+ initialCoordinates,
1503
+ props
1504
+ } = this;
1505
+ const {
1506
+ onMove,
1507
+ options: {
1508
+ activationConstraint
1509
+ }
1510
+ } = props;
1511
+
1512
+ if (!initialCoordinates) {
1513
+ return;
1514
+ }
1515
+
1516
+ const coordinates = (_getEventCoordinates2 = dndKitUtilities.getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
1517
+ const delta = dndKitUtilities.subtract(initialCoordinates, coordinates);
1518
+
1519
+ if (!activated && activationConstraint) {
1520
+ // Constraint validation
1521
+ if (isDelayConstraint(activationConstraint)) {
1522
+ if (hasExceededDistance(delta, activationConstraint.tolerance)) {
1523
+ return this.handleCancel();
1524
+ }
1525
+
1526
+ return;
1527
+ }
1528
+
1529
+ if (isDistanceConstraint(activationConstraint)) {
1530
+ if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
1531
+ return this.handleCancel();
1532
+ }
1533
+
1534
+ if (hasExceededDistance(delta, activationConstraint.distance)) {
1535
+ return this.handleStart();
1536
+ }
1537
+
1538
+ return;
1539
+ }
1540
+ }
1541
+
1542
+ if (event.cancelable) {
1543
+ event.preventDefault();
1544
+ }
1545
+
1546
+ onMove(coordinates);
1547
+ }
1548
+
1549
+ handleEnd() {
1550
+ const {
1551
+ onEnd
1552
+ } = this.props;
1553
+ this.detach();
1554
+ onEnd();
1555
+ }
1556
+
1557
+ handleCancel() {
1558
+ const {
1559
+ onCancel
1560
+ } = this.props;
1561
+ this.detach();
1562
+ onCancel();
1563
+ }
1564
+
1565
+ handleKeydown(event) {
1566
+ if (event.code === exports.KeyboardCode.Esc) {
1567
+ this.handleCancel();
1568
+ }
1569
+ }
1570
+
1571
+ removeTextSelection() {
1572
+ var _this$document$getSel;
1573
+
1574
+ (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
1575
+ }
1576
+
1577
+ }
1578
+
1579
+ const events = {
1580
+ move: {
1581
+ name: 'pointermove'
1582
+ },
1583
+ end: {
1584
+ name: 'pointerup'
1585
+ }
1586
+ };
1587
+ class PointerSensor extends AbstractPointerSensor {
1588
+ constructor(props) {
1589
+ const {
1590
+ event
1591
+ } = props; // Pointer events stop firing if the target is unmounted while dragging
1592
+ // Therefore we attach listeners to the owner document instead
1593
+
1594
+ const listenerTarget = dndKitUtilities.getOwnerDocument(event.target);
1595
+ super(props, events, listenerTarget);
1596
+ }
1597
+
1598
+ }
1599
+ PointerSensor.activators = [{
1600
+ eventName: 'onPointerDown',
1601
+ handler: (_ref, _ref2) => {
1602
+ let {
1603
+ nativeEvent: event
1604
+ } = _ref;
1605
+ let {
1606
+ onActivation
1607
+ } = _ref2;
1608
+
1609
+ if (!event.isPrimary || event.button !== 0) {
1610
+ return false;
1611
+ }
1612
+
1613
+ onActivation == null ? void 0 : onActivation({
1614
+ event
1615
+ });
1616
+ return true;
1617
+ }
1618
+ }];
1619
+
1620
+ const events$1 = {
1621
+ move: {
1622
+ name: 'mousemove'
1623
+ },
1624
+ end: {
1625
+ name: 'mouseup'
1626
+ }
1627
+ };
1628
+ var MouseButton;
1629
+
1630
+ (function (MouseButton) {
1631
+ MouseButton[MouseButton["RightClick"] = 2] = "RightClick";
1632
+ })(MouseButton || (MouseButton = {}));
1633
+
1634
+ class MouseSensor extends AbstractPointerSensor {
1635
+ constructor(props) {
1636
+ super(props, events$1, dndKitUtilities.getOwnerDocument(props.event.target));
1637
+ }
1638
+
1639
+ }
1640
+ MouseSensor.activators = [{
1641
+ eventName: 'onMouseDown',
1642
+ handler: (_ref, _ref2) => {
1643
+ let {
1644
+ nativeEvent: event
1645
+ } = _ref;
1646
+ let {
1647
+ onActivation
1648
+ } = _ref2;
1649
+
1650
+ if (event.button === MouseButton.RightClick) {
1651
+ return false;
1652
+ }
1653
+
1654
+ onActivation == null ? void 0 : onActivation({
1655
+ event
1656
+ });
1657
+ return true;
1658
+ }
1659
+ }];
1660
+
1661
+ const events$2 = {
1662
+ move: {
1663
+ name: 'touchmove'
1664
+ },
1665
+ end: {
1666
+ name: 'touchend'
1667
+ }
1668
+ };
1669
+ class TouchSensor extends AbstractPointerSensor {
1670
+ constructor(props) {
1671
+ super(props, events$2);
1672
+ }
1673
+
1674
+ static setup() {
1675
+ // Adding a non-capture and non-passive `touchmove` listener in order
1676
+ // to force `event.preventDefault()` calls to work in dynamically added
1677
+ // touchmove event handlers. This is required for iOS Safari.
1678
+ window.addEventListener(events$2.move.name, noop, {
1679
+ capture: false,
1680
+ passive: false
1681
+ });
1682
+ return function teardown() {
1683
+ window.removeEventListener(events$2.move.name, noop);
1684
+ }; // We create a new handler because the teardown function of another sensor
1685
+ // could remove our event listener if we use a referentially equal listener.
1686
+
1687
+ function noop() {}
1688
+ }
1689
+
1690
+ }
1691
+ TouchSensor.activators = [{
1692
+ eventName: 'onTouchStart',
1693
+ handler: (_ref, _ref2) => {
1694
+ let {
1695
+ nativeEvent: event
1696
+ } = _ref;
1697
+ let {
1698
+ onActivation
1699
+ } = _ref2;
1700
+ const {
1701
+ touches
1702
+ } = event;
1703
+
1704
+ if (touches.length > 1) {
1705
+ return false;
1706
+ }
1707
+
1708
+ onActivation == null ? void 0 : onActivation({
1709
+ event
1710
+ });
1711
+ return true;
1712
+ }
1713
+ }];
1714
+
1715
+ (function (AutoScrollActivator) {
1716
+ AutoScrollActivator[AutoScrollActivator["Pointer"] = 0] = "Pointer";
1717
+ AutoScrollActivator[AutoScrollActivator["DraggableRect"] = 1] = "DraggableRect";
1718
+ })(exports.AutoScrollActivator || (exports.AutoScrollActivator = {}));
1719
+
1720
+ (function (TraversalOrder) {
1721
+ TraversalOrder[TraversalOrder["TreeOrder"] = 0] = "TreeOrder";
1722
+ TraversalOrder[TraversalOrder["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
1723
+ })(exports.TraversalOrder || (exports.TraversalOrder = {}));
1724
+
1725
+ function useAutoScroller(_ref) {
1726
+ let {
1727
+ acceleration,
1728
+ activator = exports.AutoScrollActivator.Pointer,
1729
+ canScroll,
1730
+ draggingRect,
1731
+ enabled,
1732
+ interval = 5,
1733
+ order = exports.TraversalOrder.TreeOrder,
1734
+ pointerCoordinates,
1735
+ scrollableAncestors,
1736
+ scrollableAncestorRects,
1737
+ delta,
1738
+ threshold
1739
+ } = _ref;
1740
+ const scrollIntent = useScrollIntent({
1741
+ delta,
1742
+ disabled: !enabled
1743
+ });
1744
+ const [setAutoScrollInterval, clearAutoScrollInterval] = dndKitUtilities.useInterval();
1745
+ const scrollSpeed = React.useRef({
1746
+ x: 0,
1747
+ y: 0
1748
+ });
1749
+ const scrollDirection = React.useRef({
1750
+ x: 0,
1751
+ y: 0
1752
+ });
1753
+ const rect = React.useMemo(() => {
1754
+ switch (activator) {
1755
+ case exports.AutoScrollActivator.Pointer:
1756
+ return pointerCoordinates ? {
1757
+ top: pointerCoordinates.y,
1758
+ bottom: pointerCoordinates.y,
1759
+ left: pointerCoordinates.x,
1760
+ right: pointerCoordinates.x
1761
+ } : null;
1762
+
1763
+ case exports.AutoScrollActivator.DraggableRect:
1764
+ return draggingRect;
1765
+ }
1766
+ }, [activator, draggingRect, pointerCoordinates]);
1767
+ const scrollContainerRef = React.useRef(null);
1768
+ const autoScroll = React.useCallback(() => {
1769
+ const scrollContainer = scrollContainerRef.current;
1770
+
1771
+ if (!scrollContainer) {
1772
+ return;
1773
+ }
1774
+
1775
+ const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
1776
+ const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
1777
+ scrollContainer.scrollBy(scrollLeft, scrollTop);
1778
+ }, []);
1779
+ const sortedScrollableAncestors = React.useMemo(() => order === exports.TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
1780
+ React.useEffect(() => {
1781
+ if (!enabled || !scrollableAncestors.length || !rect) {
1782
+ clearAutoScrollInterval();
1783
+ return;
1784
+ }
1785
+
1786
+ for (const scrollContainer of sortedScrollableAncestors) {
1787
+ var _scrollableAncestorRe;
1788
+
1789
+ if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
1790
+ continue;
1791
+ }
1792
+
1793
+ const scrollContainerRect = (_scrollableAncestorRe = scrollableAncestorRects.find(_ref2 => {
1794
+ let {
1795
+ element
1796
+ } = _ref2;
1797
+ return element === scrollContainer;
1798
+ })) == null ? void 0 : _scrollableAncestorRe.rect;
1799
+
1800
+ if (!scrollContainerRect) {
1801
+ continue;
1802
+ }
1803
+
1804
+ const {
1805
+ direction,
1806
+ speed
1807
+ } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
1808
+
1809
+ for (const axis of ['x', 'y']) {
1810
+ if (!scrollIntent[axis][direction[axis]]) {
1811
+ speed[axis] = 0;
1812
+ direction[axis] = 0;
1813
+ }
1814
+ }
1815
+
1816
+ if (speed.x > 0 || speed.y > 0) {
1817
+ clearAutoScrollInterval();
1818
+ scrollContainerRef.current = scrollContainer;
1819
+ setAutoScrollInterval(autoScroll, interval);
1820
+ scrollSpeed.current = speed;
1821
+ scrollDirection.current = direction;
1822
+ return;
1823
+ }
1824
+ }
1825
+
1826
+ scrollSpeed.current = {
1827
+ x: 0,
1828
+ y: 0
1829
+ };
1830
+ scrollDirection.current = {
1831
+ x: 0,
1832
+ y: 0
1833
+ };
1834
+ clearAutoScrollInterval();
1835
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
1836
+ [acceleration, autoScroll, canScroll, clearAutoScrollInterval, enabled, interval, // eslint-disable-next-line react-hooks/exhaustive-deps
1837
+ JSON.stringify(rect), // eslint-disable-next-line react-hooks/exhaustive-deps
1838
+ JSON.stringify(scrollIntent), setAutoScrollInterval, scrollableAncestors, sortedScrollableAncestors, scrollableAncestorRects, // eslint-disable-next-line react-hooks/exhaustive-deps
1839
+ JSON.stringify(threshold)]);
1840
+ }
1841
+ const defaultScrollIntent = {
1842
+ x: {
1843
+ [Direction.Backward]: false,
1844
+ [Direction.Forward]: false
1845
+ },
1846
+ y: {
1847
+ [Direction.Backward]: false,
1848
+ [Direction.Forward]: false
1849
+ }
1850
+ };
1851
+
1852
+ function useScrollIntent(_ref3) {
1853
+ let {
1854
+ delta,
1855
+ disabled
1856
+ } = _ref3;
1857
+ const previousDelta = dndKitUtilities.usePrevious(delta);
1858
+ return dndKitUtilities.useLazyMemo(previousIntent => {
1859
+ if (disabled || !previousDelta || !previousIntent) {
1860
+ // Reset scroll intent tracking when auto-scrolling is disabled
1861
+ return defaultScrollIntent;
1862
+ }
1863
+
1864
+ const direction = {
1865
+ x: Math.sign(delta.x - previousDelta.x),
1866
+ y: Math.sign(delta.y - previousDelta.y)
1867
+ }; // Keep track of the user intent to scroll in each direction for both axis
1868
+
1869
+ return {
1870
+ x: {
1871
+ [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
1872
+ [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
1873
+ },
1874
+ y: {
1875
+ [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
1876
+ [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
1877
+ }
1878
+ };
1879
+ }, [disabled, delta, previousDelta]);
1880
+ }
1881
+
1882
+ function useCachedNode(draggableNodes, id) {
1883
+ const draggableNode = id !== null ? draggableNodes.get(id) : undefined;
1884
+ const node = draggableNode ? draggableNode.node.current : null;
1885
+ return dndKitUtilities.useLazyMemo(cachedNode => {
1886
+ var _ref;
1887
+
1888
+ if (id === null) {
1889
+ return null;
1890
+ } // In some cases, the draggable node can unmount while dragging
1891
+ // This is the case for virtualized lists. In those situations,
1892
+ // we fall back to the last known value for that node.
1893
+
1894
+
1895
+ return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
1896
+ }, [node, id]);
1897
+ }
1898
+
1899
+ function useCombineActivators(sensors, getSyntheticHandler) {
1900
+ return React.useMemo(() => sensors.reduce((accumulator, sensor) => {
1901
+ const {
1902
+ sensor: Sensor
1903
+ } = sensor;
1904
+ const sensorActivators = Sensor.activators.map(activator => ({
1905
+ eventName: activator.eventName,
1906
+ handler: getSyntheticHandler(activator.handler, sensor)
1907
+ }));
1908
+ return [...accumulator, ...sensorActivators];
1909
+ }, []), [sensors, getSyntheticHandler]);
1910
+ }
1911
+
1912
+ (function (MeasuringStrategy) {
1913
+ MeasuringStrategy[MeasuringStrategy["Always"] = 0] = "Always";
1914
+ MeasuringStrategy[MeasuringStrategy["BeforeDragging"] = 1] = "BeforeDragging";
1915
+ MeasuringStrategy[MeasuringStrategy["WhileDragging"] = 2] = "WhileDragging";
1916
+ })(exports.MeasuringStrategy || (exports.MeasuringStrategy = {}));
1917
+
1918
+ (function (MeasuringFrequency) {
1919
+ MeasuringFrequency["Optimized"] = "optimized";
1920
+ })(exports.MeasuringFrequency || (exports.MeasuringFrequency = {}));
1921
+
1922
+ const defaultValue = /*#__PURE__*/new Map();
1923
+ function useDroppableMeasuring(containers, _ref) {
1924
+ let {
1925
+ dragging,
1926
+ dependencies,
1927
+ config
1928
+ } = _ref;
1929
+ const [queue, setQueue] = React.useState(null);
1930
+ const {
1931
+ frequency,
1932
+ measure,
1933
+ strategy
1934
+ } = config;
1935
+ const containersRef = React.useRef(containers);
1936
+ const disabled = isDisabled();
1937
+ const disabledRef = dndKitUtilities.useLatestValue(disabled);
1938
+ const measureDroppableContainers = React.useCallback(function (ids) {
1939
+ if (ids === void 0) {
1940
+ ids = [];
1941
+ }
1942
+
1943
+ if (disabledRef.current) {
1944
+ return;
1945
+ }
1946
+
1947
+ setQueue(value => {
1948
+ if (value === null) {
1949
+ return ids;
1950
+ }
1951
+
1952
+ return value.concat(ids.filter(id => !value.includes(id)));
1953
+ });
1954
+ }, [disabledRef]);
1955
+ const timeoutId = React.useRef(null);
1956
+ const droppableRects = dndKitUtilities.useLazyMemo(previousValue => {
1957
+ if (disabled && !dragging) {
1958
+ return defaultValue;
1959
+ }
1960
+
1961
+ if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
1962
+ const map = new Map();
1963
+
1964
+ for (let container of containers) {
1965
+ if (!container) {
1966
+ continue;
1967
+ }
1968
+
1969
+ if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
1970
+ // This container does not need to be re-measured
1971
+ map.set(container.id, container.rect.current);
1972
+ continue;
1973
+ }
1974
+
1975
+ const node = container.node.current;
1976
+ const rect = node ? new Rect(measure(node), node) : null;
1977
+ container.rect.current = rect;
1978
+
1979
+ if (rect) {
1980
+ map.set(container.id, rect);
1981
+ }
1982
+ }
1983
+
1984
+ return map;
1985
+ }
1986
+
1987
+ return previousValue;
1988
+ }, [containers, queue, dragging, disabled, measure]);
1989
+ React.useEffect(() => {
1990
+ containersRef.current = containers;
1991
+ }, [containers]);
1992
+ React.useEffect(() => {
1993
+ if (disabled) {
1994
+ return;
1995
+ }
1996
+
1997
+ measureDroppableContainers();
1998
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
1999
+ [dragging, disabled]);
2000
+ React.useEffect(() => {
2001
+ if (queue && queue.length > 0) {
2002
+ setQueue(null);
2003
+ }
2004
+ }, //eslint-disable-next-line react-hooks/exhaustive-deps
2005
+ [JSON.stringify(queue)]);
2006
+ React.useEffect(() => {
2007
+ if (disabled || typeof frequency !== 'number' || timeoutId.current !== null) {
2008
+ return;
2009
+ }
2010
+
2011
+ timeoutId.current = setTimeout(() => {
2012
+ measureDroppableContainers();
2013
+ timeoutId.current = null;
2014
+ }, frequency);
2015
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2016
+ [frequency, disabled, measureDroppableContainers, ...dependencies]);
2017
+ return {
2018
+ droppableRects,
2019
+ measureDroppableContainers,
2020
+ measuringScheduled: queue != null
2021
+ };
2022
+
2023
+ function isDisabled() {
2024
+ switch (strategy) {
2025
+ case exports.MeasuringStrategy.Always:
2026
+ return false;
2027
+
2028
+ case exports.MeasuringStrategy.BeforeDragging:
2029
+ return dragging;
2030
+
2031
+ default:
2032
+ return !dragging;
2033
+ }
2034
+ }
2035
+ }
2036
+
2037
+ function useInitialValue(value, computeFn) {
2038
+ return dndKitUtilities.useLazyMemo(previousValue => {
2039
+ if (!value) {
2040
+ return null;
2041
+ }
2042
+
2043
+ if (previousValue) {
2044
+ return previousValue;
2045
+ }
2046
+
2047
+ return typeof computeFn === 'function' ? computeFn(value) : value;
2048
+ }, [computeFn, value]);
2049
+ }
2050
+
2051
+ function useInitialRect(node, measure) {
2052
+ return useInitialValue(node, measure);
2053
+ }
2054
+
2055
+ /**
2056
+ * Returns a new MutationObserver instance.
2057
+ * If `MutationObserver` is undefined in the execution environment, returns `undefined`.
2058
+ */
2059
+
2060
+ function useMutationObserver(_ref) {
2061
+ let {
2062
+ callback,
2063
+ disabled
2064
+ } = _ref;
2065
+ const handleMutations = dndKitUtilities.useEvent(callback);
2066
+ const mutationObserver = React.useMemo(() => {
2067
+ if (disabled || typeof window === 'undefined' || typeof window.MutationObserver === 'undefined') {
2068
+ return undefined;
2069
+ }
2070
+
2071
+ const {
2072
+ MutationObserver
2073
+ } = window;
2074
+ return new MutationObserver(handleMutations);
2075
+ }, [handleMutations, disabled]);
2076
+ React.useEffect(() => {
2077
+ return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
2078
+ }, [mutationObserver]);
2079
+ return mutationObserver;
2080
+ }
2081
+
2082
+ /**
2083
+ * Returns a new ResizeObserver instance bound to the `onResize` callback.
2084
+ * If `ResizeObserver` is undefined in the execution environment, returns `undefined`.
2085
+ */
2086
+
2087
+ function useResizeObserver(_ref) {
2088
+ let {
2089
+ callback,
2090
+ disabled
2091
+ } = _ref;
2092
+ const handleResize = dndKitUtilities.useEvent(callback);
2093
+ const resizeObserver = React.useMemo(() => {
2094
+ if (disabled || typeof window === 'undefined' || typeof window.ResizeObserver === 'undefined') {
2095
+ return undefined;
2096
+ }
2097
+
2098
+ const {
2099
+ ResizeObserver
2100
+ } = window;
2101
+ return new ResizeObserver(handleResize);
2102
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2103
+ [disabled]);
2104
+ React.useEffect(() => {
2105
+ return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
2106
+ }, [resizeObserver]);
2107
+ return resizeObserver;
2108
+ }
2109
+
2110
+ function defaultMeasure(element) {
2111
+ return new Rect(getClientRect(element), element);
2112
+ }
2113
+
2114
+ function useRect(element, measure, fallbackRect) {
2115
+ if (measure === void 0) {
2116
+ measure = defaultMeasure;
2117
+ }
2118
+
2119
+ const [rect, measureRect] = React.useReducer(reducer, null);
2120
+ const mutationObserver = useMutationObserver({
2121
+ callback(records) {
2122
+ if (!element) {
2123
+ return;
2124
+ }
2125
+
2126
+ for (const record of records) {
2127
+ const {
2128
+ type,
2129
+ target
2130
+ } = record;
2131
+
2132
+ if (type === 'childList' && target instanceof HTMLElement && target.contains(element)) {
2133
+ measureRect();
2134
+ break;
2135
+ }
2136
+ }
2137
+ }
2138
+
2139
+ });
2140
+ const resizeObserver = useResizeObserver({
2141
+ callback: measureRect
2142
+ });
2143
+ dndKitUtilities.useIsomorphicLayoutEffect(() => {
2144
+ measureRect();
2145
+
2146
+ if (element) {
2147
+ resizeObserver == null ? void 0 : resizeObserver.observe(element);
2148
+ mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
2149
+ childList: true,
2150
+ subtree: true
2151
+ });
2152
+ } else {
2153
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2154
+ mutationObserver == null ? void 0 : mutationObserver.disconnect();
2155
+ }
2156
+ }, [element]);
2157
+ return rect;
2158
+
2159
+ function reducer(currentRect) {
2160
+ if (!element) {
2161
+ return null;
2162
+ }
2163
+
2164
+ if (element.isConnected === false) {
2165
+ var _ref;
2166
+
2167
+ // Fall back to last rect we measured if the element is
2168
+ // no longer connected to the DOM.
2169
+ return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
2170
+ }
2171
+
2172
+ const newRect = measure(element);
2173
+
2174
+ if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
2175
+ return currentRect;
2176
+ }
2177
+
2178
+ return newRect;
2179
+ }
2180
+ }
2181
+
2182
+ function useRectDelta(rect) {
2183
+ const initialRect = useInitialValue(rect);
2184
+ return getRectDelta(rect, initialRect);
2185
+ }
2186
+
2187
+ const defaultValue$1 = [];
2188
+ function useScrollableAncestors(node) {
2189
+ const previousNode = React.useRef(node);
2190
+ const ancestors = dndKitUtilities.useLazyMemo(previousValue => {
2191
+ if (!node) {
2192
+ return defaultValue$1;
2193
+ }
2194
+
2195
+ if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
2196
+ return previousValue;
2197
+ }
2198
+
2199
+ return getScrollableAncestors(node);
2200
+ }, [node]);
2201
+ React.useEffect(() => {
2202
+ previousNode.current = node;
2203
+ }, [node]);
2204
+ return ancestors;
2205
+ }
2206
+
2207
+ function useScrollOffsets(elements) {
2208
+ const [scrollCoordinates, setScrollCoordinates] = React.useState(null);
2209
+ const prevElements = React.useRef(elements); // To-do: Throttle the handleScroll callback
2210
+
2211
+ const handleScroll = React.useCallback(event => {
2212
+ const scrollingElement = getScrollableElement(event.target);
2213
+
2214
+ if (!scrollingElement) {
2215
+ return;
2216
+ }
2217
+
2218
+ setScrollCoordinates(scrollCoordinates => {
2219
+ if (!scrollCoordinates) {
2220
+ return null;
2221
+ }
2222
+
2223
+ scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));
2224
+ return new Map(scrollCoordinates);
2225
+ });
2226
+ }, []);
2227
+ React.useEffect(() => {
2228
+ const previousElements = prevElements.current;
2229
+
2230
+ if (elements !== previousElements) {
2231
+ cleanup(previousElements);
2232
+ const entries = elements.map(element => {
2233
+ const scrollableElement = getScrollableElement(element);
2234
+
2235
+ if (scrollableElement) {
2236
+ scrollableElement.addEventListener('scroll', handleScroll, {
2237
+ passive: true
2238
+ });
2239
+ return [scrollableElement, getScrollCoordinates(scrollableElement)];
2240
+ }
2241
+
2242
+ return null;
2243
+ }).filter(entry => entry != null);
2244
+ setScrollCoordinates(entries.length ? new Map(entries) : null);
2245
+ prevElements.current = elements;
2246
+ }
2247
+
2248
+ return () => {
2249
+ cleanup(elements);
2250
+ cleanup(previousElements);
2251
+ };
2252
+
2253
+ function cleanup(elements) {
2254
+ elements.forEach(element => {
2255
+ const scrollableElement = getScrollableElement(element);
2256
+ scrollableElement == null ? void 0 : scrollableElement.removeEventListener('scroll', handleScroll);
2257
+ });
2258
+ }
2259
+ }, [handleScroll, elements]);
2260
+ return React.useMemo(() => {
2261
+ if (elements.length) {
2262
+ return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => dndKitUtilities.add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
2263
+ }
2264
+
2265
+ return defaultCoordinates;
2266
+ }, [elements, scrollCoordinates]);
2267
+ }
2268
+
2269
+ function useScrollOffsetsDelta(scrollOffsets, dependencies) {
2270
+ if (dependencies === void 0) {
2271
+ dependencies = [];
2272
+ }
2273
+
2274
+ const initialScrollOffsets = React.useRef(null);
2275
+ React.useEffect(() => {
2276
+ initialScrollOffsets.current = null;
2277
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
2278
+ dependencies);
2279
+ React.useEffect(() => {
2280
+ const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
2281
+
2282
+ if (hasScrollOffsets && !initialScrollOffsets.current) {
2283
+ initialScrollOffsets.current = scrollOffsets;
2284
+ }
2285
+
2286
+ if (!hasScrollOffsets && initialScrollOffsets.current) {
2287
+ initialScrollOffsets.current = null;
2288
+ }
2289
+ }, [scrollOffsets]);
2290
+ return initialScrollOffsets.current ? dndKitUtilities.subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
2291
+ }
2292
+
2293
+ function useSensorSetup(sensors) {
2294
+ React.useEffect(() => {
2295
+ if (!dndKitUtilities.canUseDOM) {
2296
+ return;
2297
+ }
2298
+
2299
+ const teardownFns = sensors.map(_ref => {
2300
+ let {
2301
+ sensor
2302
+ } = _ref;
2303
+ return sensor.setup == null ? void 0 : sensor.setup();
2304
+ });
2305
+ return () => {
2306
+ for (const teardown of teardownFns) {
2307
+ teardown == null ? void 0 : teardown();
2308
+ }
2309
+ };
2310
+ }, // TO-DO: Sensors length could theoretically change which would not be a valid dependency
2311
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2312
+ sensors.map(_ref2 => {
2313
+ let {
2314
+ sensor
2315
+ } = _ref2;
2316
+ return sensor;
2317
+ }));
2318
+ }
2319
+
2320
+ function useSyntheticListeners(listeners, id) {
2321
+ return React.useMemo(() => {
2322
+ return listeners.reduce((acc, _ref) => {
2323
+ let {
2324
+ eventName,
2325
+ handler
2326
+ } = _ref;
2327
+
2328
+ acc[eventName] = event => {
2329
+ handler(event, id);
2330
+ };
2331
+
2332
+ return acc;
2333
+ }, {});
2334
+ }, [listeners, id]);
2335
+ }
2336
+
2337
+ function useWindowRect(element) {
2338
+ return React.useMemo(() => element ? getWindowClientRect(element) : null, [element]);
2339
+ }
2340
+
2341
+ const defaultValue$2 = [];
2342
+ function useRects(elements, measure) {
2343
+ if (measure === void 0) {
2344
+ measure = getClientRect;
2345
+ }
2346
+
2347
+ const [firstElement] = elements;
2348
+ const windowRect = useWindowRect(firstElement ? dndKitUtilities.getWindow(firstElement) : null);
2349
+ const [rects, measureRects] = React.useReducer(reducer, defaultValue$2);
2350
+ const resizeObserver = useResizeObserver({
2351
+ callback: measureRects
2352
+ });
2353
+
2354
+ if (elements.length > 0 && rects === defaultValue$2) {
2355
+ measureRects();
2356
+ }
2357
+
2358
+ dndKitUtilities.useIsomorphicLayoutEffect(() => {
2359
+ if (elements.length) {
2360
+ elements.forEach(element => resizeObserver == null ? void 0 : resizeObserver.observe(element));
2361
+ } else {
2362
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2363
+ measureRects();
2364
+ }
2365
+ }, [elements]);
2366
+ return rects;
2367
+
2368
+ function reducer() {
2369
+ if (!elements.length) {
2370
+ return defaultValue$2;
2371
+ }
2372
+
2373
+ return elements.map(element => isDocumentScrollingElement(element) ? {
2374
+ rect: windowRect,
2375
+ element
2376
+ } : {
2377
+ rect: new Rect(measure(element), element),
2378
+ element
2379
+ });
2380
+ }
2381
+ }
2382
+
2383
+ function getMeasurableNode(node) {
2384
+ if (!node) {
2385
+ return null;
2386
+ }
2387
+
2388
+ if (node.children.length > 1) {
2389
+ return node;
2390
+ }
2391
+
2392
+ const firstChild = node.children[0];
2393
+ return dndKitUtilities.isHTMLElement(firstChild) ? firstChild : node;
2394
+ }
2395
+
2396
+ function useDragOverlayMeasuring(_ref) {
2397
+ let {
2398
+ measure
2399
+ } = _ref;
2400
+ const [rect, setRect] = React.useState(null);
2401
+ const handleResize = React.useCallback(entries => {
2402
+ for (const {
2403
+ target
2404
+ } of entries) {
2405
+ if (dndKitUtilities.isHTMLElement(target)) {
2406
+ setRect(rect => {
2407
+ const newRect = measure(target);
2408
+ return rect ? { ...rect,
2409
+ width: newRect.width,
2410
+ height: newRect.height
2411
+ } : newRect;
2412
+ });
2413
+ break;
2414
+ }
2415
+ }
2416
+ }, [measure]);
2417
+ const resizeObserver = useResizeObserver({
2418
+ callback: handleResize
2419
+ });
2420
+ const handleNodeChange = React.useCallback(element => {
2421
+ const node = getMeasurableNode(element);
2422
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2423
+
2424
+ if (node) {
2425
+ resizeObserver == null ? void 0 : resizeObserver.observe(node);
2426
+ }
2427
+
2428
+ setRect(node ? measure(node) : null);
2429
+ }, [measure, resizeObserver]);
2430
+ const [nodeRef, setRef] = dndKitUtilities.useNodeRef(handleNodeChange);
2431
+ return React.useMemo(() => ({
2432
+ nodeRef,
2433
+ rect,
2434
+ setRef
2435
+ }), [rect, nodeRef, setRef]);
2436
+ }
2437
+
2438
+ const defaultSensors = [{
2439
+ sensor: PointerSensor,
2440
+ options: {}
2441
+ }, {
2442
+ sensor: KeyboardSensor,
2443
+ options: {}
2444
+ }];
2445
+ const defaultData = {
2446
+ current: {}
2447
+ };
2448
+ const defaultMeasuringConfiguration = {
2449
+ draggable: {
2450
+ measure: getTransformAgnosticClientRect
2451
+ },
2452
+ droppable: {
2453
+ measure: getTransformAgnosticClientRect,
2454
+ strategy: exports.MeasuringStrategy.WhileDragging,
2455
+ frequency: exports.MeasuringFrequency.Optimized
2456
+ },
2457
+ dragOverlay: {
2458
+ measure: getClientRect
2459
+ }
2460
+ };
2461
+
2462
+ class DroppableContainersMap extends Map {
2463
+ get(id) {
2464
+ var _super$get;
2465
+
2466
+ return id != null ? (_super$get = super.get(id)) != null ? _super$get : undefined : undefined;
2467
+ }
2468
+
2469
+ toArray() {
2470
+ return Array.from(this.values());
2471
+ }
2472
+
2473
+ getEnabled() {
2474
+ return this.toArray().filter(_ref => {
2475
+ let {
2476
+ disabled
2477
+ } = _ref;
2478
+ return !disabled;
2479
+ });
2480
+ }
2481
+
2482
+ getNodeFor(id) {
2483
+ var _this$get$node$curren, _this$get;
2484
+
2485
+ return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : undefined;
2486
+ }
2487
+
2488
+ }
2489
+
2490
+ const defaultPublicContext = {
2491
+ activatorEvent: null,
2492
+ active: null,
2493
+ activeNode: null,
2494
+ activeNodeRect: null,
2495
+ collisions: null,
2496
+ containerNodeRect: null,
2497
+ draggableNodes: /*#__PURE__*/new Map(),
2498
+ droppableRects: /*#__PURE__*/new Map(),
2499
+ droppableContainers: /*#__PURE__*/new DroppableContainersMap(),
2500
+ over: null,
2501
+ dragOverlay: {
2502
+ nodeRef: {
2503
+ current: null
2504
+ },
2505
+ rect: null,
2506
+ setRef: noop
2507
+ },
2508
+ scrollableAncestors: [],
2509
+ scrollableAncestorRects: [],
2510
+ measuringConfiguration: defaultMeasuringConfiguration,
2511
+ measureDroppableContainers: noop,
2512
+ windowRect: null,
2513
+ measuringScheduled: false
2514
+ };
2515
+ const defaultInternalContext = {
2516
+ activatorEvent: null,
2517
+ activators: [],
2518
+ active: null,
2519
+ activeNodeRect: null,
2520
+ ariaDescribedById: {
2521
+ draggable: ''
2522
+ },
2523
+ dispatch: noop,
2524
+ draggableNodes: /*#__PURE__*/new Map(),
2525
+ over: null,
2526
+ measureDroppableContainers: noop
2527
+ };
2528
+ const InternalContext = /*#__PURE__*/React.createContext(defaultInternalContext);
2529
+ const PublicContext = /*#__PURE__*/React.createContext(defaultPublicContext);
2530
+
2531
+ function getInitialState() {
2532
+ return {
2533
+ draggable: {
2534
+ active: null,
2535
+ initialCoordinates: {
2536
+ x: 0,
2537
+ y: 0
2538
+ },
2539
+ nodes: new Map(),
2540
+ translate: {
2541
+ x: 0,
2542
+ y: 0
2543
+ }
2544
+ },
2545
+ droppable: {
2546
+ containers: new DroppableContainersMap()
2547
+ }
2548
+ };
2549
+ }
2550
+ function reducer(state, action) {
2551
+ switch (action.type) {
2552
+ case Action.DragStart:
2553
+ return { ...state,
2554
+ draggable: { ...state.draggable,
2555
+ initialCoordinates: action.initialCoordinates,
2556
+ active: action.active
2557
+ }
2558
+ };
2559
+
2560
+ case Action.DragMove:
2561
+ if (!state.draggable.active) {
2562
+ return state;
2563
+ }
2564
+
2565
+ return { ...state,
2566
+ draggable: { ...state.draggable,
2567
+ translate: {
2568
+ x: action.coordinates.x - state.draggable.initialCoordinates.x,
2569
+ y: action.coordinates.y - state.draggable.initialCoordinates.y
2570
+ }
2571
+ }
2572
+ };
2573
+
2574
+ case Action.DragEnd:
2575
+ case Action.DragCancel:
2576
+ return { ...state,
2577
+ draggable: { ...state.draggable,
2578
+ active: null,
2579
+ initialCoordinates: {
2580
+ x: 0,
2581
+ y: 0
2582
+ },
2583
+ translate: {
2584
+ x: 0,
2585
+ y: 0
2586
+ }
2587
+ }
2588
+ };
2589
+
2590
+ case Action.RegisterDroppable:
2591
+ {
2592
+ const {
2593
+ element
2594
+ } = action;
2595
+ const {
2596
+ id
2597
+ } = element;
2598
+ const containers = new DroppableContainersMap(state.droppable.containers);
2599
+ containers.set(id, element);
2600
+ return { ...state,
2601
+ droppable: { ...state.droppable,
2602
+ containers
2603
+ }
2604
+ };
2605
+ }
2606
+
2607
+ case Action.SetDroppableDisabled:
2608
+ {
2609
+ const {
2610
+ id,
2611
+ key,
2612
+ disabled
2613
+ } = action;
2614
+ const element = state.droppable.containers.get(id);
2615
+
2616
+ if (!element || key !== element.key) {
2617
+ return state;
2618
+ }
2619
+
2620
+ const containers = new DroppableContainersMap(state.droppable.containers);
2621
+ containers.set(id, { ...element,
2622
+ disabled
2623
+ });
2624
+ return { ...state,
2625
+ droppable: { ...state.droppable,
2626
+ containers
2627
+ }
2628
+ };
2629
+ }
2630
+
2631
+ case Action.UnregisterDroppable:
2632
+ {
2633
+ const {
2634
+ id,
2635
+ key
2636
+ } = action;
2637
+ const element = state.droppable.containers.get(id);
2638
+
2639
+ if (!element || key !== element.key) {
2640
+ return state;
2641
+ }
2642
+
2643
+ const containers = new DroppableContainersMap(state.droppable.containers);
2644
+ containers.delete(id);
2645
+ return { ...state,
2646
+ droppable: { ...state.droppable,
2647
+ containers
2648
+ }
2649
+ };
2650
+ }
2651
+
2652
+ default:
2653
+ {
2654
+ return state;
2655
+ }
2656
+ }
2657
+ }
2658
+
2659
+ function RestoreFocus(_ref) {
2660
+ let {
2661
+ disabled
2662
+ } = _ref;
2663
+ const {
2664
+ active,
2665
+ activatorEvent,
2666
+ draggableNodes
2667
+ } = React.useContext(InternalContext);
2668
+ const previousActivatorEvent = dndKitUtilities.usePrevious(activatorEvent);
2669
+ const previousActiveId = dndKitUtilities.usePrevious(active == null ? void 0 : active.id); // Restore keyboard focus on the activator node
2670
+
2671
+ React.useEffect(() => {
2672
+ if (disabled) {
2673
+ return;
2674
+ }
2675
+
2676
+ if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
2677
+ if (!dndKitUtilities.isKeyboardEvent(previousActivatorEvent)) {
2678
+ return;
2679
+ }
2680
+
2681
+ if (document.activeElement === previousActivatorEvent.target) {
2682
+ // No need to restore focus
2683
+ return;
2684
+ }
2685
+
2686
+ const draggableNode = draggableNodes.get(previousActiveId);
2687
+
2688
+ if (!draggableNode) {
2689
+ return;
2690
+ }
2691
+
2692
+ const {
2693
+ activatorNode,
2694
+ node
2695
+ } = draggableNode;
2696
+
2697
+ if (!activatorNode.current && !node.current) {
2698
+ return;
2699
+ }
2700
+
2701
+ requestAnimationFrame(() => {
2702
+ for (const element of [activatorNode.current, node.current]) {
2703
+ if (!element) {
2704
+ continue;
2705
+ }
2706
+
2707
+ const focusableNode = dndKitUtilities.findFirstFocusableNode(element);
2708
+
2709
+ if (focusableNode) {
2710
+ focusableNode.focus();
2711
+ break;
2712
+ }
2713
+ }
2714
+ });
2715
+ }
2716
+ }, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
2717
+ return null;
2718
+ }
2719
+
2720
+ function applyModifiers(modifiers, _ref) {
2721
+ let {
2722
+ transform,
2723
+ ...args
2724
+ } = _ref;
2725
+ return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
2726
+ return modifier({
2727
+ transform: accumulator,
2728
+ ...args
2729
+ });
2730
+ }, transform) : transform;
2731
+ }
2732
+
2733
+ function useMeasuringConfiguration(config) {
2734
+ return React.useMemo(() => ({
2735
+ draggable: { ...defaultMeasuringConfiguration.draggable,
2736
+ ...(config == null ? void 0 : config.draggable)
2737
+ },
2738
+ droppable: { ...defaultMeasuringConfiguration.droppable,
2739
+ ...(config == null ? void 0 : config.droppable)
2740
+ },
2741
+ dragOverlay: { ...defaultMeasuringConfiguration.dragOverlay,
2742
+ ...(config == null ? void 0 : config.dragOverlay)
2743
+ }
2744
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
2745
+ [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]);
2746
+ }
2747
+
2748
+ function useLayoutShiftScrollCompensation(_ref) {
2749
+ let {
2750
+ activeNode,
2751
+ measure,
2752
+ initialRect,
2753
+ config = true
2754
+ } = _ref;
2755
+ const initialized = React.useRef(false);
2756
+ const {
2757
+ x,
2758
+ y
2759
+ } = typeof config === 'boolean' ? {
2760
+ x: config,
2761
+ y: config
2762
+ } : config;
2763
+ dndKitUtilities.useIsomorphicLayoutEffect(() => {
2764
+ const disabled = !x && !y;
2765
+
2766
+ if (disabled || !activeNode) {
2767
+ initialized.current = false;
2768
+ return;
2769
+ }
2770
+
2771
+ if (initialized.current || !initialRect) {
2772
+ // Return early if layout shift scroll compensation was already attempted
2773
+ // or if there is no initialRect to compare to.
2774
+ return;
2775
+ } // Get the most up to date node ref for the active draggable
2776
+
2777
+
2778
+ const node = activeNode == null ? void 0 : activeNode.node.current;
2779
+
2780
+ if (!node || node.isConnected === false) {
2781
+ // Return early if there is no attached node ref or if the node is
2782
+ // disconnected from the document.
2783
+ return;
2784
+ }
2785
+
2786
+ const rect = measure(node);
2787
+ const rectDelta = getRectDelta(rect, initialRect);
2788
+
2789
+ if (!x) {
2790
+ rectDelta.x = 0;
2791
+ }
2792
+
2793
+ if (!y) {
2794
+ rectDelta.y = 0;
2795
+ } // Only perform layout shift scroll compensation once
2796
+
2797
+
2798
+ initialized.current = true;
2799
+
2800
+ if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
2801
+ const firstScrollableAncestor = getFirstScrollableAncestor(node);
2802
+
2803
+ if (firstScrollableAncestor) {
2804
+ firstScrollableAncestor.scrollBy({
2805
+ top: rectDelta.y,
2806
+ left: rectDelta.x
2807
+ });
2808
+ }
2809
+ }
2810
+ }, [activeNode, x, y, initialRect, measure]);
2811
+ }
2812
+
2813
+ const ActiveDraggableContext = /*#__PURE__*/React.createContext({ ...defaultCoordinates,
2814
+ scaleX: 1,
2815
+ scaleY: 1
2816
+ });
2817
+ var Status;
2818
+
2819
+ (function (Status) {
2820
+ Status[Status["Uninitialized"] = 0] = "Uninitialized";
2821
+ Status[Status["Initializing"] = 1] = "Initializing";
2822
+ Status[Status["Initialized"] = 2] = "Initialized";
2823
+ })(Status || (Status = {}));
2824
+
2825
+ const DndContext = /*#__PURE__*/React.memo(function DndContext(_ref) {
2826
+ var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
2827
+
2828
+ let {
2829
+ id,
2830
+ accessibility,
2831
+ autoScroll = true,
2832
+ children,
2833
+ sensors = defaultSensors,
2834
+ collisionDetection = rectIntersection,
2835
+ measuring,
2836
+ modifiers,
2837
+ ...props
2838
+ } = _ref;
2839
+ const store = React.useReducer(reducer, undefined, getInitialState);
2840
+ const [state, dispatch] = store;
2841
+ const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
2842
+ const [status, setStatus] = React.useState(Status.Uninitialized);
2843
+ const isInitialized = status === Status.Initialized;
2844
+ const {
2845
+ draggable: {
2846
+ active: activeId,
2847
+ nodes: draggableNodes,
2848
+ translate
2849
+ },
2850
+ droppable: {
2851
+ containers: droppableContainers
2852
+ }
2853
+ } = state;
2854
+ const node = activeId ? draggableNodes.get(activeId) : null;
2855
+ const activeRects = React.useRef({
2856
+ initial: null,
2857
+ translated: null
2858
+ });
2859
+ const active = React.useMemo(() => {
2860
+ var _node$data;
2861
+
2862
+ return activeId != null ? {
2863
+ id: activeId,
2864
+ // It's possible for the active node to unmount while dragging
2865
+ data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
2866
+ rect: activeRects
2867
+ } : null;
2868
+ }, [activeId, node]);
2869
+ const activeRef = React.useRef(null);
2870
+ const [activeSensor, setActiveSensor] = React.useState(null);
2871
+ const [activatorEvent, setActivatorEvent] = React.useState(null);
2872
+ const latestProps = dndKitUtilities.useLatestValue(props, Object.values(props));
2873
+ const draggableDescribedById = dndKitUtilities.useUniqueId("DndDescribedBy", id);
2874
+ const enabledDroppableContainers = React.useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
2875
+ const measuringConfiguration = useMeasuringConfiguration(measuring);
2876
+ const {
2877
+ droppableRects,
2878
+ measureDroppableContainers,
2879
+ measuringScheduled
2880
+ } = useDroppableMeasuring(enabledDroppableContainers, {
2881
+ dragging: isInitialized,
2882
+ dependencies: [translate.x, translate.y],
2883
+ config: measuringConfiguration.droppable
2884
+ });
2885
+ const activeNode = useCachedNode(draggableNodes, activeId);
2886
+ const activationCoordinates = React.useMemo(() => activatorEvent ? dndKitUtilities.getEventCoordinates(activatorEvent) : null, [activatorEvent]);
2887
+ const autoScrollOptions = getAutoScrollerOptions();
2888
+ const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
2889
+ useLayoutShiftScrollCompensation({
2890
+ activeNode: activeId ? draggableNodes.get(activeId) : null,
2891
+ config: autoScrollOptions.layoutShiftCompensation,
2892
+ initialRect: initialActiveNodeRect,
2893
+ measure: measuringConfiguration.draggable.measure
2894
+ });
2895
+ const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
2896
+ const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
2897
+ const sensorContext = React.useRef({
2898
+ activatorEvent: null,
2899
+ active: null,
2900
+ activeNode,
2901
+ collisionRect: null,
2902
+ collisions: null,
2903
+ droppableRects,
2904
+ draggableNodes,
2905
+ draggingNode: null,
2906
+ draggingNodeRect: null,
2907
+ droppableContainers,
2908
+ over: null,
2909
+ scrollableAncestors: [],
2910
+ scrollAdjustedTranslate: null
2911
+ });
2912
+ const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
2913
+ const dragOverlay = useDragOverlayMeasuring({
2914
+ measure: measuringConfiguration.dragOverlay.measure
2915
+ }); // Use the rect of the drag overlay if it is mounted
2916
+
2917
+ const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
2918
+ const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
2919
+ const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect); // The delta between the previous and new position of the draggable node
2920
+ // is only relevant when there is no drag overlay
2921
+
2922
+ const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect); // Get the window rect of the dragging node
2923
+
2924
+ const windowRect = useWindowRect(draggingNode ? dndKitUtilities.getWindow(draggingNode) : null); // Get scrollable ancestors of the dragging node
2925
+
2926
+ const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
2927
+ const scrollableAncestorRects = useRects(scrollableAncestors);
2928
+ const scrollableAncestorRectsRects = React.useMemo(() => scrollableAncestorRects.map(_ref2 => {
2929
+ let {
2930
+ rect
2931
+ } = _ref2;
2932
+ return rect;
2933
+ }), [scrollableAncestorRects]); // Apply modifiers
2934
+
2935
+ const modifiedTranslate = applyModifiers(modifiers, {
2936
+ transform: {
2937
+ x: translate.x - nodeRectDelta.x,
2938
+ y: translate.y - nodeRectDelta.y,
2939
+ scaleX: 1,
2940
+ scaleY: 1
2941
+ },
2942
+ activatorEvent,
2943
+ active,
2944
+ activeNodeRect,
2945
+ containerNodeRect,
2946
+ draggingNodeRect,
2947
+ over: sensorContext.current.over,
2948
+ overlayNodeRect: dragOverlay.rect,
2949
+ scrollableAncestors,
2950
+ scrollableAncestorRects: scrollableAncestorRectsRects,
2951
+ windowRect
2952
+ });
2953
+ const pointerCoordinates = activationCoordinates ? dndKitUtilities.add(activationCoordinates, translate) : null;
2954
+ const scrollOffsets = useScrollOffsets(scrollableAncestors); // Represents the scroll delta since dragging was initiated
2955
+
2956
+ const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets); // Represents the scroll delta since the last time the active node rect was measured
2957
+
2958
+ const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
2959
+ const scrollAdjustedTranslate = dndKitUtilities.add(modifiedTranslate, scrollAdjustment);
2960
+ const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
2961
+ const collisions = active && collisionRect ? collisionDetection({
2962
+ active,
2963
+ collisionRect,
2964
+ droppableRects,
2965
+ droppableContainers: enabledDroppableContainers,
2966
+ pointerCoordinates
2967
+ }) : null;
2968
+ const overId = getFirstCollision(collisions, 'id');
2969
+ const [over, setOver] = React.useState(null); // When there is no drag overlay used, we need to account for the
2970
+ // window scroll delta
2971
+
2972
+ const appliedTranslate = usesDragOverlay ? modifiedTranslate : dndKitUtilities.add(modifiedTranslate, activeNodeScrollDelta);
2973
+ const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
2974
+ const instantiateSensor = React.useCallback((event, _ref3) => {
2975
+ let {
2976
+ sensor: Sensor,
2977
+ options
2978
+ } = _ref3;
2979
+
2980
+ if (activeRef.current == null) {
2981
+ return;
2982
+ }
2983
+
2984
+ const activeNode = draggableNodes.get(activeRef.current);
2985
+
2986
+ if (!activeNode) {
2987
+ return;
2988
+ }
2989
+
2990
+ const activatorEvent = event.nativeEvent;
2991
+ const sensorInstance = new Sensor({
2992
+ active: activeRef.current,
2993
+ activeNode,
2994
+ event: activatorEvent,
2995
+ options,
2996
+ // Sensors need to be instantiated with refs for arguments that change over time
2997
+ // otherwise they are frozen in time with the stale arguments
2998
+ context: sensorContext,
2999
+
3000
+ onStart(initialCoordinates) {
3001
+ const id = activeRef.current;
3002
+
3003
+ if (id == null) {
3004
+ return;
3005
+ }
3006
+
3007
+ const draggableNode = draggableNodes.get(id);
3008
+
3009
+ if (!draggableNode) {
3010
+ return;
3011
+ }
3012
+
3013
+ const {
3014
+ onDragStart
3015
+ } = latestProps.current;
3016
+ const event = {
3017
+ active: {
3018
+ id,
3019
+ data: draggableNode.data,
3020
+ rect: activeRects
3021
+ }
3022
+ };
3023
+ reactDom.unstable_batchedUpdates(() => {
3024
+ onDragStart == null ? void 0 : onDragStart(event);
3025
+ setStatus(Status.Initializing);
3026
+ dispatch({
3027
+ type: Action.DragStart,
3028
+ initialCoordinates,
3029
+ active: id
3030
+ });
3031
+ dispatchMonitorEvent({
3032
+ type: 'onDragStart',
3033
+ event
3034
+ });
3035
+ });
3036
+ },
3037
+
3038
+ onMove(coordinates) {
3039
+ dispatch({
3040
+ type: Action.DragMove,
3041
+ coordinates
3042
+ });
3043
+ },
3044
+
3045
+ onEnd: createHandler(Action.DragEnd),
3046
+ onCancel: createHandler(Action.DragCancel)
3047
+ });
3048
+ reactDom.unstable_batchedUpdates(() => {
3049
+ setActiveSensor(sensorInstance);
3050
+ setActivatorEvent(event.nativeEvent);
3051
+ });
3052
+
3053
+ function createHandler(type) {
3054
+ return async function handler() {
3055
+ const {
3056
+ active,
3057
+ collisions,
3058
+ over,
3059
+ scrollAdjustedTranslate
3060
+ } = sensorContext.current;
3061
+ let event = null;
3062
+
3063
+ if (active && scrollAdjustedTranslate) {
3064
+ const {
3065
+ cancelDrop
3066
+ } = latestProps.current;
3067
+ event = {
3068
+ activatorEvent,
3069
+ active: active,
3070
+ collisions,
3071
+ delta: scrollAdjustedTranslate,
3072
+ over
3073
+ };
3074
+
3075
+ if (type === Action.DragEnd && typeof cancelDrop === 'function') {
3076
+ const shouldCancel = await Promise.resolve(cancelDrop(event));
3077
+
3078
+ if (shouldCancel) {
3079
+ type = Action.DragCancel;
3080
+ }
3081
+ }
3082
+ }
3083
+
3084
+ activeRef.current = null;
3085
+ reactDom.unstable_batchedUpdates(() => {
3086
+ dispatch({
3087
+ type
3088
+ });
3089
+ setStatus(Status.Uninitialized);
3090
+ setOver(null);
3091
+ setActiveSensor(null);
3092
+ setActivatorEvent(null);
3093
+ const eventName = type === Action.DragEnd ? 'onDragEnd' : 'onDragCancel';
3094
+
3095
+ if (event) {
3096
+ const handler = latestProps.current[eventName];
3097
+ handler == null ? void 0 : handler(event);
3098
+ dispatchMonitorEvent({
3099
+ type: eventName,
3100
+ event
3101
+ });
3102
+ }
3103
+ });
3104
+ };
3105
+ }
3106
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3107
+ [draggableNodes]);
3108
+ const bindActivatorToSensorInstantiator = React.useCallback((handler, sensor) => {
3109
+ return (event, active) => {
3110
+ const nativeEvent = event.nativeEvent;
3111
+ const activeDraggableNode = draggableNodes.get(active);
3112
+
3113
+ if ( // Another sensor is already instantiating
3114
+ activeRef.current !== null || // No active draggable
3115
+ !activeDraggableNode || // Event has already been captured
3116
+ nativeEvent.dndKit || nativeEvent.defaultPrevented) {
3117
+ return;
3118
+ }
3119
+
3120
+ const activationContext = {
3121
+ active: activeDraggableNode
3122
+ };
3123
+ const shouldActivate = handler(event, sensor.options, activationContext);
3124
+
3125
+ if (shouldActivate === true) {
3126
+ nativeEvent.dndKit = {
3127
+ capturedBy: sensor.sensor
3128
+ };
3129
+ activeRef.current = active;
3130
+ instantiateSensor(event, sensor);
3131
+ }
3132
+ };
3133
+ }, [draggableNodes, instantiateSensor]);
3134
+ const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
3135
+ useSensorSetup(sensors);
3136
+ dndKitUtilities.useIsomorphicLayoutEffect(() => {
3137
+ if (activeNodeRect && status === Status.Initializing) {
3138
+ setStatus(Status.Initialized);
3139
+ }
3140
+ }, [activeNodeRect, status]);
3141
+ React.useEffect(() => {
3142
+ const {
3143
+ onDragMove
3144
+ } = latestProps.current;
3145
+ const {
3146
+ active,
3147
+ activatorEvent,
3148
+ collisions,
3149
+ over
3150
+ } = sensorContext.current;
3151
+
3152
+ if (!active || !activatorEvent) {
3153
+ return;
3154
+ }
3155
+
3156
+ const event = {
3157
+ active,
3158
+ activatorEvent,
3159
+ collisions,
3160
+ delta: {
3161
+ x: scrollAdjustedTranslate.x,
3162
+ y: scrollAdjustedTranslate.y
3163
+ },
3164
+ over
3165
+ };
3166
+ reactDom.unstable_batchedUpdates(() => {
3167
+ onDragMove == null ? void 0 : onDragMove(event);
3168
+ dispatchMonitorEvent({
3169
+ type: 'onDragMove',
3170
+ event
3171
+ });
3172
+ });
3173
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3174
+ [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]);
3175
+ React.useEffect(() => {
3176
+ const {
3177
+ active,
3178
+ activatorEvent,
3179
+ collisions,
3180
+ droppableContainers,
3181
+ scrollAdjustedTranslate
3182
+ } = sensorContext.current;
3183
+
3184
+ if (!active || activeRef.current == null || !activatorEvent || !scrollAdjustedTranslate) {
3185
+ return;
3186
+ }
3187
+
3188
+ const {
3189
+ onDragOver
3190
+ } = latestProps.current;
3191
+ const overContainer = droppableContainers.get(overId);
3192
+ const over = overContainer && overContainer.rect.current ? {
3193
+ id: overContainer.id,
3194
+ rect: overContainer.rect.current,
3195
+ data: overContainer.data,
3196
+ disabled: overContainer.disabled
3197
+ } : null;
3198
+ const event = {
3199
+ active,
3200
+ activatorEvent,
3201
+ collisions,
3202
+ delta: {
3203
+ x: scrollAdjustedTranslate.x,
3204
+ y: scrollAdjustedTranslate.y
3205
+ },
3206
+ over
3207
+ };
3208
+ reactDom.unstable_batchedUpdates(() => {
3209
+ setOver(over);
3210
+ onDragOver == null ? void 0 : onDragOver(event);
3211
+ dispatchMonitorEvent({
3212
+ type: 'onDragOver',
3213
+ event
3214
+ });
3215
+ });
3216
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3217
+ [overId]);
3218
+ dndKitUtilities.useIsomorphicLayoutEffect(() => {
3219
+ sensorContext.current = {
3220
+ activatorEvent,
3221
+ active,
3222
+ activeNode,
3223
+ collisionRect,
3224
+ collisions,
3225
+ droppableRects,
3226
+ draggableNodes,
3227
+ draggingNode,
3228
+ draggingNodeRect,
3229
+ droppableContainers,
3230
+ over,
3231
+ scrollableAncestors,
3232
+ scrollAdjustedTranslate
3233
+ };
3234
+ activeRects.current = {
3235
+ initial: draggingNodeRect,
3236
+ translated: collisionRect
3237
+ };
3238
+ }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
3239
+ useAutoScroller({ ...autoScrollOptions,
3240
+ delta: translate,
3241
+ draggingRect: collisionRect,
3242
+ pointerCoordinates,
3243
+ scrollableAncestors,
3244
+ scrollableAncestorRects
3245
+ });
3246
+ const publicContext = React.useMemo(() => {
3247
+ const context = {
3248
+ active,
3249
+ activeNode,
3250
+ activeNodeRect,
3251
+ activatorEvent,
3252
+ collisions,
3253
+ containerNodeRect,
3254
+ dragOverlay,
3255
+ draggableNodes,
3256
+ droppableContainers,
3257
+ droppableRects,
3258
+ over,
3259
+ measureDroppableContainers,
3260
+ scrollableAncestors,
3261
+ scrollableAncestorRects: scrollableAncestorRectsRects,
3262
+ measuringConfiguration,
3263
+ measuringScheduled,
3264
+ windowRect
3265
+ };
3266
+ return context;
3267
+ }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
3268
+ const internalContext = React.useMemo(() => {
3269
+ const context = {
3270
+ activatorEvent,
3271
+ activators,
3272
+ active,
3273
+ activeNodeRect,
3274
+ ariaDescribedById: {
3275
+ draggable: draggableDescribedById
3276
+ },
3277
+ dispatch,
3278
+ draggableNodes,
3279
+ over,
3280
+ measureDroppableContainers
3281
+ };
3282
+ return context;
3283
+ }, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
3284
+ return React__default.createElement(DndMonitorContext.Provider, {
3285
+ value: registerMonitorListener
3286
+ }, React__default.createElement(InternalContext.Provider, {
3287
+ value: internalContext
3288
+ }, React__default.createElement(PublicContext.Provider, {
3289
+ value: publicContext
3290
+ }, React__default.createElement(ActiveDraggableContext.Provider, {
3291
+ value: transform
3292
+ }, children)), React__default.createElement(RestoreFocus, {
3293
+ disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
3294
+ })), React__default.createElement(Accessibility, { ...accessibility,
3295
+ hiddenTextDescribedById: draggableDescribedById
3296
+ }));
3297
+
3298
+ function getAutoScrollerOptions() {
3299
+ const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
3300
+ const autoScrollGloballyDisabled = typeof autoScroll === 'object' ? autoScroll.enabled === false : autoScroll === false;
3301
+ const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
3302
+
3303
+ if (typeof autoScroll === 'object') {
3304
+ return { ...autoScroll,
3305
+ enabled
3306
+ };
3307
+ }
3308
+
3309
+ return {
3310
+ enabled
3311
+ };
3312
+ }
3313
+ });
3314
+
3315
+ const NullContext = /*#__PURE__*/React.createContext(null);
3316
+ const defaultRole = 'button';
3317
+ const ID_PREFIX = 'Droppable';
3318
+ function useDraggable(_ref) {
3319
+ let {
3320
+ id,
3321
+ data,
3322
+ disabled = false,
3323
+ attributes
3324
+ } = _ref;
3325
+ const key = dndKitUtilities.useUniqueId(ID_PREFIX);
3326
+ const {
3327
+ activators,
3328
+ activatorEvent,
3329
+ active,
3330
+ activeNodeRect,
3331
+ ariaDescribedById,
3332
+ draggableNodes,
3333
+ over
3334
+ } = React.useContext(InternalContext);
3335
+ const {
3336
+ role = defaultRole,
3337
+ roleDescription = 'draggable',
3338
+ tabIndex = 0
3339
+ } = attributes != null ? attributes : {};
3340
+ const isDragging = (active == null ? void 0 : active.id) === id;
3341
+ const transform = React.useContext(isDragging ? ActiveDraggableContext : NullContext);
3342
+ const [node, setNodeRef] = dndKitUtilities.useNodeRef();
3343
+ const [activatorNode, setActivatorNodeRef] = dndKitUtilities.useNodeRef();
3344
+ const listeners = useSyntheticListeners(activators, id);
3345
+ const dataRef = dndKitUtilities.useLatestValue(data);
3346
+ dndKitUtilities.useIsomorphicLayoutEffect(() => {
3347
+ draggableNodes.set(id, {
3348
+ id,
3349
+ key,
3350
+ node,
3351
+ activatorNode,
3352
+ data: dataRef
3353
+ });
3354
+ return () => {
3355
+ const node = draggableNodes.get(id);
3356
+
3357
+ if (node && node.key === key) {
3358
+ draggableNodes.delete(id);
3359
+ }
3360
+ };
3361
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3362
+ [draggableNodes, id]);
3363
+ const memoizedAttributes = React.useMemo(() => ({
3364
+ role,
3365
+ tabIndex,
3366
+ 'aria-disabled': disabled,
3367
+ 'aria-pressed': isDragging && role === defaultRole ? true : undefined,
3368
+ 'aria-roledescription': roleDescription,
3369
+ 'aria-describedby': ariaDescribedById.draggable
3370
+ }), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
3371
+ return {
3372
+ active,
3373
+ activatorEvent,
3374
+ activeNodeRect,
3375
+ attributes: memoizedAttributes,
3376
+ isDragging,
3377
+ listeners: disabled ? undefined : listeners,
3378
+ node,
3379
+ over,
3380
+ setNodeRef,
3381
+ setActivatorNodeRef,
3382
+ transform
3383
+ };
3384
+ }
3385
+
3386
+ function useDndContext() {
3387
+ return React.useContext(PublicContext);
3388
+ }
3389
+
3390
+ const ID_PREFIX$1 = 'Droppable';
3391
+ const defaultResizeObserverConfig = {
3392
+ timeout: 25
3393
+ };
3394
+ function useDroppable(_ref) {
3395
+ let {
3396
+ data,
3397
+ disabled = false,
3398
+ id,
3399
+ resizeObserverConfig
3400
+ } = _ref;
3401
+ const key = dndKitUtilities.useUniqueId(ID_PREFIX$1);
3402
+ const {
3403
+ active,
3404
+ dispatch,
3405
+ over,
3406
+ measureDroppableContainers
3407
+ } = React.useContext(InternalContext);
3408
+ const previous = React.useRef({
3409
+ disabled
3410
+ });
3411
+ const resizeObserverConnected = React.useRef(false);
3412
+ const rect = React.useRef(null);
3413
+ const callbackId = React.useRef(null);
3414
+ const {
3415
+ disabled: resizeObserverDisabled,
3416
+ updateMeasurementsFor,
3417
+ timeout: resizeObserverTimeout
3418
+ } = { ...defaultResizeObserverConfig,
3419
+ ...resizeObserverConfig
3420
+ };
3421
+ const ids = dndKitUtilities.useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
3422
+ const handleResize = React.useCallback(() => {
3423
+ if (!resizeObserverConnected.current) {
3424
+ // ResizeObserver invokes the `handleResize` callback as soon as `observe` is called,
3425
+ // assuming the element is rendered and displayed.
3426
+ resizeObserverConnected.current = true;
3427
+ return;
3428
+ }
3429
+
3430
+ if (callbackId.current != null) {
3431
+ clearTimeout(callbackId.current);
3432
+ }
3433
+
3434
+ callbackId.current = setTimeout(() => {
3435
+ measureDroppableContainers(Array.isArray(ids.current) ? ids.current : [ids.current]);
3436
+ callbackId.current = null;
3437
+ }, resizeObserverTimeout);
3438
+ }, //eslint-disable-next-line react-hooks/exhaustive-deps
3439
+ [resizeObserverTimeout]);
3440
+ const resizeObserver = useResizeObserver({
3441
+ callback: handleResize,
3442
+ disabled: resizeObserverDisabled || !active
3443
+ });
3444
+ const handleNodeChange = React.useCallback((newElement, previousElement) => {
3445
+ if (!resizeObserver) {
3446
+ return;
3447
+ }
3448
+
3449
+ if (previousElement) {
3450
+ resizeObserver.unobserve(previousElement);
3451
+ resizeObserverConnected.current = false;
3452
+ }
3453
+
3454
+ if (newElement) {
3455
+ resizeObserver.observe(newElement);
3456
+ }
3457
+ }, [resizeObserver]);
3458
+ const [nodeRef, setNodeRef] = dndKitUtilities.useNodeRef(handleNodeChange);
3459
+ const dataRef = dndKitUtilities.useLatestValue(data);
3460
+ React.useEffect(() => {
3461
+ if (!resizeObserver || !nodeRef.current) {
3462
+ return;
3463
+ }
3464
+
3465
+ resizeObserver.disconnect();
3466
+ resizeObserverConnected.current = false;
3467
+ resizeObserver.observe(nodeRef.current);
3468
+ }, [nodeRef, resizeObserver]);
3469
+ dndKitUtilities.useIsomorphicLayoutEffect(() => {
3470
+ dispatch({
3471
+ type: Action.RegisterDroppable,
3472
+ element: {
3473
+ id,
3474
+ key,
3475
+ disabled,
3476
+ node: nodeRef,
3477
+ rect,
3478
+ data: dataRef
3479
+ }
3480
+ });
3481
+ return () => dispatch({
3482
+ type: Action.UnregisterDroppable,
3483
+ key,
3484
+ id
3485
+ });
3486
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
3487
+ [id]);
3488
+ React.useEffect(() => {
3489
+ if (disabled !== previous.current.disabled) {
3490
+ dispatch({
3491
+ type: Action.SetDroppableDisabled,
3492
+ id,
3493
+ key,
3494
+ disabled
3495
+ });
3496
+ previous.current.disabled = disabled;
3497
+ }
3498
+ }, [id, key, disabled, dispatch]);
3499
+ return {
3500
+ active,
3501
+ rect,
3502
+ isOver: (over == null ? void 0 : over.id) === id,
3503
+ node: nodeRef,
3504
+ over,
3505
+ setNodeRef
3506
+ };
3507
+ }
3508
+
3509
+ function AnimationManager(_ref) {
3510
+ let {
3511
+ animation,
3512
+ children
3513
+ } = _ref;
3514
+ const [clonedChildren, setClonedChildren] = React.useState(null);
3515
+ const [element, setElement] = React.useState(null);
3516
+ const previousChildren = dndKitUtilities.usePrevious(children);
3517
+
3518
+ if (!children && !clonedChildren && previousChildren) {
3519
+ setClonedChildren(previousChildren);
3520
+ }
3521
+
3522
+ dndKitUtilities.useIsomorphicLayoutEffect(() => {
3523
+ if (!element) {
3524
+ return;
3525
+ }
3526
+
3527
+ const key = clonedChildren == null ? void 0 : clonedChildren.key;
3528
+ const id = clonedChildren == null ? void 0 : clonedChildren.props.id;
3529
+
3530
+ if (key == null || id == null) {
3531
+ setClonedChildren(null);
3532
+ return;
3533
+ }
3534
+
3535
+ Promise.resolve(animation(id, element)).then(() => {
3536
+ setClonedChildren(null);
3537
+ });
3538
+ }, [animation, clonedChildren, element]);
3539
+ return React__default.createElement(React__default.Fragment, null, children, clonedChildren ? React.cloneElement(clonedChildren, {
3540
+ ref: setElement
3541
+ }) : null);
3542
+ }
3543
+
3544
+ const defaultTransform = {
3545
+ x: 0,
3546
+ y: 0,
3547
+ scaleX: 1,
3548
+ scaleY: 1
3549
+ };
3550
+ function NullifiedContextProvider(_ref) {
3551
+ let {
3552
+ children
3553
+ } = _ref;
3554
+ return React__default.createElement(InternalContext.Provider, {
3555
+ value: defaultInternalContext
3556
+ }, React__default.createElement(ActiveDraggableContext.Provider, {
3557
+ value: defaultTransform
3558
+ }, children));
3559
+ }
3560
+
3561
+ const baseStyles = {
3562
+ position: 'fixed',
3563
+ touchAction: 'none'
3564
+ };
3565
+
3566
+ const defaultTransition = activatorEvent => {
3567
+ const isKeyboardActivator = dndKitUtilities.isKeyboardEvent(activatorEvent);
3568
+ return isKeyboardActivator ? 'transform 250ms ease' : undefined;
3569
+ };
3570
+
3571
+ const PositionedOverlay = /*#__PURE__*/React.forwardRef((_ref, ref) => {
3572
+ let {
3573
+ as,
3574
+ activatorEvent,
3575
+ adjustScale,
3576
+ children,
3577
+ className,
3578
+ rect,
3579
+ style,
3580
+ transform,
3581
+ transition = defaultTransition
3582
+ } = _ref;
3583
+
3584
+ if (!rect) {
3585
+ return null;
3586
+ }
3587
+
3588
+ const scaleAdjustedTransform = adjustScale ? transform : { ...transform,
3589
+ scaleX: 1,
3590
+ scaleY: 1
3591
+ };
3592
+ const styles = { ...baseStyles,
3593
+ width: rect.width,
3594
+ height: rect.height,
3595
+ top: rect.top,
3596
+ left: rect.left,
3597
+ transform: dndKitUtilities.CSS.Transform.toString(scaleAdjustedTransform),
3598
+ transformOrigin: adjustScale && activatorEvent ? getRelativeTransformOrigin(activatorEvent, rect) : undefined,
3599
+ transition: typeof transition === 'function' ? transition(activatorEvent) : transition,
3600
+ ...style
3601
+ };
3602
+ return React__default.createElement(as, {
3603
+ className,
3604
+ style: styles,
3605
+ ref
3606
+ }, children);
3607
+ });
3608
+
3609
+ const defaultDropAnimationSideEffects = options => _ref => {
3610
+ let {
3611
+ active,
3612
+ dragOverlay
3613
+ } = _ref;
3614
+ const originalStyles = {};
3615
+ const {
3616
+ styles,
3617
+ className
3618
+ } = options;
3619
+
3620
+ if (styles != null && styles.active) {
3621
+ for (const [key, value] of Object.entries(styles.active)) {
3622
+ if (value === undefined) {
3623
+ continue;
3624
+ }
3625
+
3626
+ originalStyles[key] = active.node.style.getPropertyValue(key);
3627
+ active.node.style.setProperty(key, value);
3628
+ }
3629
+ }
3630
+
3631
+ if (styles != null && styles.dragOverlay) {
3632
+ for (const [key, value] of Object.entries(styles.dragOverlay)) {
3633
+ if (value === undefined) {
3634
+ continue;
3635
+ }
3636
+
3637
+ dragOverlay.node.style.setProperty(key, value);
3638
+ }
3639
+ }
3640
+
3641
+ if (className != null && className.active) {
3642
+ active.node.classList.add(className.active);
3643
+ }
3644
+
3645
+ if (className != null && className.dragOverlay) {
3646
+ dragOverlay.node.classList.add(className.dragOverlay);
3647
+ }
3648
+
3649
+ return function cleanup() {
3650
+ for (const [key, value] of Object.entries(originalStyles)) {
3651
+ active.node.style.setProperty(key, value);
3652
+ }
3653
+
3654
+ if (className != null && className.active) {
3655
+ active.node.classList.remove(className.active);
3656
+ }
3657
+ };
3658
+ };
3659
+
3660
+ const defaultKeyframeResolver = _ref2 => {
3661
+ let {
3662
+ transform: {
3663
+ initial,
3664
+ final
3665
+ }
3666
+ } = _ref2;
3667
+ return [{
3668
+ transform: dndKitUtilities.CSS.Transform.toString(initial)
3669
+ }, {
3670
+ transform: dndKitUtilities.CSS.Transform.toString(final)
3671
+ }];
3672
+ };
3673
+
3674
+ const defaultDropAnimationConfiguration = {
3675
+ duration: 250,
3676
+ easing: 'ease',
3677
+ keyframes: defaultKeyframeResolver,
3678
+ sideEffects: /*#__PURE__*/defaultDropAnimationSideEffects({
3679
+ styles: {
3680
+ active: {
3681
+ opacity: '0'
3682
+ }
3683
+ }
3684
+ })
3685
+ };
3686
+ function useDropAnimation(_ref3) {
3687
+ let {
3688
+ config,
3689
+ draggableNodes,
3690
+ droppableContainers,
3691
+ measuringConfiguration
3692
+ } = _ref3;
3693
+ return dndKitUtilities.useEvent((id, node) => {
3694
+ if (config === null) {
3695
+ return;
3696
+ }
3697
+
3698
+ const activeDraggable = draggableNodes.get(id);
3699
+
3700
+ if (!activeDraggable) {
3701
+ return;
3702
+ }
3703
+
3704
+ const activeNode = activeDraggable.node.current;
3705
+
3706
+ if (!activeNode) {
3707
+ return;
3708
+ }
3709
+
3710
+ const measurableNode = getMeasurableNode(node);
3711
+
3712
+ if (!measurableNode) {
3713
+ return;
3714
+ }
3715
+
3716
+ const {
3717
+ transform
3718
+ } = dndKitUtilities.getWindow(node).getComputedStyle(node);
3719
+ const parsedTransform = parseTransform(transform);
3720
+
3721
+ if (!parsedTransform) {
3722
+ return;
3723
+ }
3724
+
3725
+ const animation = typeof config === 'function' ? config : createDefaultDropAnimation(config);
3726
+ scrollIntoViewIfNeeded(activeNode, measuringConfiguration.draggable.measure);
3727
+ return animation({
3728
+ active: {
3729
+ id,
3730
+ data: activeDraggable.data,
3731
+ node: activeNode,
3732
+ rect: measuringConfiguration.draggable.measure(activeNode)
3733
+ },
3734
+ draggableNodes,
3735
+ dragOverlay: {
3736
+ node,
3737
+ rect: measuringConfiguration.dragOverlay.measure(measurableNode)
3738
+ },
3739
+ droppableContainers,
3740
+ measuringConfiguration,
3741
+ transform: parsedTransform
3742
+ });
3743
+ });
3744
+ }
3745
+
3746
+ function createDefaultDropAnimation(options) {
3747
+ const {
3748
+ duration,
3749
+ easing,
3750
+ sideEffects,
3751
+ keyframes
3752
+ } = { ...defaultDropAnimationConfiguration,
3753
+ ...options
3754
+ };
3755
+ return _ref4 => {
3756
+ let {
3757
+ active,
3758
+ dragOverlay,
3759
+ transform,
3760
+ ...rest
3761
+ } = _ref4;
3762
+
3763
+ if (!duration) {
3764
+ // Do not animate if animation duration is zero.
3765
+ return;
3766
+ }
3767
+
3768
+ const delta = {
3769
+ x: dragOverlay.rect.left - active.rect.left,
3770
+ y: dragOverlay.rect.top - active.rect.top
3771
+ };
3772
+ const scale = {
3773
+ scaleX: transform.scaleX !== 1 ? active.rect.width * transform.scaleX / dragOverlay.rect.width : 1,
3774
+ scaleY: transform.scaleY !== 1 ? active.rect.height * transform.scaleY / dragOverlay.rect.height : 1
3775
+ };
3776
+ const finalTransform = {
3777
+ x: transform.x - delta.x,
3778
+ y: transform.y - delta.y,
3779
+ ...scale
3780
+ };
3781
+ const animationKeyframes = keyframes({ ...rest,
3782
+ active,
3783
+ dragOverlay,
3784
+ transform: {
3785
+ initial: transform,
3786
+ final: finalTransform
3787
+ }
3788
+ });
3789
+ const [firstKeyframe] = animationKeyframes;
3790
+ const lastKeyframe = animationKeyframes[animationKeyframes.length - 1];
3791
+
3792
+ if (JSON.stringify(firstKeyframe) === JSON.stringify(lastKeyframe)) {
3793
+ // The start and end keyframes are the same, infer that there is no animation needed.
3794
+ return;
3795
+ }
3796
+
3797
+ const cleanup = sideEffects == null ? void 0 : sideEffects({
3798
+ active,
3799
+ dragOverlay,
3800
+ ...rest
3801
+ });
3802
+ const animation = dragOverlay.node.animate(animationKeyframes, {
3803
+ duration,
3804
+ easing,
3805
+ fill: 'forwards'
3806
+ });
3807
+ return new Promise(resolve => {
3808
+ animation.onfinish = () => {
3809
+ cleanup == null ? void 0 : cleanup();
3810
+ resolve();
3811
+ };
3812
+ });
3813
+ };
3814
+ }
3815
+
3816
+ let key = 0;
3817
+ function useKey(id) {
3818
+ return React.useMemo(() => {
3819
+ if (id == null) {
3820
+ return;
3821
+ }
3822
+
3823
+ key++;
3824
+ return key;
3825
+ }, [id]);
3826
+ }
3827
+
3828
+ const DragOverlay = /*#__PURE__*/React__default.memo(_ref => {
3829
+ let {
3830
+ adjustScale = false,
3831
+ children,
3832
+ dropAnimation: dropAnimationConfig,
3833
+ style,
3834
+ transition,
3835
+ modifiers,
3836
+ wrapperElement = 'div',
3837
+ className,
3838
+ zIndex = 999
3839
+ } = _ref;
3840
+ const {
3841
+ activatorEvent,
3842
+ active,
3843
+ activeNodeRect,
3844
+ containerNodeRect,
3845
+ draggableNodes,
3846
+ droppableContainers,
3847
+ dragOverlay,
3848
+ over,
3849
+ measuringConfiguration,
3850
+ scrollableAncestors,
3851
+ scrollableAncestorRects,
3852
+ windowRect
3853
+ } = useDndContext();
3854
+ const transform = React.useContext(ActiveDraggableContext);
3855
+ const key = useKey(active == null ? void 0 : active.id);
3856
+ const modifiedTransform = applyModifiers(modifiers, {
3857
+ activatorEvent,
3858
+ active,
3859
+ activeNodeRect,
3860
+ containerNodeRect,
3861
+ draggingNodeRect: dragOverlay.rect,
3862
+ over,
3863
+ overlayNodeRect: dragOverlay.rect,
3864
+ scrollableAncestors,
3865
+ scrollableAncestorRects,
3866
+ transform,
3867
+ windowRect
3868
+ });
3869
+ const initialRect = useInitialValue(activeNodeRect);
3870
+ const dropAnimation = useDropAnimation({
3871
+ config: dropAnimationConfig,
3872
+ draggableNodes,
3873
+ droppableContainers,
3874
+ measuringConfiguration
3875
+ }); // We need to wait for the active node to be measured before connecting the drag overlay ref
3876
+ // otherwise collisions can be computed against a mispositioned drag overlay
3877
+
3878
+ const ref = initialRect ? dragOverlay.setRef : undefined;
3879
+ return React__default.createElement(NullifiedContextProvider, null, React__default.createElement(AnimationManager, {
3880
+ animation: dropAnimation
3881
+ }, active && key ? React__default.createElement(PositionedOverlay, {
3882
+ key: key,
3883
+ id: active.id,
3884
+ ref: ref,
3885
+ as: wrapperElement,
3886
+ activatorEvent: activatorEvent,
3887
+ adjustScale: adjustScale,
3888
+ className: className,
3889
+ transition: transition,
3890
+ rect: initialRect,
3891
+ style: {
3892
+ zIndex,
3893
+ ...style
3894
+ },
3895
+ transform: modifiedTransform
3896
+ }, children) : null));
3897
+ });
3898
+
3899
+ exports.DndContext = DndContext;
3900
+ exports.DragOverlay = DragOverlay;
3901
+ exports.KeyboardSensor = KeyboardSensor;
3902
+ exports.MouseSensor = MouseSensor;
3903
+ exports.PointerSensor = PointerSensor;
3904
+ exports.TouchSensor = TouchSensor;
3905
+ exports.applyModifiers = applyModifiers;
3906
+ exports.closestCenter = closestCenter;
3907
+ exports.closestCorners = closestCorners;
3908
+ exports.defaultAnnouncements = defaultAnnouncements;
3909
+ exports.defaultCoordinates = defaultCoordinates;
3910
+ exports.defaultDropAnimation = defaultDropAnimationConfiguration;
3911
+ exports.defaultDropAnimationSideEffects = defaultDropAnimationSideEffects;
3912
+ exports.defaultScreenReaderInstructions = defaultScreenReaderInstructions;
3913
+ exports.getClientRect = getClientRect;
3914
+ exports.getFirstCollision = getFirstCollision;
3915
+ exports.getScrollableAncestors = getScrollableAncestors;
3916
+ exports.pointerWithin = pointerWithin;
3917
+ exports.rectIntersection = rectIntersection;
3918
+ exports.useDndContext = useDndContext;
3919
+ exports.useDndMonitor = useDndMonitor;
3920
+ exports.useDraggable = useDraggable;
3921
+ exports.useDroppable = useDroppable;
3922
+ exports.useSensor = useSensor;
3923
+ exports.useSensors = useSensors;
3924
+ //# sourceMappingURL=dnd-kit-core.cjs.development.js.map