@react-aria/interactions 3.21.0 → 3.21.2

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 (88) hide show
  1. package/dist/PressResponder.main.js +62 -0
  2. package/dist/PressResponder.main.js.map +1 -0
  3. package/dist/PressResponder.mjs +52 -0
  4. package/dist/PressResponder.module.js +52 -0
  5. package/dist/PressResponder.module.js.map +1 -0
  6. package/dist/Pressable.main.js +43 -0
  7. package/dist/Pressable.main.js.map +1 -0
  8. package/dist/Pressable.mjs +34 -0
  9. package/dist/Pressable.module.js +34 -0
  10. package/dist/Pressable.module.js.map +1 -0
  11. package/dist/context.main.js +30 -0
  12. package/dist/context.main.js.map +1 -0
  13. package/dist/context.mjs +21 -0
  14. package/dist/context.module.js +21 -0
  15. package/dist/context.module.js.map +1 -0
  16. package/dist/createEventHandler.main.js +42 -0
  17. package/dist/createEventHandler.main.js.map +1 -0
  18. package/dist/createEventHandler.mjs +37 -0
  19. package/dist/createEventHandler.module.js +37 -0
  20. package/dist/createEventHandler.module.js.map +1 -0
  21. package/dist/import.mjs +12 -1771
  22. package/dist/main.js +31 -1794
  23. package/dist/main.js.map +1 -1
  24. package/dist/module.js +12 -1771
  25. package/dist/module.js.map +1 -1
  26. package/dist/textSelection.main.js +77 -0
  27. package/dist/textSelection.main.js.map +1 -0
  28. package/dist/textSelection.mjs +71 -0
  29. package/dist/textSelection.module.js +71 -0
  30. package/dist/textSelection.module.js.map +1 -0
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/useFocus.main.js +64 -0
  33. package/dist/useFocus.main.js.map +1 -0
  34. package/dist/useFocus.mjs +59 -0
  35. package/dist/useFocus.module.js +59 -0
  36. package/dist/useFocus.module.js.map +1 -0
  37. package/dist/useFocusVisible.main.js +248 -0
  38. package/dist/useFocusVisible.main.js.map +1 -0
  39. package/dist/useFocusVisible.mjs +237 -0
  40. package/dist/useFocusVisible.module.js +237 -0
  41. package/dist/useFocusVisible.module.js.map +1 -0
  42. package/dist/useFocusWithin.main.js +76 -0
  43. package/dist/useFocusWithin.main.js.map +1 -0
  44. package/dist/useFocusWithin.mjs +71 -0
  45. package/dist/useFocusWithin.module.js +71 -0
  46. package/dist/useFocusWithin.module.js.map +1 -0
  47. package/dist/useHover.main.js +142 -0
  48. package/dist/useHover.main.js.map +1 -0
  49. package/dist/useHover.mjs +137 -0
  50. package/dist/useHover.module.js +137 -0
  51. package/dist/useHover.module.js.map +1 -0
  52. package/dist/useInteractOutside.main.js +101 -0
  53. package/dist/useInteractOutside.main.js.map +1 -0
  54. package/dist/useInteractOutside.mjs +96 -0
  55. package/dist/useInteractOutside.module.js +96 -0
  56. package/dist/useInteractOutside.module.js.map +1 -0
  57. package/dist/useKeyboard.main.js +30 -0
  58. package/dist/useKeyboard.main.js.map +1 -0
  59. package/dist/useKeyboard.mjs +25 -0
  60. package/dist/useKeyboard.module.js +25 -0
  61. package/dist/useKeyboard.module.js.map +1 -0
  62. package/dist/useLongPress.main.js +84 -0
  63. package/dist/useLongPress.main.js.map +1 -0
  64. package/dist/useLongPress.mjs +79 -0
  65. package/dist/useLongPress.module.js +79 -0
  66. package/dist/useLongPress.module.js.map +1 -0
  67. package/dist/useMove.main.js +236 -0
  68. package/dist/useMove.main.js.map +1 -0
  69. package/dist/useMove.mjs +231 -0
  70. package/dist/useMove.module.js +231 -0
  71. package/dist/useMove.module.js.map +1 -0
  72. package/dist/usePress.main.js +571 -0
  73. package/dist/usePress.main.js.map +1 -0
  74. package/dist/usePress.mjs +566 -0
  75. package/dist/usePress.module.js +566 -0
  76. package/dist/usePress.module.js.map +1 -0
  77. package/dist/useScrollWheel.main.js +41 -0
  78. package/dist/useScrollWheel.main.js.map +1 -0
  79. package/dist/useScrollWheel.mjs +36 -0
  80. package/dist/useScrollWheel.module.js +36 -0
  81. package/dist/useScrollWheel.module.js.map +1 -0
  82. package/dist/utils.main.js +120 -0
  83. package/dist/utils.main.js.map +1 -0
  84. package/dist/utils.mjs +115 -0
  85. package/dist/utils.module.js +115 -0
  86. package/dist/utils.module.js.map +1 -0
  87. package/package.json +5 -5
  88. package/src/useFocus.ts +5 -1
package/dist/import.mjs CHANGED
@@ -1,21 +1,17 @@
1
- import {useObjectRef as $bx7SL$useObjectRef, mergeProps as $bx7SL$mergeProps, useSyncRef as $bx7SL$useSyncRef, useGlobalListeners as $bx7SL$useGlobalListeners, useEffectEvent as $bx7SL$useEffectEvent, getOwnerDocument as $bx7SL$getOwnerDocument, chain as $bx7SL$chain, isMac as $bx7SL$isMac, openLink as $bx7SL$openLink, isVirtualClick as $bx7SL$isVirtualClick, focusWithoutScrolling as $bx7SL$focusWithoutScrolling, isVirtualPointerEvent as $bx7SL$isVirtualPointerEvent, getOwnerWindow as $bx7SL$getOwnerWindow, isIOS as $bx7SL$isIOS, runAfterTransition as $bx7SL$runAfterTransition, useLayoutEffect as $bx7SL$useLayoutEffect, useEvent as $bx7SL$useEvent, useDescription as $bx7SL$useDescription} from "@react-aria/utils";
2
- import $bx7SL$react, {useContext as $bx7SL$useContext, useState as $bx7SL$useState, useRef as $bx7SL$useRef, useMemo as $bx7SL$useMemo, useEffect as $bx7SL$useEffect, useCallback as $bx7SL$useCallback} from "react";
3
- import {_ as $bx7SL$_} from "@swc/helpers/_/_class_private_field_get";
4
- import {_ as $bx7SL$_1} from "@swc/helpers/_/_class_private_field_init";
5
- import {_ as $bx7SL$_2} from "@swc/helpers/_/_class_private_field_set";
6
- import {useIsSSR as $bx7SL$useIsSSR} from "@react-aria/ssr";
1
+ import {Pressable as $3b117e43dc0ca95d$export$27c701ed9e449e99} from "./Pressable.mjs";
2
+ import {ClearPressResponder as $f1ab8c75478c6f73$export$cf75428e0b9ed1ea, PressResponder as $f1ab8c75478c6f73$export$3351871ee4b288b8} from "./PressResponder.mjs";
3
+ import {useFocus as $a1ea59d68270f0dd$export$f8168d8dd8fd66e6} from "./useFocus.mjs";
4
+ import {addWindowFocusTracking as $507fabe10e71c6fb$export$2f1888112f558a7d, getInteractionModality as $507fabe10e71c6fb$export$630ff653c5ada6a9, isFocusVisible as $507fabe10e71c6fb$export$b9b3dfddab17db27, setInteractionModality as $507fabe10e71c6fb$export$8397ddfc504fdb9a, useFocusVisible as $507fabe10e71c6fb$export$ffd9e5021c1fb2d6, useFocusVisibleListener as $507fabe10e71c6fb$export$ec71b4b83ac08ec3, useInteractionModality as $507fabe10e71c6fb$export$98e20ec92f614cfe} from "./useFocusVisible.mjs";
5
+ import {useFocusWithin as $9ab94262bd0047c7$export$420e68273165f4ec} from "./useFocusWithin.mjs";
6
+ import {useHover as $6179b936705e76d3$export$ae780daf29e6d456} from "./useHover.mjs";
7
+ import {useInteractOutside as $e0b6e0b68ec7f50f$export$872b660ac5a1ff98} from "./useInteractOutside.mjs";
8
+ import {useKeyboard as $46d819fcbaf35654$export$8f71654801c2f7cd} from "./useKeyboard.mjs";
9
+ import {useMove as $e8a7022cf87cba2a$export$36da96379f79f245} from "./useMove.mjs";
10
+ import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.mjs";
11
+ import {useScrollWheel as $7d0a636d7a4dcefd$export$2123ff2b87c81ca} from "./useScrollWheel.mjs";
12
+ import {useLongPress as $8a26561d2877236e$export$c24ed0104d07eab9} from "./useLongPress.mjs";
7
13
 
8
14
  /*
9
- * Copyright 2020 Adobe. All rights reserved.
10
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License. You may obtain a copy
12
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software distributed under
15
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
- * OF ANY KIND, either express or implied. See the License for the specific language
17
- * governing permissions and limitations under the License.
18
- */ /*
19
15
  * Copyright 2020 Adobe. All rights reserved.
20
16
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
21
17
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -26,1770 +22,15 @@ import {useIsSSR as $bx7SL$useIsSSR} from "@react-aria/ssr";
26
22
  * OF ANY KIND, either express or implied. See the License for the specific language
27
23
  * governing permissions and limitations under the License.
28
24
  */
