wrec 0.42.1 → 0.43.0

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/README.md CHANGED
@@ -123,6 +123,21 @@ class TrafficLight extends Wrec {
123
123
  With that configuration, the `color` attribute and property can only be set
124
124
  to one of those strings.
125
125
 
126
+ Property definitions can set `reflect` to `false` to prevent property changes
127
+ from being copied to matching attributes:
128
+
129
+ ```js
130
+ class MessageDisplay extends Wrec {
131
+ static properties = {
132
+ message: {
133
+ type: String,
134
+ value: "",
135
+ reflect: false,
136
+ },
137
+ };
138
+ }
139
+ ```
140
+
126
141
  1. Create the file `index.html` containing the following.
127
142
 
128
143
  ```html
@@ -455,16 +455,17 @@ var $ = class e extends O {
455
455
  #t = /* @__PURE__ */ new Set();
456
456
  #n = this.constructor;
457
457
  #r = !1;
458
- #i = /* @__PURE__ */ new Map();
459
- #a = {};
460
- #o;
461
- #s = {};
462
- #c = null;
463
- #l = /* @__PURE__ */ new Map();
458
+ #i = /* @__PURE__ */ new Set();
459
+ #a = /* @__PURE__ */ new Map();
460
+ #o = {};
461
+ #s;
462
+ #c = {};
463
+ #l = null;
464
464
  #u = /* @__PURE__ */ new Map();
465
- #d = /* @__PURE__ */ new WeakMap();
466
- #f = /* @__PURE__ */ new WeakSet();
467
- #p = /* @__PURE__ */ new Map();
465
+ #d = /* @__PURE__ */ new Map();
466
+ #f = /* @__PURE__ */ new WeakMap();
467
+ #p = /* @__PURE__ */ new WeakSet();
468
+ #m = /* @__PURE__ */ new Map();
468
469
  static define(e) {
469
470
  if (this.elementName = e, k.get(e)) throw new A(`custom element ${e} is already defined`);
470
471
  k.define(e, this);
@@ -472,47 +473,51 @@ var $ = class e extends O {
472
473
  constructor() {
473
474
  super(), this.attachShadow({ mode: "open" });
474
475
  let e = this.#n;
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());
476
+ this.#j("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#j("computedGraph") || (e.computedGraph = null), this.#j("computedPropsRegistered") || (e.computedPropsRegistered = !1), this.#j("properties") || (e.properties = {}), this.#j("propToAttrMap") || (e.propToAttrMap = /* @__PURE__ */ new Map()), this.#j("propToComputedMap") || (e.propToComputedMap = /* @__PURE__ */ new Map()), this.#j("propToExprsMap") || (e.propToExprsMap = /* @__PURE__ */ new Map()), this.#j("registeredComputedProps") || (e.registeredComputedProps = /* @__PURE__ */ new Set());
476
477
  }
477
478
  attributeChangedCallback(t, n, r) {
478
- t === "disabled" && this.#y();
479
+ if (this.#i.has(t)) return;
480
+ t === "disabled" && this.#b();
479
481
  let i = e.getPropName(t);
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];
484
- t && this.setFormValue(t, String(e));
482
+ if (!this.#N(i) && this.#M(i)) {
483
+ let e = this.#J(i, r), a = this.#O(i);
484
+ if (this.#V(i, e), e !== a && this.#O(i) === a) {
485
+ this.#U(t, n);
486
+ return;
487
+ }
488
+ let o = this.#o[i];
489
+ o && this.setFormValue(o, String(e));
485
490
  }
486
491
  }
487
492
  batchSet(e) {
488
- let t = this.#$(e);
493
+ let t = this.#te(e);
489
494
  if (t.entries.length === 0) return;
490
495
  let [n, r] = t.entries[0];
491
496
  if (t.errors.length) {
492
- this.#b(n, r, t.errors);
497
+ this.#x(n, r, t.errors);
493
498
  return;
494
499
  }
495
500
  this.#e = !0;
496
501
  let i = this.#n.propToExprsMap, a = /* @__PURE__ */ new Set();
497
502
  try {
498
503
  for (let [e, n] of t.entries) {
499
- this.#B(e, n);
504
+ this.#V(e, n);
500
505
  let t = i.get(e) ?? [];
501
506
  for (let e of t) a.add(e);
502
507
  }
503
- let e = this.#E(t.entries.map(([e]) => e));
508
+ let e = this.#D(t.entries.map(([e]) => e));
504
509
  for (let [t, n] of e) {
505
- this.#z(t, this.#C(n));
510
+ this.#B(t, this.#w(n));
506
511
  let e = i.get(t) ?? [];
507
512
  for (let t of e) a.add(t);
508
513
  }
509
- this.#S([...a]);
514
+ this.#C([...a]);
510
515
  } finally {
511
516
  this.#e = !1;
512
517
  }
513
- for (let [e, n] of t.entries) this.#n.properties[e] && this.#b(e, n, []);
518
+ for (let [e, n] of t.entries) this.#n.properties[e] && this.#x(e, n, []);
514
519
  }
515
- async #m() {
520
+ async #h() {
516
521
  let e = this.#n, { template: t } = e;
517
522
  t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await le(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
518
523
  }
@@ -524,48 +529,48 @@ var $ = class e extends O {
524
529
  return t.startsWith("<") || (t = `<span><!--${t}--></span>`), e + t;
525
530
  }
526
531
  changed(e, t, n) {
527
- this.#B(t, n);
532
+ this.#V(t, n);
528
533
  }
529
- #h() {
534
+ #g() {
530
535
  let { properties: e } = this.#n;
531
- for (let [t, { computed: n }] of Object.entries(e)) n && this.#z(t, this.#C(n));
536
+ for (let [t, { computed: n }] of Object.entries(e)) n && this.#B(t, this.#w(n));
532
537
  }
533
538
  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();
539
+ this.#ee(), this.#_(), await this.#h(), this.hasAttribute("disabled") && this.#b(), this.#se(this.shadowRoot), this.#F(this.shadowRoot), this.#$(), this.#g(), this.ready();
535
540
  }
536
- #g() {
541
+ #_() {
537
542
  let { observedAttributes: e, properties: t } = this.#n;
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();
543
+ for (let [n, r] of Object.entries(t)) r.computed || this.#v(n, r, e);
544
+ for (let [n, r] of Object.entries(t)) r.computed && this.#v(n, r, e);
545
+ this.#R();
541
546
  }
542
- #_(t, n, r) {
547
+ #v(t, n, r) {
543
548
  if (t === "class" || t === "style") throw new A(`"${t}" is a reserved property`);
544
549
  let i = e.getAttrName(t), a = this.hasAttribute(i);
545
- n.required && !a && this.#U(this, i, "is a required attribute");
550
+ n.required && !a && this.#G(this, i, "is a required attribute");
546
551
  let o = n.value;
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, {
552
+ this.hasOwnProperty(t) && (o = this.#O(t), this.#y(t));
553
+ let { type: s } = n, c = s === Boolean ? o || a : r.includes(i) && a ? this.#q(t, i) : o ?? F(n), u = "#" + t;
554
+ this.#V(u, this.#P(t, s, c)), Object.defineProperty(this, t, {
550
555
  enumerable: !0,
551
556
  get() {
552
- return this.#D(u);
557
+ return this.#O(u);
553
558
  },
554
559
  set(e) {
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);
560
+ n.computed && !this.#t.has(t) && this.#G(null, t, "is a computed property and cannot be set directly"), s === Number && typeof e == "string" && (e = Y(e));
561
+ let r = this.#O(u);
557
562
  if (e === r) return;
558
- this.#re(t, s, e);
559
- let a = this.#ee(n, t, e);
563
+ this.#ae(t, s, e);
564
+ let a = this.#ne(n, t, e);
560
565
  if (!a.skipped && a.errors.length) {
561
- this.#b(t, e, a.errors);
566
+ this.#x(t, e, a.errors);
562
567
  return;
563
568
  }
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", {
569
+ e = this.#P(t, s, e), this.#V(u, e);
570
+ let o = this.#d.get(t);
571
+ o && l(o.state, o.stateProp, e), this.#Y(t, s, e, i, n.reflect), this.#e || (this.#X(t), this.#L(t)), this.#Q(t, e);
572
+ let c = this.#o[t];
573
+ c && this.setFormValue(c, String(e)), this.propertyChangedCallback(t, r, e), a.skipped || this.#x(t, e, a.errors), n.dispatch && this.dispatch("change", {
569
574
  tagName: this.localName,
570
575
  property: t,
571
576
  oldValue: r,
@@ -574,16 +579,16 @@ var $ = class e extends O {
574
579
  }
575
580
  });
576
581
  }
577
- #v(e) {
582
+ #y(e) {
578
583
  delete this[e];
579
584
  }
580
- #y() {
585
+ #b() {
581
586
  let t = this.hasAttribute("disabled"), n = L(this.shadowRoot);
582
587
  for (let r of n) N(r) && (r instanceof e ? t ? r.setAttribute("disabled", "") : r.removeAttribute("disabled") : r.disabled = t);
583
588
  }
584
589
  disconnectedCallback() {
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();
590
+ for (let { unsubscribe: e } of this.#m.values()) e();
591
+ this.#a.clear(), this.#c = {}, this.#u.clear(), this.#d.clear(), this.#m.clear();
587
592
  }
588
593
  dispatch(e, t) {
589
594
  this.dispatchEvent(new CustomEvent(e, {
@@ -592,14 +597,12 @@ var $ = class e extends O {
592
597
  detail: t
593
598
  }));
594
599
  }
595
- #b(e, t, n) {
596
- let r = n.length === 0;
600
+ #x(e, t, n) {
597
601
  this.#r = !0;
598
602
  try {
599
603
  this.dispatch("validation", {
600
604
  instance: this,
601
605
  property: e,
602
- valid: r,
603
606
  value: t,
604
607
  errors: n
605
608
  });
@@ -610,39 +613,39 @@ var $ = class e extends O {
610
613
  displayIfSet(e, t = "block") {
611
614
  return `display: ${e == null ? "none" : t}`;
612
615
  }
613
- #x(t) {
616
+ #S(t) {
614
617
  let n = t instanceof e;
615
618
  for (let r of t.getAttributeNames()) {
616
619
  let i = t.getAttribute(r);
617
620
  if (r === "ref") {
618
- this.#H(t, i);
621
+ this.#W(t, i);
619
622
  continue;
620
623
  }
621
- let a = this.#F(t, i);
624
+ let a = this.#I(t, i);
622
625
  if (a) {
623
- let i = this.#D(a);
624
- i === void 0 && this.#W(t, r, a);
626
+ let i = this.#O(a);
627
+ i === void 0 && this.#K(t, r, a);
625
628
  let [o, s] = r.split(":"), c = e.getPropName(o);
626
629
  if (o === "checked") {
627
630
  let { type: e } = this.#n.properties[a];
628
- 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`);
631
+ V(t) && e !== Boolean && this.#G(t, r, `refers to property "${a}" whose type is not Boolean`), W(t) && e !== String && this.#G(t, r, `refers to property "${a}" whose type is not String`);
629
632
  }
