@react-aria/dnd 3.11.5 → 3.12.0

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 (281) hide show
  1. package/dist/import.mjs +8 -18
  2. package/dist/main.js +22 -32
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +8 -18
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +13 -0
  7. package/package.json +16 -21
  8. package/src/index.ts +13 -56
  9. package/dist/DragManager.main.js +0 -519
  10. package/dist/DragManager.main.js.map +0 -1
  11. package/dist/DragManager.mjs +0 -510
  12. package/dist/DragManager.module.js +0 -510
  13. package/dist/DragManager.module.js.map +0 -1
  14. package/dist/DragPreview.main.js +0 -73
  15. package/dist/DragPreview.main.js.map +0 -1
  16. package/dist/DragPreview.mjs +0 -64
  17. package/dist/DragPreview.module.js +0 -64
  18. package/dist/DragPreview.module.js.map +0 -1
  19. package/dist/DropTargetKeyboardNavigation.main.js +0 -205
  20. package/dist/DropTargetKeyboardNavigation.main.js.map +0 -1
  21. package/dist/DropTargetKeyboardNavigation.mjs +0 -200
  22. package/dist/DropTargetKeyboardNavigation.module.js +0 -200
  23. package/dist/DropTargetKeyboardNavigation.module.js.map +0 -1
  24. package/dist/ListDropTargetDelegate.main.js +0 -129
  25. package/dist/ListDropTargetDelegate.main.js.map +0 -1
  26. package/dist/ListDropTargetDelegate.mjs +0 -124
  27. package/dist/ListDropTargetDelegate.module.js +0 -124
  28. package/dist/ListDropTargetDelegate.module.js.map +0 -1
  29. package/dist/ar-AE.main.js +0 -44
  30. package/dist/ar-AE.main.js.map +0 -1
  31. package/dist/ar-AE.mjs +0 -46
  32. package/dist/ar-AE.module.js +0 -46
  33. package/dist/ar-AE.module.js.map +0 -1
  34. package/dist/bg-BG.main.js +0 -44
  35. package/dist/bg-BG.main.js.map +0 -1
  36. package/dist/bg-BG.mjs +0 -46
  37. package/dist/bg-BG.module.js +0 -46
  38. package/dist/bg-BG.module.js.map +0 -1
  39. package/dist/constants.main.js +0 -64
  40. package/dist/constants.main.js.map +0 -1
  41. package/dist/constants.mjs +0 -52
  42. package/dist/constants.module.js +0 -52
  43. package/dist/constants.module.js.map +0 -1
  44. package/dist/cs-CZ.main.js +0 -45
  45. package/dist/cs-CZ.main.js.map +0 -1
  46. package/dist/cs-CZ.mjs +0 -47
  47. package/dist/cs-CZ.module.js +0 -47
  48. package/dist/cs-CZ.module.js.map +0 -1
  49. package/dist/da-DK.main.js +0 -44
  50. package/dist/da-DK.main.js.map +0 -1
  51. package/dist/da-DK.mjs +0 -46
  52. package/dist/da-DK.module.js +0 -46
  53. package/dist/da-DK.module.js.map +0 -1
  54. package/dist/de-DE.main.js +0 -44
  55. package/dist/de-DE.main.js.map +0 -1
  56. package/dist/de-DE.mjs +0 -46
  57. package/dist/de-DE.module.js +0 -46
  58. package/dist/de-DE.module.js.map +0 -1
  59. package/dist/el-GR.main.js +0 -44
  60. package/dist/el-GR.main.js.map +0 -1
  61. package/dist/el-GR.mjs +0 -46
  62. package/dist/el-GR.module.js +0 -46
  63. package/dist/el-GR.module.js.map +0 -1
  64. package/dist/en-US.main.js +0 -44
  65. package/dist/en-US.main.js.map +0 -1
  66. package/dist/en-US.mjs +0 -46
  67. package/dist/en-US.module.js +0 -46
  68. package/dist/en-US.module.js.map +0 -1
  69. package/dist/es-ES.main.js +0 -44
  70. package/dist/es-ES.main.js.map +0 -1
  71. package/dist/es-ES.mjs +0 -46
  72. package/dist/es-ES.module.js +0 -46
  73. package/dist/es-ES.module.js.map +0 -1
  74. package/dist/et-EE.main.js +0 -44
  75. package/dist/et-EE.main.js.map +0 -1
  76. package/dist/et-EE.mjs +0 -46
  77. package/dist/et-EE.module.js +0 -46
  78. package/dist/et-EE.module.js.map +0 -1
  79. package/dist/fi-FI.main.js +0 -44
  80. package/dist/fi-FI.main.js.map +0 -1
  81. package/dist/fi-FI.mjs +0 -46
  82. package/dist/fi-FI.module.js +0 -46
  83. package/dist/fi-FI.module.js.map +0 -1
  84. package/dist/fr-FR.main.js +0 -44
  85. package/dist/fr-FR.main.js.map +0 -1
  86. package/dist/fr-FR.mjs +0 -46
  87. package/dist/fr-FR.module.js +0 -46
  88. package/dist/fr-FR.module.js.map +0 -1
  89. package/dist/he-IL.main.js +0 -44
  90. package/dist/he-IL.main.js.map +0 -1
  91. package/dist/he-IL.mjs +0 -46
  92. package/dist/he-IL.module.js +0 -46
  93. package/dist/he-IL.module.js.map +0 -1
  94. package/dist/hr-HR.main.js +0 -44
  95. package/dist/hr-HR.main.js.map +0 -1
  96. package/dist/hr-HR.mjs +0 -46
  97. package/dist/hr-HR.module.js +0 -46
  98. package/dist/hr-HR.module.js.map +0 -1
  99. package/dist/hu-HU.main.js +0 -44
  100. package/dist/hu-HU.main.js.map +0 -1
  101. package/dist/hu-HU.mjs +0 -46
  102. package/dist/hu-HU.module.js +0 -46
  103. package/dist/hu-HU.module.js.map +0 -1
  104. package/dist/intlStrings.main.js +0 -108
  105. package/dist/intlStrings.main.js.map +0 -1
  106. package/dist/intlStrings.mjs +0 -110
  107. package/dist/intlStrings.module.js +0 -110
  108. package/dist/intlStrings.module.js.map +0 -1
  109. package/dist/it-IT.main.js +0 -44
  110. package/dist/it-IT.main.js.map +0 -1
  111. package/dist/it-IT.mjs +0 -46
  112. package/dist/it-IT.module.js +0 -46
  113. package/dist/it-IT.module.js.map +0 -1
  114. package/dist/ja-JP.main.js +0 -44
  115. package/dist/ja-JP.main.js.map +0 -1
  116. package/dist/ja-JP.mjs +0 -46
  117. package/dist/ja-JP.module.js +0 -46
  118. package/dist/ja-JP.module.js.map +0 -1
  119. package/dist/ko-KR.main.js +0 -44
  120. package/dist/ko-KR.main.js.map +0 -1
  121. package/dist/ko-KR.mjs +0 -46
  122. package/dist/ko-KR.module.js +0 -46
  123. package/dist/ko-KR.module.js.map +0 -1
  124. package/dist/lt-LT.main.js +0 -44
  125. package/dist/lt-LT.main.js.map +0 -1
  126. package/dist/lt-LT.mjs +0 -46
  127. package/dist/lt-LT.module.js +0 -46
  128. package/dist/lt-LT.module.js.map +0 -1
  129. package/dist/lv-LV.main.js +0 -44
  130. package/dist/lv-LV.main.js.map +0 -1
  131. package/dist/lv-LV.mjs +0 -46
  132. package/dist/lv-LV.module.js +0 -46
  133. package/dist/lv-LV.module.js.map +0 -1
  134. package/dist/nb-NO.main.js +0 -44
  135. package/dist/nb-NO.main.js.map +0 -1
  136. package/dist/nb-NO.mjs +0 -46
  137. package/dist/nb-NO.module.js +0 -46
  138. package/dist/nb-NO.module.js.map +0 -1
  139. package/dist/nl-NL.main.js +0 -44
  140. package/dist/nl-NL.main.js.map +0 -1
  141. package/dist/nl-NL.mjs +0 -46
  142. package/dist/nl-NL.module.js +0 -46
  143. package/dist/nl-NL.module.js.map +0 -1
  144. package/dist/pl-PL.main.js +0 -44
  145. package/dist/pl-PL.main.js.map +0 -1
  146. package/dist/pl-PL.mjs +0 -46
  147. package/dist/pl-PL.module.js +0 -46
  148. package/dist/pl-PL.module.js.map +0 -1
  149. package/dist/pt-BR.main.js +0 -44
  150. package/dist/pt-BR.main.js.map +0 -1
  151. package/dist/pt-BR.mjs +0 -46
  152. package/dist/pt-BR.module.js +0 -46
  153. package/dist/pt-BR.module.js.map +0 -1
  154. package/dist/pt-PT.main.js +0 -44
  155. package/dist/pt-PT.main.js.map +0 -1
  156. package/dist/pt-PT.mjs +0 -46
  157. package/dist/pt-PT.module.js +0 -46
  158. package/dist/pt-PT.module.js.map +0 -1
  159. package/dist/ro-RO.main.js +0 -44
  160. package/dist/ro-RO.main.js.map +0 -1
  161. package/dist/ro-RO.mjs +0 -46
  162. package/dist/ro-RO.module.js +0 -46
  163. package/dist/ro-RO.module.js.map +0 -1
  164. package/dist/ru-RU.main.js +0 -44
  165. package/dist/ru-RU.main.js.map +0 -1
  166. package/dist/ru-RU.mjs +0 -46
  167. package/dist/ru-RU.module.js +0 -46
  168. package/dist/ru-RU.module.js.map +0 -1
  169. package/dist/sk-SK.main.js +0 -44
  170. package/dist/sk-SK.main.js.map +0 -1
  171. package/dist/sk-SK.mjs +0 -46
  172. package/dist/sk-SK.module.js +0 -46
  173. package/dist/sk-SK.module.js.map +0 -1
  174. package/dist/sl-SI.main.js +0 -44
  175. package/dist/sl-SI.main.js.map +0 -1
  176. package/dist/sl-SI.mjs +0 -46
  177. package/dist/sl-SI.module.js +0 -46
  178. package/dist/sl-SI.module.js.map +0 -1
  179. package/dist/sr-SP.main.js +0 -44
  180. package/dist/sr-SP.main.js.map +0 -1
  181. package/dist/sr-SP.mjs +0 -46
  182. package/dist/sr-SP.module.js +0 -46
  183. package/dist/sr-SP.module.js.map +0 -1
  184. package/dist/sv-SE.main.js +0 -44
  185. package/dist/sv-SE.main.js.map +0 -1
  186. package/dist/sv-SE.mjs +0 -46
  187. package/dist/sv-SE.module.js +0 -46
  188. package/dist/sv-SE.module.js.map +0 -1
  189. package/dist/tr-TR.main.js +0 -44
  190. package/dist/tr-TR.main.js.map +0 -1
  191. package/dist/tr-TR.mjs +0 -46
  192. package/dist/tr-TR.module.js +0 -46
  193. package/dist/tr-TR.module.js.map +0 -1
  194. package/dist/types.d.ts +0 -244
  195. package/dist/types.d.ts.map +0 -1
  196. package/dist/uk-UA.main.js +0 -44
  197. package/dist/uk-UA.main.js.map +0 -1
  198. package/dist/uk-UA.mjs +0 -46
  199. package/dist/uk-UA.module.js +0 -46
  200. package/dist/uk-UA.module.js.map +0 -1
  201. package/dist/useAutoScroll.main.js +0 -89
  202. package/dist/useAutoScroll.main.js.map +0 -1
  203. package/dist/useAutoScroll.mjs +0 -84
  204. package/dist/useAutoScroll.module.js +0 -84
  205. package/dist/useAutoScroll.module.js.map +0 -1
  206. package/dist/useClipboard.main.js +0 -111
  207. package/dist/useClipboard.main.js.map +0 -1
  208. package/dist/useClipboard.mjs +0 -106
  209. package/dist/useClipboard.module.js +0 -106
  210. package/dist/useClipboard.module.js.map +0 -1
  211. package/dist/useDrag.main.js +0 -307
  212. package/dist/useDrag.main.js.map +0 -1
  213. package/dist/useDrag.mjs +0 -302
  214. package/dist/useDrag.module.js +0 -302
  215. package/dist/useDrag.module.js.map +0 -1
  216. package/dist/useDraggableCollection.main.js +0 -27
  217. package/dist/useDraggableCollection.main.js.map +0 -1
  218. package/dist/useDraggableCollection.mjs +0 -22
  219. package/dist/useDraggableCollection.module.js +0 -22
  220. package/dist/useDraggableCollection.module.js.map +0 -1
  221. package/dist/useDraggableItem.main.js +0 -128
  222. package/dist/useDraggableItem.main.js.map +0 -1
  223. package/dist/useDraggableItem.mjs +0 -123
  224. package/dist/useDraggableItem.module.js +0 -123
  225. package/dist/useDraggableItem.module.js.map +0 -1
  226. package/dist/useDrop.main.js +0 -295
  227. package/dist/useDrop.main.js.map +0 -1
  228. package/dist/useDrop.mjs +0 -290
  229. package/dist/useDrop.module.js +0 -290
  230. package/dist/useDrop.module.js.map +0 -1
  231. package/dist/useDropIndicator.main.js +0 -102
  232. package/dist/useDropIndicator.main.js.map +0 -1
  233. package/dist/useDropIndicator.mjs +0 -97
  234. package/dist/useDropIndicator.module.js +0 -97
  235. package/dist/useDropIndicator.module.js.map +0 -1
  236. package/dist/useDroppableCollection.main.js +0 -536
  237. package/dist/useDroppableCollection.main.js.map +0 -1
  238. package/dist/useDroppableCollection.mjs +0 -531
  239. package/dist/useDroppableCollection.module.js +0 -531
  240. package/dist/useDroppableCollection.module.js.map +0 -1
  241. package/dist/useDroppableItem.main.js +0 -81
  242. package/dist/useDroppableItem.main.js.map +0 -1
  243. package/dist/useDroppableItem.mjs +0 -76
  244. package/dist/useDroppableItem.module.js +0 -76
  245. package/dist/useDroppableItem.module.js.map +0 -1
  246. package/dist/useVirtualDrop.main.js +0 -56
  247. package/dist/useVirtualDrop.main.js.map +0 -1
  248. package/dist/useVirtualDrop.mjs +0 -51
  249. package/dist/useVirtualDrop.module.js +0 -51
  250. package/dist/useVirtualDrop.module.js.map +0 -1
  251. package/dist/utils.main.js +0 -285
  252. package/dist/utils.main.js.map +0 -1
  253. package/dist/utils.mjs +0 -257
  254. package/dist/utils.module.js +0 -257
  255. package/dist/utils.module.js.map +0 -1
  256. package/dist/zh-CN.main.js +0 -44
  257. package/dist/zh-CN.main.js.map +0 -1
  258. package/dist/zh-CN.mjs +0 -46
  259. package/dist/zh-CN.module.js +0 -46
  260. package/dist/zh-CN.module.js.map +0 -1
  261. package/dist/zh-TW.main.js +0 -44
  262. package/dist/zh-TW.main.js.map +0 -1
  263. package/dist/zh-TW.mjs +0 -46
  264. package/dist/zh-TW.module.js +0 -46
  265. package/dist/zh-TW.module.js.map +0 -1
  266. package/src/DragManager.ts +0 -656
  267. package/src/DragPreview.tsx +0 -81
  268. package/src/DropTargetKeyboardNavigation.ts +0 -282
  269. package/src/ListDropTargetDelegate.ts +0 -182
  270. package/src/constants.ts +0 -85
  271. package/src/useAutoScroll.ts +0 -105
  272. package/src/useClipboard.ts +0 -151
  273. package/src/useDrag.ts +0 -390
  274. package/src/useDraggableCollection.ts +0 -29
  275. package/src/useDraggableItem.ts +0 -158
  276. package/src/useDrop.ts +0 -444
  277. package/src/useDropIndicator.ts +0 -124
  278. package/src/useDroppableCollection.ts +0 -665
  279. package/src/useDroppableItem.ts +0 -86
  280. package/src/useVirtualDrop.ts +0 -49
  281. package/src/utils.ts +0 -385
