1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-22 16:55:23 +01:00
This commit is contained in:
Jan Andrle 2023-09-21 16:27:00 +02:00
parent eb68fff211
commit e3c2786a72
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
4 changed files with 308 additions and 336 deletions

View File

@ -1,7 +1,7 @@
//deka-dom-el library is available via global namespace `dde` //deka-dom-el library is available via global namespace `dde`
(()=> { (()=> {
// src/signals-common.js // src/signals-common.js
var x = { var E = {
isSignal(e) { isSignal(e) {
return !1; return !1;
}, },
@ -10,10 +10,10 @@
} }
}; };
function C(e, t = !0) { function C(e, t = !0) {
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e); return t ? Object.assign(E, e) : (Object.setPrototypeOf(e, E), e);
} }
function v(e) { function x(e) {
return x.isPrototypeOf(e) && e !== x ? e : x; return E.isPrototypeOf(e) && e !== E ? e : E;
} }
// src/helpers.js // src/helpers.js
@ -37,7 +37,7 @@
var P = { setDeleteAttr: W }; var P = { setDeleteAttr: W };
function W(e, t, n) { function W(e, t, n) {
if (Reflect.set(e, t, n), !!m(n)) { if (Reflect.set(e, t, n), !!m(n)) {
if (e instanceof HTMLElement && e.getAttribute(t) === "undefined") if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t); return e.removeAttribute(t);
if (Reflect.get(e, t) === "undefined") if (Reflect.get(e, t) === "undefined")
return Reflect.set(e, t, ""); return Reflect.set(e, t, "");
@ -45,78 +45,71 @@
} }
// src/dom.js // src/dom.js
var S = "html"; var w = "html";
function oe(e) { function oe(e) {
return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, { return w = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
append(...t) { append(...t) {
return S = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t); return w = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
} }
}; };
} }
function ce(e, t, ...n) { function ce(e, t, ...n) {
let r = v(this), o; let r = x(this), o;
switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) { switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
o = e(t || void 0, (p) => p ? (n.unshift(p), void 0) : o); o = e(t || void 0, (p) => p ? (n.unshift(p), void 0) : o);
break; break;
} }
case e === "#text": case e === "#text":
o = w(document.createTextNode(""), t); o = S(document.createTextNode(""), t);
break; break;
case e === "<>": case e === "<>":
o = w(document.createDocumentFragment(), t); o = S(document.createDocumentFragment(), t);
break; break;
case S !== "html": case w !== "html":
o = w(document.createElementNS(S, e), t); o = S(document.createElementNS(w, e), t);
break; break;
case !o: case !o:
o = w(document.createElement(e), t); o = S(document.createElement(e), t);
} }
return n.forEach((i) => i(o)), o; return n.forEach((i) => i(o)), o;
} }
var { setDeleteAttr: j } = P; var { setDeleteAttr: j } = P;
function w(e, ...t) { function S(e, ...t) {
let n = this, r = v(this); let n = this, r = x(this);
if (!t.length) if (!t.length)
return e; return e;
let o = e instanceof SVGElement, i = (o ? J : I).bind(null, e, "Attribute"); let i = (e instanceof SVGElement ? I : H).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function p([f, a]) { return Object.entries(Object.assign({}, ...t)).forEach(function p([f, a]) {
a = r.processReactiveAttribute(e, f, a, p); a = r.processReactiveAttribute(e, f, a, p);
let [b] = f; let [b] = f;
if (b === "=") if (b === "=")
return i(f.slice(1), a); return i(f.slice(1), a);
if (b === ".") if (b === ".")
return T(e, f.slice(1), a); return F(e, f.slice(1), a);
if (/(aria|data)([A-Z])/.test(f)) if (/(aria|data)([A-Z])/.test(f))
return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i(f, a); return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i(f, a);
switch (f === "className" && (f = "class"), f) { switch (f === "className" && (f = "class"), f) {
case "href":
case "src":
case "class":
case "xlink:href": case "xlink:href":
return i( return i(f, a, "http://www.w3.org/1999/xlink");
f,
a,
/* this applies only to SVG elements, see setRemove/setRemoveNS */
"http://www.w3.org/1999/xlink"
);
case "textContent": case "textContent":
case "innerText": return j(e, f, a);
return o ? e.appendChild(document.createTextNode(a)) : j(e, f, a);
case "style": case "style":
if (typeof a != "object")
break;
case "dataset": case "dataset":
return N(r, a, T.bind(null, e[f])); return D(r, a, F.bind(null, e[f]));
case "ariaset": case "ariaset":
return N(r, a, (E, c) => i("aria-" + E, c)); return D(r, a, (v, c) => i("aria-" + v, c));
case "classList": case "classList":
return B.call(n, e, a); return B.call(n, e, a);
} }
return H(e, f) ? j(e, f, a) : i(f, a); return G(e, f) ? j(e, f, a) : i(f, a);
}), e; }), e;
} }
function B(e, t) { function B(e, t) {
let n = v(this); let n = x(this);
return N( return D(
n, n,
t, t,
(r, o) => e.classList.toggle(r, o === -1 ? void 0 : !!o) (r, o) => e.classList.toggle(r, o === -1 ? void 0 : !!o)
@ -125,34 +118,34 @@
function se(e) { function se(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function H(e, t) { function G(e, t) {
if (!Reflect.has(e, t)) if (!Reflect.has(e, t))
return !1; return !1;
let n = F(e, t); let n = M(e, t);
return !m(n.set); return !m(n.set);
} }
function F(e, t, n = 0) { function M(e, t) {
if (e = Object.getPrototypeOf(e), !e) if (e = Object.getPrototypeOf(e), !e)
return {}; return {};
let r = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return r || F(e, t, n + 1); return n || M(e, t);
} }
function N(e, t, n) { function D(e, t, n) {
if (typeof t == "object") if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([o, i]) { return Object.entries(t).forEach(function([o, i]) {
o && (i = e.processReactiveAttribute(t, o, i, (p) => n(...p)), n(o, i)); o && (i = e.processReactiveAttribute(t, o, i, (p) => n(...p)), n(o, i));
}); });
} }
function M(e) { function z(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e; return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
} }
function I(e, t, n, r) { function H(e, t, n, r) {
return e[(m(r) ? "remove" : "set") + t](n, M(r)); return e[(m(r) ? "remove" : "set") + t](n, z(r));
} }
function J(e, t, n, r, o = null) { function I(e, t, n, r, o = null) {
return e[(m(r) ? "remove" : "set") + t + "NS"](o, n, M(r)); return e[(m(r) ? "remove" : "set") + t + "NS"](o, n, z(r));
} }
function T(e, t, n) { function F(e, t, n) {
if (Reflect.set(e, t, n), !!m(n)) if (Reflect.set(e, t, n), !!m(n))
return Reflect.deleteProperty(e, t); return Reflect.deleteProperty(e, t);
} }
@ -162,23 +155,23 @@
let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t); let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(r); return e.dispatchEvent(r);
} }
function z(e, t, n) { function T(e, t, n) {
return function(o) { return function(o) {
return o.addEventListener(e, t, n), o; return o.addEventListener(e, t, n), o;
}; };
} }
var O = Z(); var O = J();
z.connected = function(e, t) { T.connected = function(e, t) {
return function(r) { return function(r) {
return typeof r.connectedCallback == "function" ? (r.addEventListener("dde:connected", e, t), r) : (L(t && t.signal, () => O.offConnected(r, e)) && (r.isConnected ? e(new Event("dde:connected")) : O.onConnected(r, e)), r); return typeof r.connectedCallback == "function" ? (r.addEventListener("dde:connected", e, t), r) : (L(t && t.signal, () => O.offConnected(r, e)) && (r.isConnected ? e(new Event("dde:connected")) : O.onConnected(r, e)), r);
}; };
}; };
z.disconnected = function(e, t) { T.disconnected = function(e, t) {
return function(r) { return function(r) {
return typeof r.disconnectedCallback == "function" ? (r.addEventListener("dde:disconnected", e, t), r) : (L(t && t.signal, () => O.offDisconnected(r, e)) && O.onDisconnected(r, e), r); return typeof r.disconnectedCallback == "function" ? (r.addEventListener("dde:disconnected", e, t), r) : (L(t && t.signal, () => O.offDisconnected(r, e)) && O.onDisconnected(r, e), r);
}; };
}; };
function Z() { function J() {
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(c) { let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(c) {
for (let s of c) for (let s of c)
if (s.type === "childList") { if (s.type === "childList") {
@ -186,7 +179,7 @@
p(); p();
continue; continue;
} }
E(s.removedNodes, !0) && p(); v(s.removedNodes, !0) && p();
} }
}); });
return { return {
@ -243,23 +236,23 @@
if (s && a(u).then(b), !e.has(u)) if (s && a(u).then(b), !e.has(u))
continue; continue;
let l = e.get(u); let l = e.get(u);
return l.connected.forEach((y) => y(u)), l.connected.length = 0, l.disconnected.length || e.delete(u), !0; return l.connected.forEach((A) => A(u)), l.connected.length = 0, l.disconnected.length || e.delete(u), !0;
} }
return !1; return !1;
} }
function E(c, s) { function v(c, s) {
for (let u of c) { for (let u of c) {
if (s && a(u).then(E), !e.has(u)) if (s && a(u).then(v), !e.has(u))
continue; continue;
let l = e.get(u); let l = e.get(u);
return l.disconnected.forEach((y) => y(u)), l.connected.length = 0, l.disconnected.length = 0, e.delete(u), !0; return l.disconnected.forEach((A) => A(u)), l.connected.length = 0, l.disconnected.length = 0, e.delete(u), !0;
} }
return !1; return !1;
} }
} }
// index.js // index.js
[HTMLElement, DocumentFragment].forEach((e) => { [HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
let { append: t } = e.prototype; let { append: t } = e.prototype;
e.prototype.append = function(...n) { e.prototype.append = function(...n) {
return t.apply(this, n), this; return t.apply(this, n), this;
@ -268,7 +261,7 @@
// src/signals-lib.js // src/signals-lib.js
var d = Symbol.for("Signal"); var d = Symbol.for("Signal");
function A(e) { function y(e) {
try { try {
return Reflect.has(e, d); return Reflect.has(e, d);
} catch { } catch {
@ -279,10 +272,10 @@
function g(e, t) { function g(e, t) {
if (typeof e != "function") if (typeof e != "function")
return U(e, t); return U(e, t);
if (A(e)) if (y(e))
return e; return e;
let n = U(""), r = () => n(e()); let n = U(""), r = () => n(e());
return h.set(r, /* @__PURE__ */ new Set([n])), K(r), n; return h.set(r, /* @__PURE__ */ new Set([n])), k(r), n;
} }
g.action = function(e, t, ...n) { g.action = function(e, t, ...n) {
let r = e[d], { actions: o } = r; let r = e[d], { actions: o } = r;
@ -297,7 +290,7 @@
if (!(o && o.aborted)) { if (!(o && o.aborted)) {
if (Array.isArray(t)) if (Array.isArray(t))
return t.forEach((i) => e(i, n, r)); return t.forEach((i) => e(i, n, r));
D(t, n), o && o.addEventListener("abort", () => q(t, n)); N(t, n), o && o.addEventListener("abort", () => q(t, n));
} }
}; };
g.symbols = { g.symbols = {
@ -332,54 +325,54 @@
a.remove(); a.remove();
n.after(...f); n.after(...f);
}; };
return D(e, i), i(e()), o; return N(e, i), i(e()), o;
}; };
var $ = { var $ = {
isSignal: A, isSignal: y,
processReactiveAttribute(e, t, n, r) { processReactiveAttribute(e, t, n, r) {
return A(n) ? (D(n, (o) => r([t, o])), n()) : n; return y(n) ? (N(n, (o) => r([t, o])), n()) : n;
} }
}; };
function U(e, t) { function U(e, t) {
let n = (...r) => r.length ? Y(n, r[0]) : X(n); let n = (...r) => r.length ? X(n, r[0]) : Q(n);
return V(n, e, t); return Z(n, e, t);
} }
var G = Object.assign(/* @__PURE__ */ Object.create(null), { var V = Object.assign(/* @__PURE__ */ Object.create(null), {
stopPropagation() { stopPropagation() {
this.skip = !0; this.skip = !0;
} }
}); });
function V(e, t, n) { function Z(e, t, n) {
return _(n) !== "[object Object]" && (n = {}), e[d] = { return _(n) !== "[object Object]" && (n = {}), e[d] = {
value: t, value: t,
actions: n, actions: n,
listeners: /* @__PURE__ */ new Set() listeners: /* @__PURE__ */ new Set()
}, e.toJSON = () => e(), Object.setPrototypeOf(e[d], G), e; }, e.toJSON = () => e(), Object.setPrototypeOf(e[d], V), e;
} }
var R = []; var R = [];
function K(e) { function k(e) {
let t = function() { let t = function() {
R.push(t), e(), R.pop(); R.push(t), e(), R.pop();
}; };
h.has(e) && (h.set(t, h.get(e)), h.delete(e)), t(); h.has(e) && (h.set(t, h.get(e)), h.delete(e)), t();
} }
function Q() { function K() {
return R[R.length - 1]; return R[R.length - 1];
} }
function X(e) { function Q(e) {
if (!e[d]) if (!e[d])
return; return;
let { value: t, listeners: n } = e[d], r = Q(); let { value: t, listeners: n } = e[d], r = K();
return r && n.add(r), h.has(r) && h.get(r).add(e), t; return r && n.add(r), h.has(r) && h.get(r).add(e), t;
} }
function Y(e, t) { function X(e, t) {
if (!e[d]) if (!e[d])
return; return;
let n = e[d]; let n = e[d];
if (n.value !== t) if (n.value !== t)
return n.value = t, n.listeners.forEach((r) => r(t)), t; return n.value = t, n.listeners.forEach((r) => r(t)), t;
} }
function D(e, t) { function N(e, t) {
if (e[d]) if (e[d])
return e[d].listeners.add(t); return e[d].listeners.add(t);
} }
@ -393,15 +386,15 @@
globalThis.dde= { globalThis.dde= {
S: g, S: g,
assign: w, assign: S,
classListDeclarative: B, classListDeclarative: B,
createElement: ce, createElement: ce,
dispatchEvent: ae, dispatchEvent: ae,
el: ce, el: ce,
empty: se, empty: se,
isSignal: A, isSignal: y,
namespace: oe, namespace: oe,
on: z, on: T,
registerReactivity: C registerReactivity: C
}; };

171
dist/dde.js vendored
View File

@ -5,11 +5,11 @@
isSignal(e) { isSignal(e) {
return !1; return !1;
}, },
processReactiveAttribute(e, t, r, n) { processReactiveAttribute(e, t, n, r) {
return r; return n;
} }
}; };
function P(e, t = !0) { function y(e, t = !0) {
return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e); return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e);
} }
function v(e) { function v(e) {
@ -30,10 +30,10 @@
} }
// src/dom-common.js // src/dom-common.js
var C = { setDeleteAttr: y }; var R = { setDeleteAttr: P };
function y(e, t, r) { function P(e, t, n) {
if (Reflect.set(e, t, r), !!p(r)) { if (Reflect.set(e, t, n), !!p(n)) {
if (e instanceof HTMLElement && e.getAttribute(t) === "undefined") if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t); return e.removeAttribute(t);
if (Reflect.get(e, t) === "undefined") if (Reflect.get(e, t) === "undefined")
return Reflect.set(e, t, ""); return Reflect.set(e, t, "");
@ -41,43 +41,43 @@
} }
// src/dom.js // src/dom.js
var m = "html"; var x = "html";
function I(e) { function H(e) {
return m = e === "svg" ? "http://www.w3.org/2000/svg" : e, { return x = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
append(...t) { append(...t) {
return m = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t); return x = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
} }
}; };
} }
function Z(e, t, ...r) { function I(e, t, ...n) {
let n = v(this), c; let r = v(this), c;
switch ((Object(t) !== t || n.isSignal(t)) && (t = { textContent: t }), !0) { switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
c = e(t || void 0, (l) => l ? (r.unshift(l), void 0) : c); c = e(t || void 0, (l) => l ? (n.unshift(l), void 0) : c);
break; break;
} }
case e === "#text": case e === "#text":
c = x(document.createTextNode(""), t); c = m(document.createTextNode(""), t);
break; break;
case e === "<>": case e === "<>":
c = x(document.createDocumentFragment(), t); c = m(document.createDocumentFragment(), t);
break; break;
case m !== "html": case x !== "html":
c = x(document.createElementNS(m, e), t); c = m(document.createElementNS(x, e), t);
break; break;
case !c: case !c:
c = x(document.createElement(e), t); c = m(document.createElement(e), t);
} }
return r.forEach((d) => d(c)), c; return n.forEach((d) => d(c)), c;
} }
var { setDeleteAttr: R } = C; var { setDeleteAttr: C } = R;
function x(e, ...t) { function m(e, ...t) {
let r = this, n = v(this); let n = this, r = v(this);
if (!t.length) if (!t.length)
return e; return e;
let c = e instanceof SVGElement, d = (c ? F : j).bind(null, e, "Attribute"); let d = (e instanceof SVGElement ? M : F).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function l([f, u]) { return Object.entries(Object.assign({}, ...t)).forEach(function l([f, u]) {
u = n.processReactiveAttribute(e, f, u, l); u = r.processReactiveAttribute(e, f, u, l);
let [h] = f; let [h] = f;
if (h === "=") if (h === "=")
return d(f.slice(1), u); return d(f.slice(1), u);
@ -86,96 +86,89 @@
if (/(aria|data)([A-Z])/.test(f)) if (/(aria|data)([A-Z])/.test(f))
return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), d(f, u); return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), d(f, u);
switch (f === "className" && (f = "class"), f) { switch (f === "className" && (f = "class"), f) {
case "href":
case "src":
case "class":
case "xlink:href": case "xlink:href":
return d( return d(f, u, "http://www.w3.org/1999/xlink");
f,
u,
/* this applies only to SVG elements, see setRemove/setRemoveNS */
"http://www.w3.org/1999/xlink"
);
case "textContent": case "textContent":
case "innerText": return C(e, f, u);
return c ? e.appendChild(document.createTextNode(u)) : R(e, f, u);
case "style": case "style":
if (typeof u != "object")
break;
case "dataset": case "dataset":
return O(n, u, D.bind(null, e[f])); return O(r, u, D.bind(null, e[f]));
case "ariaset": case "ariaset":
return O(n, u, (E, o) => d("aria-" + E, o)); return O(r, u, (E, o) => d("aria-" + E, o));
case "classList": case "classList":
return _.call(r, e, u); return _.call(n, e, u);
} }
return T(e, f) ? R(e, f, u) : d(f, u); return j(e, f) ? C(e, f, u) : d(f, u);
}), e; }), e;
} }
function _(e, t) { function _(e, t) {
let r = v(this); let n = v(this);
return O( return O(
r, n,
t, t,
(n, c) => e.classList.toggle(n, c === -1 ? void 0 : !!c) (r, c) => e.classList.toggle(r, c === -1 ? void 0 : !!c)
), e; ), e;
} }
function G(e) { function Z(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function T(e, t) { function j(e, t) {
if (!Reflect.has(e, t)) if (!Reflect.has(e, t))
return !1; return !1;
let r = L(e, t); let n = L(e, t);
return !p(r.set); return !p(n.set);
} }
function L(e, t, r = 0) { function L(e, t) {
if (e = Object.getPrototypeOf(e), !e) if (e = Object.getPrototypeOf(e), !e)
return {}; return {};
let n = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return n || L(e, t, r + 1); return n || L(e, t);
} }
function O(e, t, r) { function O(e, t, n) {
if (typeof t == "object") if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([c, d]) { return Object.entries(t).forEach(function([c, d]) {
c && (d = e.processReactiveAttribute(t, c, d, (l) => r(...l)), r(c, d)); c && (d = e.processReactiveAttribute(t, c, d, (l) => n(...l)), n(c, d));
}); });
} }
function N(e) { function S(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e; return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
} }
function j(e, t, r, n) { function F(e, t, n, r) {
return e[(p(n) ? "remove" : "set") + t](r, N(n)); return e[(p(r) ? "remove" : "set") + t](n, S(r));
} }
function F(e, t, r, n, c = null) { function M(e, t, n, r, c = null) {
return e[(p(n) ? "remove" : "set") + t + "NS"](c, r, N(n)); return e[(p(r) ? "remove" : "set") + t + "NS"](c, n, S(r));
} }
function D(e, t, r) { function D(e, t, n) {
if (Reflect.set(e, t, r), !!p(r)) if (Reflect.set(e, t, n), !!p(n))
return Reflect.deleteProperty(e, t); return Reflect.deleteProperty(e, t);
} }
// src/events.js // src/events.js
function J(e, t, ...r) { function J(e, t, ...n) {
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t); let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(n); return e.dispatchEvent(r);
} }
function S(e, t, r) { function N(e, t, n) {
return function(c) { return function(c) {
return c.addEventListener(e, t, r), c; return c.addEventListener(e, t, n), c;
}; };
} }
var b = M(); var b = T();
S.connected = function(e, t) { N.connected = function(e, t) {
return function(n) { return function(r) {
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (w(t && t.signal, () => b.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : b.onConnected(n, e)), n); return typeof r.connectedCallback == "function" ? (r.addEventListener("dde:connected", e, t), r) : (w(t && t.signal, () => b.offConnected(r, e)) && (r.isConnected ? e(new Event("dde:connected")) : b.onConnected(r, e)), r);
}; };
}; };
S.disconnected = function(e, t) { N.disconnected = function(e, t) {
return function(n) { return function(r) {
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (w(t && t.signal, () => b.offDisconnected(n, e)) && b.onDisconnected(n, e), n); return typeof r.disconnectedCallback == "function" ? (r.addEventListener("dde:disconnected", e, t), r) : (w(t && t.signal, () => b.offDisconnected(r, e)) && b.onDisconnected(r, e), r);
}; };
}; };
function M() { function T() {
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) { let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(o) {
for (let s of o) for (let s of o)
if (s.type === "childList") { if (s.type === "childList") {
if (h(s.addedNodes, !0)) { if (h(s.addedNodes, !0)) {
@ -193,7 +186,7 @@
if (!e.has(o)) if (!e.has(o))
return; return;
let i = e.get(o), a = i.connected; let i = e.get(o), a = i.connected;
a.splice(a.indexOf(s), 1), n(o, i); a.splice(a.indexOf(s), 1), r(o, i);
}, },
onDisconnected(o, s) { onDisconnected(o, s) {
d(), c(o).disconnected.push(s); d(), c(o).disconnected.push(s);
@ -202,10 +195,10 @@
if (!e.has(o)) if (!e.has(o))
return; return;
let i = e.get(o), a = i.disconnected; let i = e.get(o), a = i.disconnected;
a.splice(a.indexOf(s), 1), n(o, i); a.splice(a.indexOf(s), 1), r(o, i);
} }
}; };
function n(o, s) { function r(o, s) {
s.connected.length || s.disconnected.length || (e.delete(o), l()); s.connected.length || s.disconnected.length || (e.delete(o), l());
} }
function c(o) { function c(o) {
@ -215,10 +208,10 @@
return e.set(o, s), s; return e.set(o, s), s;
} }
function d() { function d() {
t || (t = !0, r.observe(document.body, { childList: !0, subtree: !0 })); t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
} }
function l() { function l() {
!t || e.size || (t = !1, r.disconnect()); !t || e.size || (t = !1, n.disconnect());
} }
function f() { function f() {
return new Promise(function(o) { return new Promise(function(o) {
@ -255,23 +248,23 @@
} }
// index.js // index.js
[HTMLElement, DocumentFragment].forEach((e) => { [HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
let { append: t } = e.prototype; let { append: t } = e.prototype;
e.prototype.append = function(...r) { e.prototype.append = function(...n) {
return t.apply(this, r), this; return t.apply(this, n), this;
}; };
}); });
globalThis.dde= { globalThis.dde= {
assign: x, assign: m,
classListDeclarative: _, classListDeclarative: _,
createElement: Z, createElement: I,
dispatchEvent: J, dispatchEvent: J,
el: Z, el: I,
empty: G, empty: Z,
namespace: I, namespace: H,
on: S, on: N,
registerReactivity: P registerReactivity: y
}; };
})(); })();

View File

@ -1,5 +1,5 @@
// src/signals-common.js // src/signals-common.js
var x = { var E = {
isSignal(e) { isSignal(e) {
return !1; return !1;
}, },
@ -8,10 +8,10 @@ var x = {
} }
}; };
function C(e, t = !0) { function C(e, t = !0) {
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e); return t ? Object.assign(E, e) : (Object.setPrototypeOf(e, E), e);
} }
function v(e) { function x(e) {
return x.isPrototypeOf(e) && e !== x ? e : x; return E.isPrototypeOf(e) && e !== E ? e : E;
} }
// src/helpers.js // src/helpers.js
@ -35,7 +35,7 @@ function L(e, t) {
var P = { setDeleteAttr: W }; var P = { setDeleteAttr: W };
function W(e, t, n) { function W(e, t, n) {
if (Reflect.set(e, t, n), !!m(n)) { if (Reflect.set(e, t, n), !!m(n)) {
if (e instanceof HTMLElement && e.getAttribute(t) === "undefined") if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t); return e.removeAttribute(t);
if (Reflect.get(e, t) === "undefined") if (Reflect.get(e, t) === "undefined")
return Reflect.set(e, t, ""); return Reflect.set(e, t, "");
@ -43,78 +43,71 @@ function W(e, t, n) {
} }
// src/dom.js // src/dom.js
var S = "html"; var w = "html";
function oe(e) { function oe(e) {
return S = e === "svg" ? "http://www.w3.org/2000/svg" : e, { return w = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
append(...t) { append(...t) {
return S = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t); return w = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
} }
}; };
} }
function ce(e, t, ...n) { function ce(e, t, ...n) {
let r = v(this), o; let r = x(this), o;
switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) { switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
o = e(t || void 0, (p) => p ? (n.unshift(p), void 0) : o); o = e(t || void 0, (p) => p ? (n.unshift(p), void 0) : o);
break; break;
} }
case e === "#text": case e === "#text":
o = w(document.createTextNode(""), t); o = S(document.createTextNode(""), t);
break; break;
case e === "<>": case e === "<>":
o = w(document.createDocumentFragment(), t); o = S(document.createDocumentFragment(), t);
break; break;
case S !== "html": case w !== "html":
o = w(document.createElementNS(S, e), t); o = S(document.createElementNS(w, e), t);
break; break;
case !o: case !o:
o = w(document.createElement(e), t); o = S(document.createElement(e), t);
} }
return n.forEach((i) => i(o)), o; return n.forEach((i) => i(o)), o;
} }
var { setDeleteAttr: j } = P; var { setDeleteAttr: j } = P;
function w(e, ...t) { function S(e, ...t) {
let n = this, r = v(this); let n = this, r = x(this);
if (!t.length) if (!t.length)
return e; return e;
let o = e instanceof SVGElement, i = (o ? J : I).bind(null, e, "Attribute"); let i = (e instanceof SVGElement ? I : H).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function p([f, a]) { return Object.entries(Object.assign({}, ...t)).forEach(function p([f, a]) {
a = r.processReactiveAttribute(e, f, a, p); a = r.processReactiveAttribute(e, f, a, p);
let [b] = f; let [b] = f;
if (b === "=") if (b === "=")
return i(f.slice(1), a); return i(f.slice(1), a);
if (b === ".") if (b === ".")
return T(e, f.slice(1), a); return F(e, f.slice(1), a);
if (/(aria|data)([A-Z])/.test(f)) if (/(aria|data)([A-Z])/.test(f))
return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i(f, a); return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), i(f, a);
switch (f === "className" && (f = "class"), f) { switch (f === "className" && (f = "class"), f) {
case "href":
case "src":
case "class":
case "xlink:href": case "xlink:href":
return i( return i(f, a, "http://www.w3.org/1999/xlink");
f,
a,
/* this applies only to SVG elements, see setRemove/setRemoveNS */
"http://www.w3.org/1999/xlink"
);
case "textContent": case "textContent":
case "innerText": return j(e, f, a);
return o ? e.appendChild(document.createTextNode(a)) : j(e, f, a);
case "style": case "style":
if (typeof a != "object")
break;
case "dataset": case "dataset":
return N(r, a, T.bind(null, e[f])); return D(r, a, F.bind(null, e[f]));
case "ariaset": case "ariaset":
return N(r, a, (E, c) => i("aria-" + E, c)); return D(r, a, (v, c) => i("aria-" + v, c));
case "classList": case "classList":
return B.call(n, e, a); return B.call(n, e, a);
} }
return H(e, f) ? j(e, f, a) : i(f, a); return G(e, f) ? j(e, f, a) : i(f, a);
}), e; }), e;
} }
function B(e, t) { function B(e, t) {
let n = v(this); let n = x(this);
return N( return D(
n, n,
t, t,
(r, o) => e.classList.toggle(r, o === -1 ? void 0 : !!o) (r, o) => e.classList.toggle(r, o === -1 ? void 0 : !!o)
@ -123,34 +116,34 @@ function B(e, t) {
function se(e) { function se(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function H(e, t) { function G(e, t) {
if (!Reflect.has(e, t)) if (!Reflect.has(e, t))
return !1; return !1;
let n = F(e, t); let n = M(e, t);
return !m(n.set); return !m(n.set);
} }
function F(e, t, n = 0) { function M(e, t) {
if (e = Object.getPrototypeOf(e), !e) if (e = Object.getPrototypeOf(e), !e)
return {}; return {};
let r = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return r || F(e, t, n + 1); return n || M(e, t);
} }
function N(e, t, n) { function D(e, t, n) {
if (typeof t == "object") if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([o, i]) { return Object.entries(t).forEach(function([o, i]) {
o && (i = e.processReactiveAttribute(t, o, i, (p) => n(...p)), n(o, i)); o && (i = e.processReactiveAttribute(t, o, i, (p) => n(...p)), n(o, i));
}); });
} }
function M(e) { function z(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e; return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
} }
function I(e, t, n, r) { function H(e, t, n, r) {
return e[(m(r) ? "remove" : "set") + t](n, M(r)); return e[(m(r) ? "remove" : "set") + t](n, z(r));
} }
function J(e, t, n, r, o = null) { function I(e, t, n, r, o = null) {
return e[(m(r) ? "remove" : "set") + t + "NS"](o, n, M(r)); return e[(m(r) ? "remove" : "set") + t + "NS"](o, n, z(r));
} }
function T(e, t, n) { function F(e, t, n) {
if (Reflect.set(e, t, n), !!m(n)) if (Reflect.set(e, t, n), !!m(n))
return Reflect.deleteProperty(e, t); return Reflect.deleteProperty(e, t);
} }
@ -160,23 +153,23 @@ function ae(e, t, ...n) {
let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t); let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(r); return e.dispatchEvent(r);
} }
function z(e, t, n) { function T(e, t, n) {
return function(o) { return function(o) {
return o.addEventListener(e, t, n), o; return o.addEventListener(e, t, n), o;
}; };
} }
var O = Z(); var O = J();
z.connected = function(e, t) { T.connected = function(e, t) {
return function(r) { return function(r) {
return typeof r.connectedCallback == "function" ? (r.addEventListener("dde:connected", e, t), r) : (L(t && t.signal, () => O.offConnected(r, e)) && (r.isConnected ? e(new Event("dde:connected")) : O.onConnected(r, e)), r); return typeof r.connectedCallback == "function" ? (r.addEventListener("dde:connected", e, t), r) : (L(t && t.signal, () => O.offConnected(r, e)) && (r.isConnected ? e(new Event("dde:connected")) : O.onConnected(r, e)), r);
}; };
}; };
z.disconnected = function(e, t) { T.disconnected = function(e, t) {
return function(r) { return function(r) {
return typeof r.disconnectedCallback == "function" ? (r.addEventListener("dde:disconnected", e, t), r) : (L(t && t.signal, () => O.offDisconnected(r, e)) && O.onDisconnected(r, e), r); return typeof r.disconnectedCallback == "function" ? (r.addEventListener("dde:disconnected", e, t), r) : (L(t && t.signal, () => O.offDisconnected(r, e)) && O.onDisconnected(r, e), r);
}; };
}; };
function Z() { function J() {
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(c) { let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(c) {
for (let s of c) for (let s of c)
if (s.type === "childList") { if (s.type === "childList") {
@ -184,7 +177,7 @@ function Z() {
p(); p();
continue; continue;
} }
E(s.removedNodes, !0) && p(); v(s.removedNodes, !0) && p();
} }
}); });
return { return {
@ -241,23 +234,23 @@ function Z() {
if (s && a(u).then(b), !e.has(u)) if (s && a(u).then(b), !e.has(u))
continue; continue;
let l = e.get(u); let l = e.get(u);
return l.connected.forEach((y) => y(u)), l.connected.length = 0, l.disconnected.length || e.delete(u), !0; return l.connected.forEach((A) => A(u)), l.connected.length = 0, l.disconnected.length || e.delete(u), !0;
} }
return !1; return !1;
} }
function E(c, s) { function v(c, s) {
for (let u of c) { for (let u of c) {
if (s && a(u).then(E), !e.has(u)) if (s && a(u).then(v), !e.has(u))
continue; continue;
let l = e.get(u); let l = e.get(u);
return l.disconnected.forEach((y) => y(u)), l.connected.length = 0, l.disconnected.length = 0, e.delete(u), !0; return l.disconnected.forEach((A) => A(u)), l.connected.length = 0, l.disconnected.length = 0, e.delete(u), !0;
} }
return !1; return !1;
} }
} }
// index.js // index.js
[HTMLElement, DocumentFragment].forEach((e) => { [HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
let { append: t } = e.prototype; let { append: t } = e.prototype;
e.prototype.append = function(...n) { e.prototype.append = function(...n) {
return t.apply(this, n), this; return t.apply(this, n), this;
@ -266,7 +259,7 @@ function Z() {
// src/signals-lib.js // src/signals-lib.js
var d = Symbol.for("Signal"); var d = Symbol.for("Signal");
function A(e) { function y(e) {
try { try {
return Reflect.has(e, d); return Reflect.has(e, d);
} catch { } catch {
@ -277,10 +270,10 @@ var h = /* @__PURE__ */ new WeakMap();
function g(e, t) { function g(e, t) {
if (typeof e != "function") if (typeof e != "function")
return U(e, t); return U(e, t);
if (A(e)) if (y(e))
return e; return e;
let n = U(""), r = () => n(e()); let n = U(""), r = () => n(e());
return h.set(r, /* @__PURE__ */ new Set([n])), K(r), n; return h.set(r, /* @__PURE__ */ new Set([n])), k(r), n;
} }
g.action = function(e, t, ...n) { g.action = function(e, t, ...n) {
let r = e[d], { actions: o } = r; let r = e[d], { actions: o } = r;
@ -295,7 +288,7 @@ g.on = function e(t, n, r = {}) {
if (!(o && o.aborted)) { if (!(o && o.aborted)) {
if (Array.isArray(t)) if (Array.isArray(t))
return t.forEach((i) => e(i, n, r)); return t.forEach((i) => e(i, n, r));
D(t, n), o && o.addEventListener("abort", () => q(t, n)); N(t, n), o && o.addEventListener("abort", () => q(t, n));
} }
}; };
g.symbols = { g.symbols = {
@ -330,54 +323,54 @@ g.el = function(e, t) {
a.remove(); a.remove();
n.after(...f); n.after(...f);
}; };
return D(e, i), i(e()), o; return N(e, i), i(e()), o;
}; };
var $ = { var $ = {
isSignal: A, isSignal: y,
processReactiveAttribute(e, t, n, r) { processReactiveAttribute(e, t, n, r) {
return A(n) ? (D(n, (o) => r([t, o])), n()) : n; return y(n) ? (N(n, (o) => r([t, o])), n()) : n;
} }
}; };
function U(e, t) { function U(e, t) {
let n = (...r) => r.length ? Y(n, r[0]) : X(n); let n = (...r) => r.length ? X(n, r[0]) : Q(n);
return V(n, e, t); return Z(n, e, t);
} }
var G = Object.assign(/* @__PURE__ */ Object.create(null), { var V = Object.assign(/* @__PURE__ */ Object.create(null), {
stopPropagation() { stopPropagation() {
this.skip = !0; this.skip = !0;
} }
}); });
function V(e, t, n) { function Z(e, t, n) {
return _(n) !== "[object Object]" && (n = {}), e[d] = { return _(n) !== "[object Object]" && (n = {}), e[d] = {
value: t, value: t,
actions: n, actions: n,
listeners: /* @__PURE__ */ new Set() listeners: /* @__PURE__ */ new Set()
}, e.toJSON = () => e(), Object.setPrototypeOf(e[d], G), e; }, e.toJSON = () => e(), Object.setPrototypeOf(e[d], V), e;
} }
var R = []; var R = [];
function K(e) { function k(e) {
let t = function() { let t = function() {
R.push(t), e(), R.pop(); R.push(t), e(), R.pop();
}; };
h.has(e) && (h.set(t, h.get(e)), h.delete(e)), t(); h.has(e) && (h.set(t, h.get(e)), h.delete(e)), t();
} }
function Q() { function K() {
return R[R.length - 1]; return R[R.length - 1];
} }
function X(e) { function Q(e) {
if (!e[d]) if (!e[d])
return; return;
let { value: t, listeners: n } = e[d], r = Q(); let { value: t, listeners: n } = e[d], r = K();
return r && n.add(r), h.has(r) && h.get(r).add(e), t; return r && n.add(r), h.has(r) && h.get(r).add(e), t;
} }
function Y(e, t) { function X(e, t) {
if (!e[d]) if (!e[d])
return; return;
let n = e[d]; let n = e[d];
if (n.value !== t) if (n.value !== t)
return n.value = t, n.listeners.forEach((r) => r(t)), t; return n.value = t, n.listeners.forEach((r) => r(t)), t;
} }
function D(e, t) { function N(e, t) {
if (e[d]) if (e[d])
return e[d].listeners.add(t); return e[d].listeners.add(t);
} }
@ -390,14 +383,14 @@ function q(e, t) {
C($); C($);
export { export {
g as S, g as S,
w as assign, S as assign,
B as classListDeclarative, B as classListDeclarative,
ce as createElement, ce as createElement,
ae as dispatchEvent, ae as dispatchEvent,
ce as el, ce as el,
se as empty, se as empty,
A as isSignal, y as isSignal,
oe as namespace, oe as namespace,
z as on, T as on,
C as registerReactivity C as registerReactivity
}; };

171
dist/esm.js vendored
View File

@ -3,11 +3,11 @@ var g = {
isSignal(e) { isSignal(e) {
return !1; return !1;
}, },
processReactiveAttribute(e, t, r, n) { processReactiveAttribute(e, t, n, r) {
return r; return n;
} }
}; };
function P(e, t = !0) { function y(e, t = !0) {
return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e); return t ? Object.assign(g, e) : (Object.setPrototypeOf(e, g), e);
} }
function v(e) { function v(e) {
@ -28,10 +28,10 @@ function w(e, t) {
} }
// src/dom-common.js // src/dom-common.js
var C = { setDeleteAttr: y }; var R = { setDeleteAttr: P };
function y(e, t, r) { function P(e, t, n) {
if (Reflect.set(e, t, r), !!p(r)) { if (Reflect.set(e, t, n), !!p(n)) {
if (e instanceof HTMLElement && e.getAttribute(t) === "undefined") if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
return e.removeAttribute(t); return e.removeAttribute(t);
if (Reflect.get(e, t) === "undefined") if (Reflect.get(e, t) === "undefined")
return Reflect.set(e, t, ""); return Reflect.set(e, t, "");
@ -39,43 +39,43 @@ function y(e, t, r) {
} }
// src/dom.js // src/dom.js
var m = "html"; var x = "html";
function I(e) { function H(e) {
return m = e === "svg" ? "http://www.w3.org/2000/svg" : e, { return x = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
append(...t) { append(...t) {
return m = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t); return x = "html", t.length === 1 ? t[0] : document.createDocumentFragment().append(...t);
} }
}; };
} }
function Z(e, t, ...r) { function I(e, t, ...n) {
let n = v(this), c; let r = v(this), c;
switch ((Object(t) !== t || n.isSignal(t)) && (t = { textContent: t }), !0) { switch ((Object(t) !== t || r.isSignal(t)) && (t = { textContent: t }), !0) {
case typeof e == "function": { case typeof e == "function": {
c = e(t || void 0, (l) => l ? (r.unshift(l), void 0) : c); c = e(t || void 0, (l) => l ? (n.unshift(l), void 0) : c);
break; break;
} }
case e === "#text": case e === "#text":
c = x(document.createTextNode(""), t); c = m(document.createTextNode(""), t);
break; break;
case e === "<>": case e === "<>":
c = x(document.createDocumentFragment(), t); c = m(document.createDocumentFragment(), t);
break; break;
case m !== "html": case x !== "html":
c = x(document.createElementNS(m, e), t); c = m(document.createElementNS(x, e), t);
break; break;
case !c: case !c:
c = x(document.createElement(e), t); c = m(document.createElement(e), t);
} }
return r.forEach((d) => d(c)), c; return n.forEach((d) => d(c)), c;
} }
var { setDeleteAttr: R } = C; var { setDeleteAttr: C } = R;
function x(e, ...t) { function m(e, ...t) {
let r = this, n = v(this); let n = this, r = v(this);
if (!t.length) if (!t.length)
return e; return e;
let c = e instanceof SVGElement, d = (c ? F : j).bind(null, e, "Attribute"); let d = (e instanceof SVGElement ? M : F).bind(null, e, "Attribute");
return Object.entries(Object.assign({}, ...t)).forEach(function l([f, u]) { return Object.entries(Object.assign({}, ...t)).forEach(function l([f, u]) {
u = n.processReactiveAttribute(e, f, u, l); u = r.processReactiveAttribute(e, f, u, l);
let [h] = f; let [h] = f;
if (h === "=") if (h === "=")
return d(f.slice(1), u); return d(f.slice(1), u);
@ -84,96 +84,89 @@ function x(e, ...t) {
if (/(aria|data)([A-Z])/.test(f)) if (/(aria|data)([A-Z])/.test(f))
return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), d(f, u); return f = f.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), d(f, u);
switch (f === "className" && (f = "class"), f) { switch (f === "className" && (f = "class"), f) {
case "href":
case "src":
case "class":
case "xlink:href": case "xlink:href":
return d( return d(f, u, "http://www.w3.org/1999/xlink");
f,
u,
/* this applies only to SVG elements, see setRemove/setRemoveNS */
"http://www.w3.org/1999/xlink"
);
case "textContent": case "textContent":
case "innerText": return C(e, f, u);
return c ? e.appendChild(document.createTextNode(u)) : R(e, f, u);
case "style": case "style":
if (typeof u != "object")
break;
case "dataset": case "dataset":
return O(n, u, D.bind(null, e[f])); return O(r, u, D.bind(null, e[f]));
case "ariaset": case "ariaset":
return O(n, u, (E, o) => d("aria-" + E, o)); return O(r, u, (E, o) => d("aria-" + E, o));
case "classList": case "classList":
return _.call(r, e, u); return _.call(n, e, u);
} }
return T(e, f) ? R(e, f, u) : d(f, u); return j(e, f) ? C(e, f, u) : d(f, u);
}), e; }), e;
} }
function _(e, t) { function _(e, t) {
let r = v(this); let n = v(this);
return O( return O(
r, n,
t, t,
(n, c) => e.classList.toggle(n, c === -1 ? void 0 : !!c) (r, c) => e.classList.toggle(r, c === -1 ? void 0 : !!c)
), e; ), e;
} }
function G(e) { function Z(e) {
return Array.from(e.children).forEach((t) => t.remove()), e; return Array.from(e.children).forEach((t) => t.remove()), e;
} }
function T(e, t) { function j(e, t) {
if (!Reflect.has(e, t)) if (!Reflect.has(e, t))
return !1; return !1;
let r = L(e, t); let n = L(e, t);
return !p(r.set); return !p(n.set);
} }
function L(e, t, r = 0) { function L(e, t) {
if (e = Object.getPrototypeOf(e), !e) if (e = Object.getPrototypeOf(e), !e)
return {}; return {};
let n = Object.getOwnPropertyDescriptor(e, t); let n = Object.getOwnPropertyDescriptor(e, t);
return n || L(e, t, r + 1); return n || L(e, t);
} }
function O(e, t, r) { function O(e, t, n) {
if (typeof t == "object") if (!(typeof t != "object" || t === null))
return Object.entries(t).forEach(function([c, d]) { return Object.entries(t).forEach(function([c, d]) {
c && (d = e.processReactiveAttribute(t, c, d, (l) => r(...l)), r(c, d)); c && (d = e.processReactiveAttribute(t, c, d, (l) => n(...l)), n(c, d));
}); });
} }
function N(e) { function S(e) {
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e; return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
} }
function j(e, t, r, n) { function F(e, t, n, r) {
return e[(p(n) ? "remove" : "set") + t](r, N(n)); return e[(p(r) ? "remove" : "set") + t](n, S(r));
} }
function F(e, t, r, n, c = null) { function M(e, t, n, r, c = null) {
return e[(p(n) ? "remove" : "set") + t + "NS"](c, r, N(n)); return e[(p(r) ? "remove" : "set") + t + "NS"](c, n, S(r));
} }
function D(e, t, r) { function D(e, t, n) {
if (Reflect.set(e, t, r), !!p(r)) if (Reflect.set(e, t, n), !!p(n))
return Reflect.deleteProperty(e, t); return Reflect.deleteProperty(e, t);
} }
// src/events.js // src/events.js
function J(e, t, ...r) { function J(e, t, ...n) {
let n = r.length ? new CustomEvent(t, { detail: r[0] }) : new Event(t); let r = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
return e.dispatchEvent(n); return e.dispatchEvent(r);
} }
function S(e, t, r) { function N(e, t, n) {
return function(c) { return function(c) {
return c.addEventListener(e, t, r), c; return c.addEventListener(e, t, n), c;
}; };
} }
var b = M(); var b = T();
S.connected = function(e, t) { N.connected = function(e, t) {
return function(n) { return function(r) {
return typeof n.connectedCallback == "function" ? (n.addEventListener("dde:connected", e, t), n) : (w(t && t.signal, () => b.offConnected(n, e)) && (n.isConnected ? e(new Event("dde:connected")) : b.onConnected(n, e)), n); return typeof r.connectedCallback == "function" ? (r.addEventListener("dde:connected", e, t), r) : (w(t && t.signal, () => b.offConnected(r, e)) && (r.isConnected ? e(new Event("dde:connected")) : b.onConnected(r, e)), r);
}; };
}; };
S.disconnected = function(e, t) { N.disconnected = function(e, t) {
return function(n) { return function(r) {
return typeof n.disconnectedCallback == "function" ? (n.addEventListener("dde:disconnected", e, t), n) : (w(t && t.signal, () => b.offDisconnected(n, e)) && b.onDisconnected(n, e), n); return typeof r.disconnectedCallback == "function" ? (r.addEventListener("dde:disconnected", e, t), r) : (w(t && t.signal, () => b.offDisconnected(r, e)) && b.onDisconnected(r, e), r);
}; };
}; };
function M() { function T() {
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) { let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(o) {
for (let s of o) for (let s of o)
if (s.type === "childList") { if (s.type === "childList") {
if (h(s.addedNodes, !0)) { if (h(s.addedNodes, !0)) {
@ -191,7 +184,7 @@ function M() {
if (!e.has(o)) if (!e.has(o))
return; return;
let i = e.get(o), a = i.connected; let i = e.get(o), a = i.connected;
a.splice(a.indexOf(s), 1), n(o, i); a.splice(a.indexOf(s), 1), r(o, i);
}, },
onDisconnected(o, s) { onDisconnected(o, s) {
d(), c(o).disconnected.push(s); d(), c(o).disconnected.push(s);
@ -200,10 +193,10 @@ function M() {
if (!e.has(o)) if (!e.has(o))
return; return;
let i = e.get(o), a = i.disconnected; let i = e.get(o), a = i.disconnected;
a.splice(a.indexOf(s), 1), n(o, i); a.splice(a.indexOf(s), 1), r(o, i);
} }
}; };
function n(o, s) { function r(o, s) {
s.connected.length || s.disconnected.length || (e.delete(o), l()); s.connected.length || s.disconnected.length || (e.delete(o), l());
} }
function c(o) { function c(o) {
@ -213,10 +206,10 @@ function M() {
return e.set(o, s), s; return e.set(o, s), s;
} }
function d() { function d() {
t || (t = !0, r.observe(document.body, { childList: !0, subtree: !0 })); t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
} }
function l() { function l() {
!t || e.size || (t = !1, r.disconnect()); !t || e.size || (t = !1, n.disconnect());
} }
function f() { function f() {
return new Promise(function(o) { return new Promise(function(o) {
@ -253,20 +246,20 @@ function M() {
} }
// index.js // index.js
[HTMLElement, DocumentFragment].forEach((e) => { [HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
let { append: t } = e.prototype; let { append: t } = e.prototype;
e.prototype.append = function(...r) { e.prototype.append = function(...n) {
return t.apply(this, r), this; return t.apply(this, n), this;
}; };
}); });
export { export {
x as assign, m as assign,
_ as classListDeclarative, _ as classListDeclarative,
Z as createElement, I as createElement,
J as dispatchEvent, J as dispatchEvent,
Z as el, I as el,
G as empty, Z as empty,
I as namespace, H as namespace,
S as on, N as on,
P as registerReactivity y as registerReactivity
}; };