@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
package/dist/main.js CHANGED
@@ -1,1151 +1,36 @@
1
- var $12ee6b0bfb4232ad$exports = require("./ar-AE.main.js");
2
- var $e21ef7c55796c5e1$exports = require("./bg-BG.main.js");
3
- var $dfa9cd1c2317d9aa$exports = require("./cs-CZ.main.js");
4
- var $65fff3bbacfa8956$exports = require("./da-DK.main.js");
5
- var $10b7dfe45cd41c2d$exports = require("./de-DE.main.js");
6
- var $0cadcffb7abc96b8$exports = require("./el-GR.main.js");
7
- var $7e3982b34ddf1bdf$exports = require("./en-US.main.js");
8
- var $cb29ce0b655c4023$exports = require("./es-ES.main.js");
9
- var $067d46bab80bcf4b$exports = require("./et-EE.main.js");
10
- var $8aa1b9a1f9d783d3$exports = require("./fi-FI.main.js");
11
- var $9e248ec27f7dc55f$exports = require("./fr-FR.main.js");
12
- var $6387f7228f0de45e$exports = require("./he-IL.main.js");
13
- var $34a283567735f754$exports = require("./hr-HR.main.js");
14
- var $466590c56bee4342$exports = require("./hu-HU.main.js");
15
- var $e013896dcb6a6884$exports = require("./it-IT.main.js");
16
- var $d6121e4246c6e502$exports = require("./ja-JP.main.js");
17
- var $cf48a963c482dcba$exports = require("./ko-KR.main.js");
18
- var $b156071f04f1c899$exports = require("./lt-LT.main.js");
19
- var $5300be8ef98d39fa$exports = require("./lv-LV.main.js");
20
- var $7484477aad199932$exports = require("./nb-NO.main.js");
21
- var $968e09cb41d6cd76$exports = require("./nl-NL.main.js");
22
- var $0c2c6c954dd638d7$exports = require("./pl-PL.main.js");
23
- var $db510f249c1f2e00$exports = require("./pt-BR.main.js");
24
- var $d734686296d37387$exports = require("./pt-PT.main.js");
25
- var $d239d4998a584a23$exports = require("./ro-RO.main.js");
26
- var $a06126b47eabe64f$exports = require("./ru-RU.main.js");
27
- var $0983413fc05d96fb$exports = require("./sk-SK.main.js");
28
- var $c66896a0464692f1$exports = require("./sl-SI.main.js");
29
- var $f0d9abe43a1bcdf6$exports = require("./sr-SP.main.js");
30
- var $f3e2ce4b6d6cc4ac$exports = require("./sv-SE.main.js");
31
- var $da91b0d12d273475$exports = require("./tr-TR.main.js");
32
- var $d6f72e28f0f4871c$exports = require("./uk-UA.main.js");
33
- var $187738fbdc896f75$exports = require("./zh-CN.main.js");
34
- var $80cfc1f1f7d356d3$exports = require("./zh-TW.main.js");
35
- var $4vY0V$reactariainteractions = require("@react-aria/interactions");
36
- var $4vY0V$react = require("react");
37
- var $4vY0V$reactariautils = require("@react-aria/utils");
38
- var $4vY0V$reactariai18n = require("@react-aria/i18n");
39
- var $4vY0V$reactarialiveannouncer = require("@react-aria/live-announcer");
40
- var $4vY0V$reactariaoverlays = require("@react-aria/overlays");
41
- var $4vY0V$reactdom = require("react-dom");
1
+ var $4620ae0dc40f0031$exports = require("./utils.main.js");
2
+ var $dc204e8ec58447a6$exports = require("./useDrag.main.js");
3
+ var $1ca228bc9257ca16$exports = require("./useDrop.main.js");
4
+ var $7f93a158ac20b90a$exports = require("./useDroppableCollection.main.js");
5
+ var $fc1876157e07bcec$exports = require("./useDroppableItem.main.js");
6
+ var $c5557edbed563ebf$exports = require("./useDropIndicator.main.js");
7
+ var $0cbbd00cda972c67$exports = require("./useDraggableItem.main.js");
8
+ var $c3e901bab7fcc6ff$exports = require("./useDraggableCollection.main.js");
9
+ var $74f3dedaa4d234b4$exports = require("./useClipboard.main.js");
10
+ var $2dccaca1f4baa446$exports = require("./DragPreview.main.js");
11
+ var $2268795bbb597ecb$exports = require("./ListDropTargetDelegate.main.js");
12
+ var $28e10663603f5ea1$exports = require("./DragManager.main.js");
42
13
 
43
14
 
44
15
  function $parcel$export(e, n, v, s) {
45
16
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
46
17
  }
47
18
 
