@react-aria/interactions 3.15.1 → 3.17.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 +216 -173
- package/dist/main.js +215 -172
- package/dist/main.js.map +1 -1
- package/dist/module.js +216 -173
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/PressResponder.tsx +1 -0
- package/src/useHover.ts +1 -2
- package/src/useInteractOutside.ts +25 -22
- package/src/useLongPress.ts +1 -0
- package/src/useMove.ts +43 -41
- package/src/usePress.ts +188 -129
- package/src/utils.ts +10 -7
package/dist/main.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
var $goTMa$reactariautils = require("@react-aria/utils");
|
|
2
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");
|
|
3
6
|
var $goTMa$reactariassr = require("@react-aria/ssr");
|
|
4
7
|
|
|
5
8
|
function $parcel$export(e, n, v, s) {
|
|
@@ -61,6 +64,9 @@ $parcel$export(module.exports, "useLongPress", () => $3cd7b5d0eebf0ca9$export$c2
|
|
|
61
64
|
// Original licensing for the following can be found in the
|
|
62
65
|
// NOTICE file in the root directory of this source tree.
|
|
63
66
|
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
64
70
|
/*
|
|
65
71
|
* Copyright 2020 Adobe. All rights reserved.
|
|
66
72
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -152,19 +158,32 @@ function $0294ea432cd92340$var$usePressResponderContext(props) {
|
|
|
152
158
|
(0, $goTMa$reactariautils.useSyncRef)(context, props.ref);
|
|
153
159
|
return props;
|
|
154
160
|
}
|
|
161
|
+
var $0294ea432cd92340$var$_shouldStopPropagation = /*#__PURE__*/ new WeakMap();
|
|
162
|
+
class $0294ea432cd92340$var$PressEvent {
|
|
163
|
+
continuePropagation() {
|
|
164
|
+
(0, $goTMa$swchelperscjs_class_private_field_setcjs._)(this, $0294ea432cd92340$var$_shouldStopPropagation, false);
|
|
165
|
+
}
|
|
166
|
+
get shouldStopPropagation() {
|
|
167
|
+
return (0, $goTMa$swchelperscjs_class_private_field_getcjs._)(this, $0294ea432cd92340$var$_shouldStopPropagation);
|
|
168
|
+
}
|
|
169
|
+
constructor(type, pointerType, originalEvent){
|
|
170
|
+
(0, $goTMa$swchelperscjs_class_private_field_initcjs._)(this, $0294ea432cd92340$var$_shouldStopPropagation, {
|
|
171
|
+
writable: true,
|
|
172
|
+
value: void 0
|
|
173
|
+
});
|
|
174
|
+
(0, $goTMa$swchelperscjs_class_private_field_setcjs._)(this, $0294ea432cd92340$var$_shouldStopPropagation, true);
|
|
175
|
+
this.type = type;
|
|
176
|
+
this.pointerType = pointerType;
|
|
177
|
+
this.target = originalEvent.currentTarget;
|
|
178
|
+
this.shiftKey = originalEvent.shiftKey;
|
|
179
|
+
this.metaKey = originalEvent.metaKey;
|
|
180
|
+
this.ctrlKey = originalEvent.ctrlKey;
|
|
181
|
+
this.altKey = originalEvent.altKey;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
155
184
|
function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
156
185
|
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
|
|
157
186
|
ref: _ , ...domProps } = $0294ea432cd92340$var$usePressResponderContext(props);
|
|
158
|
-
let propsRef = (0, $goTMa$react.useRef)(null);
|
|
159
|
-
propsRef.current = {
|
|
160
|
-
onPress: onPress,
|
|
161
|
-
onPressChange: onPressChange,
|
|
162
|
-
onPressStart: onPressStart,
|
|
163
|
-
onPressEnd: onPressEnd,
|
|
164
|
-
onPressUp: onPressUp,
|
|
165
|
-
isDisabled: isDisabled,
|
|
166
|
-
shouldCancelOnPointerExit: shouldCancelOnPointerExit
|
|
167
|
-
};
|
|
168
187
|
let [isPressed, setPressed] = (0, $goTMa$react.useState)(false);
|
|
169
188
|
let ref = (0, $goTMa$react.useRef)({
|
|
170
189
|
isPressed: false,
|
|
@@ -177,90 +196,83 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
177
196
|
pointerType: null
|
|
178
197
|
});
|
|
179
198
|
let { addGlobalListener: addGlobalListener , removeAllGlobalListeners: removeAllGlobalListeners } = (0, $goTMa$reactariautils.useGlobalListeners)();
|
|
199
|
+
let triggerPressStart = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType)=>{
|
|
200
|
+
let state = ref.current;
|
|
201
|
+
if (isDisabled || state.didFirePressStart) return;
|
|
202
|
+
let shouldStopPropagation = true;
|
|
203
|
+
if (onPressStart) {
|
|
204
|
+
let event = new $0294ea432cd92340$var$PressEvent("pressstart", pointerType, originalEvent);
|
|
205
|
+
onPressStart(event);
|
|
206
|
+
shouldStopPropagation = event.shouldStopPropagation;
|
|
207
|
+
}
|
|
208
|
+
if (onPressChange) onPressChange(true);
|
|
209
|
+
state.didFirePressStart = true;
|
|
210
|
+
setPressed(true);
|
|
211
|
+
return shouldStopPropagation;
|
|
212
|
+
});
|
|
213
|
+
let triggerPressEnd = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType, wasPressed = true)=>{
|
|
214
|
+
let state = ref.current;
|
|
215
|
+
if (!state.didFirePressStart) return;
|
|
216
|
+
state.ignoreClickAfterPress = true;
|
|
217
|
+
state.didFirePressStart = false;
|
|
218
|
+
let shouldStopPropagation = true;
|
|
219
|
+
if (onPressEnd) {
|
|
220
|
+
let event = new $0294ea432cd92340$var$PressEvent("pressend", pointerType, originalEvent);
|
|
221
|
+
onPressEnd(event);
|
|
222
|
+
shouldStopPropagation = event.shouldStopPropagation;
|
|
223
|
+
}
|
|
224
|
+
if (onPressChange) onPressChange(false);
|
|
225
|
+
setPressed(false);
|
|
226
|
+
if (onPress && wasPressed && !isDisabled) {
|
|
227
|
+
let event = new $0294ea432cd92340$var$PressEvent("press", pointerType, originalEvent);
|
|
228
|
+
onPress(event);
|
|
229
|
+
shouldStopPropagation && (shouldStopPropagation = event.shouldStopPropagation);
|
|
230
|
+
}
|
|
231
|
+
return shouldStopPropagation;
|
|
232
|
+
});
|
|
233
|
+
let triggerPressUp = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType)=>{
|
|
234
|
+
if (isDisabled) return;
|
|
235
|
+
if (onPressUp) {
|
|
236
|
+
let event = new $0294ea432cd92340$var$PressEvent("pressup", pointerType, originalEvent);
|
|
237
|
+
onPressUp(event);
|
|
238
|
+
return event.shouldStopPropagation;
|
|
239
|
+
}
|
|
240
|
+
return true;
|
|
241
|
+
});
|
|
242
|
+
let cancel = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
|
243
|
+
let state = ref.current;
|
|
244
|
+
if (state.isPressed) {
|
|
245
|
+
if (state.isOverTarget) triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
|
246
|
+
state.isPressed = false;
|
|
247
|
+
state.isOverTarget = false;
|
|
248
|
+
state.activePointerId = null;
|
|
249
|
+
state.pointerType = null;
|
|
250
|
+
removeAllGlobalListeners();
|
|
251
|
+
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$export$b0d6fa1ab32e3295)(state.target);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
let cancelOnPointerExit = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
|
255
|
+
if (shouldCancelOnPointerExit) cancel(e);
|
|
256
|
+
});
|
|
180
257
|
let pressProps = (0, $goTMa$react.useMemo)(()=>{
|
|
181
258
|
let state = ref.current;
|
|
182
|
-
let triggerPressStart = (originalEvent, pointerType)=>{
|
|
183
|
-
let { onPressStart: onPressStart , onPressChange: onPressChange , isDisabled: isDisabled } = propsRef.current;
|
|
184
|
-
if (isDisabled || state.didFirePressStart) return;
|
|
185
|
-
if (onPressStart) onPressStart({
|
|
186
|
-
type: "pressstart",
|
|
187
|
-
pointerType: pointerType,
|
|
188
|
-
target: originalEvent.currentTarget,
|
|
189
|
-
shiftKey: originalEvent.shiftKey,
|
|
190
|
-
metaKey: originalEvent.metaKey,
|
|
191
|
-
ctrlKey: originalEvent.ctrlKey,
|
|
192
|
-
altKey: originalEvent.altKey
|
|
193
|
-
});
|
|
194
|
-
if (onPressChange) onPressChange(true);
|
|
195
|
-
state.didFirePressStart = true;
|
|
196
|
-
setPressed(true);
|
|
197
|
-
};
|
|
198
|
-
let triggerPressEnd = (originalEvent, pointerType, wasPressed = true)=>{
|
|
199
|
-
let { onPressEnd: onPressEnd , onPressChange: onPressChange , onPress: onPress , isDisabled: isDisabled } = propsRef.current;
|
|
200
|
-
if (!state.didFirePressStart) return;
|
|
201
|
-
state.ignoreClickAfterPress = true;
|
|
202
|
-
state.didFirePressStart = false;
|
|
203
|
-
if (onPressEnd) onPressEnd({
|
|
204
|
-
type: "pressend",
|
|
205
|
-
pointerType: pointerType,
|
|
206
|
-
target: originalEvent.currentTarget,
|
|
207
|
-
shiftKey: originalEvent.shiftKey,
|
|
208
|
-
metaKey: originalEvent.metaKey,
|
|
209
|
-
ctrlKey: originalEvent.ctrlKey,
|
|
210
|
-
altKey: originalEvent.altKey
|
|
211
|
-
});
|
|
212
|
-
if (onPressChange) onPressChange(false);
|
|
213
|
-
setPressed(false);
|
|
214
|
-
if (onPress && wasPressed && !isDisabled) onPress({
|
|
215
|
-
type: "press",
|
|
216
|
-
pointerType: pointerType,
|
|
217
|
-
target: originalEvent.currentTarget,
|
|
218
|
-
shiftKey: originalEvent.shiftKey,
|
|
219
|
-
metaKey: originalEvent.metaKey,
|
|
220
|
-
ctrlKey: originalEvent.ctrlKey,
|
|
221
|
-
altKey: originalEvent.altKey
|
|
222
|
-
});
|
|
223
|
-
};
|
|
224
|
-
let triggerPressUp = (originalEvent, pointerType)=>{
|
|
225
|
-
let { onPressUp: onPressUp , isDisabled: isDisabled } = propsRef.current;
|
|
226
|
-
if (isDisabled) return;
|
|
227
|
-
if (onPressUp) onPressUp({
|
|
228
|
-
type: "pressup",
|
|
229
|
-
pointerType: pointerType,
|
|
230
|
-
target: originalEvent.currentTarget,
|
|
231
|
-
shiftKey: originalEvent.shiftKey,
|
|
232
|
-
metaKey: originalEvent.metaKey,
|
|
233
|
-
ctrlKey: originalEvent.ctrlKey,
|
|
234
|
-
altKey: originalEvent.altKey
|
|
235
|
-
});
|
|
236
|
-
};
|
|
237
|
-
let cancel = (e)=>{
|
|
238
|
-
if (state.isPressed) {
|
|
239
|
-
if (state.isOverTarget) triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
|
240
|
-
state.isPressed = false;
|
|
241
|
-
state.isOverTarget = false;
|
|
242
|
-
state.activePointerId = null;
|
|
243
|
-
state.pointerType = null;
|
|
244
|
-
removeAllGlobalListeners();
|
|
245
|
-
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$export$b0d6fa1ab32e3295)(state.target);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
259
|
let pressProps = {
|
|
249
260
|
onKeyDown (e) {
|
|
250
261
|
if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.contains(e.target)) {
|
|
251
262
|
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
|
|
252
|
-
e.stopPropagation();
|
|
253
263
|
// If the event is repeating, it may have started on a different element
|
|
254
264
|
// after which focus moved to the current element. Ignore these events and
|
|
255
265
|
// only handle the first key down event.
|
|
266
|
+
let shouldStopPropagation = true;
|
|
256
267
|
if (!state.isPressed && !e.repeat) {
|
|
257
268
|
state.target = e.currentTarget;
|
|
258
269
|
state.isPressed = true;
|
|
259
|
-
triggerPressStart(e, "keyboard");
|
|
270
|
+
shouldStopPropagation = triggerPressStart(e, "keyboard");
|
|
260
271
|
// Focus may move before the key up event, so register the event on the document
|
|
261
272
|
// instead of the same element where the key down event occurred.
|
|
262
273
|
addGlobalListener(document, "keyup", onKeyUp, false);
|
|
263
274
|
}
|
|
275
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
264
276
|
} 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
|
|
265
277
|
// browser behavior to open the link when pressing Enter. But we still need to prevent
|
|
266
278
|
// default so that elements above do not also handle it (e.g. table row).
|
|
@@ -272,30 +284,32 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
272
284
|
onClick (e) {
|
|
273
285
|
if (e && !e.currentTarget.contains(e.target)) return;
|
|
274
286
|
if (e && e.button === 0) {
|
|
275
|
-
|
|
287
|
+
let shouldStopPropagation = true;
|
|
276
288
|
if (isDisabled) e.preventDefault();
|
|
277
289
|
// If triggered from a screen reader or by using element.click(),
|
|
278
290
|
// trigger as if it were a keyboard click.
|
|
279
291
|
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === "virtual" || (0, $goTMa$reactariautils.isVirtualClick)(e.nativeEvent))) {
|
|
280
292
|
// Ensure the element receives focus (VoiceOver on iOS does not do this)
|
|
281
293
|
if (!isDisabled && !preventFocusOnPress) (0, $goTMa$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
282
|
-
triggerPressStart(e, "virtual");
|
|
283
|
-
triggerPressUp(e, "virtual");
|
|
284
|
-
triggerPressEnd(e, "virtual");
|
|
294
|
+
let stopPressStart = triggerPressStart(e, "virtual");
|
|
295
|
+
let stopPressUp = triggerPressUp(e, "virtual");
|
|
296
|
+
let stopPressEnd = triggerPressEnd(e, "virtual");
|
|
297
|
+
shouldStopPropagation = stopPressStart && stopPressUp && stopPressEnd;
|
|
285
298
|
}
|
|
286
299
|
state.ignoreEmulatedMouseEvents = false;
|
|
287
300
|
state.ignoreClickAfterPress = false;
|
|
301
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
288
302
|
}
|
|
289
303
|
}
|
|
290
304
|
};
|
|
291
305
|
let onKeyUp = (e)=>{
|
|
292
306
|
if (state.isPressed && $0294ea432cd92340$var$isValidKeyboardEvent(e, state.target)) {
|
|
293
307
|
if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
|
|
294
|
-
e.stopPropagation();
|
|
295
308
|
state.isPressed = false;
|
|
296
309
|
let target = e.target;
|
|
297
|
-
triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
|
|
310
|
+
let shouldStopPropagation = triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
|
|
298
311
|
removeAllGlobalListeners();
|
|
312
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
299
313
|
// If the target is a link, trigger the click method to open the URL,
|
|
300
314
|
// but defer triggering pressEnd until onClick event handler.
|
|
301
315
|
if (state.target instanceof HTMLElement && state.target.contains(target) && ($0294ea432cd92340$var$isHTMLAnchorLink(state.target) || state.target.getAttribute("role") === "link")) state.target.click();
|
|
@@ -317,7 +331,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
317
331
|
// default on pointer down and handle focusing the pressable element ourselves.
|
|
318
332
|
if ($0294ea432cd92340$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
|
|
319
333
|
state.pointerType = e.pointerType;
|
|
320
|
-
|
|
334
|
+
let shouldStopPropagation = true;
|
|
321
335
|
if (!state.isPressed) {
|
|
322
336
|
state.isPressed = true;
|
|
323
337
|
state.isOverTarget = true;
|
|
@@ -325,11 +339,12 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
325
339
|
state.target = e.currentTarget;
|
|
326
340
|
if (!isDisabled && !preventFocusOnPress) (0, $goTMa$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
327
341
|
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$export$16a4697467175487)(state.target);
|
|
328
|
-
triggerPressStart(e, state.pointerType);
|
|
342
|
+
shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
329
343
|
addGlobalListener(document, "pointermove", onPointerMove, false);
|
|
330
344
|
addGlobalListener(document, "pointerup", onPointerUp, false);
|
|
331
345
|
addGlobalListener(document, "pointercancel", onPointerCancel, false);
|
|
332
346
|
}
|
|
347
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
333
348
|
};
|
|
334
349
|
pressProps.onMouseDown = (e)=>{
|
|
335
350
|
if (!e.currentTarget.contains(e.target)) return;
|
|
@@ -362,7 +377,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
362
377
|
} else if (state.isOverTarget) {
|
|
363
378
|
state.isOverTarget = false;
|
|
364
379
|
triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), state.pointerType, false);
|
|
365
|
-
|
|
380
|
+
cancelOnPointerExit(e);
|
|
366
381
|
}
|
|
367
382
|
};
|
|
368
383
|
let onPointerUp = (e)=>{
|
|
@@ -392,32 +407,37 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
392
407
|
// Due to browser inconsistencies, especially on mobile browsers, we prevent
|
|
393
408
|
// default on mouse down and handle focusing the pressable element ourselves.
|
|
394
409
|
if ($0294ea432cd92340$var$shouldPreventDefault(e.currentTarget)) e.preventDefault();
|
|
395
|
-
|
|
396
|
-
|
|
410
|
+
if (state.ignoreEmulatedMouseEvents) {
|
|
411
|
+
e.stopPropagation();
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
397
414
|
state.isPressed = true;
|
|
398
415
|
state.isOverTarget = true;
|
|
399
416
|
state.target = e.currentTarget;
|
|
400
417
|
state.pointerType = (0, $goTMa$reactariautils.isVirtualClick)(e.nativeEvent) ? "virtual" : "mouse";
|
|
401
418
|
if (!isDisabled && !preventFocusOnPress) (0, $goTMa$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
402
|
-
triggerPressStart(e, state.pointerType);
|
|
419
|
+
let shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
420
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
403
421
|
addGlobalListener(document, "mouseup", onMouseUp, false);
|
|
404
422
|
};
|
|
405
423
|
pressProps.onMouseEnter = (e)=>{
|
|
406
424
|
if (!e.currentTarget.contains(e.target)) return;
|
|
407
|
-
|
|
425
|
+
let shouldStopPropagation = true;
|
|
408
426
|
if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
|
|
409
427
|
state.isOverTarget = true;
|
|
410
|
-
triggerPressStart(e, state.pointerType);
|
|
428
|
+
shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
411
429
|
}
|
|
430
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
412
431
|
};
|
|
413
432
|
pressProps.onMouseLeave = (e)=>{
|
|
414
433
|
if (!e.currentTarget.contains(e.target)) return;
|
|
415
|
-
|
|
434
|
+
let shouldStopPropagation = true;
|
|
416
435
|
if (state.isPressed && !state.ignoreEmulatedMouseEvents) {
|
|
417
436
|
state.isOverTarget = false;
|
|
418
|
-
triggerPressEnd(e, state.pointerType, false);
|
|
419
|
-
|
|
437
|
+
shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
|
|
438
|
+
cancelOnPointerExit(e);
|
|
420
439
|
}
|
|
440
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
421
441
|
};
|
|
422
442
|
pressProps.onMouseUp = (e)=>{
|
|
423
443
|
if (!e.currentTarget.contains(e.target)) return;
|
|
@@ -438,7 +458,6 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
438
458
|
};
|
|
439
459
|
pressProps.onTouchStart = (e)=>{
|
|
440
460
|
if (!e.currentTarget.contains(e.target)) return;
|
|
441
|
-
e.stopPropagation();
|
|
442
461
|
let touch = $0294ea432cd92340$var$getTouchFromEvent(e.nativeEvent);
|
|
443
462
|
if (!touch) return;
|
|
444
463
|
state.activePointerId = touch.identifier;
|
|
@@ -451,34 +470,43 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
451
470
|
// on the emulated mouse event and handle focusing the pressable element ourselves.
|
|
452
471
|
if (!isDisabled && !preventFocusOnPress) (0, $goTMa$reactariautils.focusWithoutScrolling)(e.currentTarget);
|
|
453
472
|
if (!allowTextSelectionOnPress) (0, $f7e14e656343df57$export$16a4697467175487)(state.target);
|
|
454
|
-
triggerPressStart(e, state.pointerType);
|
|
473
|
+
let shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
474
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
455
475
|
addGlobalListener(window, "scroll", onScroll, true);
|
|
456
476
|
};
|
|
457
477
|
pressProps.onTouchMove = (e)=>{
|
|
458
478
|
if (!e.currentTarget.contains(e.target)) return;
|
|
459
|
-
|
|
460
|
-
|
|
479
|
+
if (!state.isPressed) {
|
|
480
|
+
e.stopPropagation();
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
461
483
|
let touch = $0294ea432cd92340$var$getTouchById(e.nativeEvent, state.activePointerId);
|
|
484
|
+
let shouldStopPropagation = true;
|
|
462
485
|
if (touch && $0294ea432cd92340$var$isOverTarget(touch, e.currentTarget)) {
|
|
463
486
|
if (!state.isOverTarget) {
|
|
464
487
|
state.isOverTarget = true;
|
|
465
|
-
triggerPressStart(e, state.pointerType);
|
|
488
|
+
shouldStopPropagation = triggerPressStart(e, state.pointerType);
|
|
466
489
|
}
|
|
467
490
|
} else if (state.isOverTarget) {
|
|
468
491
|
state.isOverTarget = false;
|
|
469
|
-
triggerPressEnd(e, state.pointerType, false);
|
|
470
|
-
|
|
492
|
+
shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
|
|
493
|
+
cancelOnPointerExit(e);
|
|
471
494
|
}
|
|
495
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
472
496
|
};
|
|
473
497
|
pressProps.onTouchEnd = (e)=>{
|
|
474
498
|
if (!e.currentTarget.contains(e.target)) return;
|
|
475
|
-
|
|
476
|
-
|
|
499
|
+
if (!state.isPressed) {
|
|
500
|
+
e.stopPropagation();
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
477
503
|
let touch = $0294ea432cd92340$var$getTouchById(e.nativeEvent, state.activePointerId);
|
|
504
|
+
let shouldStopPropagation = true;
|
|
478
505
|
if (touch && $0294ea432cd92340$var$isOverTarget(touch, e.currentTarget)) {
|
|
479
506
|
triggerPressUp(e, state.pointerType);
|
|
480
|
-
triggerPressEnd(e, state.pointerType);
|
|
481
|
-
} else if (state.isOverTarget) triggerPressEnd(e, state.pointerType, false);
|
|
507
|
+
shouldStopPropagation = triggerPressEnd(e, state.pointerType);
|
|
508
|
+
} else if (state.isOverTarget) shouldStopPropagation = triggerPressEnd(e, state.pointerType, false);
|
|
509
|
+
if (shouldStopPropagation) e.stopPropagation();
|
|
482
510
|
state.isPressed = false;
|
|
483
511
|
state.activePointerId = null;
|
|
484
512
|
state.isOverTarget = false;
|
|
@@ -511,7 +539,12 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
511
539
|
isDisabled,
|
|
512
540
|
preventFocusOnPress,
|
|
513
541
|
removeAllGlobalListeners,
|
|
514
|
-
allowTextSelectionOnPress
|
|
542
|
+
allowTextSelectionOnPress,
|
|
543
|
+
cancel,
|
|
544
|
+
cancelOnPointerExit,
|
|
545
|
+
triggerPressEnd,
|
|
546
|
+
triggerPressStart,
|
|
547
|
+
triggerPressUp
|
|
515
548
|
]);
|
|
516
549
|
// Remove user-select: none in case component unmounts immediately after pressStart
|
|
517
550
|
// eslint-disable-next-line arrow-body-style
|
|
@@ -592,7 +625,7 @@ function $0294ea432cd92340$var$shouldPreventDefault(target) {
|
|
|
592
625
|
}
|
|
593
626
|
function $0294ea432cd92340$var$shouldPreventDefaultKeyboard(target, key) {
|
|
594
627
|
if (target instanceof HTMLInputElement) return !$0294ea432cd92340$var$isValidInputKey(target, key);
|
|
595
|
-
if (target instanceof HTMLButtonElement) return target.type !== "submit";
|
|
628
|
+
if (target instanceof HTMLButtonElement) return target.type !== "submit" && target.type !== "reset";
|
|
596
629
|
return true;
|
|
597
630
|
}
|
|
598
631
|
const $0294ea432cd92340$var$nonTextInputTypes = new Set([
|
|
@@ -655,7 +688,10 @@ const $3596bae48579386f$export$3351871ee4b288b8 = /*#__PURE__*/ (0, ($parcel$int
|
|
|
655
688
|
});
|
|
656
689
|
(0, $goTMa$reactariautils.useSyncRef)(prevContext, ref);
|
|
657
690
|
(0, $goTMa$react.useEffect)(()=>{
|
|
658
|
-
if (!isRegistered.current)
|
|
691
|
+
if (!isRegistered.current) {
|
|
692
|
+
console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component.");
|
|
693
|
+
isRegistered.current = true; // only warn once in strict mode.
|
|
694
|
+
}
|
|
659
695
|
}, []);
|
|
660
696
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($goTMa$react))).createElement((0, $01d3f539e91688c8$export$5165eccb35aaadb5).Provider, {
|
|
661
697
|
value: context
|
|
@@ -723,10 +759,8 @@ class $625cf83917e112ad$export$905e7fc544a71f36 {
|
|
|
723
759
|
function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
724
760
|
let stateRef = (0, $goTMa$react.useRef)({
|
|
725
761
|
isFocused: false,
|
|
726
|
-
onBlur: onBlur,
|
|
727
762
|
observer: null
|
|
728
763
|
});
|
|
729
|
-
stateRef.current.onBlur = onBlur;
|
|
730
764
|
// Clean up MutationObserver on unmount. See below.
|
|
731
765
|
// eslint-disable-next-line arrow-body-style
|
|
732
766
|
(0, $goTMa$reactariautils.useLayoutEffect)(()=>{
|
|
@@ -738,6 +772,9 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
|
738
772
|
}
|
|
739
773
|
};
|
|
740
774
|
}, []);
|
|
775
|
+
let dispatchBlur = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
|
776
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
777
|
+
});
|
|
741
778
|
// This function is called during a React onFocus event.
|
|
742
779
|
return (0, $goTMa$react.useCallback)((e)=>{
|
|
743
780
|
// React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
|
|
@@ -748,10 +785,9 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
|
748
785
|
stateRef.current.isFocused = true;
|
|
749
786
|
let target = e.target;
|
|
750
787
|
let onBlurHandler = (e)=>{
|
|
751
|
-
var // For backward compatibility, dispatch a (fake) React synthetic event.
|
|
752
|
-
_stateRef_current, _stateRef_current_onBlur;
|
|
753
788
|
stateRef.current.isFocused = false;
|
|
754
|
-
if (target.disabled)
|
|
789
|
+
if (target.disabled) // For backward compatibility, dispatch a (fake) React synthetic event.
|
|
790
|
+
dispatchBlur(new $625cf83917e112ad$export$905e7fc544a71f36("blur", e));
|
|
755
791
|
// We no longer need the MutationObserver once the target is blurred.
|
|
756
792
|
if (stateRef.current.observer) {
|
|
757
793
|
stateRef.current.observer.disconnect();
|
|
@@ -764,9 +800,13 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
|
764
800
|
stateRef.current.observer = new MutationObserver(()=>{
|
|
765
801
|
if (stateRef.current.isFocused && target.disabled) {
|
|
766
802
|
stateRef.current.observer.disconnect();
|
|
767
|
-
target.
|
|
803
|
+
let relatedTargetEl = target === document.activeElement ? null : document.activeElement;
|
|
804
|
+
target.dispatchEvent(new FocusEvent("blur", {
|
|
805
|
+
relatedTarget: relatedTargetEl
|
|
806
|
+
}));
|
|
768
807
|
target.dispatchEvent(new FocusEvent("focusout", {
|
|
769
|
-
bubbles: true
|
|
808
|
+
bubbles: true,
|
|
809
|
+
relatedTarget: relatedTargetEl
|
|
770
810
|
}));
|
|
771
811
|
}
|
|
772
812
|
});
|
|
@@ -777,7 +817,9 @@ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
|
777
817
|
]
|
|
778
818
|
});
|
|
779
819
|
}
|
|
780
|
-
}, [
|
|
820
|
+
}, [
|
|
821
|
+
dispatchBlur
|
|
822
|
+
]);
|
|
781
823
|
}
|
|
782
824
|
|
|
783
825
|
|
|
@@ -1200,29 +1242,29 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
1200
1242
|
// NOTICE file in the root directory of this source tree.
|
|
1201
1243
|
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
1202
1244
|
|
|
1245
|
+
|
|
1203
1246
|
function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
1204
1247
|
let { ref: ref , onInteractOutside: onInteractOutside , isDisabled: isDisabled , onInteractOutsideStart: onInteractOutsideStart } = props;
|
|
1205
1248
|
let stateRef = (0, $goTMa$react.useRef)({
|
|
1206
1249
|
isPointerDown: false,
|
|
1207
|
-
ignoreEmulatedMouseEvents: false
|
|
1208
|
-
|
|
1209
|
-
|
|
1250
|
+
ignoreEmulatedMouseEvents: false
|
|
1251
|
+
});
|
|
1252
|
+
let onPointerDown = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
|
1253
|
+
if (onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) {
|
|
1254
|
+
if (onInteractOutsideStart) onInteractOutsideStart(e);
|
|
1255
|
+
stateRef.current.isPointerDown = true;
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
let triggerInteractOutside = (0, $goTMa$reactariautils.useEffectEvent)((e)=>{
|
|
1259
|
+
if (onInteractOutside) onInteractOutside(e);
|
|
1210
1260
|
});
|
|
1211
|
-
let state = stateRef.current;
|
|
1212
|
-
state.onInteractOutside = onInteractOutside;
|
|
1213
|
-
state.onInteractOutsideStart = onInteractOutsideStart;
|
|
1214
1261
|
(0, $goTMa$react.useEffect)(()=>{
|
|
1262
|
+
let state = stateRef.current;
|
|
1215
1263
|
if (isDisabled) return;
|
|
1216
|
-
let onPointerDown = (e)=>{
|
|
1217
|
-
if ($edcfa848c42f94f4$var$isValidEvent(e, ref) && state.onInteractOutside) {
|
|
1218
|
-
if (state.onInteractOutsideStart) state.onInteractOutsideStart(e);
|
|
1219
|
-
state.isPointerDown = true;
|
|
1220
|
-
}
|
|
1221
|
-
};
|
|
1222
1264
|
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
1223
1265
|
if (typeof PointerEvent !== "undefined") {
|
|
1224
1266
|
let onPointerUp = (e)=>{
|
|
1225
|
-
if (state.isPointerDown &&
|
|
1267
|
+
if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
1226
1268
|
state.isPointerDown = false;
|
|
1227
1269
|
};
|
|
1228
1270
|
// changing these to capture phase fixed combobox
|
|
@@ -1235,12 +1277,12 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1235
1277
|
} else {
|
|
1236
1278
|
let onMouseUp = (e)=>{
|
|
1237
1279
|
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
1238
|
-
else if (state.isPointerDown &&
|
|
1280
|
+
else if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
1239
1281
|
state.isPointerDown = false;
|
|
1240
1282
|
};
|
|
1241
1283
|
let onTouchEnd = (e)=>{
|
|
1242
1284
|
state.ignoreEmulatedMouseEvents = true;
|
|
1243
|
-
if (state.
|
|
1285
|
+
if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
1244
1286
|
state.isPointerDown = false;
|
|
1245
1287
|
};
|
|
1246
1288
|
document.addEventListener("mousedown", onPointerDown, true);
|
|
@@ -1256,8 +1298,9 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1256
1298
|
}
|
|
1257
1299
|
}, [
|
|
1258
1300
|
ref,
|
|
1259
|
-
|
|
1260
|
-
|
|
1301
|
+
isDisabled,
|
|
1302
|
+
onPointerDown,
|
|
1303
|
+
triggerInteractOutside
|
|
1261
1304
|
]);
|
|
1262
1305
|
}
|
|
1263
1306
|
function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
|
|
@@ -1349,46 +1392,46 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1349
1392
|
id: null
|
|
1350
1393
|
});
|
|
1351
1394
|
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $goTMa$reactariautils.useGlobalListeners)();
|
|
1352
|
-
let
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
let move = (originalEvent, pointerType, deltaX, deltaY)=>{
|
|
1359
|
-
if (deltaX === 0 && deltaY === 0) return;
|
|
1360
|
-
if (!state.current.didMove) {
|
|
1361
|
-
state.current.didMove = true;
|
|
1362
|
-
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
1363
|
-
type: "movestart",
|
|
1364
|
-
pointerType: pointerType,
|
|
1365
|
-
shiftKey: originalEvent.shiftKey,
|
|
1366
|
-
metaKey: originalEvent.metaKey,
|
|
1367
|
-
ctrlKey: originalEvent.ctrlKey,
|
|
1368
|
-
altKey: originalEvent.altKey
|
|
1369
|
-
});
|
|
1370
|
-
}
|
|
1371
|
-
onMove({
|
|
1372
|
-
type: "move",
|
|
1373
|
-
pointerType: pointerType,
|
|
1374
|
-
deltaX: deltaX,
|
|
1375
|
-
deltaY: deltaY,
|
|
1376
|
-
shiftKey: originalEvent.shiftKey,
|
|
1377
|
-
metaKey: originalEvent.metaKey,
|
|
1378
|
-
ctrlKey: originalEvent.ctrlKey,
|
|
1379
|
-
altKey: originalEvent.altKey
|
|
1380
|
-
});
|
|
1381
|
-
};
|
|
1382
|
-
let end = (originalEvent, pointerType)=>{
|
|
1383
|
-
(0, $f7e14e656343df57$export$b0d6fa1ab32e3295)();
|
|
1384
|
-
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
1385
|
-
type: "moveend",
|
|
1395
|
+
let move = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType, deltaX, deltaY)=>{
|
|
1396
|
+
if (deltaX === 0 && deltaY === 0) return;
|
|
1397
|
+
if (!state.current.didMove) {
|
|
1398
|
+
state.current.didMove = true;
|
|
1399
|
+
onMoveStart === null || onMoveStart === void 0 ? void 0 : onMoveStart({
|
|
1400
|
+
type: "movestart",
|
|
1386
1401
|
pointerType: pointerType,
|
|
1387
1402
|
shiftKey: originalEvent.shiftKey,
|
|
1388
1403
|
metaKey: originalEvent.metaKey,
|
|
1389
1404
|
ctrlKey: originalEvent.ctrlKey,
|
|
1390
1405
|
altKey: originalEvent.altKey
|
|
1391
1406
|
});
|
|
1407
|
+
}
|
|
1408
|
+
onMove({
|
|
1409
|
+
type: "move",
|
|
1410
|
+
pointerType: pointerType,
|
|
1411
|
+
deltaX: deltaX,
|
|
1412
|
+
deltaY: deltaY,
|
|
1413
|
+
shiftKey: originalEvent.shiftKey,
|
|
1414
|
+
metaKey: originalEvent.metaKey,
|
|
1415
|
+
ctrlKey: originalEvent.ctrlKey,
|
|
1416
|
+
altKey: originalEvent.altKey
|
|
1417
|
+
});
|
|
1418
|
+
});
|
|
1419
|
+
let end = (0, $goTMa$reactariautils.useEffectEvent)((originalEvent, pointerType)=>{
|
|
1420
|
+
(0, $f7e14e656343df57$export$b0d6fa1ab32e3295)();
|
|
1421
|
+
if (state.current.didMove) onMoveEnd === null || onMoveEnd === void 0 ? void 0 : onMoveEnd({
|
|
1422
|
+
type: "moveend",
|
|
1423
|
+
pointerType: pointerType,
|
|
1424
|
+
shiftKey: originalEvent.shiftKey,
|
|
1425
|
+
metaKey: originalEvent.metaKey,
|
|
1426
|
+
ctrlKey: originalEvent.ctrlKey,
|
|
1427
|
+
altKey: originalEvent.altKey
|
|
1428
|
+
});
|
|
1429
|
+
});
|
|
1430
|
+
let moveProps = (0, $goTMa$react.useMemo)(()=>{
|
|
1431
|
+
let moveProps = {};
|
|
1432
|
+
let start = ()=>{
|
|
1433
|
+
(0, $f7e14e656343df57$export$16a4697467175487)();
|
|
1434
|
+
state.current.didMove = false;
|
|
1392
1435
|
};
|
|
1393
1436
|
if (typeof PointerEvent === "undefined") {
|
|
1394
1437
|
let onMouseMove = (e)=>{
|
|
@@ -1536,11 +1579,10 @@ function $c09386fc48fa427d$export$36da96379f79f245(props) {
|
|
|
1536
1579
|
return moveProps;
|
|
1537
1580
|
}, [
|
|
1538
1581
|
state,
|
|
1539
|
-
onMoveStart,
|
|
1540
|
-
onMove,
|
|
1541
|
-
onMoveEnd,
|
|
1542
1582
|
addGlobalListener,
|
|
1543
|
-
removeGlobalListener
|
|
1583
|
+
removeGlobalListener,
|
|
1584
|
+
move,
|
|
1585
|
+
end
|
|
1544
1586
|
]);
|
|
1545
1587
|
return {
|
|
1546
1588
|
moveProps: moveProps
|
|
@@ -1601,6 +1643,7 @@ function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
|
|
|
1601
1643
|
let { pressProps: pressProps } = (0, $0294ea432cd92340$export$45712eceda6fad21)({
|
|
1602
1644
|
isDisabled: isDisabled,
|
|
1603
1645
|
onPressStart (e) {
|
|
1646
|
+
e.continuePropagation();
|
|
1604
1647
|
if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
|
1605
1648
|
if (onLongPressStart) onLongPressStart({
|
|
1606
1649
|
...e,
|