@zag-js/tooltip 0.0.0-dev-20221005154850 → 0.0.0-dev-20221016081146
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 +27 -1
- package/dist/index.mjs +27 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -96,7 +96,25 @@ function defineDomHelpers(helpers) {
|
|
|
96
96
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
97
97
|
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
98
98
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
99
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
99
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
100
|
+
createEmitter: (ctx, target) => {
|
|
101
|
+
const win = dom2.getWin(ctx);
|
|
102
|
+
return function emit(evt, detail, options) {
|
|
103
|
+
const { bubbles = true, cancelable, composed = true } = options ?? {};
|
|
104
|
+
const eventName = `zag:${evt}`;
|
|
105
|
+
const init = { bubbles, cancelable, composed, detail };
|
|
106
|
+
const event = new win.CustomEvent(eventName, init);
|
|
107
|
+
target.dispatchEvent(event);
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
createListener: (target) => {
|
|
111
|
+
return function listen(evt, handler) {
|
|
112
|
+
const eventName = `zag:${evt}`;
|
|
113
|
+
const listener = (e) => handler(e);
|
|
114
|
+
target.addEventListener(eventName, listener);
|
|
115
|
+
return () => target.removeEventListener(eventName, listener);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
100
118
|
};
|
|
101
119
|
return {
|
|
102
120
|
...dom2,
|
|
@@ -394,6 +412,9 @@ function machine(ctx) {
|
|
|
394
412
|
computed: {
|
|
395
413
|
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
396
414
|
},
|
|
415
|
+
watch: {
|
|
416
|
+
disabled: ["closeIfDisabled"]
|
|
417
|
+
},
|
|
397
418
|
on: {
|
|
398
419
|
OPEN: "open",
|
|
399
420
|
CLOSE: "closed"
|
|
@@ -573,6 +594,11 @@ function machine(ctx) {
|
|
|
573
594
|
if (!omit.includes(evt.type)) {
|
|
574
595
|
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
575
596
|
}
|
|
597
|
+
},
|
|
598
|
+
closeIfDisabled(ctx2, _evt, { send }) {
|
|
599
|
+
if (ctx2.disabled) {
|
|
600
|
+
send("CLOSE");
|
|
601
|
+
}
|
|
576
602
|
}
|
|
577
603
|
},
|
|
578
604
|
guards: {
|
package/dist/index.mjs
CHANGED
|
@@ -69,7 +69,25 @@ function defineDomHelpers(helpers) {
|
|
|
69
69
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
70
70
|
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
71
71
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
72
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
72
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
73
|
+
createEmitter: (ctx, target) => {
|
|
74
|
+
const win = dom2.getWin(ctx);
|
|
75
|
+
return function emit(evt, detail, options) {
|
|
76
|
+
const { bubbles = true, cancelable, composed = true } = options ?? {};
|
|
77
|
+
const eventName = `zag:${evt}`;
|
|
78
|
+
const init = { bubbles, cancelable, composed, detail };
|
|
79
|
+
const event = new win.CustomEvent(eventName, init);
|
|
80
|
+
target.dispatchEvent(event);
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
createListener: (target) => {
|
|
84
|
+
return function listen(evt, handler) {
|
|
85
|
+
const eventName = `zag:${evt}`;
|
|
86
|
+
const listener = (e) => handler(e);
|
|
87
|
+
target.addEventListener(eventName, listener);
|
|
88
|
+
return () => target.removeEventListener(eventName, listener);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
73
91
|
};
|
|
74
92
|
return {
|
|
75
93
|
...dom2,
|
|
@@ -367,6 +385,9 @@ function machine(ctx) {
|
|
|
367
385
|
computed: {
|
|
368
386
|
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
369
387
|
},
|
|
388
|
+
watch: {
|
|
389
|
+
disabled: ["closeIfDisabled"]
|
|
390
|
+
},
|
|
370
391
|
on: {
|
|
371
392
|
OPEN: "open",
|
|
372
393
|
CLOSE: "closed"
|
|
@@ -546,6 +567,11 @@ function machine(ctx) {
|
|
|
546
567
|
if (!omit.includes(evt.type)) {
|
|
547
568
|
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
548
569
|
}
|
|
570
|
+
},
|
|
571
|
+
closeIfDisabled(ctx2, _evt, { send }) {
|
|
572
|
+
if (ctx2.disabled) {
|
|
573
|
+
send("CLOSE");
|
|
574
|
+
}
|
|
549
575
|
}
|
|
550
576
|
},
|
|
551
577
|
guards: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tooltip",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20221016081146",
|
|
4
4
|
"description": "Core logic for the tooltip widget implemented as a state machine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.
|
|
33
|
-
"@zag-js/popper": "0.0.0-dev-
|
|
34
|
-
"@zag-js/types": "0.
|
|
32
|
+
"@zag-js/core": "0.1.12",
|
|
33
|
+
"@zag-js/popper": "0.0.0-dev-20221016081146",
|
|
34
|
+
"@zag-js/types": "0.2.7"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@zag-js/dom-utils": "0.0.0-dev-
|
|
38
|
-
"@zag-js/utils": "0.
|
|
37
|
+
"@zag-js/dom-utils": "0.0.0-dev-20221016081146",
|
|
38
|
+
"@zag-js/utils": "0.1.6"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build-fast": "tsup src/index.ts --format=esm,cjs",
|