wrec 0.32.1 → 0.33.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.
@@ -303,7 +303,9 @@ var X = class e extends m {
303
303
  #s = null;
304
304
  #c = /* @__PURE__ */ new Map();
305
305
  #l = /* @__PURE__ */ new Map();
306
- #u = /* @__PURE__ */ new Map();
306
+ #u = /* @__PURE__ */ new WeakMap();
307
+ #d = /* @__PURE__ */ new WeakSet();
308
+ #f = /* @__PURE__ */ new Map();
307
309
  static define(e) {
308
310
  if (this.elementName = e, h.get(e)) throw new g(`custom element ${e} is already defined`);
309
311
  h.define(e, this);
@@ -311,13 +313,13 @@ var X = class e extends m {
311
313
  constructor() {
312
314
  super(), this.attachShadow({ mode: "open" });
313
315
  let e = this.#n;
314
- this.#C("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#C("computedGraph") || (e.computedGraph = null), this.#C("computedPropsRegistered") || (e.computedPropsRegistered = !1), this.#C("properties") || (e.properties = {}), this.#C("propToAttrMap") || (e.propToAttrMap = /* @__PURE__ */ new Map()), this.#C("propToComputedMap") || (e.propToComputedMap = /* @__PURE__ */ new Map()), this.#C("propToExprsMap") || (e.propToExprsMap = /* @__PURE__ */ new Map()), this.#C("registeredComputedProps") || (e.registeredComputedProps = /* @__PURE__ */ new Set());
316
+ this.#E("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#E("computedGraph") || (e.computedGraph = null), this.#E("computedPropsRegistered") || (e.computedPropsRegistered = !1), this.#E("properties") || (e.properties = {}), this.#E("propToAttrMap") || (e.propToAttrMap = /* @__PURE__ */ new Map()), this.#E("propToComputedMap") || (e.propToComputedMap = /* @__PURE__ */ new Map()), this.#E("propToExprsMap") || (e.propToExprsMap = /* @__PURE__ */ new Map()), this.#E("registeredComputedProps") || (e.registeredComputedProps = /* @__PURE__ */ new Set());
315
317
  }
316
318
  attributeChangedCallback(t, n, r) {
317
- t === "disabled" && this.#h();
319
+ t === "disabled" && this.#v();
318
320
  let i = e.getPropName(t);
319
- if (!this.#T(i) && this.#w(i)) {
320
- let e = this.#R(i, r);
321
+ if (!this.#O(i) && this.#D(i)) {
322
+ let e = this.#V(i, r);
321
323
  this[i] = e;
322
324
  let t = this.#i[i];
323
325
  t && this.setFormValue(t, String(e));
@@ -331,15 +333,15 @@ var X = class e extends m {
331
333
  let e = t.get(r) ?? [];
332
334
  for (let t of e) n.add(t);
333
335
  }
334
- let r = this.#x(Object.keys(e));
336
+ let r = this.#w(Object.keys(e));
335
337
  for (let [e, i] of r) {
336
- this.#M(e, this.#v(i));
338
+ this.#F(e, this.#x(i));
337
339
  let r = t.get(e) ?? [];
338
340
  for (let e of r) n.add(e);
339
341
  }
340
- this.#_([...n]), this.#e = !1;
342
+ this.#b([...n]), this.#e = !1;
341
343
  }
342
- async #d() {
344
+ async #p() {
343
345
  let e = this.#n, { template: t } = e;
344
346
  t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await Y(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
345
347
  }
@@ -354,37 +356,37 @@ var X = class e extends m {
354
356
  this[t] = n;
355
357
  }
356
358
  async connectedCallback() {
357
- this.#W(), this.#p(), await this.#d(), this.hasAttribute("disabled") && this.#h(), this.#J(this.shadowRoot), this.#E(this.shadowRoot), this.#U(), this.#f(), this.ready();
359
+ this.#q(), this.#h(), await this.#p(), this.hasAttribute("disabled") && this.#v(), this.#Q(this.shadowRoot), this.#A(this.shadowRoot), this.#K(), this.#m(), this.ready();
358
360
  }
359
- #f() {
361
+ #m() {
360
362
  let { properties: e } = this.#n;
361
- for (let [t, { computed: n }] of Object.entries(e)) n && this.#M(t, this.#v(n));
363
+ for (let [t, { computed: n }] of Object.entries(e)) n && this.#F(t, this.#x(n));
362
364
  }
363
- #p() {
365
+ #h() {
364
366
  let { observedAttributes: e, properties: t } = this.#n;
365
- for (let [n, r] of Object.entries(t)) r.computed || this.#m(n, r, e);
366
- for (let [n, r] of Object.entries(t)) r.computed && this.#m(n, r, e);
367
- this.#A();
367
+ for (let [n, r] of Object.entries(t)) r.computed || this.#g(n, r, e);
368
+ for (let [n, r] of Object.entries(t)) r.computed && this.#g(n, r, e);
369
+ this.#N();
368
370
  }
369
- #m(t, n, r) {
371
+ #g(t, n, r) {
370
372
  if (t === "class" || t === "style") throw new g(`"${t}" is a reserved property`);
371
373
  let i = e.getAttrName(t), a = this.hasAttribute(i);
372
- n.required && !a && this.#F(this, i, "is a required attribute");
374
+ n.required && !a && this.#R(this, i, "is a required attribute");
373
375
  let o = n.value;
374
376
  this.hasOwnProperty(t) && (o = this[t], delete this[t]);
375
- let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#L(t, i) : o ?? k(n), u = "#" + t;
376
- this[u] = l, Object.defineProperty(this, t, {
377
+ let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#B(t, i) : o ?? k(n), u = "#" + t;
378
+ this[u] = this.#k(t, c, l), Object.defineProperty(this, t, {
377
379
  enumerable: !0,
378
380
  get() {
379
381
  return this[u];
380
382
  },
381
383
  set(e) {
382
- n.computed && !this.#t.has(t) && this.#F(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e = G(e));
384
+ n.computed && !this.#t.has(t) && this.#R(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e = G(e));
383
385
  let r = this[u];
384
386
  if (e === r) return;
385
- this.#q(t, c, e), this[u] = e;
387
+ this.#X(t, c, e), e = this.#k(t, c, e), this[u] = e;
386
388
  let a = this.#l.get(t);
387
- a && s(a.state, a.stateProp, e), this.#z(t, c, e, i), this.#e || (this.#B(t), this.#k(t)), this.#H(t, e);
389
+ a && s(a.state, a.stateProp, e), this.#H(t, c, e, i), this.#e || (this.#U(t), this.#M(t)), this.#G(t, e);
388
390
  let o = this.#i[t];
389
391
  o && this.setFormValue(o, String(e)), this.propertyChangedCallback(t, r, e), n.dispatch && this.dispatch("change", {
390
392
  tagName: this.localName,
@@ -395,13 +397,17 @@ var X = class e extends m {
395
397
  }
396
398
  });
397
399
  }
398
- #h() {
400
+ #_(e, t, n) {
401
+ let r = this["#" + e], i = this.#l.get(e);
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);
403
+ }
404
+ #v() {
399
405
  let e = this.hasAttribute("disabled"), t = j(this.shadowRoot);
400
406
  for (let n of t) D(n) && (n.disabled = e);
401
407
  }
402
408
  disconnectedCallback() {
403
- for (let { unsubscribe: e } of this.#u.values()) e();
404
- this.#r.clear(), this.#o.clear(), this.#c.clear(), this.#l.clear(), this.#u.clear();
409
+ for (let { unsubscribe: e } of this.#f.values()) e();
410
+ this.#r.clear(), this.#o.clear(), this.#c.clear(), this.#l.clear(), this.#f.clear();
405
411
  }
406
412
  dispatch(e, t) {
407
413
  this.dispatchEvent(new CustomEvent(e, {
@@ -413,39 +419,39 @@ var X = class e extends m {
413
419
  displayIfSet(e, t = "block") {
414
420
  return `display: ${e == null ? "none" : t}`;
415
421
  }
416
- #g(t) {
422
+ #y(t) {
417
423
  let n = t instanceof e;
418
424
  for (let r of t.getAttributeNames()) {
419
425
  let i = t.getAttribute(r);
420
426
  if (r === "ref") {
421
- this.#P(t, i);
427
+ this.#L(t, i);
422
428
  continue;
423
429
  }
424
- let a = this.#O(t, i);
430
+ let a = this.#j(t, i);
425
431
  if (a) {
426
432
  let i = this[a];
427
- i === void 0 && this.#I(t, r, a);
433
+ i === void 0 && this.#z(t, r, a);
428
434
  let [o, s] = r.split(":"), c = e.getPropName(o);
429
435
  if (o === "checked") {
430
436
  let { type: e } = this.#n.properties[a];
431
- I(t) && e !== Boolean && this.#F(t, r, `refers to property "${a}" whose type is not Boolean`), z(t) && e !== String && this.#F(t, r, `refers to property "${a}" whose type is not String`);
437
+ I(t) && e !== Boolean && this.#R(t, r, `refers to property "${a}" whose type is not Boolean`), z(t) && e !== String && this.#R(t, r, `refers to property "${a}" whose type is not String`);
432
438
  }
433
- let l = this.#T(a);
434
- n && t.#T(c) || (o === "checked" && z(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#F(t, r, "refers to an unsupported event name"), t.setAttribute(o, this[a])) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
439
+ let l = this.#O(a);
440
+ n && t.#O(c) || (o === "checked" && z(t) ? t.checked = t.value === i : t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#R(t, r, "refers to an unsupported event name"), t.setAttribute(o, this[a])) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
435
441
  }
436
- this.#N(i, t, r);
442
+ this.#I(i, t, r);
437
443
  }
438
444
  }
439
- #_(e) {
445
+ #b(e) {
440
446
  for (let t of e) {
441
- let e = this.#v(t), n = this.#r.get(t) ?? [], r = /* @__PURE__ */ new Set();
447
+ let e = this.#x(t), n = this.#r.get(t) ?? [], r = /* @__PURE__ */ new Set();
442
448
  for (let t of n) {
443
449
  let n = t instanceof HTMLElement || t instanceof CSSStyleRule ? t : t.element;
444
450
  if (n instanceof HTMLElement && !n.isConnected) {
445
451
  r.add(t);
446
452
  continue;
447
453
  }
448
- if (t instanceof HTMLElement) this.#V(t, e);
454
+ if (t instanceof HTMLElement) this.#W(t, e);
449
455
  else if (!(t instanceof CSSStyleRule)) {
450
456
  let { element: n, attrName: r } = t;
451
457
  n instanceof CSSStyleRule ? n.style.setProperty(r, e) : q(n, r, e);
@@ -457,11 +463,11 @@ var X = class e extends m {
457
463
  }
458
464
  }
459
465
  }
460
- #v(e) {
466
+ #x(e) {
461
467
  let { context: t } = this.#n;
462
468
  return Function("context", `const {${Object.keys(t).join(",")}} = context; return ${e};`).call(this, t);
463
469
  }
464
- #y(e) {
470
+ #S(e) {
465
471
  let { localName: t } = e;
466
472
  if (t === "style") {
467
473
  let { sheet: t } = e, n = t?.cssRules ?? [], r = Array.from(n);
@@ -469,13 +475,13 @@ var X = class e extends m {
469
475
  let t = Array.from(e.style);
470
476
  for (let n of t) if (n.startsWith("--")) {
471
477
  let t = e.style.getPropertyValue(n);
472
- this.#N(t, e, n);
478
+ this.#I(t, e, n);
473
479
  }
474
480
  }
475
481
  } else {
476
482
  let t = "";
477
483
  if (B(e)) {
478
- this.#N(e.textContent, e);
484
+ this.#I(e.textContent, e);
479
485
  let n = e.textContent?.match(x);
480
486
  n && (t = n[1]);
481
487
  } else {
@@ -483,8 +489,8 @@ var X = class e extends m {
483
489
  n && (t = n.textContent?.trim() ?? "");
484
490
  }
485
491
  if (t) {
486
- let n = this.#O(e, t);
487
- n && B(e) ? e.textContent = this[n] : this.#N(t, e);
492
+ let n = this.#j(e, t);
493
+ n && B(e) ? e.textContent = this[n] : this.#I(t, e);
488
494
  }
489
495
  }
490
496
  }
@@ -492,7 +498,7 @@ var X = class e extends m {
492
498
  let e = this.getAttribute("form-assoc");
493
499
  if (!e) {
494
500
  let t = this.getAttribute("name");
495
- if (t) if (this.#w("value")) e = `value:${t}`;
501
+ if (t) if (this.#D("value")) e = `value:${t}`;
496
502
  else return;
497
503
  else return;
498
504
  }
@@ -513,14 +519,14 @@ var X = class e extends m {
513
519
  let e = this.#o;
514
520
  for (let t of Object.keys(e)) {
515
521
  let n = e[t];
516
- C.test(n) && (n = this.#v(n)), this[t] = n;
522
+ C.test(n) && (n = this.#x(n)), this[t] = n;
517
523
  }
518
524
  }
519
525
  static getAttrName(e) {
520
526
  let t = this.propToAttrMap.get(e);
521
527
  return t || (t = e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), this.propToAttrMap.set(e, t)), t;
522
528
  }
523
- #b() {
529
+ #C() {
524
530
  let e = this.#n, t = e.computedGraph;
525
531
  if (t) return t;
526
532
  let n = f(), r = f(), i = {};
@@ -537,8 +543,8 @@ var X = class e extends m {
537
543
  computedToExprMap: i
538
544
  }, e.computedGraph = t, t;
539
545
  }
540
- #x(e) {
541
- let { computedToDependenciesMap: t, computedToDependentsMap: n, computedToExprMap: r } = this.#b(), i = this.#n.propToComputedMap, a = /* @__PURE__ */ new Set(), o = [...new Set(e)];
546
+ #w(e) {
547
+ let { computedToDependenciesMap: t, computedToDependentsMap: n, computedToExprMap: r } = this.#C(), i = this.#n.propToComputedMap, a = /* @__PURE__ */ new Set(), o = [...new Set(e)];
542
548
  for (let e = 0; e < o.length; e++) {
543
549
  let t = o[e], n = i.get(t) || [];
544
550
  for (let [e, t] of n) r[e] = t, a.has(e) || (a.add(e), o.push(e));
@@ -566,62 +572,66 @@ var X = class e extends m {
566
572
  let t = this.attrToPropMap.get(e);
567
573
  return t || (t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), this.attrToPropMap.set(e, t)), t;
568
574
  }
569
- #S(e, t, n) {
575
+ #T(e, t, n) {
570
576
  if (n.length !== 1) return;
571
577
  let [r] = n;
572
578
  if (!C.test(r)) return;
573
579
  let i = I(e), a = z(e), o = V(e) || B(e), [s, c] = (t ?? "").split(":");
574
580
  if (!(o && s === "value" || i && s === "checked" || a && s === "checked" || B(e))) return;
575
- c ? e["on" + c] === void 0 && this.#F(e, t, "refers to an unsupported event name") : c = "change";
581
+ c ? e["on" + c] === void 0 && this.#R(e, t, "refers to an unsupported event name") : c = "change";
576
582
  let l = N(r);
577
583
  e.addEventListener(c, (e) => {
578
584
  let { target: t } = e;
579
585
  if (!t) return;
580
586
  let { type: n } = this.#n.properties[l], r = t, { value: o } = r;
581
- s === "checked" ? i ? this[l] = r.checked : a && r.checked && (this[l] = o) : this[l] = n === Number ? G(o) : o, this.#k(l);
587
+ s === "checked" ? i ? this[l] = r.checked : a && r.checked && (this[l] = o) : this[l] = n === Number ? G(o) : o, this.#M(l);
582
588
  });
583
589
  }
584
- #C(e) {
590
+ #E(e) {
585
591
  return Object.hasOwn(this.#n, e);
586
592
  }
587
- #w(e) {
593
+ #D(e) {
588
594
  return !!this.#n.properties[e];
589
595
  }
590
- #T(e) {
596
+ #O(e) {
591
597
  return !!this.#n.properties[e]?.computed;
592
598
  }
593
- #E(e) {
594
- let t = Array.from(e.querySelectorAll("*"));
595
- for (let e of t) this.#g(e), e.firstElementChild || this.#y(e);
599
+ #k(e, n, r) {
600
+ if (typeof r != "object" || !r || n !== Array && n !== Object || this.#d.has(r)) return r;
601
+ let i = this.#u.get(r);
602
+ if (i) return i;
603
+ let a = t(r, (t, n, r) => {
604
+ this.#_(e, n, r);
605
+ });
606
+ return this.#u.set(r, a), this.#d.add(a), a;
596
607
  }
597
- #D() {
598
- if (this.#n.formAssociated || this.closest("form") === null) return;
599
- let e = this.#n.name;
600
- this.#F(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
608
+ #A(e) {
609
+ let t = Array.from(e.querySelectorAll("*"));
610
+ for (let e of t) this.#y(e), e.firstElementChild || this.#S(e);
601
611
  }
602
612
  static get observedAttributes() {
603
613
  let t = Object.entries(this.properties || {}).filter(([e, t]) => !t.computed).map(([t]) => e.getAttrName(t));
604
614
  return t.includes("disabled") || t.push("disabled"), t;
605
615
  }
606
616
  propertyChangedCallback(e, t, n) {}
607
- #O(e, t) {
617
+ #j(e, t) {
608
618
  if (!t || !C.test(t)) return;
609
619
  let n = N(t);
610
- return this[n] === void 0 && this.#I(e, "", n), n;
620
+ return this[n] === void 0 && this.#z(e, "", n), n;
611
621
  }
612
- #k(e) {
622
+ #M(e) {
613
623
  let t = this.#n.propToExprsMap.get(e) || [];
614
- this.#_(t);
624
+ this.#b(t);
615
625
  }
616
626
  ready() {}
617
- #A() {
627
+ #N() {
618
628
  let e = this.#n;
619
629
  if (!e.computedPropsRegistered) {
620
630
  e.computedPropsRegistered = !0, e.computedGraph = null;
621
- for (let [t, n] of Object.entries(e.properties)) n.computed && this.#j(t, n);
631
+ for (let [t, n] of Object.entries(e.properties)) n.computed && this.#P(t, n);
622
632
  }
623
633
  }
624
- #j(e, t) {
634
+ #P(e, t) {
625
635
  let n = this.#n;
626
636
  n.registeredComputedProps.add(e);
627
637
  let r = n.propToComputedMap;
@@ -632,7 +642,7 @@ var X = class e extends m {
632
642
  let a = t.computed;
633
643
  for (let t of a.matchAll(w)) {
634
644
  let r = N(t[0]);
635
- this[r] === void 0 && this.#I(null, e, r);
645
+ this[r] === void 0 && this.#z(null, e, r);
636
646
  let o = H(r), s = !1;
637
647
  for (let [e, t] of Object.entries(n.properties)) J(t.usedBy)?.includes(o) && (i(e, a), s = !0);
638
648
  !s && typeof this[r] != "function" && i(r, a);
@@ -643,7 +653,7 @@ var X = class e extends m {
643
653
  for (let [e, t] of Object.entries(n.properties)) J(t.usedBy)?.includes(r) && i(e, a);
644
654
  }
645
655
  }
646
- #M(e, t) {
656
+ #F(e, t) {
647
657
  this.#t.add(e);
648
658
  try {
649
659
  this[e] = t;
@@ -651,9 +661,9 @@ var X = class e extends m {
651
661
  this.#t.delete(e);
652
662
  }
653
663
  }
654
- #N(e, t, n = void 0) {
664
+ #I(e, t, n = void 0) {
655
665
  if (!e) return;
656
- let r = this.#G(t, n, e);
666
+ let r = this.#J(t, n, e);
657
667
  if (!r) {
658
668
  let r = e.replaceAll("this..", "this.");
659
669
  n ? q(t, n, r) : "textContent" in t && (t.textContent = r);
@@ -674,13 +684,13 @@ var X = class e extends m {
674
684
  a || (a = [], this.#r.set(e, a)), a.push(n ? {
675
685
  element: t,
676
686
  attrName: n
677
- } : t), t instanceof HTMLElement && this.#S(t, n, r);
678
- let o = this.#v(e);
679
- n ? q(t, n, o) : this.#V(t, o);
687
+ } : t), t instanceof HTMLElement && this.#T(t, n, r);
688
+ let o = this.#x(e);
689
+ n ? q(t, n, o) : this.#W(t, o);
680
690
  }
681
- #P(e, t) {
691
+ #L(e, t) {
682
692
  let n = t?.trim() ?? "", r = this.#n.properties[n];
683
- r || this.#I(e, "ref", n), r.type !== m && this.#F(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this[n] && this.#F(e, "ref", `is a duplicate reference to the property "${n}"`), this[n] = e, e.removeAttribute("ref");
693
+ r || this.#z(e, "ref", n), r.type !== m && this.#R(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this[n] && this.#R(e, "ref", `is a duplicate reference to the property "${n}"`), this[n] = e, e.removeAttribute("ref");
684
694
  }
685
695
  setAttributeSafe(e, t) {
686
696
  this.hasAttribute(e) || this.setAttribute(e, t);
@@ -691,24 +701,24 @@ var X = class e extends m {
691
701
  static ssr(e = {}) {
692
702
  throw new g("SSR is not available in the browser build.");
693
703
  }
694
- #F(e, t, n) {
704
+ #R(e, t, n) {
695
705
  let r = e instanceof HTMLElement ? e.localName : "CSS rule";
696
706
  throw new g(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
697
707
  }
698
- #I(e, t, n) {
699
- this.#F(e, t, `refers to missing property "${n}"`);
708
+ #z(e, t, n) {
709
+ this.#R(e, t, `refers to missing property "${n}"`);
700
710
  }
701
- #L(e, t) {
702
- return this.#R(e, this.getAttribute(t));
711
+ #B(e, t) {
712
+ return this.#V(e, this.getAttribute(t));
703
713
  }
704
- #R(t, n) {
714
+ #V(t, n) {
705
715
  if (n?.match(w)) return n;
706
716
  let r = this.#n.properties[t], { type: i, values: a } = r;
707
- if (i || this.#F(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : k(r);
717
+ if (i || this.#R(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : k(r);
708
718
  if (i === String) {
709
719
  if (a && !a.includes(n)) {
710
720
  let e = a.map((e) => `"${e}"`).join(", ");
711
- this.#F(null, t, `must be one of ${e}`);
721
+ this.#R(null, t, `must be one of ${e}`);
712
722
  }
713
723
  return n;
714
724
  }
@@ -717,25 +727,25 @@ var X = class e extends m {
717
727
  if (n === "true") return !0;
718
728
  if (n === "false" || n === "null") return !1;
719
729
  let r = e.getAttrName(t);
720
- return n && n !== r && this.#F(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
730
+ return n && n !== r && this.#R(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
721
731
  }
722
732
  }
723
- #z(e, t, n, r) {
724
- R(n) && !this.#T(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#L(e, r)) && K(this, r || e, n);
733
+ #H(e, t, n, r) {
734
+ R(n) && !this.#O(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#B(e, r)) && K(this, r || e, n);
725
735
  }
726
- #B(e) {
727
- for (let [t, n] of this.#x([e])) this.#M(t, this.#v(n));
736
+ #U(e) {
737
+ for (let [t, n] of this.#w([e])) this.#F(t, this.#x(n));
728
738
  }
729
- #V(e, t) {
739
+ #W(e, t) {
730
740
  if (t === void 0) return;
731
741
  let n = e instanceof HTMLElement;
732
742
  Array.isArray(t) && (t = t.join(""));
733
743
  let r = typeof t;
734
- r !== "string" && r !== "number" && this.#F(e, void 0, " computed content is not a string or number");
744
+ r !== "string" && r !== "number" && this.#R(e, void 0, " computed content is not a string or number");
735
745
  let i = String(t);
736
- e instanceof HTMLElement && B(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#J(e), this.#E(e)) : n && (e.textContent = i);
746
+ e instanceof HTMLElement && B(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#Q(e), this.#A(e)) : n && (e.textContent = i);
737
747
  }
738
- #H(e, t) {
748
+ #G(e, t) {
739
749
  let n = this.#c.get(e);
740
750
  if (!n) return;
741
751
  let r = this.getRootNode();
@@ -745,7 +755,7 @@ var X = class e extends m {
745
755
  let a = i;
746
756
  a[n] = t;
747
757
  }
748
- #U() {
758
+ #K() {
749
759
  let e = this.#n, t = (e, t, n) => {
750
760
  let r = e.get(t);
751
761
  r || (r = [], e.set(t, r)), r.includes(n) || r.push(n);
@@ -779,15 +789,15 @@ var X = class e extends m {
779
789
  t = {};
780
790
  for (let n of Object.keys(e)) t[n] = n;
781
791
  }
782
- this.#K(e, t);
783
- for (let [n, r] of Object.entries(t)) if (this.#w(r)) {
792
+ this.#Y(e, t);
793
+ for (let [n, r] of Object.entries(t)) if (this.#D(r)) {
784
794
  let t = o(e, n);
785
795
  t !== void 0 && (this[r] = t), this.#l.set(r, {
786
796
  state: e,
787
797
  stateProp: n
788
798
  });
789
799
  }
790
- let n = this.#u.get(e), r = {
800
+ let n = this.#f.get(e), r = {
791
801
  ...n?.map,
792
802
  ...t
793
803
  };
@@ -796,55 +806,60 @@ var X = class e extends m {
796
806
  let n = r[e];
797
807
  n && (this[n] = t);
798
808
  }, Object.keys(r));
799
- this.#u.set(e, {
809
+ this.#f.set(e, {
800
810
  map: r,
801
811
  unsubscribe: i
802
812
  });
