@zag-js/tooltip 0.0.0-dev-20220627213436 → 0.0.0-dev-20220703125047
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 +56 -65
- package/dist/index.mjs +56 -65
- package/dist/tooltip.connect.d.ts +3 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -46,6 +46,50 @@ module.exports = __toCommonJS(src_exports);
|
|
|
46
46
|
var dataAttr = (guard) => {
|
|
47
47
|
return guard ? "" : void 0;
|
|
48
48
|
};
|
|
49
|
+
function getCache() {
|
|
50
|
+
const g = globalThis;
|
|
51
|
+
g.__styleCache__ = g.__styleCache__ || /* @__PURE__ */ new WeakMap();
|
|
52
|
+
return g.__styleCache__;
|
|
53
|
+
}
|
|
54
|
+
function getComputedStyle(el) {
|
|
55
|
+
var _a;
|
|
56
|
+
if (!el)
|
|
57
|
+
return {};
|
|
58
|
+
const cache = getCache();
|
|
59
|
+
let style = cache.get(el);
|
|
60
|
+
if (!style) {
|
|
61
|
+
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
62
|
+
style = win.getComputedStyle(el);
|
|
63
|
+
cache.set(el, style);
|
|
64
|
+
}
|
|
65
|
+
return style;
|
|
66
|
+
}
|
|
67
|
+
function isWindow(value) {
|
|
68
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
69
|
+
}
|
|
70
|
+
function getDocument(el) {
|
|
71
|
+
var _a;
|
|
72
|
+
if (isWindow(el))
|
|
73
|
+
return el.document;
|
|
74
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
75
|
+
}
|
|
76
|
+
function getWindow(el) {
|
|
77
|
+
var _a;
|
|
78
|
+
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
79
|
+
}
|
|
80
|
+
function getNodeName(node) {
|
|
81
|
+
var _a;
|
|
82
|
+
return isWindow(node) ? "" : (_a = node == null ? void 0 : node.localName) != null ? _a : "";
|
|
83
|
+
}
|
|
84
|
+
function getParent(el) {
|
|
85
|
+
const doc = getDocument(el);
|
|
86
|
+
if (getNodeName(el) === "html")
|
|
87
|
+
return el;
|
|
88
|
+
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
89
|
+
}
|
|
90
|
+
function isHTMLElement(v) {
|
|
91
|
+
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
92
|
+
}
|
|
49
93
|
var isDom = () => typeof window !== "undefined";
|
|
50
94
|
var isArray = (v) => Array.isArray(v);
|
|
51
95
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
@@ -59,9 +103,9 @@ var runIfFn = (v, ...a) => {
|
|
|
59
103
|
return res != null ? res : void 0;
|
|
60
104
|
};
|
|
61
105
|
var isRef = (v) => hasProp(v, "current");
|
|
62
|
-
var
|
|
106
|
+
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
63
107
|
function extractInfo(event, type = "page") {
|
|
64
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] ||
|
|
108
|
+
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
65
109
|
return {
|
|
66
110
|
point: {
|
|
67
111
|
x: point[`${type}X`],
|
|
@@ -122,55 +166,6 @@ function getEventName(evt) {
|
|
|
122
166
|
return mouseEventNames[evt];
|
|
123
167
|
return evt;
|
|
124
168
|
}
|
|
125
|
-
function raf(fn) {
|
|
126
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
127
|
-
return function cleanup() {
|
|
128
|
-
globalThis.cancelAnimationFrame(id);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
function getCache() {
|
|
132
|
-
const g = globalThis;
|
|
133
|
-
g.__styleCache__ = g.__styleCache__ || /* @__PURE__ */ new WeakMap();
|
|
134
|
-
return g.__styleCache__;
|
|
135
|
-
}
|
|
136
|
-
function getComputedStyle(el) {
|
|
137
|
-
var _a;
|
|
138
|
-
if (!el)
|
|
139
|
-
return {};
|
|
140
|
-
const cache = getCache();
|
|
141
|
-
let style = cache.get(el);
|
|
142
|
-
if (!style) {
|
|
143
|
-
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
144
|
-
style = win.getComputedStyle(el);
|
|
145
|
-
cache.set(el, style);
|
|
146
|
-
}
|
|
147
|
-
return style;
|
|
148
|
-
}
|
|
149
|
-
function isWindow(value) {
|
|
150
|
-
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
151
|
-
}
|
|
152
|
-
function getOwnerDocument(el) {
|
|
153
|
-
var _a;
|
|
154
|
-
if (isWindow(el))
|
|
155
|
-
return el.document;
|
|
156
|
-
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
157
|
-
}
|
|
158
|
-
function getOwnerWindow(el) {
|
|
159
|
-
var _a;
|
|
160
|
-
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
161
|
-
}
|
|
162
|
-
function getNodeName(node) {
|
|
163
|
-
return isWindow(node) ? "" : node ? node.localName || "" : "";
|
|
164
|
-
}
|
|
165
|
-
function getParent(el) {
|
|
166
|
-
const doc = getOwnerDocument(el);
|
|
167
|
-
if (getNodeName(el) === "html")
|
|
168
|
-
return el;
|
|
169
|
-
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
170
|
-
}
|
|
171
|
-
function isHTMLElement(v) {
|
|
172
|
-
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
173
|
-
}
|
|
174
169
|
var visuallyHiddenStyle = {
|
|
175
170
|
border: "0",
|
|
176
171
|
clip: "rect(0 0 0 0)",
|
|
@@ -183,6 +178,12 @@ var visuallyHiddenStyle = {
|
|
|
183
178
|
whiteSpace: "nowrap",
|
|
184
179
|
wordWrap: "normal"
|
|
185
180
|
};
|
|
181
|
+
function raf(fn) {
|
|
182
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
183
|
+
return function cleanup() {
|
|
184
|
+
globalThis.cancelAnimationFrame(id);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
186
187
|
function addPointerlockChangeListener(doc, fn) {
|
|
187
188
|
return addDomEvent(doc, "pointerlockchange", fn, false);
|
|
188
189
|
}
|
|
@@ -192,7 +193,7 @@ function isScrollParent(el) {
|
|
|
192
193
|
}
|
|
193
194
|
function getScrollParent(el) {
|
|
194
195
|
if (["html", "body", "#document"].includes(getNodeName(el))) {
|
|
195
|
-
return
|
|
196
|
+
return getDocument(el).body;
|
|
196
197
|
}
|
|
197
198
|
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
198
199
|
return el;
|
|
@@ -201,8 +202,8 @@ function getScrollParent(el) {
|
|
|
201
202
|
}
|
|
202
203
|
function getScrollParents(el, list = []) {
|
|
203
204
|
const scrollParent = getScrollParent(el);
|
|
204
|
-
const isBody = scrollParent ===
|
|
205
|
-
const win =
|
|
205
|
+
const isBody = scrollParent === getDocument(el).body;
|
|
206
|
+
const win = getWindow(scrollParent);
|
|
206
207
|
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
207
208
|
const parents = list.concat(target);
|
|
208
209
|
if (isBody)
|
|
@@ -213,16 +214,6 @@ function getScrollParents(el, list = []) {
|
|
|
213
214
|
// src/tooltip.connect.ts
|
|
214
215
|
var import_popper = require("@zag-js/popper");
|
|
215
216
|
|
|
216
|
-
// ../../types/dist/index.mjs
|
|
217
|
-
function createNormalizer(fn) {
|
|
218
|
-
return new Proxy({}, {
|
|
219
|
-
get() {
|
|
220
|
-
return fn;
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
var normalizeProp = createNormalizer((v) => v);
|
|
225
|
-
|
|
226
217
|
// src/tooltip.dom.ts
|
|
227
218
|
var dom = {
|
|
228
219
|
getDoc: (ctx) => {
|
|
@@ -273,7 +264,7 @@ var store = (0, import_core.proxy)({
|
|
|
273
264
|
});
|
|
274
265
|
|
|
275
266
|
// src/tooltip.connect.ts
|
|
276
|
-
function connect(state, send, normalize
|
|
267
|
+
function connect(state, send, normalize) {
|
|
277
268
|
const id = state.context.id;
|
|
278
269
|
const hasAriaLabel = state.context.hasAriaLabel;
|
|
279
270
|
const isOpen = state.hasTag("open");
|
package/dist/index.mjs
CHANGED
|
@@ -23,6 +23,50 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
23
23
|
var dataAttr = (guard) => {
|
|
24
24
|
return guard ? "" : void 0;
|
|
25
25
|
};
|
|
26
|
+
function getCache() {
|
|
27
|
+
const g = globalThis;
|
|
28
|
+
g.__styleCache__ = g.__styleCache__ || /* @__PURE__ */ new WeakMap();
|
|
29
|
+
return g.__styleCache__;
|
|
30
|
+
}
|
|
31
|
+
function getComputedStyle(el) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (!el)
|
|
34
|
+
return {};
|
|
35
|
+
const cache = getCache();
|
|
36
|
+
let style = cache.get(el);
|
|
37
|
+
if (!style) {
|
|
38
|
+
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
39
|
+
style = win.getComputedStyle(el);
|
|
40
|
+
cache.set(el, style);
|
|
41
|
+
}
|
|
42
|
+
return style;
|
|
43
|
+
}
|
|
44
|
+
function isWindow(value) {
|
|
45
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
46
|
+
}
|
|
47
|
+
function getDocument(el) {
|
|
48
|
+
var _a;
|
|
49
|
+
if (isWindow(el))
|
|
50
|
+
return el.document;
|
|
51
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
52
|
+
}
|
|
53
|
+
function getWindow(el) {
|
|
54
|
+
var _a;
|
|
55
|
+
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
56
|
+
}
|
|
57
|
+
function getNodeName(node) {
|
|
58
|
+
var _a;
|
|
59
|
+
return isWindow(node) ? "" : (_a = node == null ? void 0 : node.localName) != null ? _a : "";
|
|
60
|
+
}
|
|
61
|
+
function getParent(el) {
|
|
62
|
+
const doc = getDocument(el);
|
|
63
|
+
if (getNodeName(el) === "html")
|
|
64
|
+
return el;
|
|
65
|
+
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
66
|
+
}
|
|
67
|
+
function isHTMLElement(v) {
|
|
68
|
+
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
69
|
+
}
|
|
26
70
|
var isDom = () => typeof window !== "undefined";
|
|
27
71
|
var isArray = (v) => Array.isArray(v);
|
|
28
72
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
@@ -36,9 +80,9 @@ var runIfFn = (v, ...a) => {
|
|
|
36
80
|
return res != null ? res : void 0;
|
|
37
81
|
};
|
|
38
82
|
var isRef = (v) => hasProp(v, "current");
|
|
39
|
-
var
|
|
83
|
+
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
40
84
|
function extractInfo(event, type = "page") {
|
|
41
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] ||
|
|
85
|
+
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
42
86
|
return {
|
|
43
87
|
point: {
|
|
44
88
|
x: point[`${type}X`],
|
|
@@ -99,55 +143,6 @@ function getEventName(evt) {
|
|
|
99
143
|
return mouseEventNames[evt];
|
|
100
144
|
return evt;
|
|
101
145
|
}
|
|
102
|
-
function raf(fn) {
|
|
103
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
104
|
-
return function cleanup() {
|
|
105
|
-
globalThis.cancelAnimationFrame(id);
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function getCache() {
|
|
109
|
-
const g = globalThis;
|
|
110
|
-
g.__styleCache__ = g.__styleCache__ || /* @__PURE__ */ new WeakMap();
|
|
111
|
-
return g.__styleCache__;
|
|
112
|
-
}
|
|
113
|
-
function getComputedStyle(el) {
|
|
114
|
-
var _a;
|
|
115
|
-
if (!el)
|
|
116
|
-
return {};
|
|
117
|
-
const cache = getCache();
|
|
118
|
-
let style = cache.get(el);
|
|
119
|
-
if (!style) {
|
|
120
|
-
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
121
|
-
style = win.getComputedStyle(el);
|
|
122
|
-
cache.set(el, style);
|
|
123
|
-
}
|
|
124
|
-
return style;
|
|
125
|
-
}
|
|
126
|
-
function isWindow(value) {
|
|
127
|
-
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
128
|
-
}
|
|
129
|
-
function getOwnerDocument(el) {
|
|
130
|
-
var _a;
|
|
131
|
-
if (isWindow(el))
|
|
132
|
-
return el.document;
|
|
133
|
-
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
134
|
-
}
|
|
135
|
-
function getOwnerWindow(el) {
|
|
136
|
-
var _a;
|
|
137
|
-
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
138
|
-
}
|
|
139
|
-
function getNodeName(node) {
|
|
140
|
-
return isWindow(node) ? "" : node ? node.localName || "" : "";
|
|
141
|
-
}
|
|
142
|
-
function getParent(el) {
|
|
143
|
-
const doc = getOwnerDocument(el);
|
|
144
|
-
if (getNodeName(el) === "html")
|
|
145
|
-
return el;
|
|
146
|
-
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
147
|
-
}
|
|
148
|
-
function isHTMLElement(v) {
|
|
149
|
-
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
150
|
-
}
|
|
151
146
|
var visuallyHiddenStyle = {
|
|
152
147
|
border: "0",
|
|
153
148
|
clip: "rect(0 0 0 0)",
|
|
@@ -160,6 +155,12 @@ var visuallyHiddenStyle = {
|
|
|
160
155
|
whiteSpace: "nowrap",
|
|
161
156
|
wordWrap: "normal"
|
|
162
157
|
};
|
|
158
|
+
function raf(fn) {
|
|
159
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
160
|
+
return function cleanup() {
|
|
161
|
+
globalThis.cancelAnimationFrame(id);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
163
164
|
function addPointerlockChangeListener(doc, fn) {
|
|
164
165
|
return addDomEvent(doc, "pointerlockchange", fn, false);
|
|
165
166
|
}
|
|
@@ -169,7 +170,7 @@ function isScrollParent(el) {
|
|
|
169
170
|
}
|
|
170
171
|
function getScrollParent(el) {
|
|
171
172
|
if (["html", "body", "#document"].includes(getNodeName(el))) {
|
|
172
|
-
return
|
|
173
|
+
return getDocument(el).body;
|
|
173
174
|
}
|
|
174
175
|
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
175
176
|
return el;
|
|
@@ -178,8 +179,8 @@ function getScrollParent(el) {
|
|
|
178
179
|
}
|
|
179
180
|
function getScrollParents(el, list = []) {
|
|
180
181
|
const scrollParent = getScrollParent(el);
|
|
181
|
-
const isBody = scrollParent ===
|
|
182
|
-
const win =
|
|
182
|
+
const isBody = scrollParent === getDocument(el).body;
|
|
183
|
+
const win = getWindow(scrollParent);
|
|
183
184
|
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
184
185
|
const parents = list.concat(target);
|
|
185
186
|
if (isBody)
|
|
@@ -190,16 +191,6 @@ function getScrollParents(el, list = []) {
|
|
|
190
191
|
// src/tooltip.connect.ts
|
|
191
192
|
import { getPlacementStyles } from "@zag-js/popper";
|
|
192
193
|
|
|
193
|
-
// ../../types/dist/index.mjs
|
|
194
|
-
function createNormalizer(fn) {
|
|
195
|
-
return new Proxy({}, {
|
|
196
|
-
get() {
|
|
197
|
-
return fn;
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
var normalizeProp = createNormalizer((v) => v);
|
|
202
|
-
|
|
203
194
|
// src/tooltip.dom.ts
|
|
204
195
|
var dom = {
|
|
205
196
|
getDoc: (ctx) => {
|
|
@@ -250,7 +241,7 @@ var store = proxy({
|
|
|
250
241
|
});
|
|
251
242
|
|
|
252
243
|
// src/tooltip.connect.ts
|
|
253
|
-
function connect(state, send, normalize
|
|
244
|
+
function connect(state, send, normalize) {
|
|
254
245
|
const id = state.context.id;
|
|
255
246
|
const hasAriaLabel = state.context.hasAriaLabel;
|
|
256
247
|
const isOpen = state.hasTag("open");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Send, State } from "./tooltip.types";
|
|
3
|
-
export declare function connect<T extends PropTypes
|
|
1
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
|
+
import type { Send, State } from "./tooltip.types";
|
|
3
|
+
export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
open(): void;
|
|
6
6
|
close(): void;
|
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-20220703125047",
|
|
4
4
|
"description": "Core logic for the tooltip widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.0.0-dev-
|
|
33
|
-
"@zag-js/dom-utils": "0.0.0-dev-
|
|
34
|
-
"@zag-js/popper": "0.0.0-dev-
|
|
35
|
-
"@zag-js/types": "0.
|
|
32
|
+
"@zag-js/core": "0.0.0-dev-20220703125047",
|
|
33
|
+
"@zag-js/dom-utils": "0.0.0-dev-20220703125047",
|
|
34
|
+
"@zag-js/popper": "0.0.0-dev-20220703125047",
|
|
35
|
+
"@zag-js/types": "0.0.0-dev-20220703125047"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build:fast": "zag build",
|