@zag-js/interact-outside 1.46.0 → 1.47.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/index.js CHANGED
@@ -141,9 +141,10 @@ function trackInteractOutsideImpl(node, options) {
141
141
  cleanups.add(parentWin.addEventListener("pointerdown", onPointerDown, true));
142
142
  cleanups.add(frames.addEventListener("pointerdown", onPointerDown, true));
143
143
  }, 0);
144
+ const focusFrame = import_dom_query2.AnimationFrame.create();
144
145
  function onFocusin(event) {
145
146
  if (isPointerDown) return;
146
- const func = defer ? import_dom_query2.raf : (v) => v();
147
+ const func = defer ? (fn) => focusFrame.request(fn) : (fn) => fn();
147
148
  func(() => {
148
149
  const composedPath = event?.composedPath?.() ?? [event?.target];
149
150
  const target = isInShadowRoot ? composedPath[0] : (0, import_dom_query2.getEventTarget)(event);
@@ -171,6 +172,7 @@ function trackInteractOutsideImpl(node, options) {
171
172
  }
172
173
  return () => {
173
174
  clearTimeout(timer);
175
+ focusFrame.cancel();
174
176
  pointerdownCleanups.forEach((fn) => fn());
175
177
  cleanups.forEach((fn) => fn());
176
178
  };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/index.ts
2
2
  import { addDomEvent, isContextMenuEvent, isShadowRoot, isTouchDevice } from "@zag-js/dom-query";
3
3
  import {
4
+ AnimationFrame,
4
5
  contains,
5
6
  getDocument,
6
7
  getEventTarget,
@@ -127,9 +128,10 @@ function trackInteractOutsideImpl(node, options) {
127
128
  cleanups.add(parentWin.addEventListener("pointerdown", onPointerDown, true));
128
129
  cleanups.add(frames.addEventListener("pointerdown", onPointerDown, true));
129
130
  }, 0);
131
+ const focusFrame = AnimationFrame.create();
130
132
  function onFocusin(event) {
131
133
  if (isPointerDown) return;
132
- const func = defer ? raf : (v) => v();
134
+ const func = defer ? (fn) => focusFrame.request(fn) : (fn) => fn();
133
135
  func(() => {
134
136
  const composedPath = event?.composedPath?.() ?? [event?.target];
135
137
  const target = isInShadowRoot ? composedPath[0] : getEventTarget(event);
@@ -157,6 +159,7 @@ function trackInteractOutsideImpl(node, options) {
157
159
  }
158
160
  return () => {
159
161
  clearTimeout(timer);
162
+ focusFrame.cancel();
160
163
  pointerdownCleanups.forEach((fn) => fn());
161
164
  cleanups.forEach((fn) => fn());
162
165
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/interact-outside",
3
- "version": "1.46.0",
3
+ "version": "1.47.0",
4
4
  "description": "Track interactions or focus outside an element",
5
5
  "keywords": [
6
6
  "js",
@@ -19,8 +19,8 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@zag-js/dom-query": "1.46.0",
23
- "@zag-js/utils": "1.46.0"
22
+ "@zag-js/dom-query": "1.47.0",
23
+ "@zag-js/utils": "1.47.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "clean-package": "2.2.0"