@react-aria/interactions 3.13.0 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +1628 -0
- package/dist/main.js +481 -298
- package/dist/main.js.map +1 -1
- package/dist/module.js +481 -298
- package/dist/module.js.map +1 -1
- package/package.json +10 -5
- package/src/useFocus.ts +1 -1
- package/src/useInteractOutside.ts +9 -4
package/dist/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);
|
|
@@ -720,12 +807,26 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
|
720
807
|
return {
|
|
721
808
|
focusProps: {
|
|
722
809
|
onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
|
|
723
|
-
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur :
|
|
810
|
+
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
|
|
724
811
|
}
|
|
725
812
|
};
|
|
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,44 +1214,38 @@ 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
|
-
if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref))
|
|
1079
|
-
|
|
1080
|
-
state.onInteractOutside(e);
|
|
1081
|
-
}
|
|
1219
|
+
if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1220
|
+
state.isPointerDown = false;
|
|
1082
1221
|
};
|
|
1083
1222
|
// changing these to capture phase fixed combobox
|
|
1084
|
-
document.addEventListener(
|
|
1085
|
-
document.addEventListener(
|
|
1223
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1224
|
+
document.addEventListener("pointerup", onPointerUp, true);
|
|
1086
1225
|
return ()=>{
|
|
1087
|
-
document.removeEventListener(
|
|
1088
|
-
document.removeEventListener(
|
|
1226
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
1227
|
+
document.removeEventListener("pointerup", onPointerUp, true);
|
|
1089
1228
|
};
|
|
1090
1229
|
} else {
|
|
1091
1230
|
let onMouseUp = (e)=>{
|
|
1092
1231
|
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
1093
|
-
else if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref))
|
|
1094
|
-
|
|
1095
|
-
state.onInteractOutside(e);
|
|
1096
|
-
}
|
|
1232
|
+
else if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1233
|
+
state.isPointerDown = false;
|
|
1097
1234
|
};
|
|
1098
1235
|
let onTouchEnd = (e)=>{
|
|
1099
1236
|
state.ignoreEmulatedMouseEvents = true;
|
|
1100
|
-
if (state.onInteractOutside && state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref))
|
|
1101
|
-
|
|
1102
|
-
state.onInteractOutside(e);
|
|
1103
|
-
}
|
|
1237
|
+
if (state.onInteractOutside && state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1238
|
+
state.isPointerDown = false;
|
|
1104
1239
|
};
|
|
1105
|
-
document.addEventListener(
|
|
1106
|
-
document.addEventListener(
|
|
1107
|
-
document.addEventListener(
|
|
1108
|
-
document.addEventListener(
|
|
1240
|
+
document.addEventListener("mousedown", onPointerDown, true);
|
|
1241
|
+
document.addEventListener("mouseup", onMouseUp, true);
|
|
1242
|
+
document.addEventListener("touchstart", onPointerDown, true);
|
|
1243
|
+
document.addEventListener("touchend", onTouchEnd, true);
|
|
1109
1244
|
return ()=>{
|
|
1110
|
-
document.removeEventListener(
|
|
1111
|
-
document.removeEventListener(
|
|
1112
|
-
document.removeEventListener(
|
|
1113
|
-
document.removeEventListener(
|
|
1245
|
+
document.removeEventListener("mousedown", onPointerDown, true);
|
|
1246
|
+
document.removeEventListener("mouseup", onMouseUp, true);
|
|
1247
|
+
document.removeEventListener("touchstart", onPointerDown, true);
|
|
1248
|
+
document.removeEventListener("touchend", onTouchEnd, true);
|
|
1114
1249
|
};
|
|
1115
1250
|
}
|
|
1116
1251
|
}, [
|
|
@@ -1121,16 +1256,38 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1121
1256
|
}
|
|
1122
1257
|
function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
|
|
1123
1258
|
if (event.button > 0) return false;
|
|
1124
|
-
// if the event target is no longer in the document
|
|
1125
1259
|
if (event.target) {
|
|
1260
|
+
// if the event target is no longer in the document, ignore
|
|
1126
1261
|
const ownerDocument = event.target.ownerDocument;
|
|
1127
1262
|
if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
|
|
1263
|
+
// If the target is within a top layer element (e.g. toasts), ignore.
|
|
1264
|
+
if (event.target.closest("[data-react-aria-top-layer]")) return false;
|
|
1128
1265
|
}
|
|
1129
1266
|
return ref.current && !ref.current.contains(event.target);
|
|
1130
1267
|
}
|
|
1131
1268
|
|
|
1132
1269
|
|
|
1133
|
-
|
|
1270
|
+
/*
|
|
1271
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1272
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1273
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1274
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1275
|
+
*
|
|
1276
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1277
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1278
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1279
|
+
* governing permissions and limitations under the License.
|
|
1280
|
+
*/ /*
|
|
1281
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1282
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1283
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1284
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1285
|
+
*
|
|
1286
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1287
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1288
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1289
|
+
* governing permissions and limitations under the License.
|
|
1290
|
+
*/ function $951fbcbbca8db6ce$export$48d1ea6320830260(handler) {
|
|
1134
1291
|
if (!handler) return;
|
|
1135
1292
|
let shouldStopPropagation = true;
|
|
1136
1293
|
return (e)=>{
|
|
@@ -1143,7 +1300,7 @@ function $951fbcbbca8db6ce$export$48d1ea6320830260(handler) {
|
|
|
1143
1300
|
return e.isDefaultPrevented();
|
|
1144
1301
|
},
|
|
1145
1302
|
stopPropagation () {
|
|
1146
|
-
console.error(
|
|
1303
|
+
console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.");
|
|
1147
1304
|
},
|
|
1148
1305
|
continuePropagation () {
|
|
1149
1306
|
shouldStopPropagation = false;
|
|
@@ -1157,31 +1314,39 @@ function $951fbcbbca8db6ce$export$48d1ea6320830260(handler) {
|
|
|
1157
1314
|
|
|
1158
1315
|
function $892d64db2a3c53b0$export$8f71654801c2f7cd(props) {
|
|
1159
1316
|
return {
|
|
1160
|
-
keyboardProps: props.isDisabled ? {
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
onKeyUp: $951fbcbbca8db6ce$export$48d1ea6320830260(props.onKeyUp)
|
|
1317
|
+
keyboardProps: props.isDisabled ? {} : {
|
|
1318
|
+
onKeyDown: (0, $951fbcbbca8db6ce$export$48d1ea6320830260)(props.onKeyDown),
|
|
1319
|
+
onKeyUp: (0, $951fbcbbca8db6ce$export$48d1ea6320830260)(props.onKeyUp)
|
|
1164
1320
|
}
|
|
1165
1321
|
};
|
|
1166
1322
|
}
|
|
1167
1323
|
|
|
1168
1324
|
|
|
1169
|
-
|
|
1325
|
+
/*
|
|
1326
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1327
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1328
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1329
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1330
|
+
*
|
|
1331
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1332
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1333
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1334
|
+
* governing permissions and limitations under the License.
|
|
1335
|
+
*/
|
|
1170
1336
|
|
|
1171
1337
|
|
|
1172
1338
|
function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
1173
1339
|
let { onMoveStart: onMoveStart , onMove: onMove , onMoveEnd: onMoveEnd } = props;
|
|
1174
|
-
let state = $goTMa$react.useRef({
|
|
1340
|
+
let state = (0, $goTMa$react.useRef)({
|
|
1175
1341
|
didMove: false,
|
|
1176
1342
|
lastPosition: null,
|
|
1177
1343
|
id: null
|
|
1178
1344
|
});
|
|
1179
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $goTMa$reactariautils.useGlobalListeners();
|
|
1180
|
-
let
|
|
1181
|
-
let moveProps = {
|
|
1182
|
-
};
|
|
1345
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $goTMa$reactariautils.useGlobalListeners)();
|
|
1346
|
+
let moveProps = (0, $goTMa$react.useMemo)(()=>{
|
|
1347
|
+
let moveProps = {};
|
|
1183
1348
|
let start = ()=>{
|
|
1184
|
-
$f7e14e656343df57$export$16a4697467175487();
|
|
1349
|
+
(0, $f7e14e656343df57$export$16a4697467175487)();
|
|
1185
1350
|
state.current.didMove = false;
|
|
1186
1351
|
};
|
|
1187
1352
|
let move = (originalEvent, pointerType, deltaX, deltaY)=>{
|
|
@@ -1189,7 +1354,7 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1189
1354
|
if (!state.current.didMove) {
|
|
1190
1355
|
state.current.didMove = true;
|
|
1191
1356
|
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
1192
|
-
type:
|
|
1357
|
+
type: "movestart",
|
|
1193
1358
|
pointerType: pointerType,
|
|
1194
1359
|
shiftKey: originalEvent.shiftKey,
|
|
1195
1360
|
metaKey: originalEvent.metaKey,
|
|
@@ -1198,7 +1363,7 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1198
1363
|
});
|
|
1199
1364
|
}
|
|
1200
1365
|
onMove({
|
|
1201
|
-
type:
|
|
1366
|
+
type: "move",
|
|
1202
1367
|
pointerType: pointerType,
|
|
1203
1368
|
deltaX: deltaX,
|
|
1204
1369
|
deltaY: deltaY,
|
|
@@ -1209,9 +1374,9 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1209
1374
|
});
|
|
1210
1375
|
};
|
|
1211
1376
|
let end = (originalEvent, pointerType)=>{
|
|
1212
|
-
$f7e14e656343df57$export$b0d6fa1ab32e3295();
|
|
1377
|
+
(0, $f7e14e656343df57$export$b0d6fa1ab32e3295)();
|
|
1213
1378
|
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
1214
|
-
type:
|
|
1379
|
+
type: "moveend",
|
|
1215
1380
|
pointerType: pointerType,
|
|
1216
1381
|
shiftKey: originalEvent.shiftKey,
|
|
1217
1382
|
metaKey: originalEvent.metaKey,
|
|
@@ -1219,10 +1384,10 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1219
1384
|
altKey: originalEvent.altKey
|
|
1220
1385
|
});
|
|
1221
1386
|
};
|
|
1222
|
-
if (typeof PointerEvent ===
|
|
1387
|
+
if (typeof PointerEvent === "undefined") {
|
|
1223
1388
|
let onMouseMove = (e)=>{
|
|
1224
1389
|
if (e.button === 0) {
|
|
1225
|
-
move(e,
|
|
1390
|
+
move(e, "mouse", e.pageX - state.current.lastPosition.pageX, e.pageY - state.current.lastPosition.pageY);
|
|
1226
1391
|
state.current.lastPosition = {
|
|
1227
1392
|
pageX: e.pageX,
|
|
1228
1393
|
pageY: e.pageY
|
|
@@ -1231,9 +1396,9 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1231
1396
|
};
|
|
1232
1397
|
let onMouseUp = (e)=>{
|
|
1233
1398
|
if (e.button === 0) {
|
|
1234
|
-
end(e,
|
|
1235
|
-
removeGlobalListener(window,
|
|
1236
|
-
removeGlobalListener(window,
|
|
1399
|
+
end(e, "mouse");
|
|
1400
|
+
removeGlobalListener(window, "mousemove", onMouseMove, false);
|
|
1401
|
+
removeGlobalListener(window, "mouseup", onMouseUp, false);
|
|
1237
1402
|
}
|
|
1238
1403
|
};
|
|
1239
1404
|
moveProps.onMouseDown = (e)=>{
|
|
@@ -1245,18 +1410,17 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1245
1410
|
pageX: e.pageX,
|
|
1246
1411
|
pageY: e.pageY
|
|
1247
1412
|
};
|
|
1248
|
-
addGlobalListener(window,
|
|
1249
|
-
addGlobalListener(window,
|
|
1413
|
+
addGlobalListener(window, "mousemove", onMouseMove, false);
|
|
1414
|
+
addGlobalListener(window, "mouseup", onMouseUp, false);
|
|
1250
1415
|
}
|
|
1251
1416
|
};
|
|
1252
1417
|
let onTouchMove = (e)=>{
|
|
1253
1418
|
let touch = [
|
|
1254
1419
|
...e.changedTouches
|
|
1255
|
-
].findIndex(({ identifier: identifier })=>identifier === state.current.id
|
|
1256
|
-
);
|
|
1420
|
+
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
1257
1421
|
if (touch >= 0) {
|
|
1258
1422
|
let { pageX: pageX , pageY: pageY } = e.changedTouches[touch];
|
|
1259
|
-
move(e,
|
|
1423
|
+
move(e, "touch", pageX - state.current.lastPosition.pageX, pageY - state.current.lastPosition.pageY);
|
|
1260
1424
|
state.current.lastPosition = {
|
|
1261
1425
|
pageX: pageX,
|
|
1262
1426
|
pageY: pageY
|
|
@@ -1266,14 +1430,13 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1266
1430
|
let onTouchEnd = (e)=>{
|
|
1267
1431
|
let touch = [
|
|
1268
1432
|
...e.changedTouches
|
|
1269
|
-
].findIndex(({ identifier: identifier })=>identifier === state.current.id
|
|
1270
|
-
);
|
|
1433
|
+
].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
|
1271
1434
|
if (touch >= 0) {
|
|
1272
|
-
end(e,
|
|
1435
|
+
end(e, "touch");
|
|
1273
1436
|
state.current.id = null;
|
|
1274
|
-
removeGlobalListener(window,
|
|
1275
|
-
removeGlobalListener(window,
|
|
1276
|
-
removeGlobalListener(window,
|
|
1437
|
+
removeGlobalListener(window, "touchmove", onTouchMove);
|
|
1438
|
+
removeGlobalListener(window, "touchend", onTouchEnd);
|
|
1439
|
+
removeGlobalListener(window, "touchcancel", onTouchEnd);
|
|
1277
1440
|
}
|
|
1278
1441
|
};
|
|
1279
1442
|
moveProps.onTouchStart = (e)=>{
|
|
@@ -1287,14 +1450,14 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1287
1450
|
pageY: pageY
|
|
1288
1451
|
};
|
|
1289
1452
|
state.current.id = identifier;
|
|
1290
|
-
addGlobalListener(window,
|
|
1291
|
-
addGlobalListener(window,
|
|
1292
|
-
addGlobalListener(window,
|
|
1453
|
+
addGlobalListener(window, "touchmove", onTouchMove, false);
|
|
1454
|
+
addGlobalListener(window, "touchend", onTouchEnd, false);
|
|
1455
|
+
addGlobalListener(window, "touchcancel", onTouchEnd, false);
|
|
1293
1456
|
};
|
|
1294
1457
|
} else {
|
|
1295
1458
|
let onPointerMove = (e)=>{
|
|
1296
1459
|
if (e.pointerId === state.current.id) {
|
|
1297
|
-
let pointerType = e.pointerType ||
|
|
1460
|
+
let pointerType = e.pointerType || "mouse";
|
|
1298
1461
|
// Problems with PointerEvent#movementX/movementY:
|
|
1299
1462
|
// 1. it is always 0 on macOS Safari.
|
|
1300
1463
|
// 2. On Chrome Android, it's scaled by devicePixelRatio, but not on Chrome macOS
|
|
@@ -1307,12 +1470,12 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1307
1470
|
};
|
|
1308
1471
|
let onPointerUp = (e)=>{
|
|
1309
1472
|
if (e.pointerId === state.current.id) {
|
|
1310
|
-
let pointerType = e.pointerType ||
|
|
1473
|
+
let pointerType = e.pointerType || "mouse";
|
|
1311
1474
|
end(e, pointerType);
|
|
1312
1475
|
state.current.id = null;
|
|
1313
|
-
removeGlobalListener(window,
|
|
1314
|
-
removeGlobalListener(window,
|
|
1315
|
-
removeGlobalListener(window,
|
|
1476
|
+
removeGlobalListener(window, "pointermove", onPointerMove, false);
|
|
1477
|
+
removeGlobalListener(window, "pointerup", onPointerUp, false);
|
|
1478
|
+
removeGlobalListener(window, "pointercancel", onPointerUp, false);
|
|
1316
1479
|
}
|
|
1317
1480
|
};
|
|
1318
1481
|
moveProps.onPointerDown = (e)=>{
|
|
@@ -1325,39 +1488,39 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1325
1488
|
pageY: e.pageY
|
|
1326
1489
|
};
|
|
1327
1490
|
state.current.id = e.pointerId;
|
|
1328
|
-
addGlobalListener(window,
|
|
1329
|
-
addGlobalListener(window,
|
|
1330
|
-
addGlobalListener(window,
|
|
1491
|
+
addGlobalListener(window, "pointermove", onPointerMove, false);
|
|
1492
|
+
addGlobalListener(window, "pointerup", onPointerUp, false);
|
|
1493
|
+
addGlobalListener(window, "pointercancel", onPointerUp, false);
|
|
1331
1494
|
}
|
|
1332
1495
|
};
|
|
1333
1496
|
}
|
|
1334
1497
|
let triggerKeyboardMove = (e, deltaX, deltaY)=>{
|
|
1335
1498
|
start();
|
|
1336
|
-
move(e,
|
|
1337
|
-
end(e,
|
|
1499
|
+
move(e, "keyboard", deltaX, deltaY);
|
|
1500
|
+
end(e, "keyboard");
|
|
1338
1501
|
};
|
|
1339
1502
|
moveProps.onKeyDown = (e)=>{
|
|
1340
1503
|
switch(e.key){
|
|
1341
|
-
case
|
|
1342
|
-
case
|
|
1504
|
+
case "Left":
|
|
1505
|
+
case "ArrowLeft":
|
|
1343
1506
|
e.preventDefault();
|
|
1344
1507
|
e.stopPropagation();
|
|
1345
1508
|
triggerKeyboardMove(e, -1, 0);
|
|
1346
1509
|
break;
|
|
1347
|
-
case
|
|
1348
|
-
case
|
|
1510
|
+
case "Right":
|
|
1511
|
+
case "ArrowRight":
|
|
1349
1512
|
e.preventDefault();
|
|
1350
1513
|
e.stopPropagation();
|
|
1351
1514
|
triggerKeyboardMove(e, 1, 0);
|
|
1352
1515
|
break;
|
|
1353
|
-
case
|
|
1354
|
-
case
|
|
1516
|
+
case "Up":
|
|
1517
|
+
case "ArrowUp":
|
|
1355
1518
|
e.preventDefault();
|
|
1356
1519
|
e.stopPropagation();
|
|
1357
1520
|
triggerKeyboardMove(e, 0, -1);
|
|
1358
1521
|
break;
|
|
1359
|
-
case
|
|
1360
|
-
case
|
|
1522
|
+
case "Down":
|
|
1523
|
+
case "ArrowDown":
|
|
1361
1524
|
e.preventDefault();
|
|
1362
1525
|
e.stopPropagation();
|
|
1363
1526
|
triggerKeyboardMove(e, 0, 1);
|
|
@@ -1374,17 +1537,27 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1374
1537
|
removeGlobalListener
|
|
1375
1538
|
]);
|
|
1376
1539
|
return {
|
|
1377
|
-
moveProps:
|
|
1540
|
+
moveProps: moveProps
|
|
1378
1541
|
};
|
|
1379
1542
|
}
|
|
1380
1543
|
|
|
1381
1544
|
|
|
1382
1545
|
|
|
1383
|
-
|
|
1546
|
+
/*
|
|
1547
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
1548
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1549
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1550
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1551
|
+
*
|
|
1552
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1553
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1554
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1555
|
+
* governing permissions and limitations under the License.
|
|
1556
|
+
*/
|
|
1384
1557
|
|
|
1385
1558
|
function $a3dbce0aed7087e2$export$2123ff2b87c81ca(props, ref) {
|
|
1386
1559
|
let { onScroll: onScroll , isDisabled: isDisabled } = props;
|
|
1387
|
-
let onScrollHandler = $goTMa$react.useCallback((e)=>{
|
|
1560
|
+
let onScrollHandler = (0, $goTMa$react.useCallback)((e)=>{
|
|
1388
1561
|
// If the ctrlKey is pressed, this is a zoom event, do nothing.
|
|
1389
1562
|
if (e.ctrlKey) return;
|
|
1390
1563
|
// stop scrolling the page
|
|
@@ -1397,50 +1570,60 @@ function $a3dbce0aed7087e2$export$2123ff2b87c81ca(props, ref) {
|
|
|
1397
1570
|
}, [
|
|
1398
1571
|
onScroll
|
|
1399
1572
|
]);
|
|
1400
|
-
$goTMa$reactariautils.useEvent(ref,
|
|
1573
|
+
(0, $goTMa$reactariautils.useEvent)(ref, "wheel", isDisabled ? null : onScrollHandler);
|
|
1401
1574
|
}
|
|
1402
1575
|
|
|
1403
1576
|
|
|
1404
|
-
|
|
1577
|
+
/*
|
|
1578
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
1579
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
1580
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
1581
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
1582
|
+
*
|
|
1583
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
1584
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
1585
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
1586
|
+
* governing permissions and limitations under the License.
|
|
1587
|
+
*/
|
|
1405
1588
|
|
|
1406
1589
|
|
|
1407
1590
|
const $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD = 500;
|
|
1408
1591
|
function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
|
|
1409
1592
|
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({
|
|
1593
|
+
const timeRef = (0, $goTMa$react.useRef)(null);
|
|
1594
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $goTMa$reactariautils.useGlobalListeners)();
|
|
1595
|
+
let { pressProps: pressProps } = (0, $0294ea432cd92340$export$45712eceda6fad21)({
|
|
1413
1596
|
isDisabled: isDisabled,
|
|
1414
|
-
onPressStart (
|
|
1415
|
-
if (
|
|
1597
|
+
onPressStart (e) {
|
|
1598
|
+
if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
|
1416
1599
|
if (onLongPressStart) onLongPressStart({
|
|
1417
|
-
...
|
|
1418
|
-
type:
|
|
1600
|
+
...e,
|
|
1601
|
+
type: "longpressstart"
|
|
1419
1602
|
});
|
|
1420
1603
|
timeRef.current = setTimeout(()=>{
|
|
1421
1604
|
// Prevent other usePress handlers from also handling this event.
|
|
1422
|
-
|
|
1605
|
+
e.target.dispatchEvent(new PointerEvent("pointercancel", {
|
|
1423
1606
|
bubbles: true
|
|
1424
1607
|
}));
|
|
1425
1608
|
if (onLongPress) onLongPress({
|
|
1426
|
-
...
|
|
1427
|
-
type:
|
|
1609
|
+
...e,
|
|
1610
|
+
type: "longpress"
|
|
1428
1611
|
});
|
|
1429
1612
|
timeRef.current = null;
|
|
1430
1613
|
}, threshold);
|
|
1431
1614
|
// Prevent context menu, which may be opened on long press on touch devices
|
|
1432
|
-
if (
|
|
1615
|
+
if (e.pointerType === "touch") {
|
|
1433
1616
|
let onContextMenu = (e)=>{
|
|
1434
1617
|
e.preventDefault();
|
|
1435
1618
|
};
|
|
1436
|
-
addGlobalListener(
|
|
1619
|
+
addGlobalListener(e.target, "contextmenu", onContextMenu, {
|
|
1437
1620
|
once: true
|
|
1438
1621
|
});
|
|
1439
|
-
addGlobalListener(window,
|
|
1622
|
+
addGlobalListener(window, "pointerup", ()=>{
|
|
1440
1623
|
// If no contextmenu event is fired quickly after pointerup, remove the handler
|
|
1441
1624
|
// so future context menu events outside a long press are not prevented.
|
|
1442
1625
|
setTimeout(()=>{
|
|
1443
|
-
removeGlobalListener(
|
|
1626
|
+
removeGlobalListener(e.target, "contextmenu", onContextMenu);
|
|
1444
1627
|
}, 30);
|
|
1445
1628
|
}, {
|
|
1446
1629
|
once: true
|
|
@@ -1450,15 +1633,15 @@ function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
|
|
|
1450
1633
|
},
|
|
1451
1634
|
onPressEnd (e) {
|
|
1452
1635
|
if (timeRef.current) clearTimeout(timeRef.current);
|
|
1453
|
-
if (onLongPressEnd && (e.pointerType ===
|
|
1636
|
+
if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
|
|
1454
1637
|
...e,
|
|
1455
|
-
type:
|
|
1638
|
+
type: "longpressend"
|
|
1456
1639
|
});
|
|
1457
1640
|
}
|
|
1458
1641
|
});
|
|
1459
|
-
let descriptionProps = $goTMa$reactariautils.useDescription(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1642
|
+
let descriptionProps = (0, $goTMa$reactariautils.useDescription)(onLongPress && !isDisabled ? accessibilityDescription : null);
|
|
1460
1643
|
return {
|
|
1461
|
-
longPressProps: $goTMa$reactariautils.mergeProps(pressProps, descriptionProps)
|
|
1644
|
+
longPressProps: (0, $goTMa$reactariautils.mergeProps)(pressProps, descriptionProps)
|
|
1462
1645
|
};
|
|
1463
1646
|
}
|
|
1464
1647
|
|