@react-aria/dnd 3.11.5 → 3.11.6
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/DragManager.main.js +19 -16
- package/dist/DragManager.main.js.map +1 -1
- package/dist/DragManager.mjs +20 -17
- package/dist/DragManager.module.js +20 -17
- package/dist/DragManager.module.js.map +1 -1
- package/dist/DropTargetKeyboardNavigation.main.js +13 -3
- package/dist/DropTargetKeyboardNavigation.main.js.map +1 -1
- package/dist/DropTargetKeyboardNavigation.mjs +13 -3
- package/dist/DropTargetKeyboardNavigation.module.js +13 -3
- package/dist/DropTargetKeyboardNavigation.module.js.map +1 -1
- package/dist/useDrag.main.js +6 -6
- package/dist/useDrag.main.js.map +1 -1
- package/dist/useDrag.mjs +7 -7
- package/dist/useDrag.module.js +7 -7
- package/dist/useDrag.module.js.map +1 -1
- package/dist/useDrop.main.js +2 -2
- package/dist/useDrop.main.js.map +1 -1
- package/dist/useDrop.mjs +3 -3
- package/dist/useDrop.module.js +3 -3
- package/dist/useDrop.module.js.map +1 -1
- package/package.json +10 -10
- package/src/DragManager.ts +19 -16
- package/src/DropTargetKeyboardNavigation.ts +14 -3
- package/src/useDrag.ts +8 -8
- package/src/useDrop.ts +3 -3
package/dist/DragManager.main.js
CHANGED
|
@@ -154,7 +154,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
154
154
|
onKeyUp(e) {
|
|
155
155
|
this.cancelEvent(e);
|
|
156
156
|
if (e.key === 'Enter') {
|
|
157
|
-
if (e.altKey || (0, $hMqHl$reactariautils.nodeContains)(this.getCurrentActivateButton(),
|
|
157
|
+
if (e.altKey || (0, $hMqHl$reactariautils.nodeContains)(this.getCurrentActivateButton(), (0, $hMqHl$reactariautils.getEventTarget)(e))) this.activate(this.currentDropTarget, this.currentDropItem);
|
|
158
158
|
else this.drop();
|
|
159
159
|
}
|
|
160
160
|
}
|
|
@@ -165,16 +165,17 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
165
165
|
}
|
|
166
166
|
onFocus(e) {
|
|
167
167
|
let activateButton = this.getCurrentActivateButton();
|
|
168
|
-
|
|
168
|
+
let eventTarget = (0, $hMqHl$reactariautils.getEventTarget)(e);
|
|
169
|
+
if (eventTarget === activateButton) {
|
|
169
170
|
// TODO: canceling this breaks the focus ring. Revisit when we support tabbing.
|
|
170
171
|
this.cancelEvent(e);
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
173
174
|
// Prevent focus events, except to the original drag target.
|
|
174
|
-
if (
|
|
175
|
+
if (eventTarget !== this.dragTarget.element) this.cancelEvent(e);
|
|
175
176
|
// Ignore focus events on the window/document (JSDOM). Will be handled in onBlur, below.
|
|
176
|
-
if (!(
|
|
177
|
-
let dropTarget = this.validDropTargets.find((target)=>target.element ===
|
|
177
|
+
if (!(eventTarget instanceof HTMLElement) || eventTarget === this.dragTarget.element) return;
|
|
178
|
+
let dropTarget = this.validDropTargets.find((target)=>target.element === eventTarget) || this.validDropTargets.find((target)=>(0, $hMqHl$reactariautils.nodeContains)(target.element, eventTarget));
|
|
178
179
|
if (!dropTarget) {
|
|
179
180
|
// if (e.target === activateButton) {
|
|
180
181
|
// activateButton.focus();
|
|
@@ -183,7 +184,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
183
184
|
else this.dragTarget.element.focus();
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
186
|
-
let item = $28e10663603f5ea1$var$dropItems.get(
|
|
187
|
+
let item = $28e10663603f5ea1$var$dropItems.get(eventTarget);
|
|
187
188
|
if (dropTarget) this.setCurrentDropTarget(dropTarget, item);
|
|
188
189
|
}
|
|
189
190
|
onBlur(e) {
|
|
@@ -192,7 +193,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
192
193
|
this.cancelEvent(e);
|
|
193
194
|
return;
|
|
194
195
|
}
|
|
195
|
-
if (e
|
|
196
|
+
if ((0, $hMqHl$reactariautils.getEventTarget)(e) !== this.dragTarget.element) this.cancelEvent(e);
|
|
196
197
|
// If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM),
|
|
197
198
|
// restore focus back to the current drop target if any, or the original drag target.
|
|
198
199
|
if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) {
|
|
@@ -205,20 +206,21 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
205
206
|
if ((0, $hMqHl$reactariautils.isVirtualClick)(e) || this.isVirtualClick) {
|
|
206
207
|
var _item_activateButtonRef, _dropTarget_activateButtonRef;
|
|
207
208
|
let dropElements = $28e10663603f5ea1$var$dropItems.values();
|
|
209
|
+
let eventTarget = (0, $hMqHl$reactariautils.getEventTarget)(e);
|
|
208
210
|
let item = [
|
|
209
211
|
...dropElements
|
|
210
212
|
].find((item)=>{
|
|
211
213
|
var _item_activateButtonRef;
|
|
212
|
-
return item.element ===
|
|
214
|
+
return item.element === eventTarget || (0, $hMqHl$reactariautils.nodeContains)((_item_activateButtonRef = item.activateButtonRef) === null || _item_activateButtonRef === void 0 ? void 0 : _item_activateButtonRef.current, eventTarget);
|
|
213
215
|
});
|
|
214
|
-
let dropTarget = this.validDropTargets.find((target)=>(0, $hMqHl$reactariautils.nodeContains)(target.element,
|
|
216
|
+
let dropTarget = this.validDropTargets.find((target)=>(0, $hMqHl$reactariautils.nodeContains)(target.element, eventTarget));
|
|
215
217
|
var _item_activateButtonRef_current;
|
|
216
218
|
let activateButton = (_item_activateButtonRef_current = item === null || item === void 0 ? void 0 : (_item_activateButtonRef = item.activateButtonRef) === null || _item_activateButtonRef === void 0 ? void 0 : _item_activateButtonRef.current) !== null && _item_activateButtonRef_current !== void 0 ? _item_activateButtonRef_current : dropTarget === null || dropTarget === void 0 ? void 0 : (_dropTarget_activateButtonRef = dropTarget.activateButtonRef) === null || _dropTarget_activateButtonRef === void 0 ? void 0 : _dropTarget_activateButtonRef.current;
|
|
217
|
-
if ((0, $hMqHl$reactariautils.nodeContains)(activateButton,
|
|
219
|
+
if ((0, $hMqHl$reactariautils.nodeContains)(activateButton, eventTarget) && dropTarget) {
|
|
218
220
|
this.activate(dropTarget, item);
|
|
219
221
|
return;
|
|
220
222
|
}
|
|
221
|
-
if (e
|
|
223
|
+
if ((0, $hMqHl$reactariautils.getEventTarget)(e) === this.dragTarget.element) {
|
|
222
224
|
this.cancel();
|
|
223
225
|
return;
|
|
224
226
|
}
|
|
@@ -237,7 +239,8 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
237
239
|
cancelEvent(e) {
|
|
238
240
|
var _this_dragTarget;
|
|
239
241
|
// Allow focusin and focusout on the drag target so focus ring works properly.
|
|
240
|
-
|
|
242
|
+
let eventTarget = (0, $hMqHl$reactariautils.getEventTarget)(e);
|
|
243
|
+
if ((e.type === 'focusin' || e.type === 'focusout') && (eventTarget === ((_this_dragTarget = this.dragTarget) === null || _this_dragTarget === void 0 ? void 0 : _this_dragTarget.element) || eventTarget === this.getCurrentActivateButton())) return;
|
|
241
244
|
// Allow default for events that might cancel a click event
|
|
242
245
|
if (!$28e10663603f5ea1$var$CLICK_EVENTS.includes(e.type)) e.preventDefault();
|
|
243
246
|
e.stopPropagation();
|
|
@@ -411,7 +414,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
411
414
|
var // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).
|
|
412
415
|
// This corrects state such as whether focus ring should appear.
|
|
413
416
|
// useDroppableCollection handles this itself, so this is only for standalone drop zones.
|
|
414
|
-
|
|
417
|
+
_getActiveElement;
|
|
415
418
|
this.teardown();
|
|
416
419
|
$28e10663603f5ea1$var$endDragging();
|
|
417
420
|
if (typeof this.dragTarget.onDragEnd === 'function') {
|
|
@@ -424,18 +427,18 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
424
427
|
dropOperation: this.dropOperation || 'cancel'
|
|
425
428
|
});
|
|
426
429
|
}
|
|
427
|
-
if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) (
|
|
430
|
+
if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) (_getActiveElement = (0, $hMqHl$reactariautils.getActiveElement)()) === null || _getActiveElement === void 0 ? void 0 : _getActiveElement.dispatchEvent(new FocusEvent('focusin', {
|
|
428
431
|
bubbles: true
|
|
429
432
|
}));
|
|
430
433
|
this.setCurrentDropTarget(null);
|
|
431
434
|
}
|
|
432
435
|
cancel() {
|
|
433
436
|
var // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).
|
|
434
|
-
|
|
437
|
+
_getActiveElement;
|
|
435
438
|
this.setCurrentDropTarget(null);
|
|
436
439
|
this.end();
|
|
437
440
|
if (!this.dragTarget.element.closest('[aria-hidden="true"], [inert]')) this.dragTarget.element.focus();
|
|
438
|
-
(
|
|
441
|
+
(_getActiveElement = (0, $hMqHl$reactariautils.getActiveElement)()) === null || _getActiveElement === void 0 ? void 0 : _getActiveElement.dispatchEvent(new FocusEvent('focusin', {
|
|
439
442
|
bubbles: true
|
|
440
443
|
}));
|
|
441
444
|
(0, $hMqHl$reactarialiveannouncer.announce)(this.stringFormatter.format('dropCanceled'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAUD,IAAI,oCAAc,IAAI;AACtB,IAAI,kCAAY,IAAI;AACpB,IAAI,oCAAkC;AACtC,IAAI,sCAAgB,IAAI;AAejB,SAAS,0CAAmB,MAAkB;IACnD,kCAAY,GAAG,CAAC,OAAO,OAAO,EAAE;IAChC,8CAAA,wDAAA,kCAAa,sBAAsB;IACnC,OAAO;QACL,kCAAY,MAAM,CAAC,OAAO,OAAO;QACjC,8CAAA,wDAAA,kCAAa,sBAAsB;IACrC;AACF;AASO,SAAS,0CAAiB,IAAmB;IAClD,gCAAU,GAAG,CAAC,KAAK,OAAO,EAAE;IAC5B,OAAO;QACL,gCAAU,MAAM,CAAC,KAAK,OAAO;IAC/B;AACF;AASO,SAAS,0CAAc,MAAkB,EAAE,eAAyC;IACzF,IAAI,mCACF,MAAM,IA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AAC,SAAS,CAAC,IAAI,CAAC,IAAI;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;QACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI;QACjD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI;QAC7C,IAAI,CAAC,cAAc,GAAG;IACxB;AA0cF;AAEA,SAAS,2CAAqB,OAAmB;IAC/C,IAAI,QAAQ,CAAA,GAAA,kCAAO,EAAE,QAAQ,KAAK;IAClC,OAAO;WAAI,kCAAY,MAAM;KAAG,CAAC,MAAM,CAAC,CAAA;QACtC,IAAI,OAAO,OAAO,CAAC,OAAO,CAAC,kCACzB,OAAO;QAGT,IAAI,OAAO,OAAO,gBAAgB,KAAK,YACrC,OAAO,OAAO,gBAAgB,CAAC,OAAO,QAAQ,qBAAqB,MAAM;QAG3E,OAAO;IACT;AACF","sources":["packages/@react-aria/dnd/src/DragManager.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 {announce} from '@react-aria/live-announcer';\nimport {ariaHideOutside} from '@react-aria/overlays';\nimport {DragEndEvent, DragItem, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropItem, DropOperation, DropTarget as DroppableCollectionTarget, FocusableElement} from '@react-types/shared';\nimport {getDragModality, getTypes} from './utils';\nimport {isVirtualClick, isVirtualPointerEvent, nodeContains} from '@react-aria/utils';\nimport type {LocalizedStringFormatter} from '@internationalized/string';\nimport {RefObject, useEffect, useState} from 'react';\n\nlet dropTargets = new Map<Element, DropTarget>();\nlet dropItems = new Map<Element, DroppableItem>();\nlet dragSession: DragSession | null = null;\nlet subscriptions = new Set<() => void>();\n\ninterface DropTarget {\n element: FocusableElement,\n preventFocusOnDrop?: boolean,\n getDropOperation?: (types: Set<string>, allowedOperations: DropOperation[]) => DropOperation,\n onDropEnter?: (e: DropEnterEvent, dragTarget: DragTarget) => void,\n onDropExit?: (e: DropExitEvent) => void,\n onDropTargetEnter?: (target: DroppableCollectionTarget | null) => void,\n onDropActivate?: (e: DropActivateEvent, target: DroppableCollectionTarget | null) => void,\n onDrop?: (e: DropEvent, target: DroppableCollectionTarget | null) => void,\n onKeyDown?: (e: KeyboardEvent, dragTarget: DragTarget) => void,\n activateButtonRef?: RefObject<FocusableElement | null>\n}\n\nexport function registerDropTarget(target: DropTarget) {\n dropTargets.set(target.element, target);\n dragSession?.updateValidDropTargets();\n return (): void => {\n dropTargets.delete(target.element);\n dragSession?.updateValidDropTargets();\n };\n}\n\ninterface DroppableItem {\n element: FocusableElement,\n target: DroppableCollectionTarget,\n getDropOperation?: (types: Set<string>, allowedOperations: DropOperation[]) => DropOperation,\n activateButtonRef?: RefObject<FocusableElement | null>\n}\n\nexport function registerDropItem(item: DroppableItem) {\n dropItems.set(item.element, item);\n return (): void => {\n dropItems.delete(item.element);\n };\n}\n\ninterface DragTarget {\n element: FocusableElement,\n items: DragItem[],\n allowedDropOperations: DropOperation[],\n onDragEnd?: (e: DragEndEvent) => void\n}\n\nexport function beginDragging(target: DragTarget, stringFormatter: LocalizedStringFormatter): void {\n if (dragSession) {\n throw new Error('Cannot begin dragging while already dragging');\n }\n\n dragSession = new DragSession(target, stringFormatter);\n requestAnimationFrame(() => {\n if (dragSession) {\n dragSession.setup();\n if (getDragModality() === 'keyboard') {\n dragSession.next();\n }\n }\n });\n\n for (let cb of subscriptions) {\n cb();\n }\n}\n\nexport function useDragSession(): DragSession | null {\n let [session, setSession] = useState(dragSession);\n\n useEffect(() => {\n let cb = () => setSession(dragSession);\n subscriptions.add(cb);\n return () => {\n subscriptions.delete(cb);\n };\n }, []);\n\n return session;\n}\n\n/** @private */\nexport function isVirtualDragging(): boolean {\n return !!dragSession;\n}\n\nfunction endDragging() {\n dragSession = null;\n for (let cb of subscriptions) {\n cb();\n }\n}\n\nexport function isValidDropTarget(element: Element): boolean {\n for (let target of dropTargets.keys()) {\n if (nodeContains(target, element)) {\n return true;\n }\n }\n\n return false;\n}\n\nconst CANCELED_EVENTS = [\n 'pointerdown',\n 'pointermove',\n 'pointerenter',\n 'pointerleave',\n 'pointerover',\n 'pointerout',\n 'pointerup',\n 'mousedown',\n 'mousemove',\n 'mouseenter',\n 'mouseleave',\n 'mouseover',\n 'mouseout',\n 'mouseup',\n 'touchstart',\n 'touchmove',\n 'touchend',\n 'focusin',\n 'focusout'\n];\n\nconst CLICK_EVENTS = [\n 'pointerup',\n 'mouseup',\n 'touchend'\n];\n\nconst MESSAGES = {\n keyboard: 'dragStartedKeyboard',\n touch: 'dragStartedTouch',\n virtual: 'dragStartedVirtual'\n};\n\nclass DragSession {\n dragTarget: DragTarget;\n validDropTargets: DropTarget[] = [];\n currentDropTarget: DropTarget | null = null;\n currentDropItem: DroppableItem | null = null;\n dropOperation: DropOperation | null = null;\n private mutationObserver: MutationObserver | null = null;\n private restoreAriaHidden: (() => void) | null = null;\n private stringFormatter: LocalizedStringFormatter;\n private isVirtualClick: boolean = false;\n private initialFocused: boolean;\n\n constructor(target: DragTarget, stringFormatter: LocalizedStringFormatter) {\n this.dragTarget = target;\n this.stringFormatter = stringFormatter;\n\n this.onKeyDown = this.onKeyDown.bind(this);\n this.onKeyUp = this.onKeyUp.bind(this);\n this.onFocus = this.onFocus.bind(this);\n this.onBlur = this.onBlur.bind(this);\n this.onClick = this.onClick.bind(this);\n this.onPointerDown = this.onPointerDown.bind(this);\n this.cancelEvent = this.cancelEvent.bind(this);\n this.initialFocused = false;\n }\n\n setup(): void {\n document.addEventListener('keydown', this.onKeyDown, true);\n document.addEventListener('keyup', this.onKeyUp, true);\n window.addEventListener('focus', this.onFocus, true);\n window.addEventListener('blur', this.onBlur, true);\n document.addEventListener('click', this.onClick, true);\n document.addEventListener('pointerdown', this.onPointerDown, true);\n\n for (let event of CANCELED_EVENTS) {\n document.addEventListener(event, this.cancelEvent, true);\n }\n\n this.mutationObserver = new MutationObserver(() =>\n this.updateValidDropTargets()\n );\n this.updateValidDropTargets();\n\n announce(this.stringFormatter.format(MESSAGES[getDragModality()]));\n }\n\n teardown(): void {\n document.removeEventListener('keydown', this.onKeyDown, true);\n document.removeEventListener('keyup', this.onKeyUp, true);\n window.removeEventListener('focus', this.onFocus, true);\n window.removeEventListener('blur', this.onBlur, true);\n document.removeEventListener('click', this.onClick, true);\n document.removeEventListener('pointerdown', this.onPointerDown, true);\n\n for (let event of CANCELED_EVENTS) {\n document.removeEventListener(event, this.cancelEvent, true);\n }\n\n this.mutationObserver?.disconnect();\n this.restoreAriaHidden?.();\n }\n\n onKeyDown(e: KeyboardEvent): void {\n this.cancelEvent(e);\n\n if (e.key === 'Escape') {\n this.cancel();\n return;\n }\n\n if (e.key === 'Tab' && !(e.metaKey || e.altKey || e.ctrlKey)) {\n if (e.shiftKey) {\n this.previous();\n } else {\n this.next();\n }\n }\n\n if (typeof this.currentDropTarget?.onKeyDown === 'function') {\n this.currentDropTarget.onKeyDown(e, this.dragTarget);\n }\n }\n\n onKeyUp(e: KeyboardEvent): void {\n this.cancelEvent(e);\n\n if (e.key === 'Enter') {\n if (e.altKey || nodeContains(this.getCurrentActivateButton(), e.target as Node)) {\n this.activate(this.currentDropTarget, this.currentDropItem);\n } else {\n this.drop();\n }\n }\n }\n\n getCurrentActivateButton(): FocusableElement | null {\n return this.currentDropItem?.activateButtonRef?.current ?? this.currentDropTarget?.activateButtonRef?.current ?? null;\n }\n\n onFocus(e: FocusEvent): void {\n let activateButton = this.getCurrentActivateButton();\n if (e.target === activateButton) {\n // TODO: canceling this breaks the focus ring. Revisit when we support tabbing.\n this.cancelEvent(e);\n return;\n }\n\n // Prevent focus events, except to the original drag target.\n if (e.target !== this.dragTarget.element) {\n this.cancelEvent(e);\n }\n\n // Ignore focus events on the window/document (JSDOM). Will be handled in onBlur, below.\n if (!(e.target instanceof HTMLElement) || e.target === this.dragTarget.element) {\n return;\n }\n\n let dropTarget =\n this.validDropTargets.find(target => target.element === e.target as HTMLElement) ||\n this.validDropTargets.find(target => nodeContains(target.element, e.target as HTMLElement));\n\n if (!dropTarget) {\n // if (e.target === activateButton) {\n // activateButton.focus();\n // }\n if (this.currentDropTarget) {\n this.currentDropTarget.element.focus();\n } else {\n this.dragTarget.element.focus();\n }\n return;\n }\n\n let item = dropItems.get(e.target as HTMLElement);\n if (dropTarget) {\n this.setCurrentDropTarget(dropTarget, item);\n }\n }\n\n onBlur(e: FocusEvent): void {\n let activateButton = this.getCurrentActivateButton();\n if (e.relatedTarget === activateButton) {\n this.cancelEvent(e);\n return;\n }\n\n if (e.target !== this.dragTarget.element) {\n this.cancelEvent(e);\n }\n\n // If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM),\n // restore focus back to the current drop target if any, or the original drag target.\n if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) {\n if (this.currentDropTarget) {\n this.currentDropTarget.element.focus();\n } else {\n this.dragTarget.element.focus();\n }\n }\n }\n\n onClick(e: MouseEvent): void {\n this.cancelEvent(e);\n if (isVirtualClick(e) || this.isVirtualClick) {\n let dropElements = dropItems.values();\n let item = [...dropElements].find(item => item.element === e.target as HTMLElement || nodeContains(item.activateButtonRef?.current, e.target as HTMLElement));\n let dropTarget = this.validDropTargets.find(target => nodeContains(target.element, e.target as HTMLElement));\n let activateButton = item?.activateButtonRef?.current ?? dropTarget?.activateButtonRef?.current;\n if (nodeContains(activateButton, e.target as HTMLElement) && dropTarget) {\n this.activate(dropTarget, item);\n return;\n }\n\n if (e.target === this.dragTarget.element) {\n this.cancel();\n return;\n }\n\n if (dropTarget) {\n this.setCurrentDropTarget(dropTarget, item);\n this.drop(item);\n }\n }\n }\n\n onPointerDown(e: PointerEvent): void {\n // Android Talkback double tap has e.detail = 1 for onClick. Detect the virtual click in onPointerDown before onClick fires\n // so we can properly perform cancel and drop operations.\n this.cancelEvent(e);\n this.isVirtualClick = isVirtualPointerEvent(e);\n }\n\n cancelEvent(e: Event): void {\n // Allow focusin and focusout on the drag target so focus ring works properly.\n if ((e.type === 'focusin' || e.type === 'focusout') && (e.target === this.dragTarget?.element || e.target === this.getCurrentActivateButton())) {\n return;\n }\n\n // Allow default for events that might cancel a click event\n if (!CLICK_EVENTS.includes(e.type)) {\n e.preventDefault();\n }\n\n e.stopPropagation();\n e.stopImmediatePropagation();\n }\n\n updateValidDropTargets(): void {\n if (!this.mutationObserver) {\n return;\n }\n\n this.mutationObserver.disconnect();\n if (this.restoreAriaHidden) {\n this.restoreAriaHidden();\n }\n\n this.validDropTargets = findValidDropTargets(this.dragTarget);\n\n // Shuffle drop target order based on starting drag target.\n if (this.validDropTargets.length > 0) {\n let nearestIndex = this.findNearestDropTarget();\n this.validDropTargets = [\n ...this.validDropTargets.slice(nearestIndex),\n ...this.validDropTargets.slice(0, nearestIndex)\n ];\n }\n\n if (this.currentDropTarget && !this.validDropTargets.includes(this.currentDropTarget)) {\n this.setCurrentDropTarget(this.validDropTargets[0]);\n }\n\n // Find valid drop items within collections\n let types = getTypes(this.dragTarget.items);\n let validDropItems = [...dropItems.values()].filter(item => {\n if (typeof item.getDropOperation === 'function') {\n return item.getDropOperation(types, this.dragTarget.allowedDropOperations) !== 'cancel';\n }\n\n return true;\n });\n\n // Filter out drop targets that contain valid items. We don't want to stop hiding elements\n // other than the drop items that exist inside the collection.\n let visibleDropTargets = this.validDropTargets.filter(target =>\n !validDropItems.some(item => nodeContains(target.element, item.element))\n );\n\n this.restoreAriaHidden = ariaHideOutside([\n this.dragTarget.element,\n ...validDropItems.flatMap(item => item.activateButtonRef?.current ? [item.element, item.activateButtonRef?.current] : [item.element]),\n ...visibleDropTargets.flatMap(target => target.activateButtonRef?.current ? [target.element, target.activateButtonRef?.current] : [target.element])\n ], {shouldUseInert: true});\n\n this.mutationObserver.observe(document.body, {subtree: true, attributes: true, attributeFilter: ['aria-hidden', 'inert']});\n }\n\n next(): void {\n // TODO: Allow tabbing to the activate button. Revisit once we fix the focus ring.\n // For now, the activate button is reachable by screen readers and ArrowLeft/ArrowRight\n // is usable specifically by Tree. Will need tabbing for other components.\n // let activateButton = this.getCurrentActivateButton();\n // if (activateButton && document.activeElement !== activateButton) {\n // activateButton.focus();\n // return;\n // }\n\n if (!this.currentDropTarget) {\n this.setCurrentDropTarget(this.validDropTargets[0]);\n return;\n }\n\n let index = this.validDropTargets.indexOf(this.currentDropTarget);\n if (index < 0) {\n this.setCurrentDropTarget(this.validDropTargets[0]);\n return;\n }\n\n // If we've reached the end of the valid drop targets, cycle back to the original drag target.\n // This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).\n if (index === this.validDropTargets.length - 1) {\n if (!this.dragTarget.element.closest('[aria-hidden=\"true\"], [inert]')) {\n this.setCurrentDropTarget(null);\n this.dragTarget.element.focus();\n } else {\n this.setCurrentDropTarget(this.validDropTargets[0]);\n }\n } else {\n this.setCurrentDropTarget(this.validDropTargets[index + 1]);\n }\n }\n\n previous(): void {\n // let activateButton = this.getCurrentActivateButton();\n // if (activateButton && document.activeElement === activateButton) {\n // let target = this.currentDropItem ?? this.currentDropTarget;\n // if (target) {\n // target.element.focus();\n // return;\n // }\n // }\n\n if (!this.currentDropTarget) {\n this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);\n return;\n }\n\n let index = this.validDropTargets.indexOf(this.currentDropTarget);\n if (index < 0) {\n this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);\n return;\n }\n\n // If we've reached the start of the valid drop targets, cycle back to the original drag target.\n // This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).\n if (index === 0) {\n if (!this.dragTarget.element.closest('[aria-hidden=\"true\"], [inert]')) {\n this.setCurrentDropTarget(null);\n this.dragTarget.element.focus();\n } else {\n this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);\n }\n } else {\n this.setCurrentDropTarget(this.validDropTargets[index - 1]);\n }\n }\n\n findNearestDropTarget(): number {\n let dragTargetRect = this.dragTarget.element.getBoundingClientRect();\n\n let minDistance = Infinity;\n let nearest = -1;\n for (let i = 0; i < this.validDropTargets.length; i++) {\n let dropTarget = this.validDropTargets[i];\n let rect = dropTarget.element.getBoundingClientRect();\n let dx = rect.left - dragTargetRect.left;\n let dy = rect.top - dragTargetRect.top;\n let dist = (dx * dx) + (dy * dy);\n if (dist < minDistance) {\n minDistance = dist;\n nearest = i;\n }\n }\n\n return nearest;\n }\n\n setCurrentDropTarget(dropTarget: DropTarget | null, item?: DroppableItem): void {\n if (dropTarget !== this.currentDropTarget) {\n if (this.currentDropTarget && typeof this.currentDropTarget.onDropExit === 'function') {\n let rect = this.currentDropTarget.element.getBoundingClientRect();\n this.currentDropTarget.onDropExit({\n type: 'dropexit',\n x: rect.left + (rect.width / 2),\n y: rect.top + (rect.height / 2)\n });\n }\n\n this.currentDropTarget = dropTarget;\n\n if (dropTarget) {\n if (typeof dropTarget.onDropEnter === 'function') {\n let rect = dropTarget.element.getBoundingClientRect();\n dropTarget.onDropEnter({\n type: 'dropenter',\n x: rect.left + (rect.width / 2),\n y: rect.top + (rect.height / 2)\n }, this.dragTarget);\n }\n\n if (!item) {\n dropTarget?.element.focus();\n }\n }\n }\n\n if (item != null && item !== this.currentDropItem) {\n if (this.currentDropTarget && typeof this.currentDropTarget.onDropTargetEnter === 'function') {\n this.currentDropTarget.onDropTargetEnter(item.target);\n }\n item.element.focus();\n this.currentDropItem = item;\n\n // Announce first drop target after drag start announcement finishes.\n // Otherwise, it will never get announced because drag start announcement is assertive.\n if (!this.initialFocused) {\n let label = item?.element.getAttribute('aria-label');\n if (label) {\n announce(label, 'polite');\n }\n this.initialFocused = true;\n }\n }\n }\n\n end(): void {\n this.teardown();\n endDragging();\n\n if (typeof this.dragTarget.onDragEnd === 'function') {\n let target = this.currentDropTarget && this.dropOperation !== 'cancel' ? this.currentDropTarget : this.dragTarget;\n let rect = target.element.getBoundingClientRect();\n this.dragTarget.onDragEnd({\n type: 'dragend',\n x: rect.x + (rect.width / 2),\n y: rect.y + (rect.height / 2),\n dropOperation: this.dropOperation || 'cancel'\n });\n }\n\n if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) {\n // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).\n // This corrects state such as whether focus ring should appear.\n // useDroppableCollection handles this itself, so this is only for standalone drop zones.\n document.activeElement?.dispatchEvent(new FocusEvent('focusin', {bubbles: true}));\n }\n\n this.setCurrentDropTarget(null);\n }\n\n cancel(): void {\n this.setCurrentDropTarget(null);\n this.end();\n if (!this.dragTarget.element.closest('[aria-hidden=\"true\"], [inert]')) {\n this.dragTarget.element.focus();\n }\n\n // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).\n document.activeElement?.dispatchEvent(new FocusEvent('focusin', {bubbles: true}));\n\n announce(this.stringFormatter.format('dropCanceled'));\n }\n\n drop(item?: DroppableItem): void {\n if (!this.currentDropTarget) {\n this.cancel();\n return;\n }\n\n if (typeof item?.getDropOperation === 'function') {\n let types = getTypes(this.dragTarget.items);\n this.dropOperation = item.getDropOperation(types, this.dragTarget.allowedDropOperations);\n } else if (typeof this.currentDropTarget.getDropOperation === 'function') {\n let types = getTypes(this.dragTarget.items);\n this.dropOperation = this.currentDropTarget.getDropOperation(types, this.dragTarget.allowedDropOperations);\n } else {\n // TODO: show menu ??\n this.dropOperation = this.dragTarget.allowedDropOperations[0];\n }\n\n if (typeof this.currentDropTarget.onDrop === 'function') {\n let items: DropItem[] = this.dragTarget.items.map(item => ({\n kind: 'text',\n types: new Set(Object.keys(item)),\n getText: (type: string) => Promise.resolve(item[type])\n }));\n\n let rect = this.currentDropTarget.element.getBoundingClientRect();\n this.currentDropTarget.onDrop({\n type: 'drop',\n x: rect.left + (rect.width / 2),\n y: rect.top + (rect.height / 2),\n items,\n dropOperation: this.dropOperation\n }, item?.target ?? null);\n }\n\n this.end();\n announce(this.stringFormatter.format('dropComplete'));\n }\n\n activate(dropTarget: DropTarget | null, dropItem: DroppableItem | null | undefined): void {\n if (dropTarget && typeof dropTarget.onDropActivate === 'function') {\n let target = dropItem?.target ?? null;\n let rect = dropTarget.element.getBoundingClientRect();\n dropTarget.onDropActivate({\n type: 'dropactivate',\n x: rect.left + (rect.width / 2),\n y: rect.top + (rect.height / 2)\n }, target);\n }\n }\n}\n\nfunction findValidDropTargets(options: DragTarget) {\n let types = getTypes(options.items);\n return [...dropTargets.values()].filter(target => {\n if (target.element.closest('[aria-hidden=\"true\"], [inert]')) {\n return false;\n }\n\n if (typeof target.getDropOperation === 'function') {\n return target.getDropOperation(types, options.allowedDropOperations) !== 'cancel';\n }\n\n return true;\n });\n}\n"],"names":[],"version":3,"file":"DragManager.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAUD,IAAI,oCAAc,IAAI;AACtB,IAAI,kCAAY,IAAI;AACpB,IAAI,oCAAkC;AACtC,IAAI,sCAAgB,IAAI;AAejB,SAAS,0CAAmB,MAAkB;IACnD,kCAAY,GAAG,CAAC,OAAO,OAAO,EAAE;IAChC,8CAAA,wDAAA,kCAAa,sBAAsB;IACnC,OAAO;QACL,kCAAY,MAAM,CAAC,OAAO,OAAO;QACjC,8CAAA,wDAAA,kCAAa,sBAAsB;IACrC;AACF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YAAY,MAAkB,EAAE,eAAyC,CAAE;aAV3E,mBAAiC,EAAE;aACnC,oBAAuC;aACvC,kBAAwC;aACxC,gBAAsC;aAC9B,mBAA4C;aAC5C,oBAAyC;aAEzC,iBAA0B;QAIhC,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,eAAe,GAAG;QAEvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;QACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI;QACjD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI;QAC7C,IAAI,CAAC,cAAc,GAAG;IACxB;AA6cF;AAEA,SAAS,2CAAqB,OAAmB;IAC/C,IAAI,QAAQ,CAAA,GAAA,kCAAO,EAAE,QAAQ,KAAK;IAClC,OAAO;WAAI,kCAAY,MAAM;KAAG,CAAC,MAAM,CAAC,CAAA;QACtC,IAAI,OAAO,OAAO,CAAC,OAAO,CAAC,kCACzB,OAAO;QAGT,IAAI,OAAO,OAAO,gBAAgB,KAAK,YACrC,OAAO,OAAO,gBAAgB,CAAC,OAAO,QAAQ,qBAAqB,MAAM;QAG3E,OAAO;IACT;AACF","sources":["packages/@react-aria/dnd/src/DragManager.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 {announce} from '@react-aria/live-announcer';\nimport {ariaHideOutside} from '@react-aria/overlays';\nimport {DragEndEvent, DragItem, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropItem, DropOperation, DropTarget as DroppableCollectionTarget, FocusableElement} from '@react-types/shared';\nimport {getActiveElement, getEventTarget, isVirtualClick, isVirtualPointerEvent, nodeContains} from '@react-aria/utils';\nimport {getDragModality, getTypes} from './utils';\nimport type {LocalizedStringFormatter} from '@internationalized/string';\nimport {RefObject, useEffect, useState} from 'react';\n\nlet dropTargets = new Map<Element, DropTarget>();\nlet dropItems = new Map<Element, DroppableItem>();\nlet dragSession: DragSession | null = null;\nlet subscriptions = new Set<() => void>();\n\ninterface DropTarget {\n element: FocusableElement,\n preventFocusOnDrop?: boolean,\n getDropOperation?: (types: Set<string>, allowedOperations: DropOperation[]) => DropOperation,\n onDropEnter?: (e: DropEnterEvent, dragTarget: DragTarget) => void,\n onDropExit?: (e: DropExitEvent) => void,\n onDropTargetEnter?: (target: DroppableCollectionTarget | null) => void,\n onDropActivate?: (e: DropActivateEvent, target: DroppableCollectionTarget | null) => void,\n onDrop?: (e: DropEvent, target: DroppableCollectionTarget | null) => void,\n onKeyDown?: (e: KeyboardEvent, dragTarget: DragTarget) => void,\n activateButtonRef?: RefObject<FocusableElement | null>\n}\n\nexport function registerDropTarget(target: DropTarget) {\n dropTargets.set(target.element, target);\n dragSession?.updateValidDropTargets();\n return (): void => {\n dropTargets.delete(target.element);\n dragSession?.updateValidDropTargets();\n };\n}\n\ninterface DroppableItem {\n element: FocusableElement,\n target: DroppableCollectionTarget,\n getDropOperation?: (types: Set<string>, allowedOperations: DropOperation[]) => DropOperation,\n activateButtonRef?: RefObject<FocusableElement | null>\n}\n\nexport function registerDropItem(item: DroppableItem) {\n dropItems.set(item.element, item);\n return (): void => {\n dropItems.delete(item.element);\n };\n}\n\ninterface DragTarget {\n element: FocusableElement,\n items: DragItem[],\n allowedDropOperations: DropOperation[],\n onDragEnd?: (e: DragEndEvent) => void\n}\n\nexport function beginDragging(target: DragTarget, stringFormatter: LocalizedStringFormatter): void {\n if (dragSession) {\n throw new Error('Cannot begin dragging while already dragging');\n }\n\n dragSession = new DragSession(target, stringFormatter);\n requestAnimationFrame(() => {\n if (dragSession) {\n dragSession.setup();\n if (getDragModality() === 'keyboard') {\n dragSession.next();\n }\n }\n });\n\n for (let cb of subscriptions) {\n cb();\n }\n}\n\nexport function useDragSession(): DragSession | null {\n let [session, setSession] = useState(dragSession);\n\n useEffect(() => {\n let cb = () => setSession(dragSession);\n subscriptions.add(cb);\n return () => {\n subscriptions.delete(cb);\n };\n }, []);\n\n return session;\n}\n\n/** @private */\nexport function isVirtualDragging(): boolean {\n return !!dragSession;\n}\n\nfunction endDragging() {\n dragSession = null;\n for (let cb of subscriptions) {\n cb();\n }\n}\n\nexport function isValidDropTarget(element: Element): boolean {\n for (let target of dropTargets.keys()) {\n if (nodeContains(target, element)) {\n return true;\n }\n }\n\n return false;\n}\n\nconst CANCELED_EVENTS = [\n 'pointerdown',\n 'pointermove',\n 'pointerenter',\n 'pointerleave',\n 'pointerover',\n 'pointerout',\n 'pointerup',\n 'mousedown',\n 'mousemove',\n 'mouseenter',\n 'mouseleave',\n 'mouseover',\n 'mouseout',\n 'mouseup',\n 'touchstart',\n 'touchmove',\n 'touchend',\n 'focusin',\n 'focusout'\n];\n\nconst CLICK_EVENTS = [\n 'pointerup',\n 'mouseup',\n 'touchend'\n];\n\nconst MESSAGES = {\n keyboard: 'dragStartedKeyboard',\n touch: 'dragStartedTouch',\n virtual: 'dragStartedVirtual'\n};\n\nclass DragSession {\n dragTarget: DragTarget;\n validDropTargets: DropTarget[] = [];\n currentDropTarget: DropTarget | null = null;\n currentDropItem: DroppableItem | null = null;\n dropOperation: DropOperation | null = null;\n private mutationObserver: MutationObserver | null = null;\n private restoreAriaHidden: (() => void) | null = null;\n private stringFormatter: LocalizedStringFormatter;\n private isVirtualClick: boolean = false;\n private initialFocused: boolean;\n\n constructor(target: DragTarget, stringFormatter: LocalizedStringFormatter) {\n this.dragTarget = target;\n this.stringFormatter = stringFormatter;\n\n this.onKeyDown = this.onKeyDown.bind(this);\n this.onKeyUp = this.onKeyUp.bind(this);\n this.onFocus = this.onFocus.bind(this);\n this.onBlur = this.onBlur.bind(this);\n this.onClick = this.onClick.bind(this);\n this.onPointerDown = this.onPointerDown.bind(this);\n this.cancelEvent = this.cancelEvent.bind(this);\n this.initialFocused = false;\n }\n\n setup(): void {\n document.addEventListener('keydown', this.onKeyDown, true);\n document.addEventListener('keyup', this.onKeyUp, true);\n window.addEventListener('focus', this.onFocus, true);\n window.addEventListener('blur', this.onBlur, true);\n document.addEventListener('click', this.onClick, true);\n document.addEventListener('pointerdown', this.onPointerDown, true);\n\n for (let event of CANCELED_EVENTS) {\n document.addEventListener(event, this.cancelEvent, true);\n }\n\n this.mutationObserver = new MutationObserver(() =>\n this.updateValidDropTargets()\n );\n this.updateValidDropTargets();\n\n announce(this.stringFormatter.format(MESSAGES[getDragModality()]));\n }\n\n teardown(): void {\n document.removeEventListener('keydown', this.onKeyDown, true);\n document.removeEventListener('keyup', this.onKeyUp, true);\n window.removeEventListener('focus', this.onFocus, true);\n window.removeEventListener('blur', this.onBlur, true);\n document.removeEventListener('click', this.onClick, true);\n document.removeEventListener('pointerdown', this.onPointerDown, true);\n\n for (let event of CANCELED_EVENTS) {\n document.removeEventListener(event, this.cancelEvent, true);\n }\n\n this.mutationObserver?.disconnect();\n this.restoreAriaHidden?.();\n }\n\n onKeyDown(e: KeyboardEvent): void {\n this.cancelEvent(e);\n\n if (e.key === 'Escape') {\n this.cancel();\n return;\n }\n\n if (e.key === 'Tab' && !(e.metaKey || e.altKey || e.ctrlKey)) {\n if (e.shiftKey) {\n this.previous();\n } else {\n this.next();\n }\n }\n\n if (typeof this.currentDropTarget?.onKeyDown === 'function') {\n this.currentDropTarget.onKeyDown(e, this.dragTarget);\n }\n }\n\n onKeyUp(e: KeyboardEvent): void {\n this.cancelEvent(e);\n\n if (e.key === 'Enter') {\n if (e.altKey || nodeContains(this.getCurrentActivateButton(), getEventTarget(e) as Node)) {\n this.activate(this.currentDropTarget, this.currentDropItem);\n } else {\n this.drop();\n }\n }\n }\n\n getCurrentActivateButton(): FocusableElement | null {\n return this.currentDropItem?.activateButtonRef?.current ?? this.currentDropTarget?.activateButtonRef?.current ?? null;\n }\n\n onFocus(e: FocusEvent): void {\n let activateButton = this.getCurrentActivateButton();\n let eventTarget = getEventTarget(e);\n if (eventTarget === activateButton) {\n // TODO: canceling this breaks the focus ring. Revisit when we support tabbing.\n this.cancelEvent(e);\n return;\n }\n\n // Prevent focus events, except to the original drag target.\n if (eventTarget !== this.dragTarget.element) {\n this.cancelEvent(e);\n }\n\n // Ignore focus events on the window/document (JSDOM). Will be handled in onBlur, below.\n if (!(eventTarget instanceof HTMLElement) || eventTarget === this.dragTarget.element) {\n return;\n }\n\n let dropTarget =\n this.validDropTargets.find(target => target.element === eventTarget) ||\n this.validDropTargets.find(target => nodeContains(target.element, eventTarget));\n\n if (!dropTarget) {\n // if (e.target === activateButton) {\n // activateButton.focus();\n // }\n if (this.currentDropTarget) {\n this.currentDropTarget.element.focus();\n } else {\n this.dragTarget.element.focus();\n }\n return;\n }\n\n let item = dropItems.get(eventTarget);\n if (dropTarget) {\n this.setCurrentDropTarget(dropTarget, item);\n }\n }\n\n onBlur(e: FocusEvent): void {\n let activateButton = this.getCurrentActivateButton();\n if (e.relatedTarget === activateButton) {\n this.cancelEvent(e);\n return;\n }\n\n if (getEventTarget(e) !== this.dragTarget.element) {\n this.cancelEvent(e);\n }\n\n // If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM),\n // restore focus back to the current drop target if any, or the original drag target.\n if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) {\n if (this.currentDropTarget) {\n this.currentDropTarget.element.focus();\n } else {\n this.dragTarget.element.focus();\n }\n }\n }\n\n onClick(e: MouseEvent): void {\n this.cancelEvent(e);\n if (isVirtualClick(e) || this.isVirtualClick) {\n let dropElements = dropItems.values();\n let eventTarget = getEventTarget(e) as HTMLElement;\n let item = [...dropElements].find(item => item.element === eventTarget || nodeContains(item.activateButtonRef?.current, eventTarget));\n let dropTarget = this.validDropTargets.find(target => nodeContains(target.element, eventTarget));\n let activateButton = item?.activateButtonRef?.current ?? dropTarget?.activateButtonRef?.current;\n if (nodeContains(activateButton, eventTarget) && dropTarget) {\n this.activate(dropTarget, item);\n return;\n }\n\n if (getEventTarget(e) === this.dragTarget.element) {\n this.cancel();\n return;\n }\n\n if (dropTarget) {\n this.setCurrentDropTarget(dropTarget, item);\n this.drop(item);\n }\n }\n }\n\n onPointerDown(e: PointerEvent): void {\n // Android Talkback double tap has e.detail = 1 for onClick. Detect the virtual click in onPointerDown before onClick fires\n // so we can properly perform cancel and drop operations.\n this.cancelEvent(e);\n this.isVirtualClick = isVirtualPointerEvent(e);\n }\n\n cancelEvent(e: Event): void {\n // Allow focusin and focusout on the drag target so focus ring works properly.\n let eventTarget = getEventTarget(e);\n if ((e.type === 'focusin' || e.type === 'focusout') && (eventTarget === this.dragTarget?.element || eventTarget === this.getCurrentActivateButton())) {\n return;\n }\n\n // Allow default for events that might cancel a click event\n if (!CLICK_EVENTS.includes(e.type)) {\n e.preventDefault();\n }\n\n e.stopPropagation();\n e.stopImmediatePropagation();\n }\n\n updateValidDropTargets(): void {\n if (!this.mutationObserver) {\n return;\n }\n\n this.mutationObserver.disconnect();\n if (this.restoreAriaHidden) {\n this.restoreAriaHidden();\n }\n\n this.validDropTargets = findValidDropTargets(this.dragTarget);\n\n // Shuffle drop target order based on starting drag target.\n if (this.validDropTargets.length > 0) {\n let nearestIndex = this.findNearestDropTarget();\n this.validDropTargets = [\n ...this.validDropTargets.slice(nearestIndex),\n ...this.validDropTargets.slice(0, nearestIndex)\n ];\n }\n\n if (this.currentDropTarget && !this.validDropTargets.includes(this.currentDropTarget)) {\n this.setCurrentDropTarget(this.validDropTargets[0]);\n }\n\n // Find valid drop items within collections\n let types = getTypes(this.dragTarget.items);\n let validDropItems = [...dropItems.values()].filter(item => {\n if (typeof item.getDropOperation === 'function') {\n return item.getDropOperation(types, this.dragTarget.allowedDropOperations) !== 'cancel';\n }\n\n return true;\n });\n\n // Filter out drop targets that contain valid items. We don't want to stop hiding elements\n // other than the drop items that exist inside the collection.\n let visibleDropTargets = this.validDropTargets.filter(target =>\n !validDropItems.some(item => nodeContains(target.element, item.element))\n );\n\n this.restoreAriaHidden = ariaHideOutside([\n this.dragTarget.element,\n ...validDropItems.flatMap(item => item.activateButtonRef?.current ? [item.element, item.activateButtonRef?.current] : [item.element]),\n ...visibleDropTargets.flatMap(target => target.activateButtonRef?.current ? [target.element, target.activateButtonRef?.current] : [target.element])\n ], {shouldUseInert: true});\n\n this.mutationObserver.observe(document.body, {subtree: true, attributes: true, attributeFilter: ['aria-hidden', 'inert']});\n }\n\n next(): void {\n // TODO: Allow tabbing to the activate button. Revisit once we fix the focus ring.\n // For now, the activate button is reachable by screen readers and ArrowLeft/ArrowRight\n // is usable specifically by Tree. Will need tabbing for other components.\n // let activateButton = this.getCurrentActivateButton();\n // if (activateButton && document.activeElement !== activateButton) {\n // activateButton.focus();\n // return;\n // }\n\n if (!this.currentDropTarget) {\n this.setCurrentDropTarget(this.validDropTargets[0]);\n return;\n }\n\n let index = this.validDropTargets.indexOf(this.currentDropTarget);\n if (index < 0) {\n this.setCurrentDropTarget(this.validDropTargets[0]);\n return;\n }\n\n // If we've reached the end of the valid drop targets, cycle back to the original drag target.\n // This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).\n if (index === this.validDropTargets.length - 1) {\n if (!this.dragTarget.element.closest('[aria-hidden=\"true\"], [inert]')) {\n this.setCurrentDropTarget(null);\n this.dragTarget.element.focus();\n } else {\n this.setCurrentDropTarget(this.validDropTargets[0]);\n }\n } else {\n this.setCurrentDropTarget(this.validDropTargets[index + 1]);\n }\n }\n\n previous(): void {\n // let activateButton = this.getCurrentActivateButton();\n // if (activateButton && document.activeElement === activateButton) {\n // let target = this.currentDropItem ?? this.currentDropTarget;\n // if (target) {\n // target.element.focus();\n // return;\n // }\n // }\n\n if (!this.currentDropTarget) {\n this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);\n return;\n }\n\n let index = this.validDropTargets.indexOf(this.currentDropTarget);\n if (index < 0) {\n this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);\n return;\n }\n\n // If we've reached the start of the valid drop targets, cycle back to the original drag target.\n // This lets the user cancel the drag in case they don't have an Escape key (e.g. iPad keyboard case).\n if (index === 0) {\n if (!this.dragTarget.element.closest('[aria-hidden=\"true\"], [inert]')) {\n this.setCurrentDropTarget(null);\n this.dragTarget.element.focus();\n } else {\n this.setCurrentDropTarget(this.validDropTargets[this.validDropTargets.length - 1]);\n }\n } else {\n this.setCurrentDropTarget(this.validDropTargets[index - 1]);\n }\n }\n\n findNearestDropTarget(): number {\n let dragTargetRect = this.dragTarget.element.getBoundingClientRect();\n\n let minDistance = Infinity;\n let nearest = -1;\n for (let i = 0; i < this.validDropTargets.length; i++) {\n let dropTarget = this.validDropTargets[i];\n let rect = dropTarget.element.getBoundingClientRect();\n let dx = rect.left - dragTargetRect.left;\n let dy = rect.top - dragTargetRect.top;\n let dist = (dx * dx) + (dy * dy);\n if (dist < minDistance) {\n minDistance = dist;\n nearest = i;\n }\n }\n\n return nearest;\n }\n\n setCurrentDropTarget(dropTarget: DropTarget | null, item?: DroppableItem): void {\n if (dropTarget !== this.currentDropTarget) {\n if (this.currentDropTarget && typeof this.currentDropTarget.onDropExit === 'function') {\n let rect = this.currentDropTarget.element.getBoundingClientRect();\n this.currentDropTarget.onDropExit({\n type: 'dropexit',\n x: rect.left + (rect.width / 2),\n y: rect.top + (rect.height / 2)\n });\n }\n\n this.currentDropTarget = dropTarget;\n\n if (dropTarget) {\n if (typeof dropTarget.onDropEnter === 'function') {\n let rect = dropTarget.element.getBoundingClientRect();\n dropTarget.onDropEnter({\n type: 'dropenter',\n x: rect.left + (rect.width / 2),\n y: rect.top + (rect.height / 2)\n }, this.dragTarget);\n }\n\n if (!item) {\n dropTarget?.element.focus();\n }\n }\n }\n\n if (item != null && item !== this.currentDropItem) {\n if (this.currentDropTarget && typeof this.currentDropTarget.onDropTargetEnter === 'function') {\n this.currentDropTarget.onDropTargetEnter(item.target);\n }\n item.element.focus();\n this.currentDropItem = item;\n\n // Announce first drop target after drag start announcement finishes.\n // Otherwise, it will never get announced because drag start announcement is assertive.\n if (!this.initialFocused) {\n let label = item?.element.getAttribute('aria-label');\n if (label) {\n announce(label, 'polite');\n }\n this.initialFocused = true;\n }\n }\n }\n\n end(): void {\n this.teardown();\n endDragging();\n\n if (typeof this.dragTarget.onDragEnd === 'function') {\n let target = this.currentDropTarget && this.dropOperation !== 'cancel' ? this.currentDropTarget : this.dragTarget;\n let rect = target.element.getBoundingClientRect();\n this.dragTarget.onDragEnd({\n type: 'dragend',\n x: rect.x + (rect.width / 2),\n y: rect.y + (rect.height / 2),\n dropOperation: this.dropOperation || 'cancel'\n });\n }\n\n if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) {\n // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).\n // This corrects state such as whether focus ring should appear.\n // useDroppableCollection handles this itself, so this is only for standalone drop zones.\n getActiveElement()?.dispatchEvent(new FocusEvent('focusin', {bubbles: true}));\n }\n\n this.setCurrentDropTarget(null);\n }\n\n cancel(): void {\n this.setCurrentDropTarget(null);\n this.end();\n if (!this.dragTarget.element.closest('[aria-hidden=\"true\"], [inert]')) {\n this.dragTarget.element.focus();\n }\n\n // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).\n getActiveElement()?.dispatchEvent(new FocusEvent('focusin', {bubbles: true}));\n\n announce(this.stringFormatter.format('dropCanceled'));\n }\n\n drop(item?: DroppableItem): void {\n if (!this.currentDropTarget) {\n this.cancel();\n return;\n }\n\n if (typeof item?.getDropOperation === 'function') {\n let types = getTypes(this.dragTarget.items);\n this.dropOperation = item.getDropOperation(types, this.dragTarget.allowedDropOperations);\n } else if (typeof this.currentDropTarget.getDropOperation === 'function') {\n let types = getTypes(this.dragTarget.items);\n this.dropOperation = this.currentDropTarget.getDropOperation(types, this.dragTarget.allowedDropOperations);\n } else {\n // TODO: show menu ??\n this.dropOperation = this.dragTarget.allowedDropOperations[0];\n }\n\n if (typeof this.currentDropTarget.onDrop === 'function') {\n let items: DropItem[] = this.dragTarget.items.map(item => ({\n kind: 'text',\n types: new Set(Object.keys(item)),\n getText: (type: string) => Promise.resolve(item[type])\n }));\n\n let rect = this.currentDropTarget.element.getBoundingClientRect();\n this.currentDropTarget.onDrop({\n type: 'drop',\n x: rect.left + (rect.width / 2),\n y: rect.top + (rect.height / 2),\n items,\n dropOperation: this.dropOperation\n }, item?.target ?? null);\n }\n\n this.end();\n announce(this.stringFormatter.format('dropComplete'));\n }\n\n activate(dropTarget: DropTarget | null, dropItem: DroppableItem | null | undefined): void {\n if (dropTarget && typeof dropTarget.onDropActivate === 'function') {\n let target = dropItem?.target ?? null;\n let rect = dropTarget.element.getBoundingClientRect();\n dropTarget.onDropActivate({\n type: 'dropactivate',\n x: rect.left + (rect.width / 2),\n y: rect.top + (rect.height / 2)\n }, target);\n }\n }\n}\n\nfunction findValidDropTargets(options: DragTarget) {\n let types = getTypes(options.items);\n return [...dropTargets.values()].filter(target => {\n if (target.element.closest('[aria-hidden=\"true\"], [inert]')) {\n return false;\n }\n\n if (typeof target.getDropOperation === 'function') {\n return target.getDropOperation(types, options.allowedDropOperations) !== 'cancel';\n }\n\n return true;\n });\n}\n"],"names":[],"version":3,"file":"DragManager.main.js.map"}
|
package/dist/DragManager.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {getDragModality as $7252cd45fc48c07c$export$1fb2158d224b542c, getTypes as $7252cd45fc48c07c$export$e1d41611756c6326} from "./utils.mjs";
|
|
2
2
|
import {announce as $irqIb$announce} from "@react-aria/live-announcer";
|
|
3
3
|
import {ariaHideOutside as $irqIb$ariaHideOutside} from "@react-aria/overlays";
|
|
4
|
-
import {nodeContains as $irqIb$nodeContains, isVirtualClick as $irqIb$isVirtualClick, isVirtualPointerEvent as $irqIb$isVirtualPointerEvent} from "@react-aria/utils";
|
|
4
|
+
import {nodeContains as $irqIb$nodeContains, getEventTarget as $irqIb$getEventTarget, isVirtualClick as $irqIb$isVirtualClick, isVirtualPointerEvent as $irqIb$isVirtualPointerEvent, getActiveElement as $irqIb$getActiveElement} from "@react-aria/utils";
|
|
5
5
|
import {useState as $irqIb$useState, useEffect as $irqIb$useEffect} from "react";
|
|
6
6
|
|
|
7
7
|
/*
|
|
@@ -144,7 +144,7 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
144
144
|
onKeyUp(e) {
|
|
145
145
|
this.cancelEvent(e);
|
|
146
146
|
if (e.key === 'Enter') {
|
|
147
|
-
if (e.altKey || (0, $irqIb$nodeContains)(this.getCurrentActivateButton(), e
|
|
147
|
+
if (e.altKey || (0, $irqIb$nodeContains)(this.getCurrentActivateButton(), (0, $irqIb$getEventTarget)(e))) this.activate(this.currentDropTarget, this.currentDropItem);
|
|
148
148
|
else this.drop();
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -155,16 +155,17 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
155
155
|
}
|
|
156
156
|
onFocus(e) {
|
|
157
157
|
let activateButton = this.getCurrentActivateButton();
|
|
158
|
-
|
|
158
|
+
let eventTarget = (0, $irqIb$getEventTarget)(e);
|
|
159
|
+
if (eventTarget === activateButton) {
|
|
159
160
|
// TODO: canceling this breaks the focus ring. Revisit when we support tabbing.
|
|
160
161
|
this.cancelEvent(e);
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
164
|
// Prevent focus events, except to the original drag target.
|
|
164
|
-
if (
|
|
165
|
+
if (eventTarget !== this.dragTarget.element) this.cancelEvent(e);
|
|
165
166
|
// Ignore focus events on the window/document (JSDOM). Will be handled in onBlur, below.
|
|
166
|
-
if (!(
|
|
167
|
-
let dropTarget = this.validDropTargets.find((target)=>target.element ===
|
|
167
|
+
if (!(eventTarget instanceof HTMLElement) || eventTarget === this.dragTarget.element) return;
|
|
168
|
+
let dropTarget = this.validDropTargets.find((target)=>target.element === eventTarget) || this.validDropTargets.find((target)=>(0, $irqIb$nodeContains)(target.element, eventTarget));
|
|
168
169
|
if (!dropTarget) {
|
|
169
170
|
// if (e.target === activateButton) {
|
|
170
171
|
// activateButton.focus();
|
|
@@ -173,7 +174,7 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
173
174
|
else this.dragTarget.element.focus();
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
176
|
-
let item = $67560de7c78cb232$var$dropItems.get(
|
|
177
|
+
let item = $67560de7c78cb232$var$dropItems.get(eventTarget);
|
|
177
178
|
if (dropTarget) this.setCurrentDropTarget(dropTarget, item);
|
|
178
179
|
}
|
|
179
180
|
onBlur(e) {
|
|
@@ -182,7 +183,7 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
182
183
|
this.cancelEvent(e);
|
|
183
184
|
return;
|
|
184
185
|
}
|
|
185
|
-
if (e
|
|
186
|
+
if ((0, $irqIb$getEventTarget)(e) !== this.dragTarget.element) this.cancelEvent(e);
|
|
186
187
|
// If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM),
|
|
187
188
|
// restore focus back to the current drop target if any, or the original drag target.
|
|
188
189
|
if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) {
|
|
@@ -195,20 +196,21 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
195
196
|
if ((0, $irqIb$isVirtualClick)(e) || this.isVirtualClick) {
|
|
196
197
|
var _item_activateButtonRef, _dropTarget_activateButtonRef;
|
|
197
198
|
let dropElements = $67560de7c78cb232$var$dropItems.values();
|
|
199
|
+
let eventTarget = (0, $irqIb$getEventTarget)(e);
|
|
198
200
|
let item = [
|
|
199
201
|
...dropElements
|
|
200
202
|
].find((item)=>{
|
|
201
203
|
var _item_activateButtonRef;
|
|
202
|
-
return item.element ===
|
|
204
|
+
return item.element === eventTarget || (0, $irqIb$nodeContains)((_item_activateButtonRef = item.activateButtonRef) === null || _item_activateButtonRef === void 0 ? void 0 : _item_activateButtonRef.current, eventTarget);
|
|
203
205
|
});
|
|
204
|
-
let dropTarget = this.validDropTargets.find((target)=>(0, $irqIb$nodeContains)(target.element,
|
|
206
|
+
let dropTarget = this.validDropTargets.find((target)=>(0, $irqIb$nodeContains)(target.element, eventTarget));
|
|
205
207
|
var _item_activateButtonRef_current;
|
|
206
208
|
let activateButton = (_item_activateButtonRef_current = item === null || item === void 0 ? void 0 : (_item_activateButtonRef = item.activateButtonRef) === null || _item_activateButtonRef === void 0 ? void 0 : _item_activateButtonRef.current) !== null && _item_activateButtonRef_current !== void 0 ? _item_activateButtonRef_current : dropTarget === null || dropTarget === void 0 ? void 0 : (_dropTarget_activateButtonRef = dropTarget.activateButtonRef) === null || _dropTarget_activateButtonRef === void 0 ? void 0 : _dropTarget_activateButtonRef.current;
|
|
207
|
-
if ((0, $irqIb$nodeContains)(activateButton,
|
|
209
|
+
if ((0, $irqIb$nodeContains)(activateButton, eventTarget) && dropTarget) {
|
|
208
210
|
this.activate(dropTarget, item);
|
|
209
211
|
return;
|
|
210
212
|
}
|
|
211
|
-
if (e
|
|
213
|
+
if ((0, $irqIb$getEventTarget)(e) === this.dragTarget.element) {
|
|
212
214
|
this.cancel();
|
|
213
215
|
return;
|
|
214
216
|
}
|
|
@@ -227,7 +229,8 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
227
229
|
cancelEvent(e) {
|
|
228
230
|
var _this_dragTarget;
|
|
229
231
|
// Allow focusin and focusout on the drag target so focus ring works properly.
|
|
230
|
-
|
|
232
|
+
let eventTarget = (0, $irqIb$getEventTarget)(e);
|
|
233
|
+
if ((e.type === 'focusin' || e.type === 'focusout') && (eventTarget === ((_this_dragTarget = this.dragTarget) === null || _this_dragTarget === void 0 ? void 0 : _this_dragTarget.element) || eventTarget === this.getCurrentActivateButton())) return;
|
|
231
234
|
// Allow default for events that might cancel a click event
|
|
232
235
|
if (!$67560de7c78cb232$var$CLICK_EVENTS.includes(e.type)) e.preventDefault();
|
|
233
236
|
e.stopPropagation();
|
|
@@ -401,7 +404,7 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
401
404
|
var // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).
|
|
402
405
|
// This corrects state such as whether focus ring should appear.
|
|
403
406
|
// useDroppableCollection handles this itself, so this is only for standalone drop zones.
|
|
404
|
-
|
|
407
|
+
_getActiveElement;
|
|
405
408
|
this.teardown();
|
|
406
409
|
$67560de7c78cb232$var$endDragging();
|
|
407
410
|
if (typeof this.dragTarget.onDragEnd === 'function') {
|
|
@@ -414,18 +417,18 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
414
417
|
dropOperation: this.dropOperation || 'cancel'
|
|
415
418
|
});
|
|
416
419
|
}
|
|
417
|
-
if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) (
|
|
420
|
+
if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) (_getActiveElement = (0, $irqIb$getActiveElement)()) === null || _getActiveElement === void 0 ? void 0 : _getActiveElement.dispatchEvent(new FocusEvent('focusin', {
|
|
418
421
|
bubbles: true
|
|
419
422
|
}));
|
|
420
423
|
this.setCurrentDropTarget(null);
|
|
421
424
|
}
|
|
422
425
|
cancel() {
|
|
423
426
|
var // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).
|
|
424
|
-
|
|
427
|
+
_getActiveElement;
|
|
425
428
|
this.setCurrentDropTarget(null);
|
|
426
429
|
this.end();
|
|
427
430
|
if (!this.dragTarget.element.closest('[aria-hidden="true"], [inert]')) this.dragTarget.element.focus();
|
|
428
|
-
(
|
|
431
|
+
(_getActiveElement = (0, $irqIb$getActiveElement)()) === null || _getActiveElement === void 0 ? void 0 : _getActiveElement.dispatchEvent(new FocusEvent('focusin', {
|
|
429
432
|
bubbles: true
|
|
430
433
|
}));
|
|
431
434
|
(0, $irqIb$announce)(this.stringFormatter.format('dropCanceled'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {getDragModality as $7252cd45fc48c07c$export$1fb2158d224b542c, getTypes as $7252cd45fc48c07c$export$e1d41611756c6326} from "./utils.module.js";
|
|
2
2
|
import {announce as $irqIb$announce} from "@react-aria/live-announcer";
|
|
3
3
|
import {ariaHideOutside as $irqIb$ariaHideOutside} from "@react-aria/overlays";
|
|
4
|
-
import {nodeContains as $irqIb$nodeContains, isVirtualClick as $irqIb$isVirtualClick, isVirtualPointerEvent as $irqIb$isVirtualPointerEvent} from "@react-aria/utils";
|
|
4
|
+
import {nodeContains as $irqIb$nodeContains, getEventTarget as $irqIb$getEventTarget, isVirtualClick as $irqIb$isVirtualClick, isVirtualPointerEvent as $irqIb$isVirtualPointerEvent, getActiveElement as $irqIb$getActiveElement} from "@react-aria/utils";
|
|
5
5
|
import {useState as $irqIb$useState, useEffect as $irqIb$useEffect} from "react";
|
|
6
6
|
|
|
7
7
|
/*
|
|
@@ -144,7 +144,7 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
144
144
|
onKeyUp(e) {
|
|
145
145
|
this.cancelEvent(e);
|
|
146
146
|
if (e.key === 'Enter') {
|
|
147
|
-
if (e.altKey || (0, $irqIb$nodeContains)(this.getCurrentActivateButton(), e
|
|
147
|
+
if (e.altKey || (0, $irqIb$nodeContains)(this.getCurrentActivateButton(), (0, $irqIb$getEventTarget)(e))) this.activate(this.currentDropTarget, this.currentDropItem);
|
|
148
148
|
else this.drop();
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -155,16 +155,17 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
155
155
|
}
|
|
156
156
|
onFocus(e) {
|
|
157
157
|
let activateButton = this.getCurrentActivateButton();
|
|
158
|
-
|
|
158
|
+
let eventTarget = (0, $irqIb$getEventTarget)(e);
|
|
159
|
+
if (eventTarget === activateButton) {
|
|
159
160
|
// TODO: canceling this breaks the focus ring. Revisit when we support tabbing.
|
|
160
161
|
this.cancelEvent(e);
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
164
|
// Prevent focus events, except to the original drag target.
|
|
164
|
-
if (
|
|
165
|
+
if (eventTarget !== this.dragTarget.element) this.cancelEvent(e);
|
|
165
166
|
// Ignore focus events on the window/document (JSDOM). Will be handled in onBlur, below.
|
|
166
|
-
if (!(
|
|
167
|
-
let dropTarget = this.validDropTargets.find((target)=>target.element ===
|
|
167
|
+
if (!(eventTarget instanceof HTMLElement) || eventTarget === this.dragTarget.element) return;
|
|
168
|
+
let dropTarget = this.validDropTargets.find((target)=>target.element === eventTarget) || this.validDropTargets.find((target)=>(0, $irqIb$nodeContains)(target.element, eventTarget));
|
|
168
169
|
if (!dropTarget) {
|
|
169
170
|
// if (e.target === activateButton) {
|
|
170
171
|
// activateButton.focus();
|
|
@@ -173,7 +174,7 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
173
174
|
else this.dragTarget.element.focus();
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
176
|
-
let item = $67560de7c78cb232$var$dropItems.get(
|
|
177
|
+
let item = $67560de7c78cb232$var$dropItems.get(eventTarget);
|
|
177
178
|
if (dropTarget) this.setCurrentDropTarget(dropTarget, item);
|
|
178
179
|
}
|
|
179
180
|
onBlur(e) {
|
|
@@ -182,7 +183,7 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
182
183
|
this.cancelEvent(e);
|
|
183
184
|
return;
|
|
184
185
|
}
|
|
185
|
-
if (e
|
|
186
|
+
if ((0, $irqIb$getEventTarget)(e) !== this.dragTarget.element) this.cancelEvent(e);
|
|
186
187
|
// If nothing is gaining focus, or e.relatedTarget is the window/document (JSDOM),
|
|
187
188
|
// restore focus back to the current drop target if any, or the original drag target.
|
|
188
189
|
if (!e.relatedTarget || !(e.relatedTarget instanceof HTMLElement)) {
|
|
@@ -195,20 +196,21 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
195
196
|
if ((0, $irqIb$isVirtualClick)(e) || this.isVirtualClick) {
|
|
196
197
|
var _item_activateButtonRef, _dropTarget_activateButtonRef;
|
|
197
198
|
let dropElements = $67560de7c78cb232$var$dropItems.values();
|
|
199
|
+
let eventTarget = (0, $irqIb$getEventTarget)(e);
|
|
198
200
|
let item = [
|
|
199
201
|
...dropElements
|
|
200
202
|
].find((item)=>{
|
|
201
203
|
var _item_activateButtonRef;
|
|
202
|
-
return item.element ===
|
|
204
|
+
return item.element === eventTarget || (0, $irqIb$nodeContains)((_item_activateButtonRef = item.activateButtonRef) === null || _item_activateButtonRef === void 0 ? void 0 : _item_activateButtonRef.current, eventTarget);
|
|
203
205
|
});
|
|
204
|
-
let dropTarget = this.validDropTargets.find((target)=>(0, $irqIb$nodeContains)(target.element,
|
|
206
|
+
let dropTarget = this.validDropTargets.find((target)=>(0, $irqIb$nodeContains)(target.element, eventTarget));
|
|
205
207
|
var _item_activateButtonRef_current;
|
|
206
208
|
let activateButton = (_item_activateButtonRef_current = item === null || item === void 0 ? void 0 : (_item_activateButtonRef = item.activateButtonRef) === null || _item_activateButtonRef === void 0 ? void 0 : _item_activateButtonRef.current) !== null && _item_activateButtonRef_current !== void 0 ? _item_activateButtonRef_current : dropTarget === null || dropTarget === void 0 ? void 0 : (_dropTarget_activateButtonRef = dropTarget.activateButtonRef) === null || _dropTarget_activateButtonRef === void 0 ? void 0 : _dropTarget_activateButtonRef.current;
|
|
207
|
-
if ((0, $irqIb$nodeContains)(activateButton,
|
|
209
|
+
if ((0, $irqIb$nodeContains)(activateButton, eventTarget) && dropTarget) {
|
|
208
210
|
this.activate(dropTarget, item);
|
|
209
211
|
return;
|
|
210
212
|
}
|
|
211
|
-
if (e
|
|
213
|
+
if ((0, $irqIb$getEventTarget)(e) === this.dragTarget.element) {
|
|
212
214
|
this.cancel();
|
|
213
215
|
return;
|
|
214
216
|
}
|
|
@@ -227,7 +229,8 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
227
229
|
cancelEvent(e) {
|
|
228
230
|
var _this_dragTarget;
|
|
229
231
|
// Allow focusin and focusout on the drag target so focus ring works properly.
|
|
230
|
-
|
|
232
|
+
let eventTarget = (0, $irqIb$getEventTarget)(e);
|
|
233
|
+
if ((e.type === 'focusin' || e.type === 'focusout') && (eventTarget === ((_this_dragTarget = this.dragTarget) === null || _this_dragTarget === void 0 ? void 0 : _this_dragTarget.element) || eventTarget === this.getCurrentActivateButton())) return;
|
|
231
234
|
// Allow default for events that might cancel a click event
|
|
232
235
|
if (!$67560de7c78cb232$var$CLICK_EVENTS.includes(e.type)) e.preventDefault();
|
|
233
236
|
e.stopPropagation();
|
|
@@ -401,7 +404,7 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
401
404
|
var // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).
|
|
402
405
|
// This corrects state such as whether focus ring should appear.
|
|
403
406
|
// useDroppableCollection handles this itself, so this is only for standalone drop zones.
|
|
404
|
-
|
|
407
|
+
_getActiveElement;
|
|
405
408
|
this.teardown();
|
|
406
409
|
$67560de7c78cb232$var$endDragging();
|
|
407
410
|
if (typeof this.dragTarget.onDragEnd === 'function') {
|
|
@@ -414,18 +417,18 @@ class $67560de7c78cb232$var$DragSession {
|
|
|
414
417
|
dropOperation: this.dropOperation || 'cancel'
|
|
415
418
|
});
|
|
416
419
|
}
|
|
417
|
-
if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) (
|
|
420
|
+
if (this.currentDropTarget && !this.currentDropTarget.preventFocusOnDrop) (_getActiveElement = (0, $irqIb$getActiveElement)()) === null || _getActiveElement === void 0 ? void 0 : _getActiveElement.dispatchEvent(new FocusEvent('focusin', {
|
|
418
421
|
bubbles: true
|
|
419
422
|
}));
|
|
420
423
|
this.setCurrentDropTarget(null);
|
|
421
424
|
}
|
|
422
425
|
cancel() {
|
|
423
426
|
var // Re-trigger focus event on active element, since it will not have received it during dragging (see cancelEvent).
|
|
424
|
-
|
|
427
|
+
_getActiveElement;
|
|
425
428
|
this.setCurrentDropTarget(null);
|
|
426
429
|
this.end();
|
|
427
430
|
if (!this.dragTarget.element.closest('[aria-hidden="true"], [inert]')) this.dragTarget.element.focus();
|
|
428
|
-
(
|
|
431
|
+
(_getActiveElement = (0, $irqIb$getActiveElement)()) === null || _getActiveElement === void 0 ? void 0 : _getActiveElement.dispatchEvent(new FocusEvent('focusin', {
|
|
429
432
|
bubbles: true
|
|
430
433
|
}));
|
|
431
434
|
(0, $irqIb$announce)(this.stringFormatter.format('dropCanceled'));
|