@zag-js/tooltip 0.0.0-dev-20220616105142 → 0.0.0-dev-20220617070002
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 +7 -68
- package/dist/index.mjs +7 -68
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -58,70 +58,6 @@ var runIfFn = (v, ...a) => {
|
|
|
58
58
|
const res = typeof v === "function" ? v(...a) : v;
|
|
59
59
|
return res != null ? res : void 0;
|
|
60
60
|
};
|
|
61
|
-
var noop = () => {
|
|
62
|
-
};
|
|
63
|
-
function getListenerElements() {
|
|
64
|
-
;
|
|
65
|
-
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
|
|
66
|
-
return globalThis.__listenerElements__;
|
|
67
|
-
}
|
|
68
|
-
function getListenerCache() {
|
|
69
|
-
;
|
|
70
|
-
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
71
|
-
return globalThis.__listenerCache__;
|
|
72
|
-
}
|
|
73
|
-
function addGlobalEventListener(node, type, handler, options) {
|
|
74
|
-
var _a;
|
|
75
|
-
if (!node)
|
|
76
|
-
return noop;
|
|
77
|
-
const hash = JSON.stringify({ type, options });
|
|
78
|
-
const listenerElements = getListenerElements();
|
|
79
|
-
const listenerCache = getListenerCache();
|
|
80
|
-
const group = listenerElements.get(node);
|
|
81
|
-
if (!listenerElements.has(node)) {
|
|
82
|
-
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
|
|
83
|
-
listenerElements.set(node, group2);
|
|
84
|
-
} else if (group == null ? void 0 : group.has(hash)) {
|
|
85
|
-
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
|
|
86
|
-
} else {
|
|
87
|
-
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
|
|
88
|
-
}
|
|
89
|
-
function attach(node2) {
|
|
90
|
-
var _a2, _b;
|
|
91
|
-
function listener(event) {
|
|
92
|
-
var _a3;
|
|
93
|
-
const group2 = listenerElements.get(node2);
|
|
94
|
-
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
|
|
95
|
-
}
|
|
96
|
-
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
|
|
97
|
-
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
|
|
98
|
-
node2.addEventListener(type, listener, options);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
|
|
102
|
-
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
|
|
103
|
-
node2.addEventListener(type, listener, options);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
attach(node);
|
|
107
|
-
return function remove() {
|
|
108
|
-
var _a2, _b, _c, _d;
|
|
109
|
-
if (!listenerElements.has(node))
|
|
110
|
-
return;
|
|
111
|
-
const group2 = listenerElements.get(node);
|
|
112
|
-
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
|
|
113
|
-
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
|
|
114
|
-
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
|
|
115
|
-
node.removeEventListener(type, listener, options);
|
|
116
|
-
group2 == null ? void 0 : group2.delete(hash);
|
|
117
|
-
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
|
|
118
|
-
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
119
|
-
listenerElements.delete(node);
|
|
120
|
-
listenerCache.delete(node);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
61
|
var isRef = (v) => hasProp(v, "current");
|
|
126
62
|
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
127
63
|
function extractInfo(event, type = "page") {
|
|
@@ -133,9 +69,12 @@ function extractInfo(event, type = "page") {
|
|
|
133
69
|
}
|
|
134
70
|
};
|
|
135
71
|
}
|
|
136
|
-
function addDomEvent(target,
|
|
72
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
137
73
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
138
|
-
|
|
74
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
75
|
+
return () => {
|
|
76
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
77
|
+
};
|
|
139
78
|
}
|
|
140
79
|
function addPointerEvent(target, event, listener, options) {
|
|
141
80
|
var _a;
|
|
@@ -452,7 +391,7 @@ var pt = (v) => isDom2() && v.test(getPlatform());
|
|
|
452
391
|
var vn = (v) => isDom2() && v.test(navigator.vendor);
|
|
453
392
|
var isSafari = () => isApple() && vn(/apple/i);
|
|
454
393
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
455
|
-
var
|
|
394
|
+
var noop = () => {
|
|
456
395
|
};
|
|
457
396
|
|
|
458
397
|
// src/tooltip.machine.ts
|
|
@@ -614,7 +553,7 @@ function machine(ctx = {}) {
|
|
|
614
553
|
},
|
|
615
554
|
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
616
555
|
if (!isSafari())
|
|
617
|
-
return
|
|
556
|
+
return noop;
|
|
618
557
|
const doc = dom.getDoc(ctx2);
|
|
619
558
|
return addPointerEvent(doc, "pointermove", (event) => {
|
|
620
559
|
const selector = "[data-part=trigger][data-expanded]";
|
package/dist/index.mjs
CHANGED
|
@@ -35,70 +35,6 @@ var runIfFn = (v, ...a) => {
|
|
|
35
35
|
const res = typeof v === "function" ? v(...a) : v;
|
|
36
36
|
return res != null ? res : void 0;
|
|
37
37
|
};
|
|
38
|
-
var noop = () => {
|
|
39
|
-
};
|
|
40
|
-
function getListenerElements() {
|
|
41
|
-
;
|
|
42
|
-
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
|
|
43
|
-
return globalThis.__listenerElements__;
|
|
44
|
-
}
|
|
45
|
-
function getListenerCache() {
|
|
46
|
-
;
|
|
47
|
-
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
48
|
-
return globalThis.__listenerCache__;
|
|
49
|
-
}
|
|
50
|
-
function addGlobalEventListener(node, type, handler, options) {
|
|
51
|
-
var _a;
|
|
52
|
-
if (!node)
|
|
53
|
-
return noop;
|
|
54
|
-
const hash = JSON.stringify({ type, options });
|
|
55
|
-
const listenerElements = getListenerElements();
|
|
56
|
-
const listenerCache = getListenerCache();
|
|
57
|
-
const group = listenerElements.get(node);
|
|
58
|
-
if (!listenerElements.has(node)) {
|
|
59
|
-
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
|
|
60
|
-
listenerElements.set(node, group2);
|
|
61
|
-
} else if (group == null ? void 0 : group.has(hash)) {
|
|
62
|
-
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
|
|
63
|
-
} else {
|
|
64
|
-
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
|
|
65
|
-
}
|
|
66
|
-
function attach(node2) {
|
|
67
|
-
var _a2, _b;
|
|
68
|
-
function listener(event) {
|
|
69
|
-
var _a3;
|
|
70
|
-
const group2 = listenerElements.get(node2);
|
|
71
|
-
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
|
|
72
|
-
}
|
|
73
|
-
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
|
|
74
|
-
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
|
|
75
|
-
node2.addEventListener(type, listener, options);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
|
|
79
|
-
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
|
|
80
|
-
node2.addEventListener(type, listener, options);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
attach(node);
|
|
84
|
-
return function remove() {
|
|
85
|
-
var _a2, _b, _c, _d;
|
|
86
|
-
if (!listenerElements.has(node))
|
|
87
|
-
return;
|
|
88
|
-
const group2 = listenerElements.get(node);
|
|
89
|
-
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
|
|
90
|
-
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
|
|
91
|
-
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
|
|
92
|
-
node.removeEventListener(type, listener, options);
|
|
93
|
-
group2 == null ? void 0 : group2.delete(hash);
|
|
94
|
-
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
|
|
95
|
-
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
96
|
-
listenerElements.delete(node);
|
|
97
|
-
listenerCache.delete(node);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
38
|
var isRef = (v) => hasProp(v, "current");
|
|
103
39
|
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
104
40
|
function extractInfo(event, type = "page") {
|
|
@@ -110,9 +46,12 @@ function extractInfo(event, type = "page") {
|
|
|
110
46
|
}
|
|
111
47
|
};
|
|
112
48
|
}
|
|
113
|
-
function addDomEvent(target,
|
|
49
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
114
50
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
115
|
-
|
|
51
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
52
|
+
return () => {
|
|
53
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
54
|
+
};
|
|
116
55
|
}
|
|
117
56
|
function addPointerEvent(target, event, listener, options) {
|
|
118
57
|
var _a;
|
|
@@ -429,7 +368,7 @@ var pt = (v) => isDom2() && v.test(getPlatform());
|
|
|
429
368
|
var vn = (v) => isDom2() && v.test(navigator.vendor);
|
|
430
369
|
var isSafari = () => isApple() && vn(/apple/i);
|
|
431
370
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
432
|
-
var
|
|
371
|
+
var noop = () => {
|
|
433
372
|
};
|
|
434
373
|
|
|
435
374
|
// src/tooltip.machine.ts
|
|
@@ -591,7 +530,7 @@ function machine(ctx = {}) {
|
|
|
591
530
|
},
|
|
592
531
|
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
593
532
|
if (!isSafari())
|
|
594
|
-
return
|
|
533
|
+
return noop;
|
|
595
534
|
const doc = dom.getDoc(ctx2);
|
|
596
535
|
return addPointerEvent(doc, "pointermove", (event) => {
|
|
597
536
|
const selector = "[data-part=trigger][data-expanded]";
|
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-20220617070002",
|
|
4
4
|
"description": "Core logic for the tooltip widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@zag-js/core": "0.1.6",
|
|
33
|
-
"@zag-js/dom-utils": "0.0.0-dev-
|
|
34
|
-
"@zag-js/popper": "0.0.0-dev-
|
|
35
|
-
"@zag-js/types": "0.0.0-dev-
|
|
33
|
+
"@zag-js/dom-utils": "0.0.0-dev-20220617070002",
|
|
34
|
+
"@zag-js/popper": "0.0.0-dev-20220617070002",
|
|
35
|
+
"@zag-js/types": "0.0.0-dev-20220617070002"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build:fast": "zag build",
|