48
- function $parcel$interopDefault(a) {
49
- return a && a.__esModule ? a.default : a;
50
- }
51
-
52
- $parcel$export(module.exports, "DIRECTORY_DRAG_TYPE", () => $4620ae0dc40f0031$export$990fced5dfac2637);
53
- $parcel$export(module.exports, "useDrag", () => $dc204e8ec58447a6$export$7941f8aafa4b6021);
54
- $parcel$export(module.exports, "useDrop", () => $1ca228bc9257ca16$export$ccdee5eaf73cf661);
55
- $parcel$export(module.exports, "useDroppableCollection", () => $7f93a158ac20b90a$export$f4e2f423c21f7b04);
56
- $parcel$export(module.exports, "useDroppableItem", () => $fc1876157e07bcec$export$f7b0c5d28b66b6a5);
57
- $parcel$export(module.exports, "useDropIndicator", () => $c5557edbed563ebf$export$8d0e41d2815afac5);
58
- $parcel$export(module.exports, "useDraggableItem", () => $0cbbd00cda972c67$export$b35afafff42da2d9);
59
- $parcel$export(module.exports, "useDraggableCollection", () => $c3e901bab7fcc6ff$export$2962a7984b2f0a80);
60
- $parcel$export(module.exports, "useClipboard", () => $74f3dedaa4d234b4$export$2314ca2a3e892862);
61
- $parcel$export(module.exports, "DragPreview", () => $2dccaca1f4baa446$export$905ab40ac2179daa);
62
- $parcel$export(module.exports, "ListDropTargetDelegate", () => $2268795bbb597ecb$export$fbd65d14c79e28cc);
63
- $parcel$export(module.exports, "isVirtualDragging", () => $28e10663603f5ea1$export$403bc76cbf68cf60);
64
- $parcel$export(module.exports, "isDirectoryDropItem", () => $4620ae0dc40f0031$export$2b40a62bdbe6b2b0);
65
- $parcel$export(module.exports, "isFileDropItem", () => $4620ae0dc40f0031$export$a144e1752ebe0aa);
66
- $parcel$export(module.exports, "isTextDropItem", () => $4620ae0dc40f0031$export$97fd558bdc44bea1);
67
- /*
68
- * Copyright 2020 Adobe. All rights reserved.
69
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
70
- * you may not use this file except in compliance with the License. You may obtain a copy
71
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
72
- *
73
- * Unless required by applicable law or agreed to in writing, software distributed under
74
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
75
- * OF ANY KIND, either express or implied. See the License for the specific language
76
- * governing permissions and limitations under the License.
77
- */ /*
78
- * Copyright 2020 Adobe. All rights reserved.
79
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
80
- * you may not use this file except in compliance with the License. You may obtain a copy
81
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
82
- *
83
- * Unless required by applicable law or agreed to in writing, software distributed under
84
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
85
- * OF ANY KIND, either express or implied. See the License for the specific language
86
- * governing permissions and limitations under the License.
87
- */ /*
88
- * Copyright 2020 Adobe. All rights reserved.
89
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
90
- * you may not use this file except in compliance with the License. You may obtain a copy
91
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
92
- *
93
- * Unless required by applicable law or agreed to in writing, software distributed under
94
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
95
- * OF ANY KIND, either express or implied. See the License for the specific language
96
- * governing permissions and limitations under the License.
97
- */ var $76b1e110a27b1ccd$export$60b7b4bcf3903d8e;
98
- (function(DROP_OPERATION) {
99
- DROP_OPERATION[DROP_OPERATION["none"] = 0] = "none";
100
- DROP_OPERATION[DROP_OPERATION["cancel"] = 0] = "cancel";
101
- DROP_OPERATION[DROP_OPERATION["move"] = 1] = "move";
102
- DROP_OPERATION[DROP_OPERATION["copy"] = 2] = "copy";
103
- DROP_OPERATION[DROP_OPERATION["link"] = 4] = "link";
104
- DROP_OPERATION[DROP_OPERATION["all"] = 7] = "all";
105
- })($76b1e110a27b1ccd$export$60b7b4bcf3903d8e || ($76b1e110a27b1ccd$export$60b7b4bcf3903d8e = {}));
106
- const $76b1e110a27b1ccd$export$9bbdfc78cf083e16 = {
107
- ...$76b1e110a27b1ccd$export$60b7b4bcf3903d8e,
108
- copyMove: 3,
109
- copyLink: 6,
110
- linkMove: 5,
111
- all: 7,
112
- uninitialized: 7
113
- };
114
- const $76b1e110a27b1ccd$export$dd0165308d8bff45 = $76b1e110a27b1ccd$var$invert($76b1e110a27b1ccd$export$9bbdfc78cf083e16);
115
- $76b1e110a27b1ccd$export$dd0165308d8bff45[7] = "all"; // ensure we don't map to 'uninitialized'.
116
- const $76b1e110a27b1ccd$export$d7ebf00f36b7a95e = $76b1e110a27b1ccd$var$invert($76b1e110a27b1ccd$export$60b7b4bcf3903d8e);
117
- const $76b1e110a27b1ccd$export$608ecc6f1b23c35d = {
118
- none: "cancel",
119
- link: "link",
120
- copy: "copy",
121
- move: "move"
122
- };
123
- const $76b1e110a27b1ccd$export$5eacb0769d26d3b2 = $76b1e110a27b1ccd$var$invert($76b1e110a27b1ccd$export$608ecc6f1b23c35d);
124
- function $76b1e110a27b1ccd$var$invert(object) {
125
- let res = {};
126
- for(let key in object)res[object[key]] = key;
127
- return res;
128
- }
129
- const $76b1e110a27b1ccd$export$4a7729b856e9a690 = new Set([
130
- "text/plain",
131
- "text/uri-list",
132
- "text/html"
133
- ]);
134
- const $76b1e110a27b1ccd$export$fd9f9fc120c5402d = "application/vnd.react-aria.items+json";
135
- const $76b1e110a27b1ccd$export$f8fc6581787339b3 = "application/octet-stream";
136
-
137
-
138
-
139
- const $4620ae0dc40f0031$export$dfdf5deeaf27473f = new WeakMap();
140
- const $4620ae0dc40f0031$export$990fced5dfac2637 = Symbol();
141
- function $4620ae0dc40f0031$export$3093291712f09a77(state) {
142
- let { id: id } = $4620ae0dc40f0031$export$dfdf5deeaf27473f.get(state);
143
- if (!id) throw new Error("Droppable item outside a droppable collection");
144
- return id;
145
- }
146
- function $4620ae0dc40f0031$export$7e397efd01d3db27(state) {
147
- let { ref: ref } = $4620ae0dc40f0031$export$dfdf5deeaf27473f.get(state);
148
- if (!ref) throw new Error("Droppable item outside a droppable collection");
149
- return ref;
150
- }
151
- function $4620ae0dc40f0031$export$e1d41611756c6326(items) {
152
- let types = new Set();
153
- for (let item of items)for (let type of Object.keys(item))types.add(type);
154
- return types;
155
- }
156
- function $4620ae0dc40f0031$var$mapModality(modality) {
157
- if (!modality) modality = "virtual";
158
- if (modality === "pointer") modality = "virtual";
159
- if (modality === "virtual" && typeof window !== "undefined" && "ontouchstart" in window) modality = "touch";
160
- return modality;
161
- }
162
- function $4620ae0dc40f0031$export$49bac5d6d4b352ea() {
163
- return $4620ae0dc40f0031$var$mapModality((0, $4vY0V$reactariainteractions.useInteractionModality)());
164
- }
165
- function $4620ae0dc40f0031$export$1fb2158d224b542c() {
166
- return $4620ae0dc40f0031$var$mapModality((0, $4vY0V$reactariainteractions.getInteractionModality)());
167
- }
168
- function $4620ae0dc40f0031$export$f9c1490890ddd063(dataTransfer, items) {
169
- // The data transfer API doesn't support more than one item of a given type at once.
170
- // In addition, only a small set of types are supported natively for transfer between applications.
171
- // We allow for both multiple items, as well as multiple representations of a single item.
172
- // In order to make our API work with the native API, we serialize all items to JSON and
173
- // store as a single native item. We only need to do this if there is more than one item
174
- // of the same type, or if an item has more than one representation. Otherwise the native
175
- // API is sufficient.
176
- //
177
- // The DataTransferItemList API also theoretically supports adding files, which would enable
178
- // dragging binary data out of the browser onto the user's desktop for example. Unfortunately,
179
- // this does not currently work in any browser, so it is not currently supported by our API.
180
- // See e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=438479.
181
- let groupedByType = new Map();
182
- let needsCustomData = false;
183
- let customData = [];
184
- for (let item of items){
185
- let types = Object.keys(item);
186
- if (types.length > 1) needsCustomData = true;
187
- let dataByType = {};
188
- for (let type of types){
189
- let typeItems = groupedByType.get(type);
190
- if (!typeItems) {
191
- typeItems = [];
192
- groupedByType.set(type, typeItems);
193
- } else needsCustomData = true;
194
- let data = item[type];
195
- dataByType[type] = data;
196
- typeItems.push(data);
197
- }
198
- customData.push(dataByType);
199
- }
200
- for (let [type, items] of groupedByType)if ((0, $76b1e110a27b1ccd$export$4a7729b856e9a690).has(type)) {
201
- // Only one item of a given type can be set on a data transfer.
202
- // Join all of the items together separated by newlines.
203
- let data = items.join("\n");
204
- dataTransfer.items.add(data, type);
205
- } else // Set data to the first item so we have access to the list of types.
206
- dataTransfer.items.add(items[0], type);
207
- if (needsCustomData) {
208
- let data = JSON.stringify(customData);
209
- dataTransfer.items.add(data, (0, $76b1e110a27b1ccd$export$fd9f9fc120c5402d));
210
- }
211
- }
212
- class $4620ae0dc40f0031$export$7f04ce188c91447c {
213
- has(type) {
214
- if (this.includesUnknownTypes || type === $4620ae0dc40f0031$export$990fced5dfac2637 && this.types.has((0, $76b1e110a27b1ccd$export$f8fc6581787339b3))) return true;
215
- return typeof type === "string" && this.types.has(type);
216
- }
217
- constructor(dataTransfer){
218
- this.types = new Set();
219
- let hasFiles = false;
220
- for (let item of dataTransfer.items)if (item.type !== (0, $76b1e110a27b1ccd$export$fd9f9fc120c5402d)) {
221
- if (item.kind === "file") hasFiles = true;
222
- if (item.type) this.types.add(item.type);
223
- else // Files with unknown types or extensions that don't map to a known mime type
224
- // are sometimes exposed as an empty string by the browser. Map to a generic
225
- // mime type instead. Note that this could also be a directory as there's no
226
- // way to determine if something is a file or directory until drop.
227
- this.types.add((0, $76b1e110a27b1ccd$export$f8fc6581787339b3));
228
- }
229
- // In Safari, when dragging files, the dataTransfer.items list is empty, but dataTransfer.types contains "Files".
230
- // Unfortunately, this doesn't tell us what types of files the user is dragging, so we need to assume that any
231
- // type the user checks for is included. See https://bugs.webkit.org/show_bug.cgi?id=223517.
232
- this.includesUnknownTypes = !hasFiles && dataTransfer.types.includes("Files");
233
- }
234
- }
235
- function $4620ae0dc40f0031$export$d9e760437831f8b3(dataTransfer) {
236
- let items = [];
237
- // If our custom drag type is available, use that. This is a JSON serialized
238
- // representation of all items in the drag, set when there are multiple items
239
- // of the same type, or an individual item has multiple representations.
240
- let hasCustomType = false;
241
- if (dataTransfer.types.includes((0, $76b1e110a27b1ccd$export$fd9f9fc120c5402d))) try {
242
- let data = dataTransfer.getData((0, $76b1e110a27b1ccd$export$fd9f9fc120c5402d));
243
- let parsed = JSON.parse(data);
244
- for (let item of parsed)items.push({
245
- kind: "text",
246
- types: new Set(Object.keys(item)),
247
- getText: (type)=>Promise.resolve(item[type])
248
- });
249
- hasCustomType = true;
250
- } catch (e) {
251
- // ignore
252
- }
253
- // Otherwise, map native drag items to items of a single representation.
254
- if (!hasCustomType) {
255
- let stringItems = new Map();
256
- for (let item of dataTransfer.items){
257
- if (item.kind === "string") // The data for all formats must be read here because the data transfer gets
258
- // cleared out after the event handler finishes. If the item has an empty string
259
- // as a type, the mime type is unknown. Map to a generic mime type instead.
260
- stringItems.set(item.type || (0, $76b1e110a27b1ccd$export$f8fc6581787339b3), dataTransfer.getData(item.type));
261
- else if (item.kind === "file") {
262
- // Despite the name, webkitGetAsEntry is also implemented in Firefox and Edge.
263
- // In the future, we may use getAsFileSystemHandle instead, but that's currently
264
- // only implemented in Chrome.
265
- if (typeof item.webkitGetAsEntry === "function") {
266
- let entry = item.webkitGetAsEntry();
267
- // eslint-disable-next-line max-depth
268
- if (!entry) continue;
269
- // eslint-disable-next-line max-depth
270
- if (entry.isFile) items.push($4620ae0dc40f0031$var$createFileItem(item.getAsFile()));
271
- else if (entry.isDirectory) items.push($4620ae0dc40f0031$var$createDirectoryItem(entry));
272
- } else // Assume it's a file.
273
- items.push($4620ae0dc40f0031$var$createFileItem(item.getAsFile()));
274
- }
275
- }
276
- // All string items are different representations of the same item. There's no way to have
277
- // multiple string items at once in the current DataTransfer API.
278
- if (stringItems.size > 0) items.push({
279
- kind: "text",
280
- types: new Set(stringItems.keys()),
281
- getText: (type)=>Promise.resolve(stringItems.get(type))
282
- });
283
- }
284
- return items;
285
- }
286
- function $4620ae0dc40f0031$var$blobToString(blob) {
287
- if (typeof blob.text === "function") return blob.text();
288
- // Safari doesn't have the Blob#text() method yet...
289
- return new Promise((resolve, reject)=>{
290
- let reader = new FileReader;
291
- reader.onload = ()=>{
292
- resolve(reader.result);
293
- };
294
- reader.onerror = reject;
295
- reader.readAsText(blob);
296
- });
297
- }
298
- function $4620ae0dc40f0031$var$createFileItem(file) {
299
- return {
300
- kind: "file",
301
- type: file.type || (0, $76b1e110a27b1ccd$export$f8fc6581787339b3),
302
- name: file.name,
303
- getText: ()=>$4620ae0dc40f0031$var$blobToString(file),
304
- getFile: ()=>Promise.resolve(file)
305
- };
306
- }
307
- function $4620ae0dc40f0031$var$createDirectoryItem(entry) {
308
- return {
309
- kind: "directory",
310
- name: entry.name,
311
- getEntries: ()=>$4620ae0dc40f0031$var$getEntries(entry)
312
- };
313
- }
314
- async function* $4620ae0dc40f0031$var$getEntries(item) {
315
- let reader = item.createReader();
316
- // We must call readEntries repeatedly because there may be a limit to the
317
- // number of entries that are returned at once.
318
- let entries;
319
- do {
320
- entries = await new Promise((resolve, reject)=>{
321
- reader.readEntries(resolve, reject);
322
- });
323
- for (let entry of entries){
324
- if (entry.isFile) {
325
- let file = await $4620ae0dc40f0031$var$getEntryFile(entry);
326
- yield $4620ae0dc40f0031$var$createFileItem(file);
327
- } else if (entry.isDirectory) yield $4620ae0dc40f0031$var$createDirectoryItem(entry);
328
- }
329
- }while (entries.length > 0);
330
- }
331
- function $4620ae0dc40f0031$var$getEntryFile(entry) {
332
- return new Promise((resolve, reject)=>entry.file(resolve, reject));
333
- }
334
- function $4620ae0dc40f0031$export$97fd558bdc44bea1(dropItem) {
335
- return dropItem.kind === "text";
336
- }
337
- function $4620ae0dc40f0031$export$a144e1752ebe0aa(dropItem) {
338
- return dropItem.kind === "file";
339
- }
340
- function $4620ae0dc40f0031$export$2b40a62bdbe6b2b0(dropItem) {
341
- return dropItem.kind === "directory";
342
- }
343
- let $4620ae0dc40f0031$export$6ca6700462636d0b = {
344
- draggingKeys: new Set()
345
- };
346
- function $4620ae0dc40f0031$export$f2be18a910c0caa6(ref) {
347
- $4620ae0dc40f0031$export$6ca6700462636d0b.draggingCollectionRef = ref;
348
- }
349
- function $4620ae0dc40f0031$export$72cb63bdda528276(keys) {
350
- $4620ae0dc40f0031$export$6ca6700462636d0b.draggingKeys = keys;
351
- }
352
- function $4620ae0dc40f0031$export$dac8db29d42db9a1(ref) {
353
- $4620ae0dc40f0031$export$6ca6700462636d0b.dropCollectionRef = ref;
354
- }
355
- function $4620ae0dc40f0031$export$70936501603e6c57() {
356
- $4620ae0dc40f0031$export$6ca6700462636d0b = {
357
- draggingKeys: new Set()
358
- };
359
- }
360
- function $4620ae0dc40f0031$export$6c10d32b362bfa5f(state) {
361
- $4620ae0dc40f0031$export$6ca6700462636d0b = state;
362
- }
363
- function $4620ae0dc40f0031$export$78bf638634500fa5(ref) {
364
- let { draggingCollectionRef: draggingCollectionRef, dropCollectionRef: dropCollectionRef } = $4620ae0dc40f0031$export$6ca6700462636d0b;
365
- return (draggingCollectionRef === null || draggingCollectionRef === void 0 ? void 0 : draggingCollectionRef.current) != null && draggingCollectionRef.current === ((ref === null || ref === void 0 ? void 0 : ref.current) || (dropCollectionRef === null || dropCollectionRef === void 0 ? void 0 : dropCollectionRef.current));
366
- }
367
- let $4620ae0dc40f0031$export$8e6636520ac15722;
368
- function $4620ae0dc40f0031$export$64f52ed7349ddb84(dropEffect) {
369
- $4620ae0dc40f0031$export$8e6636520ac15722 = dropEffect;
370
- }
371
- let $4620ae0dc40f0031$export$f0130eb70b6347b8 = (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).none;
372
- function $4620ae0dc40f0031$export$6539bc8c3a0a2d67(o) {
373
- $4620ae0dc40f0031$export$f0130eb70b6347b8 = o;
374
- }
375
-
376
-
377
- /*
378
- * Copyright 2020 Adobe. All rights reserved.
379
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
380
- * you may not use this file except in compliance with the License. You may obtain a copy
381
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
382
- *
383
- * Unless required by applicable law or agreed to in writing, software distributed under
384
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
385
- * OF ANY KIND, either express or implied. See the License for the specific language
386
- * governing permissions and limitations under the License.
387
- */
388
- /*
389
- * Copyright 2020 Adobe. All rights reserved.
390
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
391
- * you may not use this file except in compliance with the License. You may obtain a copy
392
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
393
- *
394
- * Unless required by applicable law or agreed to in writing, software distributed under
395
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
396
- * OF ANY KIND, either express or implied. See the License for the specific language
397
- * governing permissions and limitations under the License.
398
- */
399
-
400
-
401
-
402
-
403
-
404
- let $28e10663603f5ea1$var$dropTargets = new Map();
405
- let $28e10663603f5ea1$var$dropItems = new Map();
406
- let $28e10663603f5ea1$var$dragSession = null;
407
- let $28e10663603f5ea1$var$subscriptions = new Set();
408
- function $28e10663603f5ea1$export$c28d9fb4a54e471a(target) {
409
- $28e10663603f5ea1$var$dropTargets.set(target.element, target);
410
- $28e10663603f5ea1$var$dragSession === null || $28e10663603f5ea1$var$dragSession === void 0 ? void 0 : $28e10663603f5ea1$var$dragSession.updateValidDropTargets();
411
- return ()=>{
412
- $28e10663603f5ea1$var$dropTargets.delete(target.element);
413
- $28e10663603f5ea1$var$dragSession === null || $28e10663603f5ea1$var$dragSession === void 0 ? void 0 : $28e10663603f5ea1$var$dragSession.updateValidDropTargets();
414
- };
415
- }
416
- function $28e10663603f5ea1$export$aef80212ac99c003(item) {
417
- $28e10663603f5ea1$var$dropItems.set(item.element, item);
418
- return ()=>{
419
- $28e10663603f5ea1$var$dropItems.delete(item.element);
420
- };
421
- }
422
- function $28e10663603f5ea1$export$549dbcf8649bf3b2(target, stringFormatter) {
423
- if ($28e10663603f5ea1$var$dragSession) throw new Error("Cannot begin dragging while already dragging");
424
- $28e10663603f5ea1$var$dragSession = new $28e10663603f5ea1$var$DragSession(target, stringFormatter);
425
- requestAnimationFrame(()=>{
426
- $28e10663603f5ea1$var$dragSession.setup();
427
- if ((0, $4620ae0dc40f0031$export$1fb2158d224b542c)() === "keyboard") $28e10663603f5ea1$var$dragSession.next();
428
- });
429
- for (let cb of $28e10663603f5ea1$var$subscriptions)cb();
430
- }
431
- function $28e10663603f5ea1$export$418e185dd3f1b968() {
432
- let [session, setSession] = (0, $4vY0V$react.useState)($28e10663603f5ea1$var$dragSession);
433
- (0, $4vY0V$react.useEffect)(()=>{
434
- let cb = ()=>setSession($28e10663603f5ea1$var$dragSession);
435
- $28e10663603f5ea1$var$subscriptions.add(cb);
436
- return ()=>{
437
- $28e10663603f5ea1$var$subscriptions.delete(cb);
438
- };
439
- }, []);
440
- return session;
441
- }
442
- function $28e10663603f5ea1$export$403bc76cbf68cf60() {
443
- return !!$28e10663603f5ea1$var$dragSession;
444
- }
445
- function $28e10663603f5ea1$var$endDragging() {
446
- $28e10663603f5ea1$var$dragSession = null;
447
- for (let cb of $28e10663603f5ea1$var$subscriptions)cb();
448
- }
449
- function $28e10663603f5ea1$export$7454aff2e161f241(element) {
450
- for (let target of $28e10663603f5ea1$var$dropTargets.keys()){
451
- if (target.contains(element)) return true;
452
- }
453
- return false;
454
- }
455
- const $28e10663603f5ea1$var$CANCELED_EVENTS = [
456
- "pointerdown",
457
- "pointermove",
458
- "pointerenter",
459
- "pointerleave",
460
- "pointerover",
461
- "pointerout",
462
- "pointerup",
463
- "mousedown",
464
- "mousemove",
465
- "mouseenter",
466
- "mouseleave",
467
- "mouseover",
468
- "mouseout",
469
- "mouseup",
470
- "touchstart",
471
- "touchmove",
472
- "touchend",
473
- "focusin",
474
- "focusout"
475
- ];
476
- const $28e10663603f5ea1$var$CLICK_EVENTS = [
477
- "pointerup",
478
- "mouseup",
479
- "touchend"
480
- ];
481
- const $28e10663603f5ea1$var$MESSAGES = {
482
- keyboard: "dragStartedKeyboard",
483
- touch: "dragStartedTouch",
484
- virtual: "dragStartedVirtual"
485
- };
486
- class $28e10663603f5ea1$var$DragSession {
487
- setup() {
488
- document.addEventListener("keydown", this.onKeyDown, true);
489
- document.addEventListener("keyup", this.onKeyUp, true);
490
- window.addEventListener("focus", this.onFocus, true);
491
- window.addEventListener("blur", this.onBlur, true);
492
- document.addEventListener("click", this.onClick, true);
493
- document.addEventListener("pointerdown", this.onPointerDown, true);
494
- for (let event of $28e10663603f5ea1$var$CANCELED_EVENTS)document.addEventListener(event, this.cancelEvent, true);
495
- this.mutationObserver = new MutationObserver(()=>this.updateValidDropTargets());
496
- this.updateValidDropTargets();
497
- (0, $4vY0V$reactarialiveannouncer.announce)(this.stringFormatter.format($28e10663603f5ea1$var$MESSAGES[(0, $4620ae0dc40f0031$export$1fb2158d224b542c)()]));
498
- }
499
- teardown() {
500
- document.removeEventListener("keydown", this.onKeyDown, true);
501
- document.removeEventListener("keyup", this.onKeyUp, true);
502
- window.removeEventListener("focus", this.onFocus, true);
503
- window.removeEventListener("blur", this.onBlur, true);
504
- document.removeEventListener("click", this.onClick, true);
505
- document.removeEventListener("pointerdown", this.onPointerDown, true);
506
- for (let event of $28e10663603f5ea1$var$CANCELED_EVENTS)document.removeEventListener(event, this.cancelEvent, true);
507
- this.mutationObserver.disconnect();
508
- this.restoreAriaHidden();
509
- }
510
- onKeyDown(e) {
511
- var _this_currentDropTarget;
512
- this.cancelEvent(e);
513
- if (e.key === "Escape") {
514
- this.cancel();
515
- return;
516
- }
517
- if (e.key === "Tab" && !(e.metaKey || e.altKey || e.ctrlKey)) {
518
- if (e.shiftKey) this.previous();
519
- else this.next();
520
- }
521
- if (typeof ((_this_currentDropTarget = this.currentDropTarget) === null || _this_currentDropTarget === void 0 ? void 0 : _this_currentDropTarget.onKeyDown) === "function") this.currentDropTarget.onKeyDown(e, this.dragTarget);
522
- }
523
- onKeyUp(e) {
524
- this.cancelEvent(e);
525
- if (e.key === "Enter") {
526
- if (e.altKey) this.activate();
527
- else this.drop();
528
- }
529
- }
530
- onFocus(e) {
531
- // Prevent focus events, except to the original drag target.
532
- if (e.target !== this.dragTarget.element) this.cancelEvent(e);
533
- // Ignore focus events on the window/document (JSDOM). Will be handled in onBlur, below.
534
- if (!(e.target instanceof HTMLElement) || e.target === this.dragTarget.element) return;
535
- let dropTarget = this.validDropTargets.find((target)=>target.element === e.target) || this.validDropTargets.find((target)=>target.element.contains(e.target));
536
- if (!dropTarget) {
537
- if (this.currentDropTarget) this.currentDropTarget.element.focus();
538
- else this.dragTarget.element.focus();
539
- return;
540
- }
541
- let item = $28e10663603f5ea1$var$dropItems.get(e.target);
542
- this.setCurrentDropTarget(dropTarget, item);
543
- }
544
- onBlur(e) {
545
- if (e.target !== this.dragTarget.element) this.cancelEvent(e);
546
- // If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM),
547
- // restore focus back to the current drop target if any, or the original drag target.
548
- if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) {
549
- if (this.currentDropTarget) this.currentDropTarget.element.focus();
550
- else this.dragTarget.element.focus();
551
- }
552
- }
553
- onClick(e) {
554
- this.cancelEvent(e);
555
- if ((0, $4vY0V$reactariautils.isVirtualClick)(e) || this.isVirtualClick) {
556
- if (e.target === this.dragTarget.element) {
557
- this.cancel();
558
- return;
559
- }
560
- let dropTarget = this.validDropTargets.find((target)=>target.element.contains(e.target));
561
- if (dropTarget) {
562
- let item = $28e10663603f5ea1$var$dropItems.get(e.target);
563
- this.setCurrentDropTarget(dropTarget, item);
564
- this.drop(item);
565
- }
566
- }
567
- }
568
- onPointerDown(e) {
569
- // Android Talkback double tap has e.detail = 1 for onClick. Detect the virtual click in onPointerDown before onClick fires
570
- // so we can properly perform cancel and drop operations.
571
- this.cancelEvent(e);
572
- this.isVirtualClick = (0, $4vY0V$reactariautils.isVirtualPointerEvent)(e);
573
- }
574
- cancelEvent(e) {
575
- var _this_dragTarget;
576
- // Allow focusin and focusout on the drag target so focus ring works properly.
577
- if ((e.type === "focusin" || e.type === "focusout") && e.target === ((_this_dragTarget = this.dragTarget) === null || _this_dragTarget === void 0 ? void 0 : _this_dragTarget.element)) return;
578
- // Allow default for events that might cancel a click event
579
- if (!$28e10663603f5ea1$var$CLICK_EVENTS.includes(e.type)) e.preventDefault();
580
- e.stopPropagation();
581
- e.stopImmediatePropagation();
582
- }
583
- updateValidDropTargets() {
584
- if (!this.mutationObserver) return;
585
- this.mutationObserver.disconnect();
586
- if (this.restoreAriaHidden) this.restoreAriaHidden();
587
- this.validDropTargets = $28e10663603f5ea1$var$findValidDropTargets(this.dragTarget);
588
- // Shuffle drop target order based on starting drag target.
589
- if (this.validDropTargets.length > 0) {
590
- let nearestIndex = this.findNearestDropTarget();
591
- this.validDropTargets = [
592
- ...this.validDropTargets.slice(nearestIndex),
593
- ...this.validDropTargets.slice(0, nearestIndex)
594
- ];
595
- }
596
- if (this.currentDropTarget && !this.validDropTargets.includes(this.currentDropTarget)) this.setCurrentDropTarget(this.validDropTargets[0]);
597
- // Find valid drop items within collections
598
- let types = (0, $4620ae0dc40f0031$export$e1d41611756c6326)(this.dragTarget.items);
599
- let validDropItems = [
600
- ...$28e10663603f5ea1$var$dropItems.values()
601
- ].filter((item)=>{
602
- if (typeof item.getDropOperation === "function") return item.getDropOperation(types, this.dragTarget.allowedDropOperations) !== "cancel";
603
- return true;
604
- });
605
- // Filter out drop targets that contain valid items. We don't want to stop hiding elements
606
- // other than the drop items that exist inside the collection.
607
- let visibleDropTargets = this.validDropTargets.filter((target)=>!validDropItems.some((item)=>target.element.contains(item.element)));
608
- this.restoreAriaHidden = (0, $4vY0V$reactariaoverlays.ariaHideOutside)([
609
- this.dragTarget.element,
610
- ...validDropItems.map((item)=>item.element),
611
- ...visibleDropTargets.map((target)=>target.element)
612
- ]);
613
- this.mutationObserver.observe(document.body, {
614
- subtree: true,
615
- attributes: true,
616
- attributeFilter: [
617
- "aria-hidden"
618
- ]
619
- });
620
- }
621
- next() {
622
- if (!this.currentDropTarget) {
623
- this.setCurrentDropTarget(this.validDropTargets[0]);
624
- return;
625
- }
626
- let index = this.validDropTargets.indexOf(this.currentDropTarget);
627
- if (index < 0) {
628
- this.setCurrentDropTarget(this.validDropTargets[0]);
629
- return;
630
- }
631
- // If we've reached the end of the valid drop targets, cycle back to the original drag target.
632
- // This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).
633
- if (index === this.validDropTargets.length - 1) {
634
- if (!this.dragTarget.element.closest('[aria-hidden="true"]')) {
635
- this.setCurrentDropTarget(null);
636
- this.dragTarget.element.focus();
637
- } else this.setCurrentDropTarget(this.validDropTargets[0]);
638
- } else this.setCurrentDropTarget(this.validDropTargets[index + 1]);
639
- }
640
- previous() {
641
- if (!this.currentDropTarget) {
642
- this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);
643
- return;
644
- }
645
- let index = this.validDropTargets.indexOf(this.currentDropTarget);
646
- if (index < 0) {
647
- this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);
648
- return;
649
- }
650
- // If we've reached the start of the valid drop targets, cycle back to the original drag target.
651
- // This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).
652
- if (index === 0) {
653
- if (!this.dragTarget.element.closest('[aria-hidden="true"]')) {
654
- this.setCurrentDropTarget(null);
655
- this.dragTarget.element.focus();
656
- } else this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);
657
- } else this.setCurrentDropTarget(this.validDropTargets[index - 1]);
658
- }
659
- findNearestDropTarget() {
660
- let dragTargetRect = this.dragTarget.element.getBoundingClientRect();
661
- let minDistance = Infinity;
662
- let nearest = -1;
663
- for(let i = 0; i < this.validDropTargets.length; i++){
664
- let dropTarget = this.validDropTargets[i];
665
- let rect = dropTarget.element.getBoundingClientRect();
666
- let dx = rect.left - dragTargetRect.left;
667
- let dy = rect.top - dragTargetRect.top;
668
- let dist = dx * dx + dy * dy;
669
- if (dist < minDistance) {
670
- minDistance = dist;
671
- nearest = i;
672
- }
673
- }
674
- return nearest;
675
- }
676
- setCurrentDropTarget(dropTarget, item) {
677
- if (dropTarget !== this.currentDropTarget) {
678
- if (this.currentDropTarget && typeof this.currentDropTarget.onDropExit === "function") {
679
- let rect = this.currentDropTarget.element.getBoundingClientRect();
680
- this.currentDropTarget.onDropExit({
681
- type: "dropexit",
682
- x: rect.left + rect.width / 2,
683
- y: rect.top + rect.height / 2
684
- });
685
- }
686
- this.currentDropTarget = dropTarget;
687
- if (dropTarget) {
688
- if (typeof dropTarget.onDropEnter === "function") {
689
- let rect = dropTarget.element.getBoundingClientRect();
690
- dropTarget.onDropEnter({
691
- type: "dropenter",
692
- x: rect.left + rect.width / 2,
693
- y: rect.top + rect.height / 2
694
- }, this.dragTarget);
695
- }
696
- if (!item) dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.element.focus();
697
- }
698
- }
699
- if (item !== this.currentDropItem) {
700
- if (item && typeof this.currentDropTarget.onDropTargetEnter === "function") this.currentDropTarget.onDropTargetEnter(item === null || item === void 0 ? void 0 : item.target);
701
- item === null || item === void 0 ? void 0 : item.element.focus();
702
- this.currentDropItem = item;
703
- // Announce first drop target after drag start announcement finishes.
704
- // Otherwise, it will never get announced because drag start announcement is assertive.
705
- if (!this.initialFocused) {
706
- (0, $4vY0V$reactarialiveannouncer.announce)(item === null || item === void 0 ? void 0 : item.element.getAttribute("aria-label"), "polite");
707
- this.initialFocused = true;
708
- }
709
- }
710
- }
711
- end() {
712
- this.teardown();
713
- $28e10663603f5ea1$var$endDragging();
714
- if (typeof this.dragTarget.onDragEnd === "function") {
715
- let target = this.currentDropTarget && this.dropOperation !== "cancel" ? this.currentDropTarget : this.dragTarget;
716
- let rect = target.element.getBoundingClientRect();
717
- this.dragTarget.onDragEnd({
718
- type: "dragend",
719
- x: rect.x + rect.width / 2,
720
- y: rect.y + rect.height / 2,
721
- dropOperation: this.dropOperation || "cancel"
722
- });
723
- }
724
- // Blur and re-focus the drop target so that the focus ring appears.
725
- if (this.currentDropTarget) {
726
- // Since we cancel all focus events in drag sessions, refire blur to make sure state gets updated so drag target doesn't think it's still focused
727
- // i.e. When you from one list to another during a drag session, we need the blur to fire on the first list after the drag.
728
- if (!this.dragTarget.element.contains(this.currentDropTarget.element)) {
729
- this.dragTarget.element.dispatchEvent(new FocusEvent("blur"));
730
- this.dragTarget.element.dispatchEvent(new FocusEvent("focusout", {
731
- bubbles: true
732
- }));
733
- }
734
- // Re-focus the focusedKey upon reorder. This requires a React rerender between blurring and focusing.
735
- (0, $4vY0V$reactdom.flushSync)(()=>{
736
- this.currentDropTarget.element.blur();
737
- });
738
- this.currentDropTarget.element.focus();
739
- }
740
- this.setCurrentDropTarget(null);
741
- }
742
- cancel() {
743
- this.setCurrentDropTarget(null);
744
- this.end();
745
- if (!this.dragTarget.element.closest('[aria-hidden="true"]')) this.dragTarget.element.focus();
746
- (0, $4vY0V$reactarialiveannouncer.announce)(this.stringFormatter.format("dropCanceled"));
747
- }
748
- drop(item) {
749
- if (!this.currentDropTarget) {
750
- this.cancel();
751
- return;
752
- }
753
- if (typeof (item === null || item === void 0 ? void 0 : item.getDropOperation) === "function") {
754
- let types = (0, $4620ae0dc40f0031$export$e1d41611756c6326)(this.dragTarget.items);
755
- this.dropOperation = item.getDropOperation(types, this.dragTarget.allowedDropOperations);
756
- } else if (typeof this.currentDropTarget.getDropOperation === "function") {
757
- let types = (0, $4620ae0dc40f0031$export$e1d41611756c6326)(this.dragTarget.items);
758
- this.dropOperation = this.currentDropTarget.getDropOperation(types, this.dragTarget.allowedDropOperations);
759
- } else // TODO: show menu ??
760
- this.dropOperation = this.dragTarget.allowedDropOperations[0];
761
- if (typeof this.currentDropTarget.onDrop === "function") {
762
- let items = this.dragTarget.items.map((item)=>({
763
- kind: "text",
764
- types: new Set(Object.keys(item)),
765
- getText: (type)=>Promise.resolve(item[type])
766
- }));
767
- let rect = this.currentDropTarget.element.getBoundingClientRect();
768
- this.currentDropTarget.onDrop({
769
- type: "drop",
770
- x: rect.left + rect.width / 2,
771
- y: rect.top + rect.height / 2,
772
- items: items,
773
- dropOperation: this.dropOperation
774
- }, item === null || item === void 0 ? void 0 : item.target);
775
- }
776
- this.end();
777
- (0, $4vY0V$reactarialiveannouncer.announce)(this.stringFormatter.format("dropComplete"));
778
- }
779
- activate() {
780
- if (this.currentDropTarget && typeof this.currentDropTarget.onDropActivate === "function") {
781
- let rect = this.currentDropTarget.element.getBoundingClientRect();
782
- this.currentDropTarget.onDropActivate({
783
- type: "dropactivate",
784
- x: rect.left + rect.width / 2,
785
- y: rect.top + rect.height / 2
786
- });
787
- }
788
- }
789
- constructor(target, stringFormatter){
790
- this.dragTarget = target;
791
- this.stringFormatter = stringFormatter;
792
- this.onKeyDown = this.onKeyDown.bind(this);
793
- this.onKeyUp = this.onKeyUp.bind(this);
794
- this.onFocus = this.onFocus.bind(this);
795
- this.onBlur = this.onBlur.bind(this);
796
- this.onClick = this.onClick.bind(this);
797
- this.onPointerDown = this.onPointerDown.bind(this);
798
- this.cancelEvent = this.cancelEvent.bind(this);
799
- this.initialFocused = false;
800
- }
801
- }
802
- function $28e10663603f5ea1$var$findValidDropTargets(options) {
803
- let types = (0, $4620ae0dc40f0031$export$e1d41611756c6326)(options.items);
804
- return [
805
- ...$28e10663603f5ea1$var$dropTargets.values()
806
- ].filter((target)=>{
807
- if (target.element.closest('[aria-hidden="true"]')) return false;
808
- if (typeof target.getDropOperation === "function") return target.getDropOperation(types, options.allowedDropOperations) !== "cancel";
809
- return true;
810
- });
811
- }
812
-
813
-
814
-
815
-
816
- var $7c8adf3925a26206$exports = {};
817
-
818
-
819
-
820
-
821
-
822
-
823
-
824
-
825
-
826
-
827
-
828
-
829
-
830
-
831
-
832
-
833
-
834
-
835
-
836
-
837
-
838
-
839
-
840
-
841
-
842
-
843
-
844
-
845
-
846
-
847
-
848
-
849
-
850
-
851
- $7c8adf3925a26206$exports = {
852
- "ar-AE": $12ee6b0bfb4232ad$exports,
853
- "bg-BG": $e21ef7c55796c5e1$exports,
854
- "cs-CZ": $dfa9cd1c2317d9aa$exports,
855
- "da-DK": $65fff3bbacfa8956$exports,
856
- "de-DE": $10b7dfe45cd41c2d$exports,
857
- "el-GR": $0cadcffb7abc96b8$exports,
858
- "en-US": $7e3982b34ddf1bdf$exports,
859
- "es-ES": $cb29ce0b655c4023$exports,
860
- "et-EE": $067d46bab80bcf4b$exports,
861
- "fi-FI": $8aa1b9a1f9d783d3$exports,
862
- "fr-FR": $9e248ec27f7dc55f$exports,
863
- "he-IL": $6387f7228f0de45e$exports,
864
- "hr-HR": $34a283567735f754$exports,
865
- "hu-HU": $466590c56bee4342$exports,
866
- "it-IT": $e013896dcb6a6884$exports,
867
- "ja-JP": $d6121e4246c6e502$exports,
868
- "ko-KR": $cf48a963c482dcba$exports,
869
- "lt-LT": $b156071f04f1c899$exports,
870
- "lv-LV": $5300be8ef98d39fa$exports,
871
- "nb-NO": $7484477aad199932$exports,
872
- "nl-NL": $968e09cb41d6cd76$exports,
873
- "pl-PL": $0c2c6c954dd638d7$exports,
874
- "pt-BR": $db510f249c1f2e00$exports,
875
- "pt-PT": $d734686296d37387$exports,
876
- "ro-RO": $d239d4998a584a23$exports,
877
- "ru-RU": $a06126b47eabe64f$exports,
878
- "sk-SK": $0983413fc05d96fb$exports,
879
- "sl-SI": $c66896a0464692f1$exports,
880
- "sr-SP": $f0d9abe43a1bcdf6$exports,
881
- "sv-SE": $f3e2ce4b6d6cc4ac$exports,
882
- "tr-TR": $da91b0d12d273475$exports,
883
- "uk-UA": $d6f72e28f0f4871c$exports,
884
- "zh-CN": $187738fbdc896f75$exports,
885
- "zh-TW": $80cfc1f1f7d356d3$exports
886
- };
887
-
888
-
889
-
890
-
891
- const $dc204e8ec58447a6$var$MESSAGES = {
892
- keyboard: {
893
- start: "dragDescriptionKeyboard",
894
- end: "endDragKeyboard"
895
- },
896
- touch: {
897
- start: "dragDescriptionTouch",
898
- end: "endDragTouch"
899
- },
900
- virtual: {
901
- start: "dragDescriptionVirtual",
902
- end: "endDragVirtual"
903
- }
904
- };
905
- function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
906
- let { hasDragButton: hasDragButton } = options;
907
- let stringFormatter = (0, $4vY0V$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7c8adf3925a26206$exports))), "@react-aria/dnd");
908
- let state = (0, $4vY0V$react.useRef)({
909
- options: options,
910
- x: 0,
911
- y: 0
912
- }).current;
913
- state.options = options;
914
- let isDraggingRef = (0, $4vY0V$react.useRef)(false);
915
- let [isDragging, setDraggingState] = (0, $4vY0V$react.useState)(false);
916
- let setDragging = (isDragging)=>{
917
- isDraggingRef.current = isDragging;
918
- setDraggingState(isDragging);
919
- };
920
- let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $4vY0V$reactariautils.useGlobalListeners)();
921
- let modalityOnPointerDown = (0, $4vY0V$react.useRef)(null);
922
- let onDragStart = (e)=>{
923
- var _options_preview;
924
- if (e.defaultPrevented) return;
925
- // Prevent the drag event from propagating to any parent draggables
926
- e.stopPropagation();
927
- // If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.
928
- if (modalityOnPointerDown.current === "virtual") {
929
- e.preventDefault();
930
- startDragging(e.target);
931
- modalityOnPointerDown.current = null;
932
- return;
933
- }
934
- if (typeof options.onDragStart === "function") options.onDragStart({
935
- type: "dragstart",
936
- x: e.clientX,
937
- y: e.clientY
938
- });
939
- let items = options.getItems();
940
- (0, $4620ae0dc40f0031$export$f9c1490890ddd063)(e.dataTransfer, items);
941
- let allowed = (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).all;
942
- if (typeof options.getAllowedDropOperations === "function") {
943
- let allowedOperations = options.getAllowedDropOperations();
944
- allowed = (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).none;
945
- for (let operation of allowedOperations)allowed |= (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e)[operation] || (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).none;
946
- }
947
- (0, $4620ae0dc40f0031$export$6539bc8c3a0a2d67)(allowed);
948
- e.dataTransfer.effectAllowed = (0, $76b1e110a27b1ccd$export$dd0165308d8bff45)[allowed] || "none";
949
- // If there is a preview option, use it to render a custom preview image that will
950
- // appear under the pointer while dragging. If not, the element itself is dragged by the browser.
951
- if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === "function") options.preview.current(items, (node)=>{
952
- // Compute the offset that the preview will appear under the mouse.
953
- // If possible, this is based on the point the user clicked on the target.
954
- // If the preview is much smaller, then just use the center point of the preview.
955
- let size = node.getBoundingClientRect();
956
- let rect = e.currentTarget.getBoundingClientRect();
957
- let x = e.clientX - rect.x;
958
- let y = e.clientY - rect.y;
959
- if (x > size.width || y > size.height) {
960
- x = size.width / 2;
961
- y = size.height / 2;
962
- }
963
- // Rounding height to an even number prevents blurry preview seen on some screens
964
- let height = 2 * Math.round(size.height / 2);
965
- node.style.height = `${height}px`;
966
- e.dataTransfer.setDragImage(node, x, y);
967
- });
968
- // Enforce that drops are handled by useDrop.
969
- addGlobalListener(window, "drop", (e)=>{
970
- e.preventDefault();
971
- e.stopPropagation();
972
- console.warn("Drags initiated from the React Aria useDrag hook may only be dropped on a target created with useDrop. This ensures that a keyboard and screen reader accessible alternative is available.");
973
- }, {
974
- once: true
975
- });
976
- state.x = e.clientX;
977
- state.y = e.clientY;
978
- // Wait a frame before we set dragging to true so that the browser has time to
979
- // render the preview image before we update the element that has been dragged.
980
- requestAnimationFrame(()=>{
981
- setDragging(true);
982
- });
983
- };
984
- let onDrag = (e)=>{
985
- // Prevent the drag event from propagating to any parent draggables
986
- e.stopPropagation();
987
- if (e.clientX === state.x && e.clientY === state.y) return;
988
- if (typeof options.onDragMove === "function") options.onDragMove({
989
- type: "dragmove",
990
- x: e.clientX,
991
- y: e.clientY
992
- });
993
- state.x = e.clientX;
994
- state.y = e.clientY;
995
- };
996
- let onDragEnd = (e)=>{
997
- // Prevent the drag event from propagating to any parent draggables
998
- e.stopPropagation();
999
- if (typeof options.onDragEnd === "function") {
1000
- let event = {
1001
- type: "dragend",
1002
- x: e.clientX,
1003
- y: e.clientY,
1004
- dropOperation: (0, $76b1e110a27b1ccd$export$608ecc6f1b23c35d)[e.dataTransfer.dropEffect]
1005
- };
1006
- // Chrome Android always returns none as its dropEffect so we use the drop effect set in useDrop via
1007
- // onDragEnter/onDragOver instead. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951
1008
- if (0, $4620ae0dc40f0031$export$8e6636520ac15722) event.dropOperation = (0, $76b1e110a27b1ccd$export$608ecc6f1b23c35d)[0, $4620ae0dc40f0031$export$8e6636520ac15722];
1009
- options.onDragEnd(event);
1010
- }
1011
- setDragging(false);
1012
- removeAllGlobalListeners();
1013
- (0, $4620ae0dc40f0031$export$6539bc8c3a0a2d67)((0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).none);
1014
- (0, $4620ae0dc40f0031$export$64f52ed7349ddb84)(undefined);
1015
- };
1016
- // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
1017
- // In this case, we need to manually call onDragEnd on cleanup
1018
- // eslint-disable-next-line arrow-body-style
1019
- (0, $4vY0V$reactariautils.useLayoutEffect)(()=>{
1020
- return ()=>{
1021
- if (isDraggingRef.current) {
1022
- if (typeof state.options.onDragEnd === "function") {
1023
- let event = {
1024
- type: "dragend",
1025
- x: 0,
1026
- y: 0,
1027
- dropOperation: (0, $76b1e110a27b1ccd$export$608ecc6f1b23c35d)[(0, $4620ae0dc40f0031$export$8e6636520ac15722) || "none"]
1028
- };
1029
- state.options.onDragEnd(event);
1030
- }
1031
- setDragging(false);
1032
- (0, $4620ae0dc40f0031$export$6539bc8c3a0a2d67)((0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).none);
1033
- (0, $4620ae0dc40f0031$export$64f52ed7349ddb84)(undefined);
1034
- }
1035
- };
1036
- }, [
1037
- state
1038
- ]);
1039
- let onPress = (e)=>{
1040
- if (e.pointerType !== "keyboard" && e.pointerType !== "virtual") return;
1041
- startDragging(e.target);
1042
- };
1043
- let startDragging = (target)=>{
1044
- if (typeof state.options.onDragStart === "function") {
1045
- let rect = target.getBoundingClientRect();
1046
- state.options.onDragStart({
1047
- type: "dragstart",
1048
- x: rect.x + rect.width / 2,
1049
- y: rect.y + rect.height / 2
1050
- });
1051
- }
1052
- $28e10663603f5ea1$export$549dbcf8649bf3b2({
1053
- element: target,
1054
- items: state.options.getItems(),
1055
- allowedDropOperations: typeof state.options.getAllowedDropOperations === "function" ? state.options.getAllowedDropOperations() : [
1056
- "move",
1057
- "copy",
1058
- "link"
1059
- ],
1060
- onDragEnd (e) {
1061
- setDragging(false);
1062
- if (typeof state.options.onDragEnd === "function") state.options.onDragEnd(e);
1063
- }
1064
- }, stringFormatter);
1065
- setDragging(true);
1066
- };
1067
- let modality = (0, $4620ae0dc40f0031$export$49bac5d6d4b352ea)();
1068
- let message = !isDragging ? $dc204e8ec58447a6$var$MESSAGES[modality].start : $dc204e8ec58447a6$var$MESSAGES[modality].end;
1069
- let descriptionProps = (0, $4vY0V$reactariautils.useDescription)(stringFormatter.format(message));
1070
- let interactions;
1071
- if (!hasDragButton) // If there's no separate button to trigger accessible drag and drop mode,
1072
- // then add event handlers to the draggable element itself to start dragging.
1073
- // For keyboard, we use the Enter key in a capturing listener to prevent other
1074
- // events such as selection from also occurring. We attempt to infer whether a
1075
- // pointer event (e.g. long press) came from a touch screen reader, and then initiate
1076
- // dragging in the native onDragStart listener above.
1077
- interactions = {
1078
- ...descriptionProps,
1079
- onPointerDown (e) {
1080
- modalityOnPointerDown.current = (0, $4vY0V$reactariautils.isVirtualPointerEvent)(e.nativeEvent) ? "virtual" : e.pointerType;
1081
- // Try to detect virtual drag passthrough gestures.
1082
- if (e.width < 1 && e.height < 1) // iOS VoiceOver.
1083
- modalityOnPointerDown.current = "virtual";
1084
- else {
1085
- let rect = e.currentTarget.getBoundingClientRect();
1086
- let offsetX = e.clientX - rect.x;
1087
- let offsetY = e.clientY - rect.y;
1088
- let centerX = rect.width / 2;
1089
- let centerY = rect.height / 2;
1090
- if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) // Android TalkBack.
1091
- modalityOnPointerDown.current = "virtual";
1092
- else modalityOnPointerDown.current = e.pointerType;
1093
- }
1094
- },
1095
- onKeyDownCapture (e) {
1096
- if (e.target === e.currentTarget && e.key === "Enter") {
1097
- e.preventDefault();
1098
- e.stopPropagation();
1099
- }
1100
- },
1101
- onKeyUpCapture (e) {
1102
- if (e.target === e.currentTarget && e.key === "Enter") {
1103
- e.preventDefault();
1104
- e.stopPropagation();
1105
- startDragging(e.target);
1106
- }
1107
- },
1108
- onClick (e) {
1109
- // Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.
1110
- if ((0, $4vY0V$reactariautils.isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current === "virtual") {
1111
- e.preventDefault();
1112
- e.stopPropagation();
1113
- startDragging(e.target);
1114
- }
1115
- }
1116
- };
1117
- return {
1118
- dragProps: {
1119
- ...interactions,
1120
- draggable: "true",
1121
- onDragStart: onDragStart,
1122
- onDrag: onDrag,
1123
- onDragEnd: onDragEnd
1124
- },
1125
- dragButtonProps: {
1126
- ...descriptionProps,
1127
- onPress: onPress
1128
- },
1129
- isDragging: isDragging
1130
- };
1131
- }
1132
-
1133
-
1134
- /*
1135
- * Copyright 2020 Adobe. All rights reserved.
1136
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1137
- * you may not use this file except in compliance with the License. You may obtain a copy
1138
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1139
- *
1140
- * Unless required by applicable law or agreed to in writing, software distributed under
1141
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1142
- * OF ANY KIND, either express or implied. See the License for the specific language
1143
- * governing permissions and limitations under the License.
1144
- */
1145
-
1146
-
1147
-
1148
-
19
+ $parcel$export(module.exports, "DIRECTORY_DRAG_TYPE", () => $4620ae0dc40f0031$exports.DIRECTORY_DRAG_TYPE);
20
+ $parcel$export(module.exports, "useDrag", () => $dc204e8ec58447a6$exports.useDrag);
21
+ $parcel$export(module.exports, "useDrop", () => $1ca228bc9257ca16$exports.useDrop);
22
+ $parcel$export(module.exports, "useDroppableCollection", () => $7f93a158ac20b90a$exports.useDroppableCollection);
23
+ $parcel$export(module.exports, "useDroppableItem", () => $fc1876157e07bcec$exports.useDroppableItem);
24
+ $parcel$export(module.exports, "useDropIndicator", () => $c5557edbed563ebf$exports.useDropIndicator);
25
+ $parcel$export(module.exports, "useDraggableItem", () => $0cbbd00cda972c67$exports.useDraggableItem);
26
+ $parcel$export(module.exports, "useDraggableCollection", () => $c3e901bab7fcc6ff$exports.useDraggableCollection);
27
+ $parcel$export(module.exports, "useClipboard", () => $74f3dedaa4d234b4$exports.useClipboard);
28
+ $parcel$export(module.exports, "DragPreview", () => $2dccaca1f4baa446$exports.DragPreview);
29
+ $parcel$export(module.exports, "ListDropTargetDelegate", () => $2268795bbb597ecb$exports.ListDropTargetDelegate);
30
+ $parcel$export(module.exports, "isVirtualDragging", () => $28e10663603f5ea1$exports.isVirtualDragging);
31
+ $parcel$export(module.exports, "isDirectoryDropItem", () => $4620ae0dc40f0031$exports.isDirectoryDropItem);
32
+ $parcel$export(module.exports, "isFileDropItem", () => $4620ae0dc40f0031$exports.isFileDropItem);
33
+ $parcel$export(module.exports, "isTextDropItem", () => $4620ae0dc40f0031$exports.isTextDropItem);
1149
34
  /*
1150
35
  * Copyright 2020 Adobe. All rights reserved.
1151
36
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1161,1465 +46,10 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
1161
46
 
1162
47
 
1163
48
 
1164
- const $419982e205c8e8dc$var$MESSAGES = {
1165
- keyboard: "dropDescriptionKeyboard",
1166
- touch: "dropDescriptionTouch",
1167
- virtual: "dropDescriptionVirtual"
1168
- };
1169
- function $419982e205c8e8dc$export$62447ad3d2ec7da6() {
1170
- let stringFormatter = (0, $4vY0V$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7c8adf3925a26206$exports))), "@react-aria/dnd");
1171
- let modality = (0, $4620ae0dc40f0031$export$49bac5d6d4b352ea)();
1172
- let dragSession = $28e10663603f5ea1$export$418e185dd3f1b968();
1173
- let descriptionProps = (0, $4vY0V$reactariautils.useDescription)(dragSession ? stringFormatter.format($419982e205c8e8dc$var$MESSAGES[modality]) : "");
1174
- return {
1175
- dropProps: {
1176
- ...descriptionProps,
1177
- // Mobile Safari does not properly bubble click events on elements except links or inputs
1178
- // unless there is an onclick handler bound directly to the element itself. By adding this
1179
- // handler, React will take care of adding that for us, and we are able to handle document
1180
- // level click events in the DragManager.
1181
- // See https://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
1182
- onClick: ()=>{}
1183
- }
1184
- };
1185
- }
1186
-
1187
-
1188
- const $1ca228bc9257ca16$var$DROP_ACTIVATE_TIMEOUT = 800;
1189
- function $1ca228bc9257ca16$export$ccdee5eaf73cf661(options) {
1190
- let { hasDropButton: hasDropButton, isDisabled: isDisabled } = options;
1191
- let [isDropTarget, setDropTarget] = (0, $4vY0V$react.useState)(false);
1192
- let state = (0, $4vY0V$react.useRef)({
1193
- x: 0,
1194
- y: 0,
1195
- dragOverElements: new Set(),
1196
- dropEffect: "none",
1197
- allowedOperations: (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).all,
1198
- dropActivateTimer: null
1199
- }).current;
1200
- let fireDropEnter = (e)=>{
1201
- setDropTarget(true);
1202
- if (typeof options.onDropEnter === "function") {
1203
- let rect = e.currentTarget.getBoundingClientRect();
1204
- options.onDropEnter({
1205
- type: "dropenter",
1206
- x: e.clientX - rect.x,
1207
- y: e.clientY - rect.y
1208
- });
1209
- }
1210
- };
1211
- let fireDropExit = (e)=>{
1212
- setDropTarget(false);
1213
- if (typeof options.onDropExit === "function") {
1214
- let rect = e.currentTarget.getBoundingClientRect();
1215
- options.onDropExit({
1216
- type: "dropexit",
1217
- x: e.clientX - rect.x,
1218
- y: e.clientY - rect.y
1219
- });
1220
- }
1221
- };
1222
- let onDragOver = (e)=>{
1223
- e.preventDefault();
1224
- e.stopPropagation();
1225
- let allowedOperations = $1ca228bc9257ca16$var$getAllowedOperations(e);
1226
- if (e.clientX === state.x && e.clientY === state.y && allowedOperations === state.allowedOperations) {
1227
- e.dataTransfer.dropEffect = state.dropEffect;
1228
- return;
1229
- }
1230
- state.x = e.clientX;
1231
- state.y = e.clientY;
1232
- let prevDropEffect = state.dropEffect;
1233
- // Update drop effect if allowed drop operations changed (e.g. user pressed modifier key).
1234
- if (allowedOperations !== state.allowedOperations) {
1235
- let allowedOps = $1ca228bc9257ca16$var$allowedOperationsToArray(allowedOperations);
1236
- let dropOperation = allowedOps[0];
1237
- if (typeof options.getDropOperation === "function") {
1238
- let types = new (0, $4620ae0dc40f0031$export$7f04ce188c91447c)(e.dataTransfer);
1239
- dropOperation = $1ca228bc9257ca16$var$getDropOperation(allowedOperations, options.getDropOperation(types, allowedOps));
1240
- }
1241
- state.dropEffect = (0, $76b1e110a27b1ccd$export$5eacb0769d26d3b2)[dropOperation] || "none";
1242
- }
1243
- if (typeof options.getDropOperationForPoint === "function") {
1244
- let types = new (0, $4620ae0dc40f0031$export$7f04ce188c91447c)(e.dataTransfer);
1245
- let rect = e.currentTarget.getBoundingClientRect();
1246
- let dropOperation = $1ca228bc9257ca16$var$getDropOperation(allowedOperations, options.getDropOperationForPoint(types, $1ca228bc9257ca16$var$allowedOperationsToArray(allowedOperations), state.x - rect.x, state.y - rect.y));
1247
- state.dropEffect = (0, $76b1e110a27b1ccd$export$5eacb0769d26d3b2)[dropOperation] || "none";
1248
- }
1249
- state.allowedOperations = allowedOperations;
1250
- e.dataTransfer.dropEffect = state.dropEffect;
1251
- // If the drop operation changes, update state and fire events appropriately.
1252
- if (state.dropEffect === "none" && prevDropEffect !== "none") fireDropExit(e);
1253
- else if (state.dropEffect !== "none" && prevDropEffect === "none") fireDropEnter(e);
1254
- if (typeof options.onDropMove === "function" && state.dropEffect !== "none") {
1255
- let rect = e.currentTarget.getBoundingClientRect();
1256
- options.onDropMove({
1257
- type: "dropmove",
1258
- x: state.x - rect.x,
1259
- y: state.y - rect.y
1260
- });
1261
- }
1262
- clearTimeout(state.dropActivateTimer);
1263
- if (typeof options.onDropActivate === "function" && state.dropEffect !== "none") {
1264
- let rect = e.currentTarget.getBoundingClientRect();
1265
- state.dropActivateTimer = setTimeout(()=>{
1266
- options.onDropActivate({
1267
- type: "dropactivate",
1268
- x: state.x - rect.x,
1269
- y: state.y - rect.y
1270
- });
1271
- }, $1ca228bc9257ca16$var$DROP_ACTIVATE_TIMEOUT);
1272
- }
1273
- };
1274
- let onDragEnter = (e)=>{
1275
- e.preventDefault();
1276
- e.stopPropagation();
1277
- state.dragOverElements.add(e.target);
1278
- if (state.dragOverElements.size > 1) return;
1279
- let allowedOperationsBits = $1ca228bc9257ca16$var$getAllowedOperations(e);
1280
- let allowedOperations = $1ca228bc9257ca16$var$allowedOperationsToArray(allowedOperationsBits);
1281
- let dropOperation = allowedOperations[0];
1282
- if (typeof options.getDropOperation === "function") {
1283
- let types = new (0, $4620ae0dc40f0031$export$7f04ce188c91447c)(e.dataTransfer);
1284
- dropOperation = $1ca228bc9257ca16$var$getDropOperation(allowedOperationsBits, options.getDropOperation(types, allowedOperations));
1285
- }
1286
- if (typeof options.getDropOperationForPoint === "function") {
1287
- let types = new (0, $4620ae0dc40f0031$export$7f04ce188c91447c)(e.dataTransfer);
1288
- let rect = e.currentTarget.getBoundingClientRect();
1289
- dropOperation = $1ca228bc9257ca16$var$getDropOperation(allowedOperationsBits, options.getDropOperationForPoint(types, allowedOperations, e.clientX - rect.x, e.clientY - rect.y));
1290
- }
1291
- state.x = e.clientX;
1292
- state.y = e.clientY;
1293
- state.allowedOperations = allowedOperationsBits;
1294
- state.dropEffect = (0, $76b1e110a27b1ccd$export$5eacb0769d26d3b2)[dropOperation] || "none";
1295
- e.dataTransfer.dropEffect = state.dropEffect;
1296
- if (dropOperation !== "cancel") fireDropEnter(e);
1297
- };
1298
- let onDragLeave = (e)=>{
1299
- e.preventDefault();
1300
- e.stopPropagation();
1301
- // We would use e.relatedTarget to detect if the drag is still inside the drop target,
1302
- // but it is always null in WebKit. https://bugs.webkit.org/show_bug.cgi?id=66547
1303
- // Instead, we track all of the targets of dragenter events in a set, and remove them
1304
- // in dragleave. When the set becomes empty, we've left the drop target completely.
1305
- // We must also remove any elements that are no longer in the DOM, because dragleave
1306
- // events will never be fired for these. This can happen, for example, with drop
1307
- // indicators between items, which disappear when the drop target changes.
1308
- state.dragOverElements.delete(e.target);
1309
- for (let element of state.dragOverElements)if (!e.currentTarget.contains(element)) state.dragOverElements.delete(element);
1310
- if (state.dragOverElements.size > 0) return;
1311
- if (state.dropEffect !== "none") fireDropExit(e);
1312
- clearTimeout(state.dropActivateTimer);
1313
- };
1314
- let onDrop = (e)=>{
1315
- e.preventDefault();
1316
- e.stopPropagation();
1317
- // Track drop effect in global state for Chrome Android. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951
1318
- // Android onDragEnd always returns "none" as its drop effect.
1319
- (0, $4620ae0dc40f0031$export$64f52ed7349ddb84)(state.dropEffect);
1320
- if (typeof options.onDrop === "function") {
1321
- let dropOperation = (0, $76b1e110a27b1ccd$export$608ecc6f1b23c35d)[state.dropEffect];
1322
- let items = (0, $4620ae0dc40f0031$export$d9e760437831f8b3)(e.dataTransfer);
1323
- let rect = e.currentTarget.getBoundingClientRect();
1324
- let event = {
1325
- type: "drop",
1326
- x: e.clientX - rect.x,
1327
- y: e.clientY - rect.y,
1328
- items: items,
1329
- dropOperation: dropOperation
1330
- };
1331
- options.onDrop(event);
1332
- }
1333
- let dndStateSnapshot = {
1334
- ...(0, $4620ae0dc40f0031$export$6ca6700462636d0b)
1335
- };
1336
- state.dragOverElements.clear();
1337
- fireDropExit(e);
1338
- clearTimeout(state.dropActivateTimer);
1339
- // 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
1340
- // RSP collection and thus we don't need to preserve the global drop effect
1341
- if (dndStateSnapshot.draggingCollectionRef == null) (0, $4620ae0dc40f0031$export$64f52ed7349ddb84)(undefined);
1342
- else // Otherwise we need to preserve the global dnd state for onDragEnd's isInternal check.
1343
- // At the moment fireDropExit may clear dropCollectionRef (i.e. useDroppableCollection's provided onDropExit, required to clear dropCollectionRef when exiting a valid drop target)
1344
- (0, $4620ae0dc40f0031$export$6c10d32b362bfa5f)(dndStateSnapshot);
1345
- };
1346
- let onDropEnter = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
1347
- if (typeof options.onDropEnter === "function") options.onDropEnter(e);
1348
- });
1349
- let onDropExit = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
1350
- if (typeof options.onDropExit === "function") options.onDropExit(e);
1351
- });
1352
- let onDropActivate = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
1353
- if (typeof options.onDropActivate === "function") options.onDropActivate(e);
1354
- });
1355
- let onKeyboardDrop = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
1356
- if (typeof options.onDrop === "function") options.onDrop(e);
1357
- });
1358
- let getDropOperationKeyboard = (0, $4vY0V$reactariautils.useEffectEvent)((types, allowedOperations)=>{
1359
- if (options.getDropOperation) return options.getDropOperation(types, allowedOperations);
1360
- return allowedOperations[0];
1361
- });
1362
- let { ref: ref } = options;
1363
- (0, $4vY0V$reactariautils.useLayoutEffect)(()=>{
1364
- if (isDisabled) return;
1365
- return $28e10663603f5ea1$export$c28d9fb4a54e471a({
1366
- element: ref.current,
1367
- getDropOperation: getDropOperationKeyboard,
1368
- onDropEnter (e) {
1369
- setDropTarget(true);
1370
- onDropEnter(e);
1371
- },
1372
- onDropExit (e) {
1373
- setDropTarget(false);
1374
- onDropExit(e);
1375
- },
1376
- onDrop: onKeyboardDrop,
1377
- onDropActivate: onDropActivate
1378
- });
1379
- }, [
1380
- isDisabled,
1381
- ref,
1382
- getDropOperationKeyboard,
1383
- onDropEnter,
1384
- onDropExit,
1385
- onKeyboardDrop,
1386
- onDropActivate
1387
- ]);
1388
- let { dropProps: dropProps } = (0, $419982e205c8e8dc$export$62447ad3d2ec7da6)();
1389
- if (isDisabled) return {
1390
- dropProps: {},
1391
- dropButtonProps: {
1392
- isDisabled: true
1393
- },
1394
- isDropTarget: false
1395
- };
1396
- return {
1397
- dropProps: {
1398
- ...!hasDropButton && dropProps,
1399
- onDragEnter: onDragEnter,
1400
- onDragOver: onDragOver,
1401
- onDragLeave: onDragLeave,
1402
- onDrop: onDrop
1403
- },
1404
- dropButtonProps: {
1405
- ...hasDropButton && dropProps
1406
- },
1407
- isDropTarget: isDropTarget
1408
- };
1409
- }
1410
- function $1ca228bc9257ca16$var$getAllowedOperations(e) {
1411
- let allowedOperations = (0, $76b1e110a27b1ccd$export$9bbdfc78cf083e16)[e.dataTransfer.effectAllowed];
1412
- // WebKit always sets effectAllowed to "copyMove" on macOS, and "all" on iOS, regardless of what was
1413
- // set during the dragstart event: https://bugs.webkit.org/show_bug.cgi?id=178058
1414
- //
1415
- // Android Chrome also sets effectAllowed to "copyMove" in all cases: https://bugs.chromium.org/p/chromium/issues/detail?id=1359182
1416
- //
1417
- // If the drag started within the page, we can use a global variable to get the real allowed operations.
1418
- // This needs to be intersected with the actual effectAllowed, which may have been filtered based on modifier keys.
1419
- // Unfortunately, this means that link operations do not work at all in Safari.
1420
- if (0, $4620ae0dc40f0031$export$f0130eb70b6347b8) allowedOperations &= (0, $4620ae0dc40f0031$export$f0130eb70b6347b8);
1421
- // Chrome and Safari on macOS will automatically filter effectAllowed when pressing modifier keys,
1422
- // allowing the user to switch between move, link, and copy operations. Firefox on macOS and all
1423
- // Windows browsers do not do this, so do it ourselves instead. The exact keys are platform dependent.
1424
- // https://ux.stackexchange.com/questions/83748/what-are-the-most-common-modifier-keys-for-dragging-objects-with-a-mouse
1425
- //
1426
- // Note that none of these modifiers are ever set in WebKit due to a bug: https://bugs.webkit.org/show_bug.cgi?id=77465
1427
- // However, Safari does update effectAllowed correctly, so we can just rely on that.
1428
- let allowedModifiers = (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).none;
1429
- if ((0, $4vY0V$reactariautils.isMac)()) {
1430
- if (e.altKey) allowedModifiers |= (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).copy;
1431
- // Chrome and Safari both use the Control key for link, even though Finder uses Command + Option.
1432
- // iPadOS doesn't support link operations and will not fire the drop event at all if dropEffect is set to link.
1433
- // https://bugs.webkit.org/show_bug.cgi?id=244701
1434
- if (e.ctrlKey && !(0, $4vY0V$reactariautils.isIPad)()) allowedModifiers |= (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).link;
1435
- if (e.metaKey) allowedModifiers |= (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).move;
1436
- } else {
1437
- if (e.altKey) allowedModifiers |= (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).link;
1438
- if (e.shiftKey) allowedModifiers |= (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).move;
1439
- if (e.ctrlKey) allowedModifiers |= (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).copy;
1440
- }
1441
- if (allowedModifiers) return allowedOperations & allowedModifiers;
1442
- return allowedOperations;
1443
- }
1444
- function $1ca228bc9257ca16$var$allowedOperationsToArray(allowedOperationsBits) {
1445
- let allowedOperations = [];
1446
- if (allowedOperationsBits & (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).move) allowedOperations.push("move");
1447
- if (allowedOperationsBits & (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).copy) allowedOperations.push("copy");
1448
- if (allowedOperationsBits & (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e).link) allowedOperations.push("link");
1449
- return allowedOperations;
1450
- }
1451
- function $1ca228bc9257ca16$var$getDropOperation(allowedOperations, operation) {
1452
- let op = (0, $76b1e110a27b1ccd$export$60b7b4bcf3903d8e)[operation];
1453
- return allowedOperations & op ? operation : "cancel";
1454
- }
1455
-
1456
-
1457
- /*
1458
- * Copyright 2020 Adobe. All rights reserved.
1459
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1460
- * you may not use this file except in compliance with the License. You may obtain a copy
1461
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1462
- *
1463
- * Unless required by applicable law or agreed to in writing, software distributed under
1464
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1465
- * OF ANY KIND, either express or implied. See the License for the specific language
1466
- * governing permissions and limitations under the License.
1467
- */
1468
49
 
