@react-aria/interactions 3.12.0 → 3.13.1
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 +474 -284
- package/dist/main.js.map +1 -1
- package/dist/module.js +474 -284
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -1
- package/src/useFocusVisible.ts +2 -1
- package/src/useHover.ts +1 -0
- package/src/usePress.ts +1 -0
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,36 +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
|
-
if (!allowTextSelectionOnPress)
|
|
495
|
+
if (!allowTextSelectionOnPress) // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
496
|
+
(0, $14c0b72509d70225$export$b0d6fa1ab32e3295)(ref.current.target);
|
|
442
497
|
};
|
|
443
498
|
}, [
|
|
444
499
|
allowTextSelectionOnPress
|
|
445
500
|
]);
|
|
446
501
|
return {
|
|
447
502
|
isPressed: isPressedProp || isPressed,
|
|
448
|
-
pressProps: $bx7SL$mergeProps(domProps,
|
|
503
|
+
pressProps: (0, $bx7SL$mergeProps)(domProps, pressProps)
|
|
449
504
|
};
|
|
450
505
|
}
|
|
451
506
|
function $f6c31cce2adf654f$var$isHTMLAnchorLink(target) {
|
|
452
|
-
return target.tagName ===
|
|
507
|
+
return target.tagName === "A" && target.hasAttribute("href");
|
|
453
508
|
}
|
|
454
509
|
function $f6c31cce2adf654f$var$isValidKeyboardEvent(event, currentTarget) {
|
|
455
510
|
const { key: key , code: code } = event;
|
|
456
511
|
const element = currentTarget;
|
|
457
|
-
const role = element.getAttribute(
|
|
512
|
+
const role = element.getAttribute("role");
|
|
458
513
|
// Accessibility for keyboards. Space and Enter only.
|
|
459
514
|
// "Spacebar" is for IE 11
|
|
460
|
-
return (key ===
|
|
461
|
-
|
|
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");
|
|
462
519
|
}
|
|
463
520
|
function $f6c31cce2adf654f$var$getTouchFromEvent(event) {
|
|
464
521
|
const { targetTouches: targetTouches } = event;
|
|
@@ -510,51 +567,60 @@ function $f6c31cce2adf654f$var$shouldPreventDefault(target) {
|
|
|
510
567
|
}
|
|
511
568
|
function $f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(target, key) {
|
|
512
569
|
if (target instanceof HTMLInputElement) return !$f6c31cce2adf654f$var$isValidInputKey(target, key);
|
|
513
|
-
if (target instanceof HTMLButtonElement) return target.type !==
|
|
570
|
+
if (target instanceof HTMLButtonElement) return target.type !== "submit";
|
|
514
571
|
return true;
|
|
515
572
|
}
|
|
516
573
|
const $f6c31cce2adf654f$var$nonTextInputTypes = new Set([
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
574
|
+
"checkbox",
|
|
575
|
+
"radio",
|
|
576
|
+
"range",
|
|
577
|
+
"color",
|
|
578
|
+
"file",
|
|
579
|
+
"image",
|
|
580
|
+
"button",
|
|
581
|
+
"submit",
|
|
582
|
+
"reset"
|
|
526
583
|
]);
|
|
527
584
|
function $f6c31cce2adf654f$var$isValidInputKey(target, key) {
|
|
528
585
|
// Only space should toggle checkboxes and radios, not enter.
|
|
529
|
-
return target.type ===
|
|
586
|
+
return target.type === "checkbox" || target.type === "radio" ? key === " " : $f6c31cce2adf654f$var$nonTextInputTypes.has(target.type);
|
|
530
587
|
}
|
|
531
588
|
|
|
532
589
|
|
|
533
590
|
|
|
534
|
-
const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ $bx7SL$react.forwardRef(({ children: children , ...props }, ref)=>{
|
|
535
|
-
let newRef = $bx7SL$useRef();
|
|
591
|
+
const $3b117e43dc0ca95d$export$27c701ed9e449e99 = /*#__PURE__*/ (0, $bx7SL$react).forwardRef(({ children: children , ...props }, ref)=>{
|
|
592
|
+
let newRef = (0, $bx7SL$useRef)();
|
|
536
593
|
ref = ref !== null && ref !== void 0 ? ref : newRef;
|
|
537
|
-
let { pressProps: pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
|
|
594
|
+
let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
|
|
538
595
|
...props,
|
|
539
596
|
ref: ref
|
|
540
597
|
});
|
|
541
|
-
let child = $bx7SL$react.Children.only(children);
|
|
542
|
-
return
|
|
598
|
+
let child = (0, $bx7SL$react).Children.only(children);
|
|
599
|
+
return /*#__PURE__*/ (0, $bx7SL$react).cloneElement(child, // @ts-ignore
|
|
543
600
|
{
|
|
544
601
|
ref: ref,
|
|
545
|
-
|
|
546
|
-
})
|
|
602
|
+
...(0, $bx7SL$mergeProps)(child.props, pressProps)
|
|
603
|
+
});
|
|
547
604
|
});
|
|
548
605
|
|
|
549
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
|
+
*/
|
|
550
618
|
|
|
551
619
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
let
|
|
555
|
-
let
|
|
556
|
-
let context = $bx7SL$mergeProps(prevContext || {
|
|
557
|
-
}, {
|
|
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 || {}, {
|
|
558
624
|
...props,
|
|
559
625
|
ref: ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref),
|
|
560
626
|
register () {
|
|
@@ -562,18 +628,42 @@ const $f1ab8c75478c6f73$export$3351871ee4b288b8 = /*#__PURE__*/ $bx7SL$react.for
|
|
|
562
628
|
if (prevContext) prevContext.register();
|
|
563
629
|
}
|
|
564
630
|
});
|
|
565
|
-
$bx7SL$useSyncRef(prevContext, ref);
|
|
566
|
-
$bx7SL$useEffect(()=>{
|
|
631
|
+
(0, $bx7SL$useSyncRef)(prevContext, ref);
|
|
632
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
567
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.");
|
|
568
634
|
}, []);
|
|
569
|
-
return
|
|
635
|
+
return /*#__PURE__*/ (0, $bx7SL$react).createElement((0, $ae1eeba8b9eafd08$export$5165eccb35aaadb5).Provider, {
|
|
570
636
|
value: context
|
|
571
|
-
}, children)
|
|
637
|
+
}, children);
|
|
572
638
|
});
|
|
573
639
|
|
|
574
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
|
|
575
655
|
|
|
576
|
-
|
|
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
|
+
*/
|
|
577
667
|
|
|
578
668
|
class $8a9cb279dc87e130$export$905e7fc544a71f36 {
|
|
579
669
|
isDefaultPrevented() {
|
|
@@ -585,14 +675,12 @@ class $8a9cb279dc87e130$export$905e7fc544a71f36 {
|
|
|
585
675
|
}
|
|
586
676
|
stopPropagation() {
|
|
587
677
|
this.nativeEvent.stopPropagation();
|
|
588
|
-
this.isPropagationStopped = ()=>true
|
|
589
|
-
;
|
|
678
|
+
this.isPropagationStopped = ()=>true;
|
|
590
679
|
}
|
|
591
680
|
isPropagationStopped() {
|
|
592
681
|
return false;
|
|
593
682
|
}
|
|
594
|
-
persist() {
|
|
595
|
-
}
|
|
683
|
+
persist() {}
|
|
596
684
|
constructor(type, nativeEvent){
|
|
597
685
|
this.nativeEvent = nativeEvent;
|
|
598
686
|
this.target = nativeEvent.target;
|
|
@@ -608,7 +696,7 @@ class $8a9cb279dc87e130$export$905e7fc544a71f36 {
|
|
|
608
696
|
}
|
|
609
697
|
}
|
|
610
698
|
function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
611
|
-
let stateRef = $bx7SL$useRef({
|
|
699
|
+
let stateRef = (0, $bx7SL$useRef)({
|
|
612
700
|
isFocused: false,
|
|
613
701
|
onBlur: onBlur,
|
|
614
702
|
observer: null
|
|
@@ -616,7 +704,7 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
|
616
704
|
stateRef.current.onBlur = onBlur;
|
|
617
705
|
// Clean up MutationObserver on unmount. See below.
|
|
618
706
|
// eslint-disable-next-line arrow-body-style
|
|
619
|
-
$bx7SL$useLayoutEffect(()=>{
|
|
707
|
+
(0, $bx7SL$useLayoutEffect)(()=>{
|
|
620
708
|
const state = stateRef.current;
|
|
621
709
|
return ()=>{
|
|
622
710
|
if (state.observer) {
|
|
@@ -626,33 +714,33 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
|
626
714
|
};
|
|
627
715
|
}, []);
|
|
628
716
|
// This function is called during a React onFocus event.
|
|
629
|
-
return $bx7SL$useCallback((
|
|
717
|
+
return (0, $bx7SL$useCallback)((e)=>{
|
|
630
718
|
// React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
|
|
631
719
|
// Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
|
|
632
720
|
// MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
|
|
633
721
|
// For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
|
|
634
|
-
if (
|
|
722
|
+
if (e.target instanceof HTMLButtonElement || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement) {
|
|
635
723
|
stateRef.current.isFocused = true;
|
|
636
|
-
let target =
|
|
724
|
+
let target = e.target;
|
|
637
725
|
let onBlurHandler = (e)=>{
|
|
638
726
|
var // For backward compatibility, dispatch a (fake) React synthetic event.
|
|
639
|
-
|
|
727
|
+
_stateRef_current, _stateRef_current_onBlur;
|
|
640
728
|
stateRef.current.isFocused = false;
|
|
641
|
-
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));
|
|
642
730
|
// We no longer need the MutationObserver once the target is blurred.
|
|
643
731
|
if (stateRef.current.observer) {
|
|
644
732
|
stateRef.current.observer.disconnect();
|
|
645
733
|
stateRef.current.observer = null;
|
|
646
734
|
}
|
|
647
735
|
};
|
|
648
|
-
target.addEventListener(
|
|
736
|
+
target.addEventListener("focusout", onBlurHandler, {
|
|
649
737
|
once: true
|
|
650
738
|
});
|
|
651
739
|
stateRef.current.observer = new MutationObserver(()=>{
|
|
652
740
|
if (stateRef.current.isFocused && target.disabled) {
|
|
653
741
|
stateRef.current.observer.disconnect();
|
|
654
|
-
target.dispatchEvent(new FocusEvent(
|
|
655
|
-
target.dispatchEvent(new FocusEvent(
|
|
742
|
+
target.dispatchEvent(new FocusEvent("blur"));
|
|
743
|
+
target.dispatchEvent(new FocusEvent("focusout", {
|
|
656
744
|
bubbles: true
|
|
657
745
|
}));
|
|
658
746
|
}
|
|
@@ -660,7 +748,7 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
|
660
748
|
stateRef.current.observer.observe(target, {
|
|
661
749
|
attributes: true,
|
|
662
750
|
attributeFilter: [
|
|
663
|
-
|
|
751
|
+
"disabled"
|
|
664
752
|
]
|
|
665
753
|
});
|
|
666
754
|
}
|
|
@@ -670,7 +758,7 @@ function $8a9cb279dc87e130$export$715c682d09d639cc(onBlur) {
|
|
|
670
758
|
|
|
671
759
|
function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
672
760
|
let { isDisabled: isDisabled , onFocus: onFocusProp , onBlur: onBlurProp , onFocusChange: onFocusChange } = props;
|
|
673
|
-
const onBlur = $bx7SL$useCallback((e)=>{
|
|
761
|
+
const onBlur = (0, $bx7SL$useCallback)((e)=>{
|
|
674
762
|
if (e.target === e.currentTarget) {
|
|
675
763
|
if (onBlurProp) onBlurProp(e);
|
|
676
764
|
if (onFocusChange) onFocusChange(false);
|
|
@@ -680,8 +768,8 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
680
768
|
onBlurProp,
|
|
681
769
|
onFocusChange
|
|
682
770
|
]);
|
|
683
|
-
const onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
|
|
684
|
-
const onFocus = $bx7SL$useCallback((e)=>{
|
|
771
|
+
const onSyntheticFocus = (0, $8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
|
|
772
|
+
const onFocus = (0, $bx7SL$useCallback)((e)=>{
|
|
685
773
|
if (e.target === e.currentTarget) {
|
|
686
774
|
if (onFocusProp) onFocusProp(e);
|
|
687
775
|
if (onFocusChange) onFocusChange(true);
|
|
@@ -701,6 +789,20 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
701
789
|
}
|
|
702
790
|
|
|
703
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
|
|
704
806
|
|
|
705
807
|
|
|
706
808
|
let $507fabe10e71c6fb$var$currentModality = null;
|
|
@@ -720,26 +822,26 @@ function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
|
|
|
720
822
|
* Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
721
823
|
*/ function $507fabe10e71c6fb$var$isValidKey(e) {
|
|
722
824
|
// Control and Shift keys trigger when navigating back to the tab with keyboard.
|
|
723
|
-
return !(e.metaKey ||
|
|
825
|
+
return !(e.metaKey || !(0, $bx7SL$isMac)() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
|
724
826
|
}
|
|
725
827
|
function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
|
|
726
828
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
727
829
|
if ($507fabe10e71c6fb$var$isValidKey(e)) {
|
|
728
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
729
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
830
|
+
$507fabe10e71c6fb$var$currentModality = "keyboard";
|
|
831
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("keyboard", e);
|
|
730
832
|
}
|
|
731
833
|
}
|
|
732
834
|
function $507fabe10e71c6fb$var$handlePointerEvent(e) {
|
|
733
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
734
|
-
if (e.type ===
|
|
835
|
+
$507fabe10e71c6fb$var$currentModality = "pointer";
|
|
836
|
+
if (e.type === "mousedown" || e.type === "pointerdown") {
|
|
735
837
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
736
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
838
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("pointer", e);
|
|
737
839
|
}
|
|
738
840
|
}
|
|
739
841
|
function $507fabe10e71c6fb$var$handleClickEvent(e) {
|
|
740
|
-
if ($bx7SL$isVirtualClick(e)) {
|
|
842
|
+
if ((0, $bx7SL$isVirtualClick)(e)) {
|
|
741
843
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
742
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
844
|
+
$507fabe10e71c6fb$var$currentModality = "virtual";
|
|
743
845
|
}
|
|
744
846
|
}
|
|
745
847
|
function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
@@ -750,8 +852,8 @@ function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
|
750
852
|
// If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
|
|
751
853
|
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
752
854
|
if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
|
|
753
|
-
$507fabe10e71c6fb$var$currentModality =
|
|
754
|
-
$507fabe10e71c6fb$var$triggerChangeHandlers(
|
|
855
|
+
$507fabe10e71c6fb$var$currentModality = "virtual";
|
|
856
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("virtual", e);
|
|
755
857
|
}
|
|
756
858
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
757
859
|
$507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
@@ -765,7 +867,7 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
765
867
|
/**
|
|
766
868
|
* Setup global event listeners to control when keyboard focus style should be visible.
|
|
767
869
|
*/ function $507fabe10e71c6fb$var$setupGlobalFocusEvents() {
|
|
768
|
-
if (typeof window ===
|
|
870
|
+
if (typeof window === "undefined" || $507fabe10e71c6fb$var$hasSetupGlobalListeners) return;
|
|
769
871
|
// Programmatic focus() calls shouldn't affect the current input modality.
|
|
770
872
|
// However, we need to detect other cases when a focus event occurs without
|
|
771
873
|
// a preceding user event (e.g. screen reader focus). Overriding the focus
|
|
@@ -775,30 +877,30 @@ function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
|
775
877
|
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
776
878
|
focus.apply(this, arguments);
|
|
777
879
|
};
|
|
778
|
-
document.addEventListener(
|
|
779
|
-
document.addEventListener(
|
|
780
|
-
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);
|
|
781
883
|
// Register focus events on the window so they are sure to happen
|
|
782
884
|
// before React's event listeners (registered on the document).
|
|
783
|
-
window.addEventListener(
|
|
784
|
-
window.addEventListener(
|
|
785
|
-
if (typeof PointerEvent !==
|
|
786
|
-
document.addEventListener(
|
|
787
|
-
document.addEventListener(
|
|
788
|
-
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);
|
|
789
891
|
} else {
|
|
790
|
-
document.addEventListener(
|
|
791
|
-
document.addEventListener(
|
|
792
|
-
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);
|
|
793
895
|
}
|
|
794
896
|
$507fabe10e71c6fb$var$hasSetupGlobalListeners = true;
|
|
795
897
|
}
|
|
796
|
-
if (typeof document !==
|
|
797
|
-
if (document.readyState !==
|
|
798
|
-
else document.addEventListener(
|
|
898
|
+
if (typeof document !== "undefined") {
|
|
899
|
+
if (document.readyState !== "loading") $507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
900
|
+
else document.addEventListener("DOMContentLoaded", $507fabe10e71c6fb$var$setupGlobalFocusEvents);
|
|
799
901
|
}
|
|
800
902
|
function $507fabe10e71c6fb$export$b9b3dfddab17db27() {
|
|
801
|
-
return $507fabe10e71c6fb$var$currentModality !==
|
|
903
|
+
return $507fabe10e71c6fb$var$currentModality !== "pointer";
|
|
802
904
|
}
|
|
803
905
|
function $507fabe10e71c6fb$export$630ff653c5ada6a9() {
|
|
804
906
|
return $507fabe10e71c6fb$var$currentModality;
|
|
@@ -809,8 +911,8 @@ function $507fabe10e71c6fb$export$8397ddfc504fdb9a(modality) {
|
|
|
809
911
|
}
|
|
810
912
|
function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
|
|
811
913
|
$507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
812
|
-
let [modality, setModality] = $bx7SL$useState($507fabe10e71c6fb$var$currentModality);
|
|
813
|
-
$bx7SL$useEffect(()=>{
|
|
914
|
+
let [modality, setModality] = (0, $bx7SL$useState)($507fabe10e71c6fb$var$currentModality);
|
|
915
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
814
916
|
let handler = ()=>{
|
|
815
917
|
setModality($507fabe10e71c6fb$var$currentModality);
|
|
816
918
|
};
|
|
@@ -825,14 +927,13 @@ function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
|
|
|
825
927
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
826
928
|
* focus visible style can be properly set.
|
|
827
929
|
*/ function $507fabe10e71c6fb$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
|
828
|
-
return !(isTextInput && modality ===
|
|
930
|
+
return !(isTextInput && modality === "keyboard" && e instanceof KeyboardEvent && !$507fabe10e71c6fb$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
|
829
931
|
}
|
|
830
|
-
function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {
|
|
831
|
-
}) {
|
|
932
|
+
function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {}) {
|
|
832
933
|
let { isTextInput: isTextInput , autoFocus: autoFocus } = props;
|
|
833
|
-
let [isFocusVisibleState, setFocusVisible] = $bx7SL$useState(autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
834
|
-
$507fabe10e71c6fb$export$ec71b4b83ac08ec3((
|
|
835
|
-
setFocusVisible(
|
|
934
|
+
let [isFocusVisibleState, setFocusVisible] = (0, $bx7SL$useState)(autoFocus || $507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
935
|
+
$507fabe10e71c6fb$export$ec71b4b83ac08ec3((isFocusVisible)=>{
|
|
936
|
+
setFocusVisible(isFocusVisible);
|
|
836
937
|
}, [
|
|
837
938
|
isTextInput
|
|
838
939
|
], {
|
|
@@ -844,7 +945,7 @@ function $507fabe10e71c6fb$export$ffd9e5021c1fb2d6(props = {
|
|
|
844
945
|
}
|
|
845
946
|
function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
846
947
|
$507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
847
|
-
$bx7SL$useEffect(()=>{
|
|
948
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
848
949
|
let handler = (modality, e)=>{
|
|
849
950
|
if (!$507fabe10e71c6fb$var$isKeyboardFocusEvent(opts === null || opts === void 0 ? void 0 : opts.isTextInput, modality, e)) return;
|
|
850
951
|
fn($507fabe10e71c6fb$export$b9b3dfddab17db27());
|
|
@@ -853,18 +954,33 @@ function $507fabe10e71c6fb$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
|
853
954
|
return ()=>{
|
|
854
955
|
$507fabe10e71c6fb$var$changeHandlers.delete(handler);
|
|
855
956
|
};
|
|
957
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
856
958
|
}, deps);
|
|
857
959
|
}
|
|
858
960
|
|
|
859
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
|
|
860
976
|
|
|
861
977
|
|
|
862
978
|
function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
863
979
|
let { isDisabled: isDisabled , onBlurWithin: onBlurWithin , onFocusWithin: onFocusWithin , onFocusWithinChange: onFocusWithinChange } = props;
|
|
864
|
-
let state = $bx7SL$useRef({
|
|
980
|
+
let state = (0, $bx7SL$useRef)({
|
|
865
981
|
isFocusWithin: false
|
|
866
982
|
});
|
|
867
|
-
let onBlur = $bx7SL$useCallback((e)=>{
|
|
983
|
+
let onBlur = (0, $bx7SL$useCallback)((e)=>{
|
|
868
984
|
// We don't want to trigger onBlurWithin and then immediately onFocusWithin again
|
|
869
985
|
// when moving focus inside the element. Only trigger if the currentTarget doesn't
|
|
870
986
|
// include the relatedTarget (where focus is moving).
|
|
@@ -878,8 +994,8 @@ function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
|
878
994
|
onFocusWithinChange,
|
|
879
995
|
state
|
|
880
996
|
]);
|
|
881
|
-
let onSyntheticFocus = $8a9cb279dc87e130$export$715c682d09d639cc(onBlur);
|
|
882
|
-
let onFocus = $bx7SL$useCallback((e)=>{
|
|
997
|
+
let onSyntheticFocus = (0, $8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
|
|
998
|
+
let onFocus = (0, $bx7SL$useCallback)((e)=>{
|
|
883
999
|
if (!state.current.isFocusWithin) {
|
|
884
1000
|
if (onFocusWithin) onFocusWithin(e);
|
|
885
1001
|
if (onFocusWithinChange) onFocusWithinChange(true);
|
|
@@ -906,6 +1022,20 @@ function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
|
906
1022
|
}
|
|
907
1023
|
|
|
908
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
|
|
909
1039
|
|
|
910
1040
|
// iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
|
|
911
1041
|
// We want to ignore these emulated events so they do not trigger hover behavior.
|
|
@@ -923,39 +1053,39 @@ function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
|
|
|
923
1053
|
}, 50);
|
|
924
1054
|
}
|
|
925
1055
|
function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
|
|
926
|
-
if (e.pointerType ===
|
|
1056
|
+
if (e.pointerType === "touch") $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
|
|
927
1057
|
}
|
|
928
1058
|
function $6179b936705e76d3$var$setupGlobalTouchEvents() {
|
|
929
|
-
if (typeof document ===
|
|
930
|
-
if (typeof PointerEvent !==
|
|
931
|
-
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);
|
|
932
1062
|
$6179b936705e76d3$var$hoverCount++;
|
|
933
1063
|
return ()=>{
|
|
934
1064
|
$6179b936705e76d3$var$hoverCount--;
|
|
935
1065
|
if ($6179b936705e76d3$var$hoverCount > 0) return;
|
|
936
|
-
if (typeof PointerEvent !==
|
|
937
|
-
else document.removeEventListener(
|
|
1066
|
+
if (typeof PointerEvent !== "undefined") document.removeEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
1067
|
+
else document.removeEventListener("touchend", $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
938
1068
|
};
|
|
939
1069
|
}
|
|
940
1070
|
function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
941
1071
|
let { onHoverStart: onHoverStart , onHoverChange: onHoverChange , onHoverEnd: onHoverEnd , isDisabled: isDisabled } = props;
|
|
942
|
-
let [isHovered, setHovered] = $bx7SL$useState(false);
|
|
943
|
-
let state = $bx7SL$useRef({
|
|
1072
|
+
let [isHovered, setHovered] = (0, $bx7SL$useState)(false);
|
|
1073
|
+
let state = (0, $bx7SL$useRef)({
|
|
944
1074
|
isHovered: false,
|
|
945
1075
|
ignoreEmulatedMouseEvents: false,
|
|
946
|
-
pointerType:
|
|
1076
|
+
pointerType: "",
|
|
947
1077
|
target: null
|
|
948
1078
|
}).current;
|
|
949
|
-
$bx7SL$useEffect($6179b936705e76d3$var$setupGlobalTouchEvents, []);
|
|
950
|
-
let { hoverProps:
|
|
1079
|
+
(0, $bx7SL$useEffect)($6179b936705e76d3$var$setupGlobalTouchEvents, []);
|
|
1080
|
+
let { hoverProps: hoverProps , triggerHoverEnd: triggerHoverEnd } = (0, $bx7SL$useMemo)(()=>{
|
|
951
1081
|
let triggerHoverStart = (event, pointerType)=>{
|
|
952
1082
|
state.pointerType = pointerType;
|
|
953
|
-
if (isDisabled || pointerType ===
|
|
1083
|
+
if (isDisabled || pointerType === "touch" || state.isHovered || !event.currentTarget.contains(event.target)) return;
|
|
954
1084
|
state.isHovered = true;
|
|
955
1085
|
let target = event.currentTarget;
|
|
956
1086
|
state.target = target;
|
|
957
1087
|
if (onHoverStart) onHoverStart({
|
|
958
|
-
type:
|
|
1088
|
+
type: "hoverstart",
|
|
959
1089
|
target: target,
|
|
960
1090
|
pointerType: pointerType
|
|
961
1091
|
});
|
|
@@ -963,24 +1093,23 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
963
1093
|
setHovered(true);
|
|
964
1094
|
};
|
|
965
1095
|
let triggerHoverEnd = (event, pointerType)=>{
|
|
966
|
-
state.pointerType =
|
|
1096
|
+
state.pointerType = "";
|
|
967
1097
|
state.target = null;
|
|
968
|
-
if (pointerType ===
|
|
1098
|
+
if (pointerType === "touch" || !state.isHovered) return;
|
|
969
1099
|
state.isHovered = false;
|
|
970
1100
|
let target = event.currentTarget;
|
|
971
1101
|
if (onHoverEnd) onHoverEnd({
|
|
972
|
-
type:
|
|
1102
|
+
type: "hoverend",
|
|
973
1103
|
target: target,
|
|
974
1104
|
pointerType: pointerType
|
|
975
1105
|
});
|
|
976
1106
|
if (onHoverChange) onHoverChange(false);
|
|
977
1107
|
setHovered(false);
|
|
978
1108
|
};
|
|
979
|
-
let hoverProps = {
|
|
980
|
-
|
|
981
|
-
if (typeof PointerEvent !== 'undefined') {
|
|
1109
|
+
let hoverProps = {};
|
|
1110
|
+
if (typeof PointerEvent !== "undefined") {
|
|
982
1111
|
hoverProps.onPointerEnter = (e)=>{
|
|
983
|
-
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType ===
|
|
1112
|
+
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === "mouse") return;
|
|
984
1113
|
triggerHoverStart(e, e.pointerType);
|
|
985
1114
|
};
|
|
986
1115
|
hoverProps.onPointerLeave = (e)=>{
|
|
@@ -991,11 +1120,11 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
991
1120
|
state.ignoreEmulatedMouseEvents = true;
|
|
992
1121
|
};
|
|
993
1122
|
hoverProps.onMouseEnter = (e)=>{
|
|
994
|
-
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e,
|
|
1123
|
+
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, "mouse");
|
|
995
1124
|
state.ignoreEmulatedMouseEvents = false;
|
|
996
1125
|
};
|
|
997
1126
|
hoverProps.onMouseLeave = (e)=>{
|
|
998
|
-
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e,
|
|
1127
|
+
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, "mouse");
|
|
999
1128
|
};
|
|
1000
1129
|
}
|
|
1001
1130
|
return {
|
|
@@ -1009,26 +1138,41 @@ function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
|
1009
1138
|
isDisabled,
|
|
1010
1139
|
state
|
|
1011
1140
|
]);
|
|
1012
|
-
$bx7SL$useEffect(()=>{
|
|
1141
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
1013
1142
|
// Call the triggerHoverEnd as soon as isDisabled changes to true
|
|
1014
1143
|
// Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
|
|
1015
|
-
if (isDisabled)
|
|
1144
|
+
if (isDisabled) triggerHoverEnd({
|
|
1016
1145
|
currentTarget: state.target
|
|
1017
1146
|
}, state.pointerType);
|
|
1147
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1018
1148
|
}, [
|
|
1019
1149
|
isDisabled
|
|
1020
1150
|
]);
|
|
1021
1151
|
return {
|
|
1022
|
-
hoverProps:
|
|
1152
|
+
hoverProps: hoverProps,
|
|
1023
1153
|
isHovered: isHovered
|
|
1024
1154
|
};
|
|
1025
1155
|
}
|
|
1026
1156
|
|
|
1027
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
|
|
1028
1172
|
|
|
1029
1173
|
function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
1030
1174
|
let { ref: ref , onInteractOutside: onInteractOutside , isDisabled: isDisabled , onInteractOutsideStart: onInteractOutsideStart } = props;
|
|
1031
|
-
let stateRef = $bx7SL$useRef({
|
|
1175
|
+
let stateRef = (0, $bx7SL$useRef)({
|
|
1032
1176
|
isPointerDown: false,
|
|
1033
1177
|
ignoreEmulatedMouseEvents: false,
|
|
1034
1178
|
onInteractOutside: onInteractOutside,
|
|
@@ -1037,7 +1181,7 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1037
1181
|
let state = stateRef.current;
|
|
1038
1182
|
state.onInteractOutside = onInteractOutside;
|
|
1039
1183
|
state.onInteractOutsideStart = onInteractOutsideStart;
|
|
1040
|
-
$bx7SL$useEffect(()=>{
|
|
1184
|
+
(0, $bx7SL$useEffect)(()=>{
|
|
1041
1185
|
if (isDisabled) return;
|
|
1042
1186
|
let onPointerDown = (e)=>{
|
|
1043
1187
|
if ($e0b6e0b68ec7f50f$var$isValidEvent(e, ref) && state.onInteractOutside) {
|
|
@@ -1046,7 +1190,7 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1046
1190
|
}
|
|
1047
1191
|
};
|
|
1048
1192
|
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
1049
|
-
if (typeof PointerEvent !==
|
|
1193
|
+
if (typeof PointerEvent !== "undefined") {
|
|
1050
1194
|
let onPointerUp = (e)=>{
|
|
1051
1195
|
if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
|
|
1052
1196
|
state.isPointerDown = false;
|
|
@@ -1054,11 +1198,11 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1054
1198
|
}
|
|
1055
1199
|
};
|
|
1056
1200
|
// changing these to capture phase fixed combobox
|
|
1057
|
-
document.addEventListener(
|
|
1058
|
-
document.addEventListener(
|
|
1201
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1202
|
+
document.addEventListener("pointerup", onPointerUp, true);
|
|
1059
1203
|
return ()=>{
|
|
1060
|
-
document.removeEventListener(
|
|
1061
|
-
document.removeEventListener(
|
|
1204
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1205
|
+
document.removeEventListener("pointerup", onPointerUp, true);
|
|
1062
1206
|
};
|
|
1063
1207
|
} else {
|
|
1064
1208
|
let onMouseUp = (e)=>{
|
|
@@ -1075,15 +1219,15 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1075
1219
|
state.onInteractOutside(e);
|
|
1076
1220
|
}
|
|
1077
1221
|
};
|
|
1078
|
-
document.addEventListener(
|
|
1079
|
-
document.addEventListener(
|
|
1080
|
-
document.addEventListener(
|
|
1081
|
-
document.addEventListener(
|
|
1222
|
+
document.addEventListener("mousedown", onPointerDown, true);
|
|
1223
|
+
document.addEventListener("mouseup", onMouseUp, true);
|
|
1224
|
+
document.addEventListener("touchstart", onPointerDown, true);
|
|
1225
|
+
document.addEventListener("touchend", onTouchEnd, true);
|
|
1082
1226
|
return ()=>{
|
|
1083
|
-
document.removeEventListener(
|
|
1084
|
-
document.removeEventListener(
|
|
1085
|
-
document.removeEventListener(
|
|
1086
|
-
document.removeEventListener(
|
|
1227
|
+
document.removeEventListener("mousedown", onPointerDown, true);
|
|
1228
|
+
document.removeEventListener("mouseup", onMouseUp, true);
|
|
1229
|
+
document.removeEventListener("touchstart", onPointerDown, true);
|
|
1230
|
+
document.removeEventListener("touchend", onTouchEnd, true);
|
|
1087
1231
|
};
|
|
1088
1232
|
}
|
|
1089
1233
|
}, [
|
|
@@ -1103,7 +1247,27 @@ function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
|
|
|
1103
1247
|
}
|
|
1104
1248
|
|
|
1105
1249
|
|
|
1106
|
-
|
|
1250
|
+
/*
|
|
1251
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1252
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1253
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1254
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1255
|
+
*
|
|
1256
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1257
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1258
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1259
|
+
* governing permissions and limitations under the License.
|
|
1260
|
+
*/ /*
|
|
1261
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1262
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1263
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1264
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1265
|
+
*
|
|
1266
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1267
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1268
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1269
|
+
* governing permissions and limitations under the License.
|
|
1270
|
+
*/ function $93925083ecbb358c$export$48d1ea6320830260(handler) {
|
|
1107
1271
|
if (!handler) return;
|
|
1108
1272
|
let shouldStopPropagation = true;
|
|
1109
1273
|
return (e)=>{
|
|
@@ -1116,7 +1280,7 @@ function $93925083ecbb358c$export$48d1ea6320830260(handler) {
|
|
|
1116
1280
|
return e.isDefaultPrevented();
|
|
1117
1281
|
},
|
|
1118
1282
|
stopPropagation () {
|
|
1119
|
-
console.error(
|
|
1283
|
+
console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.");
|
|
1120
1284
|
},
|
|
1121
1285
|
continuePropagation () {
|
|
1122
1286
|
shouldStopPropagation = false;
|
|
@@ -1130,31 +1294,39 @@ function $93925083ecbb358c$export$48d1ea6320830260(handler) {
|
|
|
1130
1294
|
|
|
1131
1295
|
function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
|
|
1132
1296
|
return {
|
|
1133
|
-
keyboardProps: props.isDisabled ? {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
onKeyUp: $93925083ecbb358c$export$48d1ea6320830260(props.onKeyUp)
|
|
1297
|
+
keyboardProps: props.isDisabled ? {} : {
|
|
1298
|
+
onKeyDown: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyDown),
|
|
1299
|
+
onKeyUp: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyUp)
|
|
1137
1300
|
}
|
|
1138
1301
|
};
|
|
1139
1302
|
}
|
|
1140
1303
|
|
|
1141
1304
|
|
|
1142
|
-
|
|
1305
|
+
/*
|
|
1306
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1307
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1308
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1309
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1310
|
+
*
|
|
1311
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1312
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1313
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1314
|
+
* governing permissions and limitations under the License.
|
|
1315
|
+
*/
|
|
1143
1316
|
|
|
1144
1317
|
|
|
1145
1318
|
function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
1146
1319
|
let { onMoveStart: onMoveStart , onMove: onMove , onMoveEnd: onMoveEnd } = props;
|
|
1147
|
-
let state = $bx7SL$useRef({
|
|
1320
|
+
let state = (0, $bx7SL$useRef)({
|
|
1148
1321
|
didMove: false,
|
|
1149
1322
|
lastPosition: null,
|
|
1150
1323
|
id: null
|
|
1151
1324
|
});
|
|
1152
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $bx7SL$useGlobalListeners();
|
|
1153
|
-
let
|
|
1154
|
-
let moveProps = {
|
|
1155
|
-
};
|
|
1325
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $bx7SL$useGlobalListeners)();
|
|
1326
|
+
let moveProps = (0, $bx7SL$useMemo)(()=>{
|
|
1327
|
+
let moveProps = {};
|
|
1156
1328
|
let start = ()=>{
|
|
1157
|
-
$14c0b72509d70225$export$16a4697467175487();
|
|
1329
|
+
(0, $14c0b72509d70225$export$16a4697467175487)();
|
|
1158
1330
|
state.current.didMove = false;
|
|
1159
1331
|
};
|
|
1160
1332
|
let move = (originalEvent, pointerType, deltaX, deltaY)=>{
|
|
@@ -1162,7 +1334,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1162
1334
|
if (!state.current.didMove) {
|
|
1163
1335
|
state.current.didMove = true;
|
|
1164
1336
|
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
1165
|
-
type:
|
|
1337
|
+
type: "movestart",
|
|
1166
1338
|
pointerType: pointerType,
|
|
1167
1339
|
shiftKey: originalEvent.shiftKey,
|
|
1168
1340
|
metaKey: originalEvent.metaKey,
|
|
@@ -1171,7 +1343,7 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1171
1343
|
});
|
|
1172
1344
|
}
|
|
1173
1345
|
onMove({
|
|
1174
|
-
type:
|
|
1346
|
+
type: "move",
|
|
1175
1347
|
pointerType: pointerType,
|
|
1176
1348
|
deltaX: deltaX,
|
|
1177
1349
|
deltaY: deltaY,
|
|
@@ -1182,9 +1354,9 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1182
1354
|
});
|
|
1183
1355
|
};
|
|
1184
1356
|
let end = (originalEvent, pointerType)=>{
|
|
1185
|
-
$14c0b72509d70225$export$b0d6fa1ab32e3295();
|
|
1357
|
+
(0, $14c0b72509d70225$export$b0d6fa1ab32e3295)();
|
|
1186
1358
|
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
1187
|
-
type:
|
|
1359
|
+
type: "moveend",
|
|
1188
1360
|
pointerType: pointerType,
|
|
1189
1361
|
shiftKey: originalEvent.shiftKey,
|
|
1190
1362
|
metaKey: originalEvent.metaKey,
|
|
@@ -1192,10 +1364,10 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1192
1364
|
altKey: originalEvent.altKey
|
|
1193
1365
|
});
|
|
1194
1366
|
};
|
|
1195
|
-
if (typeof PointerEvent ===
|
|
1367
|
+
if (typeof PointerEvent === "undefined") {
|
|
1196
1368
|
let onMouseMove = (e)=>{
|
|
1197
1369
|
if (e.button === 0) {
|
|
1198
|
-
move(e,
|
|
1370
|
+
move(e, "mouse", e.pageX - state.current.lastPosition.pageX, e.pageY - state.current.lastPosition.pageY);
|
|
1199
1371
|
state.current.lastPosition = {
|
|
1200
1372
|
pageX: e.pageX,
|
|
1201
1373
|
pageY: e.pageY
|
|
@@ -1204,9 +1376,9 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1204
1376
|
};
|
|
1205
1377
|
let onMouseUp = (e)=>{
|
|
1206
1378
|
if (e.button === 0) {
|
|
1207
|
-
end(e,
|
|
1208
|
-
removeGlobalListener(window,
|
|
1209
|
-
removeGlobalListener(window,
|
|
1379
|
+
end(e, "mouse");
|
|
1380
|
+
removeGlobalListener(window, "mousemove", onMouseMove, false);
|
|
1381
|
+
removeGlobalListener(window, "mouseup", onMouseUp, false);
|
|
1210
1382
|
}
|
|
1211
1383
|
};
|
|
1212
1384
|
moveProps.onMouseDown = (e)=>{
|
|
@@ -1218,18 +1390,17 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1218
1390
|
pageX: e.pageX,
|
|
1219
1391
|
pageY: e.pageY
|
|
1220
1392
|
};
|
|
1221
|
-
addGlobalListener(window,
|
|
1222
|
-
addGlobalListener(window,
|
|
1393
|
+
addGlobalListener(window, "mousemove", onMouseMove, false);
|
|
1394
|
+
addGlobalListener(window, "mouseup", onMouseUp, false);
|
|
1223
1395
|
}
|
|
1224
1396
|
};
|
|
1225
1397
|
let onTouchMove = (e)=>{
|
|
1226
1398
|
let touch = [
|
|
1227
1399
|
...e.changedTouches
|
|
1228
|
-
].findIndex(({ identifier: identifier })=>identifier === state.current.id
|
|
1229
|
-
);
|
|
1400
|
+
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
1230
1401
|
if (touch >= 0) {
|
|
1231
1402
|
let { pageX: pageX , pageY: pageY } = e.changedTouches[touch];
|
|
1232
|
-
move(e,
|
|
1403
|
+
move(e, "touch", pageX - state.current.lastPosition.pageX, pageY - state.current.lastPosition.pageY);
|
|
1233
1404
|
state.current.lastPosition = {
|
|
1234
1405
|
pageX: pageX,
|
|
1235
1406
|
pageY: pageY
|
|
@@ -1239,14 +1410,13 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1239
1410
|
let onTouchEnd = (e)=>{
|
|
1240
1411
|
let touch = [
|
|
1241
1412
|
...e.changedTouches
|
|
1242
|
-
].findIndex(({ identifier: identifier })=>identifier === state.current.id
|
|
1243
|
-
);
|
|
1413
|
+
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
1244
1414
|
if (touch >= 0) {
|
|
1245
|
-
end(e,
|
|
1415
|
+
end(e, "touch");
|
|
1246
1416
|
state.current.id = null;
|
|
1247
|
-
removeGlobalListener(window,
|
|
1248
|
-
removeGlobalListener(window,
|
|
1249
|
-
removeGlobalListener(window,
|
|
1417
|
+
removeGlobalListener(window, "touchmove", onTouchMove);
|
|
1418
|
+
removeGlobalListener(window, "touchend", onTouchEnd);
|
|
1419
|
+
removeGlobalListener(window, "touchcancel", onTouchEnd);
|
|
1250
1420
|
}
|
|
1251
1421
|
};
|
|
1252
1422
|
moveProps.onTouchStart = (e)=>{
|
|
@@ -1260,14 +1430,14 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1260
1430
|
pageY: pageY
|
|
1261
1431
|
};
|
|
1262
1432
|
state.current.id = identifier;
|
|
1263
|
-
addGlobalListener(window,
|
|
1264
|
-
addGlobalListener(window,
|
|
1265
|
-
addGlobalListener(window,
|
|
1433
|
+
addGlobalListener(window, "touchmove", onTouchMove, false);
|
|
1434
|
+
addGlobalListener(window, "touchend", onTouchEnd, false);
|
|
1435
|
+
addGlobalListener(window, "touchcancel", onTouchEnd, false);
|
|
1266
1436
|
};
|
|
1267
1437
|
} else {
|
|
1268
1438
|
let onPointerMove = (e)=>{
|
|
1269
1439
|
if (e.pointerId === state.current.id) {
|
|
1270
|
-
let pointerType = e.pointerType ||
|
|
1440
|
+
let pointerType = e.pointerType || "mouse";
|
|
1271
1441
|
// Problems with PointerEvent#movementX/movementY:
|
|
1272
1442
|
// 1. it is always 0 on macOS Safari.
|
|
1273
1443
|
// 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS
|
|
@@ -1280,12 +1450,12 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1280
1450
|
};
|
|
1281
1451
|
let onPointerUp = (e)=>{
|
|
1282
1452
|
if (e.pointerId === state.current.id) {
|
|
1283
|
-
let pointerType = e.pointerType ||
|
|
1453
|
+
let pointerType = e.pointerType || "mouse";
|
|
1284
1454
|
end(e, pointerType);
|
|
1285
1455
|
state.current.id = null;
|
|
1286
|
-
removeGlobalListener(window,
|
|
1287
|
-
removeGlobalListener(window,
|
|
1288
|
-
removeGlobalListener(window,
|
|
1456
|
+
removeGlobalListener(window, "pointermove", onPointerMove, false);
|
|
1457
|
+
removeGlobalListener(window, "pointerup", onPointerUp, false);
|
|
1458
|
+
removeGlobalListener(window, "pointercancel", onPointerUp, false);
|
|
1289
1459
|
}
|
|
1290
1460
|
};
|
|
1291
1461
|
moveProps.onPointerDown = (e)=>{
|
|
@@ -1298,39 +1468,39 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1298
1468
|
pageY: e.pageY
|
|
1299
1469
|
};
|
|
1300
1470
|
state.current.id = e.pointerId;
|
|
1301
|
-
addGlobalListener(window,
|
|
1302
|
-
addGlobalListener(window,
|
|
1303
|
-
addGlobalListener(window,
|
|
1471
|
+
addGlobalListener(window, "pointermove", onPointerMove, false);
|
|
1472
|
+
addGlobalListener(window, "pointerup", onPointerUp, false);
|
|
1473
|
+
addGlobalListener(window, "pointercancel", onPointerUp, false);
|
|
1304
1474
|
}
|
|
1305
1475
|
};
|
|
1306
1476
|
}
|
|
1307
1477
|
let triggerKeyboardMove = (e, deltaX, deltaY)=>{
|
|
1308
1478
|
start();
|
|
1309
|
-
move(e,
|
|
1310
|
-
end(e,
|
|
1479
|
+
move(e, "keyboard", deltaX, deltaY);
|
|
1480
|
+
end(e, "keyboard");
|
|
1311
1481
|
};
|
|
1312
1482
|
moveProps.onKeyDown = (e)=>{
|
|
1313
1483
|
switch(e.key){
|
|
1314
|
-
case
|
|
1315
|
-
case
|
|
1484
|
+
case "Left":
|
|
1485
|
+
case "ArrowLeft":
|
|
1316
1486
|
e.preventDefault();
|
|
1317
1487
|
e.stopPropagation();
|
|
1318
1488
|
triggerKeyboardMove(e, -1, 0);
|
|
1319
1489
|
break;
|
|
1320
|
-
case
|
|
1321
|
-
case
|
|
1490
|
+
case "Right":
|
|
1491
|
+
case "ArrowRight":
|
|
1322
1492
|
e.preventDefault();
|
|
1323
1493
|
e.stopPropagation();
|
|
1324
1494
|
triggerKeyboardMove(e, 1, 0);
|
|
1325
1495
|
break;
|
|
1326
|
-
case
|
|
1327
|
-
case
|
|
1496
|
+
case "Up":
|
|
1497
|
+
case "ArrowUp":
|
|
1328
1498
|
e.preventDefault();
|
|
1329
1499
|
e.stopPropagation();
|
|
1330
1500
|
triggerKeyboardMove(e, 0, -1);
|
|
1331
1501
|
break;
|
|
1332
|
-
case
|
|
1333
|
-
case
|
|
1502
|
+
case "Down":
|
|
1503
|
+
case "ArrowDown":
|
|
1334
1504
|
e.preventDefault();
|
|
1335
1505
|
e.stopPropagation();
|
|
1336
1506
|
triggerKeyboardMove(e, 0, 1);
|
|
@@ -1347,17 +1517,27 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
1347
1517
|
removeGlobalListener
|
|
1348
1518
|
]);
|
|
1349
1519
|
return {
|
|
1350
|
-
moveProps:
|
|
1520
|
+
moveProps: moveProps
|
|
1351
1521
|
};
|
|
1352
1522
|
}
|
|
1353
1523
|
|
|
1354
1524
|
|
|
1355
1525
|
|
|
1356
|
-
|
|
1526
|
+
/*
|
|
1527
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
1528
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1529
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1530
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1531
|
+
*
|
|
1532
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1533
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1534
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1535
|
+
* governing permissions and limitations under the License.
|
|
1536
|
+
*/
|
|
1357
1537
|
|
|
1358
1538
|
function $7d0a636d7a4dcefd$export$2123ff2b87c81ca(props, ref) {
|
|
1359
1539
|
let { onScroll: onScroll , isDisabled: isDisabled } = props;
|
|
1360
|
-
let onScrollHandler = $bx7SL$useCallback((e)=>{
|
|
1540
|
+
let onScrollHandler = (0, $bx7SL$useCallback)((e)=>{
|
|
1361
1541
|
// If the ctrlKey is pressed, this is a zoom event, do nothing.
|
|
1362
1542
|
if (e.ctrlKey) return;
|
|
1363
1543
|
// stop scrolling the page
|
|
@@ -1370,50 +1550,60 @@ function $7d0a636d7a4dcefd$export$2123ff2b87c81ca(props, ref) {
|
|
|
1370
1550
|
}, [
|
|
1371
1551
|
onScroll
|
|
1372
1552
|
]);
|
|
1373
|
-
$bx7SL$useEvent(ref,
|
|
1553
|
+
(0, $bx7SL$useEvent)(ref, "wheel", isDisabled ? null : onScrollHandler);
|
|
1374
1554
|
}
|
|
1375
1555
|
|
|
1376
1556
|
|
|
1377
|
-
|
|
1557
|
+
/*
|
|
1558
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1559
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1560
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1561
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1562
|
+
*
|
|
1563
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1564
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1565
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1566
|
+
* governing permissions and limitations under the License.
|
|
1567
|
+
*/
|
|
1378
1568
|
|
|
1379
1569
|
|
|
1380
1570
|
const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
|
|
1381
1571
|
function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
|
|
1382
1572
|
let { isDisabled: isDisabled , onLongPressStart: onLongPressStart , onLongPressEnd: onLongPressEnd , onLongPress: onLongPress , threshold: threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD , accessibilityDescription: accessibilityDescription } = props;
|
|
1383
|
-
const timeRef = $bx7SL$useRef(null);
|
|
1384
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $bx7SL$useGlobalListeners();
|
|
1385
|
-
let { pressProps: pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
|
|
1573
|
+
const timeRef = (0, $bx7SL$useRef)(null);
|
|
1574
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $bx7SL$useGlobalListeners)();
|
|
1575
|
+
let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
|
|
1386
1576
|
isDisabled: isDisabled,
|
|
1387
|
-
onPressStart (
|
|
1388
|
-
if (
|
|
1577
|
+
onPressStart (e) {
|
|
1578
|
+
if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
|
1389
1579
|
if (onLongPressStart) onLongPressStart({
|
|
1390
|
-
...
|
|
1391
|
-
type:
|
|
1580
|
+
...e,
|
|
1581
|
+
type: "longpressstart"
|
|
1392
1582
|
});
|
|
1393
1583
|
timeRef.current = setTimeout(()=>{
|
|
1394
1584
|
// Prevent other usePress handlers from also handling this event.
|
|
1395
|
-
|
|
1585
|
+
e.target.dispatchEvent(new PointerEvent("pointercancel", {
|
|
1396
1586
|
bubbles: true
|
|
1397
1587
|
}));
|
|
1398
1588
|
if (onLongPress) onLongPress({
|
|
1399
|
-
...
|
|
1400
|
-
type:
|
|
1589
|
+
...e,
|
|
1590
|
+
type: "longpress"
|
|
1401
1591
|
});
|
|
1402
1592
|
timeRef.current = null;
|
|
1403
1593
|
}, threshold);
|
|
1404
1594
|
// Prevent context menu, which may be opened on long press on touch devices
|
|
1405
|
-
if (
|
|
1595
|
+
if (e.pointerType === "touch") {
|
|
1406
1596
|
let onContextMenu = (e)=>{
|
|
1407
1597
|
e.preventDefault();
|
|
1408
1598
|
};
|
|
1409
|
-
addGlobalListener(
|
|
1599
|
+
addGlobalListener(e.target, "contextmenu", onContextMenu, {
|
|
1410
1600
|
once: true
|
|
1411
1601
|
});
|
|
1412
|
-
addGlobalListener(window,
|
|
1602
|
+
addGlobalListener(window, "pointerup", ()=>{
|
|
1413
1603
|
// If no contextmenu event is fired quickly after pointerup, remove the handler
|
|
1414
1604
|
// so future context menu events outside a long press are not prevented.
|
|
1415
1605
|
setTimeout(()=>{
|
|
1416
|
-
removeGlobalListener(
|
|
1606
|
+
removeGlobalListener(e.target, "contextmenu", onContextMenu);
|
|
1417
1607
|
}, 30);
|
|
1418
1608
|
}, {
|
|
1419
1609
|
once: true
|
|
@@ -1423,15 +1613,15 @@ function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
|
|
|
1423
1613
|
},
|
|
1424
1614
|
onPressEnd (e) {
|
|
1425
1615
|
if (timeRef.current) clearTimeout(timeRef.current);
|
|
1426
|
-
if (onLongPressEnd && (e.pointerType ===
|
|
1616
|
+
if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
|
|
1427
1617
|
...e,
|
|
1428
|
-
type:
|
|
1618
|
+
type: "longpressend"
|
|
1429
1619
|
});
|
|
1430
1620
|
}
|
|
1431
1621
|
});
|
|
1432
|
-
let descriptionProps = $bx7SL$useDescription(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1622
|
+
let descriptionProps = (0, $bx7SL$useDescription)(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1433
1623
|
return {
|
|
1434
|
-
longPressProps: $bx7SL$mergeProps(pressProps, descriptionProps)
|
|
1624
|
+
longPressProps: (0, $bx7SL$mergeProps)(pressProps, descriptionProps)
|
|
1435
1625
|
};
|
|
1436
1626
|
}
|
|
1437
1627
|
|