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AAQ;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 {DraggableCollectionProps, DragItem, DroppableCollectionProps, Key, RefObject} 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<DraggableCollectionStateOptions<T>, 'getItems'> {}\n\ninterface DragHooks<T = object> {\n  useDraggableCollectionState?: (props: DraggableCollectionStateOpts<T>) => DraggableCollectionState,\n  useDraggableCollection?: (props: DraggableCollectionOptions, state: DraggableCollectionState, ref: RefObject<HTMLElement | null>) => void,\n  useDraggableItem?: (props: DraggableItemProps, state: DraggableCollectionState) => DraggableItemResult,\n  DragPreview?: typeof DragPreview\n}\n\ninterface DropHooks {\n  useDroppableCollectionState?: (props: DroppableCollectionStateOptions) => DroppableCollectionState,\n  useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableCollectionResult,\n  useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableItemResult,\n  useDropIndicator?: (props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DropIndicatorAria\n}\n\nexport interface DragAndDropHooks<T = object> {\n  /** Drag and drop hooks for the collection element.  */\n  dragAndDropHooks: DragHooks<T> & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element}\n}\n\nexport interface DragAndDropOptions<T = object> extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, Omit<DroppableCollectionProps, 'onMove'> {\n  /**\n   * A function that returns the items being dragged. If not specified, we assume that the collection is not draggable.\n   * @default () => []\n   */\n  getItems?: (keys: Set<Key>, items: T[]) => DragItem[],\n  /** Provide a custom drag preview. `draggedKey` represents the key of the item the user actually dragged. */\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 Spectrum component.\n */\nexport function useDragAndDrop<T = object>(options: DragAndDropOptions<T>): DragAndDropHooks {\n  let dragAndDropHooks = useMemo(() => {\n    let {\n      onDrop,\n      onInsert,\n      onItemDrop,\n      onReorder,\n      onRootDrop,\n      getItems,\n      renderPreview\n     } = options;\n\n    let isDraggable = !!getItems;\n    let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);\n\n    let hooks = {} as DragHooks & DropHooks & {isVirtualDragging?: () => boolean, renderPreview?: (keys: Set<Key>, draggedKey: Key) => JSX.Element};\n    if (isDraggable) {\n      hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props: DraggableCollectionStateOpts<T>) {\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(props: DroppableCollectionStateOptions) {\n        return useDroppableCollectionState({...props, ...options});\n      };\n      hooks.useDroppableItem = useDroppableItem;\n      hooks.useDroppableCollection = function useDroppableCollectionOverride(props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) {\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.cjs.map"}