wrec 0.42.0 → 0.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{wrec-RkviIlbF.js → wrec-jeb0Pxec.js} +290 -232
- package/dist/wrec-ssr.es.js +5 -5
- package/dist/wrec.es.js +1 -1
- package/package.json +10 -10
- package/scripts/lint.js +62 -0
- package/dist/wrec-ssr.d.ts +0 -97
- package/dist/wrec.d.ts +0 -97
|
@@ -140,20 +140,20 @@ function l(e, t, n) {
|
|
|
140
140
|
}
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/evaluation.ts
|
|
143
|
-
var u = "a-zA-Z_$
|
|
144
|
-
function
|
|
143
|
+
var u = "[a-zA-Z_$][a-zA-Z_$0-9]*", d = RegExp(`this\\.(${u})\\s*\\(`, "g"), ee = /<!--\s*(.*?)\s*-->/, f = RegExp(`^this\\.${u}$`), p = RegExp(`this\\.${u}(\\.${u})*`, "g"), m = RegExp(`this\\.${u}(\\.${u})*`);
|
|
144
|
+
function h(e, t) {
|
|
145
145
|
for (let [n, r] of Object.entries(t)) e[n] === void 0 && (e[n] = te(r));
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function g(e, t) {
|
|
148
148
|
let n = Object.entries(t).filter(([e, t]) => !!t.computed).map(([e]) => e), r = new Set(n), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
149
149
|
for (let o of n) {
|
|
150
150
|
let n = t[o].computed, s = /* @__PURE__ */ new Set();
|
|
151
|
-
for (let r of n.matchAll(
|
|
152
|
-
let n =
|
|
151
|
+
for (let r of n.matchAll(p)) {
|
|
152
|
+
let n = y(r[0]), i = x(n), a = !1;
|
|
153
153
|
for (let [e, n] of Object.entries(t)) S(n.usedBy)?.includes(i) && (s.add(e), a = !0);
|
|
154
154
|
!a && typeof e[n] != "function" && s.add(n);
|
|
155
155
|
}
|
|
156
|
-
for (let e of n.matchAll(
|
|
156
|
+
for (let e of n.matchAll(d)) {
|
|
157
157
|
let n = e[1];
|
|
158
158
|
for (let [e, r] of Object.entries(t)) S(r.usedBy)?.includes(n) && s.add(e);
|
|
159
159
|
}
|
|
@@ -165,8 +165,8 @@ function v(e, t) {
|
|
|
165
165
|
expressions: a
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
let { computedNames: n, dependenciesMap: r, expressions: i } =
|
|
168
|
+
function _(e, t) {
|
|
169
|
+
let { computedNames: n, dependenciesMap: r, expressions: i } = g(t, e.properties ?? {}), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = [];
|
|
170
170
|
for (let e of n) {
|
|
171
171
|
let t = r.get(e) ?? [];
|
|
172
172
|
o.set(e, t.length), t.length === 0 && s.push(e);
|
|
@@ -190,25 +190,25 @@ function ee(e, t) {
|
|
|
190
190
|
throw Error(`computed properties form a cycle: ${e.join(", ")}`);
|
|
191
191
|
}
|
|
192
192
|
let l = e.context ?? {};
|
|
193
|
-
for (let e of c) t[e] =
|
|
193
|
+
for (let e of c) t[e] = v(i.get(e), t, l);
|
|
194
194
|
}
|
|
195
195
|
function te(e) {
|
|
196
|
-
return e.value === void 0 ? Array.isArray(e.values) && e.values.length > 0 ? e.values[0] :
|
|
196
|
+
return e.value === void 0 ? Array.isArray(e.values) && e.values.length > 0 ? e.values[0] : ne(e.type) : e.value;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function ne(e) {
|
|
199
199
|
return e === String ? "" : e === Number ? 0 : e === Boolean ? !1 : e === Array ? [] : e === Object ? {} : void 0;
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function v(e, t, n = {}) {
|
|
202
202
|
return Function("context", `const {${Object.keys(n).join(",")}} = context; return ${e};`).call(t, n);
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function y(e) {
|
|
205
205
|
return e.substring(5).split(".")[0];
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function b(e, t = {}) {
|
|
208
208
|
let n = Object.create(e.prototype);
|
|
209
|
-
return Object.assign(n, t),
|
|
209
|
+
return Object.assign(n, t), h(n, e.properties ?? {}), _(e, n), n;
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function x(e) {
|
|
212
212
|
return `get ${e}`;
|
|
213
213
|
}
|
|
214
214
|
function S(e) {
|
|
@@ -216,7 +216,7 @@ function S(e) {
|
|
|
216
216
|
}
|
|
217
217
|
//#endregion
|
|
218
218
|
//#region src/sanitize-xss.ts
|
|
219
|
-
var
|
|
219
|
+
var C = "__WREC", re = "__", ie = "[A-Za-z_$][A-Za-z0-9_$]*", ae = new Set([
|
|
220
220
|
"checked",
|
|
221
221
|
"colspan",
|
|
222
222
|
"disabled",
|
|
@@ -231,26 +231,26 @@ var ie = "__WREC", ae = "__", oe = "[A-Za-z_$][A-Za-z0-9_$]*", se = new Set([
|
|
|
231
231
|
"type",
|
|
232
232
|
"value"
|
|
233
233
|
]);
|
|
234
|
-
function
|
|
235
|
-
return `${
|
|
234
|
+
function oe(e, t) {
|
|
235
|
+
return `${C}${e}_${t}${re}`;
|
|
236
236
|
}
|
|
237
237
|
function w(e) {
|
|
238
238
|
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function T(e) {
|
|
241
241
|
let t = e.trim();
|
|
242
|
-
return t ? RegExp(`^${
|
|
242
|
+
return t ? RegExp(`^${ie}$`).test(t) ? !0 : t.startsWith("this.") : !1;
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function se(t) {
|
|
245
245
|
let n = {
|
|
246
246
|
allowCommentTag: !0,
|
|
247
247
|
onTagAttr(e, t, n) {
|
|
248
|
-
if (t.startsWith("on")) return
|
|
248
|
+
if (t.startsWith("on")) return T(n) ? `${t}="${w(n)}"` : "";
|
|
249
249
|
if (t === "title" || t.startsWith("aria-") || t.startsWith("data-")) return `${t}="${w(n)}"`;
|
|
250
250
|
if (e === "a" && t === "href" && n.startsWith("javascript")) return "";
|
|
251
251
|
},
|
|
252
252
|
safeAttrValue(e, t, n) {
|
|
253
|
-
return t === "class" ||
|
|
253
|
+
return t === "class" || ae.has(t) || e === "a" && t === "href" || e === "img" && t === "src" ? n : "";
|
|
254
254
|
},
|
|
255
255
|
stripIgnoreTagBody: [
|
|
256
256
|
"script",
|
|
@@ -297,7 +297,7 @@ function T(t) {
|
|
|
297
297
|
}
|
|
298
298
|
}, r = [], i = Date.now() + Math.floor(Math.random() * 1e6);
|
|
299
299
|
t = t.replace(/<!--[\s\S]*?-->/g, (e) => {
|
|
300
|
-
let t =
|
|
300
|
+
let t = oe(i, r.length);
|
|
301
301
|
return r.push({
|
|
302
302
|
comment: e,
|
|
303
303
|
token: t
|
|
@@ -376,7 +376,7 @@ function K(e) {
|
|
|
376
376
|
let { localName: t } = e;
|
|
377
377
|
return t === "input" || t === "select";
|
|
378
378
|
}
|
|
379
|
-
var q = (e) => `get ${e}`,
|
|
379
|
+
var q = (e) => `get ${e}`, ce = (e) => e.replace(/<!--[\s\S]*?-->/g, "");
|
|
380
380
|
function J(e, t, n, r) {
|
|
381
381
|
return e.slice(0, t) + r + e.slice(t + n);
|
|
382
382
|
}
|
|
@@ -410,7 +410,7 @@ function Z(e, t, n) {
|
|
|
410
410
|
e instanceof CSSStyleRule ? e.style.getPropertyValue(r) !== n && e.style.setProperty(r, n) : (X(e, r, n), r === "value" && K(e) && e.value !== n && (e.value = n));
|
|
411
411
|
}
|
|
412
412
|
var Q = (e) => typeof e == "string" ? [e] : e;
|
|
413
|
-
async function
|
|
413
|
+
async function le(e) {
|
|
414
414
|
let t = /* @__PURE__ */ new Set();
|
|
415
415
|
for (let n of L(e.content)) {
|
|
416
416
|
let { localName: e } = n;
|
|
@@ -454,16 +454,17 @@ var $ = class e extends O {
|
|
|
454
454
|
#e = !1;
|
|
455
455
|
#t = /* @__PURE__ */ new Set();
|
|
456
456
|
#n = this.constructor;
|
|
457
|
-
#r =
|
|
458
|
-
#i =
|
|
459
|
-
#a;
|
|
460
|
-
#o
|
|
461
|
-
#s =
|
|
462
|
-
#c =
|
|
457
|
+
#r = !1;
|
|
458
|
+
#i = /* @__PURE__ */ new Map();
|
|
459
|
+
#a = {};
|
|
460
|
+
#o;
|
|
461
|
+
#s = {};
|
|
462
|
+
#c = null;
|
|
463
463
|
#l = /* @__PURE__ */ new Map();
|
|
464
|
-
#u = /* @__PURE__ */ new
|
|
465
|
-
#d = /* @__PURE__ */ new
|
|
466
|
-
#f = /* @__PURE__ */ new
|
|
464
|
+
#u = /* @__PURE__ */ new Map();
|
|
465
|
+
#d = /* @__PURE__ */ new WeakMap();
|
|
466
|
+
#f = /* @__PURE__ */ new WeakSet();
|
|
467
|
+
#p = /* @__PURE__ */ new Map();
|
|
467
468
|
static define(e) {
|
|
468
469
|
if (this.elementName = e, k.get(e)) throw new A(`custom element ${e} is already defined`);
|
|
469
470
|
k.define(e, this);
|
|
@@ -471,37 +472,49 @@ var $ = class e extends O {
|
|
|
471
472
|
constructor() {
|
|
472
473
|
super(), this.attachShadow({ mode: "open" });
|
|
473
474
|
let e = this.#n;
|
|
474
|
-
this.#
|
|
475
|
+
this.#A("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#A("computedGraph") || (e.computedGraph = null), this.#A("computedPropsRegistered") || (e.computedPropsRegistered = !1), this.#A("properties") || (e.properties = {}), this.#A("propToAttrMap") || (e.propToAttrMap = /* @__PURE__ */ new Map()), this.#A("propToComputedMap") || (e.propToComputedMap = /* @__PURE__ */ new Map()), this.#A("propToExprsMap") || (e.propToExprsMap = /* @__PURE__ */ new Map()), this.#A("registeredComputedProps") || (e.registeredComputedProps = /* @__PURE__ */ new Set());
|
|
475
476
|
}
|
|
476
477
|
attributeChangedCallback(t, n, r) {
|
|
477
|
-
t === "disabled" && this.#
|
|
478
|
+
t === "disabled" && this.#y();
|
|
478
479
|
let i = e.getPropName(t);
|
|
479
|
-
if (!this.#
|
|
480
|
-
let e = this.#
|
|
481
|
-
this.#
|
|
482
|
-
let t = this.#
|
|
480
|
+
if (!this.#M(i) && this.#j(i)) {
|
|
481
|
+
let e = this.#K(i, r);
|
|
482
|
+
this.#B(i, e);
|
|
483
|
+
let t = this.#a[i];
|
|
483
484
|
t && this.setFormValue(t, String(e));
|
|
484
485
|
}
|
|
485
486
|
}
|
|
486
487
|
batchSet(e) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
488
|
+
let t = this.#$(e);
|
|
489
|
+
if (t.entries.length === 0) return;
|
|
490
|
+
let [n, r] = t.entries[0];
|
|
491
|
+
if (t.errors.length) {
|
|
492
|
+
this.#b(n, r, t.errors);
|
|
493
|
+
return;
|
|
493
494
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
let
|
|
498
|
-
|
|
495
|
+
this.#e = !0;
|
|
496
|
+
let i = this.#n.propToExprsMap, a = /* @__PURE__ */ new Set();
|
|
497
|
+
try {
|
|
498
|
+
for (let [e, n] of t.entries) {
|
|
499
|
+
this.#B(e, n);
|
|
500
|
+
let t = i.get(e) ?? [];
|
|
501
|
+
for (let e of t) a.add(e);
|
|
502
|
+
}
|
|
503
|
+
let e = this.#E(t.entries.map(([e]) => e));
|
|
504
|
+
for (let [t, n] of e) {
|
|
505
|
+
this.#z(t, this.#C(n));
|
|
506
|
+
let e = i.get(t) ?? [];
|
|
507
|
+
for (let t of e) a.add(t);
|
|
508
|
+
}
|
|
509
|
+
this.#S([...a]);
|
|
510
|
+
} finally {
|
|
511
|
+
this.#e = !1;
|
|
499
512
|
}
|
|
500
|
-
|
|
513
|
+
for (let [e, n] of t.entries) this.#n.properties[e] && this.#b(e, n, []);
|
|
501
514
|
}
|
|
502
|
-
async #
|
|
515
|
+
async #m() {
|
|
503
516
|
let e = this.#n, { template: t } = e;
|
|
504
|
-
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await
|
|
517
|
+
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await le(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
|
|
505
518
|
}
|
|
506
519
|
static buildHTML() {
|
|
507
520
|
let e = "<style>\n :host([hidden]) { display: none; }";
|
|
@@ -511,42 +524,48 @@ var $ = class e extends O {
|
|
|
511
524
|
return t.startsWith("<") || (t = `<span><!--${t}--></span>`), e + t;
|
|
512
525
|
}
|
|
513
526
|
changed(e, t, n) {
|
|
514
|
-
this.#
|
|
527
|
+
this.#B(t, n);
|
|
515
528
|
}
|
|
516
|
-
|
|
517
|
-
this.#X(), this.#h(), await this.#p(), this.hasAttribute("disabled") && this.#v(), this.#ne(this.shadowRoot), this.#M(this.shadowRoot), this.#Y(), this.#m(), this.ready();
|
|
518
|
-
}
|
|
519
|
-
#m() {
|
|
529
|
+
#h() {
|
|
520
530
|
let { properties: e } = this.#n;
|
|
521
|
-
for (let [t, { computed: n }] of Object.entries(e)) n && this.#
|
|
531
|
+
for (let [t, { computed: n }] of Object.entries(e)) n && this.#z(t, this.#C(n));
|
|
522
532
|
}
|
|
523
|
-
|
|
533
|
+
async connectedCallback() {
|
|
534
|
+
this.#Q(), this.#g(), await this.#m(), this.hasAttribute("disabled") && this.#y(), this.#ae(this.shadowRoot), this.#P(this.shadowRoot), this.#Z(), this.#h(), this.ready();
|
|
535
|
+
}
|
|
536
|
+
#g() {
|
|
524
537
|
let { observedAttributes: e, properties: t } = this.#n;
|
|
525
|
-
for (let [n, r] of Object.entries(t)) r.computed || this.#
|
|
526
|
-
for (let [n, r] of Object.entries(t)) r.computed && this.#
|
|
527
|
-
this.#
|
|
538
|
+
for (let [n, r] of Object.entries(t)) r.computed || this.#_(n, r, e);
|
|
539
|
+
for (let [n, r] of Object.entries(t)) r.computed && this.#_(n, r, e);
|
|
540
|
+
this.#L();
|
|
528
541
|
}
|
|
529
|
-
#
|
|
542
|
+
#_(t, n, r) {
|
|
530
543
|
if (t === "class" || t === "style") throw new A(`"${t}" is a reserved property`);
|
|
531
544
|
let i = e.getAttrName(t), a = this.hasAttribute(i);
|
|
532
|
-
n.required && !a && this.#
|
|
545
|
+
n.required && !a && this.#U(this, i, "is a required attribute");
|
|
533
546
|
let o = n.value;
|
|
534
|
-
this.hasOwnProperty(t) && (o = this.#
|
|
535
|
-
let { type: s } = n, c = s === Boolean ? o || a : r.includes(i) && a ? this.#
|
|
536
|
-
this.#
|
|
547
|
+
this.hasOwnProperty(t) && (o = this.#D(t), this.#v(t));
|
|
548
|
+
let { type: s } = n, c = s === Boolean ? o || a : r.includes(i) && a ? this.#G(t, i) : o ?? F(n), u = "#" + t;
|
|
549
|
+
this.#B(u, this.#N(t, s, c)), Object.defineProperty(this, t, {
|
|
537
550
|
enumerable: !0,
|
|
538
551
|
get() {
|
|
539
|
-
return this.#
|
|
552
|
+
return this.#D(u);
|
|
540
553
|
},
|
|
541
554
|
set(e) {
|
|
542
|
-
n.computed && !this.#t.has(t) && this.#
|
|
543
|
-
let r = this.#
|
|
544
|
-
if (e === r
|
|
545
|
-
|
|
546
|
-
let a = this.#
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
555
|
+
n.computed && !this.#t.has(t) && this.#U(null, t, "is a computed property and cannot be set directly"), s === Number && typeof e == "string" && (e = Y(e));
|
|
556
|
+
let r = this.#D(u);
|
|
557
|
+
if (e === r) return;
|
|
558
|
+
this.#re(t, s, e);
|
|
559
|
+
let a = this.#ee(n, t, e);
|
|
560
|
+
if (!a.skipped && a.errors.length) {
|
|
561
|
+
this.#b(t, e, a.errors);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
e = this.#N(t, s, e), this.#B(u, e);
|
|
565
|
+
let o = this.#u.get(t);
|
|
566
|
+
o && l(o.state, o.stateProp, e), this.#q(t, s, e, i), this.#e || (this.#J(t), this.#I(t)), this.#X(t, e);
|
|
567
|
+
let c = this.#a[t];
|
|
568
|
+
c && this.setFormValue(c, String(e)), this.propertyChangedCallback(t, r, e), a.skipped || this.#b(t, e, a.errors), n.dispatch && this.dispatch("change", {
|
|
550
569
|
tagName: this.localName,
|
|
551
570
|
property: t,
|
|
552
571
|
oldValue: r,
|
|
@@ -555,16 +574,16 @@ var $ = class e extends O {
|
|
|
555
574
|
}
|
|
556
575
|
});
|
|
557
576
|
}
|
|
558
|
-
#
|
|
577
|
+
#v(e) {
|
|
559
578
|
delete this[e];
|
|
560
579
|
}
|
|
561
|
-
#
|
|
580
|
+
#y() {
|
|
562
581
|
let t = this.hasAttribute("disabled"), n = L(this.shadowRoot);
|
|
563
582
|
for (let r of n) N(r) && (r instanceof e ? t ? r.setAttribute("disabled", "") : r.removeAttribute("disabled") : r.disabled = t);
|
|
564
583
|
}
|
|
565
584
|
disconnectedCallback() {
|
|
566
|
-
for (let { unsubscribe: e } of this.#
|
|
567
|
-
this.#
|
|
585
|
+
for (let { unsubscribe: e } of this.#p.values()) e();
|
|
586
|
+
this.#i.clear(), this.#s = {}, this.#l.clear(), this.#u.clear(), this.#p.clear();
|
|
568
587
|
}
|
|
569
588
|
dispatch(e, t) {
|
|
570
589
|
this.dispatchEvent(new CustomEvent(e, {
|
|
@@ -573,42 +592,55 @@ var $ = class e extends O {
|
|
|
573
592
|
detail: t
|
|
574
593
|
}));
|
|
575
594
|
}
|
|
595
|
+
#b(e, t, n) {
|
|
596
|
+
this.#r = !0;
|
|
597
|
+
try {
|
|
598
|
+
this.dispatch("validation", {
|
|
599
|
+
instance: this,
|
|
600
|
+
property: e,
|
|
601
|
+
value: t,
|
|
602
|
+
errors: n
|
|
603
|
+
});
|
|
604
|
+
} finally {
|
|
605
|
+
this.#r = !1;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
576
608
|
displayIfSet(e, t = "block") {
|
|
577
609
|
return `display: ${e == null ? "none" : t}`;
|
|
578
610
|
}
|
|
579
|
-
#
|
|
611
|
+
#x(t) {
|
|
580
612
|
let n = t instanceof e;
|
|
581
613
|
for (let r of t.getAttributeNames()) {
|
|
582
614
|
let i = t.getAttribute(r);
|
|
583
615
|
if (r === "ref") {
|
|
584
|
-
this.#
|
|
616
|
+
this.#H(t, i);
|
|
585
617
|
continue;
|
|
586
618
|
}
|
|
587
|
-
let a = this.#
|
|
619
|
+
let a = this.#F(t, i);
|
|
588
620
|
if (a) {
|
|
589
|
-
let i = this.#
|
|
590
|
-
i === void 0 && this.#
|
|
621
|
+
let i = this.#D(a);
|
|
622
|
+
i === void 0 && this.#W(t, r, a);
|
|
591
623
|
let [o, s] = r.split(":"), c = e.getPropName(o);
|
|
592
624
|
if (o === "checked") {
|
|
593
625
|
let { type: e } = this.#n.properties[a];
|
|
594
|
-
V(t) && e !== Boolean && this.#
|
|
626
|
+
V(t) && e !== Boolean && this.#U(t, r, `refers to property "${a}" whose type is not Boolean`), W(t) && e !== String && this.#U(t, r, `refers to property "${a}" whose type is not String`);
|
|
595
627
|
}
|
|
596
|
-
let l = this.#
|
|
597
|
-
n && t.#
|
|
628
|
+
let l = this.#M(a);
|
|
629
|
+
n && t.#M(c) || (o === "checked" && W(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#U(t, r, "refers to an unsupported event name"), t.setAttribute(o, this.#D(a))) : s = "change"), n && !l && t.#l.set(e.getPropName(o), a);
|
|
598
630
|
}
|
|
599
|
-
this.#
|
|
631
|
+
this.#V(i, t, r);
|
|
600
632
|
}
|
|
601
633
|
}
|
|
602
|
-
#
|
|
634
|
+
#S(e) {
|
|
603
635
|
for (let t of e) {
|
|
604
|
-
let e = this.#
|
|
636
|
+
let e = this.#C(t), n = this.#i.get(t) ?? [], r = /* @__PURE__ */ new Set();
|
|
605
637
|
for (let t of n) {
|
|
606
638
|
let n = t instanceof HTMLElement || t instanceof CSSStyleRule ? t : t.element;
|
|
607
639
|
if (n instanceof HTMLElement && !n.isConnected) {
|
|
608
640
|
r.add(t);
|
|
609
641
|
continue;
|
|
610
642
|
}
|
|
611
|
-
if (t instanceof HTMLElement) this.#
|
|
643
|
+
if (t instanceof HTMLElement) this.#Y(t, e);
|
|
612
644
|
else if (!(t instanceof CSSStyleRule)) {
|
|
613
645
|
let { element: n, attrName: r } = t;
|
|
614
646
|
n instanceof CSSStyleRule ? n.style.setProperty(r, e) : Z(n, r, e);
|
|
@@ -616,14 +648,14 @@ var $ = class e extends O {
|
|
|
616
648
|
}
|
|
617
649
|
if (r.size > 0) {
|
|
618
650
|
let e = n.filter((e) => !r.has(e));
|
|
619
|
-
e.length === 0 ? this.#
|
|
651
|
+
e.length === 0 ? this.#i.delete(t) : this.#i.set(t, e);
|
|
620
652
|
}
|
|
621
653
|
}
|
|
622
654
|
}
|
|
623
|
-
#
|
|
624
|
-
return
|
|
655
|
+
#C(e) {
|
|
656
|
+
return v(e, this, this.#n.context);
|
|
625
657
|
}
|
|
626
|
-
#
|
|
658
|
+
#w(e) {
|
|
627
659
|
let { localName: t } = e;
|
|
628
660
|
if (t === "style") {
|
|
629
661
|
let { sheet: t } = e, n = t?.cssRules ?? [], r = Array.from(n);
|
|
@@ -631,22 +663,22 @@ var $ = class e extends O {
|
|
|
631
663
|
let t = Array.from(e.style);
|
|
632
664
|
for (let n of t) if (n.startsWith("--")) {
|
|
633
665
|
let t = e.style.getPropertyValue(n);
|
|
634
|
-
this.#
|
|
666
|
+
this.#V(t, e, n);
|
|
635
667
|
}
|
|
636
668
|
}
|
|
637
669
|
} else {
|
|
638
670
|
let t = "";
|
|
639
671
|
if (G(e)) {
|
|
640
|
-
this.#
|
|
641
|
-
let n = e.textContent?.match(
|
|
672
|
+
this.#V(e.textContent, e);
|
|
673
|
+
let n = e.textContent?.match(ee);
|
|
642
674
|
n && (t = n[1]);
|
|
643
675
|
} else {
|
|
644
676
|
let n = Array.from(e.childNodes).find((e) => e.nodeType === Node.COMMENT_NODE);
|
|
645
677
|
n && (t = n.textContent?.trim() ?? "");
|
|
646
678
|
}
|
|
647
679
|
if (t) {
|
|
648
|
-
let n = this.#
|
|
649
|
-
n && G(e) ? e.textContent = this.#
|
|
680
|
+
let n = this.#F(e, t);
|
|
681
|
+
n && G(e) ? e.textContent = this.#D(n) : this.#V(t, e);
|
|
650
682
|
}
|
|
651
683
|
}
|
|
652
684
|
}
|
|
@@ -654,7 +686,7 @@ var $ = class e extends O {
|
|
|
654
686
|
let e = this.getAttribute("form-assoc");
|
|
655
687
|
if (!e) {
|
|
656
688
|
let t = this.getAttribute("name");
|
|
657
|
-
if (t) if (this.#
|
|
689
|
+
if (t) if (this.#j("value")) e = `value:${t}`;
|
|
658
690
|
else return;
|
|
659
691
|
else return;
|
|
660
692
|
}
|
|
@@ -663,26 +695,26 @@ var $ = class e extends O {
|
|
|
663
695
|
let [n, r] = e.split(":");
|
|
664
696
|
t[n.trim()] = r.trim();
|
|
665
697
|
}
|
|
666
|
-
this.#
|
|
698
|
+
this.#a = t, this.#o = new FormData(), this.#c = this.attachInternals(), this.#c.setFormValue(this.#o);
|
|
667
699
|
for (let [e, n] of Object.entries(t)) {
|
|
668
|
-
let t = this.#
|
|
700
|
+
let t = this.#D(e);
|
|
669
701
|
U(t) && this.setFormValue(n, String(t));
|
|
670
702
|
}
|
|
671
|
-
let r = Object.keys(this.#n.properties), i = this.#
|
|
672
|
-
for (let e of r) i[e] = this.#
|
|
703
|
+
let r = Object.keys(this.#n.properties), i = this.#s;
|
|
704
|
+
for (let e of r) i[e] = this.#D(e);
|
|
673
705
|
}
|
|
674
706
|
formResetCallback() {
|
|
675
|
-
let e = this.#
|
|
707
|
+
let e = this.#s;
|
|
676
708
|
for (let t of Object.keys(e)) {
|
|
677
709
|
let n = e[t];
|
|
678
|
-
|
|
710
|
+
f.test(n) && (n = this.#C(n)), this.#B(t, n);
|
|
679
711
|
}
|
|
680
712
|
}
|
|
681
713
|
static getAttrName(e) {
|
|
682
714
|
let t = this.propToAttrMap.get(e);
|
|
683
715
|
return t || (t = e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), this.propToAttrMap.set(e, t)), t;
|
|
684
716
|
}
|
|
685
|
-
#
|
|
717
|
+
#T() {
|
|
686
718
|
let e = this.#n, t = e.computedGraph;
|
|
687
719
|
if (t) return t;
|
|
688
720
|
let n = E(), r = E(), i = {};
|
|
@@ -699,8 +731,8 @@ var $ = class e extends O {
|
|
|
699
731
|
computedToExprMap: i
|
|
700
732
|
}, e.computedGraph = t, t;
|
|
701
733
|
}
|
|
702
|
-
#
|
|
703
|
-
let { computedToDependenciesMap: t, computedToDependentsMap: n, computedToExprMap: r } = this.#
|
|
734
|
+
#E(e) {
|
|
735
|
+
let { computedToDependenciesMap: t, computedToDependentsMap: n, computedToExprMap: r } = this.#T(), i = this.#n.propToComputedMap, a = /* @__PURE__ */ new Set(), o = [...new Set(e)];
|
|
704
736
|
for (let e = 0; e < o.length; e++) {
|
|
705
737
|
let t = o[e], n = i.get(t) || [];
|
|
706
738
|
for (let [e, t] of n) r[e] = t, a.has(e) || (a.add(e), o.push(e));
|
|
@@ -724,77 +756,77 @@ var $ = class e extends O {
|
|
|
724
756
|
if (c.length !== a.size) throw new A(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
|
|
725
757
|
return c.map((e) => [e, r[e]]);
|
|
726
758
|
}
|
|
727
|
-
#
|
|
759
|
+
#D(e) {
|
|
728
760
|
return this[e];
|
|
729
761
|
}
|
|
730
762
|
static getPropName(e) {
|
|
731
763
|
let t = this.attrToPropMap.get(e);
|
|
732
764
|
return t || (t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), this.attrToPropMap.set(e, t)), t;
|
|
733
765
|
}
|
|
734
|
-
#
|
|
735
|
-
let r = this.#
|
|
736
|
-
i && l(i.state, i.stateProp, r), this.#e || (this.#
|
|
766
|
+
#O(e, t, n) {
|
|
767
|
+
let r = this.#D("#" + e), i = this.#u.get(e);
|
|
768
|
+
i && l(i.state, i.stateProp, r), this.#e || (this.#J(e), this.#I(e)), this.#X(e, r), this.propertyChangedCallback(e, t, n);
|
|
737
769
|
}
|
|
738
|
-
#
|
|
770
|
+
#k(e, t, n) {
|
|
739
771
|
if (n.length !== 1) return;
|
|
740
772
|
let [r] = n;
|
|
741
|
-
if (!
|
|
773
|
+
if (!f.test(r)) return;
|
|
742
774
|
let i = V(e), a = W(e), o = K(e) || G(e), [s, c] = (t ?? "").split(":");
|
|
743
775
|
if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || G(e))) return;
|
|
744
|
-
c ? e["on" + c] === void 0 && this.#
|
|
745
|
-
let l =
|
|
776
|
+
c ? e["on" + c] === void 0 && this.#U(e, t, "refers to an unsupported event name") : c = "change";
|
|
777
|
+
let l = y(r);
|
|
746
778
|
e.addEventListener(c, (e) => {
|
|
747
779
|
let { target: t } = e;
|
|
748
780
|
if (!t) return;
|
|
749
781
|
let { type: n } = this.#n.properties[l], r = t, { value: o } = r;
|
|
750
|
-
s === "checked" ? i ? this.#
|
|
782
|
+
s === "checked" ? i ? this.#B(l, r.checked) : a && r.checked && this.#B(l, o) : this.#B(l, n === Number ? Y(o) : o), this.#I(l);
|
|
751
783
|
});
|
|
752
784
|
}
|
|
753
|
-
#
|
|
785
|
+
#A(e) {
|
|
754
786
|
return Object.hasOwn(this.#n, e);
|
|
755
787
|
}
|
|
756
|
-
#
|
|
788
|
+
#j(e) {
|
|
757
789
|
return !!this.#n.properties[e];
|
|
758
790
|
}
|
|
759
|
-
#
|
|
791
|
+
#M(e) {
|
|
760
792
|
return !!this.#n.properties[e]?.computed;
|
|
761
793
|
}
|
|
762
|
-
#
|
|
763
|
-
if (typeof r != "object" || !r || n !== Array && n !== Object || this.#
|
|
764
|
-
let i = this.#
|
|
794
|
+
#N(e, n, r) {
|
|
795
|
+
if (typeof r != "object" || !r || n !== Array && n !== Object || this.#f.has(r)) return r;
|
|
796
|
+
let i = this.#d.get(r);
|
|
765
797
|
if (i) return i;
|
|
766
798
|
let a = t(r, (t, n, r) => {
|
|
767
|
-
this.#
|
|
799
|
+
this.#O(e, n, r);
|
|
768
800
|
});
|
|
769
|
-
return this.#
|
|
801
|
+
return this.#d.set(r, a), this.#f.add(a), a;
|
|
770
802
|
}
|
|
771
|
-
#
|
|
803
|
+
#P(e) {
|
|
772
804
|
let t = Array.from(e.querySelectorAll("*"));
|
|
773
|
-
for (let e of t) this.#
|
|
805
|
+
for (let e of t) this.#x(e), e.firstElementChild || this.#w(e);
|
|
774
806
|
}
|
|
775
807
|
static get observedAttributes() {
|
|
776
808
|
let t = Object.entries(this.properties || {}).filter(([e, t]) => !t.computed).map(([t]) => e.getAttrName(t));
|
|
777
809
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
778
810
|
}
|
|
779
811
|
propertyChangedCallback(e, t, n) {}
|
|
780
|
-
#
|
|
781
|
-
if (!t || !
|
|
782
|
-
let n =
|
|
783
|
-
return this.#
|
|
812
|
+
#F(e, t) {
|
|
813
|
+
if (!t || !f.test(t)) return;
|
|
814
|
+
let n = y(t);
|
|
815
|
+
return this.#D(n) === void 0 && this.#W(e, "", n), n;
|
|
784
816
|
}
|
|
785
|
-
#
|
|
817
|
+
#I(e) {
|
|
786
818
|
let t = this.#n.propToExprsMap.get(e) || [];
|
|
787
|
-
this.#
|
|
819
|
+
this.#S(t);
|
|
788
820
|
}
|
|
789
821
|
ready() {}
|
|
790
|
-
#
|
|
822
|
+
#L() {
|
|
791
823
|
let e = this.#n;
|
|
792
824
|
if (!e.computedPropsRegistered) {
|
|
793
825
|
e.computedPropsRegistered = !0, e.computedGraph = null;
|
|
794
|
-
for (let [t, n] of Object.entries(e.properties)) n.computed && this.#
|
|
826
|
+
for (let [t, n] of Object.entries(e.properties)) n.computed && this.#R(t, n);
|
|
795
827
|
}
|
|
796
828
|
}
|
|
797
|
-
#
|
|
829
|
+
#R(e, t) {
|
|
798
830
|
let n = this.#n;
|
|
799
831
|
n.registeredComputedProps.add(e);
|
|
800
832
|
let r = n.propToComputedMap;
|
|
@@ -803,33 +835,33 @@ var $ = class e extends O {
|
|
|
803
835
|
i || (i = [], r.set(t, i)), i.push([e, n]);
|
|
804
836
|
}
|
|
805
837
|
let a = t.computed;
|
|
806
|
-
for (let t of a.matchAll(
|
|
807
|
-
let r =
|
|
808
|
-
this.#
|
|
838
|
+
for (let t of a.matchAll(p)) {
|
|
839
|
+
let r = y(t[0]);
|
|
840
|
+
this.#D(r) === void 0 && this.#W(null, e, r);
|
|
809
841
|
let o = q(r), s = !1;
|
|
810
842
|
for (let [e, t] of Object.entries(n.properties)) Q(t.usedBy)?.includes(o) && (i(e, a), s = !0);
|
|
811
|
-
!s && typeof this.#
|
|
843
|
+
!s && typeof this.#D(r) != "function" && i(r, a);
|
|
812
844
|
}
|
|
813
|
-
for (let t of a.matchAll(
|
|
845
|
+
for (let t of a.matchAll(d)) {
|
|
814
846
|
let r = t[1];
|
|
815
|
-
if (typeof this.#
|
|
847
|
+
if (typeof this.#D(r) != "function") throw new A(`property ${e} computed calls non-method ${r}`);
|
|
816
848
|
for (let [e, t] of Object.entries(n.properties)) Q(t.usedBy)?.includes(r) && i(e, a);
|
|
817
849
|
}
|
|
818
850
|
}
|
|
819
|
-
#
|
|
851
|
+
#z(e, t) {
|
|
820
852
|
this.#t.add(e);
|
|
821
853
|
try {
|
|
822
|
-
this.#
|
|
854
|
+
this.#B(e, t);
|
|
823
855
|
} finally {
|
|
824
856
|
this.#t.delete(e);
|
|
825
857
|
}
|
|
826
858
|
}
|
|
827
|
-
#
|
|
859
|
+
#B(e, t) {
|
|
828
860
|
this[e] = t;
|
|
829
861
|
}
|
|
830
|
-
#
|
|
862
|
+
#V(e, t, n = void 0) {
|
|
831
863
|
if (!e) return;
|
|
832
|
-
let r = this.#
|
|
864
|
+
let r = this.#te(t, n, e);
|
|
833
865
|
if (!r) {
|
|
834
866
|
let r = e.replaceAll("this..", "this.");
|
|
835
867
|
n ? Z(t, n, r) : "textContent" in t && (t.textContent = r);
|
|
@@ -837,54 +869,54 @@ var $ = class e extends O {
|
|
|
837
869
|
}
|
|
838
870
|
let i = this.#n;
|
|
839
871
|
r.forEach((t) => {
|
|
840
|
-
let n =
|
|
841
|
-
if (typeof this.#
|
|
872
|
+
let n = y(t);
|
|
873
|
+
if (typeof this.#D(n) == "function") return;
|
|
842
874
|
let r = i.propToExprsMap, a = r.get(n);
|
|
843
875
|
a || (a = [], r.set(n, a)), a.includes(e) || a.push(e);
|
|
844
876
|
});
|
|
845
|
-
for (let [e, t] of this.#
|
|
877
|
+
for (let [e, t] of this.#i.entries()) for (let n of t) {
|
|
846
878
|
let r = n instanceof HTMLElement || n instanceof CSSStyleRule ? n : n.element;
|
|
847
|
-
r instanceof CSSStyleRule || r.isConnected || this.#
|
|
879
|
+
r instanceof CSSStyleRule || r.isConnected || this.#i.set(e, t.filter((e) => e !== n));
|
|
848
880
|
}
|
|
849
|
-
let a = this.#
|
|
850
|
-
a || (a = [], this.#
|
|
881
|
+
let a = this.#i.get(e);
|
|
882
|
+
a || (a = [], this.#i.set(e, a)), a.push(n ? {
|
|
851
883
|
element: t,
|
|
852
884
|
attrName: n
|
|
853
|
-
} : t), t instanceof HTMLElement && this.#
|
|
854
|
-
let o = this.#
|
|
855
|
-
n ? Z(t, n, o) : this.#
|
|
885
|
+
} : t), t instanceof HTMLElement && this.#k(t, n, r);
|
|
886
|
+
let o = this.#C(e);
|
|
887
|
+
n ? Z(t, n, o) : this.#Y(t, o);
|
|
856
888
|
}
|
|
857
|
-
#
|
|
889
|
+
#H(e, t) {
|
|
858
890
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
859
|
-
r || this.#
|
|
891
|
+
r || this.#W(e, "ref", n), r.type !== O && this.#U(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this.#D(n) && this.#U(e, "ref", `is a duplicate reference to the property "${n}"`), this.#B(n, e), e.removeAttribute("ref");
|
|
860
892
|
}
|
|
861
893
|
setAttributeSafe(e, t) {
|
|
862
894
|
this.hasAttribute(e) || this.setAttribute(e, t);
|
|
863
895
|
}
|
|
864
896
|
setFormValue(e, t) {
|
|
865
|
-
!this.#
|
|
897
|
+
!this.#o || !U(t) || (this.#o.set(e, t), this.#c?.setFormValue(this.#o));
|
|
866
898
|
}
|
|
867
899
|
static ssr(e = {}) {
|
|
868
900
|
throw new A("SSR is not available in the browser build.");
|
|
869
901
|
}
|
|
870
|
-
#
|
|
902
|
+
#U(e, t, n) {
|
|
871
903
|
let r = e instanceof HTMLElement ? e.localName : "CSS rule";
|
|
872
904
|
throw new A(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
|
|
873
905
|
}
|
|
874
|
-
#
|
|
875
|
-
this.#
|
|
906
|
+
#W(e, t, n) {
|
|
907
|
+
this.#U(e, t, `refers to missing property "${n}"`);
|
|
876
908
|
}
|
|
877
|
-
#
|
|
878
|
-
return this.#
|
|
909
|
+
#G(e, t) {
|
|
910
|
+
return this.#K(e, this.getAttribute(t));
|
|
879
911
|
}
|
|
880
|
-
#
|
|
881
|
-
if (n?.match(
|
|
912
|
+
#K(t, n) {
|
|
913
|
+
if (n?.match(p)) return n;
|
|
882
914
|
let r = this.#n.properties[t], { type: i, values: a } = r;
|
|
883
|
-
if (i || this.#
|
|
915
|
+
if (i || this.#U(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : F(r);
|
|
884
916
|
if (i === String) {
|
|
885
917
|
if (a && !a.includes(n)) {
|
|
886
918
|
let e = a.map((e) => `"${e}"`).join(", ");
|
|
887
|
-
this.#
|
|
919
|
+
this.#U(null, t, `must be one of ${e}`);
|
|
888
920
|
}
|
|
889
921
|
return n;
|
|
890
922
|
}
|
|
@@ -893,31 +925,31 @@ var $ = class e extends O {
|
|
|
893
925
|
if (n === "true") return !0;
|
|
894
926
|
if (n === "false" || n === "null") return !1;
|
|
895
927
|
let r = e.getAttrName(t);
|
|
896
|
-
return n && n !== r && this.#
|
|
928
|
+
return n && n !== r && this.#U(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
|
|
897
929
|
}
|
|
898
930
|
}
|
|
899
|
-
#
|
|
900
|
-
U(n) && !this.#
|
|
931
|
+
#q(e, t, n, r) {
|
|
932
|
+
U(n) && !this.#M(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#G(e, r)) && X(this, r || e, n);
|
|
901
933
|
}
|
|
902
|
-
#
|
|
903
|
-
for (let [t, n] of this.#
|
|
934
|
+
#J(e) {
|
|
935
|
+
for (let [t, n] of this.#E([e])) this.#z(t, this.#C(n));
|
|
904
936
|
}
|
|
905
|
-
#
|
|
937
|
+
#Y(e, t) {
|
|
906
938
|
if (t === void 0) return;
|
|
907
939
|
let n = e instanceof HTMLElement;
|
|
908
940
|
Array.isArray(t) && (t = t.join(""));
|
|
909
941
|
let r = typeof t;
|
|
910
|
-
r !== "string" && r !== "number" && this.#
|
|
942
|
+
r !== "string" && r !== "number" && this.#U(e, void 0, " computed content is not a string or number");
|
|
911
943
|
let i = String(t);
|
|
912
944
|
if (e instanceof HTMLElement && G(e)) e.value !== i && (e.value = i);
|
|
913
945
|
else if (n && r === "string" && i.trim().startsWith("<")) {
|
|
914
|
-
let t =
|
|
946
|
+
let t = se(i);
|
|
915
947
|
if (e.innerHTML === t) return;
|
|
916
|
-
e.innerHTML = t, this.#
|
|
948
|
+
e.innerHTML = t, this.#ae(e), this.#P(e);
|
|
917
949
|
} else n && e.textContent !== i && (e.textContent = i);
|
|
918
950
|
}
|
|
919
|
-
#
|
|
920
|
-
let n = this.#
|
|
951
|
+
#X(e, t) {
|
|
952
|
+
let n = this.#l.get(e);
|
|
921
953
|
if (!n) return;
|
|
922
954
|
let r = this.getRootNode();
|
|
923
955
|
if (!(r instanceof ShadowRoot)) return;
|
|
@@ -926,17 +958,17 @@ var $ = class e extends O {
|
|
|
926
958
|
let a = i;
|
|
927
959
|
a[n] = t;
|
|
928
960
|
}
|
|
929
|
-
#
|
|
961
|
+
#Z() {
|
|
930
962
|
let e = this.#n, t = (e, t, n) => {
|
|
931
963
|
let r = e.get(t);
|
|
932
964
|
r || (r = [], e.set(t, r)), r.includes(n) || r.push(n);
|
|
933
965
|
}, n = () => {
|
|
934
966
|
let n = E();
|
|
935
967
|
e.methodToExprsMap = n;
|
|
936
|
-
let r = Array.from(this.#
|
|
968
|
+
let r = Array.from(this.#i.keys());
|
|
937
969
|
for (let e of r) {
|
|
938
|
-
for (let r of e.matchAll(
|
|
939
|
-
for (let r of e.matchAll(
|
|
970
|
+
for (let r of e.matchAll(d)) t(n, r[1], e);
|
|
971
|
+
for (let r of e.matchAll(p)) t(n, q(y(r[0])), e);
|
|
940
972
|
}
|
|
941
973
|
}, { properties: r, propToExprsMap: i } = e;
|
|
942
974
|
for (let [t, a] of Object.entries(r)) {
|
|
@@ -949,7 +981,7 @@ var $ = class e extends O {
|
|
|
949
981
|
if (H(e)) {
|
|
950
982
|
let n = z(e);
|
|
951
983
|
if (typeof R(this, n)?.get != "function") throw new A(`property ${t} usedBy contains non-getter ${e}`);
|
|
952
|
-
} else if (typeof this.#
|
|
984
|
+
} else if (typeof this.#D(e) != "function") throw new A(`property ${t} usedBy contains non-method ${e}`);
|
|
953
985
|
let n = o.get(e) || [];
|
|
954
986
|
for (let e of n) s.includes(e) || s.push(e);
|
|
955
987
|
}
|
|
@@ -960,15 +992,15 @@ var $ = class e extends O {
|
|
|
960
992
|
t = {};
|
|
961
993
|
for (let n of Object.keys(e)) t[n] = n;
|
|
962
994
|
}
|
|
963
|
-
this.#
|
|
964
|
-
for (let [n, r] of Object.entries(t)) if (this.#
|
|
995
|
+
this.#ne(e, t);
|
|
996
|
+
for (let [n, r] of Object.entries(t)) if (this.#j(r)) {
|
|
965
997
|
let t = o(e, n);
|
|
966
|
-
t !== void 0 && this.#
|
|
998
|
+
t !== void 0 && this.#B(r, t), this.#u.set(r, {
|
|
967
999
|
state: e,
|
|
968
1000
|
stateProp: n
|
|
969
1001
|
});
|
|
970
1002
|
}
|
|
971
|
-
let n = this.#
|
|
1003
|
+
let n = this.#p.get(e), r = {
|
|
972
1004
|
...n?.map,
|
|
973
1005
|
...t
|
|
974
1006
|
};
|
|
@@ -976,77 +1008,103 @@ var $ = class e extends O {
|
|
|
976
1008
|
let i = e.subscribe(({ statePath: t, newValue: n }) => {
|
|
977
1009
|
let i = r[t];
|
|
978
1010
|
if (i) {
|
|
979
|
-
this.#
|
|
1011
|
+
this.#B(i, n);
|
|
980
1012
|
return;
|
|
981
1013
|
}
|
|
982
1014
|
let a = Object.keys(r).find((e) => t.startsWith(e + ".") || e.startsWith(t + "."));
|
|
983
1015
|
if (!a) return;
|
|
984
1016
|
let s = r[a];
|
|
985
|
-
this.#
|
|
1017
|
+
this.#B(s, o(e, a));
|
|
986
1018
|
}, Object.keys(r));
|
|
987
|
-
this.#
|
|
1019
|
+
this.#p.set(e, {
|
|
988
1020
|
map: r,
|
|
989
1021
|
unsubscribe: i
|
|
990
1022
|
});
|
|
991
1023
|
}
|
|
992
|
-
|
|
1024
|
+
validate(e) {
|
|
1025
|
+
return [];
|
|
1026
|
+
}
|
|
1027
|
+
#Q() {
|
|
993
1028
|
let t = new Set(Object.keys(this.#n.properties));
|
|
994
1029
|
for (let n of this.getAttributeNames()) if (!D.has(n) && !n.startsWith("on") && n !== "ref") {
|
|
995
1030
|
if (n === "form-assoc") {
|
|
996
|
-
this.#
|
|
1031
|
+
this.#ie();
|
|
997
1032
|
continue;
|
|
998
1033
|
}
|
|
999
1034
|
if (!t.has(e.getPropName(n))) {
|
|
1000
1035
|
if (n === "name") {
|
|
1001
|
-
this.#
|
|
1036
|
+
this.#ie();
|
|
1002
1037
|
continue;
|
|
1003
1038
|
}
|
|
1004
|
-
this.#
|
|
1039
|
+
this.#U(null, n, "is not a supported attribute");
|
|
1005
1040
|
}
|
|
1006
1041
|
}
|
|
1007
1042
|
}
|
|
1008
|
-
|
|
1009
|
-
let r =
|
|
1043
|
+
#$(e) {
|
|
1044
|
+
let t = [], n = [], r = { ...this };
|
|
1045
|
+
for (let [i, a] of Object.entries(e)) {
|
|
1046
|
+
let e = this.#n.properties[i], o = a;
|
|
1047
|
+
if (e) {
|
|
1048
|
+
e.computed && this.#U(null, i, "is a computed property and cannot be set directly"), e.type === Number && typeof o == "string" && (o = Y(o)), this.#re(i, e.type, o);
|
|
1049
|
+
let t = e.validate?.(o);
|
|
1050
|
+
typeof t == "string" && n.push(t);
|
|
1051
|
+
}
|
|
1052
|
+
t.push([i, o]), r[i] = o;
|
|
1053
|
+
}
|
|
1054
|
+
return this.#r || n.push(...this.validate(r)), {
|
|
1055
|
+
entries: t,
|
|
1056
|
+
errors: n
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
#ee(e, t, n) {
|
|
1060
|
+
if (this.#e || this.#r) return {
|
|
1061
|
+
errors: [],
|
|
1062
|
+
skipped: !0
|
|
1063
|
+
};
|
|
1064
|
+
let r = [], { validate: i } = e, a = i?.(n);
|
|
1065
|
+
typeof a == "string" && r.push(a);
|
|
1066
|
+
let o = {
|
|
1067
|
+
...this,
|
|
1068
|
+
[t]: n
|
|
1069
|
+
};
|
|
1070
|
+
return r.push(...this.validate(o)), {
|
|
1071
|
+
errors: r,
|
|
1072
|
+
skipped: !1
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
#te(e, t, n) {
|
|
1076
|
+
let r = n.match(p);
|
|
1010
1077
|
if (r) return r.forEach((n) => {
|
|
1011
|
-
let r =
|
|
1012
|
-
this.#
|
|
1078
|
+
let r = y(n);
|
|
1079
|
+
this.#D(r) === void 0 && this.#W(e, t, r);
|
|
1013
1080
|
}), r;
|
|
1014
1081
|
}
|
|
1015
|
-
#
|
|
1082
|
+
#ne(e, t) {
|
|
1016
1083
|
for (let [n, r] of Object.entries(t)) {
|
|
1017
1084
|
let t = o(e, n);
|
|
1018
|
-
t === void 0 && this.#
|
|
1085
|
+
t === void 0 && this.#U(this, void 0, `invalid state path "${n}"`), t = this.#D(r), this.#j(r) || this.#U(null, r, "refers to missing property in useState map");
|
|
1019
1086
|
}
|
|
1020
1087
|
}
|
|
1021
|
-
|
|
1088
|
+
#re(e, t, n) {
|
|
1022
1089
|
let { values: r } = this.#n.properties[e];
|
|
1023
1090
|
if (r) {
|
|
1024
1091
|
let i;
|
|
1025
|
-
t === String ? typeof n == "string" ? r.includes(n) || (i = `must be one of ${r.map((e) => `"${e}"`).join(", ")}`) : i = `value is a ${typeof n}, but type is String` : i = "declares allowed values, but its type is not String", i && this.#
|
|
1092
|
+
t === String ? typeof n == "string" ? r.includes(n) || (i = `must be one of ${r.map((e) => `"${e}"`).join(", ")}`) : i = `value is a ${typeof n}, but type is String` : i = "declares allowed values, but its type is not String", i && this.#U(null, e, i);
|
|
1026
1093
|
}
|
|
1027
1094
|
if (n instanceof t) return;
|
|
1028
1095
|
let i = typeof n;
|
|
1029
1096
|
if (i === "object") {
|
|
1030
1097
|
let { constructor: r } = n;
|
|
1031
|
-
i = r.name, r !== t && this.#
|
|
1098
|
+
i = r.name, r !== t && this.#U(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
1032
1099
|
}
|
|
1033
|
-
i !== t.name.toLowerCase() && this.#
|
|
1100
|
+
i !== t.name.toLowerCase() && this.#U(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
1034
1101
|
}
|
|
1035
|
-
#
|
|
1036
|
-
let r = t.validate?.(n), i = typeof r != "string";
|
|
1037
|
-
return i || this.dispatch("validation", {
|
|
1038
|
-
object: this,
|
|
1039
|
-
property: e,
|
|
1040
|
-
value: n,
|
|
1041
|
-
message: r
|
|
1042
|
-
}), i;
|
|
1043
|
-
}
|
|
1044
|
-
#te() {
|
|
1102
|
+
#ie() {
|
|
1045
1103
|
if (this.#n.formAssociated || this.closest("form") === null) return;
|
|
1046
1104
|
let e = this.#n.name;
|
|
1047
|
-
this.#
|
|
1105
|
+
this.#U(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
|
|
1048
1106
|
}
|
|
1049
|
-
#
|
|
1107
|
+
#ae(e) {
|
|
1050
1108
|
let t = Array.from(e.querySelectorAll("*"));
|
|
1051
1109
|
for (let e of t) {
|
|
1052
1110
|
let t = [];
|
|
@@ -1056,22 +1114,22 @@ var $ = class e extends O {
|
|
|
1056
1114
|
let i = r.slice(2);
|
|
1057
1115
|
i = i[0].toLowerCase() + i.slice(1).toLowerCase();
|
|
1058
1116
|
let a = n.value;
|
|
1059
|
-
this.#
|
|
1117
|
+
this.#te(e, r, a);
|
|
1060
1118
|
let o;
|
|
1061
|
-
typeof this.#
|
|
1119
|
+
typeof this.#D(a) == "function" ? o = (e) => this.#D(a).call(this, e) : (this.#te(e, r, a), o = () => this.#C(a)), e.addEventListener(i, o), t.push(r);
|
|
1062
1120
|
}
|
|
1063
1121
|
}
|
|
1064
1122
|
for (let n of t) e.removeAttribute(n);
|
|
1065
1123
|
}
|
|
1066
1124
|
}
|
|
1067
1125
|
};
|
|
1068
|
-
function
|
|
1126
|
+
function ue(e, ...t) {
|
|
1069
1127
|
let n = B(e, t);
|
|
1070
1128
|
for (;;) {
|
|
1071
1129
|
let e = j.exec(n);
|
|
1072
1130
|
if (!e) break;
|
|
1073
1131
|
let t = e[2];
|
|
1074
|
-
if (
|
|
1132
|
+
if (m.test(t)) {
|
|
1075
1133
|
let r = e[1];
|
|
1076
1134
|
if (!r.startsWith("--")) {
|
|
1077
1135
|
let i = `--${r}: ${t};
|
|
@@ -1082,13 +1140,13 @@ function de(e, ...t) {
|
|
|
1082
1140
|
}
|
|
1083
1141
|
return n;
|
|
1084
1142
|
}
|
|
1085
|
-
function
|
|
1143
|
+
function de(e, ...t) {
|
|
1086
1144
|
let n = B(e, t);
|
|
1087
1145
|
for (;;) {
|
|
1088
1146
|
let e = M.exec(n);
|
|
1089
1147
|
if (!e || e[1] === "style") break;
|
|
1090
|
-
let t =
|
|
1091
|
-
if (
|
|
1148
|
+
let t = ce(e[2]);
|
|
1149
|
+
if (m.test(t)) {
|
|
1092
1150
|
let r = `<!-- ${t.trim()} -->`, i = e.index + e[0].indexOf(">") + 1;
|
|
1093
1151
|
n = J(n, i, t.length, r);
|
|
1094
1152
|
}
|
|
@@ -1096,4 +1154,4 @@ function fe(e, ...t) {
|
|
|
1096
1154
|
return n;
|
|
1097
1155
|
}
|
|
1098
1156
|
//#endregion
|
|
1099
|
-
export {
|
|
1157
|
+
export { m as a, y as c, de as i, b as l, P as n, f as o, ue as r, v as s, $ as t, a as u };
|