wrec 0.21.1 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wrec.es.js +331 -324
- package/package.json +2 -2
package/dist/wrec.es.js
CHANGED
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var K = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import
|
|
7
|
-
|
|
4
|
+
var D = (r, t, e) => t.has(r) || K("Cannot " + e);
|
|
5
|
+
var p = (r, t, e) => (D(r, t, "read from private field"), e ? e.call(r) : t.get(r)), E = (r, t, e) => t.has(r) ? K("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), M = (r, t, e, s) => (D(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), Z = (r, t, e) => (D(r, t, "access private method"), e);
|
|
6
|
+
import { HTMLElement as nt, NodeType as F, parse as rt, TextNode as ct } from "node-html-parser";
|
|
7
|
+
import X from "xss";
|
|
8
|
+
function G(r, t, e = "") {
|
|
8
9
|
const s = /* @__PURE__ */ new WeakMap(), o = {
|
|
9
10
|
// Intercept property reads.
|
|
10
11
|
// This creates nested proxies lazily.
|
|
11
|
-
get(i,
|
|
12
|
-
const c = Reflect.get(i,
|
|
12
|
+
get(i, n) {
|
|
13
|
+
const c = Reflect.get(i, n);
|
|
13
14
|
if (c === null || typeof c != "object") return c;
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
15
|
+
const a = s.get(c);
|
|
16
|
+
if (a) return a;
|
|
17
|
+
const f = e ? `${e}.${n}` : n, l = G(c, t, f);
|
|
17
18
|
return s.set(c, l), l;
|
|
18
19
|
},
|
|
19
20
|
// Intercept property writes.
|
|
20
|
-
set(i,
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
Reflect.set(i,
|
|
24
|
-
const
|
|
25
|
-
t(
|
|
21
|
+
set(i, n, c) {
|
|
22
|
+
const a = Reflect.get(i, n);
|
|
23
|
+
if (a !== c) {
|
|
24
|
+
Reflect.set(i, n, c);
|
|
25
|
+
const f = e ? `${e}.${n}` : n;
|
|
26
|
+
t(f, a, c);
|
|
26
27
|
}
|
|
27
28
|
return !0;
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
|
-
return new Proxy(
|
|
31
|
+
return new Proxy(r, o);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function Q(r) {
|
|
33
34
|
const t = {};
|
|
34
|
-
for (const [e, s] of Object.entries(
|
|
35
|
+
for (const [e, s] of Object.entries(r)) {
|
|
35
36
|
const o = typeof s == "object" && s !== null;
|
|
36
|
-
t[e] = o ?
|
|
37
|
+
t[e] = o ? Q(s) : s;
|
|
37
38
|
}
|
|
38
39
|
return t;
|
|
39
40
|
}
|
|
40
|
-
const
|
|
41
|
-
let
|
|
41
|
+
const O = typeof window < "u" && typeof window.document < "u";
|
|
42
|
+
let U = class extends Error {
|
|
42
43
|
};
|
|
43
|
-
var
|
|
44
|
-
const
|
|
44
|
+
var T, H, m, N, $, w, _, tt;
|
|
45
|
+
const A = class A {
|
|
45
46
|
constructor(t, e, s) {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
E(this, _);
|
|
48
|
+
E(this, H, /* @__PURE__ */ Symbol("objectId"));
|
|
48
49
|
// This cannot be replaced by a WeakMap<ChangeListener, Set<string>>
|
|
49
50
|
// because there is no way to iterate over the keys of a WeakMap.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!t) throw new
|
|
55
|
-
if (
|
|
56
|
-
throw new
|
|
57
|
-
if (
|
|
51
|
+
E(this, m, []);
|
|
52
|
+
E(this, N);
|
|
53
|
+
E(this, $);
|
|
54
|
+
E(this, w);
|
|
55
|
+
if (!t) throw new U("name cannot be empty");
|
|
56
|
+
if (p(A, T).has(t))
|
|
57
|
+
throw new U(`WrecState with name "${t}" already exists`);
|
|
58
|
+
if (M(this, N, t), M(this, $, e), M(this, w, G({}, Z(this, _, tt).bind(this))), e && O) {
|
|
58
59
|
const o = sessionStorage.getItem("wrec-state-" + t), i = o ? JSON.parse(o) : void 0;
|
|
59
60
|
i && (s = i);
|
|
60
61
|
}
|
|
61
62
|
if (s)
|
|
62
63
|
for (const [o, i] of Object.entries(s))
|
|
63
64
|
this.addProperty(o, i);
|
|
64
|
-
|
|
65
|
+
p(A, T).set(t, this);
|
|
65
66
|
}
|
|
66
67
|
// This static method is useful for accessing a specific WrecState object
|
|
67
68
|
// from the DevTools console. For example:
|
|
@@ -74,22 +75,22 @@ const T = class T {
|
|
|
74
75
|
// state.color = 'blue';
|
|
75
76
|
// state.team.leader.name = 'Mark';
|
|
76
77
|
static get(t) {
|
|
77
|
-
return
|
|
78
|
+
return p(this, T).get(t);
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
81
|
* @param listener - object that has a "changed" method
|
|
81
82
|
* @param map - map from state property paths to component properties
|
|
82
83
|
*/
|
|
83
84
|
addListener(t, e = {}) {
|
|
84
|
-
const s =
|
|
85
|
+
const s = p(this, m).find(
|
|
85
86
|
(o) => o.listenerRef.deref() === t
|
|
86
87
|
);
|
|
87
88
|
if (s) {
|
|
88
89
|
const { propertyMap: o } = s;
|
|
89
|
-
for (const [i,
|
|
90
|
-
o[i] =
|
|
90
|
+
for (const [i, n] of Object.entries(e))
|
|
91
|
+
o[i] = n;
|
|
91
92
|
} else
|
|
92
|
-
|
|
93
|
+
p(this, m).push({
|
|
93
94
|
listenerRef: new WeakRef(t),
|
|
94
95
|
propertyMap: e
|
|
95
96
|
});
|
|
@@ -98,38 +99,38 @@ const T = class T {
|
|
|
98
99
|
Object.defineProperty(this, t, {
|
|
99
100
|
enumerable: !0,
|
|
100
101
|
get() {
|
|
101
|
-
return
|
|
102
|
+
return p(this, w)[t];
|
|
102
103
|
},
|
|
103
104
|
set(s) {
|
|
104
|
-
|
|
105
|
+
p(this, w)[t] = s;
|
|
105
106
|
}
|
|
106
|
-
}),
|
|
107
|
+
}), p(this, w)[t] = e;
|
|
107
108
|
}
|
|
108
109
|
get id() {
|
|
109
|
-
return
|
|
110
|
+
return p(this, H);
|
|
110
111
|
}
|
|
111
112
|
// This is useful for debugging from the DevTools console.
|
|
112
113
|
// For example: state.log()
|
|
113
114
|
log() {
|
|
114
|
-
console.log("WrecState:",
|
|
115
|
-
for (const [t, e] of Object.entries(
|
|
115
|
+
console.log("WrecState:", p(this, N));
|
|
116
|
+
for (const [t, e] of Object.entries(p(this, w)))
|
|
116
117
|
console.log(` ${t} = ${JSON.stringify(e)}`);
|
|
117
118
|
}
|
|
118
119
|
removeListener(t) {
|
|
119
|
-
|
|
120
|
+
M(this, m, p(this, m).filter((e) => e.listenerRef.deref() !== t));
|
|
120
121
|
}
|
|
121
122
|
};
|
|
122
|
-
|
|
123
|
+
T = new WeakMap(), H = new WeakMap(), m = new WeakMap(), N = new WeakMap(), $ = new WeakMap(), w = new WeakMap(), _ = new WeakSet(), tt = function(t, e, s) {
|
|
123
124
|
const o = /* @__PURE__ */ new Set();
|
|
124
|
-
for (const i of
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
125
|
+
for (const i of p(this, m)) {
|
|
126
|
+
const n = i.listenerRef.deref();
|
|
127
|
+
if (!n)
|
|
127
128
|
o.add(i);
|
|
128
|
-
else if (
|
|
129
|
+
else if (O && n instanceof HTMLElement && !n.isConnected)
|
|
129
130
|
o.add(i);
|
|
130
131
|
else {
|
|
131
|
-
const { propertyMap: c } = i,
|
|
132
|
-
(
|
|
132
|
+
const { propertyMap: c } = i, a = Object.keys(c);
|
|
133
|
+
(a.length === 0 || a.includes(t)) && n.changed(
|
|
133
134
|
t,
|
|
134
135
|
c[t],
|
|
135
136
|
s,
|
|
@@ -138,59 +139,59 @@ y = new WeakMap(), R = new WeakMap(), p = new WeakMap(), S = new WeakMap(), C =
|
|
|
138
139
|
);
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
+
M(this, m, p(this, m).filter(
|
|
142
143
|
(i) => !o.has(i)
|
|
143
144
|
));
|
|
144
|
-
},
|
|
145
|
-
for (const [t, e] of
|
|
146
|
-
if (
|
|
147
|
-
const s =
|
|
145
|
+
}, E(A, T, /* @__PURE__ */ new Map()), O && window.addEventListener("beforeunload", () => {
|
|
146
|
+
for (const [t, e] of p(A, T).entries())
|
|
147
|
+
if (p(e, $)) {
|
|
148
|
+
const s = Q(e);
|
|
148
149
|
sessionStorage.setItem("wrec-state-" + t, JSON.stringify(s));
|
|
149
150
|
}
|
|
150
151
|
});
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
function
|
|
154
|
-
let e =
|
|
152
|
+
let z = A;
|
|
153
|
+
O && process.env.NODE_ENV === "development" && (window.WrecState = z);
|
|
154
|
+
function Y(r, t) {
|
|
155
|
+
let e = r;
|
|
155
156
|
for (const s of t.split("."))
|
|
156
157
|
e = e[s];
|
|
157
158
|
return e;
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
+
function at(r, t, e) {
|
|
160
161
|
const s = t.split("."), o = s.length - 1;
|
|
161
|
-
let i =
|
|
162
|
-
s.forEach((
|
|
163
|
-
c === o ? i[
|
|
162
|
+
let i = r;
|
|
163
|
+
s.forEach((n, c) => {
|
|
164
|
+
c === o ? i[n] = e : i = i[n];
|
|
164
165
|
});
|
|
165
166
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
167
|
+
const ft = /* @__PURE__ */ new Set(["input", "label", "option", "th"]);
|
|
168
|
+
function lt(r) {
|
|
168
169
|
const t = {
|
|
169
170
|
allowCommentTag: !0,
|
|
170
171
|
onTag: (o, i) => {
|
|
171
|
-
if (
|
|
172
|
+
if (ft.has(o)) return i;
|
|
172
173
|
},
|
|
173
|
-
onTagAttr(o, i,
|
|
174
|
+
onTagAttr(o, i, n) {
|
|
174
175
|
if (i.startsWith("on")) return "";
|
|
175
176
|
},
|
|
176
|
-
safeAttrValue(o, i,
|
|
177
|
-
return i === "class" || o === "a" && i === "href" && !
|
|
177
|
+
safeAttrValue(o, i, n) {
|
|
178
|
+
return i === "class" || o === "a" && i === "href" && !n.startsWith("javascript") || o === "img" && i === "src" ? n : "";
|
|
178
179
|
},
|
|
179
180
|
stripIgnoreTagBody: ["script", "style", "iframe"],
|
|
180
181
|
whiteList: {
|
|
181
|
-
...
|
|
182
|
+
...X.getDefaultWhiteList(),
|
|
182
183
|
label: ["class", "for"],
|
|
183
184
|
span: ["class"]
|
|
184
185
|
}
|
|
185
186
|
}, e = [];
|
|
186
|
-
|
|
187
|
+
r = r.replace(/<!--[\s\S]*?-->/g, (o) => {
|
|
187
188
|
const i = `__COMMENT_${e.length}__`;
|
|
188
189
|
return e.push(o), i;
|
|
189
190
|
});
|
|
190
|
-
let s =
|
|
191
|
+
let s = X(r, t);
|
|
191
192
|
return s = s.replace(/__COMMENT_(\d+)__/g, (o, i) => e[i]), s;
|
|
192
193
|
}
|
|
193
|
-
const
|
|
194
|
+
const ht = /* @__PURE__ */ new Set([
|
|
194
195
|
"class",
|
|
195
196
|
"disabled",
|
|
196
197
|
"hidden",
|
|
@@ -198,99 +199,95 @@ const it = /* @__PURE__ */ new Set([
|
|
|
198
199
|
"tabindex",
|
|
199
200
|
"title"
|
|
200
201
|
]);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
whenDefined: () => Promise.reject()
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
class v extends Error {
|
|
202
|
+
typeof window > "u" && (global.HTMLElement = nt, global.customElements = {
|
|
203
|
+
get: (r) => {
|
|
204
|
+
},
|
|
205
|
+
getName: () => "",
|
|
206
|
+
define: () => {
|
|
207
|
+
},
|
|
208
|
+
upgrade: () => {
|
|
209
|
+
},
|
|
210
|
+
whenDefined: () => Promise.reject()
|
|
211
|
+
});
|
|
212
|
+
class x extends Error {
|
|
216
213
|
}
|
|
217
|
-
const
|
|
218
|
-
function
|
|
219
|
-
return
|
|
214
|
+
const ut = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, et = "a-zA-Z_$", pt = et + "0-9", P = `[${et}][${pt}]*`, dt = /<!--\s*(.*?)\s*-->/, mt = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, V = new RegExp(`^this\\.${P}$`), I = new RegExp(`this\\.${P}(\\.${P})*`, "g"), L = new RegExp(`this\\.${P}(\\.${P})*`), bt = 5;
|
|
215
|
+
function gt(r) {
|
|
216
|
+
return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof b;
|
|
220
217
|
}
|
|
221
|
-
function
|
|
222
|
-
const s = document.createElement(
|
|
218
|
+
function St(r, t, e) {
|
|
219
|
+
const s = document.createElement(r);
|
|
223
220
|
if (t)
|
|
224
221
|
for (const [o, i] of Object.entries(t))
|
|
225
222
|
s.setAttribute(o, i);
|
|
226
223
|
return e && (s.innerHTML = e), s;
|
|
227
224
|
}
|
|
228
|
-
const
|
|
229
|
-
function
|
|
225
|
+
const yt = (r) => r === String ? "" : r === Number ? 0 : r === Boolean ? !1 : r === Array ? [] : r === Object ? {} : void 0;
|
|
226
|
+
function j(r) {
|
|
230
227
|
const t = [];
|
|
231
|
-
let e =
|
|
228
|
+
let e = r.firstElementChild;
|
|
232
229
|
for (; e; )
|
|
233
|
-
t.push(e), e.shadowRoot && t.push(...
|
|
230
|
+
t.push(e), e.shadowRoot && t.push(...j(e.shadowRoot)), e.firstElementChild && t.push(...j(e)), e = e.nextElementSibling;
|
|
234
231
|
return t;
|
|
235
232
|
}
|
|
236
|
-
const
|
|
237
|
-
function
|
|
238
|
-
let e =
|
|
233
|
+
const S = (r) => r.substring(bt).split(".")[0];
|
|
234
|
+
function st(r, t) {
|
|
235
|
+
let e = r[0];
|
|
239
236
|
return t.forEach((s, o) => {
|
|
240
|
-
e += s +
|
|
237
|
+
e += s + r[o + 1];
|
|
241
238
|
}), e;
|
|
242
239
|
}
|
|
243
|
-
function
|
|
244
|
-
const t = typeof
|
|
240
|
+
function q(r) {
|
|
241
|
+
const t = typeof r;
|
|
245
242
|
return t === "string" || t === "number" || t === "boolean";
|
|
246
243
|
}
|
|
247
|
-
function
|
|
248
|
-
return
|
|
244
|
+
function C(r) {
|
|
245
|
+
return r.localName === "textarea";
|
|
249
246
|
}
|
|
250
|
-
function
|
|
251
|
-
const { localName: t } =
|
|
247
|
+
function J(r) {
|
|
248
|
+
const { localName: t } = r;
|
|
252
249
|
return t === "input" || t === "select";
|
|
253
250
|
}
|
|
254
|
-
const
|
|
255
|
-
function
|
|
256
|
-
return
|
|
251
|
+
const Et = (r) => r.replace(/<!--[\s\S]*?-->/g, "");
|
|
252
|
+
function ot(r, t, e, s) {
|
|
253
|
+
return r.slice(0, t) + s + r.slice(t + e);
|
|
257
254
|
}
|
|
258
|
-
function
|
|
259
|
-
const t = Number(
|
|
260
|
-
if (isNaN(t)) throw new
|
|
255
|
+
function W(r) {
|
|
256
|
+
const t = Number(r);
|
|
257
|
+
if (isNaN(t)) throw new x(`can't convert "${r}" to a number`);
|
|
261
258
|
return t;
|
|
262
259
|
}
|
|
263
|
-
function
|
|
260
|
+
function it(r, t, e) {
|
|
264
261
|
const [s, o] = t.split(":");
|
|
265
|
-
if (
|
|
262
|
+
if (q(e))
|
|
266
263
|
if (typeof e == "boolean") {
|
|
267
|
-
e ?
|
|
268
|
-
const i =
|
|
269
|
-
|
|
264
|
+
e ? r.setAttribute(s, s) : r.removeAttribute(s);
|
|
265
|
+
const i = b.getPropName(s);
|
|
266
|
+
r[i] = e;
|
|
270
267
|
} else {
|
|
271
|
-
const i =
|
|
272
|
-
i !==
|
|
268
|
+
const i = r.getAttribute(t), n = String(e);
|
|
269
|
+
i !== n && (r.setAttribute(s, n), s === "value" && J(r) && (r.value = n));
|
|
273
270
|
}
|
|
274
271
|
else {
|
|
275
|
-
const i =
|
|
276
|
-
|
|
272
|
+
const i = b.getPropName(t);
|
|
273
|
+
r[i] = e;
|
|
277
274
|
}
|
|
278
275
|
}
|
|
279
|
-
function
|
|
276
|
+
function B(r, t, e) {
|
|
280
277
|
const [s, o] = t.split(":");
|
|
281
|
-
|
|
278
|
+
r instanceof CSSStyleRule ? r.style.setProperty(s, e) : (it(r, s, e), s === "value" && J(r) && (r.value = e));
|
|
282
279
|
}
|
|
283
|
-
async function
|
|
280
|
+
async function wt(r) {
|
|
284
281
|
const t = /* @__PURE__ */ new Set();
|
|
285
|
-
for (const s of
|
|
282
|
+
for (const s of j(r.content)) {
|
|
286
283
|
const { localName: o } = s;
|
|
287
284
|
o.includes("-") && t.add(o);
|
|
288
285
|
}
|
|
289
286
|
function e(s) {
|
|
290
287
|
return new Promise((o, i) => {
|
|
291
288
|
setTimeout(() => {
|
|
292
|
-
const
|
|
293
|
-
i(new Error(
|
|
289
|
+
const n = `custom element <${s}> not defined`;
|
|
290
|
+
i(new Error(n));
|
|
294
291
|
}, 1e3);
|
|
295
292
|
});
|
|
296
293
|
}
|
|
@@ -300,7 +297,7 @@ async function pt(n) {
|
|
|
300
297
|
)
|
|
301
298
|
);
|
|
302
299
|
}
|
|
303
|
-
class
|
|
300
|
+
class b extends HTMLElement {
|
|
304
301
|
// There is one instance of `attrToPropMap`, `properties`, `propToAttrMap`,
|
|
305
302
|
// `propToComputedMap`, and `propToExprsMap` per Wrec subclass,
|
|
306
303
|
// not one for only the Wrec class.
|
|
@@ -367,7 +364,7 @@ class d extends HTMLElement {
|
|
|
367
364
|
#u = /* @__PURE__ */ new Map();
|
|
368
365
|
static define(t) {
|
|
369
366
|
if (this.elementName = t, customElements.get(t))
|
|
370
|
-
throw new
|
|
367
|
+
throw new x(`custom element ${t} is already defined`);
|
|
371
368
|
customElements.define(t, this);
|
|
372
369
|
}
|
|
373
370
|
constructor() {
|
|
@@ -377,12 +374,12 @@ class d extends HTMLElement {
|
|
|
377
374
|
}
|
|
378
375
|
attributeChangedCallback(t, e, s) {
|
|
379
376
|
t === "disabled" && this.#m();
|
|
380
|
-
const o =
|
|
377
|
+
const o = b.getPropName(t);
|
|
381
378
|
if (this.#n(o)) {
|
|
382
379
|
const i = this.#M(o, String(s));
|
|
383
380
|
this[o] = i;
|
|
384
|
-
const
|
|
385
|
-
|
|
381
|
+
const n = this.#f[o];
|
|
382
|
+
n && this.setFormValue(n, String(i)), this.propertyChangedCallback(o, e, s);
|
|
386
383
|
}
|
|
387
384
|
}
|
|
388
385
|
// This applies multiple property changes and only updates
|
|
@@ -390,30 +387,30 @@ class d extends HTMLElement {
|
|
|
390
387
|
batchSet(t) {
|
|
391
388
|
this.#a = !0;
|
|
392
389
|
const e = this.#t.propToExprsMap, s = /* @__PURE__ */ new Set();
|
|
393
|
-
for (const [c,
|
|
394
|
-
this[c] =
|
|
395
|
-
const
|
|
396
|
-
for (const l of
|
|
390
|
+
for (const [c, a] of Object.entries(t)) {
|
|
391
|
+
this[c] = a;
|
|
392
|
+
const f = e.get(c) ?? [];
|
|
393
|
+
for (const l of f)
|
|
397
394
|
s.add(l);
|
|
398
395
|
}
|
|
399
|
-
const o = this.#t.propToComputedMap, i = /* @__PURE__ */ new Set(),
|
|
396
|
+
const o = this.#t.propToComputedMap, i = /* @__PURE__ */ new Set(), n = {};
|
|
400
397
|
for (const c of Object.keys(t)) {
|
|
401
|
-
const
|
|
402
|
-
for (const [
|
|
403
|
-
i.add(
|
|
398
|
+
const a = o.get(c) || [];
|
|
399
|
+
for (const [f, l] of a)
|
|
400
|
+
i.add(f), n[f] = l;
|
|
404
401
|
}
|
|
405
402
|
for (const c of i) {
|
|
406
|
-
const
|
|
407
|
-
this[c] = this.#s(
|
|
408
|
-
const
|
|
409
|
-
for (const l of
|
|
403
|
+
const a = n[c];
|
|
404
|
+
this[c] = this.#s(a);
|
|
405
|
+
const f = e.get(c) ?? [];
|
|
406
|
+
for (const l of f)
|
|
410
407
|
s.add(l);
|
|
411
408
|
}
|
|
412
409
|
for (; ; ) {
|
|
413
410
|
let c = !1;
|
|
414
|
-
for (const
|
|
415
|
-
const
|
|
416
|
-
JSON.stringify(l) !== JSON.stringify(
|
|
411
|
+
for (const a of i) {
|
|
412
|
+
const f = n[a], l = this.#s(f), u = this[a];
|
|
413
|
+
JSON.stringify(l) !== JSON.stringify(u) && (this[a] = l, c = !0);
|
|
417
414
|
}
|
|
418
415
|
if (!c) break;
|
|
419
416
|
}
|
|
@@ -422,7 +419,7 @@ class d extends HTMLElement {
|
|
|
422
419
|
async #S() {
|
|
423
420
|
const t = this.#t;
|
|
424
421
|
let { template: e } = t;
|
|
425
|
-
e || (e = t.template = document.createElement("template"), e.innerHTML = t.buildHTML()), await
|
|
422
|
+
e || (e = t.template = document.createElement("template"), e.innerHTML = t.buildHTML()), await wt(e), this.shadowRoot.replaceChildren(e.content.cloneNode(!0));
|
|
426
423
|
}
|
|
427
424
|
static buildHTML() {
|
|
428
425
|
let t = `<style>
|
|
@@ -430,7 +427,7 @@ class d extends HTMLElement {
|
|
|
430
427
|
this.css && (t += this.css), t += `</style>
|
|
431
428
|
`;
|
|
432
429
|
let e = this.html.trim();
|
|
433
|
-
if (!e) throw new
|
|
430
|
+
if (!e) throw new x("static property html must be set");
|
|
434
431
|
return e.startsWith("<") || (e = `<span><!--${e}--></span>`), t + e;
|
|
435
432
|
}
|
|
436
433
|
changed(t, e, s) {
|
|
@@ -438,7 +435,7 @@ class d extends HTMLElement {
|
|
|
438
435
|
}
|
|
439
436
|
connectedCallback() {
|
|
440
437
|
this.#H(), this.#x(), this.#S().then(() => {
|
|
441
|
-
this.hasAttribute("disabled") && this.#m(), this.#
|
|
438
|
+
this.hasAttribute("disabled") && this.#m(), this.#v(this.shadowRoot), this.#g(this.shadowRoot), this.#C();
|
|
442
439
|
});
|
|
443
440
|
}
|
|
444
441
|
#C() {
|
|
@@ -455,38 +452,38 @@ class d extends HTMLElement {
|
|
|
455
452
|
}
|
|
456
453
|
#d(t, e, s) {
|
|
457
454
|
if (t === "class" || t === "style")
|
|
458
|
-
throw new
|
|
459
|
-
const o =
|
|
455
|
+
throw new x(`"${t}" is a reserved property`);
|
|
456
|
+
const o = b.getAttrName(t), i = this.hasAttribute(o);
|
|
460
457
|
e.required && !i && this.#e(this, o, "is a required attribute");
|
|
461
|
-
let
|
|
462
|
-
this.hasOwnProperty(t) && (
|
|
463
|
-
const { type: c } = e,
|
|
464
|
-
this[
|
|
458
|
+
let n = e.value;
|
|
459
|
+
this.hasOwnProperty(t) && (n = this[t], delete this[t]);
|
|
460
|
+
const { type: c } = e, a = c === Boolean ? n || i : s.includes(o) && i ? this.#T(t, o) : n || yt(c), f = "#" + t;
|
|
461
|
+
this[f] = a, e.computed && this.#R(t, e), Object.defineProperty(this, t, {
|
|
465
462
|
enumerable: !0,
|
|
466
463
|
get() {
|
|
467
|
-
return this[
|
|
464
|
+
return this[f];
|
|
468
465
|
},
|
|
469
466
|
set(l) {
|
|
470
|
-
c === Number && typeof l == "string" && (l =
|
|
471
|
-
const
|
|
472
|
-
if (l ===
|
|
473
|
-
this.#k(t, c, l), this[
|
|
474
|
-
const { state:
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
467
|
+
c === Number && typeof l == "string" && (l = W(l));
|
|
468
|
+
const u = this[f];
|
|
469
|
+
if (l === u) return;
|
|
470
|
+
this.#k(t, c, l), this[f] = l;
|
|
471
|
+
const { state: h, stateProp: d } = this.#t.properties[t];
|
|
472
|
+
d && at(h, d, l), this.#O(t, c, l, o), this.#a || (this.#L(t), this.#w(t)), this.#j(t, l);
|
|
473
|
+
const g = this.#f[t];
|
|
474
|
+
g && this.setFormValue(g, String(l)), this.propertyChangedCallback(t, u, l), e.dispatch && this.dispatch("change", {
|
|
478
475
|
tagName: this.localName,
|
|
479
476
|
property: t,
|
|
480
|
-
oldValue:
|
|
477
|
+
oldValue: u,
|
|
481
478
|
value: l
|
|
482
479
|
});
|
|
483
480
|
}
|
|
484
481
|
});
|
|
485
482
|
}
|
|
486
483
|
#m() {
|
|
487
|
-
const t = this.hasAttribute("disabled"), e =
|
|
484
|
+
const t = this.hasAttribute("disabled"), e = j(this.shadowRoot);
|
|
488
485
|
for (const s of e)
|
|
489
|
-
|
|
486
|
+
gt(s) && (s.disabled = t);
|
|
490
487
|
}
|
|
491
488
|
disconnectedCallback() {
|
|
492
489
|
this.#o.clear(), this.#l.clear(), this.#u.clear();
|
|
@@ -506,15 +503,15 @@ class d extends HTMLElement {
|
|
|
506
503
|
return `display: ${t ? e : "none"}`;
|
|
507
504
|
}
|
|
508
505
|
#P(t) {
|
|
509
|
-
const e = t instanceof
|
|
506
|
+
const e = t instanceof b;
|
|
510
507
|
for (const s of t.getAttributeNames()) {
|
|
511
|
-
const o = t.getAttribute(s), i = this.#
|
|
508
|
+
const o = t.getAttribute(s), i = this.#E(t, o);
|
|
512
509
|
if (i) {
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
let [c,
|
|
516
|
-
c === "value" && (
|
|
517
|
-
|
|
510
|
+
const n = this[i];
|
|
511
|
+
n === void 0 && this.#c(t, s, i), t[i] = n;
|
|
512
|
+
let [c, a] = s.split(":");
|
|
513
|
+
c === "value" && (a ? (t["on" + a] === void 0 && this.#e(t, s, "refers to an unsupported event name"), t.setAttribute(c, this[i])) : a = "change"), e && t.#u.set(
|
|
514
|
+
b.getPropName(c),
|
|
518
515
|
i
|
|
519
516
|
);
|
|
520
517
|
}
|
|
@@ -526,10 +523,10 @@ class d extends HTMLElement {
|
|
|
526
523
|
const s = this.#s(e), o = this.#o.get(e) ?? [];
|
|
527
524
|
for (const i of o)
|
|
528
525
|
if (i instanceof HTMLElement)
|
|
529
|
-
this.#
|
|
526
|
+
this.#A(i, s);
|
|
530
527
|
else if (!(i instanceof CSSStyleRule)) {
|
|
531
|
-
const { element:
|
|
532
|
-
|
|
528
|
+
const { element: n, attrName: c } = i;
|
|
529
|
+
n instanceof CSSStyleRule ? n.style.setProperty(c, s) : B(n, c, s);
|
|
533
530
|
}
|
|
534
531
|
}
|
|
535
532
|
}
|
|
@@ -540,34 +537,34 @@ class d extends HTMLElement {
|
|
|
540
537
|
`const {${Object.keys(e).join(",")}} = context; return ${t};`
|
|
541
538
|
).call(this, e);
|
|
542
539
|
}
|
|
543
|
-
|
|
540
|
+
#N(t) {
|
|
544
541
|
const { localName: e } = t;
|
|
545
542
|
if (e === "style") {
|
|
546
543
|
const { sheet: s } = t, o = s?.cssRules ?? [], i = Array.from(o);
|
|
547
|
-
for (const
|
|
548
|
-
if (
|
|
549
|
-
const c = Array.from(
|
|
550
|
-
for (const
|
|
551
|
-
if (
|
|
552
|
-
const
|
|
553
|
-
this.#r(
|
|
544
|
+
for (const n of i)
|
|
545
|
+
if (n.constructor === CSSStyleRule) {
|
|
546
|
+
const c = Array.from(n.style);
|
|
547
|
+
for (const a of c)
|
|
548
|
+
if (a.startsWith("--")) {
|
|
549
|
+
const f = n.style.getPropertyValue(a);
|
|
550
|
+
this.#r(f, n, a);
|
|
554
551
|
}
|
|
555
552
|
}
|
|
556
553
|
} else {
|
|
557
554
|
let s = "";
|
|
558
|
-
if (
|
|
555
|
+
if (C(t)) {
|
|
559
556
|
this.#r(t.textContent, t);
|
|
560
|
-
const o = t.textContent?.match(
|
|
557
|
+
const o = t.textContent?.match(dt);
|
|
561
558
|
o && (s = o[1]);
|
|
562
559
|
} else {
|
|
563
560
|
const o = Array.from(t.childNodes).find(
|
|
564
|
-
(i) => i.nodeType ===
|
|
561
|
+
(i) => i.nodeType === F.COMMENT_NODE
|
|
565
562
|
);
|
|
566
563
|
o && (s = o.textContent?.trim() ?? "");
|
|
567
564
|
}
|
|
568
565
|
if (s) {
|
|
569
|
-
const o = this.#
|
|
570
|
-
o &&
|
|
566
|
+
const o = this.#E(t, s);
|
|
567
|
+
o && C(t) ? t.textContent = this[o] : this.#r(s, t);
|
|
571
568
|
}
|
|
572
569
|
}
|
|
573
570
|
}
|
|
@@ -578,30 +575,30 @@ class d extends HTMLElement {
|
|
|
578
575
|
formAssociatedCallback() {
|
|
579
576
|
let t = this.getAttribute("form-assoc");
|
|
580
577
|
if (!t) {
|
|
581
|
-
const
|
|
582
|
-
if (
|
|
578
|
+
const n = this.getAttribute("name");
|
|
579
|
+
if (n)
|
|
583
580
|
if (this.#n("value"))
|
|
584
|
-
t = `value:${
|
|
581
|
+
t = `value:${n}`;
|
|
585
582
|
else
|
|
586
583
|
return;
|
|
587
584
|
else
|
|
588
585
|
return;
|
|
589
586
|
}
|
|
590
587
|
const e = {}, s = t.split(",");
|
|
591
|
-
for (const
|
|
592
|
-
const [c,
|
|
593
|
-
e[c.trim()] =
|
|
588
|
+
for (const n of s) {
|
|
589
|
+
const [c, a] = n.split(":");
|
|
590
|
+
e[c.trim()] = a.trim();
|
|
594
591
|
}
|
|
595
592
|
this.#f = e, this.#i = new FormData(), this.#h = this.attachInternals(), this.#h.setFormValue(this.#i);
|
|
596
593
|
const o = Object.keys(this.#t.properties), i = this.#l;
|
|
597
|
-
for (const
|
|
598
|
-
i[
|
|
594
|
+
for (const n of o)
|
|
595
|
+
i[n] = this[n];
|
|
599
596
|
}
|
|
600
597
|
formResetCallback() {
|
|
601
598
|
const t = this.#l;
|
|
602
599
|
for (const e of Object.keys(t)) {
|
|
603
600
|
let s = t[e];
|
|
604
|
-
|
|
601
|
+
V.test(s) && (s = this.#s(s)), this[e] = s;
|
|
605
602
|
}
|
|
606
603
|
}
|
|
607
604
|
static getAttrName(t) {
|
|
@@ -612,20 +609,20 @@ class d extends HTMLElement {
|
|
|
612
609
|
let e = this.attrToPropMap.get(t);
|
|
613
610
|
return e || (e = t.replace(/-([a-z])/g, (s, o) => o.toUpperCase()), this.attrToPropMap.set(t, e)), e;
|
|
614
611
|
}
|
|
615
|
-
|
|
612
|
+
#$(t, e, s) {
|
|
616
613
|
if (s.length !== 1) return;
|
|
617
614
|
const [o] = s;
|
|
618
|
-
if (!
|
|
619
|
-
const i =
|
|
620
|
-
let [
|
|
621
|
-
if (!(i &&
|
|
615
|
+
if (!V.test(o)) return;
|
|
616
|
+
const i = J(t) || C(t);
|
|
617
|
+
let [n, c] = (e ?? "").split(":");
|
|
618
|
+
if (!(i && n === "value" || C(t))) return;
|
|
622
619
|
c ? t["on" + c] === void 0 && this.#e(t, e, "refers to an unsupported event name") : c = "change";
|
|
623
|
-
const
|
|
620
|
+
const f = S(o);
|
|
624
621
|
t.addEventListener(c, (l) => {
|
|
625
|
-
const { target:
|
|
626
|
-
if (!
|
|
627
|
-
const
|
|
628
|
-
this[
|
|
622
|
+
const { target: u } = l;
|
|
623
|
+
if (!u) return;
|
|
624
|
+
const h = u.value, { type: d } = this.#t.properties[f];
|
|
625
|
+
this[f] = d === Number ? W(h) : h, this.#w(f);
|
|
629
626
|
});
|
|
630
627
|
}
|
|
631
628
|
#n(t) {
|
|
@@ -634,7 +631,7 @@ class d extends HTMLElement {
|
|
|
634
631
|
#g(t) {
|
|
635
632
|
const e = Array.from(t.querySelectorAll("*"));
|
|
636
633
|
for (const s of e)
|
|
637
|
-
this.#P(s), s.firstElementChild || this
|
|
634
|
+
this.#P(s), s.firstElementChild || this.#N(s);
|
|
638
635
|
}
|
|
639
636
|
// formAssociated is only needed when the component is inside a form.
|
|
640
637
|
#y() {
|
|
@@ -648,36 +645,36 @@ class d extends HTMLElement {
|
|
|
648
645
|
}
|
|
649
646
|
static get observedAttributes() {
|
|
650
647
|
const t = Object.keys(this.properties || {}).map(
|
|
651
|
-
(e) =>
|
|
648
|
+
(e) => b.getAttrName(e)
|
|
652
649
|
);
|
|
653
650
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
654
651
|
}
|
|
655
652
|
// Subclasses can override this to add functionality.
|
|
656
653
|
propertyChangedCallback(t, e, s) {
|
|
657
654
|
}
|
|
658
|
-
#
|
|
659
|
-
if (!e || !
|
|
660
|
-
const s =
|
|
655
|
+
#E(t, e) {
|
|
656
|
+
if (!e || !V.test(e)) return;
|
|
657
|
+
const s = S(e);
|
|
661
658
|
return this[s] === void 0 && this.#c(t, "", s), s;
|
|
662
659
|
}
|
|
663
|
-
#
|
|
660
|
+
#w(t) {
|
|
664
661
|
const e = this.#t.propToExprsMap.get(t) || [];
|
|
665
662
|
this.#b(e);
|
|
666
663
|
}
|
|
667
664
|
#R(t, e) {
|
|
668
665
|
const { computed: s, uses: o } = e, i = this.#t.propToComputedMap;
|
|
669
|
-
function
|
|
670
|
-
let l = i.get(
|
|
671
|
-
l || (l = [], i.set(
|
|
666
|
+
function n(a, f) {
|
|
667
|
+
let l = i.get(a);
|
|
668
|
+
l || (l = [], i.set(a, l)), l.push([t, f]);
|
|
672
669
|
}
|
|
673
|
-
const c = s.match(
|
|
674
|
-
for (const
|
|
675
|
-
const
|
|
676
|
-
this[
|
|
670
|
+
const c = s.match(I) || [];
|
|
671
|
+
for (const a of c) {
|
|
672
|
+
const f = S(a);
|
|
673
|
+
this[f] === void 0 && this.#c(null, t, f), typeof this[f] != "function" && n(f, s);
|
|
677
674
|
}
|
|
678
675
|
if (o)
|
|
679
|
-
for (const
|
|
680
|
-
|
|
676
|
+
for (const a of o.split(","))
|
|
677
|
+
n(a.trim(), s);
|
|
681
678
|
}
|
|
682
679
|
// WARNING: Do not place untrusted JavaScript expressions
|
|
683
680
|
// in attribute values or the text content of elements!
|
|
@@ -685,30 +682,30 @@ class d extends HTMLElement {
|
|
|
685
682
|
if (!t) return;
|
|
686
683
|
const o = this.#p(e, s, t);
|
|
687
684
|
if (!o) {
|
|
688
|
-
const
|
|
689
|
-
s ?
|
|
685
|
+
const a = t.replaceAll("this..", "this.");
|
|
686
|
+
s ? B(e, s, a) : "textContent" in e && (e.textContent = a);
|
|
690
687
|
return;
|
|
691
688
|
}
|
|
692
689
|
const i = this.#t;
|
|
693
|
-
o.forEach((
|
|
694
|
-
const
|
|
695
|
-
if (typeof this[
|
|
690
|
+
o.forEach((a) => {
|
|
691
|
+
const f = S(a);
|
|
692
|
+
if (typeof this[f] == "function") return;
|
|
696
693
|
const l = i.propToExprsMap;
|
|
697
|
-
let
|
|
698
|
-
|
|
694
|
+
let u = l.get(f);
|
|
695
|
+
u || (u = [], l.set(f, u)), u.includes(t) || u.push(t);
|
|
699
696
|
});
|
|
700
|
-
for (const [
|
|
701
|
-
for (const l of
|
|
702
|
-
const
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
697
|
+
for (const [a, f] of this.#o.entries())
|
|
698
|
+
for (const l of f) {
|
|
699
|
+
const u = l instanceof HTMLElement || l instanceof CSSStyleRule ? l : l.element;
|
|
700
|
+
u instanceof CSSStyleRule || u.isConnected || this.#o.set(
|
|
701
|
+
a,
|
|
702
|
+
f.filter((h) => h !== l)
|
|
706
703
|
);
|
|
707
704
|
}
|
|
708
|
-
let
|
|
709
|
-
|
|
705
|
+
let n = this.#o.get(t);
|
|
706
|
+
n || (n = [], this.#o.set(t, n)), n.push(s ? { element: e, attrName: s } : e), e instanceof HTMLElement && this.#$(e, s, o);
|
|
710
707
|
const c = this.#s(t);
|
|
711
|
-
s ?
|
|
708
|
+
s ? B(e, s, c) : this.#A(e, c);
|
|
712
709
|
}
|
|
713
710
|
// This follows the best practice
|
|
714
711
|
// "Do not override author-set, global attributes."
|
|
@@ -716,64 +713,74 @@ class d extends HTMLElement {
|
|
|
716
713
|
this.hasAttribute(t) || this.setAttribute(t, e);
|
|
717
714
|
}
|
|
718
715
|
setFormValue(t, e) {
|
|
719
|
-
!this.#i || !
|
|
716
|
+
!this.#i || !q(e) || (this.#i.set(t, e), this.#h?.setFormValue(this.#i));
|
|
720
717
|
}
|
|
721
718
|
static ssr(t = {}) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
return new Function("return " + a).call(t);
|
|
729
|
-
}
|
|
730
|
-
let s = "";
|
|
731
|
-
for (const [a, l] of Object.entries(t)) {
|
|
732
|
-
const h = this.getAttrName(a);
|
|
733
|
-
s += ` ${h}="${l}"`;
|
|
719
|
+
let e = "";
|
|
720
|
+
const s = Object.keys(t);
|
|
721
|
+
s.sort();
|
|
722
|
+
for (const h of s) {
|
|
723
|
+
const d = this.getAttrName(h);
|
|
724
|
+
e += ` ${d}="${t[h]}"`;
|
|
734
725
|
}
|
|
735
|
-
const o = this.
|
|
736
|
-
for (const
|
|
737
|
-
|
|
738
|
-
const { value:
|
|
739
|
-
|
|
726
|
+
const o = this.properties;
|
|
727
|
+
for (const [h, d] of Object.entries(o))
|
|
728
|
+
if (t[h] === void 0) {
|
|
729
|
+
const { value: g } = d;
|
|
730
|
+
g !== void 0 && (t[h] = g);
|
|
740
731
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
732
|
+
function i(h) {
|
|
733
|
+
return new Function("return " + h).call(t);
|
|
734
|
+
}
|
|
735
|
+
function n(h) {
|
|
736
|
+
const { attributes: d } = h;
|
|
737
|
+
for (const [y, R] of Object.entries(d))
|
|
738
|
+
if (L.test(R)) {
|
|
739
|
+
const v = i(R), k = o[y].value;
|
|
740
|
+
v === k ? h.removeAttribute(y) : h.setAttribute(y, v);
|
|
741
|
+
}
|
|
742
|
+
const { childNodes: g } = h;
|
|
743
|
+
g.forEach((y, R) => {
|
|
744
|
+
if (y.nodeType === F.ELEMENT_NODE)
|
|
745
|
+
n(y);
|
|
746
|
+
else if (y.nodeType === F.COMMENT_NODE) {
|
|
747
|
+
const v = y.textContent ?? "";
|
|
748
|
+
if (L.test(v)) {
|
|
749
|
+
const k = i(v);
|
|
750
|
+
g[R] = new ct(k);
|
|
747
751
|
}
|
|
748
752
|
}
|
|
753
|
+
});
|
|
749
754
|
}
|
|
750
|
-
const c =
|
|
751
|
-
|
|
755
|
+
const c = this.buildHTML(), a = rt(c, { comment: !0 }), { children: f } = a;
|
|
756
|
+
f.forEach(n);
|
|
757
|
+
const l = f.map((h) => h.outerHTML).join(`
|
|
758
|
+
`), { elementName: u } = this;
|
|
752
759
|
return `
|
|
753
|
-
<${
|
|
760
|
+
<${u}${e}>
|
|
754
761
|
<template shadowrootmode="open">
|
|
755
|
-
${
|
|
762
|
+
${l}
|
|
756
763
|
</template>
|
|
757
|
-
</${
|
|
764
|
+
</${u}>
|
|
758
765
|
`;
|
|
759
766
|
}
|
|
760
767
|
#e(t, e, s) {
|
|
761
768
|
const o = t instanceof HTMLElement ? t.localName : "CSS rule";
|
|
762
|
-
throw new
|
|
769
|
+
throw new x(
|
|
763
770
|
`component ${this.#t.elementName}` + (t ? `, element "${o}"` : "") + (e ? `, attribute "${e}"` : "") + ` ${s}`
|
|
764
771
|
);
|
|
765
772
|
}
|
|
766
773
|
#c(t, e, s) {
|
|
767
774
|
this.#e(t, e, `refers to missing property "${s}"`);
|
|
768
775
|
}
|
|
769
|
-
#
|
|
776
|
+
#T(t, e) {
|
|
770
777
|
return this.#M(t, this.getAttribute(e));
|
|
771
778
|
}
|
|
772
779
|
#M(t, e) {
|
|
773
|
-
if (e?.match(
|
|
780
|
+
if (e?.match(I)) return e;
|
|
774
781
|
const s = this.#t, { type: o } = s.properties[t];
|
|
775
782
|
if (o || this.#e(null, t, "does not specify its type"), o === String) return e;
|
|
776
|
-
if (o === Number) return
|
|
783
|
+
if (o === Number) return W(e);
|
|
777
784
|
if (o === Boolean)
|
|
778
785
|
return e === "true" ? !0 : e === "false" || e === "null" ? !1 : (e && e !== t && this.#e(
|
|
779
786
|
null,
|
|
@@ -784,9 +791,9 @@ class d extends HTMLElement {
|
|
|
784
791
|
// Updates the matching attribute for a property.
|
|
785
792
|
// VS Code thinks this is never called, but it is called by #defineProp.
|
|
786
793
|
#O(t, e, s, o) {
|
|
787
|
-
if (
|
|
788
|
-
const i = e === Boolean ? this.hasAttribute(o) : this.#
|
|
789
|
-
s !== i &&
|
|
794
|
+
if (q(s)) {
|
|
795
|
+
const i = e === Boolean ? this.hasAttribute(o) : this.#T(t, o);
|
|
796
|
+
s !== i && it(this, o || t, s);
|
|
790
797
|
}
|
|
791
798
|
}
|
|
792
799
|
// Updates all computed properties that reference this property.
|
|
@@ -796,7 +803,7 @@ class d extends HTMLElement {
|
|
|
796
803
|
for (const [o, i] of s)
|
|
797
804
|
this[o] = this.#s(i);
|
|
798
805
|
}
|
|
799
|
-
#
|
|
806
|
+
#A(t, e) {
|
|
800
807
|
if (e === void 0) return;
|
|
801
808
|
const s = t instanceof HTMLElement;
|
|
802
809
|
Array.isArray(e) && (e = e.join(""));
|
|
@@ -807,11 +814,11 @@ class d extends HTMLElement {
|
|
|
807
814
|
" computed content is not a string or number"
|
|
808
815
|
);
|
|
809
816
|
const i = String(e);
|
|
810
|
-
if (t instanceof HTMLElement &&
|
|
817
|
+
if (t instanceof HTMLElement && C(t))
|
|
811
818
|
t.value = i;
|
|
812
819
|
else if (s && o === "string" && i.trim().startsWith("<")) {
|
|
813
|
-
const
|
|
814
|
-
t.innerHTML =
|
|
820
|
+
const n = lt(i);
|
|
821
|
+
t.innerHTML = n, this.#v(t), this.#g(t);
|
|
815
822
|
} else s && (t.textContent = i);
|
|
816
823
|
}
|
|
817
824
|
// Update corresponding parent web component property if bound to one.
|
|
@@ -823,8 +830,8 @@ class d extends HTMLElement {
|
|
|
823
830
|
if (!(o instanceof ShadowRoot)) return;
|
|
824
831
|
const { host: i } = o;
|
|
825
832
|
if (!i) return;
|
|
826
|
-
const
|
|
827
|
-
|
|
833
|
+
const n = i;
|
|
834
|
+
n[s] = e;
|
|
828
835
|
}
|
|
829
836
|
/**
|
|
830
837
|
* @param state - WrecState object
|
|
@@ -840,22 +847,22 @@ class d extends HTMLElement {
|
|
|
840
847
|
this.#_(t, e);
|
|
841
848
|
for (const [s, o] of Object.entries(e))
|
|
842
849
|
if (this.#n(o)) {
|
|
843
|
-
const i =
|
|
850
|
+
const i = Y(t, s);
|
|
844
851
|
i !== void 0 && (this[o] = i);
|
|
845
|
-
const
|
|
846
|
-
|
|
852
|
+
const n = this.#t.properties[o];
|
|
853
|
+
n.state = t, n.stateProp = s;
|
|
847
854
|
}
|
|
848
855
|
t.addListener(this, e);
|
|
849
856
|
}
|
|
850
857
|
#H() {
|
|
851
858
|
const t = new Set(Object.keys(this.#t.properties));
|
|
852
859
|
for (const e of this.getAttributeNames())
|
|
853
|
-
if (!
|
|
860
|
+
if (!ht.has(e) && !e.startsWith("on")) {
|
|
854
861
|
if (e === "form-assoc") {
|
|
855
862
|
this.#y();
|
|
856
863
|
continue;
|
|
857
864
|
}
|
|
858
|
-
if (!t.has(
|
|
865
|
+
if (!t.has(b.getPropName(e))) {
|
|
859
866
|
if (e === "name") {
|
|
860
867
|
this.#y();
|
|
861
868
|
continue;
|
|
@@ -865,16 +872,16 @@ class d extends HTMLElement {
|
|
|
865
872
|
}
|
|
866
873
|
}
|
|
867
874
|
#p(t, e, s) {
|
|
868
|
-
const o = s.match(
|
|
875
|
+
const o = s.match(I);
|
|
869
876
|
if (o)
|
|
870
877
|
return o.forEach((i) => {
|
|
871
|
-
const
|
|
872
|
-
this[
|
|
878
|
+
const n = S(i);
|
|
879
|
+
this[n] === void 0 && this.#c(t, e, n);
|
|
873
880
|
}), o;
|
|
874
881
|
}
|
|
875
882
|
#_(t, e) {
|
|
876
883
|
for (const [s, o] of Object.entries(e)) {
|
|
877
|
-
let i =
|
|
884
|
+
let i = Y(t, s);
|
|
878
885
|
i === void 0 && this.#e(this, void 0, `invalid state path "${s}"`), i = this[o], this.#n(o) || this.#e(
|
|
879
886
|
null,
|
|
880
887
|
o,
|
|
@@ -901,19 +908,19 @@ class d extends HTMLElement {
|
|
|
901
908
|
`was set to a ${o}, but must be a ${e.name}`
|
|
902
909
|
);
|
|
903
910
|
}
|
|
904
|
-
#
|
|
911
|
+
#v(t) {
|
|
905
912
|
const e = Array.from(t.querySelectorAll("*"));
|
|
906
913
|
for (const s of e) {
|
|
907
914
|
const o = [];
|
|
908
915
|
for (const i of Array.from(s.attributes)) {
|
|
909
|
-
const
|
|
910
|
-
if (
|
|
911
|
-
let c =
|
|
916
|
+
const n = i.name;
|
|
917
|
+
if (n.startsWith("on")) {
|
|
918
|
+
let c = n.slice(2);
|
|
912
919
|
c = c[0].toLowerCase() + c.slice(1).toLowerCase();
|
|
913
|
-
const
|
|
914
|
-
this.#p(s,
|
|
915
|
-
let
|
|
916
|
-
typeof this[
|
|
920
|
+
const a = i.value;
|
|
921
|
+
this.#p(s, n, a);
|
|
922
|
+
let f;
|
|
923
|
+
typeof this[a] == "function" ? f = (l) => this[a](l) : (this.#p(s, n, a), f = () => this.#s(a)), s.addEventListener(c, f), o.push(n);
|
|
917
924
|
}
|
|
918
925
|
}
|
|
919
926
|
for (const i of o)
|
|
@@ -921,40 +928,40 @@ class d extends HTMLElement {
|
|
|
921
928
|
}
|
|
922
929
|
}
|
|
923
930
|
}
|
|
924
|
-
function
|
|
925
|
-
let e =
|
|
931
|
+
function Ct(r, ...t) {
|
|
932
|
+
let e = st(r, t);
|
|
926
933
|
for (; ; ) {
|
|
927
|
-
const s =
|
|
934
|
+
const s = ut.exec(e);
|
|
928
935
|
if (!s) break;
|
|
929
936
|
const o = s[2];
|
|
930
|
-
if (
|
|
937
|
+
if (L.test(o)) {
|
|
931
938
|
const i = s[1];
|
|
932
939
|
if (!i.startsWith("--")) {
|
|
933
|
-
const
|
|
940
|
+
const n = `--${i}: ${o};
|
|
934
941
|
${i}: var(--${i})`;
|
|
935
|
-
e =
|
|
942
|
+
e = ot(e, s.index, s[0].length, n);
|
|
936
943
|
}
|
|
937
944
|
}
|
|
938
945
|
}
|
|
939
946
|
return e;
|
|
940
947
|
}
|
|
941
|
-
function
|
|
942
|
-
let e =
|
|
948
|
+
function xt(r, ...t) {
|
|
949
|
+
let e = st(r, t);
|
|
943
950
|
for (; ; ) {
|
|
944
|
-
const s =
|
|
951
|
+
const s = mt.exec(e);
|
|
945
952
|
if (!s || s[1] === "style") break;
|
|
946
|
-
const o =
|
|
947
|
-
if (
|
|
948
|
-
const i = `<!-- ${o.trim()} -->`,
|
|
949
|
-
e =
|
|
953
|
+
const o = Et(s[2]);
|
|
954
|
+
if (L.test(o)) {
|
|
955
|
+
const i = `<!-- ${o.trim()} -->`, n = s.index + s[0].indexOf(">") + 1;
|
|
956
|
+
e = ot(e, n, o.length, i);
|
|
950
957
|
}
|
|
951
958
|
}
|
|
952
959
|
return e;
|
|
953
960
|
}
|
|
954
961
|
export {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
962
|
+
b as Wrec,
|
|
963
|
+
z as WrecState,
|
|
964
|
+
St as createElement,
|
|
965
|
+
Ct as css,
|
|
966
|
+
xt as html
|
|
960
967
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "wrec",
|
|
3
3
|
"description": "a small library that greatly simplifies building web components",
|
|
4
4
|
"author": "R. Mark Volkmann",
|
|
5
|
-
"version": "0.21.
|
|
5
|
+
"version": "0.21.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"vite-plugin-dts": "^4.5.4"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"
|
|
49
|
+
"node-html-parser": "^7.1.0",
|
|
50
50
|
"xss": "^1.0.15"
|
|
51
51
|
}
|
|
52
52
|
}
|