630
- let l = this.#M(a);
631
- 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);
633
+ let l = this.#N(a);
634
+ n && t.#N(c) || (o === "checked" && W(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#G(t, r, "refers to an unsupported event name"), t.setAttribute(o, this.#O(a))) : s = "change"), n && !l && t.#u.set(e.getPropName(o), a);
632
635
  }
633
- this.#V(i, t, r);
636
+ this.#H(i, t, r);
634
637
  }
635
638
  }
636
- #S(e) {
639
+ #C(e) {
637
640
  for (let t of e) {
638
- let e = this.#C(t), n = this.#i.get(t) ?? [], r = /* @__PURE__ */ new Set();
641
+ let e = this.#w(t), n = this.#a.get(t) ?? [], r = /* @__PURE__ */ new Set();
639
642
  for (let t of n) {
640
643
  let n = t instanceof HTMLElement || t instanceof CSSStyleRule ? t : t.element;
641
644
  if (n instanceof HTMLElement && !n.isConnected) {
642
645
  r.add(t);
643
646
  continue;
644
647
  }
645
- if (t instanceof HTMLElement) this.#Y(t, e);
648
+ if (t instanceof HTMLElement) this.#Z(t, e);
646
649
  else if (!(t instanceof CSSStyleRule)) {
647
650
  let { element: n, attrName: r } = t;
648
651
  n instanceof CSSStyleRule ? n.style.setProperty(r, e) : Z(n, r, e);
@@ -650,14 +653,14 @@ var $ = class e extends O {
650
653
  }
651
654
  if (r.size > 0) {
652
655
  let e = n.filter((e) => !r.has(e));
653
- e.length === 0 ? this.#i.delete(t) : this.#i.set(t, e);
656
+ e.length === 0 ? this.#a.delete(t) : this.#a.set(t, e);
654
657
  }
655
658
  }
656
659
  }
657
- #C(e) {
660
+ #w(e) {
658
661
  return v(e, this, this.#n.context);
659
662
  }
660
- #w(e) {
663
+ #T(e) {
661
664
  let { localName: t } = e;
662
665
  if (t === "style") {
663
666
  let { sheet: t } = e, n = t?.cssRules ?? [], r = Array.from(n);
@@ -665,13 +668,13 @@ var $ = class e extends O {
665
668
  let t = Array.from(e.style);
666
669
  for (let n of t) if (n.startsWith("--")) {
667
670
  let t = e.style.getPropertyValue(n);
668
- this.#V(t, e, n);
671
+ this.#H(t, e, n);
669
672
  }
670
673
  }
671
674
  } else {
672
675
  let t = "";
673
676
  if (G(e)) {
674
- this.#V(e.textContent, e);
677
+ this.#H(e.textContent, e);
675
678
  let n = e.textContent?.match(ee);
676
679
  n && (t = n[1]);
677
680
  } else {
@@ -679,8 +682,8 @@ var $ = class e extends O {
679
682
  n && (t = n.textContent?.trim() ?? "");
680
683
  }
681
684
  if (t) {
682
- let n = this.#F(e, t);
683
- n && G(e) ? e.textContent = this.#D(n) : this.#V(t, e);
685
+ let n = this.#I(e, t);
686
+ n && G(e) ? e.textContent = this.#O(n) : this.#H(t, e);
684
687
  }
685
688
  }
686
689
  }
@@ -688,7 +691,7 @@ var $ = class e extends O {
688
691
  let e = this.getAttribute("form-assoc");
689
692
  if (!e) {
690
693
  let t = this.getAttribute("name");
691
- if (t) if (this.#j("value")) e = `value:${t}`;
694
+ if (t) if (this.#M("value")) e = `value:${t}`;
692
695
  else return;
693
696
  else return;
694
697
  }
@@ -697,26 +700,26 @@ var $ = class e extends O {
697
700
  let [n, r] = e.split(":");
698
701
  t[n.trim()] = r.trim();
699
702
  }
700
- this.#a = t, this.#o = new FormData(), this.#c = this.attachInternals(), this.#c.setFormValue(this.#o);
703
+ this.#o = t, this.#s = new FormData(), this.#l = this.attachInternals(), this.#l.setFormValue(this.#s);
701
704
  for (let [e, n] of Object.entries(t)) {
702
- let t = this.#D(e);
705
+ let t = this.#O(e);
703
706
  U(t) && this.setFormValue(n, String(t));
704
707
  }
705
- let r = Object.keys(this.#n.properties), i = this.#s;
706
- for (let e of r) i[e] = this.#D(e);
708
+ let r = Object.keys(this.#n.properties), i = this.#c;
709
+ for (let e of r) i[e] = this.#O(e);
707
710
  }
708
711
  formResetCallback() {
709
- let e = this.#s;
712
+ let e = this.#c;
710
713
  for (let t of Object.keys(e)) {
711
714
  let n = e[t];
712
- f.test(n) && (n = this.#C(n)), this.#B(t, n);
715
+ f.test(n) && (n = this.#w(n)), this.#V(t, n);
713
716
  }
714
717
  }
715
718
  static getAttrName(e) {
716
719
  let t = this.propToAttrMap.get(e);
717
720
  return t || (t = e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), this.propToAttrMap.set(e, t)), t;
718
721
  }
719
- #T() {
722
+ #E() {
720
723
  let e = this.#n, t = e.computedGraph;
721
724
  if (t) return t;
722
725
  let n = E(), r = E(), i = {};
@@ -733,8 +736,8 @@ var $ = class e extends O {
733
736
  computedToExprMap: i
734
737
  }, e.computedGraph = t, t;
735
738
  }
736
- #E(e) {
737
- let { computedToDependenciesMap: t, computedToDependentsMap: n, computedToExprMap: r } = this.#T(), i = this.#n.propToComputedMap, a = /* @__PURE__ */ new Set(), o = [...new Set(e)];
739
+ #D(e) {
740
+ let { computedToDependenciesMap: t, computedToDependentsMap: n, computedToExprMap: r } = this.#E(), i = this.#n.propToComputedMap, a = /* @__PURE__ */ new Set(), o = [...new Set(e)];
738
741
  for (let e = 0; e < o.length; e++) {
739
742
  let t = o[e], n = i.get(t) || [];
740
743
  for (let [e, t] of n) r[e] = t, a.has(e) || (a.add(e), o.push(e));
@@ -758,77 +761,77 @@ var $ = class e extends O {
758
761
  if (c.length !== a.size) throw new A(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
759
762
  return c.map((e) => [e, r[e]]);
760
763
  }
761
- #D(e) {
764
+ #O(e) {
762
765
  return this[e];
763
766
  }
764
767
  static getPropName(e) {
765
768
  let t = this.attrToPropMap.get(e);
766
769
  return t || (t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), this.attrToPropMap.set(e, t)), t;
767
770
  }
768
- #O(e, t, n) {
769
- let r = this.#D("#" + e), i = this.#u.get(e);
770
- i && l(i.state, i.stateProp, r), this.#e || (this.#J(e), this.#I(e)), this.#X(e, r), this.propertyChangedCallback(e, t, n);
771
- }
772
771
  #k(e, t, n) {
772
+ let r = this.#O("#" + e), i = this.#d.get(e);
773
+ i && l(i.state, i.stateProp, r), this.#e || (this.#X(e), this.#L(e)), this.#Q(e, r), this.propertyChangedCallback(e, t, n);
774
+ }
775
+ #A(e, t, n) {
773
776
  if (n.length !== 1) return;
774
777
  let [r] = n;
775
778
  if (!f.test(r)) return;
776
779
  let i = V(e), a = W(e), o = K(e) || G(e), [s, c] = (t ?? "").split(":");
777
780
  if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || G(e))) return;
778
- c ? e["on" + c] === void 0 && this.#U(e, t, "refers to an unsupported event name") : c = "change";
781
+ c ? e["on" + c] === void 0 && this.#G(e, t, "refers to an unsupported event name") : c = "change";
779
782
  let l = y(r);
780
783
  e.addEventListener(c, (e) => {
781
784
  let { target: t } = e;
782
785
  if (!t) return;
783
786
  let { type: n } = this.#n.properties[l], r = t, { value: o } = r;
784
- 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);
787
+ s === "checked" ? i ? this.#V(l, r.checked) : a && r.checked && this.#V(l, o) : this.#V(l, n === Number ? Y(o) : o), this.#L(l);
785
788
  });
