wrec 0.22.5 → 0.22.6
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 +19 -0
- package/dist/wrec-ssr.d.ts +12 -1
- package/dist/wrec.d.ts +12 -1
- package/dist/wrec.es.js +236 -223
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,6 +110,23 @@ Here are the steps:
|
|
|
110
110
|
MyCounter.define('my-counter');
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
+
Property definitions can also constrain string values to an allowed set:
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
class TrafficLight extends Wrec {
|
|
117
|
+
static properties = {
|
|
118
|
+
color: {
|
|
119
|
+
type: String,
|
|
120
|
+
values: ['red', 'yellow', 'green'],
|
|
121
|
+
value: 'red'
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
With that configuration, the `color` attribute and property can only be set
|
|
128
|
+
to one of those strings.
|
|
129
|
+
|
|
113
130
|
1. Create the file `index.html` containing the following.
|
|
114
131
|
|
|
115
132
|
```html
|
|
@@ -225,3 +242,5 @@ to share state across multiple wrec components.
|
|
|
225
242
|
state.name; // to see current value of "name" property
|
|
226
243
|
state.name = 'Earth'; // to modify "name" property
|
|
227
244
|
```
|
|
245
|
+
|
|
246
|
+
`traffic-light.html` demonstrates a property with an enumerated value.
|
package/dist/wrec-ssr.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
declare type AnyClass = new (...args: any[]) => any;
|
|
2
|
+
|
|
1
3
|
declare type ChangeListener = {
|
|
2
4
|
changed: (statePath: string, componentProperty: string, newValue: unknown, oldValue: unknown, state: WrecState) => void;
|
|
3
5
|
};
|
|
@@ -15,6 +17,15 @@ declare const HTMLElementBase: {
|
|
|
15
17
|
|
|
16
18
|
declare type LooseObject = Record<string, unknown>;
|
|
17
19
|
|
|
20
|
+
declare type PropertyConfig = {
|
|
21
|
+
computed?: string;
|
|
22
|
+
dispatch?: boolean;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
type: AnyClass;
|
|
25
|
+
value?: any;
|
|
26
|
+
values?: string[];
|
|
27
|
+
};
|
|
28
|
+
|
|
18
29
|
declare type StringToAny = Record<string, any>;
|
|
19
30
|
|
|
20
31
|
declare type StringToString = Record<string, string>;
|
|
@@ -28,7 +39,7 @@ export declare abstract class Wrec extends HTMLElementBase implements ChangeList
|
|
|
28
39
|
private static elementName;
|
|
29
40
|
static formAssociated: boolean;
|
|
30
41
|
static html: string;
|
|
31
|
-
static properties:
|
|
42
|
+
static properties: Record<string, PropertyConfig>;
|
|
32
43
|
private static propToComputedMap;
|
|
33
44
|
private static propToExprsMap;
|
|
34
45
|
private static template;
|
package/dist/wrec.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
declare type AnyClass = new (...args: any[]) => any;
|
|
2
|
+
|
|
1
3
|
export declare type ChangeListener = {
|
|
2
4
|
changed: (statePath: string, componentProperty: string, newValue: unknown, oldValue: unknown, state: WrecState) => void;
|
|
3
5
|
};
|
|
@@ -15,6 +17,15 @@ declare const HTMLElementBase: {
|
|
|
15
17
|
|
|
16
18
|
declare type LooseObject = Record<string, unknown>;
|
|
17
19
|
|
|
20
|
+
declare type PropertyConfig = {
|
|
21
|
+
computed?: string;
|
|
22
|
+
dispatch?: boolean;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
type: AnyClass;
|
|
25
|
+
value?: any;
|
|
26
|
+
values?: string[];
|
|
27
|
+
};
|
|
28
|
+
|
|
18
29
|
declare type StringToAny = Record<string, any>;
|
|
19
30
|
|
|
20
31
|
declare type StringToString = Record<string, string>;
|
|
@@ -28,7 +39,7 @@ export declare abstract class Wrec extends HTMLElementBase implements ChangeList
|
|
|
28
39
|
private static elementName;
|
|
29
40
|
static formAssociated: boolean;
|
|
30
41
|
static html: string;
|
|
31
|
-
static properties:
|
|
42
|
+
static properties: Record<string, PropertyConfig>;
|
|
32
43
|
private static propToComputedMap;
|
|
33
44
|
private static propToExprsMap;
|
|
34
45
|
private static template;
|
package/dist/wrec.es.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var B = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var O = (
|
|
5
|
-
var
|
|
4
|
+
var O = (r, t, e) => t.has(r) || B("Cannot " + e);
|
|
5
|
+
var u = (r, t, e) => (O(r, t, "read from private field"), e ? e.call(r) : t.get(r)), b = (r, t, e) => t.has(r) ? B("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), w = (r, t, e, s) => (O(r, t, "write to private field"), s ? s.call(r, e) : t.set(r, e), e), V = (r, t, e) => (O(r, t, "access private method"), e);
|
|
6
6
|
import W from "xss";
|
|
7
|
-
function
|
|
7
|
+
function Z(r, t, e = "") {
|
|
8
8
|
const s = /* @__PURE__ */ new WeakMap(), o = {
|
|
9
9
|
// Intercept property reads.
|
|
10
10
|
// This creates nested proxies lazily.
|
|
11
|
-
get(i,
|
|
12
|
-
const c = Reflect.get(i,
|
|
11
|
+
get(i, n) {
|
|
12
|
+
const c = Reflect.get(i, n);
|
|
13
13
|
if (c === null || typeof c != "object") return c;
|
|
14
14
|
const a = s.get(c);
|
|
15
15
|
if (a) return a;
|
|
16
|
-
const h = e ? `${e}.${
|
|
16
|
+
const h = e ? `${e}.${n}` : n, f = Z(c, t, h);
|
|
17
17
|
return s.set(c, f), f;
|
|
18
18
|
},
|
|
19
19
|
// Intercept property writes.
|
|
20
|
-
set(i,
|
|
21
|
-
const a = Reflect.get(i,
|
|
20
|
+
set(i, n, c) {
|
|
21
|
+
const a = Reflect.get(i, n);
|
|
22
22
|
if (a !== c) {
|
|
23
|
-
Reflect.set(i,
|
|
24
|
-
const h = e ? `${e}.${
|
|
23
|
+
Reflect.set(i, n, c);
|
|
24
|
+
const h = e ? `${e}.${n}` : n;
|
|
25
25
|
t(h, a, c);
|
|
26
26
|
}
|
|
27
27
|
return !0;
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
return new Proxy(
|
|
30
|
+
return new Proxy(r, o);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function U(r) {
|
|
33
33
|
const t = {};
|
|
34
|
-
for (const [e, s] of Object.entries(
|
|
34
|
+
for (const [e, s] of Object.entries(r)) {
|
|
35
35
|
const o = typeof s == "object" && s !== null;
|
|
36
|
-
t[e] = o ?
|
|
36
|
+
t[e] = o ? U(s) : s;
|
|
37
37
|
}
|
|
38
38
|
return t;
|
|
39
39
|
}
|
|
40
40
|
const P = typeof window < "u" && typeof window.document < "u";
|
|
41
41
|
let z = class extends Error {
|
|
42
42
|
};
|
|
43
|
-
var y,
|
|
43
|
+
var y, R, d, v, C, g, N, Y;
|
|
44
44
|
const T = class T {
|
|
45
45
|
constructor(t, e, s) {
|
|
46
|
-
b(this,
|
|
47
|
-
b(this,
|
|
46
|
+
b(this, N);
|
|
47
|
+
b(this, R, /* @__PURE__ */ Symbol("objectId"));
|
|
48
48
|
// This cannot be replaced by a WeakMap<ChangeListener, Set<string>>
|
|
49
49
|
// because there is no way to iterate over the keys of a WeakMap.
|
|
50
50
|
b(this, d, []);
|
|
@@ -52,16 +52,16 @@ const T = class T {
|
|
|
52
52
|
b(this, C);
|
|
53
53
|
b(this, g);
|
|
54
54
|
if (!t) throw new z("name cannot be empty");
|
|
55
|
-
if (
|
|
55
|
+
if (u(T, y).has(t))
|
|
56
56
|
throw new z(`WrecState with name "${t}" already exists`);
|
|
57
|
-
if (w(this, v, t), w(this, C, e), w(this, g,
|
|
57
|
+
if (w(this, v, t), w(this, C, e), w(this, g, Z({}, V(this, N, Y).bind(this))), e && P) {
|
|
58
58
|
const o = sessionStorage.getItem("wrec-state-" + t), i = o ? JSON.parse(o) : void 0;
|
|
59
59
|
i && (s = i);
|
|
60
60
|
}
|
|
61
61
|
if (s)
|
|
62
62
|
for (const [o, i] of Object.entries(s))
|
|
63
63
|
this.addProperty(o, i);
|
|
64
|
-
|
|
64
|
+
u(T, y).set(t, this);
|
|
65
65
|
}
|
|
66
66
|
// This static method is useful for accessing a specific WrecState object
|
|
67
67
|
// from the DevTools console. For example:
|
|
@@ -74,22 +74,22 @@ const T = class T {
|
|
|
74
74
|
// state.color = 'blue';
|
|
75
75
|
// state.team.leader.name = 'Mark';
|
|
76
76
|
static get(t) {
|
|
77
|
-
return
|
|
77
|
+
return u(this, y).get(t);
|
|
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
83
|
addListener(t, e = {}) {
|
|
84
|
-
const s =
|
|
84
|
+
const s = u(this, d).find(
|
|
85
85
|
(o) => o.listenerRef.deref() === t
|
|
86
86
|
);
|
|
87
87
|
if (s) {
|
|
88
88
|
const { propertyMap: o } = s;
|
|
89
|
-
for (const [i,
|
|
90
|
-
o[i] =
|
|
89
|
+
for (const [i, n] of Object.entries(e))
|
|
90
|
+
o[i] = n;
|
|
91
91
|
} else
|
|
92
|
-
|
|
92
|
+
u(this, d).push({
|
|
93
93
|
listenerRef: new WeakRef(t),
|
|
94
94
|
propertyMap: e
|
|
95
95
|
});
|
|
@@ -98,38 +98,38 @@ const T = class T {
|
|
|
98
98
|
Object.defineProperty(this, t, {
|
|
99
99
|
enumerable: !0,
|
|
100
100
|
get() {
|
|
101
|
-
return
|
|
101
|
+
return u(this, g)[t];
|
|
102
102
|
},
|
|
103
103
|
set(s) {
|
|
104
|
-
|
|
104
|
+
u(this, g)[t] = s;
|
|
105
105
|
}
|
|
106
|
-
}),
|
|
106
|
+
}), u(this, g)[t] = e;
|
|
107
107
|
}
|
|
108
108
|
get id() {
|
|
109
|
-
return
|
|
109
|
+
return u(this, R);
|
|
110
110
|
}
|
|
111
111
|
// This is useful for debugging from the DevTools console.
|
|
112
112
|
// For example: state.log()
|
|
113
113
|
log() {
|
|
114
|
-
console.log("WrecState:",
|
|
115
|
-
for (const [t, e] of Object.entries(
|
|
114
|
+
console.log("WrecState:", u(this, v));
|
|
115
|
+
for (const [t, e] of Object.entries(u(this, g)))
|
|
116
116
|
console.log(` ${t} = ${JSON.stringify(e)}`);
|
|
117
117
|
}
|
|
118
118
|
removeListener(t) {
|
|
119
|
-
w(this, d,
|
|
119
|
+
w(this, d, u(this, d).filter((e) => e.listenerRef.deref() !== t));
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
y = new WeakMap(),
|
|
122
|
+
y = new WeakMap(), R = new WeakMap(), d = new WeakMap(), v = new WeakMap(), C = new WeakMap(), g = new WeakMap(), N = new WeakSet(), Y = function(t, e, s) {
|
|
123
123
|
const o = /* @__PURE__ */ new Set();
|
|
124
|
-
for (const i of
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
124
|
+
for (const i of u(this, d)) {
|
|
125
|
+
const n = i.listenerRef.deref();
|
|
126
|
+
if (!n)
|
|
127
127
|
o.add(i);
|
|
128
|
-
else if (P &&
|
|
128
|
+
else if (P && n instanceof HTMLElement && !n.isConnected)
|
|
129
129
|
o.add(i);
|
|
130
130
|
else {
|
|
131
131
|
const { propertyMap: c } = i, a = Object.keys(c);
|
|
132
|
-
(a.length === 0 || a.includes(t)) &&
|
|
132
|
+
(a.length === 0 || a.includes(t)) && n.changed(
|
|
133
133
|
t,
|
|
134
134
|
c[t],
|
|
135
135
|
s,
|
|
@@ -138,43 +138,43 @@ y = new WeakMap(), N = new WeakMap(), d = new WeakMap(), v = new WeakMap(), C =
|
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
w(this, d,
|
|
141
|
+
w(this, d, u(this, d).filter(
|
|
142
142
|
(i) => !o.has(i)
|
|
143
143
|
));
|
|
144
144
|
}, b(T, y, /* @__PURE__ */ new Map()), P && window.addEventListener("beforeunload", () => {
|
|
145
|
-
for (const [t, e] of
|
|
146
|
-
if (
|
|
147
|
-
const s =
|
|
145
|
+
for (const [t, e] of u(T, y).entries())
|
|
146
|
+
if (u(e, C)) {
|
|
147
|
+
const s = U(e);
|
|
148
148
|
sessionStorage.setItem("wrec-state-" + t, JSON.stringify(s));
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
|
-
let
|
|
152
|
-
P && process.env.NODE_ENV === "development" && (window.WrecState =
|
|
153
|
-
function q(
|
|
154
|
-
let e =
|
|
151
|
+
let F = T;
|
|
152
|
+
P && process.env.NODE_ENV === "development" && (window.WrecState = F);
|
|
153
|
+
function q(r, t) {
|
|
154
|
+
let e = r;
|
|
155
155
|
for (const s of t.split("."))
|
|
156
156
|
e = e[s];
|
|
157
157
|
return e;
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function ot(r, t, e) {
|
|
160
160
|
const s = t.split("."), o = s.length - 1;
|
|
161
|
-
let i =
|
|
162
|
-
s.forEach((
|
|
163
|
-
c === o ? i[
|
|
161
|
+
let i = r;
|
|
162
|
+
s.forEach((n, c) => {
|
|
163
|
+
c === o ? i[n] = e : i = i[n];
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
const
|
|
167
|
-
function
|
|
166
|
+
const it = /* @__PURE__ */ new Set(["input", "label", "option", "th"]), J = "__WREC", X = "__";
|
|
167
|
+
function nt(r) {
|
|
168
168
|
const t = {
|
|
169
169
|
allowCommentTag: !0,
|
|
170
170
|
onTag: (o, i) => {
|
|
171
|
-
if (
|
|
171
|
+
if (it.has(o)) return i;
|
|
172
172
|
},
|
|
173
|
-
onTagAttr(o, i,
|
|
173
|
+
onTagAttr(o, i, n) {
|
|
174
174
|
if (i.startsWith("on")) return "";
|
|
175
175
|
},
|
|
176
|
-
safeAttrValue(o, i,
|
|
177
|
-
return i === "class" || o === "a" && i === "href" && !
|
|
176
|
+
safeAttrValue(o, i, n) {
|
|
177
|
+
return i === "class" || o === "a" && i === "href" && !n.startsWith("javascript") || o === "img" && i === "src" ? n : "";
|
|
178
178
|
},
|
|
179
179
|
stripIgnoreTagBody: ["script", "style", "iframe"],
|
|
180
180
|
whiteList: {
|
|
@@ -183,32 +183,32 @@ function it(n) {
|
|
|
183
183
|
span: ["class"]
|
|
184
184
|
}
|
|
185
185
|
}, e = [];
|
|
186
|
-
|
|
186
|
+
r = r.replace(/<!--[\s\S]*?-->/g, (o) => {
|
|
187
187
|
let i = "";
|
|
188
188
|
do
|
|
189
189
|
i = J + e.length + X;
|
|
190
|
-
while (
|
|
190
|
+
while (r.includes(i));
|
|
191
191
|
return e.push(o), i;
|
|
192
192
|
});
|
|
193
|
-
let s = W(
|
|
193
|
+
let s = W(r, t);
|
|
194
194
|
return e.forEach((o, i) => {
|
|
195
|
-
const
|
|
195
|
+
const n = new RegExp(
|
|
196
196
|
`${J}${i}${X}`,
|
|
197
197
|
"g"
|
|
198
198
|
);
|
|
199
|
-
s = s.replace(
|
|
199
|
+
s = s.replace(n, o);
|
|
200
200
|
}), s;
|
|
201
201
|
}
|
|
202
|
-
const
|
|
202
|
+
const rt = /* @__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
|
+
]), ct = globalThis.HTMLElement ?? class {
|
|
210
|
+
}, _ = globalThis.customElements ?? {
|
|
211
|
+
get: (r) => {
|
|
212
212
|
},
|
|
213
213
|
getName: () => "",
|
|
214
214
|
define: () => {
|
|
@@ -221,96 +221,96 @@ const nt = /* @__PURE__ */ new Set([
|
|
|
221
221
|
};
|
|
222
222
|
class E extends Error {
|
|
223
223
|
}
|
|
224
|
-
const
|
|
225
|
-
function pt(
|
|
226
|
-
return
|
|
224
|
+
const at = /([a-zA-Z-]+)\s*:\s*([^;}]+)/g, G = "a-zA-Z_$", ft = G + "0-9", S = `[${G}][${ft}]*`, ht = /<!--\s*(.*?)\s*-->/, lt = /<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g, j = new RegExp(`^this\\.${S}$`), L = new RegExp(`this\\.${S}(\\.${S})*`, "g"), Q = new RegExp(`this\\.${S}(\\.${S})*`), ut = 5;
|
|
225
|
+
function pt(r) {
|
|
226
|
+
return r instanceof HTMLButtonElement || r instanceof HTMLFieldSetElement || r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement || r instanceof p;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
const s = document.createElement(
|
|
228
|
+
function Et(r, t, e) {
|
|
229
|
+
const s = document.createElement(r);
|
|
230
230
|
if (t)
|
|
231
231
|
for (const [o, i] of Object.entries(t))
|
|
232
232
|
s.setAttribute(o, i);
|
|
233
233
|
return e && (s.innerHTML = e), s;
|
|
234
234
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
235
|
+
const K = (r) => Array.isArray(r.values) && r.values.length > 0 ? r.values[0] : dt(r.type), dt = (r) => r === String ? "" : r === Number ? 0 : r === Boolean ? !1 : r === Array ? [] : r === Object ? {} : void 0;
|
|
236
|
+
function $(r) {
|
|
237
237
|
const t = [];
|
|
238
|
-
let e =
|
|
238
|
+
let e = r.firstElementChild;
|
|
239
239
|
for (; e; )
|
|
240
|
-
t.push(e), e.shadowRoot && t.push(
|
|
240
|
+
t.push(e), e.shadowRoot && t.push(...$(e.shadowRoot)), e.firstElementChild && t.push(...$(e)), e = e.nextElementSibling;
|
|
241
241
|
return t;
|
|
242
242
|
}
|
|
243
|
-
const M = (
|
|
244
|
-
function
|
|
245
|
-
let e =
|
|
243
|
+
const M = (r) => r.substring(ut).split(".")[0];
|
|
244
|
+
function tt(r, t) {
|
|
245
|
+
let e = r[0];
|
|
246
246
|
return t.forEach((s, o) => {
|
|
247
|
-
e += s +
|
|
247
|
+
e += s + r[o + 1];
|
|
248
248
|
}), e;
|
|
249
249
|
}
|
|
250
|
-
function I(
|
|
251
|
-
const t = typeof
|
|
250
|
+
function I(r) {
|
|
251
|
+
const t = typeof r;
|
|
252
252
|
return t === "string" || t === "number" || t === "boolean";
|
|
253
253
|
}
|
|
254
|
-
function A(
|
|
255
|
-
return
|
|
254
|
+
function A(r) {
|
|
255
|
+
return r.localName === "textarea";
|
|
256
256
|
}
|
|
257
|
-
function D(
|
|
258
|
-
const { localName: t } =
|
|
257
|
+
function D(r) {
|
|
258
|
+
const { localName: t } = r;
|
|
259
259
|
return t === "input" || t === "select";
|
|
260
260
|
}
|
|
261
|
-
const
|
|
262
|
-
function
|
|
263
|
-
return
|
|
261
|
+
const mt = (r) => r.replace(/<!--[\s\S]*?-->/g, "");
|
|
262
|
+
function et(r, t, e, s) {
|
|
263
|
+
return r.slice(0, t) + s + r.slice(t + e);
|
|
264
264
|
}
|
|
265
|
-
function H(
|
|
266
|
-
const t = Number(
|
|
267
|
-
if (isNaN(t)) throw new E(`can't convert "${
|
|
265
|
+
function H(r) {
|
|
266
|
+
const t = Number(r);
|
|
267
|
+
if (isNaN(t)) throw new E(`can't convert "${r}" to a number`);
|
|
268
268
|
return t;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function st(r, t, e) {
|
|
271
271
|
const [s, o] = t.split(":");
|
|
272
272
|
if (I(e))
|
|
273
273
|
if (typeof e == "boolean") {
|
|
274
|
-
e ?
|
|
275
|
-
const i =
|
|
276
|
-
|
|
274
|
+
e ? r.setAttribute(s, s) : r.removeAttribute(s);
|
|
275
|
+
const i = p.getPropName(s);
|
|
276
|
+
r[i] = e;
|
|
277
277
|
} else {
|
|
278
|
-
const i =
|
|
279
|
-
i !==
|
|
278
|
+
const i = r.getAttribute(t), n = String(e);
|
|
279
|
+
i !== n && (r.setAttribute(s, n), s === "value" && D(r) && (r.value = n));
|
|
280
280
|
}
|
|
281
281
|
else {
|
|
282
|
-
const i =
|
|
283
|
-
|
|
282
|
+
const i = p.getPropName(t);
|
|
283
|
+
r[i] = e;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
function k(
|
|
286
|
+
function k(r, t, e) {
|
|
287
287
|
const [s, o] = t.split(":");
|
|
288
|
-
|
|
288
|
+
r instanceof CSSStyleRule ? r.style.setProperty(s, e) : (st(r, s, e), s === "value" && D(r) && (r.value = e));
|
|
289
289
|
}
|
|
290
|
-
async function
|
|
290
|
+
async function bt(r) {
|
|
291
291
|
const t = /* @__PURE__ */ new Set();
|
|
292
|
-
for (const s of
|
|
292
|
+
for (const s of $(r.content)) {
|
|
293
293
|
const { localName: o } = s;
|
|
294
294
|
o.includes("-") && t.add(o);
|
|
295
295
|
}
|
|
296
296
|
function e(s) {
|
|
297
297
|
return new Promise((o, i) => {
|
|
298
298
|
setTimeout(() => {
|
|
299
|
-
const
|
|
300
|
-
i(new Error(
|
|
299
|
+
const n = `custom element <${s}> not defined`;
|
|
300
|
+
i(new Error(n));
|
|
301
301
|
}, 1e3);
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
304
|
return Promise.all(
|
|
305
305
|
[...t].map(
|
|
306
306
|
async (s) => Promise.race([
|
|
307
|
-
|
|
307
|
+
_.whenDefined(s),
|
|
308
308
|
e(s)
|
|
309
309
|
])
|
|
310
310
|
)
|
|
311
311
|
);
|
|
312
312
|
}
|
|
313
|
-
class
|
|
313
|
+
class p extends ct {
|
|
314
314
|
// There is one instance of `attrToPropMap`, `properties`, `propToAttrMap`,
|
|
315
315
|
// `propToComputedMap`, and `propToExprsMap` per Wrec subclass,
|
|
316
316
|
// not one for only the Wrec class.
|
|
@@ -366,7 +366,7 @@ class u extends rt {
|
|
|
366
366
|
// in the formAssociatedCallback method
|
|
367
367
|
// so they can be restored in the formResetCallback method.
|
|
368
368
|
#l = {};
|
|
369
|
-
#
|
|
369
|
+
#u = null;
|
|
370
370
|
// This is a map from properties in this web component
|
|
371
371
|
// to corresponding properties in a parent web component.
|
|
372
372
|
// This must be an instance property because
|
|
@@ -374,15 +374,15 @@ class u extends rt {
|
|
|
374
374
|
// to the properties of different parent components.
|
|
375
375
|
// This is used to update a parent property
|
|
376
376
|
// when the corresponding child property value changes.
|
|
377
|
-
#
|
|
377
|
+
#p = /* @__PURE__ */ new Map();
|
|
378
378
|
// This is a map from component properties to state bindings.
|
|
379
379
|
// It must be instance-specific because each component instance
|
|
380
380
|
// can bind the same property to a different WrecState/path.
|
|
381
381
|
#m = /* @__PURE__ */ new Map();
|
|
382
382
|
static define(t) {
|
|
383
|
-
if (this.elementName = t,
|
|
383
|
+
if (this.elementName = t, _.get(t))
|
|
384
384
|
throw new E(`custom element ${t} is already defined`);
|
|
385
|
-
|
|
385
|
+
_.define(t, this);
|
|
386
386
|
}
|
|
387
387
|
constructor() {
|
|
388
388
|
super(), this.attachShadow({ mode: "open" });
|
|
@@ -391,12 +391,12 @@ class u extends rt {
|
|
|
391
391
|
}
|
|
392
392
|
attributeChangedCallback(t, e, s) {
|
|
393
393
|
t === "disabled" && this.#g();
|
|
394
|
-
const o =
|
|
394
|
+
const o = p.getPropName(t);
|
|
395
395
|
if (this.#r(o)) {
|
|
396
|
-
const i = this.#S(o,
|
|
396
|
+
const i = this.#S(o, s);
|
|
397
397
|
this[o] = i;
|
|
398
|
-
const
|
|
399
|
-
|
|
398
|
+
const n = this.#h[o];
|
|
399
|
+
n && this.setFormValue(n, String(i)), this.propertyChangedCallback(o, e, s);
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
// This applies multiple property changes and only updates
|
|
@@ -410,14 +410,14 @@ class u extends rt {
|
|
|
410
410
|
for (const f of h)
|
|
411
411
|
s.add(f);
|
|
412
412
|
}
|
|
413
|
-
const o = this.#t.propToComputedMap, i = /* @__PURE__ */ new Set(),
|
|
413
|
+
const o = this.#t.propToComputedMap, i = /* @__PURE__ */ new Set(), n = {};
|
|
414
414
|
for (const c of Object.keys(t)) {
|
|
415
415
|
const a = o.get(c) || [];
|
|
416
416
|
for (const [h, f] of a)
|
|
417
|
-
i.add(h),
|
|
417
|
+
i.add(h), n[h] = f;
|
|
418
418
|
}
|
|
419
419
|
for (const c of i) {
|
|
420
|
-
const a =
|
|
420
|
+
const a = n[c];
|
|
421
421
|
this[c] = this.#s(a);
|
|
422
422
|
const h = e.get(c) ?? [];
|
|
423
423
|
for (const f of h)
|
|
@@ -426,7 +426,7 @@ class u extends rt {
|
|
|
426
426
|
for (; ; ) {
|
|
427
427
|
let c = !1;
|
|
428
428
|
for (const a of i) {
|
|
429
|
-
const h =
|
|
429
|
+
const h = n[a], f = this.#s(h), l = this[a];
|
|
430
430
|
JSON.stringify(f) !== JSON.stringify(l) && (this[a] = f, c = !0);
|
|
431
431
|
}
|
|
432
432
|
if (!c) break;
|
|
@@ -436,7 +436,7 @@ class u extends rt {
|
|
|
436
436
|
async #x() {
|
|
437
437
|
const t = this.#t;
|
|
438
438
|
let { template: e } = t;
|
|
439
|
-
e || (e = t.template = document.createElement("template"), e.innerHTML = t.buildHTML()), await
|
|
439
|
+
e || (e = t.template = document.createElement("template"), e.innerHTML = t.buildHTML()), await bt(e), this.shadowRoot.replaceChildren(e.content.cloneNode(!0));
|
|
440
440
|
}
|
|
441
441
|
static buildHTML() {
|
|
442
442
|
let t = `<style>
|
|
@@ -451,7 +451,7 @@ class u extends rt {
|
|
|
451
451
|
this[e] = s;
|
|
452
452
|
}
|
|
453
453
|
connectedCallback() {
|
|
454
|
-
this.#
|
|
454
|
+
this.#F(), this.#$(), this.#x().then(() => {
|
|
455
455
|
this.hasAttribute("disabled") && this.#g(), this.#C(this.shadowRoot), this.#w(this.shadowRoot), this.#P();
|
|
456
456
|
});
|
|
457
457
|
}
|
|
@@ -460,7 +460,7 @@ class u extends rt {
|
|
|
460
460
|
for (const [s, { computed: o }] of Object.entries(e))
|
|
461
461
|
o && (this[s] = this.#s(o));
|
|
462
462
|
}
|
|
463
|
-
|
|
463
|
+
#$() {
|
|
464
464
|
const t = this.#t, { observedAttributes: e, properties: s } = t;
|
|
465
465
|
for (const [o, i] of Object.entries(s))
|
|
466
466
|
i.computed || this.#b(o, i, e);
|
|
@@ -470,12 +470,12 @@ class u extends rt {
|
|
|
470
470
|
#b(t, e, s) {
|
|
471
471
|
if (t === "class" || t === "style")
|
|
472
472
|
throw new E(`"${t}" is a reserved property`);
|
|
473
|
-
const o =
|
|
473
|
+
const o = p.getAttrName(t), i = this.hasAttribute(o);
|
|
474
474
|
e.required && !i && this.#e(this, o, "is a required attribute");
|
|
475
|
-
let
|
|
476
|
-
this.hasOwnProperty(t) && (
|
|
477
|
-
const { type: c } = e, a = c === Boolean ?
|
|
478
|
-
this[h] = a, e.computed && this.#
|
|
475
|
+
let n = e.value;
|
|
476
|
+
this.hasOwnProperty(t) && (n = this[t], delete this[t]);
|
|
477
|
+
const { type: c } = e, a = c === Boolean ? n || i : s.includes(o) && i ? this.#A(t, o) : n ?? K(e), h = "#" + t;
|
|
478
|
+
this[h] = a, e.computed && this.#j(t, e), Object.defineProperty(this, t, {
|
|
479
479
|
enumerable: !0,
|
|
480
480
|
get() {
|
|
481
481
|
return this[h];
|
|
@@ -486,7 +486,7 @@ class u extends rt {
|
|
|
486
486
|
if (f === l) return;
|
|
487
487
|
this.#I(t, c, f), this[h] = f;
|
|
488
488
|
const m = this.#m.get(t);
|
|
489
|
-
m &&
|
|
489
|
+
m && ot(m.state, m.stateProp, f), this.#L(t, c, f, o), this.#f || (this.#H(t), this.#M(t)), this.#k(t, f);
|
|
490
490
|
const x = this.#h[t];
|
|
491
491
|
x && this.setFormValue(x, String(f)), this.propertyChangedCallback(t, l, f), e.dispatch && this.dispatch("change", {
|
|
492
492
|
tagName: this.localName,
|
|
@@ -498,12 +498,12 @@ class u extends rt {
|
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
500
|
#g() {
|
|
501
|
-
const t = this.hasAttribute("disabled"), e =
|
|
501
|
+
const t = this.hasAttribute("disabled"), e = $(this.shadowRoot);
|
|
502
502
|
for (const s of e)
|
|
503
503
|
pt(s) && (s.disabled = t);
|
|
504
504
|
}
|
|
505
505
|
disconnectedCallback() {
|
|
506
|
-
this.#o.clear(), this.#l.clear(), this.#
|
|
506
|
+
this.#o.clear(), this.#l.clear(), this.#p.clear();
|
|
507
507
|
}
|
|
508
508
|
dispatch(t, e) {
|
|
509
509
|
this.dispatchEvent(
|
|
@@ -519,17 +519,17 @@ class u extends rt {
|
|
|
519
519
|
displayIfSet(t, e = "block") {
|
|
520
520
|
return `display: ${t ? e : "none"}`;
|
|
521
521
|
}
|
|
522
|
-
#
|
|
523
|
-
const e = t instanceof
|
|
522
|
+
#R(t) {
|
|
523
|
+
const e = t instanceof p;
|
|
524
524
|
for (const s of t.getAttributeNames()) {
|
|
525
525
|
const o = t.getAttribute(s), i = this.#T(t, o);
|
|
526
526
|
if (i) {
|
|
527
|
-
const
|
|
528
|
-
|
|
527
|
+
const n = this[i];
|
|
528
|
+
n === void 0 && this.#a(t, s, i);
|
|
529
529
|
let [c, a] = s.split(":");
|
|
530
|
-
const h =
|
|
531
|
-
t[h] =
|
|
532
|
-
|
|
530
|
+
const h = p.getPropName(c);
|
|
531
|
+
t[h] = n, c === "value" && (a ? (t["on" + a] === void 0 && this.#e(t, s, "refers to an unsupported event name"), t.setAttribute(c, this[i])) : a = "change"), e && t.#p.set(
|
|
532
|
+
p.getPropName(c),
|
|
533
533
|
i
|
|
534
534
|
);
|
|
535
535
|
}
|
|
@@ -543,8 +543,8 @@ class u extends rt {
|
|
|
543
543
|
if (i instanceof HTMLElement)
|
|
544
544
|
this.#v(i, s);
|
|
545
545
|
else if (!(i instanceof CSSStyleRule)) {
|
|
546
|
-
const { element:
|
|
547
|
-
|
|
546
|
+
const { element: n, attrName: c } = i;
|
|
547
|
+
n instanceof CSSStyleRule ? n.style.setProperty(c, s) : k(n, c, s);
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
}
|
|
@@ -555,24 +555,24 @@ class u extends rt {
|
|
|
555
555
|
`const {${Object.keys(e).join(",")}} = context; return ${t};`
|
|
556
556
|
).call(this, e);
|
|
557
557
|
}
|
|
558
|
-
|
|
558
|
+
#N(t) {
|
|
559
559
|
const { localName: e } = t;
|
|
560
560
|
if (e === "style") {
|
|
561
561
|
const { sheet: s } = t, o = s?.cssRules ?? [], i = Array.from(o);
|
|
562
|
-
for (const
|
|
563
|
-
if (
|
|
564
|
-
const c = Array.from(
|
|
562
|
+
for (const n of i)
|
|
563
|
+
if (n.constructor === CSSStyleRule) {
|
|
564
|
+
const c = Array.from(n.style);
|
|
565
565
|
for (const a of c)
|
|
566
566
|
if (a.startsWith("--")) {
|
|
567
|
-
const h =
|
|
568
|
-
this.#c(h,
|
|
567
|
+
const h = n.style.getPropertyValue(a);
|
|
568
|
+
this.#c(h, n, a);
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
} else {
|
|
572
572
|
let s = "";
|
|
573
573
|
if (A(t)) {
|
|
574
574
|
this.#c(t.textContent, t);
|
|
575
|
-
const o = t.textContent?.match(
|
|
575
|
+
const o = t.textContent?.match(ht);
|
|
576
576
|
o && (s = o[1]);
|
|
577
577
|
} else {
|
|
578
578
|
const o = Array.from(t.childNodes).find(
|
|
@@ -593,30 +593,30 @@ class u extends rt {
|
|
|
593
593
|
formAssociatedCallback() {
|
|
594
594
|
let t = this.getAttribute("form-assoc");
|
|
595
595
|
if (!t) {
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
596
|
+
const n = this.getAttribute("name");
|
|
597
|
+
if (n)
|
|
598
598
|
if (this.#r("value"))
|
|
599
|
-
t = `value:${
|
|
599
|
+
t = `value:${n}`;
|
|
600
600
|
else
|
|
601
601
|
return;
|
|
602
602
|
else
|
|
603
603
|
return;
|
|
604
604
|
}
|
|
605
605
|
const e = {}, s = t.split(",");
|
|
606
|
-
for (const
|
|
607
|
-
const [c, a] =
|
|
606
|
+
for (const n of s) {
|
|
607
|
+
const [c, a] = n.split(":");
|
|
608
608
|
e[c.trim()] = a.trim();
|
|
609
609
|
}
|
|
610
|
-
this.#h = e, this.#i = new FormData(), this.#
|
|
610
|
+
this.#h = e, this.#i = new FormData(), this.#u = this.attachInternals(), this.#u.setFormValue(this.#i);
|
|
611
611
|
const o = Object.keys(this.#t.properties), i = this.#l;
|
|
612
|
-
for (const
|
|
613
|
-
i[
|
|
612
|
+
for (const n of o)
|
|
613
|
+
i[n] = this[n];
|
|
614
614
|
}
|
|
615
615
|
formResetCallback() {
|
|
616
616
|
const t = this.#l;
|
|
617
617
|
for (const e of Object.keys(t)) {
|
|
618
618
|
let s = t[e];
|
|
619
|
-
|
|
619
|
+
j.test(s) && (s = this.#s(s)), this[e] = s;
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
static getAttrName(t) {
|
|
@@ -630,10 +630,10 @@ class u extends rt {
|
|
|
630
630
|
#O(t, e, s) {
|
|
631
631
|
if (s.length !== 1) return;
|
|
632
632
|
const [o] = s;
|
|
633
|
-
if (!
|
|
633
|
+
if (!j.test(o)) return;
|
|
634
634
|
const i = D(t) || A(t);
|
|
635
|
-
let [
|
|
636
|
-
if (!(i &&
|
|
635
|
+
let [n, c] = (e ?? "").split(":");
|
|
636
|
+
if (!(i && n === "value" || A(t))) return;
|
|
637
637
|
c ? t["on" + c] === void 0 && this.#e(t, e, "refers to an unsupported event name") : c = "change";
|
|
638
638
|
const h = M(o);
|
|
639
639
|
t.addEventListener(c, (f) => {
|
|
@@ -652,7 +652,7 @@ class u extends rt {
|
|
|
652
652
|
#w(t) {
|
|
653
653
|
const e = Array.from(t.querySelectorAll("*"));
|
|
654
654
|
for (const s of e)
|
|
655
|
-
this.#
|
|
655
|
+
this.#R(s), s.firstElementChild || this.#N(s);
|
|
656
656
|
}
|
|
657
657
|
// formAssociated is only needed when the component is inside a form.
|
|
658
658
|
#E() {
|
|
@@ -666,7 +666,7 @@ class u extends rt {
|
|
|
666
666
|
}
|
|
667
667
|
static get observedAttributes() {
|
|
668
668
|
const t = Object.keys(this.properties || {}).map(
|
|
669
|
-
(e) =>
|
|
669
|
+
(e) => p.getAttrName(e)
|
|
670
670
|
);
|
|
671
671
|
return t.includes("disabled") || t.push("disabled"), t;
|
|
672
672
|
}
|
|
@@ -674,7 +674,7 @@ class u extends rt {
|
|
|
674
674
|
propertyChangedCallback(t, e, s) {
|
|
675
675
|
}
|
|
676
676
|
#T(t, e) {
|
|
677
|
-
if (!e || !
|
|
677
|
+
if (!e || !j.test(e)) return;
|
|
678
678
|
const s = M(e);
|
|
679
679
|
return this[s] === void 0 && this.#a(t, "", s), s;
|
|
680
680
|
}
|
|
@@ -682,20 +682,20 @@ class u extends rt {
|
|
|
682
682
|
const e = this.#t.propToExprsMap.get(t) || [];
|
|
683
683
|
this.#y(e);
|
|
684
684
|
}
|
|
685
|
-
#
|
|
685
|
+
#j(t, e) {
|
|
686
686
|
const { computed: s, uses: o } = e, i = this.#t.propToComputedMap;
|
|
687
|
-
function
|
|
687
|
+
function n(a, h) {
|
|
688
688
|
let f = i.get(a);
|
|
689
689
|
f || (f = [], i.set(a, f)), f.push([t, h]);
|
|
690
690
|
}
|
|
691
|
-
const c = s.match(
|
|
691
|
+
const c = s.match(L) || [];
|
|
692
692
|
for (const a of c) {
|
|
693
693
|
const h = M(a);
|
|
694
|
-
this[h] === void 0 && this.#a(null, t, h), typeof this[h] != "function" &&
|
|
694
|
+
this[h] === void 0 && this.#a(null, t, h), typeof this[h] != "function" && n(h, s);
|
|
695
695
|
}
|
|
696
696
|
if (o)
|
|
697
697
|
for (const a of o.split(","))
|
|
698
|
-
|
|
698
|
+
n(a.trim(), s);
|
|
699
699
|
}
|
|
700
700
|
// WARNING: Do not place untrusted JavaScript expressions
|
|
701
701
|
// in attribute values or the text content of elements!
|
|
@@ -723,8 +723,8 @@ class u extends rt {
|
|
|
723
723
|
h.filter((m) => m !== f)
|
|
724
724
|
);
|
|
725
725
|
}
|
|
726
|
-
let
|
|
727
|
-
|
|
726
|
+
let n = this.#o.get(t);
|
|
727
|
+
n || (n = [], this.#o.set(t, n)), n.push(s ? { element: e, attrName: s } : e), e instanceof HTMLElement && this.#O(e, s, o);
|
|
728
728
|
const c = this.#s(t);
|
|
729
729
|
s ? k(e, s, c) : this.#v(e, c);
|
|
730
730
|
}
|
|
@@ -734,7 +734,7 @@ class u extends rt {
|
|
|
734
734
|
this.hasAttribute(t) || this.setAttribute(t, e);
|
|
735
735
|
}
|
|
736
736
|
setFormValue(t, e) {
|
|
737
|
-
!this.#i || !I(e) || (this.#i.set(t, e), this.#
|
|
737
|
+
!this.#i || !I(e) || (this.#i.set(t, e), this.#u?.setFormValue(this.#i));
|
|
738
738
|
}
|
|
739
739
|
static ssr(t = {}) {
|
|
740
740
|
throw new E('Import Wrec from "wrec/ssr" to use the ssr method.');
|
|
@@ -752,27 +752,35 @@ class u extends rt {
|
|
|
752
752
|
return this.#S(t, this.getAttribute(e));
|
|
753
753
|
}
|
|
754
754
|
#S(t, e) {
|
|
755
|
-
if (e?.match(
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
|
|
759
|
-
if (
|
|
755
|
+
if (e?.match(L)) return e;
|
|
756
|
+
const o = this.#t.properties[t], { type: i, values: n } = o;
|
|
757
|
+
if (i || this.#e(null, t, "does not specify its type"), e === null)
|
|
758
|
+
return i === Boolean ? !1 : K(o);
|
|
759
|
+
if (i === String) {
|
|
760
|
+
if (n && !n.includes(e)) {
|
|
761
|
+
const c = n.map((a) => `"${a}"`).join(", ");
|
|
762
|
+
this.#e(null, t, `must be one of ${c}`);
|
|
763
|
+
}
|
|
764
|
+
return e;
|
|
765
|
+
}
|
|
766
|
+
if (i === Number) return H(e);
|
|
767
|
+
if (i === Boolean) {
|
|
760
768
|
if (e === "true") return !0;
|
|
761
769
|
if (e === "false" || e === "null") return !1;
|
|
762
|
-
const
|
|
763
|
-
return e && e !==
|
|
770
|
+
const c = p.getAttrName(t);
|
|
771
|
+
return e && e !== c && this.#e(
|
|
764
772
|
null,
|
|
765
773
|
t,
|
|
766
774
|
"is a Boolean attribute, so its value must match attribute name or be missing"
|
|
767
|
-
), e === "" || e ===
|
|
775
|
+
), e === "" || e === c;
|
|
768
776
|
}
|
|
769
777
|
}
|
|
770
778
|
// Updates the matching attribute for a property.
|
|
771
779
|
// VS Code thinks this is never called, but it is called by #defineProp.
|
|
772
|
-
#
|
|
780
|
+
#L(t, e, s, o) {
|
|
773
781
|
if (I(s)) {
|
|
774
782
|
const i = e === Boolean ? this.hasAttribute(o) : this.#A(t, o);
|
|
775
|
-
s !== i &&
|
|
783
|
+
s !== i && st(this, o || t, s);
|
|
776
784
|
}
|
|
777
785
|
}
|
|
778
786
|
// Updates all computed properties that reference this property.
|
|
@@ -796,21 +804,21 @@ class u extends rt {
|
|
|
796
804
|
if (t instanceof HTMLElement && A(t))
|
|
797
805
|
t.value = i;
|
|
798
806
|
else if (s && o === "string" && i.trim().startsWith("<")) {
|
|
799
|
-
const
|
|
800
|
-
t.innerHTML =
|
|
807
|
+
const n = nt(i);
|
|
808
|
+
t.innerHTML = n, this.#C(t), this.#w(t);
|
|
801
809
|
} else s && (t.textContent = i);
|
|
802
810
|
}
|
|
803
811
|
// Update corresponding parent web component property if bound to one.
|
|
804
812
|
// VS Code thinks this is never called, but it is called by #defineProp.
|
|
805
813
|
#k(t, e) {
|
|
806
|
-
const s = this.#
|
|
814
|
+
const s = this.#p.get(t);
|
|
807
815
|
if (!s) return;
|
|
808
816
|
const o = this.getRootNode();
|
|
809
817
|
if (!(o instanceof ShadowRoot)) return;
|
|
810
818
|
const { host: i } = o;
|
|
811
819
|
if (!i) return;
|
|
812
|
-
const
|
|
813
|
-
|
|
820
|
+
const n = i;
|
|
821
|
+
n[s] = e;
|
|
814
822
|
}
|
|
815
823
|
/**
|
|
816
824
|
* @param state - WrecState object
|
|
@@ -823,7 +831,7 @@ class u extends rt {
|
|
|
823
831
|
for (const s of Object.keys(t))
|
|
824
832
|
e[s] = s;
|
|
825
833
|
}
|
|
826
|
-
this.#
|
|
834
|
+
this.#_(t, e);
|
|
827
835
|
for (const [s, o] of Object.entries(e))
|
|
828
836
|
if (this.#r(o)) {
|
|
829
837
|
const i = q(t, s);
|
|
@@ -831,15 +839,15 @@ class u extends rt {
|
|
|
831
839
|
}
|
|
832
840
|
t.addListener(this, e);
|
|
833
841
|
}
|
|
834
|
-
#
|
|
842
|
+
#F() {
|
|
835
843
|
const t = new Set(Object.keys(this.#t.properties));
|
|
836
844
|
for (const e of this.getAttributeNames())
|
|
837
|
-
if (!
|
|
845
|
+
if (!rt.has(e) && !e.startsWith("on")) {
|
|
838
846
|
if (e === "form-assoc") {
|
|
839
847
|
this.#E();
|
|
840
848
|
continue;
|
|
841
849
|
}
|
|
842
|
-
if (!t.has(
|
|
850
|
+
if (!t.has(p.getPropName(e))) {
|
|
843
851
|
if (e === "name") {
|
|
844
852
|
this.#E();
|
|
845
853
|
continue;
|
|
@@ -849,14 +857,14 @@ class u extends rt {
|
|
|
849
857
|
}
|
|
850
858
|
}
|
|
851
859
|
#d(t, e, s) {
|
|
852
|
-
const o = s.match(
|
|
860
|
+
const o = s.match(L);
|
|
853
861
|
if (o)
|
|
854
862
|
return o.forEach((i) => {
|
|
855
|
-
const
|
|
856
|
-
this[
|
|
863
|
+
const n = M(i);
|
|
864
|
+
this[n] === void 0 && this.#a(t, e, n);
|
|
857
865
|
}), o;
|
|
858
866
|
}
|
|
859
|
-
#
|
|
867
|
+
#_(t, e) {
|
|
860
868
|
for (const [s, o] of Object.entries(e)) {
|
|
861
869
|
let i = q(t, s);
|
|
862
870
|
i === void 0 && this.#e(this, void 0, `invalid state path "${s}"`), i = this[o], this.#r(o) || this.#e(
|
|
@@ -869,20 +877,25 @@ class u extends rt {
|
|
|
869
877
|
// When type is an array, this can't validate the type of the array elements.
|
|
870
878
|
// This is called by #defineProp.
|
|
871
879
|
#I(t, e, s) {
|
|
880
|
+
const { values: o } = this.#t.properties[t];
|
|
881
|
+
if (o) {
|
|
882
|
+
let n;
|
|
883
|
+
e !== String ? n = "declares allowed values, but its type is not String" : typeof s != "string" ? n = `value is a ${typeof s}, but type is String` : o.includes(s) || (n = `must be one of ${o.map((a) => `"${a}"`).join(", ")}`), n && this.#e(null, t, n);
|
|
884
|
+
}
|
|
872
885
|
if (s instanceof e) return;
|
|
873
|
-
let
|
|
874
|
-
if (
|
|
875
|
-
const { constructor:
|
|
876
|
-
|
|
886
|
+
let i = typeof s;
|
|
887
|
+
if (i === "object") {
|
|
888
|
+
const { constructor: n } = s;
|
|
889
|
+
i = n.name, n !== e && this.#e(
|
|
877
890
|
null,
|
|
878
891
|
t,
|
|
879
|
-
`was set to a ${
|
|
892
|
+
`was set to a ${i}, but must be a ${e.name}`
|
|
880
893
|
);
|
|
881
894
|
}
|
|
882
|
-
|
|
895
|
+
i !== e.name.toLowerCase() && this.#e(
|
|
883
896
|
null,
|
|
884
897
|
t,
|
|
885
|
-
`was set to a ${
|
|
898
|
+
`was set to a ${i}, but must be a ${e.name}`
|
|
886
899
|
);
|
|
887
900
|
}
|
|
888
901
|
#C(t) {
|
|
@@ -890,14 +903,14 @@ class u extends rt {
|
|
|
890
903
|
for (const s of e) {
|
|
891
904
|
const o = [];
|
|
892
905
|
for (const i of Array.from(s.attributes)) {
|
|
893
|
-
const
|
|
894
|
-
if (
|
|
895
|
-
let c =
|
|
906
|
+
const n = i.name;
|
|
907
|
+
if (n.startsWith("on")) {
|
|
908
|
+
let c = n.slice(2);
|
|
896
909
|
c = c[0].toLowerCase() + c.slice(1).toLowerCase();
|
|
897
910
|
const a = i.value;
|
|
898
|
-
this.#d(s,
|
|
911
|
+
this.#d(s, n, a);
|
|
899
912
|
let h;
|
|
900
|
-
typeof this[a] == "function" ? h = (f) => this[a](f) : (this.#d(s,
|
|
913
|
+
typeof this[a] == "function" ? h = (f) => this[a](f) : (this.#d(s, n, a), h = () => this.#s(a)), s.addEventListener(c, h), o.push(n);
|
|
901
914
|
}
|
|
902
915
|
}
|
|
903
916
|
for (const i of o)
|
|
@@ -905,40 +918,40 @@ class u extends rt {
|
|
|
905
918
|
}
|
|
906
919
|
}
|
|
907
920
|
}
|
|
908
|
-
function
|
|
909
|
-
let e =
|
|
921
|
+
function Tt(r, ...t) {
|
|
922
|
+
let e = tt(r, t);
|
|
910
923
|
for (; ; ) {
|
|
911
|
-
const s =
|
|
924
|
+
const s = at.exec(e);
|
|
912
925
|
if (!s) break;
|
|
913
926
|
const o = s[2];
|
|
914
|
-
if (
|
|
927
|
+
if (Q.test(o)) {
|
|
915
928
|
const i = s[1];
|
|
916
929
|
if (!i.startsWith("--")) {
|
|
917
|
-
const
|
|
930
|
+
const n = `--${i}: ${o};
|
|
918
931
|
${i}: var(--${i})`;
|
|
919
|
-
e =
|
|
932
|
+
e = et(e, s.index, s[0].length, n);
|
|
920
933
|
}
|
|
921
934
|
}
|
|
922
935
|
}
|
|
923
936
|
return e;
|
|
924
937
|
}
|
|
925
|
-
function
|
|
926
|
-
let e =
|
|
938
|
+
function Mt(r, ...t) {
|
|
939
|
+
let e = tt(r, t);
|
|
927
940
|
for (; ; ) {
|
|
928
|
-
const s =
|
|
941
|
+
const s = lt.exec(e);
|
|
929
942
|
if (!s || s[1] === "style") break;
|
|
930
|
-
const o =
|
|
931
|
-
if (
|
|
932
|
-
const i = `<!-- ${o.trim()} -->`,
|
|
933
|
-
e =
|
|
943
|
+
const o = mt(s[2]);
|
|
944
|
+
if (Q.test(o)) {
|
|
945
|
+
const i = `<!-- ${o.trim()} -->`, n = s.index + s[0].indexOf(">") + 1;
|
|
946
|
+
e = et(e, n, o.length, i);
|
|
934
947
|
}
|
|
935
948
|
}
|
|
936
949
|
return e;
|
|
937
950
|
}
|
|
938
951
|
export {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
952
|
+
p as Wrec,
|
|
953
|
+
F as WrecState,
|
|
954
|
+
Et as createElement,
|
|
955
|
+
Tt as css,
|
|
956
|
+
Mt as html
|
|
944
957
|
};
|