@react-aria/interactions 3.11.0 → 3.13.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/main.js +102 -115
- package/dist/main.js.map +1 -1
- package/dist/module.js +103 -116
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -1
- package/src/useFocusVisible.ts +3 -3
- package/src/useHover.ts +1 -0
- package/src/usePress.ts +2 -20
- package/src/utils.ts +0 -20
package/dist/main.js
CHANGED
|
@@ -81,106 +81,6 @@ function $f7e14e656343df57$export$b0d6fa1ab32e3295(target) {
|
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
function $625cf83917e112ad$export$60278871457622de(event) {
|
|
86
|
-
// JAWS/NVDA with Firefox.
|
|
87
|
-
if (event.mozInputSource === 0 && event.isTrusted) return true;
|
|
88
|
-
return event.detail === 0 && !event.pointerType;
|
|
89
|
-
}
|
|
90
|
-
class $625cf83917e112ad$export$905e7fc544a71f36 {
|
|
91
|
-
isDefaultPrevented() {
|
|
92
|
-
return this.nativeEvent.defaultPrevented;
|
|
93
|
-
}
|
|
94
|
-
preventDefault() {
|
|
95
|
-
this.defaultPrevented = true;
|
|
96
|
-
this.nativeEvent.preventDefault();
|
|
97
|
-
}
|
|
98
|
-
stopPropagation() {
|
|
99
|
-
this.nativeEvent.stopPropagation();
|
|
100
|
-
this.isPropagationStopped = ()=>true
|
|
101
|
-
;
|
|
102
|
-
}
|
|
103
|
-
isPropagationStopped() {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
persist() {
|
|
107
|
-
}
|
|
108
|
-
constructor(type, nativeEvent){
|
|
109
|
-
this.nativeEvent = nativeEvent;
|
|
110
|
-
this.target = nativeEvent.target;
|
|
111
|
-
this.currentTarget = nativeEvent.currentTarget;
|
|
112
|
-
this.relatedTarget = nativeEvent.relatedTarget;
|
|
113
|
-
this.bubbles = nativeEvent.bubbles;
|
|
114
|
-
this.cancelable = nativeEvent.cancelable;
|
|
115
|
-
this.defaultPrevented = nativeEvent.defaultPrevented;
|
|
116
|
-
this.eventPhase = nativeEvent.eventPhase;
|
|
117
|
-
this.isTrusted = nativeEvent.isTrusted;
|
|
118
|
-
this.timeStamp = nativeEvent.timeStamp;
|
|
119
|
-
this.type = type;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
123
|
-
let stateRef = $goTMa$react.useRef({
|
|
124
|
-
isFocused: false,
|
|
125
|
-
onBlur: onBlur,
|
|
126
|
-
observer: null
|
|
127
|
-
});
|
|
128
|
-
stateRef.current.onBlur = onBlur;
|
|
129
|
-
// Clean up MutationObserver on unmount. See below.
|
|
130
|
-
// eslint-disable-next-line arrow-body-style
|
|
131
|
-
$goTMa$reactariautils.useLayoutEffect(()=>{
|
|
132
|
-
const state = stateRef.current;
|
|
133
|
-
return ()=>{
|
|
134
|
-
if (state.observer) {
|
|
135
|
-
state.observer.disconnect();
|
|
136
|
-
state.observer = null;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}, []);
|
|
140
|
-
// This function is called during a React onFocus event.
|
|
141
|
-
return $goTMa$react.useCallback((e1)=>{
|
|
142
|
-
// React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
|
|
143
|
-
// Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
|
|
144
|
-
// MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
|
|
145
|
-
// For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
|
|
146
|
-
if (e1.target instanceof HTMLButtonElement || e1.target instanceof HTMLInputElement || e1.target instanceof HTMLTextAreaElement || e1.target instanceof HTMLSelectElement) {
|
|
147
|
-
stateRef.current.isFocused = true;
|
|
148
|
-
let target = e1.target;
|
|
149
|
-
let onBlurHandler = (e)=>{
|
|
150
|
-
var // For backward compatibility, dispatch a (fake) React synthetic event.
|
|
151
|
-
_current, ref;
|
|
152
|
-
stateRef.current.isFocused = false;
|
|
153
|
-
if (target.disabled) (ref = (_current = stateRef.current).onBlur) === null || ref === void 0 ? void 0 : ref.call(_current, new $625cf83917e112ad$export$905e7fc544a71f36('blur', e));
|
|
154
|
-
// We no longer need the MutationObserver once the target is blurred.
|
|
155
|
-
if (stateRef.current.observer) {
|
|
156
|
-
stateRef.current.observer.disconnect();
|
|
157
|
-
stateRef.current.observer = null;
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
target.addEventListener('focusout', onBlurHandler, {
|
|
161
|
-
once: true
|
|
162
|
-
});
|
|
163
|
-
stateRef.current.observer = new MutationObserver(()=>{
|
|
164
|
-
if (stateRef.current.isFocused && target.disabled) {
|
|
165
|
-
stateRef.current.observer.disconnect();
|
|
166
|
-
target.dispatchEvent(new FocusEvent('blur'));
|
|
167
|
-
target.dispatchEvent(new FocusEvent('focusout', {
|
|
168
|
-
bubbles: true
|
|
169
|
-
}));
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
stateRef.current.observer.observe(target, {
|
|
173
|
-
attributes: true,
|
|
174
|
-
attributeFilter: [
|
|
175
|
-
'disabled'
|
|
176
|
-
]
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}, []);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
84
|
const $01d3f539e91688c8$export$5165eccb35aaadb5 = ($parcel$interopDefault($goTMa$react)).createContext(null);
|
|
185
85
|
$01d3f539e91688c8$export$5165eccb35aaadb5.displayName = 'PressResponderContext';
|
|
186
86
|
|
|
@@ -321,7 +221,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
321
221
|
if (isDisabled1) e.preventDefault();
|
|
322
222
|
// If triggered from a screen reader or by using element.click(),
|
|
323
223
|
// trigger as if it were a keyboard click.
|
|
324
|
-
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === 'virtual' || $
|
|
224
|
+
if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === 'virtual' || $goTMa$reactariautils.isVirtualClick(e.nativeEvent))) {
|
|
325
225
|
// Ensure the element receives focus (VoiceOver on iOS does not do this)
|
|
326
226
|
if (!isDisabled1 && !preventFocusOnPress) $goTMa$reactariautils.focusWithoutScrolling(e.currentTarget);
|
|
327
227
|
triggerPressStart(e, 'virtual');
|
|
@@ -354,7 +254,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
354
254
|
// Ignore and let the onClick handler take care of it instead.
|
|
355
255
|
// https://bugs.webkit.org/show_bug.cgi?id=222627
|
|
356
256
|
// https://bugs.webkit.org/show_bug.cgi?id=223202
|
|
357
|
-
if ($
|
|
257
|
+
if ($goTMa$reactariautils.isVirtualPointerEvent(e.nativeEvent)) {
|
|
358
258
|
state.pointerType = 'virtual';
|
|
359
259
|
return;
|
|
360
260
|
}
|
|
@@ -442,7 +342,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
442
342
|
state.isPressed = true;
|
|
443
343
|
state.isOverTarget = true;
|
|
444
344
|
state.target = e.currentTarget;
|
|
445
|
-
state.pointerType = $
|
|
345
|
+
state.pointerType = $goTMa$reactariautils.isVirtualClick(e.nativeEvent) ? 'virtual' : 'mouse';
|
|
446
346
|
if (!isDisabled1 && !preventFocusOnPress) $goTMa$reactariautils.focusWithoutScrolling(e.currentTarget);
|
|
447
347
|
triggerPressStart(e, state.pointerType);
|
|
448
348
|
addGlobalListener(document, 'mouseup', onMouseUp, false);
|
|
@@ -562,7 +462,8 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
|
|
|
562
462
|
// eslint-disable-next-line arrow-body-style
|
|
563
463
|
$goTMa$react.useEffect(()=>{
|
|
564
464
|
return ()=>{
|
|
565
|
-
if (!allowTextSelectionOnPress)
|
|
465
|
+
if (!allowTextSelectionOnPress) // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
466
|
+
$f7e14e656343df57$export$b0d6fa1ab32e3295(ref.current.target);
|
|
566
467
|
};
|
|
567
468
|
}, [
|
|
568
469
|
allowTextSelectionOnPress
|
|
@@ -652,15 +553,6 @@ function $0294ea432cd92340$var$isValidInputKey(target, key) {
|
|
|
652
553
|
// Only space should toggle checkboxes and radios, not enter.
|
|
653
554
|
return target.type === 'checkbox' || target.type === 'radio' ? key === ' ' : $0294ea432cd92340$var$nonTextInputTypes.has(target.type);
|
|
654
555
|
}
|
|
655
|
-
function $0294ea432cd92340$var$isVirtualPointerEvent(event) {
|
|
656
|
-
// If the pointer size is zero, then we assume it's from a screen reader.
|
|
657
|
-
// Android TalkBack double tap will sometimes return a event with width and height of 1
|
|
658
|
-
// and pointerType === 'mouse' so we need to check for a specific combination of event attributes.
|
|
659
|
-
// Cannot use "event.pressure === 0" as the sole check due to Safari pointer events always returning pressure === 0
|
|
660
|
-
// instead of .5, see https://bugs.webkit.org/show_bug.cgi?id=206216. event.pointerType === 'mouse' is to distingush
|
|
661
|
-
// Talkback double tap from Windows Firefox touch screen press
|
|
662
|
-
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'mouse';
|
|
663
|
-
}
|
|
664
556
|
|
|
665
557
|
|
|
666
558
|
|
|
@@ -707,6 +599,100 @@ const $3596bae48579386f$export$3351871ee4b288b8 = /*#__PURE__*/ ($parcel$interop
|
|
|
707
599
|
|
|
708
600
|
|
|
709
601
|
|
|
602
|
+
|
|
603
|
+
class $625cf83917e112ad$export$905e7fc544a71f36 {
|
|
604
|
+
isDefaultPrevented() {
|
|
605
|
+
return this.nativeEvent.defaultPrevented;
|
|
606
|
+
}
|
|
607
|
+
preventDefault() {
|
|
608
|
+
this.defaultPrevented = true;
|
|
609
|
+
this.nativeEvent.preventDefault();
|
|
610
|
+
}
|
|
611
|
+
stopPropagation() {
|
|
612
|
+
this.nativeEvent.stopPropagation();
|
|
613
|
+
this.isPropagationStopped = ()=>true
|
|
614
|
+
;
|
|
615
|
+
}
|
|
616
|
+
isPropagationStopped() {
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
persist() {
|
|
620
|
+
}
|
|
621
|
+
constructor(type, nativeEvent){
|
|
622
|
+
this.nativeEvent = nativeEvent;
|
|
623
|
+
this.target = nativeEvent.target;
|
|
624
|
+
this.currentTarget = nativeEvent.currentTarget;
|
|
625
|
+
this.relatedTarget = nativeEvent.relatedTarget;
|
|
626
|
+
this.bubbles = nativeEvent.bubbles;
|
|
627
|
+
this.cancelable = nativeEvent.cancelable;
|
|
628
|
+
this.defaultPrevented = nativeEvent.defaultPrevented;
|
|
629
|
+
this.eventPhase = nativeEvent.eventPhase;
|
|
630
|
+
this.isTrusted = nativeEvent.isTrusted;
|
|
631
|
+
this.timeStamp = nativeEvent.timeStamp;
|
|
632
|
+
this.type = type;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
|
|
636
|
+
let stateRef = $goTMa$react.useRef({
|
|
637
|
+
isFocused: false,
|
|
638
|
+
onBlur: onBlur,
|
|
639
|
+
observer: null
|
|
640
|
+
});
|
|
641
|
+
stateRef.current.onBlur = onBlur;
|
|
642
|
+
// Clean up MutationObserver on unmount. See below.
|
|
643
|
+
// eslint-disable-next-line arrow-body-style
|
|
644
|
+
$goTMa$reactariautils.useLayoutEffect(()=>{
|
|
645
|
+
const state = stateRef.current;
|
|
646
|
+
return ()=>{
|
|
647
|
+
if (state.observer) {
|
|
648
|
+
state.observer.disconnect();
|
|
649
|
+
state.observer = null;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}, []);
|
|
653
|
+
// This function is called during a React onFocus event.
|
|
654
|
+
return $goTMa$react.useCallback((e1)=>{
|
|
655
|
+
// React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
|
|
656
|
+
// Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
|
|
657
|
+
// MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
|
|
658
|
+
// For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
|
|
659
|
+
if (e1.target instanceof HTMLButtonElement || e1.target instanceof HTMLInputElement || e1.target instanceof HTMLTextAreaElement || e1.target instanceof HTMLSelectElement) {
|
|
660
|
+
stateRef.current.isFocused = true;
|
|
661
|
+
let target = e1.target;
|
|
662
|
+
let onBlurHandler = (e)=>{
|
|
663
|
+
var // For backward compatibility, dispatch a (fake) React synthetic event.
|
|
664
|
+
_current, ref;
|
|
665
|
+
stateRef.current.isFocused = false;
|
|
666
|
+
if (target.disabled) (ref = (_current = stateRef.current).onBlur) === null || ref === void 0 ? void 0 : ref.call(_current, new $625cf83917e112ad$export$905e7fc544a71f36('blur', e));
|
|
667
|
+
// We no longer need the MutationObserver once the target is blurred.
|
|
668
|
+
if (stateRef.current.observer) {
|
|
669
|
+
stateRef.current.observer.disconnect();
|
|
670
|
+
stateRef.current.observer = null;
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
target.addEventListener('focusout', onBlurHandler, {
|
|
674
|
+
once: true
|
|
675
|
+
});
|
|
676
|
+
stateRef.current.observer = new MutationObserver(()=>{
|
|
677
|
+
if (stateRef.current.isFocused && target.disabled) {
|
|
678
|
+
stateRef.current.observer.disconnect();
|
|
679
|
+
target.dispatchEvent(new FocusEvent('blur'));
|
|
680
|
+
target.dispatchEvent(new FocusEvent('focusout', {
|
|
681
|
+
bubbles: true
|
|
682
|
+
}));
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
stateRef.current.observer.observe(target, {
|
|
686
|
+
attributes: true,
|
|
687
|
+
attributeFilter: [
|
|
688
|
+
'disabled'
|
|
689
|
+
]
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
}, []);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
|
|
710
696
|
function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
711
697
|
let { isDisabled: isDisabled , onFocus: onFocusProp , onBlur: onBlurProp , onFocusChange: onFocusChange } = props;
|
|
712
698
|
const onBlur = $goTMa$react.useCallback((e)=>{
|
|
@@ -742,7 +728,6 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
|
742
728
|
|
|
743
729
|
|
|
744
730
|
|
|
745
|
-
|
|
746
731
|
let $e77252a287ef94ab$var$currentModality = null;
|
|
747
732
|
let $e77252a287ef94ab$var$changeHandlers = new Set();
|
|
748
733
|
let $e77252a287ef94ab$var$hasSetupGlobalListeners = false;
|
|
@@ -777,7 +762,7 @@ function $e77252a287ef94ab$var$handlePointerEvent(e) {
|
|
|
777
762
|
}
|
|
778
763
|
}
|
|
779
764
|
function $e77252a287ef94ab$var$handleClickEvent(e) {
|
|
780
|
-
if ($
|
|
765
|
+
if ($goTMa$reactariautils.isVirtualClick(e)) {
|
|
781
766
|
$e77252a287ef94ab$var$hasEventBeforeFocus = true;
|
|
782
767
|
$e77252a287ef94ab$var$currentModality = 'virtual';
|
|
783
768
|
}
|
|
@@ -893,6 +878,7 @@ function $e77252a287ef94ab$export$ec71b4b83ac08ec3(fn, deps, opts) {
|
|
|
893
878
|
return ()=>{
|
|
894
879
|
$e77252a287ef94ab$var$changeHandlers.delete(handler);
|
|
895
880
|
};
|
|
881
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
896
882
|
}, deps);
|
|
897
883
|
}
|
|
898
884
|
|
|
@@ -1055,6 +1041,7 @@ function $ffbc150311c75f01$export$ae780daf29e6d456(props) {
|
|
|
1055
1041
|
if (isDisabled) triggerHoverEnd1({
|
|
1056
1042
|
currentTarget: state.target
|
|
1057
1043
|
}, state.pointerType);
|
|
1044
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1058
1045
|
}, [
|
|
1059
1046
|
isDisabled
|
|
1060
1047
|
]);
|