29
- /*
30
- * Copyright 2020 Adobe. All rights reserved.
31
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
32
- * you may not use this file except in compliance with the License. You may obtain a copy
33
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
34
- *
35
- * Unless required by applicable law or agreed to in writing, software distributed under
36
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
37
- * OF ANY KIND, either express or implied. See the License for the specific language
38
- * governing permissions and limitations under the License.
39
- */ // Portions of the code in this file are based on code from react.
40
- // Original licensing for the following can be found in the
41
- // NOTICE file in the root directory of this source tree.
42
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
43
-
44
-
45
-
46
-
47
- /*
48
- * Copyright 2020 Adobe. All rights reserved.
49
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
50
- * you may not use this file except in compliance with the License. You may obtain a copy
51
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
52
- *
53
- * Unless required by applicable law or agreed to in writing, software distributed under
54
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
55
- * OF ANY KIND, either express or implied. See the License for the specific language
56
- * governing permissions and limitations under the License.
57
- */
58
- // Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
59
- // rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
60
- let $14c0b72509d70225$var$state = "default";
61
- let $14c0b72509d70225$var$savedUserSelect = "";
62
- let $14c0b72509d70225$var$modifiedElementMap = new WeakMap();
63
- function $14c0b72509d70225$export$16a4697467175487(target) {
64
- if ((0, $bx7SL$isIOS)()) {
65
- if ($14c0b72509d70225$var$state === "default") {
66
- // eslint-disable-next-line no-restricted-globals
67
- const documentObject = (0, $bx7SL$getOwnerDocument)(target);
68
- $14c0b72509d70225$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
69
- documentObject.documentElement.style.webkitUserSelect = "none";
70
- }
71
- $14c0b72509d70225$var$state = "disabled";
72
- } else if (target instanceof HTMLElement || target instanceof SVGElement) {
73
- // If not iOS, store the target's original user-select and change to user-select: none
74
- // Ignore state since it doesn't apply for non iOS
75
- $14c0b72509d70225$var$modifiedElementMap.set(target, target.style.userSelect);
76
- target.style.userSelect = "none";
77
- }
78
- }
79
- function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
80
- if ((0, $bx7SL$isIOS)()) {
81
- // If the state is already default, there's nothing to do.
82
- // If it is restoring, then there's no need to queue a second restore.
83
- if ($14c0b72509d70225$var$state !== "disabled") return;
84
- $14c0b72509d70225$var$state = "restoring";
85
- // There appears to be a delay on iOS where selection still might occur
86
- // after pointer up, so wait a bit before removing user-select.
87
- setTimeout(()=>{
88
- // Wait for any CSS transitions to complete so we don't recompute style
89
- // for the whole page in the middle of the animation and cause jank.
90
- (0, $bx7SL$runAfterTransition)(()=>{
91
- // Avoid race conditions
92
- if ($14c0b72509d70225$var$state === "restoring") {
93
- // eslint-disable-next-line no-restricted-globals
94
- const documentObject = (0, $bx7SL$getOwnerDocument)(target);
95
- if (documentObject.documentElement.style.webkitUserSelect === "none") documentObject.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || "";
96
- $14c0b72509d70225$var$savedUserSelect = "";
97
- $14c0b72509d70225$var$state = "default";
98
- }
99
- });
100
- }, 300);
101
- } else if (target instanceof HTMLElement || target instanceof SVGElement) // If not iOS, restore the target's original user-select if any
102
- // Ignore state since it doesn't apply for non iOS
103
- {
104
- if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
105
- let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
106
- if (target.style.userSelect === "none") target.style.userSelect = targetOldUserSelect;
107
- if (target.getAttribute("style") === "") target.removeAttribute("style");
108
- $14c0b72509d70225$var$modifiedElementMap.delete(target);
109
- }
110
- }
111
- }
112
-
113
-
114
- /*
115
- * Copyright 2020 Adobe. All rights reserved.
116
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
117
- * you may not use this file except in compliance with the License. You may obtain a copy
118
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
119
- *
120
- * Unless required by applicable law or agreed to in writing, software distributed under
121
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
122
- * OF ANY KIND, either express or implied. See the License for the specific language
123
- * governing permissions and limitations under the License.
124
- */
125
- const $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = (0, $bx7SL$react).createContext({
126
- register: ()=>{}
127
- });
128
- $ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = "PressResponderContext";
129
-
130
-
131
-
132
- function $f6c31cce2adf654f$var$usePressResponderContext(props) {
133
- // Consume context from <PressResponder> and merge with props.
134
- let context = (0, $bx7SL$useContext)((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5));
135
- if (context) {
136
- let { register: register, ...contextProps } = context;
137
- props = (0, $bx7SL$mergeProps)(contextProps, props);
138
- register();
139
- }
140
- (0, $bx7SL$useSyncRef)(context, props.ref);
141
- return props;
142
- }
143
- var $f6c31cce2adf654f$var$_shouldStopPropagation = /*#__PURE__*/ new WeakMap();
144
- class $f6c31cce2adf654f$var$PressEvent {
145
- continuePropagation() {
146
- (0, $bx7SL$_2)(this, $f6c31cce2adf654f$var$_shouldStopPropagation, false);
147
- }
148
- get shouldStopPropagation() {
149
- return (0, $bx7SL$_)(this, $f6c31cce2adf654f$var$_shouldStopPropagation);
150
- }
151
- constructor(type, pointerType, originalEvent){
152
- (0, $bx7SL$_1)(this, $f6c31cce2adf654f$var$_shouldStopPropagation, {
153
- writable: true,
154
- value: void 0
155
- });
156
- (0, $bx7SL$_2)(this, $f6c31cce2adf654f$var$_shouldStopPropagation, true);
157
- this.type = type;
158
- this.pointerType = pointerType;
159
- this.target = originalEvent.currentTarget;
160
- this.shiftKey = originalEvent.shiftKey;
161
- this.metaKey = originalEvent.metaKey;
162
- this.ctrlKey = originalEvent.ctrlKey;
163
- this.altKey = originalEvent.altKey;
164
- }
165
- }
166
- const $f6c31cce2adf654f$var$LINK_CLICKED = Symbol("linkClicked");
167
- function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
168
- let { onPress: onPress, onPressChange: onPressChange, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, isDisabled: isDisabled, isPressed: isPressedProp, preventFocusOnPress: preventFocusOnPress, shouldCancelOnPointerExit: shouldCancelOnPointerExit, allowTextSelectionOnPress: allowTextSelectionOnPress, // eslint-disable-next-line @typescript-eslint/no-unused-vars
169
- ref: _, ...domProps } = $f6c31cce2adf654f$var$usePressResponderContext(props);
170
- let [isPressed, setPressed] = (0, $bx7SL$useState)(false);
171
- let ref = (0, $bx7SL$useRef)({
172
- isPressed: false,
173
- ignoreEmulatedMouseEvents: false,
174
- ignoreClickAfterPress: false,
175
- didFirePressStart: false,
176
- isTriggeringEvent: false,
177
- activePointerId: null,
178
- target: null,
179
- isOverTarget: false,
180
- pointerType: null
181
- });
182
- let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $bx7SL$useGlobalListeners)();
183
- let triggerPressStart = (0, $bx7SL$useEffectEvent)((originalEvent, pointerType)=>{
184
- let state = ref.current;
185
- if (isDisabled || state.didFirePressStart) return false;
186
- let shouldStopPropagation = true;
187
- state.isTriggeringEvent = true;
188
- if (onPressStart) {
189
- let event = new $f6c31cce2adf654f$var$PressEvent("pressstart", pointerType, originalEvent);
190
- onPressStart(event);
191
- shouldStopPropagation = event.shouldStopPropagation;
192
- }
193
- if (onPressChange) onPressChange(true);
194
- state.isTriggeringEvent = false;
195
- state.didFirePressStart = true;
196
- setPressed(true);
197
- return shouldStopPropagation;
198
- });
199
- let triggerPressEnd = (0, $bx7SL$useEffectEvent)((originalEvent, pointerType, wasPressed = true)=>{
200
- let state = ref.current;
201
- if (!state.didFirePressStart) return false;
202
- state.ignoreClickAfterPress = true;
203
- state.didFirePressStart = false;
204
- state.isTriggeringEvent = true;
205
- let shouldStopPropagation = true;
206
- if (onPressEnd) {
207
- let event = new $f6c31cce2adf654f$var$PressEvent("pressend", pointerType, originalEvent);
208
- onPressEnd(event);
209
- shouldStopPropagation = event.shouldStopPropagation;
210
- }
211
- if (onPressChange) onPressChange(false);
212
- setPressed(false);
213
- if (onPress && wasPressed && !isDisabled) {
214
- let event = new $f6c31cce2adf654f$var$PressEvent("press", pointerType, originalEvent);
215
- onPress(event);
216
- shouldStopPropagation && (shouldStopPropagation = event.shouldStopPropagation);
217
- }
218
- state.isTriggeringEvent = false;
219
- return shouldStopPropagation;
220
- });
221
- let triggerPressUp = (0, $bx7SL$useEffectEvent)((originalEvent, pointerType)=>{
222
- let state = ref.current;
223
- if (isDisabled) return false;
224
- if (onPressUp) {
225
- state.isTriggeringEvent = true;
226
- let event = new $f6c31cce2adf654f$var$PressEvent("pressup", pointerType, originalEvent);
227
- onPressUp(event);
228
- state.isTriggeringEvent = false;
229
- return event.shouldStopPropagation;
230
- }
231
- return true;
232
- });
233
- let cancel = (0, $bx7SL$useEffectEvent)((e)=>{
234
- let state = ref.current;
235
- if (state.isPressed && state.target) {
236
- if (state.isOverTarget && state.pointerType != null) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
237
- state.isPressed = false;
238
- state.isOverTarget = false;
239
- state.activePointerId = null;
240
- state.pointerType = null;
241
- removeAllGlobalListeners();
242
- if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(state.target);
243
- }
244
- });
245
- let cancelOnPointerExit = (0, $bx7SL$useEffectEvent)((e)=>{
246
- if (shouldCancelOnPointerExit) cancel(e);
247
- });
248
- let pressProps = (0, $bx7SL$useMemo)(()=>{
249
- let state = ref.current;
250
- let pressProps = {
251
- onKeyDown (e) {
252
- if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.contains(e.target)) {
253
- var _state_metaKeyEvents;
254
- if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
255
- // If the event is repeating, it may have started on a different element
256
- // after which focus moved to the current element. Ignore these events and
257
- // only handle the first key down event.
258
- let shouldStopPropagation = true;
259
- if (!state.isPressed && !e.repeat) {
260
- state.target = e.currentTarget;
261
- state.isPressed = true;
262
- shouldStopPropagation = triggerPressStart(e, "keyboard");
263
- // Focus may move before the key up event, so register the event on the document
264
- // instead of the same element where the key down event occurred. Make it capturing so that it will trigger
265
- // before stopPropagation from useKeyboard on a child element may happen and thus we can still call triggerPress for the parent element.
266
- let originalTarget = e.currentTarget;
267
- let pressUp = (e)=>{
268
- if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e, originalTarget) && !e.repeat && originalTarget.contains(e.target) && state.target) triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e), "keyboard");
269
- };
270
- addGlobalListener((0, $bx7SL$getOwnerDocument)(e.currentTarget), "keyup", (0, $bx7SL$chain)(pressUp, onKeyUp), true);
271
- }
272
- if (shouldStopPropagation) e.stopPropagation();
273
- // Keep track of the keydown events that occur while the Meta (e.g. Command) key is held.
274
- // macOS has a bug where keyup events are not fired while the Meta key is down.
275
- // When the Meta key itself is released we will get an event for that, and we'll act as if
276
- // all of these other keys were released as well.
277
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1393524
278
- // https://bugs.webkit.org/show_bug.cgi?id=55291
279
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1299553
280
- if (e.metaKey && (0, $bx7SL$isMac)()) (_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 ? void 0 : _state_metaKeyEvents.set(e.key, e.nativeEvent);
281
- } else if (e.key === "Meta") state.metaKeyEvents = new Map();
282
- },
283
- onClick (e) {
284
- if (e && !e.currentTarget.contains(e.target)) return;
285
- if (e && e.button === 0 && !state.isTriggeringEvent && !(0, $bx7SL$openLink).isOpening) {
286
- let shouldStopPropagation = true;
287
- if (isDisabled) e.preventDefault();
288
- // If triggered from a screen reader or by using element.click(),
289
- // trigger as if it were a keyboard click.
290
- if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType === "virtual" || (0, $bx7SL$isVirtualClick)(e.nativeEvent))) {
291
- // Ensure the element receives focus (VoiceOver on iOS does not do this)
292
- if (!isDisabled && !preventFocusOnPress) (0, $bx7SL$focusWithoutScrolling)(e.currentTarget);
293
- let stopPressStart = triggerPressStart(e, "virtual");
294
- let stopPressUp = triggerPressUp(e, "virtual");
295
- let stopPressEnd = triggerPressEnd(e, "virtual");
296
- shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;
297
- }
298
- state.ignoreEmulatedMouseEvents = false;
299
- state.ignoreClickAfterPress = false;
300
- if (shouldStopPropagation) e.stopPropagation();
301
- }
302
- }
303
- };
304
- let onKeyUp = (e)=>{
305
- var _state_metaKeyEvents;
306
- if (state.isPressed && state.target && $f6c31cce2adf654f$var$isValidKeyboardEvent(e, state.target)) {
307
- var _state_metaKeyEvents1;
308
- if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
309
- let target = e.target;
310
- triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
311
- removeAllGlobalListeners();
312
- // If a link was triggered with a key other than Enter, open the URL ourselves.
313
- // This means the link has a role override, and the default browser behavior
314
- // only applies when using the Enter key.
315
- if (e.key !== "Enter" && $f6c31cce2adf654f$var$isHTMLAnchorLink(state.target) && state.target.contains(target) && !e[$f6c31cce2adf654f$var$LINK_CLICKED]) {
316
- // Store a hidden property on the event so we only trigger link click once,
317
- // even if there are multiple usePress instances attached to the element.
318
- e[$f6c31cce2adf654f$var$LINK_CLICKED] = true;
319
- (0, $bx7SL$openLink)(state.target, e, false);
320
- }
321
- state.isPressed = false;
322
- (_state_metaKeyEvents1 = state.metaKeyEvents) === null || _state_metaKeyEvents1 === void 0 ? void 0 : _state_metaKeyEvents1.delete(e.key);
323
- } else if (e.key === "Meta" && ((_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 ? void 0 : _state_metaKeyEvents.size)) {
324
- var _state_target;
325
- // If we recorded keydown events that occurred while the Meta key was pressed,
326
- // and those haven't received keyup events already, fire keyup events ourselves.
327
- // See comment above for more info about the macOS bug causing this.
328
- let events = state.metaKeyEvents;
329
- state.metaKeyEvents = undefined;
330
- for (let event of events.values())(_state_target = state.target) === null || _state_target === void 0 ? void 0 : _state_target.dispatchEvent(new KeyboardEvent("keyup", event));
331
- }
332
- };
333
- if (typeof PointerEvent !== "undefined") {
334
- pressProps.onPointerDown = (e)=>{
335
- // Only handle left clicks, and ignore events that bubbled through portals.
336
- if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
337
- // iOS safari fires pointer events from VoiceOver with incorrect coordinates/target.
338
- // Ignore and let the onClick handler take care of it instead.
339
- // https://bugs.webkit.org/show_bug.cgi?id=222627
340
- // https://bugs.webkit.org/show_bug.cgi?id=223202
341
- if ((0, $bx7SL$isVirtualPointerEvent)(e.nativeEvent)) {
342
- state.pointerType = "virtual";
343
- return;
344
- }
345
- // Due to browser inconsistencies, especially on mobile browsers, we prevent
346
- // default on pointer down and handle focusing the pressable element ourselves.
347
- if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
348
- state.pointerType = e.pointerType;
349
- let shouldStopPropagation = true;
350
- if (!state.isPressed) {
351
- state.isPressed = true;
352
- state.isOverTarget = true;
353
- state.activePointerId = e.pointerId;
354
- state.target = e.currentTarget;
355
- if (!isDisabled && !preventFocusOnPress) (0, $bx7SL$focusWithoutScrolling)(e.currentTarget);
356
- if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$16a4697467175487)(state.target);
357
- shouldStopPropagation = triggerPressStart(e, state.pointerType);
358
- addGlobalListener((0, $bx7SL$getOwnerDocument)(e.currentTarget), "pointermove", onPointerMove, false);
359
- addGlobalListener((0, $bx7SL$getOwnerDocument)(e.currentTarget), "pointerup", onPointerUp, false);
360
- addGlobalListener((0, $bx7SL$getOwnerDocument)(e.currentTarget), "pointercancel", onPointerCancel, false);
361
- }
362
- if (shouldStopPropagation) e.stopPropagation();
363
- };
364
- pressProps.onMouseDown = (e)=>{
365
- if (!e.currentTarget.contains(e.target)) return;
366
- if (e.button === 0) {
367
- // Chrome and Firefox on touch Windows devices require mouse down events
368
- // to be canceled in addition to pointer events, or an extra asynchronous
369
- // focus event will be fired.
370
- if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
371
- e.stopPropagation();
372
- }
373
- };
374
- pressProps.onPointerUp = (e)=>{
375
- // iOS fires pointerup with zero width and height, so check the pointerType recorded during pointerdown.
376
- if (!e.currentTarget.contains(e.target) || state.pointerType === "virtual") return;
377
- // Only handle left clicks
378
- // Safari on iOS sometimes fires pointerup events, even
379
- // when the touch isn't over the target, so double check.
380
- if (e.button === 0 && $f6c31cce2adf654f$var$isOverTarget(e, e.currentTarget)) triggerPressUp(e, state.pointerType || e.pointerType);
381
- };
382
- // Safari on iOS < 13.2 does not implement pointerenter/pointerleave events correctly.
383
- // Use pointer move events instead to implement our own hit testing.
384
- // See https://bugs.webkit.org/show_bug.cgi?id=199803
385
- let onPointerMove = (e)=>{
386
- if (e.pointerId !== state.activePointerId) return;
387
- if (state.target && $f6c31cce2adf654f$var$isOverTarget(e, state.target)) {
388
- if (!state.isOverTarget && state.pointerType != null) {
389
- state.isOverTarget = true;
390
- triggerPressStart($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
391
- }
392
- } else if (state.target && state.isOverTarget && state.pointerType != null) {
393
- state.isOverTarget = false;
394
- triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
395
- cancelOnPointerExit(e);
396
- }
397
- };
398
- let onPointerUp = (e)=>{
399
- if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0 && state.target) {
400
- if ($f6c31cce2adf654f$var$isOverTarget(e, state.target) && state.pointerType != null) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
401
- else if (state.isOverTarget && state.pointerType != null) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
402
- state.isPressed = false;
403
- state.isOverTarget = false;
404
- state.activePointerId = null;
405
- state.pointerType = null;
406
- removeAllGlobalListeners();
407
- if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(state.target);
408
- }
409
- };
410
- let onPointerCancel = (e)=>{
411
- cancel(e);
412
- };
413
- pressProps.onDragStart = (e)=>{
414
- if (!e.currentTarget.contains(e.target)) return;
415
- // Safari does not call onPointerCancel when a drag starts, whereas Chrome and Firefox do.
416
- cancel(e);
417
- };
418
- } else {
419
- pressProps.onMouseDown = (e)=>{
420
- // Only handle left clicks
421
- if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
422
- // Due to browser inconsistencies, especially on mobile browsers, we prevent
423
- // default on mouse down and handle focusing the pressable element ourselves.
424
- if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
425
- if (state.ignoreEmulatedMouseEvents) {
426
- e.stopPropagation();
427
- return;
428
- }
429
- state.isPressed = true;
430
- state.isOverTarget = true;
431
- state.target = e.currentTarget;
432
- state.pointerType = (0, $bx7SL$isVirtualClick)(e.nativeEvent) ? "virtual" : "mouse";
433
- if (!isDisabled && !preventFocusOnPress) (0, $bx7SL$focusWithoutScrolling)(e.currentTarget);
434
- let shouldStopPropagation = triggerPressStart(e, state.pointerType);
435
- if (shouldStopPropagation) e.stopPropagation();
436
- addGlobalListener((0, $bx7SL$getOwnerDocument)(e.currentTarget), "mouseup", onMouseUp, false);
437
- };
438
- pressProps.onMouseEnter = (e)=>{
439
- if (!e.currentTarget.contains(e.target)) return;
440
- let shouldStopPropagation = true;
441
- if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {
442
- state.isOverTarget = true;
443
- shouldStopPropagation = triggerPressStart(e, state.pointerType);
444
- }
445
- if (shouldStopPropagation) e.stopPropagation();
446
- };
447
- pressProps.onMouseLeave = (e)=>{
448
- if (!e.currentTarget.contains(e.target)) return;
449
- let shouldStopPropagation = true;
450
- if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {
451
- state.isOverTarget = false;
452
- shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
453
- cancelOnPointerExit(e);
454
- }
455
- if (shouldStopPropagation) e.stopPropagation();
456
- };
457
- pressProps.onMouseUp = (e)=>{
458
- if (!e.currentTarget.contains(e.target)) return;
459
- if (!state.ignoreEmulatedMouseEvents && e.button === 0) triggerPressUp(e, state.pointerType || "mouse");
460
- };
461
- let onMouseUp = (e)=>{
462
- // Only handle left clicks
463
- if (e.button !== 0) return;
464
- state.isPressed = false;
465
- removeAllGlobalListeners();
466
- if (state.ignoreEmulatedMouseEvents) {
467
- state.ignoreEmulatedMouseEvents = false;
468
- return;
469
- }
470
- if (state.target && $f6c31cce2adf654f$var$isOverTarget(e, state.target) && state.pointerType != null) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
471
- else if (state.target && state.isOverTarget && state.pointerType != null) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
472
- state.isOverTarget = false;
473
- };
474
- pressProps.onTouchStart = (e)=>{
475
- if (!e.currentTarget.contains(e.target)) return;
476
- let touch = $f6c31cce2adf654f$var$getTouchFromEvent(e.nativeEvent);
477
- if (!touch) return;
478
- state.activePointerId = touch.identifier;
479
- state.ignoreEmulatedMouseEvents = true;
480
- state.isOverTarget = true;
481
- state.isPressed = true;
482
- state.target = e.currentTarget;
483
- state.pointerType = "touch";
484
- // Due to browser inconsistencies, especially on mobile browsers, we prevent default
485
- // on the emulated mouse event and handle focusing the pressable element ourselves.
486
- if (!isDisabled && !preventFocusOnPress) (0, $bx7SL$focusWithoutScrolling)(e.currentTarget);
487
- if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$16a4697467175487)(state.target);
488
- let shouldStopPropagation = triggerPressStart(e, state.pointerType);
489
- if (shouldStopPropagation) e.stopPropagation();
490
- addGlobalListener((0, $bx7SL$getOwnerWindow)(e.currentTarget), "scroll", onScroll, true);
491
- };
492
- pressProps.onTouchMove = (e)=>{
493
- if (!e.currentTarget.contains(e.target)) return;
494
- if (!state.isPressed) {
495
- e.stopPropagation();
496
- return;
497
- }
498
- let touch = $f6c31cce2adf654f$var$getTouchById(e.nativeEvent, state.activePointerId);
499
- let shouldStopPropagation = true;
500
- if (touch && $f6c31cce2adf654f$var$isOverTarget(touch, e.currentTarget)) {
501
- if (!state.isOverTarget && state.pointerType != null) {
502
- state.isOverTarget = true;
503
- shouldStopPropagation = triggerPressStart(e, state.pointerType);
504
- }
505
- } else if (state.isOverTarget && state.pointerType != null) {
506
- state.isOverTarget = false;
507
- shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
508
- cancelOnPointerExit(e);
509
- }
510
- if (shouldStopPropagation) e.stopPropagation();
511
- };
512
- pressProps.onTouchEnd = (e)=>{
513
- if (!e.currentTarget.contains(e.target)) return;
514
- if (!state.isPressed) {
515
- e.stopPropagation();
516
- return;
517
- }
518
- let touch = $f6c31cce2adf654f$var$getTouchById(e.nativeEvent, state.activePointerId);
519
- let shouldStopPropagation = true;
520
- if (touch && $f6c31cce2adf654f$var$isOverTarget(touch, e.currentTarget) && state.pointerType != null) {
521
- triggerPressUp(e, state.pointerType);
522
- shouldStopPropagation = triggerPressEnd(e, state.pointerType);
523
- } else if (state.isOverTarget && state.pointerType != null) shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
524
- if (shouldStopPropagation) e.stopPropagation();
525
- state.isPressed = false;
526
- state.activePointerId = null;
527
- state.isOverTarget = false;
528
- state.ignoreEmulatedMouseEvents = true;
529
- if (state.target && !allowTextSelectionOnPress) (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(state.target);
530
- removeAllGlobalListeners();
531
- };
532
- pressProps.onTouchCancel = (e)=>{
533
- if (!e.currentTarget.contains(e.target)) return;
534
- e.stopPropagation();
535
- if (state.isPressed) cancel(e);
536
- };
537
- let onScroll = (e)=>{
538
- if (state.isPressed && e.target.contains(state.target)) cancel({
539
- currentTarget: state.target,
540
- shiftKey: false,
541
- ctrlKey: false,
542
- metaKey: false,
543
- altKey: false
544
- });
545
- };
546
- pressProps.onDragStart = (e)=>{
547
- if (!e.currentTarget.contains(e.target)) return;
548
- cancel(e);
549
- };
550
- }
551
- return pressProps;
552
- }, [
553
- addGlobalListener,
554
- isDisabled,
555
- preventFocusOnPress,
556
- removeAllGlobalListeners,
557
- allowTextSelectionOnPress,
558
- cancel,
559
- cancelOnPointerExit,
560
- triggerPressEnd,
561
- triggerPressStart,
562
- triggerPressUp
563
- ]);
564
- // Remove user-select: none in case component unmounts immediately after pressStart
565
- // eslint-disable-next-line arrow-body-style
566
- (0, $bx7SL$useEffect)(()=>{
567
- return ()=>{
568
- var _ref_current_target;
569
- if (!allowTextSelectionOnPress) // eslint-disable-next-line react-hooks/exhaustive-deps
570
- (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)((_ref_current_target = ref.current.target) !== null && _ref_current_target !== void 0 ? _ref_current_target : undefined);
571
- };
572
- }, [
573
- allowTextSelectionOnPress
574
- ]);
575
- return {
576
- isPressed: isPressedProp || isPressed,
577
- pressProps: (0, $bx7SL$mergeProps)(domProps, pressProps)
578
- };
579
- }
580
- function $f6c31cce2adf654f$var$isHTMLAnchorLink(target) {
581
- return target.tagName === "A" && target.hasAttribute("href");
582
- }
583
- function $f6c31cce2adf654f$var$isValidKeyboardEvent(event, currentTarget) {
584
- const { key: key, code: code } = event;
585
- const element = currentTarget;
586
- const role = element.getAttribute("role");
587
- // Accessibility for keyboards. Space and Enter only.
588
- // "Spacebar" is for IE 11
589
- return (key === "Enter" || key === " " || key === "Spacebar" || code === "Space") && !(element instanceof (0, $bx7SL$getOwnerWindow)(element).HTMLInputElement && !$f6c31cce2adf654f$var$isValidInputKey(element, key) || element instanceof (0, $bx7SL$getOwnerWindow)(element).HTMLTextAreaElement || element.isContentEditable) && // Links should only trigger with Enter key
590
- !((role === "link" || !role && $f6c31cce2adf654f$var$isHTMLAnchorLink(element)) && key !== "Enter");
591
- }
592
- function $f6c31cce2adf654f$var$getTouchFromEvent(event) {
593
- const { targetTouches: targetTouches } = event;
594
- if (targetTouches.length > 0) return targetTouches[0];
595
- return null;
596
- }
597
- function $f6c31cce2adf654f$var$getTouchById(event, pointerId) {
598
- const changedTouches = event.changedTouches;
599
- for(let i = 0; i < changedTouches.length; i++){
600
- const touch = changedTouches[i];
601
- if (touch.identifier === pointerId) return touch;
602
- }
603
- return null;
604
- }
605
- function $f6c31cce2adf654f$var$createEvent(target, e) {
606
- return {
607
- currentTarget: target,
608
- shiftKey: e.shiftKey,
609
- ctrlKey: e.ctrlKey,
610
- metaKey: e.metaKey,
611
- altKey: e.altKey
612
- };
613
- }
614
- function $f6c31cce2adf654f$var$getPointClientRect(point) {
615
- let offsetX = 0;
616
- let offsetY = 0;
617
- if (point.width !== undefined) offsetX = point.width / 2;
618
- else if (point.radiusX !== undefined) offsetX = point.radiusX;
619
- if (point.height !== undefined) offsetY = point.height / 2;
620
- else if (point.radiusY !== undefined) offsetY = point.radiusY;
621
- return {
622
- top: point.clientY - offsetY,
623
- right: point.clientX + offsetX,
624
- bottom: point.clientY + offsetY,
625
- left: point.clientX - offsetX
626
- };
627
- }
628
- function $f6c31cce2adf654f$var$areRectanglesOverlapping(a, b) {
629
- // check if they cannot overlap on x axis
630
- if (a.left > b.right || b.left > a.right) return false;
631
- // check if they cannot overlap on y axis
632
- if (a.top > b.bottom || b.top > a.bottom) return false;
633
- return true;
634
- }
635
- function $f6c31cce2adf654f$var$isOverTarget(point, target) {
636
- let rect = target.getBoundingClientRect();
637
- let pointRect = $f6c31cce2adf654f$var$getPointClientRect(point);
638
- return $f6c31cce2adf654f$var$areRectanglesOverlapping(rect, pointRect);
639
- }
640
- function $f6c31cce2adf654f$var$shouldPreventDefault(target) {
641
- // We cannot prevent default if the target is a draggable element.
642
- return !(target instanceof HTMLElement) || !target.hasAttribute("draggable");
643
- }
644
- function $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(target, key) {
645
- if (target instanceof HTMLInputElement) return !$f6c31cce2adf654f$var$isValidInputKey(target, key);
646
- if (target instanceof HTMLButtonElement) return target.type !== "submit" && target.type !== "reset";
647
- if ($f6c31cce2adf654f$var$isHTMLAnchorLink(target)) return false;
648
- return true;
649
- }
650
- const $f6c31cce2adf654f$var$nonTextInputTypes = new Set([
651
- "checkbox",
652
- "radio",
653
- "range",
654
- "color",
655
- "file",
656
- "image",
657
- "button",
658
- "submit",
659
- "reset"
660
- ]);
661
- function $f6c31cce2adf654f$var$isValidInputKey(target, key) {
662
- // Only space should toggle checkboxes and radios, not enter.
663
- return target.type === "checkbox" || target.type === "radio" ? key === " " : $f6c31cce2adf654f$var$nonTextInputTypes.has(target.type);
664
- }
665
-
666
-
667
-
668
- const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ (0, $bx7SL$react).forwardRef(({ children: children, ...props }, ref)=>{
669
- ref = (0, $bx7SL$useObjectRef)(ref);
670
- let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
671
- ...props,
672
- ref: ref
673
- });
674
- let child = (0, $bx7SL$react).Children.only(children);
675
- return /*#__PURE__*/ (0, $bx7SL$react).cloneElement(child, // @ts-ignore
676
- {
677
- ref: ref,
678
- ...(0, $bx7SL$mergeProps)(child.props, pressProps)
679
- });
680
- });
681
25
 
