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