@zag-js/tooltip 1.43.0 → 2.0.0-next.1

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.d.mts CHANGED
@@ -2,7 +2,7 @@ export { anatomy } from './tooltip.anatomy.mjs';
2
2
  export { connect } from './tooltip.connect.mjs';
3
3
  export { machine } from './tooltip.machine.mjs';
4
4
  export { props, splitProps } from './tooltip.props.mjs';
5
- export { TooltipApi as Api, ElementIds, TooltipMachine as Machine, OpenChangeDetails, TooltipProps as Props, TooltipService as Service, TriggerProps, TriggerValueChangeDetails } from './tooltip.types.mjs';
5
+ export { TooltipApi as Api, ContentState, ElementIds, TooltipMachine as Machine, OpenChangeDetails, TooltipProps as Props, TooltipService as Service, TriggerProps, TriggerState, TriggerValueChangeDetails } from './tooltip.types.mjs';
6
6
  export { Placement, PositioningOptions } from '@zag-js/popper';
7
7
  import '@zag-js/anatomy';
8
8
  import '@zag-js/core';
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { anatomy } from './tooltip.anatomy.js';
2
2
  export { connect } from './tooltip.connect.js';
3
3
  export { machine } from './tooltip.machine.js';
4
4
  export { props, splitProps } from './tooltip.props.js';
5
- export { TooltipApi as Api, ElementIds, TooltipMachine as Machine, OpenChangeDetails, TooltipProps as Props, TooltipService as Service, TriggerProps, TriggerValueChangeDetails } from './tooltip.types.js';
5
+ export { TooltipApi as Api, ContentState, ElementIds, TooltipMachine as Machine, OpenChangeDetails, TooltipProps as Props, TooltipService as Service, TriggerProps, TriggerState, TriggerValueChangeDetails } from './tooltip.types.js';
6
6
  export { Placement, PositioningOptions } from '@zag-js/popper';
7
7
  import '@zag-js/anatomy';
8
8
  import '@zag-js/core';
@@ -53,6 +53,17 @@ function connect(service, normalize) {
53
53
  ...prop("positioning"),
54
54
  placement: currentPlacement
55
55
  });
