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C5B,MAAM,kBAAkB,GAAG;YAC3B,MAAM,sBAAsB,GAAG,CAAA,GAAA,6BAAqB;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 {DraggableCollectionProps, DroppableCollectionProps, Key, RefObject} 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<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  renderDragPreview?: (items: DragItem[]) => JSX.Element | {element: JSX.Element, x: number, y: number},\n  isVirtualDragging?: () => boolean\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: AriaDropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => 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> extends Omit<DraggableCollectionProps, 'preview' | 'getItems'>, DroppableCollectionProps {\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  /**\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?: (items: DragItem[]) => 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  /** A custom delegate object that provides drop targets for pointer coordinates within the collection. */\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 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(props: DraggableCollectionStateOpts) {\n        return useDraggableCollectionState({...props, ...options} 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(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      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.mjs.map"}