react-aria 3.49.0 → 3.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/private/autocomplete/useAutocomplete.cjs +16 -7
- package/dist/private/autocomplete/useAutocomplete.cjs.map +1 -1
- package/dist/private/autocomplete/useAutocomplete.js +16 -7
- package/dist/private/autocomplete/useAutocomplete.js.map +1 -1
- package/dist/private/autocomplete/useAutocomplete.mjs +16 -7
- package/dist/private/autocomplete/useAutocomplete.mjs.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.cjs.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.js.map +1 -1
- package/dist/private/breadcrumbs/useBreadcrumbs.mjs.map +1 -1
- package/dist/private/calendar/useCalendarBase.cjs.map +1 -1
- package/dist/private/calendar/useCalendarBase.js.map +1 -1
- package/dist/private/calendar/useCalendarBase.mjs.map +1 -1
- package/dist/private/calendar/useCalendarCell.cjs.map +1 -1
- package/dist/private/calendar/useCalendarCell.js.map +1 -1
- package/dist/private/calendar/useCalendarCell.mjs.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.cjs +4 -4
- package/dist/private/calendar/useCalendarYearPicker.cjs.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.js +4 -4
- package/dist/private/calendar/useCalendarYearPicker.js.map +1 -1
- package/dist/private/calendar/useCalendarYearPicker.mjs +4 -4
- package/dist/private/calendar/useCalendarYearPicker.mjs.map +1 -1
- package/dist/private/calendar/utils.cjs.map +1 -1
- package/dist/private/calendar/utils.js.map +1 -1
- package/dist/private/calendar/utils.mjs.map +1 -1
- package/dist/private/color/useColorArea.cjs.map +1 -1
- package/dist/private/color/useColorArea.js.map +1 -1
- package/dist/private/color/useColorArea.mjs.map +1 -1
- package/dist/private/color/useColorSwatch.cjs.map +1 -1
- package/dist/private/color/useColorSwatch.js.map +1 -1
- package/dist/private/color/useColorSwatch.mjs.map +1 -1
- package/dist/private/combobox/useComboBox.cjs +2 -0
- package/dist/private/combobox/useComboBox.cjs.map +1 -1
- package/dist/private/combobox/useComboBox.js +2 -0
- package/dist/private/combobox/useComboBox.js.map +1 -1
- package/dist/private/combobox/useComboBox.mjs +2 -0
- package/dist/private/combobox/useComboBox.mjs.map +1 -1
- package/dist/private/datepicker/useDateField.cjs.map +1 -1
- package/dist/private/datepicker/useDateField.js.map +1 -1
- package/dist/private/datepicker/useDateField.mjs.map +1 -1
- package/dist/private/datepicker/useDatePicker.cjs.map +1 -1
- package/dist/private/datepicker/useDatePicker.js.map +1 -1
- package/dist/private/datepicker/useDatePicker.mjs.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.cjs.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.js.map +1 -1
- package/dist/private/datepicker/useDateRangePicker.mjs.map +1 -1
- package/dist/private/datepicker/useDisplayNames.cjs +1 -2
- package/dist/private/datepicker/useDisplayNames.cjs.map +1 -1
- package/dist/private/datepicker/useDisplayNames.js +1 -2
- package/dist/private/datepicker/useDisplayNames.js.map +1 -1
- package/dist/private/datepicker/useDisplayNames.mjs +1 -2
- package/dist/private/datepicker/useDisplayNames.mjs.map +1 -1
- package/dist/private/dnd/DragManager.cjs +4 -1
- package/dist/private/dnd/DragManager.cjs.map +1 -1
- package/dist/private/dnd/DragManager.js +4 -1
- package/dist/private/dnd/DragManager.js.map +1 -1
- package/dist/private/dnd/DragManager.mjs +4 -1
- package/dist/private/dnd/DragManager.mjs.map +1 -1
- package/dist/private/dnd/useDrag.cjs.map +1 -1
- package/dist/private/dnd/useDrag.js.map +1 -1
- package/dist/private/dnd/useDrag.mjs.map +1 -1
- package/dist/private/dnd/useDraggableItem.cjs.map +1 -1
- package/dist/private/dnd/useDraggableItem.js.map +1 -1
- package/dist/private/dnd/useDraggableItem.mjs.map +1 -1
- package/dist/private/dnd/useDropIndicator.cjs.map +1 -1
- package/dist/private/dnd/useDropIndicator.js.map +1 -1
- package/dist/private/dnd/useDropIndicator.mjs.map +1 -1
- package/dist/private/dnd/useVirtualDrop.cjs.map +1 -1
- package/dist/private/dnd/useVirtualDrop.js.map +1 -1
- package/dist/private/dnd/useVirtualDrop.mjs.map +1 -1
- package/dist/private/dnd/utils.cjs +13 -3
- package/dist/private/dnd/utils.cjs.map +1 -1
- package/dist/private/dnd/utils.js +13 -3
- package/dist/private/dnd/utils.js.map +1 -1
- package/dist/private/dnd/utils.mjs +13 -3
- package/dist/private/dnd/utils.mjs.map +1 -1
- package/dist/private/form/useFormValidation.cjs +1 -1
- package/dist/private/form/useFormValidation.cjs.map +1 -1
- package/dist/private/form/useFormValidation.js +1 -1
- package/dist/private/form/useFormValidation.js.map +1 -1
- package/dist/private/form/useFormValidation.mjs +1 -1
- package/dist/private/form/useFormValidation.mjs.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.cjs.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.js.map +1 -1
- package/dist/private/grid/useGridSelectionAnnouncement.mjs.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.cjs.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.js.map +1 -1
- package/dist/private/grid/useGridSelectionCheckbox.mjs.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.cjs.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.js.map +1 -1
- package/dist/private/grid/useHighlightSelectionDescription.mjs.map +1 -1
- package/dist/private/gridlist/useGridList.cjs +2 -1
- package/dist/private/gridlist/useGridList.cjs.map +1 -1
- package/dist/private/gridlist/useGridList.js +2 -1
- package/dist/private/gridlist/useGridList.js.map +1 -1
- package/dist/private/gridlist/useGridList.mjs +2 -1
- package/dist/private/gridlist/useGridList.mjs.map +1 -1
- package/dist/private/gridlist/useGridListItem.cjs +62 -21
- package/dist/private/gridlist/useGridListItem.cjs.map +1 -1
- package/dist/private/gridlist/useGridListItem.js +63 -22
- package/dist/private/gridlist/useGridListItem.js.map +1 -1
- package/dist/private/gridlist/useGridListItem.mjs +62 -21
- package/dist/private/gridlist/useGridListItem.mjs.map +1 -1
- package/dist/private/interactions/createEventHandler.cjs +3 -0
- package/dist/private/interactions/createEventHandler.cjs.map +1 -1
- package/dist/private/interactions/createEventHandler.js +3 -0
- package/dist/private/interactions/createEventHandler.js.map +1 -1
- package/dist/private/interactions/createEventHandler.mjs +3 -0
- package/dist/private/interactions/createEventHandler.mjs.map +1 -1
- package/dist/private/interactions/useFocusVisible.cjs +16 -5
- package/dist/private/interactions/useFocusVisible.cjs.map +1 -1
- package/dist/private/interactions/useFocusVisible.js +16 -5
- package/dist/private/interactions/useFocusVisible.js.map +1 -1
- package/dist/private/interactions/useFocusVisible.mjs +16 -5
- package/dist/private/interactions/useFocusVisible.mjs.map +1 -1
- package/dist/private/menu/useMenu.cjs.map +1 -1
- package/dist/private/menu/useMenu.js.map +1 -1
- package/dist/private/menu/useMenu.mjs.map +1 -1
- package/dist/private/menu/useMenuItem.cjs +1 -1
- package/dist/private/menu/useMenuItem.cjs.map +1 -1
- package/dist/private/menu/useMenuItem.js +1 -1
- package/dist/private/menu/useMenuItem.js.map +1 -1
- package/dist/private/menu/useMenuItem.mjs +1 -1
- package/dist/private/menu/useMenuItem.mjs.map +1 -1
- package/dist/private/menu/useMenuTrigger.cjs.map +1 -1
- package/dist/private/menu/useMenuTrigger.js.map +1 -1
- package/dist/private/menu/useMenuTrigger.mjs.map +1 -1
- package/dist/private/menu/utils.cjs.map +1 -1
- package/dist/private/menu/utils.js.map +1 -1
- package/dist/private/menu/utils.mjs.map +1 -1
- package/dist/private/numberfield/useNumberField.cjs.map +1 -1
- package/dist/private/numberfield/useNumberField.js.map +1 -1
- package/dist/private/numberfield/useNumberField.mjs.map +1 -1
- package/dist/private/overlays/DismissButton.cjs.map +1 -1
- package/dist/private/overlays/DismissButton.js.map +1 -1
- package/dist/private/overlays/DismissButton.mjs.map +1 -1
- package/dist/private/overlays/calculatePosition.cjs +7 -7
- package/dist/private/overlays/calculatePosition.cjs.map +1 -1
- package/dist/private/overlays/calculatePosition.js +7 -7
- package/dist/private/overlays/calculatePosition.js.map +1 -1
- package/dist/private/overlays/calculatePosition.mjs +7 -7
- package/dist/private/overlays/calculatePosition.mjs.map +1 -1
- package/dist/private/overlays/useOverlayPosition.cjs +3 -2
- package/dist/private/overlays/useOverlayPosition.cjs.map +1 -1
- package/dist/private/overlays/useOverlayPosition.js +3 -2
- package/dist/private/overlays/useOverlayPosition.js.map +1 -1
- package/dist/private/overlays/useOverlayPosition.mjs +3 -2
- package/dist/private/overlays/useOverlayPosition.mjs.map +1 -1
- package/dist/private/searchfield/useSearchField.cjs.map +1 -1
- package/dist/private/searchfield/useSearchField.js.map +1 -1
- package/dist/private/searchfield/useSearchField.mjs.map +1 -1
- package/dist/private/select/useSelect.cjs +1 -2
- package/dist/private/select/useSelect.cjs.map +1 -1
- package/dist/private/select/useSelect.js +1 -2
- package/dist/private/select/useSelect.js.map +1 -1
- package/dist/private/select/useSelect.mjs +1 -2
- package/dist/private/select/useSelect.mjs.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.cjs +31 -3
- package/dist/private/selection/ListKeyboardDelegate.cjs.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.js +31 -3
- package/dist/private/selection/ListKeyboardDelegate.js.map +1 -1
- package/dist/private/selection/ListKeyboardDelegate.mjs +31 -3
- package/dist/private/selection/ListKeyboardDelegate.mjs.map +1 -1
- package/dist/private/selection/useSelectableCollection.cjs +20 -14
- package/dist/private/selection/useSelectableCollection.cjs.map +1 -1
- package/dist/private/selection/useSelectableCollection.js +26 -19
- package/dist/private/selection/useSelectableCollection.js.map +1 -1
- package/dist/private/selection/useSelectableCollection.mjs +20 -14
- package/dist/private/selection/useSelectableCollection.mjs.map +1 -1
- package/dist/private/selection/useTypeSelect.cjs +50 -18
- package/dist/private/selection/useTypeSelect.cjs.map +1 -1
- package/dist/private/selection/useTypeSelect.js +51 -19
- package/dist/private/selection/useTypeSelect.js.map +1 -1
- package/dist/private/selection/useTypeSelect.mjs +51 -19
- package/dist/private/selection/useTypeSelect.mjs.map +1 -1
- package/dist/private/spinbutton/useSpinButton.cjs.map +1 -1
- package/dist/private/spinbutton/useSpinButton.js.map +1 -1
- package/dist/private/spinbutton/useSpinButton.mjs.map +1 -1
- package/dist/private/steplist/useStepList.cjs.map +1 -1
- package/dist/private/steplist/useStepList.js.map +1 -1
- package/dist/private/steplist/useStepList.mjs.map +1 -1
- package/dist/private/table/useTable.cjs.map +1 -1
- package/dist/private/table/useTable.js.map +1 -1
- package/dist/private/table/useTable.mjs.map +1 -1
- package/dist/private/table/useTableColumnHeader.cjs.map +1 -1
- package/dist/private/table/useTableColumnHeader.js.map +1 -1
- package/dist/private/table/useTableColumnHeader.mjs.map +1 -1
- package/dist/private/table/useTableColumnResize.cjs.map +1 -1
- package/dist/private/table/useTableColumnResize.js.map +1 -1
- package/dist/private/table/useTableColumnResize.mjs.map +1 -1
- package/dist/private/table/useTableRow.cjs.map +1 -1
- package/dist/private/table/useTableRow.js.map +1 -1
- package/dist/private/table/useTableRow.mjs.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.cjs.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.js.map +1 -1
- package/dist/private/table/useTableSelectionCheckbox.mjs.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.cjs +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.cjs.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.js +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.js.map +1 -1
- package/dist/private/tabs/TabsKeyboardDelegate.mjs +2 -2
- package/dist/private/tabs/TabsKeyboardDelegate.mjs.map +1 -1
- package/dist/private/tag/useTag.cjs.map +1 -1
- package/dist/private/tag/useTag.js.map +1 -1
- package/dist/private/tag/useTag.mjs.map +1 -1
- package/dist/private/toast/useToast.cjs.map +1 -1
- package/dist/private/toast/useToast.js.map +1 -1
- package/dist/private/toast/useToast.mjs.map +1 -1
- package/dist/private/toast/useToastRegion.cjs.map +1 -1
- package/dist/private/toast/useToastRegion.js.map +1 -1
- package/dist/private/toast/useToastRegion.mjs.map +1 -1
- package/dist/private/toolbar/useToolbar.cjs +0 -1
- package/dist/private/toolbar/useToolbar.cjs.map +1 -1
- package/dist/private/toolbar/useToolbar.js +0 -1
- package/dist/private/toolbar/useToolbar.js.map +1 -1
- package/dist/private/toolbar/useToolbar.mjs +0 -1
- package/dist/private/toolbar/useToolbar.mjs.map +1 -1
- package/dist/private/tree/useTree.cjs.map +1 -1
- package/dist/private/tree/useTree.js.map +1 -1
- package/dist/private/tree/useTree.mjs.map +1 -1
- package/dist/private/tree/useTreeItem.cjs.map +1 -1
- package/dist/private/tree/useTreeItem.js.map +1 -1
- package/dist/private/tree/useTreeItem.mjs.map +1 -1
- package/dist/private/utils/isElementVisible.cjs +1 -1
- package/dist/private/utils/isElementVisible.cjs.map +1 -1
- package/dist/private/utils/isElementVisible.js +1 -1
- package/dist/private/utils/isElementVisible.js.map +1 -1
- package/dist/private/utils/isElementVisible.mjs +1 -1
- package/dist/private/utils/isElementVisible.mjs.map +1 -1
- package/dist/private/utils/isFocusable.cjs +3 -1
- package/dist/private/utils/isFocusable.cjs.map +1 -1
- package/dist/private/utils/isFocusable.js +3 -1
- package/dist/private/utils/isFocusable.js.map +1 -1
- package/dist/private/utils/isFocusable.mjs +3 -1
- package/dist/private/utils/isFocusable.mjs.map +1 -1
- package/dist/types/src/dnd/utils.d.ts +2 -2
- package/dist/types/src/gridlist/useGridList.d.ts +7 -0
- package/dist/types/src/menu/useMenu.d.ts +1 -1
- package/dist/types/src/menu/utils.d.ts +1 -1
- package/dist/types/src/overlays/calculatePosition.d.ts +1 -0
- package/dist/types/src/overlays/useOverlayPosition.d.ts +8 -0
- package/dist/types/src/selection/ListKeyboardDelegate.d.ts +1 -0
- package/dist/types/src/selection/useSelectableCollection.d.ts +7 -0
- package/dist/types/src/tree/useTree.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;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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 {\n DragEndEvent,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n PressEvent,\n RefObject\n} from '@react-types/shared';\nimport {\n DragEvent,\n HTMLAttributes,\n version as ReactVersion,\n useEffect,\n useRef,\n useState\n} 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 {\n globalDropEffect,\n setGlobalAllowedDropOperations,\n setGlobalDropEffect,\n useDragModality,\n writeToDataTransfer\n} 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 /**\n * Handler that is called when the drag operation is ended, either as a result of a drop or a\n * cancellation.\n */\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 /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * 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(\n window,\n 'drop',\n e => {\n e.preventDefault();\n e.stopPropagation();\n console.warn(\n '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 );\n },\n {once: true}\n );\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 (\n isDraggingRef.current &&\n (!isDraggingRef.current.isConnected || parseInt(ReactVersion, 10) < 17)\n ) {\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 {\n element: target,\n items: state.options.getItems(),\n allowedDropOperations:\n 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 },\n stringFormatter\n );\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)\n ? 'virtual'\n : 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"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA6ED,MAAM,iCAAW;IACf,UAAU;QACR,OAAO;QACP,KAAK;IACP;IACA,OAAO;QACL,OAAO;QACP,KAAK;IACP;IACA,SAAS;QACP,OAAO;QACP,KAAK;IACP;AACF;AAMO,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAAE;iBACjB;QACA,GAAG;QACH,GAAG;IACL,GAAG,OAAO;IACV,MAAM,OAAO,GAAG;IA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,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';\nimport {\n DragEndEvent,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n PressEvent,\n RefObject\n} from '@react-types/shared';\nimport {\n DragEvent,\n HTMLAttributes,\n version as ReactVersion,\n useEffect,\n useRef,\n useState\n} 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 {\n globalDropEffect,\n setGlobalAllowedDropOperations,\n setGlobalDropEffect,\n useDragModality,\n writeToDataTransfer\n} from './utils';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {isVirtualClick, isVirtualPointerEvent} from '../utils/isVirtualEvent';\nimport {useDescription} from '../utils/useDescription';\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 /**\n * Handler that is called when the drag operation is ended, either as a result of a drop or a\n * cancellation.\n */\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 /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * 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(\n window,\n 'drop',\n e => {\n e.preventDefault();\n e.stopPropagation();\n console.warn(\n '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 );\n },\n {once: true}\n );\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 (\n isDraggingRef.current &&\n (!isDraggingRef.current.isConnected || parseInt(ReactVersion, 10) < 17)\n ) {\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 {\n element: target,\n items: state.options.getItems(),\n allowedDropOperations:\n 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 },\n stringFormatter\n );\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)\n ? 'virtual'\n : 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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA+ED,MAAM,iCAAW;IACf,UAAU;QACR,OAAO;QACP,KAAK;IACP;IACA,OAAO;QACL,OAAO;QACP,KAAK;IACP;IACA,SAAS;QACP,OAAO;QACP,KAAK;IACP;AACF;AAMO,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;iBACjB;QACA,GAAG;QACH,GAAG;IACL,GAAG,OAAO;IACV,MAAM,OAAO,GAAG;IAChB,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAkB;IAC3C,IAAI,CAAC,YAAY,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAE;IAC9C,IAAI,cAAc,CAAC;QACjB,cAAc,OAAO,GAAG;QACxB,iBAAiB,CAAC,CAAC;IACrB;IACA,IAAI,qBAAC,iBAAiB,4BAAE,wBAAwB,EAAC,GAAG,CAAA,GAAA,yCAAiB;IACrE,IAAI,wBAAwB,CAAA,GAAA,aAAK,EAAU;IAE3C,IAAI,cAAc,CAAC;YAyBjB,0FAA0F;QAC1F,2BAAA,iBAkBW;QA3CX,IAAI,EAAE,gBAAgB,EACpB;QAGF,mEAAmE;QACnE,EAAE,eAAe;QAEjB,kHAAkH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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 {\n DragEndEvent,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n PressEvent,\n RefObject\n} from '@react-types/shared';\nimport {\n DragEvent,\n HTMLAttributes,\n version as ReactVersion,\n useEffect,\n useRef,\n useState\n} 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 {\n globalDropEffect,\n setGlobalAllowedDropOperations,\n setGlobalDropEffect,\n useDragModality,\n writeToDataTransfer\n} 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 /**\n * Handler that is called when the drag operation is ended, either as a result of a drop or a\n * cancellation.\n */\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 /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * 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(\n window,\n 'drop',\n e => {\n e.preventDefault();\n e.stopPropagation();\n console.warn(\n '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 );\n },\n {once: true}\n );\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 (\n isDraggingRef.current &&\n (!isDraggingRef.current.isConnected || parseInt(ReactVersion, 10) < 17)\n ) {\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 {\n element: target,\n items: state.options.getItems(),\n allowedDropOperations:\n 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 },\n stringFormatter\n );\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)\n ? 'virtual'\n : 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.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;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BAE5B,IAAI,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,yCAAa,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE,GAAG,KAAK,SAAS;gBAC9D,EAAE,cAAc;gBAChB,EAAE,eAAe;YACnB;QACF;QACA,gBAAe,CAAC;YACd,IAAI,CAAA,GAAA,yCAAa,EAAE,OAAO,EAAE,aAAa,IAAI,EAAE,GAAG,KAAK,SAAS;gBAC9D,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,cAAc,CAAA,GAAA,yCAAa,EAAE;YAC/B;QACF;QACA,SAAQ,CAAC;YACP,yGAAyG;YACzG,IAAI,CAAA,GAAA,yCAAa,EAAE,EAAE,WAAW,KAAK,sBAAsB,OAAO,KAAK,WAAW;gBAChF,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,cAAc,CAAA,GAAA,yCAAa,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';\nimport {\n DragEndEvent,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n PressEvent,\n RefObject\n} from '@react-types/shared';\nimport {\n DragEvent,\n HTMLAttributes,\n version as ReactVersion,\n useEffect,\n useRef,\n useState\n} 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 {\n globalDropEffect,\n setGlobalAllowedDropOperations,\n setGlobalDropEffect,\n useDragModality,\n writeToDataTransfer\n} from './utils';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {isVirtualClick, isVirtualPointerEvent} from '../utils/isVirtualEvent';\nimport {useDescription} from '../utils/useDescription';\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 /**\n * Handler that is called when the drag operation is ended, either as a result of a drop or a\n * cancellation.\n */\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 /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * 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(\n window,\n 'drop',\n e => {\n e.preventDefault();\n e.stopPropagation();\n console.warn(\n '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 );\n },\n {once: true}\n );\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 (\n isDraggingRef.current &&\n (!isDraggingRef.current.isConnected || parseInt(ReactVersion, 10) < 17)\n ) {\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 {\n element: target,\n items: state.options.getItems(),\n allowedDropOperations:\n 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 },\n stringFormatter\n );\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)\n ? 'virtual'\n : 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.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA+ED,MAAM,iCAAW;IACf,UAAU;QACR,OAAO;QACP,KAAK;IACP;IACA,OAAO;QACL,OAAO;QACP,KAAK;IACP;IACA,SAAS;QACP,OAAO;QACP,KAAK;IACP;AACF;AAMO,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;iBACjB;QACA,GAAG;QACH,GAAG;IAC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AAE,eAAe;gBACjB,cAAc,CAAA,GAAA,yCAAa,EAAE;YAC/B;QACF;QACA,SAAQ,CAAC;YACP,yGAAyG;YACzG,IAAI,CAAA,GAAA,yCAAa,EAAE,EAAE,WAAW,KAAK,sBAAsB,OAAO,KAAK,WAAW;gBAChF,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,cAAc,CAAA,GAAA,yCAAa,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 {\n DragEndEvent,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n PressEvent,\n RefObject\n} from '@react-types/shared';\nimport {\n DragEvent,\n HTMLAttributes,\n version as ReactVersion,\n useEffect,\n useRef,\n useState\n} 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 {\n globalDropEffect,\n setGlobalAllowedDropOperations,\n setGlobalDropEffect,\n useDragModality,\n writeToDataTransfer\n} 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 /**\n * Handler that is called when the drag operation is ended, either as a result of a drop or a\n * cancellation.\n */\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 /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * 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(\n window,\n 'drop',\n e => {\n e.preventDefault();\n e.stopPropagation();\n console.warn(\n '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 );\n },\n {once: true}\n );\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 (\n isDraggingRef.current &&\n (!isDraggingRef.current.isConnected || parseInt(ReactVersion, 10) < 17)\n ) {\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 {\n element: target,\n items: state.options.getItems(),\n allowedDropOperations:\n 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 },\n stringFormatter\n );\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)\n ? 'virtual'\n : 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.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA6ED,MAAM,iCAAW;IACf,UAAU;QACR,OAAO;QACP,KAAK;IACP;IACA,OAAO;QACL,OAAO;QACP,KAAK;IACP;IACA,SAAS;QACP,OAAO;QACP,KAAK;IACP;AACF;AAMO,SAAS,0CAAQ,OAAoB;IAC1C,IAAI,iBAAC,aAAa,cAAE,UAAU,EAAC,GAAG;IAClC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;iBACjB;QACA,GAAG;QACH,GAAG;IACL,GAAG,OAAO;IACV,MAAM,OAAO,GAAG;IAChB,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAkB;IAC3C,IAAI,CAAC,YAAY,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAE;IAC9C,IAAI,cAAc,CAAC;QACjB,cAAc,OAAO,GAAG;QACxB,iBAAiB,CAAC,CAAC;IACrB;IACA,IAAI,qBAAC,iBAAiB,4BAAE,wBAAwB,EAAC,GAAG,CAAA,GAAA,yCAAiB;IACrE,IAAI,wBAAwB,CAAA,GAAA,aAAK,EAAU;IAE3C,IAAI,cAAc,CAAC;QACjB,IAAI,EAAE,gBAAgB,EACpB;QAGF,mEAAmE;QACnE,EAAE,eAAe;QAEjB,kHAAkH;QAClH,IAAI,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;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';\nimport {\n DragEndEvent,\n DragItem,\n DragMoveEvent,\n DragPreviewRenderer,\n DragStartEvent,\n DropOperation,\n PressEvent,\n RefObject\n} from '@react-types/shared';\nimport {\n DragEvent,\n HTMLAttributes,\n version as ReactVersion,\n useEffect,\n useRef,\n useState\n} 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 {\n globalDropEffect,\n setGlobalAllowedDropOperations,\n setGlobalDropEffect,\n useDragModality,\n writeToDataTransfer\n} from './utils';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {isVirtualClick, isVirtualPointerEvent} from '../utils/isVirtualEvent';\nimport {useDescription} from '../utils/useDescription';\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 /**\n * Handler that is called when the drag operation is ended, either as a result of a drop or a\n * cancellation.\n */\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 /**\n * Function that returns the drop operations that are allowed for the dragged items. If not\n * provided, all drop operations are allowed.\n */\n getAllowedDropOperations?: () => DropOperation[];\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * 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(\n window,\n 'drop',\n e => {\n e.preventDefault();\n e.stopPropagation();\n console.warn(\n '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 );\n },\n {once: true}\n );\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 (\n isDraggingRef.current &&\n (!isDraggingRef.current.isConnected || parseInt(ReactVersion, 10) < 17)\n ) {\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 {\n element: target,\n items: state.options.getItems(),\n allowedDropOperations:\n 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 },\n stringFormatter\n );\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)\n ? 'virtual'\n : 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.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CA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IAAI,CAAC,MAAM,aAAa,IAAI,MAAM,gBAAgB,CAAC,aAAa,KAAK,QAAQ;QAC3E,IAAI,MAAM,8BAAQ,CAAC,SAAS,CAAC,aAAa,aAAa,cAAc;QACrE,IAAI,MAAM,SAAS,IAAI,aAAa,YAClC,OAAO;QAGT,IAAI,YACF,cAAc,gBAAgB,MAAM,CAAC,KAAK;YAAC,OAAO;QAAc;aAEhE,cAAc,gBAAgB,MAAM,CAAC;QAGvC,4FAA4F;QAC5F,uEAAuE;QACvE,OAAO,UAAU,OAAO;IAC1B,OACE,IAAI,YACF,kBAAkB,gBAAgB,MAAM,CAAC,qBAAqB;QAAC,OAAO;IAAc;SAC/E;QACL,IAAI,WAAW,MAAM,UAAU,CAAC,YAAY,GAAG,MAAM,GAAG,KAAK,MAAM,aAAa;QAChF,kBAAkB,gBAAgB,MAAM,CAAC,YAAY;sBAAC;QAAQ;IAChE;IAGF,IAAI,mBAAmB,CAAA,GAAA,wCAAa,EAAE;IACtC,IAAI,aACF,OAAO,MAAM,CAAC,WAAW;IAG3B,IAAI,CAAC,MAAM,aAAa,IAAI,MAAM,SAAS,EAAE;QAC3C,IAAI,oBAAC,gBAAgB,kBAAE,cAAc,EAAC,GAAG;QACzC,IAAI,aAAa,SACf,8GAA8G;QAC9G,OAAO,SAAS,CAAC,mBAAmB;QAGtC,oDAAoD;QACpD,UAAU,gBAAgB,GAAG,CAAA;YAC3B,IAAI,EAAE,MAAM,EACV,mBAAmB;QAEvB;QAEA,UAAU,cAAc,GAAG,CAAA;YACzB,IAAI,EAAE,MAAM,EACV,iBAAiB;QAErB;IACF;IAEA,OAAO;QACL,WAAW,aAAa,CAAC,IAAI;QAC7B,iBAAiB;YACf,GAAG,eAAe;wBAClB;YACA,cAAc;QAChB;IACF;AACF","sources":["packages/react-aria/src/dnd/useDraggableItem.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';\nimport {\n clearGlobalDnDState,\n isInternalDropOperation,\n setDraggingKeys,\n useDragModality\n} from './utils';\nimport {DraggableCollectionState} from 'react-stately/useDraggableCollectionState';\nimport {HTMLAttributes} from 'react';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {Key} from '@react-types/shared';\nimport {useDescription} from '../utils/useDescription';\nimport {useDrag} from './useDrag';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface DraggableItemProps {\n /** The key of the draggable item within the collection. */\n key: Key;\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * dragButtonProps instead.\n */\n hasDragButton?: boolean;\n /**\n * Whether the item has a primary action (e.g. Enter key or long press) that would conflict with\n * initiating accessible drag and drop. If true, the Alt key must be held to start dragging with a\n * keyboard, and long press is disabled until selection mode is entered. This should be passed\n * from the associated collection item hook (e.g. useOption, useGridListItem, etc.).\n */\n hasAction?: boolean;\n}\n\nexport interface DraggableItemResult {\n /** Props for the draggable item. */\n dragProps: HTMLAttributes<HTMLElement>;\n /** Props for the explicit drag button affordance, if any. */\n dragButtonProps: AriaButtonProps;\n}\n\nconst MESSAGES = {\n keyboard: {\n selected: 'dragSelectedKeyboard',\n notSelected: 'dragDescriptionKeyboard'\n },\n touch: {\n selected: 'dragSelectedLongPress',\n notSelected: 'dragDescriptionLongPress'\n },\n virtual: {\n selected: 'dragDescriptionVirtual',\n notSelected: 'dragDescriptionVirtual'\n }\n};\n\n/**\n * Handles drag interactions for an item within a draggable collection.\n */\nexport function useDraggableItem(\n props: DraggableItemProps,\n state: DraggableCollectionState\n): DraggableItemResult {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let isDisabled = state.isDisabled || state.selectionManager.isDisabled(props.key);\n let {dragProps, dragButtonProps} = useDrag({\n getItems() {\n return state.getItems(props.key);\n },\n preview: state.preview,\n getAllowedDropOperations: state.getAllowedDropOperations,\n hasDragButton: props.hasDragButton,\n onDragStart(e) {\n state.startDrag(props.key, e);\n // Track draggingKeys for useDroppableCollection's default onDrop handler and useDroppableCollectionState's default getDropOperation\n setDraggingKeys(state.draggingKeys);\n },\n onDragMove(e) {\n state.moveDrag(e);\n },\n onDragEnd(e) {\n let {dropOperation} = e;\n let isInternal = dropOperation === 'cancel' ? false : isInternalDropOperation();\n state.endDrag({...e, keys: state.draggingKeys, isInternal});\n clearGlobalDnDState();\n }\n });\n\n let item = state.collection.getItem(props.key);\n let numKeysForDrag = state.getKeysForDrag(props.key).size;\n let isSelected = numKeysForDrag > 1 && state.selectionManager.isSelected(props.key);\n let dragButtonLabel: string | undefined;\n let description: string | undefined;\n\n // Override description to include selected item count.\n let modality = useDragModality();\n if (!props.hasDragButton && state.selectionManager.selectionMode !== 'none') {\n let msg = MESSAGES[modality][isSelected ? 'selected' : 'notSelected'];\n if (props.hasAction && modality === 'keyboard') {\n msg += 'Alt';\n }\n\n if (isSelected) {\n description = stringFormatter.format(msg, {count: numKeysForDrag});\n } else {\n description = stringFormatter.format(msg);\n }\n\n // Remove the onClick handler from useDrag. Long pressing will be required on touch devices,\n // and NVDA/JAWS are always in forms mode within collection components.\n delete dragProps.onClick;\n } else {\n if (isSelected) {\n dragButtonLabel = stringFormatter.format('dragSelectedItems', {count: numKeysForDrag});\n } else {\n let itemText = state.collection.getTextValue?.(props.key) ?? item?.textValue ?? '';\n dragButtonLabel = stringFormatter.format('dragItem', {itemText});\n }\n }\n\n let descriptionProps = useDescription(description);\n if (description) {\n Object.assign(dragProps, descriptionProps);\n }\n\n if (!props.hasDragButton && props.hasAction) {\n let {onKeyDownCapture, onKeyUpCapture} = dragProps;\n if (modality === 'touch') {\n // Remove long press description if an action is present, because in that case long pressing selects the item.\n delete dragProps['aria-describedby'];\n }\n\n // Require Alt key if there is a conflicting action.\n dragProps.onKeyDownCapture = e => {\n if (e.altKey) {\n onKeyDownCapture?.(e);\n }\n };\n\n dragProps.onKeyUpCapture = e => {\n if (e.altKey) {\n onKeyUpCapture?.(e);\n }\n };\n }\n\n return {\n dragProps: isDisabled ? {} : dragProps,\n dragButtonProps: {\n ...dragButtonProps,\n isDisabled,\n 'aria-label': dragButtonLabel\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableItem.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA0CD,MAAM,iCAAW;IACf,UAAU;QACR,UAAU;QACV,aAAa;IACf;IACA,OAAO;QACL,UAAU;QACV,aAAa;IACf;IACA,SAAS;QACP,UAAU;QACV,aAAa;IACf;AACF;AAKO,SAAS,0CACd,KAAyB,EACzB,KAA+B;IAE/B,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,aAAa,MAAM,UAAU,IAAI,MAAM,gBAAgB,CAAC,UAAU,CAAC,MAAM,GAAG;IAChF,IAAI,aAAC,SAAS,mBAAE,eAAe,EAAC,GAAG,CAAA,GAAA,yCAAM,EAAE;QACzC;YACE,OAAO,MAAM,QAAQ,CAAC,MAAM,GAAG;QACjC;QACA,SAAS,MAAM,OAAO;QACtB,0BAA0B,MAAM,wBAAwB;QACxD,eAAe,MAAM,aAAa;QAClC,aAAY,CAAC;YACX,MAAM,SAAS,CAAC,MAAM,GAAG,EAAE;YAC3B,oIAAoI;YACpI,CAAA,GAAA,yCAAc,EAAE,MAAM,YAAY;QACpC;QACA,YAAW,CAAC;YAC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AAY;sBAAC;QAAQ;IAChE;IAGF,IAAI,mBAAmB,CAAA,GAAA,yCAAa,EAAE;IACtC,IAAI,aACF,OAAO,MAAM,CAAC,WAAW;IAG3B,IAAI,CAAC,MAAM,aAAa,IAAI,MAAM,SAAS,EAAE;QAC3C,IAAI,oBAAC,gBAAgB,kBAAE,cAAc,EAAC,GAAG;QACzC,IAAI,aAAa,SACf,8GAA8G;QAC9G,OAAO,SAAS,CAAC,mBAAmB;QAGtC,oDAAoD;QACpD,UAAU,gBAAgB,GAAG,CAAA;YAC3B,IAAI,EAAE,MAAM,EACV,6BAAA,uCAAA,iBAAmB;QAEvB;QAEA,UAAU,cAAc,GAAG,CAAA;YACzB,IAAI,EAAE,MAAM,EACV,2BAAA,qCAAA,eAAiB;QAErB;IACF;IAEA,OAAO;QACL,WAAW,aAAa,CAAC,IAAI;QAC7B,iBAAiB;YACf,GAAG,eAAe;wBAClB;YACA,cAAc;QAChB;IACF;AACF","sources":["packages/react-aria/src/dnd/useDraggableItem.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';\nimport {\n clearGlobalDnDState,\n isInternalDropOperation,\n setDraggingKeys,\n useDragModality\n} from './utils';\nimport {DraggableCollectionState} from 'react-stately/useDraggableCollectionState';\nimport {HTMLAttributes} from 'react';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {Key} from '@react-types/shared';\nimport {useDescription} from '../utils/useDescription';\nimport {useDrag} from './useDrag';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface DraggableItemProps {\n /** The key of the draggable item within the collection. */\n key: Key;\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * dragButtonProps instead.\n */\n hasDragButton?: boolean;\n /**\n * Whether the item has a primary action (e.g. Enter key or long press) that would conflict with\n * initiating accessible drag and drop. If true, the Alt key must be held to start dragging with a\n * keyboard, and long press is disabled until selection mode is entered. This should be passed\n * from the associated collection item hook (e.g. useOption, useGridListItem, etc.).\n */\n hasAction?: boolean;\n}\n\nexport interface DraggableItemResult {\n /** Props for the draggable item. */\n dragProps: HTMLAttributes<HTMLElement>;\n /** Props for the explicit drag button affordance, if any. */\n dragButtonProps: AriaButtonProps;\n}\n\nconst MESSAGES = {\n keyboard: {\n selected: 'dragSelectedKeyboard',\n notSelected: 'dragDescriptionKeyboard'\n },\n touch: {\n selected: 'dragSelectedLongPress',\n notSelected: 'dragDescriptionLongPress'\n },\n virtual: {\n selected: 'dragDescriptionVirtual',\n notSelected: 'dragDescriptionVirtual'\n }\n};\n\n/**\n * Handles drag interactions for an item within a draggable collection.\n */\nexport function useDraggableItem(\n props: DraggableItemProps,\n state: DraggableCollectionState\n): DraggableItemResult {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let isDisabled = state.isDisabled || state.selectionManager.isDisabled(props.key);\n let {dragProps, dragButtonProps} = useDrag({\n getItems() {\n return state.getItems(props.key);\n },\n preview: state.preview,\n getAllowedDropOperations: state.getAllowedDropOperations,\n hasDragButton: props.hasDragButton,\n onDragStart(e) {\n state.startDrag(props.key, e);\n // Track draggingKeys for useDroppableCollection's default onDrop handler and useDroppableCollectionState's default getDropOperation\n setDraggingKeys(state.draggingKeys);\n },\n onDragMove(e) {\n state.moveDrag(e);\n },\n onDragEnd(e) {\n let {dropOperation} = e;\n let isInternal = dropOperation === 'cancel' ? false : isInternalDropOperation();\n state.endDrag({...e, keys: state.draggingKeys, isInternal});\n clearGlobalDnDState();\n }\n });\n\n let item = state.collection.getItem(props.key);\n let numKeysForDrag = state.getKeysForDrag(props.key).size;\n let isSelected = numKeysForDrag > 1 && state.selectionManager.isSelected(props.key);\n let dragButtonLabel: string | undefined;\n let description: string | undefined;\n\n // Override description to include selected item count.\n let modality = useDragModality();\n if (!props.hasDragButton && state.selectionManager.selectionMode !== 'none') {\n let msg = MESSAGES[modality][isSelected ? 'selected' : 'notSelected'];\n if (props.hasAction && modality === 'keyboard') {\n msg += 'Alt';\n }\n\n if (isSelected) {\n description = stringFormatter.format(msg, {count: numKeysForDrag});\n } else {\n description = stringFormatter.format(msg);\n }\n\n // Remove the onClick handler from useDrag. Long pressing will be required on touch devices,\n // and NVDA/JAWS are always in forms mode within collection components.\n delete dragProps.onClick;\n } else {\n if (isSelected) {\n dragButtonLabel = stringFormatter.format('dragSelectedItems', {count: numKeysForDrag});\n } else {\n let itemText = state.collection.getTextValue?.(props.key) ?? item?.textValue ?? '';\n dragButtonLabel = stringFormatter.format('dragItem', {itemText});\n }\n }\n\n let descriptionProps = useDescription(description);\n if (description) {\n Object.assign(dragProps, descriptionProps);\n }\n\n if (!props.hasDragButton && props.hasAction) {\n let {onKeyDownCapture, onKeyUpCapture} = dragProps;\n if (modality === 'touch') {\n // Remove long press description if an action is present, because in that case long pressing selects the item.\n delete dragProps['aria-describedby'];\n }\n\n // Require Alt key if there is a conflicting action.\n dragProps.onKeyDownCapture = e => {\n if (e.altKey) {\n onKeyDownCapture?.(e);\n }\n };\n\n dragProps.onKeyUpCapture = e => {\n if (e.altKey) {\n onKeyUpCapture?.(e);\n }\n };\n }\n\n return {\n dragProps: isDisabled ? {} : dragProps,\n dragButtonProps: {\n ...dragButtonProps,\n isDisabled,\n 'aria-label': dragButtonLabel\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableItem.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;
|
|
1
|
+
{"m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I,WAAW,CAAA,GAAA,yCAAc;IAC7B,IAAI,CAAC,MAAM,aAAa,IAAI,MAAM,gBAAgB,CAAC,aAAa,KAAK,QAAQ;QAC3E,IAAI,MAAM,8BAAQ,CAAC,SAAS,CAAC,aAAa,aAAa,cAAc;QACrE,IAAI,MAAM,SAAS,IAAI,aAAa,YAClC,OAAO;QAGT,IAAI,YACF,cAAc,gBAAgB,MAAM,CAAC,KAAK;YAAC,OAAO;QAAc;aAEhE,cAAc,gBAAgB,MAAM,CAAC;QAGvC,4FAA4F;QAC5F,uEAAuE;QACvE,OAAO,UAAU,OAAO;IAC1B,OACE,IAAI,YACF,kBAAkB,gBAAgB,MAAM,CAAC,qBAAqB;QAAC,OAAO;IAAc;SAC/E;QACL,IAAI,WAAW,MAAM,UAAU,CAAC,YAAY,GAAG,MAAM,GAAG,KAAK,MAAM,aAAa;QAChF,kBAAkB,gBAAgB,MAAM,CAAC,YAAY;sBAAC;QAAQ;IAChE;IAGF,IAAI,mBAAmB,CAAA,GAAA,yCAAa,EAAE;IACtC,IAAI,aACF,OAAO,MAAM,CAAC,WAAW;IAG3B,IAAI,CAAC,MAAM,aAAa,IAAI,MAAM,SAAS,EAAE;QAC3C,IAAI,oBAAC,gBAAgB,kBAAE,cAAc,EAAC,GAAG;QACzC,IAAI,aAAa,SACf,8GAA8G;QAC9G,OAAO,SAAS,CAAC,mBAAmB;QAGtC,oDAAoD;QACpD,UAAU,gBAAgB,GAAG,CAAA;YAC3B,IAAI,EAAE,MAAM,EACV,mBAAmB;QAEvB;QAEA,UAAU,cAAc,GAAG,CAAA;YACzB,IAAI,EAAE,MAAM,EACV,iBAAiB;QAErB;IACF;IAEA,OAAO;QACL,WAAW,aAAa,CAAC,IAAI;QAC7B,iBAAiB;YACf,GAAG,eAAe;wBAClB;YACA,cAAc;QAChB;IACF;AACF","sources":["packages/react-aria/src/dnd/useDraggableItem.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';\nimport {\n clearGlobalDnDState,\n isInternalDropOperation,\n setDraggingKeys,\n useDragModality\n} from './utils';\nimport {DraggableCollectionState} from 'react-stately/useDraggableCollectionState';\nimport {HTMLAttributes} from 'react';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {Key} from '@react-types/shared';\nimport {useDescription} from '../utils/useDescription';\nimport {useDrag} from './useDrag';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface DraggableItemProps {\n /** The key of the draggable item within the collection. */\n key: Key;\n /**\n * Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop\n * mode. If true, the dragProps will omit these event handlers, and they will be applied to\n * dragButtonProps instead.\n */\n hasDragButton?: boolean;\n /**\n * Whether the item has a primary action (e.g. Enter key or long press) that would conflict with\n * initiating accessible drag and drop. If true, the Alt key must be held to start dragging with a\n * keyboard, and long press is disabled until selection mode is entered. This should be passed\n * from the associated collection item hook (e.g. useOption, useGridListItem, etc.).\n */\n hasAction?: boolean;\n}\n\nexport interface DraggableItemResult {\n /** Props for the draggable item. */\n dragProps: HTMLAttributes<HTMLElement>;\n /** Props for the explicit drag button affordance, if any. */\n dragButtonProps: AriaButtonProps;\n}\n\nconst MESSAGES = {\n keyboard: {\n selected: 'dragSelectedKeyboard',\n notSelected: 'dragDescriptionKeyboard'\n },\n touch: {\n selected: 'dragSelectedLongPress',\n notSelected: 'dragDescriptionLongPress'\n },\n virtual: {\n selected: 'dragDescriptionVirtual',\n notSelected: 'dragDescriptionVirtual'\n }\n};\n\n/**\n * Handles drag interactions for an item within a draggable collection.\n */\nexport function useDraggableItem(\n props: DraggableItemProps,\n state: DraggableCollectionState\n): DraggableItemResult {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let isDisabled = state.isDisabled || state.selectionManager.isDisabled(props.key);\n let {dragProps, dragButtonProps} = useDrag({\n getItems() {\n return state.getItems(props.key);\n },\n preview: state.preview,\n getAllowedDropOperations: state.getAllowedDropOperations,\n hasDragButton: props.hasDragButton,\n onDragStart(e) {\n state.startDrag(props.key, e);\n // Track draggingKeys for useDroppableCollection's default onDrop handler and useDroppableCollectionState's default getDropOperation\n setDraggingKeys(state.draggingKeys);\n },\n onDragMove(e) {\n state.moveDrag(e);\n },\n onDragEnd(e) {\n let {dropOperation} = e;\n let isInternal = dropOperation === 'cancel' ? false : isInternalDropOperation();\n state.endDrag({...e, keys: state.draggingKeys, isInternal});\n clearGlobalDnDState();\n }\n });\n\n let item = state.collection.getItem(props.key);\n let numKeysForDrag = state.getKeysForDrag(props.key).size;\n let isSelected = numKeysForDrag > 1 && state.selectionManager.isSelected(props.key);\n let dragButtonLabel: string | undefined;\n let description: string | undefined;\n\n // Override description to include selected item count.\n let modality = useDragModality();\n if (!props.hasDragButton && state.selectionManager.selectionMode !== 'none') {\n let msg = MESSAGES[modality][isSelected ? 'selected' : 'notSelected'];\n if (props.hasAction && modality === 'keyboard') {\n msg += 'Alt';\n }\n\n if (isSelected) {\n description = stringFormatter.format(msg, {count: numKeysForDrag});\n } else {\n description = stringFormatter.format(msg);\n }\n\n // Remove the onClick handler from useDrag. Long pressing will be required on touch devices,\n // and NVDA/JAWS are always in forms mode within collection components.\n delete dragProps.onClick;\n } else {\n if (isSelected) {\n dragButtonLabel = stringFormatter.format('dragSelectedItems', {count: numKeysForDrag});\n } else {\n let itemText = state.collection.getTextValue?.(props.key) ?? item?.textValue ?? '';\n dragButtonLabel = stringFormatter.format('dragItem', {itemText});\n }\n }\n\n let descriptionProps = useDescription(description);\n if (description) {\n Object.assign(dragProps, descriptionProps);\n }\n\n if (!props.hasDragButton && props.hasAction) {\n let {onKeyDownCapture, onKeyUpCapture} = dragProps;\n if (modality === 'touch') {\n // Remove long press description if an action is present, because in that case long pressing selects the item.\n delete dragProps['aria-describedby'];\n }\n\n // Require Alt key if there is a conflicting action.\n dragProps.onKeyDownCapture = e => {\n if (e.altKey) {\n onKeyDownCapture?.(e);\n }\n };\n\n dragProps.onKeyUpCapture = e => {\n if (e.altKey) {\n onKeyUpCapture?.(e);\n }\n };\n }\n\n return {\n dragProps: isDisabled ? {} : dragProps,\n dragButtonProps: {\n ...dragButtonProps,\n isDisabled,\n 'aria-label': dragButtonLabel\n }\n };\n}\n"],"names":[],"version":3,"file":"useDraggableItem.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAkCM,SAAS,0CACd,KAAyB,EACzB,KAA+B,EAC/B,GAAkC;IAElC,IAAI,UAAC,MAAM,EAAC,GAAG;IACf,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,cAAc;IAClB,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,0CAAe,EAAE,OAAO,OAAO;IACjD,IAAI,KAAK,CAAA,GAAA,+BAAI;IACb,IAAI,UAAU,CAAC;QACb,IAAI,OAAO,MACT,OAAO;aAEP,OAAO,WAAW,YAAY,GAAG,QAAQ,WAAW,OAAO,CAAC,MAAM,aAAa;IAEnF;IAEA,IAAI,QAAQ;IACZ,IAAI;IACJ,IAAI,OAAO,IAAI,KAAK,QAAQ;QAC1B,QAAQ,gBAAgB,MAAM,CAAC;QAC/B,aAAa,GAAG,GAAG,CAAC,EAAE,CAAA,GAAA,kDAAuB,EAAE,QAA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packages/react-aria/src/dnd/useDropIndicator.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 * as DragManager from './DragManager';\nimport {DroppableCollectionState} from 'react-stately/useDroppableCollectionState';\nimport {DropTarget, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getDroppableCollectionId} from './utils';\nimport {HTMLAttributes} from 'react';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {useDroppableItem} from './useDroppableItem';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface DropIndicatorProps {\n /** The drop target that the drop indicator represents. */\n target: DropTarget;\n /** The ref to the activate button. */\n activateButtonRef?: RefObject<FocusableElement | null>;\n}\n\nexport interface DropIndicatorAria {\n /** Props for the drop indicator element. */\n dropIndicatorProps: HTMLAttributes<HTMLElement>;\n /** Whether the drop indicator is currently the active drop target. */\n isDropTarget: boolean;\n /**\n * Whether the drop indicator is hidden, both visually and from assistive technology.\n * Use this to determine whether to omit the element from the DOM entirely.\n */\n isHidden: boolean;\n}\n\n/**\n * Handles drop interactions for a target within a droppable collection.\n */\nexport function useDropIndicator(\n props: DropIndicatorProps,\n state: DroppableCollectionState,\n ref: RefObject<HTMLElement | null>\n): DropIndicatorAria {\n let {target} = props;\n let {collection} = state;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let dragSession = DragManager.useDragSession();\n let {dropProps} = useDroppableItem(props, state, ref);\n let id = useId();\n let getText = (key: Key | null) => {\n if (key == null) {\n return '';\n } else {\n return collection.getTextValue?.(key) ?? collection.getItem(key)?.textValue ?? '';\n }\n };\n\n let label = '';\n let labelledBy: string | undefined;\n if (target.type === 'root') {\n label = stringFormatter.format('dropOnRoot');\n labelledBy = `${id} ${getDroppableCollectionId(state)}`;\n } else if (target.dropPosition === 'on') {\n label = stringFormatter.format('dropOnItem', {\n itemText: getText(target.key)\n });\n } else {\n let before: Key | null | undefined;\n let after: Key | null | undefined;\n if (target.dropPosition === 'before') {\n let prevKey = collection.getItem(target.key)?.prevKey;\n let prevNode = prevKey != null ? collection.getItem(prevKey) : null;\n before = prevNode?.type === 'item' ? prevNode.key : null;\n } else {\n before = target.key;\n }\n\n if (target.dropPosition === 'after') {\n let nextKey = collection.getItem(target.key)?.nextKey;\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n after = nextNode?.type === 'item' ? nextNode.key : null;\n } else {\n after = target.key;\n }\n\n if (before != null && after != null) {\n label = stringFormatter.format('insertBetween', {\n beforeItemText: getText(before),\n afterItemText: getText(after)\n });\n } else if (before != null) {\n label = stringFormatter.format('insertAfter', {\n itemText: getText(before)\n });\n } else if (after != null) {\n label = stringFormatter.format('insertBefore', {\n itemText: getText(after)\n });\n }\n }\n\n let isDropTarget = state.isDropTarget(target);\n let ariaHidden = !dragSession ? 'true' : dropProps['aria-hidden'];\n return {\n dropIndicatorProps: {\n ...dropProps,\n id,\n 'aria-roledescription': stringFormatter.format('dropIndicator'),\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n 'aria-hidden': ariaHidden,\n tabIndex: -1\n },\n isDropTarget,\n // If aria-hidden, we are either not in a drag session or the drop target is invalid.\n // In that case, there's no need to render anything at all unless we need to show the indicator visually.\n // This can happen when dragging using the native DnD API as opposed to keyboard dragging.\n isHidden: !isDropTarget && !!ariaHidden\n };\n}\n"],"names":[],"version":3,"file":"useDropIndicator.cjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
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;QACtD,OACE,SAAS,OAAO,GAAG;QAGrB,IAAI,OAAO,YAAY,KAAK,SAAS;gBACrB;YAAd,IAAI,WAAU,uBAAA,WAAW,OAAO,CAAC,OAAO,GAAG,eAA7B,2CAAA,qBAAgC,OAAO;YACrD,IAAI,WAAW,WAAW,OAAO,WAAW,OAAO,CAAC,WAAW;YAC/D,QAAQ,CAAA,qBAAA,+BAAA,SAAU,IAAI,MAAK,SAAS,SAAS,GAAG,GAAG;QACrD,OACE,QAAQ,OAAO,GAAG;QAGpB,IAAI,UAAU,QAAQ,SAAS,MAC7B,QAAQ,gBAAgB,MAAM,CAAC,iBAAiB;YAC9C,gBAAgB,QAAQ;YACxB,eAAe,QAAQ;QACzB;aACK,IAAI,UAAU,MACnB,QAAQ,gBAAgB,MAAM,CAAC,eAAe;YAC5C,UAAU,QAAQ;QACpB;aACK,IAAI,SAAS,MAClB,QAAQ,gBAAgB,MAAM,CAAC,gBAAgB;YAC7C,UAAU,QAAQ;QACpB;IAEJ;IAEA,IAAI,eAAe,MAAM,YAAY,CAAC;IACtC,IAAI,aAAa,CAAC,cAAc,SAAS,SAAS,CAAC,cAAc;IACjE,OAAO;QACL,oBAAoB;YAClB,GAAG,SAAS;gBACZ;YACA,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;YACd,mBAAmB;YACnB,eAAe;YACf,UAAU;QACZ;sBACA;QACA,qFAAqF;QACrF,yGAAyG;QACzG,0FAA0F;QAC1F,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/B;AACF","sources":["packages/react-aria/src/dnd/useDropIndicator.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 * as DragManager from './DragManager';\nimport {DroppableCollectionState} from 'react-stately/useDroppableCollectionState';\nimport {DropTarget, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getDroppableCollectionId} from './utils';\nimport {HTMLAttributes} from 'react';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {useDroppableItem} from './useDroppableItem';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface DropIndicatorProps {\n /** The drop target that the drop indicator represents. */\n target: DropTarget;\n /** The ref to the activate button. */\n activateButtonRef?: RefObject<FocusableElement | null>;\n}\n\nexport interface DropIndicatorAria {\n /** Props for the drop indicator element. */\n dropIndicatorProps: HTMLAttributes<HTMLElement>;\n /** Whether the drop indicator is currently the active drop target. */\n isDropTarget: boolean;\n /**\n * Whether the drop indicator is hidden, both visually and from assistive technology.\n * Use this to determine whether to omit the element from the DOM entirely.\n */\n isHidden: boolean;\n}\n\n/**\n * Handles drop interactions for a target within a droppable collection.\n */\nexport function useDropIndicator(\n props: DropIndicatorProps,\n state: DroppableCollectionState,\n ref: RefObject<HTMLElement | null>\n): DropIndicatorAria {\n let {target} = props;\n let {collection} = state;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let dragSession = DragManager.useDragSession();\n let {dropProps} = useDroppableItem(props, state, ref);\n let id = useId();\n let getText = (key: Key | null) => {\n if (key == null) {\n return '';\n } else {\n return collection.getTextValue?.(key) ?? collection.getItem(key)?.textValue ?? '';\n }\n };\n\n let label = '';\n let labelledBy: string | undefined;\n if (target.type === 'root') {\n label = stringFormatter.format('dropOnRoot');\n labelledBy = `${id} ${getDroppableCollectionId(state)}`;\n } else if (target.dropPosition === 'on') {\n label = stringFormatter.format('dropOnItem', {\n itemText: getText(target.key)\n });\n } else {\n let before: Key | null | undefined;\n let after: Key | null | undefined;\n if (target.dropPosition === 'before') {\n let prevKey = collection.getItem(target.key)?.prevKey;\n let prevNode = prevKey != null ? collection.getItem(prevKey) : null;\n before = prevNode?.type === 'item' ? prevNode.key : null;\n } else {\n before = target.key;\n }\n\n if (target.dropPosition === 'after') {\n let nextKey = collection.getItem(target.key)?.nextKey;\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n after = nextNode?.type === 'item' ? nextNode.key : null;\n } else {\n after = target.key;\n }\n\n if (before != null && after != null) {\n label = stringFormatter.format('insertBetween', {\n beforeItemText: getText(before),\n afterItemText: getText(after)\n });\n } else if (before != null) {\n label = stringFormatter.format('insertAfter', {\n itemText: getText(before)\n });\n } else if (after != null) {\n label = stringFormatter.format('insertBefore', {\n itemText: getText(after)\n });\n }\n }\n\n let isDropTarget = state.isDropTarget(target);\n let ariaHidden = !dragSession ? 'true' : dropProps['aria-hidden'];\n return {\n dropIndicatorProps: {\n ...dropProps,\n id,\n 'aria-roledescription': stringFormatter.format('dropIndicator'),\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n 'aria-hidden': ariaHidden,\n tabIndex: -1\n },\n isDropTarget,\n // If aria-hidden, we are either not in a drag session or the drop target is invalid.\n // In that case, there's no need to render anything at all unless we need to show the indicator visually.\n // This can happen when dragging using the native DnD API as opposed to keyboard dragging.\n isHidden: !isDropTarget && !!ariaHidden\n };\n}\n"],"names":[],"version":3,"file":"useDropIndicator.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAkCM,SAAS,0CACd,KAAyB,EACzB,KAA+B,EAC/B,GAAkC;IAElC,IAAI,UAAC,MAAM,EAAC,GAAG;IACf,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,cAAc;IAClB,I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,gBAAgB,MAAM,CAAC,gBAAgB;YAC7C,UAAU,QAAQ;QACpB;IAEJ;IAEA,IAAI,eAAe,MAAM,YAAY,CAAC;IACtC,IAAI,aAAa,CAAC,cAAc,SAAS,SAAS,CAAC,cAAc;IACjE,OAAO;QACL,oBAAoB;YAClB,GAAG,SAAS;gBACZ;YACA,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;YACd,mBAAmB;YACnB,eAAe;YACf,UAAU;QACZ;sBACA;QACA,qFAAqF;QACrF,yGAAyG;QACzG,0FAA0F;QAC1F,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/B;AACF","sources":["packages/react-aria/src/dnd/useDropIndicator.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 * as DragManager from './DragManager';\nimport {DroppableCollectionState} from 'react-stately/useDroppableCollectionState';\nimport {DropTarget, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getDroppableCollectionId} from './utils';\nimport {HTMLAttributes} from 'react';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {useDroppableItem} from './useDroppableItem';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface DropIndicatorProps {\n /** The drop target that the drop indicator represents. */\n target: DropTarget;\n /** The ref to the activate button. */\n activateButtonRef?: RefObject<FocusableElement | null>;\n}\n\nexport interface DropIndicatorAria {\n /** Props for the drop indicator element. */\n dropIndicatorProps: HTMLAttributes<HTMLElement>;\n /** Whether the drop indicator is currently the active drop target. */\n isDropTarget: boolean;\n /**\n * Whether the drop indicator is hidden, both visually and from assistive technology.\n * Use this to determine whether to omit the element from the DOM entirely.\n */\n isHidden: boolean;\n}\n\n/**\n * Handles drop interactions for a target within a droppable collection.\n */\nexport function useDropIndicator(\n props: DropIndicatorProps,\n state: DroppableCollectionState,\n ref: RefObject<HTMLElement | null>\n): DropIndicatorAria {\n let {target} = props;\n let {collection} = state;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let dragSession = DragManager.useDragSession();\n let {dropProps} = useDroppableItem(props, state, ref);\n let id = useId();\n let getText = (key: Key | null) => {\n if (key == null) {\n return '';\n } else {\n return collection.getTextValue?.(key) ?? collection.getItem(key)?.textValue ?? '';\n }\n };\n\n let label = '';\n let labelledBy: string | undefined;\n if (target.type === 'root') {\n label = stringFormatter.format('dropOnRoot');\n labelledBy = `${id} ${getDroppableCollectionId(state)}`;\n } else if (target.dropPosition === 'on') {\n label = stringFormatter.format('dropOnItem', {\n itemText: getText(target.key)\n });\n } else {\n let before: Key | null | undefined;\n let after: Key | null | undefined;\n if (target.dropPosition === 'before') {\n let prevKey = collection.getItem(target.key)?.prevKey;\n let prevNode = prevKey != null ? collection.getItem(prevKey) : null;\n before = prevNode?.type === 'item' ? prevNode.key : null;\n } else {\n before = target.key;\n }\n\n if (target.dropPosition === 'after') {\n let nextKey = collection.getItem(target.key)?.nextKey;\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n after = nextNode?.type === 'item' ? nextNode.key : null;\n } else {\n after = target.key;\n }\n\n if (before != null && after != null) {\n label = stringFormatter.format('insertBetween', {\n beforeItemText: getText(before),\n afterItemText: getText(after)\n });\n } else if (before != null) {\n label = stringFormatter.format('insertAfter', {\n itemText: getText(before)\n });\n } else if (after != null) {\n label = stringFormatter.format('insertBefore', {\n itemText: getText(after)\n });\n }\n }\n\n let isDropTarget = state.isDropTarget(target);\n let ariaHidden = !dragSession ? 'true' : dropProps['aria-hidden'];\n return {\n dropIndicatorProps: {\n ...dropProps,\n id,\n 'aria-roledescription': stringFormatter.format('dropIndicator'),\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n 'aria-hidden': ariaHidden,\n tabIndex: -1\n },\n isDropTarget,\n // If aria-hidden, we are either not in a drag session or the drop target is invalid.\n // In that case, there's no need to render anything at all unless we need to show the indicator visually.\n // This can happen when dragging using the native DnD API as opposed to keyboard dragging.\n isHidden: !isDropTarget && !!ariaHidden\n };\n}\n"],"names":[],"version":3,"file":"useDropIndicator.mjs.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAcD,MAAM,iCAAW;IACf,UAAU;IACV,OAAO;IACP,SAAS;AACX;AAEO,SAAS;IACd,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,yCAAc;IAC7B,IAAI,cAAc;IAClB,IAAI,mBAAmB,CAAA,GAAA,wCAAa,EAClC,cAAc,gBAAgB,MAAM,CAAC,8BAAQ,CAAC,SAAS,IAAI;IAG7D,OAAO;QACL,WAAW;YACT,GAAG,gBAAgB;YACnB,yFAAyF;YACzF,0FAA0F;YAC1F,0FAA0F;YAC1F,yCAAyC;YACzC,4EAA4E;YAC5E,SAAS,KAAO;QAClB;IACF;AACF","sources":["packages/react-aria/src/dnd/useVirtualDrop.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';\nimport {DOMAttributes} from 'react';\nimport * as DragManager from './DragManager';\nimport intlMessages from '../../intl/dnd/*.json';\nimport {useDescription} from '../utils/useDescription';\nimport {useDragModality} from './utils';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\ninterface VirtualDropResult {\n dropProps: AriaButtonProps & DOMAttributes<HTMLDivElement>;\n}\n\nconst MESSAGES = {\n keyboard: 'dropDescriptionKeyboard',\n touch: 'dropDescriptionTouch',\n virtual: 'dropDescriptionVirtual'\n};\n\nexport function useVirtualDrop(): VirtualDropResult {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let modality = useDragModality();\n let dragSession = DragManager.useDragSession();\n let descriptionProps = useDescription(\n dragSession ? stringFormatter.format(MESSAGES[modality]) : ''\n );\n\n return {\n dropProps: {\n ...descriptionProps,\n // Mobile Safari does not properly bubble click events on elements except links or inputs\n // unless there is an onclick handler bound directly to the element itself. By adding this\n // handler, React will take care of adding that for us, and we are able to handle document\n // level click events in the DragManager.\n // See https://www.quirksmode.org/blog/archives/2010/09/click_event_del.html\n onClick: () => {}\n }\n };\n}\n"],"names":[],"version":3,"file":"useVirtualDrop.cjs.map"}
|