682
26
 
683
- /*
684
- * Copyright 2020 Adobe. All rights reserved.
685
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
686
- * you may not use this file except in compliance with the License. You may obtain a copy
687
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
688
- *
689
- * Unless required by applicable law or agreed to in writing, software distributed under
690
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
691
- * OF ANY KIND, either express or implied. See the License for the specific language
692
- * governing permissions and limitations under the License.
693
- */
694
-
695
-
696
- const $f1ab8c75478c6f73$export$3351871ee4b288b8 = /*#__PURE__*/ (0, $bx7SL$react).forwardRef(({ children: children, ...props }, ref)=>{
697
- let isRegistered = (0, $bx7SL$useRef)(false);
698
- let prevContext = (0, $bx7SL$useContext)((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5));
699
- ref = (0, $bx7SL$useObjectRef)(ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref));
700
- let context = (0, $bx7SL$mergeProps)(prevContext || {}, {
701
- ...props,
702
- ref: ref,
703
- register () {
704
- isRegistered.current = true;
705
- if (prevContext) prevContext.register();
706
- }
707
- });
708
- (0, $bx7SL$useSyncRef)(prevContext, ref);
709
- (0, $bx7SL$useEffect)(()=>{
710
- if (!isRegistered.current) {
711
- console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component.");
712
- isRegistered.current = true; // only warn once in strict mode.
713
- }
714
- }, []);
715
- return /*#__PURE__*/ (0, $bx7SL$react).createElement((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5).Provider, {
716
- value: context
717
- }, children);
718
- });
719
- function $f1ab8c75478c6f73$export$cf75428e0b9ed1ea({ children: children }) {
720
- let context = (0, $bx7SL$useMemo)(()=>({
721
- register: ()=>{}
722
- }), []);
723
- return /*#__PURE__*/ (0, $bx7SL$react).createElement((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5).Provider, {
724
- value: context
725
- }, children);
726
- }
727
-
728
-
729
- /*
730
- * Copyright 2020 Adobe. All rights reserved.
731
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
732
- * you may not use this file except in compliance with the License. You may obtain a copy
733
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
734
- *
735
- * Unless required by applicable law or agreed to in writing, software distributed under
736
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
737
- * OF ANY KIND, either express or implied. See the License for the specific language
738
- * governing permissions and limitations under the License.
739
- */ // Portions of the code in this file are based on code from react.
740
- // Original licensing for the following can be found in the
741
- // NOTICE file in the root directory of this source tree.
742
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
743
-
744
- /*
745
- * Copyright 2020 Adobe. All rights reserved.
746
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
747
- * you may not use this file except in compliance with the License. You may obtain a copy
748
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
749
- *
750
- * Unless required by applicable law or agreed to in writing, software distributed under
751
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
752
- * OF ANY KIND, either express or implied. See the License for the specific language
753
- * governing permissions and limitations under the License.
754
- */
755
-
756
- class $8a9cb279dc87e130$export$905e7fc544a71f36 {
757
- isDefaultPrevented() {
758
- return this.nativeEvent.defaultPrevented;
759
- }
760
- preventDefault() {
761
- this.defaultPrevented = true;
762
- this.nativeEvent.preventDefault();
763
- }
764
- stopPropagation() {
765
- this.nativeEvent.stopPropagation();
766
- this.isPropagationStopped = ()=>true;
767
- }
768
- isPropagationStopped() {
769
- return false;
770
- }
771
- persist() {}
772
- constructor(type, nativeEvent){
773
- this.nativeEvent = nativeEvent;
774
- this.target = nativeEvent.target;
775
- this.currentTarget = nativeEvent.currentTarget;
776
- this.relatedTarget = nativeEvent.relatedTarget;
777
- this.bubbles = nativeEvent.bubbles;
778
- this.cancelable = nativeEvent.cancelable;
779
- this.defaultPrevented = nativeEvent.defaultPrevented;
780
- this.eventPhase = nativeEvent.eventPhase;
781
- this.isTrusted = nativeEvent.isTrusted;
782
- this.timeStamp = nativeEvent.timeStamp;
783
- this.type = type;
784
- }
785
- }
786
- function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
787
- let stateRef = (0, $bx7SL$useRef)({
788
- isFocused: false,
789
- observer: null
790
- });
791
- // Clean up MutationObserver on unmount. See below.
792
- // eslint-disable-next-line arrow-body-style
793
- (0, $bx7SL$useLayoutEffect)(()=>{
794
- const state = stateRef.current;
795
- return ()=>{
796
- if (state.observer) {
797
- state.observer.disconnect();
798
- state.observer = null;
799
- }
800
- };
801
- }, []);
802
- let dispatchBlur = (0, $bx7SL$useEffectEvent)((e)=>{
803
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
804
- });
805
- // This function is called during a React onFocus event.
806
- return (0, $bx7SL$useCallback)((e)=>{
807
- // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
808
- // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
809
- // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
810
- // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
811
- if (e.target instanceof HTMLButtonElement || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement) {
812
- stateRef.current.isFocused = true;
813
- let target = e.target;
814
- let onBlurHandler = (e)=>{
815
- stateRef.current.isFocused = false;
816
- if (target.disabled) // For backward compatibility, dispatch a (fake) React synthetic event.
817
- dispatchBlur(new $8a9cb279dc87e130$export$905e7fc544a71f36("blur", e));
818
- // We no longer need the MutationObserver once the target is blurred.
819
- if (stateRef.current.observer) {
820
- stateRef.current.observer.disconnect();
821
- stateRef.current.observer = null;
822
- }
823
- };
824
- target.addEventListener("focusout", onBlurHandler, {
825
- once: true
826
- });
827
- stateRef.current.observer = new MutationObserver(()=>{
828
- if (stateRef.current.isFocused && target.disabled) {
829
- var _stateRef_current_observer;
830
- (_stateRef_current_observer = stateRef.current.observer) === null || _stateRef_current_observer === void 0 ? void 0 : _stateRef_current_observer.disconnect();
831
- let relatedTargetEl = target === document.activeElement ? null : document.activeElement;
832
- target.dispatchEvent(new FocusEvent("blur", {
833
- relatedTarget: relatedTargetEl
834
- }));
835
- target.dispatchEvent(new FocusEvent("focusout", {
836
- bubbles: true,
837
- relatedTarget: relatedTargetEl
838
- }));
839
- }
840
- });
841
- stateRef.current.observer.observe(target, {
842
- attributes: true,
843
- attributeFilter: [
844
- "disabled"
845
- ]
846
- });
847
- }
848
- }, [
849
- dispatchBlur
850
- ]);
851
- }
852
-
853
-
854
- function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
855
- let { isDisabled: isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange: onFocusChange } = props;
856
- const onBlur = (0, $bx7SL$useCallback)((e)=>{
857
- if (e.target === e.currentTarget) {
858
- if (onBlurProp) onBlurProp(e);
859
- if (onFocusChange) onFocusChange(false);
860
- return true;
861
- }
862
- }, [
863
- onBlurProp,
864
- onFocusChange
865
- ]);
866
- const onSyntheticFocus = (0, $8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
867
- const onFocus = (0, $bx7SL$useCallback)((e)=>{
868
- // Double check that document.activeElement actually matches e.target in case a previously chained
869
- // focus handler already moved focus somewhere else.
870
- if (e.target === e.currentTarget && document.activeElement === e.target) {
871
- if (onFocusProp) onFocusProp(e);
872
- if (onFocusChange) onFocusChange(true);
873
- onSyntheticFocus(e);
874
- }
875
- }, [
876
- onFocusChange,
877
- onFocusProp,
878
- onSyntheticFocus
879
- ]);
880
- return {
881
- focusProps: {
882
- onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
883
- onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
884
- }
885
- };
886
- }
887
-
888
-
889
- /*
890
- * Copyright 2020 Adobe. All rights reserved.
891
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
892
- * you may not use this file except in compliance with the License. You may obtain a copy
893
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
894
- *
895
- * Unless required by applicable law or agreed to in writing, software distributed under
896
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
897
- * OF ANY KIND, either express or implied. See the License for the specific language
898
- * governing permissions and limitations under the License.
899
- */ // Portions of the code in this file are based on code from react.
900
- // Original licensing for the following can be found in the
901
- // NOTICE file in the root directory of this source tree.
902
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
903
27
 
