ladrillosjs 2.0.0-beta.3.2 → 2.0.0-beta.3.3
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/{index-JWdjGiUA.mjs → index-5zcCcI-K.mjs} +3 -3
- package/dist/{index-JWdjGiUA.mjs.map → index-5zcCcI-K.mjs.map} +1 -1
- package/dist/{index-qEisp6n5.js → index-BKUM0X36.js} +2 -2
- package/dist/{index-qEisp6n5.js.map → index-BKUM0X36.js.map} +1 -1
- package/dist/ladrillosjs.cjs.js +1 -1
- package/dist/ladrillosjs.es.js +1 -1
- package/dist/ladrillosjs.umd.js +20 -20
- package/dist/ladrillosjs.umd.js.map +1 -1
- package/dist/webcomponent-D0F4yQdI.js +79 -0
- package/dist/webcomponent-D0F4yQdI.js.map +1 -0
- package/dist/webcomponent-SSpadLeF.mjs +1154 -0
- package/dist/webcomponent-SSpadLeF.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/webcomponent-B-2Pj2ku.js +0 -79
- package/dist/webcomponent-B-2Pj2ku.js.map +0 -1
- package/dist/webcomponent-DT_kduma.mjs +0 -1059
- package/dist/webcomponent-DT_kduma.mjs.map +0 -1
|
@@ -1,1059 +0,0 @@
|
|
|
1
|
-
var ft = Object.defineProperty, ht = Object.defineProperties;
|
|
2
|
-
var pt = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var K = Object.getOwnPropertySymbols;
|
|
4
|
-
var mt = Object.prototype.hasOwnProperty, bt = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var Y = (e) => {
|
|
6
|
-
throw TypeError(e);
|
|
7
|
-
};
|
|
8
|
-
var Q = (e, n, t) => n in e ? ft(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, O = (e, n) => {
|
|
9
|
-
for (var t in n || (n = {}))
|
|
10
|
-
mt.call(n, t) && Q(e, t, n[t]);
|
|
11
|
-
if (K)
|
|
12
|
-
for (var t of K(n))
|
|
13
|
-
bt.call(n, t) && Q(e, t, n[t]);
|
|
14
|
-
return e;
|
|
15
|
-
}, tt = (e, n) => ht(e, pt(n));
|
|
16
|
-
var U = (e, n, t) => n.has(e) || Y("Cannot " + t);
|
|
17
|
-
var A = (e, n, t) => (U(e, n, "read from private field"), t ? t.call(e) : n.get(e)), _ = (e, n, t) => n.has(e) ? Y("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), M = (e, n, t, s) => (U(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t), W = (e, n, t) => (U(e, n, "access private method"), t);
|
|
18
|
-
var j = (e, n, t) => new Promise((s, o) => {
|
|
19
|
-
var i = (d) => {
|
|
20
|
-
try {
|
|
21
|
-
c(t.next(d));
|
|
22
|
-
} catch (a) {
|
|
23
|
-
o(a);
|
|
24
|
-
}
|
|
25
|
-
}, r = (d) => {
|
|
26
|
-
try {
|
|
27
|
-
c(t.throw(d));
|
|
28
|
-
} catch (a) {
|
|
29
|
-
o(a);
|
|
30
|
-
}
|
|
31
|
-
}, c = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(i, r);
|
|
32
|
-
c((t = t.apply(e, n)).next());
|
|
33
|
-
});
|
|
34
|
-
import { R as et, l as gt, a as X, c as R, b as Et, d as wt, e as $t, f as yt, g as vt, h as D, i as At } from "./index-JWdjGiUA.mjs";
|
|
35
|
-
const xt = (e, n, t) => {
|
|
36
|
-
if (!n) return;
|
|
37
|
-
const s = document.createElement("style");
|
|
38
|
-
s.textContent = n, t ? e.appendChild(s) : document.head.appendChild(s);
|
|
39
|
-
}, St = (e, n) => {
|
|
40
|
-
e.innerHTML = n;
|
|
41
|
-
const t = _t(e), s = Ct(e), o = Tt(e), i = Lt(e);
|
|
42
|
-
return { bindings: t, twoWayBindings: s, conditionals: o, loops: i };
|
|
43
|
-
}, nt = (e) => {
|
|
44
|
-
const n = [], t = e.match(/\((.*)\)/);
|
|
45
|
-
if (!t) return n;
|
|
46
|
-
const s = t[1].trim();
|
|
47
|
-
return s && s.split(",").map((i) => i.trim()).forEach((i) => {
|
|
48
|
-
if (/^['"]/.test(i) || /^\d+/.test(i)) return;
|
|
49
|
-
const r = i.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
50
|
-
r && n.push(r[1]);
|
|
51
|
-
}), n;
|
|
52
|
-
}, _t = (e) => {
|
|
53
|
-
const n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null), t = [];
|
|
54
|
-
let s;
|
|
55
|
-
const o = (r) => {
|
|
56
|
-
let c = r.parentElement;
|
|
57
|
-
for (; c; ) {
|
|
58
|
-
if (c.hasAttribute && c.hasAttribute("$for"))
|
|
59
|
-
return !0;
|
|
60
|
-
c = c.parentElement;
|
|
61
|
-
}
|
|
62
|
-
return !1;
|
|
63
|
-
};
|
|
64
|
-
for (; s = n.nextNode(); ) {
|
|
65
|
-
if (o(s))
|
|
66
|
-
continue;
|
|
67
|
-
const r = [...s.textContent.matchAll(et.bindings)];
|
|
68
|
-
if (r.length > 0) {
|
|
69
|
-
const c = s.textContent, d = r.map((a) => {
|
|
70
|
-
const l = a[1].trim(), u = l.includes("(") && l.includes(")"), f = /[+*/%<>=!&|]/.test(l) || // Math or logical operators (excluding hyphen)
|
|
71
|
-
/\s-\s/.test(l), p = /^(!|typeof\s|void\s|delete\s)/.test(l), E = f || p || // Expressions starting with operators
|
|
72
|
-
/\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(l) || // Method calls like name.toLowerCase()
|
|
73
|
-
/\bnew\s+/.test(l) || // Object instantiation like new Date()
|
|
74
|
-
/\b(typeof|instanceof|void|delete)\b/.test(l), m = u ? [l.split("(")[0].trim()] : l.split(".").map((C) => C.trim()), b = u ? nt(l) : [];
|
|
75
|
-
return { raw: l, path: m, isFunction: u, isExpression: E, functionArgs: b };
|
|
76
|
-
});
|
|
77
|
-
t.push({ node: s, bindings: d, original: c });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return e.querySelectorAll("*").forEach((r) => {
|
|
81
|
-
if (!(r.hasAttribute("$for") || o(r)))
|
|
82
|
-
for (const c of r.attributes) {
|
|
83
|
-
if (c.name === "$if" || c.name === "$else-if" || c.name === "$else" || c.name === "$bind")
|
|
84
|
-
continue;
|
|
85
|
-
const d = [...c.value.matchAll(et.bindings)];
|
|
86
|
-
if (d.length > 0) {
|
|
87
|
-
const a = c.value, l = d.map((u) => {
|
|
88
|
-
const f = u[1].trim(), p = f.includes("(") && f.includes(")"), E = /[+*/%<>=!&|]/.test(f) || // Math or logical operators (excluding hyphen)
|
|
89
|
-
/\s-\s/.test(f), m = /^(!|typeof\s|void\s|delete\s)/.test(f), b = E || m || // Expressions starting with operators
|
|
90
|
-
/\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(f) || // Method calls like name.toLowerCase()
|
|
91
|
-
/\bnew\s+/.test(f) || // Object instantiation like new Date()
|
|
92
|
-
/\b(typeof|instanceof|void|delete)\b/.test(f), C = p ? [f.split("(")[0].trim()] : f.split(".").map((z) => z.trim()), N = p ? nt(f) : [];
|
|
93
|
-
return { raw: f, path: C, isFunction: p, isExpression: b, functionArgs: N };
|
|
94
|
-
});
|
|
95
|
-
t.push({
|
|
96
|
-
node: r,
|
|
97
|
-
bindings: l,
|
|
98
|
-
original: a,
|
|
99
|
-
isAttribute: !0,
|
|
100
|
-
attributeName: c.name
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}), t;
|
|
105
|
-
}, Ct = (e) => {
|
|
106
|
-
const n = [];
|
|
107
|
-
return e.querySelectorAll("[\\$bind]").forEach((s) => {
|
|
108
|
-
var c;
|
|
109
|
-
const o = s.getAttribute("$bind");
|
|
110
|
-
if (!o) return;
|
|
111
|
-
const i = o.trim(), r = i.split(".").map((d) => d.trim());
|
|
112
|
-
s instanceof HTMLInputElement || s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement ? (n.push({
|
|
113
|
-
element: s,
|
|
114
|
-
path: r,
|
|
115
|
-
raw: i,
|
|
116
|
-
isContentEditable: !1,
|
|
117
|
-
initialValue: s.value || ""
|
|
118
|
-
}), s.removeAttribute("$bind")) : s instanceof HTMLElement && s.hasAttribute("contenteditable") && (n.push({
|
|
119
|
-
element: s,
|
|
120
|
-
path: r,
|
|
121
|
-
raw: i,
|
|
122
|
-
isContentEditable: !0,
|
|
123
|
-
initialValue: ((c = s.textContent) == null ? void 0 : c.trim()) || ""
|
|
124
|
-
}), s.removeAttribute("$bind"));
|
|
125
|
-
}), n;
|
|
126
|
-
}, Tt = (e) => {
|
|
127
|
-
const n = [], t = /* @__PURE__ */ new Set();
|
|
128
|
-
return e.querySelectorAll("[\\$if]").forEach((o) => {
|
|
129
|
-
if (t.has(o)) return;
|
|
130
|
-
const i = [];
|
|
131
|
-
let r = o;
|
|
132
|
-
for (; r; ) {
|
|
133
|
-
const c = r.hasAttribute("$if"), d = r.hasAttribute("$else-if"), a = r.hasAttribute("$else");
|
|
134
|
-
if (!c && !d && !a) break;
|
|
135
|
-
t.add(r);
|
|
136
|
-
let l, u = "";
|
|
137
|
-
c ? (l = "if", u = r.getAttribute("$if") || "", r.removeAttribute("$if")) : d ? (l = "else-if", u = r.getAttribute("$else-if") || "", r.removeAttribute("$else-if")) : (l = "else", r.removeAttribute("$else"));
|
|
138
|
-
const f = document.createComment(
|
|
139
|
-
`conditional:${l}:${u}`
|
|
140
|
-
), p = r.parentElement || e, E = r.nextSibling;
|
|
141
|
-
p.insertBefore(f, r);
|
|
142
|
-
const m = {
|
|
143
|
-
element: r,
|
|
144
|
-
condition: u.trim(),
|
|
145
|
-
type: l,
|
|
146
|
-
placeholder: f,
|
|
147
|
-
group: [],
|
|
148
|
-
// Will be set after the group is complete
|
|
149
|
-
originalParent: p,
|
|
150
|
-
nextSibling: E
|
|
151
|
-
};
|
|
152
|
-
i.push(m);
|
|
153
|
-
const b = r.nextElementSibling;
|
|
154
|
-
if (r.remove(), r = b, b && !b.hasAttribute("$else-if") && !b.hasAttribute("$else"))
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
i.forEach((c) => {
|
|
158
|
-
c.group = i;
|
|
159
|
-
}), n.push(i);
|
|
160
|
-
}), n;
|
|
161
|
-
}, kt = (e) => {
|
|
162
|
-
const n = /* @__PURE__ */ new Set();
|
|
163
|
-
return e.forEach((t) => {
|
|
164
|
-
t.forEach((s) => {
|
|
165
|
-
let o = s.condition;
|
|
166
|
-
o = o.replace(/\{([^}]+)\}/g, "$1");
|
|
167
|
-
const i = /\b([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)\b/g, r = /* @__PURE__ */ new Set([
|
|
168
|
-
"true",
|
|
169
|
-
"false",
|
|
170
|
-
"null",
|
|
171
|
-
"undefined",
|
|
172
|
-
"typeof",
|
|
173
|
-
"instanceof",
|
|
174
|
-
"new",
|
|
175
|
-
"return",
|
|
176
|
-
"if",
|
|
177
|
-
"else",
|
|
178
|
-
"for",
|
|
179
|
-
"while",
|
|
180
|
-
"do",
|
|
181
|
-
"switch",
|
|
182
|
-
"case",
|
|
183
|
-
"break",
|
|
184
|
-
"continue"
|
|
185
|
-
]);
|
|
186
|
-
let c;
|
|
187
|
-
for (; (c = i.exec(o)) !== null; ) {
|
|
188
|
-
const a = c[1].split(".")[0];
|
|
189
|
-
r.has(a) || n.add(a);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}), n;
|
|
193
|
-
}, Lt = (e) => {
|
|
194
|
-
const n = [];
|
|
195
|
-
return e.querySelectorAll("[\\$for]").forEach((s) => {
|
|
196
|
-
var p;
|
|
197
|
-
const o = s.getAttribute("$for");
|
|
198
|
-
if (!o) return;
|
|
199
|
-
const i = s.getAttribute("$key") || void 0, r = o.match(
|
|
200
|
-
/^\s*(?:\(([^,]+),\s*([^)]+)\)|([^\s]+))\s+(?:in|of)\s+(.+)\s*$/
|
|
201
|
-
);
|
|
202
|
-
if (!r) {
|
|
203
|
-
gt(`Invalid $for expression: "${o}"`, {
|
|
204
|
-
expression: o,
|
|
205
|
-
lineHint: "$for attribute parsing"
|
|
206
|
-
});
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const c = (r[1] || r[3]).trim(), d = (p = r[2]) == null ? void 0 : p.trim(), a = r[4].trim(), l = document.createComment(`loop:${o}`), u = s.parentElement || e;
|
|
210
|
-
u.insertBefore(l, s), s.removeAttribute("$for"), i && s.removeAttribute("$key"), s.remove();
|
|
211
|
-
const f = {
|
|
212
|
-
template: s,
|
|
213
|
-
expression: o,
|
|
214
|
-
itemName: c,
|
|
215
|
-
indexName: d,
|
|
216
|
-
arrayName: a,
|
|
217
|
-
keyAttribute: i,
|
|
218
|
-
placeholder: l,
|
|
219
|
-
renderedElements: [],
|
|
220
|
-
originalParent: u
|
|
221
|
-
};
|
|
222
|
-
n.push(f);
|
|
223
|
-
}), n;
|
|
224
|
-
}, Rt = (e) => {
|
|
225
|
-
const n = /* @__PURE__ */ new Set();
|
|
226
|
-
return e.forEach((t) => {
|
|
227
|
-
const s = t.arrayName.split(".")[0];
|
|
228
|
-
n.add(s);
|
|
229
|
-
}), n;
|
|
230
|
-
}, F = /* @__PURE__ */ new Map(), Nt = 100, J = (e) => {
|
|
231
|
-
const n = F.get(e);
|
|
232
|
-
if (n)
|
|
233
|
-
return F.delete(e), F.set(e, n), n;
|
|
234
|
-
const t = new Function(
|
|
235
|
-
"component",
|
|
236
|
-
`
|
|
237
|
-
const { Date, Array, Math, String, Number, Boolean, Object, JSON, RegExp } = globalThis;
|
|
238
|
-
with(component) {
|
|
239
|
-
return ${e};
|
|
240
|
-
}
|
|
241
|
-
`
|
|
242
|
-
);
|
|
243
|
-
if (F.size >= Nt) {
|
|
244
|
-
const s = F.keys().next().value;
|
|
245
|
-
s && F.delete(s);
|
|
246
|
-
}
|
|
247
|
-
return F.set(e, t), t;
|
|
248
|
-
}, q = (e, n) => n.reduce((t, s) => {
|
|
249
|
-
if (!(t == null || typeof t != "object"))
|
|
250
|
-
return t[s];
|
|
251
|
-
}, e), Z = (e, n, t) => {
|
|
252
|
-
if (n.length === 0) return;
|
|
253
|
-
const s = n[n.length - 1], o = n.slice(0, -1);
|
|
254
|
-
let i = e;
|
|
255
|
-
for (const r of o)
|
|
256
|
-
(i[r] === void 0 || i[r] === null) && (i[r] = {}), i = i[r];
|
|
257
|
-
i[s] = t;
|
|
258
|
-
}, st = (e, n, t) => {
|
|
259
|
-
for (const s of e) {
|
|
260
|
-
let o = s.original, i, r = !1;
|
|
261
|
-
for (const { raw: c, path: d, isFunction: a, isExpression: l } of s.bindings) {
|
|
262
|
-
let u, f = !1;
|
|
263
|
-
if (l || a)
|
|
264
|
-
try {
|
|
265
|
-
u = J(c)(t || n);
|
|
266
|
-
} catch (E) {
|
|
267
|
-
X(c, E, R(t)), u = void 0, f = !0;
|
|
268
|
-
}
|
|
269
|
-
else
|
|
270
|
-
u = q(n, d), u === void 0 && (f = !0);
|
|
271
|
-
if (f) {
|
|
272
|
-
r = !0;
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
const p = String(u != null ? u : "");
|
|
276
|
-
i = u, o = o.replace(`{${c}}`, p);
|
|
277
|
-
}
|
|
278
|
-
if (r && s.original, s.node.nodeType === Node.TEXT_NODE) {
|
|
279
|
-
const c = s.node, d = c.parentElement, a = o.trim().startsWith("<") && o.includes(">");
|
|
280
|
-
d && a ? d.innerHTML = o : c.textContent = o;
|
|
281
|
-
} else {
|
|
282
|
-
const c = s.node;
|
|
283
|
-
s.isAttribute && s.attributeName && ([
|
|
284
|
-
"disabled",
|
|
285
|
-
"checked",
|
|
286
|
-
"readonly",
|
|
287
|
-
"required",
|
|
288
|
-
"selected",
|
|
289
|
-
"hidden",
|
|
290
|
-
"open",
|
|
291
|
-
"autofocus",
|
|
292
|
-
"autoplay",
|
|
293
|
-
"controls",
|
|
294
|
-
"loop",
|
|
295
|
-
"muted"
|
|
296
|
-
].includes(s.attributeName.toLowerCase()) ? (typeof i == "boolean" ? i : i === "true" || i === "True") ? c.setAttribute(s.attributeName, "") : c.removeAttribute(s.attributeName) : c.setAttribute(s.attributeName, o));
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}, Vt = (e, n, t) => {
|
|
300
|
-
if (!e) return !0;
|
|
301
|
-
let s = e.trim();
|
|
302
|
-
s = s.replace(/\{([^}]+)\}/g, "$1");
|
|
303
|
-
try {
|
|
304
|
-
return new Function(
|
|
305
|
-
"context",
|
|
306
|
-
"component",
|
|
307
|
-
`
|
|
308
|
-
with (context) {
|
|
309
|
-
try {
|
|
310
|
-
return Boolean(${s});
|
|
311
|
-
} catch (e) {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
`
|
|
316
|
-
)(n, t);
|
|
317
|
-
} catch (o) {
|
|
318
|
-
return wt(
|
|
319
|
-
e,
|
|
320
|
-
o,
|
|
321
|
-
R(t)
|
|
322
|
-
), !1;
|
|
323
|
-
}
|
|
324
|
-
}, it = (e, n) => {
|
|
325
|
-
const t = [
|
|
326
|
-
"click",
|
|
327
|
-
"dblclick",
|
|
328
|
-
"mousedown",
|
|
329
|
-
"mouseup",
|
|
330
|
-
"mouseover",
|
|
331
|
-
"mouseout",
|
|
332
|
-
"mousemove",
|
|
333
|
-
"mouseenter",
|
|
334
|
-
"mouseleave",
|
|
335
|
-
"keydown",
|
|
336
|
-
"keyup",
|
|
337
|
-
"keypress",
|
|
338
|
-
"focus",
|
|
339
|
-
"blur",
|
|
340
|
-
"change",
|
|
341
|
-
"input",
|
|
342
|
-
"submit",
|
|
343
|
-
"reset",
|
|
344
|
-
"scroll",
|
|
345
|
-
"resize",
|
|
346
|
-
"load",
|
|
347
|
-
"unload",
|
|
348
|
-
"touchstart",
|
|
349
|
-
"touchend",
|
|
350
|
-
"touchmove",
|
|
351
|
-
"touchcancel",
|
|
352
|
-
"dragstart",
|
|
353
|
-
"drag",
|
|
354
|
-
"dragend",
|
|
355
|
-
"dragenter",
|
|
356
|
-
"dragover",
|
|
357
|
-
"dragleave",
|
|
358
|
-
"drop"
|
|
359
|
-
];
|
|
360
|
-
[e, ...e.querySelectorAll("*")].forEach((o) => {
|
|
361
|
-
t.forEach((i) => {
|
|
362
|
-
const r = `on${i}`, c = o.getAttribute(r);
|
|
363
|
-
if (c) {
|
|
364
|
-
const d = `__processed_${r}`;
|
|
365
|
-
if (o[d]) return;
|
|
366
|
-
o.removeAttribute(r), o.addEventListener(
|
|
367
|
-
i,
|
|
368
|
-
function(a) {
|
|
369
|
-
try {
|
|
370
|
-
new Function(
|
|
371
|
-
"event",
|
|
372
|
-
"component",
|
|
373
|
-
`
|
|
374
|
-
with(component) {
|
|
375
|
-
${c}
|
|
376
|
-
}
|
|
377
|
-
`
|
|
378
|
-
).call(this, a, n);
|
|
379
|
-
} catch (l) {
|
|
380
|
-
$t(
|
|
381
|
-
i,
|
|
382
|
-
c,
|
|
383
|
-
l,
|
|
384
|
-
R(n, {
|
|
385
|
-
elementTag: o.tagName.toLowerCase()
|
|
386
|
-
})
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
), o[d] = !0;
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
}, ot = (e, n, t) => {
|
|
395
|
-
var s;
|
|
396
|
-
for (const o of e) {
|
|
397
|
-
let i = !1;
|
|
398
|
-
for (const r of o) {
|
|
399
|
-
const { element: c, condition: d, type: a, placeholder: l, originalParent: u } = r;
|
|
400
|
-
let f = !1;
|
|
401
|
-
a === "else" ? f = !i : i || (f = Vt(d, n, t), f && (i = !0));
|
|
402
|
-
const p = c.parentNode !== null;
|
|
403
|
-
f && !p ? ((s = l.parentNode) == null || s.insertBefore(c, l.nextSibling), t && it(c, t)) : !f && p && c.remove();
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}, rt = (e, n, t) => {
|
|
407
|
-
for (const s of e) {
|
|
408
|
-
const {
|
|
409
|
-
template: o,
|
|
410
|
-
itemName: i,
|
|
411
|
-
indexName: r,
|
|
412
|
-
arrayName: c,
|
|
413
|
-
placeholder: d,
|
|
414
|
-
renderedElements: a
|
|
415
|
-
} = s, l = q(n, c.split("."));
|
|
416
|
-
if (l !== void 0 && !Array.isArray(l)) {
|
|
417
|
-
Et(
|
|
418
|
-
`${i} in ${c}`,
|
|
419
|
-
new Error(`"${c}" is not an array, got: ${typeof l}`),
|
|
420
|
-
R(t, {
|
|
421
|
-
lineHint: "$for loop in template"
|
|
422
|
-
})
|
|
423
|
-
), a.forEach((u) => u.remove()), a.length = 0;
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
if (!l)
|
|
427
|
-
return;
|
|
428
|
-
a.forEach((u) => u.remove()), a.length = 0, l.forEach((u, f) => {
|
|
429
|
-
var b;
|
|
430
|
-
const p = o.cloneNode(!0), E = tt(O({}, n), {
|
|
431
|
-
[i]: u
|
|
432
|
-
});
|
|
433
|
-
r && (E[r] = f), Bt(p, E, t);
|
|
434
|
-
const m = a.length > 0 ? a[a.length - 1] : d;
|
|
435
|
-
(b = m.parentNode) == null || b.insertBefore(p, m.nextSibling), a.push(p), t && it(p, t);
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
}, Bt = (e, n, t) => {
|
|
439
|
-
const s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null);
|
|
440
|
-
let o;
|
|
441
|
-
for (; o = s.nextNode(); )
|
|
442
|
-
if (o.textContent && o.textContent.includes("{")) {
|
|
443
|
-
let r = o.textContent;
|
|
444
|
-
[...o.textContent.matchAll(/\{([^}]+)\}/g)].forEach((d) => {
|
|
445
|
-
const a = d[1].trim(), l = a.includes("(") && a.includes(")"), f = /[+*/%<>=!&|]/.test(a) || /\s-\s/.test(a) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(a) || // Method calls
|
|
446
|
-
/\bnew\s+/.test(a) || // Object instantiation like new Date()
|
|
447
|
-
/\b(typeof|instanceof|void|delete)\b/.test(a);
|
|
448
|
-
let p;
|
|
449
|
-
if (f || l)
|
|
450
|
-
try {
|
|
451
|
-
const E = J(a), m = typeof n == "object" && n !== null ? O(O({}, n), t || {}) : t || {};
|
|
452
|
-
p = E(m);
|
|
453
|
-
} catch (E) {
|
|
454
|
-
X(
|
|
455
|
-
a,
|
|
456
|
-
E,
|
|
457
|
-
R(t, {
|
|
458
|
-
lineHint: "$for loop template binding"
|
|
459
|
-
})
|
|
460
|
-
), p = void 0;
|
|
461
|
-
}
|
|
462
|
-
else {
|
|
463
|
-
const E = a.split(".").map((m) => m.trim());
|
|
464
|
-
p = q(n, E);
|
|
465
|
-
}
|
|
466
|
-
p !== void 0 && (r = r.replace(`{${a}}`, String(p != null ? p : "")));
|
|
467
|
-
}), o.textContent = r;
|
|
468
|
-
}
|
|
469
|
-
[e, ...e.querySelectorAll("*")].forEach((r) => {
|
|
470
|
-
Array.from(r.attributes).forEach((c) => {
|
|
471
|
-
if (c.value.includes("{")) {
|
|
472
|
-
let d = c.value;
|
|
473
|
-
[...c.value.matchAll(/\{([^}]+)\}/g)].forEach((l) => {
|
|
474
|
-
const u = l[1].trim(), f = u.includes("(") && u.includes(")"), E = /[+*/%<>=!&|]/.test(u) || /\s-\s/.test(u) || /\.(?![\s}])[a-zA-Z_$][\w]*\(/.test(u) || // Method calls
|
|
475
|
-
/\bnew\s+/.test(u) || // Object instantiation like new Date()
|
|
476
|
-
/\b(typeof|instanceof|void|delete)\b/.test(u);
|
|
477
|
-
let m;
|
|
478
|
-
if (E || f)
|
|
479
|
-
try {
|
|
480
|
-
const b = J(u), C = typeof n == "object" && n !== null ? O(O({}, n), t || {}) : t || {};
|
|
481
|
-
m = b(C);
|
|
482
|
-
} catch (b) {
|
|
483
|
-
X(
|
|
484
|
-
u,
|
|
485
|
-
b,
|
|
486
|
-
R(t, {
|
|
487
|
-
attributeName: c.name,
|
|
488
|
-
lineHint: "$for loop attribute binding"
|
|
489
|
-
})
|
|
490
|
-
), m = void 0;
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
const b = u.split(".").map((C) => C.trim());
|
|
494
|
-
m = q(n, b);
|
|
495
|
-
}
|
|
496
|
-
m !== void 0 && (d = d.replace(`{${u}}`, String(m != null ? m : "")));
|
|
497
|
-
}), r.setAttribute(c.name, d);
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
});
|
|
501
|
-
}, ct = (e) => e instanceof ShadowRoot ? e.host : e, Ft = (e, n) => {
|
|
502
|
-
const t = /* @__PURE__ */ new Set();
|
|
503
|
-
n.forEach(({ path: o }) => {
|
|
504
|
-
const i = o[0];
|
|
505
|
-
t.add(i);
|
|
506
|
-
});
|
|
507
|
-
const s = [];
|
|
508
|
-
return t.forEach((o) => {
|
|
509
|
-
s.push(`
|
|
510
|
-
if (!Object.getOwnPropertyDescriptor(component, '${o}')) {
|
|
511
|
-
Object.defineProperty(component, '${o}', {
|
|
512
|
-
get() { return this.state.${o}; },
|
|
513
|
-
set(val) { this.state.${o} = val; },
|
|
514
|
-
enumerable: true,
|
|
515
|
-
configurable: true
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
`);
|
|
519
|
-
}), {
|
|
520
|
-
injectedCode: "",
|
|
521
|
-
// No longer needed in script scope
|
|
522
|
-
componentInjections: s.join(`
|
|
523
|
-
`),
|
|
524
|
-
bindVarNames: t
|
|
525
|
-
};
|
|
526
|
-
}, Ot = (e, n, t = /* @__PURE__ */ new Set()) => {
|
|
527
|
-
const s = [], o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
528
|
-
n.forEach((d) => {
|
|
529
|
-
d.bindings.forEach((a) => {
|
|
530
|
-
const l = a.path[0];
|
|
531
|
-
i.add(l), a.isFunction && a.functionArgs && a.functionArgs.forEach((u) => {
|
|
532
|
-
i.add(u);
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
}), t.forEach((d) => {
|
|
536
|
-
i.add(d);
|
|
537
|
-
});
|
|
538
|
-
const r = /(?:const|let|var)\s+(\w+)\s*=\s*([^;]+);?/g;
|
|
539
|
-
let c;
|
|
540
|
-
for (; (c = r.exec(e)) !== null; ) {
|
|
541
|
-
const d = c[1], a = c[2].trim();
|
|
542
|
-
i.has(d) && (s.push(`component.state.${d} = ${d};`), o.set(d, a));
|
|
543
|
-
}
|
|
544
|
-
return { stateBindings: s, boundVarNames: i, defaultValues: o };
|
|
545
|
-
}, Mt = (e, n) => {
|
|
546
|
-
if (n.size === 0) return e;
|
|
547
|
-
let t = e;
|
|
548
|
-
return n.forEach((s) => {
|
|
549
|
-
const o = new RegExp(
|
|
550
|
-
`\\b${s}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
|
|
551
|
-
"g"
|
|
552
|
-
);
|
|
553
|
-
t = t.replace(
|
|
554
|
-
o,
|
|
555
|
-
`component.state.${s}$1 $2`
|
|
556
|
-
);
|
|
557
|
-
const i = new RegExp(
|
|
558
|
-
`(?<!component\\.state\\.)\\b${s}((?:\\[[^\\]]+\\])(?:\\.[\\w]+|\\[[^\\]]+\\])*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
|
|
559
|
-
"g"
|
|
560
|
-
);
|
|
561
|
-
t = t.replace(
|
|
562
|
-
i,
|
|
563
|
-
`component.state.${s}$1`
|
|
564
|
-
);
|
|
565
|
-
const r = new RegExp(
|
|
566
|
-
`\\b${s}\\.(\\w+(?:\\.\\w+)*)\\s*([=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
|
|
567
|
-
"g"
|
|
568
|
-
);
|
|
569
|
-
t = t.replace(
|
|
570
|
-
r,
|
|
571
|
-
`component.state.${s}.$1 $2`
|
|
572
|
-
);
|
|
573
|
-
const c = new RegExp(
|
|
574
|
-
`(?<!component\\.state\\.)(?<!const\\s${s}\\s*=\\s*{[^}]*)\\b${s}\\.(\\w+(?:\\.\\w+)*)(?![=+\\-*/%&|^]|\\+\\+|\\-\\-)`,
|
|
575
|
-
"g"
|
|
576
|
-
);
|
|
577
|
-
t = t.replace(
|
|
578
|
-
c,
|
|
579
|
-
`component.state.${s}.$1`
|
|
580
|
-
);
|
|
581
|
-
const d = new RegExp(
|
|
582
|
-
`(?<!\\.)\\b(\\+\\+|\\-\\-)${s}\\b|\\b${s}(\\+\\+|\\-\\-)`,
|
|
583
|
-
"g"
|
|
584
|
-
);
|
|
585
|
-
t = t.replace(d, (u) => {
|
|
586
|
-
if (u.startsWith("++") || u.startsWith("--"))
|
|
587
|
-
return `${u.substring(0, 2)}component.state.${s}`;
|
|
588
|
-
{
|
|
589
|
-
const f = u.substring(u.length - 2);
|
|
590
|
-
return `component.state.${s}${f}`;
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
const a = new RegExp(
|
|
594
|
-
`(?<!\\.)\\b${s}\\s*(\\+=|\\-=|\\*=|\\/=|%=|\\*\\*=|<<=|>>=|>>>=|&=|\\|=|\\^=)`,
|
|
595
|
-
"g"
|
|
596
|
-
);
|
|
597
|
-
t = t.replace(
|
|
598
|
-
a,
|
|
599
|
-
`component.state.${s}$1`
|
|
600
|
-
);
|
|
601
|
-
const l = new RegExp(
|
|
602
|
-
`(?<!const\\s)(?<!let\\s)(?<!var\\s)(?<!\\.)\\b${s}\\s*=\\s*([^=])`,
|
|
603
|
-
"g"
|
|
604
|
-
);
|
|
605
|
-
t = t.replace(
|
|
606
|
-
l,
|
|
607
|
-
`component.state.${s} = $1`
|
|
608
|
-
);
|
|
609
|
-
}), t;
|
|
610
|
-
}, at = (e, n, t, s, o, i = /* @__PURE__ */ new Set()) => {
|
|
611
|
-
try {
|
|
612
|
-
const { injectedCode: r, componentInjections: c, bindVarNames: d } = Ft(e, t), a = /function\s+(\w+)|const\s+(\w+)\s*=\s*(?:\([^)]*\)|[\w\s]*)\s*=>/g, l = [];
|
|
613
|
-
let u;
|
|
614
|
-
for (; (u = a.exec(e)) !== null; ) {
|
|
615
|
-
const S = u[1] || u[2];
|
|
616
|
-
S && l.push(S);
|
|
617
|
-
}
|
|
618
|
-
const f = l.map(
|
|
619
|
-
(S) => `component.${S} = typeof ${S} !== 'undefined' ? ${S}.bind(component) : undefined;`
|
|
620
|
-
).join(`
|
|
621
|
-
`), { stateBindings: p, boundVarNames: E, defaultValues: m } = Ot(e, n, i), b = /* @__PURE__ */ new Set([...E, ...d]), C = p.join(`
|
|
622
|
-
`), N = Mt(
|
|
623
|
-
e,
|
|
624
|
-
b
|
|
625
|
-
), z = `
|
|
626
|
-
(function() {
|
|
627
|
-
// Create component scope with direct access to state
|
|
628
|
-
const component = this;
|
|
629
|
-
const $state = component.state;
|
|
630
|
-
|
|
631
|
-
// Define $bind variables on component object for event handler access
|
|
632
|
-
${c}
|
|
633
|
-
|
|
634
|
-
// Provide framework utilities with $ prefix to avoid naming conflicts
|
|
635
|
-
const $setState = (updates) => component.setState(updates);
|
|
636
|
-
|
|
637
|
-
// Event bus methods for component communication
|
|
638
|
-
const $emit = (eventName, data) => arguments[2].emit(eventName, data);
|
|
639
|
-
const $listen = (eventName, callback) => {
|
|
640
|
-
const unsubscribe = arguments[2].listen(eventName, callback);
|
|
641
|
-
// Store unsubscribe function for cleanup on disconnect
|
|
642
|
-
if (!component.__eventUnsubscribers) {
|
|
643
|
-
component.__eventUnsubscribers = [];
|
|
644
|
-
}
|
|
645
|
-
component.__eventUnsubscribers.push(unsubscribe);
|
|
646
|
-
return unsubscribe;
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
// Also attach to component for event handler access
|
|
650
|
-
component.$emit = $emit;
|
|
651
|
-
component.$listen = $listen;
|
|
652
|
-
|
|
653
|
-
// Override querySelector/querySelectorAll to query within the component's host
|
|
654
|
-
const host = arguments[1];
|
|
655
|
-
const $querySelector = (selector) => host.querySelector(selector);
|
|
656
|
-
const $querySelectorAll = (selector) => host.querySelectorAll(selector);
|
|
657
|
-
|
|
658
|
-
// Execute script content within component scope so $bind variables are accessible
|
|
659
|
-
with(component) {
|
|
660
|
-
${N}
|
|
661
|
-
|
|
662
|
-
// Auto-bind variables to component state (e.g., const name = "value" → this.state.name = "value")
|
|
663
|
-
${C}
|
|
664
|
-
|
|
665
|
-
// Auto-attach all detected functions to component for onclick access
|
|
666
|
-
${f}
|
|
667
|
-
}
|
|
668
|
-
}).call(arguments[0], arguments[0], arguments[1], arguments[2])
|
|
669
|
-
`;
|
|
670
|
-
return new Function(z)(o, s, yt), m;
|
|
671
|
-
} catch (r) {
|
|
672
|
-
return vt(r, R(o)), /* @__PURE__ */ new Map();
|
|
673
|
-
}
|
|
674
|
-
}, lt = (e, n) => {
|
|
675
|
-
[
|
|
676
|
-
"click",
|
|
677
|
-
"dblclick",
|
|
678
|
-
"mousedown",
|
|
679
|
-
"mouseup",
|
|
680
|
-
"mouseover",
|
|
681
|
-
"mouseout",
|
|
682
|
-
"mousemove",
|
|
683
|
-
"mouseenter",
|
|
684
|
-
"mouseleave",
|
|
685
|
-
"keydown",
|
|
686
|
-
"keyup",
|
|
687
|
-
"keypress",
|
|
688
|
-
"focus",
|
|
689
|
-
"blur",
|
|
690
|
-
"change",
|
|
691
|
-
"input",
|
|
692
|
-
"submit",
|
|
693
|
-
"reset",
|
|
694
|
-
"scroll",
|
|
695
|
-
"resize",
|
|
696
|
-
"load",
|
|
697
|
-
"unload",
|
|
698
|
-
"touchstart",
|
|
699
|
-
"touchend",
|
|
700
|
-
"touchmove",
|
|
701
|
-
"touchcancel",
|
|
702
|
-
"dragstart",
|
|
703
|
-
"drag",
|
|
704
|
-
"dragend",
|
|
705
|
-
"dragenter",
|
|
706
|
-
"dragover",
|
|
707
|
-
"dragleave",
|
|
708
|
-
"drop"
|
|
709
|
-
].forEach((s) => {
|
|
710
|
-
const o = `on${s}`;
|
|
711
|
-
(e instanceof ShadowRoot ? e.querySelectorAll(`[${o}]`) : n.querySelectorAll(`[${o}]`)).forEach((r) => {
|
|
712
|
-
const c = `${o}`;
|
|
713
|
-
if (r[`__processed_${c}`]) return;
|
|
714
|
-
const d = r.getAttribute(o);
|
|
715
|
-
d && (r.removeAttribute(o), r.addEventListener(
|
|
716
|
-
s,
|
|
717
|
-
function(a) {
|
|
718
|
-
new Function(
|
|
719
|
-
"event",
|
|
720
|
-
"component",
|
|
721
|
-
`
|
|
722
|
-
with(component) {
|
|
723
|
-
${d}
|
|
724
|
-
}
|
|
725
|
-
`
|
|
726
|
-
).call(this, a, n);
|
|
727
|
-
}
|
|
728
|
-
), r[`__processed_${c}`] = !0);
|
|
729
|
-
});
|
|
730
|
-
});
|
|
731
|
-
}, Wt = (i, r, c, ...d) => j(null, [i, r, c, ...d], function* (e, n, t, s = [], o = /* @__PURE__ */ new Set()) {
|
|
732
|
-
const a = /* @__PURE__ */ new Map();
|
|
733
|
-
if (!(n != null && n.length)) return a;
|
|
734
|
-
const l = ct(e);
|
|
735
|
-
for (const u of n)
|
|
736
|
-
u.content && at(
|
|
737
|
-
u.content,
|
|
738
|
-
t,
|
|
739
|
-
s,
|
|
740
|
-
e,
|
|
741
|
-
l,
|
|
742
|
-
o
|
|
743
|
-
).forEach((p, E) => {
|
|
744
|
-
a.has(E) || a.set(E, p);
|
|
745
|
-
});
|
|
746
|
-
return lt(e, l), a;
|
|
747
|
-
}), Ht = (e, n) => new Promise((t, s) => {
|
|
748
|
-
const o = document.querySelector(
|
|
749
|
-
`script[src="${e}"]`
|
|
750
|
-
);
|
|
751
|
-
if (o) {
|
|
752
|
-
if (o.dataset.loaded === "true") {
|
|
753
|
-
t();
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
o.addEventListener("load", () => t(), { once: !0 }), o.addEventListener(
|
|
757
|
-
"error",
|
|
758
|
-
() => s(new Error(`Failed to load external script: ${e}`)),
|
|
759
|
-
{ once: !0 }
|
|
760
|
-
);
|
|
761
|
-
return;
|
|
762
|
-
}
|
|
763
|
-
const i = document.createElement("script");
|
|
764
|
-
i.src = e, n && (i.type = n), i.onload = () => {
|
|
765
|
-
i.dataset.loaded = "true", t();
|
|
766
|
-
}, i.onerror = () => s(new Error(`Failed to load external script: ${e}`)), document.head.appendChild(i);
|
|
767
|
-
}), It = (r, c, d, ...a) => j(null, [r, c, d, ...a], function* (e, n, t, s = [], o = /* @__PURE__ */ new Set(), i) {
|
|
768
|
-
var u;
|
|
769
|
-
const l = ct(e);
|
|
770
|
-
for (const f of n) {
|
|
771
|
-
let p;
|
|
772
|
-
i ? i.startsWith("http://") || i.startsWith("https://") ? p = i : p = new URL(
|
|
773
|
-
i,
|
|
774
|
-
window.location.href
|
|
775
|
-
).href : p = window.location.href;
|
|
776
|
-
const E = new URL(f.src, p).href;
|
|
777
|
-
if (f.external)
|
|
778
|
-
yield Ht(E, f.type);
|
|
779
|
-
else if (f.type === "module") {
|
|
780
|
-
const m = l.tagName.toLowerCase();
|
|
781
|
-
window.__ladrilloContexts || (window.__ladrilloContexts = /* @__PURE__ */ new Map()), window.__ladrilloContexts.set(m, {
|
|
782
|
-
host: e,
|
|
783
|
-
shadowRoot: e instanceof ShadowRoot ? e : null,
|
|
784
|
-
element: l,
|
|
785
|
-
state: l.state,
|
|
786
|
-
setState: (u = l.setState) == null ? void 0 : u.bind(l)
|
|
787
|
-
});
|
|
788
|
-
const b = document.createElement("script");
|
|
789
|
-
b.type = "module", b.src = E, b.setAttribute("data-component", m), document.head.appendChild(b);
|
|
790
|
-
} else
|
|
791
|
-
yield fetch(E).then((m) => {
|
|
792
|
-
if (!m.ok)
|
|
793
|
-
throw new Error(`HTTP ${m.status}: ${m.statusText}`);
|
|
794
|
-
const b = m.headers.get("content-type");
|
|
795
|
-
if (b && !b.includes("javascript") && !b.includes("text/plain"))
|
|
796
|
-
throw new Error(`Expected JavaScript but got ${b}`);
|
|
797
|
-
return m.text();
|
|
798
|
-
}).then((m) => {
|
|
799
|
-
at(
|
|
800
|
-
m,
|
|
801
|
-
t,
|
|
802
|
-
s,
|
|
803
|
-
e,
|
|
804
|
-
l,
|
|
805
|
-
o
|
|
806
|
-
);
|
|
807
|
-
}).catch((m) => {
|
|
808
|
-
console.error(`Failed to load external script: ${f.src}`, m);
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
lt(e, l);
|
|
812
|
-
}), Ut = (e, n) => {
|
|
813
|
-
var a, l, u, f, p, E, m, b, G, N, ut, dt;
|
|
814
|
-
const { tagName: t, template: s, scripts: o, externalScripts: i, styles: r, sourcePath: c } = e, S = class S extends HTMLElement {
|
|
815
|
-
constructor() {
|
|
816
|
-
super();
|
|
817
|
-
_(this, b);
|
|
818
|
-
_(this, a, []);
|
|
819
|
-
_(this, l, []);
|
|
820
|
-
_(this, u, []);
|
|
821
|
-
_(this, f, []);
|
|
822
|
-
_(this, p, []);
|
|
823
|
-
_(this, E, c);
|
|
824
|
-
_(this, m, /* @__PURE__ */ new WeakMap());
|
|
825
|
-
n && this.attachShadow({ mode: "open" });
|
|
826
|
-
const h = {}, w = () => {
|
|
827
|
-
st(A(this, a), this.state, this), ot(A(this, u), this.state, this), rt(A(this, f), this.state, this), W(this, b, dt).call(this);
|
|
828
|
-
};
|
|
829
|
-
this.state = new Proxy(h, {
|
|
830
|
-
get: (y, g) => y[g],
|
|
831
|
-
set: (y, g, $) => {
|
|
832
|
-
const x = y[g];
|
|
833
|
-
return g in y && Object.is(x, $) || ($ !== null && typeof $ == "object" ? y[g] = W(this, b, G).call(this, $, w) : y[g] = $, Object.getOwnPropertyDescriptor(this, g) || Object.defineProperty(this, g, {
|
|
834
|
-
get() {
|
|
835
|
-
return this.state[g];
|
|
836
|
-
},
|
|
837
|
-
set(B) {
|
|
838
|
-
this.state[g] = B;
|
|
839
|
-
},
|
|
840
|
-
enumerable: !0,
|
|
841
|
-
configurable: !0
|
|
842
|
-
}), w()), !0;
|
|
843
|
-
}
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* Updates component state with one or more key-value pairs
|
|
848
|
-
* @param updates - Object containing state updates
|
|
849
|
-
* @example
|
|
850
|
-
* component.setState({ count: 5, name: 'John' })
|
|
851
|
-
*/
|
|
852
|
-
setState(h) {
|
|
853
|
-
Object.assign(this.state, h);
|
|
854
|
-
}
|
|
855
|
-
// Invoked when element is added to the DOM
|
|
856
|
-
connectedCallback() {
|
|
857
|
-
return j(this, null, function* () {
|
|
858
|
-
const h = n ? this.shadowRoot : this, { bindings: w, twoWayBindings: y, conditionals: g, loops: $ } = St(
|
|
859
|
-
h,
|
|
860
|
-
s
|
|
861
|
-
);
|
|
862
|
-
M(this, a, w), M(this, l, y), M(this, u, g), M(this, f, $);
|
|
863
|
-
const x = kt(g), T = Rt($);
|
|
864
|
-
xt(h, r, n), yield It(
|
|
865
|
-
h,
|
|
866
|
-
i,
|
|
867
|
-
A(this, a),
|
|
868
|
-
A(this, l),
|
|
869
|
-
/* @__PURE__ */ new Set([...x, ...T]),
|
|
870
|
-
A(this, E)
|
|
871
|
-
), (yield Wt(
|
|
872
|
-
h,
|
|
873
|
-
o,
|
|
874
|
-
A(this, a),
|
|
875
|
-
A(this, l),
|
|
876
|
-
/* @__PURE__ */ new Set([...x, ...T])
|
|
877
|
-
)).forEach((v, V) => {
|
|
878
|
-
if (this.state[V] === void 0)
|
|
879
|
-
try {
|
|
880
|
-
const k = new Function(`return ${v}`);
|
|
881
|
-
this.state[V] = k();
|
|
882
|
-
} catch (k) {
|
|
883
|
-
this.state[V] = v;
|
|
884
|
-
}
|
|
885
|
-
}), this._initializeStateFromAttributes(), this._setupTwoWayBindings(), st(A(this, a), this.state, this), ot(A(this, u), this.state, this), rt(A(this, f), this.state, this), this._setupAttributeObserver();
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
// Invoked when element is removed from the DOM
|
|
889
|
-
disconnectedCallback() {
|
|
890
|
-
this.__attributeObserver && (this.__attributeObserver.disconnect(), this.__attributeObserver = null), A(this, p).forEach((w) => {
|
|
891
|
-
try {
|
|
892
|
-
w();
|
|
893
|
-
} catch (y) {
|
|
894
|
-
At(
|
|
895
|
-
"cleanup",
|
|
896
|
-
y,
|
|
897
|
-
R(this, {
|
|
898
|
-
lineHint: "disconnectedCallback cleanup"
|
|
899
|
-
})
|
|
900
|
-
);
|
|
901
|
-
}
|
|
902
|
-
}), M(this, p, []);
|
|
903
|
-
const h = this.__eventUnsubscribers;
|
|
904
|
-
h && Array.isArray(h) && (h.forEach((w) => {
|
|
905
|
-
try {
|
|
906
|
-
w();
|
|
907
|
-
} catch (y) {
|
|
908
|
-
D.error(
|
|
909
|
-
"⚠️ Event Bus Error: Failed to unsubscribe from event",
|
|
910
|
-
R(this)
|
|
911
|
-
), D.error(` Error details: ${y.message}`);
|
|
912
|
-
}
|
|
913
|
-
}), this.__eventUnsubscribers = []);
|
|
914
|
-
}
|
|
915
|
-
// Set up observer to watch for attribute changes
|
|
916
|
-
_setupAttributeObserver() {
|
|
917
|
-
const h = new MutationObserver((w) => {
|
|
918
|
-
w.forEach((y) => {
|
|
919
|
-
if (y.type === "attributes" && y.attributeName) {
|
|
920
|
-
const g = this.getAttribute(y.attributeName);
|
|
921
|
-
this._handleAttributeChange(y.attributeName, g);
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
});
|
|
925
|
-
h.observe(this, {
|
|
926
|
-
attributes: !0,
|
|
927
|
-
attributeOldValue: !0
|
|
928
|
-
}), this.__attributeObserver = h;
|
|
929
|
-
}
|
|
930
|
-
// initializes the state from the attributes
|
|
931
|
-
_initializeStateFromAttributes() {
|
|
932
|
-
this.getAttributeNames().forEach((h) => {
|
|
933
|
-
const w = this.getAttribute(h);
|
|
934
|
-
this._handleAttributeChange(h, w);
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
// Invoked when attributes are changed.
|
|
938
|
-
_handleAttributeChange(h, w) {
|
|
939
|
-
var g;
|
|
940
|
-
if (h) {
|
|
941
|
-
const $ = "this.state.";
|
|
942
|
-
h.startsWith($) && (h = h.slice($.length));
|
|
943
|
-
}
|
|
944
|
-
const y = W(g = S, N, ut).call(g, w);
|
|
945
|
-
this.state[h] = y;
|
|
946
|
-
}
|
|
947
|
-
// Setup two-way data bindings for input elements with $bind
|
|
948
|
-
_setupTwoWayBindings() {
|
|
949
|
-
A(this, l).forEach(
|
|
950
|
-
({ element: h, path: w, raw: y, isContentEditable: g, initialValue: $ }) => {
|
|
951
|
-
var T, B;
|
|
952
|
-
if (this._getNestedValue(w) === void 0) {
|
|
953
|
-
const v = $ || "";
|
|
954
|
-
Z(this.state, w, v);
|
|
955
|
-
}
|
|
956
|
-
if (g) {
|
|
957
|
-
const v = h;
|
|
958
|
-
v.textContent = (T = this._getNestedValue(w)) != null ? T : "";
|
|
959
|
-
const V = (P) => {
|
|
960
|
-
const L = P.target.textContent || "";
|
|
961
|
-
Z(this.state, w, L);
|
|
962
|
-
};
|
|
963
|
-
v.addEventListener("input", V);
|
|
964
|
-
const k = () => {
|
|
965
|
-
v.removeEventListener("input", V);
|
|
966
|
-
};
|
|
967
|
-
A(this, p).push(k);
|
|
968
|
-
} else {
|
|
969
|
-
const v = h, V = v instanceof HTMLInputElement && v.type === "checkbox";
|
|
970
|
-
v instanceof HTMLInputElement && v.type, V ? v.checked = !!this._getNestedValue(w) : v.value = (B = this._getNestedValue(w)) != null ? B : "";
|
|
971
|
-
const k = (H) => {
|
|
972
|
-
const L = H.target;
|
|
973
|
-
let I;
|
|
974
|
-
L instanceof HTMLInputElement && L.type === "checkbox" ? I = L.checked : (L instanceof HTMLInputElement && L.type, I = L.value), Z(this.state, w, I);
|
|
975
|
-
};
|
|
976
|
-
v.addEventListener("input", k);
|
|
977
|
-
const P = () => {
|
|
978
|
-
v.removeEventListener("input", k);
|
|
979
|
-
};
|
|
980
|
-
if (A(this, p).push(P), v instanceof HTMLSelectElement || v instanceof HTMLInputElement && ["checkbox", "radio", "file"].includes(v.type)) {
|
|
981
|
-
v.addEventListener("change", k);
|
|
982
|
-
const H = () => {
|
|
983
|
-
v.removeEventListener("change", k);
|
|
984
|
-
};
|
|
985
|
-
A(this, p).push(H);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
);
|
|
990
|
-
}
|
|
991
|
-
// Helper to get nested value from state
|
|
992
|
-
_getNestedValue(h) {
|
|
993
|
-
return h.reduce((w, y) => w == null ? void 0 : w[y], this.state);
|
|
994
|
-
}
|
|
995
|
-
};
|
|
996
|
-
a = new WeakMap(), l = new WeakMap(), u = new WeakMap(), f = new WeakMap(), p = new WeakMap(), E = new WeakMap(), m = new WeakMap(), b = new WeakSet(), /**
|
|
997
|
-
* Creates a deep reactive proxy that tracks nested object/array mutations
|
|
998
|
-
* @param target - The object or array to make reactive
|
|
999
|
-
* @param callback - Function to call when any nested property changes
|
|
1000
|
-
*/
|
|
1001
|
-
G = function(h, w) {
|
|
1002
|
-
if (h === null || typeof h != "object" || h instanceof HTMLElement || h instanceof Node)
|
|
1003
|
-
return h;
|
|
1004
|
-
if (A(this, m).has(h))
|
|
1005
|
-
return A(this, m).get(h);
|
|
1006
|
-
const y = new Proxy(h, {
|
|
1007
|
-
get: (g, $) => {
|
|
1008
|
-
const x = g[$];
|
|
1009
|
-
return Array.isArray(g) && typeof x == "function" && [
|
|
1010
|
-
"push",
|
|
1011
|
-
"pop",
|
|
1012
|
-
"shift",
|
|
1013
|
-
"unshift",
|
|
1014
|
-
"splice",
|
|
1015
|
-
"sort",
|
|
1016
|
-
"reverse"
|
|
1017
|
-
].includes($) ? (...B) => {
|
|
1018
|
-
const v = x.apply(g, B);
|
|
1019
|
-
return w(), v;
|
|
1020
|
-
} : x !== null && typeof x == "object" ? W(this, b, G).call(this, x, w) : x;
|
|
1021
|
-
},
|
|
1022
|
-
set: (g, $, x) => {
|
|
1023
|
-
const T = g[$];
|
|
1024
|
-
return Object.is(T, x) || (g[$] = x, w()), !0;
|
|
1025
|
-
}
|
|
1026
|
-
});
|
|
1027
|
-
return A(this, m).set(h, y), y;
|
|
1028
|
-
}, N = new WeakSet(), ut = function(h) {
|
|
1029
|
-
if (h === null || h === "") return null;
|
|
1030
|
-
if (h !== "undefined")
|
|
1031
|
-
try {
|
|
1032
|
-
return JSON.parse(h);
|
|
1033
|
-
} catch (w) {
|
|
1034
|
-
return h;
|
|
1035
|
-
}
|
|
1036
|
-
}, // Update two-way bound elements when state changes
|
|
1037
|
-
dt = function() {
|
|
1038
|
-
A(this, l).forEach(({ element: h, path: w, isContentEditable: y }) => {
|
|
1039
|
-
const g = this._getNestedValue(w);
|
|
1040
|
-
if (y) {
|
|
1041
|
-
const $ = h;
|
|
1042
|
-
$.textContent !== g && ($.textContent = g != null ? g : "");
|
|
1043
|
-
} else {
|
|
1044
|
-
const $ = h;
|
|
1045
|
-
if ($ instanceof HTMLInputElement && $.type === "checkbox") {
|
|
1046
|
-
const x = !!g;
|
|
1047
|
-
$.checked !== x && ($.checked = x);
|
|
1048
|
-
} else
|
|
1049
|
-
$.value !== g && ($.value = g != null ? g : "");
|
|
1050
|
-
}
|
|
1051
|
-
});
|
|
1052
|
-
}, _(S, N);
|
|
1053
|
-
let d = S;
|
|
1054
|
-
customElements.get(t) || (customElements.define(t, d), D.log(`Web component defined: <${t}></${t}>`));
|
|
1055
|
-
};
|
|
1056
|
-
export {
|
|
1057
|
-
Ut as defineWebComponent
|
|
1058
|
-
};
|
|
1059
|
-
//# sourceMappingURL=webcomponent-DT_kduma.mjs.map
|