@react-aria/interactions 3.0.0-nightly.1791 → 3.0.0-nightly.1806

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 CHANGED
@@ -81,110 +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
- // Android TalkBack's detail value varies depending on the event listener providing the event so we have specific logic here instead
89
- // If pointerType is defined, event is from a click listener. For events from mousedown listener, detail === 0 is a sufficient check
90
- // to detect TalkBack virtual clicks.
91
- if ($goTMa$reactariautils.isAndroid() && event.pointerType) return event.type === 'click' && event.buttons === 1;
92
- return event.detail === 0 && !event.pointerType;
93
- }
94
- class $625cf83917e112ad$export$905e7fc544a71f36 {
95
- isDefaultPrevented() {
96
- return this.nativeEvent.defaultPrevented;
97
- }
98
- preventDefault() {
99
- this.defaultPrevented = true;
100
- this.nativeEvent.preventDefault();
101
- }
102
- stopPropagation() {
103
- this.nativeEvent.stopPropagation();
104
- this.isPropagationStopped = ()=>true
105
- ;
106
- }
107
- isPropagationStopped() {
108
- return false;
109
- }
110
- persist() {
111
- }
112
- constructor(type, nativeEvent){
113
- this.nativeEvent = nativeEvent;
114
- this.target = nativeEvent.target;
115
- this.currentTarget = nativeEvent.currentTarget;
116
- this.relatedTarget = nativeEvent.relatedTarget;
117
- this.bubbles = nativeEvent.bubbles;
118
- this.cancelable = nativeEvent.cancelable;
119
- this.defaultPrevented = nativeEvent.defaultPrevented;
120
- this.eventPhase = nativeEvent.eventPhase;
121
- this.isTrusted = nativeEvent.isTrusted;
122
- this.timeStamp = nativeEvent.timeStamp;
123
- this.type = type;
124
- }
125
- }
126
- function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
127
- let stateRef = $goTMa$react.useRef({
128
- isFocused: false,
129
- onBlur: onBlur,
130
- observer: null
131
- });
132
- stateRef.current.onBlur = onBlur;
133
- // Clean up MutationObserver on unmount. See below.
134
- // eslint-disable-next-line arrow-body-style
135
- $goTMa$reactariautils.useLayoutEffect(()=>{
136
- const state = stateRef.current;
137
- return ()=>{
138
- if (state.observer) {
139
- state.observer.disconnect();
140
- state.observer = null;
141
- }
142
- };
143
- }, []);
144
- // This function is called during a React onFocus event.
145
- return $goTMa$react.useCallback((e1)=>{
146
- // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
147
- // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
148
- // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
149
- // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
150
- if (e1.target instanceof HTMLButtonElement || e1.target instanceof HTMLInputElement || e1.target instanceof HTMLTextAreaElement || e1.target instanceof HTMLSelectElement) {
151
- stateRef.current.isFocused = true;
152
- let target = e1.target;
153
- let onBlurHandler = (e)=>{
154
- var // For backward compatibility, dispatch a (fake) React synthetic event.
155
- _current, ref;
156
- stateRef.current.isFocused = false;
157
- if (target.disabled) (ref = (_current = stateRef.current).onBlur) === null || ref === void 0 ? void 0 : ref.call(_current, new $625cf83917e112ad$export$905e7fc544a71f36('blur', e));
158
- // We no longer need the MutationObserver once the target is blurred.
159
- if (stateRef.current.observer) {
160
- stateRef.current.observer.disconnect();
161
- stateRef.current.observer = null;
162
- }
163
- };
164
- target.addEventListener('focusout', onBlurHandler, {
165
- once: true
166
- });
167
- stateRef.current.observer = new MutationObserver(()=>{
168
- if (stateRef.current.isFocused && target.disabled) {
169
- stateRef.current.observer.disconnect();
170
- target.dispatchEvent(new FocusEvent('blur'));
171
- target.dispatchEvent(new FocusEvent('focusout', {
172
- bubbles: true
173
- }));
174
- }
175
- });
176
- stateRef.current.observer.observe(target, {
177
- attributes: true,
178
- attributeFilter: [
179
- 'disabled'
180
- ]
181
- });
182
- }
183
- }, []);
184
- }
185
-
186
-
187
-
188
84
  const $01d3f539e91688c8$export$5165eccb35aaadb5 = ($parcel$interopDefault($goTMa$react)).createContext(null);
