wrec 0.23.1 → 0.23.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.
@@ -42,6 +42,7 @@ export declare abstract class Wrec extends HTMLElementBase implements ChangeList
42
42
  static html: string;
43
43
  static properties: Record<string, PropertyConfig>;
44
44
  private static propToComputedMap;
45
+ private static methodToExprsMap;
45
46
  private static propToExprsMap;
46
47
  private static template;
47
48
  [key: string]: any;
package/dist/wrec.d.ts CHANGED
@@ -42,6 +42,7 @@ export declare abstract class Wrec extends HTMLElementBase implements ChangeList
42
42
  static html: string;
43
43
  static properties: Record<string, PropertyConfig>;
44
44
  private static propToComputedMap;
45
+ private static methodToExprsMap;
45
46
  private static propToExprsMap;
46
47
  private static template;
47
48
  [key: string]: any;
package/dist/wrec.es.js CHANGED
@@ -1,66 +1,66 @@
1
1
  var D = (r) => {
2
2
  throw TypeError(r);
3
3
  };
4
- var L = (r, t, e) => t.has(r) || D("Cannot " + e);
5
- var p = (r, t, e) => (L(r, t, "read from private field"), e ? e.call(r) : t.get(r)), b = (r, t, e) => t.has(r) ? D("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), E = (r, t, e, s) => (L(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), V = (r, t, e) => (L(r, t, "access private method"), e);
4
+ var N = (r, t, e) => t.has(r) || D("Cannot " + e);
5
+ var p = (r, t, e) => (N(r, t, "read from private field"), e ? e.call(r) : t.get(r)), b = (r, t, e) => t.has(r) ? D("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), E = (r, t, e, s) => (N(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), V = (r, t, e) => (N(r, t, "access private method"), e);
6
6
  import W from "xss";
7
- function U(r, t, e = "") {
8
- const s = /* @__PURE__ */ new WeakMap(), o = {
7
+ function Z(r, t, e = "") {
8
+ const s = /* @__PURE__ */ new WeakMap(), i = {
9
9
  // Intercept property reads.
10
10
  // This creates nested proxies lazily.
11
- get(i, n) {
12
- const c = Reflect.get(i, n);
11
+ get(o, n) {
12
+ const c = Reflect.get(o, n);
13
13
  if (c === null || typeof c != "object") return c;
14
14
  const a = s.get(c);
15
15
  if (a) return a;
16
- const f = e ? `${e}.${n}` : n, l = U(c, t, f);
17
- return s.set(c, l), l;
16
+ const f = e ? `${e}.${n}` : n, h = Z(c, t, f);
17
+ return s.set(c, h), h;
18
18
  },
19
19
  // Intercept property writes.
20
- set(i, n, c) {
21
- const a = Reflect.get(i, n);
20
+ set(o, n, c) {
21
+ const a = Reflect.get(o, n);
22
22
  if (a !== c) {
23
- Reflect.set(i, n, c);
23
+ Reflect.set(o, n, c);
24
24
  const f = e ? `${e}.${n}` : n;
25
25
  t(f, a, c);
26
26
  }
27
27
  return !0;
28
28
  }
29
29
  };
30
- return new Proxy(r, o);
30
+ return new Proxy(r, i);
31
31
  }
32
- function Z(r) {
32
+ function Y(r) {
33
33
  const t = {};
34
34
  for (const [e, s] of Object.entries(r)) {
35
- const o = typeof s == "object" && s !== null;
36
- t[e] = o ? Z(s) : s;
35
+ const i = typeof s == "object" && s !== null;
36
+ t[e] = i ? Y(s) : s;
37
37
  }
38
38
  return t;
39
39
  }
40
40
  const P = typeof window < "u" && typeof window.document < "u";
41
41
  let z = class extends Error {
42
42
  };
43
- var w, $, d, v, C, g, O, Y;
43
+ var w, R, m, x, C, y, O, G;
44
44
  const T = class T {
45
45
  constructor(t, e, s) {
46
46
  b(this, O);
47
- b(this, $, /* @__PURE__ */ Symbol("objectId"));
47
+ b(this, R, /* @__PURE__ */ Symbol("objectId"));
48
48
  // This cannot be replaced by a WeakMap<ChangeListener, Set<string>>
49
49
  // because there is no way to iterate over the keys of a WeakMap.
50
- b(this, d, []);
51
- b(this, v);
50
+ b(this, m, []);
51
+ b(this, x);
52
52
  b(this, C);
53
- b(this, g);
53
+ b(this, y);
54
54
  if (!t) throw new z("name cannot be empty");
55
55
  if (p(T, w).has(t))
56
56
  throw new z(`WrecState with name "${t}" already exists`);
57
- if (E(this, v, t), E(this, C, e), E(this, g, U({}, V(this, O, Y).bind(this))), e && P) {
58
- const o = sessionStorage.getItem("wrec-state-" + t), i = o ? JSON.parse(o) : void 0;
59
- i && (s = i);
57
+ if (E(this, x, t), E(this, C, e), E(this, y, Z({}, V(this, O, G).bind(this))), e && P) {
58
+ const i = sessionStorage.getItem("wrec-state-" + t), o = i ? JSON.parse(i) : void 0;
59
+ o && (s = o);
60
60
  }
61
61
  if (s)
62
- for (const [o, i] of Object.entries(s))
63
- this.addProperty(o, i);
62
+ for (const [i, o] of Object.entries(s))
63
+ this.addProperty(i, o);
64
64
  p(T, w).set(t, this);
65
65
  }
66
66
  // This static method is useful for accessing a specific WrecState object
@@ -81,15 +81,15 @@ const T = class T {
81
81
  * @param map - map from state property paths to component properties
82
82
  */
83
83
  addListener(t, e = {}) {
84
- const s = p(this, d).find(
85
- (o) => o.listenerRef.deref() === t
84
+ const s = p(this, m).find(
85
+ (i) => i.listenerRef.deref() === t
86
86
  );
87
87
  if (s) {
88
- const { propertyMap: o } = s;
89
- for (const [i, n] of Object.entries(e))
90
- o[i] = n;
88
+ const { propertyMap: i } = s;
89
+ for (const [o, n] of Object.entries(e))
90
+ i[o] = n;
91
91
  } else
92
- p(this, d).push({
92
+ p(this, m).push({
93
93
  listenerRef: new WeakRef(t),
94
94
  propertyMap: e
95
95
  });
@@ -98,37 +98,37 @@ const T = class T {
98
98
  Object.defineProperty(this, t, {
99
99
  enumerable: !0,
100
100
  get() {
101
- return p(this, g)[t];
101
+ return p(this, y)[t];
102
102
  },
103
103
  set(s) {
104
- p(this, g)[t] = s;
104
+ p(this, y)[t] = s;
105
105
  }
106
- }), p(this, g)[t] = e;
106
+ }), p(this, y)[t] = e;
107
107
  }
108
108
  get id() {
109
- return p(this, $);
109
+ return p(this, R);
110
110
  }
111
111
  // This is useful for debugging from the DevTools console.
112
112
  // For example: state.log()
113
113
  log() {
114
- console.log("WrecState:", p(this, v));
115
- for (const [t, e] of Object.entries(p(this, g)))
114
+ console.log("WrecState:", p(this, x));
115
+ for (const [t, e] of Object.entries(p(this, y)))
116
116
  console.log(` ${t} = ${JSON.stringify(e)}`);
117
117
  }
118
118
  removeListener(t) {
119
- E(this, d, p(this, d).filter((e) => e.listenerRef.deref() !== t));
119
+ E(this, m, p(this, m).filter((e) => e.listenerRef.deref() !== t));
120
120
  }
121
121
  };
122
- w = new WeakMap(), $ = new WeakMap(), d = new WeakMap(), v = new WeakMap(), C = new WeakMap(), g = new WeakMap(), O = new WeakSet(), Y = function(t, e, s) {
123
- const o = /* @__PURE__ */ new Set();
124
- for (const i of p(this, d)) {
125
- const n = i.listenerRef.deref();
122
+ w = new WeakMap(), R = new WeakMap(), m = new WeakMap(), x = new WeakMap(), C = new WeakMap(), y = new WeakMap(), O = new WeakSet(), G = function(t, e, s) {
123
+ const i = /* @__PURE__ */ new Set();
124
+ for (const o of p(this, m)) {
125
+ const n = o.listenerRef.deref();
126
126
  if (!n)
127
- o.add(i);
127
+ i.add(o);
128
128
  else if (P && n instanceof HTMLElement && !n.isConnected)
129
- o.add(i);
129
+ i.add(o);
130
130
  else {
131
- const { propertyMap: c } = i, a = Object.keys(c);
131
+ const { propertyMap: c } = o, a = Object.keys(c);
132
132
  (a.length === 0 || a.includes(t)) && n.changed(
133
133
  t,
134
134
  c[t],
@@ -138,13 +138,13 @@ w = new WeakMap(), $ = new WeakMap(), d = new WeakMap(), v = new WeakMap(), C =
138
138
  );
139
139
  }
140
140
  }
141
- E(this, d, p(this, d).filter(
142
- (i) => !o.has(i)
141
+ E(this, m, p(this, m).filter(
142
+ (o) => !i.has(o)
143
143
  ));
144
144
  }, b(T, w, /* @__PURE__ */ new Map()), P && window.addEventListener("beforeunload", () => {
145
145
  for (const [t, e] of p(T, w).entries())
146
146
  if (p(e, C)) {
147
- const s = Z(e);
147
+ const s = Y(e);
148
148
  sessionStorage.setItem("wrec-state-" + t, JSON.stringify(s));
149
149
  }
150
150
  });
@@ -156,25 +156,25 @@ function q(r, t) {
156
156
  e = e[s];
157
157
  return e;
158
158
  }
159
- function ot(r, t, e) {
160
- const s = t.split("."), o = s.length - 1;
161
- let i = r;
159
+ function it(r, t, e) {
160
+ const s = t.split("."), i = s.length - 1;
161
+ let o = r;
162
162
  s.forEach((n, c) => {
163
- c === o ? i[n] = e : i = i[n];
163
+ c === i ? o[n] = e : o = o[n];
164
164
  });
165
165
  }
166
- const it = /* @__PURE__ */ new Set(["button", "input", "label", "option", "th"]), J = "__WREC", X = "__";
167
- function nt(r) {
166
+ const nt = /* @__PURE__ */ new Set(["button", "input", "label", "option", "th"]), J = "__WREC", X = "__";
167
+ function rt(r) {
168
168
  const t = {
169
169
  allowCommentTag: !0,
170
- onTag: (o, i) => {
171
- if (it.has(o)) return i;
170
+ onTag: (i, o) => {
171
+ if (nt.has(i)) return o;
172
172
  },
173
- onTagAttr(o, i, n) {
174
- if (i.startsWith("on")) return "";
173
+ onTagAttr(i, o, n) {
174
+ if (o.startsWith("on")) return "";
175
175
  },
176
- safeAttrValue(o, i, n) {
177
- return i === "class" || o === "a" && i === "href" && !n.startsWith("javascript") || o === "img" && i === "src" ? n : "";
176
+ safeAttrValue(i, o, n) {
177
+ return o === "class" || i === "a" && o === "href" && !n.startsWith("javascript") || i === "img" && o === "src" ? n : "";
178
178
  },
179
179
  stripIgnoreTagBody: ["script", "style", "iframe"],
180
180
  whiteList: {
@@ -183,30 +183,30 @@ function nt(r) {
183
183
  span: ["class"]
184
184
  }
185
185
  }, e = [];
186
- r = r.replace(/<!--[\s\S]*?-->/g, (o) => {
187
- let i = "";
186
+ r = r.replace(/<!--[\s\S]*?-->/g, (i) => {
187
+ let o = "";
188
188
  do
189
- i = J + e.length + X;
190
- while (r.includes(i));
191
- return e.push(o), i;
189
+ o = J + e.length + X;
190
+ while (r.includes(o));
191
+ return e.push(i), o;
192
192
  });
193
193
  let s = W(r, t);
194
- return e.forEach((o, i) => {
194
+ return e.forEach((i, o) => {
195
195
  const n = new RegExp(
196
- `${J}${i}${X}`,
196
+ `${J}${o}${X}`,
197
197
  "g"
198
198
  );
199
- s = s.replace(n, o);
199
+ s = s.replace(n, i);
200
200
  }), s;
201
201
  }
202
- const rt = /* @__PURE__ */ new Set([
202
+ const ct = /* @__PURE__ */ new Set([
203
203
  "class",
204
204
  "disabled",
205
205
  "hidden",
206
206
  "id",
207
207
  "tabindex",
208
208
  "title"
209
- ]), ct = globalThis.HTMLElement ?? class {
209
+ ]), at = globalThis.HTMLElement ?? class {
210
210
  }, F = globalThis.customElements ?? {
211
211
  get: (r) => {
212
212
  },
@@ -219,32 +219,32 @@ const rt = /* @__PURE__ */ new Set([
219
219
  new Error("customElements is not available in this environment")
220
220
  )
221
221
  };
222
- class y extends Error {
222
+ class g extends Error {
223
223
  }
224
- const at = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, G = "a-zA-Z_$", ft = G + "0-9", M = `[${G}][${ft}]*`, lt = /<!--\s*(.*?)\s*-->/, ht = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, N = new RegExp(`^this\\.${M}$`), j = new RegExp(`this\\.${M}(\\.${M})*`, "g"), Q = new RegExp(`this\\.${M}(\\.${M})*`), pt = 5;
225
- function ut(r) {
226
- return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof u;
224
+ const ft = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, Q = "a-zA-Z_$", ht = Q + "0-9", M = `[${Q}][${ht}]*`, K = new RegExp(`this\\.(${M})\\s*\\(`, "g"), lt = /<!--\s*(.*?)\s*-->/, pt = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, L = new RegExp(`^this\\.${M}$`), j = new RegExp(`this\\.${M}(\\.${M})*`, "g"), tt = new RegExp(`this\\.${M}(\\.${M})*`), ut = 5;
225
+ function dt(r) {
226
+ return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof d;
227
227
  }
228
- function Et(r, t, e) {
228
+ function Tt(r, t, e) {
229
229
  const s = document.createElement(r);
230
230
  if (t)
231
- for (const [o, i] of Object.entries(t))
232
- s.setAttribute(o, i);
231
+ for (const [i, o] of Object.entries(t))
232
+ s.setAttribute(i, o);
233
233
  return e && (s.innerHTML = e), s;
234
234
  }
235
- const K = (r) => Array.isArray(r.values) && r.values.length > 0 ? r.values[0] : dt(r.type), dt = (r) => r === String ? "" : r === Number ? 0 : r === Boolean ? !1 : r === Array ? [] : r === Object ? {} : void 0;
236
- function R(r) {
235
+ const U = (r) => Array.isArray(r.values) && r.values.length > 0 ? r.values[0] : mt(r.type), mt = (r) => r === String ? "" : r === Number ? 0 : r === Boolean ? !1 : r === Array ? [] : r === Object ? {} : void 0;
236
+ function $(r) {
237
237
  const t = [];
238
238
  let e = r.firstElementChild;
239
239
  for (; e; )
240
- t.push(e), e.shadowRoot && t.push(...R(e.shadowRoot)), e.firstElementChild && t.push(...R(e)), e = e.nextElementSibling;
240
+ t.push(e), e.shadowRoot && t.push(...$(e.shadowRoot)), e.firstElementChild && t.push(...$(e)), e = e.nextElementSibling;
241
241
  return t;
242
242
  }
243
- const A = (r) => r.substring(pt).split(".")[0];
244
- function tt(r, t) {
243
+ const A = (r) => r.substring(ut).split(".")[0];
244
+ function et(r, t) {
245
245
  let e = r[0];
246
- return t.forEach((s, o) => {
247
- e += s + r[o + 1];
246
+ return t.forEach((s, i) => {
247
+ e += s + r[i + 1];
248
248
  }), e;
249
249
  }
250
250
  function I(r) {
@@ -258,46 +258,46 @@ function B(r) {
258
258
  const { localName: t } = r;
259
259
  return t === "input" || t === "select";
260
260
  }
261
- const mt = (r) => r.replace(/<!--[\s\S]*?-->/g, "");
262
- function et(r, t, e, s) {
261
+ const bt = (r) => r.replace(/<!--[\s\S]*?-->/g, "");
262
+ function st(r, t, e, s) {
263
263
  return r.slice(0, t) + s + r.slice(t + e);
264
264
  }
265
265
  function H(r) {
266
266
  const t = Number(r);
267
- if (isNaN(t)) throw new y(`can't convert "${r}" to a number`);
267
+ if (isNaN(t)) throw new g(`can't convert "${r}" to a number`);
268
268
  return t;
269
269
  }
270
- function st(r, t, e) {
271
- const [s, o] = t.split(":");
270
+ function ot(r, t, e) {
271
+ const [s, i] = t.split(":");
272
272
  if (I(e))
273
273
  if (typeof e == "boolean") {
274
274
  e ? r.setAttribute(s, s) : r.removeAttribute(s);
275
- const i = u.getPropName(s);
276
- r[i] = e;
275
+ const o = d.getPropName(s);
276
+ r[o] = e;
277
277
  } else {
278
- const i = r.getAttribute(t), n = String(e);
279
- i !== n && (r.setAttribute(s, n), s === "value" && B(r) && (r.value = n));
278
+ const o = r.getAttribute(t), n = String(e);
279
+ o !== n && (r.setAttribute(s, n), s === "value" && B(r) && (r.value = n));
280
280
  }
281
281
  else {
282
- const i = u.getPropName(t);
283
- r[i] = e;
282
+ const o = d.getPropName(t);
283
+ r[o] = e;
284
284
  }
285
285
  }
286
286
  function k(r, t, e) {
287
- const [s, o] = t.split(":");
288
- r instanceof CSSStyleRule ? r.style.setProperty(s, e) : (st(r, s, e), s === "value" && B(r) && (r.value = e));
287
+ const [s, i] = t.split(":");
288
+ r instanceof CSSStyleRule ? r.style.setProperty(s, e) : (ot(r, s, e), s === "value" && B(r) && (r.value = e));
289
289
  }
290
- async function bt(r) {
290
+ async function gt(r) {
291
291
  const t = /* @__PURE__ */ new Set();
292
- for (const s of R(r.content)) {
293
- const { localName: o } = s;
294
- o.includes("-") && t.add(o);
292
+ for (const s of $(r.content)) {
293
+ const { localName: i } = s;
294
+ i.includes("-") && t.add(i);
295
295
  }
296
296
  function e(s) {
297
- return new Promise((o, i) => {
297
+ return new Promise((i, o) => {
298
298
  setTimeout(() => {
299
299
  const n = `custom element <${s}> not defined`;
300
- i(new Error(n));
300
+ o(new Error(n));
301
301
  }, 1e3);
302
302
  });
303
303
  }
@@ -310,7 +310,7 @@ async function bt(r) {
310
310
  )
311
311
  );
312
312
  }
313
- class u extends ct {
313
+ class d extends at {
314
314
  // There is one instance of `attrToPropMap`, `properties`, `propToAttrMap`,
315
315
  // `propToComputedMap`, and `propToExprsMap` per Wrec subclass,
316
316
  // not one for only the Wrec class.
@@ -344,11 +344,13 @@ class u extends ct {
344
344
  // It is used to update computed properties
345
345
  // when the properties on which they depend are modified.
346
346
  // See the method #updateComputedProperties.
347
- // This map cannot be private.
348
347
  static propToComputedMap;
348
+ // This is a map from method names to expressions
349
+ // that include calls to them.
350
+ // It is the same for all instances of a component.
351
+ static methodToExprsMap;
349
352
  // This is a map from properties to expressions that refer to them.
350
- // It is the sma for all instances of a component.
351
- // This map cannot be private.
353
+ // It is the same for all instances of a component.
352
354
  static propToExprsMap;
353
355
  static template = null;
354
356
  // This is true while the batchSet method is running.
@@ -384,7 +386,7 @@ class u extends ct {
384
386
  #r = /* @__PURE__ */ new Map();
385
387
  static define(t) {
386
388
  if (this.elementName = t, F.get(t))
387
- throw new y(`custom element ${t} is already defined`);
389
+ throw new g(`custom element ${t} is already defined`);
388
390
  F.define(t, this);
389
391
  }
390
392
  constructor() {
@@ -394,12 +396,12 @@ class u extends ct {
394
396
  }
395
397
  attributeChangedCallback(t, e, s) {
396
398
  t === "disabled" && this.#E();
397
- const o = u.getPropName(t);
398
- if (!this.#a(o) && this.#c(o)) {
399
- const i = this.#x(o, s);
400
- this[o] = i;
401
- const n = this.#d[o];
402
- n && this.setFormValue(n, String(i)), this.propertyChangedCallback(o, e, s);
399
+ const i = d.getPropName(t);
400
+ if (!this.#a(i) && this.#c(i)) {
401
+ const o = this.#v(i, s);
402
+ this[i] = o;
403
+ const n = this.#d[i];
404
+ n && this.setFormValue(n, String(o)), this.propertyChangedCallback(i, e, s);
403
405
  }
404
406
  }
405
407
  // This applies multiple property changes and only updates
@@ -410,36 +412,36 @@ class u extends ct {
410
412
  for (const [c, a] of Object.entries(t)) {
411
413
  this[c] = a;
412
414
  const f = e.get(c) ?? [];
413
- for (const l of f)
414
- s.add(l);
415
+ for (const h of f)
416
+ s.add(h);
415
417
  }
416
- const o = this.#t.propToComputedMap, i = /* @__PURE__ */ new Set(), n = {};
418
+ const i = this.#t.propToComputedMap, o = /* @__PURE__ */ new Set(), n = {};
417
419
  for (const c of Object.keys(t)) {
418
- const a = o.get(c) || [];
419
- for (const [f, l] of a)
420
- i.add(f), n[f] = l;
420
+ const a = i.get(c) || [];
421
+ for (const [f, h] of a)
422
+ o.add(f), n[f] = h;
421
423
  }
422
- for (const c of i) {
424
+ for (const c of o) {
423
425
  const a = n[c];
424
426
  this.#f(c, this.#o(a));
425
427
  const f = e.get(c) ?? [];
426
- for (const l of f)
427
- s.add(l);
428
+ for (const h of f)
429
+ s.add(h);
428
430
  }
429
431
  for (; ; ) {
430
432
  let c = !1;
431
- for (const a of i) {
432
- const f = n[a], l = this.#o(f), h = this[a];
433
- JSON.stringify(l) !== JSON.stringify(h) && (this.#f(a, l), c = !0);
433
+ for (const a of o) {
434
+ const f = n[a], h = this.#o(f), l = this[a];
435
+ JSON.stringify(h) !== JSON.stringify(l) && (this.#f(a, h), c = !0);
434
436
  }
435
437
  if (!c) break;
436
438
  }
437
439
  this.#T([...s]), this.#p = !1;
438
440
  }
439
- async #$() {
441
+ async #R() {
440
442
  const t = this.#t;
441
443
  let { template: e } = t;
442
- e || (e = t.template = document.createElement("template"), e.innerHTML = t.buildHTML()), await bt(e), this.shadowRoot.replaceChildren(e.content.cloneNode(!0));
444
+ e || (e = t.template = document.createElement("template"), e.innerHTML = t.buildHTML()), await gt(e), this.shadowRoot.replaceChildren(e.content.cloneNode(!0));
443
445
  }
444
446
  static buildHTML() {
445
447
  let t = `<style>
@@ -447,65 +449,65 @@ class u extends ct {
447
449
  this.css && (t += this.css), t += `</style>
448
450
  `;
449
451
  let e = this.html.trim();
450
- if (!e) throw new y("static property html must be set");
452
+ if (!e) throw new g("static property html must be set");
451
453
  return e.startsWith("<") || (e = `<span><!--${e}--></span>`), t + e;
452
454
  }
453
455
  changed(t, e, s) {
454
456
  this[e] = s;
455
457
  }
456
458
  async connectedCallback() {
457
- this.#D(), this.#L(), await this.#$(), this.hasAttribute("disabled") && this.#E(), this.#R(this.shadowRoot), this.#M(this.shadowRoot), this.#B(), this.#O();
459
+ this.#D(), this.#N(), await this.#R(), this.hasAttribute("disabled") && this.#E(), this.#$(this.shadowRoot), this.#M(this.shadowRoot), this.#B(), this.#O();
458
460
  }
459
461
  #O() {
460
462
  const t = this.#t, { properties: e } = t;
461
- for (const [s, { computed: o }] of Object.entries(e))
462
- o && this.#f(s, this.#o(o));
463
+ for (const [s, { computed: i }] of Object.entries(e))
464
+ i && this.#f(s, this.#o(i));
463
465
  }
464
- #L() {
466
+ #N() {
465
467
  const t = this.#t, { observedAttributes: e, properties: s } = t;
466
- for (const [o, i] of Object.entries(s))
467
- i.computed || this.#w(o, i, e);
468
- for (const [o, i] of Object.entries(s))
469
- i.computed && this.#w(o, i, e);
468
+ for (const [i, o] of Object.entries(s))
469
+ o.computed || this.#w(i, o, e);
470
+ for (const [i, o] of Object.entries(s))
471
+ o.computed && this.#w(i, o, e);
470
472
  }
471
473
  #w(t, e, s) {
472
474
  if (t === "class" || t === "style")
473
- throw new y(`"${t}" is a reserved property`);
474
- const o = u.getAttrName(t), i = this.hasAttribute(o);
475
- e.required && !i && this.#e(this, o, "is a required attribute");
475
+ throw new g(`"${t}" is a reserved property`);
476
+ const i = d.getAttrName(t), o = this.hasAttribute(i);
477
+ e.required && !o && this.#e(this, i, "is a required attribute");
476
478
  let n = e.value;
477
479
  this.hasOwnProperty(t) && (n = this[t], delete this[t]);
478
- const { type: c } = e, a = c === Boolean ? n || i : s.includes(o) && i ? this.#C(t, o) : n ?? K(e), f = "#" + t;
480
+ const { type: c } = e, a = c === Boolean ? n || o : s.includes(i) && o ? this.#C(t, i) : n ?? U(e), f = "#" + t;
479
481
  this[f] = a, e.computed && this.#k(t, e), Object.defineProperty(this, t, {
480
482
  enumerable: !0,
481
483
  get() {
482
484
  return this[f];
483
485
  },
484
- set(l) {
486
+ set(h) {
485
487
  e.computed && !this.#u.has(t) && this.#e(
486
488
  null,
487
489
  t,
488
490
  "is a computed property and cannot be set directly"
489
- ), c === Number && typeof l == "string" && (l = H(l));
490
- const h = this[f];
491
- if (l === h) return;
492
- this.#W(t, c, l), this[f] = l;
493
- const m = this.#r.get(t);
494
- m && ot(m.state, m.stateProp, l), this.#_(t, c, l, o), this.#p || (this.#F(t), this.#v(t)), this.#I(t, l);
495
- const x = this.#d[t];
496
- x && this.setFormValue(x, String(l)), this.propertyChangedCallback(t, h, l), e.dispatch && this.dispatch("change", {
491
+ ), c === Number && typeof h == "string" && (h = H(h));
492
+ const l = this[f];
493
+ if (h === l) return;
494
+ this.#W(t, c, h), this[f] = h;
495
+ const u = this.#r.get(t);
496
+ u && it(u.state, u.stateProp, h), this.#_(t, c, h, i), this.#p || (this.#F(t), this.#x(t)), this.#I(t, h);
497
+ const v = this.#d[t];
498
+ v && this.setFormValue(v, String(h)), this.propertyChangedCallback(t, l, h), e.dispatch && this.dispatch("change", {
497
499
  tagName: this.localName,
498
500
  property: t,
499
- oldValue: h,
500
- value: l
501
+ oldValue: l,
502
+ value: h
501
503
  });
502
504
  }
503
505
  });
504
506
  }
505
507
  #E() {
506
- const t = this.hasAttribute("disabled"), e = R(this.shadowRoot);
508
+ const t = this.hasAttribute("disabled"), e = $(this.shadowRoot);
507
509
  for (const s of e)
508
- ut(s) && (s.disabled = t);
510
+ dt(s) && (s.disabled = t);
509
511
  }
510
512
  disconnectedCallback() {
511
513
  for (const { state: t } of this.#r.values())
@@ -526,30 +528,30 @@ class u extends ct {
526
528
  displayIfSet(t, e = "block") {
527
529
  return `display: ${t ? e : "none"}`;
528
530
  }
529
- #N(t) {
530
- const e = t instanceof u;
531
+ #L(t) {
532
+ const e = t instanceof d;
531
533
  for (const s of t.getAttributeNames()) {
532
- const o = t.getAttribute(s), i = this.#S(t, o);
533
- if (i) {
534
- const n = this[i];
535
- n === void 0 && this.#h(t, s, i);
534
+ const i = t.getAttribute(s), o = this.#S(t, i);
535
+ if (o) {
536
+ const n = this[o];
537
+ n === void 0 && this.#l(t, s, o);
536
538
  let [c, a] = s.split(":");
537
- const f = u.getPropName(c), l = this.#a(i);
538
- e && t.#a(f) || (t[f] = n), c === "value" && (a ? (t["on" + a] === void 0 && this.#e(t, s, "refers to an unsupported event name"), t.setAttribute(c, this[i])) : a = "change"), e && !l && t.#g.set(
539
- u.getPropName(c),
540
- i
539
+ const f = d.getPropName(c), h = this.#a(o);
540
+ e && t.#a(f) || (t[f] = n), c === "value" && (a ? (t["on" + a] === void 0 && this.#e(t, s, "refers to an unsupported event name"), t.setAttribute(c, this[o])) : a = "change"), e && !h && t.#g.set(
541
+ d.getPropName(c),
542
+ o
541
543
  );
542
544
  }
543
- this.#l(o, t, s);
545
+ this.#h(i, t, s);
544
546
  }
545
547
  }
546
548
  #T(t) {
547
549
  for (const e of t) {
548
- const s = this.#o(e), o = this.#s.get(e) ?? [], i = /* @__PURE__ */ new Set();
549
- for (const n of o) {
550
+ const s = this.#o(e), i = this.#s.get(e) ?? [], o = /* @__PURE__ */ new Set();
551
+ for (const n of i) {
550
552
  const c = n instanceof HTMLElement || n instanceof CSSStyleRule ? n : n.element;
551
553
  if (c instanceof HTMLElement && !c.isConnected) {
552
- i.add(n);
554
+ o.add(n);
553
555
  continue;
554
556
  }
555
557
  if (n instanceof HTMLElement)
@@ -559,8 +561,8 @@ class u extends ct {
559
561
  a instanceof CSSStyleRule ? a.style.setProperty(f, s) : k(a, f, s);
560
562
  }
561
563
  }
562
- if (i.size > 0) {
563
- const n = o.filter((c) => !i.has(c));
564
+ if (o.size > 0) {
565
+ const n = i.filter((c) => !o.has(c));
564
566
  n.length === 0 ? this.#s.delete(e) : this.#s.set(e, n);
565
567
  }
566
568
  }
@@ -575,31 +577,31 @@ class u extends ct {
575
577
  #j(t) {
576
578
  const { localName: e } = t;
577
579
  if (e === "style") {
578
- const { sheet: s } = t, o = s?.cssRules ?? [], i = Array.from(o);
579
- for (const n of i)
580
+ const { sheet: s } = t, i = s?.cssRules ?? [], o = Array.from(i);
581
+ for (const n of o)
580
582
  if (n.constructor === CSSStyleRule) {
581
583
  const c = Array.from(n.style);
582
584
  for (const a of c)
583
585
  if (a.startsWith("--")) {
584
586
  const f = n.style.getPropertyValue(a);
585
- this.#l(f, n, a);
587
+ this.#h(f, n, a);
586
588
  }
587
589
  }
588
590
  } else {
589
591
  let s = "";
590
592
  if (S(t)) {
591
- this.#l(t.textContent, t);
592
- const o = t.textContent?.match(lt);
593
- o && (s = o[1]);
593
+ this.#h(t.textContent, t);
594
+ const i = t.textContent?.match(lt);
595
+ i && (s = i[1]);
594
596
  } else {
595
- const o = Array.from(t.childNodes).find(
596
- (i) => i.nodeType === Node.COMMENT_NODE
597
+ const i = Array.from(t.childNodes).find(
598
+ (o) => o.nodeType === Node.COMMENT_NODE
597
599
  );
598
- o && (s = o.textContent?.trim() ?? "");
600
+ i && (s = i.textContent?.trim() ?? "");
599
601
  }
600
602
  if (s) {
601
- const o = this.#S(t, s);
602
- o && S(t) ? t.textContent = this[o] : this.#l(s, t);
603
+ const i = this.#S(t, s);
604
+ i && S(t) ? t.textContent = this[i] : this.#h(s, t);
603
605
  }
604
606
  }
605
607
  }
@@ -625,15 +627,15 @@ class u extends ct {
625
627
  e[c.trim()] = a.trim();
626
628
  }
627
629
  this.#d = e, this.#i = new FormData(), this.#b = this.attachInternals(), this.#b.setFormValue(this.#i);
628
- const o = Object.keys(this.#t.properties), i = this.#m;
629
- for (const n of o)
630
- i[n] = this[n];
630
+ const i = Object.keys(this.#t.properties), o = this.#m;
631
+ for (const n of i)
632
+ o[n] = this[n];
631
633
  }
632
634
  formResetCallback() {
633
635
  const t = this.#m;
634
636
  for (const e of Object.keys(t)) {
635
637
  let s = t[e];
636
- N.test(s) && (s = this.#o(s)), this[e] = s;
638
+ L.test(s) && (s = this.#o(s)), this[e] = s;
637
639
  }
638
640
  }
639
641
  static getAttrName(t) {
@@ -642,22 +644,22 @@ class u extends ct {
642
644
  }
643
645
  static getPropName(t) {
644
646
  let e = this.attrToPropMap.get(t);
645
- return e || (e = t.replace(/-([a-z])/g, (s, o) => o.toUpperCase()), this.attrToPropMap.set(t, e)), e;
647
+ return e || (e = t.replace(/-([a-z])/g, (s, i) => i.toUpperCase()), this.attrToPropMap.set(t, e)), e;
646
648
  }
647
649
  #H(t, e, s) {
648
650
  if (s.length !== 1) return;
649
- const [o] = s;
650
- if (!N.test(o)) return;
651
- const i = B(t) || S(t);
651
+ const [i] = s;
652
+ if (!L.test(i)) return;
653
+ const o = B(t) || S(t);
652
654
  let [n, c] = (e ?? "").split(":");
653
- if (!(i && n === "value" || S(t))) return;
655
+ if (!(o && n === "value" || S(t))) return;
654
656
  c ? t["on" + c] === void 0 && this.#e(t, e, "refers to an unsupported event name") : c = "change";
655
- const f = A(o);
656
- t.addEventListener(c, (l) => {
657
- const { target: h } = l;
658
- if (!h) return;
659
- const m = h.value, { type: x } = this.#t.properties[f];
660
- this[f] = x === Number ? H(m) : m, this.#v(f);
657
+ const f = A(i);
658
+ t.addEventListener(c, (h) => {
659
+ const { target: l } = h;
660
+ if (!l) return;
661
+ const u = l.value, { type: v } = this.#t.properties[f];
662
+ this[f] = v === Number ? H(u) : u, this.#x(f);
661
663
  });
662
664
  }
663
665
  #n(t) {
@@ -672,7 +674,7 @@ class u extends ct {
672
674
  #M(t) {
673
675
  const e = Array.from(t.querySelectorAll("*"));
674
676
  for (const s of e)
675
- this.#N(s), s.firstElementChild || this.#j(s);
677
+ this.#L(s), s.firstElementChild || this.#j(s);
676
678
  }
677
679
  // formAssociated is only needed when the component is inside a form.
678
680
  #A() {
@@ -685,35 +687,41 @@ class u extends ct {
685
687
  );
686
688
  }
687
689
  static get observedAttributes() {
688
- const t = Object.entries(this.properties || {}).filter(([e, s]) => !s.computed).map(([e]) => u.getAttrName(e));
690
+ const t = Object.entries(this.properties || {}).filter(([e, s]) => !s.computed).map(([e]) => d.getAttrName(e));
689
691
  return t.includes("disabled") || t.push("disabled"), t;
690
692
  }
691
693
  // Subclasses can override this to add functionality.
692
694
  propertyChangedCallback(t, e, s) {
693
695
  }
694
696
  #S(t, e) {
695
- if (!e || !N.test(e)) return;
697
+ if (!e || !L.test(e)) return;
696
698
  const s = A(e);
697
- return this[s] === void 0 && this.#h(t, "", s), s;
699
+ return this[s] === void 0 && this.#l(t, "", s), s;
698
700
  }
699
- #v(t) {
701
+ #x(t) {
700
702
  const e = this.#t.propToExprsMap.get(t) || [];
701
703
  this.#T(e);
702
704
  }
703
705
  #k(t, e) {
704
- const { computed: s, uses: o } = e, i = this.#t.propToComputedMap;
705
- function n(a, f) {
706
- let l = i.get(a);
707
- l || (l = [], i.set(a, l)), l.push([t, f]);
706
+ const s = this.#t, i = s.propToComputedMap;
707
+ function o(a, f) {
708
+ let h = i.get(a);
709
+ h || (h = [], i.set(a, h)), h.push([t, f]);
708
710
  }
709
- const c = s.match(j) || [];
711
+ const { computed: n } = e, c = n.match(j) || [];
710
712
  for (const a of c) {
711
713
  const f = A(a);
712
- this[f] === void 0 && this.#h(null, t, f), typeof this[f] != "function" && n(f, s);
714
+ this[f] === void 0 && this.#l(null, t, f), typeof this[f] != "function" && o(f, n);
715
+ }
716
+ for (const a of n.matchAll(K)) {
717
+ const f = a[1];
718
+ if (typeof this[f] != "function")
719
+ throw new g(
720
+ `property ${t} computed calls non-method ${f}`
721
+ );
722
+ for (const [h, l] of Object.entries(s.properties))
723
+ l.usedBy?.includes(f) && o(h, n);
713
724
  }
714
- if (o)
715
- for (const a of o.split(","))
716
- n(a.trim(), s);
717
725
  }
718
726
  #f(t, e) {
719
727
  this.#u.add(t);
@@ -725,32 +733,32 @@ class u extends ct {
725
733
  }
726
734
  // WARNING: Do not place untrusted JavaScript expressions
727
735
  // in attribute values or the text content of elements!
728
- #l(t, e, s = void 0) {
736
+ #h(t, e, s = void 0) {
729
737
  if (!t) return;
730
- const o = this.#y(e, s, t);
731
- if (!o) {
738
+ const i = this.#y(e, s, t);
739
+ if (!i) {
732
740
  const a = t.replaceAll("this..", "this.");
733
741
  s ? k(e, s, a) : "textContent" in e && (e.textContent = a);
734
742
  return;
735
743
  }
736
- const i = this.#t;
737
- o.forEach((a) => {
744
+ const o = this.#t;
745
+ i.forEach((a) => {
738
746
  const f = A(a);
739
747
  if (typeof this[f] == "function") return;
740
- const l = i.propToExprsMap;
741
- let h = l.get(f);
742
- h || (h = [], l.set(f, h)), h.includes(t) || h.push(t);
748
+ const h = o.propToExprsMap;
749
+ let l = h.get(f);
750
+ l || (l = [], h.set(f, l)), l.includes(t) || l.push(t);
743
751
  });
744
752
  for (const [a, f] of this.#s.entries())
745
- for (const l of f) {
746
- const h = l instanceof HTMLElement || l instanceof CSSStyleRule ? l : l.element;
747
- h instanceof CSSStyleRule || h.isConnected || this.#s.set(
753
+ for (const h of f) {
754
+ const l = h instanceof HTMLElement || h instanceof CSSStyleRule ? h : h.element;
755
+ l instanceof CSSStyleRule || l.isConnected || this.#s.set(
748
756
  a,
749
- f.filter((m) => m !== l)
757
+ f.filter((u) => u !== h)
750
758
  );
751
759
  }
752
760
  let n = this.#s.get(t);
753
- n || (n = [], this.#s.set(t, n)), n.push(s ? { element: e, attrName: s } : e), e instanceof HTMLElement && this.#H(e, s, o);
761
+ n || (n = [], this.#s.set(t, n)), n.push(s ? { element: e, attrName: s } : e), e instanceof HTMLElement && this.#H(e, s, i);
754
762
  const c = this.#o(t);
755
763
  s ? k(e, s, c) : this.#P(e, c);
756
764
  }
@@ -763,37 +771,37 @@ class u extends ct {
763
771
  !this.#i || !I(e) || (this.#i.set(t, e), this.#b?.setFormValue(this.#i));
764
772
  }
765
773
  static ssr(t = {}) {
766
- throw new y('Import Wrec from "wrec/ssr" to use the ssr method.');
774
+ throw new g('Import Wrec from "wrec/ssr" to use the ssr method.');
767
775
  }
768
776
  #e(t, e, s) {
769
- const o = t instanceof HTMLElement ? t.localName : "CSS rule";
770
- throw new y(
771
- `component ${this.#t.elementName}` + (t ? `, element "${o}"` : "") + (e ? `, attribute "${e}"` : "") + ` ${s}`
777
+ const i = t instanceof HTMLElement ? t.localName : "CSS rule";
778
+ throw new g(
779
+ `component ${this.#t.elementName}` + (t ? `, element "${i}"` : "") + (e ? `, attribute "${e}"` : "") + ` ${s}`
772
780
  );
773
781
  }
774
- #h(t, e, s) {
782
+ #l(t, e, s) {
775
783
  this.#e(t, e, `refers to missing property "${s}"`);
776
784
  }
777
785
  #C(t, e) {
778
- return this.#x(t, this.getAttribute(e));
786
+ return this.#v(t, this.getAttribute(e));
779
787
  }
780
- #x(t, e) {
788
+ #v(t, e) {
781
789
  if (e?.match(j)) return e;
782
- const o = this.#t.properties[t], { type: i, values: n } = o;
783
- if (i || this.#e(null, t, "does not specify its type"), e === null)
784
- return i === Boolean ? !1 : K(o);
785
- if (i === String) {
790
+ const i = this.#t.properties[t], { type: o, values: n } = i;
791
+ if (o || this.#e(null, t, "does not specify its type"), e === null)
792
+ return o === Boolean ? !1 : U(i);
793
+ if (o === String) {
786
794
  if (n && !n.includes(e)) {
787
795
  const c = n.map((a) => `"${a}"`).join(", ");
788
796
  this.#e(null, t, `must be one of ${c}`);
789
797
  }
790
798
  return e;
791
799
  }
792
- if (i === Number) return H(e);
793
- if (i === Boolean) {
800
+ if (o === Number) return H(e);
801
+ if (o === Boolean) {
794
802
  if (e === "true") return !0;
795
803
  if (e === "false" || e === "null") return !1;
796
- const c = u.getAttrName(t);
804
+ const c = d.getAttrName(t);
797
805
  return e && e !== c && this.#e(
798
806
  null,
799
807
  t,
@@ -803,78 +811,80 @@ class u extends ct {
803
811
  }
804
812
  // Updates the matching attribute for a property.
805
813
  // VS Code thinks this is never called, but it is called by #defineProp.
806
- #_(t, e, s, o) {
814
+ #_(t, e, s, i) {
807
815
  if (I(s) && !this.#a(t)) {
808
- const i = e === Boolean ? this.hasAttribute(o) : this.#C(t, o);
809
- s !== i && st(this, o || t, s);
816
+ const o = e === Boolean ? this.hasAttribute(i) : this.#C(t, i);
817
+ s !== o && ot(this, i || t, s);
810
818
  }
811
819
  }
812
820
  // Updates all computed properties that reference this property.
813
821
  // VS Code thinks this is never called, but it is called by #defineProp.
814
822
  #F(t) {
815
823
  const s = this.#t.propToComputedMap.get(t) || [];
816
- for (const [o, i] of s)
817
- this.#f(o, this.#o(i));
824
+ for (const [i, o] of s)
825
+ this.#f(i, this.#o(o));
818
826
  }
819
827
  #P(t, e) {
820
828
  if (e === void 0) return;
821
829
  const s = t instanceof HTMLElement;
822
830
  Array.isArray(e) && (e = e.join(""));
823
- const o = typeof e;
824
- o !== "string" && o !== "number" && this.#e(
831
+ const i = typeof e;
832
+ i !== "string" && i !== "number" && this.#e(
825
833
  t,
826
834
  void 0,
827
835
  " computed content is not a string or number"
828
836
  );
829
- const i = String(e);
837
+ const o = String(e);
830
838
  if (t instanceof HTMLElement && S(t))
831
- t.value = i;
832
- else if (s && o === "string" && i.trim().startsWith("<")) {
833
- const n = nt(i);
834
- t.innerHTML = n, this.#R(t), this.#M(t);
835
- } else s && (t.textContent = i);
839
+ t.value = o;
840
+ else if (s && i === "string" && o.trim().startsWith("<")) {
841
+ const n = rt(o);
842
+ t.innerHTML = n, this.#$(t), this.#M(t);
843
+ } else s && (t.textContent = o);
836
844
  }
837
845
  // Update corresponding parent web component property if bound to one.
838
846
  // VS Code thinks this is never called, but it is called by #defineProp.
839
847
  #I(t, e) {
840
848
  const s = this.#g.get(t);
841
849
  if (!s) return;
842
- const o = this.getRootNode();
843
- if (!(o instanceof ShadowRoot)) return;
844
- const { host: i } = o;
845
- if (!i) return;
846
- const n = i;
850
+ const i = this.getRootNode();
851
+ if (!(i instanceof ShadowRoot)) return;
852
+ const { host: o } = i;
853
+ if (!o) return;
854
+ const n = o;
847
855
  n[s] = e;
848
856
  }
849
857
  // This adds expressions to the expressions arrays in propToExprsMap
850
858
  // that contain calls to methods listed the usedBy array or each property.
851
859
  #B() {
852
- let t;
860
+ const t = this.#t;
853
861
  function e() {
854
- t = /* @__PURE__ */ new Map();
855
- const i = Array.from(this.#s.keys()), n = new RegExp(`this\\.(${M})\\s*\\(`, "g");
856
- for (const c of i)
857
- for (const a of c.matchAll(n)) {
862
+ const o = /* @__PURE__ */ new Map();
863
+ t.methodToExprsMap = o;
864
+ const n = Array.from(this.#s.keys());
865
+ for (const c of n)
866
+ for (const a of c.matchAll(K)) {
858
867
  const f = a[1];
859
- let l = t.get(f);
860
- l || (l = [], t.set(f, l)), l.includes(c) || l.push(c);
868
+ let h = o.get(f);
869
+ h || (h = [], o.set(f, h)), h.includes(c) || h.push(c);
861
870
  }
862
871
  }
863
- const { properties: s, propToExprsMap: o } = this.#t;
864
- for (const [i, n] of Object.entries(s)) {
872
+ const { properties: s, propToExprsMap: i } = t;
873
+ for (const [o, n] of Object.entries(s)) {
865
874
  const { usedBy: c } = n;
866
875
  if (!c) continue;
867
- t || e.call(this);
868
- let a = o.get(i);
869
- a || (a = [], o.set(i, a));
870
- for (const f of c) {
871
- if (typeof this[f] != "function") {
872
- const h = `property ${i} usedBy contains non-method ${f}`;
873
- throw new y(h);
874
- }
875
- const l = t.get(f) || [];
876
- for (const h of l)
877
- a.includes(h) || a.push(h);
876
+ t.methodToExprsMap || e.call(this);
877
+ const { methodToExprsMap: a } = t;
878
+ let f = i.get(o);
879
+ f || (f = [], i.set(o, f));
880
+ for (const h of c) {
881
+ if (typeof this[h] != "function")
882
+ throw new g(
883
+ `property ${o} usedBy contains non-method ${h}`
884
+ );
885
+ const l = a.get(h) || [];
886
+ for (const u of l)
887
+ f.includes(u) || f.push(u);
878
888
  }
879
889
  }
880
890
  }
@@ -890,22 +900,22 @@ class u extends ct {
890
900
  e[s] = s;
891
901
  }
892
902
  this.#V(t, e);
893
- for (const [s, o] of Object.entries(e))
894
- if (this.#c(o)) {
895
- const i = q(t, s);
896
- i !== void 0 && (this[o] = i), this.#r.set(o, { state: t, stateProp: s });
903
+ for (const [s, i] of Object.entries(e))
904
+ if (this.#c(i)) {
905
+ const o = q(t, s);
906
+ o !== void 0 && (this[i] = o), this.#r.set(i, { state: t, stateProp: s });
897
907
  }
898
908
  t.addListener(this, e);
899
909
  }
900
910
  #D() {
901
911
  const t = new Set(Object.keys(this.#t.properties));
902
912
  for (const e of this.getAttributeNames())
903
- if (!rt.has(e) && !e.startsWith("on")) {
913
+ if (!ct.has(e) && !e.startsWith("on")) {
904
914
  if (e === "form-assoc") {
905
915
  this.#A();
906
916
  continue;
907
917
  }
908
- if (!t.has(u.getPropName(e))) {
918
+ if (!t.has(d.getPropName(e))) {
909
919
  if (e === "name") {
910
920
  this.#A();
911
921
  continue;
@@ -915,19 +925,19 @@ class u extends ct {
915
925
  }
916
926
  }
917
927
  #y(t, e, s) {
918
- const o = s.match(j);
919
- if (o)
920
- return o.forEach((i) => {
921
- const n = A(i);
922
- this[n] === void 0 && this.#h(t, e, n);
923
- }), o;
928
+ const i = s.match(j);
929
+ if (i)
930
+ return i.forEach((o) => {
931
+ const n = A(o);
932
+ this[n] === void 0 && this.#l(t, e, n);
933
+ }), i;
924
934
  }
925
935
  #V(t, e) {
926
- for (const [s, o] of Object.entries(e)) {
927
- let i = q(t, s);
928
- i === void 0 && this.#e(this, void 0, `invalid state path "${s}"`), i = this[o], this.#c(o) || this.#e(
936
+ for (const [s, i] of Object.entries(e)) {
937
+ let o = q(t, s);
938
+ o === void 0 && this.#e(this, void 0, `invalid state path "${s}"`), o = this[i], this.#c(i) || this.#e(
929
939
  null,
930
- o,
940
+ i,
931
941
  "refers to missing property in useState map"
932
942
  );
933
943
  }
@@ -935,81 +945,81 @@ class u extends ct {
935
945
  // When type is an array, this can't validate the type of the array elements.
936
946
  // This is called by #defineProp.
937
947
  #W(t, e, s) {
938
- const { values: o } = this.#t.properties[t];
939
- if (o) {
948
+ const { values: i } = this.#t.properties[t];
949
+ if (i) {
940
950
  let n;
941
- e !== String ? n = "declares allowed values, but its type is not String" : typeof s != "string" ? n = `value is a ${typeof s}, but type is String` : o.includes(s) || (n = `must be one of ${o.map((a) => `"${a}"`).join(", ")}`), n && this.#e(null, t, n);
951
+ e !== String ? n = "declares allowed values, but its type is not String" : typeof s != "string" ? n = `value is a ${typeof s}, but type is String` : i.includes(s) || (n = `must be one of ${i.map((a) => `"${a}"`).join(", ")}`), n && this.#e(null, t, n);
942
952
  }
943
953
  if (s instanceof e) return;
944
- let i = typeof s;
945
- if (i === "object") {
954
+ let o = typeof s;
955
+ if (o === "object") {
946
956
  const { constructor: n } = s;
947
- i = n.name, n !== e && this.#e(
957
+ o = n.name, n !== e && this.#e(
948
958
  null,
949
959
  t,
950
- `was set to a ${i}, but must be a ${e.name}`
960
+ `was set to a ${o}, but must be a ${e.name}`
951
961
  );
952
962
  }
953
- i !== e.name.toLowerCase() && this.#e(
963
+ o !== e.name.toLowerCase() && this.#e(
954
964
  null,
955
965
  t,
956
- `was set to a ${i}, but must be a ${e.name}`
966
+ `was set to a ${o}, but must be a ${e.name}`
957
967
  );
958
968
  }
959
- #R(t) {
969
+ #$(t) {
960
970
  const e = Array.from(t.querySelectorAll("*"));
961
971
  for (const s of e) {
962
- const o = [];
963
- for (const i of Array.from(s.attributes)) {
964
- const n = i.name;
972
+ const i = [];
973
+ for (const o of Array.from(s.attributes)) {
974
+ const n = o.name;
965
975
  if (n.startsWith("on")) {
966
976
  let c = n.slice(2);
967
977
  c = c[0].toLowerCase() + c.slice(1).toLowerCase();
968
- const a = i.value;
978
+ const a = o.value;
969
979
  this.#y(s, n, a);
970
980
  let f;
971
- typeof this[a] == "function" ? f = (l) => this[a](l) : (this.#y(s, n, a), f = () => this.#o(a)), s.addEventListener(c, f), o.push(n);
981
+ typeof this[a] == "function" ? f = (h) => this[a](h) : (this.#y(s, n, a), f = () => this.#o(a)), s.addEventListener(c, f), i.push(n);
972
982
  }
973
983
  }
974
- for (const i of o)
975
- s.removeAttribute(i);
984
+ for (const o of i)
985
+ s.removeAttribute(o);
976
986
  }
977
987
  }
978
988
  }
979
- function Tt(r, ...t) {
980
- let e = tt(r, t);
989
+ function Mt(r, ...t) {
990
+ let e = et(r, t);
981
991
  for (; ; ) {
982
- const s = at.exec(e);
992
+ const s = ft.exec(e);
983
993
  if (!s) break;
984
- const o = s[2];
985
- if (Q.test(o)) {
986
- const i = s[1];
987
- if (!i.startsWith("--")) {
988
- const n = `--${i}: ${o};
989
- ${i}: var(--${i})`;
990
- e = et(e, s.index, s[0].length, n);
994
+ const i = s[2];
995
+ if (tt.test(i)) {
996
+ const o = s[1];
997
+ if (!o.startsWith("--")) {
998
+ const n = `--${o}: ${i};
999
+ ${o}: var(--${o})`;
1000
+ e = st(e, s.index, s[0].length, n);
991
1001
  }
992
1002
  }
993
1003
  }
994
1004
  return e;
995
1005
  }
996
- function Mt(r, ...t) {
997
- let e = tt(r, t);
1006
+ function At(r, ...t) {
1007
+ let e = et(r, t);
998
1008
  for (; ; ) {
999
- const s = ht.exec(e);
1009
+ const s = pt.exec(e);
1000
1010
  if (!s || s[1] === "style") break;
1001
- const o = mt(s[2]);
1002
- if (Q.test(o)) {
1003
- const i = `<!-- ${o.trim()} -->`, n = s.index + s[0].indexOf(">") + 1;
1004
- e = et(e, n, o.length, i);
1011
+ const i = bt(s[2]);
1012
+ if (tt.test(i)) {
1013
+ const o = `<!-- ${i.trim()} -->`, n = s.index + s[0].indexOf(">") + 1;
1014
+ e = st(e, n, i.length, o);
1005
1015
  }
1006
1016
  }
1007
1017
  return e;
1008
1018
  }
1009
1019
  export {
1010
- u as Wrec,
1020
+ d as Wrec,
1011
1021
  _ as WrecState,
1012
- Et as createElement,
1013
- Tt as css,
1014
- Mt as html
1022
+ Tt as createElement,
1023
+ Mt as css,
1024
+ At as html
1015
1025
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "wrec",
3
3
  "description": "a small library that greatly simplifies building web components",
4
4
  "author": "R. Mark Volkmann",
5
- "version": "0.23.1",
5
+ "version": "0.23.2",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",