@react-aria/dnd 3.7.4 → 3.8.1

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 (139) hide show
  1. package/dist/DragManager.main.js +25 -13
  2. package/dist/DragManager.main.js.map +1 -1
  3. package/dist/DragManager.mjs +25 -13
  4. package/dist/DragManager.module.js +25 -13
  5. package/dist/DragManager.module.js.map +1 -1
  6. package/dist/DragPreview.main.js +9 -4
  7. package/dist/DragPreview.main.js.map +1 -1
  8. package/dist/DragPreview.mjs +10 -5
  9. package/dist/DragPreview.module.js +10 -5
  10. package/dist/DragPreview.module.js.map +1 -1
  11. package/dist/ListDropTargetDelegate.main.js +5 -4
  12. package/dist/ListDropTargetDelegate.main.js.map +1 -1
  13. package/dist/ListDropTargetDelegate.mjs +5 -4
  14. package/dist/ListDropTargetDelegate.module.js +5 -4
  15. package/dist/ListDropTargetDelegate.module.js.map +1 -1
  16. package/dist/ar-AE.main.js.map +1 -1
  17. package/dist/ar-AE.module.js.map +1 -1
  18. package/dist/bg-BG.main.js.map +1 -1
  19. package/dist/bg-BG.module.js.map +1 -1
  20. package/dist/constants.main.js +3 -3
  21. package/dist/constants.main.js.map +1 -1
  22. package/dist/constants.mjs +3 -3
  23. package/dist/constants.module.js +3 -3
  24. package/dist/constants.module.js.map +1 -1
  25. package/dist/cs-CZ.main.js.map +1 -1
  26. package/dist/cs-CZ.module.js.map +1 -1
  27. package/dist/da-DK.main.js.map +1 -1
  28. package/dist/da-DK.module.js.map +1 -1
  29. package/dist/de-DE.main.js.map +1 -1
  30. package/dist/de-DE.module.js.map +1 -1
  31. package/dist/el-GR.main.js.map +1 -1
  32. package/dist/el-GR.module.js.map +1 -1
  33. package/dist/en-US.main.js.map +1 -1
  34. package/dist/en-US.module.js.map +1 -1
  35. package/dist/es-ES.main.js.map +1 -1
  36. package/dist/es-ES.module.js.map +1 -1
  37. package/dist/et-EE.main.js.map +1 -1
  38. package/dist/et-EE.module.js.map +1 -1
  39. package/dist/fi-FI.main.js.map +1 -1
  40. package/dist/fi-FI.module.js.map +1 -1
  41. package/dist/fr-FR.main.js.map +1 -1
  42. package/dist/fr-FR.module.js.map +1 -1
  43. package/dist/he-IL.main.js.map +1 -1
  44. package/dist/he-IL.module.js.map +1 -1
  45. package/dist/hr-HR.main.js.map +1 -1
  46. package/dist/hr-HR.module.js.map +1 -1
  47. package/dist/hu-HU.main.js.map +1 -1
  48. package/dist/hu-HU.module.js.map +1 -1
  49. package/dist/it-IT.main.js.map +1 -1
  50. package/dist/it-IT.module.js.map +1 -1
  51. package/dist/ja-JP.main.js.map +1 -1
  52. package/dist/ja-JP.module.js.map +1 -1
  53. package/dist/ko-KR.main.js.map +1 -1
  54. package/dist/ko-KR.module.js.map +1 -1
  55. package/dist/lt-LT.main.js.map +1 -1
  56. package/dist/lt-LT.module.js.map +1 -1
  57. package/dist/lv-LV.main.js.map +1 -1
  58. package/dist/lv-LV.module.js.map +1 -1
  59. package/dist/nb-NO.main.js.map +1 -1
  60. package/dist/nb-NO.module.js.map +1 -1
  61. package/dist/nl-NL.main.js.map +1 -1
  62. package/dist/nl-NL.module.js.map +1 -1
  63. package/dist/pl-PL.main.js.map +1 -1
  64. package/dist/pl-PL.module.js.map +1 -1
  65. package/dist/pt-BR.main.js.map +1 -1
  66. package/dist/pt-BR.module.js.map +1 -1
  67. package/dist/pt-PT.main.js.map +1 -1
  68. package/dist/pt-PT.module.js.map +1 -1
  69. package/dist/ro-RO.main.js.map +1 -1
  70. package/dist/ro-RO.module.js.map +1 -1
  71. package/dist/ru-RU.main.js.map +1 -1
  72. package/dist/ru-RU.module.js.map +1 -1
  73. package/dist/sk-SK.main.js.map +1 -1
  74. package/dist/sk-SK.module.js.map +1 -1
  75. package/dist/sl-SI.main.js.map +1 -1
  76. package/dist/sl-SI.module.js.map +1 -1
  77. package/dist/sr-SP.main.js.map +1 -1
  78. package/dist/sr-SP.module.js.map +1 -1
  79. package/dist/sv-SE.main.js.map +1 -1
  80. package/dist/sv-SE.module.js.map +1 -1
  81. package/dist/tr-TR.main.js.map +1 -1
  82. package/dist/tr-TR.module.js.map +1 -1
  83. package/dist/types.d.ts +4 -4
  84. package/dist/types.d.ts.map +1 -1
  85. package/dist/uk-UA.main.js.map +1 -1
  86. package/dist/uk-UA.module.js.map +1 -1
  87. package/dist/useAutoScroll.main.js +5 -5
  88. package/dist/useAutoScroll.main.js.map +1 -1
  89. package/dist/useAutoScroll.mjs +5 -5
  90. package/dist/useAutoScroll.module.js +5 -5
  91. package/dist/useAutoScroll.module.js.map +1 -1
  92. package/dist/useClipboard.main.js +13 -7
  93. package/dist/useClipboard.main.js.map +1 -1
  94. package/dist/useClipboard.mjs +13 -7
  95. package/dist/useClipboard.module.js +13 -7
  96. package/dist/useClipboard.module.js.map +1 -1
  97. package/dist/useDrag.main.js +2 -2
  98. package/dist/useDrag.main.js.map +1 -1
  99. package/dist/useDrag.mjs +2 -2
  100. package/dist/useDrag.module.js +2 -2
  101. package/dist/useDrag.module.js.map +1 -1
  102. package/dist/useDrop.main.js +5 -4
  103. package/dist/useDrop.main.js.map +1 -1
  104. package/dist/useDrop.mjs +5 -4
  105. package/dist/useDrop.module.js +5 -4
  106. package/dist/useDrop.module.js.map +1 -1
  107. package/dist/useDropIndicator.main.js +3 -2
  108. package/dist/useDropIndicator.main.js.map +1 -1
  109. package/dist/useDropIndicator.mjs +3 -2
  110. package/dist/useDropIndicator.module.js +3 -2
  111. package/dist/useDropIndicator.module.js.map +1 -1
  112. package/dist/useDroppableCollection.main.js +33 -19
  113. package/dist/useDroppableCollection.main.js.map +1 -1
  114. package/dist/useDroppableCollection.mjs +33 -19
  115. package/dist/useDroppableCollection.module.js +33 -19
  116. package/dist/useDroppableCollection.module.js.map +1 -1
  117. package/dist/useVirtualDrop.main.js.map +1 -1
  118. package/dist/useVirtualDrop.module.js.map +1 -1
  119. package/dist/utils.main.js +5 -3
  120. package/dist/utils.main.js.map +1 -1
  121. package/dist/utils.mjs +5 -3
  122. package/dist/utils.module.js +5 -3
  123. package/dist/utils.module.js.map +1 -1
  124. package/dist/zh-CN.main.js.map +1 -1
  125. package/dist/zh-CN.module.js.map +1 -1
  126. package/dist/zh-TW.main.js.map +1 -1
  127. package/dist/zh-TW.module.js.map +1 -1
  128. package/package.json +13 -13
  129. package/src/DragManager.ts +26 -24
  130. package/src/DragPreview.tsx +18 -12
  131. package/src/ListDropTargetDelegate.ts +8 -5
  132. package/src/useAutoScroll.ts +6 -6
  133. package/src/useClipboard.ts +12 -6
  134. package/src/useDrag.ts +5 -2
  135. package/src/useDrop.ts +17 -9
  136. package/src/useDropIndicator.ts +10 -4
  137. package/src/useDroppableCollection.ts +62 -39
  138. package/src/useVirtualDrop.ts +3 -2
  139. package/src/utils.ts +16 -10
