wrec 0.28.0 → 0.29.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-S6tBBntE.js → wrec-DdxbuCnt.js} +114 -98
- package/dist/wrec-ssr.d.ts +92 -0
- package/dist/wrec-ssr.es.js +1 -1
- package/dist/wrec.d.ts +92 -0
- package/dist/wrec.es.js +1 -1
- package/package.json +1 -1
|
@@ -286,13 +286,13 @@ var U = class e extends p {
|
|
|
286
286
|
constructor() {
|
|
287
287
|
super(), this.attachShadow({ mode: "open" });
|
|
288
288
|
let e = this.#n;
|
|
289
|
-
this.#
|
|
289
|
+
this.#S("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#S("properties") || (e.properties = {}), this.#S("propToAttrMap") || (e.propToAttrMap = /* @__PURE__ */ new Map()), this.#S("propToComputedMap") || (e.propToComputedMap = /* @__PURE__ */ new Map()), this.#S("propToExprsMap") || (e.propToExprsMap = /* @__PURE__ */ new Map());
|
|
290
290
|
}
|
|
291
291
|
attributeChangedCallback(t, n, r) {
|
|
292
292
|
t === "disabled" && this.#h();
|
|
293
293
|
let i = e.getPropName(t);
|
|
294
|
-
if (!this.#
|
|
295
|
-
let e = this.#
|
|
294
|
+
if (!this.#w(i) && this.#C(i)) {
|
|
295
|
+
let e = this.#I(i, r);
|
|
296
296
|
this[i] = e;
|
|
297
297
|
let t = this.#i[i];
|
|
298
298
|
t && this.setFormValue(t, String(e));
|
|
@@ -306,24 +306,11 @@ var U = class e extends p {
|
|
|
306
306
|
let e = t.get(r) ?? [];
|
|
307
307
|
for (let t of e) n.add(t);
|
|
308
308
|
}
|
|
309
|
-
let r = this.#
|
|
310
|
-
for (let
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
for (let e of i) {
|
|
315
|
-
let r = a[e];
|
|
316
|
-
this.#k(e, this.#v(r));
|
|
317
|
-
let i = t.get(e) ?? [];
|
|
318
|
-
for (let e of i) n.add(e);
|
|
319
|
-
}
|
|
320
|
-
for (;;) {
|
|
321
|
-
let e = !1;
|
|
322
|
-
for (let t of i) {
|
|
323
|
-
let n = a[t], r = this.#v(n), i = this[t];
|
|
324
|
-
JSON.stringify(r) !== JSON.stringify(i) && (this.#k(t, r), e = !0);
|
|
325
|
-
}
|
|
326
|
-
if (!e) break;
|
|
309
|
+
let r = this.#b(Object.keys(e));
|
|
310
|
+
for (let [e, i] of r) {
|
|
311
|
+
this.#A(e, this.#v(i));
|
|
312
|
+
let r = t.get(e) ?? [];
|
|
313
|
+
for (let e of r) n.add(e);
|
|
327
314
|
}
|
|
328
315
|
this.#_([...n]), this.#e = !1;
|
|
329
316
|
}
|
|
@@ -342,11 +329,11 @@ var U = class e extends p {
|
|
|
342
329
|
this[t] = n;
|
|
343
330
|
}
|
|
344
331
|
async connectedCallback() {
|
|
345
|
-
this.#
|
|
332
|
+
this.#H(), this.#p(), await this.#d(), this.hasAttribute("disabled") && this.#h(), this.#K(this.shadowRoot), this.#T(this.shadowRoot), this.#V(), this.#f(), this.ready();
|
|
346
333
|
}
|
|
347
334
|
#f() {
|
|
348
335
|
let { properties: e } = this.#n;
|
|
349
|
-
for (let [t, { computed: n }] of Object.entries(e)) n && this.#
|
|
336
|
+
for (let [t, { computed: n }] of Object.entries(e)) n && this.#A(t, this.#v(n));
|
|
350
337
|
}
|
|
351
338
|
#p() {
|
|
352
339
|
let { observedAttributes: e, properties: t } = this.#n;
|
|
@@ -356,22 +343,22 @@ var U = class e extends p {
|
|
|
356
343
|
#m(t, n, r) {
|
|
357
344
|
if (t === "class" || t === "style") throw new h(`"${t}" is a reserved property`);
|
|
358
345
|
let i = e.getAttrName(t), a = this.hasAttribute(i);
|
|
359
|
-
n.required && !a && this.#
|
|
346
|
+
n.required && !a && this.#N(this, i, "is a required attribute");
|
|
360
347
|
let o = n.value;
|
|
361
348
|
this.hasOwnProperty(t) && (o = this[t], delete this[t]);
|
|
362
|
-
let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#
|
|
363
|
-
this[u] = l, n.computed && this.#
|
|
349
|
+
let { type: c } = n, l = c === Boolean ? o || a : r.includes(i) && a ? this.#F(t, i) : o ?? O(n), u = "#" + t;
|
|
350
|
+
this[u] = l, n.computed && this.#k(t, n), Object.defineProperty(this, t, {
|
|
364
351
|
enumerable: !0,
|
|
365
352
|
get() {
|
|
366
353
|
return this[u];
|
|
367
354
|
},
|
|
368
355
|
set(e) {
|
|
369
|
-
n.computed && !this.#t.has(t) && this.#
|
|
356
|
+
n.computed && !this.#t.has(t) && this.#N(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e = R(e));
|
|
370
357
|
let r = this[u];
|
|
371
358
|
if (e === r) return;
|
|
372
|
-
this.#
|
|
359
|
+
this.#G(t, c, e), this[u] = e;
|
|
373
360
|
let a = this.#l.get(t);
|
|
374
|
-
a && s(a.state, a.stateProp, e), this.#
|
|
361
|
+
a && s(a.state, a.stateProp, e), this.#L(t, c, e, i), this.#e || (this.#R(t), this.#O(t)), this.#B(t, e);
|
|
375
362
|
let o = this.#i[t];
|
|
376
363
|
o && this.setFormValue(o, String(e)), this.propertyChangedCallback(t, r, e), n.dispatch && this.dispatch("change", {
|
|
377
364
|
tagName: this.localName,
|
|
@@ -405,17 +392,17 @@ var U = class e extends p {
|
|
|
405
392
|
for (let r of t.getAttributeNames()) {
|
|
406
393
|
let i = t.getAttribute(r);
|
|
407
394
|
if (r === "ref") {
|
|
408
|
-
this.#
|
|
395
|
+
this.#M(t, i);
|
|
409
396
|
continue;
|
|
410
397
|
}
|
|
411
|
-
let a = this.#
|
|
398
|
+
let a = this.#D(t, i);
|
|
412
399
|
if (a) {
|
|
413
400
|
let i = this[a];
|
|
414
|
-
i === void 0 && this.#
|
|
415
|
-
let [o, s] = r.split(":"), c = e.getPropName(o), l = this.#
|
|
416
|
-
n && t.#
|
|
401
|
+
i === void 0 && this.#P(t, r, a);
|
|
402
|
+
let [o, s] = r.split(":"), c = e.getPropName(o), l = this.#w(a);
|
|
403
|
+
n && t.#w(c) || (t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#N(t, r, "refers to an unsupported event name"), t.setAttribute(o, this[a])) : s = "change"), n && !l && t.#c.set(e.getPropName(o), a);
|
|
417
404
|
}
|
|
418
|
-
this.#
|
|
405
|
+
this.#j(i, t, r);
|
|
419
406
|
}
|
|
420
407
|
}
|
|
421
408
|
#_(e) {
|
|
@@ -427,7 +414,7 @@ var U = class e extends p {
|
|
|
427
414
|
r.add(t);
|
|
428
415
|
continue;
|
|
429
416
|
}
|
|
430
|
-
if (t instanceof HTMLElement) this.#
|
|
417
|
+
if (t instanceof HTMLElement) this.#z(t, e);
|
|
431
418
|
else if (!(t instanceof CSSStyleRule)) {
|
|
432
419
|
let { element: n, attrName: r } = t;
|
|
433
420
|
n instanceof CSSStyleRule ? n.style.setProperty(r, e) : B(n, r, e);
|
|
@@ -451,13 +438,13 @@ var U = class e extends p {
|
|
|
451
438
|
let t = Array.from(e.style);
|
|
452
439
|
for (let n of t) if (n.startsWith("--")) {
|
|
453
440
|
let t = e.style.getPropertyValue(n);
|
|
454
|
-
this.#
|
|
441
|
+
this.#j(t, e, n);
|
|
455
442
|
}
|
|
456
443
|
}
|
|
457
444
|
} else {
|
|
458
445
|
let t = "";
|
|
459
446
|
if (P(e)) {
|
|
460
|
-
this.#
|
|
447
|
+
this.#j(e.textContent, e);
|
|
461
448
|
let n = e.textContent?.match(b);
|
|
462
449
|
n && (t = n[1]);
|
|
463
450
|
} else {
|
|
@@ -465,8 +452,8 @@ var U = class e extends p {
|
|
|
465
452
|
n && (t = n.textContent?.trim() ?? "");
|
|
466
453
|
}
|
|
467
454
|
if (t) {
|
|
468
|
-
let n = this.#
|
|
469
|
-
n && P(e) ? e.textContent = this[n] : this.#
|
|
455
|
+
let n = this.#D(e, t);
|
|
456
|
+
n && P(e) ? e.textContent = this[n] : this.#j(t, e);
|
|
470
457
|
}
|
|
471
458
|
}
|
|
472
459
|
}
|
|
@@ -474,7 +461,7 @@ var U = class e extends p {
|
|
|
474
461
|
let e = this.getAttribute("form-assoc");
|
|
475
462
|
if (!e) {
|
|
476
463
|
let t = this.getAttribute("name");
|
|
477
|
-
if (t) if (this.#
|
|
464
|
+
if (t) if (this.#C("value")) e = `value:${t}`;
|
|
478
465
|
else return;
|
|
479
466
|
else return;
|
|
480
467
|
}
|
|
@@ -502,59 +489,89 @@ var U = class e extends p {
|
|
|
502
489
|
let t = this.propToAttrMap.get(e);
|
|
503
490
|
return t || (t = e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), this.propToAttrMap.set(e, t)), t;
|
|
504
491
|
}
|
|
492
|
+
#b(e) {
|
|
493
|
+
let t = this.#n.propToComputedMap, n = /* @__PURE__ */ new Set(), r = {}, i = [...new Set(e)];
|
|
494
|
+
for (let e = 0; e < i.length; e++) {
|
|
495
|
+
let a = i[e], o = t.get(a) || [];
|
|
496
|
+
for (let [e, t] of o) r[e] = t, n.has(e) || (n.add(e), i.push(e));
|
|
497
|
+
}
|
|
498
|
+
let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
499
|
+
for (let e of n) a.set(e, 0);
|
|
500
|
+
for (let e of n) {
|
|
501
|
+
let r = t.get(e) || [];
|
|
502
|
+
for (let [t] of r) {
|
|
503
|
+
if (!n.has(t)) continue;
|
|
504
|
+
a.set(t, a.get(t) + 1);
|
|
505
|
+
let r = o.get(e);
|
|
506
|
+
r || (r = [], o.set(e, r)), r.push(t);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
let s = [...n].filter((e) => a.get(e) === 0), c = [];
|
|
510
|
+
for (let e = 0; e < s.length; e++) {
|
|
511
|
+
let t = s[e];
|
|
512
|
+
c.push(t);
|
|
513
|
+
let n = o.get(t) || [];
|
|
514
|
+
for (let e of n) {
|
|
515
|
+
let t = a.get(e) - 1;
|
|
516
|
+
a.set(e, t), t === 0 && s.push(e);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (c.length !== n.size) throw new h(`computed properties form a cycle: ${[...n].filter((e) => a.get(e) > 0).sort().join(", ")}`);
|
|
520
|
+
return c.map((e) => [e, r[e]]);
|
|
521
|
+
}
|
|
505
522
|
static getPropName(e) {
|
|
506
523
|
let t = this.attrToPropMap.get(e);
|
|
507
524
|
return t || (t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), this.attrToPropMap.set(e, t)), t;
|
|
508
525
|
}
|
|
509
|
-
#
|
|
526
|
+
#x(e, t, n) {
|
|
510
527
|
if (n.length !== 1) return;
|
|
511
528
|
let [r] = n;
|
|
512
529
|
if (!S.test(r)) return;
|
|
513
530
|
let i = F(e) || P(e), [a, o] = (t ?? "").split(":");
|
|
514
531
|
if (!(i && a === "value" || P(e))) return;
|
|
515
|
-
o ? e["on" + o] === void 0 && this.#
|
|
532
|
+
o ? e["on" + o] === void 0 && this.#N(e, t, "refers to an unsupported event name") : o = "change";
|
|
516
533
|
let s = j(r);
|
|
517
534
|
e.addEventListener(o, (e) => {
|
|
518
535
|
let { target: t } = e;
|
|
519
536
|
if (!t) return;
|
|
520
537
|
let n = t.value, { type: r } = this.#n.properties[s];
|
|
521
|
-
this[s] = r === Number ? R(n) : n, this.#
|
|
538
|
+
this[s] = r === Number ? R(n) : n, this.#O(s);
|
|
522
539
|
});
|
|
523
540
|
}
|
|
524
|
-
#
|
|
541
|
+
#S(e) {
|
|
525
542
|
return Object.hasOwn(this.#n, e);
|
|
526
543
|
}
|
|
527
|
-
#
|
|
544
|
+
#C(e) {
|
|
528
545
|
return !!this.#n.properties[e];
|
|
529
546
|
}
|
|
530
|
-
#
|
|
547
|
+
#w(e) {
|
|
531
548
|
return !!this.#n.properties[e]?.computed;
|
|
532
549
|
}
|
|
533
|
-
#
|
|
550
|
+
#T(e) {
|
|
534
551
|
let t = Array.from(e.querySelectorAll("*"));
|
|
535
552
|
for (let e of t) this.#g(e), e.firstElementChild || this.#y(e);
|
|
536
553
|
}
|
|
537
|
-
#
|
|
554
|
+
#E() {
|
|
538
555
|
if (this.#n.formAssociated || this.closest("form") === null) return;
|
|
539
556
|
let e = this.#n.name;
|
|
540
|
-
this.#
|
|
557
|
+
this.#N(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
|
|
541
558
|
}
|
|
542
559
|
static get observedAttributes() {
|
|
543
560
|
let t = Object.entries(this.properties || {}).filter(([e, t]) => !t.computed).map(([t]) => e.getAttrName(t));
|
|
544
561
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
545
562
|
}
|
|
546
563
|
propertyChangedCallback(e, t, n) {}
|
|
547
|
-
#
|
|
564
|
+
#D(e, t) {
|
|
548
565
|
if (!t || !S.test(t)) return;
|
|
549
566
|
let n = j(t);
|
|
550
|
-
return this[n] === void 0 && this.#
|
|
567
|
+
return this[n] === void 0 && this.#P(e, "", n), n;
|
|
551
568
|
}
|
|
552
|
-
#
|
|
569
|
+
#O(e) {
|
|
553
570
|
let t = this.#n.propToExprsMap.get(e) || [];
|
|
554
571
|
this.#_(t);
|
|
555
572
|
}
|
|
556
573
|
ready() {}
|
|
557
|
-
#
|
|
574
|
+
#k(e, t) {
|
|
558
575
|
let n = this.#n, r = n.propToComputedMap;
|
|
559
576
|
function i(t, n) {
|
|
560
577
|
let i = r.get(t);
|
|
@@ -563,7 +580,7 @@ var U = class e extends p {
|
|
|
563
580
|
let { computed: a } = t, o = a.match(C) || [];
|
|
564
581
|
for (let t of o) {
|
|
565
582
|
let n = j(t);
|
|
566
|
-
this[n] === void 0 && this.#
|
|
583
|
+
this[n] === void 0 && this.#P(null, e, n), typeof this[n] != "function" && i(n, a);
|
|
567
584
|
}
|
|
568
585
|
for (let t of a.matchAll(y)) {
|
|
569
586
|
let r = t[1];
|
|
@@ -571,7 +588,7 @@ var U = class e extends p {
|
|
|
571
588
|
for (let [e, t] of Object.entries(n.properties)) V(t.usedBy)?.includes(r) && i(e, a);
|
|
572
589
|
}
|
|
573
590
|
}
|
|
574
|
-
#
|
|
591
|
+
#A(e, t) {
|
|
575
592
|
this.#t.add(e);
|
|
576
593
|
try {
|
|
577
594
|
this[e] = t;
|
|
@@ -579,9 +596,9 @@ var U = class e extends p {
|
|
|
579
596
|
this.#t.delete(e);
|
|
580
597
|
}
|
|
581
598
|
}
|
|
582
|
-
#
|
|
599
|
+
#j(e, t, n = void 0) {
|
|
583
600
|
if (!e) return;
|
|
584
|
-
let r = this.#
|
|
601
|
+
let r = this.#U(t, n, e);
|
|
585
602
|
if (!r) {
|
|
586
603
|
let r = e.replaceAll("this..", "this.");
|
|
587
604
|
n ? B(t, n, r) : "textContent" in t && (t.textContent = r);
|
|
@@ -602,13 +619,13 @@ var U = class e extends p {
|
|
|
602
619
|
a || (a = [], this.#r.set(e, a)), a.push(n ? {
|
|
603
620
|
element: t,
|
|
604
621
|
attrName: n
|
|
605
|
-
} : t), t instanceof HTMLElement && this.#
|
|
622
|
+
} : t), t instanceof HTMLElement && this.#x(t, n, r);
|
|
606
623
|
let o = this.#v(e);
|
|
607
|
-
n ? B(t, n, o) : this.#
|
|
624
|
+
n ? B(t, n, o) : this.#z(t, o);
|
|
608
625
|
}
|
|
609
|
-
#
|
|
626
|
+
#M(e, t) {
|
|
610
627
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
611
|
-
r || this.#
|
|
628
|
+
r || this.#P(e, "ref", n), r.type !== p && this.#N(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this[n] && this.#N(e, "ref", `is a duplicate reference to the property "${n}"`), this[n] = e, e.removeAttribute("ref");
|
|
612
629
|
}
|
|
613
630
|
setAttributeSafe(e, t) {
|
|
614
631
|
this.hasAttribute(e) || this.setAttribute(e, t);
|
|
@@ -619,24 +636,24 @@ var U = class e extends p {
|
|
|
619
636
|
static ssr(e = {}) {
|
|
620
637
|
throw new h("SSR is not available in the browser build.");
|
|
621
638
|
}
|
|
622
|
-
#
|
|
639
|
+
#N(e, t, n) {
|
|
623
640
|
let r = e instanceof HTMLElement ? e.localName : "CSS rule";
|
|
624
641
|
throw new h(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
|
|
625
642
|
}
|
|
626
|
-
#
|
|
627
|
-
this.#
|
|
643
|
+
#P(e, t, n) {
|
|
644
|
+
this.#N(e, t, `refers to missing property "${n}"`);
|
|
628
645
|
}
|
|
629
|
-
#
|
|
630
|
-
return this.#
|
|
646
|
+
#F(e, t) {
|
|
647
|
+
return this.#I(e, this.getAttribute(t));
|
|
631
648
|
}
|
|
632
|
-
#
|
|
649
|
+
#I(t, n) {
|
|
633
650
|
if (n?.match(C)) return n;
|
|
634
651
|
let r = this.#n.properties[t], { type: i, values: a } = r;
|
|
635
|
-
if (i || this.#
|
|
652
|
+
if (i || this.#N(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : O(r);
|
|
636
653
|
if (i === String) {
|
|
637
654
|
if (a && !a.includes(n)) {
|
|
638
655
|
let e = a.map((e) => `"${e}"`).join(", ");
|
|
639
|
-
this.#
|
|
656
|
+
this.#N(null, t, `must be one of ${e}`);
|
|
640
657
|
}
|
|
641
658
|
return n;
|
|
642
659
|
}
|
|
@@ -645,26 +662,25 @@ var U = class e extends p {
|
|
|
645
662
|
if (n === "true") return !0;
|
|
646
663
|
if (n === "false" || n === "null") return !1;
|
|
647
664
|
let r = e.getAttrName(t);
|
|
648
|
-
return n && n !== r && this.#
|
|
665
|
+
return n && n !== r && this.#N(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
|
|
649
666
|
}
|
|
650
667
|
}
|
|
651
|
-
#
|
|
652
|
-
N(n) && !this.#
|
|
668
|
+
#L(e, t, n, r) {
|
|
669
|
+
N(n) && !this.#w(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#F(e, r)) && z(this, r || e, n);
|
|
653
670
|
}
|
|
654
|
-
#
|
|
655
|
-
let t
|
|
656
|
-
for (let [e, n] of t) this.#k(e, this.#v(n));
|
|
671
|
+
#R(e) {
|
|
672
|
+
for (let [t, n] of this.#b([e])) this.#A(t, this.#v(n));
|
|
657
673
|
}
|
|
658
|
-
#
|
|
674
|
+
#z(e, t) {
|
|
659
675
|
if (t === void 0) return;
|
|
660
676
|
let n = e instanceof HTMLElement;
|
|
661
677
|
Array.isArray(t) && (t = t.join(""));
|
|
662
678
|
let r = typeof t;
|
|
663
|
-
r !== "string" && r !== "number" && this.#
|
|
679
|
+
r !== "string" && r !== "number" && this.#N(e, void 0, " computed content is not a string or number");
|
|
664
680
|
let i = String(t);
|
|
665
|
-
e instanceof HTMLElement && P(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#
|
|
681
|
+
e instanceof HTMLElement && P(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#K(e), this.#T(e)) : n && (e.textContent = i);
|
|
666
682
|
}
|
|
667
|
-
#
|
|
683
|
+
#B(e, t) {
|
|
668
684
|
let n = this.#c.get(e);
|
|
669
685
|
if (!n) return;
|
|
670
686
|
let r = this.getRootNode();
|
|
@@ -674,7 +690,7 @@ var U = class e extends p {
|
|
|
674
690
|
let a = i;
|
|
675
691
|
a[n] = t;
|
|
676
692
|
}
|
|
677
|
-
#
|
|
693
|
+
#V() {
|
|
678
694
|
let e = this.#n;
|
|
679
695
|
function t() {
|
|
680
696
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -704,8 +720,8 @@ var U = class e extends p {
|
|
|
704
720
|
t = {};
|
|
705
721
|
for (let n of Object.keys(e)) t[n] = n;
|
|
706
722
|
}
|
|
707
|
-
this.#
|
|
708
|
-
for (let [n, r] of Object.entries(t)) if (this.#
|
|
723
|
+
this.#W(e, t);
|
|
724
|
+
for (let [n, r] of Object.entries(t)) if (this.#C(r)) {
|
|
709
725
|
let t = o(e, n);
|
|
710
726
|
t !== void 0 && (this[r] = t), this.#l.set(r, {
|
|
711
727
|
state: e,
|
|
@@ -726,50 +742,50 @@ var U = class e extends p {
|
|
|
726
742
|
unsubscribe: i
|
|
727
743
|
});
|
|
728
744
|
}
|
|
729
|
-
#
|
|
745
|
+
#H() {
|
|
730
746
|
let t = new Set(Object.keys(this.#n.properties));
|
|
731
747
|
for (let n of this.getAttributeNames()) if (!f.has(n) && !n.startsWith("on") && n !== "ref") {
|
|
732
748
|
if (n === "form-assoc") {
|
|
733
|
-
this.#
|
|
749
|
+
this.#E();
|
|
734
750
|
continue;
|
|
735
751
|
}
|
|
736
752
|
if (!t.has(e.getPropName(n))) {
|
|
737
753
|
if (n === "name") {
|
|
738
|
-
this.#
|
|
754
|
+
this.#E();
|
|
739
755
|
continue;
|
|
740
756
|
}
|
|
741
|
-
this.#
|
|
757
|
+
this.#N(null, n, "is not a supported attribute");
|
|
742
758
|
}
|
|
743
759
|
}
|
|
744
760
|
}
|
|
745
|
-
#
|
|
761
|
+
#U(e, t, n) {
|
|
746
762
|
let r = n.match(C);
|
|
747
763
|
if (r) return r.forEach((n) => {
|
|
748
764
|
let r = j(n);
|
|
749
|
-
this[r] === void 0 && this.#
|
|
765
|
+
this[r] === void 0 && this.#P(e, t, r);
|
|
750
766
|
}), r;
|
|
751
767
|
}
|
|
752
|
-
#
|
|
768
|
+
#W(e, t) {
|
|
753
769
|
for (let [n, r] of Object.entries(t)) {
|
|
754
770
|
let t = o(e, n);
|
|
755
|
-
t === void 0 && this.#
|
|
771
|
+
t === void 0 && this.#N(this, void 0, `invalid state path "${n}"`), t = this[r], this.#C(r) || this.#N(null, r, "refers to missing property in useState map");
|
|
756
772
|
}
|
|
757
773
|
}
|
|
758
|
-
#
|
|
774
|
+
#G(e, t, n) {
|
|
759
775
|
let { values: r } = this.#n.properties[e];
|
|
760
776
|
if (r) {
|
|
761
777
|
let i;
|
|
762
|
-
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.#
|
|
778
|
+
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.#N(null, e, i);
|
|
763
779
|
}
|
|
764
780
|
if (n instanceof t) return;
|
|
765
781
|
let i = typeof n;
|
|
766
782
|
if (i === "object") {
|
|
767
783
|
let { constructor: r } = n;
|
|
768
|
-
i = r.name, r !== t && this.#
|
|
784
|
+
i = r.name, r !== t && this.#N(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
769
785
|
}
|
|
770
|
-
i !== t.name.toLowerCase() && this.#
|
|
786
|
+
i !== t.name.toLowerCase() && this.#N(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
771
787
|
}
|
|
772
|
-
#
|
|
788
|
+
#K(e) {
|
|
773
789
|
let t = Array.from(e.querySelectorAll("*"));
|
|
774
790
|
for (let e of t) {
|
|
775
791
|
let t = [];
|
|
@@ -779,9 +795,9 @@ var U = class e extends p {
|
|
|
779
795
|
let i = r.slice(2);
|
|
780
796
|
i = i[0].toLowerCase() + i.slice(1).toLowerCase();
|
|
781
797
|
let a = n.value;
|
|
782
|
-
this.#
|
|
798
|
+
this.#U(e, r, a);
|
|
783
799
|
let o;
|
|
784
|
-
typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#
|
|
800
|
+
typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#U(e, r, a), o = () => this.#v(a)), e.addEventListener(i, o), t.push(r);
|
|
785
801
|
}
|
|
786
802
|
}
|
|
787
803
|
for (let n of t) e.removeAttribute(n);
|
package/dist/wrec-ssr.d.ts
CHANGED
|
@@ -1 +1,93 @@
|
|
|
1
|
+
declare type AnyClass = new (...args: any[]) => any;
|
|
2
|
+
|
|
3
|
+
declare type ChangeCallback = (change: StateChange) => void;
|
|
4
|
+
|
|
5
|
+
export declare function createElement(name: string, attributes: StringToString, innerHTML: string): HTMLElement;
|
|
6
|
+
|
|
7
|
+
export declare function css(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
8
|
+
|
|
9
|
+
export declare function html(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
10
|
+
|
|
11
|
+
declare const HTMLElementBase: {
|
|
12
|
+
new (): HTMLElement;
|
|
13
|
+
prototype: HTMLElement;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare type LooseObject = Record<string, unknown>;
|
|
17
|
+
|
|
18
|
+
declare type PropertyConfig = {
|
|
19
|
+
computed?: string;
|
|
20
|
+
dispatch?: boolean;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
type: AnyClass;
|
|
23
|
+
usedBy?: string | string[];
|
|
24
|
+
value?: any;
|
|
25
|
+
values?: string[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
declare type StateChange = {
|
|
29
|
+
state: WrecState;
|
|
30
|
+
statePath: string;
|
|
31
|
+
oldValue: unknown;
|
|
32
|
+
newValue: unknown;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
declare type StringToAny = Record<string, any>;
|
|
36
|
+
|
|
37
|
+
declare type StringToString = Record<string, string>;
|
|
38
|
+
|
|
39
|
+
export declare abstract class Wrec extends HTMLElementBase {
|
|
40
|
+
#private;
|
|
41
|
+
private static attrToPropMap;
|
|
42
|
+
private static propToAttrMap;
|
|
43
|
+
static context: {};
|
|
44
|
+
static css: string;
|
|
45
|
+
private static elementName;
|
|
46
|
+
static formAssociated: boolean;
|
|
47
|
+
static html: string;
|
|
48
|
+
static properties: Record<string, PropertyConfig>;
|
|
49
|
+
private static propToComputedMap;
|
|
50
|
+
private static methodToExprsMap;
|
|
51
|
+
private static propToExprsMap;
|
|
52
|
+
private static template;
|
|
53
|
+
[key: string]: any;
|
|
54
|
+
static define(elementName: string): void;
|
|
55
|
+
constructor();
|
|
56
|
+
attributeChangedCallback(attrName: string, _oldValue: string | null, newValue: string | null): void;
|
|
57
|
+
batchSet(changes: StringToAny): void;
|
|
58
|
+
private static buildHTML;
|
|
59
|
+
changed(_statePath: string, componentProp: string, newValue: unknown): void;
|
|
60
|
+
connectedCallback(): Promise<void>;
|
|
61
|
+
disconnectedCallback(): void;
|
|
62
|
+
dispatch(name: string, detail: any): void;
|
|
63
|
+
displayIfSet(value: any, display?: string): string;
|
|
64
|
+
formAssociatedCallback(): void;
|
|
65
|
+
formResetCallback(): void;
|
|
66
|
+
private static getAttrName;
|
|
67
|
+
static getPropName(attrName: string): string;
|
|
68
|
+
static get observedAttributes(): string[];
|
|
69
|
+
propertyChangedCallback(_propName: string, _oldValue: unknown, _newValue: unknown): void;
|
|
70
|
+
ready(): void;
|
|
71
|
+
setAttributeSafe(name: string, value: string): void;
|
|
72
|
+
setFormValue(propName: string, value: string): void;
|
|
73
|
+
static ssr(properties?: StringToAny): string;
|
|
74
|
+
/**
|
|
75
|
+
* @param state - WrecState object
|
|
76
|
+
* @param map - object whose keys are state properties and
|
|
77
|
+
* whose values are component properties
|
|
78
|
+
*/
|
|
79
|
+
useState(state: WrecState, map?: StringToString): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare class WrecState {
|
|
83
|
+
#private;
|
|
84
|
+
static get(name: string): WrecState | undefined;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
constructor(name: string, persist: boolean, initial?: LooseObject);
|
|
87
|
+
subscribe(callback: ChangeCallback, paths?: string[]): () => void;
|
|
88
|
+
addProperty(propName: string, initialValue: unknown): void;
|
|
89
|
+
get id(): symbol;
|
|
90
|
+
log(): void;
|
|
91
|
+
}
|
|
92
|
+
|
|
1
93
|
export { }
|
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-DdxbuCnt.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
|
@@ -1 +1,93 @@
|
|
|
1
|
+
declare type AnyClass = new (...args: any[]) => any;
|
|
2
|
+
|
|
3
|
+
declare type ChangeCallback = (change: StateChange) => void;
|
|
4
|
+
|
|
5
|
+
export declare function createElement(name: string, attributes: StringToString, innerHTML: string): HTMLElement;
|
|
6
|
+
|
|
7
|
+
export declare function css(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
8
|
+
|
|
9
|
+
export declare function html(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
10
|
+
|
|
11
|
+
declare const HTMLElementBase: {
|
|
12
|
+
new (): HTMLElement;
|
|
13
|
+
prototype: HTMLElement;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare type LooseObject = Record<string, unknown>;
|
|
17
|
+
|
|
18
|
+
declare type PropertyConfig = {
|
|
19
|
+
computed?: string;
|
|
20
|
+
dispatch?: boolean;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
type: AnyClass;
|
|
23
|
+
usedBy?: string | string[];
|
|
24
|
+
value?: any;
|
|
25
|
+
values?: string[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
declare type StateChange = {
|
|
29
|
+
state: WrecState;
|
|
30
|
+
statePath: string;
|
|
31
|
+
oldValue: unknown;
|
|
32
|
+
newValue: unknown;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
declare type StringToAny = Record<string, any>;
|
|
36
|
+
|
|
37
|
+
declare type StringToString = Record<string, string>;
|
|
38
|
+
|
|
39
|
+
export declare abstract class Wrec extends HTMLElementBase {
|
|
40
|
+
#private;
|
|
41
|
+
private static attrToPropMap;
|
|
42
|
+
private static propToAttrMap;
|
|
43
|
+
static context: {};
|
|
44
|
+
static css: string;
|
|
45
|
+
private static elementName;
|
|
46
|
+
static formAssociated: boolean;
|
|
47
|
+
static html: string;
|
|
48
|
+
static properties: Record<string, PropertyConfig>;
|
|
49
|
+
private static propToComputedMap;
|
|
50
|
+
private static methodToExprsMap;
|
|
51
|
+
private static propToExprsMap;
|
|
52
|
+
private static template;
|
|
53
|
+
[key: string]: any;
|
|
54
|
+
static define(elementName: string): void;
|
|
55
|
+
constructor();
|
|
56
|
+
attributeChangedCallback(attrName: string, _oldValue: string | null, newValue: string | null): void;
|
|
57
|
+
batchSet(changes: StringToAny): void;
|
|
58
|
+
private static buildHTML;
|
|
59
|
+
changed(_statePath: string, componentProp: string, newValue: unknown): void;
|
|
60
|
+
connectedCallback(): Promise<void>;
|
|
61
|
+
disconnectedCallback(): void;
|
|
62
|
+
dispatch(name: string, detail: any): void;
|
|
63
|
+
displayIfSet(value: any, display?: string): string;
|
|
64
|
+
formAssociatedCallback(): void;
|
|
65
|
+
formResetCallback(): void;
|
|
66
|
+
private static getAttrName;
|
|
67
|
+
static getPropName(attrName: string): string;
|
|
68
|
+
static get observedAttributes(): string[];
|
|
69
|
+
propertyChangedCallback(_propName: string, _oldValue: unknown, _newValue: unknown): void;
|
|
70
|
+
ready(): void;
|
|
71
|
+
setAttributeSafe(name: string, value: string): void;
|
|
72
|
+
setFormValue(propName: string, value: string): void;
|
|
73
|
+
static ssr(properties?: StringToAny): string;
|
|
74
|
+
/**
|
|
75
|
+
* @param state - WrecState object
|
|
76
|
+
* @param map - object whose keys are state properties and
|
|
77
|
+
* whose values are component properties
|
|
78
|
+
*/
|
|
79
|
+
useState(state: WrecState, map?: StringToString): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare class WrecState {
|
|
83
|
+
#private;
|
|
84
|
+
static get(name: string): WrecState | undefined;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
constructor(name: string, persist: boolean, initial?: LooseObject);
|
|
87
|
+
subscribe(callback: ChangeCallback, paths?: string[]): () => void;
|
|
88
|
+
addProperty(propName: string, initialValue: unknown): void;
|
|
89
|
+
get id(): symbol;
|
|
90
|
+
log(): void;
|
|
91
|
+
}
|
|
92
|
+
|
|
1
93
|
export { }
|
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-DdxbuCnt.js";
|
|
2
2
|
export { i as Wrec, e as WrecState, n as createElement, r as css, t as html };
|