dune-react 0.0.22 → 0.0.24

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 (131) hide show
  1. package/dist/components/puck-base/image.js +1 -1
  2. package/dist/components/puck-block/banner-sections/css-marquee-banner/css-marquee-banner.js +13 -13
  3. package/dist/components/puck-block/banner-sections/dual-row-marquee/dual-row-marquee.js +77 -53
  4. package/dist/components/puck-block/banner-sections/scroll-driven-marquee/scroll-driven-marquee.js +8 -6
  5. package/dist/components/puck-block/banner-sections/scroll-parallax-text/scroll-parallax-text.js +3 -1
  6. package/dist/components/puck-block/contact-sections/contact-cards-grid/contact-cards-grid.js +1 -1
  7. package/dist/components/puck-block/contact-sections/form-with-media/form-with-media.js +1 -1
  8. package/dist/components/puck-block/contact-sections/header-form-cards/header-form-cards.js +1 -1
  9. package/dist/components/puck-block/contact-sections/header-info-fullwidth/header-info-fullwidth.js +2 -2
  10. package/dist/components/puck-block/contact-sections/info-cards-media/info-cards-media.js +2 -2
  11. package/dist/components/puck-block/contact-sections/split-info-form/split-info-form.js +1 -1
  12. package/dist/components/puck-block/contact-sections/tab-locations/tab-locations.js +71 -55
  13. package/dist/components/puck-block/cta-sections/mouse-track-cta/mouse-track-cta.js +4 -4
  14. package/dist/components/puck-block/cta-sections/side-media-cta/side-media-cta.js +1 -1
  15. package/dist/components/puck-block/cta-sections/text-block-cta/text-block-cta.js +2 -2
  16. package/dist/components/puck-block/feature-sections/feature-cards-grid/component.js +1 -1
  17. package/dist/components/puck-block/feature-sections/feature-list-split/component.js +1 -1
  18. package/dist/components/puck-block/feature-sections/tab-feature/component.js +4 -4
  19. package/dist/components/puck-block/feature-sections/text-media-split/component.js +1 -1
  20. package/dist/components/puck-block/footer-sections/centered-minimal-footer/centered-minimal-footer.js +72 -18
  21. package/dist/components/puck-block/footer-sections/centered-minimal-footer/index.d.ts +79 -0
  22. package/dist/components/puck-block/footer-sections/centered-minimal-footer/index.js +43 -1
  23. package/dist/components/puck-block/footer-sections/compact-newsletter-footer/index.d.ts +41 -0
  24. package/dist/components/puck-block/footer-sections/contact-links-footer/contact-links-footer.js +4 -3
  25. package/dist/components/puck-block/footer-sections/contact-links-footer/index.d.ts +86 -0
  26. package/dist/components/puck-block/footer-sections/contact-links-footer/index.js +1 -1
  27. package/dist/components/puck-block/footer-sections/cta-links-footer/cta-links-footer.js +3 -2
  28. package/dist/components/puck-block/footer-sections/cta-links-footer/index.d.ts +37 -0
  29. package/dist/components/puck-block/footer-sections/cta-links-footer/index.js +1 -1
  30. package/dist/components/puck-block/footer-sections/links-newsletter-footer/index.d.ts +54 -0
  31. package/dist/components/puck-block/footer-sections/newsletter-links-footer/index.d.ts +41 -0
  32. package/dist/components/puck-block/footer-sections/newsletter-top-links-footer/index.d.ts +54 -0
  33. package/dist/components/puck-block/footer-sections/props.d.ts +3 -0
  34. package/dist/components/puck-block/gallery-sections/fullscreen-portfolio/fullscreen-portfolio.js +1 -1
  35. package/dist/components/puck-block/gallery-sections/image-carousel/index.d.ts +14 -1
  36. package/dist/components/puck-block/gallery-sections/interactive-portfolio/interactive-portfolio.js +166 -105
  37. package/dist/components/puck-block/gallery-sections/masonry-grid/index.d.ts +17 -1
  38. package/dist/components/puck-block/gallery-sections/masonry-grid/masonry-grid.js +56 -31
  39. package/dist/components/puck-block/gallery-sections/portfolio-cards/index.d.ts +17 -1
  40. package/dist/components/puck-block/gallery-sections/portfolio-cards/portfolio-cards.js +41 -13
  41. package/dist/components/puck-block/gallery-sections/portfolio-divider/portfolio-divider.js +1 -1
  42. package/dist/components/puck-block/gallery-sections/props.d.ts +42 -3
  43. package/dist/components/puck-block/gallery-sections/props.js +24 -6
  44. package/dist/components/puck-block/gallery-sections/scroll-parallax/scroll-parallax.js +71 -22
  45. package/dist/components/puck-block/gallery-sections/scroll-parallax-portfolio/scroll-parallax-portfolio.js +284 -159
  46. package/dist/components/puck-block/gallery-sections/split-carousel/index.d.ts +11 -1
  47. package/dist/components/puck-block/gallery-sections/static-grid/index.d.ts +17 -1
  48. package/dist/components/puck-block/header-sections/centered-navbar/centered-navbar.js +95 -14
  49. package/dist/components/puck-block/header-sections/drawer-navbar/drawer-navbar.js +4 -3
  50. package/dist/components/puck-block/header-sections/floating-bordered-navbar/floating-bordered-navbar.js +5 -4
  51. package/dist/components/puck-block/header-sections/fullscreen-overlay-navbar/fullscreen-overlay-navbar.js +4 -3
  52. package/dist/components/puck-block/header-sections/mega-menu-navbar/mega-menu-navbar.js +3 -2
  53. package/dist/components/puck-block/header-sections/props.d.ts +3 -0
  54. package/dist/components/puck-block/header-sections/standard-navbar/standard-navbar.js +3 -2
  55. package/dist/components/puck-block/hero-sections/carousel-hero/component.js +3 -3
  56. package/dist/components/puck-block/hero-sections/column-scroll-hero/component.js +8 -8
  57. package/dist/components/puck-block/hero-sections/dual-marquee-hero/component.js +6 -6
  58. package/dist/components/puck-block/hero-sections/fullscreen-video-hero/component.js +1 -1
  59. package/dist/components/puck-block/hero-sections/grid-expand-hero/component.js +26 -17
  60. package/dist/components/puck-block/hero-sections/grid-expand-hero/index.d.ts +17 -1
  61. package/dist/components/puck-block/hero-sections/horizontal-marquee-hero/component.js +3 -3
  62. package/dist/components/puck-block/hero-sections/inline-image-hero/inline-image-hero.js +59 -28
  63. package/dist/components/puck-block/hero-sections/mouse-track-hero/component.js +60 -19
  64. package/dist/components/puck-block/hero-sections/multi-image-grid-hero/index.d.ts +17 -1
  65. package/dist/components/puck-block/hero-sections/multi-image-grid-hero/multi-image-grid-hero.js +2 -2
  66. package/dist/components/puck-block/hero-sections/overlapping-image-hero/overlapping-image-hero.js +3 -3
  67. package/dist/components/puck-block/hero-sections/parallax-images-hero/component.js +18 -6
  68. package/dist/components/puck-block/hero-sections/props.d.ts +34 -2
  69. package/dist/components/puck-block/hero-sections/props.js +18 -4
  70. package/dist/components/puck-block/hero-sections/scatter-parallax-hero/component.js +9 -7
  71. package/dist/components/puck-block/hero-sections/scroll-expand-video-hero/component.js +7 -5
  72. package/dist/components/puck-block/hero-sections/scroll-zoom-hero/component.js +5 -3
  73. package/dist/components/puck-block/hero-sections/sticky-expand-hero/component.js +1 -1
  74. package/dist/components/puck-block/hero-sections/sticky-expand-hero/index.d.ts +13 -5
  75. package/dist/components/puck-block/hero-sections/sticky-expand-hero/index.js +2 -2
  76. package/dist/components/puck-block/hero-sections/sticky-video-hero/component.js +2 -2
  77. package/dist/components/puck-block/hero-sections/tab-hero/component.js +5 -5
  78. package/dist/components/puck-block/hero-sections/three-image-parallax-hero/component.js +3 -3
  79. package/dist/components/puck-block/hero-sections/vertical-gallery-hero/component.js +6 -6
  80. package/dist/components/puck-block/hero-sections/zoom-grid-hero/component.js +14 -12
  81. package/dist/components/puck-block/index.d.ts +1 -0
  82. package/dist/components/puck-block/location-sections/index.d.ts +3 -0
  83. package/dist/components/puck-block/location-sections/location-1/index.js +102 -0
  84. package/dist/components/puck-block/location-sections/location-1/location.d.ts +0 -3
  85. package/dist/components/puck-block/location-sections/location-1/location.js +139 -0
  86. package/dist/components/puck-block/location-sections/location-2/index.js +126 -0
  87. package/dist/components/puck-block/location-sections/location-2/location.d.ts +0 -3
  88. package/dist/components/puck-block/location-sections/location-2/location.js +133 -0
  89. package/dist/components/puck-block/location-sections/location-3/index.js +109 -0
  90. package/dist/components/puck-block/location-sections/location-3/location.d.ts +0 -3
  91. package/dist/components/puck-block/location-sections/location-3/location.js +140 -0
  92. package/dist/components/puck-block/location-sections/props.d.ts +0 -3
  93. package/dist/components/puck-block/metrics-sections/center-media-stats/center-media-stats.js +1 -1
  94. package/dist/components/puck-block/metrics-sections/header-stats-row/header-stats-row.js +1 -1
  95. package/dist/components/puck-block/metrics-sections/mixed-grid-stats/mixed-grid-stats.js +2 -2
  96. package/dist/components/puck-block/metrics-sections/split-stats/split-stats.js +1 -1
  97. package/dist/components/puck-block/metrics-sections/tab-stats/tab-stats.js +4 -4
  98. package/dist/components/puck-block/pricing-sections/pricing-comparison-table/component.js +134 -33
  99. package/dist/components/puck-block/pricing-sections/pricing-comparison-table/index.d.ts +47 -0
  100. package/dist/components/puck-block/pricing-sections/pricing-comparison-table/index.js +34 -0
  101. package/dist/components/puck-block/pricing-sections/split-pricing/component.js +3 -3
  102. package/dist/components/puck-block/pricing-sections/tab-pricing-grid/component.js +86 -40
  103. package/dist/components/puck-block/pricing-sections/tab-single-pricing/component.js +1 -1
  104. package/dist/components/puck-block/registry.generated.d.ts +501 -12
  105. package/dist/components/puck-block/registry.generated.js +157 -138
  106. package/dist/components/puck-block/showcase-sections/tab-timeline/component.js +2 -2
  107. package/dist/components/puck-block/testimonial-sections/bento-testimonial/component.js +157 -83
  108. package/dist/components/puck-block/testimonial-sections/centered-testimonial/component.js +71 -28
  109. package/dist/components/puck-block/testimonial-sections/image-testimonial/component.js +66 -29
  110. package/dist/components/puck-block/testimonial-sections/image-testimonial-carousel/component.js +1 -1
  111. package/dist/components/puck-block/testimonial-sections/tab-testimonial/component.js +6 -6
  112. package/dist/components/puck-block/testimonial-sections/testimonial-card-grid/component.js +2 -2
  113. package/dist/components/puck-block/testimonial-sections/testimonial-carousel/component.js +1 -1
  114. package/dist/components/puck-block/text-sections/prose-content/component.js +1 -1
  115. package/dist/components/puck-block/text-sections/side-media-content/component.js +1 -1
  116. package/dist/components/puck-block/text-sections/sticky-text-multi-image/component.js +3 -3
  117. package/dist/components/puck-core/core/props/form.js +25 -1
  118. package/dist/components/puck-core/core/props/media.js +6 -1
  119. package/dist/components/puck-core/fields/array-field.d.ts +7 -0
  120. package/dist/components/puck-core/fields/array-field.js +229 -0
  121. package/dist/components/puck-core/fields/auto-field.js +11 -0
  122. package/dist/components/puck-core/fields/image-upload-field.js +1 -1
  123. package/dist/components/puck-core/fields/index.d.ts +1 -0
  124. package/dist/components/puck-core/fields/location-field.js +4 -1
  125. package/dist/components/puck-core/fields/object-field.js +1 -1
  126. package/dist/index.js +6 -0
  127. package/dist/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.4/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js +59 -0
  128. package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@dnd-kit/core/dist/core.esm.js +3093 -0
  129. package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.4_react@19.2.4__react@19.2.4__react@19.2.4/node_modules/@dnd-kit/sortable/dist/sortable.esm.js +592 -0
  130. package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.4/node_modules/@dnd-kit/utilities/dist/utilities.esm.js +301 -0
  131. package/package.json +7 -1