786
789
  }
787
- #A(e) {
790
+ #j(e) {
788
791
  return Object.hasOwn(this.#n, e);
789
792
  }
790
- #j(e) {
793
+ #M(e) {
791
794
  return !!this.#n.properties[e];
792
795
  }
793
- #M(e) {
796
+ #N(e) {
794
797
  return !!this.#n.properties[e]?.computed;
795
798
  }
796
- #N(e, n, r) {
797
- if (typeof r != "object" || !r || n !== Array && n !== Object || this.#f.has(r)) return r;
798
- let i = this.#d.get(r);
799
+ #P(e, n, r) {
800
+ if (typeof r != "object" || !r || n !== Array && n !== Object || this.#p.has(r)) return r;
801
+ let i = this.#f.get(r);
799
802
  if (i) return i;
800
803
  let a = t(r, (t, n, r) => {
801
- this.#O(e, n, r);
804
+ this.#k(e, n, r);
802
805
  });
803
- return this.#d.set(r, a), this.#f.add(a), a;
806
+ return this.#f.set(r, a), this.#p.add(a), a;
804
807
  }
805
- #P(e) {
808
+ #F(e) {
806
809
  let t = Array.from(e.querySelectorAll("*"));
807
- for (let e of t) this.#x(e), e.firstElementChild || this.#w(e);
810
+ for (let e of t) this.#S(e), e.firstElementChild || this.#T(e);
808
811
  }
