wrec 0.18.2 → 0.18.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/README.md +5 -0
- package/dist/wrec.es.js +313 -342
- package/dist/wrec.js +11 -41
- package/dist/wrec.js.map +1 -1
- package/dist/wrec.min.js +1 -1
- package/dist/wrec.umd.js +4 -2
- package/package.json +1 -1
package/dist/wrec.es.js
CHANGED
|
@@ -1,89 +1,83 @@
|
|
|
1
|
-
function
|
|
2
|
-
let
|
|
3
|
-
for (const
|
|
4
|
-
|
|
5
|
-
return
|
|
1
|
+
function R(r, t) {
|
|
2
|
+
let s = r;
|
|
3
|
+
for (const e of t.split("."))
|
|
4
|
+
s = s[e];
|
|
5
|
+
return s;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
let i =
|
|
10
|
-
|
|
11
|
-
h === o ? i[
|
|
7
|
+
function O(r, t, s) {
|
|
8
|
+
const e = t.split("."), o = e.length - 1;
|
|
9
|
+
let i = r;
|
|
10
|
+
e.forEach((n, h) => {
|
|
11
|
+
h === o ? i[n] = s : i = i[n];
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
class m extends Error {
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
function I(
|
|
18
|
-
return
|
|
16
|
+
const k = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, P = "a-zA-Z_$", F = P + "0-9", b = `[${P}][${F}]*`, j = /<!--\s*(.*?)\s*-->/, _ = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, A = new RegExp(`^this\\.${b}$`), y = new RegExp(`this\\.${b}(\\.${b})*`, "g"), N = new RegExp(`this\\.${b}(\\.${b})*`), V = /* @__PURE__ */ new Set(["class", "style"]), $ = 5;
|
|
17
|
+
function I(r) {
|
|
18
|
+
return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof u;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
for (const e of Array.from(n.cssRules))
|
|
23
|
-
t.insertRule(e.cssText);
|
|
24
|
-
return t;
|
|
25
|
-
}
|
|
26
|
-
function z(n, t, e) {
|
|
27
|
-
const s = document.createElement(n);
|
|
20
|
+
function q(r, t, s) {
|
|
21
|
+
const e = document.createElement(r);
|
|
28
22
|
if (t)
|
|
29
23
|
for (const [o, i] of Object.entries(t))
|
|
30
|
-
|
|
31
|
-
return
|
|
24
|
+
e.setAttribute(o, i);
|
|
25
|
+
return s && (e.innerHTML = s), e;
|
|
32
26
|
}
|
|
33
|
-
const
|
|
34
|
-
function w(
|
|
27
|
+
const D = (r) => r === String ? "" : r === Number ? 0 : r === Boolean ? !1 : r === Array ? [] : r === Object ? {} : void 0;
|
|
28
|
+
function w(r) {
|
|
35
29
|
const t = [];
|
|
36
|
-
let
|
|
37
|
-
for (;
|
|
38
|
-
t.push(
|
|
30
|
+
let s = r.firstElementChild;
|
|
31
|
+
for (; s; )
|
|
32
|
+
t.push(s), s.shadowRoot && t.push(...w(s.shadowRoot)), s.firstElementChild && t.push(...w(s)), s = s.nextElementSibling;
|
|
39
33
|
return t;
|
|
40
34
|
}
|
|
41
|
-
const
|
|
42
|
-
function x(
|
|
43
|
-
let
|
|
44
|
-
return t.forEach((
|
|
45
|
-
|
|
46
|
-
}),
|
|
35
|
+
const E = (r) => r.substring($).split(".")[0];
|
|
36
|
+
function x(r, t) {
|
|
37
|
+
let s = r[0];
|
|
38
|
+
return t.forEach((e, o) => {
|
|
39
|
+
s += e + r[o + 1];
|
|
40
|
+
}), s;
|
|
47
41
|
}
|
|
48
|
-
function
|
|
49
|
-
const t = typeof
|
|
42
|
+
function S(r) {
|
|
43
|
+
const t = typeof r;
|
|
50
44
|
return t === "string" || t === "number" || t === "boolean";
|
|
51
45
|
}
|
|
52
|
-
function d(
|
|
53
|
-
return
|
|
46
|
+
function d(r) {
|
|
47
|
+
return r.localName === "textarea";
|
|
54
48
|
}
|
|
55
|
-
function
|
|
56
|
-
const { localName: t } =
|
|
49
|
+
function v(r) {
|
|
50
|
+
const { localName: t } = r;
|
|
57
51
|
return t === "input" || t === "select";
|
|
58
52
|
}
|
|
59
|
-
const
|
|
60
|
-
function L(
|
|
61
|
-
return
|
|
53
|
+
const B = (r) => r.replace(/<!--[\s\S]*?-->/g, "");
|
|
54
|
+
function L(r, t, s, e) {
|
|
55
|
+
return r.slice(0, t) + e + r.slice(t + s);
|
|
62
56
|
}
|
|
63
|
-
function
|
|
64
|
-
const t = Number(
|
|
65
|
-
if (isNaN(t)) throw new m(`can't convert "${
|
|
57
|
+
function C(r) {
|
|
58
|
+
const t = Number(r);
|
|
59
|
+
if (isNaN(t)) throw new m(`can't convert "${r}" to a number`);
|
|
66
60
|
return t;
|
|
67
61
|
}
|
|
68
|
-
function
|
|
69
|
-
const [
|
|
70
|
-
if (
|
|
71
|
-
if (typeof
|
|
72
|
-
|
|
73
|
-
const i = u.getPropName(
|
|
74
|
-
|
|
62
|
+
function H(r, t, s) {
|
|
63
|
+
const [e, o] = t.split(":");
|
|
64
|
+
if (S(s))
|
|
65
|
+
if (typeof s == "boolean") {
|
|
66
|
+
s ? r.setAttribute(e, e) : r.removeAttribute(e);
|
|
67
|
+
const i = u.getPropName(e);
|
|
68
|
+
r[i] = s;
|
|
75
69
|
} else {
|
|
76
|
-
const i =
|
|
77
|
-
i !==
|
|
70
|
+
const i = r.getAttribute(t), n = String(s);
|
|
71
|
+
i !== n && (r.setAttribute(e, n), e === "value" && v(r) && (r.value = n));
|
|
78
72
|
}
|
|
79
73
|
else {
|
|
80
74
|
const i = u.getPropName(t);
|
|
81
|
-
|
|
75
|
+
r[i] = s;
|
|
82
76
|
}
|
|
83
77
|
}
|
|
84
|
-
function
|
|
85
|
-
const [
|
|
86
|
-
|
|
78
|
+
function T(r, t, s) {
|
|
79
|
+
const [e, o] = t.split(":");
|
|
80
|
+
r instanceof CSSStyleRule ? r.style.setProperty(e, s) : (H(r, e, s), e === "value" && v(r) && (r.value = s));
|
|
87
81
|
}
|
|
88
82
|
class u extends HTMLElement {
|
|
89
83
|
// This is used to lookup the camelCase property name
|
|
@@ -117,17 +111,15 @@ class u extends HTMLElement {
|
|
|
117
111
|
// This is a map from properties to expressions that refer to them.
|
|
118
112
|
// It is the sma for all instances of a component.
|
|
119
113
|
// This map cannot be private.
|
|
120
|
-
//static propToExprsMap: Map<string, string[]> | null = null;
|
|
121
114
|
static propToExprsMap;
|
|
122
|
-
static stylesheet = null;
|
|
123
115
|
static template = null;
|
|
124
116
|
#t = this.constructor;
|
|
125
117
|
// This is a map from expressions to references to them
|
|
126
118
|
// which can be found in element text content,
|
|
127
119
|
// attribute values, and CSS property values.
|
|
128
120
|
// Each component instance needs its own map.
|
|
129
|
-
#
|
|
130
|
-
#
|
|
121
|
+
#e = /* @__PURE__ */ new Map();
|
|
122
|
+
#c = {};
|
|
131
123
|
#i;
|
|
132
124
|
// For components that set `formAssociated` to true,
|
|
133
125
|
// this stores in the initial value of each property
|
|
@@ -148,157 +140,147 @@ class u extends HTMLElement {
|
|
|
148
140
|
const t = this.#t;
|
|
149
141
|
t.properties || (t.properties = {}), t.propToComputedMap || (t.propToComputedMap = /* @__PURE__ */ new Map()), t.propToExprsMap || (t.propToExprsMap = /* @__PURE__ */ new Map());
|
|
150
142
|
}
|
|
151
|
-
attributeChangedCallback(t,
|
|
143
|
+
attributeChangedCallback(t, s, e) {
|
|
152
144
|
t === "disabled" && this.#m();
|
|
153
145
|
const o = u.getPropName(t);
|
|
154
|
-
if (this.#
|
|
155
|
-
const i = this.#
|
|
146
|
+
if (this.#n(o)) {
|
|
147
|
+
const i = this.#y(o, String(e));
|
|
156
148
|
this[o] = i;
|
|
157
|
-
const
|
|
158
|
-
|
|
149
|
+
const n = this.#c[o];
|
|
150
|
+
n && this.setFormValue(n, String(i)), this.propertyChangedCallback(o, s, e);
|
|
159
151
|
}
|
|
160
152
|
}
|
|
161
153
|
#w() {
|
|
162
154
|
if (!this.shadowRoot) return;
|
|
163
155
|
const t = this.#t;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
let e = t.template;
|
|
174
|
-
if (!e) {
|
|
175
|
-
e = t.template = document.createElement("template");
|
|
176
|
-
const s = t.html.trim();
|
|
177
|
-
e.innerHTML = s.startsWith("<") ? s : `<span><!--${s}--></span>`;
|
|
156
|
+
let { template: s } = t;
|
|
157
|
+
if (!s) {
|
|
158
|
+
s = t.template = document.createElement("template");
|
|
159
|
+
let e = `<style>
|
|
160
|
+
:host([hidden]) { display: none; }`;
|
|
161
|
+
t.css && (e += t.css), e += `</style>
|
|
162
|
+
`;
|
|
163
|
+
let o = t.html.trim();
|
|
164
|
+
o.startsWith("<") || (o = `<span><!--${o}--></span>`), s.innerHTML = e + o;
|
|
178
165
|
}
|
|
179
|
-
this.shadowRoot.replaceChildren(
|
|
166
|
+
this.shadowRoot.replaceChildren(s.content.cloneNode(!0));
|
|
180
167
|
}
|
|
181
|
-
changed(t,
|
|
182
|
-
this[
|
|
168
|
+
changed(t, s, e) {
|
|
169
|
+
this[s] = e;
|
|
183
170
|
}
|
|
184
171
|
connectedCallback() {
|
|
185
|
-
this.#O(), this.#
|
|
186
|
-
|
|
187
|
-
this.#C(this.shadowRoot), this.#b(this.shadowRoot);
|
|
188
|
-
for (const t of this.shadowRoot.adoptedStyleSheets)
|
|
189
|
-
this.#N(t);
|
|
190
|
-
}
|
|
191
|
-
this.#T();
|
|
172
|
+
this.#O(), this.#v(), this.#w(), this.hasAttribute("disabled") && this.#m(), requestAnimationFrame(() => {
|
|
173
|
+
this.shadowRoot && (this.#T(this.shadowRoot), this.#b(this.shadowRoot)), this.#S();
|
|
192
174
|
});
|
|
193
175
|
}
|
|
194
|
-
#
|
|
195
|
-
const t = this.#t, { properties:
|
|
196
|
-
for (const [
|
|
197
|
-
o && (this[
|
|
176
|
+
#S() {
|
|
177
|
+
const t = this.#t, { properties: s } = t;
|
|
178
|
+
for (const [e, { computed: o }] of Object.entries(s))
|
|
179
|
+
o && (this[e] = this.#o(o));
|
|
198
180
|
}
|
|
199
|
-
#
|
|
200
|
-
const t = this.#t, { observedAttributes:
|
|
201
|
-
for (const [o, i] of Object.entries(
|
|
202
|
-
this.#
|
|
181
|
+
#v() {
|
|
182
|
+
const t = this.#t, { observedAttributes: s, properties: e } = t;
|
|
183
|
+
for (const [o, i] of Object.entries(e))
|
|
184
|
+
this.#M(o, i, s);
|
|
203
185
|
}
|
|
204
|
-
#
|
|
186
|
+
#M(t, s, e) {
|
|
205
187
|
const o = u.getAttrName(t), i = this.hasAttribute(o);
|
|
206
|
-
|
|
207
|
-
let
|
|
208
|
-
this.hasOwnProperty(t) && (
|
|
209
|
-
const { type: h } =
|
|
210
|
-
this[f] =
|
|
188
|
+
s.required && !i && this.#s(this, t, "is a required attribute");
|
|
189
|
+
let n = s.value;
|
|
190
|
+
this.hasOwnProperty(t) && (n = this[t], delete this[t]);
|
|
191
|
+
const { type: h } = s, a = h === Boolean ? n || i : e.includes(o) && i ? this.#A(t, o) : n || D(h), f = "#" + t;
|
|
192
|
+
this[f] = a, s.computed && this.#$(t, s), Object.defineProperty(this, t, {
|
|
211
193
|
enumerable: !0,
|
|
212
194
|
get() {
|
|
213
195
|
return this[f];
|
|
214
196
|
},
|
|
215
|
-
set(
|
|
216
|
-
h === Number && typeof
|
|
197
|
+
set(c) {
|
|
198
|
+
h === Number && typeof c == "string" && (c = C(c));
|
|
217
199
|
const l = this[f];
|
|
218
|
-
if (
|
|
219
|
-
this.#
|
|
220
|
-
const { state: p, stateProp:
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
|
|
200
|
+
if (c === l) return;
|
|
201
|
+
this.#F(t, h, c), this[f] = c;
|
|
202
|
+
const { state: p, stateProp: g } = this.#t.properties[t];
|
|
203
|
+
g && O(p, g, c), this.#L(t), this.#x(t, h, c, o), this.#E(t), this.#H(t, c);
|
|
204
|
+
const M = this.#c[t];
|
|
205
|
+
M && this.setFormValue(M, String(c)), this.propertyChangedCallback(t, l, c), s.dispatch && this.dispatch("change", { [t]: c });
|
|
224
206
|
}
|
|
225
207
|
});
|
|
226
208
|
}
|
|
227
209
|
#m() {
|
|
228
|
-
const t = this.hasAttribute("disabled"),
|
|
229
|
-
for (const
|
|
230
|
-
I(
|
|
210
|
+
const t = this.hasAttribute("disabled"), s = w(this.shadowRoot);
|
|
211
|
+
for (const e of s)
|
|
212
|
+
I(e) && (e.disabled = t);
|
|
231
213
|
}
|
|
232
214
|
disconnectedCallback() {
|
|
233
|
-
this.#
|
|
215
|
+
this.#e.clear(), this.#f.clear(), this.#l.clear();
|
|
234
216
|
}
|
|
235
|
-
dispatch(t,
|
|
217
|
+
dispatch(t, s) {
|
|
236
218
|
this.dispatchEvent(
|
|
237
219
|
new CustomEvent(t, {
|
|
238
220
|
bubbles: !0,
|
|
239
221
|
// up DOM tree
|
|
240
222
|
composed: !0,
|
|
241
223
|
// can pass through shadow DOM
|
|
242
|
-
detail:
|
|
224
|
+
detail: s
|
|
243
225
|
})
|
|
244
226
|
);
|
|
245
227
|
}
|
|
246
|
-
displayIfSet(t,
|
|
247
|
-
return `display: ${t ?
|
|
228
|
+
displayIfSet(t, s = "block") {
|
|
229
|
+
return `display: ${t ? s : "none"}`;
|
|
248
230
|
}
|
|
249
231
|
// This inserts a dash before each uppercase letter
|
|
250
232
|
// that is preceded by a lowercase letter or digit.
|
|
251
233
|
static elementName() {
|
|
252
234
|
return this.name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
253
235
|
}
|
|
254
|
-
#
|
|
255
|
-
const
|
|
256
|
-
for (const
|
|
257
|
-
const o = t.getAttribute(
|
|
236
|
+
#R(t) {
|
|
237
|
+
const s = t instanceof u;
|
|
238
|
+
for (const e of t.getAttributeNames()) {
|
|
239
|
+
const o = t.getAttribute(e), i = this.#g(t, o);
|
|
258
240
|
if (i) {
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
let [h,
|
|
262
|
-
h === "value" && (
|
|
241
|
+
const n = this[i];
|
|
242
|
+
n === void 0 && this.#a(t, e, i), t[i] = n;
|
|
243
|
+
let [h, a] = e.split(":");
|
|
244
|
+
h === "value" && (a ? (t["on" + a] === void 0 && this.#s(t, e, "refers to an unsupported event name"), t.setAttribute(h, this[i])) : a = "change"), s && t.#l.set(
|
|
263
245
|
u.getPropName(h),
|
|
264
246
|
i
|
|
265
247
|
);
|
|
266
248
|
}
|
|
267
|
-
this.#
|
|
249
|
+
this.#r(o, t, e);
|
|
268
250
|
}
|
|
269
251
|
}
|
|
270
252
|
#o(t) {
|
|
271
|
-
const
|
|
272
|
-
return Array.isArray(
|
|
253
|
+
const s = new Function("return " + t).call(this);
|
|
254
|
+
return Array.isArray(s) ? s.join("") : s;
|
|
273
255
|
}
|
|
274
256
|
#P(t) {
|
|
275
|
-
const { localName:
|
|
276
|
-
if (
|
|
277
|
-
const { sheet:
|
|
278
|
-
for (const
|
|
279
|
-
if (
|
|
280
|
-
const h = Array.from(
|
|
281
|
-
for (const
|
|
282
|
-
if (
|
|
283
|
-
const f =
|
|
284
|
-
this.#
|
|
257
|
+
const { localName: s } = t;
|
|
258
|
+
if (s === "style") {
|
|
259
|
+
const { sheet: e } = t, o = e?.cssRules ?? [], i = Array.from(o);
|
|
260
|
+
for (const n of i)
|
|
261
|
+
if (n.constructor === CSSStyleRule) {
|
|
262
|
+
const h = Array.from(n.style);
|
|
263
|
+
for (const a of h)
|
|
264
|
+
if (a.startsWith("--")) {
|
|
265
|
+
const f = n.style.getPropertyValue(a);
|
|
266
|
+
this.#r(f, n, a);
|
|
285
267
|
}
|
|
286
268
|
}
|
|
287
269
|
} else {
|
|
288
|
-
let
|
|
270
|
+
let e = "";
|
|
289
271
|
if (d(t)) {
|
|
290
|
-
this.#
|
|
272
|
+
this.#r(t.textContent, t);
|
|
291
273
|
const o = t.textContent?.match(j);
|
|
292
|
-
o && (
|
|
274
|
+
o && (e = o[1]);
|
|
293
275
|
} else {
|
|
294
276
|
const o = Array.from(t.childNodes).find(
|
|
295
277
|
(i) => i.nodeType === Node.COMMENT_NODE
|
|
296
278
|
);
|
|
297
|
-
o && (
|
|
279
|
+
o && (e = o.textContent?.trim() ?? "");
|
|
298
280
|
}
|
|
299
|
-
if (
|
|
300
|
-
const o = this.#
|
|
301
|
-
o && d(t) ? t.textContent = this[o] : this.#
|
|
281
|
+
if (e) {
|
|
282
|
+
const o = this.#g(t, e);
|
|
283
|
+
o && d(t) ? t.textContent = this[o] : this.#r(e, t);
|
|
302
284
|
}
|
|
303
285
|
}
|
|
304
286
|
}
|
|
@@ -309,98 +291,87 @@ class u extends HTMLElement {
|
|
|
309
291
|
formAssociatedCallback() {
|
|
310
292
|
let t = this.getAttribute("form-assoc");
|
|
311
293
|
if (!t) {
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
if (this.#
|
|
315
|
-
t = `value:${
|
|
294
|
+
const n = this.getAttribute("name");
|
|
295
|
+
if (n)
|
|
296
|
+
if (this.#n("value"))
|
|
297
|
+
t = `value:${n}`;
|
|
316
298
|
else
|
|
317
299
|
return;
|
|
318
300
|
else
|
|
319
301
|
return;
|
|
320
302
|
}
|
|
321
|
-
const
|
|
322
|
-
for (const
|
|
323
|
-
const [h,
|
|
324
|
-
|
|
303
|
+
const s = {}, e = t.split(",");
|
|
304
|
+
for (const n of e) {
|
|
305
|
+
const [h, a] = n.split(":");
|
|
306
|
+
s[h.trim()] = a.trim();
|
|
325
307
|
}
|
|
326
|
-
this.#
|
|
308
|
+
this.#c = s, this.#i = new FormData(), this.#h = this.attachInternals(), this.#h.setFormValue(this.#i);
|
|
327
309
|
const o = Object.keys(this.#t.properties), i = this.#f;
|
|
328
|
-
for (const
|
|
329
|
-
i[
|
|
310
|
+
for (const n of o)
|
|
311
|
+
i[n] = this[n];
|
|
330
312
|
}
|
|
331
313
|
formResetCallback() {
|
|
332
314
|
const t = this.#f;
|
|
333
|
-
for (const
|
|
334
|
-
let
|
|
335
|
-
A.test(
|
|
315
|
+
for (const s of Object.keys(t)) {
|
|
316
|
+
let e = t[s];
|
|
317
|
+
A.test(e) && (e = this.#o(e)), this[s] = e;
|
|
336
318
|
}
|
|
337
319
|
}
|
|
338
320
|
static getAttrName(t) {
|
|
339
|
-
let
|
|
340
|
-
return
|
|
321
|
+
let s = u.#d.get(t);
|
|
322
|
+
return s || (s = t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), u.#d.set(t, s)), s;
|
|
341
323
|
}
|
|
342
324
|
static getPropName(t) {
|
|
343
|
-
let
|
|
344
|
-
return
|
|
325
|
+
let s = u.#p.get(t);
|
|
326
|
+
return s || (s = t.replace(/-([a-z])/g, (e, o) => o.toUpperCase()), u.#p.set(t, s)), s;
|
|
345
327
|
}
|
|
346
|
-
|
|
347
|
-
if (
|
|
348
|
-
const [o] =
|
|
328
|
+
#N(t, s, e) {
|
|
329
|
+
if (e.length !== 1) return;
|
|
330
|
+
const [o] = e;
|
|
349
331
|
if (!A.test(o)) return;
|
|
350
|
-
const i =
|
|
351
|
-
let [
|
|
352
|
-
if (!(i &&
|
|
353
|
-
h ? t["on" + h] === void 0 && this.#
|
|
354
|
-
const f =
|
|
355
|
-
t.addEventListener(h, (
|
|
356
|
-
const { target: l } =
|
|
332
|
+
const i = v(t) || d(t);
|
|
333
|
+
let [n, h] = (s ?? "").split(":");
|
|
334
|
+
if (!(i && n === "value" || d(t))) return;
|
|
335
|
+
h ? t["on" + h] === void 0 && this.#s(t, s, "refers to an unsupported event name") : h = "change";
|
|
336
|
+
const f = E(o);
|
|
337
|
+
t.addEventListener(h, (c) => {
|
|
338
|
+
const { target: l } = c;
|
|
357
339
|
if (!l) return;
|
|
358
|
-
const p = l.value, { type:
|
|
359
|
-
this[f] =
|
|
340
|
+
const p = l.value, { type: g } = this.#t.properties[f];
|
|
341
|
+
this[f] = g === Number ? C(p) : p, this.#E(f);
|
|
360
342
|
});
|
|
361
343
|
}
|
|
362
|
-
#
|
|
344
|
+
#n(t) {
|
|
363
345
|
return !!this.#t.properties[t];
|
|
364
346
|
}
|
|
365
347
|
#b(t) {
|
|
366
|
-
const
|
|
367
|
-
for (const
|
|
368
|
-
this.#
|
|
369
|
-
}
|
|
370
|
-
#N(t) {
|
|
371
|
-
const e = t.cssRules;
|
|
372
|
-
for (const s of Array.from(e))
|
|
373
|
-
if (s instanceof CSSStyleRule) {
|
|
374
|
-
for (const o of Array.from(s.style))
|
|
375
|
-
if (o.startsWith("--")) {
|
|
376
|
-
const i = s.style.getPropertyValue(o);
|
|
377
|
-
this.#n(i, s, o);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
348
|
+
const s = Array.from(t.querySelectorAll("*"));
|
|
349
|
+
for (const e of s)
|
|
350
|
+
this.#R(e), e.firstElementChild || this.#P(e);
|
|
380
351
|
}
|
|
381
352
|
static get observedAttributes() {
|
|
382
353
|
const t = Object.keys(this.properties || {}).map(u.getAttrName);
|
|
383
354
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
384
355
|
}
|
|
385
356
|
// Subclasses can override this to add functionality.
|
|
386
|
-
propertyChangedCallback(t,
|
|
357
|
+
propertyChangedCallback(t, s, e) {
|
|
387
358
|
}
|
|
388
|
-
#
|
|
389
|
-
if (!
|
|
390
|
-
const
|
|
391
|
-
return this[
|
|
359
|
+
#g(t, s) {
|
|
360
|
+
if (!s || !A.test(s)) return;
|
|
361
|
+
const e = E(s);
|
|
362
|
+
return this[e] === void 0 && this.#a(t, "", e), e;
|
|
392
363
|
}
|
|
393
|
-
#
|
|
364
|
+
#E(t) {
|
|
394
365
|
const o = this.#t.propToExprsMap.get(t) || [];
|
|
395
366
|
for (const i of o) {
|
|
396
|
-
let
|
|
397
|
-
const h = this.#
|
|
398
|
-
for (const
|
|
399
|
-
if (
|
|
400
|
-
this.#
|
|
401
|
-
else if (!(
|
|
402
|
-
const { element: f, attrName:
|
|
403
|
-
f instanceof CSSStyleRule ? f.style.setProperty(
|
|
367
|
+
let n = this.#o(i);
|
|
368
|
+
const h = this.#e.get(i) ?? [];
|
|
369
|
+
for (const a of h)
|
|
370
|
+
if (a instanceof HTMLElement)
|
|
371
|
+
this.#C(a, n);
|
|
372
|
+
else if (!(a instanceof CSSStyleRule)) {
|
|
373
|
+
const { element: f, attrName: c } = a;
|
|
374
|
+
f instanceof CSSStyleRule ? f.style.setProperty(c, n) : T(f, c, n);
|
|
404
375
|
}
|
|
405
376
|
}
|
|
406
377
|
}
|
|
@@ -408,184 +379,184 @@ class u extends HTMLElement {
|
|
|
408
379
|
const t = this.elementName();
|
|
409
380
|
customElements.get(t) || customElements.define(t, this);
|
|
410
381
|
}
|
|
411
|
-
|
|
412
|
-
const { computed:
|
|
413
|
-
function
|
|
414
|
-
let
|
|
415
|
-
|
|
382
|
+
#$(t, s) {
|
|
383
|
+
const { computed: e, uses: o } = s, i = this.#t.propToComputedMap;
|
|
384
|
+
function n(a, f) {
|
|
385
|
+
let c = i.get(a);
|
|
386
|
+
c || (c = [], i.set(a, c)), c.push([t, f]);
|
|
416
387
|
}
|
|
417
|
-
const h =
|
|
418
|
-
for (const
|
|
419
|
-
const f =
|
|
420
|
-
this[f] === void 0 && this.#
|
|
388
|
+
const h = e.match(y) || [];
|
|
389
|
+
for (const a of h) {
|
|
390
|
+
const f = a.substring($);
|
|
391
|
+
this[f] === void 0 && this.#a(null, t, f), typeof this[f] != "function" && n(f, e);
|
|
421
392
|
}
|
|
422
393
|
if (o)
|
|
423
|
-
for (const
|
|
424
|
-
|
|
394
|
+
for (const a of o.split(","))
|
|
395
|
+
n(a, e);
|
|
425
396
|
}
|
|
426
397
|
// WARNING: Do not place untrusted JavaScript expressions
|
|
427
398
|
// in attribute values or the text content of elements!
|
|
428
|
-
#
|
|
399
|
+
#r(t, s, e = void 0) {
|
|
429
400
|
if (!t) return;
|
|
430
|
-
const o = this.#u(
|
|
401
|
+
const o = this.#u(s, e, t);
|
|
431
402
|
if (!o) {
|
|
432
|
-
const
|
|
433
|
-
|
|
403
|
+
const a = t.replaceAll("this..", "this.");
|
|
404
|
+
e ? T(s, e, a) : "textContent" in s && (s.textContent = a);
|
|
434
405
|
return;
|
|
435
406
|
}
|
|
436
407
|
const i = this.#t;
|
|
437
|
-
o.forEach((
|
|
438
|
-
const f =
|
|
408
|
+
o.forEach((a) => {
|
|
409
|
+
const f = E(a);
|
|
439
410
|
if (typeof this[f] == "function") return;
|
|
440
|
-
const
|
|
441
|
-
let l =
|
|
442
|
-
l || (l = [],
|
|
411
|
+
const c = i.propToExprsMap;
|
|
412
|
+
let l = c.get(f);
|
|
413
|
+
l || (l = [], c.set(f, l)), l.includes(t) || l.push(t);
|
|
443
414
|
});
|
|
444
|
-
for (const [
|
|
445
|
-
for (const
|
|
446
|
-
const l =
|
|
447
|
-
l instanceof CSSStyleRule || l.isConnected || this.#
|
|
448
|
-
|
|
449
|
-
f.filter((p) => p !==
|
|
415
|
+
for (const [a, f] of this.#e.entries())
|
|
416
|
+
for (const c of f) {
|
|
417
|
+
const l = c instanceof HTMLElement || c instanceof CSSStyleRule ? c : c.element;
|
|
418
|
+
l instanceof CSSStyleRule || l.isConnected || this.#e.set(
|
|
419
|
+
a,
|
|
420
|
+
f.filter((p) => p !== c)
|
|
450
421
|
);
|
|
451
422
|
}
|
|
452
|
-
let
|
|
453
|
-
|
|
423
|
+
let n = this.#e.get(t);
|
|
424
|
+
n || (n = [], this.#e.set(t, n)), n.push(e ? { element: s, attrName: e } : s), s instanceof HTMLElement && this.#N(s, e, o);
|
|
454
425
|
const h = this.#o(t);
|
|
455
|
-
|
|
426
|
+
e ? T(s, e, h) : this.#C(s, h);
|
|
456
427
|
}
|
|
457
428
|
// This follows the best practice
|
|
458
429
|
// "Do not override author-set, global attributes."
|
|
459
|
-
setAttributeSafe(t,
|
|
460
|
-
this.hasAttribute(t) || this.setAttribute(t,
|
|
430
|
+
setAttributeSafe(t, s) {
|
|
431
|
+
this.hasAttribute(t) || this.setAttribute(t, s);
|
|
461
432
|
}
|
|
462
|
-
setFormValue(t,
|
|
463
|
-
!this.#i || !
|
|
433
|
+
setFormValue(t, s) {
|
|
434
|
+
!this.#i || !S(s) || (this.#i.set(t, s), this.#h?.setFormValue(this.#i));
|
|
464
435
|
}
|
|
465
|
-
#
|
|
436
|
+
#s(t, s, e) {
|
|
466
437
|
const o = this.#t, i = t instanceof HTMLElement ? t.localName : "CSS rule";
|
|
467
438
|
throw new m(
|
|
468
|
-
`component ${o.elementName()}` + (t ? `, element "${i}"` : "") + (
|
|
439
|
+
`component ${o.elementName()}` + (t ? `, element "${i}"` : "") + (s ? `, attribute "${s}"` : "") + ` ${e}`
|
|
469
440
|
);
|
|
470
441
|
}
|
|
471
|
-
#
|
|
472
|
-
this.#
|
|
442
|
+
#a(t, s, e) {
|
|
443
|
+
this.#s(t, s, `refers to missing property "${e}"`);
|
|
473
444
|
}
|
|
474
|
-
#A(t,
|
|
475
|
-
return this.#
|
|
445
|
+
#A(t, s) {
|
|
446
|
+
return this.#y(t, this.getAttribute(s));
|
|
476
447
|
}
|
|
477
|
-
#
|
|
478
|
-
if (
|
|
479
|
-
const
|
|
480
|
-
if (o || this.#
|
|
481
|
-
if (o === Number) return
|
|
448
|
+
#y(t, s) {
|
|
449
|
+
if (s?.match(y)) return s;
|
|
450
|
+
const e = this.#t, { type: o } = e.properties[t];
|
|
451
|
+
if (o || this.#s(null, t, "does not specify its type"), o === String) return s;
|
|
452
|
+
if (o === Number) return C(s);
|
|
482
453
|
if (o === Boolean)
|
|
483
|
-
return
|
|
454
|
+
return s === "true" ? !0 : s === "false" || s === "null" ? !1 : (s && s !== t && this.#s(
|
|
484
455
|
null,
|
|
485
456
|
t,
|
|
486
457
|
"is a Boolean attribute, so its value must match attribute name or be missing"
|
|
487
|
-
),
|
|
458
|
+
), s === t);
|
|
488
459
|
}
|
|
489
460
|
// Updates the matching attribute for a property if there is one.
|
|
490
461
|
// VS Code thinks this is never called, but it is called by #defineProp.
|
|
491
|
-
#
|
|
492
|
-
if (
|
|
493
|
-
const i =
|
|
494
|
-
|
|
462
|
+
#x(t, s, e, o) {
|
|
463
|
+
if (S(e) && this.hasAttribute(o)) {
|
|
464
|
+
const i = s === Boolean ? this.hasAttribute(o) : this.#A(t, o);
|
|
465
|
+
e !== i && H(this, t, e);
|
|
495
466
|
}
|
|
496
467
|
}
|
|
497
468
|
// Updates all computed properties that reference this property.
|
|
498
469
|
// VS Code thinks this is never called, but it is called by #defineProp.
|
|
499
|
-
#
|
|
500
|
-
const
|
|
501
|
-
for (const [o, i] of
|
|
470
|
+
#L(t) {
|
|
471
|
+
const e = this.#t.propToComputedMap.get(t) || [];
|
|
472
|
+
for (const [o, i] of e)
|
|
502
473
|
this[o] = this.#o(i);
|
|
503
474
|
}
|
|
504
|
-
#
|
|
505
|
-
if (
|
|
506
|
-
const
|
|
507
|
-
o !== "string" && o !== "number" && this.#
|
|
475
|
+
#C(t, s) {
|
|
476
|
+
if (s === void 0) return;
|
|
477
|
+
const e = t instanceof HTMLElement, o = typeof s;
|
|
478
|
+
o !== "string" && o !== "number" && this.#s(
|
|
508
479
|
t,
|
|
509
480
|
void 0,
|
|
510
481
|
" computed content is not a string or number"
|
|
511
|
-
), t instanceof HTMLElement && d(t) ? t.value =
|
|
482
|
+
), t instanceof HTMLElement && d(t) ? t.value = s : e && o === "string" && s.trim().startsWith("<") ? (t.innerHTML = s, this.#T(t), this.#b(t)) : e && (t.textContent = s);
|
|
512
483
|
}
|
|
513
484
|
// Update corresponding parent web component property if bound to one.
|
|
514
485
|
// VS Code thinks this is never called, but it is called by #defineProp.
|
|
515
|
-
#H(t,
|
|
516
|
-
const
|
|
517
|
-
if (!
|
|
486
|
+
#H(t, s) {
|
|
487
|
+
const e = this.#l.get(t);
|
|
488
|
+
if (!e) return;
|
|
518
489
|
const o = this.getRootNode();
|
|
519
490
|
if (!(o instanceof ShadowRoot)) return;
|
|
520
491
|
const { host: i } = o;
|
|
521
492
|
if (!i) return;
|
|
522
|
-
const
|
|
523
|
-
|
|
493
|
+
const n = i;
|
|
494
|
+
n[e] = s;
|
|
524
495
|
}
|
|
525
496
|
/**
|
|
526
497
|
* @param state - WrecState object
|
|
527
498
|
* @param map - object whose keys are state properties and
|
|
528
499
|
* whose values are component properties
|
|
529
500
|
*/
|
|
530
|
-
useState(t,
|
|
531
|
-
if (!
|
|
532
|
-
|
|
533
|
-
for (const
|
|
534
|
-
e
|
|
501
|
+
useState(t, s) {
|
|
502
|
+
if (!s) {
|
|
503
|
+
s = {};
|
|
504
|
+
for (const e of Object.keys(t))
|
|
505
|
+
s[e] = e;
|
|
535
506
|
}
|
|
536
|
-
this.#
|
|
537
|
-
for (const [
|
|
538
|
-
if (this.#
|
|
539
|
-
const i =
|
|
507
|
+
this.#k(t, s);
|
|
508
|
+
for (const [e, o] of Object.entries(s))
|
|
509
|
+
if (this.#n(o)) {
|
|
510
|
+
const i = R(t, e);
|
|
540
511
|
i !== void 0 && (this[o] = i);
|
|
541
|
-
const
|
|
542
|
-
|
|
512
|
+
const n = this.#t.properties[o];
|
|
513
|
+
n.state = t, n.stateProp = e;
|
|
543
514
|
}
|
|
544
|
-
t.addListener(this,
|
|
515
|
+
t.addListener(this, s);
|
|
545
516
|
}
|
|
546
517
|
#O() {
|
|
547
|
-
const t = this.#t,
|
|
548
|
-
for (const o of
|
|
549
|
-
|
|
518
|
+
const t = this.#t, s = new Set(Object.keys(t.properties));
|
|
519
|
+
for (const o of s)
|
|
520
|
+
V.has(o) && this.#s(
|
|
550
521
|
null,
|
|
551
522
|
"",
|
|
552
523
|
`property "${o}" is not allowed because it is a reserved attribute`
|
|
553
524
|
);
|
|
554
|
-
const
|
|
525
|
+
const e = this.#t.name;
|
|
555
526
|
for (const o of this.getAttributeNames())
|
|
556
527
|
if (o !== "class" && o !== "id" && o !== "disabled" && !o.startsWith("on")) {
|
|
557
528
|
if (o === "form-assoc") {
|
|
558
529
|
if (!t.formAssociated)
|
|
559
530
|
throw new m(
|
|
560
|
-
`add "static formAssociated = true;" to class ${
|
|
531
|
+
`add "static formAssociated = true;" to class ${e}`
|
|
561
532
|
);
|
|
562
533
|
continue;
|
|
563
534
|
}
|
|
564
|
-
if (!
|
|
535
|
+
if (!s.has(u.getPropName(o))) {
|
|
565
536
|
if (o === "name") {
|
|
566
537
|
if (t.formAssociated) continue;
|
|
567
538
|
throw new m(
|
|
568
|
-
`name attribute requires "static formAssociated = true;" in class ${
|
|
539
|
+
`name attribute requires "static formAssociated = true;" in class ${e}`
|
|
569
540
|
);
|
|
570
541
|
}
|
|
571
|
-
this.#
|
|
542
|
+
this.#s(null, o, "is not a supported attribute");
|
|
572
543
|
}
|
|
573
544
|
}
|
|
574
545
|
}
|
|
575
|
-
#u(t,
|
|
576
|
-
const o =
|
|
546
|
+
#u(t, s, e) {
|
|
547
|
+
const o = e.match(y);
|
|
577
548
|
if (o)
|
|
578
549
|
return o.forEach((i) => {
|
|
579
|
-
const
|
|
580
|
-
this[
|
|
550
|
+
const n = E(i);
|
|
551
|
+
this[n] === void 0 && this.#a(t, s, n);
|
|
581
552
|
}), o;
|
|
582
553
|
}
|
|
583
|
-
#
|
|
584
|
-
for (const [
|
|
585
|
-
let i =
|
|
554
|
+
#k(t, s) {
|
|
555
|
+
for (const [e, o] of Object.entries(s)) {
|
|
556
|
+
let i = R(t, e);
|
|
586
557
|
if (i === void 0)
|
|
587
|
-
throw new m(`invalid state path "${
|
|
588
|
-
i = this[o], this.#
|
|
558
|
+
throw new m(`invalid state path "${e}"`);
|
|
559
|
+
i = this[o], this.#n(o) || this.#s(
|
|
589
560
|
null,
|
|
590
561
|
o,
|
|
591
562
|
"refers to missing property in useState map"
|
|
@@ -593,76 +564,76 @@ class u extends HTMLElement {
|
|
|
593
564
|
}
|
|
594
565
|
}
|
|
595
566
|
// When type is an array, this can't validate the type of the array elements.
|
|
596
|
-
#
|
|
597
|
-
if (
|
|
598
|
-
let o = typeof
|
|
567
|
+
#F(t, s, e) {
|
|
568
|
+
if (e instanceof s) return;
|
|
569
|
+
let o = typeof e;
|
|
599
570
|
if (o === "object") {
|
|
600
|
-
const { constructor: i } =
|
|
601
|
-
o = i.name, i !==
|
|
571
|
+
const { constructor: i } = e;
|
|
572
|
+
o = i.name, i !== s && this.#s(
|
|
602
573
|
null,
|
|
603
574
|
t,
|
|
604
|
-
`was set to a ${o}, but must be a ${
|
|
575
|
+
`was set to a ${o}, but must be a ${s.name}`
|
|
605
576
|
);
|
|
606
577
|
}
|
|
607
|
-
o !==
|
|
578
|
+
o !== s.name.toLowerCase() && this.#s(
|
|
608
579
|
null,
|
|
609
580
|
t,
|
|
610
|
-
`was set to a ${o}, but must be a ${
|
|
581
|
+
`was set to a ${o}, but must be a ${s.name}`
|
|
611
582
|
);
|
|
612
583
|
}
|
|
613
|
-
#
|
|
614
|
-
const
|
|
615
|
-
for (const
|
|
584
|
+
#T(t) {
|
|
585
|
+
const s = Array.from(t.querySelectorAll("*"));
|
|
586
|
+
for (const e of s) {
|
|
616
587
|
const o = [];
|
|
617
|
-
for (const i of Array.from(
|
|
618
|
-
const
|
|
619
|
-
if (
|
|
620
|
-
let h =
|
|
588
|
+
for (const i of Array.from(e.attributes)) {
|
|
589
|
+
const n = i.name;
|
|
590
|
+
if (n.startsWith("on")) {
|
|
591
|
+
let h = n.slice(2);
|
|
621
592
|
h = h[0].toLowerCase() + h.slice(1).toLowerCase();
|
|
622
|
-
const
|
|
623
|
-
this.#u(
|
|
593
|
+
const a = i.value;
|
|
594
|
+
this.#u(e, n, a);
|
|
624
595
|
let f;
|
|
625
|
-
typeof this[
|
|
596
|
+
typeof this[a] == "function" ? f = (c) => this[a](c) : (this.#u(e, n, a), f = () => this.#o(a)), e.addEventListener(h, f), o.push(n);
|
|
626
597
|
}
|
|
627
598
|
}
|
|
628
599
|
for (const i of o)
|
|
629
|
-
|
|
600
|
+
e.removeAttribute(i);
|
|
630
601
|
}
|
|
631
602
|
}
|
|
632
603
|
}
|
|
633
|
-
function
|
|
634
|
-
let
|
|
604
|
+
function z(r, ...t) {
|
|
605
|
+
let s = x(r, t);
|
|
635
606
|
for (; ; ) {
|
|
636
|
-
const
|
|
637
|
-
if (!
|
|
638
|
-
const o =
|
|
639
|
-
if (
|
|
640
|
-
const i =
|
|
607
|
+
const e = k.exec(s);
|
|
608
|
+
if (!e) break;
|
|
609
|
+
const o = e[2];
|
|
610
|
+
if (N.test(o)) {
|
|
611
|
+
const i = e[1];
|
|
641
612
|
if (!i.startsWith("--")) {
|
|
642
|
-
const
|
|
613
|
+
const n = `--${i}: ${o};
|
|
643
614
|
${i}: var(--${i})`;
|
|
644
|
-
|
|
615
|
+
s = L(s, e.index, e[0].length, n);
|
|
645
616
|
}
|
|
646
617
|
}
|
|
647
618
|
}
|
|
648
|
-
return
|
|
619
|
+
return s;
|
|
649
620
|
}
|
|
650
|
-
function
|
|
651
|
-
let
|
|
621
|
+
function Z(r, ...t) {
|
|
622
|
+
let s = x(r, t);
|
|
652
623
|
for (; ; ) {
|
|
653
|
-
const
|
|
654
|
-
if (!
|
|
655
|
-
const o =
|
|
656
|
-
if (
|
|
657
|
-
const i = `<!-- ${o.trim()} -->`,
|
|
658
|
-
|
|
624
|
+
const e = _.exec(s);
|
|
625
|
+
if (!e || e[1] === "style") break;
|
|
626
|
+
const o = B(e[2]);
|
|
627
|
+
if (N.test(o)) {
|
|
628
|
+
const i = `<!-- ${o.trim()} -->`, n = e.index + e[0].indexOf(">") + 1;
|
|
629
|
+
s = L(s, n, o.length, i);
|
|
659
630
|
}
|
|
660
631
|
}
|
|
661
|
-
return
|
|
632
|
+
return s;
|
|
662
633
|
}
|
|
663
634
|
export {
|
|
664
635
|
u as Wrec,
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
636
|
+
q as createElement,
|
|
637
|
+
z as css,
|
|
638
|
+
Z as html
|
|
668
639
|
};
|