@react-aria/dnd 3.5.4-nightly.4555 → 3.5.4-nightly.4558

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 (120) hide show
  1. package/dist/DragManager.main.js +444 -0
  2. package/dist/DragManager.main.js.map +1 -0
  3. package/dist/DragManager.mjs +435 -0
  4. package/dist/DragManager.module.js +435 -0
  5. package/dist/DragManager.module.js.map +1 -0
  6. package/dist/DragPreview.main.js +59 -0
  7. package/dist/DragPreview.main.js.map +1 -0
  8. package/dist/DragPreview.mjs +50 -0
  9. package/dist/DragPreview.module.js +50 -0
  10. package/dist/DragPreview.module.js.map +1 -0
  11. package/dist/ListDropTargetDelegate.main.js +119 -0
  12. package/dist/ListDropTargetDelegate.main.js.map +1 -0
  13. package/dist/ListDropTargetDelegate.mjs +114 -0
  14. package/dist/ListDropTargetDelegate.module.js +114 -0
  15. package/dist/ListDropTargetDelegate.module.js.map +1 -0
  16. package/dist/ar-AE.mjs +1 -1
  17. package/dist/bg-BG.mjs +1 -1
  18. package/dist/constants.main.js +65 -0
  19. package/dist/constants.main.js.map +1 -0
  20. package/dist/constants.mjs +53 -0
  21. package/dist/constants.module.js +53 -0
  22. package/dist/constants.module.js.map +1 -0
  23. package/dist/cs-CZ.mjs +1 -1
  24. package/dist/da-DK.mjs +1 -1
  25. package/dist/de-DE.mjs +1 -1
  26. package/dist/el-GR.mjs +1 -1
  27. package/dist/en-US.mjs +1 -1
  28. package/dist/es-ES.mjs +1 -1
  29. package/dist/et-EE.mjs +1 -1
  30. package/dist/fi-FI.mjs +1 -1
  31. package/dist/fr-FR.mjs +1 -1
  32. package/dist/he-IL.mjs +1 -1
  33. package/dist/hr-HR.mjs +1 -1
  34. package/dist/hu-HU.mjs +1 -1
  35. package/dist/import.mjs +12 -2582
  36. package/dist/intlStrings.main.js +108 -0
  37. package/dist/intlStrings.main.js.map +1 -0
  38. package/dist/intlStrings.mjs +110 -0
  39. package/dist/intlStrings.module.js +110 -0
  40. package/dist/intlStrings.module.js.map +1 -0
  41. package/dist/it-IT.mjs +1 -1
  42. package/dist/ja-JP.mjs +1 -1
  43. package/dist/ko-KR.mjs +1 -1
  44. package/dist/lt-LT.mjs +1 -1
  45. package/dist/lv-LV.mjs +1 -1
  46. package/dist/main.js +27 -2597
  47. package/dist/main.js.map +1 -1
  48. package/dist/module.js +12 -2582
  49. package/dist/module.js.map +1 -1
  50. package/dist/nb-NO.mjs +1 -1
  51. package/dist/nl-NL.mjs +1 -1
  52. package/dist/pl-PL.mjs +1 -1
  53. package/dist/pt-BR.mjs +1 -1
  54. package/dist/pt-PT.mjs +1 -1
  55. package/dist/ro-RO.mjs +1 -1
  56. package/dist/ru-RU.mjs +1 -1
  57. package/dist/sk-SK.mjs +1 -1
  58. package/dist/sl-SI.mjs +1 -1
  59. package/dist/sr-SP.mjs +1 -1
  60. package/dist/sv-SE.mjs +1 -1
  61. package/dist/tr-TR.mjs +1 -1
  62. package/dist/uk-UA.mjs +1 -1
  63. package/dist/useAutoScroll.main.js +89 -0
  64. package/dist/useAutoScroll.main.js.map +1 -0
  65. package/dist/useAutoScroll.mjs +84 -0
  66. package/dist/useAutoScroll.module.js +84 -0
  67. package/dist/useAutoScroll.module.js.map +1 -0
  68. package/dist/useClipboard.main.js +107 -0
  69. package/dist/useClipboard.main.js.map +1 -0
  70. package/dist/useClipboard.mjs +102 -0
  71. package/dist/useClipboard.module.js +102 -0
  72. package/dist/useClipboard.module.js.map +1 -0
  73. package/dist/useDrag.main.js +279 -0
  74. package/dist/useDrag.main.js.map +1 -0
  75. package/dist/useDrag.mjs +274 -0
  76. package/dist/useDrag.module.js +274 -0
  77. package/dist/useDrag.module.js.map +1 -0
  78. package/dist/useDraggableCollection.main.js +27 -0
  79. package/dist/useDraggableCollection.main.js.map +1 -0
  80. package/dist/useDraggableCollection.mjs +22 -0
  81. package/dist/useDraggableCollection.module.js +22 -0
  82. package/dist/useDraggableCollection.module.js.map +1 -0
  83. package/dist/useDraggableItem.main.js +128 -0
  84. package/dist/useDraggableItem.main.js.map +1 -0
  85. package/dist/useDraggableItem.mjs +123 -0
  86. package/dist/useDraggableItem.module.js +123 -0
  87. package/dist/useDraggableItem.module.js.map +1 -0
  88. package/dist/useDrop.main.js +299 -0
  89. package/dist/useDrop.main.js.map +1 -0
  90. package/dist/useDrop.mjs +294 -0
  91. package/dist/useDrop.module.js +294 -0
  92. package/dist/useDrop.module.js.map +1 -0
  93. package/dist/useDropIndicator.main.js +93 -0
  94. package/dist/useDropIndicator.main.js.map +1 -0
  95. package/dist/useDropIndicator.mjs +88 -0
  96. package/dist/useDropIndicator.module.js +88 -0
  97. package/dist/useDropIndicator.module.js.map +1 -0
  98. package/dist/useDroppableCollection.main.js +583 -0
  99. package/dist/useDroppableCollection.main.js.map +1 -0
  100. package/dist/useDroppableCollection.mjs +578 -0
  101. package/dist/useDroppableCollection.module.js +578 -0
  102. package/dist/useDroppableCollection.module.js.map +1 -0
  103. package/dist/useDroppableItem.main.js +79 -0
  104. package/dist/useDroppableItem.main.js.map +1 -0
  105. package/dist/useDroppableItem.mjs +74 -0
  106. package/dist/useDroppableItem.module.js +74 -0
  107. package/dist/useDroppableItem.module.js.map +1 -0
  108. package/dist/useVirtualDrop.main.js +56 -0
  109. package/dist/useVirtualDrop.main.js.map +1 -0
  110. package/dist/useVirtualDrop.mjs +51 -0
  111. package/dist/useVirtualDrop.module.js +51 -0
  112. package/dist/useVirtualDrop.module.js.map +1 -0
  113. package/dist/utils.main.js +283 -0
  114. package/dist/utils.main.js.map +1 -0
  115. package/dist/utils.mjs +255 -0
  116. package/dist/utils.module.js +255 -0
  117. package/dist/utils.module.js.map +1 -0
  118. package/dist/zh-CN.mjs +1 -1
  119. package/dist/zh-TW.mjs +1 -1
  120. package/package.json +11 -11
