dap-design-system
Version:
Official design system for the DÁP (dap.gov.hu)
277 lines (276 loc) • 9.94 kB
JavaScript
var E = (h, t, e) => new Promise((s, i) => {
var o = (n) => {
try {
a(e.next(n));
} catch (l) {
i(l);
}
}, r = (n) => {
try {
a(e.throw(n));
} catch (l) {
i(l);
}
}, a = (n) => n.done ? s(n.value) : Promise.resolve(n.value).then(o, r);
a((e = e.apply(h, t)).next());
});
import { getCompatibleStyle as _, adoptStyles as w } from "./css-tag.js";
import { CSSResult as q, css as D, supportsAdoptingStyleSheets as N, unsafeCSS as T } from "./css-tag.js";
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const { is: S, defineProperty: U, getOwnPropertyDescriptor: A, getOwnPropertyNames: O, getOwnPropertySymbols: C, getPrototypeOf: M } = Object, c = globalThis, $ = c.trustedTypes, R = $ ? $.emptyScript : "", u = c.reactiveElementPolyfillSupport, d = (h, t) => h, f = { toAttribute(h, t) {
switch (t) {
case Boolean:
h = h ? R : null;
break;
case Object:
case Array:
h = h == null ? h : JSON.stringify(h);
}
return h;
}, fromAttribute(h, t) {
let e = h;
switch (t) {
case Boolean:
e = h !== null;
break;
case Number:
e = h === null ? null : Number(h);
break;
case Object:
case Array:
try {
e = JSON.parse(h);
} catch (s) {
e = null;
}
}
return e;
} }, P = (h, t) => !S(h, t), y = { attribute: !0, type: String, converter: f, reflect: !1, useDefault: !1, hasChanged: P };
var m, g;
(m = Symbol.metadata) != null || (Symbol.metadata = Symbol("metadata")), (g = c.litPropertyMetadata) != null || (c.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
class p extends HTMLElement {
static addInitializer(t) {
var e;
this._$Ei(), ((e = this.l) != null ? e : this.l = []).push(t);
}
static get observedAttributes() {
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
}
static createProperty(t, e = y) {
if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
i !== void 0 && U(this.prototype, t, i);
}
}
static getPropertyDescriptor(t, e, s) {
var r;
const { get: i, set: o } = (r = A(this.prototype, t)) != null ? r : { get() {
return this[e];
}, set(a) {
this[e] = a;
} };
return { get: i, set(a) {
const n = i == null ? void 0 : i.call(this);
o == null || o.call(this, a), this.requestUpdate(t, n, s);
}, configurable: !0, enumerable: !0 };
}
static getPropertyOptions(t) {
var e;
return (e = this.elementProperties.get(t)) != null ? e : y;
}
static _$Ei() {
if (this.hasOwnProperty(d("elementProperties"))) return;
const t = M(this);
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
}
static finalize() {
if (this.hasOwnProperty(d("finalized"))) return;
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(d("properties"))) {
const e = this.properties, s = [...O(e), ...C(e)];
for (const i of s) this.createProperty(i, e[i]);
}
const t = this[Symbol.metadata];
if (t !== null) {
const e = litPropertyMetadata.get(t);
if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i);
}
this._$Eh = /* @__PURE__ */ new Map();
for (const [e, s] of this.elementProperties) {
const i = this._$Eu(e, s);
i !== void 0 && this._$Eh.set(i, e);
}
this.elementStyles = this.finalizeStyles(this.styles);
}
static finalizeStyles(t) {
const e = [];
if (Array.isArray(t)) {
const s = new Set(t.flat(1 / 0).reverse());
for (const i of s) e.unshift(_(i));
} else t !== void 0 && e.push(_(t));
return e;
}
static _$Eu(t, e) {
const s = e.attribute;
return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
}
constructor() {
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
}
_$Ev() {
var t;
this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
}
addController(t) {
var e, s;
((e = this._$EO) != null ? e : this._$EO = /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && ((s = t.hostConnected) == null || s.call(t));
}
removeController(t) {
var e;
(e = this._$EO) == null || e.delete(t);
}
_$E_() {
const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
t.size > 0 && (this._$Ep = t);
}
createRenderRoot() {
var e;
const t = (e = this.shadowRoot) != null ? e : this.attachShadow(this.constructor.shadowRootOptions);
return w(t, this.constructor.elementStyles), t;
}
connectedCallback() {
var t, e;
(t = this.renderRoot) != null || (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (e = this._$EO) == null || e.forEach((s) => {
var i;
return (i = s.hostConnected) == null ? void 0 : i.call(s);
});
}
enableUpdating(t) {
}
disconnectedCallback() {
var t;
(t = this._$EO) == null || t.forEach((e) => {
var s;
return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
});
}
attributeChangedCallback(t, e, s) {
this._$AK(t, s);
}
_$ET(t, e) {
var o;
const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
if (i !== void 0 && s.reflect === !0) {
const r = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : f).toAttribute(e, s.type);
this._$Em = t, r == null ? this.removeAttribute(i) : this.setAttribute(i, r), this._$Em = null;
}
}
_$AK(t, e) {
var o, r, a, n;
const s = this.constructor, i = s._$Eh.get(t);
if (i !== void 0 && this._$Em !== i) {
const l = s.getPropertyOptions(i), v = typeof l.converter == "function" ? { fromAttribute: l.converter } : ((o = l.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? l.converter : f;
this._$Em = i, this[i] = (n = (a = v.fromAttribute(e, l.type)) != null ? a : (r = this._$Ej) == null ? void 0 : r.get(i)) != null ? n : null, this._$Em = null;
}
}
requestUpdate(t, e, s) {
var i, o;
if (t !== void 0) {
const r = this.constructor, a = this[t];
if (s != null || (s = r.getPropertyOptions(t)), !(((i = s.hasChanged) != null ? i : P)(a, e) || s.useDefault && s.reflect && a === ((o = this._$Ej) == null ? void 0 : o.get(t)) && !this.hasAttribute(r._$Eu(t, s)))) return;
this.C(t, e, s);
}
this.isUpdatePending === !1 && (this._$ES = this._$EP());
}
C(t, e, { useDefault: s, reflect: i, wrapped: o }, r) {
var a, n, l;
s && !((a = this._$Ej) != null ? a : this._$Ej = /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, (n = r != null ? r : e) != null ? n : this[t]), o !== !0 || r !== void 0) || (this._$AL.has(t) || (this.hasUpdated || s || (e = void 0), this._$AL.set(t, e)), i === !0 && this._$Em !== t && ((l = this._$Eq) != null ? l : this._$Eq = /* @__PURE__ */ new Set()).add(t));
}
_$EP() {
return E(this, null, function* () {
this.isUpdatePending = !0;
try {
yield this._$ES;
} catch (e) {
Promise.reject(e);
}
const t = this.scheduleUpdate();
return t != null && (yield t), !this.isUpdatePending;
});
}
scheduleUpdate() {
return this.performUpdate();
}
performUpdate() {
var s, i;
if (!this.isUpdatePending) return;
if (!this.hasUpdated) {
if ((s = this.renderRoot) != null || (this.renderRoot = this.createRenderRoot()), this._$Ep) {
for (const [r, a] of this._$Ep) this[r] = a;
this._$Ep = void 0;
}
const o = this.constructor.elementProperties;
if (o.size > 0) for (const [r, a] of o) {
const { wrapped: n } = a, l = this[r];
n !== !0 || this._$AL.has(r) || l === void 0 || this.C(r, void 0, a, l);
}
}
let t = !1;
const e = this._$AL;
try {
t = this.shouldUpdate(e), t ? (this.willUpdate(e), (i = this._$EO) == null || i.forEach((o) => {
var r;
return (r = o.hostUpdate) == null ? void 0 : r.call(o);
}), this.update(e)) : this._$EM();
} catch (o) {
throw t = !1, this._$EM(), o;
}
t && this._$AE(e);
}
willUpdate(t) {
}
_$AE(t) {
var e;
(e = this._$EO) == null || e.forEach((s) => {
var i;
return (i = s.hostUpdated) == null ? void 0 : i.call(s);
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
}
_$EM() {
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
}
get updateComplete() {
return this.getUpdateComplete();
}
getUpdateComplete() {
return this._$ES;
}
shouldUpdate(t) {
return !0;
}
update(t) {
this._$Eq && (this._$Eq = this._$Eq.forEach((e) => this._$ET(e, this[e]))), this._$EM();
}
updated(t) {
}
firstUpdated(t) {
}
}
var b;
p.elementStyles = [], p.shadowRootOptions = { mode: "open" }, p[d("elementProperties")] = /* @__PURE__ */ new Map(), p[d("finalized")] = /* @__PURE__ */ new Map(), u == null || u({ ReactiveElement: p }), ((b = c.reactiveElementVersions) != null ? b : c.reactiveElementVersions = []).push("2.1.0");
export {
q as CSSResult,
p as ReactiveElement,
w as adoptStyles,
D as css,
f as defaultConverter,
_ as getCompatibleStyle,
P as notEqual,
N as supportsAdoptingStyleSheets,
T as unsafeCSS
};
//# sourceMappingURL=reactive-element.js.map