809
812
  static get observedAttributes() {
810
813
  let t = Object.entries(this.properties || {}).filter(([e, t]) => !t.computed).map(([t]) => e.getAttrName(t));
811
814
  return t.includes("disabled") || t.push("disabled"), t;
812
815
  }
813
816
  propertyChangedCallback(e, t, n) {}
814
- #F(e, t) {
817
+ #I(e, t) {
815
818
  if (!t || !f.test(t)) return;
816
819
  let n = y(t);
817
- return this.#D(n) === void 0 && this.#W(e, "", n), n;
820
+ return this.#O(n) === void 0 && this.#K(e, "", n), n;
818
821
  }
819
- #I(e) {
822
+ #L(e) {
820
823
  let t = this.#n.propToExprsMap.get(e) || [];
821
- this.#S(t);
824
+ this.#C(t);
822
825
  }
823
826
  ready() {}
824
- #L() {
827
+ #R() {
825
828
  let e = this.#n;
826
829
  if (!e.computedPropsRegistered) {
827
830
  e.computedPropsRegistered = !0, e.computedGraph = null;
828
- for (let [t, n] of Object.entries(e.properties)) n.computed && this.#R(t, n);
831
+ for (let [t, n] of Object.entries(e.properties)) n.computed && this.#z(t, n);
829
832
  }
