@zag-js/splitter 0.0.0-dev-20220616105639 → 0.0.0-dev-20220616113129
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 +5 -66
- package/dist/index.mjs +5 -66
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -68,71 +68,7 @@ var runIfFn = (v, ...a) => {
|
|
|
68
68
|
const res = typeof v === "function" ? v(...a) : v;
|
|
69
69
|
return res != null ? res : void 0;
|
|
70
70
|
};
|
|
71
|
-
var noop = () => {
|
|
72
|
-
};
|
|
73
71
|
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
74
|
-
function getListenerElements() {
|
|
75
|
-
;
|
|
76
|
-
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
|
|
77
|
-
return globalThis.__listenerElements__;
|
|
78
|
-
}
|
|
79
|
-
function getListenerCache() {
|
|
80
|
-
;
|
|
81
|
-
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
82
|
-
return globalThis.__listenerCache__;
|
|
83
|
-
}
|
|
84
|
-
function addGlobalEventListener(node, type, handler, options) {
|
|
85
|
-
var _a;
|
|
86
|
-
if (!node)
|
|
87
|
-
return noop;
|
|
88
|
-
const hash = JSON.stringify({ type, options });
|
|
89
|
-
const listenerElements = getListenerElements();
|
|
90
|
-
const listenerCache = getListenerCache();
|
|
91
|
-
const group = listenerElements.get(node);
|
|
92
|
-
if (!listenerElements.has(node)) {
|
|
93
|
-
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
|
|
94
|
-
listenerElements.set(node, group2);
|
|
95
|
-
} else if (group == null ? void 0 : group.has(hash)) {
|
|
96
|
-
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
|
|
97
|
-
} else {
|
|
98
|
-
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
|
|
99
|
-
}
|
|
100
|
-
function attach(node2) {
|
|
101
|
-
var _a2, _b;
|
|
102
|
-
function listener(event) {
|
|
103
|
-
var _a3;
|
|
104
|
-
const group2 = listenerElements.get(node2);
|
|
105
|
-
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
|
|
106
|
-
}
|
|
107
|
-
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
|
|
108
|
-
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
|
|
109
|
-
node2.addEventListener(type, listener, options);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
|
|
113
|
-
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
|
|
114
|
-
node2.addEventListener(type, listener, options);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
attach(node);
|
|
118
|
-
return function remove() {
|
|
119
|
-
var _a2, _b, _c, _d;
|
|
120
|
-
if (!listenerElements.has(node))
|
|
121
|
-
return;
|
|
122
|
-
const group2 = listenerElements.get(node);
|
|
123
|
-
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
|
|
124
|
-
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
|
|
125
|
-
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
|
|
126
|
-
node.removeEventListener(type, listener, options);
|
|
127
|
-
group2 == null ? void 0 : group2.delete(hash);
|
|
128
|
-
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
|
|
129
|
-
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
130
|
-
listenerElements.delete(node);
|
|
131
|
-
listenerCache.delete(node);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
72
|
var isRef = (v) => hasProp(v, "current");
|
|
137
73
|
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
138
74
|
function extractInfo(event, type = "page") {
|
|
@@ -144,9 +80,12 @@ function extractInfo(event, type = "page") {
|
|
|
144
80
|
}
|
|
145
81
|
};
|
|
146
82
|
}
|
|
147
|
-
function addDomEvent(target,
|
|
83
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
148
84
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
149
|
-
|
|
85
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
86
|
+
return () => {
|
|
87
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
88
|
+
};
|
|
150
89
|
}
|
|
151
90
|
function addPointerEvent(target, event, listener, options) {
|
|
152
91
|
var _a;
|
package/dist/index.mjs
CHANGED
|
@@ -45,71 +45,7 @@ var runIfFn = (v, ...a) => {
|
|
|
45
45
|
const res = typeof v === "function" ? v(...a) : v;
|
|
46
46
|
return res != null ? res : void 0;
|
|
47
47
|
};
|
|
48
|
-
var noop = () => {
|
|
49
|
-
};
|
|
50
48
|
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
51
|
-
function getListenerElements() {
|
|
52
|
-
;
|
|
53
|
-
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
|
|
54
|
-
return globalThis.__listenerElements__;
|
|
55
|
-
}
|
|
56
|
-
function getListenerCache() {
|
|
57
|
-
;
|
|
58
|
-
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
59
|
-
return globalThis.__listenerCache__;
|
|
60
|
-
}
|
|
61
|
-
function addGlobalEventListener(node, type, handler, options) {
|
|
62
|
-
var _a;
|
|
63
|
-
if (!node)
|
|
64
|
-
return noop;
|
|
65
|
-
const hash = JSON.stringify({ type, options });
|
|
66
|
-
const listenerElements = getListenerElements();
|
|
67
|
-
const listenerCache = getListenerCache();
|
|
68
|
-
const group = listenerElements.get(node);
|
|
69
|
-
if (!listenerElements.has(node)) {
|
|
70
|
-
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
|
|
71
|
-
listenerElements.set(node, group2);
|
|
72
|
-
} else if (group == null ? void 0 : group.has(hash)) {
|
|
73
|
-
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
|
|
74
|
-
} else {
|
|
75
|
-
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
|
|
76
|
-
}
|
|
77
|
-
function attach(node2) {
|
|
78
|
-
var _a2, _b;
|
|
79
|
-
function listener(event) {
|
|
80
|
-
var _a3;
|
|
81
|
-
const group2 = listenerElements.get(node2);
|
|
82
|
-
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
|
|
83
|
-
}
|
|
84
|
-
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
|
|
85
|
-
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
|
|
86
|
-
node2.addEventListener(type, listener, options);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
|
|
90
|
-
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
|
|
91
|
-
node2.addEventListener(type, listener, options);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
attach(node);
|
|
95
|
-
return function remove() {
|
|
96
|
-
var _a2, _b, _c, _d;
|
|
97
|
-
if (!listenerElements.has(node))
|
|
98
|
-
return;
|
|
99
|
-
const group2 = listenerElements.get(node);
|
|
100
|
-
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
|
|
101
|
-
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
|
|
102
|
-
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
|
|
103
|
-
node.removeEventListener(type, listener, options);
|
|
104
|
-
group2 == null ? void 0 : group2.delete(hash);
|
|
105
|
-
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
|
|
106
|
-
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
107
|
-
listenerElements.delete(node);
|
|
108
|
-
listenerCache.delete(node);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
49
|
var isRef = (v) => hasProp(v, "current");
|
|
114
50
|
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
115
51
|
function extractInfo(event, type = "page") {
|
|
@@ -121,9 +57,12 @@ function extractInfo(event, type = "page") {
|
|
|
121
57
|
}
|
|
122
58
|
};
|
|
123
59
|
}
|
|
124
|
-
function addDomEvent(target,
|
|
60
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
125
61
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
126
|
-
|
|
62
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
63
|
+
return () => {
|
|
64
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
65
|
+
};
|
|
127
66
|
}
|
|
128
67
|
function addPointerEvent(target, event, listener, options) {
|
|
129
68
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/splitter",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20220616113129",
|
|
4
4
|
"description": "Core logic for the splitter widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@zag-js/core": "0.1.6",
|
|
34
|
-
"@zag-js/dom-utils": "0.0.0-dev-
|
|
34
|
+
"@zag-js/dom-utils": "0.0.0-dev-20220616113129",
|
|
35
35
|
"@zag-js/number-utils": "0.1.2",
|
|
36
36
|
"@zag-js/rect-utils": "0.1.2",
|
|
37
|
-
"@zag-js/types": "0.0.0-dev-
|
|
37
|
+
"@zag-js/types": "0.0.0-dev-20220616113129"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build:fast": "zag build",
|