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.
- package/dist/wrec-ssr.d.ts +1 -0
- package/dist/wrec.d.ts +1 -0
- package/dist/wrec.es.js +339 -329
- package/package.json +1 -1
package/dist/wrec-ssr.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.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
|
|
5
|
-
var p = (r, t, 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
|
|
8
|
-
const s = /* @__PURE__ */ new WeakMap(),
|
|
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(
|
|
12
|
-
const c = Reflect.get(
|
|
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,
|
|
17
|
-
return s.set(c,
|
|
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(
|
|
21
|
-
const a = Reflect.get(
|
|
20
|
+
set(o, n, c) {
|
|
21
|
+
const a = Reflect.get(o, n);
|
|
22
22
|
if (a !== c) {
|
|
23
|
-
Reflect.set(
|
|
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,
|
|
30
|
+
return new Proxy(r, i);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Y(r) {
|
|
33
33
|
const t = {};
|
|
34
34
|
for (const [e, s] of Object.entries(r)) {
|
|
35
|
-
const
|
|
36
|
-
t[e] =
|
|
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,
|
|
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,
|
|
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,
|
|
51
|
-
b(this,
|
|
50
|
+
b(this, m, []);
|
|
51
|
+
b(this, x);
|
|
52
52
|
b(this, C);
|
|
53
|
-
b(this,
|
|
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,
|
|
58
|
-
const
|
|
59
|
-
|
|
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 [
|
|
63
|
-
this.addProperty(
|
|
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,
|
|
85
|
-
(
|
|
84
|
+
const s = p(this, m).find(
|
|
85
|
+
(i) => i.listenerRef.deref() === t
|
|
86
86
|
);
|
|
87
87
|
if (s) {
|
|
88
|
-
const { propertyMap:
|
|
89
|
-
for (const [
|
|
90
|
-
o
|
|
88
|
+
const { propertyMap: i } = s;
|
|
89
|
+
for (const [o, n] of Object.entries(e))
|
|
90
|
+
i[o] = n;
|
|
91
91
|
} else
|
|
92
|
-
p(this,
|
|
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,
|
|
101
|
+
return p(this, y)[t];
|
|
102
102
|
},
|
|
103
103
|
set(s) {
|
|
104
|
-
p(this,
|
|
104
|
+
p(this, y)[t] = s;
|
|
105
105
|
}
|
|
106
|
-
}), p(this,
|
|
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,
|
|
115
|
-
for (const [t, e] of Object.entries(p(this,
|
|
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,
|
|
119
|
+
E(this, m, p(this, m).filter((e) => e.listenerRef.deref() !== t));
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
w = new WeakMap(),
|
|
123
|
-
const
|
|
124
|
-
for (const
|
|
125
|
-
const n =
|
|
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
|
-
|
|
127
|
+
i.add(o);
|
|
128
128
|
else if (P && n instanceof HTMLElement && !n.isConnected)
|
|
129
|
-
|
|
129
|
+
i.add(o);
|
|
130
130
|
else {
|
|
131
|
-
const { propertyMap: 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,
|
|
142
|
-
(
|
|
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 =
|
|
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
|
|
160
|
-
const s = t.split("."),
|
|
161
|
-
let
|
|
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 ===
|
|
163
|
+
c === i ? o[n] = e : o = o[n];
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
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: (
|
|
171
|
-
if (
|
|
170
|
+
onTag: (i, o) => {
|
|
171
|
+
if (nt.has(i)) return o;
|
|
172
172
|
},
|
|
173
|
-
onTagAttr(
|
|
174
|
-
if (
|
|
173
|
+
onTagAttr(i, o, n) {
|
|
174
|
+
if (o.startsWith("on")) return "";
|
|
175
175
|
},
|
|
176
|
-
safeAttrValue(
|
|
177
|
-
return
|
|
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, (
|
|
187
|
-
let
|
|
186
|
+
r = r.replace(/<!--[\s\S]*?-->/g, (i) => {
|
|
187
|
+
let o = "";
|
|
188
188
|
do
|
|
189
|
-
|
|
190
|
-
while (r.includes(
|
|
191
|
-
return e.push(
|
|
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((
|
|
194
|
+
return e.forEach((i, o) => {
|
|
195
195
|
const n = new RegExp(
|
|
196
|
-
`${J}${
|
|
196
|
+
`${J}${o}${X}`,
|
|
197
197
|
"g"
|
|
198
198
|
);
|
|
199
|
-
s = s.replace(n,
|
|
199
|
+
s = s.replace(n, i);
|
|
200
200
|
}), s;
|
|
201
201
|
}
|
|
202
|
-
const
|
|
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
|
-
]),
|
|
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
|
|
222
|
+
class g extends Error {
|
|
223
223
|
}
|
|
224
|
-
const
|
|
225
|
-
function
|
|
226
|
-
return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof
|
|
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
|
|
228
|
+
function Tt(r, t, e) {
|
|
229
229
|
const s = document.createElement(r);
|
|
230
230
|
if (t)
|
|
231
|
-
for (const [
|
|
232
|
-
s.setAttribute(
|
|
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
|
|
236
|
-
function
|
|
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(
|
|
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(
|
|
244
|
-
function
|
|
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,
|
|
247
|
-
e += s + r[
|
|
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
|
|
262
|
-
function
|
|
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
|
|
267
|
+
if (isNaN(t)) throw new g(`can't convert "${r}" to a number`);
|
|
268
268
|
return t;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
const [s,
|
|
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
|
|
276
|
-
r[
|
|
275
|
+
const o = d.getPropName(s);
|
|
276
|
+
r[o] = e;
|
|
277
277
|
} else {
|
|
278
|
-
const
|
|
279
|
-
|
|
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
|
|
283
|
-
r[
|
|
282
|
+
const o = d.getPropName(t);
|
|
283
|
+
r[o] = e;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
function k(r, t, e) {
|
|
287
|
-
const [s,
|
|
288
|
-
r instanceof CSSStyleRule ? r.style.setProperty(s, 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
|
|
290
|
+
async function gt(r) {
|
|
291
291
|
const t = /* @__PURE__ */ new Set();
|
|
292
|
-
for (const s of
|
|
293
|
-
const { localName:
|
|
294
|
-
|
|
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((
|
|
297
|
+
return new Promise((i, o) => {
|
|
298
298
|
setTimeout(() => {
|
|
299
299
|
const n = `custom element <${s}> not defined`;
|
|
300
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
398
|
-
if (!this.#a(
|
|
399
|
-
const
|
|
400
|
-
this[
|
|
401
|
-
const n = this.#d[
|
|
402
|
-
n && this.setFormValue(n, String(
|
|
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
|
|
414
|
-
s.add(
|
|
415
|
+
for (const h of f)
|
|
416
|
+
s.add(h);
|
|
415
417
|
}
|
|
416
|
-
const
|
|
418
|
+
const i = this.#t.propToComputedMap, o = /* @__PURE__ */ new Set(), n = {};
|
|
417
419
|
for (const c of Object.keys(t)) {
|
|
418
|
-
const a =
|
|
419
|
-
for (const [f,
|
|
420
|
-
|
|
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
|
|
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
|
|
427
|
-
s.add(
|
|
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
|
|
432
|
-
const f = n[a],
|
|
433
|
-
JSON.stringify(
|
|
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
|
|
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
|
|
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.#
|
|
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:
|
|
462
|
-
|
|
463
|
+
for (const [s, { computed: i }] of Object.entries(e))
|
|
464
|
+
i && this.#f(s, this.#o(i));
|
|
463
465
|
}
|
|
464
|
-
#
|
|
466
|
+
#N() {
|
|
465
467
|
const t = this.#t, { observedAttributes: e, properties: s } = t;
|
|
466
|
-
for (const [
|
|
467
|
-
|
|
468
|
-
for (const [
|
|
469
|
-
|
|
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
|
|
474
|
-
const
|
|
475
|
-
e.required && !
|
|
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 ||
|
|
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(
|
|
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
|
|
490
|
-
const
|
|
491
|
-
if (
|
|
492
|
-
this.#W(t, c,
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
const
|
|
496
|
-
|
|
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:
|
|
500
|
-
value:
|
|
501
|
+
oldValue: l,
|
|
502
|
+
value: h
|
|
501
503
|
});
|
|
502
504
|
}
|
|
503
505
|
});
|
|
504
506
|
}
|
|
505
507
|
#E() {
|
|
506
|
-
const t = this.hasAttribute("disabled"), e =
|
|
508
|
+
const t = this.hasAttribute("disabled"), e = $(this.shadowRoot);
|
|
507
509
|
for (const s of e)
|
|
508
|
-
|
|
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
|
-
#
|
|
530
|
-
const e = t instanceof
|
|
531
|
+
#L(t) {
|
|
532
|
+
const e = t instanceof d;
|
|
531
533
|
for (const s of t.getAttributeNames()) {
|
|
532
|
-
const
|
|
533
|
-
if (
|
|
534
|
-
const n = this[
|
|
535
|
-
n === void 0 && this.#
|
|
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 =
|
|
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[
|
|
539
|
-
|
|
540
|
-
|
|
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.#
|
|
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),
|
|
549
|
-
for (const n of
|
|
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
|
-
|
|
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 (
|
|
563
|
-
const n =
|
|
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,
|
|
579
|
-
for (const n of
|
|
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.#
|
|
587
|
+
this.#h(f, n, a);
|
|
586
588
|
}
|
|
587
589
|
}
|
|
588
590
|
} else {
|
|
589
591
|
let s = "";
|
|
590
592
|
if (S(t)) {
|
|
591
|
-
this.#
|
|
592
|
-
const
|
|
593
|
-
|
|
593
|
+
this.#h(t.textContent, t);
|
|
594
|
+
const i = t.textContent?.match(lt);
|
|
595
|
+
i && (s = i[1]);
|
|
594
596
|
} else {
|
|
595
|
-
const
|
|
596
|
-
(
|
|
597
|
+
const i = Array.from(t.childNodes).find(
|
|
598
|
+
(o) => o.nodeType === Node.COMMENT_NODE
|
|
597
599
|
);
|
|
598
|
-
|
|
600
|
+
i && (s = i.textContent?.trim() ?? "");
|
|
599
601
|
}
|
|
600
602
|
if (s) {
|
|
601
|
-
const
|
|
602
|
-
|
|
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
|
|
629
|
-
for (const n of
|
|
630
|
-
|
|
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
|
-
|
|
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,
|
|
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 [
|
|
650
|
-
if (!
|
|
651
|
-
const
|
|
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 (!(
|
|
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(
|
|
656
|
-
t.addEventListener(c, (
|
|
657
|
-
const { target:
|
|
658
|
-
if (!
|
|
659
|
-
const
|
|
660
|
-
this[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.#
|
|
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]) =>
|
|
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 || !
|
|
697
|
+
if (!e || !L.test(e)) return;
|
|
696
698
|
const s = A(e);
|
|
697
|
-
return this[s] === void 0 && this.#
|
|
699
|
+
return this[s] === void 0 && this.#l(t, "", s), s;
|
|
698
700
|
}
|
|
699
|
-
#
|
|
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
|
|
705
|
-
function
|
|
706
|
-
let
|
|
707
|
-
|
|
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 =
|
|
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.#
|
|
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
|
-
#
|
|
736
|
+
#h(t, e, s = void 0) {
|
|
729
737
|
if (!t) return;
|
|
730
|
-
const
|
|
731
|
-
if (!
|
|
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
|
|
737
|
-
|
|
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
|
|
741
|
-
let
|
|
742
|
-
|
|
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
|
|
746
|
-
const
|
|
747
|
-
|
|
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((
|
|
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,
|
|
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
|
|
774
|
+
throw new g('Import Wrec from "wrec/ssr" to use the ssr method.');
|
|
767
775
|
}
|
|
768
776
|
#e(t, e, s) {
|
|
769
|
-
const
|
|
770
|
-
throw new
|
|
771
|
-
`component ${this.#t.elementName}` + (t ? `, element "${
|
|
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
|
-
#
|
|
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.#
|
|
786
|
+
return this.#v(t, this.getAttribute(e));
|
|
779
787
|
}
|
|
780
|
-
#
|
|
788
|
+
#v(t, e) {
|
|
781
789
|
if (e?.match(j)) return e;
|
|
782
|
-
const
|
|
783
|
-
if (
|
|
784
|
-
return
|
|
785
|
-
if (
|
|
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 (
|
|
793
|
-
if (
|
|
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 =
|
|
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,
|
|
814
|
+
#_(t, e, s, i) {
|
|
807
815
|
if (I(s) && !this.#a(t)) {
|
|
808
|
-
const
|
|
809
|
-
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 [
|
|
817
|
-
this.#f(
|
|
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
|
|
824
|
-
|
|
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
|
|
837
|
+
const o = String(e);
|
|
830
838
|
if (t instanceof HTMLElement && S(t))
|
|
831
|
-
t.value =
|
|
832
|
-
else if (s &&
|
|
833
|
-
const n =
|
|
834
|
-
t.innerHTML = n, this
|
|
835
|
-
} else s && (t.textContent =
|
|
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
|
|
843
|
-
if (!(
|
|
844
|
-
const { host:
|
|
845
|
-
if (!
|
|
846
|
-
const n =
|
|
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
|
-
|
|
860
|
+
const t = this.#t;
|
|
853
861
|
function e() {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
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
|
|
860
|
-
|
|
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:
|
|
864
|
-
for (const [
|
|
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
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
throw new
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
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,
|
|
894
|
-
if (this.#c(
|
|
895
|
-
const
|
|
896
|
-
|
|
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 (!
|
|
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(
|
|
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
|
|
919
|
-
if (
|
|
920
|
-
return
|
|
921
|
-
const n = A(
|
|
922
|
-
this[n] === void 0 && this.#
|
|
923
|
-
}),
|
|
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,
|
|
927
|
-
let
|
|
928
|
-
|
|
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
|
-
|
|
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:
|
|
939
|
-
if (
|
|
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` :
|
|
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
|
|
945
|
-
if (
|
|
954
|
+
let o = typeof s;
|
|
955
|
+
if (o === "object") {
|
|
946
956
|
const { constructor: n } = s;
|
|
947
|
-
|
|
957
|
+
o = n.name, n !== e && this.#e(
|
|
948
958
|
null,
|
|
949
959
|
t,
|
|
950
|
-
`was set to a ${
|
|
960
|
+
`was set to a ${o}, but must be a ${e.name}`
|
|
951
961
|
);
|
|
952
962
|
}
|
|
953
|
-
|
|
963
|
+
o !== e.name.toLowerCase() && this.#e(
|
|
954
964
|
null,
|
|
955
965
|
t,
|
|
956
|
-
`was set to a ${
|
|
966
|
+
`was set to a ${o}, but must be a ${e.name}`
|
|
957
967
|
);
|
|
958
968
|
}
|
|
959
|
-
|
|
969
|
+
#$(t) {
|
|
960
970
|
const e = Array.from(t.querySelectorAll("*"));
|
|
961
971
|
for (const s of e) {
|
|
962
|
-
const
|
|
963
|
-
for (const
|
|
964
|
-
const n =
|
|
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 =
|
|
978
|
+
const a = o.value;
|
|
969
979
|
this.#y(s, n, a);
|
|
970
980
|
let f;
|
|
971
|
-
typeof this[a] == "function" ? f = (
|
|
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
|
|
975
|
-
s.removeAttribute(
|
|
984
|
+
for (const o of i)
|
|
985
|
+
s.removeAttribute(o);
|
|
976
986
|
}
|
|
977
987
|
}
|
|
978
988
|
}
|
|
979
|
-
function
|
|
980
|
-
let e =
|
|
989
|
+
function Mt(r, ...t) {
|
|
990
|
+
let e = et(r, t);
|
|
981
991
|
for (; ; ) {
|
|
982
|
-
const s =
|
|
992
|
+
const s = ft.exec(e);
|
|
983
993
|
if (!s) break;
|
|
984
|
-
const
|
|
985
|
-
if (
|
|
986
|
-
const
|
|
987
|
-
if (!
|
|
988
|
-
const n = `--${
|
|
989
|
-
${
|
|
990
|
-
e =
|
|
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
|
|
997
|
-
let e =
|
|
1006
|
+
function At(r, ...t) {
|
|
1007
|
+
let e = et(r, t);
|
|
998
1008
|
for (; ; ) {
|
|
999
|
-
const s =
|
|
1009
|
+
const s = pt.exec(e);
|
|
1000
1010
|
if (!s || s[1] === "style") break;
|
|
1001
|
-
const
|
|
1002
|
-
if (
|
|
1003
|
-
const
|
|
1004
|
-
e =
|
|
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
|
-
|
|
1020
|
+
d as Wrec,
|
|
1011
1021
|
_ as WrecState,
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1022
|
+
Tt as createElement,
|
|
1023
|
+
Mt as css,
|
|
1024
|
+
At as html
|
|
1015
1025
|
};
|