@zag-js/tabs 1.8.0 → 1.8.2

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
@@ -489,15 +489,16 @@ var machine = core.createMachine({
489
489
  const triggerEl = getTriggerEl(scope, value);
490
490
  const indicatorEl = getIndicatorEl(scope);
491
491
  if (!triggerEl || !indicatorEl) return;
492
- const exec = () => {
493
- const rect = getOffsetRect(triggerEl);
494
- context.set("indicatorRect", resolveRect(rect));
495
- };
496
- exec();
497
- const win = scope.getWin();
498
- const obs = new win.ResizeObserver(exec);
499
- obs.observe(triggerEl);
500
- refs.set("indicatorCleanup", () => obs.disconnect());
492
+ const indicatorCleanup = domQuery.trackElementRect([triggerEl], {
493
+ measure(el) {
494
+ return getOffsetRect(el);
495
+ },
496
+ onEntry({ rects }) {
497
+ const [rect] = rects;
498
+ context.set("indicatorRect", resolveRect(rect));
499
+ }
500
+ });
501
+ refs.set("indicatorCleanup", indicatorCleanup);
501
502
  },
502
503
  navigateIfNeeded({ context, prop, scope }) {
503
504
  const value = context.get("value");
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createAnatomy } from '@zag-js/anatomy';
2
- import { isAnchorElement, nextTick, raf, getFocusables, prevById, nextById, clickIfLink, itemById, queryAll, dataAttr, isSafari, isSelfTarget, isComposingEvent, getEventKey } from '@zag-js/dom-query';
2
+ import { isAnchorElement, trackElementRect, nextTick, raf, getFocusables, prevById, nextById, clickIfLink, itemById, queryAll, dataAttr, isSafari, isSelfTarget, isComposingEvent, getEventKey } from '@zag-js/dom-query';
3
3
  import { last, first, createSplitProps } from '@zag-js/utils';
4
4
  import { createGuards, createMachine } from '@zag-js/core';
5
5
  import { createProps } from '@zag-js/types';
@@ -487,15 +487,16 @@ var machine = createMachine({
487
487
  const triggerEl = getTriggerEl(scope, value);
488
488
  const indicatorEl = getIndicatorEl(scope);
489
489
  if (!triggerEl || !indicatorEl) return;
490
- const exec = () => {
491
- const rect = getOffsetRect(triggerEl);
492
- context.set("indicatorRect", resolveRect(rect));
493
- };
494
- exec();
495
- const win = scope.getWin();
496
- const obs = new win.ResizeObserver(exec);
497
- obs.observe(triggerEl);
498
- refs.set("indicatorCleanup", () => obs.disconnect());
490
+ const indicatorCleanup = trackElementRect([triggerEl], {
491
+ measure(el) {
492
+ return getOffsetRect(el);
493
+ },
494
+ onEntry({ rects }) {
495
+ const [rect] = rects;
496
+ context.set("indicatorRect", resolveRect(rect));
497
+ }
498
+ });
499
+ refs.set("indicatorCleanup", indicatorCleanup);
499
500
  },
500
501
  navigateIfNeeded({ context, prop, scope }) {
501
502
  const value = context.get("value");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/tabs",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Core logic for the tabs widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,12 +26,11 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "1.8.0",
30
- "@zag-js/dom-query": "1.8.0",
31
- "@zag-js/element-rect": "1.8.0",
32
- "@zag-js/utils": "1.8.0",
33
- "@zag-js/core": "1.8.0",
34
- "@zag-js/types": "1.8.0"
29
+ "@zag-js/anatomy": "1.8.2",
30
+ "@zag-js/dom-query": "1.8.2",
31
+ "@zag-js/utils": "1.8.2",
32
+ "@zag-js/core": "1.8.2",
33
+ "@zag-js/types": "1.8.2"
35
34
  },
36
35
  "devDependencies": {
37
36
  "clean-package": "2.2.0"