@@ -1 +1 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,2BAA2B,CAAC,oOAA0C,CAAC;IACzF,8BAA8B,CAAC,0OAAgD,CAAC;IAChF,4BAA4B,CAAC,sSAAgD,CAAC;IAC9E,wBAAwB,CAAC,kQAA0C,CAAC;IACpE,0BAA0B,CAAC,8NAAoC,CAAC;IAChE,YAAY,CAAC,OAAS,CAAC,8EAAY,EAAE,KAAK,QAAQ,CAAC,CAAC;IACpD,qBAAqB,CAAC,MAAM,YAAc,CAAC,8EAAY,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,2GAAiB,CAAC;YAAE,OAAO,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,sFAAc,CAAC;QAAA,GAAG,CAAC;IACtN,wBAAwB,CAAC,MAAM,YAAc,CAAC,2KAAiC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,2GAAiB,CAAC;YAAE,OAAO,IAAM,CAAC,EAAE,U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AgB,CAAC,OAAS,CAAC,6FAAe,EAAE,KAAK,QAAQ,CAAC,CAAC;IAC3D,iBAAiB,CAAC,OAAS,CAAC,+EAAa,EAAE,KAAK,cAAc,CAAC,SAAG,EAAE,KAAK,aAAa,CAAC,CAAC;AAC1F","sources":["packages/@react-aria/dnd/intl/uk-UA.json"],"sourcesContent":["{\n \"dragDescriptionKeyboard\": \"Натисніть Enter, щоб почати перетягування.\",\n \"dragDescriptionKeyboardAlt\": \"Натисніть Alt + Enter, щоб почати перетягування.\",\n \"dragDescriptionLongPress\": \"Натисніть і утримуйте, щоб почати перетягування.\",\n \"dragDescriptionTouch\": \"Натисніть двічі, щоб почати перетягування.\",\n \"dragDescriptionVirtual\": \"Натисніть, щоб почати перетягування.\",\n \"dragItem\": \"Перетягнути {itemText}\",\n \"dragSelectedItems\": \"Перетягніть {count, plural, one {# вибраний елемент} other {# вибраних елем}}\",\n \"dragSelectedKeyboard\": \"Натисніть Enter, щоб перетягнути {count, plural, one {# вибраний елемент} other {# вибраних елементи(-ів)}}.\",\n \"dragSelectedKeyboardAlt\": \"Натисніть Alt + Enter, щоб перетягнути {count, plural, one {# вибраний елемент} other {# вибраних елементи(-ів)}}.\",\n \"dragSelectedLongPress\": \"Утримуйте, щоб перетягнути {count, plural, one {# вибраний елемент} other {# вибраних елементи(-ів)}}.\",\n \"dragStartedKeyboard\": \"Перетягування почалося. Натисніть Tab, щоб перейти до цілі перетягування, потім натисніть Enter, щоб перетягнути, або Escape, щоб скасувати.\",\n \"dragStartedTouch\": \"Перетягування почалося. Перейдіть до цілі перетягування, потім натисніть двічі, щоб перетягнути.\",\n \"dragStartedVirtual\": \"Перетягування почалося. Перейдіть до цілі перетягування, потім натисніть Enter, щоб перетягнути.\",\n \"dropCanceled\": \"Перетягування скасовано.\",\n \"dropComplete\": \"Перетягування завершено.\",\n \"dropDescriptionKeyboard\": \"Натисніть Enter, щоб перетягнути. Натисніть Escape, щоб скасувати перетягування.\",\n \"dropDescriptionTouch\": \"Натисніть двічі, щоб перетягнути.\",\n \"dropDescriptionVirtual\": \"Натисніть, щоб перетягнути.\",\n \"dropIndicator\": \"індикатор перетягування\",\n \"dropOnItem\": \"Перетягнути на {itemText}\",\n \"dropOnRoot\": \"Перетягнути на\",\n \"endDragKeyboard\": \"Триває перетягування. Натисніть Enter, щоб скасувати перетягування.\",\n \"endDragTouch\": \"Триває перетягування. Натисніть двічі, щоб скасувати перетягування.\",\n \"endDragVirtual\": \"Триває перетягування. Натисніть, щоб скасувати перетягування.\",\n \"insertAfter\": \"Вставити після {itemText}\",\n \"insertBefore\": \"Вставити перед {itemText}\",\n \"insertBetween\": \"Вставити між {beforeItemText} і {afterItemText}\"\n}\n"],"names":[],"version":3,"file":"uk-UA.module.js.map"}
1
+ {"mappings":";AAAA,4BAAiB;IAAG,2BAA2B,CAAC,oOAA0C,CAAC;IACzF,8BAA8B,CAAC,0OAAgD,CAAC;IAChF,4BAA4B,CAAC,sSAAgD,CAAC;IAC9E,wBAAwB,CAAC,kQAA0C,CAAC;IACpE,0BAA0B,CAAC,8NAAoC,CAAC;IAChE,YAAY,CAAC,OAAS,CAAC,8EAAY,EAAE,KAAK,QAAQ,EAAE;IACpD,qBAAqB,CAAC,MAAM,YAAc,CAAC,8EAAY,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,2GAAiB,CAAC;YAAE,OAAO,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,sFAAc,CAAC;QAAA,IAAI;IACtN,wBAAwB,CAAC,MAAM,YAAc,CAAC,2KAAiC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,2GAAiB,CAAC;YAAE,OAAO,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,mIAAuB,CAAC;QAAA,GAAG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EAAE,KAAK,cAAc,CAAC,SAAG,EAAE,KAAK,aAAa,EAAE;AAC1F","sources":["packages/@react-aria/dnd/intl/uk-UA.json"],"sourcesContent":["{\n \"dragDescriptionKeyboard\": \"Натисніть Enter, щоб почати перетягування.\",\n \"dragDescriptionKeyboardAlt\": \"Натисніть Alt + Enter, щоб почати перетягування.\",\n \"dragDescriptionLongPress\": \"Натисніть і утримуйте, щоб почати перетягування.\",\n \"dragDescriptionTouch\": \"Натисніть двічі, щоб почати перетягування.\",\n \"dragDescriptionVirtual\": \"Натисніть, щоб почати перетягування.\",\n \"dragItem\": \"Перетягнути {itemText}\",\n \"dragSelectedItems\": \"Перетягніть {count, plural, one {# вибраний елемент} other {# вибраних елем}}\",\n \"dragSelectedKeyboard\": \"Натисніть Enter, щоб перетягнути {count, plural, one {# вибраний елемент} other {# вибраних елементи(-ів)}}.\",\n \"dragSelectedKeyboardAlt\": \"Натисніть Alt + Enter, щоб перетягнути {count, plural, one {# вибраний елемент} other {# вибраних елементи(-ів)}}.\",\n \"dragSelectedLongPress\": \"Утримуйте, щоб перетягнути {count, plural, one {# вибраний елемент} other {# вибраних елементи(-ів)}}.\",\n \"dragStartedKeyboard\": \"Перетягування почалося. Натисніть Tab, щоб перейти до цілі перетягування, потім натисніть Enter, щоб перетягнути, або Escape, щоб скасувати.\",\n \"dragStartedTouch\": \"Перетягування почалося. Перейдіть до цілі перетягування, потім натисніть двічі, щоб перетягнути.\",\n \"dragStartedVirtual\": \"Перетягування почалося. Перейдіть до цілі перетягування, потім натисніть Enter, щоб перетягнути.\",\n \"dropCanceled\": \"Перетягування скасовано.\",\n \"dropComplete\": \"Перетягування завершено.\",\n \"dropDescriptionKeyboard\": \"Натисніть Enter, щоб перетягнути. Натисніть Escape, щоб скасувати перетягування.\",\n \"dropDescriptionTouch\": \"Натисніть двічі, щоб перетягнути.\",\n \"dropDescriptionVirtual\": \"Натисніть, щоб перетягнути.\",\n \"dropIndicator\": \"індикатор перетягування\",\n \"dropOnItem\": \"Перетягнути на {itemText}\",\n \"dropOnRoot\": \"Перетягнути на\",\n \"endDragKeyboard\": \"Триває перетягування. Натисніть Enter, щоб скасувати перетягування.\",\n \"endDragTouch\": \"Триває перетягування. Натисніть двічі, щоб скасувати перетягування.\",\n \"endDragVirtual\": \"Триває перетягування. Натисніть, щоб скасувати перетягування.\",\n \"insertAfter\": \"Вставити після {itemText}\",\n \"insertBefore\": \"Вставити перед {itemText}\",\n \"insertBetween\": \"Вставити між {beforeItemText} і {afterItemText}\"\n}\n"],"names":[],"version":3,"file":"uk-UA.module.js.map"}
@@ -35,7 +35,7 @@ function $12cc069a1c69155b$export$6323452ca4533ed8(ref) {
35
35
  ref
36
36
  ]);
37
37
  let state = (0, $8QIlU$react.useRef)({
38
- timer: null,
38
+ timer: undefined,
39
39
  dx: 0,
40
40
  dy: 0
41
41
  }).current;
@@ -43,7 +43,7 @@ function $12cc069a1c69155b$export$6323452ca4533ed8(ref) {
43
43
  return ()=>{
44
44
  if (state.timer) {
45
45
  cancelAnimationFrame(state.timer);
46
- state.timer = null;
46
+ state.timer = undefined;
47
47
  }
48
48
  };
49
49
  // state will become a new object, so it's ok to use in the dependency array for unmount
@@ -51,8 +51,8 @@ function $12cc069a1c69155b$export$6323452ca4533ed8(ref) {
51
51
  state
52
52
  ]);
