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