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

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