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