@react-aria/dnd 3.9.1 → 3.9.3
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.
- package/dist/DragManager.main.js.map +1 -1
- package/dist/DragManager.module.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/useAutoScroll.main.js.map +1 -1
- package/dist/useAutoScroll.module.js.map +1 -1
- package/dist/useDrop.main.js.map +1 -1
- package/dist/useDrop.module.js.map +1 -1
- package/dist/useDroppableCollection.main.js +10 -5
- package/dist/useDroppableCollection.main.js.map +1 -1
- package/dist/useDroppableCollection.mjs +10 -5
- package/dist/useDroppableCollection.module.js +10 -5
- package/dist/useDroppableCollection.module.js.map +1 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.module.js.map +1 -1
- package/package.json +11 -11
- package/src/DragManager.ts +4 -4
- package/src/useAutoScroll.ts +6 -1
- package/src/useDrop.ts +3 -3
- package/src/useDroppableCollection.ts +18 -11
- package/src/utils.ts +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAwDD,MAAM,uCAAiC;IAAC;IAAU;IAAM;CAAQ;AAChE,MAAM,2CAAqC;IAAC;IAAS;IAAM;CAAS;AAM7D,SAAS,0CAAuB,KAAiC,EAAE,KAA+B,EAAE,GAAkC;IAC3I,IAAI,aAAa,CAAA,GAAA,aAAK,EAKnB;eACD;eACA;QACA,YAAY;QACZ,eAAe;IACjB,GAAG,OAAO;IACV,WAAW,KAAK,GAAG;IACnB,WAAW,KAAK,GAAG;IAEnB,IAAI,gBAAgB,CAAA,GAAA,kBAAU,EAAE,OAAO;QACrC,IAAI,YACF,QAAQ,cACR,UAAU,cACV,UAAU,aACV,SAAS,qBACT,oBAAoB,6BACpB,oBAAoB,EACrB,GAAG,WAAW,KAAK;QAEpB,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA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QAAQ;KAAU;IAEvC,IAAI,KAAK,CAAA,GAAA,YAAI;IACb,CAAA,GAAA,yCAAqB,EAAE,GAAG,CAAC,OAAO;YAAC;aAAI;IAAG;IAC1C,OAAO;QACL,iBAAiB,CAAA,GAAA,iBAAS,EAAE,WAAW;gBACrC;YACA,oFAAoF;YACpF,6FAA6F;YAC7F,oBAAoB;QACtB;IACF;AACF","sources":["packages/@react-aria/dnd/src/useDroppableCollection.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 {\n clearGlobalDnDState,\n DIRECTORY_DRAG_TYPE,\n droppableCollectionMap,\n getTypes,\n globalDndState,\n isInternalDropOperation,\n setDropCollectionRef\n} from './utils';\nimport {\n Collection,\n DropEvent,\n DropOperation,\n DroppableCollectionDropEvent,\n DroppableCollectionProps,\n DropPosition,\n DropTarget,\n DropTargetDelegate,\n Key,\n KeyboardDelegate,\n Node,\n RefObject\n} from '@react-types/shared';\nimport * as DragManager from './DragManager';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {HTMLAttributes, useCallback, useEffect, useRef} from 'react';\nimport {mergeProps, useId, useLayoutEffect} from '@react-aria/utils';\nimport {setInteractionModality} from '@react-aria/interactions';\nimport {useAutoScroll} from './useAutoScroll';\nimport {useDrop} from './useDrop';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface DroppableCollectionOptions extends DroppableCollectionProps {\n /** A delegate object that implements behavior for keyboard focus movement. */\n keyboardDelegate: KeyboardDelegate,\n /** A delegate object that provides drop targets for pointer coordinates within the collection. */\n dropTargetDelegate: DropTargetDelegate\n}\n\nexport interface DroppableCollectionResult {\n /** Props for the collection element. */\n collectionProps: HTMLAttributes<HTMLElement>\n}\n\ninterface DroppingState {\n collection: Collection<Node<unknown>>,\n focusedKey: Key | null,\n selectedKeys: Set<Key>,\n target: DropTarget,\n draggingKeys: Set<Key | null | undefined>,\n isInternal: boolean,\n timeout: ReturnType<typeof setTimeout> | undefined\n}\n\nconst DROP_POSITIONS: DropPosition[] = ['before', 'on', 'after'];\nconst DROP_POSITIONS_RTL: DropPosition[] = ['after', 'on', 'before'];\n\n/**\n * Handles drop interactions for a collection component, 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 useDroppableCollection(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>): DroppableCollectionResult {\n let localState = useRef<{\n props: DroppableCollectionOptions,\n state: DroppableCollectionState,\n nextTarget: DropTarget | null,\n dropOperation: DropOperation | null\n }>({\n props,\n state,\n nextTarget: null,\n dropOperation: null\n }).current;\n localState.props = props;\n localState.state = state;\n\n let defaultOnDrop = useCallback(async (e: DroppableCollectionDropEvent) => {\n let {\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n acceptedDragTypes = 'all',\n shouldAcceptItemDrop\n } = localState.props;\n\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let {\n target,\n dropOperation,\n items\n } = e;\n\n let filteredItems = items;\n if (acceptedDragTypes !== 'all' || shouldAcceptItemDrop) {\n filteredItems = items.filter(item => {\n let itemTypes: Set<string | symbol>;\n if (item.kind === 'directory') {\n itemTypes = new Set([DIRECTORY_DRAG_TYPE]);\n } else {\n itemTypes = item.kind === 'file' ? new Set([item.type]) : item.types;\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => itemTypes.has(type))) {\n // If we are performing a on item drop, check if the item in question accepts the dropped item since the item may have heavier restrictions\n // than the droppable collection itself\n if (target.type === 'item' && target.dropPosition === 'on' && shouldAcceptItemDrop) {\n return shouldAcceptItemDrop(target, itemTypes);\n }\n return true;\n }\n\n return false;\n });\n }\n\n if (filteredItems.length > 0) {\n if (target.type === 'root' && onRootDrop) {\n await onRootDrop({items: filteredItems, dropOperation});\n }\n\n if (target.type === 'item') {\n if (target.dropPosition === 'on' && onItemDrop) {\n await onItemDrop({items: filteredItems, dropOperation, isInternal, target});\n }\n\n if (target.dropPosition !== 'on') {\n if (!isInternal && onInsert) {\n await onInsert({items: filteredItems, dropOperation, target});\n }\n\n if (isInternal && onReorder) {\n await onReorder({keys: draggingKeys, dropOperation, target});\n }\n }\n }\n }\n }, [localState, ref]);\n\n let autoScroll = useAutoScroll(ref);\n let {dropProps} = useDrop({\n ref,\n onDropEnter() {\n if (localState.nextTarget != null) {\n state.setTarget(localState.nextTarget);\n }\n },\n onDropMove(e) {\n if (localState.nextTarget != null) {\n state.setTarget(localState.nextTarget);\n }\n autoScroll.move(e.x, e.y);\n },\n getDropOperationForPoint(types, allowedOperations, x, y) {\n let {draggingKeys, dropCollectionRef} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let isValidDropTarget = (target) => state.getDropOperation({target, types, allowedOperations, isInternal, draggingKeys}) !== 'cancel';\n let target = props.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);\n if (!target) {\n localState.dropOperation = 'cancel';\n localState.nextTarget = null;\n return 'cancel';\n }\n\n localState.dropOperation = state.getDropOperation({target, types, allowedOperations, isInternal, draggingKeys});\n\n // If the target doesn't accept the drop, see if the root accepts it instead.\n if (localState.dropOperation === 'cancel') {\n let rootTarget: DropTarget = {type: 'root'};\n let dropOperation = state.getDropOperation({target: rootTarget, types, allowedOperations, isInternal, draggingKeys});\n if (dropOperation !== 'cancel') {\n target = rootTarget;\n localState.dropOperation = dropOperation;\n }\n }\n\n // Only set dropCollectionRef if there is a valid drop target since we cleanup dropCollectionRef in onDropExit\n // which only runs when leaving a valid drop target or if the dropEffect become none (mouse dnd only).\n if (target && localState.dropOperation !== 'cancel' && ref?.current !== dropCollectionRef?.current) {\n setDropCollectionRef(ref);\n }\n localState.nextTarget = localState.dropOperation === 'cancel' ? null : target;\n return localState.dropOperation;\n },\n onDropExit() {\n setDropCollectionRef(undefined);\n state.setTarget(null);\n autoScroll.stop();\n },\n onDropActivate(e) {\n if (state.target?.type === 'item' && state.target?.dropPosition === 'on' && typeof props.onDropActivate === 'function') {\n props.onDropActivate({\n type: 'dropactivate',\n x: e.x, // todo\n y: e.y,\n target: state.target\n });\n }\n },\n onDrop(e) {\n setDropCollectionRef(ref);\n if (state.target) {\n onDrop(e, state.target);\n }\n\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global DnD state for onDragEnd\n let {draggingCollectionRef} = globalDndState;\n if (draggingCollectionRef == null) {\n clearGlobalDnDState();\n }\n }\n });\n\n let droppingState = useRef<DroppingState>(null);\n let updateFocusAfterDrop = useCallback(() => {\n let {state} = localState;\n if (droppingState.current) {\n let {\n target,\n collection: prevCollection,\n selectedKeys: prevSelectedKeys,\n focusedKey: prevFocusedKey,\n isInternal,\n draggingKeys\n } = droppingState.current;\n\n // If an insert occurs during a drop, we want to immediately select these items to give\n // feedback to the user that a drop occurred. Only do this if the selection didn't change\n // since the drop started so we don't override if the user or application did something.\n if (\n state.collection.size > prevCollection.size &&\n state.selectionManager.isSelectionEqual(prevSelectedKeys)\n ) {\n let newKeys = new Set<Key>();\n for (let key of state.collection.getKeys()) {\n if (!prevCollection.getItem(key)) {\n newKeys.add(key);\n }\n }\n\n state.selectionManager.setSelectedKeys(newKeys);\n\n // If the focused item didn't change since the drop occurred, also focus the first\n // inserted item. If selection is disabled, then also show the focus ring so there\n // is some indication that items were added.\n if (state.selectionManager.focusedKey === prevFocusedKey) {\n let first = newKeys.keys().next().value;\n let item = state.collection.getItem(first);\n\n // If this is a cell, focus the parent row.\n if (item?.type === 'cell') {\n first = item.parentKey;\n }\n\n state.selectionManager.setFocusedKey(first);\n\n if (state.selectionManager.selectionMode === 'none') {\n setInteractionModality('keyboard');\n }\n }\n } else if (\n prevFocusedKey != null &&\n state.selectionManager.focusedKey === prevFocusedKey &&\n isInternal &&\n target.type === 'item' &&\n target.dropPosition !== 'on' &&\n draggingKeys.has(state.collection.getItem(prevFocusedKey)?.parentKey)\n ) {\n // Focus row instead of cell when reordering.\n state.selectionManager.setFocusedKey(state.collection.getItem(prevFocusedKey)?.parentKey ?? null);\n setInteractionModality('keyboard');\n } else if (\n state.selectionManager.focusedKey === prevFocusedKey &&\n target.type === 'item' &&\n target.dropPosition === 'on' &&\n state.collection.getItem(target.key) != null\n ) {\n // If focus didn't move already (e.g. due to an insert), and the user dropped on an item,\n // focus that item and show the focus ring to give the user feedback that the drop occurred.\n // Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.\n state.selectionManager.setFocusedKey(target.key);\n setInteractionModality('keyboard');\n } else if (state.selectionManager.focusedKey != null && !state.selectionManager.isSelected(state.selectionManager.focusedKey)) {\n setInteractionModality('keyboard');\n }\n\n state.selectionManager.setFocused(true);\n }\n }, [localState]);\n\n let onDrop = useCallback((e: DropEvent, target: DropTarget) => {\n let {state} = localState;\n\n // Save some state of the collection/selection before the drop occurs so we can compare later.\n droppingState.current = {\n timeout: undefined,\n focusedKey: state.selectionManager.focusedKey,\n collection: state.collection,\n selectedKeys: state.selectionManager.selectedKeys,\n draggingKeys: globalDndState.draggingKeys,\n isInternal: isInternalDropOperation(ref),\n target\n };\n\n let onDropFn = localState.props.onDrop || defaultOnDrop;\n onDropFn({\n type: 'drop',\n x: e.x, // todo\n y: e.y,\n target,\n items: e.items,\n dropOperation: e.dropOperation\n });\n\n // Wait for a short time period after the onDrop is called to allow the data to be read asynchronously\n // and for React to re-render. If the collection didn't already change during this time (handled below),\n // update the focused key here.\n droppingState.current.timeout = setTimeout(() => {\n updateFocusAfterDrop();\n droppingState.current = null;\n }, 50);\n }, [localState, defaultOnDrop, ref, updateFocusAfterDrop]);\n\n \n useEffect(() => {\n return () => {\n if (droppingState.current) {\n clearTimeout(droppingState.current.timeout);\n }\n };\n }, []);\n\n useLayoutEffect(() => {\n // If the collection changed after a drop, update the focused key.\n if (droppingState.current && state.collection !== droppingState.current.collection) {\n updateFocusAfterDrop();\n }\n });\n\n let {direction} = useLocale();\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n let getNextTarget = (target: DropTarget | null | undefined, wrap = true, horizontal = false): DropTarget | null => {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n let {keyboardDelegate} = localState.props;\n let nextKey: Key | null | undefined;\n if (target?.type === 'item') {\n nextKey = horizontal ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyBelow?.(target.key);\n } else {\n nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getLastKey?.() : keyboardDelegate.getFirstKey?.();\n }\n let dropPositions = horizontal && direction === 'rtl' ? DROP_POSITIONS_RTL : DROP_POSITIONS;\n let dropPosition: DropPosition = dropPositions[0];\n\n if (target.type === 'item') {\n // If the the keyboard delegate returned the next key in the collection,\n // first try the other positions in the current key. Otherwise (e.g. in a grid layout),\n // jump to the same drop position in the new key.\n let nextCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyBefore(target.key) : localState.state.collection.getKeyAfter(target.key);\n if (nextKey == null || nextKey === nextCollectionKey) {\n let positionIndex = dropPositions.indexOf(target.dropPosition);\n let nextDropPosition = dropPositions[positionIndex + 1];\n if (positionIndex < dropPositions.length - 1 && !(nextDropPosition === dropPositions[2] && nextKey != null)) {\n return {\n type: 'item',\n key: target.key,\n dropPosition: nextDropPosition\n };\n }\n\n // If the last drop position was 'after', then 'before' on the next key is equivalent.\n // Switch to 'on' instead.\n if (target.dropPosition === dropPositions[2]) {\n dropPosition = 'on';\n }\n } else {\n dropPosition = target.dropPosition;\n }\n }\n\n if (nextKey == null) {\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n }\n\n return {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n };\n\n let getPreviousTarget = (target: DropTarget | null | undefined, wrap = true, horizontal = false): DropTarget | null => {\n let {keyboardDelegate} = localState.props;\n let nextKey: Key | null | undefined;\n if (target?.type === 'item') {\n nextKey = horizontal ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyAbove?.(target.key);\n } else {\n nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getFirstKey?.() : keyboardDelegate.getLastKey?.();\n }\n let dropPositions = horizontal && direction === 'rtl' ? DROP_POSITIONS_RTL : DROP_POSITIONS;\n let dropPosition: DropPosition = !target || target.type === 'root' ? dropPositions[2] : 'on';\n\n if (target?.type === 'item') {\n // If the the keyboard delegate returned the previous key in the collection,\n // first try the other positions in the current key. Otherwise (e.g. in a grid layout),\n // jump to the same drop position in the new key.\n let prevCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyAfter(target.key) : localState.state.collection.getKeyBefore(target.key);\n if (nextKey == null || nextKey === prevCollectionKey) {\n let positionIndex = dropPositions.indexOf(target.dropPosition);\n let nextDropPosition = dropPositions[positionIndex - 1];\n if (positionIndex > 0 && nextDropPosition !== dropPositions[2]) {\n return {\n type: 'item',\n key: target.key,\n dropPosition: nextDropPosition\n };\n }\n\n // If the last drop position was 'before', then 'after' on the previous key is equivalent.\n // Switch to 'on' instead.\n if (target.dropPosition === dropPositions[0]) {\n dropPosition = 'on';\n }\n } else {\n dropPosition = target.dropPosition;\n }\n }\n\n if (nextKey == null) {\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n }\n\n return {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n };\n\n let nextValidTarget = (\n target: DropTarget | null | undefined,\n types: Set<string>,\n allowedDropOperations: DropOperation[],\n getNextTarget: (target: DropTarget | null | undefined, wrap: boolean) => DropTarget | null,\n wrap = true\n ): DropTarget | null => {\n let seenRoot = 0;\n let operation: DropOperation;\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n do {\n let nextTarget = getNextTarget(target, wrap);\n if (!nextTarget) {\n return null;\n }\n target = nextTarget;\n operation = localState.state.getDropOperation({target: nextTarget, types, allowedOperations: allowedDropOperations, isInternal, draggingKeys});\n if (target.type === 'root') {\n seenRoot++;\n }\n } while (\n operation === 'cancel' &&\n !localState.state.isDropTarget(target) &&\n seenRoot < 2\n );\n\n if (operation === 'cancel') {\n return null;\n }\n\n return target;\n };\n\n return DragManager.registerDropTarget({\n element: ref.current,\n preventFocusOnDrop: true,\n getDropOperation(types, allowedOperations) {\n if (localState.state.target) {\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n return localState.state.getDropOperation({target: localState.state.target, types, allowedOperations, isInternal, draggingKeys});\n }\n\n // Check if any of the targets accept the drop.\n // TODO: should we have a faster way of doing this or e.g. for pagination?\n let target = nextValidTarget(null, types, allowedOperations, getNextTarget);\n return target ? 'move' : 'cancel';\n },\n onDropEnter(e, drag) {\n let types = getTypes(drag.items);\n let selectionManager = localState.state.selectionManager;\n let target: DropTarget | null = null;\n // Update the drop collection ref tracker for useDroppableItem's getDropOperation isInternal check\n setDropCollectionRef(ref);\n\n // When entering the droppable collection for the first time, the default drop target\n // is after the focused key.\n let key: Key | null | undefined = selectionManager.focusedKey;\n let dropPosition: DropPosition = 'after';\n\n // If the focused key is a cell, get the parent item instead.\n // For now, we assume that individual cells cannot be dropped on.\n let item = key != null ? localState.state.collection.getItem(key) : null;\n if (item?.type === 'cell') {\n key = item.parentKey;\n }\n\n // If the focused item is also selected, the default drop target is after the last selected item.\n // But if the focused key is the first selected item, then default to before the first selected item.\n // This is to make reordering lists slightly easier. If you select top down, we assume you want to\n // move the items down. If you select bottom up, we assume you want to move the items up.\n if (key != null && selectionManager.isSelected(key)) {\n if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) {\n dropPosition = 'before';\n } else {\n key = selectionManager.lastSelectedKey;\n }\n }\n\n if (key != null) {\n target = {\n type: 'item',\n key,\n dropPosition\n };\n\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n // If the default target is not valid, find the next one that is.\n if (localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys}) === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);\n }\n }\n\n // If no focused key, then start from the root.\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n }\n\n localState.state.setTarget(target);\n },\n onDropExit() {\n setDropCollectionRef(undefined);\n localState.state.setTarget(null);\n },\n onDropTargetEnter(target) {\n localState.state.setTarget(target);\n },\n onDropActivate(e) {\n if (\n localState.state.target?.type === 'item' &&\n localState.state.target?.dropPosition === 'on' &&\n typeof localState.props.onDropActivate === 'function'\n ) {\n localState.props.onDropActivate({\n type: 'dropactivate',\n x: e.x, // todo\n y: e.y,\n target: localState.state.target\n });\n }\n },\n onDrop(e, target) {\n setDropCollectionRef(ref);\n if (localState.state.target) {\n onDrop(e, target || localState.state.target);\n }\n },\n onKeyDown(e, drag) {\n let {keyboardDelegate} = localState.props;\n let types = getTypes(drag.items);\n switch (e.key) {\n case 'ArrowDown': {\n if (keyboardDelegate.getKeyBelow) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getNextTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowUp': {\n if (keyboardDelegate.getKeyAbove) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getPreviousTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowLeft': {\n if (keyboardDelegate.getKeyLeftOf) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap) => getPreviousTarget(target, wrap, true));\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardDelegate.getKeyRightOf) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap) => getNextTarget(target, wrap, true));\n localState.state.setTarget(target);\n }\n break;\n }\n case 'Home': {\n if (keyboardDelegate.getFirstKey) {\n let target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'End': {\n if (keyboardDelegate.getLastKey) {\n let target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'PageDown': {\n if (keyboardDelegate.getKeyPageBelow) {\n let target = localState.state.target;\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n } else {\n // If on the root, go to the item a page below the top. Otherwise a page below the current item.\n let targetKey = keyboardDelegate.getFirstKey?.();\n if (target.type === 'item') {\n targetKey = target.key;\n }\n let nextKey: Key | null = null;\n if (targetKey != null) {\n nextKey = keyboardDelegate.getKeyPageBelow(targetKey);\n }\n let dropPosition = target.type === 'item' ? target.dropPosition : 'after';\n\n // If there is no next key, or we are starting on the last key, jump to the last possible position.\n if (nextKey == null || (target.type === 'item' && target.key === keyboardDelegate.getLastKey?.())) {\n nextKey = keyboardDelegate.getLastKey?.() ?? null;\n dropPosition = 'after';\n }\n\n if (nextKey == null) {\n break;\n }\n target = {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n\n // If the target does not accept the drop, find the next valid target.\n // If no next valid target, find the previous valid target.\n let {draggingCollectionRef, draggingKeys} = globalDndState;\n let isInternal = draggingCollectionRef?.current === ref?.current;\n let operation = localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys});\n if (operation === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);\n }\n }\n\n localState.state.setTarget(target ?? localState.state.target);\n }\n break;\n }\n case 'PageUp': {\n if (!keyboardDelegate.getKeyPageAbove) {\n break;\n }\n\n let target = localState.state.target;\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);\n } else if (target.type === 'item') {\n // If at the top already, switch to the root. Otherwise navigate a page up.\n if (target.key === keyboardDelegate.getFirstKey?.()) {\n target = {\n type: 'root'\n };\n } else {\n let nextKey: Key | null | undefined = keyboardDelegate.getKeyPageAbove(target.key);\n let dropPosition = target.dropPosition;\n if (nextKey == null) {\n nextKey = keyboardDelegate.getFirstKey?.();\n dropPosition = 'before';\n }\n\n if (nextKey == null) {\n break;\n }\n target = {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n }\n\n // If the target does not accept the drop, find the previous valid target.\n // If no next valid target, find the next valid target.\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let operation = localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys});\n if (operation === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false);\n }\n }\n\n localState.state.setTarget(target ?? localState.state.target);\n break;\n }\n }\n }\n });\n }, [localState, ref, onDrop, direction]);\n\n let id = useId();\n droppableCollectionMap.set(state, {id, ref});\n return {\n collectionProps: mergeProps(dropProps, {\n id,\n // Remove description from collection element. If dropping on the entire collection,\n // there should be a drop indicator that has this description, so no need to double announce.\n 'aria-describedby': null\n })\n };\n}\n"],"names":[],"version":3,"file":"useDroppableCollection.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAwDD,MAAM,uCAAiC;IAAC;IAAU;IAAM;CAAQ;AAChE,MAAM,2CAAqC;IAAC;IAAS;IAAM;CAAS;AAM7D,SAAS,0CAAuB,KAAiC,EAAE,KAA+B,EAAE,GAAkC;IAC3I,IAAI,aAAa,CAAA,GAAA,aAAK,EAKnB;eACD;eACA;QACA,YAAY;QACZ,eAAe;IACjB,GAAG,OAAO;IACV,WAAW,KAAK,GAAG;IACnB,WAAW,KAAK,GAAG;IAE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AAI,cAAc,UAChB,SAAS,CAAA,oBAAA,gBAAgB,QAAQ,OAAO,KAAK,qBAAqB,EAAE,mBAAmB,oBAA9E,+BAAA,oBACJ,gBAAgB,QAAQ,OAAO,KAAK,qBAAqB,EAAE,eAAe;4BAEnF;4BAEA,WAAW,KAAK,CAAC,SAAS,CAAC,mBAAA,oBAAA,SAAU,WAAW,KAAK,CAAC,MAAM;4BAC5D;wBACF;gBACF;YACF;QACF;IACF,GAAG;QAAC;QAAY;QAAK;QAAQ;KAAU;IAEvC,IAAI,KAAK,CAAA,GAAA,YAAI;IACb,CAAA,GAAA,yCAAqB,EAAE,GAAG,CAAC,OAAO;YAAC;aAAI;IAAG;IAC1C,OAAO;QACL,iBAAiB,CAAA,GAAA,iBAAS,EAAE,WAAW;gBACrC;YACA,oFAAoF;YACpF,6FAA6F;YAC7F,oBAAoB;QACtB;IACF;AACF","sources":["packages/@react-aria/dnd/src/useDroppableCollection.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 {\n clearGlobalDnDState,\n DIRECTORY_DRAG_TYPE,\n droppableCollectionMap,\n getTypes,\n globalDndState,\n isInternalDropOperation,\n setDropCollectionRef\n} from './utils';\nimport {\n Collection,\n DropEvent,\n DropOperation,\n DroppableCollectionDropEvent,\n DroppableCollectionProps,\n DropPosition,\n DropTarget,\n DropTargetDelegate,\n Key,\n KeyboardDelegate,\n Node,\n RefObject\n} from '@react-types/shared';\nimport * as DragManager from './DragManager';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {HTMLAttributes, useCallback, useEffect, useRef} from 'react';\nimport {mergeProps, useId, useLayoutEffect} from '@react-aria/utils';\nimport {setInteractionModality} from '@react-aria/interactions';\nimport {useAutoScroll} from './useAutoScroll';\nimport {useDrop} from './useDrop';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface DroppableCollectionOptions extends DroppableCollectionProps {\n /** A delegate object that implements behavior for keyboard focus movement. */\n keyboardDelegate: KeyboardDelegate,\n /** A delegate object that provides drop targets for pointer coordinates within the collection. */\n dropTargetDelegate: DropTargetDelegate\n}\n\nexport interface DroppableCollectionResult {\n /** Props for the collection element. */\n collectionProps: HTMLAttributes<HTMLElement>\n}\n\ninterface DroppingState {\n collection: Collection<Node<unknown>>,\n focusedKey: Key | null,\n selectedKeys: Set<Key>,\n target: DropTarget,\n draggingKeys: Set<Key | null | undefined>,\n isInternal: boolean,\n timeout: ReturnType<typeof setTimeout> | undefined\n}\n\nconst DROP_POSITIONS: DropPosition[] = ['before', 'on', 'after'];\nconst DROP_POSITIONS_RTL: DropPosition[] = ['after', 'on', 'before'];\n\n/**\n * Handles drop interactions for a collection component, 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 useDroppableCollection(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>): DroppableCollectionResult {\n let localState = useRef<{\n props: DroppableCollectionOptions,\n state: DroppableCollectionState,\n nextTarget: DropTarget | null,\n dropOperation: DropOperation | null\n }>({\n props,\n state,\n nextTarget: null,\n dropOperation: null\n }).current;\n localState.props = props;\n localState.state = state;\n\n let defaultOnDrop = useCallback(async (e: DroppableCollectionDropEvent) => {\n let {\n onInsert,\n onRootDrop,\n onItemDrop,\n onReorder,\n acceptedDragTypes = 'all',\n shouldAcceptItemDrop\n } = localState.props;\n\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let {\n target,\n dropOperation,\n items\n } = e;\n\n let filteredItems = items;\n if (acceptedDragTypes !== 'all' || shouldAcceptItemDrop) {\n filteredItems = items.filter(item => {\n let itemTypes: Set<string | symbol>;\n if (item.kind === 'directory') {\n itemTypes = new Set([DIRECTORY_DRAG_TYPE]);\n } else {\n itemTypes = item.kind === 'file' ? new Set([item.type]) : item.types;\n }\n\n if (acceptedDragTypes === 'all' || acceptedDragTypes.some(type => itemTypes.has(type))) {\n // If we are performing a on item drop, check if the item in question accepts the dropped item since the item may have heavier restrictions\n // than the droppable collection itself\n if (target.type === 'item' && target.dropPosition === 'on' && shouldAcceptItemDrop) {\n return shouldAcceptItemDrop(target, itemTypes);\n }\n return true;\n }\n\n return false;\n });\n }\n\n if (filteredItems.length > 0) {\n if (target.type === 'root' && onRootDrop) {\n await onRootDrop({items: filteredItems, dropOperation});\n }\n\n if (target.type === 'item') {\n if (target.dropPosition === 'on' && onItemDrop) {\n await onItemDrop({items: filteredItems, dropOperation, isInternal, target});\n }\n\n if (target.dropPosition !== 'on') {\n if (!isInternal && onInsert) {\n await onInsert({items: filteredItems, dropOperation, target});\n }\n\n if (isInternal && onReorder) {\n await onReorder({keys: draggingKeys, dropOperation, target});\n }\n }\n }\n }\n }, [localState, ref]);\n\n let autoScroll = useAutoScroll(ref);\n let {dropProps} = useDrop({\n ref,\n onDropEnter() {\n if (localState.nextTarget != null) {\n state.setTarget(localState.nextTarget);\n }\n },\n onDropMove(e) {\n if (localState.nextTarget != null) {\n state.setTarget(localState.nextTarget);\n }\n autoScroll.move(e.x, e.y);\n },\n getDropOperationForPoint(types, allowedOperations, x, y) {\n let {draggingKeys, dropCollectionRef} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let isValidDropTarget = (target) => state.getDropOperation({target, types, allowedOperations, isInternal, draggingKeys}) !== 'cancel';\n let target = props.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);\n if (!target) {\n localState.dropOperation = 'cancel';\n localState.nextTarget = null;\n return 'cancel';\n }\n\n localState.dropOperation = state.getDropOperation({target, types, allowedOperations, isInternal, draggingKeys});\n\n // If the target doesn't accept the drop, see if the root accepts it instead.\n if (localState.dropOperation === 'cancel') {\n let rootTarget: DropTarget = {type: 'root'};\n let dropOperation = state.getDropOperation({target: rootTarget, types, allowedOperations, isInternal, draggingKeys});\n if (dropOperation !== 'cancel') {\n target = rootTarget;\n localState.dropOperation = dropOperation;\n }\n }\n\n // Only set dropCollectionRef if there is a valid drop target since we cleanup dropCollectionRef in onDropExit\n // which only runs when leaving a valid drop target or if the dropEffect become none (mouse dnd only).\n if (target && localState.dropOperation !== 'cancel' && ref?.current !== dropCollectionRef?.current) {\n setDropCollectionRef(ref);\n }\n localState.nextTarget = localState.dropOperation === 'cancel' ? null : target;\n return localState.dropOperation;\n },\n onDropExit() {\n setDropCollectionRef(undefined);\n state.setTarget(null);\n autoScroll.stop();\n },\n onDropActivate(e) {\n if (state.target?.type === 'item' && state.target?.dropPosition === 'on' && typeof props.onDropActivate === 'function') {\n props.onDropActivate({\n type: 'dropactivate',\n x: e.x, // todo\n y: e.y,\n target: state.target\n });\n }\n },\n onDrop(e) {\n setDropCollectionRef(ref);\n if (state.target) {\n onDrop(e, state.target);\n }\n\n // If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a\n // RSP collection and thus we don't need to preserve the global DnD state for onDragEnd\n let {draggingCollectionRef} = globalDndState;\n if (draggingCollectionRef == null) {\n clearGlobalDnDState();\n }\n }\n });\n\n let droppingState = useRef<DroppingState>(null);\n let updateFocusAfterDrop = useCallback(() => {\n let {state} = localState;\n if (droppingState.current) {\n let {\n target,\n collection: prevCollection,\n selectedKeys: prevSelectedKeys,\n focusedKey: prevFocusedKey,\n isInternal,\n draggingKeys\n } = droppingState.current;\n\n // If an insert occurs during a drop, we want to immediately select these items to give\n // feedback to the user that a drop occurred. Only do this if the selection didn't change\n // since the drop started so we don't override if the user or application did something.\n if (\n state.collection.size > prevCollection.size &&\n state.selectionManager.isSelectionEqual(prevSelectedKeys)\n ) {\n let newKeys = new Set<Key>();\n for (let key of state.collection.getKeys()) {\n if (!prevCollection.getItem(key)) {\n newKeys.add(key);\n }\n }\n\n state.selectionManager.setSelectedKeys(newKeys);\n\n // If the focused item didn't change since the drop occurred, also focus the first\n // inserted item. If selection is disabled, then also show the focus ring so there\n // is some indication that items were added.\n if (state.selectionManager.focusedKey === prevFocusedKey) {\n let first: Key | null | undefined = newKeys.keys().next().value;\n if (first != null) {\n let item = state.collection.getItem(first);\n\n // If this is a cell, focus the parent row.\n // eslint-disable-next-line max-depth\n if (item?.type === 'cell') {\n first = item.parentKey;\n }\n\n // eslint-disable-next-line max-depth\n if (first != null) {\n state.selectionManager.setFocusedKey(first);\n }\n\n // eslint-disable-next-line max-depth\n if (state.selectionManager.selectionMode === 'none') {\n setInteractionModality('keyboard');\n }\n }\n }\n } else if (\n prevFocusedKey != null &&\n state.selectionManager.focusedKey === prevFocusedKey &&\n isInternal &&\n target.type === 'item' &&\n target.dropPosition !== 'on' &&\n draggingKeys.has(state.collection.getItem(prevFocusedKey)?.parentKey)\n ) {\n // Focus row instead of cell when reordering.\n state.selectionManager.setFocusedKey(state.collection.getItem(prevFocusedKey)?.parentKey ?? null);\n setInteractionModality('keyboard');\n } else if (\n state.selectionManager.focusedKey === prevFocusedKey &&\n target.type === 'item' &&\n target.dropPosition === 'on' &&\n state.collection.getItem(target.key) != null\n ) {\n // If focus didn't move already (e.g. due to an insert), and the user dropped on an item,\n // focus that item and show the focus ring to give the user feedback that the drop occurred.\n // Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.\n state.selectionManager.setFocusedKey(target.key);\n setInteractionModality('keyboard');\n } else if (state.selectionManager.focusedKey != null && !state.selectionManager.isSelected(state.selectionManager.focusedKey)) {\n setInteractionModality('keyboard');\n }\n\n state.selectionManager.setFocused(true);\n }\n }, [localState]);\n\n let onDrop = useCallback((e: DropEvent, target: DropTarget) => {\n let {state} = localState;\n\n // Save some state of the collection/selection before the drop occurs so we can compare later.\n droppingState.current = {\n timeout: undefined,\n focusedKey: state.selectionManager.focusedKey,\n collection: state.collection,\n selectedKeys: state.selectionManager.selectedKeys,\n draggingKeys: globalDndState.draggingKeys,\n isInternal: isInternalDropOperation(ref),\n target\n };\n\n let onDropFn = localState.props.onDrop || defaultOnDrop;\n onDropFn({\n type: 'drop',\n x: e.x, // todo\n y: e.y,\n target,\n items: e.items,\n dropOperation: e.dropOperation\n });\n\n // Wait for a short time period after the onDrop is called to allow the data to be read asynchronously\n // and for React to re-render. If the collection didn't already change during this time (handled below),\n // update the focused key here.\n droppingState.current.timeout = setTimeout(() => {\n updateFocusAfterDrop();\n droppingState.current = null;\n }, 50);\n }, [localState, defaultOnDrop, ref, updateFocusAfterDrop]);\n\n\n useEffect(() => {\n return () => {\n if (droppingState.current) {\n clearTimeout(droppingState.current.timeout);\n }\n };\n }, []);\n\n useLayoutEffect(() => {\n // If the collection changed after a drop, update the focused key.\n if (droppingState.current && state.collection !== droppingState.current.collection) {\n updateFocusAfterDrop();\n }\n });\n\n let {direction} = useLocale();\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n let getNextTarget = (target: DropTarget | null | undefined, wrap = true, horizontal = false): DropTarget | null => {\n if (!target) {\n return {\n type: 'root'\n };\n }\n\n let {keyboardDelegate} = localState.props;\n let nextKey: Key | null | undefined;\n if (target?.type === 'item') {\n nextKey = horizontal ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyBelow?.(target.key);\n } else {\n nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getLastKey?.() : keyboardDelegate.getFirstKey?.();\n }\n let dropPositions = horizontal && direction === 'rtl' ? DROP_POSITIONS_RTL : DROP_POSITIONS;\n let dropPosition: DropPosition = dropPositions[0];\n\n if (target.type === 'item') {\n // If the the keyboard delegate returned the next key in the collection,\n // first try the other positions in the current key. Otherwise (e.g. in a grid layout),\n // jump to the same drop position in the new key.\n let nextCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyBefore(target.key) : localState.state.collection.getKeyAfter(target.key);\n if (nextKey == null || nextKey === nextCollectionKey) {\n let positionIndex = dropPositions.indexOf(target.dropPosition);\n let nextDropPosition = dropPositions[positionIndex + 1];\n if (positionIndex < dropPositions.length - 1 && !(nextDropPosition === dropPositions[2] && nextKey != null)) {\n return {\n type: 'item',\n key: target.key,\n dropPosition: nextDropPosition\n };\n }\n\n // If the last drop position was 'after', then 'before' on the next key is equivalent.\n // Switch to 'on' instead.\n if (target.dropPosition === dropPositions[2]) {\n dropPosition = 'on';\n }\n } else {\n dropPosition = target.dropPosition;\n }\n }\n\n if (nextKey == null) {\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n }\n\n return {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n };\n\n let getPreviousTarget = (target: DropTarget | null | undefined, wrap = true, horizontal = false): DropTarget | null => {\n let {keyboardDelegate} = localState.props;\n let nextKey: Key | null | undefined;\n if (target?.type === 'item') {\n nextKey = horizontal ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyAbove?.(target.key);\n } else {\n nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getFirstKey?.() : keyboardDelegate.getLastKey?.();\n }\n let dropPositions = horizontal && direction === 'rtl' ? DROP_POSITIONS_RTL : DROP_POSITIONS;\n let dropPosition: DropPosition = !target || target.type === 'root' ? dropPositions[2] : 'on';\n\n if (target?.type === 'item') {\n // If the the keyboard delegate returned the previous key in the collection,\n // first try the other positions in the current key. Otherwise (e.g. in a grid layout),\n // jump to the same drop position in the new key.\n let prevCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyAfter(target.key) : localState.state.collection.getKeyBefore(target.key);\n if (nextKey == null || nextKey === prevCollectionKey) {\n let positionIndex = dropPositions.indexOf(target.dropPosition);\n let nextDropPosition = dropPositions[positionIndex - 1];\n if (positionIndex > 0 && nextDropPosition !== dropPositions[2]) {\n return {\n type: 'item',\n key: target.key,\n dropPosition: nextDropPosition\n };\n }\n\n // If the last drop position was 'before', then 'after' on the previous key is equivalent.\n // Switch to 'on' instead.\n if (target.dropPosition === dropPositions[0]) {\n dropPosition = 'on';\n }\n } else {\n dropPosition = target.dropPosition;\n }\n }\n\n if (nextKey == null) {\n if (wrap) {\n return {\n type: 'root'\n };\n }\n\n return null;\n }\n\n return {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n };\n\n let nextValidTarget = (\n target: DropTarget | null | undefined,\n types: Set<string>,\n allowedDropOperations: DropOperation[],\n getNextTarget: (target: DropTarget | null | undefined, wrap: boolean) => DropTarget | null,\n wrap = true\n ): DropTarget | null => {\n let seenRoot = 0;\n let operation: DropOperation;\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n do {\n let nextTarget = getNextTarget(target, wrap);\n if (!nextTarget) {\n return null;\n }\n target = nextTarget;\n operation = localState.state.getDropOperation({target: nextTarget, types, allowedOperations: allowedDropOperations, isInternal, draggingKeys});\n if (target.type === 'root') {\n seenRoot++;\n }\n } while (\n operation === 'cancel' &&\n !localState.state.isDropTarget(target) &&\n seenRoot < 2\n );\n\n if (operation === 'cancel') {\n return null;\n }\n\n return target;\n };\n\n return DragManager.registerDropTarget({\n element: ref.current,\n preventFocusOnDrop: true,\n getDropOperation(types, allowedOperations) {\n if (localState.state.target) {\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n return localState.state.getDropOperation({target: localState.state.target, types, allowedOperations, isInternal, draggingKeys});\n }\n\n // Check if any of the targets accept the drop.\n // TODO: should we have a faster way of doing this or e.g. for pagination?\n let target = nextValidTarget(null, types, allowedOperations, getNextTarget);\n return target ? 'move' : 'cancel';\n },\n onDropEnter(e, drag) {\n let types = getTypes(drag.items);\n let selectionManager = localState.state.selectionManager;\n let target: DropTarget | null = null;\n // Update the drop collection ref tracker for useDroppableItem's getDropOperation isInternal check\n setDropCollectionRef(ref);\n\n // When entering the droppable collection for the first time, the default drop target\n // is after the focused key.\n let key: Key | null | undefined = selectionManager.focusedKey;\n let dropPosition: DropPosition = 'after';\n\n // If the focused key is a cell, get the parent item instead.\n // For now, we assume that individual cells cannot be dropped on.\n let item = key != null ? localState.state.collection.getItem(key) : null;\n if (item?.type === 'cell') {\n key = item.parentKey;\n }\n\n // If the focused item is also selected, the default drop target is after the last selected item.\n // But if the focused key is the first selected item, then default to before the first selected item.\n // This is to make reordering lists slightly easier. If you select top down, we assume you want to\n // move the items down. If you select bottom up, we assume you want to move the items up.\n if (key != null && selectionManager.isSelected(key)) {\n if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) {\n dropPosition = 'before';\n } else {\n key = selectionManager.lastSelectedKey;\n }\n }\n\n if (key != null) {\n target = {\n type: 'item',\n key,\n dropPosition\n };\n\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n // If the default target is not valid, find the next one that is.\n if (localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys}) === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);\n }\n }\n\n // If no focused key, then start from the root.\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n }\n\n localState.state.setTarget(target);\n },\n onDropExit() {\n setDropCollectionRef(undefined);\n localState.state.setTarget(null);\n },\n onDropTargetEnter(target) {\n localState.state.setTarget(target);\n },\n onDropActivate(e) {\n if (\n localState.state.target?.type === 'item' &&\n localState.state.target?.dropPosition === 'on' &&\n typeof localState.props.onDropActivate === 'function'\n ) {\n localState.props.onDropActivate({\n type: 'dropactivate',\n x: e.x, // todo\n y: e.y,\n target: localState.state.target\n });\n }\n },\n onDrop(e, target) {\n setDropCollectionRef(ref);\n if (localState.state.target) {\n onDrop(e, target || localState.state.target);\n }\n },\n onKeyDown(e, drag) {\n let {keyboardDelegate} = localState.props;\n let types = getTypes(drag.items);\n switch (e.key) {\n case 'ArrowDown': {\n if (keyboardDelegate.getKeyBelow) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getNextTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowUp': {\n if (keyboardDelegate.getKeyAbove) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getPreviousTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowLeft': {\n if (keyboardDelegate.getKeyLeftOf) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap) => getPreviousTarget(target, wrap, true));\n localState.state.setTarget(target);\n }\n break;\n }\n case 'ArrowRight': {\n if (keyboardDelegate.getKeyRightOf) {\n let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap) => getNextTarget(target, wrap, true));\n localState.state.setTarget(target);\n }\n break;\n }\n case 'Home': {\n if (keyboardDelegate.getFirstKey) {\n let target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'End': {\n if (keyboardDelegate.getLastKey) {\n let target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);\n localState.state.setTarget(target);\n }\n break;\n }\n case 'PageDown': {\n if (keyboardDelegate.getKeyPageBelow) {\n let target = localState.state.target;\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);\n } else {\n // If on the root, go to the item a page below the top. Otherwise a page below the current item.\n let targetKey = keyboardDelegate.getFirstKey?.();\n if (target.type === 'item') {\n targetKey = target.key;\n }\n let nextKey: Key | null = null;\n if (targetKey != null) {\n nextKey = keyboardDelegate.getKeyPageBelow(targetKey);\n }\n let dropPosition = target.type === 'item' ? target.dropPosition : 'after';\n\n // If there is no next key, or we are starting on the last key, jump to the last possible position.\n if (nextKey == null || (target.type === 'item' && target.key === keyboardDelegate.getLastKey?.())) {\n nextKey = keyboardDelegate.getLastKey?.() ?? null;\n dropPosition = 'after';\n }\n\n if (nextKey == null) {\n break;\n }\n target = {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n\n // If the target does not accept the drop, find the next valid target.\n // If no next valid target, find the previous valid target.\n let {draggingCollectionRef, draggingKeys} = globalDndState;\n let isInternal = draggingCollectionRef?.current === ref?.current;\n let operation = localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys});\n if (operation === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);\n }\n }\n\n localState.state.setTarget(target ?? localState.state.target);\n }\n break;\n }\n case 'PageUp': {\n if (!keyboardDelegate.getKeyPageAbove) {\n break;\n }\n\n let target = localState.state.target;\n if (!target) {\n target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);\n } else if (target.type === 'item') {\n // If at the top already, switch to the root. Otherwise navigate a page up.\n if (target.key === keyboardDelegate.getFirstKey?.()) {\n target = {\n type: 'root'\n };\n } else {\n let nextKey: Key | null | undefined = keyboardDelegate.getKeyPageAbove(target.key);\n let dropPosition = target.dropPosition;\n if (nextKey == null) {\n nextKey = keyboardDelegate.getFirstKey?.();\n dropPosition = 'before';\n }\n\n if (nextKey == null) {\n break;\n }\n target = {\n type: 'item',\n key: nextKey,\n dropPosition\n };\n }\n\n // If the target does not accept the drop, find the previous valid target.\n // If no next valid target, find the next valid target.\n let {draggingKeys} = globalDndState;\n let isInternal = isInternalDropOperation(ref);\n let operation = localState.state.getDropOperation({target, types, allowedOperations: drag.allowedDropOperations, isInternal, draggingKeys});\n if (operation === 'cancel') {\n target = nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false)\n ?? nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false);\n }\n }\n\n localState.state.setTarget(target ?? localState.state.target);\n break;\n }\n }\n }\n });\n }, [localState, ref, onDrop, direction]);\n\n let id = useId();\n droppableCollectionMap.set(state, {id, ref});\n return {\n collectionProps: mergeProps(dropProps, {\n id,\n // Remove description from collection element. If dropping on the entire collection,\n // there should be a drop indicator that has this description, so no need to double announce.\n 'aria-describedby':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AI,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,wCAAa,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.main.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,0CAAS,KAAiB;IACxC,IAAI,QAAQ,IAAI;IAChB,KAAK,IAAI,QAAQ,MACf,KAAK,IAAI,QAAQ,OAAO,IAAI,CAAC,MAC3B,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C/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,wCAAa,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): string {\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): RefObject<HTMLElement | null> {\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(): string {\n return mapModality(useInteractionModality());\n}\n\nexport function getDragModality(): string {\n return mapModality(getInteractionModality());\n}\n\nexport function writeToDataTransfer(dataTransfer: DataTransfer, items: DragItem[]): void {\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): boolean {\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): DropItem[] {\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>): void {\n globalDndState.draggingCollectionRef = ref;\n}\n\nexport function setDraggingKeys(keys: Set<Key>): void {\n globalDndState.draggingKeys = keys;\n}\n\nexport function setDropCollectionRef(ref?: RefObject<HTMLElement | null>): void {\n globalDndState.dropCollectionRef = ref;\n}\n\nexport function clearGlobalDnDState(): void {\n globalDndState = {draggingKeys: new Set()};\n}\n\nexport function setGlobalDnDState(state: DnDState): void {\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>): boolean {\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): void {\n globalDropEffect = dropEffect;\n}\n\nexport let globalAllowedDropOperations = DROP_OPERATION.none;\nexport function setGlobalAllowedDropOperations(o: DROP_OPERATION): void {\n globalAllowedD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,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
|
+
{"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,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,QAAuB;IAC1C,IAAI,CAA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AAS,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): string {\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): RefObject<HTMLElement | null> {\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(): string {\n return mapModality(useInteractionModality());\n}\n\nexport function getDragModality(): string {\n return mapModality(getInteractionModality());\n}\n\nexport function writeToDataTransfer(dataTransfer: DataTransfer, items: DragItem[]): void {\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): boolean {\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): DropItem[] {\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>): void {\n globalDndState.draggingCollectionRef = ref;\n}\n\nexport function setDraggingKeys(keys: Set<Key>): void {\n globalDndState.draggingKeys = keys;\n}\n\nexport function setDropCollectionRef(ref?: RefObject<HTMLElement | null>): void {\n globalDndState.dropCollectionRef = ref;\n}\n\nexport function clearGlobalDnDState(): void {\n globalDndState = {draggingKeys: new Set()};\n}\n\nexport function setGlobalDnDState(state: DnDState): void {\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>): boolean {\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): void {\n globalDropEffect = dropEffect;\n}\n\nexport let globalAllowedDropOperations = DROP_OPERATION.none;\nexport function setGlobalAllowedDropOperations(o: DROP_OPERATION): void {\n globalAllowedDropOperations = o;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/dnd",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.3",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@internationalized/string": "^3.2.
|
|
26
|
-
"@react-aria/i18n": "^3.12.
|
|
27
|
-
"@react-aria/interactions": "^3.
|
|
28
|
-
"@react-aria/live-announcer": "^3.4.
|
|
29
|
-
"@react-aria/overlays": "^3.
|
|
30
|
-
"@react-aria/utils": "^3.
|
|
31
|
-
"@react-stately/dnd": "^3.5.
|
|
32
|
-
"@react-types/button": "^3.
|
|
33
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@internationalized/string": "^3.2.6",
|
|
26
|
+
"@react-aria/i18n": "^3.12.9",
|
|
27
|
+
"@react-aria/interactions": "^3.25.1",
|
|
28
|
+
"@react-aria/live-announcer": "^3.4.2",
|
|
29
|
+
"@react-aria/overlays": "^3.27.1",
|
|
30
|
+
"@react-aria/utils": "^3.29.0",
|
|
31
|
+
"@react-stately/dnd": "^3.5.4",
|
|
32
|
+
"@react-types/button": "^3.12.1",
|
|
33
|
+
"@react-types/shared": "^3.29.1",
|
|
34
34
|
"@swc/helpers": "^0.5.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "9c77d4e8267ed39469c65f65da94ece7be509874"
|
|
44
44
|
}
|
package/src/DragManager.ts
CHANGED
|
@@ -38,7 +38,7 @@ interface DropTarget {
|
|
|
38
38
|
export function registerDropTarget(target: DropTarget) {
|
|
39
39
|
dropTargets.set(target.element, target);
|
|
40
40
|
dragSession?.updateValidDropTargets();
|
|
41
|
-
return () => {
|
|
41
|
+
return (): void => {
|
|
42
42
|
dropTargets.delete(target.element);
|
|
43
43
|
dragSession?.updateValidDropTargets();
|
|
44
44
|
};
|
|
@@ -52,7 +52,7 @@ interface DroppableItem {
|
|
|
52
52
|
|
|
53
53
|
export function registerDropItem(item: DroppableItem) {
|
|
54
54
|
dropItems.set(item.element, item);
|
|
55
|
-
return () => {
|
|
55
|
+
return (): void => {
|
|
56
56
|
dropItems.delete(item.element);
|
|
57
57
|
};
|
|
58
58
|
}
|
|
@@ -64,7 +64,7 @@ interface DragTarget {
|
|
|
64
64
|
onDragEnd?: (e: DragEndEvent) => void
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export function beginDragging(target: DragTarget, stringFormatter: LocalizedStringFormatter) {
|
|
67
|
+
export function beginDragging(target: DragTarget, stringFormatter: LocalizedStringFormatter): void {
|
|
68
68
|
if (dragSession) {
|
|
69
69
|
throw new Error('Cannot begin dragging while already dragging');
|
|
70
70
|
}
|
|
@@ -84,7 +84,7 @@ export function beginDragging(target: DragTarget, stringFormatter: LocalizedStri
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export function useDragSession() {
|
|
87
|
+
export function useDragSession(): DragSession | null {
|
|
88
88
|
let [session, setSession] = useState(dragSession);
|
|
89
89
|
|
|
90
90
|
useEffect(() => {
|
package/src/useAutoScroll.ts
CHANGED
|
@@ -16,7 +16,12 @@ import {useCallback, useEffect, useRef} from 'react';
|
|
|
16
16
|
|
|
17
17
|
const AUTOSCROLL_AREA_SIZE = 20;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
interface AutoScrollAria {
|
|
20
|
+
move(x: number, y: number): void,
|
|
21
|
+
stop(): void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function useAutoScroll(ref: RefObject<Element | null>): AutoScrollAria {
|
|
20
25
|
let scrollableRef = useRef<Element>(null);
|
|
21
26
|
let scrollableX = useRef(true);
|
|
22
27
|
let scrollableY = useRef(true);
|
package/src/useDrop.ts
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {AriaButtonProps} from '@react-types/button';
|
|
14
|
-
import {
|
|
14
|
+
import {DOMAttributes, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DropOperation, FocusableElement, DragTypes as IDragTypes, RefObject} from '@react-types/shared';
|
|
15
|
+
import {DragEvent, useRef, useState} from 'react';
|
|
15
16
|
import * as DragManager from './DragManager';
|
|
16
17
|
import {DragTypes, globalAllowedDropOperations, globalDndState, readFromDataTransfer, setGlobalDnDState, setGlobalDropEffect} from './utils';
|
|
17
18
|
import {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, DROP_OPERATION_ALLOWED, DROP_OPERATION_TO_DROP_EFFECT} from './constants';
|
|
18
|
-
import {DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropMoveEvent, DropOperation, FocusableElement, DragTypes as IDragTypes, RefObject} from '@react-types/shared';
|
|
19
19
|
import {isIPad, isMac, useEffectEvent, useLayoutEffect} from '@react-aria/utils';
|
|
20
20
|
import {useVirtualDrop} from './useVirtualDrop';
|
|
21
21
|
|
|
@@ -56,7 +56,7 @@ export interface DropOptions {
|
|
|
56
56
|
|
|
57
57
|
export interface DropResult {
|
|
58
58
|
/** Props for the droppable element. */
|
|
59
|
-
dropProps:
|
|
59
|
+
dropProps: DOMAttributes,
|
|
60
60
|
/** Whether the drop target is currently focused or hovered. */
|
|
61
61
|
isDropTarget: boolean,
|
|
62
62
|
/** Props for the explicit drop button affordance, if any. */
|
|
@@ -258,18 +258,25 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:
|
|
|
258
258
|
// inserted item. If selection is disabled, then also show the focus ring so there
|
|
259
259
|
// is some indication that items were added.
|
|
260
260
|
if (state.selectionManager.focusedKey === prevFocusedKey) {
|
|
261
|
-
let first = newKeys.keys().next().value;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
let first: Key | null | undefined = newKeys.keys().next().value;
|
|
262
|
+
if (first != null) {
|
|
263
|
+
let item = state.collection.getItem(first);
|
|
264
|
+
|
|
265
|
+
// If this is a cell, focus the parent row.
|
|
266
|
+
// eslint-disable-next-line max-depth
|
|
267
|
+
if (item?.type === 'cell') {
|
|
268
|
+
first = item.parentKey;
|
|
269
|
+
}
|
|
268
270
|
|
|
269
|
-
|
|
271
|
+
// eslint-disable-next-line max-depth
|
|
272
|
+
if (first != null) {
|
|
273
|
+
state.selectionManager.setFocusedKey(first);
|
|
274
|
+
}
|
|
270
275
|
|
|
271
|
-
|
|
272
|
-
|
|
276
|
+
// eslint-disable-next-line max-depth
|
|
277
|
+
if (state.selectionManager.selectionMode === 'none') {
|
|
278
|
+
setInteractionModality('keyboard');
|
|
279
|
+
}
|
|
273
280
|
}
|
|
274
281
|
}
|
|
275
282
|
} else if (
|
|
@@ -335,7 +342,7 @@ export function useDroppableCollection(props: DroppableCollectionOptions, state:
|
|
|
335
342
|
}, 50);
|
|
336
343
|
}, [localState, defaultOnDrop, ref, updateFocusAfterDrop]);
|
|
337
344
|
|
|
338
|
-
|
|
345
|
+
|
|
339
346
|
useEffect(() => {
|
|
340
347
|
return () => {
|
|
341
348
|
if (droppingState.current) {
|