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