@zag-js/tooltip 1.21.9 → 1.22.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
@@ -4,10 +4,9 @@ var anatomy$1 = require('@zag-js/anatomy');
4
4
  var domQuery = require('@zag-js/dom-query');
5
5
  var focusVisible = require('@zag-js/focus-visible');
6
6
  var popper = require('@zag-js/popper');
7
- var store$1 = require('@zag-js/store');
7
+ var utils = require('@zag-js/utils');
8
8
  var core = require('@zag-js/core');
9
9
  var types = require('@zag-js/types');
10
- var utils = require('@zag-js/utils');
11
10
 
12
11
  // src/tooltip.anatomy.ts
13
12
  var anatomy = anatomy$1.createAnatomy("tooltip").parts("trigger", "arrow", "arrowTip", "positioner", "content");
@@ -20,7 +19,7 @@ var getArrowId = (scope) => scope.ids?.arrow ?? `tooltip:${scope.id}:arrow`;
20
19
  var getPositionerId = (scope) => scope.ids?.positioner ?? `tooltip:${scope.id}:popper`;
21
20
  var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
22
21
  var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
23
- var store = store$1.proxy({ id: null });
22
+ var store = utils.createStore({ id: null });
24
23
 
25
24
  // src/tooltip.connect.ts
26
25
  function connect(service, normalize) {
@@ -71,7 +70,7 @@ function connect(service, normalize) {
71
70
  onBlur(event) {
72
71
  if (event.defaultPrevented) return;
73
72
  if (disabled) return;
74
- if (id === store.id) {
73
+ if (id === store.get("id")) {
75
74
  send({ type: "close", src: "trigger.blur" });
76
75
  }
77
76
  },
@@ -80,7 +79,7 @@ function connect(service, normalize) {
80
79
  if (disabled) return;
81
80
  if (!domQuery.isLeftClick(event)) return;
82
81
  if (!prop("closeOnPointerDown")) return;
83
- if (id === store.id) {
82
+ if (id === store.get("id")) {
84
83
  send({ type: "close", src: "trigger.pointerdown" });
85
84
  }
86
85
  },
@@ -152,17 +151,19 @@ var machine = core.createMachine({
152
151
  return open ? "open" : "closed";
153
152
  },
154
153
  props({ props: props2 }) {
154
+ const closeOnClick = props2.closeOnClick ?? true;
155
+ const closeOnPointerDown = props2.closeOnPointerDown ?? closeOnClick;
155
156
  return {
156
157
  id: "x",
157
158
  openDelay: 1e3,
158
159
  closeDelay: 500,
159
- closeOnPointerDown: true,
160
160
  closeOnEscape: true,
161
161
  interactive: false,
162
162
  closeOnScroll: true,
163
- closeOnClick: true,
164
163
  disabled: false,
165
164
  ...props2,
165
+ closeOnPointerDown,
166
+ closeOnClick,
166
167
  positioning: {
167
168
  placement: "bottom",
168
169
  ...props2.positioning
@@ -362,19 +363,19 @@ var machine = core.createMachine({
362
363
  },
363
364
  implementations: {
364
365
  guards: {
365
- noVisibleTooltip: () => store.id === null,
366
- isVisible: ({ prop }) => prop("id") === store.id,
366
+ noVisibleTooltip: () => store.get("id") === null,
367
+ isVisible: ({ prop }) => prop("id") === store.get("id"),
367
368
  isInteractive: ({ prop }) => !!prop("interactive"),
368
369
  hasPointerMoveOpened: ({ context }) => context.get("hasPointerMoveOpened"),
369
370
  isOpenControlled: ({ prop }) => prop("open") !== void 0
370
371
  },
371
372
  actions: {
372
373
  setGlobalId: ({ prop }) => {
373
- store.id = prop("id");
374
+ store.set("id", prop("id"));
374
375
  },
375
376
  clearGlobalId: ({ prop }) => {
376
- if (prop("id") === store.id) {
377
- store.id = null;
377
+ if (prop("id") === store.get("id")) {
378
+ store.set("id", null);
378
379
  }
379
380
  },
380
381
  invokeOnOpen: ({ prop }) => {
@@ -458,8 +459,8 @@ var machine = core.createMachine({
458
459
  trackStore: ({ prop, send }) => {
459
460
  let cleanup;
460
461
  queueMicrotask(() => {
461
- cleanup = store$1.subscribe(store, () => {
462
- if (store.id !== prop("id")) {
462
+ cleanup = store.subscribe(() => {
463
+ if (store.get("id") !== prop("id")) {
463
464
  send({ type: "close", src: "id.change" });
464
465
  }
465
466
  });
package/dist/index.mjs CHANGED
@@ -2,10 +2,9 @@ import { createAnatomy } from '@zag-js/anatomy';
2
2
  import { addDomEvent, getOverflowAncestors, isComposingEvent, dataAttr, isLeftClick } from '@zag-js/dom-query';
3
3
  import { trackFocusVisible, isFocusVisible } from '@zag-js/focus-visible';
4
4
  import { getPlacement, getPlacementStyles } from '@zag-js/popper';
5
- import { proxy, subscribe } from '@zag-js/store';
5
+ import { createStore, createSplitProps } from '@zag-js/utils';
6
6
  import { createGuards, createMachine } from '@zag-js/core';
7
7
  import { createProps } from '@zag-js/types';
8
- import { createSplitProps } from '@zag-js/utils';
9
8
 
10
9
  // src/tooltip.anatomy.ts
11
10
  var anatomy = createAnatomy("tooltip").parts("trigger", "arrow", "arrowTip", "positioner", "content");
@@ -18,7 +17,7 @@ var getArrowId = (scope) => scope.ids?.arrow ?? `tooltip:${scope.id}:arrow`;
18
17
  var getPositionerId = (scope) => scope.ids?.positioner ?? `tooltip:${scope.id}:popper`;
19
18
  var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
20
19
  var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
21
- var store = proxy({ id: null });
20
+ var store = createStore({ id: null });
22
21
 
23
22
  // src/tooltip.connect.ts
24
23
  function connect(service, normalize) {
@@ -69,7 +68,7 @@ function connect(service, normalize) {
69
68
  onBlur(event) {
70
69
  if (event.defaultPrevented) return;
71
70
  if (disabled) return;
72
- if (id === store.id) {
71
+ if (id === store.get("id")) {
73
72
  send({ type: "close", src: "trigger.blur" });
74
73
  }
75
74
  },
@@ -78,7 +77,7 @@ function connect(service, normalize) {
78
77
  if (disabled) return;
79
78
  if (!isLeftClick(event)) return;
80
79
  if (!prop("closeOnPointerDown")) return;
81
- if (id === store.id) {
80
+ if (id === store.get("id")) {
82
81
  send({ type: "close", src: "trigger.pointerdown" });
83
82
  }
84
83
  },
@@ -150,17 +149,19 @@ var machine = createMachine({
150
149
  return open ? "open" : "closed";
151
150
  },
152
151
  props({ props: props2 }) {
152
+ const closeOnClick = props2.closeOnClick ?? true;
153
+ const closeOnPointerDown = props2.closeOnPointerDown ?? closeOnClick;
153
154
  return {
154
155
  id: "x",
155
156
  openDelay: 1e3,
156
157
  closeDelay: 500,
157
- closeOnPointerDown: true,
158
158
  closeOnEscape: true,
159
159
  interactive: false,
160
160
  closeOnScroll: true,
161
- closeOnClick: true,
162
161
  disabled: false,
163
162
  ...props2,
163
+ closeOnPointerDown,
164
+ closeOnClick,
164
165
  positioning: {
165
166
  placement: "bottom",
166
167
  ...props2.positioning
@@ -360,19 +361,19 @@ var machine = createMachine({
360
361
  },
361
362
  implementations: {
362
363
  guards: {
363
- noVisibleTooltip: () => store.id === null,
364
- isVisible: ({ prop }) => prop("id") === store.id,
364
+ noVisibleTooltip: () => store.get("id") === null,
365
+ isVisible: ({ prop }) => prop("id") === store.get("id"),
365
366
  isInteractive: ({ prop }) => !!prop("interactive"),
366
367
  hasPointerMoveOpened: ({ context }) => context.get("hasPointerMoveOpened"),
367
368
  isOpenControlled: ({ prop }) => prop("open") !== void 0
368
369
  },
369
370
  actions: {
370
371
  setGlobalId: ({ prop }) => {
371
- store.id = prop("id");
372
+ store.set("id", prop("id"));
372
373
  },
373
374
  clearGlobalId: ({ prop }) => {
374
- if (prop("id") === store.id) {
375
- store.id = null;
375
+ if (prop("id") === store.get("id")) {
376
+ store.set("id", null);
376
377
  }
377
378
  },
378
379
  invokeOnOpen: ({ prop }) => {
@@ -456,8 +457,8 @@ var machine = createMachine({
456
457
  trackStore: ({ prop, send }) => {
457
458
  let cleanup;
458
459
  queueMicrotask(() => {
459
- cleanup = subscribe(store, () => {
460
- if (store.id !== prop("id")) {
460
+ cleanup = store.subscribe(() => {
461
+ if (store.get("id") !== prop("id")) {
461
462
  send({ type: "close", src: "id.change" });
462
463
  }
463
464
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/tooltip",
3
- "version": "1.21.9",
3
+ "version": "1.22.0",
4
4
  "description": "Core logic for the tooltip widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,14 +26,13 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "1.21.9",
30
- "@zag-js/core": "1.21.9",
31
- "@zag-js/store": "1.21.9",
32
- "@zag-js/popper": "1.21.9",
33
- "@zag-js/focus-visible": "1.21.9",
34
- "@zag-js/dom-query": "1.21.9",
35
- "@zag-js/utils": "1.21.9",
36
- "@zag-js/types": "1.21.9"
29
+ "@zag-js/anatomy": "1.22.0",
30
+ "@zag-js/core": "1.22.0",
31
+ "@zag-js/popper": "1.22.0",
32
+ "@zag-js/focus-visible": "1.22.0",
33
+ "@zag-js/dom-query": "1.22.0",
34
+ "@zag-js/utils": "1.22.0",
35
+ "@zag-js/types": "1.22.0"
37
36
  },
38
37
  "devDependencies": {
39
38
  "clean-package": "2.2.0"