1 | var $goTMa$reactariautils = require("@react-aria/utils");
|
2 | var $goTMa$react = require("react");
|
3 | var $goTMa$swchelperscjs_class_private_field_getcjs = require("@swc/helpers/cjs/_class_private_field_get.cjs");
|
4 | var $goTMa$swchelperscjs_class_private_field_initcjs = require("@swc/helpers/cjs/_class_private_field_init.cjs");
|
5 | var $goTMa$swchelperscjs_class_private_field_setcjs = require("@swc/helpers/cjs/_class_private_field_set.cjs");
|
6 | var $goTMa$reactariassr = require("@react-aria/ssr");
|
7 |
|
8 |
|
9 | function $parcel$export(e, n, v, s) {
|
10 | Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
11 | }
|
12 |
|
13 | function $parcel$interopDefault(a) {
|
14 | return a && a.__esModule ? a.default : a;
|
15 | }
|
16 |
|
17 | $parcel$export(module.exports, "Pressable", () => $e1dbec26039c051d$export$27c701ed9e449e99);
|
18 | $parcel$export(module.exports, "PressResponder", () => $3596bae48579386f$export$3351871ee4b288b8);
|
19 | $parcel$export(module.exports, "ClearPressResponder", () => $3596bae48579386f$export$cf75428e0b9ed1ea);
|
20 | $parcel$export(module.exports, "useFocus", () => $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6);
|
21 | $parcel$export(module.exports, "isFocusVisible", () => $e77252a287ef94ab$export$b9b3dfddab17db27);
|
22 | $parcel$export(module.exports, "getInteractionModality", () => $e77252a287ef94ab$export$630ff653c5ada6a9);
|
23 | $parcel$export(module.exports, "setInteractionModality", () => $e77252a287ef94ab$export$8397ddfc504fdb9a);
|
24 | $parcel$export(module.exports, "useInteractionModality", () => $e77252a287ef94ab$export$98e20ec92f614cfe);
|
25 | $parcel$export(module.exports, "useFocusVisible", () => $e77252a287ef94ab$export$ffd9e5021c1fb2d6);
|
26 | $parcel$export(module.exports, "useFocusVisibleListener", () => $e77252a287ef94ab$export$ec71b4b83ac08ec3);
|
27 | $parcel$export(module.exports, "useFocusWithin", () => $d16842bbd0359d1b$export$420e68273165f4ec);
|
28 | $parcel$export(module.exports, "useHover", () => $ffbc150311c75f01$export$ae780daf29e6d456);
|
29 | $parcel$export(module.exports, "useInteractOutside", () => $edcfa848c42f94f4$export$872b660ac5a1ff98);
|
30 | $parcel$export(module.exports, "useKeyboard", () => $892d64db2a3c53b0$export$8f71654801c2f7cd);
|
31 | $parcel$export(module.exports, "useMove", () => $c09386fc48fa427d$export$36da96379f79f245);
|
32 | $parcel$export(module.exports, "usePress", () => $0294ea432cd92340$export$45712eceda6fad21);
|
33 | $parcel$export(module.exports, "useScrollWheel", () => $a3dbce0aed7087e2$export$2123ff2b87c81ca);
|
34 | $parcel$export(module.exports, "useLongPress", () => $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9);
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | let $f7e14e656343df57$var$state = "default";
|
87 | let $f7e14e656343df57$var$savedUserSelect = "";
|
88 | let $f7e14e656343df57$var$modifiedElementMap = new WeakMap();
|
89 | function $f7e14e656343df57$export$16a4697467175487(target) {
|
90 | if ((0, $goTMa$reactariautils.isIOS)()) {
|
91 | if ($f7e14e656343df57$var$state === "default") {
|
92 |
|
93 | const documentObject = (0, $goTMa$reactariautils.getOwnerDocument)(target);
|
94 | $f7e14e656343df57$var$savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
|
95 | documentObject.documentElement.style.webkitUserSelect = "none";
|
96 | }
|
97 | $f7e14e656343df57$var$state = "disabled";
|
98 | } else if (target instanceof HTMLElement || target instanceof SVGElement) {
|
99 |
|
100 |
|
101 | $f7e14e656343df57$var$modifiedElementMap.set(target, target.style.userSelect);
|
102 | target.style.userSelect = "none";
|
103 | }
|
104 | }
|
105 | function $f7e14e656343df57$export$b0d6fa1ab32e3295(target) {
|
106 | if ((0, $goTMa$reactariautils.isIOS)()) {
|
107 |
|
108 |
|
109 | if ($f7e14e656343df57$var$state !== "disabled") return;
|
110 | $f7e14e656343df57$var$state = "restoring";
|
111 |
|
112 |
|
113 | setTimeout(()=>{
|
114 |
|
115 |
|
116 | (0, $goTMa$reactariautils.runAfterTransition)(()=>{
|
117 |
|
118 | if ($f7e14e656343df57$var$state === "restoring") {
|
119 |
|
120 | const documentObject = (0, $goTMa$reactariautils.getOwnerDocument)(target);
|
121 | if (documentObject.documentElement.style.webkitUserSelect === "none") documentObject.documentElement.style.webkitUserSelect = $f7e14e656343df57$var$savedUserSelect || "";
|
122 | $f7e14e656343df57$var$savedUserSelect = "";
|
123 | $f7e14e656343df57$var$state = "default";
|
124 | }
|
125 | });
|
126 | }, 300);
|
127 | } else if (target instanceof HTMLElement || target instanceof SVGElement)
|
128 |
|
129 | {
|
130 | if (target && $f7e14e656343df57$var$modifiedElementMap.has(target)) {
|
131 | let targetOldUserSelect = $f7e14e656343df57$var$modifiedElementMap.get(target);
|
132 | if (target.style.userSelect === "none" && targetOldUserSelect) target.style.userSelect = targetOldUserSelect;
|
133 | if (target.getAttribute("style") === "") target.removeAttribute("style");
|
134 | $f7e14e656343df57$var$modifiedElementMap.delete(target);
|
135 | }
|
136 | }
|
137 | }
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 | const $01d3f539e91688c8$export$5165eccb35aaadb5 = (0, ($parcel$interopDefault($goTMa$react))).createContext({
|
153 | register: ()=>{}
|
154 | });
|
155 | $01d3f539e91688c8$export$5165eccb35aaadb5.displayName = "PressResponderContext";
|
156 |
|
157 |
|
158 |
|
159 | function $0294ea432cd92340$var$usePressResponderContext(props) {
|
160 |
|
161 | let context = (0, $goTMa$react.useContext)((0, $01d3f539e91688c8$export$5165eccb35aaadb5));
|
162 | if (context) {
|
163 | let { register: register, ...contextProps } = context;
|
164 | props = (0, $goTMa$reactariautils.mergeProps)(contextProps, props);
|
165 | register();
|
166 | }
|
167 | (0, $goTMa$reactariautils.useSyncRef)(context, props.ref);
|
168 | return props;
|
169 | }
|
170 | var $0294ea432cd92340$var$_shouldStopPropagation = new WeakMap();
|
171 | class $0294ea432cd92340$var$PressEvent {
|
172 | continuePropagation() {
|
173 | (0, $goTMa$swchelperscjs_class_private_field_setcjs._)(this, $0294ea432cd92340$var$_shouldStopPropagation, false);
|
174 | }
|
175 | get shouldStopPropagation() {
|
176 | return (0, $goTMa$swchelperscjs_class_private_field_getcjs._)(this, $0294ea432cd92340$var$_shouldStopPropagation);
|
177 | }
|
178 | constructor(type, pointerType, originalEvent){
|
179 | (0, $goTMa$swchelperscjs_class_private_field_initcjs._)(this, $0294ea432cd92340$var$_shouldStopPropagation, {
|
180 | writable: true,
|
181 | value: void 0
|
182 | });
|
183 | (0, $goTMa$swchelperscjs_class_private_field_setcjs._)(this, $0294ea432cd92340$var$_shouldStopPropagation, true);
|
184 | this.type = type;
|
185 | this.pointerType = pointerType;
|
186 | this.target = originalEvent.currentTarget;
|
187 | this.shiftKey = originalEvent.shiftKey;
|
188 | this.metaKey = originalEvent.metaKey;
|
189 | this.ctrlKey = originalEvent.ctrlKey;
|
190 | this.altKey = originalEvent.altKey;
|
191 | }
|
192 | }
|
193 | const $0294ea432cd92340$var$LINK_CLICKED = Symbol("linkClicked");
|
194 | function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
195 | let { onPress: onPress, onPressChange: onPressChange, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressUp: onPressUp, isDisabled: isDisabled, isPressed: isPressedProp, preventFocusOnPress: preventFocusOnPress, shouldCancelOnPointerExit: shouldCancelOnPointerExit, allowTextSelectionOnPress: allowTextSelectionOnPress,
|
196 | ref: _, ...domProps } = $0294ea432cd92340$var$usePressResponderContext(props);
|
197 | let [isPressed, setPressed] = (0, $goTMa$react.useState)(false);
|
198 | let ref = (0, $goTMa$react.useRef)({
|
199 | isPressed: false,
|
200 | ignoreEmulatedMouseEvents: false,
|
201 | ignoreClickAfterPress: false,
|
202 | didFirePressStart: false,
|
203 | isTriggeringEvent: false,
|
204 | activePointerId: null,
|
205 | target: null,
|
206 | isOverTarget: false,
|
207 | pointerType: null
|
208 | });
|
209 | let { addGlobalListener: addGlobalListener, removeAllGlobalListeners: removeAllGlobalListeners } = (0, $goTMa$reactariautils.useGlobalListeners)();
|
210 | let triggerPressStart = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType)=>{
|
211 | let state = ref.current;
|
212 | if (isDisabled || state.didFirePressStart) return false;
|
213 | let shouldStopPropagation = true;
|
214 | state.isTriggeringEvent = true;
|
215 | if (onPressStart) {
|
216 | let event = new $0294ea432cd92340$var$PressEvent("pressstart", pointerType, originalEvent);
|
217 | onPressStart(event);
|
218 | shouldStopPropagation = event.shouldStopPropagation;
|
219 | }
|
220 | if (onPressChange) onPressChange(true);
|
221 | state.isTriggeringEvent = false;
|
222 | state.didFirePressStart = true;
|
223 | setPressed(true);
|
224 | return shouldStopPropagation;
|
225 | });
|
226 | let triggerPressEnd = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType, wasPressed = true)=>{
|
227 | let state = ref.current;
|
228 | if (!state.didFirePressStart) return false;
|
229 | state.ignoreClickAfterPress = true;
|
230 | state.didFirePressStart = false;
|
231 | state.isTriggeringEvent = true;
|
232 | let shouldStopPropagation = true;
|
233 | if (onPressEnd) {
|
234 | let event = new $0294ea432cd92340$var$PressEvent("pressend", pointerType, originalEvent);
|
235 | onPressEnd(event);
|
236 | shouldStopPropagation = event.shouldStopPropagation;
|
237 | }
|
238 | if (onPressChange) onPressChange(false);
|
239 | setPressed(false);
|
240 | if (onPress && wasPressed && !isDisabled) {
|
241 | let event = new $0294ea432cd92340$var$PressEvent("press", pointerType, originalEvent);
|
242 | onPress(event);
|
243 | shouldStopPropagation && (shouldStopPropagation = event.shouldStopPropagation);
|
244 | }
|
245 | state.isTriggeringEvent = false;
|
246 | return shouldStopPropagation;
|
247 | });
|
248 | let triggerPressUp = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType)=>{
|
249 | let state = ref.current;
|
250 | if (isDisabled) return false;
|
251 | if (onPressUp) {
|
252 | state.isTriggeringEvent = true;
|
253 | let event = new $0294ea432cd92340$var$PressEvent("pressup", pointerType, originalEvent);
|
254 | onPressUp(event);
|
255 | state.isTriggeringEvent = false;
|
256 | return event.shouldStopPropagation;
|
257 | }
|
258 | return true;
|
259 | });
|
260 | let cancel = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
261 | let state = ref.current;
|
262 | if (state.isPressed && state.target) {
|
263 | if (state.isOverTarget && state.pointerType != null) triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
264 | state.isPressed = false;
|
265 | state.isOverTarget = false;
|
266 | state.activePointerId = null;
|
267 | state.pointerType = null;
|
268 | removeAllGlobalListeners();
|
269 | if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$export$b0d6fa1ab32e3295)(state.target);
|
270 | }
|
271 | });
|
272 | let cancelOnPointerExit = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
273 | if (shouldCancelOnPointerExit) cancel(e);
|
274 | });
|
275 | let pressProps = (0, $goTMa$react.useMemo)(()=>{
|
276 | let state = ref.current;
|
277 | let pressProps = {
|
278 | onKeyDown (e) {
|
279 | if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.contains(e.target)) {
|
280 | var _state_metaKeyEvents;
|
281 | if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
|
282 |
|
283 |
|
284 |
|
285 | let shouldStopPropagation = true;
|
286 | if (!state.isPressed && !e.repeat) {
|
287 | state.target = e.currentTarget;
|
288 | state.isPressed = true;
|
289 | shouldStopPropagation = triggerPressStart(e, "keyboard");
|
290 |
|
291 |
|
292 | addGlobalListener((0, $goTMa$reactariautils.getOwnerDocument)(e.currentTarget), "keyup", onKeyUp, false);
|
293 | }
|
294 | if (shouldStopPropagation) e.stopPropagation();
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 | if (e.metaKey && (0, $goTMa$reactariautils.isMac)()) (_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 ? void 0 : _state_metaKeyEvents.set(e.key, e.nativeEvent);
|
303 | } else if (e.key === "Meta") state.metaKeyEvents = new Map();
|
304 | },
|
305 | onKeyUp (e) {
|
306 | if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && !e.repeat && e.currentTarget.contains(e.target) && state.target) triggerPressUp($0294ea432cd92340$var$createEvent(state.target, e), "keyboard");
|
307 | },
|
308 | onClick (e) {
|
309 | if (e && !e.currentTarget.contains(e.target)) return;
|
310 | if (e && e.button === 0 && !state.isTriggeringEvent && !(0, $goTMa$reactariautils.openLink).isOpening) {
|
311 | let shouldStopPropagation = true;
|
312 | if (isDisabled) e.preventDefault();
|
313 |
|
314 |
|
315 | if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && !state.isPressed && (state.pointerType === "virtual" || (0, $goTMa$reactariautils.isVirtualClick)(e.nativeEvent))) {
|
316 |
|
317 | if (!isDisabled && !preventFocusOnPress) (0, $goTMa$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
318 | let stopPressStart = triggerPressStart(e, "virtual");
|
319 | let stopPressUp = triggerPressUp(e, "virtual");
|
320 | let stopPressEnd = triggerPressEnd(e, "virtual");
|
321 | shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;
|
322 | }
|
323 | state.ignoreEmulatedMouseEvents = false;
|
324 | state.ignoreClickAfterPress = false;
|
325 | if (shouldStopPropagation) e.stopPropagation();
|
326 | }
|
327 | }
|
328 | };
|
329 | let onKeyUp = (e)=>{
|
330 | var _state_metaKeyEvents;
|
331 | if (state.isPressed && state.target && $0294ea432cd92340$var$isValidKeyboardEvent(e, state.target)) {
|
332 | var _state_metaKeyEvents1;
|
333 | if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
|
334 | let target = e.target;
|
335 | let shouldStopPropagation = triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
|
336 | removeAllGlobalListeners();
|
337 | if (shouldStopPropagation) e.stopPropagation();
|
338 |
|
339 |
|
340 |
|
341 | if (e.key !== "Enter" && $0294ea432cd92340$var$isHTMLAnchorLink(state.target) && state.target.contains(target) && !e[$0294ea432cd92340$var$LINK_CLICKED]) {
|
342 |
|
343 |
|
344 | e[$0294ea432cd92340$var$LINK_CLICKED] = true;
|
345 | (0, $goTMa$reactariautils.openLink)(state.target, e, false);
|
346 | }
|
347 | state.isPressed = false;
|
348 | (_state_metaKeyEvents1 = state.metaKeyEvents) === null || _state_metaKeyEvents1 === void 0 ? void 0 : _state_metaKeyEvents1.delete(e.key);
|
349 | } else if (e.key === "Meta" && ((_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 ? void 0 : _state_metaKeyEvents.size)) {
|
350 | var _state_target;
|
351 |
|
352 |
|
353 |
|
354 | let events = state.metaKeyEvents;
|
355 | state.metaKeyEvents = undefined;
|
356 | for (let event of events.values())(_state_target = state.target) === null || _state_target === void 0 ? void 0 : _state_target.dispatchEvent(new KeyboardEvent("keyup", event));
|
357 | }
|
358 | };
|
359 | if (typeof PointerEvent !== "undefined") {
|
360 | pressProps.onPointerDown = (e)=>{
|
361 |
|
362 | if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
|
363 |
|
364 |
|
365 |
|
366 |
|
367 | if ((0, $goTMa$reactariautils.isVirtualPointerEvent)(e.nativeEvent)) {
|
368 | state.pointerType = "virtual";
|
369 | return;
|
370 | }
|
371 |
|
372 |
|
373 | if ($0294ea432cd92340$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
|
374 | state.pointerType = e.pointerType;
|
375 | let shouldStopPropagation = true;
|
376 | if (!state.isPressed) {
|
377 | state.isPressed = true;
|
378 | state.isOverTarget = true;
|
379 | state.activePointerId = e.pointerId;
|
380 | state.target = e.currentTarget;
|
381 | if (!isDisabled && !preventFocusOnPress) (0, $goTMa$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
382 | if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$export$16a4697467175487)(state.target);
|
383 | shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
384 | addGlobalListener((0, $goTMa$reactariautils.getOwnerDocument)(e.currentTarget), "pointermove", onPointerMove, false);
|
385 | addGlobalListener((0, $goTMa$reactariautils.getOwnerDocument)(e.currentTarget), "pointerup", onPointerUp, false);
|
386 | addGlobalListener((0, $goTMa$reactariautils.getOwnerDocument)(e.currentTarget), "pointercancel", onPointerCancel, false);
|
387 | }
|
388 | if (shouldStopPropagation) e.stopPropagation();
|
389 | };
|
390 | pressProps.onMouseDown = (e)=>{
|
391 | if (!e.currentTarget.contains(e.target)) return;
|
392 | if (e.button === 0) {
|
393 |
|
394 |
|
395 |
|
396 | if ($0294ea432cd92340$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
|
397 | e.stopPropagation();
|
398 | }
|
399 | };
|
400 | pressProps.onPointerUp = (e)=>{
|
401 |
|
402 | if (!e.currentTarget.contains(e.target) || state.pointerType === "virtual") return;
|
403 |
|
404 |
|
405 |
|
406 | if (e.button === 0 && $0294ea432cd92340$var$isOverTarget(e, e.currentTarget)) triggerPressUp(e, state.pointerType || e.pointerType);
|
407 | };
|
408 |
|
409 |
|
410 |
|
411 | let onPointerMove = (e)=>{
|
412 | if (e.pointerId !== state.activePointerId) return;
|
413 | if (state.target && $0294ea432cd92340$var$isOverTarget(e, state.target)) {
|
414 | if (!state.isOverTarget && state.pointerType != null) {
|
415 | state.isOverTarget = true;
|
416 | triggerPressStart($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType);
|
417 | }
|
418 | } else if (state.target && state.isOverTarget && state.pointerType != null) {
|
419 | state.isOverTarget = false;
|
420 | triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
421 | cancelOnPointerExit(e);
|
422 | }
|
423 | };
|
424 | let onPointerUp = (e)=>{
|
425 | if (e.pointerId === state.activePointerId && state.isPressed && e.button === 0 && state.target) {
|
426 | if ($0294ea432cd92340$var$isOverTarget(e, state.target) && state.pointerType != null) triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType);
|
427 | else if (state.isOverTarget && state.pointerType != null) triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
428 | state.isPressed = false;
|
429 | state.isOverTarget = false;
|
430 | state.activePointerId = null;
|
431 | state.pointerType = null;
|
432 | removeAllGlobalListeners();
|
433 | if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$export$b0d6fa1ab32e3295)(state.target);
|
434 | }
|
435 | };
|
436 | let onPointerCancel = (e)=>{
|
437 | cancel(e);
|
438 | };
|
439 | pressProps.onDragStart = (e)=>{
|
440 | if (!e.currentTarget.contains(e.target)) return;
|
441 |
|
442 | cancel(e);
|
443 | };
|
444 | } else {
|
445 | pressProps.onMouseDown = (e)=>{
|
446 |
|
447 | if (e.button !== 0 || !e.currentTarget.contains(e.target)) return;
|
448 |
|
449 |
|
450 | if ($0294ea432cd92340$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
|
451 | if (state.ignoreEmulatedMouseEvents) {
|
452 | e.stopPropagation();
|
453 | return;
|
454 | }
|
455 | state.isPressed = true;
|
456 | state.isOverTarget = true;
|
457 | state.target = e.currentTarget;
|
458 | state.pointerType = (0, $goTMa$reactariautils.isVirtualClick)(e.nativeEvent) ? "virtual" : "mouse";
|
459 | if (!isDisabled && !preventFocusOnPress) (0, $goTMa$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
460 | let shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
461 | if (shouldStopPropagation) e.stopPropagation();
|
462 | addGlobalListener((0, $goTMa$reactariautils.getOwnerDocument)(e.currentTarget), "mouseup", onMouseUp, false);
|
463 | };
|
464 | pressProps.onMouseEnter = (e)=>{
|
465 | if (!e.currentTarget.contains(e.target)) return;
|
466 | let shouldStopPropagation = true;
|
467 | if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {
|
468 | state.isOverTarget = true;
|
469 | shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
470 | }
|
471 | if (shouldStopPropagation) e.stopPropagation();
|
472 | };
|
473 | pressProps.onMouseLeave = (e)=>{
|
474 | if (!e.currentTarget.contains(e.target)) return;
|
475 | let shouldStopPropagation = true;
|
476 | if (state.isPressed && !state.ignoreEmulatedMouseEvents && state.pointerType != null) {
|
477 | state.isOverTarget = false;
|
478 | shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
|
479 | cancelOnPointerExit(e);
|
480 | }
|
481 | if (shouldStopPropagation) e.stopPropagation();
|
482 | };
|
483 | pressProps.onMouseUp = (e)=>{
|
484 | if (!e.currentTarget.contains(e.target)) return;
|
485 | if (!state.ignoreEmulatedMouseEvents && e.button === 0) triggerPressUp(e, state.pointerType || "mouse");
|
486 | };
|
487 | let onMouseUp = (e)=>{
|
488 |
|
489 | if (e.button !== 0) return;
|
490 | state.isPressed = false;
|
491 | removeAllGlobalListeners();
|
492 | if (state.ignoreEmulatedMouseEvents) {
|
493 | state.ignoreEmulatedMouseEvents = false;
|
494 | return;
|
495 | }
|
496 | if (state.target && $0294ea432cd92340$var$isOverTarget(e, state.target) && state.pointerType != null) triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType);
|
497 | else if (state.target && state.isOverTarget && state.pointerType != null) triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
498 | state.isOverTarget = false;
|
499 | };
|
500 | pressProps.onTouchStart = (e)=>{
|
501 | if (!e.currentTarget.contains(e.target)) return;
|
502 | let touch = $0294ea432cd92340$var$getTouchFromEvent(e.nativeEvent);
|
503 | if (!touch) return;
|
504 | state.activePointerId = touch.identifier;
|
505 | state.ignoreEmulatedMouseEvents = true;
|
506 | state.isOverTarget = true;
|
507 | state.isPressed = true;
|
508 | state.target = e.currentTarget;
|
509 | state.pointerType = "touch";
|
510 |
|
511 |
|
512 | if (!isDisabled && !preventFocusOnPress) (0, $goTMa$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
513 | if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$export$16a4697467175487)(state.target);
|
514 | let shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
515 | if (shouldStopPropagation) e.stopPropagation();
|
516 | addGlobalListener((0, $goTMa$reactariautils.getOwnerWindow)(e.currentTarget), "scroll", onScroll, true);
|
517 | };
|
518 | pressProps.onTouchMove = (e)=>{
|
519 | if (!e.currentTarget.contains(e.target)) return;
|
520 | if (!state.isPressed) {
|
521 | e.stopPropagation();
|
522 | return;
|
523 | }
|
524 | let touch = $0294ea432cd92340$var$getTouchById(e.nativeEvent, state.activePointerId);
|
525 | let shouldStopPropagation = true;
|
526 | if (touch && $0294ea432cd92340$var$isOverTarget(touch, e.currentTarget)) {
|
527 | if (!state.isOverTarget && state.pointerType != null) {
|
528 | state.isOverTarget = true;
|
529 | shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
530 | }
|
531 | } else if (state.isOverTarget && state.pointerType != null) {
|
532 | state.isOverTarget = false;
|
533 | shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
|
534 | cancelOnPointerExit(e);
|
535 | }
|
536 | if (shouldStopPropagation) e.stopPropagation();
|
537 | };
|
538 | pressProps.onTouchEnd = (e)=>{
|
539 | if (!e.currentTarget.contains(e.target)) return;
|
540 | if (!state.isPressed) {
|
541 | e.stopPropagation();
|
542 | return;
|
543 | }
|
544 | let touch = $0294ea432cd92340$var$getTouchById(e.nativeEvent, state.activePointerId);
|
545 | let shouldStopPropagation = true;
|
546 | if (touch && $0294ea432cd92340$var$isOverTarget(touch, e.currentTarget) && state.pointerType != null) {
|
547 | triggerPressUp(e, state.pointerType);
|
548 | shouldStopPropagation = triggerPressEnd(e, state.pointerType);
|
549 | } else if (state.isOverTarget && state.pointerType != null) shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
|
550 | if (shouldStopPropagation) e.stopPropagation();
|
551 | state.isPressed = false;
|
552 | state.activePointerId = null;
|
553 | state.isOverTarget = false;
|
554 | state.ignoreEmulatedMouseEvents = true;
|
555 | if (state.target && !allowTextSelectionOnPress) (0, $f7e14e656343df57$export$b0d6fa1ab32e3295)(state.target);
|
556 | removeAllGlobalListeners();
|
557 | };
|
558 | pressProps.onTouchCancel = (e)=>{
|
559 | if (!e.currentTarget.contains(e.target)) return;
|
560 | e.stopPropagation();
|
561 | if (state.isPressed) cancel(e);
|
562 | };
|
563 | let onScroll = (e)=>{
|
564 | if (state.isPressed && e.target.contains(state.target)) cancel({
|
565 | currentTarget: state.target,
|
566 | shiftKey: false,
|
567 | ctrlKey: false,
|
568 | metaKey: false,
|
569 | altKey: false
|
570 | });
|
571 | };
|
572 | pressProps.onDragStart = (e)=>{
|
573 | if (!e.currentTarget.contains(e.target)) return;
|
574 | cancel(e);
|
575 | };
|
576 | }
|
577 | return pressProps;
|
578 | }, [
|
579 | addGlobalListener,
|
580 | isDisabled,
|
581 | preventFocusOnPress,
|
582 | removeAllGlobalListeners,
|
583 | allowTextSelectionOnPress,
|
584 | cancel,
|
585 | cancelOnPointerExit,
|
586 | triggerPressEnd,
|
587 | triggerPressStart,
|
588 | triggerPressUp
|
589 | ]);
|
590 |
|
591 |
|
592 | (0, $goTMa$react.useEffect)(()=>{
|
593 | return ()=>{
|
594 | var _ref_current_target;
|
595 | if (!allowTextSelectionOnPress)
|
596 | (0, $f7e14e656343df57$export$b0d6fa1ab32e3295)((_ref_current_target = ref.current.target) !== null && _ref_current_target !== void 0 ? _ref_current_target : undefined);
|
597 | };
|
598 | }, [
|
599 | allowTextSelectionOnPress
|
600 | ]);
|
601 | return {
|
602 | isPressed: isPressedProp || isPressed,
|
603 | pressProps: (0, $goTMa$reactariautils.mergeProps)(domProps, pressProps)
|
604 | };
|
605 | }
|
606 | function $0294ea432cd92340$var$isHTMLAnchorLink(target) {
|
607 | return target.tagName === "A" && target.hasAttribute("href");
|
608 | }
|
609 | function $0294ea432cd92340$var$isValidKeyboardEvent(event, currentTarget) {
|
610 | const { key: key, code: code } = event;
|
611 | const element = currentTarget;
|
612 | const role = element.getAttribute("role");
|
613 |
|
614 |
|
615 | return (key === "Enter" || key === " " || key === "Spacebar" || code === "Space") && !(element instanceof (0, $goTMa$reactariautils.getOwnerWindow)(element).HTMLInputElement && !$0294ea432cd92340$var$isValidInputKey(element, key) || element instanceof (0, $goTMa$reactariautils.getOwnerWindow)(element).HTMLTextAreaElement || element.isContentEditable) &&
|
616 | !((role === "link" || !role && $0294ea432cd92340$var$isHTMLAnchorLink(element)) && key !== "Enter");
|
617 | }
|
618 | function $0294ea432cd92340$var$getTouchFromEvent(event) {
|
619 | const { targetTouches: targetTouches } = event;
|
620 | if (targetTouches.length > 0) return targetTouches[0];
|
621 | return null;
|
622 | }
|
623 | function $0294ea432cd92340$var$getTouchById(event, pointerId) {
|
624 | const changedTouches = event.changedTouches;
|
625 | for(let i = 0; i < changedTouches.length; i++){
|
626 | const touch = changedTouches[i];
|
627 | if (touch.identifier === pointerId) return touch;
|
628 | }
|
629 | return null;
|
630 | }
|
631 | function $0294ea432cd92340$var$createEvent(target, e) {
|
632 | return {
|
633 | currentTarget: target,
|
634 | shiftKey: e.shiftKey,
|
635 | ctrlKey: e.ctrlKey,
|
636 | metaKey: e.metaKey,
|
637 | altKey: e.altKey
|
638 | };
|
639 | }
|
640 | function $0294ea432cd92340$var$getPointClientRect(point) {
|
641 | let offsetX = 0;
|
642 | let offsetY = 0;
|
643 | if (point.width !== undefined) offsetX = point.width / 2;
|
644 | else if (point.radiusX !== undefined) offsetX = point.radiusX;
|
645 | if (point.height !== undefined) offsetY = point.height / 2;
|
646 | else if (point.radiusY !== undefined) offsetY = point.radiusY;
|
647 | return {
|
648 | top: point.clientY - offsetY,
|
649 | right: point.clientX + offsetX,
|
650 | bottom: point.clientY + offsetY,
|
651 | left: point.clientX - offsetX
|
652 | };
|
653 | }
|
654 | function $0294ea432cd92340$var$areRectanglesOverlapping(a, b) {
|
655 |
|
656 | if (a.left > b.right || b.left > a.right) return false;
|
657 |
|
658 | if (a.top > b.bottom || b.top > a.bottom) return false;
|
659 | return true;
|
660 | }
|
661 | function $0294ea432cd92340$var$isOverTarget(point, target) {
|
662 | let rect = target.getBoundingClientRect();
|
663 | let pointRect = $0294ea432cd92340$var$getPointClientRect(point);
|
664 | return $0294ea432cd92340$var$areRectanglesOverlapping(rect, pointRect);
|
665 | }
|
666 | function $0294ea432cd92340$var$shouldPreventDefault(target) {
|
667 |
|
668 | return !(target instanceof HTMLElement) || !target.hasAttribute("draggable");
|
669 | }
|
670 | function $0294ea432cd92340$var$shouldPreventDefaultKeyboard(target, key) {
|
671 | if (target instanceof HTMLInputElement) return !$0294ea432cd92340$var$isValidInputKey(target, key);
|
672 | if (target instanceof HTMLButtonElement) return target.type !== "submit" && target.type !== "reset";
|
673 | if ($0294ea432cd92340$var$isHTMLAnchorLink(target)) return false;
|
674 | return true;
|
675 | }
|
676 | const $0294ea432cd92340$var$nonTextInputTypes = new Set([
|
677 | "checkbox",
|
678 | "radio",
|
679 | "range",
|
680 | "color",
|
681 | "file",
|
682 | "image",
|
683 | "button",
|
684 | "submit",
|
685 | "reset"
|
686 | ]);
|
687 | function $0294ea432cd92340$var$isValidInputKey(target, key) {
|
688 |
|
689 | return target.type === "checkbox" || target.type === "radio" ? key === " " : $0294ea432cd92340$var$nonTextInputTypes.has(target.type);
|
690 | }
|
691 |
|
692 |
|
693 |
|
694 | const $e1dbec26039c051d$export$27c701ed9e449e99 = (0, ($parcel$interopDefault($goTMa$react))).forwardRef(({ children: children, ...props }, ref)=>{
|
695 | ref = (0, $goTMa$reactariautils.useObjectRef)(ref);
|
696 | let { pressProps: pressProps } = (0, $0294ea432cd92340$export$45712eceda6fad21)({
|
697 | ...props,
|
698 | ref: ref
|
699 | });
|
700 | let child = (0, ($parcel$interopDefault($goTMa$react))).Children.only(children);
|
701 | return (0, ($parcel$interopDefault($goTMa$react))).cloneElement(child,
|
702 | {
|
703 | ref: ref,
|
704 | ...(0, $goTMa$reactariautils.mergeProps)(child.props, pressProps)
|
705 | });
|
706 | });
|
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 |
|
722 | const $3596bae48579386f$export$3351871ee4b288b8 = (0, ($parcel$interopDefault($goTMa$react))).forwardRef(({ children: children, ...props }, ref)=>{
|
723 | let isRegistered = (0, $goTMa$react.useRef)(false);
|
724 | let prevContext = (0, $goTMa$react.useContext)((0, $01d3f539e91688c8$export$5165eccb35aaadb5));
|
725 | ref = (0, $goTMa$reactariautils.useObjectRef)(ref || (prevContext === null || prevContext === void 0 ? void 0 : prevContext.ref));
|
726 | let context = (0, $goTMa$reactariautils.mergeProps)(prevContext || {}, {
|
727 | ...props,
|
728 | ref: ref,
|
729 | register () {
|
730 | isRegistered.current = true;
|
731 | if (prevContext) prevContext.register();
|
732 | }
|
733 | });
|
734 | (0, $goTMa$reactariautils.useSyncRef)(prevContext, ref);
|
735 | (0, $goTMa$react.useEffect)(()=>{
|
736 | if (!isRegistered.current) {
|
737 | console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component.");
|
738 | isRegistered.current = true;
|
739 | }
|
740 | }, []);
|
741 | return (0, ($parcel$interopDefault($goTMa$react))).createElement((0, $01d3f539e91688c8$export$5165eccb35aaadb5).Provider, {
|
742 | value: context
|
743 | }, children);
|
744 | });
|
745 | function $3596bae48579386f$export$cf75428e0b9ed1ea({ children: children }) {
|
746 | let context = (0, $goTMa$react.useMemo)(()=>({
|
747 | register: ()=>{}
|
748 | }), []);
|
749 | return (0, ($parcel$interopDefault($goTMa$react))).createElement((0, $01d3f539e91688c8$export$5165eccb35aaadb5).Provider, {
|
750 | value: context
|
751 | }, children);
|
752 | }
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 | class $625cf83917e112ad$export$905e7fc544a71f36 {
|
783 | isDefaultPrevented() {
|
784 | return this.nativeEvent.defaultPrevented;
|
785 | }
|
786 | preventDefault() {
|
787 | this.defaultPrevented = true;
|
788 | this.nativeEvent.preventDefault();
|
789 | }
|
790 | stopPropagation() {
|
791 | this.nativeEvent.stopPropagation();
|
792 | this.isPropagationStopped = ()=>true;
|
793 | }
|
794 | isPropagationStopped() {
|
795 | return false;
|
796 | }
|
797 | persist() {}
|
798 | constructor(type, nativeEvent){
|
799 | this.nativeEvent = nativeEvent;
|
800 | this.target = nativeEvent.target;
|
801 | this.currentTarget = nativeEvent.currentTarget;
|
802 | this.relatedTarget = nativeEvent.relatedTarget;
|
803 | this.bubbles = nativeEvent.bubbles;
|
804 | this.cancelable = nativeEvent.cancelable;
|
805 | this.defaultPrevented = nativeEvent.defaultPrevented;
|
806 | this.eventPhase = nativeEvent.eventPhase;
|
807 | this.isTrusted = nativeEvent.isTrusted;
|
808 | this.timeStamp = nativeEvent.timeStamp;
|
809 | this.type = type;
|
810 | }
|
811 | }
|
812 | function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
813 | let stateRef = (0, $goTMa$react.useRef)({
|
814 | isFocused: false,
|
815 | observer: null
|
816 | });
|
817 |
|
818 |
|
819 | (0, $goTMa$reactariautils.useLayoutEffect)(()=>{
|
820 | const state = stateRef.current;
|
821 | return ()=>{
|
822 | if (state.observer) {
|
823 | state.observer.disconnect();
|
824 | state.observer = null;
|
825 | }
|
826 | };
|
827 | }, []);
|
828 | let dispatchBlur = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
829 | onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
830 | });
|
831 |
|
832 | return (0, $goTMa$react.useCallback)((e)=>{
|
833 |
|
834 |
|
835 |
|
836 |
|
837 | if (e.target instanceof HTMLButtonElement || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement) {
|
838 | stateRef.current.isFocused = true;
|
839 | let target = e.target;
|
840 | let onBlurHandler = (e)=>{
|
841 | stateRef.current.isFocused = false;
|
842 | if (target.disabled)
|
843 | dispatchBlur(new $625cf83917e112ad$export$905e7fc544a71f36("blur", e));
|
844 |
|
845 | if (stateRef.current.observer) {
|
846 | stateRef.current.observer.disconnect();
|
847 | stateRef.current.observer = null;
|
848 | }
|
849 | };
|
850 | target.addEventListener("focusout", onBlurHandler, {
|
851 | once: true
|
852 | });
|
853 | stateRef.current.observer = new MutationObserver(()=>{
|
854 | if (stateRef.current.isFocused && target.disabled) {
|
855 | var _stateRef_current_observer;
|
856 | (_stateRef_current_observer = stateRef.current.observer) === null || _stateRef_current_observer === void 0 ? void 0 : _stateRef_current_observer.disconnect();
|
857 | let relatedTargetEl = target === document.activeElement ? null : document.activeElement;
|
858 | target.dispatchEvent(new FocusEvent("blur", {
|
859 | relatedTarget: relatedTargetEl
|
860 | }));
|
861 | target.dispatchEvent(new FocusEvent("focusout", {
|
862 | bubbles: true,
|
863 | relatedTarget: relatedTargetEl
|
864 | }));
|
865 | }
|
866 | });
|
867 | stateRef.current.observer.observe(target, {
|
868 | attributes: true,
|
869 | attributeFilter: [
|
870 | "disabled"
|
871 | ]
|
872 | });
|
873 | }
|
874 | }, [
|
875 | dispatchBlur
|
876 | ]);
|
877 | }
|
878 |
|
879 |
|
880 | function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
881 | let { isDisabled: isDisabled, onFocus: onFocusProp, onBlur: onBlurProp, onFocusChange: onFocusChange } = props;
|
882 | const onBlur = (0, $goTMa$react.useCallback)((e)=>{
|
883 | if (e.target === e.currentTarget) {
|
884 | if (onBlurProp) onBlurProp(e);
|
885 | if (onFocusChange) onFocusChange(false);
|
886 | return true;
|
887 | }
|
888 | }, [
|
889 | onBlurProp,
|
890 | onFocusChange
|
891 | ]);
|
892 | const onSyntheticFocus = (0, $625cf83917e112ad$export$715c682d09d639cc)(onBlur);
|
893 | const onFocus = (0, $goTMa$react.useCallback)((e)=>{
|
894 |
|
895 |
|
896 | if (e.target === e.currentTarget && document.activeElement === e.target) {
|
897 | if (onFocusProp) onFocusProp(e);
|
898 | if (onFocusChange) onFocusChange(true);
|
899 | onSyntheticFocus(e);
|
900 | }
|
901 | }, [
|
902 | onFocusChange,
|
903 | onFocusProp,
|
904 | onSyntheticFocus
|
905 | ]);
|
906 | return {
|
907 | focusProps: {
|
908 | onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
|
909 | onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
|
910 | }
|
911 | };
|
912 | }
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 | let $e77252a287ef94ab$var$currentModality = null;
|
933 | let $e77252a287ef94ab$var$changeHandlers = new Set();
|
934 | let $e77252a287ef94ab$var$hasSetupGlobalListeners = false;
|
935 | let $e77252a287ef94ab$var$hasEventBeforeFocus = false;
|
936 | let $e77252a287ef94ab$var$hasBlurredWindowRecently = false;
|
937 |
|
938 | const $e77252a287ef94ab$var$FOCUS_VISIBLE_INPUT_KEYS = {
|
939 | Tab: true,
|
940 | Escape: true
|
941 | };
|
942 | function $e77252a287ef94ab$var$triggerChangeHandlers(modality, e) {
|
943 | for (let handler of $e77252a287ef94ab$var$changeHandlers)handler(modality, e);
|
944 | }
|
945 |
|
946 |
|
947 | function $e77252a287ef94ab$var$isValidKey(e) {
|
948 |
|
949 | return !(e.metaKey || !(0, $goTMa$reactariautils.isMac)() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
950 | }
|
951 | function $e77252a287ef94ab$var$handleKeyboardEvent(e) {
|
952 | $e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
953 | if ($e77252a287ef94ab$var$isValidKey(e)) {
|
954 | $e77252a287ef94ab$var$currentModality = "keyboard";
|
955 | $e77252a287ef94ab$var$triggerChangeHandlers("keyboard", e);
|
956 | }
|
957 | }
|
958 | function $e77252a287ef94ab$var$handlePointerEvent(e) {
|
959 | $e77252a287ef94ab$var$currentModality = "pointer";
|
960 | if (e.type === "mousedown" || e.type === "pointerdown") {
|
961 | $e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
962 | $e77252a287ef94ab$var$triggerChangeHandlers("pointer", e);
|
963 | }
|
964 | }
|
965 | function $e77252a287ef94ab$var$handleClickEvent(e) {
|
966 | if ((0, $goTMa$reactariautils.isVirtualClick)(e)) {
|
967 | $e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
968 | $e77252a287ef94ab$var$currentModality = "virtual";
|
969 | }
|
970 | }
|
971 | function $e77252a287ef94ab$var$handleFocusEvent(e) {
|
972 |
|
973 |
|
974 |
|
975 | if (e.target === window || e.target === document) return;
|
976 |
|
977 |
|
978 | if (!$e77252a287ef94ab$var$hasEventBeforeFocus && !$e77252a287ef94ab$var$hasBlurredWindowRecently) {
|
979 | $e77252a287ef94ab$var$currentModality = "virtual";
|
980 | $e77252a287ef94ab$var$triggerChangeHandlers("virtual", e);
|
981 | }
|
982 | $e77252a287ef94ab$var$hasEventBeforeFocus = false;
|
983 | $e77252a287ef94ab$var$hasBlurredWindowRecently = false;
|
984 | }
|
985 | function $e77252a287ef94ab$var$handleWindowBlur() {
|
986 |
|
987 |
|
988 | $e77252a287ef94ab$var$hasEventBeforeFocus = false;
|
989 | $e77252a287ef94ab$var$hasBlurredWindowRecently = true;
|
990 | }
|
991 |
|
992 |
|
993 | function $e77252a287ef94ab$var$setupGlobalFocusEvents() {
|
994 | if (typeof window === "undefined" || $e77252a287ef94ab$var$hasSetupGlobalListeners) return;
|
995 |
|
996 |
|
997 |
|
998 |
|
999 | let focus = HTMLElement.prototype.focus;
|
1000 | HTMLElement.prototype.focus = function() {
|
1001 | $e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
1002 | focus.apply(this, arguments);
|
1003 | };
|
1004 | document.addEventListener("keydown", $e77252a287ef94ab$var$handleKeyboardEvent, true);
|
1005 | document.addEventListener("keyup", $e77252a287ef94ab$var$handleKeyboardEvent, true);
|
1006 | document.addEventListener("click", $e77252a287ef94ab$var$handleClickEvent, true);
|
1007 |
|
1008 |
|
1009 | window.addEventListener("focus", $e77252a287ef94ab$var$handleFocusEvent, true);
|
1010 | window.addEventListener("blur", $e77252a287ef94ab$var$handleWindowBlur, false);
|
1011 | if (typeof PointerEvent !== "undefined") {
|
1012 | document.addEventListener("pointerdown", $e77252a287ef94ab$var$handlePointerEvent, true);
|
1013 | document.addEventListener("pointermove", $e77252a287ef94ab$var$handlePointerEvent, true);
|
1014 | document.addEventListener("pointerup", $e77252a287ef94ab$var$handlePointerEvent, true);
|
1015 | } else {
|
1016 | document.addEventListener("mousedown", $e77252a287ef94ab$var$handlePointerEvent, true);
|
1017 | document.addEventListener("mousemove", $e77252a287ef94ab$var$handlePointerEvent, true);
|
1018 | document.addEventListener("mouseup", $e77252a287ef94ab$var$handlePointerEvent, true);
|
1019 | }
|
1020 | $e77252a287ef94ab$var$hasSetupGlobalListeners = true;
|
1021 | }
|
1022 | if (typeof document !== "undefined") {
|
1023 | if (document.readyState !== "loading") $e77252a287ef94ab$var$setupGlobalFocusEvents();
|
1024 | else document.addEventListener("DOMContentLoaded", $e77252a287ef94ab$var$setupGlobalFocusEvents);
|
1025 | }
|
1026 | function $e77252a287ef94ab$export$b9b3dfddab17db27() {
|
1027 | return $e77252a287ef94ab$var$currentModality !== "pointer";
|
1028 | }
|
1029 | function $e77252a287ef94ab$export$630ff653c5ada6a9() {
|
1030 | return $e77252a287ef94ab$var$currentModality;
|
1031 | }
|
1032 | function $e77252a287ef94ab$export$8397ddfc504fdb9a(modality) {
|
1033 | $e77252a287ef94ab$var$currentModality = modality;
|
1034 | $e77252a287ef94ab$var$triggerChangeHandlers(modality, null);
|
1035 | }
|
1036 | function $e77252a287ef94ab$export$98e20ec92f614cfe() {
|
1037 | $e77252a287ef94ab$var$setupGlobalFocusEvents();
|
1038 | let [modality, setModality] = (0, $goTMa$react.useState)($e77252a287ef94ab$var$currentModality);
|
1039 | (0, $goTMa$react.useEffect)(()=>{
|
1040 | let handler = ()=>{
|
1041 | setModality($e77252a287ef94ab$var$currentModality);
|
1042 | };
|
1043 | $e77252a287ef94ab$var$changeHandlers.add(handler);
|
1044 | return ()=>{
|
1045 | $e77252a287ef94ab$var$changeHandlers.delete(handler);
|
1046 | };
|
1047 | }, []);
|
1048 | return (0, $goTMa$reactariassr.useIsSSR)() ? null : modality;
|
1049 | }
|
1050 | const $e77252a287ef94ab$var$nonTextInputTypes = new Set([
|
1051 | "checkbox",
|
1052 | "radio",
|
1053 | "range",
|
1054 | "color",
|
1055 | "file",
|
1056 | "image",
|
1057 | "button",
|
1058 | "submit",
|
1059 | "reset"
|
1060 | ]);
|
1061 |
|
1062 |
|
1063 |
|
1064 | function $e77252a287ef94ab$var$isKeyboardFocusEvent(isTextInput, modality, e) {
|
1065 | var _e_target;
|
1066 | isTextInput = isTextInput || (e === null || e === void 0 ? void 0 : e.target) instanceof HTMLInputElement && !$e77252a287ef94ab$var$nonTextInputTypes.has(e === null || e === void 0 ? void 0 : (_e_target = e.target) === null || _e_target === void 0 ? void 0 : _e_target.type) || (e === null || e === void 0 ? void 0 : e.target) instanceof HTMLTextAreaElement || (e === null || e === void 0 ? void 0 : e.target) instanceof HTMLElement && (e === null || e === void 0 ? void 0 : e.target.isContentEditable);
|
1067 | return !(isTextInput && modality === "keyboard" && e instanceof KeyboardEvent && !$e77252a287ef94ab$var$FOCUS_VISIBLE_INPUT_KEYS[e.key]);
|
1068 | }
|
1069 | function $e77252a287ef94ab$export$ffd9e5021c1fb2d6(props = {}) {
|
1070 | let { isTextInput: isTextInput, autoFocus: autoFocus } = props;
|
1071 | let [isFocusVisibleState, setFocusVisible] = (0, $goTMa$react.useState)(autoFocus || $e77252a287ef94ab$export$b9b3dfddab17db27());
|
1072 | $e77252a287ef94ab$export$ec71b4b83ac08ec3((isFocusVisible)=>{
|
1073 | setFocusVisible(isFocusVisible);
|
1074 | }, [
|
1075 | isTextInput
|
1076 | ], {
|
1077 | isTextInput: isTextInput
|
1078 | });
|
1079 | return {
|
1080 | isFocusVisible: isFocusVisibleState
|
1081 | };
|
1082 | }
|
1083 | function $e77252a287ef94ab$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
1084 | $e77252a287ef94ab$var$setupGlobalFocusEvents();
|
1085 | (0, $goTMa$react.useEffect)(()=>{
|
1086 | let handler = (modality, e)=>{
|
1087 | if (!$e77252a287ef94ab$var$isKeyboardFocusEvent(!!(opts === null || opts === void 0 ? void 0 : opts.isTextInput), modality, e)) return;
|
1088 | fn($e77252a287ef94ab$export$b9b3dfddab17db27());
|
1089 | };
|
1090 | $e77252a287ef94ab$var$changeHandlers.add(handler);
|
1091 | return ()=>{
|
1092 | $e77252a287ef94ab$var$changeHandlers.delete(handler);
|
1093 | };
|
1094 |
|
1095 | }, deps);
|
1096 | }
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 | function $d16842bbd0359d1b$export$420e68273165f4ec(props) {
|
1116 | let { isDisabled: isDisabled, onBlurWithin: onBlurWithin, onFocusWithin: onFocusWithin, onFocusWithinChange: onFocusWithinChange } = props;
|
1117 | let state = (0, $goTMa$react.useRef)({
|
1118 | isFocusWithin: false
|
1119 | });
|
1120 | let onBlur = (0, $goTMa$react.useCallback)((e)=>{
|
1121 |
|
1122 |
|
1123 |
|
1124 | if (state.current.isFocusWithin && !e.currentTarget.contains(e.relatedTarget)) {
|
1125 | state.current.isFocusWithin = false;
|
1126 | if (onBlurWithin) onBlurWithin(e);
|
1127 | if (onFocusWithinChange) onFocusWithinChange(false);
|
1128 | }
|
1129 | }, [
|
1130 | onBlurWithin,
|
1131 | onFocusWithinChange,
|
1132 | state
|
1133 | ]);
|
1134 | let onSyntheticFocus = (0, $625cf83917e112ad$export$715c682d09d639cc)(onBlur);
|
1135 | let onFocus = (0, $goTMa$react.useCallback)((e)=>{
|
1136 |
|
1137 |
|
1138 | if (!state.current.isFocusWithin && document.activeElement === e.target) {
|
1139 | if (onFocusWithin) onFocusWithin(e);
|
1140 | if (onFocusWithinChange) onFocusWithinChange(true);
|
1141 | state.current.isFocusWithin = true;
|
1142 | onSyntheticFocus(e);
|
1143 | }
|
1144 | }, [
|
1145 | onFocusWithin,
|
1146 | onFocusWithinChange,
|
1147 | onSyntheticFocus
|
1148 | ]);
|
1149 | if (isDisabled) return {
|
1150 | focusWithinProps: {
|
1151 |
|
1152 | onFocus: undefined,
|
1153 | onBlur: undefined
|
1154 | }
|
1155 | };
|
1156 | return {
|
1157 | focusWithinProps: {
|
1158 | onFocus: onFocus,
|
1159 | onBlur: onBlur
|
1160 | }
|
1161 | };
|
1162 | }
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 | let $ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents = false;
|
1184 | let $ffbc150311c75f01$var$hoverCount = 0;
|
1185 | function $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents() {
|
1186 | $ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents = true;
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 | setTimeout(()=>{
|
1192 | $ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents = false;
|
1193 | }, 50);
|
1194 | }
|
1195 | function $ffbc150311c75f01$var$handleGlobalPointerEvent(e) {
|
1196 | if (e.pointerType === "touch") $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents();
|
1197 | }
|
1198 | function $ffbc150311c75f01$var$setupGlobalTouchEvents() {
|
1199 | if (typeof document === "undefined") return;
|
1200 | if (typeof PointerEvent !== "undefined") document.addEventListener("pointerup", $ffbc150311c75f01$var$handleGlobalPointerEvent);
|
1201 | else document.addEventListener("touchend", $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents);
|
1202 | $ffbc150311c75f01$var$hoverCount++;
|
1203 | return ()=>{
|
1204 | $ffbc150311c75f01$var$hoverCount--;
|
1205 | if ($ffbc150311c75f01$var$hoverCount > 0) return;
|
1206 | if (typeof PointerEvent !== "undefined") document.removeEventListener("pointerup", $ffbc150311c75f01$var$handleGlobalPointerEvent);
|
1207 | else document.removeEventListener("touchend", $ffbc150311c75f01$var$setGlobalIgnoreEmulatedMouseEvents);
|
1208 | };
|
1209 | }
|
1210 | function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
1211 | let { onHoverStart: onHoverStart, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, isDisabled: isDisabled } = props;
|
1212 | let [isHovered, setHovered] = (0, $goTMa$react.useState)(false);
|
1213 | let state = (0, $goTMa$react.useRef)({
|
1214 | isHovered: false,
|
1215 | ignoreEmulatedMouseEvents: false,
|
1216 | pointerType: "",
|
1217 | target: null
|
1218 | }).current;
|
1219 | (0, $goTMa$react.useEffect)($ffbc150311c75f01$var$setupGlobalTouchEvents, []);
|
1220 | let { hoverProps: hoverProps, triggerHoverEnd: triggerHoverEnd } = (0, $goTMa$react.useMemo)(()=>{
|
1221 | let triggerHoverStart = (event, pointerType)=>{
|
1222 | state.pointerType = pointerType;
|
1223 | if (isDisabled || pointerType === "touch" || state.isHovered || !event.currentTarget.contains(event.target)) return;
|
1224 | state.isHovered = true;
|
1225 | let target = event.currentTarget;
|
1226 | state.target = target;
|
1227 | if (onHoverStart) onHoverStart({
|
1228 | type: "hoverstart",
|
1229 | target: target,
|
1230 | pointerType: pointerType
|
1231 | });
|
1232 | if (onHoverChange) onHoverChange(true);
|
1233 | setHovered(true);
|
1234 | };
|
1235 | let triggerHoverEnd = (event, pointerType)=>{
|
1236 | state.pointerType = "";
|
1237 | state.target = null;
|
1238 | if (pointerType === "touch" || !state.isHovered) return;
|
1239 | state.isHovered = false;
|
1240 | let target = event.currentTarget;
|
1241 | if (onHoverEnd) onHoverEnd({
|
1242 | type: "hoverend",
|
1243 | target: target,
|
1244 | pointerType: pointerType
|
1245 | });
|
1246 | if (onHoverChange) onHoverChange(false);
|
1247 | setHovered(false);
|
1248 | };
|
1249 | let hoverProps = {};
|
1250 | if (typeof PointerEvent !== "undefined") {
|
1251 | hoverProps.onPointerEnter = (e)=>{
|
1252 | if ($ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents && e.pointerType === "mouse") return;
|
1253 | triggerHoverStart(e, e.pointerType);
|
1254 | };
|
1255 | hoverProps.onPointerLeave = (e)=>{
|
1256 | if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, e.pointerType);
|
1257 | };
|
1258 | } else {
|
1259 | hoverProps.onTouchStart = ()=>{
|
1260 | state.ignoreEmulatedMouseEvents = true;
|
1261 | };
|
1262 | hoverProps.onMouseEnter = (e)=>{
|
1263 | if (!state.ignoreEmulatedMouseEvents && !$ffbc150311c75f01$var$globalIgnoreEmulatedMouseEvents) triggerHoverStart(e, "mouse");
|
1264 | state.ignoreEmulatedMouseEvents = false;
|
1265 | };
|
1266 | hoverProps.onMouseLeave = (e)=>{
|
1267 | if (!isDisabled && e.currentTarget.contains(e.target)) triggerHoverEnd(e, "mouse");
|
1268 | };
|
1269 | }
|
1270 | return {
|
1271 | hoverProps: hoverProps,
|
1272 | triggerHoverEnd: triggerHoverEnd
|
1273 | };
|
1274 | }, [
|
1275 | onHoverStart,
|
1276 | onHoverChange,
|
1277 | onHoverEnd,
|
1278 | isDisabled,
|
1279 | state
|
1280 | ]);
|
1281 | (0, $goTMa$react.useEffect)(()=>{
|
1282 |
|
1283 |
|
1284 | if (isDisabled) triggerHoverEnd({
|
1285 | currentTarget: state.target
|
1286 | }, state.pointerType);
|
1287 |
|
1288 | }, [
|
1289 | isDisabled
|
1290 | ]);
|
1291 | return {
|
1292 | hoverProps: hoverProps,
|
1293 | isHovered: isHovered
|
1294 | };
|
1295 | }
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 | function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
1315 | let { ref: ref, onInteractOutside: onInteractOutside, isDisabled: isDisabled, onInteractOutsideStart: onInteractOutsideStart } = props;
|
1316 | let stateRef = (0, $goTMa$react.useRef)({
|
1317 | isPointerDown: false,
|
1318 | ignoreEmulatedMouseEvents: false
|
1319 | });
|
1320 | let onPointerDown = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
1321 | if (onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) {
|
1322 | if (onInteractOutsideStart) onInteractOutsideStart(e);
|
1323 | stateRef.current.isPointerDown = true;
|
1324 | }
|
1325 | });
|
1326 | let triggerInteractOutside = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
1327 | if (onInteractOutside) onInteractOutside(e);
|
1328 | });
|
1329 | (0, $goTMa$react.useEffect)(()=>{
|
1330 | let state = stateRef.current;
|
1331 | if (isDisabled) return;
|
1332 | const element = ref.current;
|
1333 | const documentObject = (0, $goTMa$reactariautils.getOwnerDocument)(element);
|
1334 |
|
1335 | if (typeof PointerEvent !== "undefined") {
|
1336 | let onPointerUp = (e)=>{
|
1337 | if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
1338 | state.isPointerDown = false;
|
1339 | };
|
1340 |
|
1341 | documentObject.addEventListener("pointerdown", onPointerDown, true);
|
1342 | documentObject.addEventListener("pointerup", onPointerUp, true);
|
1343 | return ()=>{
|
1344 | documentObject.removeEventListener("pointerdown", onPointerDown, true);
|
1345 | documentObject.removeEventListener("pointerup", onPointerUp, true);
|
1346 | };
|
1347 | } else {
|
1348 | let onMouseUp = (e)=>{
|
1349 | if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
1350 | else if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
1351 | state.isPointerDown = false;
|
1352 | };
|
1353 | let onTouchEnd = (e)=>{
|
1354 | state.ignoreEmulatedMouseEvents = true;
|
1355 | if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
1356 | state.isPointerDown = false;
|
1357 | };
|
1358 | documentObject.addEventListener("mousedown", onPointerDown, true);
|
1359 | documentObject.addEventListener("mouseup", onMouseUp, true);
|
1360 | documentObject.addEventListener("touchstart", onPointerDown, true);
|
1361 | documentObject.addEventListener("touchend", onTouchEnd, true);
|
1362 | return ()=>{
|
1363 | documentObject.removeEventListener("mousedown", onPointerDown, true);
|
1364 | documentObject.removeEventListener("mouseup", onMouseUp, true);
|
1365 | documentObject.removeEventListener("touchstart", onPointerDown, true);
|
1366 | documentObject.removeEventListener("touchend", onTouchEnd, true);
|
1367 | };
|
1368 | }
|
1369 | }, [
|
1370 | ref,
|
1371 | isDisabled,
|
1372 | onPointerDown,
|
1373 | triggerInteractOutside
|
1374 | ]);
|
1375 | }
|
1376 | function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
|
1377 | if (event.button > 0) return false;
|
1378 | if (event.target) {
|
1379 |
|
1380 | const ownerDocument = event.target.ownerDocument;
|
1381 | if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
|
1382 |
|
1383 | if (event.target.closest("[data-react-aria-top-layer]")) return false;
|
1384 | }
|
1385 | return ref.current && !ref.current.contains(event.target);
|
1386 | }
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 | |
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 | function $951fbcbbca8db6ce$export$48d1ea6320830260(handler) {
|
1410 | if (!handler) return undefined;
|
1411 | let shouldStopPropagation = true;
|
1412 | return (e)=>{
|
1413 | let event = {
|
1414 | ...e,
|
1415 | preventDefault () {
|
1416 | e.preventDefault();
|
1417 | },
|
1418 | isDefaultPrevented () {
|
1419 | return e.isDefaultPrevented();
|
1420 | },
|
1421 | stopPropagation () {
|
1422 | console.error("stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.");
|
1423 | },
|
1424 | continuePropagation () {
|
1425 | shouldStopPropagation = false;
|
1426 | }
|
1427 | };
|
1428 | handler(event);
|
1429 | if (shouldStopPropagation) e.stopPropagation();
|
1430 | };
|
1431 | }
|
1432 |
|
1433 |
|
1434 | function $892d64db2a3c53b0$export$8f71654801c2f7cd(props) {
|
1435 | return {
|
1436 | keyboardProps: props.isDisabled ? {} : {
|
1437 | onKeyDown: (0, $951fbcbbca8db6ce$export$48d1ea6320830260)(props.onKeyDown),
|
1438 | onKeyUp: (0, $951fbcbbca8db6ce$export$48d1ea6320830260)(props.onKeyUp)
|
1439 | }
|
1440 | };
|
1441 | }
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 | function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
1458 | let { onMoveStart: onMoveStart, onMove: onMove, onMoveEnd: onMoveEnd } = props;
|
1459 | let state = (0, $goTMa$react.useRef)({
|
1460 | didMove: false,
|
1461 | lastPosition: null,
|
1462 | id: null
|
1463 | });
|
1464 | let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $goTMa$reactariautils.useGlobalListeners)();
|
1465 | let move = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType, deltaX, deltaY)=>{
|
1466 | if (deltaX === 0 && deltaY === 0) return;
|
1467 | if (!state.current.didMove) {
|
1468 | state.current.didMove = true;
|
1469 | onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
1470 | type: "movestart",
|
1471 | pointerType: pointerType,
|
1472 | shiftKey: originalEvent.shiftKey,
|
1473 | metaKey: originalEvent.metaKey,
|
1474 | ctrlKey: originalEvent.ctrlKey,
|
1475 | altKey: originalEvent.altKey
|
1476 | });
|
1477 | }
|
1478 | onMove === null || onMove === void 0 ? void 0 : onMove({
|
1479 | type: "move",
|
1480 | pointerType: pointerType,
|
1481 | deltaX: deltaX,
|
1482 | deltaY: deltaY,
|
1483 | shiftKey: originalEvent.shiftKey,
|
1484 | metaKey: originalEvent.metaKey,
|
1485 | ctrlKey: originalEvent.ctrlKey,
|
1486 | altKey: originalEvent.altKey
|
1487 | });
|
1488 | });
|
1489 | let end = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType)=>{
|
1490 | (0, $f7e14e656343df57$export$b0d6fa1ab32e3295)();
|
1491 | if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
1492 | type: "moveend",
|
1493 | pointerType: pointerType,
|
1494 | shiftKey: originalEvent.shiftKey,
|
1495 | metaKey: originalEvent.metaKey,
|
1496 | ctrlKey: originalEvent.ctrlKey,
|
1497 | altKey: originalEvent.altKey
|
1498 | });
|
1499 | });
|
1500 | let moveProps = (0, $goTMa$react.useMemo)(()=>{
|
1501 | let moveProps = {};
|
1502 | let start = ()=>{
|
1503 | (0, $f7e14e656343df57$export$16a4697467175487)();
|
1504 | state.current.didMove = false;
|
1505 | };
|
1506 | if (typeof PointerEvent === "undefined") {
|
1507 | let onMouseMove = (e)=>{
|
1508 | if (e.button === 0) {
|
1509 | var _state_current_lastPosition, _state_current_lastPosition1;
|
1510 | var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
1511 | move(e, "mouse", e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
|
1512 | state.current.lastPosition = {
|
1513 | pageX: e.pageX,
|
1514 | pageY: e.pageY
|
1515 | };
|
1516 | }
|
1517 | };
|
1518 | let onMouseUp = (e)=>{
|
1519 | if (e.button === 0) {
|
1520 | end(e, "mouse");
|
1521 | removeGlobalListener(window, "mousemove", onMouseMove, false);
|
1522 | removeGlobalListener(window, "mouseup", onMouseUp, false);
|
1523 | }
|
1524 | };
|
1525 | moveProps.onMouseDown = (e)=>{
|
1526 | if (e.button === 0) {
|
1527 | start();
|
1528 | e.stopPropagation();
|
1529 | e.preventDefault();
|
1530 | state.current.lastPosition = {
|
1531 | pageX: e.pageX,
|
1532 | pageY: e.pageY
|
1533 | };
|
1534 | addGlobalListener(window, "mousemove", onMouseMove, false);
|
1535 | addGlobalListener(window, "mouseup", onMouseUp, false);
|
1536 | }
|
1537 | };
|
1538 | let onTouchMove = (e)=>{
|
1539 | let touch = [
|
1540 | ...e.changedTouches
|
1541 | ].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
1542 | if (touch >= 0) {
|
1543 | var _state_current_lastPosition, _state_current_lastPosition1;
|
1544 | let { pageX: pageX, pageY: pageY } = e.changedTouches[touch];
|
1545 | var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
1546 | move(e, "touch", pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
|
1547 | state.current.lastPosition = {
|
1548 | pageX: pageX,
|
1549 | pageY: pageY
|
1550 | };
|
1551 | }
|
1552 | };
|
1553 | let onTouchEnd = (e)=>{
|
1554 | let touch = [
|
1555 | ...e.changedTouches
|
1556 | ].findIndex(({ identifier: identifier })=>identifier === state.current.id);
|
1557 | if (touch >= 0) {
|
1558 | end(e, "touch");
|
1559 | state.current.id = null;
|
1560 | removeGlobalListener(window, "touchmove", onTouchMove);
|
1561 | removeGlobalListener(window, "touchend", onTouchEnd);
|
1562 | removeGlobalListener(window, "touchcancel", onTouchEnd);
|
1563 | }
|
1564 | };
|
1565 | moveProps.onTouchStart = (e)=>{
|
1566 | if (e.changedTouches.length === 0 || state.current.id != null) return;
|
1567 | let { pageX: pageX, pageY: pageY, identifier: identifier } = e.changedTouches[0];
|
1568 | start();
|
1569 | e.stopPropagation();
|
1570 | e.preventDefault();
|
1571 | state.current.lastPosition = {
|
1572 | pageX: pageX,
|
1573 | pageY: pageY
|
1574 | };
|
1575 | state.current.id = identifier;
|
1576 | addGlobalListener(window, "touchmove", onTouchMove, false);
|
1577 | addGlobalListener(window, "touchend", onTouchEnd, false);
|
1578 | addGlobalListener(window, "touchcancel", onTouchEnd, false);
|
1579 | };
|
1580 | } else {
|
1581 | let onPointerMove = (e)=>{
|
1582 | if (e.pointerId === state.current.id) {
|
1583 | var _state_current_lastPosition, _state_current_lastPosition1;
|
1584 | let pointerType = e.pointerType || "mouse";
|
1585 | var _state_current_lastPosition_pageX, _state_current_lastPosition_pageY;
|
1586 |
|
1587 |
|
1588 |
|
1589 | move(e, pointerType, e.pageX - ((_state_current_lastPosition_pageX = (_state_current_lastPosition = state.current.lastPosition) === null || _state_current_lastPosition === void 0 ? void 0 : _state_current_lastPosition.pageX) !== null && _state_current_lastPosition_pageX !== void 0 ? _state_current_lastPosition_pageX : 0), e.pageY - ((_state_current_lastPosition_pageY = (_state_current_lastPosition1 = state.current.lastPosition) === null || _state_current_lastPosition1 === void 0 ? void 0 : _state_current_lastPosition1.pageY) !== null && _state_current_lastPosition_pageY !== void 0 ? _state_current_lastPosition_pageY : 0));
|
1590 | state.current.lastPosition = {
|
1591 | pageX: e.pageX,
|
1592 | pageY: e.pageY
|
1593 | };
|
1594 | }
|
1595 | };
|
1596 | let onPointerUp = (e)=>{
|
1597 | if (e.pointerId === state.current.id) {
|
1598 | let pointerType = e.pointerType || "mouse";
|
1599 | end(e, pointerType);
|
1600 | state.current.id = null;
|
1601 | removeGlobalListener(window, "pointermove", onPointerMove, false);
|
1602 | removeGlobalListener(window, "pointerup", onPointerUp, false);
|
1603 | removeGlobalListener(window, "pointercancel", onPointerUp, false);
|
1604 | }
|
1605 | };
|
1606 | moveProps.onPointerDown = (e)=>{
|
1607 | if (e.button === 0 && state.current.id == null) {
|
1608 | start();
|
1609 | e.stopPropagation();
|
1610 | e.preventDefault();
|
1611 | state.current.lastPosition = {
|
1612 | pageX: e.pageX,
|
1613 | pageY: e.pageY
|
1614 | };
|
1615 | state.current.id = e.pointerId;
|
1616 | addGlobalListener(window, "pointermove", onPointerMove, false);
|
1617 | addGlobalListener(window, "pointerup", onPointerUp, false);
|
1618 | addGlobalListener(window, "pointercancel", onPointerUp, false);
|
1619 | }
|
1620 | };
|
1621 | }
|
1622 | let triggerKeyboardMove = (e, deltaX, deltaY)=>{
|
1623 | start();
|
1624 | move(e, "keyboard", deltaX, deltaY);
|
1625 | end(e, "keyboard");
|
1626 | };
|
1627 | moveProps.onKeyDown = (e)=>{
|
1628 | switch(e.key){
|
1629 | case "Left":
|
1630 | case "ArrowLeft":
|
1631 | e.preventDefault();
|
1632 | e.stopPropagation();
|
1633 | triggerKeyboardMove(e, -1, 0);
|
1634 | break;
|
1635 | case "Right":
|
1636 | case "ArrowRight":
|
1637 | e.preventDefault();
|
1638 | e.stopPropagation();
|
1639 | triggerKeyboardMove(e, 1, 0);
|
1640 | break;
|
1641 | case "Up":
|
1642 | case "ArrowUp":
|
1643 | e.preventDefault();
|
1644 | e.stopPropagation();
|
1645 | triggerKeyboardMove(e, 0, -1);
|
1646 | break;
|
1647 | case "Down":
|
1648 | case "ArrowDown":
|
1649 | e.preventDefault();
|
1650 | e.stopPropagation();
|
1651 | triggerKeyboardMove(e, 0, 1);
|
1652 | break;
|
1653 | }
|
1654 | };
|
1655 | return moveProps;
|
1656 | }, [
|
1657 | state,
|
1658 | addGlobalListener,
|
1659 | removeGlobalListener,
|
1660 | move,
|
1661 | end
|
1662 | ]);
|
1663 | return {
|
1664 | moveProps: moveProps
|
1665 | };
|
1666 | }
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 | function $a3dbce0aed7087e2$export$2123ff2b87c81ca(props, ref) {
|
1683 | let { onScroll: onScroll, isDisabled: isDisabled } = props;
|
1684 | let onScrollHandler = (0, $goTMa$react.useCallback)((e)=>{
|
1685 |
|
1686 | if (e.ctrlKey) return;
|
1687 |
|
1688 | e.preventDefault();
|
1689 | e.stopPropagation();
|
1690 | if (onScroll) onScroll({
|
1691 | deltaX: e.deltaX,
|
1692 | deltaY: e.deltaY
|
1693 | });
|
1694 | }, [
|
1695 | onScroll
|
1696 | ]);
|
1697 | (0, $goTMa$reactariautils.useEvent)(ref, "wheel", isDisabled ? undefined : onScrollHandler);
|
1698 | }
|
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 | const $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD = 500;
|
1715 | function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
|
1716 | let { isDisabled: isDisabled, onLongPressStart: onLongPressStart, onLongPressEnd: onLongPressEnd, onLongPress: onLongPress, threshold: threshold = $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD, accessibilityDescription: accessibilityDescription } = props;
|
1717 | const timeRef = (0, $goTMa$react.useRef)();
|
1718 | let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $goTMa$reactariautils.useGlobalListeners)();
|
1719 | let { pressProps: pressProps } = (0, $0294ea432cd92340$export$45712eceda6fad21)({
|
1720 | isDisabled: isDisabled,
|
1721 | onPressStart (e) {
|
1722 | e.continuePropagation();
|
1723 | if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
1724 | if (onLongPressStart) onLongPressStart({
|
1725 | ...e,
|
1726 | type: "longpressstart"
|
1727 | });
|
1728 | timeRef.current = setTimeout(()=>{
|
1729 |
|
1730 | e.target.dispatchEvent(new PointerEvent("pointercancel", {
|
1731 | bubbles: true
|
1732 | }));
|
1733 | if (onLongPress) onLongPress({
|
1734 | ...e,
|
1735 | type: "longpress"
|
1736 | });
|
1737 | timeRef.current = undefined;
|
1738 | }, threshold);
|
1739 |
|
1740 | if (e.pointerType === "touch") {
|
1741 | let onContextMenu = (e)=>{
|
1742 | e.preventDefault();
|
1743 | };
|
1744 | addGlobalListener(e.target, "contextmenu", onContextMenu, {
|
1745 | once: true
|
1746 | });
|
1747 | addGlobalListener(window, "pointerup", ()=>{
|
1748 |
|
1749 |
|
1750 | setTimeout(()=>{
|
1751 | removeGlobalListener(e.target, "contextmenu", onContextMenu);
|
1752 | }, 30);
|
1753 | }, {
|
1754 | once: true
|
1755 | });
|
1756 | }
|
1757 | }
|
1758 | },
|
1759 | onPressEnd (e) {
|
1760 | if (timeRef.current) clearTimeout(timeRef.current);
|
1761 | if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
|
1762 | ...e,
|
1763 | type: "longpressend"
|
1764 | });
|
1765 | }
|
1766 | });
|
1767 | let descriptionProps = (0, $goTMa$reactariautils.useDescription)(onLongPress && !isDisabled ? accessibilityDescription : undefined);
|
1768 | return {
|
1769 | longPressProps: (0, $goTMa$reactariautils.mergeProps)(pressProps, descriptionProps)
|
1770 | };
|
1771 | }
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 |
|