1469
50
 
1470
51
 
1471
52
 
1472
- /*
1473
- * Copyright 2020 Adobe. All rights reserved.
1474
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1475
- * you may not use this file except in compliance with the License. You may obtain a copy
1476
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1477
- *
1478
- * Unless required by applicable law or agreed to in writing, software distributed under
1479
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1480
- * OF ANY KIND, either express or implied. See the License for the specific language
1481
- * governing permissions and limitations under the License.
1482
- */
1483
-
1484
- const $12cc069a1c69155b$var$AUTOSCROLL_AREA_SIZE = 20;
1485
- function $12cc069a1c69155b$export$6323452ca4533ed8(ref) {
1486
- let scrollableRef = (0, $4vY0V$react.useRef)(null);
1487
- let scrollableX = (0, $4vY0V$react.useRef)(true);
1488
- let scrollableY = (0, $4vY0V$react.useRef)(true);
1489
- (0, $4vY0V$react.useEffect)(()=>{
1490
- if (ref.current) {
1491
- scrollableRef.current = (0, $4vY0V$reactariautils.isScrollable)(ref.current) ? ref.current : (0, $4vY0V$reactariautils.getScrollParent)(ref.current);
1492
- let style = window.getComputedStyle(scrollableRef.current);
1493
- scrollableX.current = /(auto|scroll)/.test(style.overflowX);
1494
- scrollableY.current = /(auto|scroll)/.test(style.overflowY);
1495
- }
1496
- }, [
1497
- ref
1498
- ]);
1499
- let state = (0, $4vY0V$react.useRef)({
1500
- timer: null,
1501
- dx: 0,
1502
- dy: 0
1503
- }).current;
1504
- (0, $4vY0V$react.useEffect)(()=>{
1505
- return ()=>{
1506
- if (state.timer) {
1507
- cancelAnimationFrame(state.timer);
1508
- state.timer = null;
1509
- }
1510
- };
1511
- // state will become a new object, so it's ok to use in the dependency array for unmount
1512
- }, [
1513
- state
1514
- ]);
1515
- let scroll = (0, $4vY0V$react.useCallback)(()=>{
1516
- if (scrollableX.current) scrollableRef.current.scrollLeft += state.dx;
1517
- if (scrollableY.current) scrollableRef.current.scrollTop += state.dy;
1518
- if (state.timer) state.timer = requestAnimationFrame(scroll);
1519
- }, [
1520
- scrollableRef,
1521
- state
1522
- ]);
1523
- return {
1524
- move (x, y) {
1525
- // Most browsers auto scroll natively, but WebKit on macOS does not (iOS does 🤷‍♂️).
1526
- // https://bugs.webkit.org/show_bug.cgi?id=222636
1527
- if (!(0, $4vY0V$reactariautils.isWebKit)() || (0, $4vY0V$reactariautils.isIOS)() || !scrollableRef.current) return;
1528
- let box = scrollableRef.current.getBoundingClientRect();
1529
- let left = $12cc069a1c69155b$var$AUTOSCROLL_AREA_SIZE;
1530
- let top = $12cc069a1c69155b$var$AUTOSCROLL_AREA_SIZE;
1531
- let bottom = box.height - $12cc069a1c69155b$var$AUTOSCROLL_AREA_SIZE;
1532
- let right = box.width - $12cc069a1c69155b$var$AUTOSCROLL_AREA_SIZE;
1533
- if (x < left || x > right || y < top || y > bottom) {
1534
- if (x < left) state.dx = x - left;
1535
- else if (x > right) state.dx = x - right;
1536
- if (y < top) state.dy = y - top;
1537
- else if (y > bottom) state.dy = y - bottom;
1538
- if (!state.timer) state.timer = requestAnimationFrame(scroll);
1539
- } else this.stop();
1540
- },
1541
- stop () {
1542
- if (state.timer) {
1543
- cancelAnimationFrame(state.timer);
1544
- state.timer = null;
1545
- }
1546
- }
1547
- };
1548
- }
1549
-
1550
-
1551
-
1552
-
1553
- const $7f93a158ac20b90a$var$DROP_POSITIONS = [
1554
- "before",
1555
- "on",
1556
- "after"
1557
- ];
1558
- const $7f93a158ac20b90a$var$DROP_POSITIONS_RTL = [
1559
- "after",
1560
- "on",
1561
- "before"
1562
- ];
1563
- function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
1564
- let localState = (0, $4vY0V$react.useRef)({
1565
- props: props,
1566
- state: state,
1567
- nextTarget: null,
1568
- dropOperation: null
1569
- }).current;
1570
- localState.props = props;
1571
- localState.state = state;
1572
- let defaultOnDrop = (0, $4vY0V$react.useCallback)(async (e)=>{
1573
- let { onInsert: onInsert, onRootDrop: onRootDrop, onItemDrop: onItemDrop, onReorder: onReorder, acceptedDragTypes: acceptedDragTypes = "all", shouldAcceptItemDrop: shouldAcceptItemDrop } = localState.props;
1574
- let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
1575
- let isInternal = (0, $4620ae0dc40f0031$export$78bf638634500fa5)(ref);
1576
- let { target: target, dropOperation: dropOperation, items: items } = e;
1577
- let filteredItems = items;
1578
- if (acceptedDragTypes !== "all" || shouldAcceptItemDrop) filteredItems = items.filter((item)=>{
1579
- let itemTypes;
1580
- if (item.kind === "directory") itemTypes = new Set([
1581
- (0, $4620ae0dc40f0031$export$990fced5dfac2637)
1582
- ]);
1583
- else itemTypes = item.kind === "file" ? new Set([
1584
- item.type
1585
- ]) : item.types;
1586
- if (acceptedDragTypes === "all" || acceptedDragTypes.some((type)=>itemTypes.has(type))) {
1587
- // If we are performing a on item drop, check if the item in question accepts the dropped item since the item may have heavier restrictions
1588
- // than the droppable collection itself
1589
- if (target.type === "item" && target.dropPosition === "on" && shouldAcceptItemDrop) return shouldAcceptItemDrop(target, itemTypes);
1590
- return true;
1591
- }
1592
- return false;
1593
- });
1594
- if (filteredItems.length > 0) {
1595
- if (target.type === "root" && onRootDrop) await onRootDrop({
1596
- items: filteredItems,
1597
- dropOperation: dropOperation
1598
- });
1599
- if (target.type === "item") {
1600
- if (target.dropPosition === "on" && onItemDrop) await onItemDrop({
1601
- items: filteredItems,
1602
- dropOperation: dropOperation,
1603
- isInternal: isInternal,
1604
- target: target
1605
- });
1606
- if (target.dropPosition !== "on") {
1607
- if (!isInternal && onInsert) await onInsert({
1608
- items: filteredItems,
1609
- dropOperation: dropOperation,
1610
- target: target
1611
- });
1612
- if (isInternal && onReorder) await onReorder({
1613
- keys: draggingKeys,
1614
- dropOperation: dropOperation,
1615
- target: target
1616
- });
1617
- }
1618
- }
1619
- }
1620
- }, [
1621
- localState,
1622
- ref
1623
- ]);
1624
- let autoScroll = (0, $12cc069a1c69155b$export$6323452ca4533ed8)(ref);
1625
- let { dropProps: dropProps } = (0, $1ca228bc9257ca16$export$ccdee5eaf73cf661)({
1626
- ref: ref,
1627
- onDropEnter () {
1628
- state.setTarget(localState.nextTarget);
1629
- },
1630
- onDropMove (e) {
1631
- state.setTarget(localState.nextTarget);
1632
- autoScroll.move(e.x, e.y);
1633
- },
1634
- getDropOperationForPoint (types, allowedOperations, x, y) {
1635
- let { draggingKeys: draggingKeys, dropCollectionRef: dropCollectionRef } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
1636
- let isInternal = (0, $4620ae0dc40f0031$export$78bf638634500fa5)(ref);
1637
- let isValidDropTarget = (target)=>state.getDropOperation({
1638
- target: target,
1639
- types: types,
1640
- allowedOperations: allowedOperations,
1641
- isInternal: isInternal,
1642
- draggingKeys: draggingKeys
1643
- }) !== "cancel";
1644
- let target = props.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);
1645
- if (!target) {
1646
- localState.dropOperation = "cancel";
1647
- localState.nextTarget = null;
1648
- return "cancel";
1649
- }
1650
- localState.dropOperation = state.getDropOperation({
1651
- target: target,
1652
- types: types,
1653
- allowedOperations: allowedOperations,
1654
- isInternal: isInternal,
1655
- draggingKeys: draggingKeys
1656
- });
1657
- // If the target doesn't accept the drop, see if the root accepts it instead.
1658
- if (localState.dropOperation === "cancel") {
1659
- let rootTarget = {
1660
- type: "root"
1661
- };
1662
- let dropOperation = state.getDropOperation({
1663
- target: rootTarget,
1664
- types: types,
1665
- allowedOperations: allowedOperations,
1666
- isInternal: isInternal,
1667
- draggingKeys: draggingKeys
1668
- });
1669
- if (dropOperation !== "cancel") {
1670
- target = rootTarget;
1671
- localState.dropOperation = dropOperation;
1672
- }
1673
- }
1674
- // Only set dropCollectionRef if there is a valid drop target since we cleanup dropCollectionRef in onDropExit
1675
- // which only runs when leaving a valid drop target or if the dropEffect become none (mouse dnd only).
1676
- if (target && localState.dropOperation !== "cancel" && (ref === null || ref === void 0 ? void 0 : ref.current) !== (dropCollectionRef === null || dropCollectionRef === void 0 ? void 0 : dropCollectionRef.current)) (0, $4620ae0dc40f0031$export$dac8db29d42db9a1)(ref);
1677
- localState.nextTarget = localState.dropOperation === "cancel" ? null : target;
1678
- return localState.dropOperation;
1679
- },
1680
- onDropExit () {
1681
- (0, $4620ae0dc40f0031$export$dac8db29d42db9a1)(undefined);
1682
- state.setTarget(null);
1683
- autoScroll.stop();
1684
- },
1685
- onDropActivate (e) {
1686
- var _state_target, _state_target1;
1687
- if (((_state_target = state.target) === null || _state_target === void 0 ? void 0 : _state_target.type) === "item" && ((_state_target1 = state.target) === null || _state_target1 === void 0 ? void 0 : _state_target1.dropPosition) === "on" && typeof props.onDropActivate === "function") props.onDropActivate({
1688
- type: "dropactivate",
1689
- x: e.x,
1690
- y: e.y,
1691
- target: state.target
1692
- });
1693
- },
1694
- onDrop (e) {
1695
- (0, $4620ae0dc40f0031$export$dac8db29d42db9a1)(ref);
1696
- if (state.target) onDrop(e, state.target);
1697
- // 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
1698
- // RSP collection and thus we don't need to preserve the global DnD state for onDragEnd
1699
- let { draggingCollectionRef: draggingCollectionRef } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
1700
- if (draggingCollectionRef == null) (0, $4620ae0dc40f0031$export$70936501603e6c57)();
1701
- }
1702
- });
1703
- let droppingState = (0, $4vY0V$react.useRef)(null);
1704
- let onDrop = (0, $4vY0V$react.useCallback)((e, target)=>{
1705
- var _state_collection_getItem;
1706
- let { state: state } = localState;
1707
- // Focus the collection.
1708
- state.selectionManager.setFocused(true);
1709
- // Save some state of the collection/selection before the drop occurs so we can compare later.
1710
- let focusedKey = state.selectionManager.focusedKey;
1711
- // If parent key was dragged, we want to use it instead (i.e. focus row instead of cell after dropping)
1712
- if ((0, $4620ae0dc40f0031$export$6ca6700462636d0b).draggingKeys.has((_state_collection_getItem = state.collection.getItem(focusedKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.parentKey)) {
1713
- focusedKey = state.collection.getItem(focusedKey).parentKey;
1714
- state.selectionManager.setFocusedKey(focusedKey);
1715
- }
1716
- droppingState.current = {
1717
- timeout: null,
1718
- focusedKey: focusedKey,
1719
- collection: state.collection,
1720
- selectedKeys: state.selectionManager.selectedKeys
1721
- };
1722
- let onDropFn = localState.props.onDrop || defaultOnDrop;
1723
- onDropFn({
1724
- type: "drop",
1725
- x: e.x,
1726
- y: e.y,
1727
- target: target,
1728
- items: e.items,
1729
- dropOperation: e.dropOperation
1730
- });
1731
- // Wait for a short time period after the onDrop is called to allow the data to be read asynchronously
1732
- // and for React to re-render. If an insert occurs during this time, it will be selected/focused below.
1733
- // If items are not "immediately" inserted by the onDrop handler, the application will need to handle
1734
- // selecting and focusing those items themselves.
1735
- droppingState.current.timeout = setTimeout(()=>{
1736
- // If focus didn't move already (e.g. due to an insert), and the user dropped on an item,
1737
- // focus that item and show the focus ring to give the user feedback that the drop occurred.
1738
- // Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.
1739
- let { state: state } = localState;
1740
- if (target.type === "item" && target.dropPosition === "on" && state.collection.getItem(target.key) != null) {
1741
- state.selectionManager.setFocusedKey(target.key);
1742
- state.selectionManager.setFocused(true);
1743
- (0, $4vY0V$reactariainteractions.setInteractionModality)("keyboard");
1744
- } else if (!state.selectionManager.isSelected(focusedKey)) (0, $4vY0V$reactariainteractions.setInteractionModality)("keyboard");
1745
- droppingState.current = null;
1746
- }, 50);
1747
- }, [
1748
- localState,
1749
- defaultOnDrop
1750
- ]);
1751
- // eslint-disable-next-line arrow-body-style
1752
- (0, $4vY0V$react.useEffect)(()=>{
1753
- return ()=>{
1754
- if (droppingState.current) clearTimeout(droppingState.current.timeout);
1755
- };
1756
- }, []);
1757
- (0, $4vY0V$reactariautils.useLayoutEffect)(()=>{
1758
- // If an insert occurs during a drop, we want to immediately select these items to give
1759
- // feedback to the user that a drop occurred. Only do this if the selection didn't change
1760
- // since the drop started so we don't override if the user or application did something.
1761
- if (droppingState.current && state.selectionManager.isFocused && state.collection.size > droppingState.current.collection.size && state.selectionManager.isSelectionEqual(droppingState.current.selectedKeys)) {
1762
- let newKeys = new Set();
1763
- for (let key of state.collection.getKeys())if (!droppingState.current.collection.getItem(key)) newKeys.add(key);
1764
- state.selectionManager.setSelectedKeys(newKeys);
1765
- // If the focused item didn't change since the drop occurred, also focus the first
1766
- // inserted item. If selection is disabled, then also show the focus ring so there
1767
- // is some indication that items were added.
1768
- if (state.selectionManager.focusedKey === droppingState.current.focusedKey) {
1769
- let first = newKeys.keys().next().value;
1770
- let item = state.collection.getItem(first);
1771
- // If this is a cell, focus the parent row.
1772
- if ((item === null || item === void 0 ? void 0 : item.type) === "cell") first = item.parentKey;
1773
- state.selectionManager.setFocusedKey(first);
1774
- if (state.selectionManager.selectionMode === "none") (0, $4vY0V$reactariainteractions.setInteractionModality)("keyboard");
1775
- }
1776
- droppingState.current = null;
1777
- }
1778
- });
1779
- let { direction: direction } = (0, $4vY0V$reactariai18n.useLocale)();
1780
- (0, $4vY0V$react.useEffect)(()=>{
1781
- let getNextTarget = (target, wrap = true, horizontal = false)=>{
1782
- if (!target) return {
1783
- type: "root"
1784
- };
1785
- let { keyboardDelegate: keyboardDelegate } = localState.props;
1786
- let nextKey;
1787
- if ((target === null || target === void 0 ? void 0 : target.type) === "item") nextKey = horizontal ? keyboardDelegate.getKeyRightOf(target.key) : keyboardDelegate.getKeyBelow(target.key);
1788
- else nextKey = horizontal && direction === "rtl" ? keyboardDelegate.getLastKey() : keyboardDelegate.getFirstKey();
1789
- let dropPositions = horizontal && direction === "rtl" ? $7f93a158ac20b90a$var$DROP_POSITIONS_RTL : $7f93a158ac20b90a$var$DROP_POSITIONS;
1790
- let dropPosition = dropPositions[0];
1791
- if (target.type === "item") {
1792
- // If the the keyboard delegate returned the next key in the collection,
1793
- // first try the other positions in the current key. Otherwise (e.g. in a grid layout),
1794
- // jump to the same drop position in the new key.
1795
- let nextCollectionKey = horizontal && direction === "rtl" ? localState.state.collection.getKeyBefore(target.key) : localState.state.collection.getKeyAfter(target.key);
1796
- if (nextKey == null || nextKey === nextCollectionKey) {
1797
- let positionIndex = dropPositions.indexOf(target.dropPosition);
1798
- let nextDropPosition = dropPositions[positionIndex + 1];
1799
- if (positionIndex < dropPositions.length - 1 && !(nextDropPosition === dropPositions[2] && nextKey != null)) return {
1800
- type: "item",
1801
- key: target.key,
1802
- dropPosition: nextDropPosition
1803
- };
1804
- // If the last drop position was 'after', then 'before' on the next key is equivalent.
1805
- // Switch to 'on' instead.
1806
- if (target.dropPosition === dropPositions[2]) dropPosition = "on";
1807
- } else dropPosition = target.dropPosition;
1808
- }
1809
- if (nextKey == null) {
1810
- if (wrap) return {
1811
- type: "root"
1812
- };
1813
- return null;
1814
- }
1815
- return {
1816
- type: "item",
1817
- key: nextKey,
1818
- dropPosition: dropPosition
1819
- };
1820
- };
1821
- let getPreviousTarget = (target, wrap = true, horizontal = false)=>{
1822
- let { keyboardDelegate: keyboardDelegate } = localState.props;
1823
- let nextKey;
1824
- if ((target === null || target === void 0 ? void 0 : target.type) === "item") nextKey = horizontal ? keyboardDelegate.getKeyLeftOf(target.key) : keyboardDelegate.getKeyAbove(target.key);
1825
- else nextKey = horizontal && direction === "rtl" ? keyboardDelegate.getFirstKey() : keyboardDelegate.getLastKey();
1826
- let dropPositions = horizontal && direction === "rtl" ? $7f93a158ac20b90a$var$DROP_POSITIONS_RTL : $7f93a158ac20b90a$var$DROP_POSITIONS;
1827
- let dropPosition = !target || target.type === "root" ? dropPositions[2] : "on";
1828
- if ((target === null || target === void 0 ? void 0 : target.type) === "item") {
1829
- // If the the keyboard delegate returned the previous key in the collection,
1830
- // first try the other positions in the current key. Otherwise (e.g. in a grid layout),
1831
- // jump to the same drop position in the new key.
1832
- let prevCollectionKey = horizontal && direction === "rtl" ? localState.state.collection.getKeyAfter(target.key) : localState.state.collection.getKeyBefore(target.key);
1833
- if (nextKey == null || nextKey === prevCollectionKey) {
1834
- let positionIndex = dropPositions.indexOf(target.dropPosition);
1835
- let nextDropPosition = dropPositions[positionIndex - 1];
1836
- if (positionIndex > 0 && nextDropPosition !== dropPositions[2]) return {
1837
- type: "item",
1838
- key: target.key,
1839
- dropPosition: nextDropPosition
1840
- };
1841
- // If the last drop position was 'before', then 'after' on the previous key is equivalent.
1842
- // Switch to 'on' instead.
1843
- if (target.dropPosition === dropPositions[0]) dropPosition = "on";
1844
- } else dropPosition = target.dropPosition;
1845
- }
1846
- if (nextKey == null) {
1847
- if (wrap) return {
1848
- type: "root"
1849
- };
1850
- return null;
1851
- }
1852
- return {
1853
- type: "item",
1854
- key: nextKey,
1855
- dropPosition: dropPosition
1856
- };
1857
- };
1858
- let nextValidTarget = (target, types, allowedDropOperations, getNextTarget, wrap = true)=>{
1859
- let seenRoot = 0;
1860
- let operation;
1861
- let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
1862
- let isInternal = (0, $4620ae0dc40f0031$export$78bf638634500fa5)(ref);
1863
- do {
1864
- let nextTarget = getNextTarget(target, wrap);
1865
- if (!nextTarget) return null;
1866
- target = nextTarget;
1867
- operation = localState.state.getDropOperation({
1868
- target: nextTarget,
1869
- types: types,
1870
- allowedOperations: allowedDropOperations,
1871
- isInternal: isInternal,
1872
- draggingKeys: draggingKeys
1873
- });
1874
- if (target.type === "root") seenRoot++;
1875
- }while (operation === "cancel" && !localState.state.isDropTarget(target) && seenRoot < 2);
1876
- if (operation === "cancel") return null;
1877
- return target;
1878
- };
1879
- return $28e10663603f5ea1$export$c28d9fb4a54e471a({
1880
- element: ref.current,
1881
- getDropOperation (types, allowedOperations) {
1882
- if (localState.state.target) {
1883
- let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
1884
- let isInternal = (0, $4620ae0dc40f0031$export$78bf638634500fa5)(ref);
1885
- return localState.state.getDropOperation({
1886
- target: localState.state.target,
1887
- types: types,
1888
- allowedOperations: allowedOperations,
1889
- isInternal: isInternal,
1890
- draggingKeys: draggingKeys
1891
- });
1892
- }
1893
- // Check if any of the targets accept the drop.
1894
- // TODO: should we have a faster way of doing this or e.g. for pagination?
1895
- let target = nextValidTarget(null, types, allowedOperations, getNextTarget);
1896
- return target ? "move" : "cancel";
1897
- },
1898
- onDropEnter (e, drag) {
1899
- let types = (0, $4620ae0dc40f0031$export$e1d41611756c6326)(drag.items);
1900
- let selectionManager = localState.state.selectionManager;
1901
- let target;
1902
- // Update the drop collection ref tracker for useDroppableItem's getDropOperation isInternal check
1903
- (0, $4620ae0dc40f0031$export$dac8db29d42db9a1)(ref);
1904
- // When entering the droppable collection for the first time, the default drop target
1905
- // is after the focused key.
1906
- let key = selectionManager.focusedKey;
1907
- let dropPosition = "after";
1908
- // If the focused key is a cell, get the parent item instead.
1909
- // For now, we assume that individual cells cannot be dropped on.
1910
- let item = localState.state.collection.getItem(key);
1911
- if ((item === null || item === void 0 ? void 0 : item.type) === "cell") key = item.parentKey;
1912
- // If the focused item is also selected, the default drop target is after the last selected item.
1913
- // But if the focused key is the first selected item, then default to before the first selected item.
1914
- // This is to make reordering lists slightly easier. If you select top down, we assume you want to
1915
- // move the items down. If you select bottom up, we assume you want to move the items up.
1916
- if (selectionManager.isSelected(key)) {
1917
- if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) dropPosition = "before";
1918
- else key = selectionManager.lastSelectedKey;
1919
- }
1920
- if (key != null) {
1921
- target = {
1922
- type: "item",
1923
- key: key,
1924
- dropPosition: dropPosition
1925
- };
1926
- let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
1927
- let isInternal = (0, $4620ae0dc40f0031$export$78bf638634500fa5)(ref);
1928
- var _nextValidTarget;
1929
- // If the default target is not valid, find the next one that is.
1930
- if (localState.state.getDropOperation({
1931
- target: target,
1932
- types: types,
1933
- allowedOperations: drag.allowedDropOperations,
1934
- isInternal: isInternal,
1935
- draggingKeys: draggingKeys
1936
- }) === "cancel") target = (_nextValidTarget = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)) !== null && _nextValidTarget !== void 0 ? _nextValidTarget : nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);
1937
- }
1938
- // If no focused key, then start from the root.
1939
- if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
1940
- localState.state.setTarget(target);
1941
- },
1942
- onDropExit () {
1943
- (0, $4620ae0dc40f0031$export$dac8db29d42db9a1)(undefined);
1944
- localState.state.setTarget(null);
1945
- },
1946
- onDropTargetEnter (target) {
1947
- localState.state.setTarget(target);
1948
- },
1949
- onDropActivate (e) {
1950
- var _localState_state_target, _localState_state_target1;
1951
- if (((_localState_state_target = localState.state.target) === null || _localState_state_target === void 0 ? void 0 : _localState_state_target.type) === "item" && ((_localState_state_target1 = localState.state.target) === null || _localState_state_target1 === void 0 ? void 0 : _localState_state_target1.dropPosition) === "on" && typeof localState.props.onDropActivate === "function") localState.props.onDropActivate({
1952
- type: "dropactivate",
1953
- x: e.x,
1954
- y: e.y,
1955
- target: localState.state.target
1956
- });
1957
- },
1958
- onDrop (e, target) {
1959
- (0, $4620ae0dc40f0031$export$dac8db29d42db9a1)(ref);
1960
- if (localState.state.target) onDrop(e, target || localState.state.target);
1961
- },
1962
- onKeyDown (e, drag) {
1963
- let { keyboardDelegate: keyboardDelegate } = localState.props;
1964
- let types = (0, $4620ae0dc40f0031$export$e1d41611756c6326)(drag.items);
1965
- switch(e.key){
1966
- case "ArrowDown":
1967
- if (keyboardDelegate.getKeyBelow) {
1968
- let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getNextTarget);
1969
- localState.state.setTarget(target);
1970
- }
1971
- break;
1972
- case "ArrowUp":
1973
- if (keyboardDelegate.getKeyAbove) {
1974
- let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getPreviousTarget);
1975
- localState.state.setTarget(target);
1976
- }
1977
- break;
1978
- case "ArrowLeft":
1979
- if (keyboardDelegate.getKeyLeftOf) {
1980
- let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap)=>getPreviousTarget(target, wrap, true));
1981
- localState.state.setTarget(target);
1982
- }
1983
- break;
1984
- case "ArrowRight":
1985
- if (keyboardDelegate.getKeyRightOf) {
1986
- let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap)=>getNextTarget(target, wrap, true));
1987
- localState.state.setTarget(target);
1988
- }
1989
- break;
1990
- case "Home":
1991
- if (keyboardDelegate.getFirstKey) {
1992
- let target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
1993
- localState.state.setTarget(target);
1994
- }
1995
- break;
1996
- case "End":
1997
- if (keyboardDelegate.getLastKey) {
1998
- let target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);
1999
- localState.state.setTarget(target);
2000
- }
2001
- break;
2002
- case "PageDown":
2003
- if (keyboardDelegate.getKeyPageBelow) {
2004
- let target = localState.state.target;
2005
- if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
2006
- else {
2007
- // If on the root, go to the item a page below the top. Otherwise a page below the current item.
2008
- let nextKey = keyboardDelegate.getKeyPageBelow(target.type === "item" ? target.key : keyboardDelegate.getFirstKey());
2009
- let dropPosition = target.type === "item" ? target.dropPosition : "after";
2010
- // If there is no next key, or we are starting on the last key, jump to the last possible position.
2011
- if (nextKey == null || target.type === "item" && target.key === keyboardDelegate.getLastKey()) {
2012
- nextKey = keyboardDelegate.getLastKey();
2013
- dropPosition = "after";
2014
- }
2015
- target = {
2016
- type: "item",
2017
- key: nextKey,
2018
- dropPosition: dropPosition
2019
- };
2020
- // If the target does not accept the drop, find the next valid target.
2021
- // If no next valid target, find the previous valid target.
2022
- let { draggingCollectionRef: draggingCollectionRef, draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
2023
- let isInternal = (draggingCollectionRef === null || draggingCollectionRef === void 0 ? void 0 : draggingCollectionRef.current) === (ref === null || ref === void 0 ? void 0 : ref.current);
2024
- let operation = localState.state.getDropOperation({
2025
- target: target,
2026
- types: types,
2027
- allowedOperations: drag.allowedDropOperations,
2028
- isInternal: isInternal,
2029
- draggingKeys: draggingKeys
2030
- });
2031
- var _nextValidTarget;
2032
- if (operation === "cancel") target = (_nextValidTarget = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)) !== null && _nextValidTarget !== void 0 ? _nextValidTarget : nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);
2033
- }
2034
- localState.state.setTarget(target !== null && target !== void 0 ? target : localState.state.target);
2035
- }
2036
- break;
2037
- case "PageUp":
2038
- {
2039
- if (!keyboardDelegate.getKeyPageAbove) break;
2040
- let target = localState.state.target;
2041
- if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);
2042
- else if (target.type === "item") {
2043
- // If at the top already, switch to the root. Otherwise navigate a page up.
2044
- if (target.key === keyboardDelegate.getFirstKey()) target = {
2045
- type: "root"
2046
- };
2047
- else {
2048
- let nextKey = keyboardDelegate.getKeyPageAbove(target.key);
2049
- let dropPosition = target.dropPosition;
2050
- if (nextKey == null) {
2051
- nextKey = keyboardDelegate.getFirstKey();
2052
- dropPosition = "before";
2053
- }
2054
- target = {
2055
- type: "item",
2056
- key: nextKey,
2057
- dropPosition: dropPosition
2058
- };
2059
- }
2060
- // If the target does not accept the drop, find the previous valid target.
2061
- // If no next valid target, find the next valid target.
2062
- let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
2063
- let isInternal = (0, $4620ae0dc40f0031$export$78bf638634500fa5)(ref);
2064
- let operation = localState.state.getDropOperation({
2065
- target: target,
2066
- types: types,
2067
- allowedOperations: drag.allowedDropOperations,
2068
- isInternal: isInternal,
2069
- draggingKeys: draggingKeys
2070
- });
2071
- var _nextValidTarget1;
2072
- if (operation === "cancel") target = (_nextValidTarget1 = nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false)) !== null && _nextValidTarget1 !== void 0 ? _nextValidTarget1 : nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false);
2073
- }
2074
- localState.state.setTarget(target !== null && target !== void 0 ? target : localState.state.target);
2075
- break;
2076
- }
2077
- }
2078
- }
2079
- });
2080
- }, [
2081
- localState,
2082
- ref,
2083
- onDrop,
2084
- direction
2085
- ]);
2086
- let id = (0, $4vY0V$reactariautils.useId)();
2087
- (0, $4620ae0dc40f0031$export$dfdf5deeaf27473f).set(state, {
2088
- id: id,
2089
- ref: ref
2090
- });
2091
- return {
2092
- collectionProps: (0, $4vY0V$reactariautils.mergeProps)(dropProps, {
2093
- id: id,
2094
- // Remove description from collection element. If dropping on the entire collection,
2095
- // there should be a drop indicator that has this description, so no need to double announce.
2096
- "aria-describedby": null
2097
- })
2098
- };
2099
- }
2100
-
2101
-
2102
- /*
2103
- * Copyright 2020 Adobe. All rights reserved.
2104
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
2105
- * you may not use this file except in compliance with the License. You may obtain a copy
2106
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
2107
- *
2108
- * Unless required by applicable law or agreed to in writing, software distributed under
2109
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
2110
- * OF ANY KIND, either express or implied. See the License for the specific language
2111
- * governing permissions and limitations under the License.
2112
- */
2113
-
2114
-
2115
-
2116
- function $fc1876157e07bcec$export$f7b0c5d28b66b6a5(options, state, ref) {
2117
- let { dropProps: dropProps } = (0, $419982e205c8e8dc$export$62447ad3d2ec7da6)();
2118
- let droppableCollectionRef = (0, $4620ae0dc40f0031$export$7e397efd01d3db27)(state);
2119
- (0, $4vY0V$react.useEffect)(()=>{
2120
- if (ref.current) return $28e10663603f5ea1$export$aef80212ac99c003({
2121
- element: ref.current,
2122
- target: options.target,
2123
- getDropOperation (types, allowedOperations) {
2124
- let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
2125
- let isInternal = (0, $4620ae0dc40f0031$export$78bf638634500fa5)(droppableCollectionRef);
2126
- return state.getDropOperation({
2127
- target: options.target,
2128
- types: types,
2129
- allowedOperations: allowedOperations,
2130
- isInternal: isInternal,
2131
- draggingKeys: draggingKeys
2132
- });
2133
- }
2134
- });
2135
- }, [
2136
- ref,
2137
- options.target,
2138
- state,
2139
- droppableCollectionRef
2140
- ]);
2141
- let dragSession = $28e10663603f5ea1$export$418e185dd3f1b968();
2142
- let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
2143
- let isInternal = (0, $4620ae0dc40f0031$export$78bf638634500fa5)(droppableCollectionRef);
2144
- let isValidDropTarget = dragSession && state.getDropOperation({
2145
- target: options.target,
2146
- types: (0, $4620ae0dc40f0031$export$e1d41611756c6326)(dragSession.dragTarget.items),
2147
- allowedOperations: dragSession.dragTarget.allowedDropOperations,
2148
- isInternal: isInternal,
2149
- draggingKeys: draggingKeys
2150
- }) !== "cancel";
2151
- let isDropTarget = state.isDropTarget(options.target);
2152
- (0, $4vY0V$react.useEffect)(()=>{
2153
- if (dragSession && isDropTarget && ref.current) ref.current.focus();
2154
- }, [
2155
- isDropTarget,
2156
- dragSession,
2157
- ref
2158
- ]);
2159
- return {
2160
- dropProps: {
2161
- ...dropProps,
2162
- "aria-hidden": !dragSession || isValidDropTarget ? undefined : "true"
2163
- },
2164
- isDropTarget: isDropTarget
2165
- };
2166
- }
2167
-
2168
-
2169
- /*
2170
- * Copyright 2020 Adobe. All rights reserved.
2171
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
2172
- * you may not use this file except in compliance with the License. You may obtain a copy
2173
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
2174
- *
2175
- * Unless required by applicable law or agreed to in writing, software distributed under
2176
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
2177
- * OF ANY KIND, either express or implied. See the License for the specific language
2178
- * governing permissions and limitations under the License.
2179
- */
2180
-
2181
-
2182
-
2183
-
2184
-
2185
- function $c5557edbed563ebf$export$8d0e41d2815afac5(props, state, ref) {
2186
- let { target: target } = props;
2187
- let { collection: collection } = state;
2188
- let stringFormatter = (0, $4vY0V$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7c8adf3925a26206$exports))), "@react-aria/dnd");
2189
- let dragSession = $28e10663603f5ea1$export$418e185dd3f1b968();
2190
- let { dropProps: dropProps } = (0, $fc1876157e07bcec$export$f7b0c5d28b66b6a5)(props, state, ref);
2191
- let id = (0, $4vY0V$reactariautils.useId)();
2192
- let getText = (key)=>{
2193
- var _collection_getTextValue, _collection_getItem;
2194
- var _collection_getTextValue1;
2195
- return (_collection_getTextValue1 = (_collection_getTextValue = collection.getTextValue) === null || _collection_getTextValue === void 0 ? void 0 : _collection_getTextValue.call(collection, key)) !== null && _collection_getTextValue1 !== void 0 ? _collection_getTextValue1 : (_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue;
2196
- };
2197
- let label = "";
2198
- let labelledBy;
2199
- if (target.type === "root") {
2200
- label = stringFormatter.format("dropOnRoot");
2201
- labelledBy = `${id} ${(0, $4620ae0dc40f0031$export$3093291712f09a77)(state)}`;
2202
- } else if (target.dropPosition === "on") label = stringFormatter.format("dropOnItem", {
2203
- itemText: getText(target.key)
2204
- });
2205
- else {
2206
- let before;
2207
- let after;
2208
- if (collection.getFirstKey() === target.key && target.dropPosition === "before") before = null;
2209
- else before = target.dropPosition === "before" ? collection.getKeyBefore(target.key) : target.key;
2210
- if (collection.getLastKey() === target.key && target.dropPosition === "after") after = null;
2211
- else after = target.dropPosition === "after" ? collection.getKeyAfter(target.key) : target.key;
2212
- if (before && after) label = stringFormatter.format("insertBetween", {
2213
- beforeItemText: getText(before),
2214
- afterItemText: getText(after)
2215
- });
2216
- else if (before) label = stringFormatter.format("insertAfter", {
2217
- itemText: getText(before)
2218
- });
2219
- else if (after) label = stringFormatter.format("insertBefore", {
2220
- itemText: getText(after)
2221
- });
2222
- }
2223
- let isDropTarget = state.isDropTarget(target);
2224
- let ariaHidden = !dragSession ? "true" : dropProps["aria-hidden"];
2225
- return {
2226
- dropIndicatorProps: {
2227
- ...dropProps,
2228
- id: id,
2229
- "aria-roledescription": stringFormatter.format("dropIndicator"),
2230
- "aria-label": label,
2231
- "aria-labelledby": labelledBy,
2232
- "aria-hidden": ariaHidden,
2233
- tabIndex: -1
2234
- },
2235
- isDropTarget: isDropTarget,
2236
- // If aria-hidden, we are either not in a drag session or the drop target is invalid.
2237
- // In that case, there's no need to render anything at all unless we need to show the indicator visually.
2238
- // This can happen when dragging using the native DnD API as opposed to keyboard dragging.
2239
- isHidden: !isDropTarget && !!ariaHidden
2240
- };
2241
- }
2242
-
2243
-
2244
- /*
2245
- * Copyright 2020 Adobe. All rights reserved.
2246
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
2247
- * you may not use this file except in compliance with the License. You may obtain a copy
2248
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
2249
- *
2250
- * Unless required by applicable law or agreed to in writing, software distributed under
2251
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
2252
- * OF ANY KIND, either express or implied. See the License for the specific language
2253
- * governing permissions and limitations under the License.
2254
- */
2255
-
2256
-
2257
-
2258
-
2259
- const $0cbbd00cda972c67$var$MESSAGES = {
2260
- keyboard: {
2261
- selected: "dragSelectedKeyboard",
2262
- notSelected: "dragDescriptionKeyboard"
2263
- },
2264
- touch: {
2265
- selected: "dragSelectedLongPress",
2266
- notSelected: "dragDescriptionLongPress"
2267
- },
2268
- virtual: {
2269
- selected: "dragDescriptionVirtual",
2270
- notSelected: "dragDescriptionVirtual"
2271
- }
2272
- };
2273
- function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
2274
- let stringFormatter = (0, $4vY0V$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($7c8adf3925a26206$exports))), "@react-aria/dnd");
2275
- let isDisabled = state.isDisabled || state.selectionManager.isDisabled(props.key);
2276
- let { dragProps: dragProps, dragButtonProps: dragButtonProps } = (0, $dc204e8ec58447a6$export$7941f8aafa4b6021)({
2277
- getItems () {
2278
- return state.getItems(props.key);
2279
- },
2280
- preview: state.preview,
2281
- getAllowedDropOperations: state.getAllowedDropOperations,
2282
- hasDragButton: props.hasDragButton,
2283
- onDragStart (e) {
2284
- state.startDrag(props.key, e);
2285
- // Track draggingKeys for useDroppableCollection's default onDrop handler and useDroppableCollectionState's default getDropOperation
2286
- (0, $4620ae0dc40f0031$export$72cb63bdda528276)(state.draggingKeys);
2287
- },
2288
- onDragMove (e) {
2289
- state.moveDrag(e);
2290
- },
2291
- onDragEnd (e) {
2292
- let { dropOperation: dropOperation } = e;
2293
- let isInternal = dropOperation === "cancel" ? false : (0, $4620ae0dc40f0031$export$78bf638634500fa5)();
2294
- state.endDrag({
2295
- ...e,
2296
- keys: state.draggingKeys,
2297
- isInternal: isInternal
2298
- });
2299
- (0, $4620ae0dc40f0031$export$70936501603e6c57)();
2300
- }
2301
- });
2302
- let item = state.collection.getItem(props.key);
2303
- let numKeysForDrag = state.getKeysForDrag(props.key).size;
2304
- let isSelected = numKeysForDrag > 1 && state.selectionManager.isSelected(props.key);
2305
- let dragButtonLabel;
2306
- let description;
2307
- // Override description to include selected item count.
2308
- let modality = (0, $4620ae0dc40f0031$export$49bac5d6d4b352ea)();
2309
- if (!props.hasDragButton && state.selectionManager.selectionMode !== "none") {
2310
- let msg = $0cbbd00cda972c67$var$MESSAGES[modality][isSelected ? "selected" : "notSelected"];
2311
- if (props.hasAction && modality === "keyboard") msg += "Alt";
2312
- if (isSelected) description = stringFormatter.format(msg, {
2313
- count: numKeysForDrag
2314
- });
2315
- else description = stringFormatter.format(msg);
2316
- // Remove the onClick handler from useDrag. Long pressing will be required on touch devices,
2317
- // and NVDA/JAWS are always in forms mode within collection components.
2318
- delete dragProps.onClick;
2319
- } else if (isSelected) dragButtonLabel = stringFormatter.format("dragSelectedItems", {
2320
- count: numKeysForDrag
2321
- });
2322
- else {
2323
- var _state_collection_getTextValue, _state_collection;
2324
- var _state_collection_getTextValue1, _ref;
2325
- let itemText = (_ref = (_state_collection_getTextValue1 = (_state_collection_getTextValue = (_state_collection = state.collection).getTextValue) === null || _state_collection_getTextValue === void 0 ? void 0 : _state_collection_getTextValue.call(_state_collection, props.key)) !== null && _state_collection_getTextValue1 !== void 0 ? _state_collection_getTextValue1 : item === null || item === void 0 ? void 0 : item.textValue) !== null && _ref !== void 0 ? _ref : "";
2326
- dragButtonLabel = stringFormatter.format("dragItem", {
2327
- itemText: itemText
2328
- });
2329
- }
2330
- let descriptionProps = (0, $4vY0V$reactariautils.useDescription)(description);
2331
- if (description) Object.assign(dragProps, descriptionProps);
2332
- if (!props.hasDragButton && props.hasAction) {
2333
- let { onKeyDownCapture: onKeyDownCapture, onKeyUpCapture: onKeyUpCapture } = dragProps;
2334
- if (modality === "touch") // Remove long press description if an action is present, because in that case long pressing selects the item.
2335
- delete dragProps["aria-describedby"];
2336
- // Require Alt key if there is a conflicting action.
2337
- dragProps.onKeyDownCapture = (e)=>{
2338
- if (e.altKey) onKeyDownCapture === null || onKeyDownCapture === void 0 ? void 0 : onKeyDownCapture(e);
2339
- };
2340
- dragProps.onKeyUpCapture = (e)=>{
2341
- if (e.altKey) onKeyUpCapture === null || onKeyUpCapture === void 0 ? void 0 : onKeyUpCapture(e);
2342
- };
2343
- }
2344
- return {
2345
- dragProps: isDisabled ? {} : dragProps,
2346
- dragButtonProps: {
2347
- ...dragButtonProps,
2348
- isDisabled: isDisabled,
2349
- "aria-label": dragButtonLabel
2350
- }
2351
- };
2352
- }
2353
-
2354
-
2355
- /*
2356
- * Copyright 2022 Adobe. All rights reserved.
2357
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
2358
- * you may not use this file except in compliance with the License. You may obtain a copy
2359
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
2360
- *
2361
- * Unless required by applicable law or agreed to in writing, software distributed under
2362
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
2363
- * OF ANY KIND, either express or implied. See the License for the specific language
2364
- * governing permissions and limitations under the License.
2365
- */
2366
- function $c3e901bab7fcc6ff$export$2962a7984b2f0a80(props, state, ref) {
2367
- // Update global DnD state if this keys within this collection are dragged
2368
- let { draggingCollectionRef: draggingCollectionRef } = (0, $4620ae0dc40f0031$export$6ca6700462636d0b);
2369
- if (state.draggingKeys.size > 0 && (draggingCollectionRef === null || draggingCollectionRef === void 0 ? void 0 : draggingCollectionRef.current) !== ref.current) (0, $4620ae0dc40f0031$export$f2be18a910c0caa6)(ref);
2370
- }
2371
-
2372
-
2373
- /*
2374
- * Copyright 2020 Adobe. All rights reserved.
2375
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
2376
- * you may not use this file except in compliance with the License. You may obtain a copy
2377
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
2378
- *
2379
- * Unless required by applicable law or agreed to in writing, software distributed under
2380
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
2381
- * OF ANY KIND, either express or implied. See the License for the specific language
2382
- * governing permissions and limitations under the License.
2383
- */
2384
-
2385
-
2386
-
2387
- const $74f3dedaa4d234b4$var$globalEvents = new Map();
2388
- function $74f3dedaa4d234b4$var$addGlobalEventListener(event, fn) {
2389
- let eventData = $74f3dedaa4d234b4$var$globalEvents.get(event);
2390
- if (!eventData) {
2391
- let handlers = new Set();
2392
- let listener = (e)=>{
2393
- for (let handler of handlers)handler(e);
2394
- };
2395
- eventData = {
2396
- listener: listener,
2397
- handlers: handlers
2398
- };
2399
- $74f3dedaa4d234b4$var$globalEvents.set(event, eventData);
2400
- document.addEventListener(event, listener);
2401
- }
2402
- eventData.handlers.add(fn);
2403
- return ()=>{
2404
- eventData.handlers.delete(fn);
2405
- if (eventData.handlers.size === 0) {
2406
- document.removeEventListener(event, eventData.listener);
2407
- $74f3dedaa4d234b4$var$globalEvents.delete(event);
2408
- }
2409
- };
2410
- }
2411
- function $74f3dedaa4d234b4$export$2314ca2a3e892862(options) {
2412
- let { isDisabled: isDisabled } = options;
2413
- let isFocusedRef = (0, $4vY0V$react.useRef)(false);
2414
- let { focusProps: focusProps } = (0, $4vY0V$reactariainteractions.useFocus)({
2415
- onFocusChange: (isFocused)=>{
2416
- isFocusedRef.current = isFocused;
2417
- }
2418
- });
2419
- let onBeforeCopy = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
2420
- // Enable the "Copy" menu item in Safari if this element is focused and copying is supported.
2421
- if (isFocusedRef.current && options.getItems) e.preventDefault();
2422
- });
2423
- let onCopy = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
2424
- var _options_onCopy;
2425
- if (!isFocusedRef.current || !options.getItems) return;
2426
- e.preventDefault();
2427
- (0, $4620ae0dc40f0031$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
2428
- (_options_onCopy = options.onCopy) === null || _options_onCopy === void 0 ? void 0 : _options_onCopy.call(options);
2429
- });
2430
- let onBeforeCut = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
2431
- if (isFocusedRef.current && options.onCut && options.getItems) e.preventDefault();
2432
- });
2433
- let onCut = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
2434
- if (!isFocusedRef.current || !options.onCut || !options.getItems) return;
2435
- e.preventDefault();
2436
- (0, $4620ae0dc40f0031$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
2437
- options.onCut();
2438
- });
2439
- let onBeforePaste = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
2440
- // Unfortunately, e.clipboardData.types is not available in this event so we always
2441
- // have to enable the Paste menu item even if the type of data is unsupported.
2442
- if (isFocusedRef.current && options.onPaste) e.preventDefault();
2443
- });
2444
- let onPaste = (0, $4vY0V$reactariautils.useEffectEvent)((e)=>{
2445
- if (!isFocusedRef.current || !options.onPaste) return;
2446
- e.preventDefault();
2447
- let items = (0, $4620ae0dc40f0031$export$d9e760437831f8b3)(e.clipboardData);
2448
- options.onPaste(items);
2449
- });
2450
- (0, $4vY0V$react.useEffect)(()=>{
2451
- if (isDisabled) return;
2452
- return (0, $4vY0V$reactariautils.chain)($74f3dedaa4d234b4$var$addGlobalEventListener("beforecopy", onBeforeCopy), $74f3dedaa4d234b4$var$addGlobalEventListener("copy", onCopy), $74f3dedaa4d234b4$var$addGlobalEventListener("beforecut", onBeforeCut), $74f3dedaa4d234b4$var$addGlobalEventListener("cut", onCut), $74f3dedaa4d234b4$var$addGlobalEventListener("beforepaste", onBeforePaste), $74f3dedaa4d234b4$var$addGlobalEventListener("paste", onPaste));
2453
- }, [
2454
- isDisabled,
2455
- onBeforeCopy,
2456
- onCopy,
2457
- onBeforeCut,
2458
- onCut,
2459
- onBeforePaste,
2460
- onPaste
2461
- ]);
2462
- return {
2463
- clipboardProps: focusProps
2464
- };
2465
- }
2466
-
2467
-
2468
- /*
2469
- * Copyright 2020 Adobe. All rights reserved.
2470
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
2471
- * you may not use this file except in compliance with the License. You may obtain a copy
2472
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
2473
- *
2474
- * Unless required by applicable law or agreed to in writing, software distributed under
2475
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
2476
- * OF ANY KIND, either express or implied. See the License for the specific language
2477
- * governing permissions and limitations under the License.
2478
- */
2479
-
2480
- function $2dccaca1f4baa446$var$DragPreview(props, ref) {
2481
- let render = props.children;
2482
- let [children, setChildren] = (0, $4vY0V$react.useState)(null);
2483
- let domRef = (0, $4vY0V$react.useRef)(null);
2484
- (0, $4vY0V$react.useImperativeHandle)(ref, ()=>(items, callback)=>{
2485
- // This will be called during the onDragStart event by useDrag. We need to render the
2486
- // preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.
2487
- (0, $4vY0V$reactdom.flushSync)(()=>{
2488
- setChildren(render(items));
2489
- });
2490
- // Yield back to useDrag to set the drag image.
2491
- callback(domRef.current);
2492
- // Remove the preview from the DOM after a frame so the browser has time to paint.
2493
- requestAnimationFrame(()=>{
2494
- setChildren(null);
2495
- });
2496
- }, [
2497
- render
2498
- ]);
2499
- if (!children) return null;
2500
- return /*#__PURE__*/ (0, ($parcel$interopDefault($4vY0V$react))).createElement("div", {
2501
- style: {
2502
- zIndex: -100,
2503
- position: "absolute",
2504
- top: 0,
2505
- left: -100000
2506
- },
2507
- ref: domRef
2508
- }, children);
2509
- }
2510
- let $2dccaca1f4baa446$export$905ab40ac2179daa = /*#__PURE__*/ (0, ($parcel$interopDefault($4vY0V$react))).forwardRef($2dccaca1f4baa446$var$DragPreview);
2511
-
2512
-
2513
- class $2268795bbb597ecb$export$fbd65d14c79e28cc {
2514
- getPrimaryStart(rect) {
2515
- return this.orientation === "horizontal" ? rect.left : rect.top;
2516
- }
2517
- getPrimaryEnd(rect) {
2518
- return this.orientation === "horizontal" ? rect.right : rect.bottom;
2519
- }
2520
- getSecondaryStart(rect) {
2521
- return this.orientation === "horizontal" ? rect.top : rect.left;
2522
- }
2523
- getSecondaryEnd(rect) {
2524
- return this.orientation === "horizontal" ? rect.bottom : rect.right;
2525
- }
2526
- getFlowStart(rect) {
2527
- return this.layout === "stack" ? this.getPrimaryStart(rect) : this.getSecondaryStart(rect);
2528
- }
2529
- getFlowEnd(rect) {
2530
- return this.layout === "stack" ? this.getPrimaryEnd(rect) : this.getSecondaryEnd(rect);
2531
- }
2532
- getFlowSize(rect) {
2533
- return this.getFlowEnd(rect) - this.getFlowStart(rect);
2534
- }
2535
- getDropTargetFromPoint(x, y, isValidDropTarget) {
2536
- if (this.collection.size === 0) return {
2537
- type: "root"
2538
- };
2539
- let rect = this.ref.current.getBoundingClientRect();
2540
- let primary = this.orientation === "horizontal" ? x : y;
2541
- let secondary = this.orientation === "horizontal" ? y : x;
2542
- primary += this.getPrimaryStart(rect);
2543
- secondary += this.getSecondaryStart(rect);
2544
- let flow = this.layout === "stack" ? primary : secondary;
2545
- let isPrimaryRTL = this.orientation === "horizontal" && this.direction === "rtl";
2546
- let isSecondaryRTL = this.layout === "grid" && this.orientation === "vertical" && this.direction === "rtl";
2547
- let isFlowRTL = this.layout === "stack" ? isPrimaryRTL : isSecondaryRTL;
2548
- let elements = this.ref.current.querySelectorAll("[data-key]");
2549
- let elementMap = new Map();
2550
- for (let item of elements)if (item instanceof HTMLElement) elementMap.set(item.dataset.key, item);
2551
- let items = [
2552
- ...this.collection
2553
- ];
2554
- let low = 0;
2555
- let high = items.length;
2556
- while(low < high){
2557
- let mid = Math.floor((low + high) / 2);
2558
- let item = items[mid];
2559
- let element = elementMap.get(String(item.key));
2560
- let rect = element.getBoundingClientRect();
2561
- let update = (isGreater)=>{
2562
- if (isGreater) low = mid + 1;
2563
- else high = mid;
2564
- };
2565
- if (primary < this.getPrimaryStart(rect)) update(isPrimaryRTL);
2566
- else if (primary > this.getPrimaryEnd(rect)) update(!isPrimaryRTL);
2567
- else if (secondary < this.getSecondaryStart(rect)) update(isSecondaryRTL);
2568
- else if (secondary > this.getSecondaryEnd(rect)) update(!isSecondaryRTL);
2569
- else {
2570
- let target = {
2571
- type: "item",
2572
- key: item.key,
2573
- dropPosition: "on"
2574
- };
2575
- if (isValidDropTarget(target)) {
2576
- // Otherwise, if dropping on the item is accepted, try the before/after positions if within 5px
2577
- // of the start or end of the item.
2578
- if (flow <= this.getFlowStart(rect) + 5 && isValidDropTarget({
2579
- ...target,
2580
- dropPosition: "before"
2581
- })) target.dropPosition = isFlowRTL ? "after" : "before";
2582
- else if (flow >= this.getFlowEnd(rect) - 5 && isValidDropTarget({
2583
- ...target,
2584
- dropPosition: "after"
2585
- })) target.dropPosition = isFlowRTL ? "before" : "after";
2586
- } else {
2587
- // If dropping on the item isn't accepted, try the target before or after depending on the position.
2588
- let mid = this.getFlowStart(rect) + this.getFlowSize(rect) / 2;
2589
- if (flow <= mid && isValidDropTarget({
2590
- ...target,
2591
- dropPosition: "before"
2592
- })) target.dropPosition = isFlowRTL ? "after" : "before";
2593
- else if (flow >= mid && isValidDropTarget({
2594
- ...target,
2595
- dropPosition: "after"
2596
- })) target.dropPosition = isFlowRTL ? "before" : "after";
2597
- }
2598
- return target;
2599
- }
2600
- }
2601
- let item = items[Math.min(low, items.length - 1)];
2602
- let element = elementMap.get(String(item.key));
2603
- rect = element.getBoundingClientRect();
2604
- if (primary < this.getPrimaryStart(rect) || Math.abs(flow - this.getFlowStart(rect)) < Math.abs(flow - this.getFlowEnd(rect))) return {
2605
- type: "item",
2606
- key: item.key,
2607
- dropPosition: isFlowRTL ? "after" : "before"
2608
- };
2609
- return {
2610
- type: "item",
2611
- key: item.key,
2612
- dropPosition: isFlowRTL ? "before" : "after"
2613
- };
2614
- }
2615
- constructor(collection, ref, options){
2616
- this.collection = collection;
2617
- this.ref = ref;
2618
- this.layout = (options === null || options === void 0 ? void 0 : options.layout) || "stack";
2619
- this.orientation = (options === null || options === void 0 ? void 0 : options.orientation) || "vertical";
2620
- this.direction = (options === null || options === void 0 ? void 0 : options.direction) || "ltr";
2621
- }
2622
- }
2623
53
 
2624
54
 
2625
55