@@ -0,0 +1,3093 @@
1
+ import React__default, { useMemo, memo, useReducer, useState, useRef, useCallback, useEffect, createContext, useContext } from "react";
2
+ import { unstable_batchedUpdates, createPortal } from "react-dom";
3
+ import { useLatestValue, useUniqueId, getEventCoordinates, getWindow, add, useIsomorphicLayoutEffect, getOwnerDocument, isKeyboardEvent, subtract, useLazyMemo, isHTMLElement, useNodeRef, canUseDOM, useInterval, usePrevious, findFirstFocusableNode, useEvent, isWindow, isNode, isDocument, isSVGElement } from "../../../../../@dnd-kit_utilities@3.2.2_react@19.2.4/node_modules/@dnd-kit/utilities/dist/utilities.esm.js";
4
+ import { useAnnouncement, HiddenText, LiveRegion } from "../../../../../@dnd-kit_accessibility@3.1.1_react@19.2.4/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js";
5
+ const DndMonitorContext = /* @__PURE__ */ createContext(null);
6
+ function useDndMonitor(listener) {
7
+ const registerListener = useContext(DndMonitorContext);
8
+ useEffect(() => {
9
+ if (!registerListener) {
10
+ throw new Error("useDndMonitor must be used within a children of <DndContext>");
11
+ }
12
+ const unsubscribe = registerListener(listener);
13
+ return unsubscribe;
14
+ }, [listener, registerListener]);
15
+ }
16
+ function useDndMonitorProvider() {
17
+ const [listeners] = useState(() => /* @__PURE__ */ new Set());
18
+ const registerListener = useCallback((listener) => {
19
+ listeners.add(listener);
20
+ return () => listeners.delete(listener);
21
+ }, [listeners]);
22
+ const dispatch = useCallback((_ref) => {
23
+ let {
24
+ type,
25
+ event
26
+ } = _ref;
27
+ listeners.forEach((listener) => {
28
+ var _listener$type;
29
+ return (_listener$type = listener[type]) == null ? void 0 : _listener$type.call(listener, event);
30
+ });
31
+ }, [listeners]);
32
+ return [dispatch, registerListener];
33
+ }
34
+ const defaultScreenReaderInstructions = {
35
+ 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 "
36
+ };
37
+ const defaultAnnouncements = {
38
+ onDragStart(_ref) {
39
+ let {
40
+ active
41
+ } = _ref;
42
+ return "Picked up draggable item " + active.id + ".";
43
+ },
44
+ onDragOver(_ref2) {
45
+ let {
46
+ active,
47
+ over
48
+ } = _ref2;
49
+ if (over) {
50
+ return "Draggable item " + active.id + " was moved over droppable area " + over.id + ".";
51
+ }
52
+ return "Draggable item " + active.id + " is no longer over a droppable area.";
53
+ },
54
+ onDragEnd(_ref3) {
55
+ let {
56
+ active,
57
+ over
58
+ } = _ref3;
59
+ if (over) {
60
+ return "Draggable item " + active.id + " was dropped over droppable area " + over.id;
61
+ }
62
+ return "Draggable item " + active.id + " was dropped.";
63
+ },
64
+ onDragCancel(_ref4) {
65
+ let {
66
+ active
67
+ } = _ref4;
68
+ return "Dragging was cancelled. Draggable item " + active.id + " was dropped.";
69
+ }
70
+ };
71
+ function Accessibility(_ref) {
72
+ let {
73
+ announcements = defaultAnnouncements,
74
+ container,
75
+ hiddenTextDescribedById,
76
+ screenReaderInstructions = defaultScreenReaderInstructions
77
+ } = _ref;
78
+ const {
79
+ announce,
80
+ announcement
81
+ } = useAnnouncement();
82
+ const liveRegionId = useUniqueId("DndLiveRegion");
83
+ const [mounted, setMounted] = useState(false);
84
+ useEffect(() => {
85
+ setMounted(true);
86
+ }, []);
87
+ useDndMonitor(useMemo(() => ({
88
+ onDragStart(_ref2) {
89
+ let {
90
+ active
91
+ } = _ref2;
92
+ announce(announcements.onDragStart({
93
+ active
94
+ }));
95
+ },
96
+ onDragMove(_ref3) {
97
+ let {
98
+ active,
99
+ over
100
+ } = _ref3;
101
+ if (announcements.onDragMove) {
102
+ announce(announcements.onDragMove({
103
+ active,
104
+ over
105
+ }));
106
+ }
107
+ },
108
+ onDragOver(_ref4) {
109
+ let {
110
+ active,
111
+ over
112
+ } = _ref4;
113
+ announce(announcements.onDragOver({
114
+ active,
115
+ over
116
+ }));
117
+ },
118
+ onDragEnd(_ref5) {
119
+ let {
120
+ active,
121
+ over
122
+ } = _ref5;
123
+ announce(announcements.onDragEnd({
124
+ active,
125
+ over
126
+ }));
127
+ },
128
+ onDragCancel(_ref6) {
129
+ let {
130
+ active,
131
+ over
132
+ } = _ref6;
133
+ announce(announcements.onDragCancel({
134
+ active,
135
+ over
136
+ }));
137
+ }
138
+ }), [announce, announcements]));
139
+ if (!mounted) {
140
+ return null;
141
+ }
142
+ const markup = React__default.createElement(React__default.Fragment, null, React__default.createElement(HiddenText, {
143
+ id: hiddenTextDescribedById,
144
+ value: screenReaderInstructions.draggable
145
+ }), React__default.createElement(LiveRegion, {
146
+ id: liveRegionId,
147
+ announcement
148
+ }));
149
+ return container ? createPortal(markup, container) : markup;
150
+ }
151
+ var Action;
152
+ (function(Action2) {
153
+ Action2["DragStart"] = "dragStart";
154
+ Action2["DragMove"] = "dragMove";
155
+ Action2["DragEnd"] = "dragEnd";
156
+ Action2["DragCancel"] = "dragCancel";
157
+ Action2["DragOver"] = "dragOver";
158
+ Action2["RegisterDroppable"] = "registerDroppable";
159
+ Action2["SetDroppableDisabled"] = "setDroppableDisabled";
160
+ Action2["UnregisterDroppable"] = "unregisterDroppable";
161
+ })(Action || (Action = {}));
162
+ function noop() {
163
+ }
164
+ function useSensor(sensor, options) {
165
+ return useMemo(
166
+ () => ({
167
+ sensor,
168
+ options: options != null ? options : {}
169
+ }),
170
+ // eslint-disable-next-line react-hooks/exhaustive-deps
171
+ [sensor, options]
172
+ );
173
+ }
174
+ function useSensors() {
175
+ for (var _len = arguments.length, sensors = new Array(_len), _key = 0; _key < _len; _key++) {
176
+ sensors[_key] = arguments[_key];
177
+ }
178
+ return useMemo(
179
+ () => [...sensors].filter((sensor) => sensor != null),
180
+ // eslint-disable-next-line react-hooks/exhaustive-deps
181
+ [...sensors]
182
+ );
183
+ }
184
+ const defaultCoordinates = /* @__PURE__ */ Object.freeze({
185
+ x: 0,
186
+ y: 0
187
+ });
188
+ function distanceBetween(p1, p2) {
189
+ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
190
+ }
191
+ function sortCollisionsAsc(_ref, _ref2) {
192
+ let {
193
+ data: {
194
+ value: a
195
+ }
196
+ } = _ref;
197
+ let {
198
+ data: {
199
+ value: b
200
+ }
201
+ } = _ref2;
202
+ return a - b;
203
+ }
204
+ function sortCollisionsDesc(_ref3, _ref4) {
205
+ let {
206
+ data: {
207
+ value: a
208
+ }
209
+ } = _ref3;
210
+ let {
211
+ data: {
212
+ value: b
213
+ }
214
+ } = _ref4;
215
+ return b - a;
216
+ }
217
+ function cornersOfRectangle(_ref5) {
218
+ let {
219
+ left,
220
+ top,
221
+ height,
222
+ width
223
+ } = _ref5;
224
+ return [{
225
+ x: left,
226
+ y: top
227
+ }, {
228
+ x: left + width,
229
+ y: top
230
+ }, {
231
+ x: left,
232
+ y: top + height
233
+ }, {
234
+ x: left + width,
235
+ y: top + height
236
+ }];
237
+ }
238
+ function getFirstCollision(collisions, property) {
239
+ if (!collisions || collisions.length === 0) {
240
+ return null;
241
+ }
242
+ const [firstCollision] = collisions;
243
+ return firstCollision[property];
244
+ }
245
+ function centerOfRectangle(rect, left, top) {
246
+ if (left === void 0) {
247
+ left = rect.left;
248
+ }
249
+ if (top === void 0) {
250
+ top = rect.top;
251
+ }
252
+ return {
253
+ x: left + rect.width * 0.5,
254
+ y: top + rect.height * 0.5
255
+ };
256
+ }
257
+ const closestCenter = (_ref) => {
258
+ let {
259
+ collisionRect,
260
+ droppableRects,
261
+ droppableContainers
262
+ } = _ref;
263
+ const centerRect = centerOfRectangle(collisionRect, collisionRect.left, collisionRect.top);
264
+ const collisions = [];
265
+ for (const droppableContainer of droppableContainers) {
266
+ const {
267
+ id
268
+ } = droppableContainer;
269
+ const rect = droppableRects.get(id);
270
+ if (rect) {
271
+ const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
272
+ collisions.push({
273
+ id,
274
+ data: {
275
+ droppableContainer,
276
+ value: distBetween
277
+ }
278
+ });
279
+ }
280
+ }
281
+ return collisions.sort(sortCollisionsAsc);
282
+ };
283
+ const closestCorners = (_ref) => {
284
+ let {
285
+ collisionRect,
286
+ droppableRects,
287
+ droppableContainers
288
+ } = _ref;
289
+ const corners = cornersOfRectangle(collisionRect);
290
+ const collisions = [];
291
+ for (const droppableContainer of droppableContainers) {
292
+ const {
293
+ id
294
+ } = droppableContainer;
295
+ const rect = droppableRects.get(id);
296
+ if (rect) {
297
+ const rectCorners = cornersOfRectangle(rect);
298
+ const distances = corners.reduce((accumulator, corner, index) => {
299
+ return accumulator + distanceBetween(rectCorners[index], corner);
300
+ }, 0);
301
+ const effectiveDistance = Number((distances / 4).toFixed(4));
302
+ collisions.push({
303
+ id,
304
+ data: {
305
+ droppableContainer,
306
+ value: effectiveDistance
307
+ }
308
+ });
309
+ }
310
+ }
311
+ return collisions.sort(sortCollisionsAsc);
312
+ };
313
+ function getIntersectionRatio(entry, target) {
314
+ const top = Math.max(target.top, entry.top);
315
+ const left = Math.max(target.left, entry.left);
316
+ const right = Math.min(target.left + target.width, entry.left + entry.width);
317
+ const bottom = Math.min(target.top + target.height, entry.top + entry.height);
318
+ const width = right - left;
319
+ const height = bottom - top;
320
+ if (left < right && top < bottom) {
321
+ const targetArea = target.width * target.height;
322
+ const entryArea = entry.width * entry.height;
323
+ const intersectionArea = width * height;
324
+ const intersectionRatio = intersectionArea / (targetArea + entryArea - intersectionArea);
325
+ return Number(intersectionRatio.toFixed(4));
326
+ }
327
+ return 0;
328
+ }
329
+ const rectIntersection = (_ref) => {
330
+ let {
331
+ collisionRect,
332
+ droppableRects,
333
+ droppableContainers
334
+ } = _ref;
335
+ const collisions = [];
336
+ for (const droppableContainer of droppableContainers) {
337
+ const {
338
+ id
339
+ } = droppableContainer;
340
+ const rect = droppableRects.get(id);
341
+ if (rect) {
342
+ const intersectionRatio = getIntersectionRatio(rect, collisionRect);
343
+ if (intersectionRatio > 0) {
344
+ collisions.push({
345
+ id,
346
+ data: {
347
+ droppableContainer,
348
+ value: intersectionRatio
349
+ }
350
+ });
351
+ }
352
+ }
353
+ }
354
+ return collisions.sort(sortCollisionsDesc);
355
+ };
356
+ function adjustScale(transform, rect1, rect2) {
357
+ return {
358
+ ...transform,
359
+ scaleX: rect1 && rect2 ? rect1.width / rect2.width : 1,
360
+ scaleY: rect1 && rect2 ? rect1.height / rect2.height : 1
361
+ };
362
+ }
363
+ function getRectDelta(rect1, rect2) {
364
+ return rect1 && rect2 ? {
365
+ x: rect1.left - rect2.left,
366
+ y: rect1.top - rect2.top
367
+ } : defaultCoordinates;
368
+ }
369
+ function createRectAdjustmentFn(modifier) {
370
+ return function adjustClientRect(rect) {
371
+ for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
372
+ adjustments[_key - 1] = arguments[_key];
373
+ }
374
+ return adjustments.reduce((acc, adjustment) => ({
375
+ ...acc,
376
+ top: acc.top + modifier * adjustment.y,
377
+ bottom: acc.bottom + modifier * adjustment.y,
378
+ left: acc.left + modifier * adjustment.x,
379
+ right: acc.right + modifier * adjustment.x
380
+ }), {
381
+ ...rect
382
+ });
383
+ };
384
+ }
385
+ const getAdjustedRect = /* @__PURE__ */ createRectAdjustmentFn(1);
386
+ function parseTransform(transform) {
387
+ if (transform.startsWith("matrix3d(")) {
388
+ const transformArray = transform.slice(9, -1).split(/, /);
389
+ return {
390
+ x: +transformArray[12],
391
+ y: +transformArray[13],
392
+ scaleX: +transformArray[0],
393
+ scaleY: +transformArray[5]
394
+ };
395
+ } else if (transform.startsWith("matrix(")) {
396
+ const transformArray = transform.slice(7, -1).split(/, /);
397
+ return {
398
+ x: +transformArray[4],
399
+ y: +transformArray[5],
400
+ scaleX: +transformArray[0],
401
+ scaleY: +transformArray[3]
402
+ };
403
+ }
404
+ return null;
405
+ }
406
+ function inverseTransform(rect, transform, transformOrigin) {
407
+ const parsedTransform = parseTransform(transform);
408
+ if (!parsedTransform) {
409
+ return rect;
410
+ }
411
+ const {
412
+ scaleX,
413
+ scaleY,
414
+ x: translateX,
415
+ y: translateY
416
+ } = parsedTransform;
417
+ const x = rect.left - translateX - (1 - scaleX) * parseFloat(transformOrigin);
418
+ const y = rect.top - translateY - (1 - scaleY) * parseFloat(transformOrigin.slice(transformOrigin.indexOf(" ") + 1));
419
+ const w = scaleX ? rect.width / scaleX : rect.width;
420
+ const h = scaleY ? rect.height / scaleY : rect.height;
421
+ return {
422
+ width: w,
423
+ height: h,
424
+ top: y,
425
+ right: x + w,
426
+ bottom: y + h,
427
+ left: x
428
+ };
429
+ }
430
+ const defaultOptions = {
431
+ ignoreTransform: false
432
+ };
433
+ function getClientRect(element, options) {
434
+ if (options === void 0) {
435
+ options = defaultOptions;
436
+ }
437
+ let rect = element.getBoundingClientRect();
438
+ if (options.ignoreTransform) {
439
+ const {
440
+ transform,
441
+ transformOrigin
442
+ } = getWindow(element).getComputedStyle(element);
443
+ if (transform) {
444
+ rect = inverseTransform(rect, transform, transformOrigin);
445
+ }
446
+ }
447
+ const {
448
+ top,
449
+ left,
450
+ width,
451
+ height,
452
+ bottom,
453
+ right
454
+ } = rect;
455
+ return {
456
+ top,
457
+ left,
458
+ width,
459
+ height,
460
+ bottom,
461
+ right
462
+ };
463
+ }
464
+ function getTransformAgnosticClientRect(element) {
465
+ return getClientRect(element, {
466
+ ignoreTransform: true
467
+ });
468
+ }
469
+ function getWindowClientRect(element) {
470
+ const width = element.innerWidth;
471
+ const height = element.innerHeight;
472
+ return {
473
+ top: 0,
474
+ left: 0,
475
+ right: width,
476
+ bottom: height,
477
+ width,
478
+ height
479
+ };
480
+ }
481
+ function isFixed(node, computedStyle) {
482
+ if (computedStyle === void 0) {
483
+ computedStyle = getWindow(node).getComputedStyle(node);
484
+ }
485
+ return computedStyle.position === "fixed";
486
+ }
487
+ function isScrollable(element, computedStyle) {
488
+ if (computedStyle === void 0) {
489
+ computedStyle = getWindow(element).getComputedStyle(element);
490
+ }
491
+ const overflowRegex = /(auto|scroll|overlay)/;
492
+ const properties2 = ["overflow", "overflowX", "overflowY"];
493
+ return properties2.some((property) => {
494
+ const value = computedStyle[property];
495
+ return typeof value === "string" ? overflowRegex.test(value) : false;
496
+ });
497
+ }
498
+ function getScrollableAncestors(element, limit) {
499
+ const scrollParents = [];
500
+ function findScrollableAncestors(node) {
501
+ if (limit != null && scrollParents.length >= limit) {
502
+ return scrollParents;
503
+ }
504
+ if (!node) {
505
+ return scrollParents;
506
+ }
507
+ if (isDocument(node) && node.scrollingElement != null && !scrollParents.includes(node.scrollingElement)) {
508
+ scrollParents.push(node.scrollingElement);
509
+ return scrollParents;
510
+ }
511
+ if (!isHTMLElement(node) || isSVGElement(node)) {
512
+ return scrollParents;
513
+ }
514
+ if (scrollParents.includes(node)) {
515
+ return scrollParents;
516
+ }
517
+ const computedStyle = getWindow(element).getComputedStyle(node);
518
+ if (node !== element) {
519
+ if (isScrollable(node, computedStyle)) {
520
+ scrollParents.push(node);
521
+ }
522
+ }
523
+ if (isFixed(node, computedStyle)) {
524
+ return scrollParents;
525
+ }
526
+ return findScrollableAncestors(node.parentNode);
527
+ }
528
+ if (!element) {
529
+ return scrollParents;
530
+ }
531
+ return findScrollableAncestors(element);
532
+ }
533
+ function getFirstScrollableAncestor(node) {
534
+ const [firstScrollableAncestor] = getScrollableAncestors(node, 1);
535
+ return firstScrollableAncestor != null ? firstScrollableAncestor : null;
536
+ }
537
+ function getScrollableElement(element) {
538
+ if (!canUseDOM || !element) {
539
+ return null;
540
+ }
541
+ if (isWindow(element)) {
542
+ return element;
543
+ }
544
+ if (!isNode(element)) {
545
+ return null;
546
+ }
547
+ if (isDocument(element) || element === getOwnerDocument(element).scrollingElement) {
548
+ return window;
549
+ }
550
+ if (isHTMLElement(element)) {
551
+ return element;
552
+ }
553
+ return null;
554
+ }
555
+ function getScrollXCoordinate(element) {
556
+ if (isWindow(element)) {
557
+ return element.scrollX;
558
+ }
559
+ return element.scrollLeft;
560
+ }
561
+ function getScrollYCoordinate(element) {
562
+ if (isWindow(element)) {
563
+ return element.scrollY;
564
+ }
565
+ return element.scrollTop;
566
+ }
567
+ function getScrollCoordinates(element) {
568
+ return {
569
+ x: getScrollXCoordinate(element),
570
+ y: getScrollYCoordinate(element)
571
+ };
572
+ }
573
+ var Direction;
574
+ (function(Direction2) {
575
+ Direction2[Direction2["Forward"] = 1] = "Forward";
576
+ Direction2[Direction2["Backward"] = -1] = "Backward";
577
+ })(Direction || (Direction = {}));
578
+ function isDocumentScrollingElement(element) {
579
+ if (!canUseDOM || !element) {
580
+ return false;
581
+ }
582
+ return element === document.scrollingElement;
583
+ }
584
+ function getScrollPosition(scrollingContainer) {
585
+ const minScroll = {
586
+ x: 0,
587
+ y: 0
588
+ };
589
+ const dimensions = isDocumentScrollingElement(scrollingContainer) ? {
590
+ height: window.innerHeight,
591
+ width: window.innerWidth
592
+ } : {
593
+ height: scrollingContainer.clientHeight,
594
+ width: scrollingContainer.clientWidth
595
+ };
596
+ const maxScroll = {
597
+ x: scrollingContainer.scrollWidth - dimensions.width,
598
+ y: scrollingContainer.scrollHeight - dimensions.height
599
+ };
600
+ const isTop = scrollingContainer.scrollTop <= minScroll.y;
601
+ const isLeft = scrollingContainer.scrollLeft <= minScroll.x;
602
+ const isBottom = scrollingContainer.scrollTop >= maxScroll.y;
603
+ const isRight = scrollingContainer.scrollLeft >= maxScroll.x;
604
+ return {
605
+ isTop,
606
+ isLeft,
607
+ isBottom,
608
+ isRight,
609
+ maxScroll,
610
+ minScroll
611
+ };
612
+ }
613
+ const defaultThreshold = {
614
+ x: 0.2,
615
+ y: 0.2
616
+ };
617
+ function getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, _ref, acceleration, thresholdPercentage) {
618
+ let {
619
+ top,
620
+ left,
621
+ right,
622
+ bottom
623
+ } = _ref;
624
+ if (acceleration === void 0) {
625
+ acceleration = 10;
626
+ }
627
+ if (thresholdPercentage === void 0) {
628
+ thresholdPercentage = defaultThreshold;
629
+ }
630
+ const {
631
+ isTop,
632
+ isBottom,
633
+ isLeft,
634
+ isRight
635
+ } = getScrollPosition(scrollContainer);
636
+ const direction = {
637
+ x: 0,
638
+ y: 0
639
+ };
640
+ const speed = {
641
+ x: 0,
642
+ y: 0
643
+ };
644
+ const threshold = {
645
+ height: scrollContainerRect.height * thresholdPercentage.y,
646
+ width: scrollContainerRect.width * thresholdPercentage.x
647
+ };
648
+ if (!isTop && top <= scrollContainerRect.top + threshold.height) {
649
+ direction.y = Direction.Backward;
650
+ speed.y = acceleration * Math.abs((scrollContainerRect.top + threshold.height - top) / threshold.height);
651
+ } else if (!isBottom && bottom >= scrollContainerRect.bottom - threshold.height) {
652
+ direction.y = Direction.Forward;
653
+ speed.y = acceleration * Math.abs((scrollContainerRect.bottom - threshold.height - bottom) / threshold.height);
654
+ }
655
+ if (!isRight && right >= scrollContainerRect.right - threshold.width) {
656
+ direction.x = Direction.Forward;
657
+ speed.x = acceleration * Math.abs((scrollContainerRect.right - threshold.width - right) / threshold.width);
658
+ } else if (!isLeft && left <= scrollContainerRect.left + threshold.width) {
659
+ direction.x = Direction.Backward;
660
+ speed.x = acceleration * Math.abs((scrollContainerRect.left + threshold.width - left) / threshold.width);
661
+ }
662
+ return {
663
+ direction,
664
+ speed
665
+ };
666
+ }
667
+ function getScrollElementRect(element) {
668
+ if (element === document.scrollingElement) {
669
+ const {
670
+ innerWidth,
671
+ innerHeight
672
+ } = window;
673
+ return {
674
+ top: 0,
675
+ left: 0,
676
+ right: innerWidth,
677
+ bottom: innerHeight,
678
+ width: innerWidth,
679
+ height: innerHeight
680
+ };
681
+ }
682
+ const {
683
+ top,
684
+ left,
685
+ right,
686
+ bottom
687
+ } = element.getBoundingClientRect();
688
+ return {
689
+ top,
690
+ left,
691
+ right,
692
+ bottom,
693
+ width: element.clientWidth,
694
+ height: element.clientHeight
695
+ };
696
+ }
697
+ function getScrollOffsets(scrollableAncestors) {
698
+ return scrollableAncestors.reduce((acc, node) => {
699
+ return add(acc, getScrollCoordinates(node));
700
+ }, defaultCoordinates);
701
+ }
702
+ function getScrollXOffset(scrollableAncestors) {
703
+ return scrollableAncestors.reduce((acc, node) => {
704
+ return acc + getScrollXCoordinate(node);
705
+ }, 0);
706
+ }
707
+ function getScrollYOffset(scrollableAncestors) {
708
+ return scrollableAncestors.reduce((acc, node) => {
709
+ return acc + getScrollYCoordinate(node);
710
+ }, 0);
711
+ }
712
+ function scrollIntoViewIfNeeded(element, measure) {
713
+ if (measure === void 0) {
714
+ measure = getClientRect;
715
+ }
716
+ if (!element) {
717
+ return;
718
+ }
719
+ const {
720
+ top,
721
+ left,
722
+ bottom,
723
+ right
724
+ } = measure(element);
725
+ const firstScrollableAncestor = getFirstScrollableAncestor(element);
726
+ if (!firstScrollableAncestor) {
727
+ return;
728
+ }
729
+ if (bottom <= 0 || right <= 0 || top >= window.innerHeight || left >= window.innerWidth) {
730
+ element.scrollIntoView({
731
+ block: "center",
732
+ inline: "center"
733
+ });
734
+ }
735
+ }
736
+ const properties = [["x", ["left", "right"], getScrollXOffset], ["y", ["top", "bottom"], getScrollYOffset]];
737
+ class Rect {
738
+ constructor(rect, element) {
739
+ this.rect = void 0;
740
+ this.width = void 0;
741
+ this.height = void 0;
742
+ this.top = void 0;
743
+ this.bottom = void 0;
744
+ this.right = void 0;
745
+ this.left = void 0;
746
+ const scrollableAncestors = getScrollableAncestors(element);
747
+ const scrollOffsets = getScrollOffsets(scrollableAncestors);
748
+ this.rect = {
749
+ ...rect
750
+ };
751
+ this.width = rect.width;
752
+ this.height = rect.height;
753
+ for (const [axis, keys, getScrollOffset] of properties) {
754
+ for (const key of keys) {
755
+ Object.defineProperty(this, key, {
756
+ get: () => {
757
+ const currentOffsets = getScrollOffset(scrollableAncestors);
758
+ const scrollOffsetsDeltla = scrollOffsets[axis] - currentOffsets;
759
+ return this.rect[key] + scrollOffsetsDeltla;
760
+ },
761
+ enumerable: true
762
+ });
763
+ }
764
+ }
765
+ Object.defineProperty(this, "rect", {
766
+ enumerable: false
767
+ });
768
+ }
769
+ }
770
+ class Listeners {
771
+ constructor(target) {
772
+ this.target = void 0;
773
+ this.listeners = [];
774
+ this.removeAll = () => {
775
+ this.listeners.forEach((listener) => {
776
+ var _this$target;
777
+ return (_this$target = this.target) == null ? void 0 : _this$target.removeEventListener(...listener);
778
+ });
779
+ };
780
+ this.target = target;
781
+ }
782
+ add(eventName, handler, options) {
783
+ var _this$target2;
784
+ (_this$target2 = this.target) == null ? void 0 : _this$target2.addEventListener(eventName, handler, options);
785
+ this.listeners.push([eventName, handler, options]);
786
+ }
787
+ }
788
+ function getEventListenerTarget(target) {
789
+ const {
790
+ EventTarget
791
+ } = getWindow(target);
792
+ return target instanceof EventTarget ? target : getOwnerDocument(target);
793
+ }
794
+ function hasExceededDistance(delta, measurement) {
795
+ const dx = Math.abs(delta.x);
796
+ const dy = Math.abs(delta.y);
797
+ if (typeof measurement === "number") {
798
+ return Math.sqrt(dx ** 2 + dy ** 2) > measurement;
799
+ }
800
+ if ("x" in measurement && "y" in measurement) {
801
+ return dx > measurement.x && dy > measurement.y;
802
+ }
803
+ if ("x" in measurement) {
804
+ return dx > measurement.x;
805
+ }
806
+ if ("y" in measurement) {
807
+ return dy > measurement.y;
808
+ }
809
+ return false;
810
+ }
811
+ var EventName;
812
+ (function(EventName2) {
813
+ EventName2["Click"] = "click";
814
+ EventName2["DragStart"] = "dragstart";
815
+ EventName2["Keydown"] = "keydown";
816
+ EventName2["ContextMenu"] = "contextmenu";
817
+ EventName2["Resize"] = "resize";
818
+ EventName2["SelectionChange"] = "selectionchange";
819
+ EventName2["VisibilityChange"] = "visibilitychange";
820
+ })(EventName || (EventName = {}));
821
+ function preventDefault(event) {
822
+ event.preventDefault();
823
+ }
824
+ function stopPropagation(event) {
825
+ event.stopPropagation();
826
+ }
827
+ var KeyboardCode;
828
+ (function(KeyboardCode2) {
829
+ KeyboardCode2["Space"] = "Space";
830
+ KeyboardCode2["Down"] = "ArrowDown";
831
+ KeyboardCode2["Right"] = "ArrowRight";
832
+ KeyboardCode2["Left"] = "ArrowLeft";
833
+ KeyboardCode2["Up"] = "ArrowUp";
834
+ KeyboardCode2["Esc"] = "Escape";
835
+ KeyboardCode2["Enter"] = "Enter";
836
+ KeyboardCode2["Tab"] = "Tab";
837
+ })(KeyboardCode || (KeyboardCode = {}));
838
+ const defaultKeyboardCodes = {
839
+ start: [KeyboardCode.Space, KeyboardCode.Enter],
840
+ cancel: [KeyboardCode.Esc],
841
+ end: [KeyboardCode.Space, KeyboardCode.Enter, KeyboardCode.Tab]
842
+ };
843
+ const defaultKeyboardCoordinateGetter = (event, _ref) => {
844
+ let {
845
+ currentCoordinates
846
+ } = _ref;
847
+ switch (event.code) {
848
+ case KeyboardCode.Right:
849
+ return {
850
+ ...currentCoordinates,
851
+ x: currentCoordinates.x + 25
852
+ };
853
+ case KeyboardCode.Left:
854
+ return {
855
+ ...currentCoordinates,
856
+ x: currentCoordinates.x - 25
857
+ };
858
+ case KeyboardCode.Down:
859
+ return {
860
+ ...currentCoordinates,
861
+ y: currentCoordinates.y + 25
862
+ };
863
+ case KeyboardCode.Up:
864
+ return {
865
+ ...currentCoordinates,
866
+ y: currentCoordinates.y - 25
867
+ };
868
+ }
869
+ return void 0;
870
+ };
871
+ class KeyboardSensor {
872
+ constructor(props) {
873
+ this.props = void 0;
874
+ this.autoScrollEnabled = false;
875
+ this.referenceCoordinates = void 0;
876
+ this.listeners = void 0;
877
+ this.windowListeners = void 0;
878
+ this.props = props;
879
+ const {
880
+ event: {
881
+ target
882
+ }
883
+ } = props;
884
+ this.props = props;
885
+ this.listeners = new Listeners(getOwnerDocument(target));
886
+ this.windowListeners = new Listeners(getWindow(target));
887
+ this.handleKeyDown = this.handleKeyDown.bind(this);
888
+ this.handleCancel = this.handleCancel.bind(this);
889
+ this.attach();
890
+ }
891
+ attach() {
892
+ this.handleStart();
893
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
894
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
895
+ setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));
896
+ }
897
+ handleStart() {
898
+ const {
899
+ activeNode,
900
+ onStart
901
+ } = this.props;
902
+ const node = activeNode.node.current;
903
+ if (node) {
904
+ scrollIntoViewIfNeeded(node);
905
+ }
906
+ onStart(defaultCoordinates);
907
+ }
908
+ handleKeyDown(event) {
909
+ if (isKeyboardEvent(event)) {
910
+ const {
911
+ active,
912
+ context,
913
+ options
914
+ } = this.props;
915
+ const {
916
+ keyboardCodes = defaultKeyboardCodes,
917
+ coordinateGetter = defaultKeyboardCoordinateGetter,
918
+ scrollBehavior = "smooth"
919
+ } = options;
920
+ const {
921
+ code
922
+ } = event;
923
+ if (keyboardCodes.end.includes(code)) {
924
+ this.handleEnd(event);
925
+ return;
926
+ }
927
+ if (keyboardCodes.cancel.includes(code)) {
928
+ this.handleCancel(event);
929
+ return;
930
+ }
931
+ const {
932
+ collisionRect
933
+ } = context.current;
934
+ const currentCoordinates = collisionRect ? {
935
+ x: collisionRect.left,
936
+ y: collisionRect.top
937
+ } : defaultCoordinates;
938
+ if (!this.referenceCoordinates) {
939
+ this.referenceCoordinates = currentCoordinates;
940
+ }
941
+ const newCoordinates = coordinateGetter(event, {
942
+ active,
943
+ context: context.current,
944
+ currentCoordinates
945
+ });
946
+ if (newCoordinates) {
947
+ const coordinatesDelta = subtract(newCoordinates, currentCoordinates);
948
+ const scrollDelta = {
949
+ x: 0,
950
+ y: 0
951
+ };
952
+ const {
953
+ scrollableAncestors
954
+ } = context.current;
955
+ for (const scrollContainer of scrollableAncestors) {
956
+ const direction = event.code;
957
+ const {
958
+ isTop,
959
+ isRight,
960
+ isLeft,
961
+ isBottom,
962
+ maxScroll,
963
+ minScroll
964
+ } = getScrollPosition(scrollContainer);
965
+ const scrollElementRect = getScrollElementRect(scrollContainer);
966
+ const clampedCoordinates = {
967
+ x: Math.min(direction === KeyboardCode.Right ? scrollElementRect.right - scrollElementRect.width / 2 : scrollElementRect.right, Math.max(direction === KeyboardCode.Right ? scrollElementRect.left : scrollElementRect.left + scrollElementRect.width / 2, newCoordinates.x)),
968
+ y: Math.min(direction === KeyboardCode.Down ? scrollElementRect.bottom - scrollElementRect.height / 2 : scrollElementRect.bottom, Math.max(direction === KeyboardCode.Down ? scrollElementRect.top : scrollElementRect.top + scrollElementRect.height / 2, newCoordinates.y))
969
+ };
970
+ const canScrollX = direction === KeyboardCode.Right && !isRight || direction === KeyboardCode.Left && !isLeft;
971
+ const canScrollY = direction === KeyboardCode.Down && !isBottom || direction === KeyboardCode.Up && !isTop;
972
+ if (canScrollX && clampedCoordinates.x !== newCoordinates.x) {
973
+ const newScrollCoordinates = scrollContainer.scrollLeft + coordinatesDelta.x;
974
+ const canScrollToNewCoordinates = direction === KeyboardCode.Right && newScrollCoordinates <= maxScroll.x || direction === KeyboardCode.Left && newScrollCoordinates >= minScroll.x;
975
+ if (canScrollToNewCoordinates && !coordinatesDelta.y) {
976
+ scrollContainer.scrollTo({
977
+ left: newScrollCoordinates,
978
+ behavior: scrollBehavior
979
+ });
980
+ return;
981
+ }
982
+ if (canScrollToNewCoordinates) {
983
+ scrollDelta.x = scrollContainer.scrollLeft - newScrollCoordinates;
984
+ } else {
985
+ scrollDelta.x = direction === KeyboardCode.Right ? scrollContainer.scrollLeft - maxScroll.x : scrollContainer.scrollLeft - minScroll.x;
986
+ }
987
+ if (scrollDelta.x) {
988
+ scrollContainer.scrollBy({
989
+ left: -scrollDelta.x,
990
+ behavior: scrollBehavior
991
+ });
992
+ }
993
+ break;
994
+ } else if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {
995
+ const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;
996
+ const canScrollToNewCoordinates = direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y || direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y;
997
+ if (canScrollToNewCoordinates && !coordinatesDelta.x) {
998
+ scrollContainer.scrollTo({
999
+ top: newScrollCoordinates,
1000
+ behavior: scrollBehavior
1001
+ });
1002
+ return;
1003
+ }
1004
+ if (canScrollToNewCoordinates) {
1005
+ scrollDelta.y = scrollContainer.scrollTop - newScrollCoordinates;
1006
+ } else {
1007
+ scrollDelta.y = direction === KeyboardCode.Down ? scrollContainer.scrollTop - maxScroll.y : scrollContainer.scrollTop - minScroll.y;
1008
+ }
1009
+ if (scrollDelta.y) {
1010
+ scrollContainer.scrollBy({
1011
+ top: -scrollDelta.y,
1012
+ behavior: scrollBehavior
1013
+ });
1014
+ }
1015
+ break;
1016
+ }
1017
+ }
1018
+ this.handleMove(event, add(subtract(newCoordinates, this.referenceCoordinates), scrollDelta));
1019
+ }
1020
+ }
1021
+ }
1022
+ handleMove(event, coordinates) {
1023
+ const {
1024
+ onMove
1025
+ } = this.props;
1026
+ event.preventDefault();
1027
+ onMove(coordinates);
1028
+ }
1029
+ handleEnd(event) {
1030
+ const {
1031
+ onEnd
1032
+ } = this.props;
1033
+ event.preventDefault();
1034
+ this.detach();
1035
+ onEnd();
1036
+ }
1037
+ handleCancel(event) {
1038
+ const {
1039
+ onCancel
1040
+ } = this.props;
1041
+ event.preventDefault();
1042
+ this.detach();
1043
+ onCancel();
1044
+ }
1045
+ detach() {
1046
+ this.listeners.removeAll();
1047
+ this.windowListeners.removeAll();
1048
+ }
1049
+ }
1050
+ KeyboardSensor.activators = [{
1051
+ eventName: "onKeyDown",
1052
+ handler: (event, _ref, _ref2) => {
1053
+ let {
1054
+ keyboardCodes = defaultKeyboardCodes,
1055
+ onActivation
1056
+ } = _ref;
1057
+ let {
1058
+ active
1059
+ } = _ref2;
1060
+ const {
1061
+ code
1062
+ } = event.nativeEvent;
1063
+ if (keyboardCodes.start.includes(code)) {
1064
+ const activator = active.activatorNode.current;
1065
+ if (activator && event.target !== activator) {
1066
+ return false;
1067
+ }
1068
+ event.preventDefault();
1069
+ onActivation == null ? void 0 : onActivation({
1070
+ event: event.nativeEvent
1071
+ });
1072
+ return true;
1073
+ }
1074
+ return false;
1075
+ }
1076
+ }];
1077
+ function isDistanceConstraint(constraint) {
1078
+ return Boolean(constraint && "distance" in constraint);
1079
+ }
1080
+ function isDelayConstraint(constraint) {
1081
+ return Boolean(constraint && "delay" in constraint);
1082
+ }
1083
+ class AbstractPointerSensor {
1084
+ constructor(props, events2, listenerTarget) {
1085
+ var _getEventCoordinates;
1086
+ if (listenerTarget === void 0) {
1087
+ listenerTarget = getEventListenerTarget(props.event.target);
1088
+ }
1089
+ this.props = void 0;
1090
+ this.events = void 0;
1091
+ this.autoScrollEnabled = true;
1092
+ this.document = void 0;
1093
+ this.activated = false;
1094
+ this.initialCoordinates = void 0;
1095
+ this.timeoutId = null;
1096
+ this.listeners = void 0;
1097
+ this.documentListeners = void 0;
1098
+ this.windowListeners = void 0;
1099
+ this.props = props;
1100
+ this.events = events2;
1101
+ const {
1102
+ event
1103
+ } = props;
1104
+ const {
1105
+ target
1106
+ } = event;
1107
+ this.props = props;
1108
+ this.events = events2;
1109
+ this.document = getOwnerDocument(target);
1110
+ this.documentListeners = new Listeners(this.document);
1111
+ this.listeners = new Listeners(listenerTarget);
1112
+ this.windowListeners = new Listeners(getWindow(target));
1113
+ this.initialCoordinates = (_getEventCoordinates = getEventCoordinates(event)) != null ? _getEventCoordinates : defaultCoordinates;
1114
+ this.handleStart = this.handleStart.bind(this);
1115
+ this.handleMove = this.handleMove.bind(this);
1116
+ this.handleEnd = this.handleEnd.bind(this);
1117
+ this.handleCancel = this.handleCancel.bind(this);
1118
+ this.handleKeydown = this.handleKeydown.bind(this);
1119
+ this.removeTextSelection = this.removeTextSelection.bind(this);
1120
+ this.attach();
1121
+ }
1122
+ attach() {
1123
+ const {
1124
+ events: events2,
1125
+ props: {
1126
+ options: {
1127
+ activationConstraint,
1128
+ bypassActivationConstraint
1129
+ }
1130
+ }
1131
+ } = this;
1132
+ this.listeners.add(events2.move.name, this.handleMove, {
1133
+ passive: false
1134
+ });
1135
+ this.listeners.add(events2.end.name, this.handleEnd);
1136
+ if (events2.cancel) {
1137
+ this.listeners.add(events2.cancel.name, this.handleCancel);
1138
+ }
1139
+ this.windowListeners.add(EventName.Resize, this.handleCancel);
1140
+ this.windowListeners.add(EventName.DragStart, preventDefault);
1141
+ this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
1142
+ this.windowListeners.add(EventName.ContextMenu, preventDefault);
1143
+ this.documentListeners.add(EventName.Keydown, this.handleKeydown);
1144
+ if (activationConstraint) {
1145
+ if (bypassActivationConstraint != null && bypassActivationConstraint({
1146
+ event: this.props.event,
1147
+ activeNode: this.props.activeNode,
1148
+ options: this.props.options
1149
+ })) {
1150
+ return this.handleStart();
1151
+ }
1152
+ if (isDelayConstraint(activationConstraint)) {
1153
+ this.timeoutId = setTimeout(this.handleStart, activationConstraint.delay);
1154
+ this.handlePending(activationConstraint);
1155
+ return;
1156
+ }
1157
+ if (isDistanceConstraint(activationConstraint)) {
1158
+ this.handlePending(activationConstraint);
1159
+ return;
1160
+ }
1161
+ }
1162
+ this.handleStart();
1163
+ }
1164
+ detach() {
1165
+ this.listeners.removeAll();
1166
+ this.windowListeners.removeAll();
1167
+ setTimeout(this.documentListeners.removeAll, 50);
1168
+ if (this.timeoutId !== null) {
1169
+ clearTimeout(this.timeoutId);
1170
+ this.timeoutId = null;
1171
+ }
1172
+ }
1173
+ handlePending(constraint, offset) {
1174
+ const {
1175
+ active,
1176
+ onPending
1177
+ } = this.props;
1178
+ onPending(active, constraint, this.initialCoordinates, offset);
1179
+ }
1180
+ handleStart() {
1181
+ const {
1182
+ initialCoordinates
1183
+ } = this;
1184
+ const {
1185
+ onStart
1186
+ } = this.props;
1187
+ if (initialCoordinates) {
1188
+ this.activated = true;
1189
+ this.documentListeners.add(EventName.Click, stopPropagation, {
1190
+ capture: true
1191
+ });
1192
+ this.removeTextSelection();
1193
+ this.documentListeners.add(EventName.SelectionChange, this.removeTextSelection);
1194
+ onStart(initialCoordinates);
1195
+ }
1196
+ }
1197
+ handleMove(event) {
1198
+ var _getEventCoordinates2;
1199
+ const {
1200
+ activated,
1201
+ initialCoordinates,
1202
+ props
1203
+ } = this;
1204
+ const {
1205
+ onMove,
1206
+ options: {
1207
+ activationConstraint
1208
+ }
1209
+ } = props;
1210
+ if (!initialCoordinates) {
1211
+ return;
1212
+ }
1213
+ const coordinates = (_getEventCoordinates2 = getEventCoordinates(event)) != null ? _getEventCoordinates2 : defaultCoordinates;
1214
+ const delta = subtract(initialCoordinates, coordinates);
1215
+ if (!activated && activationConstraint) {
1216
+ if (isDistanceConstraint(activationConstraint)) {
1217
+ if (activationConstraint.tolerance != null && hasExceededDistance(delta, activationConstraint.tolerance)) {
1218
+ return this.handleCancel();
1219
+ }
1220
+ if (hasExceededDistance(delta, activationConstraint.distance)) {
1221
+ return this.handleStart();
1222
+ }
1223
+ }
1224
+ if (isDelayConstraint(activationConstraint)) {
1225
+ if (hasExceededDistance(delta, activationConstraint.tolerance)) {
1226
+ return this.handleCancel();
1227
+ }
1228
+ }
1229
+ this.handlePending(activationConstraint, delta);
1230
+ return;
1231
+ }
1232
+ if (event.cancelable) {
1233
+ event.preventDefault();
1234
+ }
1235
+ onMove(coordinates);
1236
+ }
1237
+ handleEnd() {
1238
+ const {
1239
+ onAbort,
1240
+ onEnd
1241
+ } = this.props;
1242
+ this.detach();
1243
+ if (!this.activated) {
1244
+ onAbort(this.props.active);
1245
+ }
1246
+ onEnd();
1247
+ }
1248
+ handleCancel() {
1249
+ const {
1250
+ onAbort,
1251
+ onCancel
1252
+ } = this.props;
1253
+ this.detach();
1254
+ if (!this.activated) {
1255
+ onAbort(this.props.active);
1256
+ }
1257
+ onCancel();
1258
+ }
1259
+ handleKeydown(event) {
1260
+ if (event.code === KeyboardCode.Esc) {
1261
+ this.handleCancel();
1262
+ }
1263
+ }
1264
+ removeTextSelection() {
1265
+ var _this$document$getSel;
1266
+ (_this$document$getSel = this.document.getSelection()) == null ? void 0 : _this$document$getSel.removeAllRanges();
1267
+ }
1268
+ }
1269
+ const events = {
1270
+ cancel: {
1271
+ name: "pointercancel"
1272
+ },
1273
+ move: {
1274
+ name: "pointermove"
1275
+ },
1276
+ end: {
1277
+ name: "pointerup"
1278
+ }
1279
+ };
1280
+ class PointerSensor extends AbstractPointerSensor {
1281
+ constructor(props) {
1282
+ const {
1283
+ event
1284
+ } = props;
1285
+ const listenerTarget = getOwnerDocument(event.target);
1286
+ super(props, events, listenerTarget);
1287
+ }
1288
+ }
1289
+ PointerSensor.activators = [{
1290
+ eventName: "onPointerDown",
1291
+ handler: (_ref, _ref2) => {
1292
+ let {
1293
+ nativeEvent: event
1294
+ } = _ref;
1295
+ let {
1296
+ onActivation
1297
+ } = _ref2;
1298
+ if (!event.isPrimary || event.button !== 0) {
1299
+ return false;
1300
+ }
1301
+ onActivation == null ? void 0 : onActivation({
1302
+ event
1303
+ });
1304
+ return true;
1305
+ }
1306
+ }];
1307
+ const events$1 = {
1308
+ move: {
1309
+ name: "mousemove"
1310
+ },
1311
+ end: {
1312
+ name: "mouseup"
1313
+ }
1314
+ };
1315
+ var MouseButton;
1316
+ (function(MouseButton2) {
1317
+ MouseButton2[MouseButton2["RightClick"] = 2] = "RightClick";
1318
+ })(MouseButton || (MouseButton = {}));
1319
+ class MouseSensor extends AbstractPointerSensor {
1320
+ constructor(props) {
1321
+ super(props, events$1, getOwnerDocument(props.event.target));
1322
+ }
1323
+ }
1324
+ MouseSensor.activators = [{
1325
+ eventName: "onMouseDown",
1326
+ handler: (_ref, _ref2) => {
1327
+ let {
1328
+ nativeEvent: event
1329
+ } = _ref;
1330
+ let {
1331
+ onActivation
1332
+ } = _ref2;
1333
+ if (event.button === MouseButton.RightClick) {
1334
+ return false;
1335
+ }
1336
+ onActivation == null ? void 0 : onActivation({
1337
+ event
1338
+ });
1339
+ return true;
1340
+ }
1341
+ }];
1342
+ const events$2 = {
1343
+ cancel: {
1344
+ name: "touchcancel"
1345
+ },
1346
+ move: {
1347
+ name: "touchmove"
1348
+ },
1349
+ end: {
1350
+ name: "touchend"
1351
+ }
1352
+ };
1353
+ class TouchSensor extends AbstractPointerSensor {
1354
+ constructor(props) {
1355
+ super(props, events$2);
1356
+ }
1357
+ static setup() {
1358
+ window.addEventListener(events$2.move.name, noop2, {
1359
+ capture: false,
1360
+ passive: false
1361
+ });
1362
+ return function teardown() {
1363
+ window.removeEventListener(events$2.move.name, noop2);
1364
+ };
1365
+ function noop2() {
1366
+ }
1367
+ }
1368
+ }
1369
+ TouchSensor.activators = [{
1370
+ eventName: "onTouchStart",
1371
+ handler: (_ref, _ref2) => {
1372
+ let {
1373
+ nativeEvent: event
1374
+ } = _ref;
1375
+ let {
1376
+ onActivation
1377
+ } = _ref2;
1378
+ const {
1379
+ touches
1380
+ } = event;
1381
+ if (touches.length > 1) {
1382
+ return false;
1383
+ }
1384
+ onActivation == null ? void 0 : onActivation({
1385
+ event
1386
+ });
1387
+ return true;
1388
+ }
1389
+ }];
1390
+ var AutoScrollActivator;
1391
+ (function(AutoScrollActivator2) {
1392
+ AutoScrollActivator2[AutoScrollActivator2["Pointer"] = 0] = "Pointer";
1393
+ AutoScrollActivator2[AutoScrollActivator2["DraggableRect"] = 1] = "DraggableRect";
1394
+ })(AutoScrollActivator || (AutoScrollActivator = {}));
1395
+ var TraversalOrder;
1396
+ (function(TraversalOrder2) {
1397
+ TraversalOrder2[TraversalOrder2["TreeOrder"] = 0] = "TreeOrder";
1398
+ TraversalOrder2[TraversalOrder2["ReversedTreeOrder"] = 1] = "ReversedTreeOrder";
1399
+ })(TraversalOrder || (TraversalOrder = {}));
1400
+ function useAutoScroller(_ref) {
1401
+ let {
1402
+ acceleration,
1403
+ activator = AutoScrollActivator.Pointer,
1404
+ canScroll,
1405
+ draggingRect,
1406
+ enabled,
1407
+ interval = 5,
1408
+ order = TraversalOrder.TreeOrder,
1409
+ pointerCoordinates,
1410
+ scrollableAncestors,
1411
+ scrollableAncestorRects,
1412
+ delta,
1413
+ threshold
1414
+ } = _ref;
1415
+ const scrollIntent = useScrollIntent({
1416
+ delta,
1417
+ disabled: !enabled
1418
+ });
1419
+ const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();
1420
+ const scrollSpeed = useRef({
1421
+ x: 0,
1422
+ y: 0
1423
+ });
1424
+ const scrollDirection = useRef({
1425
+ x: 0,
1426
+ y: 0
1427
+ });
1428
+ const rect = useMemo(() => {
1429
+ switch (activator) {
1430
+ case AutoScrollActivator.Pointer:
1431
+ return pointerCoordinates ? {
1432
+ top: pointerCoordinates.y,
1433
+ bottom: pointerCoordinates.y,
1434
+ left: pointerCoordinates.x,
1435
+ right: pointerCoordinates.x
1436
+ } : null;
1437
+ case AutoScrollActivator.DraggableRect:
1438
+ return draggingRect;
1439
+ }
1440
+ }, [activator, draggingRect, pointerCoordinates]);
1441
+ const scrollContainerRef = useRef(null);
1442
+ const autoScroll = useCallback(() => {
1443
+ const scrollContainer = scrollContainerRef.current;
1444
+ if (!scrollContainer) {
1445
+ return;
1446
+ }
1447
+ const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
1448
+ const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;
1449
+ scrollContainer.scrollBy(scrollLeft, scrollTop);
1450
+ }, []);
1451
+ const sortedScrollableAncestors = useMemo(() => order === TraversalOrder.TreeOrder ? [...scrollableAncestors].reverse() : scrollableAncestors, [order, scrollableAncestors]);
1452
+ useEffect(
1453
+ () => {
1454
+ if (!enabled || !scrollableAncestors.length || !rect) {
1455
+ clearAutoScrollInterval();
1456
+ return;
1457
+ }
1458
+ for (const scrollContainer of sortedScrollableAncestors) {
1459
+ if ((canScroll == null ? void 0 : canScroll(scrollContainer)) === false) {
1460
+ continue;
1461
+ }
1462
+ const index = scrollableAncestors.indexOf(scrollContainer);
1463
+ const scrollContainerRect = scrollableAncestorRects[index];
1464
+ if (!scrollContainerRect) {
1465
+ continue;
1466
+ }
1467
+ const {
1468
+ direction,
1469
+ speed
1470
+ } = getScrollDirectionAndSpeed(scrollContainer, scrollContainerRect, rect, acceleration, threshold);
1471
+ for (const axis of ["x", "y"]) {
1472
+ if (!scrollIntent[axis][direction[axis]]) {
1473
+ speed[axis] = 0;
1474
+ direction[axis] = 0;
1475
+ }
1476
+ }
1477
+ if (speed.x > 0 || speed.y > 0) {
1478
+ clearAutoScrollInterval();
1479
+ scrollContainerRef.current = scrollContainer;
1480
+ setAutoScrollInterval(autoScroll, interval);
1481
+ scrollSpeed.current = speed;
1482
+ scrollDirection.current = direction;
1483
+ return;
1484
+ }
1485
+ }
1486
+ scrollSpeed.current = {
1487
+ x: 0,
1488
+ y: 0
1489
+ };
1490
+ scrollDirection.current = {
1491
+ x: 0,
1492
+ y: 0
1493
+ };
1494
+ clearAutoScrollInterval();
1495
+ },
1496
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1497
+ [
1498
+ acceleration,
1499
+ autoScroll,
1500
+ canScroll,
1501
+ clearAutoScrollInterval,
1502
+ enabled,
1503
+ interval,
1504
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1505
+ JSON.stringify(rect),
1506
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1507
+ JSON.stringify(scrollIntent),
1508
+ setAutoScrollInterval,
1509
+ scrollableAncestors,
1510
+ sortedScrollableAncestors,
1511
+ scrollableAncestorRects,
1512
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1513
+ JSON.stringify(threshold)
1514
+ ]
1515
+ );
1516
+ }
1517
+ const defaultScrollIntent = {
1518
+ x: {
1519
+ [Direction.Backward]: false,
1520
+ [Direction.Forward]: false
1521
+ },
1522
+ y: {
1523
+ [Direction.Backward]: false,
1524
+ [Direction.Forward]: false
1525
+ }
1526
+ };
1527
+ function useScrollIntent(_ref2) {
1528
+ let {
1529
+ delta,
1530
+ disabled
1531
+ } = _ref2;
1532
+ const previousDelta = usePrevious(delta);
1533
+ return useLazyMemo((previousIntent) => {
1534
+ if (disabled || !previousDelta || !previousIntent) {
1535
+ return defaultScrollIntent;
1536
+ }
1537
+ const direction = {
1538
+ x: Math.sign(delta.x - previousDelta.x),
1539
+ y: Math.sign(delta.y - previousDelta.y)
1540
+ };
1541
+ return {
1542
+ x: {
1543
+ [Direction.Backward]: previousIntent.x[Direction.Backward] || direction.x === -1,
1544
+ [Direction.Forward]: previousIntent.x[Direction.Forward] || direction.x === 1
1545
+ },
1546
+ y: {
1547
+ [Direction.Backward]: previousIntent.y[Direction.Backward] || direction.y === -1,
1548
+ [Direction.Forward]: previousIntent.y[Direction.Forward] || direction.y === 1
1549
+ }
1550
+ };
1551
+ }, [disabled, delta, previousDelta]);
1552
+ }
1553
+ function useCachedNode(draggableNodes, id) {
1554
+ const draggableNode = id != null ? draggableNodes.get(id) : void 0;
1555
+ const node = draggableNode ? draggableNode.node.current : null;
1556
+ return useLazyMemo((cachedNode) => {
1557
+ var _ref;
1558
+ if (id == null) {
1559
+ return null;
1560
+ }
1561
+ return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
1562
+ }, [node, id]);
1563
+ }
1564
+ function useCombineActivators(sensors, getSyntheticHandler) {
1565
+ return useMemo(() => sensors.reduce((accumulator, sensor) => {
1566
+ const {
1567
+ sensor: Sensor
1568
+ } = sensor;
1569
+ const sensorActivators = Sensor.activators.map((activator) => ({
1570
+ eventName: activator.eventName,
1571
+ handler: getSyntheticHandler(activator.handler, sensor)
1572
+ }));
1573
+ return [...accumulator, ...sensorActivators];
1574
+ }, []), [sensors, getSyntheticHandler]);
1575
+ }
1576
+ var MeasuringStrategy;
1577
+ (function(MeasuringStrategy2) {
1578
+ MeasuringStrategy2[MeasuringStrategy2["Always"] = 0] = "Always";
1579
+ MeasuringStrategy2[MeasuringStrategy2["BeforeDragging"] = 1] = "BeforeDragging";
1580
+ MeasuringStrategy2[MeasuringStrategy2["WhileDragging"] = 2] = "WhileDragging";
1581
+ })(MeasuringStrategy || (MeasuringStrategy = {}));
1582
+ var MeasuringFrequency;
1583
+ (function(MeasuringFrequency2) {
1584
+ MeasuringFrequency2["Optimized"] = "optimized";
1585
+ })(MeasuringFrequency || (MeasuringFrequency = {}));
1586
+ const defaultValue = /* @__PURE__ */ new Map();
1587
+ function useDroppableMeasuring(containers, _ref) {
1588
+ let {
1589
+ dragging,
1590
+ dependencies,
1591
+ config
1592
+ } = _ref;
1593
+ const [queue, setQueue] = useState(null);
1594
+ const {
1595
+ frequency,
1596
+ measure,
1597
+ strategy
1598
+ } = config;
1599
+ const containersRef = useRef(containers);
1600
+ const disabled = isDisabled();
1601
+ const disabledRef = useLatestValue(disabled);
1602
+ const measureDroppableContainers = useCallback(function(ids) {
1603
+ if (ids === void 0) {
1604
+ ids = [];
1605
+ }
1606
+ if (disabledRef.current) {
1607
+ return;
1608
+ }
1609
+ setQueue((value) => {
1610
+ if (value === null) {
1611
+ return ids;
1612
+ }
1613
+ return value.concat(ids.filter((id) => !value.includes(id)));
1614
+ });
1615
+ }, [disabledRef]);
1616
+ const timeoutId = useRef(null);
1617
+ const droppableRects = useLazyMemo((previousValue) => {
1618
+ if (disabled && !dragging) {
1619
+ return defaultValue;
1620
+ }
1621
+ if (!previousValue || previousValue === defaultValue || containersRef.current !== containers || queue != null) {
1622
+ const map = /* @__PURE__ */ new Map();
1623
+ for (let container of containers) {
1624
+ if (!container) {
1625
+ continue;
1626
+ }
1627
+ if (queue && queue.length > 0 && !queue.includes(container.id) && container.rect.current) {
1628
+ map.set(container.id, container.rect.current);
1629
+ continue;
1630
+ }
1631
+ const node = container.node.current;
1632
+ const rect = node ? new Rect(measure(node), node) : null;
1633
+ container.rect.current = rect;
1634
+ if (rect) {
1635
+ map.set(container.id, rect);
1636
+ }
1637
+ }
1638
+ return map;
1639
+ }
1640
+ return previousValue;
1641
+ }, [containers, queue, dragging, disabled, measure]);
1642
+ useEffect(() => {
1643
+ containersRef.current = containers;
1644
+ }, [containers]);
1645
+ useEffect(
1646
+ () => {
1647
+ if (disabled) {
1648
+ return;
1649
+ }
1650
+ measureDroppableContainers();
1651
+ },
1652
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1653
+ [dragging, disabled]
1654
+ );
1655
+ useEffect(
1656
+ () => {
1657
+ if (queue && queue.length > 0) {
1658
+ setQueue(null);
1659
+ }
1660
+ },
1661
+ //eslint-disable-next-line react-hooks/exhaustive-deps
1662
+ [JSON.stringify(queue)]
1663
+ );
1664
+ useEffect(
1665
+ () => {
1666
+ if (disabled || typeof frequency !== "number" || timeoutId.current !== null) {
1667
+ return;
1668
+ }
1669
+ timeoutId.current = setTimeout(() => {
1670
+ measureDroppableContainers();
1671
+ timeoutId.current = null;
1672
+ }, frequency);
1673
+ },
1674
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1675
+ [frequency, disabled, measureDroppableContainers, ...dependencies]
1676
+ );
1677
+ return {
1678
+ droppableRects,
1679
+ measureDroppableContainers,
1680
+ measuringScheduled: queue != null
1681
+ };
1682
+ function isDisabled() {
1683
+ switch (strategy) {
1684
+ case MeasuringStrategy.Always:
1685
+ return false;
1686
+ case MeasuringStrategy.BeforeDragging:
1687
+ return dragging;
1688
+ default:
1689
+ return !dragging;
1690
+ }
1691
+ }
1692
+ }
1693
+ function useInitialValue(value, computeFn) {
1694
+ return useLazyMemo((previousValue) => {
1695
+ if (!value) {
1696
+ return null;
1697
+ }
1698
+ if (previousValue) {
1699
+ return previousValue;
1700
+ }
1701
+ return typeof computeFn === "function" ? computeFn(value) : value;
1702
+ }, [computeFn, value]);
1703
+ }
1704
+ function useInitialRect(node, measure) {
1705
+ return useInitialValue(node, measure);
1706
+ }
1707
+ function useMutationObserver(_ref) {
1708
+ let {
1709
+ callback,
1710
+ disabled
1711
+ } = _ref;
1712
+ const handleMutations = useEvent(callback);
1713
+ const mutationObserver = useMemo(() => {
1714
+ if (disabled || typeof window === "undefined" || typeof window.MutationObserver === "undefined") {
1715
+ return void 0;
1716
+ }
1717
+ const {
1718
+ MutationObserver
1719
+ } = window;
1720
+ return new MutationObserver(handleMutations);
1721
+ }, [handleMutations, disabled]);
1722
+ useEffect(() => {
1723
+ return () => mutationObserver == null ? void 0 : mutationObserver.disconnect();
1724
+ }, [mutationObserver]);
1725
+ return mutationObserver;
1726
+ }
1727
+ function useResizeObserver(_ref) {
1728
+ let {
1729
+ callback,
1730
+ disabled
1731
+ } = _ref;
1732
+ const handleResize = useEvent(callback);
1733
+ const resizeObserver = useMemo(
1734
+ () => {
1735
+ if (disabled || typeof window === "undefined" || typeof window.ResizeObserver === "undefined") {
1736
+ return void 0;
1737
+ }
1738
+ const {
1739
+ ResizeObserver
1740
+ } = window;
1741
+ return new ResizeObserver(handleResize);
1742
+ },
1743
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1744
+ [disabled]
1745
+ );
1746
+ useEffect(() => {
1747
+ return () => resizeObserver == null ? void 0 : resizeObserver.disconnect();
1748
+ }, [resizeObserver]);
1749
+ return resizeObserver;
1750
+ }
1751
+ function defaultMeasure(element) {
1752
+ return new Rect(getClientRect(element), element);
1753
+ }
1754
+ function useRect(element, measure, fallbackRect) {
1755
+ if (measure === void 0) {
1756
+ measure = defaultMeasure;
1757
+ }
1758
+ const [rect, setRect] = useState(null);
1759
+ function measureRect() {
1760
+ setRect((currentRect) => {
1761
+ if (!element) {
1762
+ return null;
1763
+ }
1764
+ if (element.isConnected === false) {
1765
+ var _ref;
1766
+ return (_ref = currentRect != null ? currentRect : fallbackRect) != null ? _ref : null;
1767
+ }
1768
+ const newRect = measure(element);
1769
+ if (JSON.stringify(currentRect) === JSON.stringify(newRect)) {
1770
+ return currentRect;
1771
+ }
1772
+ return newRect;
1773
+ });
1774
+ }
1775
+ const mutationObserver = useMutationObserver({
1776
+ callback(records) {
1777
+ if (!element) {
1778
+ return;
1779
+ }
1780
+ for (const record of records) {
1781
+ const {
1782
+ type,
1783
+ target
1784
+ } = record;
1785
+ if (type === "childList" && target instanceof HTMLElement && target.contains(element)) {
1786
+ measureRect();
1787
+ break;
1788
+ }
1789
+ }
1790
+ }
1791
+ });
1792
+ const resizeObserver = useResizeObserver({
1793
+ callback: measureRect
1794
+ });
1795
+ useIsomorphicLayoutEffect(() => {
1796
+ measureRect();
1797
+ if (element) {
1798
+ resizeObserver == null ? void 0 : resizeObserver.observe(element);
1799
+ mutationObserver == null ? void 0 : mutationObserver.observe(document.body, {
1800
+ childList: true,
1801
+ subtree: true
1802
+ });
1803
+ } else {
1804
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
1805
+ mutationObserver == null ? void 0 : mutationObserver.disconnect();
1806
+ }
1807
+ }, [element]);
1808
+ return rect;
1809
+ }
1810
+ function useRectDelta(rect) {
1811
+ const initialRect = useInitialValue(rect);
1812
+ return getRectDelta(rect, initialRect);
1813
+ }
1814
+ const defaultValue$1 = [];
1815
+ function useScrollableAncestors(node) {
1816
+ const previousNode = useRef(node);
1817
+ const ancestors = useLazyMemo((previousValue) => {
1818
+ if (!node) {
1819
+ return defaultValue$1;
1820
+ }
1821
+ if (previousValue && previousValue !== defaultValue$1 && node && previousNode.current && node.parentNode === previousNode.current.parentNode) {
1822
+ return previousValue;
1823
+ }
1824
+ return getScrollableAncestors(node);
1825
+ }, [node]);
1826
+ useEffect(() => {
1827
+ previousNode.current = node;
1828
+ }, [node]);
1829
+ return ancestors;
1830
+ }
1831
+ function useScrollOffsets(elements) {
1832
+ const [scrollCoordinates, setScrollCoordinates] = useState(null);
1833
+ const prevElements = useRef(elements);
1834
+ const handleScroll = useCallback((event) => {
1835
+ const scrollingElement = getScrollableElement(event.target);
1836
+ if (!scrollingElement) {
1837
+ return;
1838
+ }
1839
+ setScrollCoordinates((scrollCoordinates2) => {
1840
+ if (!scrollCoordinates2) {
1841
+ return null;
1842
+ }
1843
+ scrollCoordinates2.set(scrollingElement, getScrollCoordinates(scrollingElement));
1844
+ return new Map(scrollCoordinates2);
1845
+ });
1846
+ }, []);
1847
+ useEffect(() => {
1848
+ const previousElements = prevElements.current;
1849
+ if (elements !== previousElements) {
1850
+ cleanup(previousElements);
1851
+ const entries = elements.map((element) => {
1852
+ const scrollableElement = getScrollableElement(element);
1853
+ if (scrollableElement) {
1854
+ scrollableElement.addEventListener("scroll", handleScroll, {
1855
+ passive: true
1856
+ });
1857
+ return [scrollableElement, getScrollCoordinates(scrollableElement)];
1858
+ }
1859
+ return null;
1860
+ }).filter((entry) => entry != null);
1861
+ setScrollCoordinates(entries.length ? new Map(entries) : null);
1862
+ prevElements.current = elements;
1863
+ }
1864
+ return () => {
1865
+ cleanup(elements);
1866
+ cleanup(previousElements);
1867
+ };
1868
+ function cleanup(elements2) {
1869
+ elements2.forEach((element) => {
1870
+ const scrollableElement = getScrollableElement(element);
1871
+ scrollableElement == null ? void 0 : scrollableElement.removeEventListener("scroll", handleScroll);
1872
+ });
1873
+ }
1874
+ }, [handleScroll, elements]);
1875
+ return useMemo(() => {
1876
+ if (elements.length) {
1877
+ return scrollCoordinates ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates) : getScrollOffsets(elements);
1878
+ }
1879
+ return defaultCoordinates;
1880
+ }, [elements, scrollCoordinates]);
1881
+ }
1882
+ function useScrollOffsetsDelta(scrollOffsets, dependencies) {
1883
+ if (dependencies === void 0) {
1884
+ dependencies = [];
1885
+ }
1886
+ const initialScrollOffsets = useRef(null);
1887
+ useEffect(
1888
+ () => {
1889
+ initialScrollOffsets.current = null;
1890
+ },
1891
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1892
+ dependencies
1893
+ );
1894
+ useEffect(() => {
1895
+ const hasScrollOffsets = scrollOffsets !== defaultCoordinates;
1896
+ if (hasScrollOffsets && !initialScrollOffsets.current) {
1897
+ initialScrollOffsets.current = scrollOffsets;
1898
+ }
1899
+ if (!hasScrollOffsets && initialScrollOffsets.current) {
1900
+ initialScrollOffsets.current = null;
1901
+ }
1902
+ }, [scrollOffsets]);
1903
+ return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;
1904
+ }
1905
+ function useSensorSetup(sensors) {
1906
+ useEffect(
1907
+ () => {
1908
+ if (!canUseDOM) {
1909
+ return;
1910
+ }
1911
+ const teardownFns = sensors.map((_ref) => {
1912
+ let {
1913
+ sensor
1914
+ } = _ref;
1915
+ return sensor.setup == null ? void 0 : sensor.setup();
1916
+ });
1917
+ return () => {
1918
+ for (const teardown of teardownFns) {
1919
+ teardown == null ? void 0 : teardown();
1920
+ }
1921
+ };
1922
+ },
1923
+ // TO-DO: Sensors length could theoretically change which would not be a valid dependency
1924
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1925
+ sensors.map((_ref2) => {
1926
+ let {
1927
+ sensor
1928
+ } = _ref2;
1929
+ return sensor;
1930
+ })
1931
+ );
1932
+ }
1933
+ function useSyntheticListeners(listeners, id) {
1934
+ return useMemo(() => {
1935
+ return listeners.reduce((acc, _ref) => {
1936
+ let {
1937
+ eventName,
1938
+ handler
1939
+ } = _ref;
1940
+ acc[eventName] = (event) => {
1941
+ handler(event, id);
1942
+ };
1943
+ return acc;
1944
+ }, {});
1945
+ }, [listeners, id]);
1946
+ }
1947
+ function useWindowRect(element) {
1948
+ return useMemo(() => element ? getWindowClientRect(element) : null, [element]);
1949
+ }
1950
+ const defaultValue$2 = [];
1951
+ function useRects(elements, measure) {
1952
+ if (measure === void 0) {
1953
+ measure = getClientRect;
1954
+ }
1955
+ const [firstElement] = elements;
1956
+ const windowRect = useWindowRect(firstElement ? getWindow(firstElement) : null);
1957
+ const [rects, setRects] = useState(defaultValue$2);
1958
+ function measureRects() {
1959
+ setRects(() => {
1960
+ if (!elements.length) {
1961
+ return defaultValue$2;
1962
+ }
1963
+ return elements.map((element) => isDocumentScrollingElement(element) ? windowRect : new Rect(measure(element), element));
1964
+ });
1965
+ }
1966
+ const resizeObserver = useResizeObserver({
1967
+ callback: measureRects
1968
+ });
1969
+ useIsomorphicLayoutEffect(() => {
1970
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
1971
+ measureRects();
1972
+ elements.forEach((element) => resizeObserver == null ? void 0 : resizeObserver.observe(element));
1973
+ }, [elements]);
1974
+ return rects;
1975
+ }
1976
+ function getMeasurableNode(node) {
1977
+ if (!node) {
1978
+ return null;
1979
+ }
1980
+ if (node.children.length > 1) {
1981
+ return node;
1982
+ }
1983
+ const firstChild = node.children[0];
1984
+ return isHTMLElement(firstChild) ? firstChild : node;
1985
+ }
1986
+ function useDragOverlayMeasuring(_ref) {
1987
+ let {
1988
+ measure
1989
+ } = _ref;
1990
+ const [rect, setRect] = useState(null);
1991
+ const handleResize = useCallback((entries) => {
1992
+ for (const {
1993
+ target
1994
+ } of entries) {
1995
+ if (isHTMLElement(target)) {
1996
+ setRect((rect2) => {
1997
+ const newRect = measure(target);
1998
+ return rect2 ? {
1999
+ ...rect2,
2000
+ width: newRect.width,
2001
+ height: newRect.height
2002
+ } : newRect;
2003
+ });
2004
+ break;
2005
+ }
2006
+ }
2007
+ }, [measure]);
2008
+ const resizeObserver = useResizeObserver({
2009
+ callback: handleResize
2010
+ });
2011
+ const handleNodeChange = useCallback((element) => {
2012
+ const node = getMeasurableNode(element);
2013
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
2014
+ if (node) {
2015
+ resizeObserver == null ? void 0 : resizeObserver.observe(node);
2016
+ }
2017
+ setRect(node ? measure(node) : null);
2018
+ }, [measure, resizeObserver]);
2019
+ const [nodeRef, setRef] = useNodeRef(handleNodeChange);
2020
+ return useMemo(() => ({
2021
+ nodeRef,
2022
+ rect,
2023
+ setRef
2024
+ }), [rect, nodeRef, setRef]);
2025
+ }
2026
+ const defaultSensors = [{
2027
+ sensor: PointerSensor,
2028
+ options: {}
2029
+ }, {
2030
+ sensor: KeyboardSensor,
2031
+ options: {}
2032
+ }];
2033
+ const defaultData = {
2034
+ current: {}
2035
+ };
2036
+ const defaultMeasuringConfiguration = {
2037
+ draggable: {
2038
+ measure: getTransformAgnosticClientRect
2039
+ },
2040
+ droppable: {
2041
+ measure: getTransformAgnosticClientRect,
2042
+ strategy: MeasuringStrategy.WhileDragging,
2043
+ frequency: MeasuringFrequency.Optimized
2044
+ },
2045
+ dragOverlay: {
2046
+ measure: getClientRect
2047
+ }
2048
+ };
2049
+ class DroppableContainersMap extends Map {
2050
+ get(id) {
2051
+ var _super$get;
2052
+ return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
2053
+ }
2054
+ toArray() {
2055
+ return Array.from(this.values());
2056
+ }
2057
+ getEnabled() {
2058
+ return this.toArray().filter((_ref) => {
2059
+ let {
2060
+ disabled
2061
+ } = _ref;
2062
+ return !disabled;
2063
+ });
2064
+ }
2065
+ getNodeFor(id) {
2066
+ var _this$get$node$curren, _this$get;
2067
+ return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
2068
+ }
2069
+ }
2070
+ const defaultPublicContext = {
2071
+ activatorEvent: null,
2072
+ active: null,
2073
+ activeNode: null,
2074
+ activeNodeRect: null,
2075
+ collisions: null,
2076
+ containerNodeRect: null,
2077
+ draggableNodes: /* @__PURE__ */ new Map(),
2078
+ droppableRects: /* @__PURE__ */ new Map(),
2079
+ droppableContainers: /* @__PURE__ */ new DroppableContainersMap(),
2080
+ over: null,
2081
+ dragOverlay: {
2082
+ nodeRef: {
2083
+ current: null
2084
+ },
2085
+ rect: null,
2086
+ setRef: noop
2087
+ },
2088
+ scrollableAncestors: [],
2089
+ scrollableAncestorRects: [],
2090
+ measuringConfiguration: defaultMeasuringConfiguration,
2091
+ measureDroppableContainers: noop,
2092
+ windowRect: null,
2093
+ measuringScheduled: false
2094
+ };
2095
+ const defaultInternalContext = {
2096
+ activatorEvent: null,
2097
+ activators: [],
2098
+ active: null,
2099
+ activeNodeRect: null,
2100
+ ariaDescribedById: {
2101
+ draggable: ""
2102
+ },
2103
+ dispatch: noop,
2104
+ draggableNodes: /* @__PURE__ */ new Map(),
2105
+ over: null,
2106
+ measureDroppableContainers: noop
2107
+ };
2108
+ const InternalContext = /* @__PURE__ */ createContext(defaultInternalContext);
2109
+ const PublicContext = /* @__PURE__ */ createContext(defaultPublicContext);
2110
+ function getInitialState() {
2111
+ return {
2112
+ draggable: {
2113
+ active: null,
2114
+ initialCoordinates: {
2115
+ x: 0,
2116
+ y: 0
2117
+ },
2118
+ nodes: /* @__PURE__ */ new Map(),
2119
+ translate: {
2120
+ x: 0,
2121
+ y: 0
2122
+ }
2123
+ },
2124
+ droppable: {
2125
+ containers: new DroppableContainersMap()
2126
+ }
2127
+ };
2128
+ }
2129
+ function reducer(state, action) {
2130
+ switch (action.type) {
2131
+ case Action.DragStart:
2132
+ return {
2133
+ ...state,
2134
+ draggable: {
2135
+ ...state.draggable,
2136
+ initialCoordinates: action.initialCoordinates,
2137
+ active: action.active
2138
+ }
2139
+ };
2140
+ case Action.DragMove:
2141
+ if (state.draggable.active == null) {
2142
+ return state;
2143
+ }
2144
+ return {
2145
+ ...state,
2146
+ draggable: {
2147
+ ...state.draggable,
2148
+ translate: {
2149
+ x: action.coordinates.x - state.draggable.initialCoordinates.x,
2150
+ y: action.coordinates.y - state.draggable.initialCoordinates.y
2151
+ }
2152
+ }
2153
+ };
2154
+ case Action.DragEnd:
2155
+ case Action.DragCancel:
2156
+ return {
2157
+ ...state,
2158
+ draggable: {
2159
+ ...state.draggable,
2160
+ active: null,
2161
+ initialCoordinates: {
2162
+ x: 0,
2163
+ y: 0
2164
+ },
2165
+ translate: {
2166
+ x: 0,
2167
+ y: 0
2168
+ }
2169
+ }
2170
+ };
2171
+ case Action.RegisterDroppable: {
2172
+ const {
2173
+ element
2174
+ } = action;
2175
+ const {
2176
+ id
2177
+ } = element;
2178
+ const containers = new DroppableContainersMap(state.droppable.containers);
2179
+ containers.set(id, element);
2180
+ return {
2181
+ ...state,
2182
+ droppable: {
2183
+ ...state.droppable,
2184
+ containers
2185
+ }
2186
+ };
2187
+ }
2188
+ case Action.SetDroppableDisabled: {
2189
+ const {
2190
+ id,
2191
+ key,
2192
+ disabled
2193
+ } = action;
2194
+ const element = state.droppable.containers.get(id);
2195
+ if (!element || key !== element.key) {
2196
+ return state;
2197
+ }
2198
+ const containers = new DroppableContainersMap(state.droppable.containers);
2199
+ containers.set(id, {
2200
+ ...element,
2201
+ disabled
2202
+ });
2203
+ return {
2204
+ ...state,
2205
+ droppable: {
2206
+ ...state.droppable,
2207
+ containers
2208
+ }
2209
+ };
2210
+ }
2211
+ case Action.UnregisterDroppable: {
2212
+ const {
2213
+ id,
2214
+ key
2215
+ } = action;
2216
+ const element = state.droppable.containers.get(id);
2217
+ if (!element || key !== element.key) {
2218
+ return state;
2219
+ }
2220
+ const containers = new DroppableContainersMap(state.droppable.containers);
2221
+ containers.delete(id);
2222
+ return {
2223
+ ...state,
2224
+ droppable: {
2225
+ ...state.droppable,
2226
+ containers
2227
+ }
2228
+ };
2229
+ }
2230
+ default: {
2231
+ return state;
2232
+ }
2233
+ }
2234
+ }
2235
+ function RestoreFocus(_ref) {
2236
+ let {
2237
+ disabled
2238
+ } = _ref;
2239
+ const {
2240
+ active,
2241
+ activatorEvent,
2242
+ draggableNodes
2243
+ } = useContext(InternalContext);
2244
+ const previousActivatorEvent = usePrevious(activatorEvent);
2245
+ const previousActiveId = usePrevious(active == null ? void 0 : active.id);
2246
+ useEffect(() => {
2247
+ if (disabled) {
2248
+ return;
2249
+ }
2250
+ if (!activatorEvent && previousActivatorEvent && previousActiveId != null) {
2251
+ if (!isKeyboardEvent(previousActivatorEvent)) {
2252
+ return;
2253
+ }
2254
+ if (document.activeElement === previousActivatorEvent.target) {
2255
+ return;
2256
+ }
2257
+ const draggableNode = draggableNodes.get(previousActiveId);
2258
+ if (!draggableNode) {
2259
+ return;
2260
+ }
2261
+ const {
2262
+ activatorNode,
2263
+ node
2264
+ } = draggableNode;
2265
+ if (!activatorNode.current && !node.current) {
2266
+ return;
2267
+ }
2268
+ requestAnimationFrame(() => {
2269
+ for (const element of [activatorNode.current, node.current]) {
2270
+ if (!element) {
2271
+ continue;
2272
+ }
2273
+ const focusableNode = findFirstFocusableNode(element);
2274
+ if (focusableNode) {
2275
+ focusableNode.focus();
2276
+ break;
2277
+ }
2278
+ }
2279
+ });
2280
+ }
2281
+ }, [activatorEvent, disabled, draggableNodes, previousActiveId, previousActivatorEvent]);
2282
+ return null;
2283
+ }
2284
+ function applyModifiers(modifiers, _ref) {
2285
+ let {
2286
+ transform,
2287
+ ...args
2288
+ } = _ref;
2289
+ return modifiers != null && modifiers.length ? modifiers.reduce((accumulator, modifier) => {
2290
+ return modifier({
2291
+ transform: accumulator,
2292
+ ...args
2293
+ });
2294
+ }, transform) : transform;
2295
+ }
2296
+ function useMeasuringConfiguration(config) {
2297
+ return useMemo(
2298
+ () => ({
2299
+ draggable: {
2300
+ ...defaultMeasuringConfiguration.draggable,
2301
+ ...config == null ? void 0 : config.draggable
2302
+ },
2303
+ droppable: {
2304
+ ...defaultMeasuringConfiguration.droppable,
2305
+ ...config == null ? void 0 : config.droppable
2306
+ },
2307
+ dragOverlay: {
2308
+ ...defaultMeasuringConfiguration.dragOverlay,
2309
+ ...config == null ? void 0 : config.dragOverlay
2310
+ }
2311
+ }),
2312
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2313
+ [config == null ? void 0 : config.draggable, config == null ? void 0 : config.droppable, config == null ? void 0 : config.dragOverlay]
2314
+ );
2315
+ }
2316
+ function useLayoutShiftScrollCompensation(_ref) {
2317
+ let {
2318
+ activeNode,
2319
+ measure,
2320
+ initialRect,
2321
+ config = true
2322
+ } = _ref;
2323
+ const initialized = useRef(false);
2324
+ const {
2325
+ x,
2326
+ y
2327
+ } = typeof config === "boolean" ? {
2328
+ x: config,
2329
+ y: config
2330
+ } : config;
2331
+ useIsomorphicLayoutEffect(() => {
2332
+ const disabled = !x && !y;
2333
+ if (disabled || !activeNode) {
2334
+ initialized.current = false;
2335
+ return;
2336
+ }
2337
+ if (initialized.current || !initialRect) {
2338
+ return;
2339
+ }
2340
+ const node = activeNode == null ? void 0 : activeNode.node.current;
2341
+ if (!node || node.isConnected === false) {
2342
+ return;
2343
+ }
2344
+ const rect = measure(node);
2345
+ const rectDelta = getRectDelta(rect, initialRect);
2346
+ if (!x) {
2347
+ rectDelta.x = 0;
2348
+ }
2349
+ if (!y) {
2350
+ rectDelta.y = 0;
2351
+ }
2352
+ initialized.current = true;
2353
+ if (Math.abs(rectDelta.x) > 0 || Math.abs(rectDelta.y) > 0) {
2354
+ const firstScrollableAncestor = getFirstScrollableAncestor(node);
2355
+ if (firstScrollableAncestor) {
2356
+ firstScrollableAncestor.scrollBy({
2357
+ top: rectDelta.y,
2358
+ left: rectDelta.x
2359
+ });
2360
+ }
2361
+ }
2362
+ }, [activeNode, x, y, initialRect, measure]);
2363
+ }
2364
+ const ActiveDraggableContext = /* @__PURE__ */ createContext({
2365
+ ...defaultCoordinates,
2366
+ scaleX: 1,
2367
+ scaleY: 1
2368
+ });
2369
+ var Status;
2370
+ (function(Status2) {
2371
+ Status2[Status2["Uninitialized"] = 0] = "Uninitialized";
2372
+ Status2[Status2["Initializing"] = 1] = "Initializing";
2373
+ Status2[Status2["Initialized"] = 2] = "Initialized";
2374
+ })(Status || (Status = {}));
2375
+ const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
2376
+ var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
2377
+ let {
2378
+ id,
2379
+ accessibility,
2380
+ autoScroll = true,
2381
+ children,
2382
+ sensors = defaultSensors,
2383
+ collisionDetection = rectIntersection,
2384
+ measuring,
2385
+ modifiers,
2386
+ ...props
2387
+ } = _ref;
2388
+ const store = useReducer(reducer, void 0, getInitialState);
2389
+ const [state, dispatch] = store;
2390
+ const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
2391
+ const [status, setStatus] = useState(Status.Uninitialized);
2392
+ const isInitialized = status === Status.Initialized;
2393
+ const {
2394
+ draggable: {
2395
+ active: activeId,
2396
+ nodes: draggableNodes,
2397
+ translate
2398
+ },
2399
+ droppable: {
2400
+ containers: droppableContainers
2401
+ }
2402
+ } = state;
2403
+ const node = activeId != null ? draggableNodes.get(activeId) : null;
2404
+ const activeRects = useRef({
2405
+ initial: null,
2406
+ translated: null
2407
+ });
2408
+ const active = useMemo(() => {
2409
+ var _node$data;
2410
+ return activeId != null ? {
2411
+ id: activeId,
2412
+ // It's possible for the active node to unmount while dragging
2413
+ data: (_node$data = node == null ? void 0 : node.data) != null ? _node$data : defaultData,
2414
+ rect: activeRects
2415
+ } : null;
2416
+ }, [activeId, node]);
2417
+ const activeRef = useRef(null);
2418
+ const [activeSensor, setActiveSensor] = useState(null);
2419
+ const [activatorEvent, setActivatorEvent] = useState(null);
2420
+ const latestProps = useLatestValue(props, Object.values(props));
2421
+ const draggableDescribedById = useUniqueId("DndDescribedBy", id);
2422
+ const enabledDroppableContainers = useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
2423
+ const measuringConfiguration = useMeasuringConfiguration(measuring);
2424
+ const {
2425
+ droppableRects,
2426
+ measureDroppableContainers,
2427
+ measuringScheduled
2428
+ } = useDroppableMeasuring(enabledDroppableContainers, {
2429
+ dragging: isInitialized,
2430
+ dependencies: [translate.x, translate.y],
2431
+ config: measuringConfiguration.droppable
2432
+ });
2433
+ const activeNode = useCachedNode(draggableNodes, activeId);
2434
+ const activationCoordinates = useMemo(() => activatorEvent ? getEventCoordinates(activatorEvent) : null, [activatorEvent]);
2435
+ const autoScrollOptions = getAutoScrollerOptions();
2436
+ const initialActiveNodeRect = useInitialRect(activeNode, measuringConfiguration.draggable.measure);
2437
+ useLayoutShiftScrollCompensation({
2438
+ activeNode: activeId != null ? draggableNodes.get(activeId) : null,
2439
+ config: autoScrollOptions.layoutShiftCompensation,
2440
+ initialRect: initialActiveNodeRect,
2441
+ measure: measuringConfiguration.draggable.measure
2442
+ });
2443
+ const activeNodeRect = useRect(activeNode, measuringConfiguration.draggable.measure, initialActiveNodeRect);
2444
+ const containerNodeRect = useRect(activeNode ? activeNode.parentElement : null);
2445
+ const sensorContext = useRef({
2446
+ activatorEvent: null,
2447
+ active: null,
2448
+ activeNode,
2449
+ collisionRect: null,
2450
+ collisions: null,
2451
+ droppableRects,
2452
+ draggableNodes,
2453
+ draggingNode: null,
2454
+ draggingNodeRect: null,
2455
+ droppableContainers,
2456
+ over: null,
2457
+ scrollableAncestors: [],
2458
+ scrollAdjustedTranslate: null
2459
+ });
2460
+ const overNode = droppableContainers.getNodeFor((_sensorContext$curren = sensorContext.current.over) == null ? void 0 : _sensorContext$curren.id);
2461
+ const dragOverlay = useDragOverlayMeasuring({
2462
+ measure: measuringConfiguration.dragOverlay.measure
2463
+ });
2464
+ const draggingNode = (_dragOverlay$nodeRef$ = dragOverlay.nodeRef.current) != null ? _dragOverlay$nodeRef$ : activeNode;
2465
+ const draggingNodeRect = isInitialized ? (_dragOverlay$rect = dragOverlay.rect) != null ? _dragOverlay$rect : activeNodeRect : null;
2466
+ const usesDragOverlay = Boolean(dragOverlay.nodeRef.current && dragOverlay.rect);
2467
+ const nodeRectDelta = useRectDelta(usesDragOverlay ? null : activeNodeRect);
2468
+ const windowRect = useWindowRect(draggingNode ? getWindow(draggingNode) : null);
2469
+ const scrollableAncestors = useScrollableAncestors(isInitialized ? overNode != null ? overNode : activeNode : null);
2470
+ const scrollableAncestorRects = useRects(scrollableAncestors);
2471
+ const modifiedTranslate = applyModifiers(modifiers, {
2472
+ transform: {
2473
+ x: translate.x - nodeRectDelta.x,
2474
+ y: translate.y - nodeRectDelta.y,
2475
+ scaleX: 1,
2476
+ scaleY: 1
2477
+ },
2478
+ activatorEvent,
2479
+ active,
2480
+ activeNodeRect,
2481
+ containerNodeRect,
2482
+ draggingNodeRect,
2483
+ over: sensorContext.current.over,
2484
+ overlayNodeRect: dragOverlay.rect,
2485
+ scrollableAncestors,
2486
+ scrollableAncestorRects,
2487
+ windowRect
2488
+ });
2489
+ const pointerCoordinates = activationCoordinates ? add(activationCoordinates, translate) : null;
2490
+ const scrollOffsets = useScrollOffsets(scrollableAncestors);
2491
+ const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);
2492
+ const activeNodeScrollDelta = useScrollOffsetsDelta(scrollOffsets, [activeNodeRect]);
2493
+ const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);
2494
+ const collisionRect = draggingNodeRect ? getAdjustedRect(draggingNodeRect, modifiedTranslate) : null;
2495
+ const collisions = active && collisionRect ? collisionDetection({
2496
+ active,
2497
+ collisionRect,
2498
+ droppableRects,
2499
+ droppableContainers: enabledDroppableContainers,
2500
+ pointerCoordinates
2501
+ }) : null;
2502
+ const overId = getFirstCollision(collisions, "id");
2503
+ const [over, setOver] = useState(null);
2504
+ const appliedTranslate = usesDragOverlay ? modifiedTranslate : add(modifiedTranslate, activeNodeScrollDelta);
2505
+ const transform = adjustScale(appliedTranslate, (_over$rect = over == null ? void 0 : over.rect) != null ? _over$rect : null, activeNodeRect);
2506
+ const activeSensorRef = useRef(null);
2507
+ const instantiateSensor = useCallback(
2508
+ (event, _ref2) => {
2509
+ let {
2510
+ sensor: Sensor,
2511
+ options
2512
+ } = _ref2;
2513
+ if (activeRef.current == null) {
2514
+ return;
2515
+ }
2516
+ const activeNode2 = draggableNodes.get(activeRef.current);
2517
+ if (!activeNode2) {
2518
+ return;
2519
+ }
2520
+ const activatorEvent2 = event.nativeEvent;
2521
+ const sensorInstance = new Sensor({
2522
+ active: activeRef.current,
2523
+ activeNode: activeNode2,
2524
+ event: activatorEvent2,
2525
+ options,
2526
+ // Sensors need to be instantiated with refs for arguments that change over time
2527
+ // otherwise they are frozen in time with the stale arguments
2528
+ context: sensorContext,
2529
+ onAbort(id2) {
2530
+ const draggableNode = draggableNodes.get(id2);
2531
+ if (!draggableNode) {
2532
+ return;
2533
+ }
2534
+ const {
2535
+ onDragAbort
2536
+ } = latestProps.current;
2537
+ const event2 = {
2538
+ id: id2
2539
+ };
2540
+ onDragAbort == null ? void 0 : onDragAbort(event2);
2541
+ dispatchMonitorEvent({
2542
+ type: "onDragAbort",
2543
+ event: event2
2544
+ });
2545
+ },
2546
+ onPending(id2, constraint, initialCoordinates, offset) {
2547
+ const draggableNode = draggableNodes.get(id2);
2548
+ if (!draggableNode) {
2549
+ return;
2550
+ }
2551
+ const {
2552
+ onDragPending
2553
+ } = latestProps.current;
2554
+ const event2 = {
2555
+ id: id2,
2556
+ constraint,
2557
+ initialCoordinates,
2558
+ offset
2559
+ };
2560
+ onDragPending == null ? void 0 : onDragPending(event2);
2561
+ dispatchMonitorEvent({
2562
+ type: "onDragPending",
2563
+ event: event2
2564
+ });
2565
+ },
2566
+ onStart(initialCoordinates) {
2567
+ const id2 = activeRef.current;
2568
+ if (id2 == null) {
2569
+ return;
2570
+ }
2571
+ const draggableNode = draggableNodes.get(id2);
2572
+ if (!draggableNode) {
2573
+ return;
2574
+ }
2575
+ const {
2576
+ onDragStart
2577
+ } = latestProps.current;
2578
+ const event2 = {
2579
+ activatorEvent: activatorEvent2,
2580
+ active: {
2581
+ id: id2,
2582
+ data: draggableNode.data,
2583
+ rect: activeRects
2584
+ }
2585
+ };
2586
+ unstable_batchedUpdates(() => {
2587
+ onDragStart == null ? void 0 : onDragStart(event2);
2588
+ setStatus(Status.Initializing);
2589
+ dispatch({
2590
+ type: Action.DragStart,
2591
+ initialCoordinates,
2592
+ active: id2
2593
+ });
2594
+ dispatchMonitorEvent({
2595
+ type: "onDragStart",
2596
+ event: event2
2597
+ });
2598
+ setActiveSensor(activeSensorRef.current);
2599
+ setActivatorEvent(activatorEvent2);
2600
+ });
2601
+ },
2602
+ onMove(coordinates) {
2603
+ dispatch({
2604
+ type: Action.DragMove,
2605
+ coordinates
2606
+ });
2607
+ },
2608
+ onEnd: createHandler(Action.DragEnd),
2609
+ onCancel: createHandler(Action.DragCancel)
2610
+ });
2611
+ activeSensorRef.current = sensorInstance;
2612
+ function createHandler(type) {
2613
+ return async function handler() {
2614
+ const {
2615
+ active: active2,
2616
+ collisions: collisions2,
2617
+ over: over2,
2618
+ scrollAdjustedTranslate: scrollAdjustedTranslate2
2619
+ } = sensorContext.current;
2620
+ let event2 = null;
2621
+ if (active2 && scrollAdjustedTranslate2) {
2622
+ const {
2623
+ cancelDrop
2624
+ } = latestProps.current;
2625
+ event2 = {
2626
+ activatorEvent: activatorEvent2,
2627
+ active: active2,
2628
+ collisions: collisions2,
2629
+ delta: scrollAdjustedTranslate2,
2630
+ over: over2
2631
+ };
2632
+ if (type === Action.DragEnd && typeof cancelDrop === "function") {
2633
+ const shouldCancel = await Promise.resolve(cancelDrop(event2));
2634
+ if (shouldCancel) {
2635
+ type = Action.DragCancel;
2636
+ }
2637
+ }
2638
+ }
2639
+ activeRef.current = null;
2640
+ unstable_batchedUpdates(() => {
2641
+ dispatch({
2642
+ type
2643
+ });
2644
+ setStatus(Status.Uninitialized);
2645
+ setOver(null);
2646
+ setActiveSensor(null);
2647
+ setActivatorEvent(null);
2648
+ activeSensorRef.current = null;
2649
+ const eventName = type === Action.DragEnd ? "onDragEnd" : "onDragCancel";
2650
+ if (event2) {
2651
+ const handler2 = latestProps.current[eventName];
2652
+ handler2 == null ? void 0 : handler2(event2);
2653
+ dispatchMonitorEvent({
2654
+ type: eventName,
2655
+ event: event2
2656
+ });
2657
+ }
2658
+ });
2659
+ };
2660
+ }
2661
+ },
2662
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2663
+ [draggableNodes]
2664
+ );
2665
+ const bindActivatorToSensorInstantiator = useCallback((handler, sensor) => {
2666
+ return (event, active2) => {
2667
+ const nativeEvent = event.nativeEvent;
2668
+ const activeDraggableNode = draggableNodes.get(active2);
2669
+ if (
2670
+ // Another sensor is already instantiating
2671
+ activeRef.current !== null || // No active draggable
2672
+ !activeDraggableNode || // Event has already been captured
2673
+ nativeEvent.dndKit || nativeEvent.defaultPrevented
2674
+ ) {
2675
+ return;
2676
+ }
2677
+ const activationContext = {
2678
+ active: activeDraggableNode
2679
+ };
2680
+ const shouldActivate = handler(event, sensor.options, activationContext);
2681
+ if (shouldActivate === true) {
2682
+ nativeEvent.dndKit = {
2683
+ capturedBy: sensor.sensor
2684
+ };
2685
+ activeRef.current = active2;
2686
+ instantiateSensor(event, sensor);
2687
+ }
2688
+ };
2689
+ }, [draggableNodes, instantiateSensor]);
2690
+ const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
2691
+ useSensorSetup(sensors);
2692
+ useIsomorphicLayoutEffect(() => {
2693
+ if (activeNodeRect && status === Status.Initializing) {
2694
+ setStatus(Status.Initialized);
2695
+ }
2696
+ }, [activeNodeRect, status]);
2697
+ useEffect(
2698
+ () => {
2699
+ const {
2700
+ onDragMove
2701
+ } = latestProps.current;
2702
+ const {
2703
+ active: active2,
2704
+ activatorEvent: activatorEvent2,
2705
+ collisions: collisions2,
2706
+ over: over2
2707
+ } = sensorContext.current;
2708
+ if (!active2 || !activatorEvent2) {
2709
+ return;
2710
+ }
2711
+ const event = {
2712
+ active: active2,
2713
+ activatorEvent: activatorEvent2,
2714
+ collisions: collisions2,
2715
+ delta: {
2716
+ x: scrollAdjustedTranslate.x,
2717
+ y: scrollAdjustedTranslate.y
2718
+ },
2719
+ over: over2
2720
+ };
2721
+ unstable_batchedUpdates(() => {
2722
+ onDragMove == null ? void 0 : onDragMove(event);
2723
+ dispatchMonitorEvent({
2724
+ type: "onDragMove",
2725
+ event
2726
+ });
2727
+ });
2728
+ },
2729
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2730
+ [scrollAdjustedTranslate.x, scrollAdjustedTranslate.y]
2731
+ );
2732
+ useEffect(
2733
+ () => {
2734
+ const {
2735
+ active: active2,
2736
+ activatorEvent: activatorEvent2,
2737
+ collisions: collisions2,
2738
+ droppableContainers: droppableContainers2,
2739
+ scrollAdjustedTranslate: scrollAdjustedTranslate2
2740
+ } = sensorContext.current;
2741
+ if (!active2 || activeRef.current == null || !activatorEvent2 || !scrollAdjustedTranslate2) {
2742
+ return;
2743
+ }
2744
+ const {
2745
+ onDragOver
2746
+ } = latestProps.current;
2747
+ const overContainer = droppableContainers2.get(overId);
2748
+ const over2 = overContainer && overContainer.rect.current ? {
2749
+ id: overContainer.id,
2750
+ rect: overContainer.rect.current,
2751
+ data: overContainer.data,
2752
+ disabled: overContainer.disabled
2753
+ } : null;
2754
+ const event = {
2755
+ active: active2,
2756
+ activatorEvent: activatorEvent2,
2757
+ collisions: collisions2,
2758
+ delta: {
2759
+ x: scrollAdjustedTranslate2.x,
2760
+ y: scrollAdjustedTranslate2.y
2761
+ },
2762
+ over: over2
2763
+ };
2764
+ unstable_batchedUpdates(() => {
2765
+ setOver(over2);
2766
+ onDragOver == null ? void 0 : onDragOver(event);
2767
+ dispatchMonitorEvent({
2768
+ type: "onDragOver",
2769
+ event
2770
+ });
2771
+ });
2772
+ },
2773
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2774
+ [overId]
2775
+ );
2776
+ useIsomorphicLayoutEffect(() => {
2777
+ sensorContext.current = {
2778
+ activatorEvent,
2779
+ active,
2780
+ activeNode,
2781
+ collisionRect,
2782
+ collisions,
2783
+ droppableRects,
2784
+ draggableNodes,
2785
+ draggingNode,
2786
+ draggingNodeRect,
2787
+ droppableContainers,
2788
+ over,
2789
+ scrollableAncestors,
2790
+ scrollAdjustedTranslate
2791
+ };
2792
+ activeRects.current = {
2793
+ initial: draggingNodeRect,
2794
+ translated: collisionRect
2795
+ };
2796
+ }, [active, activeNode, collisions, collisionRect, draggableNodes, draggingNode, draggingNodeRect, droppableRects, droppableContainers, over, scrollableAncestors, scrollAdjustedTranslate]);
2797
+ useAutoScroller({
2798
+ ...autoScrollOptions,
2799
+ delta: translate,
2800
+ draggingRect: collisionRect,
2801
+ pointerCoordinates,
2802
+ scrollableAncestors,
2803
+ scrollableAncestorRects
2804
+ });
2805
+ const publicContext = useMemo(() => {
2806
+ const context = {
2807
+ active,
2808
+ activeNode,
2809
+ activeNodeRect,
2810
+ activatorEvent,
2811
+ collisions,
2812
+ containerNodeRect,
2813
+ dragOverlay,
2814
+ draggableNodes,
2815
+ droppableContainers,
2816
+ droppableRects,
2817
+ over,
2818
+ measureDroppableContainers,
2819
+ scrollableAncestors,
2820
+ scrollableAncestorRects,
2821
+ measuringConfiguration,
2822
+ measuringScheduled,
2823
+ windowRect
2824
+ };
2825
+ return context;
2826
+ }, [active, activeNode, activeNodeRect, activatorEvent, collisions, containerNodeRect, dragOverlay, draggableNodes, droppableContainers, droppableRects, over, measureDroppableContainers, scrollableAncestors, scrollableAncestorRects, measuringConfiguration, measuringScheduled, windowRect]);
2827
+ const internalContext = useMemo(() => {
2828
+ const context = {
2829
+ activatorEvent,
2830
+ activators,
2831
+ active,
2832
+ activeNodeRect,
2833
+ ariaDescribedById: {
2834
+ draggable: draggableDescribedById
2835
+ },
2836
+ dispatch,
2837
+ draggableNodes,
2838
+ over,
2839
+ measureDroppableContainers
2840
+ };
2841
+ return context;
2842
+ }, [activatorEvent, activators, active, activeNodeRect, dispatch, draggableDescribedById, draggableNodes, over, measureDroppableContainers]);
2843
+ return React__default.createElement(DndMonitorContext.Provider, {
2844
+ value: registerMonitorListener
2845
+ }, React__default.createElement(InternalContext.Provider, {
2846
+ value: internalContext
2847
+ }, React__default.createElement(PublicContext.Provider, {
2848
+ value: publicContext
2849
+ }, React__default.createElement(ActiveDraggableContext.Provider, {
2850
+ value: transform
2851
+ }, children)), React__default.createElement(RestoreFocus, {
2852
+ disabled: (accessibility == null ? void 0 : accessibility.restoreFocus) === false
2853
+ })), React__default.createElement(Accessibility, {
2854
+ ...accessibility,
2855
+ hiddenTextDescribedById: draggableDescribedById
2856
+ }));
2857
+ function getAutoScrollerOptions() {
2858
+ const activeSensorDisablesAutoscroll = (activeSensor == null ? void 0 : activeSensor.autoScrollEnabled) === false;
2859
+ const autoScrollGloballyDisabled = typeof autoScroll === "object" ? autoScroll.enabled === false : autoScroll === false;
2860
+ const enabled = isInitialized && !activeSensorDisablesAutoscroll && !autoScrollGloballyDisabled;
2861
+ if (typeof autoScroll === "object") {
2862
+ return {
2863
+ ...autoScroll,
2864
+ enabled
2865
+ };
2866
+ }
2867
+ return {
2868
+ enabled
2869
+ };
2870
+ }
2871
+ });
2872
+ const NullContext = /* @__PURE__ */ createContext(null);
2873
+ const defaultRole = "button";
2874
+ const ID_PREFIX = "Draggable";
2875
+ function useDraggable(_ref) {
2876
+ let {
2877
+ id,
2878
+ data,
2879
+ disabled = false,
2880
+ attributes
2881
+ } = _ref;
2882
+ const key = useUniqueId(ID_PREFIX);
2883
+ const {
2884
+ activators,
2885
+ activatorEvent,
2886
+ active,
2887
+ activeNodeRect,
2888
+ ariaDescribedById,
2889
+ draggableNodes,
2890
+ over
2891
+ } = useContext(InternalContext);
2892
+ const {
2893
+ role = defaultRole,
2894
+ roleDescription = "draggable",
2895
+ tabIndex = 0
2896
+ } = attributes != null ? attributes : {};
2897
+ const isDragging = (active == null ? void 0 : active.id) === id;
2898
+ const transform = useContext(isDragging ? ActiveDraggableContext : NullContext);
2899
+ const [node, setNodeRef] = useNodeRef();
2900
+ const [activatorNode, setActivatorNodeRef] = useNodeRef();
2901
+ const listeners = useSyntheticListeners(activators, id);
2902
+ const dataRef = useLatestValue(data);
2903
+ useIsomorphicLayoutEffect(
2904
+ () => {
2905
+ draggableNodes.set(id, {
2906
+ id,
2907
+ key,
2908
+ node,
2909
+ activatorNode,
2910
+ data: dataRef
2911
+ });
2912
+ return () => {
2913
+ const node2 = draggableNodes.get(id);
2914
+ if (node2 && node2.key === key) {
2915
+ draggableNodes.delete(id);
2916
+ }
2917
+ };
2918
+ },
2919
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2920
+ [draggableNodes, id]
2921
+ );
2922
+ const memoizedAttributes = useMemo(() => ({
2923
+ role,
2924
+ tabIndex,
2925
+ "aria-disabled": disabled,
2926
+ "aria-pressed": isDragging && role === defaultRole ? true : void 0,
2927
+ "aria-roledescription": roleDescription,
2928
+ "aria-describedby": ariaDescribedById.draggable
2929
+ }), [disabled, role, tabIndex, isDragging, roleDescription, ariaDescribedById.draggable]);
2930
+ return {
2931
+ active,
2932
+ activatorEvent,
2933
+ activeNodeRect,
2934
+ attributes: memoizedAttributes,
2935
+ isDragging,
2936
+ listeners: disabled ? void 0 : listeners,
2937
+ node,
2938
+ over,
2939
+ setNodeRef,
2940
+ setActivatorNodeRef,
2941
+ transform
2942
+ };
2943
+ }
2944
+ function useDndContext() {
2945
+ return useContext(PublicContext);
2946
+ }
2947
+ const ID_PREFIX$1 = "Droppable";
2948
+ const defaultResizeObserverConfig = {
2949
+ timeout: 25
2950
+ };
2951
+ function useDroppable(_ref) {
2952
+ let {
2953
+ data,
2954
+ disabled = false,
2955
+ id,
2956
+ resizeObserverConfig
2957
+ } = _ref;
2958
+ const key = useUniqueId(ID_PREFIX$1);
2959
+ const {
2960
+ active,
2961
+ dispatch,
2962
+ over,
2963
+ measureDroppableContainers
2964
+ } = useContext(InternalContext);
2965
+ const previous = useRef({
2966
+ disabled
2967
+ });
2968
+ const resizeObserverConnected = useRef(false);
2969
+ const rect = useRef(null);
2970
+ const callbackId = useRef(null);
2971
+ const {
2972
+ disabled: resizeObserverDisabled,
2973
+ updateMeasurementsFor,
2974
+ timeout: resizeObserverTimeout
2975
+ } = {
2976
+ ...defaultResizeObserverConfig,
2977
+ ...resizeObserverConfig
2978
+ };
2979
+ const ids = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
2980
+ const handleResize = useCallback(
2981
+ () => {
2982
+ if (!resizeObserverConnected.current) {
2983
+ resizeObserverConnected.current = true;
2984
+ return;
2985
+ }
2986
+ if (callbackId.current != null) {
2987
+ clearTimeout(callbackId.current);
2988
+ }
2989
+ callbackId.current = setTimeout(() => {
2990
+ measureDroppableContainers(Array.isArray(ids.current) ? ids.current : [ids.current]);
2991
+ callbackId.current = null;
2992
+ }, resizeObserverTimeout);
2993
+ },
2994
+ //eslint-disable-next-line react-hooks/exhaustive-deps
2995
+ [resizeObserverTimeout]
2996
+ );
2997
+ const resizeObserver = useResizeObserver({
2998
+ callback: handleResize,
2999
+ disabled: resizeObserverDisabled || !active
3000
+ });
3001
+ const handleNodeChange = useCallback((newElement, previousElement) => {
3002
+ if (!resizeObserver) {
3003
+ return;
3004
+ }
3005
+ if (previousElement) {
3006
+ resizeObserver.unobserve(previousElement);
3007
+ resizeObserverConnected.current = false;
3008
+ }
3009
+ if (newElement) {
3010
+ resizeObserver.observe(newElement);
3011
+ }
3012
+ }, [resizeObserver]);
3013
+ const [nodeRef, setNodeRef] = useNodeRef(handleNodeChange);
3014
+ const dataRef = useLatestValue(data);
3015
+ useEffect(() => {
3016
+ if (!resizeObserver || !nodeRef.current) {
3017
+ return;
3018
+ }
3019
+ resizeObserver.disconnect();
3020
+ resizeObserverConnected.current = false;
3021
+ resizeObserver.observe(nodeRef.current);
3022
+ }, [nodeRef, resizeObserver]);
3023
+ useEffect(
3024
+ () => {
3025
+ dispatch({
3026
+ type: Action.RegisterDroppable,
3027
+ element: {
3028
+ id,
3029
+ key,
3030
+ disabled,
3031
+ node: nodeRef,
3032
+ rect,
3033
+ data: dataRef
3034
+ }
3035
+ });
3036
+ return () => dispatch({
3037
+ type: Action.UnregisterDroppable,
3038
+ key,
3039
+ id
3040
+ });
3041
+ },
3042
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3043
+ [id]
3044
+ );
3045
+ useEffect(() => {
3046
+ if (disabled !== previous.current.disabled) {
3047
+ dispatch({
3048
+ type: Action.SetDroppableDisabled,
3049
+ id,
3050
+ key,
3051
+ disabled
3052
+ });
3053
+ previous.current.disabled = disabled;
3054
+ }
3055
+ }, [id, key, disabled, dispatch]);
3056
+ return {
3057
+ active,
3058
+ rect,
3059
+ isOver: (over == null ? void 0 : over.id) === id,
3060
+ node: nodeRef,
3061
+ over,
3062
+ setNodeRef
3063
+ };
3064
+ }
3065
+ export {
3066
+ AutoScrollActivator,
3067
+ DndContext,
3068
+ KeyboardCode,
3069
+ KeyboardSensor,
3070
+ MeasuringFrequency,
3071
+ MeasuringStrategy,
3072
+ MouseSensor,
3073
+ PointerSensor,
3074
+ TouchSensor,
3075
+ TraversalOrder,
3076
+ applyModifiers,
3077
+ closestCenter,
3078
+ closestCorners,
3079
+ defaultAnnouncements,
3080
+ defaultCoordinates,
3081
+ defaultKeyboardCoordinateGetter,
3082
+ defaultScreenReaderInstructions,
3083
+ getClientRect,
3084
+ getFirstCollision,
3085
+ getScrollableAncestors,
3086
+ rectIntersection,
3087
+ useDndContext,
3088
+ useDndMonitor,
3089
+ useDraggable,
3090
+ useDroppable,
3091
+ useSensor,
3092
+ useSensors
3093
+ };