830
833
  }
831
- #R(e, t) {
834
+ #z(e, t) {
832
835
  let n = this.#n;
833
836
  n.registeredComputedProps.add(e);
834
837
  let r = n.propToComputedMap;
@@ -839,31 +842,31 @@ var $ = class e extends O {
839
842
  let a = t.computed;
840
843
  for (let t of a.matchAll(p)) {
841
844
  let r = y(t[0]);
842
- this.#D(r) === void 0 && this.#W(null, e, r);
845
+ this.#O(r) === void 0 && this.#K(null, e, r);
843
846
  let o = q(r), s = !1;
844
847
  for (let [e, t] of Object.entries(n.properties)) Q(t.usedBy)?.includes(o) && (i(e, a), s = !0);
845
- !s && typeof this.#D(r) != "function" && i(r, a);
848
+ !s && typeof this.#O(r) != "function" && i(r, a);
846
849
  }
847
850
  for (let t of a.matchAll(d)) {
848
851
  let r = t[1];
849
- if (typeof this.#D(r) != "function") throw new A(`property ${e} computed calls non-method ${r}`);
852
+ if (typeof this.#O(r) != "function") throw new A(`property ${e} computed calls non-method ${r}`);
850
853
  for (let [e, t] of Object.entries(n.properties)) Q(t.usedBy)?.includes(r) && i(e, a);
851
854
  }
852
855
  }
853
- #z(e, t) {
856
+ #B(e, t) {
854
857
  this.#t.add(e);
855
858
  try {
856
- this.#B(e, t);
859
+ this.#V(e, t);
857
860
  } finally {
858
861
  this.#t.delete(e);
859
862
  }
860
863
  }
861
- #B(e, t) {
864
+ #V(e, t) {
862
865
  this[e] = t;
863
866
  }
864
- #V(e, t, n = void 0) {
867
+ #H(e, t, n = void 0) {
865
868
  if (!e) return;
