cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
263 lines (262 loc) • 11.5 kB
JavaScript
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var t;
const i = window, s = i.trustedTypes, e = s ? s.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o = "$lit$", n = `lit$${(Math.random() + "").slice(9)}$`, l = "?" + n, h = `<${l}>`, r = document, d = () => r.createComment(""), u = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _ = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false), P = (t2, i2) => {
const s2 = t2.length - 1, l2 = [];
let r2, d2 = 2 === i2 ? "<svg>" : "", u2 = f;
for (let i3 = 0; i3 < s2; i3++) {
const s3 = t2[i3];
let e2, c3, v2 = -1, a2 = 0;
for (; a2 < s3.length && (u2.lastIndex = a2, c3 = u2.exec(s3), null !== c3); )
a2 = u2.lastIndex, u2 === f ? "!--" === c3[1] ? u2 = _ : void 0 !== c3[1] ? u2 = m : void 0 !== c3[2] ? (y.test(c3[2]) && (r2 = RegExp("</" + c3[2], "g")), u2 = p) : void 0 !== c3[3] && (u2 = p) : u2 === p ? ">" === c3[0] ? (u2 = null != r2 ? r2 : f, v2 = -1) : void 0 === c3[1] ? v2 = -2 : (v2 = u2.lastIndex - c3[2].length, e2 = c3[1], u2 = void 0 === c3[3] ? p : '"' === c3[3] ? $ : g) : u2 === $ || u2 === g ? u2 = p : u2 === _ || u2 === m ? u2 = f : (u2 = p, r2 = void 0);
const w2 = u2 === p && t2[i3 + 1].startsWith("/>") ? " " : "";
d2 += u2 === f ? s3 + h : v2 >= 0 ? (l2.push(e2), s3.slice(0, v2) + o + s3.slice(v2) + n + w2) : s3 + n + (-2 === v2 ? (l2.push(void 0), i3) : w2);
}
const c2 = d2 + (t2[s2] || "<?>") + (2 === i2 ? "</svg>" : "");
if (!Array.isArray(t2) || !t2.hasOwnProperty("raw"))
throw Error("invalid template strings array");
return [void 0 !== e ? e.createHTML(c2) : c2, l2];
};
class V {
constructor({ strings: t2, _$litType$: i2 }, e2) {
let h2;
this.parts = [];
let r2 = 0, u2 = 0;
const c2 = t2.length - 1, v2 = this.parts, [a2, f2] = P(t2, i2);
if (this.el = V.createElement(a2, e2), C.currentNode = this.el.content, 2 === i2) {
const t3 = this.el.content, i3 = t3.firstChild;
i3.remove(), t3.append(...i3.childNodes);
}
for (; null !== (h2 = C.nextNode()) && v2.length < c2; ) {
if (1 === h2.nodeType) {
if (h2.hasAttributes()) {
const t3 = [];
for (const i3 of h2.getAttributeNames())
if (i3.endsWith(o) || i3.startsWith(n)) {
const s2 = f2[u2++];
if (t3.push(i3), void 0 !== s2) {
const t4 = h2.getAttribute(s2.toLowerCase() + o).split(n), i4 = /([.?@])?(.*)/.exec(s2);
v2.push({ type: 1, index: r2, name: i4[2], strings: t4, ctor: "." === i4[1] ? k : "?" === i4[1] ? I : "@" === i4[1] ? L : R });
} else
v2.push({ type: 6, index: r2 });
}
for (const i3 of t3)
h2.removeAttribute(i3);
}
if (y.test(h2.tagName)) {
const t3 = h2.textContent.split(n), i3 = t3.length - 1;
if (i3 > 0) {
h2.textContent = s ? s.emptyScript : "";
for (let s2 = 0; s2 < i3; s2++)
h2.append(t3[s2], d()), C.nextNode(), v2.push({ type: 2, index: ++r2 });
h2.append(t3[i3], d());
}
}
} else if (8 === h2.nodeType)
if (h2.data === l)
v2.push({ type: 2, index: r2 });
else {
let t3 = -1;
for (; -1 !== (t3 = h2.data.indexOf(n, t3 + 1)); )
v2.push({ type: 7, index: r2 }), t3 += n.length - 1;
}
r2++;
}
}
static createElement(t2, i2) {
const s2 = r.createElement("template");
return s2.innerHTML = t2, s2;
}
}
function N(t2, i2, s2 = t2, e2) {
var o2, n2, l2, h2;
if (i2 === T)
return i2;
let r2 = void 0 !== e2 ? null === (o2 = s2._$Co) || void 0 === o2 ? void 0 : o2[e2] : s2._$Cl;
const d2 = u(i2) ? void 0 : i2._$litDirective$;
return (null == r2 ? void 0 : r2.constructor) !== d2 && (null === (n2 = null == r2 ? void 0 : r2._$AO) || void 0 === n2 || n2.call(r2, false), void 0 === d2 ? r2 = void 0 : (r2 = new d2(t2), r2._$AT(t2, s2, e2)), void 0 !== e2 ? (null !== (l2 = (h2 = s2)._$Co) && void 0 !== l2 ? l2 : h2._$Co = [])[e2] = r2 : s2._$Cl = r2), void 0 !== r2 && (i2 = N(t2, r2._$AS(t2, i2.values), r2, e2)), i2;
}
class S {
constructor(t2, i2) {
this.u = [], this._$AN = void 0, this._$AD = t2, this._$AM = i2;
}
get parentNode() {
return this._$AM.parentNode;
}
get _$AU() {
return this._$AM._$AU;
}
v(t2) {
var i2;
const { el: { content: s2 }, parts: e2 } = this._$AD, o2 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s2, true);
C.currentNode = o2;
let n2 = C.nextNode(), l2 = 0, h2 = 0, d2 = e2[0];
for (; void 0 !== d2; ) {
if (l2 === d2.index) {
let i3;
2 === d2.type ? i3 = new M(n2, n2.nextSibling, this, t2) : 1 === d2.type ? i3 = new d2.ctor(n2, d2.name, d2.strings, this, t2) : 6 === d2.type && (i3 = new z(n2, this, t2)), this.u.push(i3), d2 = e2[++h2];
}
l2 !== (null == d2 ? void 0 : d2.index) && (n2 = C.nextNode(), l2++);
}
return o2;
}
p(t2) {
let i2 = 0;
for (const s2 of this.u)
void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++;
}
}
class M {
constructor(t2, i2, s2, e2) {
var o2;
this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cm = null === (o2 = null == e2 ? void 0 : e2.isConnected) || void 0 === o2 || o2;
}
get _$AU() {
var t2, i2;
return null !== (i2 = null === (t2 = this._$AM) || void 0 === t2 ? void 0 : t2._$AU) && void 0 !== i2 ? i2 : this._$Cm;
}
get parentNode() {
let t2 = this._$AA.parentNode;
const i2 = this._$AM;
return void 0 !== i2 && 11 === (null == t2 ? void 0 : t2.nodeType) && (t2 = i2.parentNode), t2;
}
get startNode() {
return this._$AA;
}
get endNode() {
return this._$AB;
}
_$AI(t2, i2 = this) {
t2 = N(this, t2, i2), u(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this.g(t2) : void 0 !== t2._$litType$ ? this.$(t2) : void 0 !== t2.nodeType ? this.T(t2) : v(t2) ? this.k(t2) : this.g(t2);
}
S(t2) {
return this._$AA.parentNode.insertBefore(t2, this._$AB);
}
T(t2) {
this._$AH !== t2 && (this._$AR(), this._$AH = this.S(t2));
}
g(t2) {
this._$AH !== A && u(this._$AH) ? this._$AA.nextSibling.data = t2 : this.T(r.createTextNode(t2)), this._$AH = t2;
}
$(t2) {
var i2;
const { values: s2, _$litType$: e2 } = t2, o2 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = V.createElement(e2.h, this.options)), e2);
if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o2)
this._$AH.p(s2);
else {
const t3 = new S(o2, this), i3 = t3.v(this.options);
t3.p(s2), this.T(i3), this._$AH = t3;
}
}
_$AC(t2) {
let i2 = E.get(t2.strings);
return void 0 === i2 && E.set(t2.strings, i2 = new V(t2)), i2;
}
k(t2) {
c(this._$AH) || (this._$AH = [], this._$AR());
const i2 = this._$AH;
let s2, e2 = 0;
for (const o2 of t2)
e2 === i2.length ? i2.push(s2 = new M(this.S(d()), this.S(d()), this, this.options)) : s2 = i2[e2], s2._$AI(o2), e2++;
e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2);
}
_$AR(t2 = this._$AA.nextSibling, i2) {
var s2;
for (null === (s2 = this._$AP) || void 0 === s2 || s2.call(this, false, true, i2); t2 && t2 !== this._$AB; ) {
const i3 = t2.nextSibling;
t2.remove(), t2 = i3;
}
}
setConnected(t2) {
var i2;
void 0 === this._$AM && (this._$Cm = t2, null === (i2 = this._$AP) || void 0 === i2 || i2.call(this, t2));
}
}
class R {
constructor(t2, i2, s2, e2, o2) {
this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o2, s2.length > 2 || "" !== s2[0] || "" !== s2[1] ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = A;
}
get tagName() {
return this.element.tagName;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t2, i2 = this, s2, e2) {
const o2 = this.strings;
let n2 = false;
if (void 0 === o2)
t2 = N(this, t2, i2, 0), n2 = !u(t2) || t2 !== this._$AH && t2 !== T, n2 && (this._$AH = t2);
else {
const e3 = t2;
let l2, h2;
for (t2 = o2[0], l2 = 0; l2 < o2.length - 1; l2++)
h2 = N(this, e3[s2 + l2], i2, l2), h2 === T && (h2 = this._$AH[l2]), n2 || (n2 = !u(h2) || h2 !== this._$AH[l2]), h2 === A ? t2 = A : t2 !== A && (t2 += (null != h2 ? h2 : "") + o2[l2 + 1]), this._$AH[l2] = h2;
}
n2 && !e2 && this.j(t2);
}
j(t2) {
t2 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t2 ? t2 : "");
}
}
class k extends R {
constructor() {
super(...arguments), this.type = 3;
}
j(t2) {
this.element[this.name] = t2 === A ? void 0 : t2;
}
}
const H = s ? s.emptyScript : "";
class I extends R {
constructor() {
super(...arguments), this.type = 4;
}
j(t2) {
t2 && t2 !== A ? this.element.setAttribute(this.name, H) : this.element.removeAttribute(this.name);
}
}
class L extends R {
constructor(t2, i2, s2, e2, o2) {
super(t2, i2, s2, e2, o2), this.type = 5;
}
_$AI(t2, i2 = this) {
var s2;
if ((t2 = null !== (s2 = N(this, t2, i2, 0)) && void 0 !== s2 ? s2 : A) === T)
return;
const e2 = this._$AH, o2 = t2 === A && e2 !== A || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== A && (e2 === A || o2);
o2 && this.element.removeEventListener(this.name, this, e2), n2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2;
}
handleEvent(t2) {
var i2, s2;
"function" == typeof this._$AH ? this._$AH.call(null !== (s2 = null === (i2 = this.options) || void 0 === i2 ? void 0 : i2.host) && void 0 !== s2 ? s2 : this.element, t2) : this._$AH.handleEvent(t2);
}
}
class z {
constructor(t2, i2, s2) {
this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s2;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t2) {
N(this, t2);
}
}
const j = i.litHtmlPolyfillSupport;
null == j || j(V, M), (null !== (t = i.litHtmlVersions) && void 0 !== t ? t : i.litHtmlVersions = []).push("2.7.0");
const B = (t2, i2, s2) => {
var e2, o2;
const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2;
let l2 = n2._$litPart$;
if (void 0 === l2) {
const t3 = null !== (o2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== o2 ? o2 : null;
n2._$litPart$ = l2 = new M(i2.insertBefore(d(), t3), t3, void 0, null != s2 ? s2 : {});
}
return l2._$AI(t2), l2;
};
export { x as html, T as noChange, A as nothing, B as render };