53
53
  let scroll = (0, $8QIlU$react.useCallback)(()=>{
54
- if (scrollableX.current) scrollableRef.current.scrollLeft += state.dx;
55
- if (scrollableY.current) scrollableRef.current.scrollTop += state.dy;
54
+ if (scrollableX.current && scrollableRef.current) scrollableRef.current.scrollLeft += state.dx;
55
+ if (scrollableY.current && scrollableRef.current) scrollableRef.current.scrollTop += state.dy;
56
56
  if (state.timer) state.timer = requestAnimationFrame(scroll);
57
57
  }, [
58
58
  scrollableRef,
@@ -79,7 +79,7 @@ function $12cc069a1c69155b$export$6323452ca4533ed8(ref) {
79
79
  stop () {
80
80
  if (state.timer) {
81
81
  cancelAnimationFrame(state.timer);
82
- state.timer = null;
82
+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,EAAE,CAAC;YACP,qFAAqF;YACrF,iDAAiD;YACjD,IAAI,CAAC,CAAA,GAAA,8BAAO,OAAO,CAAA,GAAA,2BAAI,OAAO,CAAC,cAAc,OAAO,EAClD;YAGF,IAAI,MAAM,cAAc,OAAO,CAAC,qBAAqB;YACrD,IAAI,OAAO;YACX,IAAI,MAAM;YACV,IAAI,SAAS,IAAI,MAAM,GAAG;YAC1B,IAAI,QAAQ,IAAI,KAAK,GAAG;YACxB,IAAI,IAAI,QAAQ,IAAI,SAAS,IAAI,OAAO,IAAI,QAAQ;gBAClD,IAAI,IAAI,MACN,MAAM,EAAE,GAAG,IAAI;qBACV,IAAI,IAAI,OACb,MAAM,EAAE,GAAG,IAAI;gBAEjB,IAAI,IAAI,KACN,MAAM,EAAE,GAAG,IAAI;qBACV,IAAI,IAAI,QACb,MAAM,EAAE,GAAG,IAAI;gBAGjB,IAAI,CAAC,MAAM,KAAK,EACd,MAAM,KAAK,GAAG,sBAAsB;YAExC,OACE,IAAI,CAAC,IAAI;QAEb;QACA;YACE,IAAI,MAAM,KAAK,EAAE;gBACf,qBAAqB,MAAM,KAAK;gBAChC,MAAM,KAAK,GAAG;YAChB;QACF;IACF;AACF","sources":["packages/@react-aria/dnd/src/useAutoScroll.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 {getScrollParent, isIOS, isScrollable, isWebKit} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useCallback, useEffect, useRef} from 'react';\n\nconst AUTOSCROLL_AREA_SIZE = 20;\n\nexport function useAutoScroll(ref: RefObject<Element | null>) {\n let scrollableRef = useRef<Element>(null);\n let scrollableX = useRef(true);\n let scrollableY = useRef(true);\n useEffect(() => {\n if (ref.current) {\n scrollableRef.current = isScrollable(ref.current) ? ref.current : getScrollParent(ref.current);\n let style = window.getComputedStyle(scrollableRef.current);\n scrollableX.current = /(auto|scroll)/.test(style.overflowX);\n scrollableY.current = /(auto|scroll)/.test(style.overflowY);\n }\n }, [ref]);\n\n let state = useRef({\n timer: null,\n dx: 0,\n dy: 0\n }).current;\n\n useEffect(() => {\n return () => {\n if (state.timer) {\n cancelAnimationFrame(state.timer);\n state.timer = null;\n }\n };\n // state will become a new object, so it's ok to use in the dependency array for unmount\n }, [state]);\n\n let scroll = useCallback(() => {\n if (scrollableX.current) {\n scrollableRef.current.scrollLeft += state.dx;\n }\n if (scrollableY.current) {\n scrollableRef.current.scrollTop += state.dy;\n }\n\n if (state.timer) {\n state.timer = requestAnimationFrame(scroll);\n }\n }, [scrollableRef, state]);\n\n return {\n move(x, y) {\n // Most browsers auto scroll natively, but WebKit on macOS does not (iOS does 🤷‍♂️).\n // https://bugs.webkit.org/show_bug.cgi?id=222636\n if (!isWebKit() || isIOS() || !scrollableRef.current) {\n return;\n }\n\n let box = scrollableRef.current.getBoundingClientRect();\n let left = AUTOSCROLL_AREA_SIZE;\n let top = AUTOSCROLL_AREA_SIZE;\n let bottom = box.height - AUTOSCROLL_AREA_SIZE;\n let right = box.width - AUTOSCROLL_AREA_SIZE;\n if (x < left || x > right || y < top || y > bottom) {\n if (x < left) {\n state.dx = x - left;\n } else if (x > right) {\n state.dx = x - right;\n }\n if (y < top) {\n state.dy = y - top;\n } else if (y > bottom) {\n state.dy = y - bottom;\n }\n\n if (!state.timer) {\n state.timer = requestAnimationFrame(scroll);\n }\n } else {\n this.stop();\n }\n },\n stop() {\n if (state.timer) {\n cancelAnimationFrame(state.timer);\n state.timer = null;\n }\n }\n };\n}\n"],"names":[],"version":3,"file":"useAutoScroll.main.js.map"}
1
+ {"mappings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qF;YACrF,iDAAiD;YACjD,IAAI,CAAC,CAAA,GAAA,8BAAO,OAAO,CAAA,GAAA,2BAAI,OAAO,CAAC,cAAc,OAAO,EAClD;YAGF,IAAI,MAAM,cAAc,OAAO,CAAC,qBAAqB;YACrD,IAAI,OAAO;YACX,IAAI,MAAM;YACV,IAAI,SAAS,IAAI,MAAM,GAAG;YAC1B,IAAI,QAAQ,IAAI,KAAK,GAAG;YACxB,IAAI,IAAI,QAAQ,IAAI,SAAS,IAAI,OAAO,IAAI,QAAQ;gBAClD,IAAI,IAAI,MACN,MAAM,EAAE,GAAG,IAAI;qBACV,IAAI,IAAI,OACb,MAAM,EAAE,GAAG,IAAI;gBAEjB,IAAI,IAAI,KACN,MAAM,EAAE,GAAG,IAAI;qBACV,IAAI,IAAI,QACb,MAAM,EAAE,GAAG,IAAI;gBAGjB,IAAI,CAAC,MAAM,KAAK,EACd,MAAM,KAAK,GAAG,sBAAsB;YAExC,OACE,IAAI,CAAC,IAAI;QAEb;QACA;YACE,IAAI,MAAM,KAAK,EAAE;gBACf,qBAAqB,MAAM,KAAK;gBAChC,MAAM,KAAK,GAAG;YAChB;QACF;IACF;AACF","sources":["packages/@react-aria/dnd/src/useAutoScroll.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 {getScrollParent, isIOS, isScrollable, isWebKit} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useCallback, useEffect, useRef} from 'react';\n\nconst AUTOSCROLL_AREA_SIZE = 20;\n\nexport function useAutoScroll(ref: RefObject<Element | null>) {\n let scrollableRef = useRef<Element>(null);\n let scrollableX = useRef(true);\n let scrollableY = useRef(true);\n useEffect(() => {\n if (ref.current) {\n scrollableRef.current = isScrollable(ref.current) ? ref.current : getScrollParent(ref.current);\n let style = window.getComputedStyle(scrollableRef.current);\n scrollableX.current = /(auto|scroll)/.test(style.overflowX);\n scrollableY.current = /(auto|scroll)/.test(style.overflowY);\n }\n }, [ref]);\n\n let state = useRef<{timer: ReturnType<typeof requestAnimationFrame> | undefined, dx: number, dy: number}>({\n timer: undefined,\n dx: 0,\n dy: 0\n }).current;\n\n useEffect(() => {\n return () => {\n if (state.timer) {\n cancelAnimationFrame(state.timer);\n state.timer = undefined;\n }\n };\n // state will become a new object, so it's ok to use in the dependency array for unmount\n }, [state]);\n\n let scroll = useCallback(() => {\n if (scrollableX.current && scrollableRef.current) {\n scrollableRef.current.scrollLeft += state.dx;\n }\n if (scrollableY.current && scrollableRef.current) {\n scrollableRef.current.scrollTop += state.dy;\n }\n\n if (state.timer) {\n state.timer = requestAnimationFrame(scroll);\n }\n }, [scrollableRef, state]);\n\n return {\n move(x, y) {\n // Most browsers auto scroll natively, but WebKit on macOS does not (iOS does 🤷‍♂️).\n // https://bugs.webkit.org/show_bug.cgi?id=222636\n if (!isWebKit() || isIOS() || !scrollableRef.current) {\n return;\n }\n\n let box = scrollableRef.current.getBoundingClientRect();\n let left = AUTOSCROLL_AREA_SIZE;\n let top = AUTOSCROLL_AREA_SIZE;\n let bottom = box.height - AUTOSCROLL_AREA_SIZE;\n let right = box.width - AUTOSCROLL_AREA_SIZE;\n if (x < left || x > right || y < top || y > bottom) {\n if (x < left) {\n state.dx = x - left;\n } else if (x > right) {\n state.dx = x - right;\n }\n if (y < top) {\n state.dy = y - top;\n } else if (y > bottom) {\n state.dy = y - bottom;\n }\n\n if (!state.timer) {\n state.timer = requestAnimationFrame(scroll);\n }\n } else {\n this.stop();\n }\n },\n stop() {\n if (state.timer) {\n cancelAnimationFrame(state.timer);\n state.timer = undefined;\n }\n }\n };\n}\n"],"names":[],"version":3,"file":"useAutoScroll.main.js.map"}
@@ -29,7 +29,7 @@ function $80d9daea3067eff3$export$6323452ca4533ed8(ref) {
29
29
  ref
30
30
  ]);
31
31
  let state = (0, $2wNms$useRef)({
32
- timer: null,
32
+ timer: undefined,
33
33
  dx: 0,
34
34
  dy: 0
35
35
  }).current;
@@ -37,7 +37,7 @@ function $80d9daea3067eff3$export$6323452ca4533ed8(ref) {
37
37
  return ()=>{
38
38
  if (state.timer) {
39
39
  cancelAnimationFrame(state.timer);
40
- state.timer = null;
40
+ state.timer = undefined;
41
41
  }
42
42
  };
43
43
  // state will become a new object, so it's ok to use in the dependency array for unmount
@@ -45,8 +45,8 @@ function $80d9daea3067eff3$export$6323452ca4533ed8(ref) {
45
45
  state
46
46
  ]);
47
47
  let scroll = (0, $2wNms$useCallback)(()=>{
48
- if (scrollableX.current) scrollableRef.current.scrollLeft += state.dx;
49
- if (scrollableY.current) scrollableRef.current.scrollTop += state.dy;
48
+ if (scrollableX.current && scrollableRef.current) scrollableRef.current.scrollLeft += state.dx;
49
+ if (scrollableY.current && scrollableRef.current) scrollableRef.current.scrollTop += state.dy;
50
50
  if (state.timer) state.timer = requestAnimationFrame(scroll);
51
51
  }, [
52
52
  scrollableRef,
@@ -73,7 +73,7 @@ function $80d9daea3067eff3$export$6323452ca4533ed8(ref) {
73
73
  stop () {
74
74
  if (state.timer) {
75
75
  cancelAnimationFrame(state.timer);
76
- state.timer = null;
76
+ state.timer = undefined;
77
77
  }
78
78
  }
79
79
  };
@@ -29,7 +29,7 @@ function $80d9daea3067eff3$export$6323452ca4533ed8(ref) {
29
29
  ref
30
30
  ]);
31
31
  let state = (0, $2wNms$useRef)({
32
- timer: null,
32
+ timer: undefined,
33
33
  dx: 0,
34
34
  dy: 0
35
35
  }).current;
@@ -37,7 +37,7 @@ function $80d9daea3067eff3$export$6323452ca4533ed8(ref) {
37
37
  return ()=>{
38
38
  if (state.timer) {
39
39
  cancelAnimationFrame(state.timer);
40
- state.timer = null;
40
+ state.timer = undefined;
41
41
  }
42
42
  };
43
43
  // state will become a new object, so it's ok to use in the dependency array for unmount
@@ -45,8 +45,8 @@ function $80d9daea3067eff3$export$6323452ca4533ed8(ref) {
45
45
  state
46
46
  ]);
47
47
  let scroll = (0, $2wNms$useCallback)(()=>{
48
- if (scrollableX.current) scrollableRef.current.scrollLeft += state.dx;
49
- if (scrollableY.current) scrollableRef.current.scrollTop += state.dy;
48
+ if (scrollableX.current && scrollableRef.current) scrollableRef.current.scrollLeft += state.dx;
49
+ if (scrollableY.current && scrollableRef.current) scrollableRef.current.scrollTop += state.dy;
50
50
  if (state.timer) state.timer = requestAnimationFrame(scroll);
51
51
  }, [
52
52
  scrollableRef,
@@ -73,7 +73,7 @@ function $80d9daea3067eff3$export$6323452ca4533ed8(ref) {
73
73
  stop () {
74
74
  if (state.timer) {
75
75
  cancelAnimationFrame(state.timer);
76
- state.timer = null;
76
+ state.timer = undefined;
77
77
  }
78
78
  }
79
79
  };
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMD,MAAM,6CAAuB;AAEtB,SAAS,0CAAc,GAA8B;IAC1D,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAW;IACpC,IAAI,cAAc,CAAA,GAAA,aAAK,EAAE;IACzB,IAAI,cAAc,CAAA,GAAA,aAAK,EAAE;IACzB,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,EAAE;YACf,cAAc,OAAO,GAAG,CAAA,GAAA,mBAAW,EAAE,IAAI,OAAO,IAAI,IAAI,OAAO,GAAG,CAAA,GAAA,sBAAc,EAAE,IAAI,OAAO;YAC7F,IAAI,QAAQ,OAAO,gBAAgB,CAAC,cAAc,OAAO;YACzD,YAAY,OAAO,GAAG,gBAAgB,IAAI,CAAC,MAAM,SAAS;YAC1D,YAAY,OAAO,GAAG,gBAAgB,IAAI,CAAC,MAAM,SAAS;QAC5D;IACF,GAAG;QAAC;KAAI;IAER,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AE;gBACf,qBAAqB,MAAM,KAAK;gBAChC,MAAM,KAAK,GAAG;YAChB;QACF;IACF;AACF","sources":["packages/@react-aria/dnd/src/useAutoScroll.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 {getScrollParent, isIOS, isScrollable, isWebKit} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useCallback, useEffect, useRef} from 'react';\n\nconst AUTOSCROLL_AREA_SIZE = 20;\n\nexport function useAutoScroll(ref: RefObject<Element | null>) {\n let scrollableRef = useRef<Element>(null);\n let scrollableX = useRef(true);\n let scrollableY = useRef(true);\n useEffect(() => {\n if (ref.current) {\n scrollableRef.current = isScrollable(ref.current) ? ref.current : getScrollParent(ref.current);\n let style = window.getComputedStyle(scrollableRef.current);\n scrollableX.current = /(auto|scroll)/.test(style.overflowX);\n scrollableY.current = /(auto|scroll)/.test(style.overflowY);\n }\n }, [ref]);\n\n let state = useRef({\n timer: null,\n dx: 0,\n dy: 0\n }).current;\n\n useEffect(() => {\n return () => {\n if (state.timer) {\n cancelAnimationFrame(state.timer);\n state.timer = null;\n }\n };\n // state will become a new object, so it's ok to use in the dependency array for unmount\n }, [state]);\n\n let scroll = useCallback(() => {\n if (scrollableX.current) {\n scrollableRef.current.scrollLeft += state.dx;\n }\n if (scrollableY.current) {\n scrollableRef.current.scrollTop += state.dy;\n }\n\n if (state.timer) {\n state.timer = requestAnimationFrame(scroll);\n }\n }, [scrollableRef, state]);\n\n return {\n move(x, y) {\n // Most browsers auto scroll natively, but WebKit on macOS does not (iOS does 🤷‍♂️).\n // https://bugs.webkit.org/show_bug.cgi?id=222636\n if (!isWebKit() || isIOS() || !scrollableRef.current) {\n return;\n }\n\n let box = scrollableRef.current.getBoundingClientRect();\n let left = AUTOSCROLL_AREA_SIZE;\n let top = AUTOSCROLL_AREA_SIZE;\n let bottom = box.height - AUTOSCROLL_AREA_SIZE;\n let right = box.width - AUTOSCROLL_AREA_SIZE;\n if (x < left || x > right || y < top || y > bottom) {\n if (x < left) {\n state.dx = x - left;\n } else if (x > right) {\n state.dx = x - right;\n }\n if (y < top) {\n state.dy = y - top;\n } else if (y > bottom) {\n state.dy = y - bottom;\n }\n\n if (!state.timer) {\n state.timer = requestAnimationFrame(scroll);\n }\n } else {\n this.stop();\n }\n },\n stop() {\n if (state.timer) {\n cancelAnimationFrame(state.timer);\n state.timer = null;\n }\n }\n };\n}\n"],"names":[],"version":3,"file":"useAutoScroll.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMD,MAAM,6CAAuB;AAEtB,SAAS,0CAAc,GAA8B;IAC1D,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAW;IACpC,IAAI,cAAc,CAAA,GAAA,aAAK,EAAE;IACzB,IAAI,cAAc,CAAA,GAAA,aAAK,EAAE;IACzB,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,IAAI,OAAO,EAAE;YACf,cAAc,OAAO,GAAG,CAAA,GAAA,mBAAW,EAAE,IAAI,OAAO,IAAI,IAAI,OAAO,GAAG,CAAA,GAAA,sBAAc,EAAE,IAAI,OAAO;YAC7F,IAAI,QAAQ,OAAO,gBAAgB,CAAC,cAAc,OAAO;YACzD,YAAY,OAAO,GAAG,gBAAgB,IAAI,CAAC,MAAM,SAAS;YAC1D,YAAY,OAAO,GAAG,gBAAgB,IAAI,CAAC,MAAM,SAAS;QAC5D;IACF,GAAG;QAAC;KAAI;IAER,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAyF;QACxG,OAAO;QACP,IAAI;QACJ,IAAI;IACN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MAAM,KAAK,GAAG;YAChB;QACF;IACF;AACF","sources":["packages/@react-aria/dnd/src/useAutoScroll.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 {getScrollParent, isIOS, isScrollable, isWebKit} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useCallback, useEffect, useRef} from 'react';\n\nconst AUTOSCROLL_AREA_SIZE = 20;\n\nexport function useAutoScroll(ref: RefObject<Element | null>) {\n let scrollableRef = useRef<Element>(null);\n let scrollableX = useRef(true);\n let scrollableY = useRef(true);\n useEffect(() => {\n if (ref.current) {\n scrollableRef.current = isScrollable(ref.current) ? ref.current : getScrollParent(ref.current);\n let style = window.getComputedStyle(scrollableRef.current);\n scrollableX.current = /(auto|scroll)/.test(style.overflowX);\n scrollableY.current = /(auto|scroll)/.test(style.overflowY);\n }\n }, [ref]);\n\n let state = useRef<{timer: ReturnType<typeof requestAnimationFrame> | undefined, dx: number, dy: number}>({\n timer: undefined,\n dx: 0,\n dy: 0\n }).current;\n\n useEffect(() => {\n return () => {\n if (state.timer) {\n cancelAnimationFrame(state.timer);\n state.timer = undefined;\n }\n };\n // state will become a new object, so it's ok to use in the dependency array for unmount\n }, [state]);\n\n let scroll = useCallback(() => {\n if (scrollableX.current && scrollableRef.current) {\n scrollableRef.current.scrollLeft += state.dx;\n }\n if (scrollableY.current && scrollableRef.current) {\n scrollableRef.current.scrollTop += state.dy;\n }\n\n if (state.timer) {\n state.timer = requestAnimationFrame(scroll);\n }\n }, [scrollableRef, state]);\n\n return {\n move(x, y) {\n // Most browsers auto scroll natively, but WebKit on macOS does not (iOS does 🤷‍♂️).\n // https://bugs.webkit.org/show_bug.cgi?id=222636\n if (!isWebKit() || isIOS() || !scrollableRef.current) {\n return;\n }\n\n let box = scrollableRef.current.getBoundingClientRect();\n let left = AUTOSCROLL_AREA_SIZE;\n let top = AUTOSCROLL_AREA_SIZE;\n let bottom = box.height - AUTOSCROLL_AREA_SIZE;\n let right = box.width - AUTOSCROLL_AREA_SIZE;\n if (x < left || x > right || y < top || y > bottom) {\n if (x < left) {\n state.dx = x - left;\n } else if (x > right) {\n state.dx = x - right;\n }\n if (y < top) {\n state.dy = y - top;\n } else if (y > bottom) {\n state.dy = y - bottom;\n }\n\n if (!state.timer) {\n state.timer = requestAnimationFrame(scroll);\n }\n } else {\n this.stop();\n }\n },\n stop() {\n if (state.timer) {\n cancelAnimationFrame(state.timer);\n state.timer = undefined;\n }\n }\n };\n}\n"],"names":[],"version":3,"file":"useAutoScroll.module.js.map"}
@@ -60,11 +60,13 @@ function $74f3dedaa4d234b4$export$2314ca2a3e892862(options) {
60
60
  if (isFocusedRef.current && options.getItems) e.preventDefault();
61
61
  });
62
62
  let onCopy = (0, $gAFdr$reactariautils.useEffectEvent)((e)=>{
63
- var _options_onCopy;
64
63
  if (!isFocusedRef.current || !options.getItems) return;
65
64
  e.preventDefault();
66
- (0, $4620ae0dc40f0031$exports.writeToDataTransfer)(e.clipboardData, options.getItems());
67
- (_options_onCopy = options.onCopy) === null || _options_onCopy === void 0 ? void 0 : _options_onCopy.call(options);
65
+ if (e.clipboardData) {
66
+ var _options_onCopy;
67
+ (0, $4620ae0dc40f0031$exports.writeToDataTransfer)(e.clipboardData, options.getItems());
68
+ (_options_onCopy = options.onCopy) === null || _options_onCopy === void 0 ? void 0 : _options_onCopy.call(options);
69
+ }
68
70
  });
69
71
  let onBeforeCut = (0, $gAFdr$reactariautils.useEffectEvent)((e)=>{
70
72
  if (isFocusedRef.current && options.onCut && options.getItems) e.preventDefault();
@@ -72,8 +74,10 @@ function $74f3dedaa4d234b4$export$2314ca2a3e892862(options) {
72
74
  let onCut = (0, $gAFdr$reactariautils.useEffectEvent)((e)=>{
73
75
  if (!isFocusedRef.current || !options.onCut || !options.getItems) return;
74
76
  e.preventDefault();
75
- (0, $4620ae0dc40f0031$exports.writeToDataTransfer)(e.clipboardData, options.getItems());
76
- options.onCut();
77
+ if (e.clipboardData) {
78
+ (0, $4620ae0dc40f0031$exports.writeToDataTransfer)(e.clipboardData, options.getItems());
79
+ options.onCut();
80
+ }
77
81
  });
78
82
  let onBeforePaste = (0, $gAFdr$reactariautils.useEffectEvent)((e)=>{
79
83
  // Unfortunately, e.clipboardData.types is not available in this event so we always
@@ -83,8 +87,10 @@ function $74f3dedaa4d234b4$export$2314ca2a3e892862(options) {
83
87
  let onPaste = (0, $gAFdr$reactariautils.useEffectEvent)((e)=>{
84
88
  if (!isFocusedRef.current || !options.onPaste) return;
85
89
  e.preventDefault();
86
- let items = (0, $4620ae0dc40f0031$exports.readFromDataTransfer)(e.clipboardData);
87
- options.onPaste(items);
90
+ if (e.clipboardData) {
91
+ let items = (0, $4620ae0dc40f0031$exports.readFromDataTransfer)(e.clipboardData);
92
+ options.onPaste(items);
93
+ }
88
94
  });
89
95
  (0, $gAFdr$react.useEffect)(()=>{
90
96
  if (isDisabled) return;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA0BD,MAAM,qCAAe,IAAI;AACzB,SAAS,6CAAuB,KAAK,EAAE,EAAE;IACvC,IAAI,YAAY,mCAAa,GAAG,CAAC;IACjC,IAAI,CAAC,WAAW;QACd,IAAI,WAAW,IAAI;QACnB,IAAI,WAAW,CAAC;YACd,KAAK,IAAI,WAAW,SAClB,QAAQ;QAEZ;QAEA,YAAY;sBAAC;sBAAU;QAAQ;QAC/B,mCAAa,GAAG,CAAC,OAAO;QAExB,SAAS,gBAAgB,CAAC,OAAO;IACnC;IAEA,UAAU,QAAQ,CAAC,GAAG,CAAC;IAC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;QAClC,mFAAmF;QACnF,8EAA8E;QAC9E,IAAI,aAAa,OAAO,IAAI,QAAQ,OAAO,EACzC,EAAE,cAAc;IAEpB;IAEA,IAAI,UAAU,CAAA,GAAA,oCAAa,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,QAAQ,OAAO,EAC3C;QAGF,EAAE,cAAc;QAChB,IAAI,QAAQ,CAAA,GAAA,8CAAmB,EAAE,EAAE,aAAa;QAChD,QAAQ,OAAO,CAAC;IAClB;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,YACF;QAEF,OAAO,CAAA,GAAA,2BAAI,EACT,6CAAuB,cAAc,eACrC,6CAAuB,QAAQ,SAC/B,6CAAuB,aAAa,cACpC,6CAAuB,OAAO,QAC9B,6CAAuB,eAAe,gBACtC,6CAAuB,SAAS;IAEpC,GAAG;QAAC;QAAY;QAAc;QAAQ;QAAa;QAAO;QAAe;KAAQ;IAEjF,OAAO;QACL,gBAAgB;IAClB;AACF","sources":["packages/@react-aria/dnd/src/useClipboard.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 {chain, useEffectEvent} from '@react-aria/utils';\nimport {DOMAttributes, DragItem, DropItem} from '@react-types/shared';\nimport {readFromDataTransfer, writeToDataTransfer} from './utils';\nimport {useEffect, useRef} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface ClipboardProps {\n /** A function that returns the items to copy. */\n getItems?: () => DragItem[],\n /** Handler that is called when the user triggers a copy interaction. */\n onCopy?: () => void,\n /** Handler that is called when the user triggers a cut interaction. */\n onCut?: () => void,\n /** Handler that is called when the user triggers a paste interaction. */\n onPaste?: (items: DropItem[]) => void,\n /** Whether the clipboard is disabled. */\n isDisabled?: boolean\n}\n\nexport interface ClipboardResult {\n /** Props for the element that will handle clipboard events. */\n clipboardProps: DOMAttributes\n}\n\nconst globalEvents = new Map();\nfunction addGlobalEventListener(event, fn) {\n let eventData = globalEvents.get(event);\n if (!eventData) {\n let handlers = new Set<(e: Event) => void>();\n let listener = (e) => {\n for (let handler of handlers) {\n handler(e);\n }\n };\n\n eventData = {listener, handlers};\n globalEvents.set(event, eventData);\n\n document.addEventListener(event, listener);\n }\n\n eventData.handlers.add(fn);\n return () => {\n eventData.handlers.delete(fn);\n if (eventData.handlers.size === 0) {\n document.removeEventListener(event, eventData.listener);\n globalEvents.delete(event);\n }\n };\n}\n\n/**\n * Handles clipboard interactions for a focusable element. Supports items of multiple\n * data types, and integrates with the operating system native clipboard.\n */\nexport function useClipboard(options: ClipboardProps): ClipboardResult {\n let {isDisabled} = options;\n let isFocusedRef = useRef(false);\n let {focusProps} = useFocus({\n onFocusChange: (isFocused) => {\n isFocusedRef.current = isFocused;\n }\n });\n\n let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {\n // Enable the \"Copy\" menu item in Safari if this element is focused and copying is supported.\n if (isFocusedRef.current && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCopy = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n writeToDataTransfer(e.clipboardData, options.getItems());\n options.onCopy?.();\n });\n\n let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {\n if (isFocusedRef.current && options.onCut && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCut = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onCut || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n writeToDataTransfer(e.clipboardData, options.getItems());\n options.onCut();\n });\n\n let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {\n // Unfortunately, e.clipboardData.types is not available in this event so we always\n // have to enable the Paste menu item even if the type of data is unsupported.\n if (isFocusedRef.current && options.onPaste) {\n e.preventDefault();\n }\n });\n\n let onPaste = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onPaste) {\n return;\n }\n\n e.preventDefault();\n let items = readFromDataTransfer(e.clipboardData);\n options.onPaste(items);\n });\n\n useEffect(() => {\n if (isDisabled) {\n return;\n }\n return chain(\n addGlobalEventListener('beforecopy', onBeforeCopy),\n addGlobalEventListener('copy', onCopy),\n addGlobalEventListener('beforecut', onBeforeCut),\n addGlobalEventListener('cut', onCut),\n addGlobalEventListener('beforepaste', onBeforePaste),\n addGlobalEventListener('paste', onPaste)\n );\n }, [isDisabled, onBeforeCopy, onCopy, onBeforeCut, onCut, onBeforePaste, onPaste]);\n\n return {\n clipboardProps: focusProps\n };\n}\n"],"names":[],"version":3,"file":"useClipboard.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA0BD,MAAM,qCAAe,IAAI;AACzB,SAAS,6CAAuB,KAAK,EAAE,EAAE;IACvC,IAAI,YAAY,mCAAa,GAAG,CAAC;IACjC,IAAI,CAAC,WAAW;QACd,IAAI,WAAW,IAAI;QACnB,IAAI,WAAW,CAAC;YACd,KAAK,IAAI,WAAW,SAClB,QAAQ;QAEZ;QAEA,YAAY;sBAAC;sBAAU;QAAQ;QAC/B,mCAAa,GAAG,CAAC,OAAO;QAExB,SAAS,gBAAgB,CAAC,OAAO;IACnC;IAEA,UAAU,QAAQ,CAAC,GAAG,CAAC;IACvB,OAAO;QACL,UAAU,QAAQ,CAAC,MAAM,CAAC;QAC1B,IAAI,UAAU,QAAQ,CAAC,IAAI,KAAK,GAAG;YACjC,SAAS,mBAAmB,CAAC,OAAO,UAAU,QAAQ;YACtD,mCAAa,MAAM,CAAC;QACtB;IACF;AACF;AAMO,SAAS,0CAAa,OAAuB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,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,QAAQ,OAAO,EAC3C;QAGF,EAAE,cAAc;QAChB,IAAI,EAAE,aAAa,EAAE;YACnB,IAAI,QAAQ,CAAA,GAAA,8CAAmB,EAAE,EAAE,aAAa;YAChD,QAAQ,OAAO,CAAC;QAClB;IACF;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,YACF;QAEF,OAAO,CAAA,GAAA,2BAAI,EACT,6CAAuB,cAAc,eACrC,6CAAuB,QAAQ,SAC/B,6CAAuB,aAAa,cACpC,6CAAuB,OAAO,QAC9B,6CAAuB,eAAe,gBACtC,6CAAuB,SAAS;IAEpC,GAAG;QAAC;QAAY;QAAc;QAAQ;QAAa;QAAO;QAAe;KAAQ;IAEjF,OAAO;QACL,gBAAgB;IAClB;AACF","sources":["packages/@react-aria/dnd/src/useClipboard.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 {chain, useEffectEvent} from '@react-aria/utils';\nimport {DOMAttributes, DragItem, DropItem} from '@react-types/shared';\nimport {readFromDataTransfer, writeToDataTransfer} from './utils';\nimport {useEffect, useRef} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface ClipboardProps {\n /** A function that returns the items to copy. */\n getItems?: () => DragItem[],\n /** Handler that is called when the user triggers a copy interaction. */\n onCopy?: () => void,\n /** Handler that is called when the user triggers a cut interaction. */\n onCut?: () => void,\n /** Handler that is called when the user triggers a paste interaction. */\n onPaste?: (items: DropItem[]) => void,\n /** Whether the clipboard is disabled. */\n isDisabled?: boolean\n}\n\nexport interface ClipboardResult {\n /** Props for the element that will handle clipboard events. */\n clipboardProps: DOMAttributes\n}\n\nconst globalEvents = new Map();\nfunction addGlobalEventListener(event, fn) {\n let eventData = globalEvents.get(event);\n if (!eventData) {\n let handlers = new Set<(e: Event) => void>();\n let listener = (e) => {\n for (let handler of handlers) {\n handler(e);\n }\n };\n\n eventData = {listener, handlers};\n globalEvents.set(event, eventData);\n\n document.addEventListener(event, listener);\n }\n\n eventData.handlers.add(fn);\n return () => {\n eventData.handlers.delete(fn);\n if (eventData.handlers.size === 0) {\n document.removeEventListener(event, eventData.listener);\n globalEvents.delete(event);\n }\n };\n}\n\n/**\n * Handles clipboard interactions for a focusable element. Supports items of multiple\n * data types, and integrates with the operating system native clipboard.\n */\nexport function useClipboard(options: ClipboardProps): ClipboardResult {\n let {isDisabled} = options;\n let isFocusedRef = useRef(false);\n let {focusProps} = useFocus({\n onFocusChange: (isFocused) => {\n isFocusedRef.current = isFocused;\n }\n });\n\n let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {\n // Enable the \"Copy\" menu item in Safari if this element is focused and copying is supported.\n if (isFocusedRef.current && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCopy = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems());\n options.onCopy?.();\n }\n });\n\n let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {\n if (isFocusedRef.current && options.onCut && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCut = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onCut || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems());\n options.onCut();\n }\n });\n\n let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {\n // Unfortunately, e.clipboardData.types is not available in this event so we always\n // have to enable the Paste menu item even if the type of data is unsupported.\n if (isFocusedRef.current && options.onPaste) {\n e.preventDefault();\n }\n });\n\n let onPaste = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onPaste) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n let items = readFromDataTransfer(e.clipboardData);\n options.onPaste(items);\n }\n });\n\n useEffect(() => {\n if (isDisabled) {\n return;\n }\n return chain(\n addGlobalEventListener('beforecopy', onBeforeCopy),\n addGlobalEventListener('copy', onCopy),\n addGlobalEventListener('beforecut', onBeforeCut),\n addGlobalEventListener('cut', onCut),\n addGlobalEventListener('beforepaste', onBeforePaste),\n addGlobalEventListener('paste', onPaste)\n );\n }, [isDisabled, onBeforeCopy, onCopy, onBeforeCut, onCut, onBeforePaste, onPaste]);\n\n return {\n clipboardProps: focusProps\n };\n}\n"],"names":[],"version":3,"file":"useClipboard.main.js.map"}
@@ -54,11 +54,13 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
54
54
  if (isFocusedRef.current && options.getItems) e.preventDefault();
55
55
  });
56
56
  let onCopy = (0, $9Tt78$useEffectEvent)((e)=>{
57
- var _options_onCopy;
58
57
  if (!isFocusedRef.current || !options.getItems) return;
59
58
  e.preventDefault();
60
- (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
61
- (_options_onCopy = options.onCopy) === null || _options_onCopy === void 0 ? void 0 : _options_onCopy.call(options);
59
+ if (e.clipboardData) {
60
+ var _options_onCopy;
61
+ (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
62
+ (_options_onCopy = options.onCopy) === null || _options_onCopy === void 0 ? void 0 : _options_onCopy.call(options);
63
+ }
62
64
  });
63
65
  let onBeforeCut = (0, $9Tt78$useEffectEvent)((e)=>{
64
66
  if (isFocusedRef.current && options.onCut && options.getItems) e.preventDefault();
@@ -66,8 +68,10 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
66
68
  let onCut = (0, $9Tt78$useEffectEvent)((e)=>{
67
69
  if (!isFocusedRef.current || !options.onCut || !options.getItems) return;
68
70
  e.preventDefault();
69
- (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
70
- options.onCut();
71
+ if (e.clipboardData) {
72
+ (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
73
+ options.onCut();
74
+ }
71
75
  });
72
76
  let onBeforePaste = (0, $9Tt78$useEffectEvent)((e)=>{
73
77
  // Unfortunately, e.clipboardData.types is not available in this event so we always
@@ -77,8 +81,10 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
77
81
  let onPaste = (0, $9Tt78$useEffectEvent)((e)=>{
78
82
  if (!isFocusedRef.current || !options.onPaste) return;
79
83
  e.preventDefault();
80
- let items = (0, $7252cd45fc48c07c$export$d9e760437831f8b3)(e.clipboardData);
81
- options.onPaste(items);
84
+ if (e.clipboardData) {
85
+ let items = (0, $7252cd45fc48c07c$export$d9e760437831f8b3)(e.clipboardData);
86
+ options.onPaste(items);
87
+ }
82
88
  });
83
89
  (0, $9Tt78$useEffect)(()=>{
84
90
  if (isDisabled) return;
@@ -54,11 +54,13 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
54
54
  if (isFocusedRef.current && options.getItems) e.preventDefault();
55
55
  });
56
56
  let onCopy = (0, $9Tt78$useEffectEvent)((e)=>{
57
- var _options_onCopy;
58
57
  if (!isFocusedRef.current || !options.getItems) return;
59
58
  e.preventDefault();
60
- (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
61
- (_options_onCopy = options.onCopy) === null || _options_onCopy === void 0 ? void 0 : _options_onCopy.call(options);
59
+ if (e.clipboardData) {
60
+ var _options_onCopy;
61
+ (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
62
+ (_options_onCopy = options.onCopy) === null || _options_onCopy === void 0 ? void 0 : _options_onCopy.call(options);
63
+ }
62
64
  });
63
65
  let onBeforeCut = (0, $9Tt78$useEffectEvent)((e)=>{
64
66
  if (isFocusedRef.current && options.onCut && options.getItems) e.preventDefault();
@@ -66,8 +68,10 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
66
68
  let onCut = (0, $9Tt78$useEffectEvent)((e)=>{
67
69
  if (!isFocusedRef.current || !options.onCut || !options.getItems) return;
68
70
  e.preventDefault();
69
- (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
70
- options.onCut();
71
+ if (e.clipboardData) {
72
+ (0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.clipboardData, options.getItems());
73
+ options.onCut();
74
+ }
71
75
  });
72
76
  let onBeforePaste = (0, $9Tt78$useEffectEvent)((e)=>{
73
77
  // Unfortunately, e.clipboardData.types is not available in this event so we always
@@ -77,8 +81,10 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
77
81
  let onPaste = (0, $9Tt78$useEffectEvent)((e)=>{
78
82
  if (!isFocusedRef.current || !options.onPaste) return;
79
83
  e.preventDefault();
80
- let items = (0, $7252cd45fc48c07c$export$d9e760437831f8b3)(e.clipboardData);
81
- options.onPaste(items);
84
+ if (e.clipboardData) {
85
+ let items = (0, $7252cd45fc48c07c$export$d9e760437831f8b3)(e.clipboardData);
86
+ options.onPaste(items);
87
+ }
82
88
  });
83
89
  (0, $9Tt78$useEffect)(()=>{
84
90
  if (isDisabled) return;
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA0BD,MAAM,qCAAe,IAAI;AACzB,SAAS,6CAAuB,KAAK,EAAE,EAAE;IACvC,IAAI,YAAY,mCAAa,GAAG,CAAC;IACjC,IAAI,CAAC,WAAW;QACd,IAAI,WAAW,IAAI;QACnB,IAAI,WAAW,CAAC;YACd,KAAK,IAAI,WAAW,SAClB,QAAQ;QAEZ;QAEA,YAAY;sBAAC;sBAAU;QAAQ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AE,EAAE,aAAa,EAAE,QAAQ,QAAQ;QACrD,QAAQ,KAAK;IACf;IAEA,IAAI,gBAAgB,CAAA,GAAA,qBAAa,EAAE,CAAC;QAClC,mFAAmF;QACnF,8EAA8E;QAC9E,IAAI,aAAa,OAAO,IAAI,QAAQ,OAAO,EACzC,EAAE,cAAc;IAEpB;IAEA,IAAI,UAAU,CAAA,GAAA,qBAAa,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,QAAQ,OAAO,EAC3C;QAGF,EAAE,cAAc;QAChB,IAAI,QAAQ,CAAA,GAAA,yCAAmB,EAAE,EAAE,aAAa;QAChD,QAAQ,OAAO,CAAC;IAClB;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,YACF;QAEF,OAAO,CAAA,GAAA,YAAI,EACT,6CAAuB,cAAc,eACrC,6CAAuB,QAAQ,SAC/B,6CAAuB,aAAa,cACpC,6CAAuB,OAAO,QAC9B,6CAAuB,eAAe,gBACtC,6CAAuB,SAAS;IAEpC,GAAG;QAAC;QAAY;QAAc;QAAQ;QAAa;QAAO;QAAe;KAAQ;IAEjF,OAAO;QACL,gBAAgB;IAClB;AACF","sources":["packages/@react-aria/dnd/src/useClipboard.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 {chain, useEffectEvent} from '@react-aria/utils';\nimport {DOMAttributes, DragItem, DropItem} from '@react-types/shared';\nimport {readFromDataTransfer, writeToDataTransfer} from './utils';\nimport {useEffect, useRef} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface ClipboardProps {\n /** A function that returns the items to copy. */\n getItems?: () => DragItem[],\n /** Handler that is called when the user triggers a copy interaction. */\n onCopy?: () => void,\n /** Handler that is called when the user triggers a cut interaction. */\n onCut?: () => void,\n /** Handler that is called when the user triggers a paste interaction. */\n onPaste?: (items: DropItem[]) => void,\n /** Whether the clipboard is disabled. */\n isDisabled?: boolean\n}\n\nexport interface ClipboardResult {\n /** Props for the element that will handle clipboard events. */\n clipboardProps: DOMAttributes\n}\n\nconst globalEvents = new Map();\nfunction addGlobalEventListener(event, fn) {\n let eventData = globalEvents.get(event);\n if (!eventData) {\n let handlers = new Set<(e: Event) => void>();\n let listener = (e) => {\n for (let handler of handlers) {\n handler(e);\n }\n };\n\n eventData = {listener, handlers};\n globalEvents.set(event, eventData);\n\n document.addEventListener(event, listener);\n }\n\n eventData.handlers.add(fn);\n return () => {\n eventData.handlers.delete(fn);\n if (eventData.handlers.size === 0) {\n document.removeEventListener(event, eventData.listener);\n globalEvents.delete(event);\n }\n };\n}\n\n/**\n * Handles clipboard interactions for a focusable element. Supports items of multiple\n * data types, and integrates with the operating system native clipboard.\n */\nexport function useClipboard(options: ClipboardProps): ClipboardResult {\n let {isDisabled} = options;\n let isFocusedRef = useRef(false);\n let {focusProps} = useFocus({\n onFocusChange: (isFocused) => {\n isFocusedRef.current = isFocused;\n }\n });\n\n let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {\n // Enable the \"Copy\" menu item in Safari if this element is focused and copying is supported.\n if (isFocusedRef.current && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCopy = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n writeToDataTransfer(e.clipboardData, options.getItems());\n options.onCopy?.();\n });\n\n let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {\n if (isFocusedRef.current && options.onCut && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCut = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onCut || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n writeToDataTransfer(e.clipboardData, options.getItems());\n options.onCut();\n });\n\n let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {\n // Unfortunately, e.clipboardData.types is not available in this event so we always\n // have to enable the Paste menu item even if the type of data is unsupported.\n if (isFocusedRef.current && options.onPaste) {\n e.preventDefault();\n }\n });\n\n let onPaste = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onPaste) {\n return;\n }\n\n e.preventDefault();\n let items = readFromDataTransfer(e.clipboardData);\n options.onPaste(items);\n });\n\n useEffect(() => {\n if (isDisabled) {\n return;\n }\n return chain(\n addGlobalEventListener('beforecopy', onBeforeCopy),\n addGlobalEventListener('copy', onCopy),\n addGlobalEventListener('beforecut', onBeforeCut),\n addGlobalEventListener('cut', onCut),\n addGlobalEventListener('beforepaste', onBeforePaste),\n addGlobalEventListener('paste', onPaste)\n );\n }, [isDisabled, onBeforeCopy, onCopy, onBeforeCut, onCut, onBeforePaste, onPaste]);\n\n return {\n clipboardProps: focusProps\n };\n}\n"],"names":[],"version":3,"file":"useClipboard.module.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA0BD,MAAM,qCAAe,IAAI;AACzB,SAAS,6CAAuB,KAAK,EAAE,EAAE;IACvC,IAAI,YAAY,mCAAa,GAAG,CAAC;IACjC,IAAI,CAAC,WAAW;QACd,IAAI,WAAW,IAAI;QACnB,IAAI,WAAW,CAAC;YACd,KAAK,IAAI,WAAW,SAClB,QAAQ;QAEZ;QAEA,YAAY;sBAAC;sBAAU;QAAQ;QAC/B,mCAAa,GAAG,CAAC,OAAO;QAExB,SAAS,gBAAgB,CAAC,OAAO;IACnC;IAEA,UAAU,QAAQ,CAAC,GAAG,CAAC;IACvB,OAAO;QACL,UAAU,QAAQ,CAAC,MAAM,CAAC;QAC1B,IAAI,UAAU,QAAQ,CAAC,IAAI,KAAK,GAAG;YACjC,SAA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,IAAI,aAAa,OAAO,IAAI,QAAQ,OAAO,EACzC,EAAE,cAAc;IAEpB;IAEA,IAAI,UAAU,CAAA,GAAA,qBAAa,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,OAAO,IAAI,CAAC,QAAQ,OAAO,EAC3C;QAGF,EAAE,cAAc;QAChB,IAAI,EAAE,aAAa,EAAE;YACnB,IAAI,QAAQ,CAAA,GAAA,yCAAmB,EAAE,EAAE,aAAa;YAChD,QAAQ,OAAO,CAAC;QAClB;IACF;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,YACF;QAEF,OAAO,CAAA,GAAA,YAAI,EACT,6CAAuB,cAAc,eACrC,6CAAuB,QAAQ,SAC/B,6CAAuB,aAAa,cACpC,6CAAuB,OAAO,QAC9B,6CAAuB,eAAe,gBACtC,6CAAuB,SAAS;IAEpC,GAAG;QAAC;QAAY;QAAc;QAAQ;QAAa;QAAO;QAAe;KAAQ;IAEjF,OAAO;QACL,gBAAgB;IAClB;AACF","sources":["packages/@react-aria/dnd/src/useClipboard.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 {chain, useEffectEvent} from '@react-aria/utils';\nimport {DOMAttributes, DragItem, DropItem} from '@react-types/shared';\nimport {readFromDataTransfer, writeToDataTransfer} from './utils';\nimport {useEffect, useRef} from 'react';\nimport {useFocus} from '@react-aria/interactions';\n\nexport interface ClipboardProps {\n /** A function that returns the items to copy. */\n getItems?: () => DragItem[],\n /** Handler that is called when the user triggers a copy interaction. */\n onCopy?: () => void,\n /** Handler that is called when the user triggers a cut interaction. */\n onCut?: () => void,\n /** Handler that is called when the user triggers a paste interaction. */\n onPaste?: (items: DropItem[]) => void,\n /** Whether the clipboard is disabled. */\n isDisabled?: boolean\n}\n\nexport interface ClipboardResult {\n /** Props for the element that will handle clipboard events. */\n clipboardProps: DOMAttributes\n}\n\nconst globalEvents = new Map();\nfunction addGlobalEventListener(event, fn) {\n let eventData = globalEvents.get(event);\n if (!eventData) {\n let handlers = new Set<(e: Event) => void>();\n let listener = (e) => {\n for (let handler of handlers) {\n handler(e);\n }\n };\n\n eventData = {listener, handlers};\n globalEvents.set(event, eventData);\n\n document.addEventListener(event, listener);\n }\n\n eventData.handlers.add(fn);\n return () => {\n eventData.handlers.delete(fn);\n if (eventData.handlers.size === 0) {\n document.removeEventListener(event, eventData.listener);\n globalEvents.delete(event);\n }\n };\n}\n\n/**\n * Handles clipboard interactions for a focusable element. Supports items of multiple\n * data types, and integrates with the operating system native clipboard.\n */\nexport function useClipboard(options: ClipboardProps): ClipboardResult {\n let {isDisabled} = options;\n let isFocusedRef = useRef(false);\n let {focusProps} = useFocus({\n onFocusChange: (isFocused) => {\n isFocusedRef.current = isFocused;\n }\n });\n\n let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {\n // Enable the \"Copy\" menu item in Safari if this element is focused and copying is supported.\n if (isFocusedRef.current && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCopy = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems());\n options.onCopy?.();\n }\n });\n\n let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {\n if (isFocusedRef.current && options.onCut && options.getItems) {\n e.preventDefault();\n }\n });\n\n let onCut = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onCut || !options.getItems) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n writeToDataTransfer(e.clipboardData, options.getItems());\n options.onCut();\n }\n });\n\n let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {\n // Unfortunately, e.clipboardData.types is not available in this event so we always\n // have to enable the Paste menu item even if the type of data is unsupported.\n if (isFocusedRef.current && options.onPaste) {\n e.preventDefault();\n }\n });\n\n let onPaste = useEffectEvent((e: ClipboardEvent) => {\n if (!isFocusedRef.current || !options.onPaste) {\n return;\n }\n\n e.preventDefault();\n if (e.clipboardData) {\n let items = readFromDataTransfer(e.clipboardData);\n options.onPaste(items);\n }\n });\n\n useEffect(() => {\n if (isDisabled) {\n return;\n }\n return chain(\n addGlobalEventListener('beforecopy', onBeforeCopy),\n addGlobalEventListener('copy', onCopy),\n addGlobalEventListener('beforecut', onBeforeCut),\n addGlobalEventListener('cut', onCut),\n addGlobalEventListener('beforepaste', onBeforePaste),\n addGlobalEventListener('paste', onPaste)\n );\n }, [isDisabled, onBeforeCopy, onCopy, onBeforeCut, onCut, onBeforePaste, onPaste]);\n\n return {\n clipboardProps: focusProps\n };\n}\n"],"names":[],"version":3,"file":"useClipboard.module.js.map"}
@@ -94,6 +94,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
94
94
  // If there is a preview option, use it to render a custom preview image that will
95
95
  // appear under the pointer while dragging. If not, the element itself is dragged by the browser.
96
96
  if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === 'function') options.preview.current(items, (node)=>{
97
+ if (!node) return;
97
98
  // Compute the offset that the preview will appear under the mouse.
98
99
  // If possible, this is based on the point the user clicked on the target.
99
100
  // If the preview is much smaller, then just use the center point of the preview.
@@ -160,7 +161,6 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
160
161
  };
161
162
  // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
162
163
  // In this case, we need to manually call onDragEnd on cleanup
163
- // eslint-disable-next-line arrow-body-style
164
164
  (0, $3w36N$reactariautils.useLayoutEffect)(()=>{
165
165
  return ()=>{
166
166
  if (isDraggingRef.current) {
@@ -212,7 +212,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
212
212
  let modality = (0, $4620ae0dc40f0031$exports.useDragModality)();
213
213
  let message = !isDragging ? $dc204e8ec58447a6$var$MESSAGES[modality].start : $dc204e8ec58447a6$var$MESSAGES[modality].end;
214
214
  let descriptionProps = (0, $3w36N$reactariautils.useDescription)(stringFormatter.format(message));
215
- let interactions;
215
+ let interactions = {};
216
216
  if (!hasDragButton) // If there's no separate button to trigger accessible drag and drop mode,
217
217
  // then add event handlers to the draggable element itself to start dragging.
218
218
  // For keyboard, we use the Enter key in a capturing listener to prevent other
@@ -1 +1 @@
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,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAAE;iBACjB;QACA,GAAG;QACH,GAAG;IACL,GAAG,OAAO;IACV,MAAM,OAAO,GAAG;IAChB,IAAI,gBAAgB,CAAA,GAAA,mBAAK,EAAE;IAC3B,IAAI,CAAC,YAAY,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC9C,IAAI,cAAc,CAAC;QACjB,cAAc,OAAO,GAAG;QACxB,iBAAiB;IACnB;IACA,IAAI,qBAAC,iBAAiB,4BAAE,wBAAwB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IACrE,IAAI,wBAAwB,CAAA,GAAA,mBAAK,EAAU;IAE3C,IAAI,cAAc,C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,IAAI,EAAE,MAAM,KAAK,EAAE,aAAa,IAAI,EAAE,GAAG,KAAK,SAAS;gBACrD,EAAE,cAAc;gBAChB,EAAE,eAAe;YACnB;QACF;QACA,gBAAe,CAAC;YACd,IAAI,EAAE,MAAM,KAAK,EAAE,aAAa,IAAI,EAAE,GAAG,KAAK,SAAS;gBACrD,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,cAAc,EAAE,MAAM;YACxB;QACF;QACA,SAAQ,CAAC;YACP,yGAAyG;YACzG,IAAI,CAAA,GAAA,oCAAa,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, 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, useLayoutEffect} 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(false);\n let [isDragging, setDraggingState] = useState(false);\n let setDragging = (isDragging) => {\n isDraggingRef.current = isDragging;\n setDraggingState(isDragging);\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 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 e.dataTransfer.effectAllowed = EFFECT_ALLOWED[allowed] || 'none';\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 => {\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 x = e.clientX - rect.x;\n let y = e.clientY - rect.y;\n if (x > size.width || y > size.height) {\n x = size.width / 2;\n y = size.height / 2;\n }\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, x, y);\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 requestAnimationFrame(() => {\n setDragging(true);\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(false);\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 // eslint-disable-next-line arrow-body-style\n useLayoutEffect(() => {\n return () => {\n if (isDraggingRef.current) {\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(false);\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(false);\n if (typeof state.options.onDragEnd === 'function') {\n state.options.onDragEnd(e);\n }\n }\n }, stringFormatter);\n\n setDragging(true);\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.main.js.map"}
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,gDAA0B,EAAE,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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, 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, useLayoutEffect} 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(false);\n let [isDragging, setDraggingState] = useState(false);\n let setDragging = (isDragging) => {\n isDraggingRef.current = isDragging;\n setDraggingState(isDragging);\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 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 e.dataTransfer.effectAllowed = EFFECT_ALLOWED[allowed] || 'none';\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 => {\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 x = e.clientX - rect.x;\n let y = e.clientY - rect.y;\n if (x > size.width || y > size.height) {\n x = size.width / 2;\n y = size.height / 2;\n }\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, x, y);\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 requestAnimationFrame(() => {\n setDragging(true);\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(false);\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 useLayoutEffect(() => {\n return () => {\n if (isDraggingRef.current) {\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(false);\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(false);\n if (typeof state.options.onDragEnd === 'function') {\n state.options.onDragEnd(e);\n }\n }\n }, stringFormatter);\n\n setDragging(true);\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.main.js.map"}
package/dist/useDrag.mjs CHANGED
@@ -88,6 +88,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
88
88
  // If there is a preview option, use it to render a custom preview image that will
89
89
  // appear under the pointer while dragging. If not, the element itself is dragged by the browser.
90
90
  if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === 'function') options.preview.current(items, (node)=>{
91
+ if (!node) return;
91
92
  // Compute the offset that the preview will appear under the mouse.
92
93
  // If possible, this is based on the point the user clicked on the target.
93
94
  // If the preview is much smaller, then just use the center point of the preview.
@@ -154,7 +155,6 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
154
155
  };
155
156
  // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
156
157
  // In this case, we need to manually call onDragEnd on cleanup
157
- // eslint-disable-next-line arrow-body-style
158
158
  (0, $72Evg$useLayoutEffect)(()=>{
159
159
  return ()=>{
160
160
  if (isDraggingRef.current) {
@@ -206,7 +206,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
206
206
  let modality = (0, $7252cd45fc48c07c$export$49bac5d6d4b352ea)();
207
207
  let message = !isDragging ? $8253ed7ece74b463$var$MESSAGES[modality].start : $8253ed7ece74b463$var$MESSAGES[modality].end;
208
208
  let descriptionProps = (0, $72Evg$useDescription)(stringFormatter.format(message));
209
- let interactions;
209
+ let interactions = {};
210
210
  if (!hasDragButton) // If there's no separate button to trigger accessible drag and drop mode,
211
211
  // then add event handlers to the draggable element itself to start dragging.
212
212
  // For keyboard, we use the Enter key in a capturing listener to prevent other
@@ -88,6 +88,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
88
88
  // If there is a preview option, use it to render a custom preview image that will
89
89
  // appear under the pointer while dragging. If not, the element itself is dragged by the browser.
90
90
  if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === 'function') options.preview.current(items, (node)=>{
91
+ if (!node) return;
91
92
  // Compute the offset that the preview will appear under the mouse.
92
93
  // If possible, this is based on the point the user clicked on the target.
93
94
  // If the preview is much smaller, then just use the center point of the preview.
@@ -154,7 +155,6 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
154
155
  };
155
156
  // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
156
157
  // In this case, we need to manually call onDragEnd on cleanup
157
- // eslint-disable-next-line arrow-body-style
158
158
  (0, $72Evg$useLayoutEffect)(()=>{
159
159
  return ()=>{
160
160
  if (isDraggingRef.current) {
@@ -206,7 +206,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
206
206
  let modality = (0, $7252cd45fc48c07c$export$49bac5d6d4b352ea)();
207
207
  let message = !isDragging ? $8253ed7ece74b463$var$MESSAGES[modality].start : $8253ed7ece74b463$var$MESSAGES[modality].end;
208
208
  let descriptionProps = (0, $72Evg$useDescription)(stringFormatter.format(message));
209
- let interactions;
209
+ let interactions = {};
210
210
  if (!hasDragButton) // If there's no separate button to trigger accessible drag and drop mode,
211
211
  // then add event handlers to the draggable element itself to start dragging.
212
212
  // For keyboard, we use the Enter key in a capturing listener to prevent other