@react-aria/interactions 3.27.0 → 3.28.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.
Files changed (118) hide show
  1. package/dist/import.mjs +21 -15
  2. package/dist/main.js +45 -39
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +21 -15
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +31 -0
  7. package/package.json +16 -15
  8. package/src/index.ts +31 -35
  9. package/dist/PressResponder.main.js +0 -61
  10. package/dist/PressResponder.main.js.map +0 -1
  11. package/dist/PressResponder.mjs +0 -51
  12. package/dist/PressResponder.module.js +0 -51
  13. package/dist/PressResponder.module.js.map +0 -1
  14. package/dist/Pressable.main.js +0 -69
  15. package/dist/Pressable.main.js.map +0 -1
  16. package/dist/Pressable.mjs +0 -60
  17. package/dist/Pressable.module.js +0 -60
  18. package/dist/Pressable.module.js.map +0 -1
  19. package/dist/context.main.js +0 -30
  20. package/dist/context.main.js.map +0 -1
  21. package/dist/context.mjs +0 -21
  22. package/dist/context.module.js +0 -21
  23. package/dist/context.module.js.map +0 -1
  24. package/dist/createEventHandler.main.js +0 -46
  25. package/dist/createEventHandler.main.js.map +0 -1
  26. package/dist/createEventHandler.mjs +0 -41
  27. package/dist/createEventHandler.module.js +0 -41
  28. package/dist/createEventHandler.module.js.map +0 -1
  29. package/dist/focusSafely.main.js +0 -40
  30. package/dist/focusSafely.main.js.map +0 -1
  31. package/dist/focusSafely.mjs +0 -35
  32. package/dist/focusSafely.module.js +0 -35
  33. package/dist/focusSafely.module.js.map +0 -1
  34. package/dist/textSelection.main.js +0 -77
  35. package/dist/textSelection.main.js.map +0 -1
  36. package/dist/textSelection.mjs +0 -71
  37. package/dist/textSelection.module.js +0 -71
  38. package/dist/textSelection.module.js.map +0 -1
  39. package/dist/types.d.ts +0 -255
  40. package/dist/types.d.ts.map +0 -1
  41. package/dist/useFocus.main.js +0 -65
  42. package/dist/useFocus.main.js.map +0 -1
  43. package/dist/useFocus.mjs +0 -60
  44. package/dist/useFocus.module.js +0 -60
  45. package/dist/useFocus.module.js.map +0 -1
  46. package/dist/useFocusVisible.main.js +0 -265
  47. package/dist/useFocusVisible.main.js.map +0 -1
  48. package/dist/useFocusVisible.mjs +0 -253
  49. package/dist/useFocusVisible.module.js +0 -253
  50. package/dist/useFocusVisible.module.js.map +0 -1
  51. package/dist/useFocusWithin.main.js +0 -105
  52. package/dist/useFocusWithin.main.js.map +0 -1
  53. package/dist/useFocusWithin.mjs +0 -100
  54. package/dist/useFocusWithin.module.js +0 -100
  55. package/dist/useFocusWithin.module.js.map +0 -1
  56. package/dist/useFocusable.main.js +0 -113
  57. package/dist/useFocusable.main.js.map +0 -1
  58. package/dist/useFocusable.mjs +0 -101
  59. package/dist/useFocusable.module.js +0 -101
  60. package/dist/useFocusable.module.js.map +0 -1
  61. package/dist/useHover.main.js +0 -159
  62. package/dist/useHover.main.js.map +0 -1
  63. package/dist/useHover.mjs +0 -154
  64. package/dist/useHover.module.js +0 -154
  65. package/dist/useHover.module.js.map +0 -1
  66. package/dist/useInteractOutside.main.js +0 -106
  67. package/dist/useInteractOutside.main.js.map +0 -1
  68. package/dist/useInteractOutside.mjs +0 -101
  69. package/dist/useInteractOutside.module.js +0 -101
  70. package/dist/useInteractOutside.module.js.map +0 -1
  71. package/dist/useKeyboard.main.js +0 -30
  72. package/dist/useKeyboard.main.js.map +0 -1
  73. package/dist/useKeyboard.mjs +0 -25
  74. package/dist/useKeyboard.module.js +0 -25
  75. package/dist/useKeyboard.module.js.map +0 -1
  76. package/dist/useLongPress.main.js +0 -86
  77. package/dist/useLongPress.main.js.map +0 -1
  78. package/dist/useLongPress.mjs +0 -81
  79. package/dist/useLongPress.module.js +0 -81
  80. package/dist/useLongPress.module.js.map +0 -1
  81. package/dist/useMove.main.js +0 -272
  82. package/dist/useMove.main.js.map +0 -1
  83. package/dist/useMove.mjs +0 -267
  84. package/dist/useMove.module.js +0 -267
  85. package/dist/useMove.module.js.map +0 -1
  86. package/dist/usePress.main.js +0 -763
  87. package/dist/usePress.main.js.map +0 -1
  88. package/dist/usePress.mjs +0 -758
  89. package/dist/usePress.module.js +0 -758
  90. package/dist/usePress.module.js.map +0 -1
  91. package/dist/useScrollWheel.main.js +0 -41
  92. package/dist/useScrollWheel.main.js.map +0 -1
  93. package/dist/useScrollWheel.mjs +0 -36
  94. package/dist/useScrollWheel.module.js +0 -36
  95. package/dist/useScrollWheel.module.js.map +0 -1
  96. package/dist/utils.main.js +0 -163
  97. package/dist/utils.main.js.map +0 -1
  98. package/dist/utils.mjs +0 -154
  99. package/dist/utils.module.js +0 -154
  100. package/dist/utils.module.js.map +0 -1
  101. package/src/PressResponder.tsx +0 -67
  102. package/src/Pressable.tsx +0 -97
  103. package/src/context.ts +0 -23
  104. package/src/createEventHandler.ts +0 -55
  105. package/src/focusSafely.ts +0 -45
  106. package/src/textSelection.ts +0 -101
  107. package/src/useFocus.ts +0 -87
  108. package/src/useFocusVisible.ts +0 -357
  109. package/src/useFocusWithin.ts +0 -132
  110. package/src/useFocusable.tsx +0 -191
  111. package/src/useHover.ts +0 -222
  112. package/src/useInteractOutside.ts +0 -142
  113. package/src/useKeyboard.ts +0 -36
  114. package/src/useLongPress.ts +0 -135
  115. package/src/useMove.ts +0 -259
  116. package/src/usePress.ts +0 -1093
  117. package/src/useScrollWheel.ts +0 -41
  118. package/src/utils.ts +0 -174
