@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
@@ -16,12 +16,12 @@ import {useInteractionModality as $j62BV$useInteractionModality, getInteractionM
16
16
  const $7252cd45fc48c07c$export$dfdf5deeaf27473f = new WeakMap();
17
17
  const $7252cd45fc48c07c$export$990fced5dfac2637 = Symbol();
18
18
  function $7252cd45fc48c07c$export$3093291712f09a77(state) {
19
- let { id: id } = $7252cd45fc48c07c$export$dfdf5deeaf27473f.get(state);
19
+ let { id: id } = $7252cd45fc48c07c$export$dfdf5deeaf27473f.get(state) || {};
20
20
  if (!id) throw new Error('Droppable item outside a droppable collection');
21
21
  return id;
22
22
  }
23
23
  function $7252cd45fc48c07c$export$7e397efd01d3db27(state) {
24
- let { ref: ref } = $7252cd45fc48c07c$export$dfdf5deeaf27473f.get(state);
24
+ let { ref: ref } = $7252cd45fc48c07c$export$dfdf5deeaf27473f.get(state) || {};
25
25
  if (!ref) throw new Error('Droppable item outside a droppable collection');
26
26
  return ref;
27
27
  }
@@ -111,6 +111,7 @@ class $7252cd45fc48c07c$export$7f04ce188c91447c {
111
111
  }
112
112
  function $7252cd45fc48c07c$export$d9e760437831f8b3(dataTransfer) {
113
113
  let items = [];
114
+ if (!dataTransfer) return items;
114
115
  // If our custom drag type is available, use that. This is a JSON serialized
115
116
  // representation of all items in the drag, set when there are multiple items
116
117
  // of the same type, or an individual item has multiple representations.
@@ -124,7 +125,7 @@ function $7252cd45fc48c07c$export$d9e760437831f8b3(dataTransfer) {
124
125
  getText: (type)=>Promise.resolve(item[type])
125
126
  });
126
127
  hasCustomType = true;
127
- } catch (e) {
128
+ } catch {
128
129
  // ignore
129
130
  }
130
131
  // Otherwise, map native drag items to items of a single representation.
@@ -173,6 +174,7 @@ function $7252cd45fc48c07c$var$blobToString(blob) {
173
174
  });
174
175
  }
