2023-09-05 09:25:47 +02:00
|
|
|
//deka-dom-el library is available via global namespace `dde`
|
|
|
|
(()=> {
|
|
|
|
// src/helpers.js
|
2023-09-07 13:52:09 +02:00
|
|
|
function N(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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// src/signals-common.js
|
2023-09-06 14:54:28 +02:00
|
|
|
var p = {
|
2023-09-05 09:25:47 +02:00
|
|
|
isReactiveAtrribute(e, t) {
|
|
|
|
return !1;
|
|
|
|
},
|
|
|
|
isTextContent(e) {
|
2023-09-07 13:52:09 +02:00
|
|
|
return N(e) !== "[object Object]";
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-09-07 13:52:09 +02:00
|
|
|
processReactiveAttribute(e, t, r, n) {
|
2023-09-05 09:25:47 +02:00
|
|
|
return !1;
|
|
|
|
},
|
|
|
|
reactiveElement(e, ...t) {
|
2023-09-07 13:52:09 +02:00
|
|
|
return null;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
};
|
2023-09-07 13:52:09 +02:00
|
|
|
function A(e, t = !0) {
|
2023-09-06 14:54:28 +02:00
|
|
|
return t ? Object.assign(p, e) : (Object.setPrototypeOf(e, p), e);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-06 14:54:28 +02:00
|
|
|
function O(e) {
|
|
|
|
return p.isPrototypeOf(e) && e !== p ? e : p;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// src/dom.js
|
2023-09-07 13:52:09 +02:00
|
|
|
var x = "html";
|
2023-09-06 14:54:28 +02:00
|
|
|
function z(e) {
|
2023-09-07 13:52:09 +02:00
|
|
|
return x = e === "svg" ? "http://www.w3.org/2000/svg" : e, {
|
2023-09-05 09:25:47 +02:00
|
|
|
append(t) {
|
2023-09-07 13:52:09 +02:00
|
|
|
return x = "html", t;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function F(e, t, ...r) {
|
|
|
|
let n = O(this), f;
|
2023-09-05 09:25:47 +02:00
|
|
|
if (e === "<>") {
|
2023-09-07 13:52:09 +02:00
|
|
|
if (n.isReactiveAtrribute(t))
|
|
|
|
return n.reactiveElement(t, ...r);
|
|
|
|
f = document.createDocumentFragment();
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
switch (n.isTextContent(t) && (t = { textContent: t }), !0) {
|
2023-09-05 09:25:47 +02:00
|
|
|
case typeof e == "function":
|
2023-09-07 13:52:09 +02:00
|
|
|
f = e(t || void 0);
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
|
|
|
case e === "#text":
|
2023-09-07 13:52:09 +02:00
|
|
|
f = w(document.createTextNode(""), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
2023-09-07 13:52:09 +02:00
|
|
|
case x !== "html":
|
|
|
|
f = w(document.createElementNS(x, e), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
2023-09-07 13:52:09 +02:00
|
|
|
case !f:
|
|
|
|
f = w(document.createElement(e), t);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
return r.forEach((d) => d(f)), f;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
var h = new Map(JSON.parse('[["#text,textContent",true],["HTMLElement,textContent",true],["HTMLElement,className",true]]'));
|
|
|
|
function w(e, ...t) {
|
|
|
|
let r = O(this);
|
2023-09-05 09:25:47 +02:00
|
|
|
if (!t.length)
|
|
|
|
return e;
|
2023-09-07 13:52:09 +02:00
|
|
|
let n = e instanceof SVGElement, f = (n ? M : j).bind(null, e, "Attribute");
|
|
|
|
return Object.entries(Object.assign({}, ...t)).forEach(function d([i, u]) {
|
|
|
|
r.isReactiveAtrribute(u, i) && (u = r.processReactiveAttribute(e, i, u, d));
|
|
|
|
let [l] = i;
|
2023-09-06 14:54:28 +02:00
|
|
|
if (l === "=")
|
2023-09-07 13:52:09 +02:00
|
|
|
return f(i.slice(1), u);
|
2023-09-06 14:54:28 +02:00
|
|
|
if (l === ".")
|
2023-09-07 13:52:09 +02:00
|
|
|
return C(e, i.slice(1), u);
|
|
|
|
if (typeof u == "object")
|
|
|
|
switch (i) {
|
2023-09-05 09:25:47 +02:00
|
|
|
case "style":
|
2023-09-07 13:52:09 +02:00
|
|
|
return m(u, j.bind(null, e.style, "Property"));
|
2023-09-05 09:25:47 +02:00
|
|
|
case "dataset":
|
2023-09-07 13:52:09 +02:00
|
|
|
return m(u, C.bind(null, e.dataset));
|
2023-09-05 09:25:47 +02:00
|
|
|
case "ariaset":
|
2023-09-07 13:52:09 +02:00
|
|
|
return m(u, (g, b) => f("aria-" + g, b));
|
2023-09-05 09:25:47 +02:00
|
|
|
case "classList":
|
2023-09-07 13:52:09 +02:00
|
|
|
return T(e, u);
|
2023-09-05 09:25:47 +02:00
|
|
|
default:
|
2023-09-07 13:52:09 +02:00
|
|
|
return Reflect.set(e, i, u);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
if (/(aria|data)([A-Z])/.test(i))
|
|
|
|
return i = i.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(), f(i, u);
|
|
|
|
switch (i) {
|
2023-09-05 09:25:47 +02:00
|
|
|
case "xlink:href":
|
2023-09-07 13:52:09 +02:00
|
|
|
return f(i, u, "http://www.w3.org/1999/xlink");
|
2023-09-05 09:25:47 +02:00
|
|
|
case "textContent":
|
2023-09-07 13:52:09 +02:00
|
|
|
if (!n)
|
2023-09-05 09:25:47 +02:00
|
|
|
break;
|
2023-09-07 13:52:09 +02:00
|
|
|
return e.appendChild(document.createTextNode(u));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
return D(e, i) ? C(e, i, u) : f(i, u);
|
2023-09-05 09:25:47 +02:00
|
|
|
}), e;
|
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function T(e, t) {
|
|
|
|
return typeof t != "object" || m(
|
2023-09-05 09:25:47 +02:00
|
|
|
t,
|
2023-09-07 13:52:09 +02:00
|
|
|
(r, n) => e.classList.toggle(r, n === -1 ? void 0 : !!n)
|
2023-09-05 09:25:47 +02:00
|
|
|
), e;
|
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function I(e) {
|
2023-09-05 09:25:47 +02:00
|
|
|
return Array.from(e.children).forEach((t) => t.remove()), e;
|
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function D(e, t) {
|
|
|
|
let r = "HTMLElement," + t;
|
|
|
|
if (e instanceof HTMLElement && h.has(r))
|
|
|
|
return h.get(r);
|
2023-09-06 14:54:28 +02:00
|
|
|
let n = e.nodeName + "," + t;
|
2023-09-07 13:52:09 +02:00
|
|
|
if (h.has(n))
|
|
|
|
return h.get(n);
|
|
|
|
let [f, d, i] = y(e, t), u = !L(f.set);
|
|
|
|
return (!u || d) && h.set(i === HTMLElement.prototype ? r : n, u), u;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function y(e, t, r = 0) {
|
2023-09-06 14:54:28 +02:00
|
|
|
if (e = Object.getPrototypeOf(e), !e)
|
2023-09-07 13:52:09 +02:00
|
|
|
return [{}, r, e];
|
2023-09-06 14:54:28 +02:00
|
|
|
let n = Object.getOwnPropertyDescriptor(e, t);
|
2023-09-07 13:52:09 +02:00
|
|
|
return n ? [n, r, e] : y(e, t, r + 1);
|
2023-09-06 14:54:28 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function m(e, t) {
|
|
|
|
return Object.entries(e).forEach(([r, n]) => t(r, n));
|
2023-09-06 14:54:28 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function L(e) {
|
2023-09-05 09:25:47 +02:00
|
|
|
return typeof e > "u";
|
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function j(e, t, r, n) {
|
|
|
|
return e[(L(n) ? "remove" : "set") + t](r, n);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function M(e, t, r, n, f = null) {
|
|
|
|
return e[(L(n) ? "remove" : "set") + t + "NS"](f, r, n);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function C(e, t, r) {
|
|
|
|
return Reflect.set(e, t, r);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// src/events.js
|
2023-09-07 13:52:09 +02:00
|
|
|
function R(e, t, r) {
|
|
|
|
return (n) => (n.addEventListener(e, t, r), n);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
var E = P();
|
|
|
|
R.connected = function(e, t) {
|
|
|
|
return function(n) {
|
|
|
|
E.onConnected(n, e), t && t.signal && t.signal.addEventListener("abort", () => E.offConnected(n, e));
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
};
|
2023-09-07 13:52:09 +02:00
|
|
|
R.disconnected = function(e, t) {
|
|
|
|
return function(n) {
|
|
|
|
E.onDisconnected(n, e), t && t.signal && t.signal.addEventListener("abort", () => E.offDisconnected(n, e));
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
};
|
2023-09-07 13:52:09 +02:00
|
|
|
function P() {
|
|
|
|
let e = /* @__PURE__ */ new Map(), t = !1, r = new MutationObserver(function(o) {
|
2023-09-06 14:54:28 +02:00
|
|
|
for (let c of o)
|
2023-09-05 09:25:47 +02:00
|
|
|
if (c.type === "childList") {
|
2023-09-07 13:52:09 +02:00
|
|
|
if (g(c.addedNodes, !0)) {
|
|
|
|
i();
|
2023-09-05 09:25:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
b(c.removedNodes, !0) && i();
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return {
|
2023-09-06 14:54:28 +02:00
|
|
|
onConnected(o, c) {
|
2023-09-07 13:52:09 +02:00
|
|
|
d(), f(o).connected.push(c);
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-09-06 14:54:28 +02:00
|
|
|
offConnected(o, c) {
|
|
|
|
if (!e.has(o))
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-09-06 14:54:28 +02:00
|
|
|
let s = e.get(o), a = s.connected;
|
2023-09-07 13:52:09 +02:00
|
|
|
a.splice(a.indexOf(c), 1), n(o, s);
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-09-06 14:54:28 +02:00
|
|
|
onDisconnected(o, c) {
|
2023-09-07 13:52:09 +02:00
|
|
|
d(), f(o).disconnected.push(c);
|
2023-09-05 09:25:47 +02:00
|
|
|
},
|
2023-09-06 14:54:28 +02:00
|
|
|
offDisconnected(o, c) {
|
|
|
|
if (!e.has(o))
|
2023-09-05 09:25:47 +02:00
|
|
|
return;
|
2023-09-06 14:54:28 +02:00
|
|
|
let s = e.get(o), a = s.disconnected;
|
2023-09-07 13:52:09 +02:00
|
|
|
a.splice(a.indexOf(c), 1), n(o, s);
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
};
|
2023-09-07 13:52:09 +02:00
|
|
|
function n(o, c) {
|
|
|
|
c.connected.length || c.disconnect.length || (e.delete(o), i());
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function f(o) {
|
2023-09-06 14:54:28 +02:00
|
|
|
if (e.has(o))
|
|
|
|
return e.get(o);
|
2023-09-05 09:25:47 +02:00
|
|
|
let c = { connected: [], disconnected: [] };
|
2023-09-06 14:54:28 +02:00
|
|
|
return e.set(o, c), c;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
function d() {
|
2023-09-07 13:52:09 +02:00
|
|
|
t || (t = !0, r.observe(document.body, { childList: !0, subtree: !0 }));
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function i() {
|
|
|
|
!t || e.size || (t = !1, r.disconnect());
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function u() {
|
2023-09-06 14:54:28 +02:00
|
|
|
return new Promise(function(o) {
|
|
|
|
(requestIdleCallback || requestAnimationFrame)(o);
|
2023-09-05 09:25:47 +02:00
|
|
|
});
|
|
|
|
}
|
2023-09-06 14:54:28 +02:00
|
|
|
async function l(o) {
|
2023-09-07 13:52:09 +02:00
|
|
|
e.size > 30 && await u();
|
2023-09-05 09:25:47 +02:00
|
|
|
let c = [];
|
2023-09-06 14:54:28 +02:00
|
|
|
if (!(o instanceof Node))
|
2023-09-05 09:25:47 +02:00
|
|
|
return c;
|
|
|
|
for (let s of e.keys())
|
2023-09-06 14:54:28 +02:00
|
|
|
s === o || !(s instanceof Node) || o.contains(s) && c.push(s);
|
2023-09-05 09:25:47 +02:00
|
|
|
return c;
|
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function g(o, c) {
|
2023-09-06 14:54:28 +02:00
|
|
|
for (let s of o) {
|
2023-09-07 13:52:09 +02:00
|
|
|
if (c && l(s).then(g), !e.has(s))
|
2023-09-05 09:25:47 +02:00
|
|
|
return !1;
|
|
|
|
let a = e.get(s);
|
2023-09-07 13:52:09 +02:00
|
|
|
return a.connected.forEach((v) => v(s)), a.connected.length = 0, a.disconnected.length || e.delete(s), !0;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
}
|
2023-09-07 13:52:09 +02:00
|
|
|
function b(o, c) {
|
2023-09-06 14:54:28 +02:00
|
|
|
for (let s of o) {
|
2023-09-07 13:52:09 +02:00
|
|
|
if (c && l(s).then(b), !e.has(s))
|
2023-09-05 09:25:47 +02:00
|
|
|
return !1;
|
|
|
|
let a = e.get(s);
|
2023-09-07 13:52:09 +02:00
|
|
|
return a.disconnected.forEach((v) => v(s)), a.connected.length = 0, a.disconnected.length = 0, e.delete(s), !0;
|
2023-09-05 09:25:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// index.js
|
|
|
|
[HTMLElement, DocumentFragment].forEach((e) => {
|
|
|
|
let { append: t } = e.prototype;
|
2023-09-07 13:52:09 +02:00
|
|
|
e.prototype.append = function(...r) {
|
|
|
|
return t.apply(this, r), this;
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
globalThis.dde= {
|
2023-09-07 13:52:09 +02:00
|
|
|
assign: w,
|
|
|
|
classListDeclartive: T,
|
|
|
|
createElement: F,
|
|
|
|
el: F,
|
|
|
|
empty: I,
|
2023-09-06 14:54:28 +02:00
|
|
|
namespace: z,
|
2023-09-07 13:52:09 +02:00
|
|
|
on: R,
|
|
|
|
registerReactivity: A
|
2023-09-05 09:25:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|