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