56
+ function getTriggerState(props = {}) {
57
+ const { value } = props;
58
+ const current = value == null ? false : triggerValue === value;
59
+ return { value, current, open: value == null ? open : open && current };
60
+ }
61
+ function getContentState() {
62
+ const isCurrentTooltip = import_tooltip2.store.get("id") === id;
63
+ const isPrevTooltip = import_tooltip2.store.get("prevId") === id;
64
+ const instant = !!import_tooltip2.store.get("instant") && (open && isCurrentTooltip || isPrevTooltip);
65
+ return { open, instant, placement: currentPlacement, side: currentPlacementSide };
66
+ }
56
67
  return {
57
68
  open,
58
69
  setOpen(nextOpen) {
@@ -67,14 +78,14 @@ function connect(service, normalize) {
67
78
  reposition(options = {}) {
68
79
  send({ type: "positioning.set", options });
69
80
  },
81
+ getTriggerState,
70
82
  getTriggerProps(props = {}) {
71
83
  const { value } = props;
72
- const current = value == null ? false : triggerValue === value;
84
+ const { current } = getTriggerState(props);
73
85
  const triggerId = dom.getTriggerId(scope, value);
74
86
  return normalize.button({
75
- ...import_tooltip.parts.trigger.attrs,
87
+ ...import_tooltip.parts.trigger.attrs(scope.id),
76
88
  id: triggerId,
77
- "data-ownedby": scope.id,
78
89
  "data-value": value,
79
90
  "data-current": (0, import_dom_query.dataAttr)(current),
80
91
  dir: prop("dir"),
@@ -100,7 +111,7 @@ function connect(service, normalize) {
100
111
  if (disabled) return;
101
112
  if (id !== import_tooltip2.store.get("id")) return;
102
113
  const activeEl = event.relatedTarget ?? scope.getDoc().activeElement;
103
- const focusedAnotherTrigger = activeEl?.closest((0, import_dom_query.getByOwnerId)(scope.id)) != null;
114
+ const focusedAnotherTrigger = activeEl?.closest(`[${import_tooltip.parts.trigger.attr}="${scope.id}"]`) != null;
104
115
  if (!focusedAnotherTrigger) {
105
116
  send({ type: "close", src: "trigger.blur", value, triggerId });
106
117
  }
@@ -139,41 +150,38 @@ function connect(service, normalize) {
139
150
  },
140
151
  getArrowProps() {
141
152
  return normalize.element({
142
- id: dom.getArrowId(scope),
143
- ...import_tooltip.parts.arrow.attrs,
153
+ ...import_tooltip.parts.arrow.attrs(scope.id),
144
154
  dir: prop("dir"),
145
155
  style: popperStyles.arrow
146
156
  });
147
157
  },
148
158
  getArrowTipProps() {
149
159
  return normalize.element({
150
- ...import_tooltip.parts.arrowTip.attrs,
160
+ ...import_tooltip.parts.arrowTip.attrs(scope.id),
151
161
  dir: prop("dir"),
152
162
  style: popperStyles.arrowTip
153
163
  });
154
164
  },
155
165
  getPositionerProps() {
156
166
  return normalize.element({
157
- id: dom.getPositionerId(scope),
158
- ...import_tooltip.parts.positioner.attrs,
167
+ ...import_tooltip.parts.positioner.attrs(scope.id),
159
168
  dir: prop("dir"),
160
169
  style: popperStyles.floating
161
170
  });
162
171
  },
172
+ getContentState,
163
173
  getContentProps() {
164
- const isCurrentTooltip = import_tooltip2.store.get("id") === id;
165
- const isPrevTooltip = import_tooltip2.store.get("prevId") === id;
166
- const instant = import_tooltip2.store.get("instant") && (open && isCurrentTooltip || isPrevTooltip);
174
+ const contentState = getContentState();
167
175
  return normalize.element({
168
- ...import_tooltip.parts.content.attrs,
176
+ ...import_tooltip.parts.content.attrs(scope.id),
169
177
  dir: prop("dir"),
170
- hidden: !open,
171
- "data-state": open ? "open" : "closed",
172
- "data-instant": (0, import_dom_query.dataAttr)(instant),
178
+ hidden: !contentState.open,
179
+ "data-state": contentState.open ? "open" : "closed",
180
+ "data-instant": (0, import_dom_query.dataAttr)(contentState.instant),
173
181
  role: hasAriaLabel ? void 0 : "tooltip",
174
182
  id: hasAriaLabel ? void 0 : contentId,
175
- "data-placement": currentPlacement,
176
- "data-side": currentPlacementSide,
183
+ "data-placement": contentState.placement,
184
+ "data-side": contentState.side,
177
185
  onPointerEnter() {
178
186
  send({ type: "content.pointer.move" });
179
187
  },
@@ -1,5 +1,5 @@
1
1
  // src/tooltip.connect.ts
2
- import { dataAttr, getByOwnerId, isLeftClick } from "@zag-js/dom-query";
2
+ import { dataAttr, isLeftClick } from "@zag-js/dom-query";
3
3
  import { isFocusVisible } from "@zag-js/focus-visible";
4
4
  import { getPlacementSide, getPlacementStyles } from "@zag-js/popper";
5
5
  import { parts } from "./tooltip.anatomy.mjs";
@@ -19,6 +19,17 @@ function connect(service, normalize) {
19
19
  ...prop("positioning"),
20
20
  placement: currentPlacement
21
21
  });
22
+ function getTriggerState(props = {}) {
23
+ const { value } = props;
24
+ const current = value == null ? false : triggerValue === value;
25
+ return { value, current, open: value == null ? open : open && current };
26
+ }
27
+ function getContentState() {
28
+ const isCurrentTooltip = store.get("id") === id;
29
+ const isPrevTooltip = store.get("prevId") === id;
30
+ const instant = !!store.get("instant") && (open && isCurrentTooltip || isPrevTooltip);
31
+ return { open, instant, placement: currentPlacement, side: currentPlacementSide };
32
+ }
22
33
  return {
23
34
  open,
24
35
  setOpen(nextOpen) {
@@ -33,14 +44,14 @@ function connect(service, normalize) {
33
44
  reposition(options = {}) {
34
45
  send({ type: "positioning.set", options });
35
46
  },
47
+ getTriggerState,
36
48
  getTriggerProps(props = {}) {
37
49
  const { value } = props;
38
- const current = value == null ? false : triggerValue === value;
50
+ const { current } = getTriggerState(props);
39
51
  const triggerId = dom.getTriggerId(scope, value);
40
52
  return normalize.button({
41
- ...parts.trigger.attrs,
53
+ ...parts.trigger.attrs(scope.id),
42
54
  id: triggerId,
43
- "data-ownedby": scope.id,
44
55
  "data-value": value,
45
56
  "data-current": dataAttr(current),
46
57
  dir: prop("dir"),
@@ -66,7 +77,7 @@ function connect(service, normalize) {
66
77
  if (disabled) return;
67
78
  if (id !== store.get("id")) return;
68
79
  const activeEl = event.relatedTarget ?? scope.getDoc().activeElement;
69
- const focusedAnotherTrigger = activeEl?.closest(getByOwnerId(scope.id)) != null;
80
+ const focusedAnotherTrigger = activeEl?.closest(`[${parts.trigger.attr}="${scope.id}"]`) != null;
70
81
  if (!focusedAnotherTrigger) {
71
82
  send({ type: "close", src: "trigger.blur", value, triggerId });
72
83
  }
@@ -105,41 +116,38 @@ function connect(service, normalize) {
105
116
  },
106
117
  getArrowProps() {
107
118
  return normalize.element({
108
- id: dom.getArrowId(scope),
109
- ...parts.arrow.attrs,
119
+ ...parts.arrow.attrs(scope.id),
110
120
  dir: prop("dir"),
111
121
  style: popperStyles.arrow
112
122
  });
113
123
  },
114
124
  getArrowTipProps() {
115
125
  return normalize.element({
116
- ...parts.arrowTip.attrs,
126
+ ...parts.arrowTip.attrs(scope.id),
117
127
  dir: prop("dir"),
118
128
  style: popperStyles.arrowTip
119
129
  });
120
130
  },
121
131
  getPositionerProps() {
122
132
  return normalize.element({
123
- id: dom.getPositionerId(scope),
124
- ...parts.positioner.attrs,
133
+ ...parts.positioner.attrs(scope.id),
125
134
  dir: prop("dir"),
126
135
  style: popperStyles.floating
127
136
  });
128
137
  },
138
+ getContentState,
129
139
  getContentProps() {
130
- const isCurrentTooltip = store.get("id") === id;
131
- const isPrevTooltip = store.get("prevId") === id;
132
- const instant = store.get("instant") && (open && isCurrentTooltip || isPrevTooltip);
140
+ const contentState = getContentState();
133
141
  return normalize.element({
134
- ...parts.content.attrs,
142
+ ...parts.content.attrs(scope.id),
135
143
  dir: prop("dir"),
136
- hidden: !open,
137
- "data-state": open ? "open" : "closed",
138
- "data-instant": dataAttr(instant),
144
+ hidden: !contentState.open,
145
+ "data-state": contentState.open ? "open" : "closed",
146
+ "data-instant": dataAttr(contentState.instant),
139
147
  role: hasAriaLabel ? void 0 : "tooltip",
140
148
  id: hasAriaLabel ? void 0 : contentId,
141
- "data-placement": currentPlacement,
142
- "data-side": currentPlacementSide,
149
+ "data-placement": contentState.placement,
150
+ "data-side": contentState.side,
143
151
  onPointerEnter() {
144
152
  send({ type: "content.pointer.move" });
145
153
  },
@@ -32,26 +32,24 @@ __export(tooltip_dom_exports, {
32
32
  getTriggerId: () => getTriggerId
33
33
  });
34
34
  module.exports = __toCommonJS(tooltip_dom_exports);
35
- var import_dom_query = require("@zag-js/dom-query");
36
35
  var import_utils = require("@zag-js/utils");
36
+ var import_tooltip = require("./tooltip.anatomy.js");
37
37
  var getTriggerId = (scope, value) => {
38
38
  const customId = scope.ids?.trigger;
39
39
  if (customId != null) return (0, import_utils.isFunction)(customId) ? customId(value) : customId;
40
- return value ? `tooltip:${scope.id}:trigger:${value}` : `tooltip:${scope.id}:trigger`;
40
+ return value ? `${scope.id}:trigger:${value}` : `${scope.id}:trigger`;
41
41
  };
42
- var getContentId = (scope) => scope.ids?.content ?? `tooltip:${scope.id}:content`;
43
- var getArrowId = (scope) => scope.ids?.arrow ?? `tooltip:${scope.id}:arrow`;
44
- var getPositionerId = (scope) => scope.ids?.positioner ?? `tooltip:${scope.id}:popper`;
45
- var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
46
- var getContentEl = (scope) => scope.getById(getContentId(scope));
47
- var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
48
- var getArrowEl = (scope) => scope.getById(getArrowId(scope));
49
- var getTriggerEls = (scope) => (0, import_dom_query.queryAll)(scope.getRootNode(), `[data-scope="tooltip"][data-part="trigger"]${(0, import_dom_query.getByOwnerId)(scope.id)}`);
42
+ var getContentId = (scope) => scope.ids?.content ?? `${scope.id}:content`;
43
+ var getArrowId = (scope) => scope.ids?.arrow ?? `${scope.id}:arrow`;
44
+ var getPositionerId = (scope) => scope.ids?.positioner ?? `${scope.id}:popper`;
45
+ var getTriggerEl = (scope) => scope.query(scope.selector(import_tooltip.parts.trigger));
46
+ var getContentEl = (scope) => scope.query(scope.selector(import_tooltip.parts.content));
47
+ var getPositionerEl = (scope) => scope.query(scope.selector(import_tooltip.parts.positioner));
48
+ var getArrowEl = (scope) => scope.query(scope.selector(import_tooltip.parts.arrow));
49
+ var getTriggerEls = (scope) => scope.queryAll(scope.selector(import_tooltip.parts.trigger));
50
50
  var getActiveTriggerEl = (scope, value) => {
51
- if (value == null) {
52
- return getTriggerEl(scope) ?? getTriggerEls(scope)[0];
53
- }
54
- return scope.getById(getTriggerId(scope, value));
51
+ if (value == null) return getTriggerEls(scope)[0];
52
+ return scope.query(`${scope.selector(import_tooltip.parts.trigger)}[data-value="${value}"]`);
55
53
  };
56
54
  // Annotate the CommonJS export names for ESM import in node:
57
55
  0 && (module.exports = {
@@ -1,24 +1,22 @@
1
1
  // src/tooltip.dom.ts
2
- import { getByOwnerId, queryAll } from "@zag-js/dom-query";
3
2
  import { isFunction } from "@zag-js/utils";
3
+ import { parts } from "./tooltip.anatomy.mjs";
4
4
  var getTriggerId = (scope, value) => {
5
5
  const customId = scope.ids?.trigger;
6
6
  if (customId != null) return isFunction(customId) ? customId(value) : customId;
7
- return value ? `tooltip:${scope.id}:trigger:${value}` : `tooltip:${scope.id}:trigger`;
7
+ return value ? `${scope.id}:trigger:${value}` : `${scope.id}:trigger`;
8
8
  };
9
- var getContentId = (scope) => scope.ids?.content ?? `tooltip:${scope.id}:content`;
10
- var getArrowId = (scope) => scope.ids?.arrow ?? `tooltip:${scope.id}:arrow`;
11
- var getPositionerId = (scope) => scope.ids?.positioner ?? `tooltip:${scope.id}:popper`;
12
- var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
13
- var getContentEl = (scope) => scope.getById(getContentId(scope));
14
- var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
15
- var getArrowEl = (scope) => scope.getById(getArrowId(scope));
16
- var getTriggerEls = (scope) => queryAll(scope.getRootNode(), `[data-scope="tooltip"][data-part="trigger"]${getByOwnerId(scope.id)}`);
9
+ var getContentId = (scope) => scope.ids?.content ?? `${scope.id}:content`;
10
+ var getArrowId = (scope) => scope.ids?.arrow ?? `${scope.id}:arrow`;
11
+ var getPositionerId = (scope) => scope.ids?.positioner ?? `${scope.id}:popper`;
12
+ var getTriggerEl = (scope) => scope.query(scope.selector(parts.trigger));
13
+ var getContentEl = (scope) => scope.query(scope.selector(parts.content));
14
+ var getPositionerEl = (scope) => scope.query(scope.selector(parts.positioner));
15
+ var getArrowEl = (scope) => scope.query(scope.selector(parts.arrow));
16
+ var getTriggerEls = (scope) => scope.queryAll(scope.selector(parts.trigger));
17
17
  var getActiveTriggerEl = (scope, value) => {
18
- if (value == null) {
19
- return getTriggerEl(scope) ?? getTriggerEls(scope)[0];
20
- }
21
- return scope.getById(getTriggerId(scope, value));
18
+ if (value == null) return getTriggerEls(scope)[0];
19
+ return scope.query(`${scope.selector(parts.trigger)}[data-value="${value}"]`);
22
20
  };
23
21
  export {
24
22
  getActiveTriggerEl,
@@ -298,10 +298,10 @@ var machine = (0, import_core.createMachine)({
298
298
  isOpenControlled: ({ prop }) => prop("open") !== void 0
299
299
  },
300
300
  actions: {
301
- setGlobalId: ({ prop }) => {
301
+ setGlobalId: ({ prop, event }) => {
302
302
  const prevId = import_tooltip.store.get("id");
303
- const isInstant = prevId !== null && prevId !== prop("id");
304
- import_tooltip.store.update({ id: prop("id"), prevId: isInstant ? prevId : null, instant: isInstant });
303
+ const isInstant = event.src === "trigger.focus" || prevId !== null && prevId !== prop("id");
304
+ import_tooltip.store.update({ id: prop("id"), prevId: isInstant && prevId !== null ? prevId : null, instant: isInstant });
305
305
  },
306
306
  clearGlobalId: ({ prop }) => {
307
307
  if (prop("id") === import_tooltip.store.get("id")) {
@@ -413,7 +413,8 @@ var machine = (0, import_core.createMachine)({
413
413
  let cleanup;
414
414
  queueMicrotask(() => {
415
415
  cleanup = import_tooltip.store.subscribe(() => {
416
- if (import_tooltip.store.get("id") !== prop("id")) {
416
+ const id = import_tooltip.store.get("id");
417
+ if (id !== null && id !== prop("id")) {
417
418
  send({ type: "close", src: "id.change" });
418
419
  }
419
420
  });
@@ -264,10 +264,10 @@ var machine = createMachine({
264
264
  isOpenControlled: ({ prop }) => prop("open") !== void 0
265
265
  },
266
266
  actions: {
267
- setGlobalId: ({ prop }) => {
267
+ setGlobalId: ({ prop, event }) => {
268
268
  const prevId = store.get("id");
269
- const isInstant = prevId !== null && prevId !== prop("id");
270
- store.update({ id: prop("id"), prevId: isInstant ? prevId : null, instant: isInstant });
269
+ const isInstant = event.src === "trigger.focus" || prevId !== null && prevId !== prop("id");
270
+ store.update({ id: prop("id"), prevId: isInstant && prevId !== null ? prevId : null, instant: isInstant });
271
271
  },
272
272
  clearGlobalId: ({ prop }) => {
273
273
  if (prop("id") === store.get("id")) {
@@ -379,7 +379,8 @@ var machine = createMachine({
379
379
  let cleanup;
380
380
  queueMicrotask(() => {
381
381
  cleanup = store.subscribe(() => {
382
- if (store.get("id") !== prop("id")) {
382
+ const id = store.get("id");
383
+ if (id !== null && id !== prop("id")) {
383
384
  send({ type: "close", src: "id.change" });
384
385
  }
385
386
  });
@@ -1,5 +1,5 @@
1
1
  import { Machine, EventObject, Service } from '@zag-js/core';
2
- import { PositioningOptions, Placement } from '@zag-js/popper';
2
+ import { PositioningOptions, Placement, PlacementSide } from '@zag-js/popper';
3
3
  export { Placement, PositioningOptions } from '@zag-js/popper';
4
4
  import { PropTypes, RequiredBy, DirectionProperty, CommonProperties } from '@zag-js/types';
5
5
 
@@ -126,6 +126,38 @@ interface TriggerProps {
126
126
  */
127
127
  value?: string;
128
128
  }
129
+ interface TriggerState {
130
+ /**
131
+ * The value that identifies this specific trigger
132
+ */
133
+ value: string | undefined;
134
+ /**
135
+ * Whether this trigger is the one that opened the tooltip
136
+ */
137
+ current: boolean;
138
+ /**
139
+ * Whether the tooltip is open
140
+ */
141
+ open: boolean;
142
+ }
143
+ interface ContentState {
144
+ /**
145
+ * Whether the tooltip is open
146
+ */
147
+ open: boolean;
148
+ /**
149
+ * Whether the tooltip should skip its enter animation, following a rapid switch between triggers
150
+ */
151
+ instant: boolean;
152
+ /**
153
+ * The current placement of the content relative to the trigger
154
+ */
155
+ placement: Placement | undefined;
156
+ /**
157
+ * The side of the trigger the content is placed on
158
+ */
159
+ side: PlacementSide | undefined;
160
+ }
129
161
  interface TooltipApi<T extends PropTypes = PropTypes> {
130
162
  /**
131
163
  * Whether the tooltip is open.
@@ -147,11 +179,19 @@ interface TooltipApi<T extends PropTypes = PropTypes> {
147
179
  * Function to reposition the popover
148
180
  */
149
181
  reposition: (options?: Partial<PositioningOptions>) => void;
182
+ /**
183
+ * Returns the state of a specific trigger, including whether it's the currently active one
184
+ */
185
+ getTriggerState: (props?: TriggerProps) => TriggerState;
150
186
  getTriggerProps: (props?: TriggerProps) => T["button"];
151
187
  getArrowProps: () => T["element"];
152
188
  getArrowTipProps: () => T["element"];
153
189
  getPositionerProps: () => T["element"];
190
+ /**
191
+ * Returns the state of the content
192
+ */
193
+ getContentState: () => ContentState;
154
194
  getContentProps: () => T["element"];
155
195
  }
156
196
 
157
- export type { ElementIds, OpenChangeDetails, TooltipApi, TooltipMachine, TooltipProps, TooltipSchema, TooltipService, TriggerProps, TriggerValueChangeDetails };
197
+ export type { ContentState, ElementIds, OpenChangeDetails, TooltipApi, TooltipMachine, TooltipProps, TooltipSchema, TooltipService, TriggerProps, TriggerState, TriggerValueChangeDetails };
@@ -1,5 +1,5 @@
1
1
  import { Machine, EventObject, Service } from '@zag-js/core';
2
- import { PositioningOptions, Placement } from '@zag-js/popper';
2
+ import { PositioningOptions, Placement, PlacementSide } from '@zag-js/popper';
3
3
  export { Placement, PositioningOptions } from '@zag-js/popper';
4
4
  import { PropTypes, RequiredBy, DirectionProperty, CommonProperties } from '@zag-js/types';
5
5
 
@@ -126,6 +126,38 @@ interface TriggerProps {
126
126
  */
127
127
  value?: string;
128
128
  }
129
+ interface TriggerState {
130
+ /**
131
+ * The value that identifies this specific trigger
132
+ */
133
+ value: string | undefined;
134
+ /**
135
+ * Whether this trigger is the one that opened the tooltip
136
+ */
137
+ current: boolean;
138
+ /**
139
+ * Whether the tooltip is open
140
+ */
141
+ open: boolean;
142
+ }
143
+ interface ContentState {
144
+ /**
145
+ * Whether the tooltip is open
146
+ */
147
+ open: boolean;
148
+ /**
149
+ * Whether the tooltip should skip its enter animation, following a rapid switch between triggers
150
+ */
151
+ instant: boolean;
152
+ /**
153
+ * The current placement of the content relative to the trigger
154
+ */
155
+ placement: Placement | undefined;
156
+ /**
157
+ * The side of the trigger the content is placed on
158
+ */
159
+ side: PlacementSide | undefined;
160
+ }
129
161
  interface TooltipApi<T extends PropTypes = PropTypes> {
130
162
  /**
131
163
  * Whether the tooltip is open.
@@ -147,11 +179,19 @@ interface TooltipApi<T extends PropTypes = PropTypes> {
147
179
  * Function to reposition the popover
148
180
  */
149
181
  reposition: (options?: Partial<PositioningOptions>) => void;
182
+ /**
183
+ * Returns the state of a specific trigger, including whether it's the currently active one
184
+ */
185
+ getTriggerState: (props?: TriggerProps) => TriggerState;
150
186
  getTriggerProps: (props?: TriggerProps) => T["button"];
151
187
  getArrowProps: () => T["element"];
152
188
  getArrowTipProps: () => T["element"];
153
189
  getPositionerProps: () => T["element"];
190
+ /**
191
+ * Returns the state of the content
192
+ */
193
+ getContentState: () => ContentState;
154
194
  getContentProps: () => T["element"];
155
195
  }
156
196
 
157
- export type { ElementIds, OpenChangeDetails, TooltipApi, TooltipMachine, TooltipProps, TooltipSchema, TooltipService, TriggerProps, TriggerValueChangeDetails };
197
+ export type { ContentState, ElementIds, OpenChangeDetails, TooltipApi, TooltipMachine, TooltipProps, TooltipSchema, TooltipService, TriggerProps, TriggerState, TriggerValueChangeDetails };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/tooltip",
3
- "version": "1.43.0",
3
+ "version": "2.0.0-next.1",
4
4
  "description": "Core logic for the tooltip widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,13 +29,13 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/anatomy": "1.43.0",
33
- "@zag-js/core": "1.43.0",
34
- "@zag-js/popper": "1.43.0",
35
- "@zag-js/focus-visible": "1.43.0",
36
- "@zag-js/dom-query": "1.43.0",
37
- "@zag-js/utils": "1.43.0",
38
- "@zag-js/types": "1.43.0"
32
+ "@zag-js/anatomy": "2.0.0-next.1",
33
+ "@zag-js/core": "2.0.0-next.1",
34
+ "@zag-js/popper": "2.0.0-next.1",
35
+ "@zag-js/focus-visible": "2.0.0-next.1",
36
+ "@zag-js/dom-query": "2.0.0-next.1",
37
+ "@zag-js/utils": "2.0.0-next.1",
38
+ "@zag-js/types": "2.0.0-next.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "clean-package": "2.2.0"