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eAAe,CAAC,eAAe,oBAAoB,YAAY;QACjE;sBACA;IACF;AACF","sources":["packages/react-aria/src/dnd/useDroppableItem.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 * as DragManager from './DragManager';\nimport {DroppableCollectionState} from 'react-stately/useDroppableCollectionState';\nimport {DropTarget, FocusableElement, RefObject} from '@react-types/shared';\nimport {getDroppableCollectionRef, getTypes, globalDndState, isInternalDropOperation} from './utils';\nimport {HTMLAttributes, useEffect} from 'react';\nimport {useVirtualDrop} from './useVirtualDrop';\n\nexport interface DroppableItemOptions {\n  /** The drop target represented by the item. */\n  target: DropTarget,\n  /** The ref to the activate button. */\n  activateButtonRef?: RefObject<FocusableElement | null>\n}\n\nexport interface DroppableItemResult {\n  /** Props for the droppable element. */\n  dropProps: HTMLAttributes<HTMLElement>,\n  /** Whether the item is currently the active drop target. */\n  isDropTarget: boolean\n}\n\n/**\n * Handles drop interactions for an item within a collection component.\n */\nexport function useDroppableItem(options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>): DroppableItemResult {\n  let {dropProps} = useVirtualDrop();\n  let droppableCollectionRef = getDroppableCollectionRef(state);\n  useEffect(() => {\n    if (ref.current) {\n      return DragManager.registerDropItem({\n        element: ref.current,\n        target: options.target,\n        getDropOperation(types, allowedOperations) {\n          let {draggingKeys} = globalDndState;\n          let isInternal = isInternalDropOperation(droppableCollectionRef);\n          return state.getDropOperation({\n            target: options.target,\n            types,\n            allowedOperations,\n            isInternal,\n            draggingKeys\n          });\n        },\n        activateButtonRef: options.activateButtonRef\n      });\n    }\n  }, [ref, options.target, state, droppableCollectionRef, options.activateButtonRef]);\n\n  let dragSession = DragManager.useDragSession();\n  let {draggingKeys} = globalDndState;\n  let isInternal = isInternalDropOperation(droppableCollectionRef);\n  let isValidDropTarget = dragSession && state.getDropOperation({\n    target: options.target,\n    types: getTypes(dragSession.dragTarget.items),\n    allowedOperations: dragSession.dragTarget.allowedDropOperations,\n    isInternal,\n    draggingKeys\n  }) !== 'cancel';\n\n  let isDropTarget = state.isDropTarget(options.target);\n  useEffect(() => {\n    if (dragSession && isDropTarget && ref.current) {\n      ref.current.focus();\n    }\n  }, [isDropTarget, dragSession, ref]);\n\n  return {\n    dropProps: {\n      ...dropProps,\n      'aria-hidden': !dragSession || isValidDropTarget ? undefined : 'true'\n    },\n    isDropTarget\n  };\n}\n"],"names":[],"version":3,"file":"useDroppableItem.mjs.map"}