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