803
813
  }
804
- #W() {
814
+ #q() {
805
815
  let t = new Set(Object.keys(this.#n.properties));
806
816
  for (let n of this.getAttributeNames()) if (!p.has(n) && !n.startsWith("on") && n !== "ref") {
807
817
  if (n === "form-assoc") {
808
- this.#D();
818
+ this.#Z();
809
819
  continue;
810
820
  }
811
821
  if (!t.has(e.getPropName(n))) {
812
822
  if (n === "name") {
813
- this.#D();
823
+ this.#Z();
814
824
  continue;
815
825
  }
816
- this.#F(null, n, "is not a supported attribute");
826
+ this.#R(null, n, "is not a supported attribute");
817
827
  }
818
828
  }
819
829
  }
820
- #G(e, t, n) {
830
+ #J(e, t, n) {
821
831
  let r = n.match(w);
822
832
  if (r) return r.forEach((n) => {
823
833
  let r = N(n);
824
- this[r] === void 0 && this.#I(e, t, r);
834
+ this[r] === void 0 && this.#z(e, t, r);
825
835
  }), r;
826
836
  }
827
- #K(e, t) {
837
+ #Y(e, t) {
828
838
  for (let [n, r] of Object.entries(t)) {
829
839
  let t = o(e, n);
830
- t === void 0 && this.#F(this, void 0, `invalid state path "${n}"`), t = this[r], this.#w(r) || this.#F(null, r, "refers to missing property in useState map");
840
+ t === void 0 && this.#R(this, void 0, `invalid state path "${n}"`), t = this[r], this.#D(r) || this.#R(null, r, "refers to missing property in useState map");
831
841
  }
