@react-aria/interactions 3.22.5 → 3.24.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/Pressable.main.js +28 -4
- package/dist/Pressable.main.js.map +1 -1
- package/dist/Pressable.mjs +30 -6
- package/dist/Pressable.module.js +30 -6
- package/dist/Pressable.module.js.map +1 -1
- package/dist/createEventHandler.main.js +5 -1
- package/dist/createEventHandler.main.js.map +1 -1
- package/dist/createEventHandler.mjs +5 -1
- package/dist/createEventHandler.module.js +5 -1
- package/dist/createEventHandler.module.js.map +1 -1
- package/dist/focusSafely.main.js +40 -0
- package/dist/focusSafely.main.js.map +1 -0
- package/dist/focusSafely.mjs +35 -0
- package/dist/focusSafely.module.js +35 -0
- package/dist/focusSafely.module.js.map +1 -0
- package/dist/import.mjs +5 -1
- package/dist/main.js +9 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +5 -1
- package/dist/module.js.map +1 -1
- package/dist/textSelection.main.js +5 -3
- package/dist/textSelection.main.js.map +1 -1
- package/dist/textSelection.mjs +5 -3
- package/dist/textSelection.module.js +5 -3
- package/dist/textSelection.module.js.map +1 -1
- package/dist/types.d.ts +59 -25
- package/dist/types.d.ts.map +1 -1
- package/dist/useFocus.main.js +2 -1
- package/dist/useFocus.main.js.map +1 -1
- package/dist/useFocus.mjs +3 -2
- package/dist/useFocus.module.js +3 -2
- package/dist/useFocus.module.js.map +1 -1
- package/dist/useFocusVisible.main.js +9 -3
- package/dist/useFocusVisible.main.js.map +1 -1
- package/dist/useFocusVisible.mjs +9 -3
- package/dist/useFocusVisible.module.js +9 -3
- package/dist/useFocusVisible.module.js.map +1 -1
- package/dist/useFocusWithin.main.js +33 -4
- package/dist/useFocusWithin.main.js.map +1 -1
- package/dist/useFocusWithin.mjs +34 -5
- package/dist/useFocusWithin.module.js +34 -5
- package/dist/useFocusWithin.module.js.map +1 -1
- package/dist/useFocusable.main.js +112 -0
- package/dist/useFocusable.main.js.map +1 -0
- package/dist/useFocusable.mjs +100 -0
- package/dist/useFocusable.module.js +100 -0
- package/dist/useFocusable.module.js.map +1 -0
- package/dist/useHover.main.js +18 -3
- package/dist/useHover.main.js.map +1 -1
- package/dist/useHover.mjs +18 -3
- package/dist/useHover.module.js +18 -3
- package/dist/useHover.module.js.map +1 -1
- package/dist/useInteractOutside.main.js +6 -1
- package/dist/useInteractOutside.main.js.map +1 -1
- package/dist/useInteractOutside.mjs +6 -1
- package/dist/useInteractOutside.module.js +6 -1
- package/dist/useInteractOutside.module.js.map +1 -1
- package/dist/useLongPress.main.js +2 -0
- package/dist/useLongPress.main.js.map +1 -1
- package/dist/useLongPress.mjs +3 -1
- package/dist/useLongPress.module.js +3 -1
- package/dist/useLongPress.module.js.map +1 -1
- package/dist/usePress.main.js +97 -94
- package/dist/usePress.main.js.map +1 -1
- package/dist/usePress.mjs +98 -95
- package/dist/usePress.module.js +98 -95
- package/dist/usePress.module.js.map +1 -1
- package/dist/utils.main.js +57 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +55 -2
- package/dist/utils.module.js +55 -2
- package/dist/utils.module.js.map +1 -1
- package/package.json +7 -5
- package/src/Pressable.tsx +66 -6
- package/src/createEventHandler.ts +8 -1
- package/src/focusSafely.ts +45 -0
- package/src/index.ts +3 -0
- package/src/textSelection.ts +6 -4
- package/src/useFocus.ts +3 -3
- package/src/useFocusVisible.ts +14 -4
- package/src/useFocusWithin.ts +34 -5
- package/src/useFocusable.tsx +183 -0
- package/src/useHover.ts +17 -3
- package/src/useInteractOutside.ts +9 -3
- package/src/useLongPress.ts +8 -2
- package/src/usePress.ts +132 -131
- package/src/utils.ts +80 -1
- package/src/DOMPropsContext.ts +0 -39
- package/src/DOMPropsResponder.tsx +0 -47
- package/src/useDOMPropsResponder.ts +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;A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QAChD,IAAI,CAAC,iBAAiB,CAAC,cAAc,eAAe,CAAC,QAAQ,CAAC,MAAM,MAAM,GACxE,OAAO;QAET,qEAAqE;QACrE,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,gCACvB,OAAO;IAEX;IAEA,IAAI,CAAC,IAAI,OAAO,EACd,OAAO;IAGT,sFAAsF;IACtF,+FAA+F;IAC/F,yFAAyF;IACzF,sEAAsE;IACtE,OAAO,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,OAAO;AACnD","sources":["packages/@react-aria/interactions/src/useInteractOutside.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\n// Portions of the code in this file are based on code from react.\n// Original licensing for the following can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions\n\nimport {getOwnerDocument, useEffectEvent} from '@react-aria/utils';\nimport {RefObject} from '@react-types/shared';\nimport {useEffect, useRef} from 'react';\n\nexport interface InteractOutsideProps {\n ref: RefObject<Element | null>,\n onInteractOutside?: (e: PointerEvent) => void,\n onInteractOutsideStart?: (e: PointerEvent) => void,\n /** Whether the interact outside events should be disabled. */\n isDisabled?: boolean\n}\n\n/**\n * Example, used in components like Dialogs and Popovers so they can close\n * when a user clicks outside them.\n */\nexport function useInteractOutside(props: InteractOutsideProps) {\n let {ref, onInteractOutside, isDisabled, onInteractOutsideStart} = props;\n let stateRef = useRef({\n isPointerDown: false,\n ignoreEmulatedMouseEvents: false\n });\n\n let onPointerDown = useEffectEvent((e) => {\n if (onInteractOutside && isValidEvent(e, ref)) {\n if (onInteractOutsideStart) {\n onInteractOutsideStart(e);\n }\n stateRef.current.isPointerDown = true;\n }\n });\n\n let triggerInteractOutside = useEffectEvent((e: PointerEvent) => {\n if (onInteractOutside) {\n onInteractOutside(e);\n }\n });\n\n useEffect(() => {\n let state = stateRef.current;\n if (isDisabled) {\n return;\n }\n\n const element = ref.current;\n const documentObject = getOwnerDocument(element);\n\n // Use pointer events if available. Otherwise, fall back to mouse and touch events.\n if (typeof PointerEvent !== 'undefined') {\n let onPointerUp = (e) => {\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n // changing these to capture phase fixed combobox\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('pointerup', onPointerUp, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('pointerup', onPointerUp, true);\n };\n } else {\n let onMouseUp = (e) => {\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n } else if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n let onTouchEnd = (e) => {\n state.ignoreEmulatedMouseEvents = true;\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n documentObject.addEventListener('mousedown', onPointerDown, true);\n documentObject.addEventListener('mouseup', onMouseUp, true);\n documentObject.addEventListener('touchstart', onPointerDown, true);\n documentObject.addEventListener('touchend', onTouchEnd, true);\n\n return () => {\n documentObject.removeEventListener('mousedown', onPointerDown, true);\n documentObject.removeEventListener('mouseup', onMouseUp, true);\n documentObject.removeEventListener('touchstart', onPointerDown, true);\n documentObject.removeEventListener('touchend', onTouchEnd, true);\n };\n }\n }, [ref, isDisabled, onPointerDown, triggerInteractOutside]);\n}\n\nfunction isValidEvent(event, ref) {\n if (event.button > 0) {\n return false;\n }\n if (event.target) {\n // if the event target is no longer in the document, ignore\n const ownerDocument = event.target.ownerDocument;\n if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) {\n return false;\n }\n // If the target is within a top layer element (e.g. toasts), ignore.\n if (event.target.closest('[data-react-aria-top-layer]')) {\n return false;\n }\n }\n\n if (!ref.current) {\n return false;\n }\n\n // When the event source is inside a Shadow DOM, event.target is just the shadow root.\n // Using event.composedPath instead means we can get the actual element inside the shadow root.\n // This only works if the shadow root is open, there is no way to detect if it is closed.\n // If the event composed path contains the ref, interaction is inside.\n return !event.composedPath().includes(ref.current);\n}\n"],"names":[],"version":3,"file":"useInteractOutside.module.js.map"}
|
|
@@ -40,6 +40,8 @@ function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
|
|
|
40
40
|
e.target.dispatchEvent(new PointerEvent('pointercancel', {
|
|
41
41
|
bubbles: true
|
|
42
42
|
}));
|
|
43
|
+
// Ensure target is focused. On touch devices, browsers typically focus on pointer up.
|
|
44
|
+
if ((0, $5sxTM$reactariautils.getOwnerDocument)(e.target).activeElement !== e.target) (0, $5sxTM$reactariautils.focusWithoutScrolling)(e.target);
|
|
43
45
|
if (onLongPress) onLongPress({
|
|
44
46
|
...e,
|
|
45
47
|
type: 'longpress'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAuCD,MAAM,0CAAoB;AAMnB,SAAS,0CAAa,KAAqB;IAChD,IAAI,cACF,UAAU,oBACV,gBAAgB,kBAChB,cAAc,eACd,WAAW,aACX,YAAY,mEACZ,wBAAwB,EACzB,GAAG;IAEJ,MAAM,UAAU,CAAA,GAAA,mBAAK,EAA6C;IAClE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,wCAAiB;IAEjE,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,kCAAO,EAAE;oBAC1B;QACA,cAAa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gBAC3E,IAAI,EAAE,WAAW,KAAK,SAAS;oBAC7B,IAAI,gBAAgB,CAAA;wBAClB,EAAE,cAAc;oBAClB;oBAEA,kBAAkB,EAAE,MAAM,EAAE,eAAe,eAAe;wBAAC,MAAM;oBAAI;oBACrE,kBAAkB,QAAQ,aAAa;wBACrC,+EAA+E;wBAC/E,wEAAwE;wBACxE,WAAW;4BACT,qBAAqB,EAAE,MAAM,EAAE,eAAe;wBAChD,GAAG;oBACL,GAAG;wBAAC,MAAM;oBAAI;gBAChB;YACF;QACF;QACA,YAAW,CAAC;YACV,IAAI,QAAQ,OAAO,EACjB,aAAa,QAAQ,OAAO;YAG9B,IAAI,kBAAmB,CAAA,EAAE,WAAW,KAAK,WAAW,EAAE,WAAW,KAAK,OAAM,GAC1E,eAAe;gBACb,GAAG,CAAC;gBACJ,MAAM;YACR;QAEJ;IACF;IAEA,IAAI,mBAAmB,CAAA,GAAA,oCAAa,EAAE,eAAe,CAAC,aAAa,2BAA2B;IAE9F,OAAO;QACL,gBAAgB,CAAA,GAAA,gCAAS,EAAE,YAAY;IACzC;AACF","sources":["packages/@react-aria/interactions/src/useLongPress.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 {DOMAttributes, FocusableElement, LongPressEvent} from '@react-types/shared';\nimport {focusWithoutScrolling, getOwnerDocument, mergeProps, useDescription, useGlobalListeners} from '@react-aria/utils';\nimport {usePress} from './usePress';\nimport {useRef} from 'react';\n\nexport interface LongPressProps {\n /** Whether long press events should be disabled. */\n isDisabled?: boolean,\n /** Handler that is called when a long press interaction starts. */\n onLongPressStart?: (e: LongPressEvent) => void,\n /**\n * Handler that is called when a long press interaction ends, either\n * over the target or when the pointer leaves the target.\n */\n onLongPressEnd?: (e: LongPressEvent) => void,\n /**\n * Handler that is called when the threshold time is met while\n * the press is over the target.\n */\n onLongPress?: (e: LongPressEvent) => void,\n /**\n * The amount of time in milliseconds to wait before triggering a long press.\n * @default 500ms\n */\n threshold?: number,\n /**\n * A description for assistive techology users indicating that a long press\n * action is available, e.g. \"Long press to open menu\".\n */\n accessibilityDescription?: string\n}\n\nexport interface LongPressResult {\n /** Props to spread on the target element. */\n longPressProps: DOMAttributes\n}\n\nconst DEFAULT_THRESHOLD = 500;\n\n/**\n * Handles long press interactions across mouse and touch devices. Supports a customizable time threshold,\n * accessibility description, and normalizes behavior across browsers and devices.\n */\nexport function useLongPress(props: LongPressProps): LongPressResult {\n let {\n isDisabled,\n onLongPressStart,\n onLongPressEnd,\n onLongPress,\n threshold = DEFAULT_THRESHOLD,\n accessibilityDescription\n } = props;\n\n const timeRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {pressProps} = usePress({\n isDisabled,\n onPressStart(e) {\n e.continuePropagation();\n if (e.pointerType === 'mouse' || e.pointerType === 'touch') {\n if (onLongPressStart) {\n onLongPressStart({\n ...e,\n type: 'longpressstart'\n });\n }\n\n timeRef.current = setTimeout(() => {\n // Prevent other usePress handlers from also handling this event.\n e.target.dispatchEvent(new PointerEvent('pointercancel', {bubbles: true}));\n\n // Ensure target is focused. On touch devices, browsers typically focus on pointer up.\n if (getOwnerDocument(e.target).activeElement !== e.target) {\n focusWithoutScrolling(e.target as FocusableElement);\n }\n\n if (onLongPress) {\n onLongPress({\n ...e,\n type: 'longpress'\n });\n }\n timeRef.current = undefined;\n }, threshold);\n\n // Prevent context menu, which may be opened on long press on touch devices\n if (e.pointerType === 'touch') {\n let onContextMenu = e => {\n e.preventDefault();\n };\n\n addGlobalListener(e.target, 'contextmenu', onContextMenu, {once: true});\n addGlobalListener(window, 'pointerup', () => {\n // If no contextmenu event is fired quickly after pointerup, remove the handler\n // so future context menu events outside a long press are not prevented.\n setTimeout(() => {\n removeGlobalListener(e.target, 'contextmenu', onContextMenu);\n }, 30);\n }, {once: true});\n }\n }\n },\n onPressEnd(e) {\n if (timeRef.current) {\n clearTimeout(timeRef.current);\n }\n\n if (onLongPressEnd && (e.pointerType === 'mouse' || e.pointerType === 'touch')) {\n onLongPressEnd({\n ...e,\n type: 'longpressend'\n });\n }\n }\n });\n\n let descriptionProps = useDescription(onLongPress && !isDisabled ? accessibilityDescription : undefined);\n\n return {\n longPressProps: mergeProps(pressProps, descriptionProps)\n };\n}\n"],"names":[],"version":3,"file":"useLongPress.main.js.map"}
|
package/dist/useLongPress.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.mjs";
|
|
2
|
-
import {useGlobalListeners as $4k2kv$useGlobalListeners, useDescription as $4k2kv$useDescription, mergeProps as $4k2kv$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {useGlobalListeners as $4k2kv$useGlobalListeners, getOwnerDocument as $4k2kv$getOwnerDocument, focusWithoutScrolling as $4k2kv$focusWithoutScrolling, useDescription as $4k2kv$useDescription, mergeProps as $4k2kv$mergeProps} from "@react-aria/utils";
|
|
3
3
|
import {useRef as $4k2kv$useRef} from "react";
|
|
4
4
|
|
|
5
5
|
/*
|
|
@@ -34,6 +34,8 @@ function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
|
|
|
34
34
|
e.target.dispatchEvent(new PointerEvent('pointercancel', {
|
|
35
35
|
bubbles: true
|
|
36
36
|
}));
|
|
37
|
+
// Ensure target is focused. On touch devices, browsers typically focus on pointer up.
|
|
38
|
+
if ((0, $4k2kv$getOwnerDocument)(e.target).activeElement !== e.target) (0, $4k2kv$focusWithoutScrolling)(e.target);
|
|
37
39
|
if (onLongPress) onLongPress({
|
|
38
40
|
...e,
|
|
39
41
|
type: 'longpress'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.module.js";
|
|
2
|
-
import {useGlobalListeners as $4k2kv$useGlobalListeners, useDescription as $4k2kv$useDescription, mergeProps as $4k2kv$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {useGlobalListeners as $4k2kv$useGlobalListeners, getOwnerDocument as $4k2kv$getOwnerDocument, focusWithoutScrolling as $4k2kv$focusWithoutScrolling, useDescription as $4k2kv$useDescription, mergeProps as $4k2kv$mergeProps} from "@react-aria/utils";
|
|
3
3
|
import {useRef as $4k2kv$useRef} from "react";
|
|
4
4
|
|
|
5
5
|
/*
|
|
@@ -34,6 +34,8 @@ function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
|
|
|
34
34
|
e.target.dispatchEvent(new PointerEvent('pointercancel', {
|
|
35
35
|
bubbles: true
|
|
36
36
|
}));
|
|
37
|
+
// Ensure target is focused. On touch devices, browsers typically focus on pointer up.
|
|
38
|
+
if ((0, $4k2kv$getOwnerDocument)(e.target).activeElement !== e.target) (0, $4k2kv$focusWithoutScrolling)(e.target);
|
|
37
39
|
if (onLongPress) onLongPress({
|
|
38
40
|
...e,
|
|
39
41
|
type: 'longpress'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAuCD,MAAM,0CAAoB;AAMnB,SAAS,0CAAa,KAAqB;IAChD,IAAI,cACF,UAAU,oBACV,gBAAgB,kBAChB,cAAc,eACd,WAAW,aACX,YAAY,mEACZ,wBAAwB,EACzB,GAAG;IAEJ,MAAM,UAAU,CAAA,GAAA,aAAK,EAA6C;IAClE,IAAI,qBAAC,iBAAiB,wBAAE,oBAAoB,EAAC,GAAG,CAAA,GAAA,yBAAiB;IAEjE,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE;oBA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AA2E;gBAC3E,IAAI,EAAE,WAAW,KAAK,SAAS;oBAC7B,IAAI,gBAAgB,CAAA;wBAClB,EAAE,cAAc;oBAClB;oBAEA,kBAAkB,EAAE,MAAM,EAAE,eAAe,eAAe;wBAAC,MAAM;oBAAI;oBACrE,kBAAkB,QAAQ,aAAa;wBACrC,+EAA+E;wBAC/E,wEAAwE;wBACxE,WAAW;4BACT,qBAAqB,EAAE,MAAM,EAAE,eAAe;wBAChD,GAAG;oBACL,GAAG;wBAAC,MAAM;oBAAI;gBAChB;YACF;QACF;QACA,YAAW,CAAC;YACV,IAAI,QAAQ,OAAO,EACjB,aAAa,QAAQ,OAAO;YAG9B,IAAI,kBAAmB,CAAA,EAAE,WAAW,KAAK,WAAW,EAAE,WAAW,KAAK,OAAM,GAC1E,eAAe;gBACb,GAAG,CAAC;gBACJ,MAAM;YACR;QAEJ;IACF;IAEA,IAAI,mBAAmB,CAAA,GAAA,qBAAa,EAAE,eAAe,CAAC,aAAa,2BAA2B;IAE9F,OAAO;QACL,gBAAgB,CAAA,GAAA,iBAAS,EAAE,YAAY;IACzC;AACF","sources":["packages/@react-aria/interactions/src/useLongPress.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 {DOMAttributes, FocusableElement, LongPressEvent} from '@react-types/shared';\nimport {focusWithoutScrolling, getOwnerDocument, mergeProps, useDescription, useGlobalListeners} from '@react-aria/utils';\nimport {usePress} from './usePress';\nimport {useRef} from 'react';\n\nexport interface LongPressProps {\n /** Whether long press events should be disabled. */\n isDisabled?: boolean,\n /** Handler that is called when a long press interaction starts. */\n onLongPressStart?: (e: LongPressEvent) => void,\n /**\n * Handler that is called when a long press interaction ends, either\n * over the target or when the pointer leaves the target.\n */\n onLongPressEnd?: (e: LongPressEvent) => void,\n /**\n * Handler that is called when the threshold time is met while\n * the press is over the target.\n */\n onLongPress?: (e: LongPressEvent) => void,\n /**\n * The amount of time in milliseconds to wait before triggering a long press.\n * @default 500ms\n */\n threshold?: number,\n /**\n * A description for assistive techology users indicating that a long press\n * action is available, e.g. \"Long press to open menu\".\n */\n accessibilityDescription?: string\n}\n\nexport interface LongPressResult {\n /** Props to spread on the target element. */\n longPressProps: DOMAttributes\n}\n\nconst DEFAULT_THRESHOLD = 500;\n\n/**\n * Handles long press interactions across mouse and touch devices. Supports a customizable time threshold,\n * accessibility description, and normalizes behavior across browsers and devices.\n */\nexport function useLongPress(props: LongPressProps): LongPressResult {\n let {\n isDisabled,\n onLongPressStart,\n onLongPressEnd,\n onLongPress,\n threshold = DEFAULT_THRESHOLD,\n accessibilityDescription\n } = props;\n\n const timeRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {pressProps} = usePress({\n isDisabled,\n onPressStart(e) {\n e.continuePropagation();\n if (e.pointerType === 'mouse' || e.pointerType === 'touch') {\n if (onLongPressStart) {\n onLongPressStart({\n ...e,\n type: 'longpressstart'\n });\n }\n\n timeRef.current = setTimeout(() => {\n // Prevent other usePress handlers from also handling this event.\n e.target.dispatchEvent(new PointerEvent('pointercancel', {bubbles: true}));\n\n // Ensure target is focused. On touch devices, browsers typically focus on pointer up.\n if (getOwnerDocument(e.target).activeElement !== e.target) {\n focusWithoutScrolling(e.target as FocusableElement);\n }\n\n if (onLongPress) {\n onLongPress({\n ...e,\n type: 'longpress'\n });\n }\n timeRef.current = undefined;\n }, threshold);\n\n // Prevent context menu, which may be opened on long press on touch devices\n if (e.pointerType === 'touch') {\n let onContextMenu = e => {\n e.preventDefault();\n };\n\n addGlobalListener(e.target, 'contextmenu', onContextMenu, {once: true});\n addGlobalListener(window, 'pointerup', () => {\n // If no contextmenu event is fired quickly after pointerup, remove the handler\n // so future context menu events outside a long press are not prevented.\n setTimeout(() => {\n removeGlobalListener(e.target, 'contextmenu', onContextMenu);\n }, 30);\n }, {once: true});\n }\n }\n },\n onPressEnd(e) {\n if (timeRef.current) {\n clearTimeout(timeRef.current);\n }\n\n if (onLongPressEnd && (e.pointerType === 'mouse' || e.pointerType === 'touch')) {\n onLongPressEnd({\n ...e,\n type: 'longpressend'\n });\n }\n }\n });\n\n let descriptionProps = useDescription(onLongPress && !isDisabled ? accessibilityDescription : undefined);\n\n return {\n longPressProps: mergeProps(pressProps, descriptionProps)\n };\n}\n"],"names":[],"version":3,"file":"useLongPress.module.js.map"}
|
package/dist/usePress.main.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
var $f7e14e656343df57$exports = require("./textSelection.main.js");
|
|
2
2
|
var $01d3f539e91688c8$exports = require("./context.main.js");
|
|
3
|
+
var $625cf83917e112ad$exports = require("./utils.main.js");
|
|
3
4
|
var $bBqCQ$swchelperscjs_class_private_field_getcjs = require("@swc/helpers/cjs/_class_private_field_get.cjs");
|
|
4
5
|
var $bBqCQ$swchelperscjs_class_private_field_initcjs = require("@swc/helpers/cjs/_class_private_field_init.cjs");
|
|
5
6
|
var $bBqCQ$swchelperscjs_class_private_field_setcjs = require("@swc/helpers/cjs/_class_private_field_set.cjs");
|
|
6
7
|
var $bBqCQ$reactariautils = require("@react-aria/utils");
|
|
8
|
+
var $bBqCQ$reactdom = require("react-dom");
|
|
7
9
|
var $bBqCQ$react = require("react");
|
|
8
10
|
|
|
9
11
|
|
|
@@ -33,6 +35,8 @@ $parcel$export(module.exports, "usePress", () => $0294ea432cd92340$export$45712e
|
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
|
|
38
|
+
|
|
39
|
+
|
|
36
40
|
function $0294ea432cd92340$var$usePressResponderContext(props) {
|
|
37
41
|
// Consume context from <PressResponder> and merge with props.
|
|
38
42
|
let context = (0, $bBqCQ$react.useContext)((0, $01d3f539e91688c8$exports.PressResponderContext));
|
|
@@ -95,13 +99,13 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
95
99
|
let ref = (0, $bBqCQ$react.useRef)({
|
|
96
100
|
isPressed: false,
|
|
97
101
|
ignoreEmulatedMouseEvents: false,
|
|
98
|
-
ignoreClickAfterPress: false,
|
|
99
102
|
didFirePressStart: false,
|
|
100
103
|
isTriggeringEvent: false,
|
|
101
104
|
activePointerId: null,
|
|
102
105
|
target: null,
|
|
103
106
|
isOverTarget: false,
|
|
104
|
-
pointerType: null
|
|
107
|
+
pointerType: null,
|
|
108
|
+
disposables: []
|
|
105
109
|
});
|
|
106
110
|
let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $bBqCQ$reactariautils.useGlobalListeners)();
|
|
107
111
|
let triggerPressStart = (0, $bBqCQ$reactariautils.useEffectEvent)((originalEvent, pointerType)=>{
|
|
@@ -123,7 +127,6 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
123
127
|
let triggerPressEnd = (0, $bBqCQ$reactariautils.useEffectEvent)((originalEvent, pointerType, wasPressed = true)=>{
|
|
124
128
|
let state = ref.current;
|
|
125
129
|
if (!state.didFirePressStart) return false;
|
|
126
|
-
state.ignoreClickAfterPress = true;
|
|
127
130
|
state.didFirePressStart = false;
|
|
128
131
|
state.isTriggeringEvent = true;
|
|
129
132
|
let shouldStopPropagation = true;
|
|
@@ -157,13 +160,15 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
157
160
|
let cancel = (0, $bBqCQ$reactariautils.useEffectEvent)((e)=>{
|
|
158
161
|
let state = ref.current;
|
|
159
162
|
if (state.isPressed && state.target) {
|
|
160
|
-
if (state.
|
|
163
|
+
if (state.didFirePressStart && state.pointerType != null) triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
|
161
164
|
state.isPressed = false;
|
|
162
165
|
state.isOverTarget = false;
|
|
163
166
|
state.activePointerId = null;
|
|
164
167
|
state.pointerType = null;
|
|
165
168
|
removeAllGlobalListeners();
|
|
166
169
|
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$exports.restoreTextSelection)(state.target);
|
|
170
|
+
for (let dispose of state.disposables)dispose();
|
|
171
|
+
state.disposables = [];
|
|
167
172
|
}
|
|
168
173
|
});
|
|
169
174
|
let cancelOnPointerExit = (0, $bBqCQ$reactariautils.useEffectEvent)((e)=>{
|
|
@@ -173,9 +178,9 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
173
178
|
let state = ref.current;
|
|
174
179
|
let pressProps = {
|
|
175
180
|
onKeyDown (e) {
|
|
176
|
-
if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.
|
|
181
|
+
if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && (0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) {
|
|
177
182
|
var _state_metaKeyEvents;
|
|
178
|
-
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.
|
|
183
|
+
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard((0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent), e.key)) e.preventDefault();
|
|
179
184
|
// If the event is repeating, it may have started on a different element
|
|
180
185
|
// after which focus moved to the current element. Ignore these events and
|
|
181
186
|
// only handle the first key down event.
|
|
@@ -183,13 +188,14 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
183
188
|
if (!state.isPressed && !e.repeat) {
|
|
184
189
|
state.target = e.currentTarget;
|
|
185
190
|
state.isPressed = true;
|
|
191
|
+
state.pointerType = 'keyboard';
|
|
186
192
|
shouldStopPropagation = triggerPressStart(e, 'keyboard');
|
|
187
193
|
// Focus may move before the key up event, so register the event on the document
|
|
188
194
|
// instead of the same element where the key down event occurred. Make it capturing so that it will trigger
|
|
189
195
|
// before stopPropagation from useKeyboard on a child element may happen and thus we can still call triggerPress for the parent element.
|
|
190
196
|
let originalTarget = e.currentTarget;
|
|
191
197
|
let pressUp = (e)=>{
|
|
192
|
-
if ($0294ea432cd92340$var$isValidKeyboardEvent(e, originalTarget) && !e.repeat && originalTarget.
|
|
198
|
+
if ($0294ea432cd92340$var$isValidKeyboardEvent(e, originalTarget) && !e.repeat && (0, $bBqCQ$reactariautils.nodeContains)(originalTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e)) && state.target) triggerPressUp($0294ea432cd92340$var$createEvent(state.target, e), 'keyboard');
|
|
193
199
|
};
|
|
194
200
|
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'keyup', (0, $bBqCQ$reactariautils.chain)(pressUp, onKeyUp), true);
|
|
195
201
|
}
|
|
@@ -205,22 +211,24 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
205
211
|
} else if (e.key === 'Meta') state.metaKeyEvents = new Map();
|
|
206
212
|
},
|
|
207
213
|
onClick (e) {
|
|
208
|
-
if (e && !e.currentTarget.
|
|
214
|
+
if (e && !(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
209
215
|
if (e && e.button === 0 && !state.isTriggeringEvent && !(0, $bBqCQ$reactariautils.openLink).isOpening) {
|
|
210
216
|
let shouldStopPropagation = true;
|
|
211
217
|
if (isDisabled) e.preventDefault();
|
|
212
218
|
// If triggered from a screen reader or by using element.click(),
|
|
213
219
|
// trigger as if it were a keyboard click.
|
|
214
|
-
if (!state.
|
|
215
|
-
// Ensure the element receives focus (VoiceOver on iOS does not do this)
|
|
216
|
-
if (!isDisabled && !preventFocusOnPress) (0, $bBqCQ$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
220
|
+
if (!state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType === 'virtual' || (0, $bBqCQ$reactariautils.isVirtualClick)(e.nativeEvent))) {
|
|
217
221
|
let stopPressStart = triggerPressStart(e, 'virtual');
|
|
218
222
|
let stopPressUp = triggerPressUp(e, 'virtual');
|
|
219
223
|
let stopPressEnd = triggerPressEnd(e, 'virtual');
|
|
220
224
|
shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;
|
|
225
|
+
} else if (state.isPressed && state.pointerType !== 'keyboard') {
|
|
226
|
+
let pointerType = state.pointerType || e.nativeEvent.pointerType || 'virtual';
|
|
227
|
+
shouldStopPropagation = triggerPressEnd($0294ea432cd92340$var$createEvent(e.currentTarget, e), pointerType, true);
|
|
228
|
+
state.isOverTarget = false;
|
|
229
|
+
cancel(e);
|
|
221
230
|
}
|
|
222
231
|
state.ignoreEmulatedMouseEvents = false;
|
|
223
|
-
state.ignoreClickAfterPress = false;
|
|
224
232
|
if (shouldStopPropagation) e.stopPropagation();
|
|
225
233
|
}
|
|
226
234
|
}
|
|
@@ -229,14 +237,14 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
229
237
|
var _state_metaKeyEvents;
|
|
230
238
|
if (state.isPressed && state.target && $0294ea432cd92340$var$isValidKeyboardEvent(e, state.target)) {
|
|
231
239
|
var _state_metaKeyEvents1;
|
|
232
|
-
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e
|
|
233
|
-
let target = e
|
|
234
|
-
triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), 'keyboard', state.target.
|
|
240
|
+
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard((0, $bBqCQ$reactariautils.getEventTarget)(e), e.key)) e.preventDefault();
|
|
241
|
+
let target = (0, $bBqCQ$reactariautils.getEventTarget)(e);
|
|
242
|
+
triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), 'keyboard', (0, $bBqCQ$reactariautils.nodeContains)(state.target, (0, $bBqCQ$reactariautils.getEventTarget)(e)));
|
|
235
243
|
removeAllGlobalListeners();
|
|
236
244
|
// If a link was triggered with a key other than Enter, open the URL ourselves.
|
|
237
245
|
// This means the link has a role override, and the default browser behavior
|
|
238
246
|
// only applies when using the Enter key.
|
|
239
|
-
if (e.key !== 'Enter' && $0294ea432cd92340$var$isHTMLAnchorLink(state.target) && state.target
|
|
247
|
+
if (e.key !== 'Enter' && $0294ea432cd92340$var$isHTMLAnchorLink(state.target) && (0, $bBqCQ$reactariautils.nodeContains)(state.target, target) && !e[$0294ea432cd92340$var$LINK_CLICKED]) {
|
|
240
248
|
// Store a hidden property on the event so we only trigger link click once,
|
|
241
249
|
// even if there are multiple usePress instances attached to the element.
|
|
242
250
|
e[$0294ea432cd92340$var$LINK_CLICKED] = true;
|
|
@@ -257,7 +265,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
257
265
|
if (typeof PointerEvent !== 'undefined') {
|
|
258
266
|
pressProps.onPointerDown = (e)=>{
|
|
259
267
|
// Only handle left clicks, and ignore events that bubbled through portals.
|
|
260
|
-
if (e.button !== 0 || !e.currentTarget.
|
|
268
|
+
if (e.button !== 0 || !(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
261
269
|
// iOS safari fires pointer events from VoiceOver with incorrect coordinates/target.
|
|
262
270
|
// Ignore and let the onClick handler take care of it instead.
|
|
263
271
|
// https://bugs.webkit.org/show_bug.cgi?id=222627
|
|
@@ -266,9 +274,6 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
266
274
|
state.pointerType = 'virtual';
|
|
267
275
|
return;
|
|
268
276
|
}
|
|
269
|
-
// Due to browser inconsistencies, especially on mobile browsers, we prevent
|
|
270
|
-
// default on pointer down and handle focusing the pressable element ourselves.
|
|
271
|
-
if ($0294ea432cd92340$var$shouldPreventDefaultDown(e.currentTarget)) e.preventDefault();
|
|
272
277
|
state.pointerType = e.pointerType;
|
|
273
278
|
let shouldStopPropagation = true;
|
|
274
279
|
if (!state.isPressed) {
|
|
@@ -276,44 +281,41 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
276
281
|
state.isOverTarget = true;
|
|
277
282
|
state.activePointerId = e.pointerId;
|
|
278
283
|
state.target = e.currentTarget;
|
|
279
|
-
if (!isDisabled && !preventFocusOnPress) (0, $bBqCQ$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
280
284
|
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$exports.disableTextSelection)(state.target);
|
|
281
285
|
shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
282
|
-
|
|
286
|
+
// Release pointer capture so that touch interactions can leave the original target.
|
|
287
|
+
// This enables onPointerLeave and onPointerEnter to fire.
|
|
288
|
+
let target = (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent);
|
|
289
|
+
if ('releasePointerCapture' in target) target.releasePointerCapture(e.pointerId);
|
|
283
290
|
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'pointerup', onPointerUp, false);
|
|
284
291
|
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'pointercancel', onPointerCancel, false);
|
|
285
292
|
}
|
|
286
293
|
if (shouldStopPropagation) e.stopPropagation();
|
|
287
294
|
};
|
|
288
295
|
pressProps.onMouseDown = (e)=>{
|
|
289
|
-
if (!e.currentTarget.
|
|
296
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
290
297
|
if (e.button === 0) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
298
|
+
if (preventFocusOnPress) {
|
|
299
|
+
let dispose = (0, $625cf83917e112ad$exports.preventFocus)(e.target);
|
|
300
|
+
if (dispose) state.disposables.push(dispose);
|
|
301
|
+
}
|
|
295
302
|
e.stopPropagation();
|
|
296
303
|
}
|
|
297
304
|
};
|
|
298
305
|
pressProps.onPointerUp = (e)=>{
|
|
299
306
|
// iOS fires pointerup with zero width and height, so check the pointerType recorded during pointerdown.
|
|
300
|
-
if (!e.currentTarget.
|
|
307
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent)) || state.pointerType === 'virtual') return;
|
|
301
308
|
// Only handle left clicks
|
|
302
|
-
|
|
303
|
-
// when the touch isn't over the target, so double check.
|
|
304
|
-
if (e.button === 0 && $0294ea432cd92340$var$isOverTarget(e, e.currentTarget)) triggerPressUp(e, state.pointerType || e.pointerType);
|
|
309
|
+
if (e.button === 0) triggerPressUp(e, state.pointerType || e.pointerType);
|
|
305
310
|
};
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
triggerPressStart($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType);
|
|
315
|
-
}
|
|
316
|
-
} else if (state.target && state.isOverTarget && state.pointerType != null) {
|
|
311
|
+
pressProps.onPointerEnter = (e)=>{
|
|
312
|
+
if (e.pointerId === state.activePointerId && state.target && !state.isOverTarget && state.pointerType != null) {
|
|
313
|
+
state.isOverTarget = true;
|
|
314
|
+
triggerPressStart($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
pressProps.onPointerLeave = (e)=>{
|
|
318
|
+
if (e.pointerId === state.activePointerId && state.target && state.isOverTarget && state.pointerType != null) {
|
|
317
319
|
state.isOverTarget = false;
|
|
318
320
|
triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
|
319
321
|
cancelOnPointerExit(e);
|
|
@@ -321,46 +323,50 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
321
323
|
};
|
|
322
324
|
let onPointerUp = (e)=>{
|
|
323
325
|
if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0 && state.target) {
|
|
324
|
-
if ($
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
if ((0, $bBqCQ$reactariautils.nodeContains)(state.target, (0, $bBqCQ$reactariautils.getEventTarget)(e)) && state.pointerType != null) {
|
|
327
|
+
// Wait for onClick to fire onPress. This avoids browser issues when the DOM
|
|
328
|
+
// is mutated between onPointerUp and onClick, and is more compatible with third party libraries.
|
|
329
|
+
// https://github.com/adobe/react-spectrum/issues/1513
|
|
330
|
+
// https://issues.chromium.org/issues/40732224
|
|
331
|
+
// However, iOS and Android do not focus or fire onClick after a long press.
|
|
332
|
+
// We work around this by triggering a click ourselves after a timeout.
|
|
333
|
+
// This timeout is canceled during the click event in case the real one fires first.
|
|
334
|
+
// The timeout must be at least 32ms, because Safari on iOS delays the click event on
|
|
335
|
+
// non-form elements without certain ARIA roles (for hover emulation).
|
|
336
|
+
// https://github.com/WebKit/WebKit/blob/dccfae42bb29bd4bdef052e469f604a9387241c0/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L875-L892
|
|
337
|
+
let clicked = false;
|
|
338
|
+
let timeout = setTimeout(()=>{
|
|
339
|
+
if (state.isPressed && state.target instanceof HTMLElement) {
|
|
340
|
+
if (clicked) cancel(e);
|
|
341
|
+
else {
|
|
342
|
+
(0, $bBqCQ$reactariautils.focusWithoutScrolling)(state.target);
|
|
343
|
+
state.target.click();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}, 80);
|
|
347
|
+
// Use a capturing listener to track if a click occurred.
|
|
348
|
+
// If stopPropagation is called it may never reach our handler.
|
|
349
|
+
addGlobalListener(e.currentTarget, 'click', ()=>clicked = true, true);
|
|
350
|
+
state.disposables.push(()=>clearTimeout(timeout));
|
|
351
|
+
} else cancel(e);
|
|
352
|
+
// Ignore subsequent onPointerLeave event before onClick on touch devices.
|
|
327
353
|
state.isOverTarget = false;
|
|
328
|
-
state.activePointerId = null;
|
|
329
|
-
state.pointerType = null;
|
|
330
|
-
removeAllGlobalListeners();
|
|
331
|
-
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$exports.restoreTextSelection)(state.target);
|
|
332
|
-
// Prevent subsequent touchend event from triggering onClick on unrelated elements on Android. See below.
|
|
333
|
-
// Both 'touch' and 'pen' pointerTypes trigger onTouchEnd, but 'mouse' does not.
|
|
334
|
-
if ('ontouchend' in state.target && e.pointerType !== 'mouse') addGlobalListener(state.target, 'touchend', onTouchEnd, {
|
|
335
|
-
once: true
|
|
336
|
-
});
|
|
337
354
|
}
|
|
338
355
|
};
|
|
339
|
-
// This is a workaround for an Android Chrome/Firefox issue where click events are fired on an incorrect element
|
|
340
|
-
// if the original target is removed during onPointerUp (before onClick).
|
|
341
|
-
// https://github.com/adobe/react-spectrum/issues/1513
|
|
342
|
-
// https://issues.chromium.org/issues/40732224
|
|
343
|
-
// Note: this event must be registered directly on the element, not via React props in order to work.
|
|
344
|
-
// https://github.com/facebook/react/issues/9809
|
|
345
|
-
let onTouchEnd = (e)=>{
|
|
346
|
-
// Don't preventDefault if we actually want the default (e.g. submit/link click).
|
|
347
|
-
if ($0294ea432cd92340$var$shouldPreventDefaultUp(e.currentTarget)) e.preventDefault();
|
|
348
|
-
};
|
|
349
356
|
let onPointerCancel = (e)=>{
|
|
350
357
|
cancel(e);
|
|
351
358
|
};
|
|
352
359
|
pressProps.onDragStart = (e)=>{
|
|
353
|
-
if (!e.currentTarget.
|
|
360
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
354
361
|
// Safari does not call onPointerCancel when a drag starts, whereas Chrome and Firefox do.
|
|
355
362
|
cancel(e);
|
|
356
363
|
};
|
|
357
364
|
} else {
|
|
365
|
+
// NOTE: this fallback branch is almost entirely used by unit tests.
|
|
366
|
+
// All browsers now support pointer events, but JSDOM still does not.
|
|
358
367
|
pressProps.onMouseDown = (e)=>{
|
|
359
368
|
// Only handle left clicks
|
|
360
|
-
if (e.button !== 0 || !e.currentTarget.
|
|
361
|
-
// Due to browser inconsistencies, especially on mobile browsers, we prevent
|
|
362
|
-
// default on mouse down and handle focusing the pressable element ourselves.
|
|
363
|
-
if ($0294ea432cd92340$var$shouldPreventDefaultDown(e.currentTarget)) e.preventDefault();
|
|
369
|
+
if (e.button !== 0 || !(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
364
370
|
if (state.ignoreEmulatedMouseEvents) {
|
|
365
371
|
e.stopPropagation();
|
|
366
372
|
return;
|
|
@@ -369,13 +375,17 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
369
375
|
state.isOverTarget = true;
|
|
370
376
|
state.target = e.currentTarget;
|
|
371
377
|
state.pointerType = (0, $bBqCQ$reactariautils.isVirtualClick)(e.nativeEvent) ? 'virtual' : 'mouse';
|
|
372
|
-
|
|
373
|
-
let shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
378
|
+
// Flush sync so that focus moved during react re-renders occurs before we yield back to the browser.
|
|
379
|
+
let shouldStopPropagation = (0, $bBqCQ$reactdom.flushSync)(()=>triggerPressStart(e, state.pointerType));
|
|
374
380
|
if (shouldStopPropagation) e.stopPropagation();
|
|
381
|
+
if (preventFocusOnPress) {
|
|
382
|
+
let dispose = (0, $625cf83917e112ad$exports.preventFocus)(e.target);
|
|
383
|
+
if (dispose) state.disposables.push(dispose);
|
|
384
|
+
}
|
|
375
385
|
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerDocument)(e.currentTarget), 'mouseup', onMouseUp, false);
|
|
376
386
|
};
|
|
377
387
|
pressProps.onMouseEnter = (e)=>{
|
|
378
|
-
if (!e.currentTarget.
|
|
388
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
379
389
|
let shouldStopPropagation = true;
|
|
380
390
|
if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {
|
|
381
391
|
state.isOverTarget = true;
|
|
@@ -384,7 +394,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
384
394
|
if (shouldStopPropagation) e.stopPropagation();
|
|
385
395
|
};
|
|
386
396
|
pressProps.onMouseLeave = (e)=>{
|
|
387
|
-
if (!e.currentTarget.
|
|
397
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
388
398
|
let shouldStopPropagation = true;
|
|
389
399
|
if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {
|
|
390
400
|
state.isOverTarget = false;
|
|
@@ -394,24 +404,22 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
394
404
|
if (shouldStopPropagation) e.stopPropagation();
|
|
395
405
|
};
|
|
396
406
|
pressProps.onMouseUp = (e)=>{
|
|
397
|
-
if (!e.currentTarget.
|
|
407
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
398
408
|
if (!state.ignoreEmulatedMouseEvents && e.button === 0) triggerPressUp(e, state.pointerType || 'mouse');
|
|
399
409
|
};
|
|
400
410
|
let onMouseUp = (e)=>{
|
|
401
411
|
// Only handle left clicks
|
|
402
412
|
if (e.button !== 0) return;
|
|
403
|
-
state.isPressed = false;
|
|
404
|
-
removeAllGlobalListeners();
|
|
405
413
|
if (state.ignoreEmulatedMouseEvents) {
|
|
406
414
|
state.ignoreEmulatedMouseEvents = false;
|
|
407
415
|
return;
|
|
408
416
|
}
|
|
409
|
-
if (state.target &&
|
|
410
|
-
else
|
|
417
|
+
if (state.target && state.target.contains(e.target) && state.pointerType != null) ;
|
|
418
|
+
else cancel(e);
|
|
411
419
|
state.isOverTarget = false;
|
|
412
420
|
};
|
|
413
421
|
pressProps.onTouchStart = (e)=>{
|
|
414
|
-
if (!e.currentTarget.
|
|
422
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
415
423
|
let touch = $0294ea432cd92340$var$getTouchFromEvent(e.nativeEvent);
|
|
416
424
|
if (!touch) return;
|
|
417
425
|
state.activePointerId = touch.identifier;
|
|
@@ -420,16 +428,13 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
420
428
|
state.isPressed = true;
|
|
421
429
|
state.target = e.currentTarget;
|
|
422
430
|
state.pointerType = 'touch';
|
|
423
|
-
// Due to browser inconsistencies, especially on mobile browsers, we prevent default
|
|
424
|
-
// on the emulated mouse event and handle focusing the pressable element ourselves.
|
|
425
|
-
if (!isDisabled && !preventFocusOnPress) (0, $bBqCQ$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
426
431
|
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$exports.disableTextSelection)(state.target);
|
|
427
432
|
let shouldStopPropagation = triggerPressStart($0294ea432cd92340$var$createTouchEvent(state.target, e), state.pointerType);
|
|
428
433
|
if (shouldStopPropagation) e.stopPropagation();
|
|
429
434
|
addGlobalListener((0, $bBqCQ$reactariautils.getOwnerWindow)(e.currentTarget), 'scroll', onScroll, true);
|
|
430
435
|
};
|
|
431
436
|
pressProps.onTouchMove = (e)=>{
|
|
432
|
-
if (!e.currentTarget.
|
|
437
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
433
438
|
if (!state.isPressed) {
|
|
434
439
|
e.stopPropagation();
|
|
435
440
|
return;
|
|
@@ -449,7 +454,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
449
454
|
if (shouldStopPropagation) e.stopPropagation();
|
|
450
455
|
};
|
|
451
456
|
pressProps.onTouchEnd = (e)=>{
|
|
452
|
-
if (!e.currentTarget.
|
|
457
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
453
458
|
if (!state.isPressed) {
|
|
454
459
|
e.stopPropagation();
|
|
455
460
|
return;
|
|
@@ -469,12 +474,12 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
469
474
|
removeAllGlobalListeners();
|
|
470
475
|
};
|
|
471
476
|
pressProps.onTouchCancel = (e)=>{
|
|
472
|
-
if (!e.currentTarget.
|
|
477
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
473
478
|
e.stopPropagation();
|
|
474
479
|
if (state.isPressed) cancel($0294ea432cd92340$var$createTouchEvent(state.target, e));
|
|
475
480
|
};
|
|
476
481
|
let onScroll = (e)=>{
|
|
477
|
-
if (state.isPressed &&
|
|
482
|
+
if (state.isPressed && (0, $bBqCQ$reactariautils.nodeContains)((0, $bBqCQ$reactariautils.getEventTarget)(e), state.target)) cancel({
|
|
478
483
|
currentTarget: state.target,
|
|
479
484
|
shiftKey: false,
|
|
480
485
|
ctrlKey: false,
|
|
@@ -483,7 +488,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
483
488
|
});
|
|
484
489
|
};
|
|
485
490
|
pressProps.onDragStart = (e)=>{
|
|
486
|
-
if (!e.currentTarget.
|
|
491
|
+
if (!(0, $bBqCQ$reactariautils.nodeContains)(e.currentTarget, (0, $bBqCQ$reactariautils.getEventTarget)(e.nativeEvent))) return;
|
|
487
492
|
cancel(e);
|
|
488
493
|
};
|
|
489
494
|
}
|
|
@@ -502,10 +507,12 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
502
507
|
]);
|
|
503
508
|
// Remove user-select: none in case component unmounts immediately after pressStart
|
|
504
509
|
(0, $bBqCQ$react.useEffect)(()=>{
|
|
510
|
+
let state = ref.current;
|
|
505
511
|
return ()=>{
|
|
506
|
-
var
|
|
507
|
-
if (!allowTextSelectionOnPress)
|
|
508
|
-
|
|
512
|
+
var _state_target;
|
|
513
|
+
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$exports.restoreTextSelection)((_state_target = state.target) !== null && _state_target !== void 0 ? _state_target : undefined);
|
|
514
|
+
for (let dispose of state.disposables)dispose();
|
|
515
|
+
state.disposables = [];
|
|
509
516
|
};
|
|
510
517
|
}, [
|
|
511
518
|
allowTextSelectionOnPress
|
|
@@ -596,10 +603,6 @@ function $0294ea432cd92340$var$isOverTarget(point, target) {
|
|
|
596
603
|
let pointRect = $0294ea432cd92340$var$getPointClientRect(point);
|
|
597
604
|
return $0294ea432cd92340$var$areRectanglesOverlapping(rect, pointRect);
|
|
598
605
|
}
|
|
599
|
-
function $0294ea432cd92340$var$shouldPreventDefaultDown(target) {
|
|
600
|
-
// We cannot prevent default if the target is a draggable element.
|
|
601
|
-
return !(target instanceof HTMLElement) || !target.hasAttribute('draggable');
|
|
602
|
-
}
|
|
603
606
|
function $0294ea432cd92340$var$shouldPreventDefaultUp(target) {
|
|
604
607
|
if (target instanceof HTMLInputElement) return false;
|
|
605
608
|
if (target instanceof HTMLButtonElement) return target.type !== 'submit' && target.type !== 'reset';
|