@@ -0,0 +1,294 @@
1
+ import {registerDropTarget as $67560de7c78cb232$export$c28d9fb4a54e471a} from "./DragManager.mjs";
2
+ import {DragTypes as $7252cd45fc48c07c$export$7f04ce188c91447c, globalAllowedDropOperations as $7252cd45fc48c07c$export$f0130eb70b6347b8, globalDndState as $7252cd45fc48c07c$export$6ca6700462636d0b, readFromDataTransfer as $7252cd45fc48c07c$export$d9e760437831f8b3, setGlobalDnDState as $7252cd45fc48c07c$export$6c10d32b362bfa5f, setGlobalDropEffect as $7252cd45fc48c07c$export$64f52ed7349ddb84} from "./utils.mjs";
3
+ import {DROP_EFFECT_TO_DROP_OPERATION as $103790afe9474d1c$export$608ecc6f1b23c35d, DROP_OPERATION as $103790afe9474d1c$export$60b7b4bcf3903d8e, DROP_OPERATION_ALLOWED as $103790afe9474d1c$export$9bbdfc78cf083e16, DROP_OPERATION_TO_DROP_EFFECT as $103790afe9474d1c$export$5eacb0769d26d3b2} from "./constants.mjs";
4
+ import {useVirtualDrop as $224594fe3e57ff1e$export$62447ad3d2ec7da6} from "./useVirtualDrop.mjs";
5
+ import {useState as $j5n4S$useState, useRef as $j5n4S$useRef} from "react";
6
+ import {useEffectEvent as $j5n4S$useEffectEvent, useLayoutEffect as $j5n4S$useLayoutEffect, isMac as $j5n4S$isMac, isIPad as $j5n4S$isIPad} from "@react-aria/utils";
7
+
8
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */
19
+
20
+
21
+
22
+
23
+
24
+ const $5c06e4929e123553$var$DROP_ACTIVATE_TIMEOUT = 800;
25
+ function $5c06e4929e123553$export$ccdee5eaf73cf661(options) {
26
+ let { hasDropButton: hasDropButton, isDisabled: isDisabled } = options;
27
+ let [isDropTarget, setDropTarget] = (0, $j5n4S$useState)(false);
28
+ let state = (0, $j5n4S$useRef)({
29
+ x: 0,
30
+ y: 0,
31
+ dragOverElements: new Set(),
32
+ dropEffect: "none",
33
+ allowedOperations: (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).all,
34
+ dropActivateTimer: null
35
+ }).current;
36
+ let fireDropEnter = (e)=>{
37
+ setDropTarget(true);
38
+ if (typeof options.onDropEnter === "function") {
39
+ let rect = e.currentTarget.getBoundingClientRect();
40
+ options.onDropEnter({
41
+ type: "dropenter",
42
+ x: e.clientX - rect.x,
43
+ y: e.clientY - rect.y
44
+ });
45
+ }
46
+ };
47
+ let fireDropExit = (e)=>{
48
+ setDropTarget(false);
49
+ if (typeof options.onDropExit === "function") {
50
+ let rect = e.currentTarget.getBoundingClientRect();
51
+ options.onDropExit({
52
+ type: "dropexit",
53
+ x: e.clientX - rect.x,
54
+ y: e.clientY - rect.y
55
+ });
56
+ }
57
+ };
58
+ let onDragOver = (e)=>{
59
+ e.preventDefault();
60
+ e.stopPropagation();
61
+ let allowedOperations = $5c06e4929e123553$var$getAllowedOperations(e);
62
+ if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {
63
+ e.dataTransfer.dropEffect = state.dropEffect;
64
+ return;
65
+ }
66
+ state.x = e.clientX;
67
+ state.y = e.clientY;
68
+ let prevDropEffect = state.dropEffect;
69
+ // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).
70
+ if (allowedOperations !== state.allowedOperations) {
71
+ let allowedOps = $5c06e4929e123553$var$allowedOperationsToArray(allowedOperations);
72
+ let dropOperation = allowedOps[0];
73
+ if (typeof options.getDropOperation === "function") {
74
+ let types = new (0, $7252cd45fc48c07c$export$7f04ce188c91447c)(e.dataTransfer);
75
+ dropOperation = $5c06e4929e123553$var$getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));
76
+ }
77
+ state.dropEffect = (0, $103790afe9474d1c$export$5eacb0769d26d3b2)[dropOperation] || "none";
78
+ }
79
+ if (typeof options.getDropOperationForPoint === "function") {
80
+ let types = new (0, $7252cd45fc48c07c$export$7f04ce188c91447c)(e.dataTransfer);
81
+ let rect = e.currentTarget.getBoundingClientRect();
82
+ let dropOperation = $5c06e4929e123553$var$getDropOperation(allowedOperations, options.getDropOperationForPoint(types, $5c06e4929e123553$var$allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y));
83
+ state.dropEffect = (0, $103790afe9474d1c$export$5eacb0769d26d3b2)[dropOperation] || "none";
84
+ }
85
+ state.allowedOperations = allowedOperations;
86
+ e.dataTransfer.dropEffect = state.dropEffect;
87
+ // If the drop operation changes, update state and fire events appropriately.
88
+ if (state.dropEffect === "none" && prevDropEffect !== "none") fireDropExit(e);
89
+ else if (state.dropEffect !== "none" && prevDropEffect === "none") fireDropEnter(e);
90
+ if (typeof options.onDropMove === "function" && state.dropEffect !== "none") {
91
+ let rect = e.currentTarget.getBoundingClientRect();
92
+ options.onDropMove({
93
+ type: "dropmove",
94
+ x: state.x - rect.x,
95
+ y: state.y - rect.y
96
+ });
97
+ }
98
+ clearTimeout(state.dropActivateTimer);
99
+ if (typeof options.onDropActivate === "function" && state.dropEffect !== "none") {
100
+ let rect = e.currentTarget.getBoundingClientRect();
101
+ state.dropActivateTimer = setTimeout(()=>{
102
+ options.onDropActivate({
103
+ type: "dropactivate",
104
+ x: state.x - rect.x,
105
+ y: state.y - rect.y
106
+ });
107
+ }, $5c06e4929e123553$var$DROP_ACTIVATE_TIMEOUT);
108
+ }
109
+ };
110
+ let onDragEnter = (e)=>{
111
+ e.preventDefault();
112
+ e.stopPropagation();
113
+ state.dragOverElements.add(e.target);
114
+ if (state.dragOverElements.size > 1) return;
115
+ let allowedOperationsBits = $5c06e4929e123553$var$getAllowedOperations(e);
116
+ let allowedOperations = $5c06e4929e123553$var$allowedOperationsToArray(allowedOperationsBits);
117
+ let dropOperation = allowedOperations[0];
118
+ if (typeof options.getDropOperation === "function") {
119
+ let types = new (0, $7252cd45fc48c07c$export$7f04ce188c91447c)(e.dataTransfer);
120
+ dropOperation = $5c06e4929e123553$var$getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));
121
+ }
122
+ if (typeof options.getDropOperationForPoint === "function") {
123
+ let types = new (0, $7252cd45fc48c07c$export$7f04ce188c91447c)(e.dataTransfer);
124
+ let rect = e.currentTarget.getBoundingClientRect();
125
+ dropOperation = $5c06e4929e123553$var$getDropOperation(allowedOperationsBits, options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y));
126
+ }
127
+ state.x = e.clientX;
128
+ state.y = e.clientY;
129
+ state.allowedOperations = allowedOperationsBits;
130
+ state.dropEffect = (0, $103790afe9474d1c$export$5eacb0769d26d3b2)[dropOperation] || "none";
131
+ e.dataTransfer.dropEffect = state.dropEffect;
132
+ if (dropOperation !== "cancel") fireDropEnter(e);
133
+ };
134
+ let onDragLeave = (e)=>{
135
+ e.preventDefault();
136
+ e.stopPropagation();
137
+ // We would use e.relatedTarget to detect if the drag is still inside the drop target,
138
+ // but it is always null in WebKit. https://bugs.webkit.org/show_bug.cgi?id=66547
139
+ // Instead, we track all of the targets of dragenter events in a set, and remove them
140
+ // in dragleave. When the set becomes empty, we've left the drop target completely.
141
+ // We must also remove any elements that are no longer in the DOM, because dragleave
142
+ // events will never be fired for these. This can happen, for example, with drop
143
+ // indicators between items, which disappear when the drop target changes.
144
+ state.dragOverElements.delete(e.target);
145
+ for (let element of state.dragOverElements)if (!e.currentTarget.contains(element)) state.dragOverElements.delete(element);
146
+ if (state.dragOverElements.size > 0) return;
147
+ if (state.dropEffect !== "none") fireDropExit(e);
148
+ clearTimeout(state.dropActivateTimer);
149
+ };
150
+ let onDrop = (e)=>{
151
+ e.preventDefault();
152
+ e.stopPropagation();
153
+ // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951
154
+ // Android onDragEnd always returns "none" as its drop effect.
155
+ (0, $7252cd45fc48c07c$export$64f52ed7349ddb84)(state.dropEffect);
156
+ if (typeof options.onDrop === "function") {
157
+ let dropOperation = (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[state.dropEffect];
158
+ let items = (0, $7252cd45fc48c07c$export$d9e760437831f8b3)(e.dataTransfer);
159
+ let rect = e.currentTarget.getBoundingClientRect();
160
+ let event = {
161
+ type: "drop",
162
+ x: e.clientX - rect.x,
163
+ y: e.clientY - rect.y,
164
+ items: items,
165
+ dropOperation: dropOperation
166
+ };
167
+ options.onDrop(event);
168
+ }
169
+ let dndStateSnapshot = {
170
+ ...(0, $7252cd45fc48c07c$export$6ca6700462636d0b)
171
+ };
172
+ state.dragOverElements.clear();
173
+ fireDropExit(e);
174
+ clearTimeout(state.dropActivateTimer);
175
+ // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a
176
+ // RSP collection and thus we don't need to preserve the global drop effect
177
+ if (dndStateSnapshot.draggingCollectionRef == null) (0, $7252cd45fc48c07c$export$64f52ed7349ddb84)(undefined);
178
+ else // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check.
179
+ // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target)
180
+ (0, $7252cd45fc48c07c$export$6c10d32b362bfa5f)(dndStateSnapshot);
181
+ };
182
+ let onDropEnter = (0, $j5n4S$useEffectEvent)((e)=>{
183
+ if (typeof options.onDropEnter === "function") options.onDropEnter(e);
184
+ });
185
+ let onDropExit = (0, $j5n4S$useEffectEvent)((e)=>{
186
+ if (typeof options.onDropExit === "function") options.onDropExit(e);
187
+ });
188
+ let onDropActivate = (0, $j5n4S$useEffectEvent)((e)=>{
189
+ if (typeof options.onDropActivate === "function") options.onDropActivate(e);
190
+ });
191
+ let onKeyboardDrop = (0, $j5n4S$useEffectEvent)((e)=>{
192
+ if (typeof options.onDrop === "function") options.onDrop(e);
193
+ });
194
+ let getDropOperationKeyboard = (0, $j5n4S$useEffectEvent)((types, allowedOperations)=>{
195
+ if (options.getDropOperation) return options.getDropOperation(types, allowedOperations);
196
+ return allowedOperations[0];
197
+ });
198
+ let { ref: ref } = options;
199
+ (0, $j5n4S$useLayoutEffect)(()=>{
200
+ if (isDisabled) return;
201
+ return $67560de7c78cb232$export$c28d9fb4a54e471a({
202
+ element: ref.current,
203
+ getDropOperation: getDropOperationKeyboard,
204
+ onDropEnter (e) {
205
+ setDropTarget(true);
206
+ onDropEnter(e);
207
+ },
208
+ onDropExit (e) {
209
+ setDropTarget(false);
210
+ onDropExit(e);
211
+ },
212
+ onDrop: onKeyboardDrop,
213
+ onDropActivate: onDropActivate
214
+ });
215
+ }, [
216
+ isDisabled,
217
+ ref,
218
+ getDropOperationKeyboard,
219
+ onDropEnter,
220
+ onDropExit,
221
+ onKeyboardDrop,
222
+ onDropActivate
223
+ ]);
224
+ let { dropProps: dropProps } = (0, $224594fe3e57ff1e$export$62447ad3d2ec7da6)();
225
+ if (isDisabled) return {
226
+ dropProps: {},
227
+ dropButtonProps: {
228
+ isDisabled: true
229
+ },
230
+ isDropTarget: false
231
+ };
232
+ return {
233
+ dropProps: {
234
+ ...!hasDropButton && dropProps,
235
+ onDragEnter: onDragEnter,
236
+ onDragOver: onDragOver,
237
+ onDragLeave: onDragLeave,
238
+ onDrop: onDrop
239
+ },
240
+ dropButtonProps: {
241
+ ...hasDropButton && dropProps
242
+ },
243
+ isDropTarget: isDropTarget
244
+ };
245
+ }
246
+ function $5c06e4929e123553$var$getAllowedOperations(e) {
247
+ let allowedOperations = (0, $103790afe9474d1c$export$9bbdfc78cf083e16)[e.dataTransfer.effectAllowed];
248
+ // WebKit always sets effectAllowed to "copyMove" on macOS, and "all" on iOS, regardless of what was
249
+ // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058
250
+ //
251
+ // Android Chrome also sets effectAllowed to "copyMove" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182
252
+ //
253
+ // If the drag started within the page, we can use a global variable to get the real allowed operations.
254
+ // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.
255
+ // Unfortunately, this means that link operations do not work at all in Safari.
256
+ if (0, $7252cd45fc48c07c$export$f0130eb70b6347b8) allowedOperations &= (0, $7252cd45fc48c07c$export$f0130eb70b6347b8);
257
+ // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,
258
+ // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all
259
+ // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.
260
+ // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse
261
+ //
262
+ // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465
263
+ // However, Safari does update effectAllowed correctly, so we can just rely on that.
264
+ let allowedModifiers = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
265
+ if ((0, $j5n4S$isMac)()) {
266
+ if (e.altKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).copy;
267
+ // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.
268
+ // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.
269
+ // https://bugs.webkit.org/show_bug.cgi?id=244701
270
+ if (e.ctrlKey && !(0, $j5n4S$isIPad)()) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).link;
271
+ if (e.metaKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).move;
272
+ } else {
273
+ if (e.altKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).link;
274
+ if (e.shiftKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).move;
275
+ if (e.ctrlKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).copy;
276
+ }
277
+ if (allowedModifiers) return allowedOperations & allowedModifiers;
278
+ return allowedOperations;
279
+ }
280
+ function $5c06e4929e123553$var$allowedOperationsToArray(allowedOperationsBits) {
281
+ let allowedOperations = [];
282
+ if (allowedOperationsBits & (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).move) allowedOperations.push("move");
283
+ if (allowedOperationsBits & (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).copy) allowedOperations.push("copy");
284
+ if (allowedOperationsBits & (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).link) allowedOperations.push("link");
285
+ return allowedOperations;
286
+ }
287
+ function $5c06e4929e123553$var$getDropOperation(allowedOperations, operation) {
288
+ let op = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e)[operation];
289
+ return allowedOperations & op ? operation : "cancel";
290
+ }
291
+
292
+
293
+ export {$5c06e4929e123553$export$ccdee5eaf73cf661 as useDrop};
294
+ //# sourceMappingURL=useDrop.mjs.map
@@ -0,0 +1,294 @@
1
+ import {registerDropTarget as $67560de7c78cb232$export$c28d9fb4a54e471a} from "./DragManager.module.js";
2
+ import {DragTypes as $7252cd45fc48c07c$export$7f04ce188c91447c, globalAllowedDropOperations as $7252cd45fc48c07c$export$f0130eb70b6347b8, globalDndState as $7252cd45fc48c07c$export$6ca6700462636d0b, readFromDataTransfer as $7252cd45fc48c07c$export$d9e760437831f8b3, setGlobalDnDState as $7252cd45fc48c07c$export$6c10d32b362bfa5f, setGlobalDropEffect as $7252cd45fc48c07c$export$64f52ed7349ddb84} from "./utils.module.js";
3
+ import {DROP_EFFECT_TO_DROP_OPERATION as $103790afe9474d1c$export$608ecc6f1b23c35d, DROP_OPERATION as $103790afe9474d1c$export$60b7b4bcf3903d8e, DROP_OPERATION_ALLOWED as $103790afe9474d1c$export$9bbdfc78cf083e16, DROP_OPERATION_TO_DROP_EFFECT as $103790afe9474d1c$export$5eacb0769d26d3b2} from "./constants.module.js";
4
+ import {useVirtualDrop as $224594fe3e57ff1e$export$62447ad3d2ec7da6} from "./useVirtualDrop.module.js";
5
+ import {useState as $j5n4S$useState, useRef as $j5n4S$useRef} from "react";
6
+ import {useEffectEvent as $j5n4S$useEffectEvent, useLayoutEffect as $j5n4S$useLayoutEffect, isMac as $j5n4S$isMac, isIPad as $j5n4S$isIPad} from "@react-aria/utils";
7
+
8
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */
19
+
20
+
21
+
22
+
23
+
24
+ const $5c06e4929e123553$var$DROP_ACTIVATE_TIMEOUT = 800;
25
+ function $5c06e4929e123553$export$ccdee5eaf73cf661(options) {
26
+ let { hasDropButton: hasDropButton, isDisabled: isDisabled } = options;
27
+ let [isDropTarget, setDropTarget] = (0, $j5n4S$useState)(false);
28
+ let state = (0, $j5n4S$useRef)({
29
+ x: 0,
30
+ y: 0,
31
+ dragOverElements: new Set(),
32
+ dropEffect: "none",
33
+ allowedOperations: (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).all,
34
+ dropActivateTimer: null
35
+ }).current;
36
+ let fireDropEnter = (e)=>{
37
+ setDropTarget(true);
38
+ if (typeof options.onDropEnter === "function") {
39
+ let rect = e.currentTarget.getBoundingClientRect();
40
+ options.onDropEnter({
41
+ type: "dropenter",
42
+ x: e.clientX - rect.x,
43
+ y: e.clientY - rect.y
44
+ });
45
+ }
46
+ };
47
+ let fireDropExit = (e)=>{
48
+ setDropTarget(false);
49
+ if (typeof options.onDropExit === "function") {
50
+ let rect = e.currentTarget.getBoundingClientRect();
51
+ options.onDropExit({
52
+ type: "dropexit",
53
+ x: e.clientX - rect.x,
54
+ y: e.clientY - rect.y
55
+ });
56
+ }
57
+ };
58
+ let onDragOver = (e)=>{
59
+ e.preventDefault();
60
+ e.stopPropagation();
61
+ let allowedOperations = $5c06e4929e123553$var$getAllowedOperations(e);
62
+ if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {
63
+ e.dataTransfer.dropEffect = state.dropEffect;
64
+ return;
65
+ }
66
+ state.x = e.clientX;
67
+ state.y = e.clientY;
68
+ let prevDropEffect = state.dropEffect;
69
+ // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).
70
+ if (allowedOperations !== state.allowedOperations) {
71
+ let allowedOps = $5c06e4929e123553$var$allowedOperationsToArray(allowedOperations);
72
+ let dropOperation = allowedOps[0];
73
+ if (typeof options.getDropOperation === "function") {
74
+ let types = new (0, $7252cd45fc48c07c$export$7f04ce188c91447c)(e.dataTransfer);
75
+ dropOperation = $5c06e4929e123553$var$getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));
76
+ }
77
+ state.dropEffect = (0, $103790afe9474d1c$export$5eacb0769d26d3b2)[dropOperation] || "none";
78
+ }
79
+ if (typeof options.getDropOperationForPoint === "function") {
80
+ let types = new (0, $7252cd45fc48c07c$export$7f04ce188c91447c)(e.dataTransfer);
81
+ let rect = e.currentTarget.getBoundingClientRect();
82
+ let dropOperation = $5c06e4929e123553$var$getDropOperation(allowedOperations, options.getDropOperationForPoint(types, $5c06e4929e123553$var$allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y));
83
+ state.dropEffect = (0, $103790afe9474d1c$export$5eacb0769d26d3b2)[dropOperation] || "none";
84
+ }
85
+ state.allowedOperations = allowedOperations;
86
+ e.dataTransfer.dropEffect = state.dropEffect;
87
+ // If the drop operation changes, update state and fire events appropriately.
88
+ if (state.dropEffect === "none" && prevDropEffect !== "none") fireDropExit(e);
89
+ else if (state.dropEffect !== "none" && prevDropEffect === "none") fireDropEnter(e);
90
+ if (typeof options.onDropMove === "function" && state.dropEffect !== "none") {
91
+ let rect = e.currentTarget.getBoundingClientRect();
92
+ options.onDropMove({
93
+ type: "dropmove",
94
+ x: state.x - rect.x,
95
+ y: state.y - rect.y
96
+ });
97
+ }
98
+ clearTimeout(state.dropActivateTimer);
99
+ if (typeof options.onDropActivate === "function" && state.dropEffect !== "none") {
100
+ let rect = e.currentTarget.getBoundingClientRect();
101
+ state.dropActivateTimer = setTimeout(()=>{
102
+ options.onDropActivate({
103
+ type: "dropactivate",
104
+ x: state.x - rect.x,
105
+ y: state.y - rect.y
106
+ });
107
+ }, $5c06e4929e123553$var$DROP_ACTIVATE_TIMEOUT);
108
+ }
109
+ };
110
+ let onDragEnter = (e)=>{
111
+ e.preventDefault();
112
+ e.stopPropagation();
113
+ state.dragOverElements.add(e.target);
114
+ if (state.dragOverElements.size > 1) return;
115
+ let allowedOperationsBits = $5c06e4929e123553$var$getAllowedOperations(e);
116
+ let allowedOperations = $5c06e4929e123553$var$allowedOperationsToArray(allowedOperationsBits);
117
+ let dropOperation = allowedOperations[0];
118
+ if (typeof options.getDropOperation === "function") {
119
+ let types = new (0, $7252cd45fc48c07c$export$7f04ce188c91447c)(e.dataTransfer);
120
+ dropOperation = $5c06e4929e123553$var$getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));
121
+ }
122
+ if (typeof options.getDropOperationForPoint === "function") {
123
+ let types = new (0, $7252cd45fc48c07c$export$7f04ce188c91447c)(e.dataTransfer);
124
+ let rect = e.currentTarget.getBoundingClientRect();
125
+ dropOperation = $5c06e4929e123553$var$getDropOperation(allowedOperationsBits, options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y));
126
+ }
127
+ state.x = e.clientX;
128
+ state.y = e.clientY;
129
+ state.allowedOperations = allowedOperationsBits;
130
+ state.dropEffect = (0, $103790afe9474d1c$export$5eacb0769d26d3b2)[dropOperation] || "none";
131
+ e.dataTransfer.dropEffect = state.dropEffect;
132
+ if (dropOperation !== "cancel") fireDropEnter(e);
133
+ };
134
+ let onDragLeave = (e)=>{
135
+ e.preventDefault();
136
+ e.stopPropagation();
137
+ // We would use e.relatedTarget to detect if the drag is still inside the drop target,
138
+ // but it is always null in WebKit. https://bugs.webkit.org/show_bug.cgi?id=66547
139
+ // Instead, we track all of the targets of dragenter events in a set, and remove them
140
+ // in dragleave. When the set becomes empty, we've left the drop target completely.
141
+ // We must also remove any elements that are no longer in the DOM, because dragleave
142
+ // events will never be fired for these. This can happen, for example, with drop
143
+ // indicators between items, which disappear when the drop target changes.
144
+ state.dragOverElements.delete(e.target);
145
+ for (let element of state.dragOverElements)if (!e.currentTarget.contains(element)) state.dragOverElements.delete(element);
146
+ if (state.dragOverElements.size > 0) return;
147
+ if (state.dropEffect !== "none") fireDropExit(e);
148
+ clearTimeout(state.dropActivateTimer);
149
+ };
150
+ let onDrop = (e)=>{
151
+ e.preventDefault();
152
+ e.stopPropagation();
153
+ // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951
154
+ // Android onDragEnd always returns "none" as its drop effect.
155
+ (0, $7252cd45fc48c07c$export$64f52ed7349ddb84)(state.dropEffect);
156
+ if (typeof options.onDrop === "function") {
157
+ let dropOperation = (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[state.dropEffect];
158
+ let items = (0, $7252cd45fc48c07c$export$d9e760437831f8b3)(e.dataTransfer);
159
+ let rect = e.currentTarget.getBoundingClientRect();
160
+ let event = {
161
+ type: "drop",
162
+ x: e.clientX - rect.x,
163
+ y: e.clientY - rect.y,
164
+ items: items,
165
+ dropOperation: dropOperation
166
+ };
167
+ options.onDrop(event);
168
+ }
169
+ let dndStateSnapshot = {
170
+ ...(0, $7252cd45fc48c07c$export$6ca6700462636d0b)
171
+ };
172
+ state.dragOverElements.clear();
173
+ fireDropExit(e);
174
+ clearTimeout(state.dropActivateTimer);
175
+ // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a
176
+ // RSP collection and thus we don't need to preserve the global drop effect
177
+ if (dndStateSnapshot.draggingCollectionRef == null) (0, $7252cd45fc48c07c$export$64f52ed7349ddb84)(undefined);
178
+ else // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check.
179
+ // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target)
180
+ (0, $7252cd45fc48c07c$export$6c10d32b362bfa5f)(dndStateSnapshot);
181
+ };
182
+ let onDropEnter = (0, $j5n4S$useEffectEvent)((e)=>{
183
+ if (typeof options.onDropEnter === "function") options.onDropEnter(e);
184
+ });
185
+ let onDropExit = (0, $j5n4S$useEffectEvent)((e)=>{
186
+ if (typeof options.onDropExit === "function") options.onDropExit(e);
187
+ });
188
+ let onDropActivate = (0, $j5n4S$useEffectEvent)((e)=>{
189
+ if (typeof options.onDropActivate === "function") options.onDropActivate(e);
190
+ });
191
+ let onKeyboardDrop = (0, $j5n4S$useEffectEvent)((e)=>{
192
+ if (typeof options.onDrop === "function") options.onDrop(e);
193
+ });
194
+ let getDropOperationKeyboard = (0, $j5n4S$useEffectEvent)((types, allowedOperations)=>{
195
+ if (options.getDropOperation) return options.getDropOperation(types, allowedOperations);
196
+ return allowedOperations[0];
197
+ });
198
+ let { ref: ref } = options;
199
+ (0, $j5n4S$useLayoutEffect)(()=>{
200
+ if (isDisabled) return;
201
+ return $67560de7c78cb232$export$c28d9fb4a54e471a({
202
+ element: ref.current,
203
+ getDropOperation: getDropOperationKeyboard,
204
+ onDropEnter (e) {
205
+ setDropTarget(true);
206
+ onDropEnter(e);
207
+ },
208
+ onDropExit (e) {
209
+ setDropTarget(false);
210
+ onDropExit(e);
211
+ },
212
+ onDrop: onKeyboardDrop,
213
+ onDropActivate: onDropActivate
214
+ });
215
+ }, [
216
+ isDisabled,
217
+ ref,
218
+ getDropOperationKeyboard,
219
+ onDropEnter,
220
+ onDropExit,
221
+ onKeyboardDrop,
222
+ onDropActivate
223
+ ]);
224
+ let { dropProps: dropProps } = (0, $224594fe3e57ff1e$export$62447ad3d2ec7da6)();
225
+ if (isDisabled) return {
226
+ dropProps: {},
227
+ dropButtonProps: {
228
+ isDisabled: true
229
+ },
230
+ isDropTarget: false
231
+ };
232
+ return {
233
+ dropProps: {
234
+ ...!hasDropButton && dropProps,
235
+ onDragEnter: onDragEnter,
236
+ onDragOver: onDragOver,
237
+ onDragLeave: onDragLeave,
238
+ onDrop: onDrop
239
+ },
240
+ dropButtonProps: {
241
+ ...hasDropButton && dropProps
242
+ },
243
+ isDropTarget: isDropTarget
244
+ };
245
+ }
246
+ function $5c06e4929e123553$var$getAllowedOperations(e) {
247
+ let allowedOperations = (0, $103790afe9474d1c$export$9bbdfc78cf083e16)[e.dataTransfer.effectAllowed];
248
+ // WebKit always sets effectAllowed to "copyMove" on macOS, and "all" on iOS, regardless of what was
249
+ // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058
250
+ //
251
+ // Android Chrome also sets effectAllowed to "copyMove" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182
252
+ //
253
+ // If the drag started within the page, we can use a global variable to get the real allowed operations.
254
+ // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.
255
+ // Unfortunately, this means that link operations do not work at all in Safari.
256
+ if (0, $7252cd45fc48c07c$export$f0130eb70b6347b8) allowedOperations &= (0, $7252cd45fc48c07c$export$f0130eb70b6347b8);
257
+ // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,
258
+ // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all
259
+ // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.
260
+ // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse
261
+ //
262
+ // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465
263
+ // However, Safari does update effectAllowed correctly, so we can just rely on that.
264
+ let allowedModifiers = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
265
+ if ((0, $j5n4S$isMac)()) {
266
+ if (e.altKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).copy;
267
+ // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.
268
+ // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.
269
+ // https://bugs.webkit.org/show_bug.cgi?id=244701
270
+ if (e.ctrlKey && !(0, $j5n4S$isIPad)()) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).link;
271
+ if (e.metaKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).move;
272
+ } else {
273
+ if (e.altKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).link;
274
+ if (e.shiftKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).move;
275
+ if (e.ctrlKey) allowedModifiers |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).copy;
276
+ }
277
+ if (allowedModifiers) return allowedOperations & allowedModifiers;
278
+ return allowedOperations;
279
+ }
280
+ function $5c06e4929e123553$var$allowedOperationsToArray(allowedOperationsBits) {
281
+ let allowedOperations = [];
282
+ if (allowedOperationsBits & (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).move) allowedOperations.push("move");
283
+ if (allowedOperationsBits & (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).copy) allowedOperations.push("copy");
284
+ if (allowedOperationsBits & (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).link) allowedOperations.push("link");
285
+ return allowedOperations;
286
+ }
287
+ function $5c06e4929e123553$var$getDropOperation(allowedOperations, operation) {
288
+ let op = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e)[operation];
289
+ return allowedOperations & op ? operation : "cancel";
290
+ }
291
+
292
+
293
+ export {$5c06e4929e123553$export$ccdee5eaf73cf661 as useDrop};
294
+ //# sourceMappingURL=useDrop.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAuDD,MAAM,8CAAwB;AAMvB,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAA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A,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,IAAI,wBAAwB,CAAA,GAAA,yCAAa,EAAE,IAAI,EAC7C,kBAAkB,IAAI,CAAC;IAGzB,OAAO;AACT;AAEA,SAAS,uCAAiB,iBAAiC,EAAE,SAAwB;IACnF,IAAI,KAAK,CAAA,GAAA,yCAAa,CAAC,CAAC,UAAU;IAClC,OAAO,oBAAoB,KAAK,YAAY;AAC9C","sources":["packages/@react-aria/dnd/src/useDrop.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DragEvent, HTMLAttributes, RefObject, useRef, useState} from 'react';\nimport * as DragManager from './DragManager';\nimport {DragTypes, globalAllowedDropOperations, globalDndState, readFromDataTransfer, setGlobalDnDState, setGlobalDropEffect} from './utils';\nimport {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, DROP_OPERATION_ALLOWED, DROP_OPERATION_TO_DROP_EFFECT} from './constants';\nimport {DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DropOperation, DragTypes as IDragTypes} from '@react-types/shared';\nimport {isIPad, isMac, useEffectEvent, useLayoutEffect} from '@react-aria/utils';\nimport {useVirtualDrop} from './useVirtualDrop';\n\nexport interface DropOptions {\n /** A ref for the droppable element. */\n ref: RefObject<HTMLElement>,\n /**\n * A function returning the drop operation to be performed when items matching the given types are dropped\n * on the drop target.\n */\n getDropOperation?: (types: IDragTypes, allowedOperations: DropOperation[]) => DropOperation,\n /** A function that returns the drop operation for a specific point within the target. */\n getDropOperationForPoint?: (types: IDragTypes, allowedOperations: DropOperation[], x: number, y: number) => DropOperation,\n /** Handler that is called when a valid drag enters the drop target. */\n onDropEnter?: (e: DropEnterEvent) => void,\n /** Handler that is called when a valid drag is moved within the drop target. */\n onDropMove?: (e: DropMoveEvent) => void,\n /**\n * Handler that is called after a valid drag is held over the drop target for a period of time.\n * This typically opens the item so that the user can drop within it.\n * @private\n */\n onDropActivate?: (e: DropActivateEvent) => void,\n /** Handler that is called when a valid drag exits the drop target. */\n onDropExit?: (e: DropExitEvent) => void,\n /** Handler that is called when a valid drag is dropped on the drop target. */\n onDrop?: (e: DropEvent) => void,\n /**\n * Whether the item has an explicit focusable drop affordance to initiate accessible drag and drop mode.\n * If true, the dropProps will omit these event handlers, and they will be applied to dropButtonProps instead.\n */\n hasDropButton?: boolean,\n /**\n * Whether the drop target is disabled. If true, the drop target will not accept any drops.\n */\n isDisabled?: boolean\n}\n\nexport interface DropResult {\n /** Props for the droppable element. */\n dropProps: HTMLAttributes<HTMLElement>,\n /** Whether the drop target is currently focused or hovered. */\n isDropTarget: boolean,\n /** Props for the explicit drop button affordance, if any. */\n dropButtonProps?: AriaButtonProps\n}\n\nconst DROP_ACTIVATE_TIMEOUT = 800;\n\n/**\n * Handles drop interactions for an element, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDrop(options: DropOptions): DropResult {\n let {hasDropButton, isDisabled} = options;\n let [isDropTarget, setDropTarget] = useState(false);\n let state = useRef({\n x: 0,\n y: 0,\n dragOverElements: new Set<Element>(),\n dropEffect: 'none' as DataTransfer['dropEffect'],\n allowedOperations: DROP_OPERATION.all,\n dropActivateTimer: null\n }).current;\n\n let fireDropEnter = (e: DragEvent) => {\n setDropTarget(true);\n\n if (typeof options.onDropEnter === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropEnter({\n type: 'dropenter',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let fireDropExit = (e: DragEvent) => {\n setDropTarget(false);\n\n if (typeof options.onDropExit === 'function') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropExit({\n type: 'dropexit',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y\n });\n }\n };\n\n let onDragOver = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n let allowedOperations = getAllowedOperations(e);\n if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {\n e.dataTransfer.dropEffect = state.dropEffect;\n return;\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n\n let prevDropEffect = state.dropEffect;\n\n // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).\n if (allowedOperations !== state.allowedOperations) {\n let allowedOps = allowedOperationsToArray(allowedOperations);\n let dropOperation = allowedOps[0];\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));\n }\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let dropOperation = getDropOperation(\n allowedOperations,\n options.getDropOperationForPoint(types, allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y)\n );\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n }\n\n state.allowedOperations = allowedOperations;\n e.dataTransfer.dropEffect = state.dropEffect;\n\n // If the drop operation changes, update state and fire events appropriately.\n if (state.dropEffect === 'none' && prevDropEffect !== 'none') {\n fireDropExit(e);\n } else if (state.dropEffect !== 'none' && prevDropEffect === 'none') {\n fireDropEnter(e);\n }\n\n if (typeof options.onDropMove === 'function' && state.dropEffect !== 'none') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n options.onDropMove({\n type: 'dropmove',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }\n\n clearTimeout(state.dropActivateTimer);\n\n if (typeof options.onDropActivate === 'function' && state.dropEffect !== 'none') {\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n state.dropActivateTimer = setTimeout(() => {\n options.onDropActivate({\n type: 'dropactivate',\n x: state.x - rect.x,\n y: state.y - rect.y\n });\n }, DROP_ACTIVATE_TIMEOUT);\n }\n };\n\n let onDragEnter = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n state.dragOverElements.add(e.target as Element);\n if (state.dragOverElements.size > 1) {\n return;\n }\n\n let allowedOperationsBits = getAllowedOperations(e);\n let allowedOperations = allowedOperationsToArray(allowedOperationsBits);\n let dropOperation = allowedOperations[0];\n\n if (typeof options.getDropOperation === 'function') {\n let types = new DragTypes(e.dataTransfer);\n dropOperation = getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));\n }\n\n if (typeof options.getDropOperationForPoint === 'function') {\n let types = new DragTypes(e.dataTransfer);\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n dropOperation = getDropOperation(\n allowedOperationsBits,\n options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y)\n );\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n state.allowedOperations = allowedOperationsBits;\n state.dropEffect = DROP_OPERATION_TO_DROP_EFFECT[dropOperation] || 'none';\n e.dataTransfer.dropEffect = state.dropEffect;\n\n if (dropOperation !== 'cancel') {\n fireDropEnter(e);\n }\n };\n\n let onDragLeave = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n // We would use e.relatedTarget to detect if the drag is still inside the drop target,\n // but it is always null in WebKit. https://bugs.webkit.org/show_bug.cgi?id=66547\n // Instead, we track all of the targets of dragenter events in a set, and remove them\n // in dragleave. When the set becomes empty, we've left the drop target completely.\n // We must also remove any elements that are no longer in the DOM, because dragleave\n // events will never be fired for these. This can happen, for example, with drop\n // indicators between items, which disappear when the drop target changes.\n\n state.dragOverElements.delete(e.target as Element);\n for (let element of state.dragOverElements) {\n if (!e.currentTarget.contains(element)) {\n state.dragOverElements.delete(element);\n }\n }\n\n if (state.dragOverElements.size > 0) {\n return;\n }\n\n if (state.dropEffect !== 'none') {\n fireDropExit(e);\n }\n\n clearTimeout(state.dropActivateTimer);\n };\n\n let onDrop = (e: DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951\n // Android onDragEnd always returns \"none\" as its drop effect.\n setGlobalDropEffect(state.dropEffect);\n\n if (typeof options.onDrop === 'function') {\n let dropOperation = DROP_EFFECT_TO_DROP_OPERATION[state.dropEffect];\n let items = readFromDataTransfer(e.dataTransfer);\n\n let rect = (e.currentTarget as HTMLElement).getBoundingClientRect();\n let event: DropEvent = {\n type: 'drop',\n x: e.clientX - rect.x,\n y: e.clientY - rect.y,\n items,\n dropOperation\n };\n\n options.onDrop(event);\n }\n\n let dndStateSnapshot = {...globalDndState};\n state.dragOverElements.clear();\n fireDropExit(e);\n clearTimeout(state.dropActivateTimer);\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global drop effect\n if (dndStateSnapshot.draggingCollectionRef == null) {\n setGlobalDropEffect(undefined);\n } else {\n // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check.\n // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target)\n setGlobalDnDState(dndStateSnapshot);\n }\n };\n\n let onDropEnter = useEffectEvent((e: DropEnterEvent) => {\n if (typeof options.onDropEnter === 'function') {\n options.onDropEnter(e);\n }\n });\n\n let onDropExit = useEffectEvent((e: DropExitEvent) => {\n if (typeof options.onDropExit === 'function') {\n options.onDropExit(e);\n }\n });\n\n let onDropActivate = useEffectEvent((e: DropActivateEvent) => {\n if (typeof options.onDropActivate === 'function') {\n options.onDropActivate(e);\n }\n });\n\n let onKeyboardDrop = useEffectEvent((e: DropEvent) => {\n if (typeof options.onDrop === 'function') {\n options.onDrop(e);\n }\n });\n\n let getDropOperationKeyboard = useEffectEvent((types: IDragTypes, allowedOperations: DropOperation[]) => {\n if (options.getDropOperation) {\n return options.getDropOperation(types, allowedOperations);\n }\n\n return allowedOperations[0];\n });\n\n let {ref} = options;\n useLayoutEffect(() => {\n if (isDisabled) {\n return;\n }\n return DragManager.registerDropTarget({\n element: ref.current,\n getDropOperation: getDropOperationKeyboard,\n onDropEnter(e) {\n setDropTarget(true);\n onDropEnter(e);\n },\n onDropExit(e) {\n setDropTarget(false);\n onDropExit(e);\n },\n onDrop: onKeyboardDrop,\n onDropActivate\n });\n }, [isDisabled, ref, getDropOperationKeyboard, onDropEnter, onDropExit, onKeyboardDrop, onDropActivate]);\n\n let {dropProps} = useVirtualDrop();\n if (isDisabled) {\n return {\n dropProps: {},\n dropButtonProps: {isDisabled: true},\n isDropTarget: false\n };\n }\n return {\n dropProps: {\n ...(!hasDropButton && dropProps),\n onDragEnter,\n onDragOver,\n onDragLeave,\n onDrop\n },\n dropButtonProps: {...(hasDropButton && dropProps)},\n isDropTarget\n };\n}\n\nfunction getAllowedOperations(e: DragEvent) {\n let allowedOperations = DROP_OPERATION_ALLOWED[e.dataTransfer.effectAllowed];\n\n // WebKit always sets effectAllowed to \"copyMove\" on macOS, and \"all\" on iOS, regardless of what was\n // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058\n //\n // Android Chrome also sets effectAllowed to \"copyMove\" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182\n //\n // If the drag started within the page, we can use a global variable to get the real allowed operations.\n // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.\n // Unfortunately, this means that link operations do not work at all in Safari.\n if (globalAllowedDropOperations) {\n allowedOperations &= globalAllowedDropOperations;\n }\n\n // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,\n // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all\n // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.\n // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse\n //\n // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465\n // However, Safari does update effectAllowed correctly, so we can just rely on that.\n let allowedModifiers = DROP_OPERATION.none;\n if (isMac()) {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n\n // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.\n // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.\n // https://bugs.webkit.org/show_bug.cgi?id=244701\n if (e.ctrlKey && !isIPad()) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.metaKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n } else {\n if (e.altKey) {\n allowedModifiers |= DROP_OPERATION.link;\n }\n\n if (e.shiftKey) {\n allowedModifiers |= DROP_OPERATION.move;\n }\n\n if (e.ctrlKey) {\n allowedModifiers |= DROP_OPERATION.copy;\n }\n }\n\n if (allowedModifiers) {\n return allowedOperations & allowedModifiers;\n }\n\n return allowedOperations;\n}\n\nfunction allowedOperationsToArray(allowedOperationsBits: DROP_OPERATION) {\n let allowedOperations = [];\n if (allowedOperationsBits & DROP_OPERATION.move) {\n allowedOperations.push('move');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.copy) {\n allowedOperations.push('copy');\n }\n\n if (allowedOperationsBits & DROP_OPERATION.link) {\n allowedOperations.push('link');\n }\n\n return allowedOperations;\n}\n\nfunction getDropOperation(allowedOperations: DROP_OPERATION, operation: DropOperation) {\n let op = DROP_OPERATION[operation];\n return allowedOperations & op ? operation : 'cancel';\n}\n"],"names":[],"version":3,"file":"useDrop.module.js.map"}