wrec 0.29.0 → 0.29.2
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-DHp2V7DA.js} +209 -178
- package/dist/wrec-ssr.d.ts +2 -0
- package/dist/wrec-ssr.es.js +1 -1
- package/dist/wrec.d.ts +2 -0
- package/dist/wrec.es.js +1 -1
- package/package.json +1 -1
|
@@ -151,85 +151,85 @@ function d(t) {
|
|
|
151
151
|
}
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/wrec.ts
|
|
154
|
-
var f = new Set([
|
|
154
|
+
var f = () => /* @__PURE__ */ new Map(), p = new Set([
|
|
155
155
|
"class",
|
|
156
156
|
"disabled",
|
|
157
157
|
"hidden",
|
|
158
158
|
"id",
|
|
159
159
|
"tabindex",
|
|
160
160
|
"title"
|
|
161
|
-
]),
|
|
161
|
+
]), m = globalThis.HTMLElement ?? class {}, h = globalThis.customElements ?? {
|
|
162
162
|
get: (e) => void 0,
|
|
163
163
|
getName: (e) => null,
|
|
164
164
|
define: () => {},
|
|
165
165
|
initialize: (e) => {},
|
|
166
166
|
upgrade: (e) => {},
|
|
167
167
|
whenDefined: () => Promise.reject(/* @__PURE__ */ Error("customElements is not available in this environment"))
|
|
168
|
-
},
|
|
169
|
-
function
|
|
170
|
-
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof
|
|
168
|
+
}, g = class extends Error {}, _ = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, v = "a-zA-Z_$", y = `[${v}][${v + "0-9"}]*`, b = RegExp(`this\\.(${y})\\s*\\(`, "g"), x = /<!--\s*(.*?)\s*-->/, S = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, C = RegExp(`^this\\.${y}$`), w = RegExp(`this\\.${y}(\\.${y})*`, "g"), T = RegExp(`this\\.${y}(\\.${y})*`), E = 5;
|
|
169
|
+
function D(e) {
|
|
170
|
+
return e instanceof HTMLButtonElement || e instanceof HTMLFieldSetElement || e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof W;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function O(e, t, n) {
|
|
173
173
|
let r = document.createElement(e);
|
|
174
174
|
if (t) for (let [e, n] of Object.entries(t)) r.setAttribute(e, n);
|
|
175
175
|
return n && (r.innerHTML = n), r;
|
|
176
176
|
}
|
|
177
|
-
var
|
|
178
|
-
function
|
|
177
|
+
var k = (e) => Array.isArray(e.values) && e.values.length > 0 ? e.values[0] : A(e.type), A = (e) => e === String ? "" : e === Number ? 0 : e === Boolean ? !1 : e === Array ? [] : e === Object ? {} : void 0;
|
|
178
|
+
function j(e) {
|
|
179
179
|
let t = [], n = e.firstElementChild;
|
|
180
|
-
for (; n;) t.push(n), n.shadowRoot && t.push(...
|
|
180
|
+
for (; n;) t.push(n), n.shadowRoot && t.push(...j(n.shadowRoot)), n.firstElementChild && t.push(...j(n)), n = n.nextElementSibling;
|
|
181
181
|
return t;
|
|
182
182
|
}
|
|
183
|
-
var
|
|
184
|
-
function
|
|
183
|
+
var M = (e) => e.substring(E).split(".")[0];
|
|
184
|
+
function N(e, t) {
|
|
185
185
|
let n = e[0];
|
|
186
186
|
return t.forEach((t, r) => {
|
|
187
187
|
n += t + e[r + 1];
|
|
188
188
|
}), n;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function P(e) {
|
|
191
191
|
let t = typeof e;
|
|
192
192
|
return t === "string" || t === "number" || t === "boolean";
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function F(e) {
|
|
195
195
|
return e.localName === "textarea";
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function I(e) {
|
|
198
198
|
let { localName: t } = e;
|
|
199
199
|
return t === "input" || t === "select";
|
|
200
200
|
}
|
|
201
|
-
var
|
|
202
|
-
function
|
|
201
|
+
var L = (e) => e.replace(/<!--[\s\S]*?-->/g, "");
|
|
202
|
+
function R(e, t, n, r) {
|
|
203
203
|
return e.slice(0, t) + r + e.slice(t + n);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function z(e) {
|
|
206
206
|
let t = Number(e);
|
|
207
|
-
if (isNaN(t)) throw new
|
|
207
|
+
if (isNaN(t)) throw new g(`can't convert "${e}" to a number`);
|
|
208
208
|
return t;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function B(e, t, n) {
|
|
211
211
|
let [r, i] = t.split(":");
|
|
212
|
-
if (
|
|
212
|
+
if (P(n)) if (typeof n == "boolean") {
|
|
213
213
|
n ? e.setAttribute(r, r) : e.removeAttribute(r);
|
|
214
|
-
let t =
|
|
214
|
+
let t = W.getPropName(r);
|
|
215
215
|
e[t] = n;
|
|
216
216
|
} else {
|
|
217
217
|
let i = e.getAttribute(t), a = String(n);
|
|
218
|
-
i !== a && (e.setAttribute(r, a), r === "value" &&
|
|
218
|
+
i !== a && (e.setAttribute(r, a), r === "value" && I(e) && (e.value = a));
|
|
219
219
|
}
|
|
220
220
|
else {
|
|
221
|
-
let r =
|
|
221
|
+
let r = W.getPropName(t);
|
|
222
222
|
e[r] = n;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function V(e, t, n) {
|
|
226
226
|
let [r, i] = t.split(":");
|
|
227
|
-
e instanceof CSSStyleRule ? e.style.setProperty(r, n) : (
|
|
227
|
+
e instanceof CSSStyleRule ? e.style.setProperty(r, n) : (B(e, r, n), r === "value" && I(e) && (e.value = n));
|
|
228
228
|
}
|
|
229
|
-
var
|
|
230
|
-
async function
|
|
229
|
+
var H = (e) => typeof e == "string" ? [e] : e;
|
|
230
|
+
async function U(e) {
|
|
231
231
|
let t = /* @__PURE__ */ new Set();
|
|
232
|
-
for (let n of
|
|
232
|
+
for (let n of j(e.content)) {
|
|
233
233
|
let { localName: e } = n;
|
|
234
234
|
e.includes("-") && t.add(e);
|
|
235
235
|
}
|
|
@@ -241,9 +241,9 @@ async function H(e) {
|
|
|
241
241
|
}, 1e3);
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
return Promise.all([...t].map(async (e) => Promise.race([
|
|
244
|
+
return Promise.all([...t].map(async (e) => Promise.race([h.whenDefined(e), n(e)])));
|
|
245
245
|
}
|
|
246
|
-
var
|
|
246
|
+
var W = class e extends m {
|
|
247
247
|
static {
|
|
248
248
|
this.attrToPropMap = /* @__PURE__ */ new Map();
|
|
249
249
|
}
|
|
@@ -280,19 +280,19 @@ var U = class e extends p {
|
|
|
280
280
|
#l = /* @__PURE__ */ new Map();
|
|
281
281
|
#u = /* @__PURE__ */ new Map();
|
|
282
282
|
static define(e) {
|
|
283
|
-
if (this.elementName = e,
|
|
284
|
-
|
|
283
|
+
if (this.elementName = e, h.get(e)) throw new g(`custom element ${e} is already defined`);
|
|
284
|
+
h.define(e, this);
|
|
285
285
|
}
|
|
286
286
|
constructor() {
|
|
287
287
|
super(), this.attachShadow({ mode: "open" });
|
|
288
288
|
let e = this.#n;
|
|
289
|
-
this.#
|
|
289
|
+
this.#C("attrToPropMap") || (e.attrToPropMap = /* @__PURE__ */ new Map()), this.#C("computedGraph") || (e.computedGraph = null), 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());
|
|
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.#T(i) && this.#w(i)) {
|
|
295
|
+
let e = this.#L(i, r);
|
|
296
296
|
this[i] = e;
|
|
297
297
|
let t = this.#i[i];
|
|
298
298
|
t && this.setFormValue(t, String(e));
|
|
@@ -306,47 +306,34 @@ 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.#x(Object.keys(e));
|
|
310
|
+
for (let [e, i] of r) {
|
|
311
|
+
this.#j(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
|
}
|
|
330
317
|
async #d() {
|
|
331
318
|
let e = this.#n, { template: t } = e;
|
|
332
|
-
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await
|
|
319
|
+
t || (t = e.template = document.createElement("template"), t.innerHTML = e.buildHTML()), await U(t), this.shadowRoot.replaceChildren(t.content.cloneNode(!0));
|
|
333
320
|
}
|
|
334
321
|
static buildHTML() {
|
|
335
322
|
let e = "<style>\n :host([hidden]) { display: none; }";
|
|
336
323
|
this.css && (e += this.css), e += "</style>\n";
|
|
337
324
|
let t = this.html.trim();
|
|
338
|
-
if (!t) throw new
|
|
325
|
+
if (!t) throw new g("static property html must be set");
|
|
339
326
|
return t.startsWith("<") || (t = `<span><!--${t}--></span>`), e + t;
|
|
340
327
|
}
|
|
341
328
|
changed(e, t, n) {
|
|
342
329
|
this[t] = n;
|
|
343
330
|
}
|
|
344
331
|
async connectedCallback() {
|
|
345
|
-
this.#
|
|
332
|
+
this.#U(), this.#p(), await this.#d(), this.hasAttribute("disabled") && this.#h(), this.#q(this.shadowRoot), this.#E(this.shadowRoot), this.#H(), 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.#j(t, this.#v(n));
|
|
350
337
|
}
|
|
351
338
|
#p() {
|
|
352
339
|
let { observedAttributes: e, properties: t } = this.#n;
|
|
@@ -354,24 +341,24 @@ var U = class e extends p {
|
|
|
354
341
|
for (let [n, r] of Object.entries(t)) r.computed && this.#m(n, r, e);
|
|
355
342
|
}
|
|
356
343
|
#m(t, n, r) {
|
|
357
|
-
if (t === "class" || t === "style") throw new
|
|
344
|
+
if (t === "class" || t === "style") throw new g(`"${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.#P(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.#I(t, i) : o ?? k(n), u = "#" + t;
|
|
350
|
+
this[u] = l, n.computed && this.#A(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.#P(null, t, "is a computed property and cannot be set directly"), c === Number && typeof e == "string" && (e = z(e));
|
|
370
357
|
let r = this[u];
|
|
371
358
|
if (e === r) return;
|
|
372
|
-
this.#
|
|
359
|
+
this.#K(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.#R(t, c, e, i), this.#e || (this.#z(t), this.#k(t)), this.#V(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,
|
|
@@ -383,8 +370,8 @@ var U = class e extends p {
|
|
|
383
370
|
});
|
|
384
371
|
}
|
|
385
372
|
#h() {
|
|
386
|
-
let e = this.hasAttribute("disabled"), t =
|
|
387
|
-
for (let n of t)
|
|
373
|
+
let e = this.hasAttribute("disabled"), t = j(this.shadowRoot);
|
|
374
|
+
for (let n of t) D(n) && (n.disabled = e);
|
|
388
375
|
}
|
|
389
376
|
disconnectedCallback() {
|
|
390
377
|
for (let { unsubscribe: e } of this.#u.values()) e();
|
|
@@ -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.#N(t, i);
|
|
409
396
|
continue;
|
|
410
397
|
}
|
|
411
|
-
let a = this.#
|
|
398
|
+
let a = this.#O(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.#F(t, r, a);
|
|
402
|
+
let [o, s] = r.split(":"), c = e.getPropName(o), l = this.#T(a);
|
|
403
|
+
n && t.#T(c) || (t[c] = i), o === "value" && (s ? (t["on" + s] === void 0 && this.#P(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.#M(i, t, r);
|
|
419
406
|
}
|
|
420
407
|
}
|
|
421
408
|
#_(e) {
|
|
@@ -427,10 +414,10 @@ 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.#B(t, e);
|
|
431
418
|
else if (!(t instanceof CSSStyleRule)) {
|
|
432
419
|
let { element: n, attrName: r } = t;
|
|
433
|
-
n instanceof CSSStyleRule ? n.style.setProperty(r, e) :
|
|
420
|
+
n instanceof CSSStyleRule ? n.style.setProperty(r, e) : V(n, r, e);
|
|
434
421
|
}
|
|
435
422
|
}
|
|
436
423
|
if (r.size > 0) {
|
|
@@ -451,22 +438,22 @@ 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.#M(t, e, n);
|
|
455
442
|
}
|
|
456
443
|
}
|
|
457
444
|
} else {
|
|
458
445
|
let t = "";
|
|
459
|
-
if (
|
|
460
|
-
this.#
|
|
461
|
-
let n = e.textContent?.match(
|
|
446
|
+
if (F(e)) {
|
|
447
|
+
this.#M(e.textContent, e);
|
|
448
|
+
let n = e.textContent?.match(x);
|
|
462
449
|
n && (t = n[1]);
|
|
463
450
|
} else {
|
|
464
451
|
let n = Array.from(e.childNodes).find((e) => e.nodeType === Node.COMMENT_NODE);
|
|
465
452
|
n && (t = n.textContent?.trim() ?? "");
|
|
466
453
|
}
|
|
467
454
|
if (t) {
|
|
468
|
-
let n = this.#
|
|
469
|
-
n &&
|
|
455
|
+
let n = this.#O(e, t);
|
|
456
|
+
n && F(e) ? e.textContent = this[n] : this.#M(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.#w("value")) e = `value:${t}`;
|
|
478
465
|
else return;
|
|
479
466
|
else return;
|
|
480
467
|
}
|
|
@@ -486,7 +473,7 @@ var U = class e extends p {
|
|
|
486
473
|
this.#i = t, this.#a = new FormData(), this.#s = this.attachInternals(), this.#s.setFormValue(this.#a);
|
|
487
474
|
for (let [e, n] of Object.entries(t)) {
|
|
488
475
|
let t = this[e];
|
|
489
|
-
|
|
476
|
+
P(t) && this.setFormValue(n, String(t));
|
|
490
477
|
}
|
|
491
478
|
let r = Object.keys(this.#n.properties), i = this.#o;
|
|
492
479
|
for (let e of r) i[e] = this[e];
|
|
@@ -495,83 +482,128 @@ var U = class e extends p {
|
|
|
495
482
|
let e = this.#o;
|
|
496
483
|
for (let t of Object.keys(e)) {
|
|
497
484
|
let n = e[t];
|
|
498
|
-
|
|
485
|
+
C.test(n) && (n = this.#v(n)), this[t] = n;
|
|
499
486
|
}
|
|
500
487
|
}
|
|
501
488
|
static getAttrName(e) {
|
|
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() {
|
|
493
|
+
let e = this.#n, t = e.computedGraph;
|
|
494
|
+
if (t) return t;
|
|
495
|
+
let n = f(), r = f(), i = {};
|
|
496
|
+
for (let t of e.registeredComputedProps) n.set(t, []);
|
|
497
|
+
for (let [t, a] of e.propToComputedMap) for (let [o, s] of a) {
|
|
498
|
+
if (i[o] = s, !e.registeredComputedProps.has(o) || (n.has(o) || n.set(o, []), !e.registeredComputedProps.has(t))) continue;
|
|
499
|
+
n.get(o).push(t);
|
|
500
|
+
let a = r.get(t);
|
|
501
|
+
a || (a = [], r.set(t, a)), a.push(o);
|
|
502
|
+
}
|
|
503
|
+
return t = {
|
|
504
|
+
computedToDependenciesMap: n,
|
|
505
|
+
computedToDependentsMap: r,
|
|
506
|
+
computedToExprMap: i
|
|
507
|
+
}, e.computedGraph = t, t;
|
|
508
|
+
}
|
|
509
|
+
#x(e) {
|
|
510
|
+
let { computedToDependenciesMap: t, computedToDependentsMap: n, computedToExprMap: r } = this.#b(), i = this.#n.propToComputedMap, a = /* @__PURE__ */ new Set(), o = [...new Set(e)];
|
|
511
|
+
for (let e = 0; e < o.length; e++) {
|
|
512
|
+
let t = o[e], n = i.get(t) || [];
|
|
513
|
+
for (let [e, t] of n) r[e] = t, a.has(e) || (a.add(e), o.push(e));
|
|
514
|
+
}
|
|
515
|
+
let s = [...a].filter((e) => (t.get(e) || []).filter((e) => a.has(e)).length === 0), c = [], l = /* @__PURE__ */ new Map();
|
|
516
|
+
for (let e of a) {
|
|
517
|
+
let n = t.get(e) || [], r = 0;
|
|
518
|
+
for (let e of n) a.has(e) && r++;
|
|
519
|
+
l.set(e, r);
|
|
520
|
+
}
|
|
521
|
+
for (let e = 0; e < s.length; e++) {
|
|
522
|
+
let t = s[e];
|
|
523
|
+
c.push(t);
|
|
524
|
+
let r = n.get(t) || [];
|
|
525
|
+
for (let e of r) {
|
|
526
|
+
if (!a.has(e)) continue;
|
|
527
|
+
let t = l.get(e) - 1;
|
|
528
|
+
l.set(e, t), t === 0 && s.push(e);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if (c.length !== a.size) throw new g(`computed properties form a cycle: ${[...a].filter((e) => l.get(e) > 0).sort().join(", ")}`);
|
|
532
|
+
return c.map((e) => [e, r[e]]);
|
|
533
|
+
}
|
|
505
534
|
static getPropName(e) {
|
|
506
535
|
let t = this.attrToPropMap.get(e);
|
|
507
536
|
return t || (t = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()), this.attrToPropMap.set(e, t)), t;
|
|
508
537
|
}
|
|
509
|
-
#
|
|
538
|
+
#S(e, t, n) {
|
|
510
539
|
if (n.length !== 1) return;
|
|
511
540
|
let [r] = n;
|
|
512
|
-
if (!
|
|
513
|
-
let i =
|
|
514
|
-
if (!(i && a === "value" ||
|
|
515
|
-
o ? e["on" + o] === void 0 && this.#
|
|
516
|
-
let s =
|
|
541
|
+
if (!C.test(r)) return;
|
|
542
|
+
let i = I(e) || F(e), [a, o] = (t ?? "").split(":");
|
|
543
|
+
if (!(i && a === "value" || F(e))) return;
|
|
544
|
+
o ? e["on" + o] === void 0 && this.#P(e, t, "refers to an unsupported event name") : o = "change";
|
|
545
|
+
let s = M(r);
|
|
517
546
|
e.addEventListener(o, (e) => {
|
|
518
547
|
let { target: t } = e;
|
|
519
548
|
if (!t) return;
|
|
520
549
|
let n = t.value, { type: r } = this.#n.properties[s];
|
|
521
|
-
this[s] = r === Number ?
|
|
550
|
+
this[s] = r === Number ? z(n) : n, this.#k(s);
|
|
522
551
|
});
|
|
523
552
|
}
|
|
524
|
-
#
|
|
553
|
+
#C(e) {
|
|
525
554
|
return Object.hasOwn(this.#n, e);
|
|
526
555
|
}
|
|
527
|
-
#
|
|
556
|
+
#w(e) {
|
|
528
557
|
return !!this.#n.properties[e];
|
|
529
558
|
}
|
|
530
|
-
#
|
|
559
|
+
#T(e) {
|
|
531
560
|
return !!this.#n.properties[e]?.computed;
|
|
532
561
|
}
|
|
533
|
-
#
|
|
562
|
+
#E(e) {
|
|
534
563
|
let t = Array.from(e.querySelectorAll("*"));
|
|
535
564
|
for (let e of t) this.#g(e), e.firstElementChild || this.#y(e);
|
|
536
565
|
}
|
|
537
|
-
#
|
|
566
|
+
#D() {
|
|
538
567
|
if (this.#n.formAssociated || this.closest("form") === null) return;
|
|
539
568
|
let e = this.#n.name;
|
|
540
|
-
this.#
|
|
569
|
+
this.#P(this, void 0, `inside form, class ${e} requires "static formAssociated = true;"`);
|
|
541
570
|
}
|
|
542
571
|
static get observedAttributes() {
|
|
543
572
|
let t = Object.entries(this.properties || {}).filter(([e, t]) => !t.computed).map(([t]) => e.getAttrName(t));
|
|
544
573
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
545
574
|
}
|
|
546
575
|
propertyChangedCallback(e, t, n) {}
|
|
547
|
-
#
|
|
548
|
-
if (!t || !
|
|
549
|
-
let n =
|
|
550
|
-
return this[n] === void 0 && this.#
|
|
576
|
+
#O(e, t) {
|
|
577
|
+
if (!t || !C.test(t)) return;
|
|
578
|
+
let n = M(t);
|
|
579
|
+
return this[n] === void 0 && this.#F(e, "", n), n;
|
|
551
580
|
}
|
|
552
|
-
#
|
|
581
|
+
#k(e) {
|
|
553
582
|
let t = this.#n.propToExprsMap.get(e) || [];
|
|
554
583
|
this.#_(t);
|
|
555
584
|
}
|
|
556
585
|
ready() {}
|
|
557
|
-
#
|
|
558
|
-
let n = this.#n
|
|
586
|
+
#A(e, t) {
|
|
587
|
+
let n = this.#n;
|
|
588
|
+
if (n.registeredComputedProps.has(e)) return;
|
|
589
|
+
n.registeredComputedProps.add(e), n.computedGraph = null;
|
|
590
|
+
let r = n.propToComputedMap;
|
|
559
591
|
function i(t, n) {
|
|
560
592
|
let i = r.get(t);
|
|
561
593
|
i || (i = [], r.set(t, i)), i.push([e, n]);
|
|
562
594
|
}
|
|
563
|
-
let { computed: a } = t, o = a.match(
|
|
595
|
+
let { computed: a } = t, o = a.match(w) || [];
|
|
564
596
|
for (let t of o) {
|
|
565
|
-
let n =
|
|
566
|
-
this[n] === void 0 && this.#
|
|
597
|
+
let n = M(t);
|
|
598
|
+
this[n] === void 0 && this.#F(null, e, n), typeof this[n] != "function" && i(n, a);
|
|
567
599
|
}
|
|
568
|
-
for (let t of a.matchAll(
|
|
600
|
+
for (let t of a.matchAll(b)) {
|
|
569
601
|
let r = t[1];
|
|
570
|
-
if (typeof this[r] != "function") throw new
|
|
571
|
-
for (let [e, t] of Object.entries(n.properties))
|
|
602
|
+
if (typeof this[r] != "function") throw new g(`property ${e} computed calls non-method ${r}`);
|
|
603
|
+
for (let [e, t] of Object.entries(n.properties)) H(t.usedBy)?.includes(r) && i(e, a);
|
|
572
604
|
}
|
|
573
605
|
}
|
|
574
|
-
#
|
|
606
|
+
#j(e, t) {
|
|
575
607
|
this.#t.add(e);
|
|
576
608
|
try {
|
|
577
609
|
this[e] = t;
|
|
@@ -579,17 +611,17 @@ var U = class e extends p {
|
|
|
579
611
|
this.#t.delete(e);
|
|
580
612
|
}
|
|
581
613
|
}
|
|
582
|
-
#
|
|
614
|
+
#M(e, t, n = void 0) {
|
|
583
615
|
if (!e) return;
|
|
584
|
-
let r = this.#
|
|
616
|
+
let r = this.#W(t, n, e);
|
|
585
617
|
if (!r) {
|
|
586
618
|
let r = e.replaceAll("this..", "this.");
|
|
587
|
-
n ?
|
|
619
|
+
n ? V(t, n, r) : "textContent" in t && (t.textContent = r);
|
|
588
620
|
return;
|
|
589
621
|
}
|
|
590
622
|
let i = this.#n;
|
|
591
623
|
r.forEach((t) => {
|
|
592
|
-
let n =
|
|
624
|
+
let n = M(t);
|
|
593
625
|
if (typeof this[n] == "function") return;
|
|
594
626
|
let r = i.propToExprsMap, a = r.get(n);
|
|
595
627
|
a || (a = [], r.set(n, a)), a.includes(e) || a.push(e);
|
|
@@ -602,69 +634,68 @@ var U = class e extends p {
|
|
|
602
634
|
a || (a = [], this.#r.set(e, a)), a.push(n ? {
|
|
603
635
|
element: t,
|
|
604
636
|
attrName: n
|
|
605
|
-
} : t), t instanceof HTMLElement && this.#
|
|
637
|
+
} : t), t instanceof HTMLElement && this.#S(t, n, r);
|
|
606
638
|
let o = this.#v(e);
|
|
607
|
-
n ?
|
|
639
|
+
n ? V(t, n, o) : this.#B(t, o);
|
|
608
640
|
}
|
|
609
|
-
#
|
|
641
|
+
#N(e, t) {
|
|
610
642
|
let n = t?.trim() ?? "", r = this.#n.properties[n];
|
|
611
|
-
r || this.#
|
|
643
|
+
r || this.#F(e, "ref", n), r.type !== m && this.#P(e, "ref", `refers to property "${n}" whose type is not HTMLElement`), this[n] && this.#P(e, "ref", `is a duplicate reference to the property "${n}"`), this[n] = e, e.removeAttribute("ref");
|
|
612
644
|
}
|
|
613
645
|
setAttributeSafe(e, t) {
|
|
614
646
|
this.hasAttribute(e) || this.setAttribute(e, t);
|
|
615
647
|
}
|
|
616
648
|
setFormValue(e, t) {
|
|
617
|
-
!this.#a || !
|
|
649
|
+
!this.#a || !P(t) || (this.#a.set(e, t), this.#s?.setFormValue(this.#a));
|
|
618
650
|
}
|
|
619
651
|
static ssr(e = {}) {
|
|
620
|
-
throw new
|
|
652
|
+
throw new g("SSR is not available in the browser build.");
|
|
621
653
|
}
|
|
622
|
-
#
|
|
654
|
+
#P(e, t, n) {
|
|
623
655
|
let r = e instanceof HTMLElement ? e.localName : "CSS rule";
|
|
624
|
-
throw new
|
|
656
|
+
throw new g(`component ${this.#n.elementName}` + (e ? `, element "${r}"` : "") + (t ? `, attribute "${t}"` : "") + ` ${n}`);
|
|
625
657
|
}
|
|
626
|
-
#
|
|
627
|
-
this.#
|
|
658
|
+
#F(e, t, n) {
|
|
659
|
+
this.#P(e, t, `refers to missing property "${n}"`);
|
|
628
660
|
}
|
|
629
|
-
#
|
|
630
|
-
return this.#
|
|
661
|
+
#I(e, t) {
|
|
662
|
+
return this.#L(e, this.getAttribute(t));
|
|
631
663
|
}
|
|
632
|
-
#
|
|
633
|
-
if (n?.match(
|
|
664
|
+
#L(t, n) {
|
|
665
|
+
if (n?.match(w)) return n;
|
|
634
666
|
let r = this.#n.properties[t], { type: i, values: a } = r;
|
|
635
|
-
if (i || this.#
|
|
667
|
+
if (i || this.#P(null, t, "does not specify its type"), n === null) return i === Boolean ? !1 : k(r);
|
|
636
668
|
if (i === String) {
|
|
637
669
|
if (a && !a.includes(n)) {
|
|
638
670
|
let e = a.map((e) => `"${e}"`).join(", ");
|
|
639
|
-
this.#
|
|
671
|
+
this.#P(null, t, `must be one of ${e}`);
|
|
640
672
|
}
|
|
641
673
|
return n;
|
|
642
674
|
}
|
|
643
|
-
if (i === Number) return
|
|
675
|
+
if (i === Number) return z(n);
|
|
644
676
|
if (i === Boolean) {
|
|
645
677
|
if (n === "true") return !0;
|
|
646
678
|
if (n === "false" || n === "null") return !1;
|
|
647
679
|
let r = e.getAttrName(t);
|
|
648
|
-
return n && n !== r && this.#
|
|
680
|
+
return n && n !== r && this.#P(null, t, "is a Boolean attribute, so its value must match attribute name or be missing"), n === "" || n === r;
|
|
649
681
|
}
|
|
650
682
|
}
|
|
651
|
-
#
|
|
652
|
-
|
|
683
|
+
#R(e, t, n, r) {
|
|
684
|
+
P(n) && !this.#T(e) && n !== (t === Boolean ? this.hasAttribute(r) : this.#I(e, r)) && B(this, r || e, n);
|
|
653
685
|
}
|
|
654
|
-
#
|
|
655
|
-
let t
|
|
656
|
-
for (let [e, n] of t) this.#k(e, this.#v(n));
|
|
686
|
+
#z(e) {
|
|
687
|
+
for (let [t, n] of this.#x([e])) this.#j(t, this.#v(n));
|
|
657
688
|
}
|
|
658
|
-
#
|
|
689
|
+
#B(e, t) {
|
|
659
690
|
if (t === void 0) return;
|
|
660
691
|
let n = e instanceof HTMLElement;
|
|
661
692
|
Array.isArray(t) && (t = t.join(""));
|
|
662
693
|
let r = typeof t;
|
|
663
|
-
r !== "string" && r !== "number" && this.#
|
|
694
|
+
r !== "string" && r !== "number" && this.#P(e, void 0, " computed content is not a string or number");
|
|
664
695
|
let i = String(t);
|
|
665
|
-
e instanceof HTMLElement &&
|
|
696
|
+
e instanceof HTMLElement && F(e) ? e.value = i : n && r === "string" && i.trim().startsWith("<") ? (e.innerHTML = d(i), this.#q(e), this.#E(e)) : n && (e.textContent = i);
|
|
666
697
|
}
|
|
667
|
-
#
|
|
698
|
+
#V(e, t) {
|
|
668
699
|
let n = this.#c.get(e);
|
|
669
700
|
if (!n) return;
|
|
670
701
|
let r = this.getRootNode();
|
|
@@ -674,26 +705,26 @@ var U = class e extends p {
|
|
|
674
705
|
let a = i;
|
|
675
706
|
a[n] = t;
|
|
676
707
|
}
|
|
677
|
-
#
|
|
708
|
+
#H() {
|
|
678
709
|
let e = this.#n;
|
|
679
710
|
function t() {
|
|
680
|
-
let t =
|
|
711
|
+
let t = f();
|
|
681
712
|
e.methodToExprsMap = t;
|
|
682
713
|
let n = Array.from(this.#r.keys());
|
|
683
|
-
for (let e of n) for (let n of e.matchAll(
|
|
714
|
+
for (let e of n) for (let n of e.matchAll(b)) {
|
|
684
715
|
let r = n[1], i = t.get(r);
|
|
685
716
|
i || (i = [], t.set(r, i)), i.includes(e) || i.push(e);
|
|
686
717
|
}
|
|
687
718
|
}
|
|
688
719
|
let { properties: n, propToExprsMap: r } = e;
|
|
689
720
|
for (let [i, a] of Object.entries(n)) {
|
|
690
|
-
let n =
|
|
721
|
+
let n = H(a.usedBy);
|
|
691
722
|
if (!n) continue;
|
|
692
723
|
e.methodToExprsMap || t.call(this);
|
|
693
724
|
let { methodToExprsMap: o } = e, s = r.get(i);
|
|
694
725
|
s || (s = [], r.set(i, s));
|
|
695
726
|
for (let e of n) {
|
|
696
|
-
if (typeof this[e] != "function") throw new
|
|
727
|
+
if (typeof this[e] != "function") throw new g(`property ${i} usedBy contains non-method ${e}`);
|
|
697
728
|
let t = o.get(e) || [];
|
|
698
729
|
for (let e of t) s.includes(e) || s.push(e);
|
|
699
730
|
}
|
|
@@ -704,8 +735,8 @@ var U = class e extends p {
|
|
|
704
735
|
t = {};
|
|
705
736
|
for (let n of Object.keys(e)) t[n] = n;
|
|
706
737
|
}
|
|
707
|
-
this.#
|
|
708
|
-
for (let [n, r] of Object.entries(t)) if (this.#
|
|
738
|
+
this.#G(e, t);
|
|
739
|
+
for (let [n, r] of Object.entries(t)) if (this.#w(r)) {
|
|
709
740
|
let t = o(e, n);
|
|
710
741
|
t !== void 0 && (this[r] = t), this.#l.set(r, {
|
|
711
742
|
state: e,
|
|
@@ -726,50 +757,50 @@ var U = class e extends p {
|
|
|
726
757
|
unsubscribe: i
|
|
727
758
|
});
|
|
728
759
|
}
|
|
729
|
-
#
|
|
760
|
+
#U() {
|
|
730
761
|
let t = new Set(Object.keys(this.#n.properties));
|
|
731
|
-
for (let n of this.getAttributeNames()) if (!
|
|
762
|
+
for (let n of this.getAttributeNames()) if (!p.has(n) && !n.startsWith("on") && n !== "ref") {
|
|
732
763
|
if (n === "form-assoc") {
|
|
733
|
-
this.#
|
|
764
|
+
this.#D();
|
|
734
765
|
continue;
|
|
735
766
|
}
|
|
736
767
|
if (!t.has(e.getPropName(n))) {
|
|
737
768
|
if (n === "name") {
|
|
738
|
-
this.#
|
|
769
|
+
this.#D();
|
|
739
770
|
continue;
|
|
740
771
|
}
|
|
741
|
-
this.#
|
|
772
|
+
this.#P(null, n, "is not a supported attribute");
|
|
742
773
|
}
|
|
743
774
|
}
|
|
744
775
|
}
|
|
745
|
-
#
|
|
746
|
-
let r = n.match(
|
|
776
|
+
#W(e, t, n) {
|
|
777
|
+
let r = n.match(w);
|
|
747
778
|
if (r) return r.forEach((n) => {
|
|
748
|
-
let r =
|
|
749
|
-
this[r] === void 0 && this.#
|
|
779
|
+
let r = M(n);
|
|
780
|
+
this[r] === void 0 && this.#F(e, t, r);
|
|
750
781
|
}), r;
|
|
751
782
|
}
|
|
752
|
-
#
|
|
783
|
+
#G(e, t) {
|
|
753
784
|
for (let [n, r] of Object.entries(t)) {
|
|
754
785
|
let t = o(e, n);
|
|
755
|
-
t === void 0 && this.#
|
|
786
|
+
t === void 0 && this.#P(this, void 0, `invalid state path "${n}"`), t = this[r], this.#w(r) || this.#P(null, r, "refers to missing property in useState map");
|
|
756
787
|
}
|
|
757
788
|
}
|
|
758
|
-
#
|
|
789
|
+
#K(e, t, n) {
|
|
759
790
|
let { values: r } = this.#n.properties[e];
|
|
760
791
|
if (r) {
|
|
761
792
|
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.#
|
|
793
|
+
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.#P(null, e, i);
|
|
763
794
|
}
|
|
764
795
|
if (n instanceof t) return;
|
|
765
796
|
let i = typeof n;
|
|
766
797
|
if (i === "object") {
|
|
767
798
|
let { constructor: r } = n;
|
|
768
|
-
i = r.name, r !== t && this.#
|
|
799
|
+
i = r.name, r !== t && this.#P(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
769
800
|
}
|
|
770
|
-
i !== t.name.toLowerCase() && this.#
|
|
801
|
+
i !== t.name.toLowerCase() && this.#P(null, e, `was set to a ${i}, but must be a ${t.name}`);
|
|
771
802
|
}
|
|
772
|
-
#
|
|
803
|
+
#q(e) {
|
|
773
804
|
let t = Array.from(e.querySelectorAll("*"));
|
|
774
805
|
for (let e of t) {
|
|
775
806
|
let t = [];
|
|
@@ -779,44 +810,44 @@ var U = class e extends p {
|
|
|
779
810
|
let i = r.slice(2);
|
|
780
811
|
i = i[0].toLowerCase() + i.slice(1).toLowerCase();
|
|
781
812
|
let a = n.value;
|
|
782
|
-
this.#
|
|
813
|
+
this.#W(e, r, a);
|
|
783
814
|
let o;
|
|
784
|
-
typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#
|
|
815
|
+
typeof this[a] == "function" ? o = (e) => this[a](e) : (this.#W(e, r, a), o = () => this.#v(a)), e.addEventListener(i, o), t.push(r);
|
|
785
816
|
}
|
|
786
817
|
}
|
|
787
818
|
for (let n of t) e.removeAttribute(n);
|
|
788
819
|
}
|
|
789
820
|
}
|
|
790
821
|
};
|
|
791
|
-
function
|
|
792
|
-
let n =
|
|
822
|
+
function G(e, ...t) {
|
|
823
|
+
let n = N(e, t);
|
|
793
824
|
for (;;) {
|
|
794
|
-
let e =
|
|
825
|
+
let e = _.exec(n);
|
|
795
826
|
if (!e) break;
|
|
796
827
|
let t = e[2];
|
|
797
|
-
if (
|
|
828
|
+
if (T.test(t)) {
|
|
798
829
|
let r = e[1];
|
|
799
830
|
if (!r.startsWith("--")) {
|
|
800
831
|
let i = `--${r}: ${t};
|
|
801
832
|
${r}: var(--${r})`;
|
|
802
|
-
n =
|
|
833
|
+
n = R(n, e.index, e[0].length, i);
|
|
803
834
|
}
|
|
804
835
|
}
|
|
805
836
|
}
|
|
806
837
|
return n;
|
|
807
838
|
}
|
|
808
|
-
function
|
|
809
|
-
let n =
|
|
839
|
+
function K(e, ...t) {
|
|
840
|
+
let n = N(e, t);
|
|
810
841
|
for (;;) {
|
|
811
|
-
let e =
|
|
842
|
+
let e = S.exec(n);
|
|
812
843
|
if (!e || e[1] === "style") break;
|
|
813
|
-
let t =
|
|
814
|
-
if (
|
|
844
|
+
let t = L(e[2]);
|
|
845
|
+
if (T.test(t)) {
|
|
815
846
|
let r = `<!-- ${t.trim()} -->`, i = e.index + e[0].indexOf(">") + 1;
|
|
816
|
-
n =
|
|
847
|
+
n = R(n, i, t.length, r);
|
|
817
848
|
}
|
|
818
849
|
}
|
|
819
850
|
return n;
|
|
820
851
|
}
|
|
821
852
|
//#endregion
|
|
822
|
-
export { a,
|
|
853
|
+
export { a, K as i, O as n, G as r, W as t };
|
package/dist/wrec-ssr.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare abstract class Wrec extends HTMLElementBase {
|
|
|
40
40
|
#private;
|
|
41
41
|
private static attrToPropMap;
|
|
42
42
|
private static propToAttrMap;
|
|
43
|
+
private static computedGraph;
|
|
43
44
|
static context: {};
|
|
44
45
|
static css: string;
|
|
45
46
|
private static elementName;
|
|
@@ -49,6 +50,7 @@ export declare abstract class Wrec extends HTMLElementBase {
|
|
|
49
50
|
private static propToComputedMap;
|
|
50
51
|
private static methodToExprsMap;
|
|
51
52
|
private static propToExprsMap;
|
|
53
|
+
private static registeredComputedProps;
|
|
52
54
|
private static template;
|
|
53
55
|
[key: string]: any;
|
|
54
56
|
static define(elementName: string): 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-DHp2V7DA.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
|
@@ -40,6 +40,7 @@ export declare abstract class Wrec extends HTMLElementBase {
|
|
|
40
40
|
#private;
|
|
41
41
|
private static attrToPropMap;
|
|
42
42
|
private static propToAttrMap;
|
|
43
|
+
private static computedGraph;
|
|
43
44
|
static context: {};
|
|
44
45
|
static css: string;
|
|
45
46
|
private static elementName;
|
|
@@ -49,6 +50,7 @@ export declare abstract class Wrec extends HTMLElementBase {
|
|
|
49
50
|
private static propToComputedMap;
|
|
50
51
|
private static methodToExprsMap;
|
|
51
52
|
private static propToExprsMap;
|
|
53
|
+
private static registeredComputedProps;
|
|
52
54
|
private static template;
|
|
53
55
|
[key: string]: any;
|
|
54
56
|
static define(elementName: string): 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-DHp2V7DA.js";
|
|
2
2
|
export { i as Wrec, e as WrecState, n as createElement, r as css, t as html };
|