@@ -1,106 +0,0 @@
1
- var $9Icr4$reactariautils = require("@react-aria/utils");
2
- var $9Icr4$react = require("react");
3
-
4
-
5
- function $parcel$export(e, n, v, s) {
6
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
- }
8
-
9
- $parcel$export(module.exports, "useInteractOutside", () => $edcfa848c42f94f4$export$872b660ac5a1ff98);
10
- /*
11
- * Copyright 2020 Adobe. All rights reserved.
12
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License. You may obtain a copy
14
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software distributed under
17
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
- * OF ANY KIND, either express or implied. See the License for the specific language
19
- * governing permissions and limitations under the License.
20
- */ // Portions of the code in this file are based on code from react.
21
- // Original licensing for the following can be found in the
22
- // NOTICE file in the root directory of this source tree.
23
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
24
-
25
-
26
- function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
27
- let { ref: ref, onInteractOutside: onInteractOutside, isDisabled: isDisabled, onInteractOutsideStart: onInteractOutsideStart } = props;
28
- let stateRef = (0, $9Icr4$react.useRef)({
29
- isPointerDown: false,
30
- ignoreEmulatedMouseEvents: false
31
- });
32
- let onPointerDown = (0, $9Icr4$reactariautils.useEffectEvent)((e)=>{
33
- if (onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) {
34
- if (onInteractOutsideStart) onInteractOutsideStart(e);
35
- stateRef.current.isPointerDown = true;
36
- }
37
- });
38
- let triggerInteractOutside = (0, $9Icr4$reactariautils.useEffectEvent)((e)=>{
39
- if (onInteractOutside) onInteractOutside(e);
40
- });
41
- (0, $9Icr4$react.useEffect)(()=>{
42
- let state = stateRef.current;
43
- if (isDisabled) return;
44
- const element = ref.current;
45
- const documentObject = (0, $9Icr4$reactariautils.getOwnerDocument)(element);
46
- // Use pointer events if available. Otherwise, fall back to mouse and touch events.
47
- if (typeof PointerEvent !== 'undefined') {
48
- let onClick = (e)=>{
49
- if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
50
- state.isPointerDown = false;
51
- };
52
- // changing these to capture phase fixed combobox
53
- // Use click instead of pointerup to avoid Android Chrome issue
54
- // https://issues.chromium.org/issues/40732224
55
- documentObject.addEventListener('pointerdown', onPointerDown, true);
56
- documentObject.addEventListener('click', onClick, true);
57
- return ()=>{
58
- documentObject.removeEventListener('pointerdown', onPointerDown, true);
59
- documentObject.removeEventListener('click', onClick, true);
60
- };
61
- } else if (process.env.NODE_ENV === 'test') {
62
- let onMouseUp = (e)=>{
63
- if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
64
- else if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
65
- state.isPointerDown = false;
66
- };
67
- let onTouchEnd = (e)=>{
68
- state.ignoreEmulatedMouseEvents = true;
69
- if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
70
- state.isPointerDown = false;
71
- };
72
- documentObject.addEventListener('mousedown', onPointerDown, true);
73
- documentObject.addEventListener('mouseup', onMouseUp, true);
74
- documentObject.addEventListener('touchstart', onPointerDown, true);
75
- documentObject.addEventListener('touchend', onTouchEnd, true);
76
- return ()=>{
77
- documentObject.removeEventListener('mousedown', onPointerDown, true);
78
- documentObject.removeEventListener('mouseup', onMouseUp, true);
79
- documentObject.removeEventListener('touchstart', onPointerDown, true);
80
- documentObject.removeEventListener('touchend', onTouchEnd, true);
81
- };
82
- }
83
- }, [
84
- ref,
85
- isDisabled
86
- ]);
87
- }
88
- function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
89
- if (event.button > 0) return false;
90
- if (event.target) {
91
- // if the event target is no longer in the document, ignore
92
- const ownerDocument = event.target.ownerDocument;
93
- if (!ownerDocument || !(0, $9Icr4$reactariautils.nodeContains)(ownerDocument.documentElement, event.target)) return false;
94
- // If the target is within a top layer element (e.g. toasts), ignore.
95
- if (event.target.closest('[data-react-aria-top-layer]')) return false;
96
- }
97
- if (!ref.current) return false;
98
- // When the event source is inside a Shadow DOM, event.target is just the shadow root.
99
- // Using event.composedPath instead means we can get the actual element inside the shadow root.
100
- // This only works if the shadow root is open, there is no way to detect if it is closed.
101
- // If the event composed path contains the ref, interaction is inside.
102
- return !event.composedPath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ent":["/*\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, nodeContains, 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): void {\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 onClick = (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 // Use click instead of pointerup to avoid Android Chrome issue\n // https://issues.chromium.org/issues/40732224\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('click', onClick, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('click', onClick, true);\n };\n } else if (process.env.NODE_ENV === 'test') {\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]);\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 || !nodeContains(ownerDocument.documentElement, 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.main.js.map"}
@@ -1,101 +0,0 @@
1
- import {useEffectEvent as $ispOf$useEffectEvent, getOwnerDocument as $ispOf$getOwnerDocument, nodeContains as $ispOf$nodeContains} from "@react-aria/utils";
2
- import {useRef as $ispOf$useRef, useEffect as $ispOf$useEffect} from "react";
3
-
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */ // Portions of the code in this file are based on code from react.
15
- // Original licensing for the following can be found in the
16
- // NOTICE file in the root directory of this source tree.
17
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
18
-
19
-
20
- function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
21
- let { ref: ref, onInteractOutside: onInteractOutside, isDisabled: isDisabled, onInteractOutsideStart: onInteractOutsideStart } = props;
22
- let stateRef = (0, $ispOf$useRef)({
23
- isPointerDown: false,
24
- ignoreEmulatedMouseEvents: false
25
- });
26
- let onPointerDown = (0, $ispOf$useEffectEvent)((e)=>{
27
- if (onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
28
- if (onInteractOutsideStart) onInteractOutsideStart(e);
29
- stateRef.current.isPointerDown = true;
30
- }
31
- });
32
- let triggerInteractOutside = (0, $ispOf$useEffectEvent)((e)=>{
33
- if (onInteractOutside) onInteractOutside(e);
34
- });
35
- (0, $ispOf$useEffect)(()=>{
36
- let state = stateRef.current;
37
- if (isDisabled) return;
38
- const element = ref.current;
39
- const documentObject = (0, $ispOf$getOwnerDocument)(element);
40
- // Use pointer events if available. Otherwise, fall back to mouse and touch events.
41
- if (typeof PointerEvent !== 'undefined') {
42
- let onClick = (e)=>{
43
- if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
44
- state.isPointerDown = false;
45
- };
46
- // changing these to capture phase fixed combobox
47
- // Use click instead of pointerup to avoid Android Chrome issue
48
- // https://issues.chromium.org/issues/40732224
49
- documentObject.addEventListener('pointerdown', onPointerDown, true);
50
- documentObject.addEventListener('click', onClick, true);
51
- return ()=>{
52
- documentObject.removeEventListener('pointerdown', onPointerDown, true);
53
- documentObject.removeEventListener('click', onClick, true);
54
- };
55
- } else if (process.env.NODE_ENV === 'test') {
56
- let onMouseUp = (e)=>{
57
- if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
58
- else if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
59
- state.isPointerDown = false;
60
- };
61
- let onTouchEnd = (e)=>{
62
- state.ignoreEmulatedMouseEvents = true;
63
- if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
64
- state.isPointerDown = false;
65
- };
66
- documentObject.addEventListener('mousedown', onPointerDown, true);
67
- documentObject.addEventListener('mouseup', onMouseUp, true);
68
- documentObject.addEventListener('touchstart', onPointerDown, true);
69
- documentObject.addEventListener('touchend', onTouchEnd, true);
70
- return ()=>{
71
- documentObject.removeEventListener('mousedown', onPointerDown, true);
72
- documentObject.removeEventListener('mouseup', onMouseUp, true);
73
- documentObject.removeEventListener('touchstart', onPointerDown, true);
74
- documentObject.removeEventListener('touchend', onTouchEnd, true);
75
- };
76
- }
77
- }, [
78
- ref,
79
- isDisabled
80
- ]);
81
- }
82
- function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
83
- if (event.button > 0) return false;
84
- if (event.target) {
85
- // if the event target is no longer in the document, ignore
86
- const ownerDocument = event.target.ownerDocument;
87
- if (!ownerDocument || !(0, $ispOf$nodeContains)(ownerDocument.documentElement, event.target)) return false;
88
- // If the target is within a top layer element (e.g. toasts), ignore.
89
- if (event.target.closest('[data-react-aria-top-layer]')) return false;
90
- }
91
- if (!ref.current) return false;
92
- // When the event source is inside a Shadow DOM, event.target is just the shadow root.
93
- // Using event.composedPath instead means we can get the actual element inside the shadow root.
94
- // This only works if the shadow root is open, there is no way to detect if it is closed.
95
- // If the event composed path contains the ref, interaction is inside.
96
- return !event.composedPath().includes(ref.current);
97
- }
98
-
99
-
100
- export {$e0b6e0b68ec7f50f$export$872b660ac5a1ff98 as useInteractOutside};
101
- //# sourceMappingURL=useInteractOutside.module.js.map
@@ -1,101 +0,0 @@
1
- import {useEffectEvent as $ispOf$useEffectEvent, getOwnerDocument as $ispOf$getOwnerDocument, nodeContains as $ispOf$nodeContains} from "@react-aria/utils";
2
- import {useRef as $ispOf$useRef, useEffect as $ispOf$useEffect} from "react";
3
-
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */ // Portions of the code in this file are based on code from react.
15
- // Original licensing for the following can be found in the
16
- // NOTICE file in the root directory of this source tree.
17
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
18
-
19
-
20
- function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
21
- let { ref: ref, onInteractOutside: onInteractOutside, isDisabled: isDisabled, onInteractOutsideStart: onInteractOutsideStart } = props;
22
- let stateRef = (0, $ispOf$useRef)({
23
- isPointerDown: false,
24
- ignoreEmulatedMouseEvents: false
25
- });
26
- let onPointerDown = (0, $ispOf$useEffectEvent)((e)=>{
27
- if (onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
28
- if (onInteractOutsideStart) onInteractOutsideStart(e);
29
- stateRef.current.isPointerDown = true;
30
- }
31
- });
32
- let triggerInteractOutside = (0, $ispOf$useEffectEvent)((e)=>{
33
- if (onInteractOutside) onInteractOutside(e);
34
- });
35
- (0, $ispOf$useEffect)(()=>{
36
- let state = stateRef.current;
37
- if (isDisabled) return;
38
- const element = ref.current;
39
- const documentObject = (0, $ispOf$getOwnerDocument)(element);
40
- // Use pointer events if available. Otherwise, fall back to mouse and touch events.
41
- if (typeof PointerEvent !== 'undefined') {
42
- let onClick = (e)=>{
43
- if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
44
- state.isPointerDown = false;
45
- };
46
- // changing these to capture phase fixed combobox
47
- // Use click instead of pointerup to avoid Android Chrome issue
48
- // https://issues.chromium.org/issues/40732224
49
- documentObject.addEventListener('pointerdown', onPointerDown, true);
50
- documentObject.addEventListener('click', onClick, true);
51
- return ()=>{
52
- documentObject.removeEventListener('pointerdown', onPointerDown, true);
53
- documentObject.removeEventListener('click', onClick, true);
54
- };
55
- } else if (process.env.NODE_ENV === 'test') {
56
- let onMouseUp = (e)=>{
57
- if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
58
- else if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
59
- state.isPointerDown = false;
60
- };
61
- let onTouchEnd = (e)=>{
62
- state.ignoreEmulatedMouseEvents = true;
63
- if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
64
- state.isPointerDown = false;
65
- };
66
- documentObject.addEventListener('mousedown', onPointerDown, true);
67
- documentObject.addEventListener('mouseup', onMouseUp, true);
68
- documentObject.addEventListener('touchstart', onPointerDown, true);
69
- documentObject.addEventListener('touchend', onTouchEnd, true);
70
- return ()=>{
71
- documentObject.removeEventListener('mousedown', onPointerDown, true);
72
- documentObject.removeEventListener('mouseup', onMouseUp, true);
73
- documentObject.removeEventListener('touchstart', onPointerDown, true);
74
- documentObject.removeEventListener('touchend', onTouchEnd, true);
75
- };
76
- }
77
- }, [
78
- ref,
79
- isDisabled
80
- ]);
81
- }
82
- function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
83
- if (event.button > 0) return false;
84
- if (event.target) {
85
- // if the event target is no longer in the document, ignore
86
- const ownerDocument = event.target.ownerDocument;
87
- if (!ownerDocument || !(0, $ispOf$nodeContains)(ownerDocument.documentElement, event.target)) return false;
88
- // If the target is within a top layer element (e.g. toasts), ignore.
89
- if (event.target.closest('[data-react-aria-top-layer]')) return false;
90
- }
91
- if (!ref.current) return false;
92
- // When the event source is inside a Shadow DOM, event.target is just the shadow root.
93
- // Using event.composedPath instead means we can get the actual element inside the shadow root.
94
- // This only works if the shadow root is open, there is no way to detect if it is closed.
95
- // If the event composed path contains the ref, interaction is inside.
96
- return !event.composedPath().includes(ref.current);
97
- }
98
-
99
-
100
- export {$e0b6e0b68ec7f50f$export$872b660ac5a1ff98 as useInteractOutside};
101
- //# sourceMappingURL=useInteractOutside.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;AAkB3G,SAAS,0CAAmB,KAA2B;IAC5D,IAAI,OAAC,GAAG,qBAAE,iBAAiB,cAAE,UAAU,0BAAE,sBAAsB,EAAC,GAAG;IACnE,IAAI,WAAW,CAAA,GAAA,aAAK,EAAE;QACpB,eAAe;QACf,2BAA2B;IAC7B;IAEA,IAAI,gBAAgB,CAAA,GAAA,qBAAa,EAAE,CAAC;QAClC,I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e,gBAAgB,CAAC,YAAY,YAAY;YAExD,OAAO;gBACL,eAAe,mBAAmB,CAAC,aAAa,eAAe;gBAC/D,eAAe,mBAAmB,CAAC,WAAW,WAAW;gBACzD,eAAe,mBAAmB,CAAC,cAAc,eAAe;gBAChE,eAAe,mBAAmB,CAAC,YAAY,YAAY;YAC7D;QACF;IACF,GAAG;QAAC;QAAK;KAAW;AACtB;AAEA,SAAS,mCAAa,KAAK,EAAE,GAAG;IAC9B,IAAI,MAAM,MAAM,GAAG,GACjB,OAAO;IAET,IAAI,MAAM,MAAM,EAAE;QAChB,2DAA2D;QAC3D,MAAM,gBAAgB,MAAM,MAAM,CAAC,aAAa;QAChD,IAAI,CAAC,iBAAiB,CAAC,CAAA,GAAA,mBAAW,EAAE,cAAc,eAAe,EAAE,MAAM,MAAM,GAC7E,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, nodeContains, 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): void {\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 onClick = (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 // Use click instead of pointerup to avoid Android Chrome issue\n // https://issues.chromium.org/issues/40732224\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('click', onClick, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('click', onClick, true);\n };\n } else if (process.env.NODE_ENV === 'test') {\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]);\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 || !nodeContains(ownerDocument.documentElement, 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"}
@@ -1,30 +0,0 @@
1
- var $951fbcbbca8db6ce$exports = require("./createEventHandler.main.js");
2
-
3
-
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
-
8
- $parcel$export(module.exports, "useKeyboard", () => $892d64db2a3c53b0$export$8f71654801c2f7cd);
9
- /*
10
- * Copyright 2020 Adobe. All rights reserved.
11
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License. You may obtain a copy
13
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software distributed under
16
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
- * OF ANY KIND, either express or implied. See the License for the specific language
18
- * governing permissions and limitations under the License.
19
- */
20
- function $892d64db2a3c53b0$export$8f71654801c2f7cd(props) {
21
- return {
22
- keyboardProps: props.isDisabled ? {} : {
23
- onKeyDown: (0, $951fbcbbca8db6ce$exports.createEventHandler)(props.onKeyDown),
24
- onKeyUp: (0, $951fbcbbca8db6ce$exports.createEventHandler)(props.onKeyUp)
25
- }
26
- };
27
- }
28
-
29
-
30
- //# sourceMappingURL=useKeyboard.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAkBM,SAAS,0CAAY,KAAoB;IAC9C,OAAO;QACL,eAAe,MAAM,UAAU,GAAG,CAAC,IAAI;YACrC,WAAW,CAAA,GAAA,4CAAiB,EAAE,MAAM,SAAS;YAC7C,SAAS,CAAA,GAAA,4CAAiB,EAAE,MAAM,OAAO;QAC3C;IACF;AACF","sources":["packages/@react-aria/interactions/src/useKeyboard.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 {createEventHandler} from './createEventHandler';\nimport {DOMAttributes, KeyboardEvents} from '@react-types/shared';\n\nexport interface KeyboardProps extends KeyboardEvents {\n /** Whether the keyboard events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface KeyboardResult {\n /** Props to spread onto the target element. */\n keyboardProps: DOMAttributes\n}\n\n/**\n * Handles keyboard interactions for a focusable element.\n */\nexport function useKeyboard(props: KeyboardProps): KeyboardResult {\n return {\n keyboardProps: props.isDisabled ? {} : {\n onKeyDown: createEventHandler(props.onKeyDown),\n onKeyUp: createEventHandler(props.onKeyUp)\n }\n };\n}\n"],"names":[],"version":3,"file":"useKeyboard.main.js.map"}
@@ -1,25 +0,0 @@
1
- import {createEventHandler as $93925083ecbb358c$export$48d1ea6320830260} from "./createEventHandler.mjs";
2
-
3
- /*
4
- * Copyright 2020 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
15
- return {
16
- keyboardProps: props.isDisabled ? {} : {
17
- onKeyDown: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyDown),
18
- onKeyUp: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyUp)
19
- }
20
- };
21
- }
22
-
23
-
24
- export {$46d819fcbaf35654$export$8f71654801c2f7cd as useKeyboard};
25
- //# sourceMappingURL=useKeyboard.module.js.map
@@ -1,25 +0,0 @@
1
- import {createEventHandler as $93925083ecbb358c$export$48d1ea6320830260} from "./createEventHandler.module.js";
2
-
3
- /*
4
- * Copyright 2020 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
15
- return {
16
- keyboardProps: props.isDisabled ? {} : {
17
- onKeyDown: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyDown),
18
- onKeyUp: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyUp)
19
- }
20
- };
21
- }
22
-
23
-
24
- export {$46d819fcbaf35654$export$8f71654801c2f7cd as useKeyboard};
25
- //# sourceMappingURL=useKeyboard.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAkBM,SAAS,0CAAY,KAAoB;IAC9C,OAAO;QACL,eAAe,MAAM,UAAU,GAAG,CAAC,IAAI;YACrC,WAAW,CAAA,GAAA,yCAAiB,EAAE,MAAM,SAAS;YAC7C,SAAS,CAAA,GAAA,yCAAiB,EAAE,MAAM,OAAO;QAC3C;IACF;AACF","sources":["packages/@react-aria/interactions/src/useKeyboard.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 {createEventHandler} from './createEventHandler';\nimport {DOMAttributes, KeyboardEvents} from '@react-types/shared';\n\nexport interface KeyboardProps extends KeyboardEvents {\n /** Whether the keyboard events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface KeyboardResult {\n /** Props to spread onto the target element. */\n keyboardProps: DOMAttributes\n}\n\n/**\n * Handles keyboard interactions for a focusable element.\n */\nexport function useKeyboard(props: KeyboardProps): KeyboardResult {\n return {\n keyboardProps: props.isDisabled ? {} : {\n onKeyDown: createEventHandler(props.onKeyDown),\n onKeyUp: createEventHandler(props.onKeyUp)\n }\n };\n}\n"],"names":[],"version":3,"file":"useKeyboard.module.js.map"}
@@ -1,86 +0,0 @@
1
- var $0294ea432cd92340$exports = require("./usePress.main.js");
2
- var $5sxTM$reactariautils = require("@react-aria/utils");
3
- var $5sxTM$react = require("react");
4
-
5
-
6
- function $parcel$export(e, n, v, s) {
7
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
- }
9
-
10
- $parcel$export(module.exports, "useLongPress", () => $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9);
11
- /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */
22
-
23
-
24
- const $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD = 500;
25
- function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
26
- let { isDisabled: isDisabled, onLongPressStart: onLongPressStart, onLongPressEnd: onLongPressEnd, onLongPress: onLongPress, threshold: threshold = $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD, accessibilityDescription: accessibilityDescription } = props;
27
- const timeRef = (0, $5sxTM$react.useRef)(undefined);
28
- let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $5sxTM$reactariautils.useGlobalListeners)();
29
- let { pressProps: pressProps } = (0, $0294ea432cd92340$exports.usePress)({
30
- isDisabled: isDisabled,
31
- onPressStart (e) {
32
- e.continuePropagation();
33
- if (e.pointerType === 'mouse' || e.pointerType === 'touch') {
34
- if (onLongPressStart) onLongPressStart({
35
- ...e,
36
- type: 'longpressstart'
37
- });
38
- timeRef.current = setTimeout(()=>{
39
- // Prevent other usePress handlers from also handling this event.
40
- e.target.dispatchEvent(new PointerEvent('pointercancel', {
41
- bubbles: true
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);
45
- if (onLongPress) onLongPress({
46
- ...e,
47
- type: 'longpress'
48
- });
49
- timeRef.current = undefined;
50
- }, threshold);
51
- // Prevent context menu, which may be opened on long press on touch devices
52
- if (e.pointerType === 'touch') {
53
- let onContextMenu = (e)=>{
54
- e.preventDefault();
55
- };
56
- addGlobalListener(e.target, 'contextmenu', onContextMenu, {
57
- once: true
58
- });
59
- addGlobalListener(window, 'pointerup', ()=>{
60
- // If no contextmenu event is fired quickly after pointerup, remove the handler
61
- // so future context menu events outside a long press are not prevented.
62
- setTimeout(()=>{
63
- removeGlobalListener(e.target, 'contextmenu', onContextMenu);
64
- }, 30);
65
- }, {
66
- once: true
67
- });
68
- }
69
- }
70
- },
71
- onPressEnd (e) {
72
- if (timeRef.current) clearTimeout(timeRef.current);
73
- if (onLongPressEnd && (e.pointerType === 'mouse' || e.pointerType === 'touch')) onLongPressEnd({
74
- ...e,
75
- type: 'longpressend'
76
- });
77
- }
78
- });
79
- let descriptionProps = (0, $5sxTM$reactariautils.useDescription)(onLongPress && !isDisabled ? accessibilityDescription : undefined);
80
- return {
81
- longPressProps: (0, $5sxTM$reactariautils.mergeProps)(pressProps, descriptionProps)
82
- };
83
- }
84
-
85
-
86
- //# sourceMappingURL=useLongPress.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAuCD,MAAM,0CAAoB;AAMnB,SAAS,0CAAa,KAAqB;IAChD,IAAI,cACF,UAAU,oBACV,gBAAgB,kB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,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"}
@@ -1,81 +0,0 @@
1
- import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.mjs";
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
- import {useRef as $4k2kv$useRef} from "react";
4
-
5
- /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */
16
-
17
-
18
- const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
19
- function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
20
- let { isDisabled: isDisabled, onLongPressStart: onLongPressStart, onLongPressEnd: onLongPressEnd, onLongPress: onLongPress, threshold: threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD, accessibilityDescription: accessibilityDescription } = props;
21
- const timeRef = (0, $4k2kv$useRef)(undefined);
22
- let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $4k2kv$useGlobalListeners)();
23
- let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
24
- isDisabled: isDisabled,
25
- onPressStart (e) {
26
- e.continuePropagation();
27
- if (e.pointerType === 'mouse' || e.pointerType === 'touch') {
28
- if (onLongPressStart) onLongPressStart({
29
- ...e,
30
- type: 'longpressstart'
31
- });
32
- timeRef.current = setTimeout(()=>{
33
- // Prevent other usePress handlers from also handling this event.
34
- e.target.dispatchEvent(new PointerEvent('pointercancel', {
35
- bubbles: true
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);
39
- if (onLongPress) onLongPress({
40
- ...e,
41
- type: 'longpress'
42
- });
43
- timeRef.current = undefined;
44
- }, threshold);
45
- // Prevent context menu, which may be opened on long press on touch devices
46
- if (e.pointerType === 'touch') {
47
- let onContextMenu = (e)=>{
48
- e.preventDefault();
49
- };
50
- addGlobalListener(e.target, 'contextmenu', onContextMenu, {
51
- once: true
52
- });
53
- addGlobalListener(window, 'pointerup', ()=>{
54
- // If no contextmenu event is fired quickly after pointerup, remove the handler
55
- // so future context menu events outside a long press are not prevented.
56
- setTimeout(()=>{
57
- removeGlobalListener(e.target, 'contextmenu', onContextMenu);
58
- }, 30);
59
- }, {
60
- once: true
61
- });
62
- }
63
- }
64
- },
65
- onPressEnd (e) {
66
- if (timeRef.current) clearTimeout(timeRef.current);
67
- if (onLongPressEnd && (e.pointerType === 'mouse' || e.pointerType === 'touch')) onLongPressEnd({
68
- ...e,
69
- type: 'longpressend'
70
- });
71
- }
72
- });
73
- let descriptionProps = (0, $4k2kv$useDescription)(onLongPress && !isDisabled ? accessibilityDescription : undefined);
74
- return {
75
- longPressProps: (0, $4k2kv$mergeProps)(pressProps, descriptionProps)
76
- };
77
- }
78
-
79
-
80
- export {$8a26561d2877236e$export$c24ed0104d07eab9 as useLongPress};
81
- //# sourceMappingURL=useLongPress.module.js.map