189
85
  $01d3f539e91688c8$export$5165eccb35aaadb5.displayName = 'PressResponderContext';
190
86
 
@@ -325,7 +221,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
325
221
  if (isDisabled1) e.preventDefault();
326
222
  // If triggered from a screen reader or by using element.click(),
327
223
  // trigger as if it were a keyboard click.
328
- if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === 'virtual' || $625cf83917e112ad$export$60278871457622de(e.nativeEvent))) {
224
+ if (!state.ignoreClickAfterPress && !state.ignoreEmulatedMouseEvents && (state.pointerType === 'virtual' || $goTMa$reactariautils.isVirtualClick(e.nativeEvent))) {
329
225
  // Ensure the element receives focus (VoiceOver on iOS does not do this)
330
226
  if (!isDisabled1 && !preventFocusOnPress) $goTMa$reactariautils.focusWithoutScrolling(e.currentTarget);
331
227
  triggerPressStart(e, 'virtual');
@@ -358,7 +254,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
358
254
  // Ignore and let the onClick handler take care of it instead.
359
255
  // https://bugs.webkit.org/show_bug.cgi?id=222627
360
256
  // https://bugs.webkit.org/show_bug.cgi?id=223202
361
- if ($0294ea432cd92340$var$isVirtualPointerEvent(e.nativeEvent)) {
257
+ if ($goTMa$reactariautils.isVirtualPointerEvent(e.nativeEvent)) {
362
258
  state.pointerType = 'virtual';
363
259
  return;
364
260
  }
@@ -446,7 +342,7 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
446
342
  state.isPressed = true;
447
343
  state.isOverTarget = true;
448
344
  state.target = e.currentTarget;
449
- state.pointerType = $625cf83917e112ad$export$60278871457622de(e.nativeEvent) ? 'virtual' : 'mouse';
345
+ state.pointerType = $goTMa$reactariautils.isVirtualClick(e.nativeEvent) ? 'virtual' : 'mouse';
450
346
  if (!isDisabled1 && !preventFocusOnPress) $goTMa$reactariautils.focusWithoutScrolling(e.currentTarget);
451
347
  triggerPressStart(e, state.pointerType);
452
348
  addGlobalListener(document, 'mouseup', onMouseUp, false);
@@ -656,15 +552,6 @@ function $0294ea432cd92340$var$isValidInputKey(target, key) {
656
552
  // Only space should toggle checkboxes and radios, not enter.
657
553
  return target.type === 'checkbox' || target.type === 'radio' ? key === ' ' : $0294ea432cd92340$var$nonTextInputTypes.has(target.type);
658
554
  }
659
- function $0294ea432cd92340$var$isVirtualPointerEvent(event) {
660
- // If the pointer size is zero, then we assume it's from a screen reader.
661
- // Android TalkBack double tap will sometimes return a event with width and height of 1
662
- // and pointerType === 'mouse' so we need to check for a specific combination of event attributes.
663
- // Cannot use "event.pressure === 0" as the sole check due to Safari pointer events always returning pressure === 0
664
- // instead of .5, see https://bugs.webkit.org/show_bug.cgi?id=206216. event.pointerType === 'mouse' is to distingush
665
- // Talkback double tap from Windows Firefox touch screen press
666
- return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === 'mouse';
667
- }
668
555
 
669
556
 
670
557
 
@@ -711,6 +598,100 @@ const $3596bae48579386f$export$3351871ee4b288b8 = /*#__PURE__*/ ($parcel$interop
711
598
 
712
599
 
713
600
 
601
+
602
+ class $625cf83917e112ad$export$905e7fc544a71f36 {
603
+ isDefaultPrevented() {
604
+ return this.nativeEvent.defaultPrevented;
605
+ }
606
+ preventDefault() {
607
+ this.defaultPrevented = true;
608
+ this.nativeEvent.preventDefault();
609
+ }
610
+ stopPropagation() {
611
+ this.nativeEvent.stopPropagation();
612
+ this.isPropagationStopped = ()=>true
613
+ ;
614
+ }
615
+ isPropagationStopped() {
616
+ return false;
617
+ }
618
+ persist() {
619
+ }
620
+ constructor(type, nativeEvent){
621
+ this.nativeEvent = nativeEvent;
622
+ this.target = nativeEvent.target;
623
+ this.currentTarget = nativeEvent.currentTarget;
624
+ this.relatedTarget = nativeEvent.relatedTarget;
625
+ this.bubbles = nativeEvent.bubbles;
626
+ this.cancelable = nativeEvent.cancelable;
627
+ this.defaultPrevented = nativeEvent.defaultPrevented;
628
+ this.eventPhase = nativeEvent.eventPhase;
629
+ this.isTrusted = nativeEvent.isTrusted;
630
+ this.timeStamp = nativeEvent.timeStamp;
631
+ this.type = type;
632
+ }
633
+ }
634
+ function $625cf83917e112ad$export$715c682d09d639cc(onBlur) {
635
+ let stateRef = $goTMa$react.useRef({
636
+ isFocused: false,
637
+ onBlur: onBlur,
638
+ observer: null
639
+ });
640
+ stateRef.current.onBlur = onBlur;
641
+ // Clean up MutationObserver on unmount. See below.
642
+ // eslint-disable-next-line arrow-body-style
643
+ $goTMa$reactariautils.useLayoutEffect(()=>{
644
+ const state = stateRef.current;
645
+ return ()=>{
646
+ if (state.observer) {
647
+ state.observer.disconnect();
648
+ state.observer = null;
649
+ }
650
+ };
651
+ }, []);
652
+ // This function is called during a React onFocus event.
653
+ return $goTMa$react.useCallback((e1)=>{
654
+ // React does not fire onBlur when an element is disabled. https://github.com/facebook/react/issues/9142
655
+ // Most browsers fire a native focusout event in this case, except for Firefox. In that case, we use a
656
+ // MutationObserver to watch for the disabled attribute, and dispatch these events ourselves.
657
+ // For browsers that do, focusout fires before the MutationObserver, so onBlur should not fire twice.
658
+ if (e1.target instanceof HTMLButtonElement || e1.target instanceof HTMLInputElement || e1.target instanceof HTMLTextAreaElement || e1.target instanceof HTMLSelectElement) {
659
+ stateRef.current.isFocused = true;
660
+ let target = e1.target;
661
+ let onBlurHandler = (e)=>{
662
+ var // For backward compatibility, dispatch a (fake) React synthetic event.
663
+ _current, ref;
664
+ stateRef.current.isFocused = false;
665
+ if (target.disabled) (ref = (_current = stateRef.current).onBlur) === null || ref === void 0 ? void 0 : ref.call(_current, new $625cf83917e112ad$export$905e7fc544a71f36('blur', e));
666
+ // We no longer need the MutationObserver once the target is blurred.
667
+ if (stateRef.current.observer) {
668
+ stateRef.current.observer.disconnect();
669
+ stateRef.current.observer = null;
670
+ }
671
+ };
672
+ target.addEventListener('focusout', onBlurHandler, {
673
+ once: true
674
+ });
675
+ stateRef.current.observer = new MutationObserver(()=>{
676
+ if (stateRef.current.isFocused && target.disabled) {
677
+ stateRef.current.observer.disconnect();
678
+ target.dispatchEvent(new FocusEvent('blur'));
679
+ target.dispatchEvent(new FocusEvent('focusout', {
680
+ bubbles: true
681
+ }));
682
+ }
683
+ });
684
+ stateRef.current.observer.observe(target, {
685
+ attributes: true,
686
+ attributeFilter: [
687
+ 'disabled'
688
+ ]
689
+ });
690
+ }
691
+ }, []);
692
+ }
693
+
694
+
714
695
  function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
715
696
  let { isDisabled: isDisabled , onFocus: onFocusProp , onBlur: onBlurProp , onFocusChange: onFocusChange } = props;
716
697
  const onBlur = $goTMa$react.useCallback((e)=>{
@@ -746,7 +727,6 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
746
727
 
747
728
 
748
729
 
749
-
750
730
  let $e77252a287ef94ab$var$currentModality = null;
751
731
  let $e77252a287ef94ab$var$changeHandlers = new Set();
752
732
  let $e77252a287ef94ab$var$hasSetupGlobalListeners = false;
@@ -781,7 +761,7 @@ function $e77252a287ef94ab$var$handlePointerEvent(e) {
781
761
  }
782
762
  }
783
763
  function $e77252a287ef94ab$var$handleClickEvent(e) {
784
- if ($625cf83917e112ad$export$60278871457622de(e)) {
764
+ if ($goTMa$reactariautils.isVirtualClick(e)) {
785
765
  $e77252a287ef94ab$var$hasEventBeforeFocus = true;
786
766
  $e77252a287ef94ab$var$currentModality = 'virtual';
787
767
  }