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C;KAAQ;IAEZ,OAAO;QACL,kBAAkB;IACpB;AACF","sources":["packages/@adobe/react-spectrum/src/dnd/useDragAndDrop.ts"],"sourcesContent":["/*\n * Copyright 2022 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  DraggableCollectionOptions,\n  DraggableItemProps,\n  DraggableItemResult,\n  DragPreview,\n  useDraggableCollection,\n  useDraggableItem\n} from 'react-aria/useDraggableCollection';\nimport {\n  DraggableCollectionProps,\n  DragItem,\n  DroppableCollectionProps,\n  Key,\n  RefObject\n} from '@react-types/shared';\nimport {\n  DraggableCollectionState,\n  DraggableCollectionStateOptions,\n  useDraggableCollectionState\n} from 'react-stately/useDraggableCollectionState';\nimport {\n  DropIndicatorAria,\n  DropIndicatorProps,\n  DroppableCollectionOptions,\n  DroppableCollectionResult,\n  DroppableItemOptions,\n  DroppableItemResult,\n  useDropIndicator,\n  useDroppableCollection,\n  useDroppableItem\n} from 'react-aria/useDroppableCollection';\nimport {\n  DroppableCollectionState,\n  DroppableCollectionStateOptions,\n  useDroppableCollectionState\n} from 'react-stately/useDroppableCollectionState';\nimport {isVirtualDragging} from 'react-aria/private/dnd/DragManager';\nimport {JSX, useMemo} from 'react';\n\ninterface DraggableCollectionStateOpts<T> extends Omit<\n  DraggableCollectionStateOptions<T>,\n  'getItems'\n> {}\n\ninterface DragHooks<T = object> {\n  useDraggableCollectionState?: (\n    props: DraggableCollectionStateOpts<T>\n  ) => DraggableCollectionState;\n  useDraggableCollection?: (\n    props: DraggableCollectionOptions,\n    state: DraggableCollectionState,\n    ref: RefObject<HTMLElement | null>\n  ) => void;\n  useDraggableItem?: (\n    props: DraggableItemProps,\n    state: DraggableCollectionState\n  ) => DraggableItemResult;\n  DragPreview?: typeof DragPreview;\n}\n\ninterface DropHooks {\n  useDroppableCollectionState?: (\n    props: DroppableCollectionStateOptions\n  ) => DroppableCollectionState;\n  useDroppableCollection?: (\n    props: DroppableCollectionOptions,\n    state: DroppableCollectionState,\n    ref: RefObject<HTMLElement | null>\n  ) => DroppableCollectionResult;\n  useDroppableItem?: (\n    options: DroppableItemOptions,\n    state: DroppableCollectionState,\n    ref: RefObject<HTMLElement | null>\n  ) => DroppableItemResult;\n  useDropIndicator?: (\n    props: DropIndicatorProps,\n    state: DroppableCollectionState,\n    ref: RefObject<HTMLElement | null>\n  ) => DropIndicatorAria;\n}\n\nexport interface DragAndDropHooks<T = object> {\n  /** Drag and drop hooks for the collection element. */\n  dragAndDropHooks: DragHooks<T> &\n    DropHooks & {\n      isVirtualDragging?: () => boolean;\n      renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element;\n    };\n}\n\nexport interface DragAndDropOptions<T = object>\n  extends\n    Omit<DraggableCollectionProps, 'preview' | 'getItems'>,\n    Omit<DroppableCollectionProps, 'onMove'> {\n  /**\n   * A function that returns the items being dragged. If not specified, we assume that the\n   * collection is not draggable.\n   *\n   * @default () => []\n   */\n  getItems?: (keys: Set<Key>, items: T[]) => DragItem[];\n  /**\n   * Provide a custom drag preview. `draggedKey` represents the key of the item the user actually\n   * dragged.\n   */\n  renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element;\n}\n\n/**\n * Provides the hooks required to enable drag and drop behavior for a drag and drop compatible React\n * Spectrum component.\n */\nexport function useDragAndDrop<T = object>(options: DragAndDropOptions<T>): DragAndDropHooks {\n  let dragAndDropHooks = useMemo(() => {\n    let {onDrop, onInsert, onItemDrop, onReorder, onRootDrop, getItems, renderPreview} = options;\n\n    let isDraggable = !!getItems;\n    let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n    let hooks = {} as DragHooks &\n      DropHooks & {\n        isVirtualDragging?: () => boolean;\n        renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element;\n      };\n    if (isDraggable) {\n      hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(\n        props: DraggableCollectionStateOpts<T>\n      ) {\n        return useDraggableCollectionState({...props, ...options, getItems: options.getItems!});\n      };\n      hooks.useDraggableCollection = useDraggableCollection;\n      hooks.useDraggableItem = useDraggableItem;\n      hooks.DragPreview = DragPreview;\n      hooks.renderPreview = renderPreview;\n    }\n\n    if (isDroppable) {\n      hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(\n        props: DroppableCollectionStateOptions\n      ) {\n        return useDroppableCollectionState({...props, ...options});\n      };\n      hooks.useDroppableItem = useDroppableItem;\n      hooks.useDroppableCollection = function useDroppableCollectionOverride(\n        props: DroppableCollectionOptions,\n        state: DroppableCollectionState,\n        ref: RefObject<HTMLElement | null>\n      ) {\n        return useDroppableCollection({...props, ...options}, state, ref);\n      };\n      hooks.useDropIndicator = useDropIndicator;\n    }\n\n    if (isDraggable || isDroppable) {\n      hooks.isVirtualDragging = isVirtualDragging;\n    }\n\n    return hooks;\n  }, [options]);\n\n  return {\n    dragAndDropHooks: dragAndDropHooks\n  };\n}\n"],"names":[],"version":3,"file":"useDragAndDrop.mjs.map"}