@react-aria/interactions 3.8.0 → 3.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +401 -304
- package/dist/main.js.map +1 -1
- package/dist/module.js +390 -293
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/useFocus.ts +21 -15
- package/src/useFocusWithin.ts +20 -21
- package/src/usePress.ts +6 -6
- package/src/utils.ts +117 -0
package/dist/module.js
CHANGED
|
@@ -1,96 +1,192 @@
|
|
|
1
|
-
import {mergeProps as $
|
|
2
|
-
import $
|
|
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, useLayoutEffect as $bx7SL$useLayoutEffect, 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";
|
|
3
3
|
|
|
4
4
|
function $parcel$export(e, n, v, s) {
|
|
5
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
6
|
}
|
|
7
|
-
var $
|
|
7
|
+
var $3b117e43dc0ca95d$exports = {};
|
|
8
8
|
|
|
9
|
-
$parcel$export($
|
|
9
|
+
$parcel$export($3b117e43dc0ca95d$exports, "Pressable", () => $3b117e43dc0ca95d$export$27c701ed9e449e99);
|
|
10
10
|
|
|
11
|
-
var $
|
|
11
|
+
var $f6c31cce2adf654f$exports = {};
|
|
12
12
|
|
|
13
|
-
$parcel$export($
|
|
13
|
+
$parcel$export($f6c31cce2adf654f$exports, "usePress", () => $f6c31cce2adf654f$export$45712eceda6fad21);
|
|
14
14
|
|
|
15
15
|
// Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
|
|
16
16
|
// rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
|
|
17
|
-
let $
|
|
18
|
-
let $
|
|
19
|
-
let $
|
|
20
|
-
function $
|
|
21
|
-
if ($
|
|
22
|
-
if ($
|
|
23
|
-
$
|
|
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
24
|
document.documentElement.style.webkitUserSelect = 'none';
|
|
25
25
|
}
|
|
26
|
-
$
|
|
26
|
+
$14c0b72509d70225$var$state = 'disabled';
|
|
27
27
|
} else if (target) {
|
|
28
28
|
// If not iOS, store the target's original user-select and change to user-select: none
|
|
29
29
|
// Ignore state since it doesn't apply for non iOS
|
|
30
|
-
$
|
|
30
|
+
$14c0b72509d70225$var$modifiedElementMap.set(target, target.style.userSelect);
|
|
31
31
|
target.style.userSelect = 'none';
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function $
|
|
35
|
-
if ($
|
|
34
|
+
function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
|
|
35
|
+
if ($bx7SL$isIOS()) {
|
|
36
36
|
// If the state is already default, there's nothing to do.
|
|
37
37
|
// If it is restoring, then there's no need to queue a second restore.
|
|
38
|
-
if ($
|
|
39
|
-
$
|
|
38
|
+
if ($14c0b72509d70225$var$state !== 'disabled') return;
|
|
39
|
+
$14c0b72509d70225$var$state = 'restoring';
|
|
40
40
|
// There appears to be a delay on iOS where selection still might occur
|
|
41
41
|
// after pointer up, so wait a bit before removing user-select.
|
|
42
42
|
setTimeout(()=>{
|
|
43
43
|
// Wait for any CSS transitions to complete so we don't recompute style
|
|
44
44
|
// for the whole page in the middle of the animation and cause jank.
|
|
45
|
-
$
|
|
45
|
+
$bx7SL$runAfterTransition(()=>{
|
|
46
46
|
// Avoid race conditions
|
|
47
|
-
if ($
|
|
48
|
-
if (document.documentElement.style.webkitUserSelect === 'none') document.documentElement.style.webkitUserSelect = $
|
|
49
|
-
$
|
|
50
|
-
$
|
|
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
51
|
}
|
|
52
52
|
});
|
|
53
53
|
}, 300);
|
|
54
54
|
} else // If not iOS, restore the target's original user-select if any
|
|
55
55
|
// Ignore state since it doesn't apply for non iOS
|
|
56
|
-
if (target && $
|
|
57
|
-
let targetOldUserSelect = $
|
|
56
|
+
if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
|
|
57
|
+
let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
|
|
58
58
|
if (target.style.userSelect === 'none') target.style.userSelect = targetOldUserSelect;
|
|
59
59
|
if (target.getAttribute('style') === '') target.removeAttribute('style');
|
|
60
|
-
$
|
|
60
|
+
$14c0b72509d70225$var$modifiedElementMap.delete(target);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
function $8a9cb279dc87e130$export$60278871457622de(event) {
|
|
68
70
|
// JAWS/NVDA with Firefox.
|
|
69
71
|
if (event.mozInputSource === 0 && event.isTrusted) return true;
|
|
70
72
|
return event.detail === 0 && !event.pointerType;
|
|
71
73
|
}
|
|
74
|
+
class $8a9cb279dc87e130$export$905e7fc544a71f36 {
|
|
75
|
+
isDefaultPrevented() {
|
|
76
|
+
return this.nativeEvent.defaultPrevented;
|
|
77
|
+
}
|
|
78
|
+
preventDefault() {
|
|
79
|
+
this.defaultPrevented = true;
|
|
80
|
+
this.nativeEvent.preventDefault();
|
|
81
|
+
}
|
|
82
|
+
stopPropagation() {
|
|
83
|
+
this.nativeEvent.stopPropagation();
|
|
84
|
+
this.isPropagationStopped = ()=>true
|
|
85
|
+
;
|
|
86
|
+
}
|
|
87
|
+
isPropagationStopped() {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
persist() {
|
|
91
|
+
}
|
|
92
|
+
constructor(type, nativeEvent){
|
|
93
|
+
this.nativeEvent = nativeEvent;
|
|
94
|
+
this.target = nativeEvent.target;
|
|
95
|
+
this.currentTarget = nativeEvent.currentTarget;
|
|
96
|
+
this.relatedTarget = nativeEvent.relatedTarget;
|
|
97
|
+
this.bubbles = nativeEvent.bubbles;
|
|
98
|
+
this.cancelable = nativeEvent.cancelable;
|
|
99
|
+
this.defaultPrevented = nativeEvent.defaultPrevented;
|
|
100
|
+
this.eventPhase = nativeEvent.eventPhase;
|
|
101
|
+
this.isTrusted = nativeEvent.isTrusted;
|
|
102
|
+
this.timeStamp = nativeEvent.timeStamp;
|
|
103
|
+
this.type = type;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
107
|
+
let stateRef = $bx7SL$useRef({
|
|
108
|
+
isFocused: false,
|
|
109
|
+
onBlur: onBlur,
|
|
110
|
+
observer: null
|
|
111
|
+
});
|
|
112
|
+
let state1 = stateRef.current;
|
|
113
|
+
state1.onBlur = onBlur;
|
|
114
|
+
// Clean up MutationObserver on unmount. See below.
|
|
115
|
+
// eslint-disable-next-line arrow-body-style
|
|
116
|
+
$bx7SL$useLayoutEffect(()=>{
|
|
117
|
+
return ()=>{
|
|
118
|
+
if (state1.observer) {
|
|
119
|
+
state1.observer.disconnect();
|
|
120
|
+
state1.observer = null;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}, [
|
|
124
|
+
state1
|
|
125
|
+
]);
|
|
126
|
+
// This function is called during a React onFocus event.
|
|
127
|
+
return (e1)=>{
|
|
128
|
+
// React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
|
|
129
|
+
// Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
|
|
130
|
+
// MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
|
|
131
|
+
// For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
|
|
132
|
+
if (e1.target instanceof HTMLButtonElement || e1.target instanceof HTMLInputElement || e1.target instanceof HTMLTextAreaElement || e1.target instanceof HTMLSelectElement) {
|
|
133
|
+
state1.isFocused = true;
|
|
134
|
+
let target = e1.target;
|
|
135
|
+
let onBlurHandler = (e)=>{
|
|
136
|
+
var // For backward compatibility, dispatch a (fake) React synthetic event.
|
|
137
|
+
ref;
|
|
138
|
+
let state = stateRef.current;
|
|
139
|
+
state.isFocused = false;
|
|
140
|
+
if (target.disabled) (ref = state.onBlur) === null || ref === void 0 ? void 0 : ref.call(state, new $8a9cb279dc87e130$export$905e7fc544a71f36('blur', e));
|
|
141
|
+
// We no longer need the MutationObserver once the target is blurred.
|
|
142
|
+
if (state.observer) {
|
|
143
|
+
state.observer.disconnect();
|
|
144
|
+
state.observer = null;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
target.addEventListener('focusout', onBlurHandler, {
|
|
148
|
+
once: true
|
|
149
|
+
});
|
|
150
|
+
state1.observer = new MutationObserver(()=>{
|
|
151
|
+
if (state1.isFocused && target.disabled) {
|
|
152
|
+
state1.observer.disconnect();
|
|
153
|
+
target.dispatchEvent(new FocusEvent('blur'));
|
|
154
|
+
target.dispatchEvent(new FocusEvent('focusout', {
|
|
155
|
+
bubbles: true
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
state1.observer.observe(target, {
|
|
160
|
+
attributes: true,
|
|
161
|
+
attributeFilter: [
|
|
162
|
+
'disabled'
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
72
168
|
|
|
73
169
|
|
|
74
170
|
|
|
75
|
-
const $
|
|
76
|
-
$
|
|
171
|
+
const $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = $bx7SL$react.createContext(null);
|
|
172
|
+
$ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = 'PressResponderContext';
|
|
77
173
|
|
|
78
174
|
|
|
79
|
-
function $
|
|
175
|
+
function $f6c31cce2adf654f$var$usePressResponderContext(props) {
|
|
80
176
|
// Consume context from <PressResponder> and merge with props.
|
|
81
|
-
let context = $
|
|
177
|
+
let context = $bx7SL$useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
|
|
82
178
|
if (context) {
|
|
83
179
|
let { register: register , ...contextProps } = context;
|
|
84
|
-
props = $
|
|
180
|
+
props = $bx7SL$mergeProps(contextProps, props);
|
|
85
181
|
register();
|
|
86
182
|
}
|
|
87
|
-
$
|
|
183
|
+
$bx7SL$useSyncRef(context, props.ref);
|
|
88
184
|
return props;
|
|
89
185
|
}
|
|
90
|
-
function $
|
|
186
|
+
function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
91
187
|
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 } = $
|
|
93
|
-
let propsRef = $
|
|
188
|
+
ref: _ , ...domProps } = $f6c31cce2adf654f$var$usePressResponderContext(props);
|
|
189
|
+
let propsRef = $bx7SL$useRef(null);
|
|
94
190
|
propsRef.current = {
|
|
95
191
|
onPress: onPress1,
|
|
96
192
|
onPressChange: onPressChange1,
|
|
@@ -100,8 +196,8 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
100
196
|
isDisabled: isDisabled1,
|
|
101
197
|
shouldCancelOnPointerExit: shouldCancelOnPointerExit
|
|
102
198
|
};
|
|
103
|
-
let [isPressed, setPressed] = $
|
|
104
|
-
let ref = $
|
|
199
|
+
let [isPressed, setPressed] = $bx7SL$useState(false);
|
|
200
|
+
let ref = $bx7SL$useRef({
|
|
105
201
|
isPressed: false,
|
|
106
202
|
ignoreEmulatedMouseEvents: false,
|
|
107
203
|
ignoreClickAfterPress: false,
|
|
@@ -111,8 +207,8 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
111
207
|
isOverTarget: false,
|
|
112
208
|
pointerType: null
|
|
113
209
|
});
|
|
114
|
-
let { addGlobalListener: addGlobalListener , removeAllGlobalListeners: removeAllGlobalListeners } = $
|
|
115
|
-
let pressProps1 = $
|
|
210
|
+
let { addGlobalListener: addGlobalListener , removeAllGlobalListeners: removeAllGlobalListeners } = $bx7SL$useGlobalListeners();
|
|
211
|
+
let pressProps1 = $bx7SL$useMemo(()=>{
|
|
116
212
|
let state = ref.current;
|
|
117
213
|
let triggerPressStart = (originalEvent, pointerType)=>{
|
|
118
214
|
let { onPressStart: onPressStart , onPressChange: onPressChange , isDisabled: isDisabled } = propsRef.current;
|
|
@@ -171,19 +267,19 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
171
267
|
};
|
|
172
268
|
let cancel = (e)=>{
|
|
173
269
|
if (state.isPressed) {
|
|
174
|
-
if (state.isOverTarget) triggerPressEnd($
|
|
270
|
+
if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
|
|
175
271
|
state.isPressed = false;
|
|
176
272
|
state.isOverTarget = false;
|
|
177
273
|
state.activePointerId = null;
|
|
178
274
|
state.pointerType = null;
|
|
179
275
|
removeAllGlobalListeners();
|
|
180
|
-
if (!allowTextSelectionOnPress) $
|
|
276
|
+
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
|
|
181
277
|
}
|
|
182
278
|
};
|
|
183
279
|
let pressProps = {
|
|
184
280
|
onKeyDown (e) {
|
|
185
|
-
if ($
|
|
186
|
-
if ($
|
|
281
|
+
if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent) && e.currentTarget.contains(e.target)) {
|
|
282
|
+
if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target)) e.preventDefault();
|
|
187
283
|
e.stopPropagation();
|
|
188
284
|
// If the event is repeating, it may have started on a different element
|
|
189
285
|
// after which focus moved to the current element. Ignore these events and
|
|
@@ -199,7 +295,7 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
199
295
|
}
|
|
200
296
|
},
|
|
201
297
|
onKeyUp (e) {
|
|
202
|
-
if ($
|
|
298
|
+
if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent) && !e.repeat && e.currentTarget.contains(e.target)) triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e), 'keyboard');
|
|
203
299
|
},
|
|
204
300
|
onClick (e) {
|
|
205
301
|
if (e && !e.currentTarget.contains(e.target)) return;
|
|
@@ -208,9 +304,9 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
208
304
|
if (isDisabled1) e.preventDefault();
|
|
209
305
|
// If triggered from a screen reader or by using element.click(),
|
|
210
306
|
// trigger as if it were a keyboard click.
|
|
211
|
-
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === 'virtual' || $
|
|
307
|
+
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === 'virtual' || $8a9cb279dc87e130$export$60278871457622de(e.nativeEvent))) {
|
|
212
308
|
// Ensure the element receives focus (VoiceOver on iOS does not do this)
|
|
213
|
-
if (!isDisabled1 && !preventFocusOnPress) $
|
|
309
|
+
if (!isDisabled1 && !preventFocusOnPress) $bx7SL$focusWithoutScrolling(e.currentTarget);
|
|
214
310
|
triggerPressStart(e, 'virtual');
|
|
215
311
|
triggerPressUp(e, 'virtual');
|
|
216
312
|
triggerPressEnd(e, 'virtual');
|
|
@@ -221,16 +317,16 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
221
317
|
}
|
|
222
318
|
};
|
|
223
319
|
let onKeyUp = (e)=>{
|
|
224
|
-
if (state.isPressed && $
|
|
225
|
-
if ($
|
|
320
|
+
if (state.isPressed && $f6c31cce2adf654f$var$isValidKeyboardEvent(e)) {
|
|
321
|
+
if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target)) e.preventDefault();
|
|
226
322
|
e.stopPropagation();
|
|
227
323
|
state.isPressed = false;
|
|
228
324
|
let target = e.target;
|
|
229
|
-
triggerPressEnd($
|
|
325
|
+
triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), 'keyboard', state.target.contains(target));
|
|
230
326
|
removeAllGlobalListeners();
|
|
231
327
|
// If the target is a link, trigger the click method to open the URL,
|
|
232
328
|
// but defer triggering pressEnd until onClick event handler.
|
|
233
|
-
if (state.target.contains(target) && $
|
|
329
|
+
if (state.target.contains(target) && $f6c31cce2adf654f$var$isHTMLAnchorLink(state.target) || state.target.getAttribute('role') === 'link') state.target.click();
|
|
234
330
|
}
|
|
235
331
|
};
|
|
236
332
|
if (typeof PointerEvent !== 'undefined') {
|
|
@@ -241,13 +337,13 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
241
337
|
// Ignore and let the onClick handler take care of it instead.
|
|
242
338
|
// https://bugs.webkit.org/show_bug.cgi?id=222627
|
|
243
339
|
// https://bugs.webkit.org/show_bug.cgi?id=223202
|
|
244
|
-
if ($
|
|
340
|
+
if ($f6c31cce2adf654f$var$isVirtualPointerEvent(e.nativeEvent)) {
|
|
245
341
|
state.pointerType = 'virtual';
|
|
246
342
|
return;
|
|
247
343
|
}
|
|
248
344
|
// Due to browser inconsistencies, especially on mobile browsers, we prevent
|
|
249
345
|
// default on pointer down and handle focusing the pressable element ourselves.
|
|
250
|
-
if ($
|
|
346
|
+
if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
|
|
251
347
|
state.pointerType = e.pointerType;
|
|
252
348
|
e.stopPropagation();
|
|
253
349
|
if (!state.isPressed) {
|
|
@@ -255,8 +351,8 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
255
351
|
state.isOverTarget = true;
|
|
256
352
|
state.activePointerId = e.pointerId;
|
|
257
353
|
state.target = e.currentTarget;
|
|
258
|
-
if (!isDisabled1 && !preventFocusOnPress) $
|
|
259
|
-
if (!allowTextSelectionOnPress) $
|
|
354
|
+
if (!isDisabled1 && !preventFocusOnPress) $bx7SL$focusWithoutScrolling(e.currentTarget);
|
|
355
|
+
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$16a4697467175487(state.target);
|
|
260
356
|
triggerPressStart(e, state.pointerType);
|
|
261
357
|
addGlobalListener(document, 'pointermove', onPointerMove, false);
|
|
262
358
|
addGlobalListener(document, 'pointerup', onPointerUp, false);
|
|
@@ -269,7 +365,7 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
269
365
|
// Chrome and Firefox on touch Windows devices require mouse down events
|
|
270
366
|
// to be canceled in addition to pointer events, or an extra asynchronous
|
|
271
367
|
// focus event will be fired.
|
|
272
|
-
if ($
|
|
368
|
+
if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
|
|
273
369
|
e.stopPropagation();
|
|
274
370
|
}
|
|
275
371
|
};
|
|
@@ -279,34 +375,34 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
279
375
|
// Only handle left clicks
|
|
280
376
|
// Safari on iOS sometimes fires pointerup events, even
|
|
281
377
|
// when the touch isn't over the target, so double check.
|
|
282
|
-
if (e.button === 0 && $
|
|
378
|
+
if (e.button === 0 && $f6c31cce2adf654f$var$isOverTarget(e, e.currentTarget)) triggerPressUp(e, state.pointerType || e.pointerType);
|
|
283
379
|
};
|
|
284
380
|
// Safari on iOS < 13.2 does not implement pointerenter/pointerleave events correctly.
|
|
285
381
|
// Use pointer move events instead to implement our own hit testing.
|
|
286
382
|
// See https://bugs.webkit.org/show_bug.cgi?id=199803
|
|
287
383
|
let onPointerMove = (e)=>{
|
|
288
384
|
if (e.pointerId !== state.activePointerId) return;
|
|
289
|
-
if ($
|
|
385
|
+
if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) {
|
|
290
386
|
if (!state.isOverTarget) {
|
|
291
387
|
state.isOverTarget = true;
|
|
292
|
-
triggerPressStart($
|
|
388
|
+
triggerPressStart($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
|
|
293
389
|
}
|
|
294
390
|
} else if (state.isOverTarget) {
|
|
295
391
|
state.isOverTarget = false;
|
|
296
|
-
triggerPressEnd($
|
|
392
|
+
triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
|
|
297
393
|
if (propsRef.current.shouldCancelOnPointerExit) cancel(e);
|
|
298
394
|
}
|
|
299
395
|
};
|
|
300
396
|
let onPointerUp = (e)=>{
|
|
301
397
|
if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0) {
|
|
302
|
-
if ($
|
|
303
|
-
else if (state.isOverTarget) triggerPressEnd($
|
|
398
|
+
if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
|
|
399
|
+
else if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
|
|
304
400
|
state.isPressed = false;
|
|
305
401
|
state.isOverTarget = false;
|
|
306
402
|
state.activePointerId = null;
|
|
307
403
|
state.pointerType = null;
|
|
308
404
|
removeAllGlobalListeners();
|
|
309
|
-
if (!allowTextSelectionOnPress) $
|
|
405
|
+
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
|
|
310
406
|
}
|
|
311
407
|
};
|
|
312
408
|
let onPointerCancel = (e)=>{
|
|
@@ -323,14 +419,14 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
323
419
|
if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
|
|
324
420
|
// Due to browser inconsistencies, especially on mobile browsers, we prevent
|
|
325
421
|
// default on mouse down and handle focusing the pressable element ourselves.
|
|
326
|
-
if ($
|
|
422
|
+
if ($f6c31cce2adf654f$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
|
|
327
423
|
e.stopPropagation();
|
|
328
424
|
if (state.ignoreEmulatedMouseEvents) return;
|
|
329
425
|
state.isPressed = true;
|
|
330
426
|
state.isOverTarget = true;
|
|
331
427
|
state.target = e.currentTarget;
|
|
332
|
-
state.pointerType = $
|
|
333
|
-
if (!isDisabled1 && !preventFocusOnPress) $
|
|
428
|
+
state.pointerType = $8a9cb279dc87e130$export$60278871457622de(e.nativeEvent) ? 'virtual' : 'mouse';
|
|
429
|
+
if (!isDisabled1 && !preventFocusOnPress) $bx7SL$focusWithoutScrolling(e.currentTarget);
|
|
334
430
|
triggerPressStart(e, state.pointerType);
|
|
335
431
|
addGlobalListener(document, 'mouseup', onMouseUp, false);
|
|
336
432
|
};
|
|
@@ -364,14 +460,14 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
364
460
|
state.ignoreEmulatedMouseEvents = false;
|
|
365
461
|
return;
|
|
366
462
|
}
|
|
367
|
-
if ($
|
|
368
|
-
else if (state.isOverTarget) triggerPressEnd($
|
|
463
|
+
if ($f6c31cce2adf654f$var$isOverTarget(e, state.target)) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType);
|
|
464
|
+
else if (state.isOverTarget) triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), state.pointerType, false);
|
|
369
465
|
state.isOverTarget = false;
|
|
370
466
|
};
|
|
371
467
|
pressProps.onTouchStart = (e)=>{
|
|
372
468
|
if (!e.currentTarget.contains(e.target)) return;
|
|
373
469
|
e.stopPropagation();
|
|
374
|
-
let touch = $
|
|
470
|
+
let touch = $f6c31cce2adf654f$var$getTouchFromEvent(e.nativeEvent);
|
|
375
471
|
if (!touch) return;
|
|
376
472
|
state.activePointerId = touch.identifier;
|
|
377
473
|
state.ignoreEmulatedMouseEvents = true;
|
|
@@ -381,8 +477,8 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
381
477
|
state.pointerType = 'touch';
|
|
382
478
|
// Due to browser inconsistencies, especially on mobile browsers, we prevent default
|
|
383
479
|
// on the emulated mouse event and handle focusing the pressable element ourselves.
|
|
384
|
-
if (!isDisabled1 && !preventFocusOnPress) $
|
|
385
|
-
if (!allowTextSelectionOnPress) $
|
|
480
|
+
if (!isDisabled1 && !preventFocusOnPress) $bx7SL$focusWithoutScrolling(e.currentTarget);
|
|
481
|
+
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$16a4697467175487(state.target);
|
|
386
482
|
triggerPressStart(e, state.pointerType);
|
|
387
483
|
addGlobalListener(window, 'scroll', onScroll, true);
|
|
388
484
|
};
|
|
@@ -390,8 +486,8 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
390
486
|
if (!e.currentTarget.contains(e.target)) return;
|
|
391
487
|
e.stopPropagation();
|
|
392
488
|
if (!state.isPressed) return;
|
|
393
|
-
let touch = $
|
|
394
|
-
if (touch && $
|
|
489
|
+
let touch = $f6c31cce2adf654f$var$getTouchById(e.nativeEvent, state.activePointerId);
|
|
490
|
+
if (touch && $f6c31cce2adf654f$var$isOverTarget(touch, e.currentTarget)) {
|
|
395
491
|
if (!state.isOverTarget) {
|
|
396
492
|
state.isOverTarget = true;
|
|
397
493
|
triggerPressStart(e, state.pointerType);
|
|
@@ -406,8 +502,8 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
406
502
|
if (!e.currentTarget.contains(e.target)) return;
|
|
407
503
|
e.stopPropagation();
|
|
408
504
|
if (!state.isPressed) return;
|
|
409
|
-
let touch = $
|
|
410
|
-
if (touch && $
|
|
505
|
+
let touch = $f6c31cce2adf654f$var$getTouchById(e.nativeEvent, state.activePointerId);
|
|
506
|
+
if (touch && $f6c31cce2adf654f$var$isOverTarget(touch, e.currentTarget)) {
|
|
411
507
|
triggerPressUp(e, state.pointerType);
|
|
412
508
|
triggerPressEnd(e, state.pointerType);
|
|
413
509
|
} else if (state.isOverTarget) triggerPressEnd(e, state.pointerType, false);
|
|
@@ -415,7 +511,7 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
415
511
|
state.activePointerId = null;
|
|
416
512
|
state.isOverTarget = false;
|
|
417
513
|
state.ignoreEmulatedMouseEvents = true;
|
|
418
|
-
if (!allowTextSelectionOnPress) $
|
|
514
|
+
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
|
|
419
515
|
removeAllGlobalListeners();
|
|
420
516
|
};
|
|
421
517
|
pressProps.onTouchCancel = (e)=>{
|
|
@@ -447,37 +543,37 @@ function $bb70d401e0bbab2b$export$45712eceda6fad21(props) {
|
|
|
447
543
|
]);
|
|
448
544
|
// Remove user-select: none in case component unmounts immediately after pressStart
|
|
449
545
|
// eslint-disable-next-line arrow-body-style
|
|
450
|
-
$
|
|
546
|
+
$bx7SL$useEffect(()=>{
|
|
451
547
|
return ()=>{
|
|
452
|
-
if (!allowTextSelectionOnPress) $
|
|
548
|
+
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(ref.current.target);
|
|
453
549
|
};
|
|
454
550
|
}, [
|
|
455
551
|
allowTextSelectionOnPress
|
|
456
552
|
]);
|
|
457
553
|
return {
|
|
458
554
|
isPressed: isPressedProp || isPressed,
|
|
459
|
-
pressProps: $
|
|
555
|
+
pressProps: $bx7SL$mergeProps(domProps, pressProps1)
|
|
460
556
|
};
|
|
461
557
|
}
|
|
462
|
-
function $
|
|
558
|
+
function $f6c31cce2adf654f$var$isHTMLAnchorLink(target) {
|
|
463
559
|
return target.tagName === 'A' && target.hasAttribute('href');
|
|
464
560
|
}
|
|
465
|
-
function $
|
|
561
|
+
function $f6c31cce2adf654f$var$isValidKeyboardEvent(event) {
|
|
466
562
|
const { key: key , code: code , target: target } = event;
|
|
467
563
|
const element = target;
|
|
468
564
|
const { tagName: tagName , isContentEditable: isContentEditable } = element;
|
|
469
565
|
const role = element.getAttribute('role');
|
|
470
566
|
// Accessibility for keyboards. Space and Enter only.
|
|
471
567
|
// "Spacebar" is for IE 11
|
|
472
|
-
return (key === 'Enter' || key === ' ' || key === 'Spacebar' || code === 'Space') && tagName !== 'INPUT' && tagName !== 'TEXTAREA' && isContentEditable !== true && (!$
|
|
568
|
+
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
569
|
!(role === 'link' && key !== 'Enter');
|
|
474
570
|
}
|
|
475
|
-
function $
|
|
571
|
+
function $f6c31cce2adf654f$var$getTouchFromEvent(event) {
|
|
476
572
|
const { targetTouches: targetTouches } = event;
|
|
477
573
|
if (targetTouches.length > 0) return targetTouches[0];
|
|
478
574
|
return null;
|
|
479
575
|
}
|
|
480
|
-
function $
|
|
576
|
+
function $f6c31cce2adf654f$var$getTouchById(event, pointerId) {
|
|
481
577
|
const changedTouches = event.changedTouches;
|
|
482
578
|
for(let i = 0; i < changedTouches.length; i++){
|
|
483
579
|
const touch = changedTouches[i];
|
|
@@ -485,7 +581,7 @@ function $bb70d401e0bbab2b$var$getTouchById(event, pointerId) {
|
|
|
485
581
|
}
|
|
486
582
|
return null;
|
|
487
583
|
}
|
|
488
|
-
function $
|
|
584
|
+
function $f6c31cce2adf654f$var$createEvent(target, e) {
|
|
489
585
|
return {
|
|
490
586
|
currentTarget: target,
|
|
491
587
|
shiftKey: e.shiftKey,
|
|
@@ -494,7 +590,7 @@ function $bb70d401e0bbab2b$var$createEvent(target, e) {
|
|
|
494
590
|
altKey: e.altKey
|
|
495
591
|
};
|
|
496
592
|
}
|
|
497
|
-
function $
|
|
593
|
+
function $f6c31cce2adf654f$var$getPointClientRect(point) {
|
|
498
594
|
let offsetX = point.width / 2 || point.radiusX || 0;
|
|
499
595
|
let offsetY = point.height / 2 || point.radiusY || 0;
|
|
500
596
|
return {
|
|
@@ -504,26 +600,26 @@ function $bb70d401e0bbab2b$var$getPointClientRect(point) {
|
|
|
504
600
|
left: point.clientX - offsetX
|
|
505
601
|
};
|
|
506
602
|
}
|
|
507
|
-
function $
|
|
603
|
+
function $f6c31cce2adf654f$var$areRectanglesOverlapping(a, b) {
|
|
508
604
|
// check if they cannot overlap on x axis
|
|
509
605
|
if (a.left > b.right || b.left > a.right) return false;
|
|
510
606
|
// check if they cannot overlap on y axis
|
|
511
607
|
if (a.top > b.bottom || b.top > a.bottom) return false;
|
|
512
608
|
return true;
|
|
513
609
|
}
|
|
514
|
-
function $
|
|
610
|
+
function $f6c31cce2adf654f$var$isOverTarget(point, target) {
|
|
515
611
|
let rect = target.getBoundingClientRect();
|
|
516
|
-
let pointRect = $
|
|
517
|
-
return $
|
|
612
|
+
let pointRect = $f6c31cce2adf654f$var$getPointClientRect(point);
|
|
613
|
+
return $f6c31cce2adf654f$var$areRectanglesOverlapping(rect, pointRect);
|
|
518
614
|
}
|
|
519
|
-
function $
|
|
520
|
-
// We cannot prevent default if the target is
|
|
521
|
-
return !target.
|
|
615
|
+
function $f6c31cce2adf654f$var$shouldPreventDefault(target) {
|
|
616
|
+
// We cannot prevent default if the target is a draggable element.
|
|
617
|
+
return !target.draggable;
|
|
522
618
|
}
|
|
523
|
-
function $
|
|
619
|
+
function $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(target) {
|
|
524
620
|
return !((target.tagName === 'INPUT' || target.tagName === 'BUTTON') && target.type === 'submit');
|
|
525
621
|
}
|
|
526
|
-
function $
|
|
622
|
+
function $f6c31cce2adf654f$var$isVirtualPointerEvent(event) {
|
|
527
623
|
// If the pointer size is zero, then we assume it's from a screen reader.
|
|
528
624
|
// Android TalkBack double tap will sometimes return a event with width and height of 1
|
|
529
625
|
// and pointerType === 'mouse' so we need to check for a specific combination of event attributes.
|
|
@@ -534,69 +630,71 @@ function $bb70d401e0bbab2b$var$isVirtualPointerEvent(event) {
|
|
|
534
630
|
|
|
535
631
|
|
|
536
632
|
|
|
537
|
-
const $
|
|
538
|
-
let newRef = $
|
|
539
|
-
ref = ref
|
|
540
|
-
let { pressProps: pressProps } = $
|
|
633
|
+
const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ $bx7SL$react.forwardRef(({ children: children , ...props }, ref)=>{
|
|
634
|
+
let newRef = $bx7SL$useRef();
|
|
635
|
+
ref = ref !== null && ref !== void 0 ? ref : newRef;
|
|
636
|
+
let { pressProps: pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
|
|
541
637
|
...props,
|
|
542
638
|
ref: ref
|
|
543
639
|
});
|
|
544
|
-
let child = $
|
|
545
|
-
return(/*#__PURE__*/ $
|
|
640
|
+
let child = $bx7SL$react.Children.only(children);
|
|
641
|
+
return(/*#__PURE__*/ $bx7SL$react.cloneElement(child, // @ts-ignore
|
|
546
642
|
{
|
|
547
643
|
ref: ref,
|
|
548
|
-
...$
|
|
644
|
+
...$bx7SL$mergeProps(child.props, pressProps)
|
|
549
645
|
}));
|
|
550
646
|
});
|
|
551
647
|
|
|
552
648
|
|
|
553
|
-
var $
|
|
649
|
+
var $f1ab8c75478c6f73$exports = {};
|
|
554
650
|
|
|
555
|
-
$parcel$export($
|
|
651
|
+
$parcel$export($f1ab8c75478c6f73$exports, "PressResponder", () => $f1ab8c75478c6f73$export$3351871ee4b288b8);
|
|
556
652
|
|
|
557
653
|
|
|
558
654
|
|
|
559
|
-
const $
|
|
560
|
-
let isRegistered = $
|
|
561
|
-
let prevContext = $
|
|
562
|
-
let context = $
|
|
655
|
+
const $f1ab8c75478c6f73$export$3351871ee4b288b8 = /*#__PURE__*/ $bx7SL$react.forwardRef(({ children: children , ...props }, ref)=>{
|
|
656
|
+
let isRegistered = $bx7SL$useRef(false);
|
|
657
|
+
let prevContext = $bx7SL$useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
|
|
658
|
+
let context = $bx7SL$mergeProps(prevContext || {
|
|
563
659
|
}, {
|
|
564
660
|
...props,
|
|
565
|
-
ref: ref || prevContext
|
|
661
|
+
ref: ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref),
|
|
566
662
|
register () {
|
|
567
663
|
isRegistered.current = true;
|
|
568
664
|
if (prevContext) prevContext.register();
|
|
569
665
|
}
|
|
570
666
|
});
|
|
571
|
-
$
|
|
572
|
-
$
|
|
667
|
+
$bx7SL$useSyncRef(prevContext, ref);
|
|
668
|
+
$bx7SL$useEffect(()=>{
|
|
573
669
|
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
670
|
}, []);
|
|
575
|
-
return(/*#__PURE__*/ $
|
|
671
|
+
return(/*#__PURE__*/ $bx7SL$react.createElement($ae1eeba8b9eafd08$export$5165eccb35aaadb5.Provider, {
|
|
576
672
|
value: context
|
|
577
673
|
}, children));
|
|
578
674
|
});
|
|
579
675
|
|
|
580
676
|
|
|
581
|
-
var $
|
|
677
|
+
var $a1ea59d68270f0dd$exports = {};
|
|
582
678
|
|
|
583
|
-
$parcel$export($
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
679
|
+
$parcel$export($a1ea59d68270f0dd$exports, "useFocus", () => $a1ea59d68270f0dd$export$f8168d8dd8fd66e6);
|
|
680
|
+
|
|
681
|
+
function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
682
|
+
let onBlur;
|
|
683
|
+
if (!props.isDisabled && (props.onBlur || props.onFocusChange)) onBlur = (e)=>{
|
|
684
|
+
if (e.target === e.currentTarget) {
|
|
685
|
+
if (props.onBlur) props.onBlur(e);
|
|
686
|
+
if (props.onFocusChange) props.onFocusChange(false);
|
|
687
|
+
return true;
|
|
587
688
|
}
|
|
588
689
|
};
|
|
589
|
-
|
|
590
|
-
|
|
690
|
+
else onBlur = null;
|
|
691
|
+
let onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
|
|
692
|
+
let onFocus;
|
|
693
|
+
if (!props.isDisabled && (props.onFocus || props.onFocusChange || props.onBlur)) onFocus = (e)=>{
|
|
591
694
|
if (e.target === e.currentTarget) {
|
|
592
695
|
if (props.onFocus) props.onFocus(e);
|
|
593
696
|
if (props.onFocusChange) props.onFocusChange(true);
|
|
594
|
-
|
|
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);
|
|
697
|
+
onSyntheticFocus(e);
|
|
600
698
|
}
|
|
601
699
|
};
|
|
602
700
|
return {
|
|
@@ -608,131 +706,131 @@ function $96cd623b8d5dd15d$export$f8168d8dd8fd66e6(props) {
|
|
|
608
706
|
}
|
|
609
707
|
|
|
610
708
|
|
|
611
|
-
var $
|
|
709
|
+
var $507fabe10e71c6fb$exports = {};
|
|
612
710
|
|
|
613
|
-
$parcel$export($
|
|
614
|
-
$parcel$export($
|
|
615
|
-
$parcel$export($
|
|
616
|
-
$parcel$export($
|
|
617
|
-
$parcel$export($
|
|
618
|
-
$parcel$export($
|
|
711
|
+
$parcel$export($507fabe10e71c6fb$exports, "isFocusVisible", () => $507fabe10e71c6fb$export$b9b3dfddab17db27);
|
|
712
|
+
$parcel$export($507fabe10e71c6fb$exports, "getInteractionModality", () => $507fabe10e71c6fb$export$630ff653c5ada6a9);
|
|
713
|
+
$parcel$export($507fabe10e71c6fb$exports, "setInteractionModality", () => $507fabe10e71c6fb$export$8397ddfc504fdb9a);
|
|
714
|
+
$parcel$export($507fabe10e71c6fb$exports, "useInteractionModality", () => $507fabe10e71c6fb$export$98e20ec92f614cfe);
|
|
715
|
+
$parcel$export($507fabe10e71c6fb$exports, "useFocusVisible", () => $507fabe10e71c6fb$export$ffd9e5021c1fb2d6);
|
|
716
|
+
$parcel$export($507fabe10e71c6fb$exports, "useFocusVisibleListener", () => $507fabe10e71c6fb$export$ec71b4b83ac08ec3);
|
|
619
717
|
|
|
620
718
|
|
|
621
719
|
|
|
622
|
-
let $
|
|
623
|
-
let $
|
|
624
|
-
let $
|
|
625
|
-
let $
|
|
626
|
-
let $
|
|
720
|
+
let $507fabe10e71c6fb$var$currentModality = null;
|
|
721
|
+
let $507fabe10e71c6fb$var$changeHandlers = new Set();
|
|
722
|
+
let $507fabe10e71c6fb$var$hasSetupGlobalListeners = false;
|
|
723
|
+
let $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
724
|
+
let $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
627
725
|
// Only Tab or Esc keys will make focus visible on text input elements
|
|
628
|
-
const $
|
|
726
|
+
const $507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS = {
|
|
629
727
|
Tab: true,
|
|
630
728
|
Escape: true
|
|
631
729
|
};
|
|
632
|
-
function $
|
|
633
|
-
for (let handler of $
|
|
730
|
+
function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
|
|
731
|
+
for (let handler of $507fabe10e71c6fb$var$changeHandlers)handler(modality, e);
|
|
634
732
|
}
|
|
635
733
|
/**
|
|
636
734
|
* Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
637
|
-
*/ function $
|
|
735
|
+
*/ function $507fabe10e71c6fb$var$isValidKey(e) {
|
|
638
736
|
// Control and Shift keys trigger when navigating back to the tab with keyboard.
|
|
639
|
-
return !(e.metaKey || !$
|
|
737
|
+
return !(e.metaKey || !$bx7SL$isMac() && e.altKey || e.ctrlKey || e.key === 'Control' || e.key === 'Shift' || e.key === 'Meta');
|
|
640
738
|
}
|
|
641
|
-
function $
|
|
642
|
-
$
|
|
643
|
-
if ($
|
|
644
|
-
$
|
|
645
|
-
$
|
|
739
|
+
function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
|
|
740
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
741
|
+
if ($507fabe10e71c6fb$var$isValidKey(e)) {
|
|
742
|
+
$507fabe10e71c6fb$var$currentModality = 'keyboard';
|
|
743
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('keyboard', e);
|
|
646
744
|
}
|
|
647
745
|
}
|
|
648
|
-
function $
|
|
649
|
-
$
|
|
746
|
+
function $507fabe10e71c6fb$var$handlePointerEvent(e) {
|
|
747
|
+
$507fabe10e71c6fb$var$currentModality = 'pointer';
|
|
650
748
|
if (e.type === 'mousedown' || e.type === 'pointerdown') {
|
|
651
|
-
$
|
|
652
|
-
$
|
|
749
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
750
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('pointer', e);
|
|
653
751
|
}
|
|
654
752
|
}
|
|
655
|
-
function $
|
|
656
|
-
if ($
|
|
657
|
-
$
|
|
658
|
-
$
|
|
753
|
+
function $507fabe10e71c6fb$var$handleClickEvent(e) {
|
|
754
|
+
if ($8a9cb279dc87e130$export$60278871457622de(e)) {
|
|
755
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
756
|
+
$507fabe10e71c6fb$var$currentModality = 'virtual';
|
|
659
757
|
}
|
|
660
758
|
}
|
|
661
|
-
function $
|
|
759
|
+
function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
662
760
|
// Firefox fires two extra focus events when the user first clicks into an iframe:
|
|
663
761
|
// first on the window, then on the document. We ignore these events so they don't
|
|
664
762
|
// cause keyboard focus rings to appear.
|
|
665
763
|
if (e.target === window || e.target === document) return;
|
|
666
764
|
// If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
|
|
667
765
|
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
668
|
-
if (!$
|
|
669
|
-
$
|
|
670
|
-
$
|
|
766
|
+
if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
|
|
767
|
+
$507fabe10e71c6fb$var$currentModality = 'virtual';
|
|
768
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers('virtual', e);
|
|
671
769
|
}
|
|
672
|
-
$
|
|
673
|
-
$
|
|
770
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
771
|
+
$507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
674
772
|
}
|
|
675
|
-
function $
|
|
773
|
+
function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
676
774
|
// When the window is blurred, reset state. This is necessary when tabbing out of the window,
|
|
677
775
|
// for example, since a subsequent focus event won't be fired.
|
|
678
|
-
$
|
|
679
|
-
$
|
|
776
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
777
|
+
$507fabe10e71c6fb$var$hasBlurredWindowRecently = true;
|
|
680
778
|
}
|
|
681
779
|
/**
|
|
682
780
|
* Setup global event listeners to control when keyboard focus style should be visible.
|
|
683
|
-
*/ function $
|
|
684
|
-
if (typeof window === 'undefined' || $
|
|
781
|
+
*/ function $507fabe10e71c6fb$var$setupGlobalFocusEvents() {
|
|
782
|
+
if (typeof window === 'undefined' || $507fabe10e71c6fb$var$hasSetupGlobalListeners) return;
|
|
685
783
|
// Programmatic focus() calls shouldn't affect the current input modality.
|
|
686
784
|
// However, we need to detect other cases when a focus event occurs without
|
|
687
785
|
// a preceding user event (e.g. screen reader focus). Overriding the focus
|
|
688
786
|
// method on HTMLElement.prototype is a bit hacky, but works.
|
|
689
787
|
let focus = HTMLElement.prototype.focus;
|
|
690
788
|
HTMLElement.prototype.focus = function() {
|
|
691
|
-
$
|
|
789
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
692
790
|
focus.apply(this, arguments);
|
|
693
791
|
};
|
|
694
|
-
document.addEventListener('keydown', $
|
|
695
|
-
document.addEventListener('keyup', $
|
|
696
|
-
document.addEventListener('click', $
|
|
792
|
+
document.addEventListener('keydown', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
793
|
+
document.addEventListener('keyup', $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
794
|
+
document.addEventListener('click', $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
697
795
|
// Register focus events on the window so they are sure to happen
|
|
698
796
|
// before React's event listeners (registered on the document).
|
|
699
|
-
window.addEventListener('focus', $
|
|
700
|
-
window.addEventListener('blur', $
|
|
797
|
+
window.addEventListener('focus', $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
798
|
+
window.addEventListener('blur', $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
701
799
|
if (typeof PointerEvent !== 'undefined') {
|
|
702
|
-
document.addEventListener('pointerdown', $
|
|
703
|
-
document.addEventListener('pointermove', $
|
|
704
|
-
document.addEventListener('pointerup', $
|
|
800
|
+
document.addEventListener('pointerdown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
801
|
+
document.addEventListener('pointermove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
802
|
+
document.addEventListener('pointerup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
705
803
|
} else {
|
|
706
|
-
document.addEventListener('mousedown', $
|
|
707
|
-
document.addEventListener('mousemove', $
|
|
708
|
-
document.addEventListener('mouseup', $
|
|
804
|
+
document.addEventListener('mousedown', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
805
|
+
document.addEventListener('mousemove', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
806
|
+
document.addEventListener('mouseup', $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
709
807
|
}
|
|
710
|
-
$
|
|
808
|
+
$507fabe10e71c6fb$var$hasSetupGlobalListeners = true;
|
|
711
809
|
}
|
|
712
810
|
if (typeof document !== 'undefined') {
|
|
713
|
-
if (document.readyState !== 'loading') $
|
|
714
|
-
else document.addEventListener('DOMContentLoaded', $
|
|
811
|
+
if (document.readyState !== 'loading') $507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
812
|
+
else document.addEventListener('DOMContentLoaded', $507fabe10e71c6fb$var$setupGlobalFocusEvents);
|
|
715
813
|
}
|
|
716
|
-
function $
|
|
717
|
-
return $
|
|
814
|
+
function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
|
|
815
|
+
return $507fabe10e71c6fb$var$currentModality !== 'pointer';
|
|
718
816
|
}
|
|
719
|
-
function $
|
|
720
|
-
return $
|
|
817
|
+
function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
|
|
818
|
+
return $507fabe10e71c6fb$var$currentModality;
|
|
721
819
|
}
|
|
722
|
-
function $
|
|
723
|
-
$
|
|
724
|
-
$
|
|
820
|
+
function $507fabe10e71c6fb$export$8397ddfc504fdb9a(modality) {
|
|
821
|
+
$507fabe10e71c6fb$var$currentModality = modality;
|
|
822
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers(modality, null);
|
|
725
823
|
}
|
|
726
|
-
function $
|
|
727
|
-
$
|
|
728
|
-
let [modality, setModality] = $
|
|
729
|
-
$
|
|
824
|
+
function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
|
|
825
|
+
$507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
826
|
+
let [modality, setModality] = $bx7SL$useState($507fabe10e71c6fb$var$currentModality);
|
|
827
|
+
$bx7SL$useEffect(()=>{
|
|
730
828
|
let handler = ()=>{
|
|
731
|
-
setModality($
|
|
829
|
+
setModality($507fabe10e71c6fb$var$currentModality);
|
|
732
830
|
};
|
|
733
|
-
$
|
|
831
|
+
$507fabe10e71c6fb$var$changeHandlers.add(handler);
|
|
734
832
|
return ()=>{
|
|
735
|
-
$
|
|
833
|
+
$507fabe10e71c6fb$var$changeHandlers.delete(handler);
|
|
736
834
|
};
|
|
737
835
|
}, []);
|
|
738
836
|
return modality;
|
|
@@ -740,15 +838,15 @@ function $d2dd66cff767efeb$export$98e20ec92f614cfe() {
|
|
|
740
838
|
/**
|
|
741
839
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
742
840
|
* focus visible style can be properly set.
|
|
743
|
-
*/ function $
|
|
744
|
-
return !(isTextInput && modality === 'keyboard' && e instanceof KeyboardEvent && !$
|
|
841
|
+
*/ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
|
842
|
+
return !(isTextInput && modality === 'keyboard' && e instanceof KeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
|
745
843
|
}
|
|
746
|
-
function $
|
|
844
|
+
function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {
|
|
747
845
|
}) {
|
|
748
846
|
let { isTextInput: isTextInput , autoFocus: autoFocus } = props;
|
|
749
|
-
let [isFocusVisibleState, setFocusVisible] = $
|
|
750
|
-
$
|
|
751
|
-
setFocusVisible($
|
|
847
|
+
let [isFocusVisibleState, setFocusVisible] = $bx7SL$useState(autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
848
|
+
$507fabe10e71c6fb$export$ec71b4b83ac08ec3(($507fabe10e71c6fb$export$b9b3dfddab17db27)=>{
|
|
849
|
+
setFocusVisible($507fabe10e71c6fb$export$b9b3dfddab17db27);
|
|
752
850
|
}, [
|
|
753
851
|
isTextInput
|
|
754
852
|
], {
|
|
@@ -758,48 +856,47 @@ function $d2dd66cff767efeb$export$ffd9e5021c1fb2d6(props = {
|
|
|
758
856
|
isFocusVisible: isFocusVisibleState
|
|
759
857
|
};
|
|
760
858
|
}
|
|
761
|
-
function $
|
|
762
|
-
$
|
|
763
|
-
$
|
|
859
|
+
function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
860
|
+
$507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
861
|
+
$bx7SL$useEffect(()=>{
|
|
764
862
|
let handler = (modality, e)=>{
|
|
765
|
-
if (!$
|
|
766
|
-
fn($
|
|
863
|
+
if (!$507fabe10e71c6fb$var$isKeyboardFocusEvent(opts === null || opts === void 0 ? void 0 : opts.isTextInput, modality, e)) return;
|
|
864
|
+
fn($507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
767
865
|
};
|
|
768
|
-
$
|
|
866
|
+
$507fabe10e71c6fb$var$changeHandlers.add(handler);
|
|
769
867
|
return ()=>{
|
|
770
|
-
$
|
|
868
|
+
$507fabe10e71c6fb$var$changeHandlers.delete(handler);
|
|
771
869
|
};
|
|
772
870
|
}, deps);
|
|
773
871
|
}
|
|
774
872
|
|
|
775
873
|
|
|
776
|
-
var $
|
|
874
|
+
var $9ab94262bd0047c7$exports = {};
|
|
777
875
|
|
|
778
|
-
$parcel$export($
|
|
876
|
+
$parcel$export($9ab94262bd0047c7$exports, "useFocusWithin", () => $9ab94262bd0047c7$export$420e68273165f4ec);
|
|
779
877
|
|
|
780
|
-
|
|
781
|
-
|
|
878
|
+
|
|
879
|
+
function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
880
|
+
let state = $bx7SL$useRef({
|
|
782
881
|
isFocusWithin: false
|
|
783
882
|
}).current;
|
|
784
|
-
|
|
785
|
-
focusWithinProps: {
|
|
786
|
-
}
|
|
787
|
-
};
|
|
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
|
-
}
|
|
794
|
-
};
|
|
795
|
-
let onBlur = (e)=>{
|
|
883
|
+
let onBlur = props.isDisabled ? null : (e)=>{
|
|
796
884
|
// We don't want to trigger onBlurWithin and then immediately onFocusWithin again
|
|
797
885
|
// when moving focus inside the element. Only trigger if the currentTarget doesn't
|
|
798
886
|
// include the relatedTarget (where focus is moving).
|
|
799
887
|
if (state.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
|
|
888
|
+
state.isFocusWithin = false;
|
|
800
889
|
if (props.onBlurWithin) props.onBlurWithin(e);
|
|
801
890
|
if (props.onFocusWithinChange) props.onFocusWithinChange(false);
|
|
802
|
-
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
let onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
|
|
894
|
+
let onFocus = props.isDisabled ? null : (e)=>{
|
|
895
|
+
if (!state.isFocusWithin) {
|
|
896
|
+
if (props.onFocusWithin) props.onFocusWithin(e);
|
|
897
|
+
if (props.onFocusWithinChange) props.onFocusWithinChange(true);
|
|
898
|
+
state.isFocusWithin = true;
|
|
899
|
+
onSyntheticFocus(e);
|
|
803
900
|
}
|
|
804
901
|
};
|
|
805
902
|
return {
|
|
@@ -811,51 +908,51 @@ function $d2acb2e6011484f7$export$420e68273165f4ec(props) {
|
|
|
811
908
|
}
|
|
812
909
|
|
|
813
910
|
|
|
814
|
-
var $
|
|
911
|
+
var $6179b936705e76d3$exports = {};
|
|
815
912
|
|
|
816
|
-
$parcel$export($
|
|
913
|
+
$parcel$export($6179b936705e76d3$exports, "useHover", () => $6179b936705e76d3$export$ae780daf29e6d456);
|
|
817
914
|
|
|
818
915
|
// iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
|
|
819
916
|
// We want to ignore these emulated events so they do not trigger hover behavior.
|
|
820
917
|
// See https://bugs.webkit.org/show_bug.cgi?id=214609.
|
|
821
|
-
let $
|
|
822
|
-
let $
|
|
823
|
-
function $
|
|
824
|
-
$
|
|
918
|
+
let $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
|
|
919
|
+
let $6179b936705e76d3$var$hoverCount = 0;
|
|
920
|
+
function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
|
|
921
|
+
$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = true;
|
|
825
922
|
// Clear globalIgnoreEmulatedMouseEvents after a short timeout. iOS fires onPointerEnter
|
|
826
923
|
// with pointerType="mouse" immediately after onPointerUp and before onFocus. On other
|
|
827
924
|
// devices that don't have this quirk, we don't want to ignore a mouse hover sometime in
|
|
828
925
|
// the distant future because a user previously touched the element.
|
|
829
926
|
setTimeout(()=>{
|
|
830
|
-
$
|
|
927
|
+
$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
|
|
831
928
|
}, 50);
|
|
832
929
|
}
|
|
833
|
-
function $
|
|
834
|
-
if (e.pointerType === 'touch') $
|
|
930
|
+
function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
|
|
931
|
+
if (e.pointerType === 'touch') $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
|
|
835
932
|
}
|
|
836
|
-
function $
|
|
933
|
+
function $6179b936705e76d3$var$setupGlobalTouchEvents() {
|
|
837
934
|
if (typeof document === 'undefined') return;
|
|
838
|
-
if (typeof PointerEvent !== 'undefined') document.addEventListener('pointerup', $
|
|
839
|
-
else document.addEventListener('touchend', $
|
|
840
|
-
$
|
|
935
|
+
if (typeof PointerEvent !== 'undefined') document.addEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
936
|
+
else document.addEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
937
|
+
$6179b936705e76d3$var$hoverCount++;
|
|
841
938
|
return ()=>{
|
|
842
|
-
$
|
|
843
|
-
if ($
|
|
844
|
-
if (typeof PointerEvent !== 'undefined') document.removeEventListener('pointerup', $
|
|
845
|
-
else document.removeEventListener('touchend', $
|
|
939
|
+
$6179b936705e76d3$var$hoverCount--;
|
|
940
|
+
if ($6179b936705e76d3$var$hoverCount > 0) return;
|
|
941
|
+
if (typeof PointerEvent !== 'undefined') document.removeEventListener('pointerup', $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
942
|
+
else document.removeEventListener('touchend', $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
846
943
|
};
|
|
847
944
|
}
|
|
848
|
-
function $
|
|
945
|
+
function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
849
946
|
let { onHoverStart: onHoverStart , onHoverChange: onHoverChange , onHoverEnd: onHoverEnd , isDisabled: isDisabled } = props;
|
|
850
|
-
let [isHovered, setHovered] = $
|
|
851
|
-
let state = $
|
|
947
|
+
let [isHovered, setHovered] = $bx7SL$useState(false);
|
|
948
|
+
let state = $bx7SL$useRef({
|
|
852
949
|
isHovered: false,
|
|
853
950
|
ignoreEmulatedMouseEvents: false,
|
|
854
951
|
pointerType: '',
|
|
855
952
|
target: null
|
|
856
953
|
}).current;
|
|
857
|
-
$
|
|
858
|
-
let { hoverProps: hoverProps1 , triggerHoverEnd: triggerHoverEnd1 } = $
|
|
954
|
+
$bx7SL$useEffect($6179b936705e76d3$var$setupGlobalTouchEvents, []);
|
|
955
|
+
let { hoverProps: hoverProps1 , triggerHoverEnd: triggerHoverEnd1 } = $bx7SL$useMemo(()=>{
|
|
859
956
|
let triggerHoverStart = (event, pointerType)=>{
|
|
860
957
|
state.pointerType = pointerType;
|
|
861
958
|
if (isDisabled || pointerType === 'touch' || state.isHovered || !event.currentTarget.contains(event.target)) return;
|
|
@@ -888,7 +985,7 @@ function $52a70f66afabebbb$export$ae780daf29e6d456(props) {
|
|
|
888
985
|
};
|
|
889
986
|
if (typeof PointerEvent !== 'undefined') {
|
|
890
987
|
hoverProps.onPointerEnter = (e)=>{
|
|
891
|
-
if ($
|
|
988
|
+
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === 'mouse') return;
|
|
892
989
|
triggerHoverStart(e, e.pointerType);
|
|
893
990
|
};
|
|
894
991
|
hoverProps.onPointerLeave = (e)=>{
|
|
@@ -899,7 +996,7 @@ function $52a70f66afabebbb$export$ae780daf29e6d456(props) {
|
|
|
899
996
|
state.ignoreEmulatedMouseEvents = true;
|
|
900
997
|
};
|
|
901
998
|
hoverProps.onMouseEnter = (e)=>{
|
|
902
|
-
if (!state.ignoreEmulatedMouseEvents && !$
|
|
999
|
+
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, 'mouse');
|
|
903
1000
|
state.ignoreEmulatedMouseEvents = false;
|
|
904
1001
|
};
|
|
905
1002
|
hoverProps.onMouseLeave = (e)=>{
|
|
@@ -917,7 +1014,7 @@ function $52a70f66afabebbb$export$ae780daf29e6d456(props) {
|
|
|
917
1014
|
isDisabled,
|
|
918
1015
|
state
|
|
919
1016
|
]);
|
|
920
|
-
$
|
|
1017
|
+
$bx7SL$useEffect(()=>{
|
|
921
1018
|
// Call the triggerHoverEnd as soon as isDisabled changes to true
|
|
922
1019
|
// Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
|
|
923
1020
|
if (isDisabled) triggerHoverEnd1({
|
|
@@ -933,13 +1030,13 @@ function $52a70f66afabebbb$export$ae780daf29e6d456(props) {
|
|
|
933
1030
|
}
|
|
934
1031
|
|
|
935
1032
|
|
|
936
|
-
var $
|
|
1033
|
+
var $e0b6e0b68ec7f50f$exports = {};
|
|
937
1034
|
|
|
938
|
-
$parcel$export($
|
|
1035
|
+
$parcel$export($e0b6e0b68ec7f50f$exports, "useInteractOutside", () => $e0b6e0b68ec7f50f$export$872b660ac5a1ff98);
|
|
939
1036
|
|
|
940
|
-
function $
|
|
1037
|
+
function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
941
1038
|
let { ref: ref , onInteractOutside: onInteractOutside , isDisabled: isDisabled , onInteractOutsideStart: onInteractOutsideStart } = props;
|
|
942
|
-
let stateRef = $
|
|
1039
|
+
let stateRef = $bx7SL$useRef({
|
|
943
1040
|
isPointerDown: false,
|
|
944
1041
|
ignoreEmulatedMouseEvents: false,
|
|
945
1042
|
onInteractOutside: onInteractOutside,
|
|
@@ -948,10 +1045,10 @@ function $ba9bc027ba236f10$export$872b660ac5a1ff98(props) {
|
|
|
948
1045
|
let state = stateRef.current;
|
|
949
1046
|
state.onInteractOutside = onInteractOutside;
|
|
950
1047
|
state.onInteractOutsideStart = onInteractOutsideStart;
|
|
951
|
-
$
|
|
1048
|
+
$bx7SL$useEffect(()=>{
|
|
952
1049
|
if (isDisabled) return;
|
|
953
1050
|
let onPointerDown = (e)=>{
|
|
954
|
-
if ($
|
|
1051
|
+
if ($e0b6e0b68ec7f50f$var$isValidEvent(e, ref) && state.onInteractOutside) {
|
|
955
1052
|
if (state.onInteractOutsideStart) state.onInteractOutsideStart(e);
|
|
956
1053
|
state.isPointerDown = true;
|
|
957
1054
|
}
|
|
@@ -959,7 +1056,7 @@ function $ba9bc027ba236f10$export$872b660ac5a1ff98(props) {
|
|
|
959
1056
|
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
960
1057
|
if (typeof PointerEvent !== 'undefined') {
|
|
961
1058
|
let onPointerUp = (e)=>{
|
|
962
|
-
if (state.isPointerDown && state.onInteractOutside && $
|
|
1059
|
+
if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
|
|
963
1060
|
state.isPointerDown = false;
|
|
964
1061
|
state.onInteractOutside(e);
|
|
965
1062
|
}
|
|
@@ -974,14 +1071,14 @@ function $ba9bc027ba236f10$export$872b660ac5a1ff98(props) {
|
|
|
974
1071
|
} else {
|
|
975
1072
|
let onMouseUp = (e)=>{
|
|
976
1073
|
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
977
|
-
else if (state.isPointerDown && state.onInteractOutside && $
|
|
1074
|
+
else if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
|
|
978
1075
|
state.isPointerDown = false;
|
|
979
1076
|
state.onInteractOutside(e);
|
|
980
1077
|
}
|
|
981
1078
|
};
|
|
982
1079
|
let onTouchEnd = (e)=>{
|
|
983
1080
|
state.ignoreEmulatedMouseEvents = true;
|
|
984
|
-
if (state.onInteractOutside && state.isPointerDown && $
|
|
1081
|
+
if (state.onInteractOutside && state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
|
|
985
1082
|
state.isPointerDown = false;
|
|
986
1083
|
state.onInteractOutside(e);
|
|
987
1084
|
}
|
|
@@ -1003,7 +1100,7 @@ function $ba9bc027ba236f10$export$872b660ac5a1ff98(props) {
|
|
|
1003
1100
|
isDisabled
|
|
1004
1101
|
]);
|
|
1005
1102
|
}
|
|
1006
|
-
function $
|
|
1103
|
+
function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
|
|
1007
1104
|
if (event.button > 0) return false;
|
|
1008
1105
|
// if the event target is no longer in the document
|
|
1009
1106
|
if (event.target) {
|
|
@@ -1014,10 +1111,10 @@ function $ba9bc027ba236f10$var$isValidEvent(event, ref) {
|
|
|
1014
1111
|
}
|
|
1015
1112
|
|
|
1016
1113
|
|
|
1017
|
-
var $
|
|
1114
|
+
var $46d819fcbaf35654$exports = {};
|
|
1018
1115
|
|
|
1019
|
-
$parcel$export($
|
|
1020
|
-
function $
|
|
1116
|
+
$parcel$export($46d819fcbaf35654$exports, "useKeyboard", () => $46d819fcbaf35654$export$8f71654801c2f7cd);
|
|
1117
|
+
function $93925083ecbb358c$export$48d1ea6320830260(handler) {
|
|
1021
1118
|
if (!handler) return;
|
|
1022
1119
|
let shouldStopPropagation = true;
|
|
1023
1120
|
return (e)=>{
|
|
@@ -1042,43 +1139,43 @@ function $23f3ec5b42541cce$export$48d1ea6320830260(handler) {
|
|
|
1042
1139
|
}
|
|
1043
1140
|
|
|
1044
1141
|
|
|
1045
|
-
function $
|
|
1142
|
+
function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
|
|
1046
1143
|
return {
|
|
1047
1144
|
keyboardProps: props.isDisabled ? {
|
|
1048
1145
|
} : {
|
|
1049
|
-
onKeyDown: $
|
|
1050
|
-
onKeyUp: $
|
|
1146
|
+
onKeyDown: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyDown),
|
|
1147
|
+
onKeyUp: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyUp)
|
|
1051
1148
|
}
|
|
1052
1149
|
};
|
|
1053
1150
|
}
|
|
1054
1151
|
|
|
1055
1152
|
|
|
1056
|
-
var $
|
|
1153
|
+
var $e8a7022cf87cba2a$exports = {};
|
|
1057
1154
|
|
|
1058
|
-
$parcel$export($
|
|
1155
|
+
$parcel$export($e8a7022cf87cba2a$exports, "useMove", () => $e8a7022cf87cba2a$export$36da96379f79f245);
|
|
1059
1156
|
|
|
1060
1157
|
|
|
1061
1158
|
|
|
1062
|
-
function $
|
|
1159
|
+
function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
1063
1160
|
let { onMoveStart: onMoveStart , onMove: onMove , onMoveEnd: onMoveEnd } = props;
|
|
1064
|
-
let state = $
|
|
1161
|
+
let state = $bx7SL$useRef({
|
|
1065
1162
|
didMove: false,
|
|
1066
1163
|
lastPosition: null,
|
|
1067
1164
|
id: null
|
|
1068
1165
|
});
|
|
1069
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $
|
|
1070
|
-
let moveProps1 = $
|
|
1166
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $bx7SL$useGlobalListeners();
|
|
1167
|
+
let moveProps1 = $bx7SL$useMemo(()=>{
|
|
1071
1168
|
let moveProps = {
|
|
1072
1169
|
};
|
|
1073
1170
|
let start = ()=>{
|
|
1074
|
-
$
|
|
1171
|
+
$14c0b72509d70225$export$16a4697467175487();
|
|
1075
1172
|
state.current.didMove = false;
|
|
1076
1173
|
};
|
|
1077
1174
|
let move = (originalEvent, pointerType, deltaX, deltaY)=>{
|
|
1078
1175
|
if (deltaX === 0 && deltaY === 0) return;
|
|
1079
1176
|
if (!state.current.didMove) {
|
|
1080
1177
|
state.current.didMove = true;
|
|
1081
|
-
onMoveStart
|
|
1178
|
+
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
1082
1179
|
type: 'movestart',
|
|
1083
1180
|
pointerType: pointerType,
|
|
1084
1181
|
shiftKey: originalEvent.shiftKey,
|
|
@@ -1099,8 +1196,8 @@ function $75f78fec52a57cf7$export$36da96379f79f245(props) {
|
|
|
1099
1196
|
});
|
|
1100
1197
|
};
|
|
1101
1198
|
let end = (originalEvent, pointerType)=>{
|
|
1102
|
-
$
|
|
1103
|
-
if (state.current.didMove) onMoveEnd
|
|
1199
|
+
$14c0b72509d70225$export$b0d6fa1ab32e3295();
|
|
1200
|
+
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
1104
1201
|
type: 'moveend',
|
|
1105
1202
|
pointerType: pointerType,
|
|
1106
1203
|
shiftKey: originalEvent.shiftKey,
|
|
@@ -1270,14 +1367,14 @@ function $75f78fec52a57cf7$export$36da96379f79f245(props) {
|
|
|
1270
1367
|
|
|
1271
1368
|
|
|
1272
1369
|
|
|
1273
|
-
var $
|
|
1370
|
+
var $7d0a636d7a4dcefd$exports = {};
|
|
1274
1371
|
|
|
1275
|
-
$parcel$export($
|
|
1372
|
+
$parcel$export($7d0a636d7a4dcefd$exports, "useScrollWheel", () => $7d0a636d7a4dcefd$export$2123ff2b87c81ca);
|
|
1276
1373
|
|
|
1277
1374
|
|
|
1278
|
-
function $
|
|
1375
|
+
function $7d0a636d7a4dcefd$export$2123ff2b87c81ca(props, ref) {
|
|
1279
1376
|
let { onScroll: onScroll , isDisabled: isDisabled } = props;
|
|
1280
|
-
let onScrollHandler = $
|
|
1377
|
+
let onScrollHandler = $bx7SL$useCallback((e)=>{
|
|
1281
1378
|
// If the ctrlKey is pressed, this is a zoom event, do nothing.
|
|
1282
1379
|
if (e.ctrlKey) return;
|
|
1283
1380
|
// stop scrolling the page
|
|
@@ -1290,22 +1387,22 @@ function $d19e70b846cd84a0$export$2123ff2b87c81ca(props, ref) {
|
|
|
1290
1387
|
}, [
|
|
1291
1388
|
onScroll
|
|
1292
1389
|
]);
|
|
1293
|
-
$
|
|
1390
|
+
$bx7SL$useEvent(ref, 'wheel', isDisabled ? null : onScrollHandler);
|
|
1294
1391
|
}
|
|
1295
1392
|
|
|
1296
1393
|
|
|
1297
|
-
var $
|
|
1394
|
+
var $8a26561d2877236e$exports = {};
|
|
1298
1395
|
|
|
1299
|
-
$parcel$export($
|
|
1396
|
+
$parcel$export($8a26561d2877236e$exports, "useLongPress", () => $8a26561d2877236e$export$c24ed0104d07eab9);
|
|
1300
1397
|
|
|
1301
1398
|
|
|
1302
1399
|
|
|
1303
|
-
const $
|
|
1304
|
-
function $
|
|
1305
|
-
let { isDisabled: isDisabled , onLongPressStart: onLongPressStart , onLongPressEnd: onLongPressEnd , onLongPress: onLongPress , threshold: threshold = $
|
|
1306
|
-
const timeRef = $
|
|
1307
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $
|
|
1308
|
-
let { pressProps: pressProps } = $
|
|
1400
|
+
const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
|
|
1401
|
+
function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
|
|
1402
|
+
let { isDisabled: isDisabled , onLongPressStart: onLongPressStart , onLongPressEnd: onLongPressEnd , onLongPress: onLongPress , threshold: threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD , accessibilityDescription: accessibilityDescription } = props;
|
|
1403
|
+
const timeRef = $bx7SL$useRef(null);
|
|
1404
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $bx7SL$useGlobalListeners();
|
|
1405
|
+
let { pressProps: pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
|
|
1309
1406
|
isDisabled: isDisabled,
|
|
1310
1407
|
onPressStart (e1) {
|
|
1311
1408
|
if (e1.pointerType === 'mouse' || e1.pointerType === 'touch') {
|
|
@@ -1352,14 +1449,14 @@ function $ea9746f03755d5ba$export$c24ed0104d07eab9(props) {
|
|
|
1352
1449
|
});
|
|
1353
1450
|
}
|
|
1354
1451
|
});
|
|
1355
|
-
let descriptionProps = $
|
|
1452
|
+
let descriptionProps = $bx7SL$useDescription(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1356
1453
|
return {
|
|
1357
|
-
longPressProps: $
|
|
1454
|
+
longPressProps: $bx7SL$mergeProps(pressProps, descriptionProps)
|
|
1358
1455
|
};
|
|
1359
1456
|
}
|
|
1360
1457
|
|
|
1361
1458
|
|
|
1362
1459
|
|
|
1363
1460
|
|
|
1364
|
-
export {$
|
|
1461
|
+
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};
|
|
1365
1462
|
//# sourceMappingURL=module.js.map
|