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