866
- let r = this.#te(t, n, e);
869
+ let r = this.#re(t, n, e);
867
870
  if (!r) {
868
871
  let r = e.replaceAll("this..", "this.");
869
872
  n ? Z(t, n, r) : "textContent" in t && (t.textContent = r);
@@ -872,53 +875,62 @@ var $ = class e extends O {
872
875
  let i = this.#n;
873
876
  r.forEach((t) => {
874
877
  let n = y(t);
875
- if (typeof this.#D(n) == "function") return;
878
+ if (typeof this.#O(n) == "function") return;
876
879
  let r = i.propToExprsMap, a = r.get(n);
877
880
  a || (a = [], r.set(n, a)), a.includes(e) || a.push(e);
878
881
  });
879
- for (let [e, t] of this.#i.entries()) for (let n of t) {
882
+ for (let [e, t] of this.#a.entries()) for (let n of t) {
880
883
  let r = n instanceof HTMLElement || n instanceof CSSStyleRule ? n : n.element;
881
- r instanceof CSSStyleRule || r.isConnected || this.#i.set(e, t.filter((e) => e !== n));
884
+ r instanceof CSSStyleRule || r.isConnected || this.#a.set(e, t.filter((e) => e !== n));
882
885
  }
883
- let a = this.#i.get(e);
884
- a || (a = [], this.#i.set(e, a)), a.push(n ? {
886
+ let a = this.#a.get(e);
887
+ a || (a = [], this.#a.set(e, a)), a.push(n ? {
885
888
  element: t,
886
889
  attrName: n
887
- } : t), t instanceof HTMLElement && this.#k(t, n, r);
888
- let o = this.#C(e);
889
- n ? Z(t, n, o) : this.#Y(t, o);
890
+ } : t), t instanceof HTMLElement && this.#A(t, n, r);
891
+ let o = this.#w(e);
892
+ n ? Z(t, n, o) : this.#Z(t, o);
890
893
  }
891
- #H(e, t) {
894
+ #U(e, t) {
895
+ this.#i.add(e);
896
+ try {
897
+ t === null ? this.removeAttribute(e) : this.setAttribute(e, t);
898
+ } finally {
899
+ this.#i.delete(e);
900
+ }
901
+ e === "disabled" && this.#b();
902
+ }
903
+ #W(e, t) {
892
904
  let n = t?.trim() ?? "", r = this.#n.properties[n];
893
- 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");
905
+ r || this.#K(e, "ref", n), r.type !== O && this.#G(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this.#O(n) && this.#G(e, "ref", `is a duplicate reference to the property "${n}"`), this.#V(n, e), e.removeAttribute("ref");
894
906
  }
895
907
  setAttributeSafe(e, t) {
896
908
  this.hasAttribute(e) || this.setAttribute(e, t);
897
909
  }
898
910
  setFormValue(e, t) {
899
- !this.#o || !U(t) || (this.#o.set(e, t), this.#c?.setFormValue(this.#o));
911
+ !this.#s || !U(t) || (this.#s.set(e, t), this.#l?.setFormValue(this.#s));
900
912
  }
901
913
  static ssr(e = {}) {
902
914
  throw new A("SSR is not available in the browser build.");
903
915
  }
904
- #U(e, t, n) {
916
+ #G(e, t, n) {
905
917
  let r = e instanceof HTMLElement ? e.localName : "CSS rule";
906
918
  throw new A(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
907
919
  }
908
- #W(e, t, n) {
909
- this.#U(e, t, `refers to missing property "${n}"`);
920
+ #K(e, t, n) {
921
+ this.#G(e, t, `refers to missing property "${n}"`);
910
922
  }
911
- #G(e, t) {
912
- return this.#K(e, this.getAttribute(t));
923
+ #q(e, t) {
924
+ return this.#J(e, this.getAttribute(t));
913
925
  }
914
- #K(t, n) {
926
+ #J(t, n) {
915
927
  if (n?.match(p)) return n;
916
928
  let r = this.#n.properties[t], { type: i, values: a } = r;
917
- if (i || this.#U(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : F(r);
929
+ if (i || this.#G(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : F(r);
918
930
  if (i === String) {
919
931
  if (a && !a.includes(n)) {
920
932
  let e = a.map((e) => `"${e}"`).join(", ");
921
- this.#U(null, t, `must be one of ${e}`);
933
+ this.#G(null, t, `must be one of ${e}`);
922
934
  }
923
935
  return n;
924
936
  }
@@ -927,31 +939,31 @@ var $ = class e extends O {
927
939
  if (n === "true") return !0;
928
940
  if (n === "false" || n === "null") return !1;
929
941
  let r = e.getAttrName(t);
930
- 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;
942
+ return n && n !== r && this.#G(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
931
943
  }
932
944
  }
933
- #q(e, t, n, r) {
934
- U(n) && !this.#M(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#G(e, r)) && X(this, r || e, n);
945
+ #Y(e, t, n, r, i = !0) {
946
+ i && U(n) && !this.#N(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#q(e, r)) && X(this, r || e, n);
935
947
  }
936
- #J(e) {
937
- for (let [t, n] of this.#E([e])) this.#z(t, this.#C(n));
948
+ #X(e) {
949
+ for (let [t, n] of this.#D([e])) this.#B(t, this.#w(n));
938
950
  }
939
- #Y(e, t) {
951
+ #Z(e, t) {
940
952
  if (t === void 0) return;
941
953
  let n = e instanceof HTMLElement;
942
954
  Array.isArray(t) && (t = t.join(""));
943
955
  let r = typeof t;
944
- r !== "string" && r !== "number" && this.#U(e, void 0, " computed content is not a string or number");
956
+ r !== "string" && r !== "number" && this.#G(e, void 0, " computed content is not a string or number");
945
957
  let i = String(t);
946
958
  if (e instanceof HTMLElement && G(e)) e.value !== i && (e.value = i);
947
959
  else if (n && r === "string" && i.trim().startsWith("<")) {
948
960
  let t = se(i);
949
961
  if (e.innerHTML === t) return;
950
- e.innerHTML = t, this.#ae(e), this.#P(e);
962
+ e.innerHTML = t, this.#se(e), this.#F(e);
951
963
  } else n && e.textContent !== i && (e.textContent = i);
952
964
  }
