@react-aria/interactions 3.13.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 +471 -284
- package/dist/main.js.map +1 -1
- package/dist/module.js +471 -284
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
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,37 +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
519
|
if (!allowTextSelectionOnPress) // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
466
|
-
$f7e14e656343df57$export$b0d6fa1ab32e3295(ref.current.target);
|
|
520
|
+
(0, $f7e14e656343df57$export$b0d6fa1ab32e3295)(ref.current.target);
|
|
467
521
|
};
|
|
468
522
|
}, [
|
|
469
523
|
allowTextSelectionOnPress
|
|
470
524
|
]);
|
|
471
525
|
return {
|
|
472
526
|
isPressed: isPressedProp || isPressed,
|
|
473
|
-
pressProps: $goTMa$reactariautils.mergeProps(domProps,
|
|
527
|
+
pressProps: (0, $goTMa$reactariautils.mergeProps)(domProps, pressProps)
|
|
474
528
|
};
|
|
475
529
|
}
|
|
476
530
|
function $0294ea432cd92340$var$isHTMLAnchorLink(target) {
|
|
477
|
-
return target.tagName ===
|
|
531
|
+
return target.tagName === "A" && target.hasAttribute("href");
|
|
478
532
|
}
|
|
479
533
|
function $0294ea432cd92340$var$isValidKeyboardEvent(event, currentTarget) {
|
|
480
534
|
const { key: key , code: code } = event;
|
|
481
535
|
const element = currentTarget;
|
|
482
|
-
const role = element.getAttribute(
|
|
536
|
+
const role = element.getAttribute("role");
|
|
483
537
|
// Accessibility for keyboards. Space and Enter only.
|
|
484
538
|
// "Spacebar" is for IE 11
|
|
485
|
-
return (key ===
|
|
486
|
-
|
|
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");
|
|
487
543
|
}
|
|
488
544
|
function $0294ea432cd92340$var$getTouchFromEvent(event) {
|
|
489
545
|
const { targetTouches: targetTouches } = event;
|
|
@@ -535,51 +591,60 @@ function $0294ea432cd92340$var$shouldPreventDefault(target) {
|
|
|
535
591
|
}
|
|
536
592
|
function $0294ea432cd92340$var$shouldPreventDefaultKeyboard(target, key) {
|
|
537
593
|
if (target instanceof HTMLInputElement) return !$0294ea432cd92340$var$isValidInputKey(target, key);
|
|
538
|
-
if (target instanceof HTMLButtonElement) return target.type !==
|
|
594
|
+
if (target instanceof HTMLButtonElement) return target.type !== "submit";
|
|
539
595
|
return true;
|
|
540
596
|
}
|
|
541
597
|
const $0294ea432cd92340$var$nonTextInputTypes = new Set([
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
598
|
+
"checkbox",
|
|
599
|
+
"radio",
|
|
600
|
+
"range",
|
|
601
|
+
"color",
|
|
602
|
+
"file",
|
|
603
|
+
"image",
|
|
604
|
+
"button",
|
|
605
|
+
"submit",
|
|
606
|
+
"reset"
|
|
551
607
|
]);
|
|
552
608
|
function $0294ea432cd92340$var$isValidInputKey(target, key) {
|
|
553
609
|
// Only space should toggle checkboxes and radios, not enter.
|
|
554
|
-
return target.type ===
|
|
610
|
+
return target.type === "checkbox" || target.type === "radio" ? key === " " : $0294ea432cd92340$var$nonTextInputTypes.has(target.type);
|
|
555
611
|
}
|
|
556
612
|
|
|
557
613
|
|
|
558
614
|
|
|
559
|
-
const $e1dbec26039c051d$export$27c701ed9e449e99 = /*#__PURE__*/ ($parcel$interopDefault($goTMa$react)).forwardRef(({ children: children , ...props }, ref)=>{
|
|
560
|
-
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)();
|
|
561
617
|
ref = ref !== null && ref !== void 0 ? ref : newRef;
|
|
562
|
-
let { pressProps: pressProps } = $0294ea432cd92340$export$45712eceda6fad21({
|
|
618
|
+
let { pressProps: pressProps } = (0, $0294ea432cd92340$export$45712eceda6fad21)({
|
|
563
619
|
...props,
|
|
564
620
|
ref: ref
|
|
565
621
|
});
|
|
566
|
-
let child = ($parcel$interopDefault($goTMa$react)).Children.only(children);
|
|
567
|
-
return
|
|
622
|
+
let child = (0, ($parcel$interopDefault($goTMa$react))).Children.only(children);
|
|
623
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($goTMa$react))).cloneElement(child, // @ts-ignore
|
|
568
624
|
{
|
|
569
625
|
ref: ref,
|
|
570
|
-
|
|
571
|
-
})
|
|
626
|
+
...(0, $goTMa$reactariautils.mergeProps)(child.props, pressProps)
|
|
627
|
+
});
|
|
572
628
|
});
|
|
573
629
|
|
|
574
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
|
+
*/
|
|
575
642
|
|
|
576
643
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
let
|
|
580
|
-
let
|
|
581
|
-
let context = $goTMa$reactariautils.mergeProps(prevContext || {
|
|
582
|
-
}, {
|
|
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 || {}, {
|
|
583
648
|
...props,
|
|
584
649
|
ref: ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref),
|
|
585
650
|
register () {
|
|
@@ -587,18 +652,42 @@ const $3596bae48579386f$export$3351871ee4b288b8 = /*#__PURE__*/ ($parcel$interop
|
|
|
587
652
|
if (prevContext) prevContext.register();
|
|
588
653
|
}
|
|
589
654
|
});
|
|
590
|
-
$goTMa$reactariautils.useSyncRef(prevContext, ref);
|
|
591
|
-
$goTMa$react.useEffect(()=>{
|
|
655
|
+
(0, $goTMa$reactariautils.useSyncRef)(prevContext, ref);
|
|
656
|
+
(0, $goTMa$react.useEffect)(()=>{
|
|
592
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.");
|
|
593
658
|
}, []);
|
|
594
|
-
return
|
|
659
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($goTMa$react))).createElement((0, $01d3f539e91688c8$export$5165eccb35aaadb5).Provider, {
|
|
595
660
|
value: context
|
|
596
|
-
}, children)
|
|
661
|
+
}, children);
|
|
597
662
|
});
|
|
598
663
|
|
|
599
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
|
|
600
679
|
|
|
601
|
-
|
|
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
|
+
*/
|
|
602
691
|
|
|
603
692
|
class $625cf83917e112ad$export$905e7fc544a71f36 {
|
|
604
693
|
isDefaultPrevented() {
|
|
@@ -610,14 +699,12 @@ class $625cf83917e112ad$export$905e7fc544a71f36 {
|
|
|
610
699
|
}
|
|
611
700
|
stopPropagation() {
|
|
612
701
|
this.nativeEvent.stopPropagation();
|
|
613
|
-
this.isPropagationStopped = ()=>true
|
|
614
|
-
;
|
|
702
|
+
this.isPropagationStopped = ()=>true;
|
|
615
703
|
}
|
|
616
704
|
isPropagationStopped() {
|
|
617
705
|
return false;
|
|
618
706
|
}
|
|
619
|
-
persist() {
|
|
620
|
-
}
|
|
707
|
+
persist() {}
|
|
621
708
|
constructor(type, nativeEvent){
|
|
622
709
|
this.nativeEvent = nativeEvent;
|
|
623
710
|
this.target = nativeEvent.target;
|
|
@@ -633,7 +720,7 @@ class $625cf83917e112ad$export$905e7fc544a71f36 {
|
|
|
633
720
|
}
|
|
634
721
|
}
|
|
635
722
|
function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
636
|
-
let stateRef = $goTMa$react.useRef({
|
|
723
|
+
let stateRef = (0, $goTMa$react.useRef)({
|
|
637
724
|
isFocused: false,
|
|
638
725
|
onBlur: onBlur,
|
|
639
726
|
observer: null
|
|
@@ -641,7 +728,7 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
|
641
728
|
stateRef.current.onBlur = onBlur;
|
|
642
729
|
// Clean up MutationObserver on unmount. See below.
|
|
643
730
|
// eslint-disable-next-line arrow-body-style
|
|
644
|
-
$goTMa$reactariautils.useLayoutEffect(()=>{
|
|
731
|
+
(0, $goTMa$reactariautils.useLayoutEffect)(()=>{
|
|
645
732
|
const state = stateRef.current;
|
|
646
733
|
return ()=>{
|
|
647
734
|
if (state.observer) {
|
|
@@ -651,33 +738,33 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
|
651
738
|
};
|
|
652
739
|
}, []);
|
|
653
740
|
// This function is called during a React onFocus event.
|
|
654
|
-
return $goTMa$react.useCallback((
|
|
741
|
+
return (0, $goTMa$react.useCallback)((e)=>{
|
|
655
742
|
// React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
|
|
656
743
|
// Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
|
|
657
744
|
// MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
|
|
658
745
|
// For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
|
|
659
|
-
if (
|
|
746
|
+
if (e.target instanceof HTMLButtonElement || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement) {
|
|
660
747
|
stateRef.current.isFocused = true;
|
|
661
|
-
let target =
|
|
748
|
+
let target = e.target;
|
|
662
749
|
let onBlurHandler = (e)=>{
|
|
663
750
|
var // For backward compatibility, dispatch a (fake) React synthetic event.
|
|
664
|
-
|
|
751
|
+
_stateRef_current, _stateRef_current_onBlur;
|
|
665
752
|
stateRef.current.isFocused = false;
|
|
666
|
-
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));
|
|
667
754
|
// We no longer need the MutationObserver once the target is blurred.
|
|
668
755
|
if (stateRef.current.observer) {
|
|
669
756
|
stateRef.current.observer.disconnect();
|
|
670
757
|
stateRef.current.observer = null;
|
|
671
758
|
}
|
|
672
759
|
};
|
|
673
|
-
target.addEventListener(
|
|
760
|
+
target.addEventListener("focusout", onBlurHandler, {
|
|
674
761
|
once: true
|
|
675
762
|
});
|
|
676
763
|
stateRef.current.observer = new MutationObserver(()=>{
|
|
677
764
|
if (stateRef.current.isFocused && target.disabled) {
|
|
678
765
|
stateRef.current.observer.disconnect();
|
|
679
|
-
target.dispatchEvent(new FocusEvent(
|
|
680
|
-
target.dispatchEvent(new FocusEvent(
|
|
766
|
+
target.dispatchEvent(new FocusEvent("blur"));
|
|
767
|
+
target.dispatchEvent(new FocusEvent("focusout", {
|
|
681
768
|
bubbles: true
|
|
682
769
|
}));
|
|
683
770
|
}
|
|
@@ -685,7 +772,7 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
|
685
772
|
stateRef.current.observer.observe(target, {
|
|
686
773
|
attributes: true,
|
|
687
774
|
attributeFilter: [
|
|
688
|
-
|
|
775
|
+
"disabled"
|
|
689
776
|
]
|
|
690
777
|
});
|
|
691
778
|
}
|
|
@@ -695,7 +782,7 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
|
695
782
|
|
|
696
783
|
function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
697
784
|
let { isDisabled: isDisabled , onFocus: onFocusProp , onBlur: onBlurProp , onFocusChange: onFocusChange } = props;
|
|
698
|
-
const onBlur = $goTMa$react.useCallback((e)=>{
|
|
785
|
+
const onBlur = (0, $goTMa$react.useCallback)((e)=>{
|
|
699
786
|
if (e.target === e.currentTarget) {
|
|
700
787
|
if (onBlurProp) onBlurProp(e);
|
|
701
788
|
if (onFocusChange) onFocusChange(false);
|
|
@@ -705,8 +792,8 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
|
705
792
|
onBlurProp,
|
|
706
793
|
onFocusChange
|
|
707
794
|
]);
|
|
708
|
-
const onSyntheticFocus = $625cf83917e112ad$export$715c682d09d639cc(onBlur);
|
|
709
|
-
const onFocus = $goTMa$react.useCallback((e)=>{
|
|
795
|
+
const onSyntheticFocus = (0, $625cf83917e112ad$export$715c682d09d639cc)(onBlur);
|
|
796
|
+
const onFocus = (0, $goTMa$react.useCallback)((e)=>{
|
|
710
797
|
if (e.target === e.currentTarget) {
|
|
711
798
|
if (onFocusProp) onFocusProp(e);
|
|
712
799
|
if (onFocusChange) onFocusChange(true);
|
|
@@ -726,6 +813,20 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
|
726
813
|
}
|
|
727
814
|
|
|
728
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
|
|
729
830
|
|
|
730
831
|
|
|
731
832
|
let $e77252a287ef94ab$var$currentModality = null;
|
|
@@ -745,26 +846,26 @@ function $e77252a287ef94ab$var$triggerChangeHandlers(modality, e) {
|
|
|
745
846
|
* Helper function to determine if a KeyboardEvent is unmodified and could make keyboard focus styles visible.
|
|
746
847
|
*/ function $e77252a287ef94ab$var$isValidKey(e) {
|
|
747
848
|
// Control and Shift keys trigger when navigating back to the tab with keyboard.
|
|
748
|
-
return !(e.metaKey ||
|
|
849
|
+
return !(e.metaKey || !(0, $goTMa$reactariautils.isMac)() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
|
749
850
|
}
|
|
750
851
|
function $e77252a287ef94ab$var$handleKeyboardEvent(e) {
|
|
751
852
|
$e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
|
752
853
|
if ($e77252a287ef94ab$var$isValidKey(e)) {
|
|
753
|
-
$e77252a287ef94ab$var$currentModality =
|
|
754
|
-
$e77252a287ef94ab$var$triggerChangeHandlers(
|
|
854
|
+
$e77252a287ef94ab$var$currentModality = "keyboard";
|
|
855
|
+
$e77252a287ef94ab$var$triggerChangeHandlers("keyboard", e);
|
|
755
856
|
}
|
|
756
857
|
}
|
|
757
858
|
function $e77252a287ef94ab$var$handlePointerEvent(e) {
|
|
758
|
-
$e77252a287ef94ab$var$currentModality =
|
|
759
|
-
if (e.type ===
|
|
859
|
+
$e77252a287ef94ab$var$currentModality = "pointer";
|
|
860
|
+
if (e.type === "mousedown" || e.type === "pointerdown") {
|
|
760
861
|
$e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
|
761
|
-
$e77252a287ef94ab$var$triggerChangeHandlers(
|
|
862
|
+
$e77252a287ef94ab$var$triggerChangeHandlers("pointer", e);
|
|
762
863
|
}
|
|
763
864
|
}
|
|
764
865
|
function $e77252a287ef94ab$var$handleClickEvent(e) {
|
|
765
|
-
if ($goTMa$reactariautils.isVirtualClick(e)) {
|
|
866
|
+
if ((0, $goTMa$reactariautils.isVirtualClick)(e)) {
|
|
766
867
|
$e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
|
767
|
-
$e77252a287ef94ab$var$currentModality =
|
|
868
|
+
$e77252a287ef94ab$var$currentModality = "virtual";
|
|
768
869
|
}
|
|
769
870
|
}
|
|
770
871
|
function $e77252a287ef94ab$var$handleFocusEvent(e) {
|
|
@@ -775,8 +876,8 @@ function $e77252a287ef94ab$var$handleFocusEvent(e) {
|
|
|
775
876
|
// If a focus event occurs without a preceding keyboard or pointer event, switch to virtual modality.
|
|
776
877
|
// This occurs, for example, when navigating a form with the next/previous buttons on iOS.
|
|
777
878
|
if (!$e77252a287ef94ab$var$hasEventBeforeFocus && !$e77252a287ef94ab$var$hasBlurredWindowRecently) {
|
|
778
|
-
$e77252a287ef94ab$var$currentModality =
|
|
779
|
-
$e77252a287ef94ab$var$triggerChangeHandlers(
|
|
879
|
+
$e77252a287ef94ab$var$currentModality = "virtual";
|
|
880
|
+
$e77252a287ef94ab$var$triggerChangeHandlers("virtual", e);
|
|
780
881
|
}
|
|
781
882
|
$e77252a287ef94ab$var$hasEventBeforeFocus = false;
|
|
782
883
|
$e77252a287ef94ab$var$hasBlurredWindowRecently = false;
|
|
@@ -790,7 +891,7 @@ function $e77252a287ef94ab$var$handleWindowBlur() {
|
|
|
790
891
|
/**
|
|
791
892
|
* Setup global event listeners to control when keyboard focus style should be visible.
|
|
792
893
|
*/ function $e77252a287ef94ab$var$setupGlobalFocusEvents() {
|
|
793
|
-
if (typeof window ===
|
|
894
|
+
if (typeof window === "undefined" || $e77252a287ef94ab$var$hasSetupGlobalListeners) return;
|
|
794
895
|
// Programmatic focus() calls shouldn't affect the current input modality.
|
|
795
896
|
// However, we need to detect other cases when a focus event occurs without
|
|
796
897
|
// a preceding user event (e.g. screen reader focus). Overriding the focus
|
|
@@ -800,30 +901,30 @@ function $e77252a287ef94ab$var$handleWindowBlur() {
|
|
|
800
901
|
$e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
|
801
902
|
focus.apply(this, arguments);
|
|
802
903
|
};
|
|
803
|
-
document.addEventListener(
|
|
804
|
-
document.addEventListener(
|
|
805
|
-
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);
|
|
806
907
|
// Register focus events on the window so they are sure to happen
|
|
807
908
|
// before React's event listeners (registered on the document).
|
|
808
|
-
window.addEventListener(
|
|
809
|
-
window.addEventListener(
|
|
810
|
-
if (typeof PointerEvent !==
|
|
811
|
-
document.addEventListener(
|
|
812
|
-
document.addEventListener(
|
|
813
|
-
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);
|
|
814
915
|
} else {
|
|
815
|
-
document.addEventListener(
|
|
816
|
-
document.addEventListener(
|
|
817
|
-
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);
|
|
818
919
|
}
|
|
819
920
|
$e77252a287ef94ab$var$hasSetupGlobalListeners = true;
|
|
820
921
|
}
|
|
821
|
-
if (typeof document !==
|
|
822
|
-
if (document.readyState !==
|
|
823
|
-
else document.addEventListener(
|
|
922
|
+
if (typeof document !== "undefined") {
|
|
923
|
+
if (document.readyState !== "loading") $e77252a287ef94ab$var$setupGlobalFocusEvents();
|
|
924
|
+
else document.addEventListener("DOMContentLoaded", $e77252a287ef94ab$var$setupGlobalFocusEvents);
|
|
824
925
|
}
|
|
825
926
|
function $e77252a287ef94ab$export$b9b3dfddab17db27() {
|
|
826
|
-
return $e77252a287ef94ab$var$currentModality !==
|
|
927
|
+
return $e77252a287ef94ab$var$currentModality !== "pointer";
|
|
827
928
|
}
|
|
828
929
|
function $e77252a287ef94ab$export$630ff653c5ada6a9() {
|
|
829
930
|
return $e77252a287ef94ab$var$currentModality;
|
|
@@ -834,8 +935,8 @@ function $e77252a287ef94ab$export$8397ddfc504fdb9a(modality) {
|
|
|
834
935
|
}
|
|
835
936
|
function $e77252a287ef94ab$export$98e20ec92f614cfe() {
|
|
836
937
|
$e77252a287ef94ab$var$setupGlobalFocusEvents();
|
|
837
|
-
let [modality, setModality] = $goTMa$react.useState($e77252a287ef94ab$var$currentModality);
|
|
838
|
-
$goTMa$react.useEffect(()=>{
|
|
938
|
+
let [modality, setModality] = (0, $goTMa$react.useState)($e77252a287ef94ab$var$currentModality);
|
|
939
|
+
(0, $goTMa$react.useEffect)(()=>{
|
|
839
940
|
let handler = ()=>{
|
|
840
941
|
setModality($e77252a287ef94ab$var$currentModality);
|
|
841
942
|
};
|
|
@@ -850,14 +951,13 @@ function $e77252a287ef94ab$export$98e20ec92f614cfe() {
|
|
|
850
951
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
851
952
|
* focus visible style can be properly set.
|
|
852
953
|
*/ function $e77252a287ef94ab$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
|
853
|
-
return !(isTextInput && modality ===
|
|
954
|
+
return !(isTextInput && modality === "keyboard" && e instanceof KeyboardEvent && !$e77252a287ef94ab$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
|
854
955
|
}
|
|
855
|
-
function $e77252a287ef94ab$export$ffd9e5021c1fb2d6(props = {
|
|
856
|
-
}) {
|
|
956
|
+
function $e77252a287ef94ab$export$ffd9e5021c1fb2d6(props = {}) {
|
|
857
957
|
let { isTextInput: isTextInput , autoFocus: autoFocus } = props;
|
|
858
|
-
let [isFocusVisibleState, setFocusVisible] = $goTMa$react.useState(autoFocus || $e77252a287ef94ab$export$b9b3dfddab17db27());
|
|
859
|
-
$e77252a287ef94ab$export$ec71b4b83ac08ec3((
|
|
860
|
-
setFocusVisible(
|
|
958
|
+
let [isFocusVisibleState, setFocusVisible] = (0, $goTMa$react.useState)(autoFocus || $e77252a287ef94ab$export$b9b3dfddab17db27());
|
|
959
|
+
$e77252a287ef94ab$export$ec71b4b83ac08ec3((isFocusVisible)=>{
|
|
960
|
+
setFocusVisible(isFocusVisible);
|
|
861
961
|
}, [
|
|
862
962
|
isTextInput
|
|
863
963
|
], {
|
|
@@ -869,7 +969,7 @@ function $e77252a287ef94ab$export$ffd9e5021c1fb2d6(props = {
|
|
|
869
969
|
}
|
|
870
970
|
function $e77252a287ef94ab$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
871
971
|
$e77252a287ef94ab$var$setupGlobalFocusEvents();
|
|
872
|
-
$goTMa$react.useEffect(()=>{
|
|
972
|
+
(0, $goTMa$react.useEffect)(()=>{
|
|
873
973
|
let handler = (modality, e)=>{
|
|
874
974
|
if (!$e77252a287ef94ab$var$isKeyboardFocusEvent(opts === null || opts === void 0 ? void 0 : opts.isTextInput, modality, e)) return;
|
|
875
975
|
fn($e77252a287ef94ab$export$b9b3dfddab17db27());
|
|
@@ -883,14 +983,28 @@ function $e77252a287ef94ab$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
|
883
983
|
}
|
|
884
984
|
|
|
885
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
|
|
886
1000
|
|
|
887
1001
|
|
|
888
1002
|
function $d16842bbd0359d1b$export$420e68273165f4ec(props) {
|
|
889
1003
|
let { isDisabled: isDisabled , onBlurWithin: onBlurWithin , onFocusWithin: onFocusWithin , onFocusWithinChange: onFocusWithinChange } = props;
|
|
890
|
-
let state = $goTMa$react.useRef({
|
|
1004
|
+
let state = (0, $goTMa$react.useRef)({
|
|
891
1005
|
isFocusWithin: false
|
|
892
1006
|
});
|
|
893
|
-
let onBlur = $goTMa$react.useCallback((e)=>{
|
|
1007
|
+
let onBlur = (0, $goTMa$react.useCallback)((e)=>{
|
|
894
1008
|
// We don't want to trigger onBlurWithin and then immediately onFocusWithin again
|
|
895
1009
|
// when moving focus inside the element. Only trigger if the currentTarget doesn't
|
|
896
1010
|
// include the relatedTarget (where focus is moving).
|
|
@@ -904,8 +1018,8 @@ function $d16842bbd0359d1b$export$420e68273165f4ec(props) {
|
|
|
904
1018
|
onFocusWithinChange,
|
|
905
1019
|
state
|
|
906
1020
|
]);
|
|
907
|
-
let onSyntheticFocus = $625cf83917e112ad$export$715c682d09d639cc(onBlur);
|
|
908
|
-
let onFocus = $goTMa$react.useCallback((e)=>{
|
|
1021
|
+
let onSyntheticFocus = (0, $625cf83917e112ad$export$715c682d09d639cc)(onBlur);
|
|
1022
|
+
let onFocus = (0, $goTMa$react.useCallback)((e)=>{
|
|
909
1023
|
if (!state.current.isFocusWithin) {
|
|
910
1024
|
if (onFocusWithin) onFocusWithin(e);
|
|
911
1025
|
if (onFocusWithinChange) onFocusWithinChange(true);
|
|
@@ -932,6 +1046,20 @@ function $d16842bbd0359d1b$export$420e68273165f4ec(props) {
|
|
|
932
1046
|
}
|
|
933
1047
|
|
|
934
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
|
|
935
1063
|
|
|
936
1064
|
// iOS fires onPointerEnter twice: once with pointerType="touch" and again with pointerType="mouse".
|
|
937
1065
|
// We want to ignore these emulated events so they do not trigger hover behavior.
|
|
@@ -949,39 +1077,39 @@ function $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents() {
|
|
|
949
1077
|
}, 50);
|
|
950
1078
|
}
|
|
951
1079
|
function $ffbc150311c75f01$var$handleGlobalPointerEvent(e) {
|
|
952
|
-
if (e.pointerType ===
|
|
1080
|
+
if (e.pointerType === "touch") $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents();
|
|
953
1081
|
}
|
|
954
1082
|
function $ffbc150311c75f01$var$setupGlobalTouchEvents() {
|
|
955
|
-
if (typeof document ===
|
|
956
|
-
if (typeof PointerEvent !==
|
|
957
|
-
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);
|
|
958
1086
|
$ffbc150311c75f01$var$hoverCount++;
|
|
959
1087
|
return ()=>{
|
|
960
1088
|
$ffbc150311c75f01$var$hoverCount--;
|
|
961
1089
|
if ($ffbc150311c75f01$var$hoverCount > 0) return;
|
|
962
|
-
if (typeof PointerEvent !==
|
|
963
|
-
else document.removeEventListener(
|
|
1090
|
+
if (typeof PointerEvent !== "undefined") document.removeEventListener("pointerup", $ffbc150311c75f01$var$handleGlobalPointerEvent);
|
|
1091
|
+
else document.removeEventListener("touchend", $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
964
1092
|
};
|
|
965
1093
|
}
|
|
966
1094
|
function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
967
1095
|
let { onHoverStart: onHoverStart , onHoverChange: onHoverChange , onHoverEnd: onHoverEnd , isDisabled: isDisabled } = props;
|
|
968
|
-
let [isHovered, setHovered] = $goTMa$react.useState(false);
|
|
969
|
-
let state = $goTMa$react.useRef({
|
|
1096
|
+
let [isHovered, setHovered] = (0, $goTMa$react.useState)(false);
|
|
1097
|
+
let state = (0, $goTMa$react.useRef)({
|
|
970
1098
|
isHovered: false,
|
|
971
1099
|
ignoreEmulatedMouseEvents: false,
|
|
972
|
-
pointerType:
|
|
1100
|
+
pointerType: "",
|
|
973
1101
|
target: null
|
|
974
1102
|
}).current;
|
|
975
|
-
$goTMa$react.useEffect($ffbc150311c75f01$var$setupGlobalTouchEvents, []);
|
|
976
|
-
let { hoverProps:
|
|
1103
|
+
(0, $goTMa$react.useEffect)($ffbc150311c75f01$var$setupGlobalTouchEvents, []);
|
|
1104
|
+
let { hoverProps: hoverProps , triggerHoverEnd: triggerHoverEnd } = (0, $goTMa$react.useMemo)(()=>{
|
|
977
1105
|
let triggerHoverStart = (event, pointerType)=>{
|
|
978
1106
|
state.pointerType = pointerType;
|
|
979
|
-
if (isDisabled || pointerType ===
|
|
1107
|
+
if (isDisabled || pointerType === "touch" || state.isHovered || !event.currentTarget.contains(event.target)) return;
|
|
980
1108
|
state.isHovered = true;
|
|
981
1109
|
let target = event.currentTarget;
|
|
982
1110
|
state.target = target;
|
|
983
1111
|
if (onHoverStart) onHoverStart({
|
|
984
|
-
type:
|
|
1112
|
+
type: "hoverstart",
|
|
985
1113
|
target: target,
|
|
986
1114
|
pointerType: pointerType
|
|
987
1115
|
});
|
|
@@ -989,24 +1117,23 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
989
1117
|
setHovered(true);
|
|
990
1118
|
};
|
|
991
1119
|
let triggerHoverEnd = (event, pointerType)=>{
|
|
992
|
-
state.pointerType =
|
|
1120
|
+
state.pointerType = "";
|
|
993
1121
|
state.target = null;
|
|
994
|
-
if (pointerType ===
|
|
1122
|
+
if (pointerType === "touch" || !state.isHovered) return;
|
|
995
1123
|
state.isHovered = false;
|
|
996
1124
|
let target = event.currentTarget;
|
|
997
1125
|
if (onHoverEnd) onHoverEnd({
|
|
998
|
-
type:
|
|
1126
|
+
type: "hoverend",
|
|
999
1127
|
target: target,
|
|
1000
1128
|
pointerType: pointerType
|
|
1001
1129
|
});
|
|
1002
1130
|
if (onHoverChange) onHoverChange(false);
|
|
1003
1131
|
setHovered(false);
|
|
1004
1132
|
};
|
|
1005
|
-
let hoverProps = {
|
|
1006
|
-
|
|
1007
|
-
if (typeof PointerEvent !== 'undefined') {
|
|
1133
|
+
let hoverProps = {};
|
|
1134
|
+
if (typeof PointerEvent !== "undefined") {
|
|
1008
1135
|
hoverProps.onPointerEnter = (e)=>{
|
|
1009
|
-
if ($ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents && e.pointerType ===
|
|
1136
|
+
if ($ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents && e.pointerType === "mouse") return;
|
|
1010
1137
|
triggerHoverStart(e, e.pointerType);
|
|
1011
1138
|
};
|
|
1012
1139
|
hoverProps.onPointerLeave = (e)=>{
|
|
@@ -1017,11 +1144,11 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
1017
1144
|
state.ignoreEmulatedMouseEvents = true;
|
|
1018
1145
|
};
|
|
1019
1146
|
hoverProps.onMouseEnter = (e)=>{
|
|
1020
|
-
if (!state.ignoreEmulatedMouseEvents && !$ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e,
|
|
1147
|
+
if (!state.ignoreEmulatedMouseEvents && !$ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, "mouse");
|
|
1021
1148
|
state.ignoreEmulatedMouseEvents = false;
|
|
1022
1149
|
};
|
|
1023
1150
|
hoverProps.onMouseLeave = (e)=>{
|
|
1024
|
-
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e,
|
|
1151
|
+
if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, "mouse");
|
|
1025
1152
|
};
|
|
1026
1153
|
}
|
|
1027
1154
|
return {
|
|
@@ -1035,10 +1162,10 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
1035
1162
|
isDisabled,
|
|
1036
1163
|
state
|
|
1037
1164
|
]);
|
|
1038
|
-
$goTMa$react.useEffect(()=>{
|
|
1165
|
+
(0, $goTMa$react.useEffect)(()=>{
|
|
1039
1166
|
// Call the triggerHoverEnd as soon as isDisabled changes to true
|
|
1040
1167
|
// Safe to call triggerHoverEnd, it will early return if we aren't currently hovering
|
|
1041
|
-
if (isDisabled)
|
|
1168
|
+
if (isDisabled) triggerHoverEnd({
|
|
1042
1169
|
currentTarget: state.target
|
|
1043
1170
|
}, state.pointerType);
|
|
1044
1171
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1046,16 +1173,30 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
1046
1173
|
isDisabled
|
|
1047
1174
|
]);
|
|
1048
1175
|
return {
|
|
1049
|
-
hoverProps:
|
|
1176
|
+
hoverProps: hoverProps,
|
|
1050
1177
|
isHovered: isHovered
|
|
1051
1178
|
};
|
|
1052
1179
|
}
|
|
1053
1180
|
|
|
1054
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
|
|
1055
1196
|
|
|
1056
1197
|
function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
1057
1198
|
let { ref: ref , onInteractOutside: onInteractOutside , isDisabled: isDisabled , onInteractOutsideStart: onInteractOutsideStart } = props;
|
|
1058
|
-
let stateRef = $goTMa$react.useRef({
|
|
1199
|
+
let stateRef = (0, $goTMa$react.useRef)({
|
|
1059
1200
|
isPointerDown: false,
|
|
1060
1201
|
ignoreEmulatedMouseEvents: false,
|
|
1061
1202
|
onInteractOutside: onInteractOutside,
|
|
@@ -1064,7 +1205,7 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1064
1205
|
let state = stateRef.current;
|
|
1065
1206
|
state.onInteractOutside = onInteractOutside;
|
|
1066
1207
|
state.onInteractOutsideStart = onInteractOutsideStart;
|
|
1067
|
-
$goTMa$react.useEffect(()=>{
|
|
1208
|
+
(0, $goTMa$react.useEffect)(()=>{
|
|
1068
1209
|
if (isDisabled) return;
|
|
1069
1210
|
let onPointerDown = (e)=>{
|
|
1070
1211
|
if ($edcfa848c42f94f4$var$isValidEvent(e, ref) && state.onInteractOutside) {
|
|
@@ -1073,7 +1214,7 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1073
1214
|
}
|
|
1074
1215
|
};
|
|
1075
1216
|
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
1076
|
-
if (typeof PointerEvent !==
|
|
1217
|
+
if (typeof PointerEvent !== "undefined") {
|
|
1077
1218
|
let onPointerUp = (e)=>{
|
|
1078
1219
|
if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) {
|
|
1079
1220
|
state.isPointerDown = false;
|
|
@@ -1081,11 +1222,11 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1081
1222
|
}
|
|
1082
1223
|
};
|
|
1083
1224
|
// changing these to capture phase fixed combobox
|
|
1084
|
-
document.addEventListener(
|
|
1085
|
-
document.addEventListener(
|
|
1225
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1226
|
+
document.addEventListener("pointerup", onPointerUp, true);
|
|
1086
1227
|
return ()=>{
|
|
1087
|
-
document.removeEventListener(
|
|
1088
|
-
document.removeEventListener(
|
|
1228
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1229
|
+
document.removeEventListener("pointerup", onPointerUp, true);
|
|
1089
1230
|
};
|
|
1090
1231
|
} else {
|
|
1091
1232
|
let onMouseUp = (e)=>{
|
|
@@ -1102,15 +1243,15 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1102
1243
|
state.onInteractOutside(e);
|
|
1103
1244
|
}
|
|
1104
1245
|
};
|
|
1105
|
-
document.addEventListener(
|
|
1106
|
-
document.addEventListener(
|
|
1107
|
-
document.addEventListener(
|
|
1108
|
-
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);
|
|
1109
1250
|
return ()=>{
|
|
1110
|
-
document.removeEventListener(
|
|
1111
|
-
document.removeEventListener(
|
|
1112
|
-
document.removeEventListener(
|
|
1113
|
-
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);
|
|
1114
1255
|
};
|
|
1115
1256
|
}
|
|
1116
1257
|
}, [
|
|
@@ -1130,7 +1271,27 @@ function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
|
|
|
1130
1271
|
}
|
|
1131
1272
|
|
|
1132
1273
|
|
|
1133
|
-
|
|
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) {
|
|
1134
1295
|
if (!handler) return;
|
|
1135
1296
|
let shouldStopPropagation = true;
|
|
1136
1297
|
return (e)=>{
|
|
@@ -1143,7 +1304,7 @@ function $951fbcbbca8db6ce$export$48d1ea6320830260(handler) {
|
|
|
1143
1304
|
return e.isDefaultPrevented();
|
|
1144
1305
|
},
|
|
1145
1306
|
stopPropagation () {
|
|
1146
|
-
console.error(
|
|
1307
|
+
console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.");
|
|
1147
1308
|
},
|
|
1148
1309
|
continuePropagation () {
|
|
1149
1310
|
shouldStopPropagation = false;
|
|
@@ -1157,31 +1318,39 @@ function $951fbcbbca8db6ce$export$48d1ea6320830260(handler) {
|
|
|
1157
1318
|
|
|
1158
1319
|
function $892d64db2a3c53b0$export$8f71654801c2f7cd(props) {
|
|
1159
1320
|
return {
|
|
1160
|
-
keyboardProps: props.isDisabled ? {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
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)
|
|
1164
1324
|
}
|
|
1165
1325
|
};
|
|
1166
1326
|
}
|
|
1167
1327
|
|
|
1168
1328
|
|
|
1169
|
-
|
|
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
|
+
*/
|
|
1170
1340
|
|
|
1171
1341
|
|
|
1172
1342
|
function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
1173
1343
|
let { onMoveStart: onMoveStart , onMove: onMove , onMoveEnd: onMoveEnd } = props;
|
|
1174
|
-
let state = $goTMa$react.useRef({
|
|
1344
|
+
let state = (0, $goTMa$react.useRef)({
|
|
1175
1345
|
didMove: false,
|
|
1176
1346
|
lastPosition: null,
|
|
1177
1347
|
id: null
|
|
1178
1348
|
});
|
|
1179
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $goTMa$reactariautils.useGlobalListeners();
|
|
1180
|
-
let
|
|
1181
|
-
let moveProps = {
|
|
1182
|
-
};
|
|
1349
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $goTMa$reactariautils.useGlobalListeners)();
|
|
1350
|
+
let moveProps = (0, $goTMa$react.useMemo)(()=>{
|
|
1351
|
+
let moveProps = {};
|
|
1183
1352
|
let start = ()=>{
|
|
1184
|
-
$f7e14e656343df57$export$16a4697467175487();
|
|
1353
|
+
(0, $f7e14e656343df57$export$16a4697467175487)();
|
|
1185
1354
|
state.current.didMove = false;
|
|
1186
1355
|
};
|
|
1187
1356
|
let move = (originalEvent, pointerType, deltaX, deltaY)=>{
|
|
@@ -1189,7 +1358,7 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1189
1358
|
if (!state.current.didMove) {
|
|
1190
1359
|
state.current.didMove = true;
|
|
1191
1360
|
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
1192
|
-
type:
|
|
1361
|
+
type: "movestart",
|
|
1193
1362
|
pointerType: pointerType,
|
|
1194
1363
|
shiftKey: originalEvent.shiftKey,
|
|
1195
1364
|
metaKey: originalEvent.metaKey,
|
|
@@ -1198,7 +1367,7 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1198
1367
|
});
|
|
1199
1368
|
}
|
|
1200
1369
|
onMove({
|
|
1201
|
-
type:
|
|
1370
|
+
type: "move",
|
|
1202
1371
|
pointerType: pointerType,
|
|
1203
1372
|
deltaX: deltaX,
|
|
1204
1373
|
deltaY: deltaY,
|
|
@@ -1209,9 +1378,9 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1209
1378
|
});
|
|
1210
1379
|
};
|
|
1211
1380
|
let end = (originalEvent, pointerType)=>{
|
|
1212
|
-
$f7e14e656343df57$export$b0d6fa1ab32e3295();
|
|
1381
|
+
(0, $f7e14e656343df57$export$b0d6fa1ab32e3295)();
|
|
1213
1382
|
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
1214
|
-
type:
|
|
1383
|
+
type: "moveend",
|
|
1215
1384
|
pointerType: pointerType,
|
|
1216
1385
|
shiftKey: originalEvent.shiftKey,
|
|
1217
1386
|
metaKey: originalEvent.metaKey,
|
|
@@ -1219,10 +1388,10 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1219
1388
|
altKey: originalEvent.altKey
|
|
1220
1389
|
});
|
|
1221
1390
|
};
|
|
1222
|
-
if (typeof PointerEvent ===
|
|
1391
|
+
if (typeof PointerEvent === "undefined") {
|
|
1223
1392
|
let onMouseMove = (e)=>{
|
|
1224
1393
|
if (e.button === 0) {
|
|
1225
|
-
move(e,
|
|
1394
|
+
move(e, "mouse", e.pageX - state.current.lastPosition.pageX, e.pageY - state.current.lastPosition.pageY);
|
|
1226
1395
|
state.current.lastPosition = {
|
|
1227
1396
|
pageX: e.pageX,
|
|
1228
1397
|
pageY: e.pageY
|
|
@@ -1231,9 +1400,9 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1231
1400
|
};
|
|
1232
1401
|
let onMouseUp = (e)=>{
|
|
1233
1402
|
if (e.button === 0) {
|
|
1234
|
-
end(e,
|
|
1235
|
-
removeGlobalListener(window,
|
|
1236
|
-
removeGlobalListener(window,
|
|
1403
|
+
end(e, "mouse");
|
|
1404
|
+
removeGlobalListener(window, "mousemove", onMouseMove, false);
|
|
1405
|
+
removeGlobalListener(window, "mouseup", onMouseUp, false);
|
|
1237
1406
|
}
|
|
1238
1407
|
};
|
|
1239
1408
|
moveProps.onMouseDown = (e)=>{
|
|
@@ -1245,18 +1414,17 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1245
1414
|
pageX: e.pageX,
|
|
1246
1415
|
pageY: e.pageY
|
|
1247
1416
|
};
|
|
1248
|
-
addGlobalListener(window,
|
|
1249
|
-
addGlobalListener(window,
|
|
1417
|
+
addGlobalListener(window, "mousemove", onMouseMove, false);
|
|
1418
|
+
addGlobalListener(window, "mouseup", onMouseUp, false);
|
|
1250
1419
|
}
|
|
1251
1420
|
};
|
|
1252
1421
|
let onTouchMove = (e)=>{
|
|
1253
1422
|
let touch = [
|
|
1254
1423
|
...e.changedTouches
|
|
1255
|
-
].findIndex(({ identifier: identifier })=>identifier === state.current.id
|
|
1256
|
-
);
|
|
1424
|
+
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
1257
1425
|
if (touch >= 0) {
|
|
1258
1426
|
let { pageX: pageX , pageY: pageY } = e.changedTouches[touch];
|
|
1259
|
-
move(e,
|
|
1427
|
+
move(e, "touch", pageX - state.current.lastPosition.pageX, pageY - state.current.lastPosition.pageY);
|
|
1260
1428
|
state.current.lastPosition = {
|
|
1261
1429
|
pageX: pageX,
|
|
1262
1430
|
pageY: pageY
|
|
@@ -1266,14 +1434,13 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1266
1434
|
let onTouchEnd = (e)=>{
|
|
1267
1435
|
let touch = [
|
|
1268
1436
|
...e.changedTouches
|
|
1269
|
-
].findIndex(({ identifier: identifier })=>identifier === state.current.id
|
|
1270
|
-
);
|
|
1437
|
+
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
1271
1438
|
if (touch >= 0) {
|
|
1272
|
-
end(e,
|
|
1439
|
+
end(e, "touch");
|
|
1273
1440
|
state.current.id = null;
|
|
1274
|
-
removeGlobalListener(window,
|
|
1275
|
-
removeGlobalListener(window,
|
|
1276
|
-
removeGlobalListener(window,
|
|
1441
|
+
removeGlobalListener(window, "touchmove", onTouchMove);
|
|
1442
|
+
removeGlobalListener(window, "touchend", onTouchEnd);
|
|
1443
|
+
removeGlobalListener(window, "touchcancel", onTouchEnd);
|
|
1277
1444
|
}
|
|
1278
1445
|
};
|
|
1279
1446
|
moveProps.onTouchStart = (e)=>{
|
|
@@ -1287,14 +1454,14 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1287
1454
|
pageY: pageY
|
|
1288
1455
|
};
|
|
1289
1456
|
state.current.id = identifier;
|
|
1290
|
-
addGlobalListener(window,
|
|
1291
|
-
addGlobalListener(window,
|
|
1292
|
-
addGlobalListener(window,
|
|
1457
|
+
addGlobalListener(window, "touchmove", onTouchMove, false);
|
|
1458
|
+
addGlobalListener(window, "touchend", onTouchEnd, false);
|
|
1459
|
+
addGlobalListener(window, "touchcancel", onTouchEnd, false);
|
|
1293
1460
|
};
|
|
1294
1461
|
} else {
|
|
1295
1462
|
let onPointerMove = (e)=>{
|
|
1296
1463
|
if (e.pointerId === state.current.id) {
|
|
1297
|
-
let pointerType = e.pointerType ||
|
|
1464
|
+
let pointerType = e.pointerType || "mouse";
|
|
1298
1465
|
// Problems with PointerEvent#movementX/movementY:
|
|
1299
1466
|
// 1. it is always 0 on macOS Safari.
|
|
1300
1467
|
// 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS
|
|
@@ -1307,12 +1474,12 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1307
1474
|
};
|
|
1308
1475
|
let onPointerUp = (e)=>{
|
|
1309
1476
|
if (e.pointerId === state.current.id) {
|
|
1310
|
-
let pointerType = e.pointerType ||
|
|
1477
|
+
let pointerType = e.pointerType || "mouse";
|
|
1311
1478
|
end(e, pointerType);
|
|
1312
1479
|
state.current.id = null;
|
|
1313
|
-
removeGlobalListener(window,
|
|
1314
|
-
removeGlobalListener(window,
|
|
1315
|
-
removeGlobalListener(window,
|
|
1480
|
+
removeGlobalListener(window, "pointermove", onPointerMove, false);
|
|
1481
|
+
removeGlobalListener(window, "pointerup", onPointerUp, false);
|
|
1482
|
+
removeGlobalListener(window, "pointercancel", onPointerUp, false);
|
|
1316
1483
|
}
|
|
1317
1484
|
};
|
|
1318
1485
|
moveProps.onPointerDown = (e)=>{
|
|
@@ -1325,39 +1492,39 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1325
1492
|
pageY: e.pageY
|
|
1326
1493
|
};
|
|
1327
1494
|
state.current.id = e.pointerId;
|
|
1328
|
-
addGlobalListener(window,
|
|
1329
|
-
addGlobalListener(window,
|
|
1330
|
-
addGlobalListener(window,
|
|
1495
|
+
addGlobalListener(window, "pointermove", onPointerMove, false);
|
|
1496
|
+
addGlobalListener(window, "pointerup", onPointerUp, false);
|
|
1497
|
+
addGlobalListener(window, "pointercancel", onPointerUp, false);
|
|
1331
1498
|
}
|
|
1332
1499
|
};
|
|
1333
1500
|
}
|
|
1334
1501
|
let triggerKeyboardMove = (e, deltaX, deltaY)=>{
|
|
1335
1502
|
start();
|
|
1336
|
-
move(e,
|
|
1337
|
-
end(e,
|
|
1503
|
+
move(e, "keyboard", deltaX, deltaY);
|
|
1504
|
+
end(e, "keyboard");
|
|
1338
1505
|
};
|
|
1339
1506
|
moveProps.onKeyDown = (e)=>{
|
|
1340
1507
|
switch(e.key){
|
|
1341
|
-
case
|
|
1342
|
-
case
|
|
1508
|
+
case "Left":
|
|
1509
|
+
case "ArrowLeft":
|
|
1343
1510
|
e.preventDefault();
|
|
1344
1511
|
e.stopPropagation();
|
|
1345
1512
|
triggerKeyboardMove(e, -1, 0);
|
|
1346
1513
|
break;
|
|
1347
|
-
case
|
|
1348
|
-
case
|
|
1514
|
+
case "Right":
|
|
1515
|
+
case "ArrowRight":
|
|
1349
1516
|
e.preventDefault();
|
|
1350
1517
|
e.stopPropagation();
|
|
1351
1518
|
triggerKeyboardMove(e, 1, 0);
|
|
1352
1519
|
break;
|
|
1353
|
-
case
|
|
1354
|
-
case
|
|
1520
|
+
case "Up":
|
|
1521
|
+
case "ArrowUp":
|
|
1355
1522
|
e.preventDefault();
|
|
1356
1523
|
e.stopPropagation();
|
|
1357
1524
|
triggerKeyboardMove(e, 0, -1);
|
|
1358
1525
|
break;
|
|
1359
|
-
case
|
|
1360
|
-
case
|
|
1526
|
+
case "Down":
|
|
1527
|
+
case "ArrowDown":
|
|
1361
1528
|
e.preventDefault();
|
|
1362
1529
|
e.stopPropagation();
|
|
1363
1530
|
triggerKeyboardMove(e, 0, 1);
|
|
@@ -1374,17 +1541,27 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1374
1541
|
removeGlobalListener
|
|
1375
1542
|
]);
|
|
1376
1543
|
return {
|
|
1377
|
-
moveProps:
|
|
1544
|
+
moveProps: moveProps
|
|
1378
1545
|
};
|
|
1379
1546
|
}
|
|
1380
1547
|
|
|
1381
1548
|
|
|
1382
1549
|
|
|
1383
|
-
|
|
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
|
+
*/
|
|
1384
1561
|
|
|
1385
1562
|
function $a3dbce0aed7087e2$export$2123ff2b87c81ca(props, ref) {
|
|
1386
1563
|
let { onScroll: onScroll , isDisabled: isDisabled } = props;
|
|
1387
|
-
let onScrollHandler = $goTMa$react.useCallback((e)=>{
|
|
1564
|
+
let onScrollHandler = (0, $goTMa$react.useCallback)((e)=>{
|
|
1388
1565
|
// If the ctrlKey is pressed, this is a zoom event, do nothing.
|
|
1389
1566
|
if (e.ctrlKey) return;
|
|
1390
1567
|
// stop scrolling the page
|
|
@@ -1397,50 +1574,60 @@ function $a3dbce0aed7087e2$export$2123ff2b87c81ca(props, ref) {
|
|
|
1397
1574
|
}, [
|
|
1398
1575
|
onScroll
|
|
1399
1576
|
]);
|
|
1400
|
-
$goTMa$reactariautils.useEvent(ref,
|
|
1577
|
+
(0, $goTMa$reactariautils.useEvent)(ref, "wheel", isDisabled ? null : onScrollHandler);
|
|
1401
1578
|
}
|
|
1402
1579
|
|
|
1403
1580
|
|
|
1404
|
-
|
|
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
|
+
*/
|
|
1405
1592
|
|
|
1406
1593
|
|
|
1407
1594
|
const $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD = 500;
|
|
1408
1595
|
function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
|
|
1409
1596
|
let { isDisabled: isDisabled , onLongPressStart: onLongPressStart , onLongPressEnd: onLongPressEnd , onLongPress: onLongPress , threshold: threshold = $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD , accessibilityDescription: accessibilityDescription } = props;
|
|
1410
|
-
const timeRef = $goTMa$react.useRef(null);
|
|
1411
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $goTMa$reactariautils.useGlobalListeners();
|
|
1412
|
-
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)({
|
|
1413
1600
|
isDisabled: isDisabled,
|
|
1414
|
-
onPressStart (
|
|
1415
|
-
if (
|
|
1601
|
+
onPressStart (e) {
|
|
1602
|
+
if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
|
1416
1603
|
if (onLongPressStart) onLongPressStart({
|
|
1417
|
-
...
|
|
1418
|
-
type:
|
|
1604
|
+
...e,
|
|
1605
|
+
type: "longpressstart"
|
|
1419
1606
|
});
|
|
1420
1607
|
timeRef.current = setTimeout(()=>{
|
|
1421
1608
|
// Prevent other usePress handlers from also handling this event.
|
|
1422
|
-
|
|
1609
|
+
e.target.dispatchEvent(new PointerEvent("pointercancel", {
|
|
1423
1610
|
bubbles: true
|
|
1424
1611
|
}));
|
|
1425
1612
|
if (onLongPress) onLongPress({
|
|
1426
|
-
...
|
|
1427
|
-
type:
|
|
1613
|
+
...e,
|
|
1614
|
+
type: "longpress"
|
|
1428
1615
|
});
|
|
1429
1616
|
timeRef.current = null;
|
|
1430
1617
|
}, threshold);
|
|
1431
1618
|
// Prevent context menu, which may be opened on long press on touch devices
|
|
1432
|
-
if (
|
|
1619
|
+
if (e.pointerType === "touch") {
|
|
1433
1620
|
let onContextMenu = (e)=>{
|
|
1434
1621
|
e.preventDefault();
|
|
1435
1622
|
};
|
|
1436
|
-
addGlobalListener(
|
|
1623
|
+
addGlobalListener(e.target, "contextmenu", onContextMenu, {
|
|
1437
1624
|
once: true
|
|
1438
1625
|
});
|
|
1439
|
-
addGlobalListener(window,
|
|
1626
|
+
addGlobalListener(window, "pointerup", ()=>{
|
|
1440
1627
|
// If no contextmenu event is fired quickly after pointerup, remove the handler
|
|
1441
1628
|
// so future context menu events outside a long press are not prevented.
|
|
1442
1629
|
setTimeout(()=>{
|
|
1443
|
-
removeGlobalListener(
|
|
1630
|
+
removeGlobalListener(e.target, "contextmenu", onContextMenu);
|
|
1444
1631
|
}, 30);
|
|
1445
1632
|
}, {
|
|
1446
1633
|
once: true
|
|
@@ -1450,15 +1637,15 @@ function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
|
|
|
1450
1637
|
},
|
|
1451
1638
|
onPressEnd (e) {
|
|
1452
1639
|
if (timeRef.current) clearTimeout(timeRef.current);
|
|
1453
|
-
if (onLongPressEnd && (e.pointerType ===
|
|
1640
|
+
if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
|
|
1454
1641
|
...e,
|
|
1455
|
-
type:
|
|
1642
|
+
type: "longpressend"
|
|
1456
1643
|
});
|
|
1457
1644
|
}
|
|
1458
1645
|
});
|
|
1459
|
-
let descriptionProps = $goTMa$reactariautils.useDescription(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1646
|
+
let descriptionProps = (0, $goTMa$reactariautils.useDescription)(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1460
1647
|
return {
|
|
1461
|
-
longPressProps: $goTMa$reactariautils.mergeProps(pressProps, descriptionProps)
|
|
1648
|
+
longPressProps: (0, $goTMa$reactariautils.mergeProps)(pressProps, descriptionProps)
|
|
1462
1649
|
};
|
|
1463
1650
|
}
|
|
1464
1651
|
|