package/dist/useDrag.mjs DELETED
@@ -1,302 +0,0 @@
1
- import {beginDragging as $67560de7c78cb232$export$549dbcf8649bf3b2} from "./DragManager.mjs";
2
- import {DROP_EFFECT_TO_DROP_OPERATION as $103790afe9474d1c$export$608ecc6f1b23c35d, DROP_OPERATION as $103790afe9474d1c$export$60b7b4bcf3903d8e, EFFECT_ALLOWED as $103790afe9474d1c$export$dd0165308d8bff45} from "./constants.mjs";
3
- import {globalDropEffect as $7252cd45fc48c07c$export$8e6636520ac15722, setGlobalAllowedDropOperations as $7252cd45fc48c07c$export$6539bc8c3a0a2d67, setGlobalDropEffect as $7252cd45fc48c07c$export$64f52ed7349ddb84, useDragModality as $7252cd45fc48c07c$export$49bac5d6d4b352ea, writeToDataTransfer as $7252cd45fc48c07c$export$f9c1490890ddd063} from "./utils.mjs";
4
- import $72Evg$intlStringsmodulejs from "./intlStrings.mjs";
5
- import {useRef as $72Evg$useRef, useState as $72Evg$useState, useEffect as $72Evg$useEffect, version as $72Evg$version} from "react";
6
- import {useGlobalListeners as $72Evg$useGlobalListeners, useDescription as $72Evg$useDescription, isVirtualPointerEvent as $72Evg$isVirtualPointerEvent, isVirtualClick as $72Evg$isVirtualClick} from "@react-aria/utils";
7
- import {useLocalizedStringFormatter as $72Evg$useLocalizedStringFormatter} from "@react-aria/i18n";
8
-
9
-
10
- function $parcel$interopDefault(a) {
11
- return a && a.__esModule ? a.default : a;
12
- }
13
- /*
14
- * Copyright 2020 Adobe. All rights reserved.
15
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
- * you may not use this file except in compliance with the License. You may obtain a copy
17
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software distributed under
20
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
- * OF ANY KIND, either express or implied. See the License for the specific language
22
- * governing permissions and limitations under the License.
23
- */
24
-
25
-
26
-
27
-
28
-
29
-
30
- const $8253ed7ece74b463$var$MESSAGES = {
31
- keyboard: {
32
- start: 'dragDescriptionKeyboard',
33
- end: 'endDragKeyboard'
34
- },
35
- touch: {
36
- start: 'dragDescriptionTouch',
37
- end: 'endDragTouch'
38
- },
39
- virtual: {
40
- start: 'dragDescriptionVirtual',
41
- end: 'endDragVirtual'
42
- }
43
- };
44
- function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
45
- let { hasDragButton: hasDragButton, isDisabled: isDisabled } = options;
46
- let stringFormatter = (0, $72Evg$useLocalizedStringFormatter)((0, ($parcel$interopDefault($72Evg$intlStringsmodulejs))), '@react-aria/dnd');
47
- let state = (0, $72Evg$useRef)({
48
- options: options,
49
- x: 0,
50
- y: 0
51
- }).current;
52
- state.options = options;
53
- let isDraggingRef = (0, $72Evg$useRef)(null);
54
- let [isDragging, setDraggingState] = (0, $72Evg$useState)(false);
55
- let setDragging = (element)=>{
56
- isDraggingRef.current = element;
57
- setDraggingState(!!element);
58
- };
59
- let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $72Evg$useGlobalListeners)();
60
- let modalityOnPointerDown = (0, $72Evg$useRef)(null);
61
- let onDragStart = (e)=>{
62
- var // Clear existing data (e.g. selected text on the page would be included in some browsers)
63
- _e_dataTransfer_clearData, _e_dataTransfer, _options_preview;
64
- if (e.defaultPrevented) return;
65
- // Prevent the drag event from propagating to any parent draggables
66
- e.stopPropagation();
67
- // If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.
68
- if (modalityOnPointerDown.current === 'virtual') {
69
- e.preventDefault();
70
- startDragging(e.target);
71
- modalityOnPointerDown.current = null;
72
- return;
73
- }
74
- if (typeof options.onDragStart === 'function') options.onDragStart({
75
- type: 'dragstart',
76
- x: e.clientX,
77
- y: e.clientY
78
- });
79
- let items = options.getItems();
80
- (_e_dataTransfer_clearData = (_e_dataTransfer = e.dataTransfer).clearData) === null || _e_dataTransfer_clearData === void 0 ? void 0 : _e_dataTransfer_clearData.call(_e_dataTransfer);
81
- (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.dataTransfer, items);
82
- let allowed = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).all;
83
- if (typeof options.getAllowedDropOperations === 'function') {
84
- let allowedOperations = options.getAllowedDropOperations();
85
- allowed = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
86
- for (let operation of allowedOperations)allowed |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e)[operation] || (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
87
- }
88
- (0, $7252cd45fc48c07c$export$6539bc8c3a0a2d67)(allowed);
89
- let effectAllowed = (0, $103790afe9474d1c$export$dd0165308d8bff45)[allowed] || 'none';
90
- e.dataTransfer.effectAllowed = effectAllowed === 'cancel' ? 'none' : effectAllowed;
91
- // If there is a preview option, use it to render a custom preview image that will
92
- // appear under the pointer while dragging. If not, the element itself is dragged by the browser.
93
- if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === 'function') options.preview.current(items, (node, userX, userY)=>{
94
- if (!node) return;
95
- // Compute the offset that the preview will appear under the mouse.
96
- // If possible, this is based on the point the user clicked on the target.
97
- // If the preview is much smaller, then just use the center point of the preview.
98
- let size = node.getBoundingClientRect();
99
- let rect = e.currentTarget.getBoundingClientRect();
100
- let defaultX = e.clientX - rect.x;
101
- let defaultY = e.clientY - rect.y;
102
- if (defaultX > size.width || defaultY > size.height) {
103
- defaultX = size.width / 2;
104
- defaultY = size.height / 2;
105
- }
106
- // Start with default offsets.
107
- let offsetX = defaultX;
108
- let offsetY = defaultY;
109
- // If the preview renderer supplied explicit offsets, use those.
110
- if (typeof userX === 'number' && typeof userY === 'number') {
111
- offsetX = userX;
112
- offsetY = userY;
113
- }
114
- // Clamp the offset so it stays within the preview bounds. Browsers
115
- // automatically clamp out-of-range values, but doing it ourselves
116
- // prevents the visible "snap" that can occur when the browser adjusts
117
- // them after the first drag update.
118
- offsetX = Math.max(0, Math.min(offsetX, size.width));
119
- offsetY = Math.max(0, Math.min(offsetY, size.height));
120
- // Rounding height to an even number prevents blurry preview seen on some screens
121
- let height = 2 * Math.round(size.height / 2);
122
- node.style.height = `${height}px`;
123
- e.dataTransfer.setDragImage(node, offsetX, offsetY);
124
- });
125
- // Enforce that drops are handled by useDrop.
126
- addGlobalListener(window, 'drop', (e)=>{
127
- e.preventDefault();
128
- e.stopPropagation();
129
- 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.');
130
- }, {
131
- once: true
132
- });
133
- state.x = e.clientX;
134
- state.y = e.clientY;
135
- // Wait a frame before we set dragging to true so that the browser has time to
136
- // render the preview image before we update the element that has been dragged.
137
- let target = e.target;
138
- requestAnimationFrame(()=>{
139
- setDragging(target);
140
- });
141
- };
142
- let onDrag = (e)=>{
143
- // Prevent the drag event from propagating to any parent draggables
144
- e.stopPropagation();
145
- if (e.clientX === state.x && e.clientY === state.y) return;
146
- if (typeof options.onDragMove === 'function') options.onDragMove({
147
- type: 'dragmove',
148
- x: e.clientX,
149
- y: e.clientY
150
- });
151
- state.x = e.clientX;
152
- state.y = e.clientY;
153
- };
154
- let onDragEnd = (e)=>{
155
- // Prevent the drag event from propagating to any parent draggables
156
- e.stopPropagation();
157
- if (typeof options.onDragEnd === 'function') {
158
- let event = {
159
- type: 'dragend',
160
- x: e.clientX,
161
- y: e.clientY,
162
- dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[e.dataTransfer.dropEffect]
163
- };
164
- // Chrome Android always returns none as its dropEffect so we use the drop effect set in useDrop via
165
- // onDragEnter/onDragOver instead. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951
166
- if (0, $7252cd45fc48c07c$export$8e6636520ac15722) event.dropOperation = (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[0, $7252cd45fc48c07c$export$8e6636520ac15722];
167
- options.onDragEnd(event);
168
- }
169
- setDragging(null);
170
- removeAllGlobalListeners();
171
- (0, $7252cd45fc48c07c$export$6539bc8c3a0a2d67)((0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none);
172
- (0, $7252cd45fc48c07c$export$64f52ed7349ddb84)(undefined);
173
- };
174
- // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
175
- // In this case, we need to manually call onDragEnd on cleanup
176
- (0, $72Evg$useEffect)(()=>{
177
- return ()=>{
178
- // Check that the dragged element has actually unmounted from the DOM and not a React Strict Mode false positive.
179
- // https://github.com/facebook/react/issues/29585
180
- // React 16 ran effect cleanups before removing elements from the DOM but did not have this issue.
181
- if (isDraggingRef.current && (!isDraggingRef.current.isConnected || parseInt((0, $72Evg$version), 10) < 17)) {
182
- if (typeof state.options.onDragEnd === 'function') {
183
- let event = {
184
- type: 'dragend',
185
- x: 0,
186
- y: 0,
187
- dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[(0, $7252cd45fc48c07c$export$8e6636520ac15722) || 'none']
188
- };
189
- state.options.onDragEnd(event);
190
- }
191
- setDragging(null);
192
- (0, $7252cd45fc48c07c$export$6539bc8c3a0a2d67)((0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none);
193
- (0, $7252cd45fc48c07c$export$64f52ed7349ddb84)(undefined);
194
- }
195
- };
196
- }, [
197
- state
198
- ]);
199
- let onPress = (e)=>{
200
- if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') return;
201
- startDragging(e.target);
202
- };
203
- let startDragging = (target)=>{
204
- if (typeof state.options.onDragStart === 'function') {
205
- let rect = target.getBoundingClientRect();
206
- state.options.onDragStart({
207
- type: 'dragstart',
208
- x: rect.x + rect.width / 2,
209
- y: rect.y + rect.height / 2
210
- });
211
- }
212
- $67560de7c78cb232$export$549dbcf8649bf3b2({
213
- element: target,
214
- items: state.options.getItems(),
215
- allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function' ? state.options.getAllowedDropOperations() : [
216
- 'move',
217
- 'copy',
218
- 'link'
219
- ],
220
- onDragEnd (e) {
221
- setDragging(null);
222
- if (typeof state.options.onDragEnd === 'function') state.options.onDragEnd(e);
223
- }
224
- }, stringFormatter);
225
- setDragging(target);
226
- };
227
- let modality = (0, $7252cd45fc48c07c$export$49bac5d6d4b352ea)();
228
- let message = !isDragging ? $8253ed7ece74b463$var$MESSAGES[modality].start : $8253ed7ece74b463$var$MESSAGES[modality].end;
229
- let descriptionProps = (0, $72Evg$useDescription)(stringFormatter.format(message));
230
- let interactions = {};
231
- if (!hasDragButton) // If there's no separate button to trigger accessible drag and drop mode,
232
- // then add event handlers to the draggable element itself to start dragging.
233
- // For keyboard, we use the Enter key in a capturing listener to prevent other
234
- // events such as selection from also occurring. We attempt to infer whether a
235
- // pointer event (e.g. long press) came from a touch screen reader, and then initiate
236
- // dragging in the native onDragStart listener above.
237
- interactions = {
238
- ...descriptionProps,
239
- onPointerDown (e) {
240
- modalityOnPointerDown.current = (0, $72Evg$isVirtualPointerEvent)(e.nativeEvent) ? 'virtual' : e.pointerType;
241
- // Try to detect virtual drag passthrough gestures.
242
- if (e.width < 1 && e.height < 1) // iOS VoiceOver.
243
- modalityOnPointerDown.current = 'virtual';
244
- else {
245
- let rect = e.currentTarget.getBoundingClientRect();
246
- let offsetX = e.clientX - rect.x;
247
- let offsetY = e.clientY - rect.y;
248
- let centerX = rect.width / 2;
249
- let centerY = rect.height / 2;
250
- if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) // Android TalkBack.
251
- modalityOnPointerDown.current = 'virtual';
252
- else modalityOnPointerDown.current = e.pointerType;
253
- }
254
- },
255
- onKeyDownCapture (e) {
256
- if (e.target === e.currentTarget && e.key === 'Enter') {
257
- e.preventDefault();
258
- e.stopPropagation();
259
- }
260
- },
261
- onKeyUpCapture (e) {
262
- if (e.target === e.currentTarget && e.key === 'Enter') {
263
- e.preventDefault();
264
- e.stopPropagation();
265
- startDragging(e.target);
266
- }
267
- },
268
- onClick (e) {
269
- // Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.
270
- if ((0, $72Evg$isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {
271
- e.preventDefault();
272
- e.stopPropagation();
273
- startDragging(e.target);
274
- }
275
- }
276
- };
277
- if (isDisabled) return {
278
- dragProps: {
279
- draggable: 'false'
280
- },
281
- dragButtonProps: {},
282
- isDragging: false
283
- };
284
- return {
285
- dragProps: {
286
- ...interactions,
287
- draggable: 'true',
288
- onDragStart: onDragStart,
289
- onDrag: onDrag,
290
- onDragEnd: onDragEnd
291
- },
292
- dragButtonProps: {
293
- ...descriptionProps,
294
- onPress: onPress
295
- },
296
- isDragging: isDragging
297
- };
298
- }
299
-
300
-
301
- export {$8253ed7ece74b463$export$7941f8aafa4b6021 as useDrag};
302
- //# sourceMappingURL=useDrag.module.js.map
@@ -1,302 +0,0 @@
1
- import {beginDragging as $67560de7c78cb232$export$549dbcf8649bf3b2} from "./DragManager.module.js";
2
- import {DROP_EFFECT_TO_DROP_OPERATION as $103790afe9474d1c$export$608ecc6f1b23c35d, DROP_OPERATION as $103790afe9474d1c$export$60b7b4bcf3903d8e, EFFECT_ALLOWED as $103790afe9474d1c$export$dd0165308d8bff45} from "./constants.module.js";
3
- import {globalDropEffect as $7252cd45fc48c07c$export$8e6636520ac15722, setGlobalAllowedDropOperations as $7252cd45fc48c07c$export$6539bc8c3a0a2d67, setGlobalDropEffect as $7252cd45fc48c07c$export$64f52ed7349ddb84, useDragModality as $7252cd45fc48c07c$export$49bac5d6d4b352ea, writeToDataTransfer as $7252cd45fc48c07c$export$f9c1490890ddd063} from "./utils.module.js";
4
- import $72Evg$intlStringsmodulejs from "./intlStrings.module.js";
5
- import {useRef as $72Evg$useRef, useState as $72Evg$useState, useEffect as $72Evg$useEffect, version as $72Evg$version} from "react";
6
- import {useGlobalListeners as $72Evg$useGlobalListeners, useDescription as $72Evg$useDescription, isVirtualPointerEvent as $72Evg$isVirtualPointerEvent, isVirtualClick as $72Evg$isVirtualClick} from "@react-aria/utils";
7
- import {useLocalizedStringFormatter as $72Evg$useLocalizedStringFormatter} from "@react-aria/i18n";
8
-
9
-
10
- function $parcel$interopDefault(a) {
11
- return a && a.__esModule ? a.default : a;
12
- }
13
- /*
14
- * Copyright 2020 Adobe. All rights reserved.
15
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
- * you may not use this file except in compliance with the License. You may obtain a copy
17
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software distributed under
20
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
- * OF ANY KIND, either express or implied. See the License for the specific language
22
- * governing permissions and limitations under the License.
23
- */
24
-
25
-
26
-
27
-
28
-
29
-
30
- const $8253ed7ece74b463$var$MESSAGES = {
31
- keyboard: {
32
- start: 'dragDescriptionKeyboard',
33
- end: 'endDragKeyboard'
34
- },
35
- touch: {
36
- start: 'dragDescriptionTouch',
37
- end: 'endDragTouch'
38
- },
39
- virtual: {
40
- start: 'dragDescriptionVirtual',
41
- end: 'endDragVirtual'
42
- }
43
- };
44
- function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
45
- let { hasDragButton: hasDragButton, isDisabled: isDisabled } = options;
46
- let stringFormatter = (0, $72Evg$useLocalizedStringFormatter)((0, ($parcel$interopDefault($72Evg$intlStringsmodulejs))), '@react-aria/dnd');
47
- let state = (0, $72Evg$useRef)({
48
- options: options,
49
- x: 0,
50
- y: 0
51
- }).current;
52
- state.options = options;
53
- let isDraggingRef = (0, $72Evg$useRef)(null);
54
- let [isDragging, setDraggingState] = (0, $72Evg$useState)(false);
55
- let setDragging = (element)=>{
56
- isDraggingRef.current = element;
57
- setDraggingState(!!element);
58
- };
59
- let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $72Evg$useGlobalListeners)();
60
- let modalityOnPointerDown = (0, $72Evg$useRef)(null);
61
- let onDragStart = (e)=>{
62
- var // Clear existing data (e.g. selected text on the page would be included in some browsers)
63
- _e_dataTransfer_clearData, _e_dataTransfer, _options_preview;
64
- if (e.defaultPrevented) return;
65
- // Prevent the drag event from propagating to any parent draggables
66
- e.stopPropagation();
67
- // If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.
68
- if (modalityOnPointerDown.current === 'virtual') {
69
- e.preventDefault();
70
- startDragging(e.target);
71
- modalityOnPointerDown.current = null;
72
- return;
73
- }
74
- if (typeof options.onDragStart === 'function') options.onDragStart({
75
- type: 'dragstart',
76
- x: e.clientX,
77
- y: e.clientY
78
- });
79
- let items = options.getItems();
80
- (_e_dataTransfer_clearData = (_e_dataTransfer = e.dataTransfer).clearData) === null || _e_dataTransfer_clearData === void 0 ? void 0 : _e_dataTransfer_clearData.call(_e_dataTransfer);
81
- (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.dataTransfer, items);
82
- let allowed = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).all;
83
- if (typeof options.getAllowedDropOperations === 'function') {
84
- let allowedOperations = options.getAllowedDropOperations();
85
- allowed = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
86
- for (let operation of allowedOperations)allowed |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e)[operation] || (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
87
- }
88
- (0, $7252cd45fc48c07c$export$6539bc8c3a0a2d67)(allowed);
89
- let effectAllowed = (0, $103790afe9474d1c$export$dd0165308d8bff45)[allowed] || 'none';
90
- e.dataTransfer.effectAllowed = effectAllowed === 'cancel' ? 'none' : effectAllowed;
91
- // If there is a preview option, use it to render a custom preview image that will
92
- // appear under the pointer while dragging. If not, the element itself is dragged by the browser.
93
- if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === 'function') options.preview.current(items, (node, userX, userY)=>{
94
- if (!node) return;
95
- // Compute the offset that the preview will appear under the mouse.
96
- // If possible, this is based on the point the user clicked on the target.
97
- // If the preview is much smaller, then just use the center point of the preview.
98
- let size = node.getBoundingClientRect();
99
- let rect = e.currentTarget.getBoundingClientRect();
100
- let defaultX = e.clientX - rect.x;
101
- let defaultY = e.clientY - rect.y;
102
- if (defaultX > size.width || defaultY > size.height) {
103
- defaultX = size.width / 2;
104
- defaultY = size.height / 2;
105
- }
106
- // Start with default offsets.
107
- let offsetX = defaultX;
108
- let offsetY = defaultY;
109
- // If the preview renderer supplied explicit offsets, use those.
110
- if (typeof userX === 'number' && typeof userY === 'number') {
111
- offsetX = userX;
112
- offsetY = userY;
113
- }
114
- // Clamp the offset so it stays within the preview bounds. Browsers
115
- // automatically clamp out-of-range values, but doing it ourselves
116
- // prevents the visible "snap" that can occur when the browser adjusts
117
- // them after the first drag update.
118
- offsetX = Math.max(0, Math.min(offsetX, size.width));
119
- offsetY = Math.max(0, Math.min(offsetY, size.height));
120
- // Rounding height to an even number prevents blurry preview seen on some screens
121
- let height = 2 * Math.round(size.height / 2);
122
- node.style.height = `${height}px`;
123
- e.dataTransfer.setDragImage(node, offsetX, offsetY);
124
- });
125
- // Enforce that drops are handled by useDrop.
126
- addGlobalListener(window, 'drop', (e)=>{
127
- e.preventDefault();
128
- e.stopPropagation();
129
- 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.');
130
- }, {
131
- once: true
132
- });
133
- state.x = e.clientX;
134
- state.y = e.clientY;
135
- // Wait a frame before we set dragging to true so that the browser has time to
136
- // render the preview image before we update the element that has been dragged.
137
- let target = e.target;
138
- requestAnimationFrame(()=>{
139
- setDragging(target);
140
- });
141
- };
142
- let onDrag = (e)=>{
143
- // Prevent the drag event from propagating to any parent draggables
144
- e.stopPropagation();
145
- if (e.clientX === state.x && e.clientY === state.y) return;
146
- if (typeof options.onDragMove === 'function') options.onDragMove({
147
- type: 'dragmove',
148
- x: e.clientX,
149
- y: e.clientY
150
- });
151
- state.x = e.clientX;
152
- state.y = e.clientY;
153
- };
154
- let onDragEnd = (e)=>{
155
- // Prevent the drag event from propagating to any parent draggables
156
- e.stopPropagation();
157
- if (typeof options.onDragEnd === 'function') {
158
- let event = {
159
- type: 'dragend',
160
- x: e.clientX,
161
- y: e.clientY,
162
- dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[e.dataTransfer.dropEffect]
163
- };
164
- // Chrome Android always returns none as its dropEffect so we use the drop effect set in useDrop via
165
- // onDragEnter/onDragOver instead. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951
166
- if (0, $7252cd45fc48c07c$export$8e6636520ac15722) event.dropOperation = (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[0, $7252cd45fc48c07c$export$8e6636520ac15722];
167
- options.onDragEnd(event);
168
- }
169
- setDragging(null);
170
- removeAllGlobalListeners();
171
- (0, $7252cd45fc48c07c$export$6539bc8c3a0a2d67)((0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none);
172
- (0, $7252cd45fc48c07c$export$64f52ed7349ddb84)(undefined);
173
- };
174
- // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
175
- // In this case, we need to manually call onDragEnd on cleanup
176
- (0, $72Evg$useEffect)(()=>{
177
- return ()=>{
178
- // Check that the dragged element has actually unmounted from the DOM and not a React Strict Mode false positive.
179
- // https://github.com/facebook/react/issues/29585
180
- // React 16 ran effect cleanups before removing elements from the DOM but did not have this issue.
181
- if (isDraggingRef.current && (!isDraggingRef.current.isConnected || parseInt((0, $72Evg$version), 10) < 17)) {
182
- if (typeof state.options.onDragEnd === 'function') {
183
- let event = {
184
- type: 'dragend',
185
- x: 0,
186
- y: 0,
187
- dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[(0, $7252cd45fc48c07c$export$8e6636520ac15722) || 'none']
188
- };
189
- state.options.onDragEnd(event);
190
- }
191
- setDragging(null);
192
- (0, $7252cd45fc48c07c$export$6539bc8c3a0a2d67)((0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none);
193
- (0, $7252cd45fc48c07c$export$64f52ed7349ddb84)(undefined);
194
- }
195
- };
196
- }, [
197
- state
198
- ]);
199
- let onPress = (e)=>{
200
- if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') return;
201
- startDragging(e.target);
202
- };
203
- let startDragging = (target)=>{
204
- if (typeof state.options.onDragStart === 'function') {
205
- let rect = target.getBoundingClientRect();
206
- state.options.onDragStart({
207
- type: 'dragstart',
208
- x: rect.x + rect.width / 2,
209
- y: rect.y + rect.height / 2
210
- });
211
- }
212
- $67560de7c78cb232$export$549dbcf8649bf3b2({
213
- element: target,
214
- items: state.options.getItems(),
215
- allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function' ? state.options.getAllowedDropOperations() : [
216
- 'move',
217
- 'copy',
218
- 'link'
219
- ],
220
- onDragEnd (e) {
221
- setDragging(null);
222
- if (typeof state.options.onDragEnd === 'function') state.options.onDragEnd(e);
223
- }
224
- }, stringFormatter);
225
- setDragging(target);
226
- };
227
- let modality = (0, $7252cd45fc48c07c$export$49bac5d6d4b352ea)();
228
- let message = !isDragging ? $8253ed7ece74b463$var$MESSAGES[modality].start : $8253ed7ece74b463$var$MESSAGES[modality].end;
229
- let descriptionProps = (0, $72Evg$useDescription)(stringFormatter.format(message));
230
- let interactions = {};
231
- if (!hasDragButton) // If there's no separate button to trigger accessible drag and drop mode,
232
- // then add event handlers to the draggable element itself to start dragging.
233
- // For keyboard, we use the Enter key in a capturing listener to prevent other
234
- // events such as selection from also occurring. We attempt to infer whether a
235
- // pointer event (e.g. long press) came from a touch screen reader, and then initiate
236
- // dragging in the native onDragStart listener above.
237
- interactions = {
238
- ...descriptionProps,
239
- onPointerDown (e) {
240
- modalityOnPointerDown.current = (0, $72Evg$isVirtualPointerEvent)(e.nativeEvent) ? 'virtual' : e.pointerType;
241
- // Try to detect virtual drag passthrough gestures.
242
- if (e.width < 1 && e.height < 1) // iOS VoiceOver.
243
- modalityOnPointerDown.current = 'virtual';
244
- else {
245
- let rect = e.currentTarget.getBoundingClientRect();
246
- let offsetX = e.clientX - rect.x;
247
- let offsetY = e.clientY - rect.y;
248
- let centerX = rect.width / 2;
249
- let centerY = rect.height / 2;
250
- if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) // Android TalkBack.
251
- modalityOnPointerDown.current = 'virtual';
252
- else modalityOnPointerDown.current = e.pointerType;
253
- }
254
- },
255
- onKeyDownCapture (e) {
256
- if (e.target === e.currentTarget && e.key === 'Enter') {
257
- e.preventDefault();
258
- e.stopPropagation();
259
- }
260
- },
261
- onKeyUpCapture (e) {
262
- if (e.target === e.currentTarget && e.key === 'Enter') {
263
- e.preventDefault();
264
- e.stopPropagation();
265
- startDragging(e.target);
266
- }
267
- },
268
- onClick (e) {
269
- // Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.
270
- if ((0, $72Evg$isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {
271
- e.preventDefault();
272
- e.stopPropagation();
273
- startDragging(e.target);
274
- }
275
- }
276
- };
277
- if (isDisabled) return {
278
- dragProps: {
279
- draggable: 'false'
280
- },
281
- dragButtonProps: {},
282
- isDragging: false
283
- };
284
- return {
285
- dragProps: {
286
- ...interactions,
287
- draggable: 'true',
288
- onDragStart: onDragStart,
289
- onDrag: onDrag,
290
- onDragEnd: onDragEnd
291
- },
292
- dragButtonProps: {
293
- ...descriptionProps,
294
- onPress: onPress
295
- },
296
- isDragging: isDragging
297
- };
298
- }
299
-
300
-
301
- export {$8253ed7ece74b463$export$7941f8aafa4b6021 as useDrag};
302
- //# sourceMappingURL=useDrag.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AA8CD,MAAM,iCAAW;IACf,UAAU;QACR,OAAO;QACP,KAAK;IACP;IACA,OAAO;QACL,OAAO;QACP,KAAK;IACP;IACA,SAAS;QACP,OAAO;QACP,KAAK;IACP;AACF;AAMO,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;iBACjB;QACA,GAAG;QACH,GAAG;IACL,GAAG,OAAO;IACV,MAAM,OAAO,GAAG;IAChB,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAkB;IAC3C,IAAI,CAAC,YAAY,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAE;IAC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GAAA,qBAAa,EAAE,EAAE,WAAW,KAAK,sBAAsB,OAAO,KAAK,WAAW;gBAChF,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,cAAc,EAAE,MAAM;YACxB;QACF;IACF;IAGF,IAAI,YACF,OAAO;QACL,WAAW;YACT,WAAW;QACb;QACA,iBAAiB,CAAC;QAClB,YAAY;IACd;IAGF,OAAO;QACL,WAAW;YACT,GAAG,YAAY;YACf,WAAW;yBACX;oBACA;uBACA;QACF;QACA,iBAAiB;YACf,GAAG,gBAAgB;qBACnB;QACF;oBACA;IACF;AACF","sources":["packages/@react-aria/dnd/src/useDrag.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {DragEndEvent, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, PressEvent, RefObject} from '@react-types/shared';\nimport {DragEvent, HTMLAttributes, version as ReactVersion, useEffect, useRef, useState} from 'react';\nimport * as DragManager from './DragManager';\nimport {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, EFFECT_ALLOWED} from './constants';\nimport {globalDropEffect, setGlobalAllowedDropOperations, setGlobalDropEffect, useDragModality, writeToDataTransfer} from './utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {isVirtualClick, isVirtualPointerEvent, useDescription, useGlobalListeners} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface DragOptions {\n /** Handler that is called when a drag operation is started. */\n onDragStart?: (e: DragStartEvent) => void,\n /** Handler that is called when the drag is moved. */\n onDragMove?: (e: DragMoveEvent) => void,\n /** Handler that is called when the drag operation is ended, either as a result of a drop or a cancellation. */\n onDragEnd?: (e: DragEndEvent) => void,\n /** A function that returns the items being dragged. */\n getItems: () => DragItem[],\n /** The ref of the element that will be rendered as the drag preview while dragging. */\n preview?: RefObject<DragPreviewRenderer | null>,\n /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */\n getAllowedDropOperations?: () => DropOperation[],\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop mode.\n * If true, the dragProps will omit these event handlers, and they will be applied to dragButtonProps instead.\n */\n hasDragButton?: boolean,\n /**\n * Whether the drag operation is disabled. If true, the element will not be draggable.\n */\n isDisabled?: boolean\n}\n\nexport interface DragResult {\n /** Props for the draggable element. */\n dragProps: HTMLAttributes<HTMLElement>,\n /** Props for the explicit drag button affordance, if any. */\n dragButtonProps: AriaButtonProps,\n /** Whether the element is currently being dragged. */\n isDragging: boolean\n}\n\nconst MESSAGES = {\n keyboard: {\n start: 'dragDescriptionKeyboard',\n end: 'endDragKeyboard'\n },\n touch: {\n start: 'dragDescriptionTouch',\n end: 'endDragTouch'\n },\n virtual: {\n start: 'dragDescriptionVirtual',\n end: 'endDragVirtual'\n }\n};\n\n/**\n * Handles drag interactions for an element, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDrag(options: DragOptions): DragResult {\n let {hasDragButton, isDisabled} = options;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let state = useRef({\n options,\n x: 0,\n y: 0\n }).current;\n state.options = options;\n let isDraggingRef = useRef<Element | null>(null);\n let [isDragging, setDraggingState] = useState(false);\n let setDragging = (element: Element | null) => {\n isDraggingRef.current = element;\n setDraggingState(!!element);\n };\n let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();\n let modalityOnPointerDown = useRef<string>(null);\n\n let onDragStart = (e: DragEvent) => {\n if (e.defaultPrevented) {\n return;\n }\n\n // Prevent the drag event from propagating to any parent draggables\n e.stopPropagation();\n\n // If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.\n if (modalityOnPointerDown.current === 'virtual') {\n e.preventDefault();\n startDragging(e.target as HTMLElement);\n modalityOnPointerDown.current = null;\n return;\n }\n\n if (typeof options.onDragStart === 'function') {\n options.onDragStart({\n type: 'dragstart',\n x: e.clientX,\n y: e.clientY\n });\n }\n\n let items = options.getItems();\n // Clear existing data (e.g. selected text on the page would be included in some browsers)\n e.dataTransfer.clearData?.();\n writeToDataTransfer(e.dataTransfer, items);\n\n let allowed = DROP_OPERATION.all;\n if (typeof options.getAllowedDropOperations === 'function') {\n let allowedOperations = options.getAllowedDropOperations();\n allowed = DROP_OPERATION.none;\n for (let operation of allowedOperations) {\n allowed |= DROP_OPERATION[operation] || DROP_OPERATION.none;\n }\n }\n\n setGlobalAllowedDropOperations(allowed);\n let effectAllowed = EFFECT_ALLOWED[allowed] || 'none';\n e.dataTransfer.effectAllowed = effectAllowed === 'cancel' ? 'none' : effectAllowed;\n\n // If there is a preview option, use it to render a custom preview image that will\n // appear under the pointer while dragging. If not, the element itself is dragged by the browser.\n if (typeof options.preview?.current === 'function') {\n options.preview.current(items, (node, userX, userY) => {\n if (!node) {\n return;\n }\n // Compute the offset that the preview will appear under the mouse.\n // If possible, this is based on the point the user clicked on the target.\n // If the preview is much smaller, then just use the center point of the preview.\n let size = node.getBoundingClientRect();\n let rect = e.currentTarget.getBoundingClientRect();\n let defaultX = e.clientX - rect.x;\n let defaultY = e.clientY - rect.y;\n if (defaultX > size.width || defaultY > size.height) {\n defaultX = size.width / 2;\n defaultY = size.height / 2;\n }\n\n // Start with default offsets.\n let offsetX = defaultX;\n let offsetY = defaultY;\n\n // If the preview renderer supplied explicit offsets, use those.\n if (typeof userX === 'number' && typeof userY === 'number') {\n offsetX = userX;\n offsetY = userY;\n }\n\n // Clamp the offset so it stays within the preview bounds. Browsers\n // automatically clamp out-of-range values, but doing it ourselves\n // prevents the visible \"snap\" that can occur when the browser adjusts\n // them after the first drag update.\n offsetX = Math.max(0, Math.min(offsetX, size.width));\n offsetY = Math.max(0, Math.min(offsetY, size.height));\n\n // Rounding height to an even number prevents blurry preview seen on some screens\n let height = 2 * Math.round(size.height / 2);\n node.style.height = `${height}px`;\n\n e.dataTransfer.setDragImage(node, offsetX, offsetY);\n });\n }\n\n // Enforce that drops are handled by useDrop.\n addGlobalListener(window, 'drop', e => {\n e.preventDefault();\n e.stopPropagation();\n 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.');\n }, {once: true});\n state.x = e.clientX;\n state.y = e.clientY;\n\n // Wait a frame before we set dragging to true so that the browser has time to\n // render the preview image before we update the element that has been dragged.\n let target = e.target;\n requestAnimationFrame(() => {\n setDragging(target as Element);\n });\n };\n\n let onDrag = (e: DragEvent) => {\n // Prevent the drag event from propagating to any parent draggables\n e.stopPropagation();\n\n if (e.clientX === state.x && e.clientY === state.y) {\n return;\n }\n\n if (typeof options.onDragMove === 'function') {\n options.onDragMove({\n type: 'dragmove',\n x: e.clientX,\n y: e.clientY\n });\n }\n\n state.x = e.clientX;\n state.y = e.clientY;\n };\n\n let onDragEnd = (e: DragEvent) => {\n // Prevent the drag event from propagating to any parent draggables\n e.stopPropagation();\n\n if (typeof options.onDragEnd === 'function') {\n let event: DragEndEvent = {\n type: 'dragend',\n x: e.clientX,\n y: e.clientY,\n dropOperation: DROP_EFFECT_TO_DROP_OPERATION[e.dataTransfer.dropEffect]\n };\n\n // Chrome Android always returns none as its dropEffect so we use the drop effect set in useDrop via\n // onDragEnter/onDragOver instead. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951\n if (globalDropEffect) {\n event.dropOperation = DROP_EFFECT_TO_DROP_OPERATION[globalDropEffect];\n }\n options.onDragEnd(event);\n }\n\n setDragging(null);\n removeAllGlobalListeners();\n setGlobalAllowedDropOperations(DROP_OPERATION.none);\n setGlobalDropEffect(undefined);\n };\n\n // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801\n // In this case, we need to manually call onDragEnd on cleanup\n\n useEffect(() => {\n return () => {\n // Check that the dragged element has actually unmounted from the DOM and not a React Strict Mode false positive.\n // https://github.com/facebook/react/issues/29585\n // React 16 ran effect cleanups before removing elements from the DOM but did not have this issue.\n if (isDraggingRef.current && (!isDraggingRef.current.isConnected || parseInt(ReactVersion, 10) < 17)) {\n if (typeof state.options.onDragEnd === 'function') {\n let event: DragEndEvent = {\n type: 'dragend',\n x: 0,\n y: 0,\n dropOperation: DROP_EFFECT_TO_DROP_OPERATION[globalDropEffect || 'none']\n };\n state.options.onDragEnd(event);\n }\n\n setDragging(null);\n setGlobalAllowedDropOperations(DROP_OPERATION.none);\n setGlobalDropEffect(undefined);\n }\n };\n }, [state]);\n\n let onPress = (e: PressEvent) => {\n if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') {\n return;\n }\n\n startDragging(e.target as HTMLElement);\n };\n\n let startDragging = (target: HTMLElement) => {\n if (typeof state.options.onDragStart === 'function') {\n let rect = target.getBoundingClientRect();\n state.options.onDragStart({\n type: 'dragstart',\n x: rect.x + (rect.width / 2),\n y: rect.y + (rect.height / 2)\n });\n }\n\n DragManager.beginDragging({\n element: target,\n items: state.options.getItems(),\n allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function'\n ? state.options.getAllowedDropOperations()\n : ['move', 'copy', 'link'],\n onDragEnd(e) {\n setDragging(null);\n if (typeof state.options.onDragEnd === 'function') {\n state.options.onDragEnd(e);\n }\n }\n }, stringFormatter);\n\n setDragging(target);\n };\n\n let modality = useDragModality();\n let message = !isDragging ? MESSAGES[modality].start : MESSAGES[modality].end;\n\n let descriptionProps = useDescription(stringFormatter.format(message));\n\n let interactions: HTMLAttributes<HTMLElement> = {};\n if (!hasDragButton) {\n // If there's no separate button to trigger accessible drag and drop mode,\n // then add event handlers to the draggable element itself to start dragging.\n // For keyboard, we use the Enter key in a capturing listener to prevent other\n // events such as selection from also occurring. We attempt to infer whether a\n // pointer event (e.g. long press) came from a touch screen reader, and then initiate\n // dragging in the native onDragStart listener above.\n\n interactions = {\n ...descriptionProps,\n onPointerDown(e) {\n modalityOnPointerDown.current = isVirtualPointerEvent(e.nativeEvent) ? 'virtual' : e.pointerType;\n\n // Try to detect virtual drag passthrough gestures.\n if (e.width < 1 && e.height < 1) {\n // iOS VoiceOver.\n modalityOnPointerDown.current = 'virtual';\n } else {\n let rect = e.currentTarget.getBoundingClientRect();\n let offsetX = e.clientX - rect.x;\n let offsetY = e.clientY - rect.y;\n let centerX = rect.width / 2;\n let centerY = rect.height / 2;\n\n if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) {\n // Android TalkBack.\n modalityOnPointerDown.current = 'virtual';\n } else {\n modalityOnPointerDown.current = e.pointerType;\n }\n }\n },\n onKeyDownCapture(e) {\n if (e.target === e.currentTarget && e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n }\n },\n onKeyUpCapture(e) {\n if (e.target === e.currentTarget && e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n startDragging(e.target as HTMLElement);\n }\n },\n onClick(e) {\n // Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.\n if (isVirtualClick(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {\n e.preventDefault();\n e.stopPropagation();\n startDragging(e.target as HTMLElement);\n }\n }\n };\n }\n\n if (isDisabled) {\n return {\n dragProps: {\n draggable: 'false'\n },\n dragButtonProps: {},\n isDragging: false\n };\n }\n\n return {\n dragProps: {\n ...interactions,\n draggable: 'true',\n onDragStart,\n onDrag,\n onDragEnd\n },\n dragButtonProps: {\n ...descriptionProps,\n onPress\n },\n isDragging\n };\n}\n"],"names":[],"version":3,"file":"useDrag.module.js.map"}