953
- #X(e, t) {
954
- let n = this.#l.get(e);
965
+ #Q(e, t) {
966
+ let n = this.#u.get(e);
955
967
  if (!n) return;
956
968
  let r = this.getRootNode();
957
969
  if (!(r instanceof ShadowRoot)) return;
@@ -960,14 +972,14 @@ var $ = class e extends O {
960
972
  let a = i;
961
973
  a[n] = t;
962
974
  }
963
- #Z() {
975
+ #$() {
964
976
  let e = this.#n, t = (e, t, n) => {
965
977
  let r = e.get(t);
966
978
  r || (r = [], e.set(t, r)), r.includes(n) || r.push(n);
967
979
  }, n = () => {
968
980
  let n = E();
969
981
  e.methodToExprsMap = n;
970
- let r = Array.from(this.#i.keys());
982
+ let r = Array.from(this.#a.keys());
971
983
  for (let e of r) {
972
984
  for (let r of e.matchAll(d)) t(n, r[1], e);
973
985
  for (let r of e.matchAll(p)) t(n, q(y(r[0])), e);
@@ -983,7 +995,7 @@ var $ = class e extends O {
983
995
  if (H(e)) {
984
996
  let n = z(e);
985
997
  if (typeof R(this, n)?.get != "function") throw new A(`property ${t} usedBy contains non-getter ${e}`);
986
- } else if (typeof this.#D(e) != "function") throw new A(`property ${t} usedBy contains non-method ${e}`);
998
+ } else if (typeof this.#O(e) != "function") throw new A(`property ${t} usedBy contains non-method ${e}`);
987
999
  let n = o.get(e) || [];
988
1000
  for (let e of n) s.includes(e) || s.push(e);
989
1001
  }
@@ -994,15 +1006,15 @@ var $ = class e extends O {
994
1006
  t = {};
995
1007
  for (let n of Object.keys(e)) t[n] = n;
996
1008
  }
997
- this.#ne(e, t);
998
- for (let [n, r] of Object.entries(t)) if (this.#j(r)) {
1009
+ this.#ie(e, t);
1010
+ for (let [n, r] of Object.entries(t)) if (this.#M(r)) {
999
1011
  let t = o(e, n);
1000
- t !== void 0 && this.#B(r, t), this.#u.set(r, {
1012
+ t !== void 0 && this.#V(r, t), this.#d.set(r, {
1001
1013
  state: e,
1002
1014
  stateProp: n
1003
1015
  });
1004
1016
  }
1005
- let n = this.#p.get(e), r = {
1017
+ let n = this.#m.get(e), r = {
1006
1018
  ...n?.map,
1007
1019
  ...t
1008
1020
  };
@@ -1010,15 +1022,15 @@ var $ = class e extends O {
1010
1022
  let i = e.subscribe(({ statePath: t, newValue: n }) => {
1011
1023
  let i = r[t];
1012
1024
  if (i) {
1013
- this.#B(i, n);
1025
+ this.#V(i, n);
1014
1026
  return;
1015
1027
  }
1016
1028
  let a = Object.keys(r).find((e) => t.startsWith(e + ".") || e.startsWith(t + "."));
1017
1029
  if (!a) return;
1018
1030
  let s = r[a];
1019
- this.#B(s, o(e, a));
1031
+ this.#V(s, o(e, a));
1020
1032
  }, Object.keys(r));
1021
- this.#p.set(e, {
1033
+ this.#m.set(e, {
1022
1034
  map: r,
1023
1035
  unsubscribe: i
1024
1036
  });
@@ -1026,28 +1038,28 @@ var $ = class e extends O {
1026
1038
  validate(e) {
1027
1039
  return [];
1028
1040
  }
1029
- #Q() {
1041
+ #ee() {
1030
1042
  let t = new Set(Object.keys(this.#n.properties));
1031
1043
  for (let n of this.getAttributeNames()) if (!D.has(n) && !n.startsWith("on") && n !== "ref") {
1032
1044
  if (n === "form-assoc") {
1033
- this.#ie();
1045
+ this.#oe();
1034
1046
  continue;
1035
1047
  }
1036
1048
  if (!t.has(e.getPropName(n))) {
1037
1049
  if (n === "name") {
1038
- this.#ie();
1050
+ this.#oe();
1039
1051
  continue;
1040
1052
  }
1041
- this.#U(null, n, "is not a supported attribute");
1053
+ this.#G(null, n, "is not a supported attribute");
1042
1054
  }
1043
1055
  }
1044
1056
  }
1045
- #$(e) {
1057
+ #te(e) {
1046
1058
  let t = [], n = [], r = { ...this };
1047
1059
  for (let [i, a] of Object.entries(e)) {
1048
1060
  let e = this.#n.properties[i], o = a;
1049
1061
  if (e) {
1050
- 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);
1062
+ e.computed && this.#G(null, i, "is a computed property and cannot be set directly"), e.type === Number && typeof o == "string" && (o = Y(o)), this.#ae(i, e.type, o);
1051
1063
  let t = e.validate?.(o);
1052
1064
  typeof t == "string" && n.push(t);
1053
1065
  }
@@ -1058,7 +1070,7 @@ var $ = class e extends O {
1058
1070
  errors: n
1059
1071
  };
1060
1072
  }
1061
- #ee(e, t, n) {
1073
+ #ne(e, t, n) {
1062
1074
  if (this.#e || this.#r) return {
1063
1075
  errors: [],
1064
1076
  skipped: !0
@@ -1074,39 +1086,39 @@ var $ = class e extends O {
1074
1086
  skipped: !1
1075
1087
  };
1076
1088
  }
1077
- #te(e, t, n) {
1089
+ #re(e, t, n) {
1078
1090
  let r = n.match(p);
1079
1091
  if (r) return r.forEach((n) => {
1080
1092
  let r = y(n);
1081
- this.#D(r) === void 0 && this.#W(e, t, r);
1093
+ this.#O(r) === void 0 && this.#K(e, t, r);
1082
1094
  }), r;
1083
1095
  }
1084
- #ne(e, t) {
1096
+ #ie(e, t) {
1085
1097
  for (let [n, r] of Object.entries(t)) {
1086
1098
  let t = o(e, n);
1087
- 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");
1099
+ t === void 0 && this.#G(this, void 0, `invalid state path "${n}"`), t = this.#O(r), this.#M(r) || this.#G(null, r, "refers to missing property in useState map");
1088
1100
  }
1089
1101
  }
1090
- #re(e, t, n) {
1102
+ #ae(e, t, n) {
1091
1103
  let { values: r } = this.#n.properties[e];
1092
1104
  if (r) {
1093
1105
  let i;
1094
- 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);
1106
+ 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.#G(null, e, i);
1095
1107
  }
