@react-aria/interactions 3.13.0 → 3.14.0
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/import.mjs +1628 -0
- package/dist/main.js +481 -298
- package/dist/main.js.map +1 -1
- package/dist/module.js +481 -298
- package/dist/module.js.map +1 -1
- package/package.json +10 -5
- package/src/useFocus.ts +1 -1
- package/src/useInteractOutside.ts +9 -4
package/dist/module.js
CHANGED
|
@@ -1,44 +1,88 @@
|
|
|
1
1
|
import {mergeProps as $bx7SL$mergeProps, useSyncRef as $bx7SL$useSyncRef, useGlobalListeners as $bx7SL$useGlobalListeners, isVirtualClick as $bx7SL$isVirtualClick, focusWithoutScrolling as $bx7SL$focusWithoutScrolling, isVirtualPointerEvent as $bx7SL$isVirtualPointerEvent, isIOS as $bx7SL$isIOS, runAfterTransition as $bx7SL$runAfterTransition, useLayoutEffect as $bx7SL$useLayoutEffect, isMac as $bx7SL$isMac, useEvent as $bx7SL$useEvent, useDescription as $bx7SL$useDescription} from "@react-aria/utils";
|
|
2
2
|
import $bx7SL$react, {useRef as $bx7SL$useRef, useContext as $bx7SL$useContext, useState as $bx7SL$useState, useMemo as $bx7SL$useMemo, useEffect as $bx7SL$useEffect, useCallback as $bx7SL$useCallback} from "react";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ /*
|
|
15
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
*
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
+
* governing permissions and limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
/*
|
|
26
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
27
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
28
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
29
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
32
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
33
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
34
|
+
* governing permissions and limitations under the License.
|
|
35
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
36
|
+
// Original licensing for the following can be found in the
|
|
37
|
+
// NOTICE file in the root directory of this source tree.
|
|
38
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
39
|
+
/*
|
|
40
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
41
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
42
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
43
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
44
|
+
*
|
|
45
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
46
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
47
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
48
|
+
* governing permissions and limitations under the License.
|
|
49
|
+
*/
|
|
6
50
|
// Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
|
|
7
51
|
// rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
|
|
8
|
-
let $14c0b72509d70225$var$state =
|
|
9
|
-
let $14c0b72509d70225$var$savedUserSelect =
|
|
52
|
+
let $14c0b72509d70225$var$state = "default";
|
|
53
|
+
let $14c0b72509d70225$var$savedUserSelect = "";
|
|
10
54
|
let $14c0b72509d70225$var$modifiedElementMap = new WeakMap();
|
|
11
55
|
function $14c0b72509d70225$export$16a4697467175487(target) {
|
|
12
|
-
if ($bx7SL$isIOS()) {
|
|
13
|
-
if ($14c0b72509d70225$var$state ===
|
|
56
|
+
if ((0, $bx7SL$isIOS)()) {
|
|
57
|
+
if ($14c0b72509d70225$var$state === "default") {
|
|
14
58
|
$14c0b72509d70225$var$savedUserSelect = document.documentElement.style.webkitUserSelect;
|
|
15
|
-
document.documentElement.style.webkitUserSelect =
|
|
59
|
+
document.documentElement.style.webkitUserSelect = "none";
|
|
16
60
|
}
|
|
17
|
-
$14c0b72509d70225$var$state =
|
|
61
|
+
$14c0b72509d70225$var$state = "disabled";
|
|
18
62
|
} else if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
19
63
|
// If not iOS, store the target's original user-select and change to user-select: none
|
|
20
64
|
// Ignore state since it doesn't apply for non iOS
|
|
21
65
|
$14c0b72509d70225$var$modifiedElementMap.set(target, target.style.userSelect);
|
|
22
|
-
target.style.userSelect =
|
|
66
|
+
target.style.userSelect = "none";
|
|
23
67
|
}
|
|
24
68
|
}
|
|
25
69
|
function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
|
|
26
|
-
if ($bx7SL$isIOS()) {
|
|
70
|
+
if ((0, $bx7SL$isIOS)()) {
|
|
27
71
|
// If the state is already default, there's nothing to do.
|
|
28
72
|
// If it is restoring, then there's no need to queue a second restore.
|
|
29
|
-
if ($14c0b72509d70225$var$state !==
|
|
30
|
-
$14c0b72509d70225$var$state =
|
|
73
|
+
if ($14c0b72509d70225$var$state !== "disabled") return;
|
|
74
|
+
$14c0b72509d70225$var$state = "restoring";
|
|
31
75
|
// There appears to be a delay on iOS where selection still might occur
|
|
32
76
|
// after pointer up, so wait a bit before removing user-select.
|
|
33
77
|
setTimeout(()=>{
|
|
34
78
|
// Wait for any CSS transitions to complete so we don't recompute style
|
|
35
79
|
// for the whole page in the middle of the animation and cause jank.
|
|
36
|
-
$bx7SL$runAfterTransition(()=>{
|
|
80
|
+
(0, $bx7SL$runAfterTransition)(()=>{
|
|
37
81
|
// Avoid race conditions
|
|
38
|
-
if ($14c0b72509d70225$var$state ===
|
|
39
|
-
if (document.documentElement.style.webkitUserSelect ===
|
|
40
|
-
$14c0b72509d70225$var$savedUserSelect =
|
|
41
|
-
$14c0b72509d70225$var$state =
|
|
82
|
+
if ($14c0b72509d70225$var$state === "restoring") {
|
|
83
|
+
if (document.documentElement.style.webkitUserSelect === "none") document.documentElement.style.webkitUserSelect = $14c0b72509d70225$var$savedUserSelect || "";
|
|
84
|
+
$14c0b72509d70225$var$savedUserSelect = "";
|
|
85
|
+
$14c0b72509d70225$var$state = "default";
|
|
42
86
|
}
|
|
43
87
|
});
|
|
44
88
|
}, 300);
|
|
@@ -47,8 +91,8 @@ function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
|
|
|
47
91
|
{
|
|
48
92
|
if (target && $14c0b72509d70225$var$modifiedElementMap.has(target)) {
|
|
49
93
|
let targetOldUserSelect = $14c0b72509d70225$var$modifiedElementMap.get(target);
|
|
50
|
-
if (target.style.userSelect ===
|
|
51
|
-
if (target.getAttribute(
|
|
94
|
+
if (target.style.userSelect === "none") target.style.userSelect = targetOldUserSelect;
|
|
95
|
+
if (target.getAttribute("style") === "") target.removeAttribute("style");
|
|
52
96
|
$14c0b72509d70225$var$modifiedElementMap.delete(target);
|
|
53
97
|
}
|
|
54
98
|
}
|
|
@@ -56,38 +100,48 @@ function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
|
|
|
56
100
|
|
|
57
101
|
|
|
58
102
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
103
|
+
/*
|
|
104
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
105
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
106
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
107
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
108
|
+
*
|
|
109
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
110
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
111
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
112
|
+
* governing permissions and limitations under the License.
|
|
113
|
+
*/
|
|
114
|
+
const $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = (0, $bx7SL$react).createContext(null);
|
|
115
|
+
$ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = "PressResponderContext";
|
|
62
116
|
|
|
63
117
|
|
|
64
118
|
|
|
65
119
|
function $f6c31cce2adf654f$var$usePressResponderContext(props) {
|
|
66
120
|
// Consume context from <PressResponder> and merge with props.
|
|
67
|
-
let context = $bx7SL$useContext($ae1eeba8b9eafd08$export$5165eccb35aaadb5);
|
|
121
|
+
let context = (0, $bx7SL$useContext)((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5));
|
|
68
122
|
if (context) {
|
|
69
123
|
let { register: register , ...contextProps } = context;
|
|
70
|
-
props = $bx7SL$mergeProps(contextProps, props);
|
|
124
|
+
props = (0, $bx7SL$mergeProps)(contextProps, props);
|
|
71
125
|
register();
|
|
72
126
|
}
|
|
73
|
-
$bx7SL$useSyncRef(context, props.ref);
|
|
127
|
+
(0, $bx7SL$useSyncRef)(context, props.ref);
|
|
74
128
|
return props;
|
|
75
129
|
}
|
|
76
130
|
function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
77
|
-
let { onPress:
|
|
131
|
+
let { onPress: onPress , onPressChange: onPressChange , onPressStart: onPressStart , onPressEnd: onPressEnd , onPressUp: onPressUp , isDisabled: isDisabled , isPressed: isPressedProp , preventFocusOnPress: preventFocusOnPress , shouldCancelOnPointerExit: shouldCancelOnPointerExit , allowTextSelectionOnPress: allowTextSelectionOnPress , // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
132
|
ref: _ , ...domProps } = $f6c31cce2adf654f$var$usePressResponderContext(props);
|
|
79
|
-
let propsRef = $bx7SL$useRef(null);
|
|
133
|
+
let propsRef = (0, $bx7SL$useRef)(null);
|
|
80
134
|
propsRef.current = {
|
|
81
|
-
onPress:
|
|
82
|
-
onPressChange:
|
|
83
|
-
onPressStart:
|
|
84
|
-
onPressEnd:
|
|
85
|
-
onPressUp:
|
|
86
|
-
isDisabled:
|
|
135
|
+
onPress: onPress,
|
|
136
|
+
onPressChange: onPressChange,
|
|
137
|
+
onPressStart: onPressStart,
|
|
138
|
+
onPressEnd: onPressEnd,
|
|
139
|
+
onPressUp: onPressUp,
|
|
140
|
+
isDisabled: isDisabled,
|
|
87
141
|
shouldCancelOnPointerExit: shouldCancelOnPointerExit
|
|
88
142
|
};
|
|
89
|
-
let [isPressed, setPressed] = $bx7SL$useState(false);
|
|
90
|
-
let ref = $bx7SL$useRef({
|
|
143
|
+
let [isPressed, setPressed] = (0, $bx7SL$useState)(false);
|
|
144
|
+
let ref = (0, $bx7SL$useRef)({
|
|
91
145
|
isPressed: false,
|
|
92
146
|
ignoreEmulatedMouseEvents: false,
|
|
93
147
|
ignoreClickAfterPress: false,
|
|
@@ -97,14 +151,14 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
97
151
|
isOverTarget: false,
|
|
98
152
|
pointerType: null
|
|
99
153
|
});
|
|
100
|
-
let { addGlobalListener: addGlobalListener , removeAllGlobalListeners: removeAllGlobalListeners } = $bx7SL$useGlobalListeners();
|
|
101
|
-
let
|
|
154
|
+
let { addGlobalListener: addGlobalListener , removeAllGlobalListeners: removeAllGlobalListeners } = (0, $bx7SL$useGlobalListeners)();
|
|
155
|
+
let pressProps = (0, $bx7SL$useMemo)(()=>{
|
|
102
156
|
let state = ref.current;
|
|
103
157
|
let triggerPressStart = (originalEvent, pointerType)=>{
|
|
104
158
|
let { onPressStart: onPressStart , onPressChange: onPressChange , isDisabled: isDisabled } = propsRef.current;
|
|
105
159
|
if (isDisabled || state.didFirePressStart) return;
|
|
106
160
|
if (onPressStart) onPressStart({
|
|
107
|
-
type:
|
|
161
|
+
type: "pressstart",
|
|
108
162
|
pointerType: pointerType,
|
|
109
163
|
target: originalEvent.currentTarget,
|
|
110
164
|
shiftKey: originalEvent.shiftKey,
|
|
@@ -122,7 +176,7 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
122
176
|
state.ignoreClickAfterPress = true;
|
|
123
177
|
state.didFirePressStart = false;
|
|
124
178
|
if (onPressEnd) onPressEnd({
|
|
125
|
-
type:
|
|
179
|
+
type: "pressend",
|
|
126
180
|
pointerType: pointerType,
|
|
127
181
|
target: originalEvent.currentTarget,
|
|
128
182
|
shiftKey: originalEvent.shiftKey,
|
|
@@ -133,7 +187,7 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
133
187
|
if (onPressChange) onPressChange(false);
|
|
134
188
|
setPressed(false);
|
|
135
189
|
if (onPress && wasPressed && !isDisabled) onPress({
|
|
136
|
-
type:
|
|
190
|
+
type: "press",
|
|
137
191
|
pointerType: pointerType,
|
|
138
192
|
target: originalEvent.currentTarget,
|
|
139
193
|
shiftKey: originalEvent.shiftKey,
|
|
@@ -146,7 +200,7 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
146
200
|
let { onPressUp: onPressUp , isDisabled: isDisabled } = propsRef.current;
|
|
147
201
|
if (isDisabled) return;
|
|
148
202
|
if (onPressUp) onPressUp({
|
|
149
|
-
type:
|
|
203
|
+
type: "pressup",
|
|
150
204
|
pointerType: pointerType,
|
|
151
205
|
target: originalEvent.currentTarget,
|
|
152
206
|
shiftKey: originalEvent.shiftKey,
|
|
@@ -163,7 +217,7 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
163
217
|
state.activePointerId = null;
|
|
164
218
|
state.pointerType = null;
|
|
165
219
|
removeAllGlobalListeners();
|
|
166
|
-
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
|
|
220
|
+
if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(state.target);
|
|
167
221
|
}
|
|
168
222
|
};
|
|
169
223
|
let pressProps = {
|
|
@@ -177,32 +231,32 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
177
231
|
if (!state.isPressed && !e.repeat) {
|
|
178
232
|
state.target = e.currentTarget;
|
|
179
233
|
state.isPressed = true;
|
|
180
|
-
triggerPressStart(e,
|
|
234
|
+
triggerPressStart(e, "keyboard");
|
|
181
235
|
// Focus may move before the key up event, so register the event on the document
|
|
182
236
|
// instead of the same element where the key down event occurred.
|
|
183
|
-
addGlobalListener(document,
|
|
237
|
+
addGlobalListener(document, "keyup", onKeyUp, false);
|
|
184
238
|
}
|
|
185
|
-
} else if (e.key ===
|
|
239
|
+
} else if (e.key === "Enter" && $f6c31cce2adf654f$var$isHTMLAnchorLink(e.currentTarget)) // If the target is a link, we won't have handled this above because we want the default
|
|
186
240
|
// browser behavior to open the link when pressing Enter. But we still need to prevent
|
|
187
241
|
// default so that elements above do not also handle it (e.g. table row).
|
|
188
242
|
e.stopPropagation();
|
|
189
243
|
},
|
|
190
244
|
onKeyUp (e) {
|
|
191
|
-
if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && !e.repeat && e.currentTarget.contains(e.target)) triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e),
|
|
245
|
+
if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && !e.repeat && e.currentTarget.contains(e.target)) triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e), "keyboard");
|
|
192
246
|
},
|
|
193
247
|
onClick (e) {
|
|
194
248
|
if (e && !e.currentTarget.contains(e.target)) return;
|
|
195
249
|
if (e && e.button === 0) {
|
|
196
250
|
e.stopPropagation();
|
|
197
|
-
if (
|
|
251
|
+
if (isDisabled) e.preventDefault();
|
|
198
252
|
// If triggered from a screen reader or by using element.click(),
|
|
199
253
|
// trigger as if it were a keyboard click.
|
|
200
|
-
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType ===
|
|
254
|
+
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === "virtual" || (0, $bx7SL$isVirtualClick)(e.nativeEvent))) {
|
|
201
255
|
// Ensure the element receives focus (VoiceOver on iOS does not do this)
|
|
202
|
-
if (!
|
|
203
|
-
triggerPressStart(e,
|
|
204
|
-
triggerPressUp(e,
|
|
205
|
-
triggerPressEnd(e,
|
|
256
|
+
if (!isDisabled && !preventFocusOnPress) (0, $bx7SL$focusWithoutScrolling)(e.currentTarget);
|
|
257
|
+
triggerPressStart(e, "virtual");
|
|
258
|
+
triggerPressUp(e, "virtual");
|
|
259
|
+
triggerPressEnd(e, "virtual");
|
|
206
260
|
}
|
|
207
261
|
state.ignoreEmulatedMouseEvents = false;
|
|
208
262
|
state.ignoreClickAfterPress = false;
|
|
@@ -215,14 +269,14 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
215
269
|
e.stopPropagation();
|
|
216
270
|
state.isPressed = false;
|
|
217
271
|
let target = e.target;
|
|
218
|
-
triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e),
|
|
272
|
+
triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
|
|
219
273
|
removeAllGlobalListeners();
|
|
220
274
|
// If the target is a link, trigger the click method to open the URL,
|
|
221
275
|
// but defer triggering pressEnd until onClick event handler.
|
|
222
|
-
if (state.target instanceof HTMLElement && state.target.contains(target) && ($f6c31cce2adf654f$var$isHTMLAnchorLink(state.target) || state.target.getAttribute(
|
|
276
|
+
if (state.target instanceof HTMLElement && state.target.contains(target) && ($f6c31cce2adf654f$var$isHTMLAnchorLink(state.target) || state.target.getAttribute("role") === "link")) state.target.click();
|
|
223
277
|
}
|
|
224
278
|
};
|
|
225
|
-
if (typeof PointerEvent !==
|
|
279
|
+
if (typeof PointerEvent !== "undefined") {
|
|
226
280
|
pressProps.onPointerDown = (e)=>{
|
|
227
281
|
// Only handle left clicks, and ignore events that bubbled through portals.
|
|
228
282
|
if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
|
|
@@ -230,8 +284,8 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
230
284
|
// Ignore and let the onClick handler take care of it instead.
|
|
231
285
|
// https://bugs.webkit.org/show_bug.cgi?id=222627
|
|
232
286
|
// https://bugs.webkit.org/show_bug.cgi?id=223202
|
|
233
|
-
if ($bx7SL$isVirtualPointerEvent(e.nativeEvent)) {
|
|
234
|
-
state.pointerType =
|
|
287
|
+
if ((0, $bx7SL$isVirtualPointerEvent)(e.nativeEvent)) {
|
|
288
|
+
state.pointerType = "virtual";
|
|
235
289
|
return;
|
|
236
290
|
}
|
|
237
291
|
// Due to browser inconsistencies, especially on mobile browsers, we prevent
|
|
@@ -244,12 +298,12 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
244
298
|
state.isOverTarget = true;
|
|
245
299
|
state.activePointerId = e.pointerId;
|
|
246
300
|
state.target = e.currentTarget;
|
|
247
|
-
if (!
|
|
248
|
-
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$16a4697467175487(state.target);
|
|
301
|
+
if (!isDisabled && !preventFocusOnPress) (0, $bx7SL$focusWithoutScrolling)(e.currentTarget);
|
|
302
|
+
if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$16a4697467175487)(state.target);
|
|
249
303
|
triggerPressStart(e, state.pointerType);
|
|
250
|
-
addGlobalListener(document,
|
|
251
|
-
addGlobalListener(document,
|
|
252
|
-
addGlobalListener(document,
|
|
304
|
+
addGlobalListener(document, "pointermove", onPointerMove, false);
|
|
305
|
+
addGlobalListener(document, "pointerup", onPointerUp, false);
|
|
306
|
+
addGlobalListener(document, "pointercancel", onPointerCancel, false);
|
|
253
307
|
}
|
|
254
308
|
};
|
|
255
309
|
pressProps.onMouseDown = (e)=>{
|
|
@@ -264,7 +318,7 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
264
318
|
};
|
|
265
319
|
pressProps.onPointerUp = (e)=>{
|
|
266
320
|
// iOS fires pointerup with zero width and height, so check the pointerType recorded during pointerdown.
|
|
267
|
-
if (!e.currentTarget.contains(e.target) || state.pointerType ===
|
|
321
|
+
if (!e.currentTarget.contains(e.target) || state.pointerType === "virtual") return;
|
|
268
322
|
// Only handle left clicks
|
|
269
323
|
// Safari on iOS sometimes fires pointerup events, even
|
|
270
324
|
// when the touch isn't over the target, so double check.
|
|
@@ -295,7 +349,7 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
295
349
|
state.activePointerId = null;
|
|
296
350
|
state.pointerType = null;
|
|
297
351
|
removeAllGlobalListeners();
|
|
298
|
-
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
|
|
352
|
+
if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(state.target);
|
|
299
353
|
}
|
|
300
354
|
};
|
|
301
355
|
let onPointerCancel = (e)=>{
|
|
@@ -318,10 +372,10 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
318
372
|
state.isPressed = true;
|
|
319
373
|
state.isOverTarget = true;
|
|
320
374
|
state.target = e.currentTarget;
|
|
321
|
-
state.pointerType = $bx7SL$isVirtualClick(e.nativeEvent) ?
|
|
322
|
-
if (!
|
|
375
|
+
state.pointerType = (0, $bx7SL$isVirtualClick)(e.nativeEvent) ? "virtual" : "mouse";
|
|
376
|
+
if (!isDisabled && !preventFocusOnPress) (0, $bx7SL$focusWithoutScrolling)(e.currentTarget);
|
|
323
377
|
triggerPressStart(e, state.pointerType);
|
|
324
|
-
addGlobalListener(document,
|
|
378
|
+
addGlobalListener(document, "mouseup", onMouseUp, false);
|
|
325
379
|
};
|
|
326
380
|
pressProps.onMouseEnter = (e)=>{
|
|
327
381
|
if (!e.currentTarget.contains(e.target)) return;
|
|
@@ -367,13 +421,13 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
367
421
|
state.isOverTarget = true;
|
|
368
422
|
state.isPressed = true;
|
|
369
423
|
state.target = e.currentTarget;
|
|
370
|
-
state.pointerType =
|
|
424
|
+
state.pointerType = "touch";
|
|
371
425
|
// Due to browser inconsistencies, especially on mobile browsers, we prevent default
|
|
372
426
|
// on the emulated mouse event and handle focusing the pressable element ourselves.
|
|
373
|
-
if (!
|
|
374
|
-
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$16a4697467175487(state.target);
|
|
427
|
+
if (!isDisabled && !preventFocusOnPress) (0, $bx7SL$focusWithoutScrolling)(e.currentTarget);
|
|
428
|
+
if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$16a4697467175487)(state.target);
|
|
375
429
|
triggerPressStart(e, state.pointerType);
|
|
376
|
-
addGlobalListener(window,
|
|
430
|
+
addGlobalListener(window, "scroll", onScroll, true);
|
|
377
431
|
};
|
|
378
432
|
pressProps.onTouchMove = (e)=>{
|
|
379
433
|
if (!e.currentTarget.contains(e.target)) return;
|
|
@@ -404,7 +458,7 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
404
458
|
state.activePointerId = null;
|
|
405
459
|
state.isOverTarget = false;
|
|
406
460
|
state.ignoreEmulatedMouseEvents = true;
|
|
407
|
-
if (!allowTextSelectionOnPress) $14c0b72509d70225$export$b0d6fa1ab32e3295(state.target);
|
|
461
|
+
if (!allowTextSelectionOnPress) (0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(state.target);
|
|
408
462
|
removeAllGlobalListeners();
|
|
409
463
|
};
|
|
410
464
|
pressProps.onTouchCancel = (e)=>{
|
|
@@ -429,37 +483,39 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
|
|
|
429
483
|
return pressProps;
|
|
430
484
|
}, [
|
|
431
485
|
addGlobalListener,
|
|
432
|
-
|
|
486
|
+
isDisabled,
|
|
433
487
|
preventFocusOnPress,
|
|
434
488
|
removeAllGlobalListeners,
|
|
435
489
|
allowTextSelectionOnPress
|
|
436
490
|
]);
|
|
437
491
|
// Remove user-select: none in case component unmounts immediately after pressStart
|
|
438
492
|
// eslint-disable-next-line arrow-body-style
|
|
439
|
-
$bx7SL$useEffect(()=>{
|
|
493
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
440
494
|
return ()=>{
|
|
441
495
|
if (!allowTextSelectionOnPress) // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
442
|
-
$14c0b72509d70225$export$b0d6fa1ab32e3295(ref.current.target);
|
|
496
|
+
(0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(ref.current.target);
|
|
443
497
|
};
|
|
444
498
|
}, [
|
|
445
499
|
allowTextSelectionOnPress
|
|
446
500
|
]);
|
|
447
501
|
return {
|
|
448
502
|
isPressed: isPressedProp || isPressed,
|
|
449
|
-
pressProps: $bx7SL$mergeProps(domProps,
|
|
503
|
+
pressProps: (0, $bx7SL$mergeProps)(domProps, pressProps)
|
|
450
504
|
};
|
|
451
505
|
}
|
|
452
506
|
function $f6c31cce2adf654f$var$isHTMLAnchorLink(target) {
|
|
453
|
-
return target.tagName ===
|
|
507
|
+
return target.tagName === "A" && target.hasAttribute("href");
|
|
454
508
|
}
|
|
455
509
|
function $f6c31cce2adf654f$var$isValidKeyboardEvent(event, currentTarget) {
|
|
456
510
|
const { key: key , code: code } = event;
|
|
457
511
|
const element = currentTarget;
|
|
458
|
-
const role = element.getAttribute(
|
|
512
|
+
const role = element.getAttribute("role");
|
|
459
513
|
// Accessibility for keyboards. Space and Enter only.
|
|
460
514
|
// "Spacebar" is for IE 11
|
|
461
|
-
return (key ===
|
|
462
|
-
|
|
515
|
+
return (key === "Enter" || key === " " || key === "Spacebar" || code === "Space") && !(element instanceof HTMLInputElement && !$f6c31cce2adf654f$var$isValidInputKey(element, key) || element instanceof HTMLTextAreaElement || element.isContentEditable) && // A link with a valid href should be handled natively,
|
|
516
|
+
// unless it also has role='button' and was triggered using Space.
|
|
517
|
+
(!$f6c31cce2adf654f$var$isHTMLAnchorLink(element) || role === "button" && key !== "Enter") && // An element with role='link' should only trigger with Enter key
|
|
518
|
+
!(role === "link" && key !== "Enter");
|
|
463
519
|
}
|
|
464
520
|
function $f6c31cce2adf654f$var$getTouchFromEvent(event) {
|
|
465
521
|
const { targetTouches: targetTouches } = event;
|
|
@@ -511,51 +567,60 @@ function $f6c31cce2adf654f$var$shouldPreventDefault(target) {
|
|
|
511
567
|
}
|
|
512
568
|
function $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(target, key) {
|
|
513
569
|
if (target instanceof HTMLInputElement) return !$f6c31cce2adf654f$var$isValidInputKey(target, key);
|
|
514
|
-
if (target instanceof HTMLButtonElement) return target.type !==
|
|
570
|
+
if (target instanceof HTMLButtonElement) return target.type !== "submit";
|
|
515
571
|
return true;
|
|
516
572
|
}
|
|
517
573
|
const $f6c31cce2adf654f$var$nonTextInputTypes = new Set([
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
574
|
+
"checkbox",
|
|
575
|
+
"radio",
|
|
576
|
+
"range",
|
|
577
|
+
"color",
|
|
578
|
+
"file",
|
|
579
|
+
"image",
|
|
580
|
+
"button",
|
|
581
|
+
"submit",
|
|
582
|
+
"reset"
|
|
527
583
|
]);
|
|
528
584
|
function $f6c31cce2adf654f$var$isValidInputKey(target, key) {
|
|
529
585
|
// Only space should toggle checkboxes and radios, not enter.
|
|
530
|
-
return target.type ===
|
|
586
|
+
return target.type === "checkbox" || target.type === "radio" ? key === " " : $f6c31cce2adf654f$var$nonTextInputTypes.has(target.type);
|
|
531
587
|
}
|
|
532
588
|
|
|
533
589
|
|
|
534
590
|
|
|
535
|
-
const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ $bx7SL$react.forwardRef(({ children: children , ...props }, ref)=>{
|
|
536
|
-
let newRef = $bx7SL$useRef();
|
|
591
|
+
const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ (0, $bx7SL$react).forwardRef(({ children: children , ...props }, ref)=>{
|
|
592
|
+
let newRef = (0, $bx7SL$useRef)();
|
|
537
593
|
ref = ref !== null && ref !== void 0 ? ref : newRef;
|
|
538
|
-
let { pressProps: pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
|
|
594
|
+
let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
|
|
539
595
|
...props,
|
|
540
596
|
ref: ref
|
|
541
597
|
});
|
|
542
|
-
let child = $bx7SL$react.Children.only(children);
|
|
543
|
-
return
|
|
598
|
+
let child = (0, $bx7SL$react).Children.only(children);
|
|
599
|
+
return /*#__PURE__*/ (0, $bx7SL$react).cloneElement(child, // @ts-ignore
|
|
544
600
|
{
|
|
545
601
|
ref: ref,
|
|
546
|
-
|
|
547
|
-
})
|
|
602
|
+
...(0, $bx7SL$mergeProps)(child.props, pressProps)
|
|
603
|
+
});
|
|
548
604
|
});
|
|
549
605
|
|
|
550
606
|
|
|
607
|
+
/*
|
|
608
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
609
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
610
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
611
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
612
|
+
*
|
|
613
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
614
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
615
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
616
|
+
* governing permissions and limitations under the License.
|
|
617
|
+
*/
|
|
551
618
|
|
|
552
619
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
let
|
|
556
|
-
let
|
|
557
|
-
let context = $bx7SL$mergeProps(prevContext || {
|
|
558
|
-
}, {
|
|
620
|
+
const $f1ab8c75478c6f73$export$3351871ee4b288b8 = /*#__PURE__*/ (0, $bx7SL$react).forwardRef(({ children: children , ...props }, ref)=>{
|
|
621
|
+
let isRegistered = (0, $bx7SL$useRef)(false);
|
|
622
|
+
let prevContext = (0, $bx7SL$useContext)((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5));
|
|
623
|
+
let context = (0, $bx7SL$mergeProps)(prevContext || {}, {
|
|
559
624
|
...props,
|
|
560
625
|
ref: ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref),
|
|
561
626
|
register () {
|
|
@@ -563,18 +628,42 @@ const $f1ab8c75478c6f73$export$3351871ee4b288b8 = /*#__PURE__*/ $bx7SL$react.for
|
|
|
563
628
|
if (prevContext) prevContext.register();
|
|
564
629
|
}
|
|
565
630
|
});
|
|
566
|
-
$bx7SL$useSyncRef(prevContext, ref);
|
|
567
|
-
$bx7SL$useEffect(()=>{
|
|
631
|
+
(0, $bx7SL$useSyncRef)(prevContext, ref);
|
|
632
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
568
633
|
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.");
|
|
569
634
|
}, []);
|
|
570
|
-
return
|
|
635
|
+
return /*#__PURE__*/ (0, $bx7SL$react).createElement((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5).Provider, {
|
|
571
636
|
value: context
|
|
572
|
-
}, children)
|
|
637
|
+
}, children);
|
|
573
638
|
});
|
|
574
639
|
|
|
575
640
|
|
|
641
|
+
/*
|
|
642
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
643
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
644
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
645
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
646
|
+
*
|
|
647
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
648
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
649
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
650
|
+
* governing permissions and limitations under the License.
|
|
651
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
652
|
+
// Original licensing for the following can be found in the
|
|
653
|
+
// NOTICE file in the root directory of this source tree.
|
|
654
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
576
655
|
|
|
577
|
-
|
|
656
|
+
/*
|
|
657
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
658
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
659
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
660
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
661
|
+
*
|
|
662
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
663
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
664
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
665
|
+
* governing permissions and limitations under the License.
|
|
666
|
+
*/
|
|
578
667
|
|
|
579
668
|
class $8a9cb279dc87e130$export$905e7fc544a71f36 {
|
|
580
669
|
isDefaultPrevented() {
|
|
@@ -586,14 +675,12 @@ class $8a9cb279dc87e130$export$905e7fc544a71f36 {
|
|
|
586
675
|
}
|
|
587
676
|
stopPropagation() {
|
|
588
677
|
this.nativeEvent.stopPropagation();
|
|
589
|
-
this.isPropagationStopped = ()=>true
|
|
590
|
-
;
|
|
678
|
+
this.isPropagationStopped = ()=>true;
|
|
591
679
|
}
|
|
592
680
|
isPropagationStopped() {
|
|
593
681
|
return false;
|
|
594
682
|
}
|
|
595
|
-
persist() {
|
|
596
|
-
}
|
|
683
|
+
persist() {}
|
|
597
684
|
constructor(type, nativeEvent){
|
|
598
685
|
this.nativeEvent = nativeEvent;
|
|
599
686
|
this.target = nativeEvent.target;
|
|
@@ -609,7 +696,7 @@ class $8a9cb279dc87e130$export$905e7fc544a71f36 {
|
|
|
609
696
|
}
|
|
610
697
|
}
|
|
611
698
|
function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
612
|
-
let stateRef = $bx7SL$useRef({
|
|
699
|
+
let stateRef = (0, $bx7SL$useRef)({
|
|
613
700
|
isFocused: false,
|
|
614
701
|
onBlur: onBlur,
|
|
615
702
|
observer: null
|
|
@@ -617,7 +704,7 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
|
617
704
|
stateRef.current.onBlur = onBlur;
|
|
618
705
|
// Clean up MutationObserver on unmount. See below.
|
|
619
706
|
// eslint-disable-next-line arrow-body-style
|
|
620
|
-
$bx7SL$useLayoutEffect(()=>{
|
|
707
|
+
(0, $bx7SL$useLayoutEffect)(()=>{
|
|
621
708
|
const state = stateRef.current;
|
|
622
709
|
return ()=>{
|
|
623
710
|
if (state.observer) {
|
|
@@ -627,33 +714,33 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
|
627
714
|
};
|
|
628
715
|
}, []);
|
|
629
716
|
// This function is called during a React onFocus event.
|
|
630
|
-
return $bx7SL$useCallback((
|
|
717
|
+
return (0, $bx7SL$useCallback)((e)=>{
|
|
631
718
|
// React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
|
|
632
719
|
// Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
|
|
633
720
|
// MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
|
|
634
721
|
// For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
|
|
635
|
-
if (
|
|
722
|
+
if (e.target instanceof HTMLButtonElement || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement) {
|
|
636
723
|
stateRef.current.isFocused = true;
|
|
637
|
-
let target =
|
|
724
|
+
let target = e.target;
|
|
638
725
|
let onBlurHandler = (e)=>{
|
|
639
726
|
var // For backward compatibility, dispatch a (fake) React synthetic event.
|
|
640
|
-
|
|
727
|
+
_stateRef_current, _stateRef_current_onBlur;
|
|
641
728
|
stateRef.current.isFocused = false;
|
|
642
|
-
if (target.disabled) (
|
|
729
|
+
if (target.disabled) (_stateRef_current_onBlur = (_stateRef_current = stateRef.current).onBlur) === null || _stateRef_current_onBlur === void 0 ? void 0 : _stateRef_current_onBlur.call(_stateRef_current, new $8a9cb279dc87e130$export$905e7fc544a71f36("blur", e));
|
|
643
730
|
// We no longer need the MutationObserver once the target is blurred.
|
|
644
731
|
if (stateRef.current.observer) {
|
|
645
732
|
stateRef.current.observer.disconnect();
|
|
646
733
|
stateRef.current.observer = null;
|
|
647
734
|
}
|
|
648
735
|
};
|
|
649
|
-
target.addEventListener(
|
|
736
|
+
target.addEventListener("focusout", onBlurHandler, {
|
|
650
737
|
once: true
|
|
651
738
|
});
|
|
652
739
|
stateRef.current.observer = new MutationObserver(()=>{
|
|
653
740
|
if (stateRef.current.isFocused && target.disabled) {
|
|
654
741
|
stateRef.current.observer.disconnect();
|
|
655
|
-
target.dispatchEvent(new FocusEvent(
|
|
656
|
-
target.dispatchEvent(new FocusEvent(
|
|
742
|
+
target.dispatchEvent(new FocusEvent("blur"));
|
|
743
|
+
target.dispatchEvent(new FocusEvent("focusout", {
|
|
657
744
|
bubbles: true
|
|
658
745
|
}));
|
|
659
746
|
}
|
|
@@ -661,7 +748,7 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
|
661
748
|
stateRef.current.observer.observe(target, {
|
|
662
749
|
attributes: true,
|
|
663
750
|
attributeFilter: [
|
|
664
|
-
|
|
751
|
+
"disabled"
|
|
665
752
|
]
|
|
666
753
|
});
|
|
667
754
|
}
|
|
@@ -671,7 +758,7 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
|
671
758
|
|
|
672
759
|
function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
673
760
|
let { isDisabled: isDisabled , onFocus: onFocusProp , onBlur: onBlurProp , onFocusChange: onFocusChange } = props;
|
|
674
|
-
const onBlur = $bx7SL$useCallback((e)=>{
|
|
761
|
+
const onBlur = (0, $bx7SL$useCallback)((e)=>{
|
|
675
762
|
if (e.target === e.currentTarget) {
|
|
676
763
|
if (onBlurProp) onBlurProp(e);
|
|
677
764
|
if (onFocusChange) onFocusChange(false);
|
|
@@ -681,8 +768,8 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
681
768
|
onBlurProp,
|
|
682
769
|
onFocusChange
|
|
683
770
|
]);
|
|
684
|
-
const onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
|
|
685
|
-
const onFocus = $bx7SL$useCallback((e)=>{
|
|
771
|
+
const onSyntheticFocus = (0, $8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
|
|
772
|
+
const onFocus = (0, $bx7SL$useCallback)((e)=>{
|
|
686
773
|
if (e.target === e.currentTarget) {
|
|
687
774
|
if (onFocusProp) onFocusProp(e);
|
|
688
775
|
if (onFocusChange) onFocusChange(true);
|
|
@@ -696,12 +783,26 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
696
783
|
return {
|
|
697
784
|
focusProps: {
|
|
698
785
|
onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
|
|
699
|
-
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur :
|
|
786
|
+
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
|
|
700
787
|
}
|
|
701
788
|
};
|
|
702
789
|
}
|
|
703
790
|
|
|
704
791
|
|
|
792
|
+
/*
|
|
793
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
794
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
795
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
796
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
797
|
+
*
|
|
798
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
799
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
800
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
801
|
+
* governing permissions and limitations under the License.
|
|
802
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
803
|
+
// Original licensing for the following can be found in the
|
|
804
|
+
// NOTICE file in the root directory of this source tree.
|
|
805
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
705
806
|
|
|
706
807
|
|
|
707
808
|
let $507fabe10e71c6fb$var$currentModality = null;
|
|
@@ -721,26 +822,26 @@ function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
|
|
|
721
822
|
* Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
722
823
|
*/ function $507fabe10e71c6fb$var$isValidKey(e) {
|
|
723
824
|
// Control and Shift keys trigger when navigating back to the tab with keyboard.
|
|
724
|
-
return !(e.metaKey ||
|
|
825
|
+
return !(e.metaKey || !(0, $bx7SL$isMac)() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
|
725
826
|
}
|
|
726
827
|
function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
|
|
727
828
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
728
829
|
if ($507fabe10e71c6fb$var$isValidKey(e)) {
|
|
729
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
730
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
830
|
+
$507fabe10e71c6fb$var$currentModality = "keyboard";
|
|
831
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("keyboard", e);
|
|
731
832
|
}
|
|
732
833
|
}
|
|
733
834
|
function $507fabe10e71c6fb$var$handlePointerEvent(e) {
|
|
734
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
735
|
-
if (e.type ===
|
|
835
|
+
$507fabe10e71c6fb$var$currentModality = "pointer";
|
|
836
|
+
if (e.type === "mousedown" || e.type === "pointerdown") {
|
|
736
837
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
737
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
838
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("pointer", e);
|
|
738
839
|
}
|
|
739
840
|
}
|
|
740
841
|
function $507fabe10e71c6fb$var$handleClickEvent(e) {
|
|
741
|
-
if ($bx7SL$isVirtualClick(e)) {
|
|
842
|
+
if ((0, $bx7SL$isVirtualClick)(e)) {
|
|
742
843
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
743
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
844
|
+
$507fabe10e71c6fb$var$currentModality = "virtual";
|
|
744
845
|
}
|
|
745
846
|
}
|
|
746
847
|
function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
@@ -751,8 +852,8 @@ function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
|
751
852
|
// If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
|
|
752
853
|
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
753
854
|
if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
|
|
754
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
755
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
855
|
+
$507fabe10e71c6fb$var$currentModality = "virtual";
|
|
856
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("virtual", e);
|
|
756
857
|
}
|
|
757
858
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
758
859
|
$507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
@@ -766,7 +867,7 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
766
867
|
/**
|
|
767
868
|
* Setup global event listeners to control when keyboard focus style should be visible.
|
|
768
869
|
*/ function $507fabe10e71c6fb$var$setupGlobalFocusEvents() {
|
|
769
|
-
if (typeof window ===
|
|
870
|
+
if (typeof window === "undefined" || $507fabe10e71c6fb$var$hasSetupGlobalListeners) return;
|
|
770
871
|
// Programmatic focus() calls shouldn't affect the current input modality.
|
|
771
872
|
// However, we need to detect other cases when a focus event occurs without
|
|
772
873
|
// a preceding user event (e.g. screen reader focus). Overriding the focus
|
|
@@ -776,30 +877,30 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
776
877
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
777
878
|
focus.apply(this, arguments);
|
|
778
879
|
};
|
|
779
|
-
document.addEventListener(
|
|
780
|
-
document.addEventListener(
|
|
781
|
-
document.addEventListener(
|
|
880
|
+
document.addEventListener("keydown", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
881
|
+
document.addEventListener("keyup", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
882
|
+
document.addEventListener("click", $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
782
883
|
// Register focus events on the window so they are sure to happen
|
|
783
884
|
// before React's event listeners (registered on the document).
|
|
784
|
-
window.addEventListener(
|
|
785
|
-
window.addEventListener(
|
|
786
|
-
if (typeof PointerEvent !==
|
|
787
|
-
document.addEventListener(
|
|
788
|
-
document.addEventListener(
|
|
789
|
-
document.addEventListener(
|
|
885
|
+
window.addEventListener("focus", $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
886
|
+
window.addEventListener("blur", $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
887
|
+
if (typeof PointerEvent !== "undefined") {
|
|
888
|
+
document.addEventListener("pointerdown", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
889
|
+
document.addEventListener("pointermove", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
890
|
+
document.addEventListener("pointerup", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
790
891
|
} else {
|
|
791
|
-
document.addEventListener(
|
|
792
|
-
document.addEventListener(
|
|
793
|
-
document.addEventListener(
|
|
892
|
+
document.addEventListener("mousedown", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
893
|
+
document.addEventListener("mousemove", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
894
|
+
document.addEventListener("mouseup", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
794
895
|
}
|
|
795
896
|
$507fabe10e71c6fb$var$hasSetupGlobalListeners = true;
|
|
796
897
|
}
|
|
797
|
-
if (typeof document !==
|
|
798
|
-
if (document.readyState !==
|
|
799
|
-
else document.addEventListener(
|
|
898
|
+
if (typeof document !== "undefined") {
|
|
899
|
+
if (document.readyState !== "loading") $507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
900
|
+
else document.addEventListener("DOMContentLoaded", $507fabe10e71c6fb$var$setupGlobalFocusEvents);
|
|
800
901
|
}
|
|
801
902
|
function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
|
|
802
|
-
return $507fabe10e71c6fb$var$currentModality !==
|
|
903
|
+
return $507fabe10e71c6fb$var$currentModality !== "pointer";
|
|
803
904
|
}
|
|
804
905
|
function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
|
|
805
906
|
return $507fabe10e71c6fb$var$currentModality;
|
|
@@ -810,8 +911,8 @@ function $507fabe10e71c6fb$export$8397ddfc504fdb9a(modality) {
|
|
|
810
911
|
}
|
|
811
912
|
function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
|
|
812
913
|
$507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
813
|
-
let [modality, setModality] = $bx7SL$useState($507fabe10e71c6fb$var$currentModality);
|
|
814
|
-
$bx7SL$useEffect(()=>{
|
|
914
|
+
let [modality, setModality] = (0, $bx7SL$useState)($507fabe10e71c6fb$var$currentModality);
|
|
915
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
815
916
|
let handler = ()=>{
|
|
816
917
|
setModality($507fabe10e71c6fb$var$currentModality);
|
|
817
918
|
};
|
|
@@ -826,14 +927,13 @@ function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
|
|
|
826
927
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
827
928
|
* focus visible style can be properly set.
|
|
828
929
|
*/ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
|
829
|
-
return !(isTextInput && modality ===
|
|
930
|
+
return !(isTextInput && modality === "keyboard" && e instanceof KeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
|
830
931
|
}
|
|
831
|
-
function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {
|
|
832
|
-
}) {
|
|
932
|
+
function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {}) {
|
|
833
933
|
let { isTextInput: isTextInput , autoFocus: autoFocus } = props;
|
|
834
|
-
let [isFocusVisibleState, setFocusVisible] = $bx7SL$useState(autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
835
|
-
$507fabe10e71c6fb$export$ec71b4b83ac08ec3((
|
|
836
|
-
setFocusVisible(
|
|
934
|
+
let [isFocusVisibleState, setFocusVisible] = (0, $bx7SL$useState)(autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
935
|
+
$507fabe10e71c6fb$export$ec71b4b83ac08ec3((isFocusVisible)=>{
|
|
936
|
+
setFocusVisible(isFocusVisible);
|
|
837
937
|
}, [
|
|
838
938
|
isTextInput
|
|
839
939
|
], {
|
|
@@ -845,7 +945,7 @@ function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {
|
|
|
845
945
|
}
|
|
846
946
|
function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
847
947
|
$507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
848
|
-
$bx7SL$useEffect(()=>{
|
|
948
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
849
949
|
let handler = (modality, e)=>{
|
|
850
950
|
if (!$507fabe10e71c6fb$var$isKeyboardFocusEvent(opts === null || opts === void 0 ? void 0 : opts.isTextInput, modality, e)) return;
|
|
851
951
|
fn($507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
@@ -859,14 +959,28 @@ function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
|
859
959
|
}
|
|
860
960
|
|
|
861
961
|
|
|
962
|
+
/*
|
|
963
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
964
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
965
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
966
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
967
|
+
*
|
|
968
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
969
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
970
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
971
|
+
* governing permissions and limitations under the License.
|
|
972
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
973
|
+
// Original licensing for the following can be found in the
|
|
974
|
+
// NOTICE file in the root directory of this source tree.
|
|
975
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
862
976
|
|
|
863
977
|
|
|
864
978
|
function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
865
979
|
let { isDisabled: isDisabled , onBlurWithin: onBlurWithin , onFocusWithin: onFocusWithin , onFocusWithinChange: onFocusWithinChange } = props;
|
|
866
|
-
let state = $bx7SL$useRef({
|
|
980
|
+
let state = (0, $bx7SL$useRef)({
|
|
867
981
|
isFocusWithin: false
|
|
868
982
|
});
|
|
869
|
-
let onBlur = $bx7SL$useCallback((e)=>{
|
|
983
|
+
let onBlur = (0, $bx7SL$useCallback)((e)=>{
|
|
870
984
|
// We don't want to trigger onBlurWithin and then immediately onFocusWithin again
|
|
871
985
|
// when moving focus inside the element. Only trigger if the currentTarget doesn't
|
|
872
986
|
// include the relatedTarget (where focus is moving).
|
|
@@ -880,8 +994,8 @@ function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
|
880
994
|
onFocusWithinChange,
|
|
881
995
|
state
|
|
882
996
|
]);
|
|
883
|
-
let onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
|
|
884
|
-
let onFocus = $bx7SL$useCallback((e)=>{
|
|
997
|
+
let onSyntheticFocus = (0, $8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
|
|
998
|
+
let onFocus = (0, $bx7SL$useCallback)((e)=>{
|
|
885
999
|
if (!state.current.isFocusWithin) {
|
|
886
1000
|
if (onFocusWithin) onFocusWithin(e);
|
|
887
1001
|
if (onFocusWithinChange) onFocusWithinChange(true);
|
|
@@ -908,6 +1022,20 @@ function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
|
908
1022
|
}
|
|
909
1023
|
|
|
910
1024
|
|
|
1025
|
+
/*
|
|
1026
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1027
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1028
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1029
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1030
|
+
*
|
|
1031
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1032
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1033
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1034
|
+
* governing permissions and limitations under the License.
|
|
1035
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
1036
|
+
// Original licensing for the following can be found in the
|
|
1037
|
+
// NOTICE file in the root directory of this source tree.
|
|
1038
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
911
1039
|
|
|
912
1040
|
// iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
|
|
913
1041
|
// We want to ignore these emulated events so they do not trigger hover behavior.
|
|
@@ -925,39 +1053,39 @@ function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
|
|
|
925
1053
|
}, 50);
|
|
926
1054
|
}
|
|
927
1055
|
function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
|
|
928
|
-
if (e.pointerType ===
|
|
1056
|
+
if (e.pointerType === "touch") $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
|
|
929
1057
|
}
|
|
930
1058
|
function $6179b936705e76d3$var$setupGlobalTouchEvents() {
|
|
931
|
-
if (typeof document ===
|
|
932
|
-
if (typeof PointerEvent !==
|
|
933
|
-
else document.addEventListener(
|
|
1059
|
+
if (typeof document === "undefined") return;
|
|
1060
|
+
if (typeof PointerEvent !== "undefined") document.addEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
1061
|
+
else document.addEventListener("touchend", $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
934
1062
|
$6179b936705e76d3$var$hoverCount++;
|
|
935
1063
|
return ()=>{
|
|
936
1064
|
$6179b936705e76d3$var$hoverCount--;
|
|
937
1065
|
if ($6179b936705e76d3$var$hoverCount > 0) return;
|
|
938
|
-
if (typeof PointerEvent !==
|
|
939
|
-
else document.removeEventListener(
|
|
1066
|
+
if (typeof PointerEvent !== "undefined") document.removeEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
1067
|
+
else document.removeEventListener("touchend", $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
940
1068
|
};
|
|
941
1069
|
}
|
|
942
1070
|
function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
943
1071
|
let { onHoverStart: onHoverStart , onHoverChange: onHoverChange , onHoverEnd: onHoverEnd , isDisabled: isDisabled } = props;
|
|
944
|
-
let [isHovered, setHovered] = $bx7SL$useState(false);
|
|
945
|
-
let state = $bx7SL$useRef({
|
|
1072
|
+
let [isHovered, setHovered] = (0, $bx7SL$useState)(false);
|
|
1073
|
+
let state = (0, $bx7SL$useRef)({
|
|
946
1074
|
isHovered: false,
|
|
947
1075
|
ignoreEmulatedMouseEvents: false,
|
|
948
|
-
pointerType:
|
|
1076
|
+
pointerType: "",
|
|
949
1077
|
target: null
|
|
950
1078
|
}).current;
|
|
951
|
-
$bx7SL$useEffect($6179b936705e76d3$var$setupGlobalTouchEvents, []);
|
|
952
|
-
let { hoverProps:
|
|
1079
|
+
(0, $bx7SL$useEffect)($6179b936705e76d3$var$setupGlobalTouchEvents, []);
|
|
1080
|
+
let { hoverProps: hoverProps , triggerHoverEnd: triggerHoverEnd } = (0, $bx7SL$useMemo)(()=>{
|
|
953
1081
|
let triggerHoverStart = (event, pointerType)=>{
|
|
954
1082
|
state.pointerType = pointerType;
|
|
955
|
-
if (isDisabled || pointerType ===
|
|
1083
|
+
if (isDisabled || pointerType === "touch" || state.isHovered || !event.currentTarget.contains(event.target)) return;
|
|
956
1084
|
state.isHovered = true;
|
|
957
1085
|
let target = event.currentTarget;
|
|
958
1086
|
state.target = target;
|
|
959
1087
|
if (onHoverStart) onHoverStart({
|
|
960
|
-
type:
|
|
1088
|
+
type: "hoverstart",
|
|
961
1089
|
target: target,
|
|
962
1090
|
pointerType: pointerType
|
|
963
1091
|
});
|
|
@@ -965,24 +1093,23 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
965
1093
|
setHovered(true);
|
|
966
1094
|
};
|
|
967
1095
|
let triggerHoverEnd = (event, pointerType)=>{
|
|
968
|
-
state.pointerType =
|
|
1096
|
+
state.pointerType = "";
|
|
969
1097
|
state.target = null;
|
|
970
|
-
if (pointerType ===
|
|
1098
|
+
if (pointerType === "touch" || !state.isHovered) return;
|
|
971
1099
|
state.isHovered = false;
|
|
972
1100
|
let target = event.currentTarget;
|
|
973
1101
|
if (onHoverEnd) onHoverEnd({
|
|
974
|
-
type:
|
|
1102
|
+
type: "hoverend",
|
|
975
1103
|
target: target,
|
|
976
1104
|
pointerType: pointerType
|
|
977
1105
|
});
|
|
978
1106
|
if (onHoverChange) onHoverChange(false);
|
|
979
1107
|
setHovered(false);
|
|
980
1108
|
};
|
|
981
|
-
let hoverProps = {
|
|
982
|
-
|
|
983
|
-
if (typeof PointerEvent !== 'undefined') {
|
|
1109
|
+
let hoverProps = {};
|
|
1110
|
+
if (typeof PointerEvent !== "undefined") {
|
|
984
1111
|
hoverProps.onPointerEnter = (e)=>{
|
|
985
|
-
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType ===
|
|
1112
|
+
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === "mouse") return;
|
|
986
1113
|
triggerHoverStart(e, e.pointerType);
|
|
987
1114
|
};
|
|
988
1115
|
hoverProps.onPointerLeave = (e)=>{
|
|
@@ -993,11 +1120,11 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
993
1120
|
state.ignoreEmulatedMouseEvents = true;
|
|
994
1121
|
};
|
|
995
1122
|
hoverProps.onMouseEnter = (e)=>{
|
|
996
|
-
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e,
|
|
1123
|
+
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, "mouse");
|
|
997
1124
|
state.ignoreEmulatedMouseEvents = false;
|
|
998
1125
|
};
|
|
999
1126
|
hoverProps.onMouseLeave = (e)=>{
|
|
1000
|
-
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e,
|
|
1127
|
+
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, "mouse");
|
|
1001
1128
|
};
|
|
1002
1129
|
}
|
|
1003
1130
|
return {
|
|
@@ -1011,10 +1138,10 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
1011
1138
|
isDisabled,
|
|
1012
1139
|
state
|
|
1013
1140
|
]);
|
|
1014
|
-
$bx7SL$useEffect(()=>{
|
|
1141
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
1015
1142
|
// Call the triggerHoverEnd as soon as isDisabled changes to true
|
|
1016
1143
|
// Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
|
|
1017
|
-
if (isDisabled)
|
|
1144
|
+
if (isDisabled) triggerHoverEnd({
|
|
1018
1145
|
currentTarget: state.target
|
|
1019
1146
|
}, state.pointerType);
|
|
1020
1147
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1022,16 +1149,30 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
1022
1149
|
isDisabled
|
|
1023
1150
|
]);
|
|
1024
1151
|
return {
|
|
1025
|
-
hoverProps:
|
|
1152
|
+
hoverProps: hoverProps,
|
|
1026
1153
|
isHovered: isHovered
|
|
1027
1154
|
};
|
|
1028
1155
|
}
|
|
1029
1156
|
|
|
1030
1157
|
|
|
1158
|
+
/*
|
|
1159
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1160
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1161
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1162
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1163
|
+
*
|
|
1164
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1165
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1166
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1167
|
+
* governing permissions and limitations under the License.
|
|
1168
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
1169
|
+
// Original licensing for the following can be found in the
|
|
1170
|
+
// NOTICE file in the root directory of this source tree.
|
|
1171
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
1031
1172
|
|
|
1032
1173
|
function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
1033
1174
|
let { ref: ref , onInteractOutside: onInteractOutside , isDisabled: isDisabled , onInteractOutsideStart: onInteractOutsideStart } = props;
|
|
1034
|
-
let stateRef = $bx7SL$useRef({
|
|
1175
|
+
let stateRef = (0, $bx7SL$useRef)({
|
|
1035
1176
|
isPointerDown: false,
|
|
1036
1177
|
ignoreEmulatedMouseEvents: false,
|
|
1037
1178
|
onInteractOutside: onInteractOutside,
|
|
@@ -1040,7 +1181,7 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1040
1181
|
let state = stateRef.current;
|
|
1041
1182
|
state.onInteractOutside = onInteractOutside;
|
|
1042
1183
|
state.onInteractOutsideStart = onInteractOutsideStart;
|
|
1043
|
-
$bx7SL$useEffect(()=>{
|
|
1184
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
1044
1185
|
if (isDisabled) return;
|
|
1045
1186
|
let onPointerDown = (e)=>{
|
|
1046
1187
|
if ($e0b6e0b68ec7f50f$var$isValidEvent(e, ref) && state.onInteractOutside) {
|
|
@@ -1049,44 +1190,38 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1049
1190
|
}
|
|
1050
1191
|
};
|
|
1051
1192
|
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
1052
|
-
if (typeof PointerEvent !==
|
|
1193
|
+
if (typeof PointerEvent !== "undefined") {
|
|
1053
1194
|
let onPointerUp = (e)=>{
|
|
1054
|
-
if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref))
|
|
1055
|
-
|
|
1056
|
-
state.onInteractOutside(e);
|
|
1057
|
-
}
|
|
1195
|
+
if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1196
|
+
state.isPointerDown = false;
|
|
1058
1197
|
};
|
|
1059
1198
|
// changing these to capture phase fixed combobox
|
|
1060
|
-
document.addEventListener(
|
|
1061
|
-
document.addEventListener(
|
|
1199
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1200
|
+
document.addEventListener("pointerup", onPointerUp, true);
|
|
1062
1201
|
return ()=>{
|
|
1063
|
-
document.removeEventListener(
|
|
1064
|
-
document.removeEventListener(
|
|
1202
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1203
|
+
document.removeEventListener("pointerup", onPointerUp, true);
|
|
1065
1204
|
};
|
|
1066
1205
|
} else {
|
|
1067
1206
|
let onMouseUp = (e)=>{
|
|
1068
1207
|
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
1069
|
-
else if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref))
|
|
1070
|
-
|
|
1071
|
-
state.onInteractOutside(e);
|
|
1072
|
-
}
|
|
1208
|
+
else if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1209
|
+
state.isPointerDown = false;
|
|
1073
1210
|
};
|
|
1074
1211
|
let onTouchEnd = (e)=>{
|
|
1075
1212
|
state.ignoreEmulatedMouseEvents = true;
|
|
1076
|
-
if (state.onInteractOutside && state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref))
|
|
1077
|
-
|
|
1078
|
-
state.onInteractOutside(e);
|
|
1079
|
-
}
|
|
1213
|
+
if (state.onInteractOutside && state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1214
|
+
state.isPointerDown = false;
|
|
1080
1215
|
};
|
|
1081
|
-
document.addEventListener(
|
|
1082
|
-
document.addEventListener(
|
|
1083
|
-
document.addEventListener(
|
|
1084
|
-
document.addEventListener(
|
|
1216
|
+
document.addEventListener("mousedown", onPointerDown, true);
|
|
1217
|
+
document.addEventListener("mouseup", onMouseUp, true);
|
|
1218
|
+
document.addEventListener("touchstart", onPointerDown, true);
|
|
1219
|
+
document.addEventListener("touchend", onTouchEnd, true);
|
|
1085
1220
|
return ()=>{
|
|
1086
|
-
document.removeEventListener(
|
|
1087
|
-
document.removeEventListener(
|
|
1088
|
-
document.removeEventListener(
|
|
1089
|
-
document.removeEventListener(
|
|
1221
|
+
document.removeEventListener("mousedown", onPointerDown, true);
|
|
1222
|
+
document.removeEventListener("mouseup", onMouseUp, true);
|
|
1223
|
+
document.removeEventListener("touchstart", onPointerDown, true);
|
|
1224
|
+
document.removeEventListener("touchend", onTouchEnd, true);
|
|
1090
1225
|
};
|
|
1091
1226
|
}
|
|
1092
1227
|
}, [
|
|
@@ -1097,16 +1232,38 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1097
1232
|
}
|
|
1098
1233
|
function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
|
|
1099
1234
|
if (event.button > 0) return false;
|
|
1100
|
-
// if the event target is no longer in the document
|
|
1101
1235
|
if (event.target) {
|
|
1236
|
+
// if the event target is no longer in the document, ignore
|
|
1102
1237
|
const ownerDocument = event.target.ownerDocument;
|
|
1103
1238
|
if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
|
|
1239
|
+
// If the target is within a top layer element (e.g. toasts), ignore.
|
|
1240
|
+
if (event.target.closest("[data-react-aria-top-layer]")) return false;
|
|
1104
1241
|
}
|
|
1105
1242
|
return ref.current && !ref.current.contains(event.target);
|
|
1106
1243
|
}
|
|
1107
1244
|
|
|
1108
1245
|
|
|
1109
|
-
|
|
1246
|
+
/*
|
|
1247
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1248
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1249
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1250
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1251
|
+
*
|
|
1252
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1253
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1254
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1255
|
+
* governing permissions and limitations under the License.
|
|
1256
|
+
*/ /*
|
|
1257
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1258
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1259
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1260
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1261
|
+
*
|
|
1262
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1263
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1264
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1265
|
+
* governing permissions and limitations under the License.
|
|
1266
|
+
*/ function $93925083ecbb358c$export$48d1ea6320830260(handler) {
|
|
1110
1267
|
if (!handler) return;
|
|
1111
1268
|
let shouldStopPropagation = true;
|
|
1112
1269
|
return (e)=>{
|
|
@@ -1119,7 +1276,7 @@ function $93925083ecbb358c$export$48d1ea6320830260(handler) {
|
|
|
1119
1276
|
return e.isDefaultPrevented();
|
|
1120
1277
|
},
|
|
1121
1278
|
stopPropagation () {
|
|
1122
|
-
console.error(
|
|
1279
|
+
console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.");
|
|
1123
1280
|
},
|
|
1124
1281
|
continuePropagation () {
|
|
1125
1282
|
shouldStopPropagation = false;
|
|
@@ -1133,31 +1290,39 @@ function $93925083ecbb358c$export$48d1ea6320830260(handler) {
|
|
|
1133
1290
|
|
|
1134
1291
|
function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
|
|
1135
1292
|
return {
|
|
1136
|
-
keyboardProps: props.isDisabled ? {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
onKeyUp: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyUp)
|
|
1293
|
+
keyboardProps: props.isDisabled ? {} : {
|
|
1294
|
+
onKeyDown: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyDown),
|
|
1295
|
+
onKeyUp: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyUp)
|
|
1140
1296
|
}
|
|
1141
1297
|
};
|
|
1142
1298
|
}
|
|
1143
1299
|
|
|
1144
1300
|
|
|
1145
|
-
|
|
1301
|
+
/*
|
|
1302
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1303
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1304
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1305
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1306
|
+
*
|
|
1307
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1308
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1309
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1310
|
+
* governing permissions and limitations under the License.
|
|
1311
|
+
*/
|
|
1146
1312
|
|
|
1147
1313
|
|
|
1148
1314
|
function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
1149
1315
|
let { onMoveStart: onMoveStart , onMove: onMove , onMoveEnd: onMoveEnd } = props;
|
|
1150
|
-
let state = $bx7SL$useRef({
|
|
1316
|
+
let state = (0, $bx7SL$useRef)({
|
|
1151
1317
|
didMove: false,
|
|
1152
1318
|
lastPosition: null,
|
|
1153
1319
|
id: null
|
|
1154
1320
|
});
|
|
1155
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $bx7SL$useGlobalListeners();
|
|
1156
|
-
let
|
|
1157
|
-
let moveProps = {
|
|
1158
|
-
};
|
|
1321
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $bx7SL$useGlobalListeners)();
|
|
1322
|
+
let moveProps = (0, $bx7SL$useMemo)(()=>{
|
|
1323
|
+
let moveProps = {};
|
|
1159
1324
|
let start = ()=>{
|
|
1160
|
-
$14c0b72509d70225$export$16a4697467175487();
|
|
1325
|
+
(0, $14c0b72509d70225$export$16a4697467175487)();
|
|
1161
1326
|
state.current.didMove = false;
|
|
1162
1327
|
};
|
|
1163
1328
|
let move = (originalEvent, pointerType, deltaX, deltaY)=>{
|
|
@@ -1165,7 +1330,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1165
1330
|
if (!state.current.didMove) {
|
|
1166
1331
|
state.current.didMove = true;
|
|
1167
1332
|
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
1168
|
-
type:
|
|
1333
|
+
type: "movestart",
|
|
1169
1334
|
pointerType: pointerType,
|
|
1170
1335
|
shiftKey: originalEvent.shiftKey,
|
|
1171
1336
|
metaKey: originalEvent.metaKey,
|
|
@@ -1174,7 +1339,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1174
1339
|
});
|
|
1175
1340
|
}
|
|
1176
1341
|
onMove({
|
|
1177
|
-
type:
|
|
1342
|
+
type: "move",
|
|
1178
1343
|
pointerType: pointerType,
|
|
1179
1344
|
deltaX: deltaX,
|
|
1180
1345
|
deltaY: deltaY,
|
|
@@ -1185,9 +1350,9 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1185
1350
|
});
|
|
1186
1351
|
};
|
|
1187
1352
|
let end = (originalEvent, pointerType)=>{
|
|
1188
|
-
$14c0b72509d70225$export$b0d6fa1ab32e3295();
|
|
1353
|
+
(0, $14c0b72509d70225$export$b0d6fa1ab32e3295)();
|
|
1189
1354
|
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
1190
|
-
type:
|
|
1355
|
+
type: "moveend",
|
|
1191
1356
|
pointerType: pointerType,
|
|
1192
1357
|
shiftKey: originalEvent.shiftKey,
|
|
1193
1358
|
metaKey: originalEvent.metaKey,
|
|
@@ -1195,10 +1360,10 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1195
1360
|
altKey: originalEvent.altKey
|
|
1196
1361
|
});
|
|
1197
1362
|
};
|
|
1198
|
-
if (typeof PointerEvent ===
|
|
1363
|
+
if (typeof PointerEvent === "undefined") {
|
|
1199
1364
|
let onMouseMove = (e)=>{
|
|
1200
1365
|
if (e.button === 0) {
|
|
1201
|
-
move(e,
|
|
1366
|
+
move(e, "mouse", e.pageX - state.current.lastPosition.pageX, e.pageY - state.current.lastPosition.pageY);
|
|
1202
1367
|
state.current.lastPosition = {
|
|
1203
1368
|
pageX: e.pageX,
|
|
1204
1369
|
pageY: e.pageY
|
|
@@ -1207,9 +1372,9 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1207
1372
|
};
|
|
1208
1373
|
let onMouseUp = (e)=>{
|
|
1209
1374
|
if (e.button === 0) {
|
|
1210
|
-
end(e,
|
|
1211
|
-
removeGlobalListener(window,
|
|
1212
|
-
removeGlobalListener(window,
|
|
1375
|
+
end(e, "mouse");
|
|
1376
|
+
removeGlobalListener(window, "mousemove", onMouseMove, false);
|
|
1377
|
+
removeGlobalListener(window, "mouseup", onMouseUp, false);
|
|
1213
1378
|
}
|
|
1214
1379
|
};
|
|
1215
1380
|
moveProps.onMouseDown = (e)=>{
|
|
@@ -1221,18 +1386,17 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1221
1386
|
pageX: e.pageX,
|
|
1222
1387
|
pageY: e.pageY
|
|
1223
1388
|
};
|
|
1224
|
-
addGlobalListener(window,
|
|
1225
|
-
addGlobalListener(window,
|
|
1389
|
+
addGlobalListener(window, "mousemove", onMouseMove, false);
|
|
1390
|
+
addGlobalListener(window, "mouseup", onMouseUp, false);
|
|
1226
1391
|
}
|
|
1227
1392
|
};
|
|
1228
1393
|
let onTouchMove = (e)=>{
|
|
1229
1394
|
let touch = [
|
|
1230
1395
|
...e.changedTouches
|
|
1231
|
-
].findIndex(({ identifier: identifier })=>identifier === state.current.id
|
|
1232
|
-
);
|
|
1396
|
+
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
1233
1397
|
if (touch >= 0) {
|
|
1234
1398
|
let { pageX: pageX , pageY: pageY } = e.changedTouches[touch];
|
|
1235
|
-
move(e,
|
|
1399
|
+
move(e, "touch", pageX - state.current.lastPosition.pageX, pageY - state.current.lastPosition.pageY);
|
|
1236
1400
|
state.current.lastPosition = {
|
|
1237
1401
|
pageX: pageX,
|
|
1238
1402
|
pageY: pageY
|
|
@@ -1242,14 +1406,13 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1242
1406
|
let onTouchEnd = (e)=>{
|
|
1243
1407
|
let touch = [
|
|
1244
1408
|
...e.changedTouches
|
|
1245
|
-
].findIndex(({ identifier: identifier })=>identifier === state.current.id
|
|
1246
|
-
);
|
|
1409
|
+
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
1247
1410
|
if (touch >= 0) {
|
|
1248
|
-
end(e,
|
|
1411
|
+
end(e, "touch");
|
|
1249
1412
|
state.current.id = null;
|
|
1250
|
-
removeGlobalListener(window,
|
|
1251
|
-
removeGlobalListener(window,
|
|
1252
|
-
removeGlobalListener(window,
|
|
1413
|
+
removeGlobalListener(window, "touchmove", onTouchMove);
|
|
1414
|
+
removeGlobalListener(window, "touchend", onTouchEnd);
|
|
1415
|
+
removeGlobalListener(window, "touchcancel", onTouchEnd);
|
|
1253
1416
|
}
|
|
1254
1417
|
};
|
|
1255
1418
|
moveProps.onTouchStart = (e)=>{
|
|
@@ -1263,14 +1426,14 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1263
1426
|
pageY: pageY
|
|
1264
1427
|
};
|
|
1265
1428
|
state.current.id = identifier;
|
|
1266
|
-
addGlobalListener(window,
|
|
1267
|
-
addGlobalListener(window,
|
|
1268
|
-
addGlobalListener(window,
|
|
1429
|
+
addGlobalListener(window, "touchmove", onTouchMove, false);
|
|
1430
|
+
addGlobalListener(window, "touchend", onTouchEnd, false);
|
|
1431
|
+
addGlobalListener(window, "touchcancel", onTouchEnd, false);
|
|
1269
1432
|
};
|
|
1270
1433
|
} else {
|
|
1271
1434
|
let onPointerMove = (e)=>{
|
|
1272
1435
|
if (e.pointerId === state.current.id) {
|
|
1273
|
-
let pointerType = e.pointerType ||
|
|
1436
|
+
let pointerType = e.pointerType || "mouse";
|
|
1274
1437
|
// Problems with PointerEvent#movementX/movementY:
|
|
1275
1438
|
// 1. it is always 0 on macOS Safari.
|
|
1276
1439
|
// 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS
|
|
@@ -1283,12 +1446,12 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1283
1446
|
};
|
|
1284
1447
|
let onPointerUp = (e)=>{
|
|
1285
1448
|
if (e.pointerId === state.current.id) {
|
|
1286
|
-
let pointerType = e.pointerType ||
|
|
1449
|
+
let pointerType = e.pointerType || "mouse";
|
|
1287
1450
|
end(e, pointerType);
|
|
1288
1451
|
state.current.id = null;
|
|
1289
|
-
removeGlobalListener(window,
|
|
1290
|
-
removeGlobalListener(window,
|
|
1291
|
-
removeGlobalListener(window,
|
|
1452
|
+
removeGlobalListener(window, "pointermove", onPointerMove, false);
|
|
1453
|
+
removeGlobalListener(window, "pointerup", onPointerUp, false);
|
|
1454
|
+
removeGlobalListener(window, "pointercancel", onPointerUp, false);
|
|
1292
1455
|
}
|
|
1293
1456
|
};
|
|
1294
1457
|
moveProps.onPointerDown = (e)=>{
|
|
@@ -1301,39 +1464,39 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1301
1464
|
pageY: e.pageY
|
|
1302
1465
|
};
|
|
1303
1466
|
state.current.id = e.pointerId;
|
|
1304
|
-
addGlobalListener(window,
|
|
1305
|
-
addGlobalListener(window,
|
|
1306
|
-
addGlobalListener(window,
|
|
1467
|
+
addGlobalListener(window, "pointermove", onPointerMove, false);
|
|
1468
|
+
addGlobalListener(window, "pointerup", onPointerUp, false);
|
|
1469
|
+
addGlobalListener(window, "pointercancel", onPointerUp, false);
|
|
1307
1470
|
}
|
|
1308
1471
|
};
|
|
1309
1472
|
}
|
|
1310
1473
|
let triggerKeyboardMove = (e, deltaX, deltaY)=>{
|
|
1311
1474
|
start();
|
|
1312
|
-
move(e,
|
|
1313
|
-
end(e,
|
|
1475
|
+
move(e, "keyboard", deltaX, deltaY);
|
|
1476
|
+
end(e, "keyboard");
|
|
1314
1477
|
};
|
|
1315
1478
|
moveProps.onKeyDown = (e)=>{
|
|
1316
1479
|
switch(e.key){
|
|
1317
|
-
case
|
|
1318
|
-
case
|
|
1480
|
+
case "Left":
|
|
1481
|
+
case "ArrowLeft":
|
|
1319
1482
|
e.preventDefault();
|
|
1320
1483
|
e.stopPropagation();
|
|
1321
1484
|
triggerKeyboardMove(e, -1, 0);
|
|
1322
1485
|
break;
|
|
1323
|
-
case
|
|
1324
|
-
case
|
|
1486
|
+
case "Right":
|
|
1487
|
+
case "ArrowRight":
|
|
1325
1488
|
e.preventDefault();
|
|
1326
1489
|
e.stopPropagation();
|
|
1327
1490
|
triggerKeyboardMove(e, 1, 0);
|
|
1328
1491
|
break;
|
|
1329
|
-
case
|
|
1330
|
-
case
|
|
1492
|
+
case "Up":
|
|
1493
|
+
case "ArrowUp":
|
|
1331
1494
|
e.preventDefault();
|
|
1332
1495
|
e.stopPropagation();
|
|
1333
1496
|
triggerKeyboardMove(e, 0, -1);
|
|
1334
1497
|
break;
|
|
1335
|
-
case
|
|
1336
|
-
case
|
|
1498
|
+
case "Down":
|
|
1499
|
+
case "ArrowDown":
|
|
1337
1500
|
e.preventDefault();
|
|
1338
1501
|
e.stopPropagation();
|
|
1339
1502
|
triggerKeyboardMove(e, 0, 1);
|
|
@@ -1350,17 +1513,27 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1350
1513
|
removeGlobalListener
|
|
1351
1514
|
]);
|
|
1352
1515
|
return {
|
|
1353
|
-
moveProps:
|
|
1516
|
+
moveProps: moveProps
|
|
1354
1517
|
};
|
|
1355
1518
|
}
|
|
1356
1519
|
|
|
1357
1520
|
|
|
1358
1521
|
|
|
1359
|
-
|
|
1522
|
+
/*
|
|
1523
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
1524
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1525
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1526
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1527
|
+
*
|
|
1528
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1529
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1530
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1531
|
+
* governing permissions and limitations under the License.
|
|
1532
|
+
*/
|
|
1360
1533
|
|
|
1361
1534
|
function $7d0a636d7a4dcefd$export$2123ff2b87c81ca(props, ref) {
|
|
1362
1535
|
let { onScroll: onScroll , isDisabled: isDisabled } = props;
|
|
1363
|
-
let onScrollHandler = $bx7SL$useCallback((e)=>{
|
|
1536
|
+
let onScrollHandler = (0, $bx7SL$useCallback)((e)=>{
|
|
1364
1537
|
// If the ctrlKey is pressed, this is a zoom event, do nothing.
|
|
1365
1538
|
if (e.ctrlKey) return;
|
|
1366
1539
|
// stop scrolling the page
|
|
@@ -1373,50 +1546,60 @@ function $7d0a636d7a4dcefd$export$2123ff2b87c81ca(props, ref) {
|
|
|
1373
1546
|
}, [
|
|
1374
1547
|
onScroll
|
|
1375
1548
|
]);
|
|
1376
|
-
$bx7SL$useEvent(ref,
|
|
1549
|
+
(0, $bx7SL$useEvent)(ref, "wheel", isDisabled ? null : onScrollHandler);
|
|
1377
1550
|
}
|
|
1378
1551
|
|
|
1379
1552
|
|
|
1380
|
-
|
|
1553
|
+
/*
|
|
1554
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1555
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1556
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1557
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1558
|
+
*
|
|
1559
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1560
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1561
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1562
|
+
* governing permissions and limitations under the License.
|
|
1563
|
+
*/
|
|
1381
1564
|
|
|
1382
1565
|
|
|
1383
1566
|
const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
|
|
1384
1567
|
function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
|
|
1385
1568
|
let { isDisabled: isDisabled , onLongPressStart: onLongPressStart , onLongPressEnd: onLongPressEnd , onLongPress: onLongPress , threshold: threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD , accessibilityDescription: accessibilityDescription } = props;
|
|
1386
|
-
const timeRef = $bx7SL$useRef(null);
|
|
1387
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $bx7SL$useGlobalListeners();
|
|
1388
|
-
let { pressProps: pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
|
|
1569
|
+
const timeRef = (0, $bx7SL$useRef)(null);
|
|
1570
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $bx7SL$useGlobalListeners)();
|
|
1571
|
+
let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
|
|
1389
1572
|
isDisabled: isDisabled,
|
|
1390
|
-
onPressStart (
|
|
1391
|
-
if (
|
|
1573
|
+
onPressStart (e) {
|
|
1574
|
+
if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
|
1392
1575
|
if (onLongPressStart) onLongPressStart({
|
|
1393
|
-
...
|
|
1394
|
-
type:
|
|
1576
|
+
...e,
|
|
1577
|
+
type: "longpressstart"
|
|
1395
1578
|
});
|
|
1396
1579
|
timeRef.current = setTimeout(()=>{
|
|
1397
1580
|
// Prevent other usePress handlers from also handling this event.
|
|
1398
|
-
|
|
1581
|
+
e.target.dispatchEvent(new PointerEvent("pointercancel", {
|
|
1399
1582
|
bubbles: true
|
|
1400
1583
|
}));
|
|
1401
1584
|
if (onLongPress) onLongPress({
|
|
1402
|
-
...
|
|
1403
|
-
type:
|
|
1585
|
+
...e,
|
|
1586
|
+
type: "longpress"
|
|
1404
1587
|
});
|
|
1405
1588
|
timeRef.current = null;
|
|
1406
1589
|
}, threshold);
|
|
1407
1590
|
// Prevent context menu, which may be opened on long press on touch devices
|
|
1408
|
-
if (
|
|
1591
|
+
if (e.pointerType === "touch") {
|
|
1409
1592
|
let onContextMenu = (e)=>{
|
|
1410
1593
|
e.preventDefault();
|
|
1411
1594
|
};
|
|
1412
|
-
addGlobalListener(
|
|
1595
|
+
addGlobalListener(e.target, "contextmenu", onContextMenu, {
|
|
1413
1596
|
once: true
|
|
1414
1597
|
});
|
|
1415
|
-
addGlobalListener(window,
|
|
1598
|
+
addGlobalListener(window, "pointerup", ()=>{
|
|
1416
1599
|
// If no contextmenu event is fired quickly after pointerup, remove the handler
|
|
1417
1600
|
// so future context menu events outside a long press are not prevented.
|
|
1418
1601
|
setTimeout(()=>{
|
|
1419
|
-
removeGlobalListener(
|
|
1602
|
+
removeGlobalListener(e.target, "contextmenu", onContextMenu);
|
|
1420
1603
|
}, 30);
|
|
1421
1604
|
}, {
|
|
1422
1605
|
once: true
|
|
@@ -1426,15 +1609,15 @@ function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
|
|
|
1426
1609
|
},
|
|
1427
1610
|
onPressEnd (e) {
|
|
1428
1611
|
if (timeRef.current) clearTimeout(timeRef.current);
|
|
1429
|
-
if (onLongPressEnd && (e.pointerType ===
|
|
1612
|
+
if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
|
|
1430
1613
|
...e,
|
|
1431
|
-
type:
|
|
1614
|
+
type: "longpressend"
|
|
1432
1615
|
});
|
|
1433
1616
|
}
|
|
1434
1617
|
});
|
|
1435
|
-
let descriptionProps = $bx7SL$useDescription(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1618
|
+
let descriptionProps = (0, $bx7SL$useDescription)(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1436
1619
|
return {
|
|
1437
|
-
longPressProps: $bx7SL$mergeProps(pressProps, descriptionProps)
|
|
1620
|
+
longPressProps: (0, $bx7SL$mergeProps)(pressProps, descriptionProps)
|
|
1438
1621
|
};
|
|
1439
1622
|
}
|
|
1440
1623
|
|