wrec 0.33.0 → 0.33.1
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-BL9AvT9R.js → wrec-BLZidsD5.js} +117 -108
- package/dist/wrec-ssr.d.ts +3 -4
- package/dist/wrec-ssr.es.js +1 -1
- package/dist/wrec.d.ts +3 -4
- package/dist/wrec.es.js +1 -1
- package/package.json +1 -1
|
@@ -313,14 +313,14 @@ var X = class e extends m {
|
|
|
313
313
|
constructor() {
|
|
314
314
|
super(), this.attachShadow({ mode: "open" });
|
|
315
315
|
let e = this.#n;
|
|
316
|
-
this.#
|
|
316
|
+
this.#O("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#O("computedGraph") || (e.computedGraph = null), this.#O("computedPropsRegistered") || (e.computedPropsRegistered = !1), this.#O("properties") || (e.properties = {}), this.#O("propToAttrMap") || (e.propToAttrMap = /* @__PURE__ */ new Map()), this.#O("propToComputedMap") || (e.propToComputedMap = /* @__PURE__ */ new Map()), this.#O("propToExprsMap") || (e.propToExprsMap = /* @__PURE__ */ new Map()), this.#O("registeredComputedProps") || (e.registeredComputedProps = /* @__PURE__ */ new Set());
|
|
317
317
|
}
|
|
318
318
|
attributeChangedCallback(t, n, r) {
|
|
319
319
|
t === "disabled" && this.#v();
|
|
320
320
|
let i = e.getPropName(t);
|
|
321
|
-
if (!this.#
|
|
322
|
-
let e = this.#
|
|
323
|
-
this
|
|
321
|
+
if (!this.#A(i) && this.#k(i)) {
|
|
322
|
+
let e = this.#W(i, r);
|
|
323
|
+
this.#R(i, e);
|
|
324
324
|
let t = this.#i[i];
|
|
325
325
|
t && this.setFormValue(t, String(e));
|
|
326
326
|
}
|
|
@@ -329,13 +329,13 @@ var X = class e extends m {
|
|
|
329
329
|
this.#e = !0;
|
|
330
330
|
let t = this.#n.propToExprsMap, n = /* @__PURE__ */ new Set();
|
|
331
331
|
for (let [r, i] of Object.entries(e)) {
|
|
332
|
-
this
|
|
332
|
+
this.#R(r, i);
|
|
333
333
|
let e = t.get(r) ?? [];
|
|
334
334
|
for (let t of e) n.add(t);
|
|
335
335
|
}
|
|
336
336
|
let r = this.#w(Object.keys(e));
|
|
337
337
|
for (let [e, i] of r) {
|
|
338
|
-
this.#
|
|
338
|
+
this.#L(e, this.#x(i));
|
|
339
339
|
let r = t.get(e) ?? [];
|
|
340
340
|
for (let e of r) n.add(e);
|
|
341
341
|
}
|
|
@@ -353,40 +353,40 @@ var X = class e extends m {
|
|
|
353
353
|
return t.startsWith("<") || (t = `<span><!--${t}--></span>`), e + t;
|
|
354
354
|
}
|
|
355
355
|
changed(e, t, n) {
|
|
356
|
-
this
|
|
356
|
+
this.#R(t, n);
|
|
357
357
|
}
|
|
358
358
|
async connectedCallback() {
|
|
359
|
-
this.#
|
|
359
|
+
this.#X(), this.#h(), await this.#p(), this.hasAttribute("disabled") && this.#v(), this.#te(this.shadowRoot), this.#M(this.shadowRoot), this.#Y(), this.#m(), this.ready();
|
|
360
360
|
}
|
|
361
361
|
#m() {
|
|
362
362
|
let { properties: e } = this.#n;
|
|
363
|
-
for (let [t, { computed: n }] of Object.entries(e)) n && this.#
|
|
363
|
+
for (let [t, { computed: n }] of Object.entries(e)) n && this.#L(t, this.#x(n));
|
|
364
364
|
}
|
|
365
365
|
#h() {
|
|
366
366
|
let { observedAttributes: e, properties: t } = this.#n;
|
|
367
367
|
for (let [n, r] of Object.entries(t)) r.computed || this.#g(n, r, e);
|
|
368
368
|
for (let [n, r] of Object.entries(t)) r.computed && this.#g(n, r, e);
|
|
369
|
-
this.#
|
|
369
|
+
this.#F();
|
|
370
370
|
}
|
|
371
371
|
#g(t, n, r) {
|
|
372
372
|
if (t === "class" || t === "style") throw new g(`"${t}" is a reserved property`);
|
|
373
373
|
let i = e.getAttrName(t), a = this.hasAttribute(i);
|
|
374
|
-
n.required && !a && this.#
|
|
374
|
+
n.required && !a && this.#V(this, i, "is a required attribute");
|
|
375
375
|
let o = n.value;
|
|
376
|
-
this.hasOwnProperty(t) && (o = this
|
|
377
|
-
let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#
|
|
378
|
-
this
|
|
376
|
+
this.hasOwnProperty(t) && (o = this.#T(t), this.#_(t));
|
|
377
|
+
let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#U(t, i) : o ?? k(n), u = "#" + t;
|
|
378
|
+
this.#R(u, this.#j(t, c, l)), Object.defineProperty(this, t, {
|
|
379
379
|
enumerable: !0,
|
|
380
380
|
get() {
|
|
381
|
-
return this
|
|
381
|
+
return this.#T(u);
|
|
382
382
|
},
|
|
383
383
|
set(e) {
|
|
384
|
-
n.computed && !this.#t.has(t) && this.#
|
|
385
|
-
let r = this
|
|
384
|
+
n.computed && !this.#t.has(t) && this.#V(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e = G(e));
|
|
385
|
+
let r = this.#T(u);
|
|
386
386
|
if (e === r) return;
|
|
387
|
-
this
|
|
387
|
+
this.#$(t, c, e), e = this.#j(t, c, e), this.#R(u, e);
|
|
388
388
|
let a = this.#l.get(t);
|
|
389
|
-
a && s(a.state, a.stateProp, e), this.#
|
|
389
|
+
a && s(a.state, a.stateProp, e), this.#G(t, c, e, i), this.#e || (this.#K(t), this.#P(t)), this.#J(t, e);
|
|
390
390
|
let o = this.#i[t];
|
|
391
391
|
o && this.setFormValue(o, String(e)), this.propertyChangedCallback(t, r, e), n.dispatch && this.dispatch("change", {
|
|
392
392
|
tagName: this.localName,
|
|
@@ -397,13 +397,12 @@ var X = class e extends m {
|
|
|
397
397
|
}
|
|
398
398
|
});
|
|
399
399
|
}
|
|
400
|
-
#_(e
|
|
401
|
-
|
|
402
|
-
i && s(i.state, i.stateProp, r), this.#e || (this.#U(e), this.#M(e)), this.#G(e, r), this.propertyChangedCallback(e, t, n);
|
|
400
|
+
#_(e) {
|
|
401
|
+
delete this[e];
|
|
403
402
|
}
|
|
404
403
|
#v() {
|
|
405
|
-
let
|
|
406
|
-
for (let
|
|
404
|
+
let t = this.hasAttribute("disabled"), n = j(this.shadowRoot);
|
|
405
|
+
for (let r of n) D(r) && (r instanceof e ? t ? r.setAttribute("disabled", "") : r.removeAttribute("disabled") : r.disabled = t);
|
|
407
406
|
}
|
|
408
407
|
disconnectedCallback() {
|
|
409
408
|
for (let { unsubscribe: e } of this.#f.values()) e();
|
|
@@ -424,22 +423,22 @@ var X = class e extends m {
|
|
|
424
423
|
for (let r of t.getAttributeNames()) {
|
|
425
424
|
let i = t.getAttribute(r);
|
|
426
425
|
if (r === "ref") {
|
|
427
|
-
this.#
|
|
426
|
+
this.#B(t, i);
|
|
428
427
|
continue;
|
|
429
428
|
}
|
|
430
|
-
let a = this.#
|
|
429
|
+
let a = this.#N(t, i);
|
|
431
430
|
if (a) {
|
|
432
|
-
let i = this
|
|
433
|
-
i === void 0 && this.#
|
|
431
|
+
let i = this.#T(a);
|
|
432
|
+
i === void 0 && this.#H(t, r, a);
|
|
434
433
|
let [o, s] = r.split(":"), c = e.getPropName(o);
|
|
435
434
|
if (o === "checked") {
|
|
436
435
|
let { type: e } = this.#n.properties[a];
|
|
437
|
-
I(t) && e !== Boolean && this.#
|
|
436
|
+
I(t) && e !== Boolean && this.#V(t, r, `refers to property "${a}" whose type is not Boolean`), z(t) && e !== String && this.#V(t, r, `refers to property "${a}" whose type is not String`);
|
|
438
437
|
}
|
|
439
|
-
let l = this.#
|
|
440
|
-
n && t.#
|
|
438
|
+
let l = this.#A(a);
|
|
439
|
+
n && t.#A(c) || (o === "checked" && z(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#V(t, r, "refers to an unsupported event name"), t.setAttribute(o, this.#T(a))) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
|
|
441
440
|
}
|
|
442
|
-
this.#
|
|
441
|
+
this.#z(i, t, r);
|
|
443
442
|
}
|
|
444
443
|
}
|
|
445
444
|
#b(e) {
|
|
@@ -451,7 +450,7 @@ var X = class e extends m {
|
|
|
451
450
|
r.add(t);
|
|
452
451
|
continue;
|
|
453
452
|
}
|
|
454
|
-
if (t instanceof HTMLElement) this.#
|
|
453
|
+
if (t instanceof HTMLElement) this.#q(t, e);
|
|
455
454
|
else if (!(t instanceof CSSStyleRule)) {
|
|
456
455
|
let { element: n, attrName: r } = t;
|
|
457
456
|
n instanceof CSSStyleRule ? n.style.setProperty(r, e) : q(n, r, e);
|
|
@@ -475,13 +474,13 @@ var X = class e extends m {
|
|
|
475
474
|
let t = Array.from(e.style);
|
|
476
475
|
for (let n of t) if (n.startsWith("--")) {
|
|
477
476
|
let t = e.style.getPropertyValue(n);
|
|
478
|
-
this.#
|
|
477
|
+
this.#z(t, e, n);
|
|
479
478
|
}
|
|
480
479
|
}
|
|
481
480
|
} else {
|
|
482
481
|
let t = "";
|
|
483
482
|
if (B(e)) {
|
|
484
|
-
this.#
|
|
483
|
+
this.#z(e.textContent, e);
|
|
485
484
|
let n = e.textContent?.match(x);
|
|
486
485
|
n && (t = n[1]);
|
|
487
486
|
} else {
|
|
@@ -489,8 +488,8 @@ var X = class e extends m {
|
|
|
489
488
|
n && (t = n.textContent?.trim() ?? "");
|
|
490
489
|
}
|
|
491
490
|
if (t) {
|
|
492
|
-
let n = this.#
|
|
493
|
-
n && B(e) ? e.textContent = this
|
|
491
|
+
let n = this.#N(e, t);
|
|
492
|
+
n && B(e) ? e.textContent = this.#T(n) : this.#z(t, e);
|
|
494
493
|
}
|
|
495
494
|
}
|
|
496
495
|
}
|
|
@@ -498,7 +497,7 @@ var X = class e extends m {
|
|
|
498
497
|
let e = this.getAttribute("form-assoc");
|
|
499
498
|
if (!e) {
|
|
500
499
|
let t = this.getAttribute("name");
|
|
501
|
-
if (t) if (this.#
|
|
500
|
+
if (t) if (this.#k("value")) e = `value:${t}`;
|
|
502
501
|
else return;
|
|
503
502
|
else return;
|
|
504
503
|
}
|
|
@@ -509,17 +508,17 @@ var X = class e extends m {
|
|
|
509
508
|
}
|
|
510
509
|
this.#i = t, this.#a = new FormData(), this.#s = this.attachInternals(), this.#s.setFormValue(this.#a);
|
|
511
510
|
for (let [e, n] of Object.entries(t)) {
|
|
512
|
-
let t = this
|
|
511
|
+
let t = this.#T(e);
|
|
513
512
|
R(t) && this.setFormValue(n, String(t));
|
|
514
513
|
}
|
|
515
514
|
let r = Object.keys(this.#n.properties), i = this.#o;
|
|
516
|
-
for (let e of r) i[e] = this
|
|
515
|
+
for (let e of r) i[e] = this.#T(e);
|
|
517
516
|
}
|
|
518
517
|
formResetCallback() {
|
|
519
518
|
let e = this.#o;
|
|
520
519
|
for (let t of Object.keys(e)) {
|
|
521
520
|
let n = e[t];
|
|
522
|
-
C.test(n) && (n = this.#x(n)), this
|
|
521
|
+
C.test(n) && (n = this.#x(n)), this.#R(t, n);
|
|
523
522
|
}
|
|
524
523
|
}
|
|
525
524
|
static getAttrName(e) {
|
|
@@ -568,44 +567,51 @@ var X = class e extends m {
|
|
|
568
567
|
if (c.length !== a.size) throw new g(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
|
|
569
568
|
return c.map((e) => [e, r[e]]);
|
|
570
569
|
}
|
|
570
|
+
#T(e) {
|
|
571
|
+
return this[e];
|
|
572
|
+
}
|
|
571
573
|
static getPropName(e) {
|
|
572
574
|
let t = this.attrToPropMap.get(e);
|
|
573
575
|
return t || (t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), this.attrToPropMap.set(e, t)), t;
|
|
574
576
|
}
|
|
575
|
-
#
|
|
577
|
+
#E(e, t, n) {
|
|
578
|
+
let r = this.#T("#" + e), i = this.#l.get(e);
|
|
579
|
+
i && s(i.state, i.stateProp, r), this.#e || (this.#K(e), this.#P(e)), this.#J(e, r), this.propertyChangedCallback(e, t, n);
|
|
580
|
+
}
|
|
581
|
+
#D(e, t, n) {
|
|
576
582
|
if (n.length !== 1) return;
|
|
577
583
|
let [r] = n;
|
|
578
584
|
if (!C.test(r)) return;
|
|
579
585
|
let i = I(e), a = z(e), o = V(e) || B(e), [s, c] = (t ?? "").split(":");
|
|
580
586
|
if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || B(e))) return;
|
|
581
|
-
c ? e["on" + c] === void 0 && this.#
|
|
587
|
+
c ? e["on" + c] === void 0 && this.#V(e, t, "refers to an unsupported event name") : c = "change";
|
|
582
588
|
let l = N(r);
|
|
583
589
|
e.addEventListener(c, (e) => {
|
|
584
590
|
let { target: t } = e;
|
|
585
591
|
if (!t) return;
|
|
586
592
|
let { type: n } = this.#n.properties[l], r = t, { value: o } = r;
|
|
587
|
-
s === "checked" ? i ? this
|
|
593
|
+
s === "checked" ? i ? this.#R(l, r.checked) : a && r.checked && this.#R(l, o) : this.#R(l, n === Number ? G(o) : o), this.#P(l);
|
|
588
594
|
});
|
|
589
595
|
}
|
|
590
|
-
#
|
|
596
|
+
#O(e) {
|
|
591
597
|
return Object.hasOwn(this.#n, e);
|
|
592
598
|
}
|
|
593
|
-
#
|
|
599
|
+
#k(e) {
|
|
594
600
|
return !!this.#n.properties[e];
|
|
595
601
|
}
|
|
596
|
-
#
|
|
602
|
+
#A(e) {
|
|
597
603
|
return !!this.#n.properties[e]?.computed;
|
|
598
604
|
}
|
|
599
|
-
#
|
|
605
|
+
#j(e, n, r) {
|
|
600
606
|
if (typeof r != "object" || !r || n !== Array && n !== Object || this.#d.has(r)) return r;
|
|
601
607
|
let i = this.#u.get(r);
|
|
602
608
|
if (i) return i;
|
|
603
609
|
let a = t(r, (t, n, r) => {
|
|
604
|
-
this.#
|
|
610
|
+
this.#E(e, n, r);
|
|
605
611
|
});
|
|
606
612
|
return this.#u.set(r, a), this.#d.add(a), a;
|
|
607
613
|
}
|
|
608
|
-
#
|
|
614
|
+
#M(e) {
|
|
609
615
|
let t = Array.from(e.querySelectorAll("*"));
|
|
610
616
|
for (let e of t) this.#y(e), e.firstElementChild || this.#S(e);
|
|
611
617
|
}
|
|
@@ -614,24 +620,24 @@ var X = class e extends m {
|
|
|
614
620
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
615
621
|
}
|
|
616
622
|
propertyChangedCallback(e, t, n) {}
|
|
617
|
-
#
|
|
623
|
+
#N(e, t) {
|
|
618
624
|
if (!t || !C.test(t)) return;
|
|
619
625
|
let n = N(t);
|
|
620
|
-
return this
|
|
626
|
+
return this.#T(n) === void 0 && this.#H(e, "", n), n;
|
|
621
627
|
}
|
|
622
|
-
#
|
|
628
|
+
#P(e) {
|
|
623
629
|
let t = this.#n.propToExprsMap.get(e) || [];
|
|
624
630
|
this.#b(t);
|
|
625
631
|
}
|
|
626
632
|
ready() {}
|
|
627
|
-
#
|
|
633
|
+
#F() {
|
|
628
634
|
let e = this.#n;
|
|
629
635
|
if (!e.computedPropsRegistered) {
|
|
630
636
|
e.computedPropsRegistered = !0, e.computedGraph = null;
|
|
631
|
-
for (let [t, n] of Object.entries(e.properties)) n.computed && this.#
|
|
637
|
+
for (let [t, n] of Object.entries(e.properties)) n.computed && this.#I(t, n);
|
|
632
638
|
}
|
|
633
639
|
}
|
|
634
|
-
#
|
|
640
|
+
#I(e, t) {
|
|
635
641
|
let n = this.#n;
|
|
636
642
|
n.registeredComputedProps.add(e);
|
|
637
643
|
let r = n.propToComputedMap;
|
|
@@ -642,28 +648,31 @@ var X = class e extends m {
|
|
|
642
648
|
let a = t.computed;
|
|
643
649
|
for (let t of a.matchAll(w)) {
|
|
644
650
|
let r = N(t[0]);
|
|
645
|
-
this
|
|
651
|
+
this.#T(r) === void 0 && this.#H(null, e, r);
|
|
646
652
|
let o = H(r), s = !1;
|
|
647
653
|
for (let [e, t] of Object.entries(n.properties)) J(t.usedBy)?.includes(o) && (i(e, a), s = !0);
|
|
648
|
-
!s && typeof this
|
|
654
|
+
!s && typeof this.#T(r) != "function" && i(r, a);
|
|
649
655
|
}
|
|
650
656
|
for (let t of a.matchAll(b)) {
|
|
651
657
|
let r = t[1];
|
|
652
|
-
if (typeof this
|
|
658
|
+
if (typeof this.#T(r) != "function") throw new g(`property ${e} computed calls non-method ${r}`);
|
|
653
659
|
for (let [e, t] of Object.entries(n.properties)) J(t.usedBy)?.includes(r) && i(e, a);
|
|
654
660
|
}
|
|
655
661
|
}
|
|
656
|
-
#
|
|
662
|
+
#L(e, t) {
|
|
657
663
|
this.#t.add(e);
|
|
658
664
|
try {
|
|
659
|
-
this
|
|
665
|
+
this.#R(e, t);
|
|
660
666
|
} finally {
|
|
661
667
|
this.#t.delete(e);
|
|
662
668
|
}
|
|
663
669
|
}
|
|
664
|
-
#
|
|
670
|
+
#R(e, t) {
|
|
671
|
+
this[e] = t;
|
|
672
|
+
}
|
|
673
|
+
#z(e, t, n = void 0) {
|
|
665
674
|
if (!e) return;
|
|
666
|
-
let r = this.#
|
|
675
|
+
let r = this.#Z(t, n, e);
|
|
667
676
|
if (!r) {
|
|
668
677
|
let r = e.replaceAll("this..", "this.");
|
|
669
678
|
n ? q(t, n, r) : "textContent" in t && (t.textContent = r);
|
|
@@ -672,7 +681,7 @@ var X = class e extends m {
|
|
|
672
681
|
let i = this.#n;
|
|
673
682
|
r.forEach((t) => {
|
|
674
683
|
let n = N(t);
|
|
675
|
-
if (typeof this
|
|
684
|
+
if (typeof this.#T(n) == "function") return;
|
|
676
685
|
let r = i.propToExprsMap, a = r.get(n);
|
|
677
686
|
a || (a = [], r.set(n, a)), a.includes(e) || a.push(e);
|
|
678
687
|
});
|
|
@@ -684,13 +693,13 @@ var X = class e extends m {
|
|
|
684
693
|
a || (a = [], this.#r.set(e, a)), a.push(n ? {
|
|
685
694
|
element: t,
|
|
686
695
|
attrName: n
|
|
687
|
-
} : t), t instanceof HTMLElement && this.#
|
|
696
|
+
} : t), t instanceof HTMLElement && this.#D(t, n, r);
|
|
688
697
|
let o = this.#x(e);
|
|
689
|
-
n ? q(t, n, o) : this.#
|
|
698
|
+
n ? q(t, n, o) : this.#q(t, o);
|
|
690
699
|
}
|
|
691
|
-
#
|
|
700
|
+
#B(e, t) {
|
|
692
701
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
693
|
-
r || this.#
|
|
702
|
+
r || this.#H(e, "ref", n), r.type !== m && this.#V(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this.#T(n) && this.#V(e, "ref", `is a duplicate reference to the property "${n}"`), this.#R(n, e), e.removeAttribute("ref");
|
|
694
703
|
}
|
|
695
704
|
setAttributeSafe(e, t) {
|
|
696
705
|
this.hasAttribute(e) || this.setAttribute(e, t);
|
|
@@ -701,24 +710,24 @@ var X = class e extends m {
|
|
|
701
710
|
static ssr(e = {}) {
|
|
702
711
|
throw new g("SSR is not available in the browser build.");
|
|
703
712
|
}
|
|
704
|
-
#
|
|
713
|
+
#V(e, t, n) {
|
|
705
714
|
let r = e instanceof HTMLElement ? e.localName : "CSS rule";
|
|
706
715
|
throw new g(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
|
|
707
716
|
}
|
|
708
|
-
#
|
|
709
|
-
this.#
|
|
717
|
+
#H(e, t, n) {
|
|
718
|
+
this.#V(e, t, `refers to missing property "${n}"`);
|
|
710
719
|
}
|
|
711
|
-
#
|
|
712
|
-
return this.#
|
|
720
|
+
#U(e, t) {
|
|
721
|
+
return this.#W(e, this.getAttribute(t));
|
|
713
722
|
}
|
|
714
|
-
#
|
|
723
|
+
#W(t, n) {
|
|
715
724
|
if (n?.match(w)) return n;
|
|
716
725
|
let r = this.#n.properties[t], { type: i, values: a } = r;
|
|
717
|
-
if (i || this.#
|
|
726
|
+
if (i || this.#V(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : k(r);
|
|
718
727
|
if (i === String) {
|
|
719
728
|
if (a && !a.includes(n)) {
|
|
720
729
|
let e = a.map((e) => `"${e}"`).join(", ");
|
|
721
|
-
this.#
|
|
730
|
+
this.#V(null, t, `must be one of ${e}`);
|
|
722
731
|
}
|
|
723
732
|
return n;
|
|
724
733
|
}
|
|
@@ -727,25 +736,25 @@ var X = class e extends m {
|
|
|
727
736
|
if (n === "true") return !0;
|
|
728
737
|
if (n === "false" || n === "null") return !1;
|
|
729
738
|
let r = e.getAttrName(t);
|
|
730
|
-
return n && n !== r && this.#
|
|
739
|
+
return n && n !== r && this.#V(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
|
|
731
740
|
}
|
|
732
741
|
}
|
|
733
|
-
#
|
|
734
|
-
R(n) && !this.#
|
|
742
|
+
#G(e, t, n, r) {
|
|
743
|
+
R(n) && !this.#A(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#U(e, r)) && K(this, r || e, n);
|
|
735
744
|
}
|
|
736
|
-
#
|
|
737
|
-
for (let [t, n] of this.#w([e])) this.#
|
|
745
|
+
#K(e) {
|
|
746
|
+
for (let [t, n] of this.#w([e])) this.#L(t, this.#x(n));
|
|
738
747
|
}
|
|
739
|
-
#
|
|
748
|
+
#q(e, t) {
|
|
740
749
|
if (t === void 0) return;
|
|
741
750
|
let n = e instanceof HTMLElement;
|
|
742
751
|
Array.isArray(t) && (t = t.join(""));
|
|
743
752
|
let r = typeof t;
|
|
744
|
-
r !== "string" && r !== "number" && this.#
|
|
753
|
+
r !== "string" && r !== "number" && this.#V(e, void 0, " computed content is not a string or number");
|
|
745
754
|
let i = String(t);
|
|
746
|
-
e instanceof HTMLElement && B(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#
|
|
755
|
+
e instanceof HTMLElement && B(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#te(e), this.#M(e)) : n && (e.textContent = i);
|
|
747
756
|
}
|
|
748
|
-
#
|
|
757
|
+
#J(e, t) {
|
|
749
758
|
let n = this.#c.get(e);
|
|
750
759
|
if (!n) return;
|
|
751
760
|
let r = this.getRootNode();
|
|
@@ -755,7 +764,7 @@ var X = class e extends m {
|
|
|
755
764
|
let a = i;
|
|
756
765
|
a[n] = t;
|
|
757
766
|
}
|
|
758
|
-
#
|
|
767
|
+
#Y() {
|
|
759
768
|
let e = this.#n, t = (e, t, n) => {
|
|
760
769
|
let r = e.get(t);
|
|
761
770
|
r || (r = [], e.set(t, r)), r.includes(n) || r.push(n);
|
|
@@ -778,7 +787,7 @@ var X = class e extends m {
|
|
|
778
787
|
if (L(e)) {
|
|
779
788
|
let n = P(e);
|
|
780
789
|
if (typeof M(this, n)?.get != "function") throw new g(`property ${t} usedBy contains non-getter ${e}`);
|
|
781
|
-
} else if (typeof this
|
|
790
|
+
} else if (typeof this.#T(e) != "function") throw new g(`property ${t} usedBy contains non-method ${e}`);
|
|
782
791
|
let n = o.get(e) || [];
|
|
783
792
|
for (let e of n) s.includes(e) || s.push(e);
|
|
784
793
|
}
|
|
@@ -789,10 +798,10 @@ var X = class e extends m {
|
|
|
789
798
|
t = {};
|
|
790
799
|
for (let n of Object.keys(e)) t[n] = n;
|
|
791
800
|
}
|
|
792
|
-
this.#
|
|
793
|
-
for (let [n, r] of Object.entries(t)) if (this.#
|
|
801
|
+
this.#Q(e, t);
|
|
802
|
+
for (let [n, r] of Object.entries(t)) if (this.#k(r)) {
|
|
794
803
|
let t = o(e, n);
|
|
795
|
-
t !== void 0 && (
|
|
804
|
+
t !== void 0 && this.#R(r, t), this.#l.set(r, {
|
|
796
805
|
state: e,
|
|
797
806
|
stateProp: n
|
|
798
807
|
});
|
|
@@ -804,62 +813,62 @@ var X = class e extends m {
|
|
|
804
813
|
n?.unsubscribe();
|
|
805
814
|
let i = e.subscribe(({ statePath: e, newValue: t }) => {
|
|
806
815
|
let n = r[e];
|
|
807
|
-
n && (
|
|
816
|
+
n && this.#R(n, t);
|
|
808
817
|
}, Object.keys(r));
|
|
809
818
|
this.#f.set(e, {
|
|
810
819
|
map: r,
|
|
811
820
|
unsubscribe: i
|
|
812
821
|
});
|
|
813
822
|
}
|
|
814
|
-
#
|
|
823
|
+
#X() {
|
|
815
824
|
let t = new Set(Object.keys(this.#n.properties));
|
|
816
825
|
for (let n of this.getAttributeNames()) if (!p.has(n) && !n.startsWith("on") && n !== "ref") {
|
|
817
826
|
if (n === "form-assoc") {
|
|
818
|
-
this.#
|
|
827
|
+
this.#ee();
|
|
819
828
|
continue;
|
|
820
829
|
}
|
|
821
830
|
if (!t.has(e.getPropName(n))) {
|
|
822
831
|
if (n === "name") {
|
|
823
|
-
this.#
|
|
832
|
+
this.#ee();
|
|
824
833
|
continue;
|
|
825
834
|
}
|
|
826
|
-
this.#
|
|
835
|
+
this.#V(null, n, "is not a supported attribute");
|
|
827
836
|
}
|
|
828
837
|
}
|
|
829
838
|
}
|
|
830
|
-
#
|
|
839
|
+
#Z(e, t, n) {
|
|
831
840
|
let r = n.match(w);
|
|
832
841
|
if (r) return r.forEach((n) => {
|
|
833
842
|
let r = N(n);
|
|
834
|
-
this
|
|
843
|
+
this.#T(r) === void 0 && this.#H(e, t, r);
|
|
835
844
|
}), r;
|
|
836
845
|
}
|
|
837
|
-
#
|
|
846
|
+
#Q(e, t) {
|
|
838
847
|
for (let [n, r] of Object.entries(t)) {
|
|
839
848
|
let t = o(e, n);
|
|
840
|
-
t === void 0 && this.#
|
|
849
|
+
t === void 0 && this.#V(this, void 0, `invalid state path "${n}"`), t = this.#T(r), this.#k(r) || this.#V(null, r, "refers to missing property in useState map");
|
|
841
850
|
}
|
|
842
851
|
}
|
|
843
|
-
|
|
852
|
+
#$(e, t, n) {
|
|
844
853
|
let { values: r } = this.#n.properties[e];
|
|
845
854
|
if (r) {
|
|
846
855
|
let i;
|
|
847
|
-
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.#
|
|
856
|
+
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.#V(null, e, i);
|
|
848
857
|
}
|
|
849
858
|
if (n instanceof t) return;
|
|
850
859
|
let i = typeof n;
|
|
851
860
|
if (i === "object") {
|
|
852
861
|
let { constructor: r } = n;
|
|
853
|
-
i = r.name, r !== t && this.#
|
|
862
|
+
i = r.name, r !== t && this.#V(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
854
863
|
}
|
|
855
|
-
i !== t.name.toLowerCase() && this.#
|
|
864
|
+
i !== t.name.toLowerCase() && this.#V(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
856
865
|
}
|
|
857
|
-
#
|
|
866
|
+
#ee() {
|
|
858
867
|
if (this.#n.formAssociated || this.closest("form") === null) return;
|
|
859
868
|
let e = this.#n.name;
|
|
860
|
-
this.#
|
|
869
|
+
this.#V(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
|
|
861
870
|
}
|
|
862
|
-
#
|
|
871
|
+
#te(e) {
|
|
863
872
|
let t = Array.from(e.querySelectorAll("*"));
|
|
864
873
|
for (let e of t) {
|
|
865
874
|
let t = [];
|
|
@@ -869,9 +878,9 @@ var X = class e extends m {
|
|
|
869
878
|
let i = r.slice(2);
|
|
870
879
|
i = i[0].toLowerCase() + i.slice(1).toLowerCase();
|
|
871
880
|
let a = n.value;
|
|
872
|
-
this.#
|
|
881
|
+
this.#Z(e, r, a);
|
|
873
882
|
let o;
|
|
874
|
-
typeof this
|
|
883
|
+
typeof this.#T(a) == "function" ? o = (e) => this.#T(a).call(this, e) : (this.#Z(e, r, a), o = () => this.#x(a)), e.addEventListener(i, o), t.push(r);
|
|
875
884
|
}
|
|
876
885
|
}
|
|
877
886
|
for (let n of t) e.removeAttribute(n);
|
package/dist/wrec-ssr.d.ts
CHANGED
|
@@ -15,14 +15,14 @@ declare const HTMLElementBase: {
|
|
|
15
15
|
|
|
16
16
|
declare type LooseObject = Record<string, unknown>;
|
|
17
17
|
|
|
18
|
-
declare type PropertyConfig = {
|
|
18
|
+
declare type PropertyConfig<T = any> = {
|
|
19
19
|
computed?: string;
|
|
20
20
|
dispatch?: boolean;
|
|
21
21
|
required?: boolean;
|
|
22
22
|
type: AnyClass;
|
|
23
23
|
usedBy?: string | string[];
|
|
24
|
-
value?:
|
|
25
|
-
values?: string[];
|
|
24
|
+
value?: T;
|
|
25
|
+
values?: T extends string ? string[] : never;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
declare type StateChange = {
|
|
@@ -53,7 +53,6 @@ export declare abstract class Wrec extends HTMLElementBase {
|
|
|
53
53
|
private static registeredComputedProps;
|
|
54
54
|
private static computedPropsRegistered;
|
|
55
55
|
private static template;
|
|
56
|
-
[key: string]: any;
|
|
57
56
|
static define(elementName: string): void;
|
|
58
57
|
constructor();
|
|
59
58
|
attributeChangedCallback(attrName: string, _oldValue: string | null, newValue: string | null): void;
|
package/dist/wrec-ssr.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./wrec-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./wrec-BLZidsD5.js";
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var a = Object.defineProperty, o = Object.getOwnPropertyDescriptor, s = Object.getOwnPropertyNames, c = Object.prototype.hasOwnProperty, l = (e, t) => () => (e && (t = e(e = 0)), t), u = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), d = (e, t) => {
|
|
4
4
|
let n = {};
|
package/dist/wrec.d.ts
CHANGED
|
@@ -15,14 +15,14 @@ declare const HTMLElementBase: {
|
|
|
15
15
|
|
|
16
16
|
declare type LooseObject = Record<string, unknown>;
|
|
17
17
|
|
|
18
|
-
declare type PropertyConfig = {
|
|
18
|
+
declare type PropertyConfig<T = any> = {
|
|
19
19
|
computed?: string;
|
|
20
20
|
dispatch?: boolean;
|
|
21
21
|
required?: boolean;
|
|
22
22
|
type: AnyClass;
|
|
23
23
|
usedBy?: string | string[];
|
|
24
|
-
value?:
|
|
25
|
-
values?: string[];
|
|
24
|
+
value?: T;
|
|
25
|
+
values?: T extends string ? string[] : never;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
declare type StateChange = {
|
|
@@ -53,7 +53,6 @@ export declare abstract class Wrec extends HTMLElementBase {
|
|
|
53
53
|
private static registeredComputedProps;
|
|
54
54
|
private static computedPropsRegistered;
|
|
55
55
|
private static template;
|
|
56
|
-
[key: string]: any;
|
|
57
56
|
static define(elementName: string): void;
|
|
58
57
|
constructor();
|
|
59
58
|
attributeChangedCallback(attrName: string, _oldValue: string | null, newValue: string | null): void;
|
package/dist/wrec.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./wrec-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./wrec-BLZidsD5.js";
|
|
2
2
|
export { i as Wrec, e as WrecState, n as createElement, r as css, t as html };
|