@react-aria/interactions 3.13.0 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/interactions",
3
- "version": "3.13.0",
3
+ "version": "3.14.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,9 +22,9 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-aria/utils": "^3.14.1",
22
- "@react-types/shared": "^3.16.0"
25
+ "@react-aria/utils": "^3.15.0",
26
+ "@react-types/shared": "^3.17.0",
27
+ "@swc/helpers": "^0.4.14"
23
28
  },
24
29
  "peerDependencies": {
25
30
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -27,5 +32,5 @@
27
32
  "publishConfig": {
28
33
  "access": "public"
29
34
  },
30
- "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
35
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
31
36
  }
package/src/useFocus.ts CHANGED
@@ -75,7 +75,7 @@ export function useFocus(props: FocusProps): FocusResult {
75
75
  return {
76
76
  focusProps: {
77
77
  onFocus: (!isDisabled && (onFocusProp || onFocusChange || onBlurProp)) ? onFocus : undefined,
78
- onBlur: (!isDisabled && (onBlurProp || onFocusChange)) ? onBlur : null
78
+ onBlur: (!isDisabled && (onBlurProp || onFocusChange)) ? onBlur : undefined
79
79
  }
80
80
  };
81
81
  }
@@ -59,9 +59,9 @@ export function useInteractOutside(props: InteractOutsideProps) {
59
59
  if (typeof PointerEvent !== 'undefined') {
60
60
  let onPointerUp = (e) => {
61
61
  if (state.isPointerDown && state.onInteractOutside && isValidEvent(e, ref)) {
62
- state.isPointerDown = false;
63
62
  state.onInteractOutside(e);
64
63
  }
64
+ state.isPointerDown = false;
65
65
  };
66
66
 
67
67
  // changing these to capture phase fixed combobox
@@ -77,17 +77,17 @@ export function useInteractOutside(props: InteractOutsideProps) {
77
77
  if (state.ignoreEmulatedMouseEvents) {
78
78
  state.ignoreEmulatedMouseEvents = false;
79
79
  } else if (state.isPointerDown && state.onInteractOutside && isValidEvent(e, ref)) {
80
- state.isPointerDown = false;
81
80
  state.onInteractOutside(e);
82
81
  }
82
+ state.isPointerDown = false;
83
83
  };
84
84
 
85
85
  let onTouchEnd = (e) => {
86
86
  state.ignoreEmulatedMouseEvents = true;
87
87
  if (state.onInteractOutside && state.isPointerDown && isValidEvent(e, ref)) {
88
- state.isPointerDown = false;
89
88
  state.onInteractOutside(e);
90
89
  }
90
+ state.isPointerDown = false;
91
91
  };
92
92
 
93
93
  document.addEventListener('mousedown', onPointerDown, true);
@@ -110,12 +110,17 @@ function isValidEvent(event, ref) {
110
110
  return false;
111
111
  }
112
112
 
113
- // if the event target is no longer in the document
114
113
  if (event.target) {
114
+ // if the event target is no longer in the document, ignore
115
115
  const ownerDocument = event.target.ownerDocument;
116
116
  if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) {
117
117
  return false;
118
118
  }
119
+
120
+ // If the target is within a top layer element (e.g. toasts), ignore.
121
+ if (event.target.closest('[data-react-aria-top-layer]')) {
122
+ return false;
123
+ }
119
124
  }
120
125
 
121
126
  return ref.current && !ref.current.contains(event.target);