dap-design-system
Version:
Official design system for the DÁP (dap.gov.hu)
250 lines (249 loc) • 10.4 kB
JavaScript
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const x = globalThis, M = x.trustedTypes, B = M ? M.createPolicy("lit-html", { createHTML: (h) => h }) : void 0, k = "$lit$", p = `lit$${Math.random().toFixed(9).slice(2)}$`, V = "?" + p, z = `<${V}>`, f = document, H = () => f.createComment(""), N = (h) => h === null || typeof h != "object" && typeof h != "function", E = Array.isArray, Z = (h) => E(h) || typeof (h == null ? void 0 : h[Symbol.iterator]) == "function", w = `[
\f\r]`, y = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, P = /-->/g, U = />/g, u = RegExp(`>|${w}(?:([^\\s"'>=/]+)(${w}*=${w}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`, "g"), L = /'/g, O = /"/g, j = /^(?:script|style|textarea|title)$/i, F = (h) => (t, ...e) => ({ _$litType$: h, strings: t, values: e }), Y = F(1), T = Symbol.for("lit-noChange"), _ = Symbol.for("lit-nothing"), R = /* @__PURE__ */ new WeakMap(), g = f.createTreeWalker(f, 129);
function D(h, t) {
if (!E(h) || !h.hasOwnProperty("raw")) throw Error("invalid template strings array");
return B !== void 0 ? B.createHTML(t) : t;
}
const q = (h, t) => {
const e = h.length - 1, s = [];
let i, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", n = y;
for (let a = 0; a < e; a++) {
const r = h[a];
let A, $, l = -1, c = 0;
for (; c < r.length && (n.lastIndex = c, $ = n.exec(r), $ !== null); ) c = n.lastIndex, n === y ? $[1] === "!--" ? n = P : $[1] !== void 0 ? n = U : $[2] !== void 0 ? (j.test($[2]) && (i = RegExp("</" + $[2], "g")), n = u) : $[3] !== void 0 && (n = u) : n === u ? $[0] === ">" ? (n = i != null ? i : y, l = -1) : $[1] === void 0 ? l = -2 : (l = n.lastIndex - $[2].length, A = $[1], n = $[3] === void 0 ? u : $[3] === '"' ? O : L) : n === O || n === L ? n = u : n === P || n === U ? n = y : (n = u, i = void 0);
const d = n === u && h[a + 1].startsWith("/>") ? " " : "";
o += n === y ? r + z : l >= 0 ? (s.push(A), r.slice(0, l) + k + r.slice(l) + p + d) : r + p + (l === -2 ? a : d);
}
return [D(h, o + (h[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
};
class b {
constructor({ strings: t, _$litType$: e }, s) {
let i;
this.parts = [];
let o = 0, n = 0;
const a = t.length - 1, r = this.parts, [A, $] = q(t, e);
if (this.el = b.createElement(A, s), g.currentNode = this.el.content, e === 2 || e === 3) {
const l = this.el.content.firstChild;
l.replaceWith(...l.childNodes);
}
for (; (i = g.nextNode()) !== null && r.length < a; ) {
if (i.nodeType === 1) {
if (i.hasAttributes()) for (const l of i.getAttributeNames()) if (l.endsWith(k)) {
const c = $[n++], d = i.getAttribute(l).split(p), C = /([.?@])?(.*)/.exec(c);
r.push({ type: 1, index: o, name: C[2], strings: d, ctor: C[1] === "." ? J : C[1] === "?" ? K : C[1] === "@" ? Q : S }), i.removeAttribute(l);
} else l.startsWith(p) && (r.push({ type: 6, index: o }), i.removeAttribute(l));
if (j.test(i.tagName)) {
const l = i.textContent.split(p), c = l.length - 1;
if (c > 0) {
i.textContent = M ? M.emptyScript : "";
for (let d = 0; d < c; d++) i.append(l[d], H()), g.nextNode(), r.push({ type: 2, index: ++o });
i.append(l[c], H());
}
}
} else if (i.nodeType === 8) if (i.data === V) r.push({ type: 2, index: o });
else {
let l = -1;
for (; (l = i.data.indexOf(p, l + 1)) !== -1; ) r.push({ type: 7, index: o }), l += p.length - 1;
}
o++;
}
}
static createElement(t, e) {
const s = f.createElement("template");
return s.innerHTML = t, s;
}
}
function v(h, t, e = h, s) {
var n, a, r;
if (t === T) return t;
let i = s !== void 0 ? (n = e._$Co) == null ? void 0 : n[s] : e._$Cl;
const o = N(t) ? void 0 : t._$litDirective$;
return (i == null ? void 0 : i.constructor) !== o && ((a = i == null ? void 0 : i._$AO) == null || a.call(i, !1), o === void 0 ? i = void 0 : (i = new o(h), i._$AT(h, e, s)), s !== void 0 ? ((r = e._$Co) != null ? r : e._$Co = [])[s] = i : e._$Cl = i), i !== void 0 && (t = v(h, i._$AS(h, t.values), i, s)), t;
}
class G {
constructor(t, e) {
this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
}
get parentNode() {
return this._$AM.parentNode;
}
get _$AU() {
return this._$AM._$AU;
}
u(t) {
var A;
const { el: { content: e }, parts: s } = this._$AD, i = ((A = t == null ? void 0 : t.creationScope) != null ? A : f).importNode(e, !0);
g.currentNode = i;
let o = g.nextNode(), n = 0, a = 0, r = s[0];
for (; r !== void 0; ) {
if (n === r.index) {
let $;
r.type === 2 ? $ = new m(o, o.nextSibling, this, t) : r.type === 1 ? $ = new r.ctor(o, r.name, r.strings, this, t) : r.type === 6 && ($ = new X(o, this, t)), this._$AV.push($), r = s[++a];
}
n !== (r == null ? void 0 : r.index) && (o = g.nextNode(), n++);
}
return g.currentNode = f, i;
}
p(t) {
let e = 0;
for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
}
}
class m {
get _$AU() {
var t, e;
return (e = (t = this._$AM) == null ? void 0 : t._$AU) != null ? e : this._$Cv;
}
constructor(t, e, s, i) {
var o;
this.type = 2, this._$AH = _, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = i, this._$Cv = (o = i == null ? void 0 : i.isConnected) != null ? o : !0;
}
get parentNode() {
let t = this._$AA.parentNode;
const e = this._$AM;
return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
}
get startNode() {
return this._$AA;
}
get endNode() {
return this._$AB;
}
_$AI(t, e = this) {
t = v(this, t, e), N(t) ? t === _ || t == null || t === "" ? (this._$AH !== _ && this._$AR(), this._$AH = _) : t !== this._$AH && t !== T && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Z(t) ? this.k(t) : this._(t);
}
O(t) {
return this._$AA.parentNode.insertBefore(t, this._$AB);
}
T(t) {
this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
}
_(t) {
this._$AH !== _ && N(this._$AH) ? this._$AA.nextSibling.data = t : this.T(f.createTextNode(t)), this._$AH = t;
}
$(t) {
var o;
const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = b.createElement(D(s.h, s.h[0]), this.options)), s);
if (((o = this._$AH) == null ? void 0 : o._$AD) === i) this._$AH.p(e);
else {
const n = new G(i, this), a = n.u(this.options);
n.p(e), this.T(a), this._$AH = n;
}
}
_$AC(t) {
let e = R.get(t.strings);
return e === void 0 && R.set(t.strings, e = new b(t)), e;
}
k(t) {
E(this._$AH) || (this._$AH = [], this._$AR());
const e = this._$AH;
let s, i = 0;
for (const o of t) i === e.length ? e.push(s = new m(this.O(H()), this.O(H()), this, this.options)) : s = e[i], s._$AI(o), i++;
i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i);
}
_$AR(t = this._$AA.nextSibling, e) {
var s;
for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, e); t && t !== this._$AB; ) {
const i = t.nextSibling;
t.remove(), t = i;
}
}
setConnected(t) {
var e;
this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
}
}
class S {
get tagName() {
return this.element.tagName;
}
get _$AU() {
return this._$AM._$AU;
}
constructor(t, e, s, i, o) {
this.type = 1, this._$AH = _, this._$AN = void 0, this.element = t, this.name = e, this._$AM = i, this.options = o, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = _;
}
_$AI(t, e = this, s, i) {
const o = this.strings;
let n = !1;
if (o === void 0) t = v(this, t, e, 0), n = !N(t) || t !== this._$AH && t !== T, n && (this._$AH = t);
else {
const a = t;
let r, A;
for (t = o[0], r = 0; r < o.length - 1; r++) A = v(this, a[s + r], e, r), A === T && (A = this._$AH[r]), n || (n = !N(A) || A !== this._$AH[r]), A === _ ? t = _ : t !== _ && (t += (A != null ? A : "") + o[r + 1]), this._$AH[r] = A;
}
n && !i && this.j(t);
}
j(t) {
t === _ ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t != null ? t : "");
}
}
class J extends S {
constructor() {
super(...arguments), this.type = 3;
}
j(t) {
this.element[this.name] = t === _ ? void 0 : t;
}
}
class K extends S {
constructor() {
super(...arguments), this.type = 4;
}
j(t) {
this.element.toggleAttribute(this.name, !!t && t !== _);
}
}
class Q extends S {
constructor(t, e, s, i, o) {
super(t, e, s, i, o), this.type = 5;
}
_$AI(t, e = this) {
var n;
if ((t = (n = v(this, t, e, 0)) != null ? n : _) === T) return;
const s = this._$AH, i = t === _ && s !== _ || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, o = t !== _ && (s === _ || i);
i && this.element.removeEventListener(this.name, this, s), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
}
handleEvent(t) {
var e, s;
typeof this._$AH == "function" ? this._$AH.call((s = (e = this.options) == null ? void 0 : e.host) != null ? s : this.element, t) : this._$AH.handleEvent(t);
}
}
class X {
constructor(t, e, s) {
this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t) {
v(this, t);
}
}
const tt = { I: m }, I = x.litHtmlPolyfillSupport;
var W;
I == null || I(b, m), ((W = x.litHtmlVersions) != null ? W : x.litHtmlVersions = []).push("3.3.0");
const et = (h, t, e) => {
var o, n;
const s = (o = e == null ? void 0 : e.renderBefore) != null ? o : t;
let i = s._$litPart$;
if (i === void 0) {
const a = (n = e == null ? void 0 : e.renderBefore) != null ? n : null;
s._$litPart$ = i = new m(t.insertBefore(H(), a), a, void 0, e != null ? e : {});
}
return i._$AI(h), i;
};
export {
tt as _$LH,
Y as html,
T as noChange,
_ as nothing,
et as render
};
//# sourceMappingURL=lit-html.js.map