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AI,KAAK,GAAG,CAAC,UAAU,YAAY,OAAO,KAAK,GAAG,CAAC,UAAU,YAAY,KACvE,oBAAoB;gBACpB,sBAAsB,OAAO,GAAG;qBAEhC,sBAAsB,OAAO,GAAG,EAAE,WAAW;YAEjD;QACF;QACA,kBAAiB,CAAC;YAChB,IAAI,CAAA,GAAA,wCAAa,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE,GAAG,KAAK,SAAS;gBAC9D,EAAE,cAAc;gBAChB,EAAE,eAAe;YACnB;QACF;QACA,gBAAe,CAAC;YACd,IAAI,CAAA,GAAA,wCAAa,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE,GAAG,KAAK,SAAS;gBAC9D,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,cAAc,CAAA,GAAA,wCAAa,EAAE;YAC/B;QACF;QACA,SAAQ,CAAC;YACP,yGAAyG;YACzG,IAAI,CAAA,GAAA,wCAAa,EAAE,EAAE,WAAW,KAAK,sBAAsB,OAAO,KAAK,WAAW;gBAChF,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,cAAc,CAAA,GAAA,wCAAa,EAAE;YAC/B;QACF;IACF;IAGF,IAAI,YACF,OAAO;QACL,WAAW;YACT,WAAW;QACb;QACA,iBAAiB,CAAC;QAClB,YAAY;IACd;IAGF,OAAO;QACL,WAAW;YACT,GAAG,YAAY;YACf,WAAW;yBACX;oBACA;uBACA;QACF;QACA,iBAAiB;YACf,GAAG,gBAAgB;qBACnB;QACF;oBACA;IACF;AACF","sources":["packages/react-aria/src/dnd/useDrag.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 {AriaButtonProps} from '../button/useButton';\n\nimport {DragEndEvent, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, PressEvent, RefObject} from '@react-types/shared';\nimport {DragEvent, HTMLAttributes, version as ReactVersion, useEffect, useRef, useState} from 'react';\nimport * as DragManager from './DragManager';\nimport {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, EFFECT_ALLOWED} from './constants';\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {globalDropEffect, setGlobalAllowedDropOperations, setGlobalDropEffect, useDragModality, writeToDataTransfer} from './utils';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {isVirtualClick, isVirtualPointerEvent} from '../utils/isVirtualEvent';\nimport {useDescription} from '../utils/useDescription';\n// @ts-ignore\nimport {useGlobalListeners} from '../utils/useGlobalListeners';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface DragOptions {\n  /** Handler that is called when a drag operation is started. */\n  onDragStart?: (e: DragStartEvent) => void,\n  /** Handler that is called when the drag is moved. */\n  onDragMove?: (e: DragMoveEvent) => void,\n  /** Handler that is called when the drag operation is ended, either as a result of a drop or a cancellation. */\n  onDragEnd?: (e: DragEndEvent) => void,\n  /** A function that returns the items being dragged. */\n  getItems: () => DragItem[],\n  /** The ref of the element that will be rendered as the drag preview while dragging. */\n  preview?: RefObject<DragPreviewRenderer | null>,\n  /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */\n  getAllowedDropOperations?: () => DropOperation[],\n  /**\n   * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop mode.\n   * If true, the dragProps will omit these event handlers, and they will be applied to dragButtonProps instead.\n   */\n  hasDragButton?: boolean,\n  /**\n   * Whether the drag operation is disabled. If true, the element will not be draggable.\n   */\n  isDisabled?: boolean\n}\n\nexport interface DragResult {\n  /** Props for the draggable element. */\n  dragProps: HTMLAttributes<HTMLElement>,\n  /** Props for the explicit drag button affordance, if any. */\n  dragButtonProps: AriaButtonProps,\n  /** Whether the element is currently being dragged. */\n  isDragging: boolean\n}\n\nconst MESSAGES = {\n  keyboard: {\n    start: 'dragDescriptionKeyboard',\n    end: 'endDragKeyboard'\n  },\n  touch: {\n    start: 'dragDescriptionTouch',\n    end: 'endDragTouch'\n  },\n  virtual: {\n    start: 'dragDescriptionVirtual',\n    end: 'endDragVirtual'\n  }\n};\n\n/**\n * Handles drag interactions for an element, with support for traditional mouse and touch\n * based drag and drop, in addition to full parity for keyboard and screen reader users.\n */\nexport function useDrag(options: DragOptions): DragResult {\n  let {hasDragButton, isDisabled} = options;\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n  let state = useRef({\n    options,\n    x: 0,\n    y: 0\n  }).current;\n  state.options = options;\n  let isDraggingRef = useRef<Element | null>(null);\n  let [isDragging, setDraggingState] = useState(false);\n  let setDragging = (element: Element | null) => {\n    isDraggingRef.current = element;\n    setDraggingState(!!element);\n  };\n  let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();\n  let modalityOnPointerDown = useRef<string>(null);\n\n  let onDragStart = (e: DragEvent) => {\n    if (e.defaultPrevented) {\n      return;\n    }\n\n    // Prevent the drag event from propagating to any parent draggables\n    e.stopPropagation();\n\n    // If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.\n    if (modalityOnPointerDown.current === 'virtual') {\n      e.preventDefault();\n      startDragging(getEventTarget(e) as HTMLElement);\n      modalityOnPointerDown.current = null;\n      return;\n    }\n\n    if (typeof options.onDragStart === 'function') {\n      options.onDragStart({\n        type: 'dragstart',\n        x: e.clientX,\n        y: e.clientY\n      });\n    }\n\n    let items = options.getItems();\n    // Clear existing data (e.g. selected text on the page would be included in some browsers)\n    e.dataTransfer.clearData?.();\n    writeToDataTransfer(e.dataTransfer, items);\n\n    let allowed = DROP_OPERATION.all;\n    if (typeof options.getAllowedDropOperations === 'function') {\n      let allowedOperations = options.getAllowedDropOperations();\n      allowed = DROP_OPERATION.none;\n      for (let operation of allowedOperations) {\n        allowed |= DROP_OPERATION[operation] || DROP_OPERATION.none;\n      }\n    }\n\n    setGlobalAllowedDropOperations(allowed);\n    let effectAllowed = EFFECT_ALLOWED[allowed] || 'none';\n    e.dataTransfer.effectAllowed = effectAllowed === 'cancel' ? 'none' : effectAllowed;\n\n    // If there is a preview option, use it to render a custom preview image that will\n    // appear under the pointer while dragging. If not, the element itself is dragged by the browser.\n    if (typeof options.preview?.current === 'function') {\n      options.preview.current(items, (node, userX, userY) => {\n        if (!node) {\n          return;\n        }\n        // Compute the offset that the preview will appear under the mouse.\n        // If possible, this is based on the point the user clicked on the target.\n        // If the preview is much smaller, then just use the center point of the preview.\n        let size = node.getBoundingClientRect();\n        let rect = e.currentTarget.getBoundingClientRect();\n        let defaultX = e.clientX - rect.x;\n        let defaultY = e.clientY - rect.y;\n        if (defaultX > size.width || defaultY > size.height) {\n          defaultX = size.width / 2;\n          defaultY = size.height / 2;\n        }\n\n        // Start with default offsets.\n        let offsetX = defaultX;\n        let offsetY = defaultY;\n\n        // If the preview renderer supplied explicit offsets, use those.\n        if (typeof userX === 'number' && typeof userY === 'number') {\n          offsetX = userX;\n          offsetY = userY;\n        }\n\n        // Clamp the offset so it stays within the preview bounds. Browsers\n        // automatically clamp out-of-range values, but doing it ourselves\n        // prevents the visible \"snap\" that can occur when the browser adjusts\n        // them after the first drag update.\n        offsetX = Math.max(0, Math.min(offsetX, size.width));\n        offsetY = Math.max(0, Math.min(offsetY, size.height));\n\n        // Rounding height to an even number prevents blurry preview seen on some screens\n        let height = 2 * Math.round(size.height / 2);\n        node.style.height = `${height}px`;\n\n        e.dataTransfer.setDragImage(node, offsetX, offsetY);\n      });\n    }\n\n    // Enforce that drops are handled by useDrop.\n    addGlobalListener(window, 'drop', e => {\n      e.preventDefault();\n      e.stopPropagation();\n      console.warn('Drags initiated from the React Aria useDrag hook may only be dropped on a target created with useDrop. This ensures that a keyboard and screen reader accessible alternative is available.');\n    }, {once: true});\n    state.x = e.clientX;\n    state.y = e.clientY;\n\n    // Wait a frame before we set dragging to true so that the browser has time to\n    // render the preview image before we update the element that has been dragged.\n    let target = getEventTarget(e);\n    requestAnimationFrame(() => {\n      setDragging(target);\n    });\n  };\n\n  let onDrag = (e: DragEvent) => {\n    // Prevent the drag event from propagating to any parent draggables\n    e.stopPropagation();\n\n    if (e.clientX === state.x && e.clientY === state.y) {\n      return;\n    }\n\n    if (typeof options.onDragMove === 'function') {\n      options.onDragMove({\n        type: 'dragmove',\n        x: e.clientX,\n        y: e.clientY\n      });\n    }\n\n    state.x = e.clientX;\n    state.y = e.clientY;\n  };\n\n  let onDragEnd = (e: DragEvent) => {\n    // Prevent the drag event from propagating to any parent draggables\n    e.stopPropagation();\n\n    if (typeof options.onDragEnd === 'function') {\n      let event: DragEndEvent = {\n        type: 'dragend',\n        x: e.clientX,\n        y: e.clientY,\n        dropOperation: DROP_EFFECT_TO_DROP_OPERATION[e.dataTransfer.dropEffect]\n      };\n\n      // Chrome Android always returns none as its dropEffect so we use the drop effect set in useDrop via\n      // onDragEnter/onDragOver instead. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951\n      if (globalDropEffect) {\n        event.dropOperation = DROP_EFFECT_TO_DROP_OPERATION[globalDropEffect];\n      }\n      options.onDragEnd(event);\n    }\n\n    setDragging(null);\n    removeAllGlobalListeners();\n    setGlobalAllowedDropOperations(DROP_OPERATION.none);\n    setGlobalDropEffect(undefined);\n  };\n\n  // If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801\n  // In this case, we need to manually call onDragEnd on cleanup\n\n  useEffect(() => {\n    return () => {\n      // Check that the dragged element has actually unmounted from the DOM and not a React Strict Mode false positive.\n      // https://github.com/facebook/react/issues/29585\n      // React 16 ran effect cleanups before removing elements from the DOM but did not have this issue.\n      if (isDraggingRef.current && (!isDraggingRef.current.isConnected || parseInt(ReactVersion, 10) < 17)) {\n        if (typeof state.options.onDragEnd === 'function') {\n          let event: DragEndEvent = {\n            type: 'dragend',\n            x: 0,\n            y: 0,\n            dropOperation: DROP_EFFECT_TO_DROP_OPERATION[globalDropEffect || 'none']\n          };\n          state.options.onDragEnd(event);\n        }\n\n        setDragging(null);\n        setGlobalAllowedDropOperations(DROP_OPERATION.none);\n        setGlobalDropEffect(undefined);\n      }\n    };\n  }, [state]);\n\n  let onPress = (e: PressEvent) => {\n    if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') {\n      return;\n    }\n\n    startDragging(e.target as HTMLElement);\n  };\n\n  let startDragging = (target: HTMLElement) => {\n    if (typeof state.options.onDragStart === 'function') {\n      let rect = target.getBoundingClientRect();\n      state.options.onDragStart({\n        type: 'dragstart',\n        x: rect.x + (rect.width / 2),\n        y: rect.y + (rect.height / 2)\n      });\n    }\n\n    DragManager.beginDragging({\n      element: target,\n      items: state.options.getItems(),\n      allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function'\n        ? state.options.getAllowedDropOperations()\n        : ['move', 'copy', 'link'],\n      onDragEnd(e) {\n        setDragging(null);\n        if (typeof state.options.onDragEnd === 'function') {\n          state.options.onDragEnd(e);\n        }\n      }\n    }, stringFormatter);\n\n    setDragging(target);\n  };\n\n  let modality = useDragModality();\n  let message = !isDragging ? MESSAGES[modality].start : MESSAGES[modality].end;\n\n  let descriptionProps = useDescription(stringFormatter.format(message));\n\n  let interactions: HTMLAttributes<HTMLElement> = {};\n  if (!hasDragButton) {\n    // If there's no separate button to trigger accessible drag and drop mode,\n    // then add event handlers to the draggable element itself to start dragging.\n    // For keyboard, we use the Enter key in a capturing listener to prevent other\n    // events such as selection from also occurring. We attempt to infer whether a\n    // pointer event (e.g. long press) came from a touch screen reader, and then initiate\n    // dragging in the native onDragStart listener above.\n\n    interactions = {\n      ...descriptionProps,\n      onPointerDown(e) {\n        modalityOnPointerDown.current = isVirtualPointerEvent(e.nativeEvent) ? 'virtual' : e.pointerType;\n\n        // Try to detect virtual drag passthrough gestures.\n        if (e.width < 1 && e.height < 1) {\n          // iOS VoiceOver.\n          modalityOnPointerDown.current = 'virtual';\n        } else {\n          let rect = e.currentTarget.getBoundingClientRect();\n          let offsetX = e.clientX - rect.x;\n          let offsetY = e.clientY - rect.y;\n          let centerX = rect.width / 2;\n          let centerY = rect.height / 2;\n\n          if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) {\n            // Android TalkBack.\n            modalityOnPointerDown.current = 'virtual';\n          } else {\n            modalityOnPointerDown.current = e.pointerType;\n          }\n        }\n      },\n      onKeyDownCapture(e) {\n        if (getEventTarget(e) === e.currentTarget && e.key === 'Enter') {\n          e.preventDefault();\n          e.stopPropagation();\n        }\n      },\n      onKeyUpCapture(e) {\n        if (getEventTarget(e) === e.currentTarget && e.key === 'Enter') {\n          e.preventDefault();\n          e.stopPropagation();\n          startDragging(getEventTarget(e));\n        }\n      },\n      onClick(e) {\n        // Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.\n        if (isVirtualClick(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {\n          e.preventDefault();\n          e.stopPropagation();\n          startDragging(getEventTarget(e));\n        }\n      }\n    };\n  }\n\n  if (isDisabled) {\n    return {\n      dragProps: {\n        draggable: 'false'\n      },\n      dragButtonProps: {},\n      isDragging: false\n    };\n  }\n\n  return {\n    dragProps: {\n      ...interactions,\n      draggable: 'true',\n      onDragStart,\n      onDrag,\n      onDragEnd\n    },\n    dragButtonProps: {\n      ...descriptionProps,\n      onPress\n    },\n    isDragging\n  };\n}\n"],"names":[],"version":3,"file":"useDrag.cjs.map"}