1096
1108
  if (n instanceof t) return;
1097
1109
  let i = typeof n;
1098
1110
  if (i === "object") {
1099
1111
  let { constructor: r } = n;
1100
- i = r.name, r !== t && this.#U(null, e, `was set to a ${i}, but must be a ${t.name}`);
1112
+ i = r.name, r !== t && this.#G(null, e, `was set to a ${i}, but must be a ${t.name}`);
1101
1113
  }
1102
- i !== t.name.toLowerCase() && this.#U(null, e, `was set to a ${i}, but must be a ${t.name}`);
1114
+ i !== t.name.toLowerCase() && this.#G(null, e, `was set to a ${i}, but must be a ${t.name}`);
1103
1115
  }
1104
- #ie() {
1116
+ #oe() {
1105
1117
  if (this.#n.formAssociated || this.closest("form") === null) return;
1106
1118
  let e = this.#n.name;
1107
- this.#U(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
1119
+ this.#G(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
1108
1120
  }
1109
- #ae(e) {
1121
+ #se(e) {
1110
1122
  let t = Array.from(e.querySelectorAll("*"));
1111
1123
  for (let e of t) {
1112
1124
  let t = [];
@@ -1116,9 +1128,9 @@ var $ = class e extends O {
1116
1128
  let i = r.slice(2);
1117
1129
  i = i[0].toLowerCase() + i.slice(1).toLowerCase();
1118
1130
  let a = n.value;
1119
- this.#te(e, r, a);
1131
+ this.#re(e, r, a);
1120
1132
  let o;
1121
- 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);
1133
+ typeof this.#O(a) == "function" ? o = (e) => this.#O(a).call(this, e) : (this.#re(e, r, a), o = () => this.#w(a)), e.addEventListener(i, o), t.push(r);
1122
1134
  }
1123
1135
  }
1124
1136
  for (let n of t) e.removeAttribute(n);
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./wrec-ClOIAA9J.js";
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./wrec-DQFGT4l_.js";
2
2
  //#region \0rolldown/runtime.js
3
3
  var u = Object.defineProperty, d = Object.getOwnPropertyDescriptor, f = Object.getOwnPropertyNames, p = Object.prototype.hasOwnProperty, m = (e, t) => () => (e && (t = e(e = 0)), t), h = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), g = (e, t) => {
4
4
  let n = {};
package/dist/wrec.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as e, n as t, r as n, t as r, u as i } from "./wrec-ClOIAA9J.js";
1
+ import { i as e, n as t, r as n, t as r, u as i } from "./wrec-DQFGT4l_.js";
2
2
  export { r as Wrec, i as WrecState, t as createElement, n as css, e as html };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrec",
3
- "version": "0.42.1",
3
+ "version": "0.43.0",
4
4
  "description": "a library that greatly simplifies building web components",
5
5
  "keywords": [
6
6
  "component",