@react-aria/interactions 3.21.1 → 3.21.3

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