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AG;YAC5B,MAAM,kBAAkB,GAAG;YAC3B,MAAM,sBAAsB,GAAG,CAAA,GAAA,6DAAqB;QACtD;QAEA,OAAO;IACT,GAAG;QAAC;KAAQ;IAEZ,OAAO;0BACL;IACF;AACF","sources":["packages/react-aria-components/src/useDragAndDrop.tsx"],"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  DropIndicatorProps as AriaDropIndicatorProps,\n  DropIndicatorAria,\n  DroppableCollectionOptions,\n  DroppableCollectionResult,\n  DroppableItemOptions,\n  DroppableItemResult,\n  useDropIndicator,\n  useDroppableCollection,\n  useDroppableItem\n} from 'react-aria/useDroppableCollection';\nimport {\n  DraggableCollectionOptions,\n  DraggableItemProps,\n  DraggableItemResult,\n  DragPreview,\n  useDraggableCollection,\n  useDraggableItem\n} from 'react-aria/useDraggableCollection';\nimport {\n  DraggableCollectionProps,\n  DroppableCollectionProps,\n  Key,\n  RefObject\n} from '@react-types/shared';\nimport {\n  DraggableCollectionState,\n  DraggableCollectionStateOptions,\n  useDraggableCollectionState\n} from 'react-stately/useDraggableCollectionState';\nimport {DragItem, DropTarget, DropTargetDelegate} from '@react-types/shared';\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';\nimport {ListDropTargetDelegate} from 'react-aria/ListDropTargetDelegate';\n\nexport {DropIndicator, DropIndicatorContext, DragAndDropContext} from './DragAndDrop';\nexport type {DropIndicatorProps, DropIndicatorRenderProps} from './DragAndDrop';\n\ninterface DraggableCollectionStateOpts<T = object> 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  renderDragPreview?: (\n    items: DragItem[]\n  ) => JSX.Element | {element: JSX.Element; x: number; y: number};\n  isVirtualDragging?: () => boolean;\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: AriaDropIndicatorProps,\n    state: DroppableCollectionState,\n    ref: RefObject<HTMLElement | null>\n  ) => DropIndicatorAria;\n  renderDropIndicator?: (target: DropTarget) => JSX.Element;\n  dropTargetDelegate?: DropTargetDelegate;\n  ListDropTargetDelegate: typeof ListDropTargetDelegate;\n}\n\nexport type DragAndDropHooks<T = object> = DragHooks<T> & DropHooks;\n\nexport interface DragAndDrop<T = object> {\n  /** Drag and drop hooks for the collection element. */\n  dragAndDropHooks: DragAndDropHooks<T>;\n}\n\nexport interface DragAndDropOptions<T = object>\n  extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {\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   * A function that renders a drag preview, which is shown under the user's cursor while dragging.\n   * By default, a copy of the dragged element is rendered.\n   */\n  renderDragPreview?: (\n    items: DragItem[]\n  ) => JSX.Element | {element: JSX.Element; x: number; y: number};\n  /**\n   * A function that renders a drop indicator element between two items in a collection.\n   * This should render a `<DropIndicator>` element. If this function is not provided, a\n   * default DropIndicator is provided.\n   */\n  renderDropIndicator?: (target: DropTarget) => JSX.Element;\n  /**\n   * A custom delegate object that provides drop targets for pointer coordinates within the\n   * collection.\n   */\n  dropTargetDelegate?: DropTargetDelegate;\n  /** Whether the drag and drop events should be disabled. */\n  isDisabled?: boolean;\n}\n\n/**\n * Provides the hooks required to enable drag and drop behavior for a drag and drop compatible\n * collection component.\n */\nexport function useDragAndDrop<T = object>(options: DragAndDropOptions<T>): DragAndDrop<T> {\n  let dragAndDropHooks = useMemo(() => {\n    let {\n      onDrop,\n      onInsert,\n      onItemDrop,\n      onReorder,\n      onMove,\n      onRootDrop,\n      getItems,\n      renderDragPreview,\n      renderDropIndicator,\n      dropTargetDelegate\n    } = options;\n\n    let isDraggable = !!getItems;\n    let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onMove || onRootDrop);\n\n    let hooks = {} as DragAndDropHooks;\n    if (isDraggable) {\n      hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(\n        props: DraggableCollectionStateOpts\n      ) {\n        return useDraggableCollectionState({\n          ...props,\n          ...options\n        } as DraggableCollectionStateOptions);\n      };\n      hooks.useDraggableCollection = useDraggableCollection;\n      hooks.useDraggableItem = useDraggableItem;\n      hooks.DragPreview = DragPreview;\n      hooks.renderDragPreview = renderDragPreview;\n      hooks.isVirtualDragging = isVirtualDragging;\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      hooks.renderDropIndicator = renderDropIndicator;\n      hooks.dropTargetDelegate = dropTargetDelegate;\n      hooks.ListDropTargetDelegate = ListDropTargetDelegate;\n    }\n\n    return hooks;\n  }, [options]);\n\n  return {\n    dragAndDropHooks\n  };\n}\n"],"names":[],"version":3,"file":"useDragAndDrop.cjs.map"}