832
842
  }
833
- #q(e, t, n) {
843
+ #X(e, t, n) {
834
844
  let { values: r } = this.#n.properties[e];
835
845
  if (r) {
836
846
  let i;
837
- 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.#F(null, e, 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.#R(null, e, i);
838
848
  }
839
849
  if (n instanceof t) return;
840
850
  let i = typeof n;
841
851
  if (i === "object") {
842
852
  let { constructor: r } = n;
843
- i = r.name, r !== t && this.#F(null, e, `was set to a ${i}, but must be a ${t.name}`);
853
+ i = r.name, r !== t && this.#R(null, e, `was set to a ${i}, but must be a ${t.name}`);
844
854
  }
845
- i !== t.name.toLowerCase() && this.#F(null, e, `was set to a ${i}, but must be a ${t.name}`);
855
+ i !== t.name.toLowerCase() && this.#R(null, e, `was set to a ${i}, but must be a ${t.name}`);
856
+ }
857
+ #Z() {
858
+ if (this.#n.formAssociated || this.closest("form") === null) return;
859
+ let e = this.#n.name;
860
+ this.#R(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
846
861
  }
847
- #J(e) {
862
+ #Q(e) {
848
863
  let t = Array.from(e.querySelectorAll("*"));
849
864
  for (let e of t) {
850
865
  let t = [];
@@ -854,9 +869,9 @@ var X = class e extends m {
854
869
  let i = r.slice(2);
855
870
  i = i[0].toLowerCase() + i.slice(1).toLowerCase();
856
871
  let a = n.value;
857
- this.#G(e, r, a);
872
+ this.#J(e, r, a);
858
873
  let o;
859
- typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#G(e, r, a), o = () => this.#v(a)), e.addEventListener(i, o), t.push(r);
874
+ typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#J(e, r, a), o = () => this.#x(a)), e.addEventListener(i, o), t.push(r);
860
875
  }
861
876
  }
862
877
  for (let n of t) e.removeAttribute(n);
@@ -1,4 +1,4 @@
1
- import { a as e, i as t, n, r, t as i } from "./wrec-Cpci7nM6.js";
1
+ import { a as e, i as t, n, r, t as i } from "./wrec-BL9AvT9R.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.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, i as t, n, r, t as i } from "./wrec-Cpci7nM6.js";
1
+ import { a as e, i as t, n, r, t as i } from "./wrec-BL9AvT9R.js";
2
2
  export { i as Wrec, e as WrecState, n as createElement, r as css, t as html };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "wrec",
3
3
  "description": "a small library that greatly simplifies building web components",
4
4
  "author": "R. Mark Volkmann",
5
- "version": "0.32.1",
5
+ "version": "0.33.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",