2023-09-05 09:25:47 +02:00
|
|
|
//deka-dom-el library is available via global namespace `dde`
|
|
|
|
(()=> {
|
2023-09-13 13:20:00 +02:00
|
|
|
// src/signals-common.js
|
2023-10-14 12:43:53 +02:00
|
|
|
var x = {
|
2023-09-21 12:35:27 +02:00
|
|
|
isSignal(e) {
|
|
|
|
return !1;
|
2023-09-13 13:20:00 +02:00
|
|
|
},
|
2023-10-14 12:43:53 +02:00
|
|
|
processReactiveAttribute(e, t, n, o) {
|
2023-09-19 12:34:42 +02:00
|
|
|
return n;
|
2023-09-13 13:20:00 +02:00
|
|
|
}
|
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
function D(e, t = !0) {
|
2023-10-14 12:43:53 +02:00
|
|
|
return t ? Object.assign(x, e) : (Object.setPrototypeOf(e, x), e);
|
2023-09-13 13:20:00 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function y(e) {
|
|
|
|
return x.isPrototypeOf(e) && e !== x ? e : x;
|
2023-09-13 13:20:00 +02:00
|
|
|
}
|
|
|
|
|
2023-09-05 09:25:47 +02:00
|
|
|
// src/helpers.js
|
2023-10-14 16:18:11 +02:00
|
|
|
function E(e) {
|
2023-09-13 13:20:00 +02:00
|
|
|
return typeof e > "u";
|
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function T(e) {
|
2023-09-05 09:25:47 +02:00
|
|
|
let t = typeof e;
|
|
|
|
return t !== "object" ? t : e === null ? "null" : Object.prototype.toString.call(e);
|
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function A(e, t) {
|
2023-09-09 21:15:43 +02:00
|
|
|
if (!e || !(e instanceof AbortSignal))
|
|
|
|
return !0;
|
|
|
|
if (!e.aborted)
|
|
|
|
return e.addEventListener("abort", t), function() {
|
|
|
|
e.removeEventListener("abort", t);
|
|
|
|
};
|
|
|
|
}
|
2023-09-05 09:25:47 +02:00
|
|
|
|
2023-09-13 13:20:00 +02:00
|
|
|
// src/dom-common.js
|
2023-10-14 12:43:53 +02:00
|
|
|
var M = { setDeleteAttr: I };
|
|
|
|
function I(e, t, n) {
|
2023-10-14 16:18:11 +02:00
|
|
|
if (Reflect.set(e, t, n), !!E(n)) {
|
2023-09-21 16:27:00 +02:00
|
|
|
if (Reflect.deleteProperty(e, t), e instanceof HTMLElement && e.getAttribute(t) === "undefined")
|
2023-09-21 12:35:27 +02:00
|
|
|
return e.removeAttribute(t);
|
|
|
|
if (Reflect.get(e, t) === "undefined")
|
|
|
|
return Reflect.set(e, t, "");
|
|
|
|
}
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// src/dom.js
|
2023-10-13 20:57:21 +02:00
|
|
|
var S = [{
|
|
|
|
scope: document.body,
|
|
|
|
namespace: "html",
|
|
|
|
host: (e) => e ? e(document.body) : document.body,
|
|
|
|
prevent: !0
|
2023-10-14 16:18:11 +02:00
|
|
|
}], W = (e) => e === "svg" ? "http://www.w3.org/2000/svg" : e, b = {
|
2023-10-10 10:55:00 +02:00
|
|
|
get current() {
|
2023-10-13 20:57:21 +02:00
|
|
|
return S[S.length - 1];
|
2023-10-10 10:55:00 +02:00
|
|
|
},
|
|
|
|
get host() {
|
|
|
|
return this.current.host;
|
|
|
|
},
|
|
|
|
get namespace() {
|
|
|
|
return this.current.namespace;
|
|
|
|
},
|
|
|
|
set namespace(e) {
|
2023-10-13 16:51:43 +02:00
|
|
|
return this.current.namespace = W(e);
|
2023-10-10 10:55:00 +02:00
|
|
|
},
|
2023-10-13 20:57:21 +02:00
|
|
|
preventDefault() {
|
|
|
|
let { current: e } = this;
|
|
|
|
return e.prevent = !0, e;
|
|
|
|
},
|
2023-10-09 13:49:38 +02:00
|
|
|
elNamespace(e) {
|
2023-10-10 10:55:00 +02:00
|
|
|
let t = this.namespace;
|
|
|
|
return this.namespace = e, {
|
|
|
|
append(...n) {
|
2023-10-14 16:18:11 +02:00
|
|
|
return b.namespace = t, n.length === 1 ? n[0] : document.createDocumentFragment().append(...n);
|
2023-10-09 13:49:38 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
2023-10-14 12:43:53 +02:00
|
|
|
get state() {
|
|
|
|
return [...S];
|
|
|
|
},
|
2023-10-10 10:55:00 +02:00
|
|
|
push(e = {}) {
|
2023-10-13 20:57:21 +02:00
|
|
|
return e.namespace && (e.namespace = W(e.namespace)), S.push(Object.assign({}, this.current, { prevent: !1 }, e));
|
2023-10-09 13:49:38 +02:00
|
|
|
},
|
2023-10-10 10:55:00 +02:00
|
|
|
pop() {
|
2023-10-13 20:57:21 +02:00
|
|
|
return S.pop();
|
2023-10-09 13:49:38 +02:00
|
|
|
}
|
2023-10-10 10:55:00 +02:00
|
|
|
};
|
2023-10-13 16:37:04 +02:00
|
|
|
function ie(e, t, ...n) {
|
2023-10-14 16:18:11 +02:00
|
|
|
let o = y(this), { namespace: r } = b, c = 0, i;
|
2023-09-21 17:04:40 +02:00
|
|
|
switch ((Object(t) !== t || o.isSignal(t)) && (t = { textContent: t }), !0) {
|
2023-09-09 21:15:43 +02:00
|
|
|
case typeof e == "function": {
|
2023-10-14 16:18:11 +02:00
|
|
|
c = 1, b.push({ scope: e, host: (s) => s ? (c === 1 ? n.unshift(s) : s(i), void 0) : i }), i = e(t || void 0), (i instanceof HTMLElement ? $ : q)(i, "Attribute", "dde-fun", e.name);
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
2023-09-09 21:15:43 +02:00
|
|
|
}
|
2023-09-05 09:25:47 +02:00
|
|
|
case e === "#text":
|
2023-10-14 16:18:11 +02:00
|
|
|
i = O.call(this, document.createTextNode(""), t);
|
2023-09-08 20:18:58 +02:00
|
|
|
break;
|
|
|
|
case e === "<>":
|
2023-10-14 16:18:11 +02:00
|
|
|
i = O.call(this, document.createDocumentFragment(), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
2023-10-14 12:43:53 +02:00
|
|
|
case r !== "html":
|
2023-10-14 16:18:11 +02:00
|
|
|
i = O.call(this, document.createElementNS(r, e), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
2023-10-14 16:18:11 +02:00
|
|
|
case !i:
|
|
|
|
i = O.call(this, document.createElement(e), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
return n.forEach((s) => s(i)), c && b.pop(), c = 2, i;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
var { setDeleteAttr: F } = M;
|
2023-10-13 16:37:04 +02:00
|
|
|
function O(e, ...t) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let n = this, o = y(this);
|
2023-09-05 09:25:47 +02:00
|
|
|
if (!t.length)
|
|
|
|
return e;
|
2023-10-13 20:57:21 +02:00
|
|
|
let c = (e instanceof SVGElement ? q : $).bind(null, e, "Attribute");
|
2023-10-14 16:18:11 +02:00
|
|
|
return Object.entries(Object.assign({}, ...t)).forEach(function i([s, d]) {
|
|
|
|
d = o.processReactiveAttribute(e, s, d, i);
|
|
|
|
let [m] = s;
|
|
|
|
if (m === "=")
|
2023-10-14 12:43:53 +02:00
|
|
|
return c(s.slice(1), d);
|
2023-10-14 16:18:11 +02:00
|
|
|
if (m === ".")
|
2023-10-14 12:43:53 +02:00
|
|
|
return z(e, s.slice(1), d);
|
2023-10-10 10:55:00 +02:00
|
|
|
if (/(aria|data)([A-Z])/.test(s))
|
2023-10-14 12:43:53 +02:00
|
|
|
return s = s.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), c(s, d);
|
2023-10-10 10:55:00 +02:00
|
|
|
switch (s === "className" && (s = "class"), s) {
|
2023-09-21 13:14:55 +02:00
|
|
|
case "xlink:href":
|
2023-10-14 12:43:53 +02:00
|
|
|
return c(s, d, "http://www.w3.org/1999/xlink");
|
2023-09-05 09:25:47 +02:00
|
|
|
case "textContent":
|
2023-10-14 12:43:53 +02:00
|
|
|
return F(e, s, d);
|
2023-09-21 14:37:20 +02:00
|
|
|
case "style":
|
2023-10-14 12:43:53 +02:00
|
|
|
if (typeof d != "object")
|
2023-09-21 16:27:00 +02:00
|
|
|
break;
|
2023-09-21 14:37:20 +02:00
|
|
|
case "dataset":
|
2023-10-14 16:18:11 +02:00
|
|
|
return P(o, d, z.bind(null, e[s]));
|
2023-09-21 14:37:20 +02:00
|
|
|
case "ariaset":
|
2023-10-14 16:18:11 +02:00
|
|
|
return P(o, d, (v, u) => c("aria-" + v, u));
|
2023-09-21 14:37:20 +02:00
|
|
|
case "classList":
|
2023-10-14 12:43:53 +02:00
|
|
|
return J.call(n, e, d);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
return V(e, s) ? F(e, s, d) : c(s, d);
|
2023-09-05 09:25:47 +02:00
|
|
|
}), e;
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function J(e, t) {
|
|
|
|
let n = y(this);
|
2023-10-14 16:18:11 +02:00
|
|
|
return P(
|
2023-09-21 12:35:27 +02:00
|
|
|
n,
|
2023-09-05 09:25:47 +02:00
|
|
|
t,
|
2023-10-14 12:43:53 +02:00
|
|
|
(o, r) => e.classList.toggle(o, r === -1 ? void 0 : !!r)
|
2023-09-05 09:25:47 +02:00
|
|
|
), e;
|
|
|
|
}
|
2023-10-09 13:49:38 +02:00
|
|
|
function fe(e) {
|
2023-09-05 09:25:47 +02:00
|
|
|
return Array.from(e.children).forEach((t) => t.remove()), e;
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function V(e, t) {
|
2023-09-21 12:35:27 +02:00
|
|
|
if (!Reflect.has(e, t))
|
|
|
|
return !1;
|
2023-10-13 20:57:21 +02:00
|
|
|
let n = H(e, t);
|
2023-10-14 16:18:11 +02:00
|
|
|
return !E(n.set);
|
2023-09-06 14:54:28 +02:00
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function H(e, t) {
|
2023-09-06 14:54:28 +02:00
|
|
|
if (e = Object.getPrototypeOf(e), !e)
|
2023-09-21 12:35:27 +02:00
|
|
|
return {};
|
2023-09-21 16:27:00 +02:00
|
|
|
let n = Object.getOwnPropertyDescriptor(e, t);
|
2023-10-13 20:57:21 +02:00
|
|
|
return n || H(e, t);
|
2023-09-06 14:54:28 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
function P(e, t, n) {
|
2023-09-21 16:27:00 +02:00
|
|
|
if (!(typeof t != "object" || t === null))
|
2023-10-14 12:43:53 +02:00
|
|
|
return Object.entries(t).forEach(function([r, c]) {
|
2023-10-14 16:18:11 +02:00
|
|
|
r && (c = e.processReactiveAttribute(t, r, c, (i) => n(...i)), n(r, c));
|
2023-09-21 14:37:20 +02:00
|
|
|
});
|
2023-09-21 12:35:27 +02:00
|
|
|
}
|
2023-10-13 16:51:43 +02:00
|
|
|
function U(e) {
|
2023-09-21 12:35:27 +02:00
|
|
|
return Array.isArray(e) ? e.filter(Boolean).join(" ") : e;
|
2023-09-19 12:34:42 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function $(e, t, n, o) {
|
2023-10-14 16:18:11 +02:00
|
|
|
return e[(E(o) ? "remove" : "set") + t](n, U(o));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function q(e, t, n, o, r = null) {
|
2023-10-14 16:18:11 +02:00
|
|
|
return e[(E(o) ? "remove" : "set") + t + "NS"](r, n, U(o));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function z(e, t, n) {
|
2023-10-14 16:18:11 +02:00
|
|
|
if (Reflect.set(e, t, n), !!E(n))
|
2023-09-19 12:34:42 +02:00
|
|
|
return Reflect.deleteProperty(e, t);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// src/events.js
|
2023-10-13 16:37:04 +02:00
|
|
|
function le(e, t, ...n) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let o = n.length ? new CustomEvent(t, { detail: n[0] }) : new Event(t);
|
|
|
|
return e.dispatchEvent(o);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
function _(e, t, n) {
|
2023-10-14 12:43:53 +02:00
|
|
|
return function(r) {
|
|
|
|
return r.addEventListener(e, t, n), r;
|
2023-09-09 21:15:43 +02:00
|
|
|
};
|
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
var R = K(), Z = /* @__PURE__ */ new WeakSet();
|
2023-10-14 16:18:11 +02:00
|
|
|
_.connected = function(e, t) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let n = "connected";
|
2023-10-14 12:43:53 +02:00
|
|
|
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let c = "dde:" + n;
|
2023-10-14 12:43:53 +02:00
|
|
|
return r.addEventListener(c, e, t), r.__dde_lifecycleToEvents ? r : r.isConnected ? (r.dispatchEvent(new Event(c)), r) : (A(t.signal, () => R.offConnected(r, e)) && R.onConnected(r, e), r);
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
_.disconnected = function(e, t) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let n = "disconnected";
|
2023-10-14 12:43:53 +02:00
|
|
|
return typeof t != "object" && (t = {}), t.once = !0, function(r) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let c = "dde:" + n;
|
2023-10-14 12:43:53 +02:00
|
|
|
return r.addEventListener(c, e, t), r.__dde_lifecycleToEvents || A(t.signal, () => R.offDisconnected(r, e)) && R.onDisconnected(r, e), r;
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
_.attributeChanged = function(e, t) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let n = "attributeChanged";
|
2023-10-14 12:43:53 +02:00
|
|
|
return typeof t != "object" && (t = {}), function(r) {
|
2023-10-13 16:37:04 +02:00
|
|
|
let c = "dde:" + n;
|
2023-10-14 12:43:53 +02:00
|
|
|
if (r.addEventListener(c, e, t), r.__dde_lifecycleToEvents || Z.has(r))
|
|
|
|
return r;
|
2023-10-14 16:18:11 +02:00
|
|
|
let i = new MutationObserver(function(d) {
|
|
|
|
for (let { attributeName: m, target: v } of d)
|
|
|
|
v.dispatchEvent(
|
|
|
|
new CustomEvent(c, { detail: [m, v.getAttribute(m)] })
|
2023-10-13 16:37:04 +02:00
|
|
|
);
|
|
|
|
});
|
2023-10-14 16:18:11 +02:00
|
|
|
return A(t.signal, () => i.disconnect()) && i.observe(r, { attributes: !0 }), r;
|
2023-10-13 16:37:04 +02:00
|
|
|
};
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
function K() {
|
2023-10-14 16:18:11 +02:00
|
|
|
let e = /* @__PURE__ */ new Map(), t = !1, n = new MutationObserver(function(u) {
|
|
|
|
for (let f of u)
|
2023-10-13 20:57:21 +02:00
|
|
|
if (f.type === "childList") {
|
2023-10-14 16:18:11 +02:00
|
|
|
if (m(f.addedNodes, !0)) {
|
|
|
|
i();
|
2023-09-05 09:25:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
v(f.removedNodes, !0) && i();
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return {
|
2023-10-14 16:18:11 +02:00
|
|
|
onConnected(u, f) {
|
2023-10-13 16:37:04 +02:00
|
|
|
c();
|
2023-10-14 16:18:11 +02:00
|
|
|
let a = r(u);
|
2023-10-13 20:57:21 +02:00
|
|
|
a.connected.has(f) || (a.connected.add(f), a.length_c += 1);
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-10-14 16:18:11 +02:00
|
|
|
offConnected(u, f) {
|
|
|
|
if (!e.has(u))
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-10-14 16:18:11 +02:00
|
|
|
let a = e.get(u);
|
|
|
|
a.connected.has(f) && (a.connected.delete(f), a.length_c -= 1, o(u, a));
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-10-14 16:18:11 +02:00
|
|
|
onDisconnected(u, f) {
|
2023-10-13 16:37:04 +02:00
|
|
|
c();
|
2023-10-14 16:18:11 +02:00
|
|
|
let a = r(u);
|
2023-10-13 20:57:21 +02:00
|
|
|
a.disconnected.has(f) || (a.disconnected.add(f), a.length_d += 1);
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-10-14 16:18:11 +02:00
|
|
|
offDisconnected(u, f) {
|
|
|
|
if (!e.has(u))
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-10-14 16:18:11 +02:00
|
|
|
let a = e.get(u);
|
|
|
|
a.disconnected.has(f) && (a.disconnected.delete(f), a.length_d -= 1, o(u, a));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
function o(u, f) {
|
|
|
|
f.length_c || f.length_d || (e.delete(u), i());
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
function r(u) {
|
|
|
|
if (e.has(u))
|
|
|
|
return e.get(u);
|
2023-10-13 20:57:21 +02:00
|
|
|
let f = {
|
2023-10-09 13:49:38 +02:00
|
|
|
connected: /* @__PURE__ */ new WeakSet(),
|
|
|
|
length_c: 0,
|
|
|
|
disconnected: /* @__PURE__ */ new WeakSet(),
|
|
|
|
length_d: 0
|
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
return e.set(u, f), f;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function c() {
|
2023-09-19 12:34:42 +02:00
|
|
|
t || (t = !0, n.observe(document.body, { childList: !0, subtree: !0 }));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
function i() {
|
2023-09-19 12:34:42 +02:00
|
|
|
!t || e.size || (t = !1, n.disconnect());
|
2023-09-11 18:32:05 +02:00
|
|
|
}
|
2023-10-10 10:55:00 +02:00
|
|
|
function s() {
|
2023-10-14 16:18:11 +02:00
|
|
|
return new Promise(function(u) {
|
|
|
|
(requestIdleCallback || requestAnimationFrame)(u);
|
2023-09-05 09:25:47 +02:00
|
|
|
});
|
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
async function d(u) {
|
2023-10-10 10:55:00 +02:00
|
|
|
e.size > 30 && await s();
|
2023-10-13 20:57:21 +02:00
|
|
|
let f = [];
|
2023-10-14 16:18:11 +02:00
|
|
|
if (!(u instanceof Node))
|
2023-10-13 20:57:21 +02:00
|
|
|
return f;
|
2023-10-13 17:13:03 +02:00
|
|
|
for (let a of e.keys())
|
2023-10-14 16:18:11 +02:00
|
|
|
a === u || !(a instanceof Node) || u.contains(a) && f.push(a);
|
2023-10-13 20:57:21 +02:00
|
|
|
return f;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
function m(u, f) {
|
2023-10-13 17:13:03 +02:00
|
|
|
let a = !1;
|
2023-10-14 16:18:11 +02:00
|
|
|
for (let h of u) {
|
|
|
|
if (f && d(h).then(m), !e.has(h))
|
2023-09-09 21:15:43 +02:00
|
|
|
continue;
|
2023-10-14 16:18:11 +02:00
|
|
|
let w = e.get(h);
|
|
|
|
w.length_c && (h.dispatchEvent(new Event("dde:connected")), w.connected = /* @__PURE__ */ new WeakSet(), w.length_c = 0, w.length_d || e.delete(h), a = !0);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 17:13:03 +02:00
|
|
|
return a;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
function v(u, f) {
|
2023-10-13 17:13:03 +02:00
|
|
|
let a = !1;
|
2023-10-14 16:18:11 +02:00
|
|
|
for (let h of u)
|
|
|
|
f && d(h).then(v), !(!e.has(h) || !e.get(h).length_d) && (h.dispatchEvent(new Event("dde:disconnected")), e.delete(h), a = !0);
|
2023-10-13 17:13:03 +02:00
|
|
|
return a;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// index.js
|
2023-09-21 16:27:00 +02:00
|
|
|
[HTMLElement, SVGElement, DocumentFragment].forEach((e) => {
|
2023-09-05 09:25:47 +02:00
|
|
|
let { append: t } = e.prototype;
|
2023-09-19 12:34:42 +02:00
|
|
|
e.prototype.append = function(...n) {
|
|
|
|
return t.apply(this, n), this;
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
// src/signals-lib.js
|
2023-10-13 16:37:04 +02:00
|
|
|
var l = Symbol.for("Signal");
|
|
|
|
function C(e) {
|
2023-09-05 09:25:47 +02:00
|
|
|
try {
|
2023-10-13 16:37:04 +02:00
|
|
|
return Reflect.has(e, l);
|
2023-09-05 09:25:47 +02:00
|
|
|
} catch {
|
|
|
|
return !1;
|
|
|
|
}
|
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
var L = [], g = /* @__PURE__ */ new WeakMap();
|
|
|
|
function p(e, t) {
|
2023-09-05 09:25:47 +02:00
|
|
|
if (typeof e != "function")
|
2023-10-13 20:57:21 +02:00
|
|
|
return k(e, t);
|
2023-10-13 16:37:04 +02:00
|
|
|
if (C(e))
|
2023-09-05 09:25:47 +02:00
|
|
|
return e;
|
2023-10-14 12:43:53 +02:00
|
|
|
let n = k(), o = function() {
|
|
|
|
L.push(o), n(e()), L.pop();
|
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
return g.set(o, /* @__PURE__ */ new Set([n])), g.set(n[l], o), o(), n;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
p.action = function(e, t, ...n) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let o = e[l], { actions: r } = o;
|
|
|
|
if (!r || !Reflect.has(r, t))
|
2023-09-05 09:25:47 +02:00
|
|
|
throw new Error(`'${e}' has no action with name '${t}'!`);
|
2023-10-14 12:43:53 +02:00
|
|
|
if (r[t].apply(o, n), o.skip)
|
|
|
|
return Reflect.deleteProperty(o, "skip");
|
|
|
|
o.listeners.forEach((c) => c(o.value));
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
p.on = function e(t, n, o = {}) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let { signal: r } = o;
|
|
|
|
if (!(r && r.aborted)) {
|
2023-09-07 17:35:23 +02:00
|
|
|
if (Array.isArray(t))
|
2023-10-14 12:43:53 +02:00
|
|
|
return t.forEach((c) => e(c, n, o));
|
2023-10-14 16:18:11 +02:00
|
|
|
j(t, n), r && r.addEventListener("abort", () => N(t, n));
|
2023-09-07 17:35:23 +02:00
|
|
|
}
|
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
p.symbols = {
|
2023-10-13 16:37:04 +02:00
|
|
|
signal: l,
|
2023-09-07 17:35:23 +02:00
|
|
|
onclear: Symbol.for("Signal.onclear")
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
p.attribute = function(e, t = void 0) {
|
|
|
|
let { host: n } = b, o = n() && n().hasAttribute(e) ? n().getAttribute(e) : t, r = new AbortController(), c = p(o, {
|
|
|
|
[p.symbols.onclear]() {
|
2023-10-14 12:43:53 +02:00
|
|
|
r.abort();
|
2023-10-13 16:37:04 +02:00
|
|
|
}
|
|
|
|
});
|
2023-10-14 16:18:11 +02:00
|
|
|
return b.host(_.attributeChanged(function({ detail: s }) {
|
|
|
|
let [d, m] = s;
|
|
|
|
d === e && c(m);
|
2023-10-14 12:43:53 +02:00
|
|
|
}, { signal: r.signal })), c;
|
2023-10-13 16:37:04 +02:00
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
p.clear = function(...e) {
|
2023-09-19 12:34:42 +02:00
|
|
|
for (let n of e) {
|
|
|
|
Reflect.deleteProperty(n, "toJSON");
|
2023-10-14 12:43:53 +02:00
|
|
|
let o = n[l];
|
|
|
|
o.onclear.forEach((r) => r.call(o)), t(n, o), Reflect.deleteProperty(n, l);
|
2023-09-08 10:52:45 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
function t(n, o) {
|
|
|
|
o.listeners.forEach((r) => {
|
2023-10-14 16:18:11 +02:00
|
|
|
if (o.listeners.delete(r), !g.has(r))
|
2023-09-08 10:52:45 +02:00
|
|
|
return;
|
2023-10-14 16:18:11 +02:00
|
|
|
let c = g.get(r);
|
|
|
|
c.delete(n), !(c.size > 1) && (p.clear(...c), g.delete(r));
|
2023-09-08 10:52:45 +02:00
|
|
|
});
|
2023-09-07 17:35:23 +02:00
|
|
|
}
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
p.el = function(e, t) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let n = document.createComment("<#reactive>"), o = document.createComment("</#reactive>"), r = document.createDocumentFragment();
|
|
|
|
r.append(n, o);
|
2023-10-14 16:18:11 +02:00
|
|
|
let c = (i) => {
|
2023-10-14 12:43:53 +02:00
|
|
|
if (!n.parentNode || !o.parentNode)
|
2023-10-14 16:18:11 +02:00
|
|
|
return N(e, c);
|
|
|
|
let s = t(i);
|
2023-10-14 12:43:53 +02:00
|
|
|
Array.isArray(s) || (s = [s]);
|
|
|
|
let d = n;
|
|
|
|
for (; (d = n.nextSibling) !== o; )
|
|
|
|
d.remove();
|
|
|
|
n.after(...s);
|
2023-09-08 20:18:58 +02:00
|
|
|
};
|
2023-10-14 16:18:11 +02:00
|
|
|
return j(e, c), G(e, c, n, t), c(e()), r;
|
2023-09-08 20:18:58 +02:00
|
|
|
};
|
2023-10-13 20:57:21 +02:00
|
|
|
var B = {
|
2023-10-13 16:37:04 +02:00
|
|
|
isSignal: C,
|
2023-10-14 12:43:53 +02:00
|
|
|
processReactiveAttribute(e, t, n, o) {
|
2023-10-13 20:57:21 +02:00
|
|
|
if (!C(n))
|
|
|
|
return n;
|
2023-10-14 12:43:53 +02:00
|
|
|
let r = (c) => o([t, c]);
|
2023-10-14 16:18:11 +02:00
|
|
|
return j(n, r), G(n, r, e, t), n();
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
};
|
2023-10-14 12:43:53 +02:00
|
|
|
function G(e, t, ...n) {
|
2023-10-14 16:18:11 +02:00
|
|
|
let { current: o } = b;
|
2023-10-14 12:43:53 +02:00
|
|
|
if (o.prevent)
|
|
|
|
return;
|
|
|
|
let r = "__dde_reactive";
|
|
|
|
o.host(function(c) {
|
2023-10-14 16:18:11 +02:00
|
|
|
c[r] || (c[r] = [], _.disconnected(
|
2023-10-14 12:43:53 +02:00
|
|
|
() => (
|
|
|
|
/*!
|
2023-10-14 16:18:11 +02:00
|
|
|
* Clears all signals listeners added in the current scope/host (`S.el`, `assign`, …?).
|
2023-10-14 12:43:53 +02:00
|
|
|
* You can investigate the `__dde_reactive` key of the element.
|
|
|
|
* */
|
2023-10-14 16:18:11 +02:00
|
|
|
c[r].forEach(([i]) => N(...i, e[l]?.host() === c))
|
2023-10-14 12:43:53 +02:00
|
|
|
)
|
2023-10-14 16:18:11 +02:00
|
|
|
)(c)), c[r].push([[e, t], ...n]);
|
2023-10-14 12:43:53 +02:00
|
|
|
});
|
|
|
|
}
|
2023-10-13 20:57:21 +02:00
|
|
|
function k(e, t) {
|
2023-10-14 12:43:53 +02:00
|
|
|
let n = (...o) => o.length ? te(n, ...o) : ee(n);
|
|
|
|
return X(n, e, t);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 12:43:53 +02:00
|
|
|
var Q = Object.assign(/* @__PURE__ */ Object.create(null), {
|
2023-09-05 09:25:47 +02:00
|
|
|
stopPropagation() {
|
|
|
|
this.skip = !0;
|
|
|
|
}
|
|
|
|
});
|
2023-10-14 12:43:53 +02:00
|
|
|
function X(e, t, n) {
|
|
|
|
let o = [];
|
|
|
|
T(n) !== "[object Object]" && (n = {});
|
2023-10-14 16:18:11 +02:00
|
|
|
let { onclear: r } = p.symbols;
|
2023-10-14 12:43:53 +02:00
|
|
|
n[r] && (o.push(n[r]), Reflect.deleteProperty(n, r));
|
2023-10-14 16:18:11 +02:00
|
|
|
let { host: c } = b;
|
2023-10-14 12:43:53 +02:00
|
|
|
return e[l] = {
|
2023-09-05 09:25:47 +02:00
|
|
|
value: t,
|
2023-09-19 12:34:42 +02:00
|
|
|
actions: n,
|
2023-10-14 12:43:53 +02:00
|
|
|
onclear: o,
|
|
|
|
host: c,
|
2023-09-05 09:25:47 +02:00
|
|
|
listeners: /* @__PURE__ */ new Set()
|
2023-10-14 12:43:53 +02:00
|
|
|
}, e.toJSON = () => e(), Object.setPrototypeOf(e[l], Q), e;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function Y() {
|
|
|
|
return L[L.length - 1];
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function ee(e) {
|
|
|
|
if (!e[l])
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-10-14 12:43:53 +02:00
|
|
|
let { value: t, listeners: n } = e[l], o = Y();
|
2023-10-14 16:18:11 +02:00
|
|
|
return o && n.add(o), g.has(o) && g.get(o).add(e), t;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-13 16:37:04 +02:00
|
|
|
function te(e, t, n) {
|
|
|
|
if (!e[l])
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-10-14 12:43:53 +02:00
|
|
|
let o = e[l];
|
|
|
|
if (!(!n && o.value === t))
|
|
|
|
return o.value = t, o.listeners.forEach((r) => r(t)), t;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
function j(e, t) {
|
2023-10-13 16:37:04 +02:00
|
|
|
if (e[l])
|
|
|
|
return e[l].listeners.add(t);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-10-14 16:18:11 +02:00
|
|
|
function N(e, t, n) {
|
|
|
|
let o = e[l];
|
|
|
|
if (!o)
|
2023-10-14 12:43:53 +02:00
|
|
|
return;
|
2023-10-14 16:18:11 +02:00
|
|
|
let r = o.listeners.delete(t);
|
|
|
|
if (n && !o.listeners.size) {
|
|
|
|
if (p.clear(e), !g.has(o))
|
|
|
|
return r;
|
|
|
|
let c = g.get(o);
|
|
|
|
if (!g.has(c))
|
|
|
|
return r;
|
|
|
|
g.get(c).forEach((i) => N(i, c, !0));
|
|
|
|
}
|
|
|
|
return r;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
|
2023-09-19 09:30:21 +02:00
|
|
|
// signals.js
|
2023-10-14 16:18:11 +02:00
|
|
|
D(B);
|
2023-09-05 09:25:47 +02:00
|
|
|
|
|
|
|
globalThis.dde= {
|
2023-10-14 16:18:11 +02:00
|
|
|
S: p,
|
2023-10-13 16:37:04 +02:00
|
|
|
assign: O,
|
2023-10-14 12:43:53 +02:00
|
|
|
classListDeclarative: J,
|
2023-10-13 16:37:04 +02:00
|
|
|
createElement: ie,
|
|
|
|
dispatchEvent: le,
|
|
|
|
el: ie,
|
2023-10-09 13:49:38 +02:00
|
|
|
empty: fe,
|
2023-10-13 16:37:04 +02:00
|
|
|
isSignal: C,
|
2023-10-14 16:18:11 +02:00
|
|
|
on: _,
|
|
|
|
registerReactivity: D,
|
|
|
|
scope: b
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|