@zag-js/tooltip 1.32.0 → 1.33.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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -3
- package/dist/index.mjs +13 -3
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
2
|
import * as _zag_js_core from '@zag-js/core';
|
|
3
|
-
import {
|
|
4
|
-
import { RequiredBy, DirectionProperty, CommonProperties,
|
|
3
|
+
import { Machine, EventObject, Service } from '@zag-js/core';
|
|
4
|
+
import { PropTypes, RequiredBy, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
5
5
|
import { PositioningOptions, Placement } from '@zag-js/popper';
|
|
6
6
|
export { Placement, PositioningOptions } from '@zag-js/popper';
|
|
7
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
2
|
import * as _zag_js_core from '@zag-js/core';
|
|
3
|
-
import {
|
|
4
|
-
import { RequiredBy, DirectionProperty, CommonProperties,
|
|
3
|
+
import { Machine, EventObject, Service } from '@zag-js/core';
|
|
4
|
+
import { PropTypes, RequiredBy, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
5
5
|
import { PositioningOptions, Placement } from '@zag-js/popper';
|
|
6
6
|
export { Placement, PositioningOptions } from '@zag-js/popper';
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,11 @@ var getArrowId = (scope) => scope.ids?.arrow ?? `tooltip:${scope.id}:arrow`;
|
|
|
19
19
|
var getPositionerId = (scope) => scope.ids?.positioner ?? `tooltip:${scope.id}:popper`;
|
|
20
20
|
var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
|
|
21
21
|
var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
|
|
22
|
-
var store = utils.createStore({
|
|
22
|
+
var store = utils.createStore({
|
|
23
|
+
id: null,
|
|
24
|
+
prevId: null,
|
|
25
|
+
instant: false
|
|
26
|
+
});
|
|
23
27
|
|
|
24
28
|
// src/tooltip.connect.ts
|
|
25
29
|
function connect(service, normalize) {
|
|
@@ -129,11 +133,15 @@ function connect(service, normalize) {
|
|
|
129
133
|
});
|
|
130
134
|
},
|
|
131
135
|
getContentProps() {
|
|
136
|
+
const isCurrentTooltip = store.get("id") === id;
|
|
137
|
+
const isPrevTooltip = store.get("prevId") === id;
|
|
138
|
+
const instant = store.get("instant") && (open && isCurrentTooltip || isPrevTooltip);
|
|
132
139
|
return normalize.element({
|
|
133
140
|
...parts.content.attrs,
|
|
134
141
|
dir: prop("dir"),
|
|
135
142
|
hidden: !open,
|
|
136
143
|
"data-state": open ? "open" : "closed",
|
|
144
|
+
"data-instant": domQuery.dataAttr(instant),
|
|
137
145
|
role: hasAriaLabel ? void 0 : "tooltip",
|
|
138
146
|
id: hasAriaLabel ? void 0 : contentId,
|
|
139
147
|
"data-placement": context.get("currentPlacement"),
|
|
@@ -377,11 +385,13 @@ var machine = core.createMachine({
|
|
|
377
385
|
},
|
|
378
386
|
actions: {
|
|
379
387
|
setGlobalId: ({ prop }) => {
|
|
380
|
-
store.
|
|
388
|
+
const prevId = store.get("id");
|
|
389
|
+
const isInstant = prevId !== null && prevId !== prop("id");
|
|
390
|
+
store.update({ id: prop("id"), prevId: isInstant ? prevId : null, instant: isInstant });
|
|
381
391
|
},
|
|
382
392
|
clearGlobalId: ({ prop }) => {
|
|
383
393
|
if (prop("id") === store.get("id")) {
|
|
384
|
-
store.
|
|
394
|
+
store.update({ id: null, prevId: null, instant: false });
|
|
385
395
|
}
|
|
386
396
|
},
|
|
387
397
|
invokeOnOpen: ({ prop }) => {
|
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,11 @@ var getArrowId = (scope) => scope.ids?.arrow ?? `tooltip:${scope.id}:arrow`;
|
|
|
17
17
|
var getPositionerId = (scope) => scope.ids?.positioner ?? `tooltip:${scope.id}:popper`;
|
|
18
18
|
var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
|
|
19
19
|
var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
|
|
20
|
-
var store = createStore({
|
|
20
|
+
var store = createStore({
|
|
21
|
+
id: null,
|
|
22
|
+
prevId: null,
|
|
23
|
+
instant: false
|
|
24
|
+
});
|
|
21
25
|
|
|
22
26
|
// src/tooltip.connect.ts
|
|
23
27
|
function connect(service, normalize) {
|
|
@@ -127,11 +131,15 @@ function connect(service, normalize) {
|
|
|
127
131
|
});
|
|
128
132
|
},
|
|
129
133
|
getContentProps() {
|
|
134
|
+
const isCurrentTooltip = store.get("id") === id;
|
|
135
|
+
const isPrevTooltip = store.get("prevId") === id;
|
|
136
|
+
const instant = store.get("instant") && (open && isCurrentTooltip || isPrevTooltip);
|
|
130
137
|
return normalize.element({
|
|
131
138
|
...parts.content.attrs,
|
|
132
139
|
dir: prop("dir"),
|
|
133
140
|
hidden: !open,
|
|
134
141
|
"data-state": open ? "open" : "closed",
|
|
142
|
+
"data-instant": dataAttr(instant),
|
|
135
143
|
role: hasAriaLabel ? void 0 : "tooltip",
|
|
136
144
|
id: hasAriaLabel ? void 0 : contentId,
|
|
137
145
|
"data-placement": context.get("currentPlacement"),
|
|
@@ -375,11 +383,13 @@ var machine = createMachine({
|
|
|
375
383
|
},
|
|
376
384
|
actions: {
|
|
377
385
|
setGlobalId: ({ prop }) => {
|
|
378
|
-
store.
|
|
386
|
+
const prevId = store.get("id");
|
|
387
|
+
const isInstant = prevId !== null && prevId !== prop("id");
|
|
388
|
+
store.update({ id: prop("id"), prevId: isInstant ? prevId : null, instant: isInstant });
|
|
379
389
|
},
|
|
380
390
|
clearGlobalId: ({ prop }) => {
|
|
381
391
|
if (prop("id") === store.get("id")) {
|
|
382
|
-
store.
|
|
392
|
+
store.update({ id: null, prevId: null, instant: false });
|
|
383
393
|
}
|
|
384
394
|
},
|
|
385
395
|
invokeOnOpen: ({ prop }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tooltip",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.1",
|
|
4
4
|
"description": "Core logic for the tooltip widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zag-js/anatomy": "1.
|
|
30
|
-
"@zag-js/
|
|
31
|
-
"@zag-js/
|
|
32
|
-
"@zag-js/
|
|
33
|
-
"@zag-js/dom-query": "1.
|
|
34
|
-
"@zag-js/utils": "1.
|
|
35
|
-
"@zag-js/types": "1.
|
|
29
|
+
"@zag-js/anatomy": "1.33.1",
|
|
30
|
+
"@zag-js/core": "1.33.1",
|
|
31
|
+
"@zag-js/popper": "1.33.1",
|
|
32
|
+
"@zag-js/focus-visible": "1.33.1",
|
|
33
|
+
"@zag-js/dom-query": "1.33.1",
|
|
34
|
+
"@zag-js/utils": "1.33.1",
|
|
35
|
+
"@zag-js/types": "1.33.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"clean-package": "2.2.0"
|