904
28
 
905
29
 
906
- let $507fabe10e71c6fb$var$currentModality = null;
907
- let $507fabe10e71c6fb$var$changeHandlers = new Set();
908
- let $507fabe10e71c6fb$export$d90243b58daecda7 = new Map(); // We use a map here to support setting event listeners across multiple document objects.
909
- let $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
910
- let $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
911
- // Only Tab or Esc keys will make focus visible on text input elements
912
- const $507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS = {
913
- Tab: true,
914
- Escape: true
915
- };
916
- function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
917
- for (let handler of $507fabe10e71c6fb$var$changeHandlers)handler(modality, e);
918
- }
919
- /**
920
- * Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
921
- */ function $507fabe10e71c6fb$var$isValidKey(e) {
922
- // Control and Shift keys trigger when navigating back to the tab with keyboard.
923
- return !(e.metaKey || !(0, $bx7SL$isMac)() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
924
- }
925
- function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
926
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
927
- if ($507fabe10e71c6fb$var$isValidKey(e)) {
928
- $507fabe10e71c6fb$var$currentModality = "keyboard";
929
- $507fabe10e71c6fb$var$triggerChangeHandlers("keyboard", e);
930
- }
931
- }
932
- function $507fabe10e71c6fb$var$handlePointerEvent(e) {
933
- $507fabe10e71c6fb$var$currentModality = "pointer";
934
- if (e.type === "mousedown" || e.type === "pointerdown") {
935
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
936
- $507fabe10e71c6fb$var$triggerChangeHandlers("pointer", e);
937
- }
938
- }
939
- function $507fabe10e71c6fb$var$handleClickEvent(e) {
940
- if ((0, $bx7SL$isVirtualClick)(e)) {
941
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
942
- $507fabe10e71c6fb$var$currentModality = "virtual";
943
- }
944
- }
945
- function $507fabe10e71c6fb$var$handleFocusEvent(e) {
946
- // Firefox fires two extra focus events when the user first clicks into an iframe:
947
- // first on the window, then on the document. We ignore these events so they don't
948
- // cause keyboard focus rings to appear.
949
- if (e.target === window || e.target === document) return;
950
- // If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
951
- // This occurs, for example, when navigating a form with the next/previous buttons on iOS.
952
- if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
953
- $507fabe10e71c6fb$var$currentModality = "virtual";
954
- $507fabe10e71c6fb$var$triggerChangeHandlers("virtual", e);
955
- }
956
- $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
957
- $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
958
- }
959
- function $507fabe10e71c6fb$var$handleWindowBlur() {
960
- // When the window is blurred, reset state. This is necessary when tabbing out of the window,
961
- // for example, since a subsequent focus event won't be fired.
962
- $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
963
- $507fabe10e71c6fb$var$hasBlurredWindowRecently = true;
964
- }
965
- /**
966
- * Setup global event listeners to control when keyboard focus style should be visible.
967
- */ function $507fabe10e71c6fb$var$setupGlobalFocusEvents(element) {
968
- if (typeof window === "undefined" || $507fabe10e71c6fb$export$d90243b58daecda7.get((0, $bx7SL$getOwnerWindow)(element))) return;
969
- const windowObject = (0, $bx7SL$getOwnerWindow)(element);
970
- const documentObject = (0, $bx7SL$getOwnerDocument)(element);
971
- // Programmatic focus() calls shouldn't affect the current input modality.
972
- // However, we need to detect other cases when a focus event occurs without
973
- // a preceding user event (e.g. screen reader focus). Overriding the focus
974
- // method on HTMLElement.prototype is a bit hacky, but works.
975
- let focus = windowObject.HTMLElement.prototype.focus;
976
- windowObject.HTMLElement.prototype.focus = function() {
977
- $507fabe10e71c6fb$var$hasEventBeforeFocus = true;
978
- focus.apply(this, arguments);
979
- };
980
- documentObject.addEventListener("keydown", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
981
- documentObject.addEventListener("keyup", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
982
- documentObject.addEventListener("click", $507fabe10e71c6fb$var$handleClickEvent, true);
983
- // Register focus events on the window so they are sure to happen
984
- // before React's event listeners (registered on the document).
985
- windowObject.addEventListener("focus", $507fabe10e71c6fb$var$handleFocusEvent, true);
986
- windowObject.addEventListener("blur", $507fabe10e71c6fb$var$handleWindowBlur, false);
987
- if (typeof PointerEvent !== "undefined") {
988
- documentObject.addEventListener("pointerdown", $507fabe10e71c6fb$var$handlePointerEvent, true);
989
- documentObject.addEventListener("pointermove", $507fabe10e71c6fb$var$handlePointerEvent, true);
990
- documentObject.addEventListener("pointerup", $507fabe10e71c6fb$var$handlePointerEvent, true);
991
- } else {
992
- documentObject.addEventListener("mousedown", $507fabe10e71c6fb$var$handlePointerEvent, true);
993
- documentObject.addEventListener("mousemove", $507fabe10e71c6fb$var$handlePointerEvent, true);
994
- documentObject.addEventListener("mouseup", $507fabe10e71c6fb$var$handlePointerEvent, true);
995
- }
996
- // Add unmount handler
997
- windowObject.addEventListener("beforeunload", ()=>{
998
- $507fabe10e71c6fb$var$tearDownWindowFocusTracking(element);
999
- }, {
1000
- once: true
1001
- });
1002
- $507fabe10e71c6fb$export$d90243b58daecda7.set(windowObject, {
1003
- focus: focus
1004
- });
1005
- }
1006
- const $507fabe10e71c6fb$var$tearDownWindowFocusTracking = (element, loadListener)=>{
1007
- const windowObject = (0, $bx7SL$getOwnerWindow)(element);
1008
- const documentObject = (0, $bx7SL$getOwnerDocument)(element);
1009
- if (loadListener) documentObject.removeEventListener("DOMContentLoaded", loadListener);
1010
- if (!$507fabe10e71c6fb$export$d90243b58daecda7.has(windowObject)) return;
1011
- windowObject.HTMLElement.prototype.focus = $507fabe10e71c6fb$export$d90243b58daecda7.get(windowObject).focus;
1012
- documentObject.removeEventListener("keydown", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
1013
- documentObject.removeEventListener("keyup", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
1014
- documentObject.removeEventListener("click", $507fabe10e71c6fb$var$handleClickEvent, true);
1015
- windowObject.removeEventListener("focus", $507fabe10e71c6fb$var$handleFocusEvent, true);
1016
- windowObject.removeEventListener("blur", $507fabe10e71c6fb$var$handleWindowBlur, false);
1017
- if (typeof PointerEvent !== "undefined") {
1018
- documentObject.removeEventListener("pointerdown", $507fabe10e71c6fb$var$handlePointerEvent, true);
1019
- documentObject.removeEventListener("pointermove", $507fabe10e71c6fb$var$handlePointerEvent, true);
1020
- documentObject.removeEventListener("pointerup", $507fabe10e71c6fb$var$handlePointerEvent, true);
1021
- } else {
1022
- documentObject.removeEventListener("mousedown", $507fabe10e71c6fb$var$handlePointerEvent, true);
1023
- documentObject.removeEventListener("mousemove", $507fabe10e71c6fb$var$handlePointerEvent, true);
1024
- documentObject.removeEventListener("mouseup", $507fabe10e71c6fb$var$handlePointerEvent, true);
1025
- }
1026
- $507fabe10e71c6fb$export$d90243b58daecda7.delete(windowObject);
1027
- };
1028
- function $507fabe10e71c6fb$export$2f1888112f558a7d(element) {
1029
- const documentObject = (0, $bx7SL$getOwnerDocument)(element);
1030
- let loadListener;
1031
- if (documentObject.readyState !== "loading") $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
1032
- else {
1033
- loadListener = ()=>{
1034
- $507fabe10e71c6fb$var$setupGlobalFocusEvents(element);
1035
- };
1036
- documentObject.addEventListener("DOMContentLoaded", loadListener);
1037
- }
1038
- return ()=>$507fabe10e71c6fb$var$tearDownWindowFocusTracking(element, loadListener);
1039
- }
1040
- // Server-side rendering does not have the document object defined
1041
- // eslint-disable-next-line no-restricted-globals
1042
- if (typeof document !== "undefined") $507fabe10e71c6fb$export$2f1888112f558a7d();
1043
- function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
1044
- return $507fabe10e71c6fb$var$currentModality !== "pointer";
1045
- }
1046
- function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
1047
- return $507fabe10e71c6fb$var$currentModality;
1048
- }
1049
- function $507fabe10e71c6fb$export$8397ddfc504fdb9a(modality) {
1050
- $507fabe10e71c6fb$var$currentModality = modality;
1051
- $507fabe10e71c6fb$var$triggerChangeHandlers(modality, null);
1052
- }
1053
- function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
1054
- $507fabe10e71c6fb$var$setupGlobalFocusEvents();
1055
- let [modality, setModality] = (0, $bx7SL$useState)($507fabe10e71c6fb$var$currentModality);
1056
- (0, $bx7SL$useEffect)(()=>{
1057
- let handler = ()=>{
1058
- setModality($507fabe10e71c6fb$var$currentModality);
1059
- };
1060
- $507fabe10e71c6fb$var$changeHandlers.add(handler);
1061
- return ()=>{
1062
- $507fabe10e71c6fb$var$changeHandlers.delete(handler);
1063
- };
1064
- }, []);
1065
- return (0, $bx7SL$useIsSSR)() ? null : modality;
1066
- }
1067
- const $507fabe10e71c6fb$var$nonTextInputTypes = new Set([
1068
- "checkbox",
1069
- "radio",
1070
- "range",
1071
- "color",
1072
- "file",
1073
- "image",
1074
- "button",
1075
- "submit",
1076
- "reset"
1077
- ]);
1078
- /**
1079
- * If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
1080
- * focus visible style can be properly set.
1081
- */ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
1082
- var _e_target;
1083
- const IHTMLInputElement = typeof window !== "undefined" ? (0, $bx7SL$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLInputElement : HTMLInputElement;
1084
- const IHTMLTextAreaElement = typeof window !== "undefined" ? (0, $bx7SL$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLTextAreaElement : HTMLTextAreaElement;
1085
- const IHTMLElement = typeof window !== "undefined" ? (0, $bx7SL$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).HTMLElement : HTMLElement;
1086
- const IKeyboardEvent = typeof window !== "undefined" ? (0, $bx7SL$getOwnerWindow)(e === null || e === void 0 ? void 0 : e.target).KeyboardEvent : KeyboardEvent;
1087
- isTextInput = isTextInput || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLInputElement && !$507fabe10e71c6fb$var$nonTextInputTypes.has(e === null || e === void 0 ? void 0 : (_e_target = e.target) === null || _e_target === void 0 ? void 0 : _e_target.type) || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLTextAreaElement || (e === null || e === void 0 ? void 0 : e.target) instanceof IHTMLElement && (e === null || e === void 0 ? void 0 : e.target.isContentEditable);
1088
- return !(isTextInput && modality === "keyboard" && e instanceof IKeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
1089
- }
1090
- function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {}) {
1091
- let { isTextInput: isTextInput, autoFocus: autoFocus } = props;
1092
- let [isFocusVisibleState, setFocusVisible] = (0, $bx7SL$useState)(autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27());
1093
- $507fabe10e71c6fb$export$ec71b4b83ac08ec3((isFocusVisible)=>{
1094
- setFocusVisible(isFocusVisible);
1095
- }, [
1096
- isTextInput
1097
- ], {
1098
- isTextInput: isTextInput
1099
- });
1100
- return {
1101
- isFocusVisible: isFocusVisibleState
1102
- };
1103
- }
1104
- function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
1105
- $507fabe10e71c6fb$var$setupGlobalFocusEvents();
1106
- (0, $bx7SL$useEffect)(()=>{
1107
- let handler = (modality, e)=>{
1108
- if (!$507fabe10e71c6fb$var$isKeyboardFocusEvent(!!(opts === null || opts === void 0 ? void 0 : opts.isTextInput), modality, e)) return;
1109
- fn($507fabe10e71c6fb$export$b9b3dfddab17db27());
1110
- };
1111
- $507fabe10e71c6fb$var$changeHandlers.add(handler);
1112
- return ()=>{
1113
- $507fabe10e71c6fb$var$changeHandlers.delete(handler);
1114
- };
1115
- // eslint-disable-next-line react-hooks/exhaustive-deps
1116
- }, deps);
1117
- }
1118
30
 
1119
31
 
1120
- /*
1121
- * Copyright 2020 Adobe. All rights reserved.
1122
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1123
- * you may not use this file except in compliance with the License. You may obtain a copy
1124
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1125
- *
1126
- * Unless required by applicable law or agreed to in writing, software distributed under
1127
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1128
- * OF ANY KIND, either express or implied. See the License for the specific language
1129
- * governing permissions and limitations under the License.
1130
- */ // Portions of the code in this file are based on code from react.
1131
- // Original licensing for the following can be found in the
1132
- // NOTICE file in the root directory of this source tree.
1133
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
1134
-
1135
-
1136
- function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
1137
- let { isDisabled: isDisabled, onBlurWithin: onBlurWithin, onFocusWithin: onFocusWithin, onFocusWithinChange: onFocusWithinChange } = props;
1138
- let state = (0, $bx7SL$useRef)({
1139
- isFocusWithin: false
1140
- });
1141
- let onBlur = (0, $bx7SL$useCallback)((e)=>{
1142
- // We don't want to trigger onBlurWithin and then immediately onFocusWithin again
1143
- // when moving focus inside the element. Only trigger if the currentTarget doesn't
1144
- // include the relatedTarget (where focus is moving).
1145
- if (state.current.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
1146
- state.current.isFocusWithin = false;
1147
- if (onBlurWithin) onBlurWithin(e);
1148
- if (onFocusWithinChange) onFocusWithinChange(false);
1149
- }
1150
- }, [
1151
- onBlurWithin,
1152
- onFocusWithinChange,
1153
- state
1154
- ]);
1155
- let onSyntheticFocus = (0, $8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
1156
- let onFocus = (0, $bx7SL$useCallback)((e)=>{
1157
- // Double check that document.activeElement actually matches e.target in case a previously chained
1158
- // focus handler already moved focus somewhere else.
1159
- if (!state.current.isFocusWithin && document.activeElement === e.target) {
1160
- if (onFocusWithin) onFocusWithin(e);
1161
- if (onFocusWithinChange) onFocusWithinChange(true);
1162
- state.current.isFocusWithin = true;
1163
- onSyntheticFocus(e);
1164
- }
1165
- }, [
1166
- onFocusWithin,
1167
- onFocusWithinChange,
1168
- onSyntheticFocus
1169
- ]);
1170
- if (isDisabled) return {
1171
- focusWithinProps: {
1172
- // These should not have been null, that would conflict in mergeProps
1173
- onFocus: undefined,
1174
- onBlur: undefined
1175
- }
1176
- };
1177
- return {
1178
- focusWithinProps: {
1179
- onFocus: onFocus,
1180
- onBlur: onBlur
1181
- }
1182
- };
1183
- }
1184
-
1185
-
1186
- /*
1187
- * Copyright 2020 Adobe. All rights reserved.
1188
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1189
- * you may not use this file except in compliance with the License. You may obtain a copy
1190
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1191
- *
1192
- * Unless required by applicable law or agreed to in writing, software distributed under
1193
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1194
- * OF ANY KIND, either express or implied. See the License for the specific language
1195
- * governing permissions and limitations under the License.
1196
- */ // Portions of the code in this file are based on code from react.
1197
- // Original licensing for the following can be found in the
1198
- // NOTICE file in the root directory of this source tree.
1199
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
1200
-
1201
- // iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
1202
- // We want to ignore these emulated events so they do not trigger hover behavior.
1203
- // See https://bugs.webkit.org/show_bug.cgi?id=214609.
1204
- let $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
1205
- let $6179b936705e76d3$var$hoverCount = 0;
1206
- function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
1207
- $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = true;
1208
- // Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter
1209
- // with pointerType="mouse" immediately after onPointerUp and before onFocus. On other
1210
- // devices that don't have this quirk, we don't want to ignore a mouse hover sometime in
1211
- // the distant future because a user previously touched the element.
1212
- setTimeout(()=>{
1213
- $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
1214
- }, 50);
1215
- }
1216
- function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
1217
- if (e.pointerType === "touch") $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
1218
- }
1219
- function $6179b936705e76d3$var$setupGlobalTouchEvents() {
1220
- if (typeof document === "undefined") return;
1221
- if (typeof PointerEvent !== "undefined") document.addEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
1222
- else document.addEventListener("touchend", $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
1223
- $6179b936705e76d3$var$hoverCount++;
1224
- return ()=>{
1225
- $6179b936705e76d3$var$hoverCount--;
1226
- if ($6179b936705e76d3$var$hoverCount > 0) return;
1227
- if (typeof PointerEvent !== "undefined") document.removeEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
1228
- else document.removeEventListener("touchend", $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
1229
- };
1230
- }
1231
- function $6179b936705e76d3$export$ae780daf29e6d456(props) {
1232
- let { onHoverStart: onHoverStart, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, isDisabled: isDisabled } = props;
1233
- let [isHovered, setHovered] = (0, $bx7SL$useState)(false);
1234
- let state = (0, $bx7SL$useRef)({
1235
- isHovered: false,
1236
- ignoreEmulatedMouseEvents: false,
1237
- pointerType: "",
1238
- target: null
1239
- }).current;
1240
- (0, $bx7SL$useEffect)($6179b936705e76d3$var$setupGlobalTouchEvents, []);
1241
- let { hoverProps: hoverProps, triggerHoverEnd: triggerHoverEnd } = (0, $bx7SL$useMemo)(()=>{
1242
- let triggerHoverStart = (event, pointerType)=>{
1243
- state.pointerType = pointerType;
1244
- if (isDisabled || pointerType === "touch" || state.isHovered || !event.currentTarget.contains(event.target)) return;
1245
- state.isHovered = true;
1246
- let target = event.currentTarget;
1247
- state.target = target;
1248
- if (onHoverStart) onHoverStart({
1249
- type: "hoverstart",
1250
- target: target,
1251
- pointerType: pointerType
1252
- });
1253
- if (onHoverChange) onHoverChange(true);
1254
- setHovered(true);
1255
- };
1256
- let triggerHoverEnd = (event, pointerType)=>{
1257
- state.pointerType = "";
1258
- state.target = null;
1259
- if (pointerType === "touch" || !state.isHovered) return;
1260
- state.isHovered = false;
1261
- let target = event.currentTarget;
1262
- if (onHoverEnd) onHoverEnd({
1263
- type: "hoverend",
1264
- target: target,
1265
- pointerType: pointerType
1266
- });
1267
- if (onHoverChange) onHoverChange(false);
1268
- setHovered(false);
1269
- };
1270
- let hoverProps = {};
1271
- if (typeof PointerEvent !== "undefined") {
1272
- hoverProps.onPointerEnter = (e)=>{
1273
- if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === "mouse") return;
1274
- triggerHoverStart(e, e.pointerType);
1275
- };
1276
- hoverProps.onPointerLeave = (e)=>{
1277
- if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, e.pointerType);
1278
- };
1279
- } else {
1280
- hoverProps.onTouchStart = ()=>{
1281
- state.ignoreEmulatedMouseEvents = true;
1282
- };
1283
- hoverProps.onMouseEnter = (e)=>{
1284
- if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, "mouse");
1285
- state.ignoreEmulatedMouseEvents = false;
1286
- };
1287
- hoverProps.onMouseLeave = (e)=>{
1288
- if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, "mouse");
1289
- };
1290
- }
1291
- return {
1292
- hoverProps: hoverProps,
1293
- triggerHoverEnd: triggerHoverEnd
1294
- };
1295
- }, [
1296
- onHoverStart,
1297
- onHoverChange,
1298
- onHoverEnd,
1299
- isDisabled,
1300
- state
1301
- ]);
1302
- (0, $bx7SL$useEffect)(()=>{
1303
- // Call the triggerHoverEnd as soon as isDisabled changes to true
1304
- // Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
1305
- if (isDisabled) triggerHoverEnd({
1306
- currentTarget: state.target
1307
- }, state.pointerType);
1308
- // eslint-disable-next-line react-hooks/exhaustive-deps
1309
- }, [
1310
- isDisabled
1311
- ]);
1312
- return {
1313
- hoverProps: hoverProps,
1314
- isHovered: isHovered
1315
- };
1316
- }
1317
-
1318
-
1319
- /*
1320
- * Copyright 2020 Adobe. All rights reserved.
1321
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1322
- * you may not use this file except in compliance with the License. You may obtain a copy
1323
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1324
- *
1325
- * Unless required by applicable law or agreed to in writing, software distributed under
1326
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1327
- * OF ANY KIND, either express or implied. See the License for the specific language
1328
- * governing permissions and limitations under the License.
1329
- */ // Portions of the code in this file are based on code from react.
1330
- // Original licensing for the following can be found in the
1331
- // NOTICE file in the root directory of this source tree.
1332
- // See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
1333
-
1334
-
1335
- function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
1336
- let { ref: ref, onInteractOutside: onInteractOutside, isDisabled: isDisabled, onInteractOutsideStart: onInteractOutsideStart } = props;
1337
- let stateRef = (0, $bx7SL$useRef)({
1338
- isPointerDown: false,
1339
- ignoreEmulatedMouseEvents: false
1340
- });
1341
- let onPointerDown = (0, $bx7SL$useEffectEvent)((e)=>{
1342
- if (onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
1343
- if (onInteractOutsideStart) onInteractOutsideStart(e);
1344
- stateRef.current.isPointerDown = true;
1345
- }
1346
- });
1347
- let triggerInteractOutside = (0, $bx7SL$useEffectEvent)((e)=>{
1348
- if (onInteractOutside) onInteractOutside(e);
1349
- });
1350
- (0, $bx7SL$useEffect)(()=>{
1351
- let state = stateRef.current;
1352
- if (isDisabled) return;
1353
- const element = ref.current;
1354
- const documentObject = (0, $bx7SL$getOwnerDocument)(element);
1355
- // Use pointer events if available. Otherwise, fall back to mouse and touch events.
1356
- if (typeof PointerEvent !== "undefined") {
1357
- let onPointerUp = (e)=>{
1358
- if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
1359
- state.isPointerDown = false;
1360
- };
1361
- // changing these to capture phase fixed combobox
1362
- documentObject.addEventListener("pointerdown", onPointerDown, true);
1363
- documentObject.addEventListener("pointerup", onPointerUp, true);
1364
- return ()=>{
1365
- documentObject.removeEventListener("pointerdown", onPointerDown, true);
1366
- documentObject.removeEventListener("pointerup", onPointerUp, true);
1367
- };
1368
- } else {
1369
- let onMouseUp = (e)=>{
1370
- if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
1371
- else if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
1372
- state.isPointerDown = false;
1373
- };
1374
- let onTouchEnd = (e)=>{
1375
- state.ignoreEmulatedMouseEvents = true;
1376
- if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
1377
- state.isPointerDown = false;
1378
- };
1379
- documentObject.addEventListener("mousedown", onPointerDown, true);
1380
- documentObject.addEventListener("mouseup", onMouseUp, true);
1381
- documentObject.addEventListener("touchstart", onPointerDown, true);
1382
- documentObject.addEventListener("touchend", onTouchEnd, true);
1383
- return ()=>{
1384
- documentObject.removeEventListener("mousedown", onPointerDown, true);
1385
- documentObject.removeEventListener("mouseup", onMouseUp, true);
1386
- documentObject.removeEventListener("touchstart", onPointerDown, true);
1387
- documentObject.removeEventListener("touchend", onTouchEnd, true);
1388
- };
1389
- }
1390
- }, [
1391
- ref,
1392
- isDisabled,
1393
- onPointerDown,
1394
- triggerInteractOutside
1395
- ]);
1396
- }
1397
- function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
1398
- if (event.button > 0) return false;
1399
- if (event.target) {
1400
- // if the event target is no longer in the document, ignore
1401
- const ownerDocument = event.target.ownerDocument;
1402
- if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
1403
- // If the target is within a top layer element (e.g. toasts), ignore.
1404
- if (event.target.closest("[data-react-aria-top-layer]")) return false;
1405
- }
1406
- return ref.current && !ref.current.contains(event.target);
1407
- }
1408
-
1409
-
1410
- /*
1411
- * Copyright 2020 Adobe. All rights reserved.
1412
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1413
- * you may not use this file except in compliance with the License. You may obtain a copy
1414
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1415
- *
1416
- * Unless required by applicable law or agreed to in writing, software distributed under
1417
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1418
- * OF ANY KIND, either express or implied. See the License for the specific language
1419
- * governing permissions and limitations under the License.
1420
- */ /*
1421
- * Copyright 2020 Adobe. All rights reserved.
1422
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1423
- * you may not use this file except in compliance with the License. You may obtain a copy
1424
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1425
- *
1426
- * Unless required by applicable law or agreed to in writing, software distributed under
1427
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1428
- * OF ANY KIND, either express or implied. See the License for the specific language
1429
- * governing permissions and limitations under the License.
1430
- */ function $93925083ecbb358c$export$48d1ea6320830260(handler) {
1431
- if (!handler) return undefined;
1432
- let shouldStopPropagation = true;
1433
- return (e)=>{
1434
- let event = {
1435
- ...e,
1436
- preventDefault () {
1437
- e.preventDefault();
1438
- },
1439
- isDefaultPrevented () {
1440
- return e.isDefaultPrevented();
1441
- },
1442
- stopPropagation () {
1443
- console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.");
1444
- },
1445
- continuePropagation () {
1446
- shouldStopPropagation = false;
1447
- }
1448
- };
1449
- handler(event);
1450
- if (shouldStopPropagation) e.stopPropagation();
1451
- };
1452
- }
1453
-
1454
-
1455
- function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
1456
- return {
1457
- keyboardProps: props.isDisabled ? {} : {
1458
- onKeyDown: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyDown),
1459
- onKeyUp: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyUp)
1460
- }
1461
- };
1462
- }
1463
-
1464
-
1465
- /*
1466
- * Copyright 2020 Adobe. All rights reserved.
1467
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1468
- * you may not use this file except in compliance with the License. You may obtain a copy
1469
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1470
- *
1471
- * Unless required by applicable law or agreed to in writing, software distributed under
1472
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1473
- * OF ANY KIND, either express or implied. See the License for the specific language
1474
- * governing permissions and limitations under the License.
1475
- */
1476
-
1477
-
1478
- function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
1479
- let { onMoveStart: onMoveStart, onMove: onMove, onMoveEnd: onMoveEnd } = props;
1480
- let state = (0, $bx7SL$useRef)({
1481
- didMove: false,
1482
- lastPosition: null,
1483
- id: null
1484
- });
1485
- let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $bx7SL$useGlobalListeners)();
1486
- let move = (0, $bx7SL$useEffectEvent)((originalEvent, pointerType, deltaX, deltaY)=>{
1487
- if (deltaX === 0 && deltaY === 0) return;
1488
- if (!state.current.didMove) {
1489
- state.current.didMove = true;
1490
- onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
1491
- type: "movestart",
1492
- pointerType: pointerType,
1493
- shiftKey: originalEvent.shiftKey,
1494
- metaKey: originalEvent.metaKey,
1495
- ctrlKey: originalEvent.ctrlKey,
1496
- altKey: originalEvent.altKey
1497
- });
1498
- }
1499
- onMove === null || onMove === void 0 ? void 0 : onMove({
1500
- type: "move",
1501
- pointerType: pointerType,
1502
- deltaX: deltaX,
1503
- deltaY: deltaY,
1504
- shiftKey: originalEvent.shiftKey,
1505
- metaKey: originalEvent.metaKey,
1506
- ctrlKey: originalEvent.ctrlKey,
1507
- altKey: originalEvent.altKey
1508
- });
1509
- });
1510
- let end = (0, $bx7SL$useEffectEvent)((originalEvent, pointerType)=>{
1511
- (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)();
1512
- if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
1513
- type: "moveend",
1514
- pointerType: pointerType,
1515
- shiftKey: originalEvent.shiftKey,
1516
- metaKey: originalEvent.metaKey,
1517
- ctrlKey: originalEvent.ctrlKey,
1518
- altKey: originalEvent.altKey
1519
- });
1520
- });
1521
- let moveProps = (0, $bx7SL$useMemo)(()=>{
1522
- let moveProps = {};
1523
- let start = ()=>{
1524
- (0, $14c0b72509d70225$export$16a4697467175487)();
1525
- state.current.didMove = false;
1526
- };
1527
- if (typeof PointerEvent === "undefined") {
1528
- let onMouseMove = (e)=>{
1529
- if (e.button === 0) {
1530
- var _state_current_lastPosition, _state_current_lastPosition1;
1531
- var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
1532
- move(e, "mouse", e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
1533
- state.current.lastPosition = {
1534
- pageX: e.pageX,
1535
- pageY: e.pageY
1536
- };
1537
- }
1538
- };
1539
- let onMouseUp = (e)=>{
1540
- if (e.button === 0) {
1541
- end(e, "mouse");
1542
- removeGlobalListener(window, "mousemove", onMouseMove, false);
1543
- removeGlobalListener(window, "mouseup", onMouseUp, false);
1544
- }
1545
- };
1546
- moveProps.onMouseDown = (e)=>{
1547
- if (e.button === 0) {
1548
- start();
1549
- e.stopPropagation();
1550
- e.preventDefault();
1551
- state.current.lastPosition = {
1552
- pageX: e.pageX,
1553
- pageY: e.pageY
1554
- };
1555
- addGlobalListener(window, "mousemove", onMouseMove, false);
1556
- addGlobalListener(window, "mouseup", onMouseUp, false);
1557
- }
1558
- };
1559
- let onTouchMove = (e)=>{
1560
- let touch = [
1561
- ...e.changedTouches
1562
- ].findIndex(({ identifier: identifier })=>identifier === state.current.id);
1563
- if (touch >= 0) {
1564
- var _state_current_lastPosition, _state_current_lastPosition1;
1565
- let { pageX: pageX, pageY: pageY } = e.changedTouches[touch];
1566
- var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
1567
- move(e, "touch", pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
1568
- state.current.lastPosition = {
1569
- pageX: pageX,
1570
- pageY: pageY
1571
- };
1572
- }
1573
- };
1574
- let onTouchEnd = (e)=>{
1575
- let touch = [
1576
- ...e.changedTouches
1577
- ].findIndex(({ identifier: identifier })=>identifier === state.current.id);
1578
- if (touch >= 0) {
1579
- end(e, "touch");
1580
- state.current.id = null;
1581
- removeGlobalListener(window, "touchmove", onTouchMove);
1582
- removeGlobalListener(window, "touchend", onTouchEnd);
1583
- removeGlobalListener(window, "touchcancel", onTouchEnd);
1584
- }
1585
- };
1586
- moveProps.onTouchStart = (e)=>{
1587
- if (e.changedTouches.length === 0 || state.current.id != null) return;
1588
- let { pageX: pageX, pageY: pageY, identifier: identifier } = e.changedTouches[0];
1589
- start();
1590
- e.stopPropagation();
1591
- e.preventDefault();
1592
- state.current.lastPosition = {
1593
- pageX: pageX,
1594
- pageY: pageY
1595
- };
1596
- state.current.id = identifier;
1597
- addGlobalListener(window, "touchmove", onTouchMove, false);
1598
- addGlobalListener(window, "touchend", onTouchEnd, false);
1599
- addGlobalListener(window, "touchcancel", onTouchEnd, false);
1600
- };
1601
- } else {
1602
- let onPointerMove = (e)=>{
1603
- if (e.pointerId === state.current.id) {
1604
- var _state_current_lastPosition, _state_current_lastPosition1;
1605
- let pointerType = e.pointerType || "mouse";
1606
- var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
1607
- // Problems with PointerEvent#movementX/movementY:
1608
- // 1. it is always 0 on macOS Safari.
1609
- // 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS
1610
- move(e, pointerType, e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
1611
- state.current.lastPosition = {
1612
- pageX: e.pageX,
1613
- pageY: e.pageY
1614
- };
1615
- }
1616
- };
1617
- let onPointerUp = (e)=>{
1618
- if (e.pointerId === state.current.id) {
1619
- let pointerType = e.pointerType || "mouse";
1620
- end(e, pointerType);
1621
- state.current.id = null;
1622
- removeGlobalListener(window, "pointermove", onPointerMove, false);
1623
- removeGlobalListener(window, "pointerup", onPointerUp, false);
1624
- removeGlobalListener(window, "pointercancel", onPointerUp, false);
1625
- }
1626
- };
1627
- moveProps.onPointerDown = (e)=>{
1628
- if (e.button === 0 && state.current.id == null) {
1629
- start();
1630
- e.stopPropagation();
1631
- e.preventDefault();
1632
- state.current.lastPosition = {
1633
- pageX: e.pageX,
1634
- pageY: e.pageY
1635
- };
1636
- state.current.id = e.pointerId;
1637
- addGlobalListener(window, "pointermove", onPointerMove, false);
1638
- addGlobalListener(window, "pointerup", onPointerUp, false);
1639
- addGlobalListener(window, "pointercancel", onPointerUp, false);
1640
- }
1641
- };
1642
- }
1643
- let triggerKeyboardMove = (e, deltaX, deltaY)=>{
1644
- start();
1645
- move(e, "keyboard", deltaX, deltaY);
1646
- end(e, "keyboard");
1647
- };
1648
- moveProps.onKeyDown = (e)=>{
1649
- switch(e.key){
1650
- case "Left":
1651
- case "ArrowLeft":
1652
- e.preventDefault();
1653
- e.stopPropagation();
1654
- triggerKeyboardMove(e, -1, 0);
1655
- break;
1656
- case "Right":
1657
- case "ArrowRight":
1658
- e.preventDefault();
1659
- e.stopPropagation();
1660
- triggerKeyboardMove(e, 1, 0);
1661
- break;
1662
- case "Up":
1663
- case "ArrowUp":
1664
- e.preventDefault();
1665
- e.stopPropagation();
1666
- triggerKeyboardMove(e, 0, -1);
1667
- break;
1668
- case "Down":
1669
- case "ArrowDown":
1670
- e.preventDefault();
1671
- e.stopPropagation();
1672
- triggerKeyboardMove(e, 0, 1);
1673
- break;
1674
- }
1675
- };
1676
- return moveProps;
1677
- }, [
1678
- state,
1679
- addGlobalListener,
1680
- removeGlobalListener,
1681
- move,
1682
- end
1683
- ]);
1684
- return {
1685
- moveProps: moveProps
1686
- };
1687
- }
1688
-
1689
-
1690
-
1691
- /*
1692
- * Copyright 2021 Adobe. All rights reserved.
1693
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1694
- * you may not use this file except in compliance with the License. You may obtain a copy
1695
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1696
- *
1697
- * Unless required by applicable law or agreed to in writing, software distributed under
1698
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1699
- * OF ANY KIND, either express or implied. See the License for the specific language
1700
- * governing permissions and limitations under the License.
1701
- */
1702
-
1703
- function $7d0a636d7a4dcefd$export$2123ff2b87c81ca(props, ref) {
1704
- let { onScroll: onScroll, isDisabled: isDisabled } = props;
1705
- let onScrollHandler = (0, $bx7SL$useCallback)((e)=>{
1706
- // If the ctrlKey is pressed, this is a zoom event, do nothing.
1707
- if (e.ctrlKey) return;
1708
- // stop scrolling the page
1709
- e.preventDefault();
1710
- e.stopPropagation();
1711
- if (onScroll) onScroll({
1712
- deltaX: e.deltaX,
1713
- deltaY: e.deltaY
1714
- });
1715
- }, [
1716
- onScroll
1717
- ]);
1718
- (0, $bx7SL$useEvent)(ref, "wheel", isDisabled ? undefined : onScrollHandler);
1719
- }
1720
-
1721
-
1722
- /*
1723
- * Copyright 2020 Adobe. All rights reserved.
1724
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
1725
- * you may not use this file except in compliance with the License. You may obtain a copy
1726
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
1727
- *
1728
- * Unless required by applicable law or agreed to in writing, software distributed under
1729
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
1730
- * OF ANY KIND, either express or implied. See the License for the specific language
1731
- * governing permissions and limitations under the License.
1732
- */
1733
32
 
1734
33
 
1735
- const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
1736
- function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
1737
- let { isDisabled: isDisabled, onLongPressStart: onLongPressStart, onLongPressEnd: onLongPressEnd, onLongPress: onLongPress, threshold: threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD, accessibilityDescription: accessibilityDescription } = props;
1738
- const timeRef = (0, $bx7SL$useRef)();
1739
- let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $bx7SL$useGlobalListeners)();
1740
- let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
1741
- isDisabled: isDisabled,
1742
- onPressStart (e) {
1743
- e.continuePropagation();
1744
- if (e.pointerType === "mouse" || e.pointerType === "touch") {
1745
- if (onLongPressStart) onLongPressStart({
1746
- ...e,
1747
- type: "longpressstart"
1748
- });
1749
- timeRef.current = setTimeout(()=>{
1750
- // Prevent other usePress handlers from also handling this event.
1751
- e.target.dispatchEvent(new PointerEvent("pointercancel", {
1752
- bubbles: true
1753
- }));
1754
- if (onLongPress) onLongPress({
1755
- ...e,
1756
- type: "longpress"
1757
- });
1758
- timeRef.current = undefined;
1759
- }, threshold);
1760
- // Prevent context menu, which may be opened on long press on touch devices
1761
- if (e.pointerType === "touch") {
1762
- let onContextMenu = (e)=>{
1763
- e.preventDefault();
1764
- };
1765
- addGlobalListener(e.target, "contextmenu", onContextMenu, {
1766
- once: true
1767
- });
1768
- addGlobalListener(window, "pointerup", ()=>{
1769
- // If no contextmenu event is fired quickly after pointerup, remove the handler
1770
- // so future context menu events outside a long press are not prevented.
1771
- setTimeout(()=>{
1772
- removeGlobalListener(e.target, "contextmenu", onContextMenu);
1773
- }, 30);
1774
- }, {
1775
- once: true
1776
- });
1777
- }
1778
- }
1779
- },
1780
- onPressEnd (e) {
1781
- if (timeRef.current) clearTimeout(timeRef.current);
1782
- if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
1783
- ...e,
1784
- type: "longpressend"
1785
- });
1786
- }
1787
- });
1788
- let descriptionProps = (0, $bx7SL$useDescription)(onLongPress && !isDisabled ? accessibilityDescription : undefined);
1789
- return {
1790
- longPressProps: (0, $bx7SL$mergeProps)(pressProps, descriptionProps)
1791
- };
1792
- }
1793
34
 
1794
35
 
1795
36