175
176
  function $7252cd45fc48c07c$var$createFileItem(file) {
177
+ if (!file) throw new Error('No file provided');
176
178
  return {
177
179
  kind: 'file',
178
180
  type: file.type || (0, $103790afe9474d1c$export$f8fc6581787339b3),
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAYM,MAAM,4CAAyB,IAAI;AACnC,MAAM,4CAAsB;AAE5B,SAAS,0CAAyB,KAA+B;IACtE,IAAI,MAAC,EAAE,EAAC,GAAG,0CAAuB,GAAG,CAAC;IACtC,IAAI,CAAC,IACH,MAAM,IAAI,MAAM;IAGlB,OAAO;AACT;AAEO,SAAS,0CAA0B,KAA+B;IACvE,IAAI,OAAC,GAAG,EAAC,GAAG,0CAAuB,GAAG,CAAC;IACvC,IAAI,CAAC,KACH,MAAM,IAAI,MAAM;IAGlB,OAAO;AACT;AAEO,SAAS,0CAAS,KAAiB;IACxC,IAAI,QAAQ,IAAI;IAChB,KAAK,IAAI,QAAQ,MACf,KAAK,IAAI,QAAQ,OAAO,IAAI,CAAC,MAC3B,MAAM,GAAG,CAAC;IAId,OAAO;AACT;AAEA,SAAS,kCAAY,QAAgB;IACnC,IAAI,CAAC,UACH,WAAW;IAGb,IAAI,aAAa,WACf,WAAW;IAGb,IAAI,aAAa,aAAe,OAAO,WAAW,eAAe,kBAAkB,QACjF,WAAW;IAGb,OAAO;AACT;AAEO,SAAS;IACd,OAAO,kCAAY,CAAA,GAAA,6BAAqB;AAC1C;AAE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;AAEO,SAAS;IACd,4CAAiB;QAAC,cAAc,IAAI;IAAK;AAC3C;AAEO,SAAS,0CAAkB,KAAe;IAC/C,4CAAiB;AACnB;AAIO,SAAS,0CAAwB,GAAmC;IACzE,IAAI,yBAAC,qBAAqB,qBAAE,iBAAiB,EAAC,GAAG;IACjD,OAAO,CAAA,kCAAA,4CAAA,sBAAuB,OAAO,KAAI,QAAQ,sBAAsB,OAAO,KAAM,CAAA,CAAA,gBAAA,0BAAA,IAAK,OAAO,MAAI,8BAAA,wCAAA,kBAAmB,OAAO,CAAD;AAC/H;AAGO,IAAI;AACJ,SAAS,0CAAoB,UAAsB;IACxD,4CAAmB;AACrB;AAEO,IAAI,4CAA8B,CAAA,GAAA,yCAAa,EAAE,IAAI;AACrD,SAAS,0CAA+B,CAAiB;IAC9D,4CAA8B;AAChC","sources":["packages/@react-aria/dnd/src/utils.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 {CUSTOM_DRAG_TYPE, DROP_OPERATION, GENERIC_TYPE, NATIVE_DRAG_TYPES} from './constants';\nimport {DirectoryDropItem, DragItem, DropItem, FileDropItem, DragTypes as IDragTypes, Key, RefObject, TextDropItem} from '@react-types/shared';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {getInteractionModality, useInteractionModality} from '@react-aria/interactions';\n\ninterface DroppableCollectionMap {\n id: string,\n ref: RefObject<HTMLElement | null>\n}\n\nexport const droppableCollectionMap = new WeakMap<DroppableCollectionState, DroppableCollectionMap>();\nexport const DIRECTORY_DRAG_TYPE = Symbol();\n\nexport function getDroppableCollectionId(state: DroppableCollectionState) {\n let {id} = droppableCollectionMap.get(state);\n if (!id) {\n throw new Error('Droppable item outside a droppable collection');\n }\n\n return id;\n}\n\nexport function getDroppableCollectionRef(state: DroppableCollectionState) {\n let {ref} = droppableCollectionMap.get(state);\n if (!ref) {\n throw new Error('Droppable item outside a droppable collection');\n }\n\n return ref;\n}\n\nexport function getTypes(items: DragItem[]): Set<string> {\n let types = new Set<string>();\n for (let item of items) {\n for (let type of Object.keys(item)) {\n types.add(type);\n }\n }\n\n return types;\n}\n\nfunction mapModality(modality: string) {\n if (!modality) {\n modality = 'virtual';\n }\n\n if (modality === 'pointer') {\n modality = 'virtual';\n }\n\n if (modality === 'virtual' && (typeof window !== 'undefined' && 'ontouchstart' in window)) {\n modality = 'touch';\n }\n\n return modality;\n}\n\nexport function useDragModality() {\n return mapModality(useInteractionModality());\n}\n\nexport function getDragModality() {\n return mapModality(getInteractionModality());\n}\n\nexport function writeToDataTransfer(dataTransfer: DataTransfer, items: DragItem[]) {\n // The data transfer API doesn't support more than one item of a given type at once.\n // In addition, only a small set of types are supported natively for transfer between applications.\n // We allow for both multiple items, as well as multiple representations of a single item.\n // In order to make our API work with the native API, we serialize all items to JSON and\n // store as a single native item. We only need to do this if there is more than one item\n // of the same type, or if an item has more than one representation. Otherwise the native\n // API is sufficient.\n //\n // The DataTransferItemList API also theoretically supports adding files, which would enable\n // dragging binary data out of the browser onto the user's desktop for example. Unfortunately,\n // this does not currently work in any browser, so it is not currently supported by our API.\n // See e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=438479.\n let groupedByType = new Map<string, string[]>();\n let needsCustomData = false;\n let customData = [];\n for (let item of items) {\n let types = Object.keys(item);\n if (types.length > 1) {\n needsCustomData = true;\n }\n\n let dataByType = {};\n for (let type of types) {\n let typeItems = groupedByType.get(type);\n if (!typeItems) {\n typeItems = [];\n groupedByType.set(type, typeItems);\n } else {\n needsCustomData = true;\n }\n\n let data = item[type];\n dataByType[type] = data;\n typeItems.push(data);\n }\n\n customData.push(dataByType);\n }\n\n for (let [type, items] of groupedByType) {\n if (NATIVE_DRAG_TYPES.has(type)) {\n // Only one item of a given type can be set on a data transfer.\n // Join all of the items together separated by newlines.\n let data = items.join('\\n');\n dataTransfer.items.add(data, type);\n } else {\n // Set data to the first item so we have access to the list of types.\n dataTransfer.items.add(items[0], type);\n }\n }\n\n if (needsCustomData) {\n let data = JSON.stringify(customData);\n dataTransfer.items.add(data, CUSTOM_DRAG_TYPE);\n }\n}\n\nexport class DragTypes implements IDragTypes {\n private types: Set<string>;\n private includesUnknownTypes: boolean;\n\n constructor(dataTransfer: DataTransfer) {\n this.types = new Set<string>();\n\n let hasFiles = false;\n for (let item of dataTransfer.items) {\n if (item.type !== CUSTOM_DRAG_TYPE) {\n if (item.kind === 'file') {\n hasFiles = true;\n }\n\n if (item.type) {\n this.types.add(item.type);\n } else {\n // Files with unknown types or extensions that don't map to a known mime type\n // are sometimes exposed as an empty string by the browser. Map to a generic\n // mime type instead. Note that this could also be a directory as there's no\n // way to determine if something is a file or directory until drop.\n this.types.add(GENERIC_TYPE);\n }\n }\n }\n\n // In Safari, when dragging files, the dataTransfer.items list is empty, but dataTransfer.types contains \"Files\".\n // Unfortunately, this doesn't tell us what types of files the user is dragging, so we need to assume that any\n // type the user checks for is included. See https://bugs.webkit.org/show_bug.cgi?id=223517.\n this.includesUnknownTypes = !hasFiles && dataTransfer.types.includes('Files');\n }\n\n has(type: string | symbol) {\n if (this.includesUnknownTypes || (type === DIRECTORY_DRAG_TYPE && this.types.has(GENERIC_TYPE))) {\n return true;\n }\n\n return typeof type === 'string' && this.types.has(type);\n }\n}\n\nexport function readFromDataTransfer(dataTransfer: DataTransfer) {\n let items: DropItem[] = [];\n\n // If our custom drag type is available, use that. This is a JSON serialized\n // representation of all items in the drag, set when there are multiple items\n // of the same type, or an individual item has multiple representations.\n let hasCustomType = false;\n if (dataTransfer.types.includes(CUSTOM_DRAG_TYPE)) {\n try {\n let data = dataTransfer.getData(CUSTOM_DRAG_TYPE);\n let parsed = JSON.parse(data);\n for (let item of parsed) {\n items.push({\n kind: 'text',\n types: new Set(Object.keys(item)),\n getText: (type) => Promise.resolve(item[type])\n });\n }\n\n hasCustomType = true;\n } catch (e) {\n // ignore\n }\n }\n\n // Otherwise, map native drag items to items of a single representation.\n if (!hasCustomType) {\n let stringItems = new Map();\n for (let item of dataTransfer.items) {\n if (item.kind === 'string') {\n // The data for all formats must be read here because the data transfer gets\n // cleared out after the event handler finishes. If the item has an empty string\n // as a type, the mime type is unknown. Map to a generic mime type instead.\n stringItems.set(item.type || GENERIC_TYPE, dataTransfer.getData(item.type));\n } else if (item.kind === 'file') {\n // Despite the name, webkitGetAsEntry is also implemented in Firefox and Edge.\n // In the future, we may use getAsFileSystemHandle instead, but that's currently\n // only implemented in Chrome.\n if (typeof item.webkitGetAsEntry === 'function') {\n let entry: FileSystemEntry = item.webkitGetAsEntry();\n // eslint-disable-next-line max-depth\n if (!entry) {\n // For some reason, Firefox includes an item with type image/png when copy\n // and pasting any file or directory (no matter the type), but returns `null` for both\n // item.getAsFile() and item.webkitGetAsEntry(). Safari works as expected. Ignore this\n // item if this happens. See https://bugzilla.mozilla.org/show_bug.cgi?id=1699743.\n // This was recently fixed in Chrome Canary: https://bugs.chromium.org/p/chromium/issues/detail?id=1175483.\n continue;\n }\n\n // eslint-disable-next-line max-depth\n if (entry.isFile) {\n items.push(createFileItem(item.getAsFile()));\n } else if (entry.isDirectory) {\n items.push(createDirectoryItem(entry));\n }\n } else {\n // Assume it's a file.\n items.push(createFileItem(item.getAsFile()));\n }\n }\n }\n\n // All string items are different representations of the same item. There's no way to have\n // multiple string items at once in the current DataTransfer API.\n if (stringItems.size > 0) {\n items.push({\n kind: 'text',\n types: new Set(stringItems.keys()),\n getText: (type) => Promise.resolve(stringItems.get(type))\n });\n }\n }\n\n return items;\n}\n\nfunction blobToString(blob: Blob): Promise<string> {\n if (typeof blob.text === 'function') {\n return blob.text();\n }\n\n // Safari doesn't have the Blob#text() method yet...\n return new Promise((resolve, reject) => {\n let reader = new FileReader;\n reader.onload = () => {\n resolve(reader.result as string);\n };\n\n reader.onerror = reject;\n reader.readAsText(blob);\n });\n}\n\nfunction createFileItem(file: File): FileDropItem {\n return {\n kind: 'file',\n type: file.type || GENERIC_TYPE,\n name: file.name,\n getText: () => blobToString(file),\n getFile: () => Promise.resolve(file)\n };\n}\n\nfunction createDirectoryItem(entry: any): DirectoryDropItem {\n return {\n kind: 'directory',\n name: entry.name,\n getEntries: () => getEntries(entry)\n };\n}\n\nasync function *getEntries(item: FileSystemDirectoryEntry): AsyncIterable<FileDropItem | DirectoryDropItem> {\n let reader = item.createReader();\n\n // We must call readEntries repeatedly because there may be a limit to the\n // number of entries that are returned at once.\n let entries: FileSystemEntry[];\n do {\n entries = await new Promise((resolve, reject) => {\n reader.readEntries(resolve, reject);\n });\n\n for (let entry of entries) {\n if (entry.isFile) {\n let file = await getEntryFile(entry as FileSystemFileEntry);\n yield createFileItem(file);\n } else if (entry.isDirectory) {\n yield createDirectoryItem(entry);\n }\n }\n } while (entries.length > 0);\n}\n\nfunction getEntryFile(entry: FileSystemFileEntry): Promise<File> {\n return new Promise((resolve, reject) => entry.file(resolve, reject));\n}\n\n/** Returns whether a drop item contains text data. */\nexport function isTextDropItem(dropItem: DropItem): dropItem is TextDropItem {\n return dropItem.kind === 'text';\n}\n\n/** Returns whether a drop item is a file. */\nexport function isFileDropItem(dropItem: DropItem): dropItem is FileDropItem {\n return dropItem.kind === 'file';\n}\n\n/** Returns whether a drop item is a directory. */\nexport function isDirectoryDropItem(dropItem: DropItem): dropItem is DirectoryDropItem {\n return dropItem.kind === 'directory';\n}\n\n// Global DnD collection state tracker.\nexport interface DnDState {\n /** A ref for the of the drag items in the current drag session if any. */\n draggingCollectionRef?: RefObject<HTMLElement | null>,\n /** The set of currently dragged keys. */\n draggingKeys: Set<Key>,\n /** A ref for the collection that is targeted for a drop operation, if any. */\n dropCollectionRef?: RefObject<HTMLElement | null>\n}\n\nexport let globalDndState: DnDState = {draggingKeys: new Set()};\n\nexport function setDraggingCollectionRef(ref: RefObject<HTMLElement | null>) {\n globalDndState.draggingCollectionRef = ref;\n}\n\nexport function setDraggingKeys(keys: Set<Key>) {\n globalDndState.draggingKeys = keys;\n}\n\nexport function setDropCollectionRef(ref: RefObject<HTMLElement | null>) {\n globalDndState.dropCollectionRef = ref;\n}\n\nexport function clearGlobalDnDState() {\n globalDndState = {draggingKeys: new Set()};\n}\n\nexport function setGlobalDnDState(state: DnDState) {\n globalDndState = state;\n}\n\n// Util function to check if the current dragging collection ref is the same as the current targeted droppable collection ref.\n// Allows a droppable ref arg in case the global drop collection ref hasn't been set\nexport function isInternalDropOperation(ref?: RefObject<HTMLElement | null>) {\n let {draggingCollectionRef, dropCollectionRef} = globalDndState;\n return draggingCollectionRef?.current != null && draggingCollectionRef.current === (ref?.current || dropCollectionRef?.current);\n}\n\ntype DropEffect = 'none' | 'copy' | 'link' | 'move';\nexport let globalDropEffect: DropEffect;\nexport function setGlobalDropEffect(dropEffect: DropEffect) {\n globalDropEffect = dropEffect;\n}\n\nexport let globalAllowedDropOperations = DROP_OPERATION.none;\nexport function setGlobalAllowedDropOperations(o: DROP_OPERATION) {\n globalAllowedDropOperations = o;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAYM,MAAM,4CAAyB,IAAI;AACnC,MAAM,4CAAsB;AAE5B,SAAS,0CAAyB,KAA+B;IACtE,IAAI,MAAC,EAAE,EAAC,GAAG,0CAAuB,GAAG,CAAC,UAAU,CAAC;IACjD,IAAI,CAAC,IACH,MAAM,IAAI,MAAM;IAGlB,OAAO;AACT;AAEO,SAAS,0CAA0B,KAA+B;IACvE,IAAI,OAAC,GAAG,EAAC,GAAG,0CAAuB,GAAG,CAAC,UAAU,CAAC;IAClD,IAAI,CAAC,KACH,MAAM,IAAI,MAAM;IAGlB,OAAO;AACT;AAEO,SAAS,0C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AAC,SAAS;AAC9D;AAGO,SAAS,0CAAe,QAAkB;IAC/C,OAAO,SAAS,IAAI,KAAK;AAC3B;AAGO,SAAS,yCAAe,QAAkB;IAC/C,OAAO,SAAS,IAAI,KAAK;AAC3B;AAGO,SAAS,0CAAoB,QAAkB;IACpD,OAAO,SAAS,IAAI,KAAK;AAC3B;AAYO,IAAI,4CAA2B;IAAC,cAAc,IAAI;AAAK;AAEvD,SAAS,0CAAyB,GAAkC;IACzE,0CAAe,qBAAqB,GAAG;AACzC;AAEO,SAAS,0CAAgB,IAAc;IAC5C,0CAAe,YAAY,GAAG;AAChC;AAEO,SAAS,0CAAqB,GAAmC;IACtE,0CAAe,iBAAiB,GAAG;AACrC;AAEO,SAAS;IACd,4CAAiB;QAAC,cAAc,IAAI;IAAK;AAC3C;AAEO,SAAS,0CAAkB,KAAe;IAC/C,4CAAiB;AACnB;AAIO,SAAS,0CAAwB,GAAmC;IACzE,IAAI,yBAAC,qBAAqB,qBAAE,iBAAiB,EAAC,GAAG;IACjD,OAAO,CAAA,kCAAA,4CAAA,sBAAuB,OAAO,KAAI,QAAQ,sBAAsB,OAAO,KAAM,CAAA,CAAA,gBAAA,0BAAA,IAAK,OAAO,MAAI,8BAAA,wCAAA,kBAAmB,OAAO,CAAD;AAC/H;AAGO,IAAI;AACJ,SAAS,0CAAoB,UAAkC;IACpE,4CAAmB;AACrB;AAEO,IAAI,4CAA8B,CAAA,GAAA,yCAAa,EAAE,IAAI;AACrD,SAAS,0CAA+B,CAAiB;IAC9D,4CAA8B;AAChC","sources":["packages/@react-aria/dnd/src/utils.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 {CUSTOM_DRAG_TYPE, DROP_OPERATION, GENERIC_TYPE, NATIVE_DRAG_TYPES} from './constants';\nimport {DirectoryDropItem, DragItem, DropItem, FileDropItem, DragTypes as IDragTypes, Key, RefObject, TextDropItem} from '@react-types/shared';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {getInteractionModality, useInteractionModality} from '@react-aria/interactions';\n\ninterface DroppableCollectionMap {\n id: string,\n ref: RefObject<HTMLElement | null>\n}\n\nexport const droppableCollectionMap = new WeakMap<DroppableCollectionState, DroppableCollectionMap>();\nexport const DIRECTORY_DRAG_TYPE = Symbol();\n\nexport function getDroppableCollectionId(state: DroppableCollectionState) {\n let {id} = droppableCollectionMap.get(state) || {};\n if (!id) {\n throw new Error('Droppable item outside a droppable collection');\n }\n\n return id;\n}\n\nexport function getDroppableCollectionRef(state: DroppableCollectionState) {\n let {ref} = droppableCollectionMap.get(state) || {};\n if (!ref) {\n throw new Error('Droppable item outside a droppable collection');\n }\n\n return ref;\n}\n\nexport function getTypes(items: DragItem[]): Set<string> {\n let types = new Set<string>();\n for (let item of items) {\n for (let type of Object.keys(item)) {\n types.add(type);\n }\n }\n\n return types;\n}\n\nfunction mapModality(modality: string | null) {\n if (!modality) {\n modality = 'virtual';\n }\n\n if (modality === 'pointer') {\n modality = 'virtual';\n }\n\n if (modality === 'virtual' && (typeof window !== 'undefined' && 'ontouchstart' in window)) {\n modality = 'touch';\n }\n\n return modality;\n}\n\nexport function useDragModality() {\n return mapModality(useInteractionModality());\n}\n\nexport function getDragModality() {\n return mapModality(getInteractionModality());\n}\n\nexport function writeToDataTransfer(dataTransfer: DataTransfer, items: DragItem[]) {\n // The data transfer API doesn't support more than one item of a given type at once.\n // In addition, only a small set of types are supported natively for transfer between applications.\n // We allow for both multiple items, as well as multiple representations of a single item.\n // In order to make our API work with the native API, we serialize all items to JSON and\n // store as a single native item. We only need to do this if there is more than one item\n // of the same type, or if an item has more than one representation. Otherwise the native\n // API is sufficient.\n //\n // The DataTransferItemList API also theoretically supports adding files, which would enable\n // dragging binary data out of the browser onto the user's desktop for example. Unfortunately,\n // this does not currently work in any browser, so it is not currently supported by our API.\n // See e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=438479.\n let groupedByType = new Map<string, string[]>();\n let needsCustomData = false;\n let customData: Array<{}> = [];\n for (let item of items) {\n let types = Object.keys(item);\n if (types.length > 1) {\n needsCustomData = true;\n }\n\n let dataByType = {};\n for (let type of types) {\n let typeItems = groupedByType.get(type);\n if (!typeItems) {\n typeItems = [];\n groupedByType.set(type, typeItems);\n } else {\n needsCustomData = true;\n }\n\n let data = item[type];\n dataByType[type] = data;\n typeItems.push(data);\n }\n\n customData.push(dataByType);\n }\n\n for (let [type, items] of groupedByType) {\n if (NATIVE_DRAG_TYPES.has(type)) {\n // Only one item of a given type can be set on a data transfer.\n // Join all of the items together separated by newlines.\n let data = items.join('\\n');\n dataTransfer.items.add(data, type);\n } else {\n // Set data to the first item so we have access to the list of types.\n dataTransfer.items.add(items[0], type);\n }\n }\n\n if (needsCustomData) {\n let data = JSON.stringify(customData);\n dataTransfer.items.add(data, CUSTOM_DRAG_TYPE);\n }\n}\n\nexport class DragTypes implements IDragTypes {\n private types: Set<string>;\n private includesUnknownTypes: boolean;\n\n constructor(dataTransfer: DataTransfer) {\n this.types = new Set<string>();\n\n let hasFiles = false;\n for (let item of dataTransfer.items) {\n if (item.type !== CUSTOM_DRAG_TYPE) {\n if (item.kind === 'file') {\n hasFiles = true;\n }\n\n if (item.type) {\n this.types.add(item.type);\n } else {\n // Files with unknown types or extensions that don't map to a known mime type\n // are sometimes exposed as an empty string by the browser. Map to a generic\n // mime type instead. Note that this could also be a directory as there's no\n // way to determine if something is a file or directory until drop.\n this.types.add(GENERIC_TYPE);\n }\n }\n }\n\n // In Safari, when dragging files, the dataTransfer.items list is empty, but dataTransfer.types contains \"Files\".\n // Unfortunately, this doesn't tell us what types of files the user is dragging, so we need to assume that any\n // type the user checks for is included. See https://bugs.webkit.org/show_bug.cgi?id=223517.\n this.includesUnknownTypes = !hasFiles && dataTransfer.types.includes('Files');\n }\n\n has(type: string | symbol) {\n if (this.includesUnknownTypes || (type === DIRECTORY_DRAG_TYPE && this.types.has(GENERIC_TYPE))) {\n return true;\n }\n\n return typeof type === 'string' && this.types.has(type);\n }\n}\n\nexport function readFromDataTransfer(dataTransfer: DataTransfer) {\n let items: DropItem[] = [];\n if (!dataTransfer) {\n return items;\n }\n\n // If our custom drag type is available, use that. This is a JSON serialized\n // representation of all items in the drag, set when there are multiple items\n // of the same type, or an individual item has multiple representations.\n let hasCustomType = false;\n if (dataTransfer.types.includes(CUSTOM_DRAG_TYPE)) {\n try {\n let data = dataTransfer.getData(CUSTOM_DRAG_TYPE);\n let parsed = JSON.parse(data);\n for (let item of parsed) {\n items.push({\n kind: 'text',\n types: new Set(Object.keys(item)),\n getText: (type) => Promise.resolve(item[type])\n });\n }\n\n hasCustomType = true;\n } catch {\n // ignore\n }\n }\n\n // Otherwise, map native drag items to items of a single representation.\n if (!hasCustomType) {\n let stringItems = new Map();\n for (let item of dataTransfer.items) {\n if (item.kind === 'string') {\n // The data for all formats must be read here because the data transfer gets\n // cleared out after the event handler finishes. If the item has an empty string\n // as a type, the mime type is unknown. Map to a generic mime type instead.\n stringItems.set(item.type || GENERIC_TYPE, dataTransfer.getData(item.type));\n } else if (item.kind === 'file') {\n // Despite the name, webkitGetAsEntry is also implemented in Firefox and Edge.\n // In the future, we may use getAsFileSystemHandle instead, but that's currently\n // only implemented in Chrome.\n if (typeof item.webkitGetAsEntry === 'function') {\n let entry: FileSystemEntry | null = item.webkitGetAsEntry();\n // eslint-disable-next-line max-depth\n if (!entry) {\n // For some reason, Firefox includes an item with type image/png when copy\n // and pasting any file or directory (no matter the type), but returns `null` for both\n // item.getAsFile() and item.webkitGetAsEntry(). Safari works as expected. Ignore this\n // item if this happens. See https://bugzilla.mozilla.org/show_bug.cgi?id=1699743.\n // This was recently fixed in Chrome Canary: https://bugs.chromium.org/p/chromium/issues/detail?id=1175483.\n continue;\n }\n\n // eslint-disable-next-line max-depth\n if (entry.isFile) {\n items.push(createFileItem(item.getAsFile()));\n } else if (entry.isDirectory) {\n items.push(createDirectoryItem(entry));\n }\n } else {\n // Assume it's a file.\n items.push(createFileItem(item.getAsFile()));\n }\n }\n }\n\n // All string items are different representations of the same item. There's no way to have\n // multiple string items at once in the current DataTransfer API.\n if (stringItems.size > 0) {\n items.push({\n kind: 'text',\n types: new Set(stringItems.keys()),\n getText: (type) => Promise.resolve(stringItems.get(type))\n });\n }\n }\n\n return items;\n}\n\nfunction blobToString(blob: Blob): Promise<string> {\n if (typeof blob.text === 'function') {\n return blob.text();\n }\n\n // Safari doesn't have the Blob#text() method yet...\n return new Promise((resolve, reject) => {\n let reader = new FileReader;\n reader.onload = () => {\n resolve(reader.result as string);\n };\n\n reader.onerror = reject;\n reader.readAsText(blob);\n });\n}\n\nfunction createFileItem(file: File | null): FileDropItem {\n if (!file) {\n throw new Error('No file provided');\n }\n return {\n kind: 'file',\n type: file.type || GENERIC_TYPE,\n name: file.name,\n getText: () => blobToString(file),\n getFile: () => Promise.resolve(file)\n };\n}\n\nfunction createDirectoryItem(entry: any): DirectoryDropItem {\n return {\n kind: 'directory',\n name: entry.name,\n getEntries: () => getEntries(entry)\n };\n}\n\nasync function *getEntries(item: FileSystemDirectoryEntry): AsyncIterable<FileDropItem | DirectoryDropItem> {\n let reader = item.createReader();\n\n // We must call readEntries repeatedly because there may be a limit to the\n // number of entries that are returned at once.\n let entries: FileSystemEntry[];\n do {\n entries = await new Promise((resolve, reject) => {\n reader.readEntries(resolve, reject);\n });\n\n for (let entry of entries) {\n if (entry.isFile) {\n let file = await getEntryFile(entry as FileSystemFileEntry);\n yield createFileItem(file);\n } else if (entry.isDirectory) {\n yield createDirectoryItem(entry);\n }\n }\n } while (entries.length > 0);\n}\n\nfunction getEntryFile(entry: FileSystemFileEntry): Promise<File> {\n return new Promise((resolve, reject) => entry.file(resolve, reject));\n}\n\n/** Returns whether a drop item contains text data. */\nexport function isTextDropItem(dropItem: DropItem): dropItem is TextDropItem {\n return dropItem.kind === 'text';\n}\n\n/** Returns whether a drop item is a file. */\nexport function isFileDropItem(dropItem: DropItem): dropItem is FileDropItem {\n return dropItem.kind === 'file';\n}\n\n/** Returns whether a drop item is a directory. */\nexport function isDirectoryDropItem(dropItem: DropItem): dropItem is DirectoryDropItem {\n return dropItem.kind === 'directory';\n}\n\n// Global DnD collection state tracker.\nexport interface DnDState {\n /** A ref for the of the drag items in the current drag session if any. */\n draggingCollectionRef?: RefObject<HTMLElement | null>,\n /** The set of currently dragged keys. */\n draggingKeys: Set<Key>,\n /** A ref for the collection that is targeted for a drop operation, if any. */\n dropCollectionRef?: RefObject<HTMLElement | null>\n}\n\nexport let globalDndState: DnDState = {draggingKeys: new Set()};\n\nexport function setDraggingCollectionRef(ref: RefObject<HTMLElement | null>) {\n globalDndState.draggingCollectionRef = ref;\n}\n\nexport function setDraggingKeys(keys: Set<Key>) {\n globalDndState.draggingKeys = keys;\n}\n\nexport function setDropCollectionRef(ref?: RefObject<HTMLElement | null>) {\n globalDndState.dropCollectionRef = ref;\n}\n\nexport function clearGlobalDnDState() {\n globalDndState = {draggingKeys: new Set()};\n}\n\nexport function setGlobalDnDState(state: DnDState) {\n globalDndState = state;\n}\n\n// Util function to check if the current dragging collection ref is the same as the current targeted droppable collection ref.\n// Allows a droppable ref arg in case the global drop collection ref hasn't been set\nexport function isInternalDropOperation(ref?: RefObject<HTMLElement | null>) {\n let {draggingCollectionRef, dropCollectionRef} = globalDndState;\n return draggingCollectionRef?.current != null && draggingCollectionRef.current === (ref?.current || dropCollectionRef?.current);\n}\n\ntype DropEffect = 'none' | 'copy' | 'link' | 'move';\nexport let globalDropEffect: DropEffect | undefined;\nexport function setGlobalDropEffect(dropEffect: DropEffect | undefined) {\n globalDropEffect = dropEffect;\n}\n\nexport let globalAllowedDropOperations = DROP_OPERATION.none;\nexport function setGlobalAllowedDropOperations(o: DROP_OPERATION) {\n globalAllowedDropOperations = o;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,2BAA2B,CAAC,uDAAa,CAAC;IAC5D,8BAA8B,CAAC,6DAAmB,CAAC;IACnD,4BAA4B,CAAC,gEAAQ,CAAC;IACtC,wBAAwB,CAAC,wDAAO,CAAC;IACjC,0BAA0B,CAAC,wDAAO,CAAC;IACnC,YAAY,CAAC,OAAS,CAAC,iBAAG,EAAE,KAAK,QAAQ,CAAC,CAAC;IAC3C,qBAAqB,CAAC,MAAM,YAAc,CAAC,iBAAG,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;YAAE,OAAO,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;QAAA,GAAG,CAAC;IACxL,wBAAwB,CAAC,MAAM,YAAc,CAAC,wCAAY,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;YAAE,OAAO,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;QAAA,GAAG,QAAC,CAAC;IACrM,2BAA2B,CAAC,MAAM,YAAc,CAAC,8CAAkB,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;YAAE,OAAO,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;QAAA,GAAG,QAAC,CAAC;IAC9M,yBAAyB,CAAC,MAAM,YAAc,CAAC,yCAAM,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;YAAE,OAAO,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;QAAA,GAAG,QAAC,CAAC;IAChM,uBAAuB,CAAC,4NAA6C,CAAC;IACtE,oBAAoB,CAAC,wKAAqB,CAAC;IAC3C,sBAAsB,CAAC,+LAA8B,CAAC;IACtD,gBAAgB,CAAC,gDAAM,CAAC;IACxB,gBAAgB,CAAC,gDAAM,CAAC;IACxB,2BAA2B,CAAC,+FAAyB,CAAC;IACtD,wBAAwB,CAAC,wCAAK,CAAC;IAC/B,0BAA0B,CAAC,wCAAK,CAAC;IACjC,iBAAiB,CAAC,gCAAI,CAAC;IACvB,cAAc,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,QAAQ,CAAC,CAAC;IAC9C,cAAc,CAAC,wBAAG,CAAC;IACnB,mBAAmB,CAAC,+FAAkB,CAAC;IACvC,gBAAgB,CAAC,gGAAY,CAAC;IAC9B,kBAAkB,CAAC,gGAAY,CAAC;IAChC,eAAe,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,QAAQ,CAAC,iBAAG,CAAC;IAClD,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,QAAQ,CAAC,iBAAG,CAAC;IACnD,iBAAiB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,cAAc,CAAC,UAAG,EAAE,KAAK,aAAa,CAAC,iBAAG,CAAC;AACpF","sources":["packages/@react-aria/dnd/intl/zh-CN.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":"zh-CN.main.js.map"}
1
+ {"mappings":"AAAA,iBAAiB;IAAG,2BAA2B,CAAC,uDAAa,CAAC;IAC5D,8BAA8B,CAAC,6DAAmB,CAAC;IACnD,4BAA4B,CAAC,gEAAQ,CAAC;IACtC,wBAAwB,CAAC,wDAAO,CAAC;IACjC,0BAA0B,CAAC,wDAAO,CAAC;IACnC,YAA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,CAAC,gDAAM,CAAC;IACxB,2BAA2B,CAAC,+FAAyB,CAAC;IACtD,wBAAwB,CAAC,wCAAK,CAAC;IAC/B,0BAA0B,CAAC,wCAAK,CAAC;IACjC,iBAAiB,CAAC,gCAAI,CAAC;IACvB,cAAc,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,QAAQ,EAAE;IAC9C,cAAc,CAAC,wBAAG,CAAC;IACnB,mBAAmB,CAAC,+FAAkB,CAAC;IACvC,gBAAgB,CAAC,gGAAY,CAAC;IAC9B,kBAAkB,CAAC,gGAAY,CAAC;IAChC,eAAe,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,QAAQ,CAAC,iBAAG,CAAC;IAClD,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,QAAQ,CAAC,iBAAG,CAAC;IACnD,iBAAiB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,cAAc,CAAC,UAAG,EAAE,KAAK,aAAa,CAAC,iBAAG,CAAC;AACpF","sources":["packages/@react-aria/dnd/intl/zh-CN.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":"zh-CN.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,2BAA2B,CAAC,uDAAa,CAAC;IAC5D,8BAA8B,CAAC,6DAAmB,CAAC;IACnD,4BAA4B,CAAC,gEAAQ,CAAC;IACtC,wBAAwB,CAAC,wDAAO,CAAC;IACjC,0BAA0B,CAAC,wDAAO,CAAC;IACnC,YAAY,CAAC,OAAS,CAAC,iBAAG,EAAE,KAAK,QAAQ,CAAC,CAAC;IAC3C,qBAAqB,CAAC,MAAM,YAAc,CAAC,iBAAG,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;YAAE,OAAO,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;QAAA,GAAG,CAAC;IACxL,wBAAwB,CAAC,MAAM,YAAc,CAAC,wCAAY,EAAE,UAAU,MAA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;IAC9B,kBAAkB,CAAC,gGAAY,CAAC;IAChC,eAAe,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,QAAQ,CAAC,iBAAG,CAAC;IAClD,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,QAAQ,CAAC,iBAAG,CAAC;IACnD,iBAAiB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,cAAc,CAAC,UAAG,EAAE,KAAK,aAAa,CAAC,iBAAG,CAAC;AACpF","sources":["packages/@react-aria/dnd/intl/zh-CN.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":"zh-CN.module.js.map"}
1
+ {"mappings":";AAAA,4BAAiB;IAAG,2BAA2B,CAAC,uDAAa,CAAC;IAC5D,8BAA8B,CAAC,6DAAmB,CAAC;IACnD,4BAA4B,CAAC,gEAAQ,CAAC;IACtC,wBAAwB,CAAC,wDAAO,CAAC;IACjC,0BAA0B,CAAC,wDAAO,CAAC;IACnC,YAAY,CAAC,OAAS,CAAC,iBAAG,EAAE,KAAK,QAAQ,EAAE;IAC3C,qBAAqB,CAAC,MAAM,YAAc,CAAC,iBAAG,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;YAAE,OAAO,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;QAAA,IAAI;IACxL,wBAAwB,CAAC,MAAM,YAAc,CAAC,wCAAY,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;YAAE,OAAO,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAAC;QAAA,GAAG,QAAC,CAAC;IACrM,2BAA2B,CAAC,MAAM,YAAc,CAAC,8CAAkB,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,iCAAK,CAA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escriptionKeyboardAlt\": \"按 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":"zh-CN.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,2BAA2B,CAAC,uEAAe,CAAC;IAC9D,8BAA8B,CAAC,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AE,yCAAM,CAAC;QAAA,GAAG,QAAC,CAAC;IAClM,uBAAuB,CAAC,oRAAoD,CAAC;IAC7E,oBAAoB,CAAC,gMAAwB,CAAC;IAC9C,sBAAsB,CAAC,uOAAmC,CAAC;IAC3D,gBAAgB,CAAC,gDAAM,CAAC;IACxB,gBAAgB,CAAC,gDAAM,CAAC;IACxB,2BAA2B,CAAC,+HAA6B,CAAC;IAC1D,wBAAwB,CAAC,gEAAQ,CAAC;IAClC,0BAA0B,CAAC,wEAAS,CAAC;IACrC,iBAAiB,CAAC,wCAAK,CAAC;IACxB,cAAc,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,gBAAE,CAAC;IAChD,cAAc,CAAC,wBAAG,CAAC;IACnB,mBAAmB,CAAC,uGAAmB,CAAC;IACxC,gBAAgB,CAAC,gHAAc,CAAC;IAChC,kBAAkB,CAAC,wHAAe,CAAC;IACnC,eAAe,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,wBAAG,CAAC;IAClD,gBAAgB,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,wBAAG,CAAC;IACnD,iBAAiB,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,cAAc,CAAC,wBAAG,EAAE,KAAK,aAAa,CAAC,wBAAG,CAAC;AACpF","sources":["packages/@react-aria/dnd/intl/zh-TW.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":"zh-TW.main.js.map"}
1
+ {"mappings":"AAAA,iBAAiB;IAAG,2BAA2B,CAAC,uEAAe,CAAC;IAC9D,8BAA8B,CAAC,2EAAmB,CAAC;IACnD,4BAA4B,CAAC,gEAAQ,CAAC;IACtC,wBAAwB,CAAC,gFAAU,CAAC;IACpC,0BAA0B,CAAC,wFAAW,CAAC;IACvC,YAAY,CAAC,OAAS,CAAC,wBAAG,EAAE,KA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IACxB,2BAA2B,CAAC,+HAA6B,CAAC;IAC1D,wBAAwB,CAAC,gEAAQ,CAAC;IAClC,0BAA0B,CAAC,wEAAS,CAAC;IACrC,iBAAiB,CAAC,wCAAK,CAAC;IACxB,cAAc,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,gBAAE,CAAC;IAChD,cAAc,CAAC,wBAAG,CAAC;IACnB,mBAAmB,CAAC,uGAAmB,CAAC;IACxC,gBAAgB,CAAC,gHAAc,CAAC;IAChC,kBAAkB,CAAC,wHAAe,CAAC;IACnC,eAAe,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,wBAAG,CAAC;IAClD,gBAAgB,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,wBAAG,CAAC;IACnD,iBAAiB,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,cAAc,CAAC,wBAAG,EAAE,KAAK,aAAa,CAAC,wBAAG,CAAC;AACpF","sources":["packages/@react-aria/dnd/intl/zh-TW.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":"zh-TW.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,2BAA2B,CAAC,uEAAe,CAAC;IAC9D,8BAA8B,CAAC,2EAAmB,CAAC;IACnD,4BAA4B,CAAC,gEAAQ,CAAC;IACtC,wBAAwB,CAAC,gFAAU,CAAC;IACpC,0BAA0B,CAAC,wFAAW,CAAC;IACvC,YAAY,CAAC,OAAS,CAAC,wBAAG,EAAE,KAAK,QAAQ,CAAC,QAAC,CAAC;IAC5C,qBAAqB,CAAC,MAAM,YAAc,CAAC,iBAAG,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,CAAC,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,yCAAM,CAAC;YAAE,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,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,gBAAE,CAAC;IAChD,cAAc,CAAC,wBAAG,CAAC;IACnB,mBAAmB,CAAC,uGAAmB,CAAC;IACxC,gBAAgB,CAAC,gHAAc,CAAC;IAChC,kBAAkB,CAAC,wHAAe,CAAC;IACnC,eAAe,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,wBAAG,CAAC;IAClD,gBAAgB,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,wBAAG,CAAC;IACnD,iBAAiB,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,cAAc,CAAC,wBAAG,EAAE,KAAK,aAAa,CAAC,wBAAG,CAAC;AACpF","sources":["packages/@react-aria/dnd/intl/zh-TW.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":"zh-TW.module.js.map"}
1
+ {"mappings":";AAAA,4BAAiB;IAAG,2BAA2B,CAAC,uEAAe,CAAC;IAC9D,8BAA8B,CAAC,2EAAmB,CAAC;IACnD,4BAA4B,CAAC,gEAAQ,CAAC;IACtC,wBAAwB,CAAC,gFAAU,CAAC;IACpC,0BAA0B,CAAC,wFAAW,CAAC;IACvC,YAAY,CAAC,OAAS,CAAC,wBAAG,EAAE,KAAK,QAAQ,CAAC,QAAC,CAAC;IAC5C,qBAAqB,CAAC,MAAM,YAAc,CAAC,iBAAG,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;YAAC,KAAK,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,yCAAM,CAAC;YAAE,OAAO,IAAM,GAAG,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE,yCAAM,CAAC;QAAA,IAAI;IAC1L,wBAAwB,CAAC,MAAM,YAAc,CAAC,gDAAa,EAAE,UAAU,MAAM,CAAC,KAAK,KAAK,EAAE;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OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,wBAAG,CAAC;IAClD,gBAAgB,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,QAAQ,CAAC,wBAAG,CAAC;IACnD,iBAAiB,CAAC,OAAS,CAAC,gCAAI,EAAE,KAAK,cAAc,CAAC,wBAAG,EAAE,KAAK,aAAa,CAAC,wBAAG,CAAC;AACpF","sources":["packages/@react-aria/dnd/intl/zh-TW.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":"zh-TW.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/dnd",
3
- "version": "3.7.4",
3
+ "version": "3.8.1",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,23 +22,23 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@internationalized/string": "^3.2.4",
26
- "@react-aria/i18n": "^3.12.3",
27
- "@react-aria/interactions": "^3.22.4",
28
- "@react-aria/live-announcer": "^3.4.0",
29
- "@react-aria/overlays": "^3.23.4",
30
- "@react-aria/utils": "^3.25.3",
31
- "@react-stately/dnd": "^3.4.3",
32
- "@react-types/button": "^3.10.0",
33
- "@react-types/shared": "^3.25.0",
25
+ "@internationalized/string": "^3.2.5",
26
+ "@react-aria/i18n": "^3.12.5",
27
+ "@react-aria/interactions": "^3.23.0",
28
+ "@react-aria/live-announcer": "^3.4.1",
29
+ "@react-aria/overlays": "^3.25.0",
30
+ "@react-aria/utils": "^3.27.0",
31
+ "@react-stately/dnd": "^3.5.1",
32
+ "@react-types/button": "^3.10.2",
33
+ "@react-types/shared": "^3.27.0",
34
34
  "@swc/helpers": "^0.5.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
38
- "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
37
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
38
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "8e0a28d188cdbdbd2b32296fa034b1b02ddde229"
43
+ "gitHead": "09e7f44bebdc9d89122926b2b439a0a38a2814ea"
44
44
  }
@@ -20,7 +20,7 @@ import {useEffect, useState} from 'react';
20
20
 
21
21
  let dropTargets = new Map<Element, DropTarget>();
22
22
  let dropItems = new Map<Element, DroppableItem>();
23
- let dragSession: DragSession = null;
23
+ let dragSession: DragSession | null = null;
24
24
  let subscriptions = new Set<() => void>();
25
25
 
26
26
  interface DropTarget {
@@ -29,9 +29,9 @@ interface DropTarget {
29
29
  getDropOperation?: (types: Set<string>, allowedOperations: DropOperation[]) => DropOperation,
30
30
  onDropEnter?: (e: DropEnterEvent, dragTarget: DragTarget) => void,
31
31
  onDropExit?: (e: DropExitEvent) => void,
32
- onDropTargetEnter?: (target?: DroppableCollectionTarget) => void,
33
- onDropActivate?: (e: DropActivateEvent, target?: DroppableCollectionTarget) => void,
34
- onDrop?: (e: DropEvent, target?: DroppableCollectionTarget) => void,
32
+ onDropTargetEnter?: (target: DroppableCollectionTarget | null) => void,
33
+ onDropActivate?: (e: DropActivateEvent, target: DroppableCollectionTarget | null) => void,
34
+ onDrop?: (e: DropEvent, target: DroppableCollectionTarget | null) => void,
35
35
  onKeyDown?: (e: KeyboardEvent, dragTarget: DragTarget) => void
36
36
  }
37
37
 
@@ -71,9 +71,11 @@ export function beginDragging(target: DragTarget, stringFormatter: LocalizedStri
71
71
 
72
72
  dragSession = new DragSession(target, stringFormatter);
73
73
  requestAnimationFrame(() => {
74
- dragSession.setup();
75
- if (getDragModality() === 'keyboard') {
76
- dragSession.next();
74
+ if (dragSession) {
75
+ dragSession.setup();
76
+ if (getDragModality() === 'keyboard') {
77
+ dragSession.next();
78
+ }
77
79
  }
78
80
  });
79
81
 
@@ -154,14 +156,14 @@ const MESSAGES = {
154
156
 
155
157
  class DragSession {
156
158
  dragTarget: DragTarget;
157
- validDropTargets: DropTarget[];
158
- currentDropTarget: DropTarget;
159
- currentDropItem: DroppableItem;
160
- dropOperation: DropOperation;
161
- private mutationObserver: MutationObserver;
162
- private restoreAriaHidden: () => void;
159
+ validDropTargets: DropTarget[] = [];
160
+ currentDropTarget: DropTarget | null = null;
161
+ currentDropItem: DroppableItem | null = null;
162
+ dropOperation: DropOperation | null = null;
163
+ private mutationObserver: MutationObserver | null = null;
164
+ private restoreAriaHidden: (() => void) | null = null;
163
165
  private stringFormatter: LocalizedStringFormatter;
164
- private isVirtualClick: boolean;
166
+ private isVirtualClick: boolean = false;
165
167
  private initialFocused: boolean;
166
168
 
167
169
  constructor(target: DragTarget, stringFormatter: LocalizedStringFormatter) {
@@ -210,8 +212,8 @@ class DragSession {
210
212
  document.removeEventListener(event, this.cancelEvent, true);
211
213
  }
212
214
 
213
- this.mutationObserver.disconnect();
214
- this.restoreAriaHidden();
215
+ this.mutationObserver?.disconnect();
216
+ this.restoreAriaHidden?.();
215
217
  }
216
218
 
217
219
  onKeyDown(e: KeyboardEvent) {
@@ -452,7 +454,7 @@ class DragSession {
452
454
  return nearest;
453
455
  }
454
456
 
455
- setCurrentDropTarget(dropTarget: DropTarget, item?: DroppableItem) {
457
+ setCurrentDropTarget(dropTarget: DropTarget | null, item?: DroppableItem) {
456
458
  if (dropTarget !== this.currentDropTarget) {
457
459
  if (this.currentDropTarget && typeof this.currentDropTarget.onDropExit === 'function') {
458
460
  let rect = this.currentDropTarget.element.getBoundingClientRect();
@@ -481,12 +483,12 @@ class DragSession {
481
483
  }
482
484
  }
483
485
 
484
- if (item !== this.currentDropItem) {
485
- if (item && typeof this.currentDropTarget.onDropTargetEnter === 'function') {
486
- this.currentDropTarget.onDropTargetEnter(item?.target);
486
+ if (item != null && item !== this.currentDropItem) {
487
+ if (this.currentDropTarget && typeof this.currentDropTarget.onDropTargetEnter === 'function') {
488
+ this.currentDropTarget.onDropTargetEnter(item.target);
487
489
  }
488
490
 
489
- item?.element.focus();
491
+ item.element.focus();
490
492
  this.currentDropItem = item;
491
493
 
492
494
  // Announce first drop target after drag start announcement finishes.
@@ -520,7 +522,7 @@ class DragSession {
520
522
  // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).
521
523
  // This corrects state such as whether focus ring should appear.
522
524
  // useDroppableCollection handles this itself, so this is only for standalone drop zones.
523
- document.activeElement.dispatchEvent(new FocusEvent('focusin', {bubbles: true}));
525
+ document.activeElement?.dispatchEvent(new FocusEvent('focusin', {bubbles: true}));
524
526
  }
525
527
 
526
528
  this.setCurrentDropTarget(null);
@@ -567,7 +569,7 @@ class DragSession {
567
569
  y: rect.top + (rect.height / 2),
568
570
  items,
569
571
  dropOperation: this.dropOperation
570
- }, item?.target);
572
+ }, item?.target ?? null);
571
573
  }
572
574
 
573
575
  this.end();
@@ -581,7 +583,7 @@ class DragSession {
581
583
  type: 'dropactivate',
582
584
  x: rect.left + (rect.width / 2),
583
585
  y: rect.top + (rect.height / 2)
584
- });
586
+ }, null);
585
587
  }
586
588
  }
587
589
  }
@@ -10,20 +10,21 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {DragItem, DragPreviewRenderer, RefObject} from '@react-types/shared';
13
+ import {DragItem, DragPreviewRenderer} from '@react-types/shared';
14
14
  import {flushSync} from 'react-dom';
15
- import React, {JSX, useImperativeHandle, useRef, useState} from 'react';
15
+ import React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';
16
16
 
17
17
  export interface DragPreviewProps {
18
- children: (items: DragItem[]) => JSX.Element
18
+ children: (items: DragItem[]) => JSX.Element | null
19
19
  }
20
20
 
21
- function DragPreview(props: DragPreviewProps, ref: RefObject<DragPreviewRenderer | null>) {
21
+ export const DragPreview = React.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {
22
22
  let render = props.children;
23
- let [children, setChildren] = useState<JSX.Element>(null);
24
- let domRef = useRef(null);
23
+ let [children, setChildren] = useState<JSX.Element | null>(null);
24
+ let domRef = useRef<HTMLDivElement | null>(null);
25
+ let raf = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(undefined);
25
26
 
26
- useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement) => void) => {
27
+ useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement | null) => void) => {
27
28
  // This will be called during the onDragStart event by useDrag. We need to render the
28
29
  // preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.
29
30
  flushSync(() => {
@@ -34,11 +35,19 @@ function DragPreview(props: DragPreviewProps, ref: RefObject<DragPreviewRenderer
34
35
  callback(domRef.current);
35
36
 
36
37
  // Remove the preview from the DOM after a frame so the browser has time to paint.
37
- requestAnimationFrame(() => {
38
+ raf.current = requestAnimationFrame(() => {
38
39
  setChildren(null);
39
40
  });
40
41
  }, [render]);
41
42
 
43
+ useEffect(() => {
44
+ return () => {
45
+ if (raf.current) {
46
+ cancelAnimationFrame(raf.current);
47
+ }
48
+ };
49
+ }, []);
50
+
42
51
  if (!children) {
43
52
  return null;
44
53
  }
@@ -48,7 +57,4 @@ function DragPreview(props: DragPreviewProps, ref: RefObject<DragPreviewRenderer
48
57
  {children}
49
58
  </div>
50
59
  );
51
- }
52
-
53
- let _DragPreview = React.forwardRef(DragPreview);
54
- export {_DragPreview as DragPreview};
60
+ });
@@ -72,11 +72,11 @@ export class ListDropTargetDelegate implements DropTargetDelegate {
72
72
  }
73
73
 
74
74
  getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {
75
- if (this.collection[Symbol.iterator]().next().done) {
75
+ if (this.collection[Symbol.iterator]().next().done || !this.ref.current) {
76
76
  return {type: 'root'};
77
77
  }
78
78
 
79
- let rect = this.ref.current.getBoundingClientRect();
79
+ let rect: DOMRect | undefined = this.ref.current.getBoundingClientRect();
80
80
  let primary = this.orientation === 'horizontal' ? x : y;
81
81
  let secondary = this.orientation === 'horizontal' ? y : x;
82
82
  primary += this.getPrimaryStart(rect);
@@ -90,7 +90,7 @@ export class ListDropTargetDelegate implements DropTargetDelegate {
90
90
  let elements = this.ref.current.querySelectorAll('[data-key]');
91
91
  let elementMap = new Map<string, HTMLElement>();
92
92
  for (let item of elements) {
93
- if (item instanceof HTMLElement) {
93
+ if (item instanceof HTMLElement && item.dataset.key != null) {
94
94
  elementMap.set(item.dataset.key, item);
95
95
  }
96
96
  }
@@ -106,6 +106,9 @@ export class ListDropTargetDelegate implements DropTargetDelegate {
106
106
  let mid = Math.floor((low + high) / 2);
107
107
  let item = items[mid];
108
108
  let element = elementMap.get(String(item.key));
109
+ if (!element) {
110
+ break;
111
+ }
109
112
  let rect = element.getBoundingClientRect();
110
113
  let update = (isGreater: boolean) => {
111
114
  if (isGreater) {
@@ -154,9 +157,9 @@ export class ListDropTargetDelegate implements DropTargetDelegate {
154
157
 
155
158
  let item = items[Math.min(low, items.length - 1)];
156
159
  let element = elementMap.get(String(item.key));
157
- rect = element.getBoundingClientRect();
160
+ rect = element?.getBoundingClientRect();
158
161
 
159
- if (primary < this.getPrimaryStart(rect) || Math.abs(flow - this.getFlowStart(rect)) < Math.abs(flow - this.getFlowEnd(rect))) {
162
+ if (rect && (primary < this.getPrimaryStart(rect) || Math.abs(flow - this.getFlowStart(rect)) < Math.abs(flow - this.getFlowEnd(rect)))) {
160
163
  return {
161
164
  type: 'item',
162
165
  key: item.key,
@@ -29,8 +29,8 @@ export function useAutoScroll(ref: RefObject<Element | null>) {
29
29
  }
30
30
  }, [ref]);
31
31
 
32
- let state = useRef({
33
- timer: null,
32
+ let state = useRef<{timer: ReturnType<typeof requestAnimationFrame> | undefined, dx: number, dy: number}>({
33
+ timer: undefined,
34
34
  dx: 0,
35
35
  dy: 0
36
36
  }).current;
@@ -39,17 +39,17 @@ export function useAutoScroll(ref: RefObject<Element | null>) {
39
39
  return () => {
40
40
  if (state.timer) {
41
41
  cancelAnimationFrame(state.timer);
42
- state.timer = null;
42
+ state.timer = undefined;
43
43
  }
44
44
  };
45
45
  // state will become a new object, so it's ok to use in the dependency array for unmount
46
46
  }, [state]);
47
47
 
48
48
  let scroll = useCallback(() => {
49
- if (scrollableX.current) {
49
+ if (scrollableX.current && scrollableRef.current) {
50
50
  scrollableRef.current.scrollLeft += state.dx;
51
51
  }
52
- if (scrollableY.current) {
52
+ if (scrollableY.current && scrollableRef.current) {
53
53
  scrollableRef.current.scrollTop += state.dy;
54
54
  }
55
55
 
@@ -93,7 +93,7 @@ export function useAutoScroll(ref: RefObject<Element | null>) {
93
93
  stop() {
94
94
  if (state.timer) {
95
95
  cancelAnimationFrame(state.timer);
96
- state.timer = null;
96
+ state.timer = undefined;
97
97
  }
98
98
  }
99
99
  };
@@ -87,8 +87,10 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
87
87
  }
88
88
 
89
89
  e.preventDefault();
90
- writeToDataTransfer(e.clipboardData, options.getItems());
91
- options.onCopy?.();
90
+ if (e.clipboardData) {
91
+ writeToDataTransfer(e.clipboardData, options.getItems());
92
+ options.onCopy?.();
93
+ }
92
94
  });
93
95
 
94
96
  let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {
@@ -103,8 +105,10 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
103
105
  }
104
106
 
105
107
  e.preventDefault();
106
- writeToDataTransfer(e.clipboardData, options.getItems());
107
- options.onCut();
108
+ if (e.clipboardData) {
109
+ writeToDataTransfer(e.clipboardData, options.getItems());
110
+ options.onCut();
111
+ }
108
112
  });
109
113
 
110
114
  let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {
@@ -121,8 +125,10 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
121
125
  }
122
126
 
123
127
  e.preventDefault();
124
- let items = readFromDataTransfer(e.clipboardData);
125
- options.onPaste(items);
128
+ if (e.clipboardData) {
129
+ let items = readFromDataTransfer(e.clipboardData);
130
+ options.onPaste(items);
131
+ }
126
132
  });
127
133
 
128
134
  useEffect(() => {
package/src/useDrag.ts CHANGED
@@ -134,6 +134,9 @@ export function useDrag(options: DragOptions): DragResult {
134
134
  // appear under the pointer while dragging. If not, the element itself is dragged by the browser.
135
135
  if (typeof options.preview?.current === 'function') {
136
136
  options.preview.current(items, node => {
137
+ if (!node) {
138
+ return;
139
+ }
137
140
  // Compute the offset that the preview will appear under the mouse.
138
141
  // If possible, this is based on the point the user clicked on the target.
139
142
  // If the preview is much smaller, then just use the center point of the preview.
@@ -218,7 +221,7 @@ export function useDrag(options: DragOptions): DragResult {
218
221
 
219
222
  // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
220
223
  // In this case, we need to manually call onDragEnd on cleanup
221
- // eslint-disable-next-line arrow-body-style
224
+
222
225
  useLayoutEffect(() => {
223
226
  return () => {
224
227
  if (isDraggingRef.current) {
@@ -279,7 +282,7 @@ export function useDrag(options: DragOptions): DragResult {
279
282
 
280
283
  let descriptionProps = useDescription(stringFormatter.format(message));
281
284
 
282
- let interactions: HTMLAttributes<HTMLElement>;
285
+ let interactions: HTMLAttributes<HTMLElement> = {};
283
286
  if (!hasDragButton) {
284
287
  // If there's no separate button to trigger accessible drag and drop mode,
285
288
  // then add event handlers to the draggable element itself to start dragging.