@bquery/bquery 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +527 -501
- package/dist/{batch-4LAvfLE7.js → batch-x7b2eZST.js} +2 -2
- package/dist/{batch-4LAvfLE7.js.map → batch-x7b2eZST.js.map} +1 -1
- package/dist/component.es.mjs +1 -1
- package/dist/core/collection.d.ts +19 -3
- package/dist/core/collection.d.ts.map +1 -1
- package/dist/core/element.d.ts +23 -4
- package/dist/core/element.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/utils/function.d.ts +21 -4
- package/dist/core/utils/function.d.ts.map +1 -1
- package/dist/{core-COenAZjD.js → core-BhpuvPhy.js} +62 -37
- package/dist/core-BhpuvPhy.js.map +1 -0
- package/dist/core.es.mjs +174 -131
- package/dist/core.es.mjs.map +1 -1
- package/dist/full.es.mjs +7 -7
- package/dist/full.iife.js +2 -2
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +2 -2
- package/dist/full.umd.js.map +1 -1
- package/dist/index.es.mjs +7 -7
- package/dist/motion.es.mjs.map +1 -1
- package/dist/{persisted-Dz_ryNuC.js → persisted-DHoi3uEs.js} +4 -4
- package/dist/{persisted-Dz_ryNuC.js.map → persisted-DHoi3uEs.js.map} +1 -1
- package/dist/platform/storage.d.ts.map +1 -1
- package/dist/platform.es.mjs +12 -7
- package/dist/platform.es.mjs.map +1 -1
- package/dist/reactive/core.d.ts +12 -0
- package/dist/reactive/core.d.ts.map +1 -1
- package/dist/reactive/effect.d.ts.map +1 -1
- package/dist/reactive/internals.d.ts +6 -0
- package/dist/reactive/internals.d.ts.map +1 -1
- package/dist/reactive.es.mjs +6 -6
- package/dist/router.es.mjs +1 -1
- package/dist/{sanitize-1FBEPAFH.js → sanitize-Cxvxa-DX.js} +50 -39
- package/dist/sanitize-Cxvxa-DX.js.map +1 -0
- package/dist/security/sanitize-core.d.ts.map +1 -1
- package/dist/security.es.mjs +2 -2
- package/dist/store.es.mjs +2 -2
- package/dist/type-guards-BdKlYYlS.js +32 -0
- package/dist/type-guards-BdKlYYlS.js.map +1 -0
- package/dist/untrack-DNnnqdlR.js +6 -0
- package/dist/{untrack-BuEQKH7_.js.map → untrack-DNnnqdlR.js.map} +1 -1
- package/dist/view/evaluate.d.ts.map +1 -1
- package/dist/view.es.mjs +157 -151
- package/dist/view.es.mjs.map +1 -1
- package/dist/{watch-CXyaBC_9.js → watch-DXXv3iAI.js} +3 -3
- package/dist/{watch-CXyaBC_9.js.map → watch-DXXv3iAI.js.map} +1 -1
- package/package.json +132 -132
- package/src/core/collection.ts +628 -588
- package/src/core/element.ts +774 -746
- package/src/core/index.ts +48 -47
- package/src/core/utils/function.ts +151 -110
- package/src/motion/animate.ts +113 -113
- package/src/motion/flip.ts +176 -176
- package/src/motion/scroll.ts +57 -57
- package/src/motion/spring.ts +150 -150
- package/src/motion/timeline.ts +246 -246
- package/src/motion/transition.ts +51 -51
- package/src/platform/storage.ts +215 -208
- package/src/reactive/core.ts +114 -93
- package/src/reactive/effect.ts +54 -43
- package/src/reactive/internals.ts +122 -105
- package/src/security/sanitize-core.ts +364 -343
- package/src/view/evaluate.ts +290 -274
- package/dist/core-COenAZjD.js.map +0 -1
- package/dist/sanitize-1FBEPAFH.js.map +0 -1
- package/dist/type-guards-DRma3-Kc.js +0 -16
- package/dist/type-guards-DRma3-Kc.js.map +0 -1
- package/dist/untrack-BuEQKH7_.js +0 -6
package/dist/view.es.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as z, i as V, e as E } from "./type-guards-
|
|
2
|
-
import { s as P } from "./core-
|
|
3
|
-
import { c as ye } from "./core-
|
|
4
|
-
import { s as Z } from "./sanitize-
|
|
5
|
-
import { b as
|
|
1
|
+
import { a as z, i as V, e as E } from "./type-guards-BdKlYYlS.js";
|
|
2
|
+
import { s as P } from "./core-BhpuvPhy.js";
|
|
3
|
+
import { c as ye } from "./core-BhpuvPhy.js";
|
|
4
|
+
import { s as Z } from "./sanitize-Cxvxa-DX.js";
|
|
5
|
+
import { b as ge } from "./batch-x7b2eZST.js";
|
|
6
6
|
const N = 500;
|
|
7
7
|
class D {
|
|
8
8
|
constructor(e) {
|
|
@@ -28,8 +28,8 @@ class D {
|
|
|
28
28
|
return this.cache.size;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const I = new D(N), O = new D(N), de = () => {
|
|
32
|
+
I.clear(), O.clear();
|
|
33
33
|
}, U = (n) => new Proxy(n, {
|
|
34
34
|
get(e, s) {
|
|
35
35
|
if (typeof s != "string")
|
|
@@ -43,16 +43,16 @@ const O = new D(N), T = new D(N), de = () => {
|
|
|
43
43
|
}), y = (n, e) => {
|
|
44
44
|
try {
|
|
45
45
|
const s = U(e);
|
|
46
|
-
let r =
|
|
47
|
-
return r || (r = new Function("$ctx", `with($ctx) { return (${n}); }`),
|
|
46
|
+
let r = I.get(n);
|
|
47
|
+
return r || (r = new Function("$ctx", `with($ctx) { return (${n}); }`), I.set(n, r)), r(s);
|
|
48
48
|
} catch (s) {
|
|
49
49
|
console.error(`bQuery view: Error evaluating "${n}"`, s);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
},
|
|
52
|
+
}, M = (n, e) => {
|
|
53
53
|
try {
|
|
54
|
-
let s =
|
|
55
|
-
return s || (s = new Function("$ctx", `with($ctx) { return (${n}); }`),
|
|
54
|
+
let s = O.get(n);
|
|
55
|
+
return s || (s = new Function("$ctx", `with($ctx) { return (${n}); }`), O.set(n, s)), s(e);
|
|
56
56
|
} catch (s) {
|
|
57
57
|
console.error(`bQuery view: Error evaluating "${n}"`, s);
|
|
58
58
|
return;
|
|
@@ -61,60 +61,66 @@ const O = new D(N), T = new D(N), de = () => {
|
|
|
61
61
|
const e = {}, s = n.trim().replace(/^\{|\}$/g, "").trim();
|
|
62
62
|
if (!s) return e;
|
|
63
63
|
const r = [];
|
|
64
|
-
let t = "",
|
|
64
|
+
let t = "", l = 0, i = null;
|
|
65
65
|
for (let c = 0; c < s.length; c++) {
|
|
66
|
-
const o = s[c]
|
|
67
|
-
if (
|
|
68
|
-
|
|
66
|
+
const o = s[c];
|
|
67
|
+
if (o === '"' || o === "'" || o === "`") {
|
|
68
|
+
let a = 0, u = c - 1;
|
|
69
|
+
for (; u >= 0 && s[u] === "\\"; )
|
|
70
|
+
a++, u--;
|
|
71
|
+
a % 2 === 0 && (i === null ? i = o : i === o && (i = null)), t += o;
|
|
69
72
|
continue;
|
|
70
73
|
}
|
|
71
74
|
if (i !== null) {
|
|
72
75
|
t += o;
|
|
73
76
|
continue;
|
|
74
77
|
}
|
|
75
|
-
o === "(" || o === "[" || o === "{" ? (
|
|
78
|
+
o === "(" || o === "[" || o === "{" ? (l++, t += o) : o === ")" || o === "]" || o === "}" ? (l--, t += o) : o === "," && l === 0 ? (r.push(t.trim()), t = "") : t += o;
|
|
76
79
|
}
|
|
77
80
|
t.trim() && r.push(t.trim());
|
|
78
81
|
for (const c of r) {
|
|
79
|
-
let o = -1,
|
|
80
|
-
for (let
|
|
81
|
-
const f = c[
|
|
82
|
-
if (
|
|
83
|
-
|
|
82
|
+
let o = -1, a = 0, u = null;
|
|
83
|
+
for (let h = 0; h < c.length; h++) {
|
|
84
|
+
const f = c[h];
|
|
85
|
+
if (f === '"' || f === "'" || f === "`") {
|
|
86
|
+
let q = 0, S = h - 1;
|
|
87
|
+
for (; S >= 0 && c[S] === "\\"; )
|
|
88
|
+
q++, S--;
|
|
89
|
+
q % 2 === 0 && (u === null ? u = f : u === f && (u = null));
|
|
84
90
|
continue;
|
|
85
91
|
}
|
|
86
|
-
if (
|
|
92
|
+
if (u === null) {
|
|
87
93
|
if (f === "(" || f === "[" || f === "{")
|
|
88
|
-
|
|
94
|
+
a++;
|
|
89
95
|
else if (f === ")" || f === "]" || f === "}")
|
|
90
|
-
|
|
91
|
-
else if (f === ":" &&
|
|
92
|
-
o =
|
|
96
|
+
a--;
|
|
97
|
+
else if (f === ":" && a === 0) {
|
|
98
|
+
o = h;
|
|
93
99
|
break;
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
103
|
if (o > -1) {
|
|
98
|
-
const
|
|
99
|
-
e[
|
|
104
|
+
const h = c.slice(0, o).trim().replace(/^['"]|['"]$/g, ""), f = c.slice(o + 1).trim();
|
|
105
|
+
e[h] = f;
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
return e;
|
|
103
109
|
}, X = (n) => (e, s, r, t) => {
|
|
104
|
-
const
|
|
110
|
+
const l = E(() => {
|
|
105
111
|
const i = y(s, r);
|
|
106
112
|
i == null || i === !1 ? e.removeAttribute(n) : i === !0 ? e.setAttribute(n, "") : e.setAttribute(n, String(i));
|
|
107
113
|
});
|
|
108
|
-
t.push(
|
|
114
|
+
t.push(l);
|
|
109
115
|
}, G = (n, e, s, r) => {
|
|
110
116
|
let t = /* @__PURE__ */ new Set();
|
|
111
|
-
const
|
|
117
|
+
const l = E(() => {
|
|
112
118
|
const i = /* @__PURE__ */ new Set();
|
|
113
119
|
if (e.trimStart().startsWith("{")) {
|
|
114
120
|
const c = _(e);
|
|
115
|
-
for (const [o,
|
|
116
|
-
const
|
|
117
|
-
n.classList.toggle(o, !!
|
|
121
|
+
for (const [o, a] of Object.entries(c)) {
|
|
122
|
+
const u = y(a, s);
|
|
123
|
+
n.classList.toggle(o, !!u), i.add(o);
|
|
118
124
|
}
|
|
119
125
|
} else if (/^\s*\[/.test(e)) {
|
|
120
126
|
const c = y(e, s);
|
|
@@ -133,42 +139,42 @@ const O = new D(N), T = new D(N), de = () => {
|
|
|
133
139
|
i.has(c) || n.classList.remove(c);
|
|
134
140
|
t = i;
|
|
135
141
|
});
|
|
136
|
-
r.push(
|
|
137
|
-
}, J = (n, e, s, r, t,
|
|
142
|
+
r.push(l);
|
|
143
|
+
}, J = (n, e, s, r, t, l) => {
|
|
138
144
|
if (!s)
|
|
139
145
|
return e;
|
|
140
146
|
const i = {
|
|
141
|
-
...
|
|
147
|
+
...l,
|
|
142
148
|
[r]: n
|
|
143
149
|
};
|
|
144
150
|
return t && (i[t] = e), y(s, i);
|
|
145
151
|
}, Y = (n) => {
|
|
146
152
|
const { prefix: e, processElement: s, processChildren: r } = n;
|
|
147
|
-
return (t,
|
|
153
|
+
return (t, l, i, c) => {
|
|
148
154
|
const o = t.parentNode;
|
|
149
155
|
if (!o) return;
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
152
|
-
console.error(`bQuery view: Invalid bq-for expression "${
|
|
156
|
+
const a = l.match(/^\(?(\w+)(?:\s*,\s*(\w+))?\)?\s+in\s+(\S.*)$/);
|
|
157
|
+
if (!a) {
|
|
158
|
+
console.error(`bQuery view: Invalid bq-for expression "${l}"`);
|
|
153
159
|
return;
|
|
154
160
|
}
|
|
155
|
-
const [,
|
|
156
|
-
|
|
157
|
-
const Q = document.createComment(`bq-for: ${
|
|
161
|
+
const [, u, h, f] = a, q = t.getAttribute(":key") || t.getAttribute(`${e}-key`), S = t.cloneNode(!0);
|
|
162
|
+
S.removeAttribute(`${e}-for`), S.removeAttribute(":key"), S.removeAttribute(`${e}-key`);
|
|
163
|
+
const Q = document.createComment(`bq-for: ${l}`);
|
|
158
164
|
o.replaceChild(Q, t);
|
|
159
|
-
let
|
|
165
|
+
let C = /* @__PURE__ */ new Map(), j = [];
|
|
160
166
|
const F = (d, p, w) => {
|
|
161
|
-
const
|
|
167
|
+
const A = S.cloneNode(!0), k = [], L = P(d), $ = h ? P(p) : null, m = {
|
|
162
168
|
...i,
|
|
163
|
-
[
|
|
169
|
+
[u]: L
|
|
164
170
|
};
|
|
165
|
-
return
|
|
171
|
+
return h && $ && (m[h] = $), s(A, m, e, k), r(A, m, e, k), {
|
|
166
172
|
key: w,
|
|
167
|
-
element:
|
|
168
|
-
cleanups:
|
|
173
|
+
element: A,
|
|
174
|
+
cleanups: k,
|
|
169
175
|
item: d,
|
|
170
176
|
index: p,
|
|
171
|
-
itemSignal:
|
|
177
|
+
itemSignal: L,
|
|
172
178
|
indexSignal: $
|
|
173
179
|
};
|
|
174
180
|
}, R = (d) => {
|
|
@@ -180,93 +186,93 @@ const O = new D(N), T = new D(N), de = () => {
|
|
|
180
186
|
}, B = E(() => {
|
|
181
187
|
const d = y(f, i);
|
|
182
188
|
if (!Array.isArray(d)) {
|
|
183
|
-
for (const m of
|
|
189
|
+
for (const m of C.values())
|
|
184
190
|
R(m);
|
|
185
|
-
|
|
191
|
+
C.clear(), j = [];
|
|
186
192
|
return;
|
|
187
193
|
}
|
|
188
|
-
const p = [], w = /* @__PURE__ */ new Map(),
|
|
194
|
+
const p = [], w = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Set();
|
|
189
195
|
d.forEach((m, v) => {
|
|
190
|
-
let
|
|
191
|
-
|
|
192
|
-
`bq-for: Duplicate key "${String(
|
|
193
|
-
),
|
|
196
|
+
let b = J(m, v, q, u, h, i);
|
|
197
|
+
A.has(b) && (console.warn(
|
|
198
|
+
`bq-for: Duplicate key "${String(b)}" detected at index ${v}. Falling back to index-based key for this item. Ensure :key expressions produce unique values for each item.`
|
|
199
|
+
), b = { __bqDuplicateKey: b, __bqIndex: v }), A.add(b), p.push(b), w.set(b, { item: m, index: v });
|
|
194
200
|
});
|
|
195
|
-
const
|
|
196
|
-
for (const m of
|
|
197
|
-
w.has(m) ||
|
|
198
|
-
for (const m of
|
|
199
|
-
const v =
|
|
200
|
-
v && (R(v),
|
|
201
|
+
const k = [];
|
|
202
|
+
for (const m of j)
|
|
203
|
+
w.has(m) || k.push(m);
|
|
204
|
+
for (const m of k) {
|
|
205
|
+
const v = C.get(m);
|
|
206
|
+
v && (R(v), C.delete(m));
|
|
201
207
|
}
|
|
202
|
-
const
|
|
208
|
+
const L = /* @__PURE__ */ new Map();
|
|
203
209
|
let $ = Q;
|
|
204
210
|
for (let m = 0; m < p.length; m++) {
|
|
205
|
-
const v = p[m], { item:
|
|
206
|
-
let
|
|
207
|
-
|
|
211
|
+
const v = p[m], { item: b, index: H } = w.get(v);
|
|
212
|
+
let g = C.get(v);
|
|
213
|
+
g ? (K(g, b, H), L.set(v, g), $.nextSibling !== g.element && $.after(g.element), $ = g.element) : (g = F(b, H, v), L.set(v, g), $.after(g.element), $ = g.element);
|
|
208
214
|
}
|
|
209
|
-
|
|
215
|
+
C = L, j = p;
|
|
210
216
|
});
|
|
211
217
|
c.push(() => {
|
|
212
218
|
B();
|
|
213
|
-
for (const d of
|
|
219
|
+
for (const d of C.values())
|
|
214
220
|
for (const p of d.cleanups)
|
|
215
221
|
p();
|
|
216
|
-
|
|
222
|
+
C.clear();
|
|
217
223
|
});
|
|
218
224
|
};
|
|
219
225
|
}, x = (n) => (e, s, r, t) => {
|
|
220
|
-
const
|
|
226
|
+
const l = E(() => {
|
|
221
227
|
const i = y(s, r), c = String(i ?? "");
|
|
222
228
|
e.innerHTML = n ? Z(c) : c;
|
|
223
229
|
});
|
|
224
|
-
t.push(
|
|
230
|
+
t.push(l);
|
|
225
231
|
}, ee = (n, e, s, r) => {
|
|
226
232
|
const t = document.createComment(`bq-if: ${e}`);
|
|
227
|
-
let
|
|
233
|
+
let l = !0;
|
|
228
234
|
const i = E(() => {
|
|
229
235
|
const c = y(e, s);
|
|
230
|
-
c && !
|
|
236
|
+
c && !l ? (t.replaceWith(n), l = !0) : !c && l && (n.replaceWith(t), l = !1);
|
|
231
237
|
});
|
|
232
238
|
r.push(i);
|
|
233
239
|
}, te = (n, e, s, r) => {
|
|
234
|
-
const t = n,
|
|
235
|
-
if (!z(
|
|
240
|
+
const t = n, l = M(e, s);
|
|
241
|
+
if (!z(l)) {
|
|
236
242
|
console.warn(`bQuery view: bq-model requires a signal, got "${e}"`);
|
|
237
243
|
return;
|
|
238
244
|
}
|
|
239
|
-
const i =
|
|
245
|
+
const i = l, c = t.type === "checkbox", o = t.type === "radio", a = () => {
|
|
240
246
|
c ? t.checked = !!i.value : o ? t.checked = i.value === t.value : t.value = String(i.value ?? "");
|
|
241
|
-
},
|
|
242
|
-
|
|
247
|
+
}, u = E(() => {
|
|
248
|
+
a();
|
|
243
249
|
});
|
|
244
|
-
r.push(
|
|
245
|
-
const
|
|
250
|
+
r.push(u);
|
|
251
|
+
const h = t.tagName === "SELECT" ? "change" : "input", f = () => {
|
|
246
252
|
c ? i.value = t.checked : o ? t.checked && (i.value = t.value) : i.value = t.value;
|
|
247
253
|
};
|
|
248
|
-
t.addEventListener(
|
|
254
|
+
t.addEventListener(h, f), r.push(() => t.removeEventListener(h, f));
|
|
249
255
|
}, ne = (n) => (e, s, r, t) => {
|
|
250
|
-
const
|
|
256
|
+
const l = (i) => {
|
|
251
257
|
const c = { ...r, $event: i, $el: e };
|
|
252
258
|
if (!s.includes("(")) {
|
|
253
|
-
const
|
|
254
|
-
if (typeof
|
|
255
|
-
|
|
259
|
+
const a = M(s, c);
|
|
260
|
+
if (typeof a == "function") {
|
|
261
|
+
a(i);
|
|
256
262
|
return;
|
|
257
263
|
}
|
|
258
264
|
return;
|
|
259
265
|
}
|
|
260
|
-
|
|
266
|
+
M(s, c);
|
|
261
267
|
};
|
|
262
|
-
e.addEventListener(n,
|
|
268
|
+
e.addEventListener(n, l), t.push(() => e.removeEventListener(n, l));
|
|
263
269
|
};
|
|
264
270
|
function se(n) {
|
|
265
271
|
const e = Object.getOwnPropertyDescriptor(n, "value");
|
|
266
272
|
return e ? "value" in e ? e.writable === !0 : typeof e.set == "function" : !1;
|
|
267
273
|
}
|
|
268
274
|
const re = (n, e, s, r) => {
|
|
269
|
-
const t =
|
|
275
|
+
const t = M(
|
|
270
276
|
e,
|
|
271
277
|
s
|
|
272
278
|
);
|
|
@@ -277,89 +283,89 @@ const re = (n, e, s, r) => {
|
|
|
277
283
|
}));
|
|
278
284
|
}, oe = (n, e, s, r) => {
|
|
279
285
|
const t = n;
|
|
280
|
-
let
|
|
281
|
-
if (!
|
|
286
|
+
let l = t.style.display;
|
|
287
|
+
if (!l || l === "none") {
|
|
282
288
|
const c = t.ownerDocument.defaultView?.getComputedStyle(t).display ?? "";
|
|
283
|
-
|
|
289
|
+
l = c !== "none" ? c : "";
|
|
284
290
|
}
|
|
285
291
|
const i = E(() => {
|
|
286
292
|
const c = y(e, s);
|
|
287
|
-
t.style.display = c ?
|
|
293
|
+
t.style.display = c ? l : "none";
|
|
288
294
|
});
|
|
289
295
|
r.push(i);
|
|
290
296
|
}, ie = (n, e, s, r) => {
|
|
291
297
|
const t = n;
|
|
292
|
-
let
|
|
298
|
+
let l = /* @__PURE__ */ new Set();
|
|
293
299
|
const i = E(() => {
|
|
294
300
|
const c = /* @__PURE__ */ new Set();
|
|
295
301
|
if (e.trimStart().startsWith("{")) {
|
|
296
302
|
const o = _(e);
|
|
297
|
-
for (const [
|
|
298
|
-
const
|
|
299
|
-
t.style.setProperty(f, String(
|
|
303
|
+
for (const [a, u] of Object.entries(o)) {
|
|
304
|
+
const h = y(u, s), f = a.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
305
|
+
t.style.setProperty(f, String(h ?? "")), c.add(f);
|
|
300
306
|
}
|
|
301
307
|
} else {
|
|
302
308
|
const o = y(e, s);
|
|
303
309
|
if (o && typeof o == "object")
|
|
304
|
-
for (const [
|
|
305
|
-
const
|
|
306
|
-
t.style.setProperty(
|
|
310
|
+
for (const [a, u] of Object.entries(o)) {
|
|
311
|
+
const h = a.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
312
|
+
t.style.setProperty(h, String(u ?? "")), c.add(h);
|
|
307
313
|
}
|
|
308
314
|
}
|
|
309
|
-
for (const o of
|
|
315
|
+
for (const o of l)
|
|
310
316
|
c.has(o) || t.style.removeProperty(o);
|
|
311
|
-
|
|
317
|
+
l = c;
|
|
312
318
|
});
|
|
313
319
|
r.push(i);
|
|
314
320
|
}, ce = (n, e, s, r) => {
|
|
315
321
|
const t = E(() => {
|
|
316
|
-
const
|
|
317
|
-
n.textContent = String(
|
|
322
|
+
const l = y(e, s);
|
|
323
|
+
n.textContent = String(l ?? "");
|
|
318
324
|
});
|
|
319
325
|
r.push(t);
|
|
320
|
-
},
|
|
321
|
-
const
|
|
322
|
-
for (const i of
|
|
326
|
+
}, W = (n, e, s, r, t) => {
|
|
327
|
+
const l = Array.from(n.attributes);
|
|
328
|
+
for (const i of l) {
|
|
323
329
|
const { name: c, value: o } = i;
|
|
324
330
|
if (!c.startsWith(`${s}-`)) continue;
|
|
325
|
-
const
|
|
326
|
-
if (
|
|
331
|
+
const a = c.slice(s.length + 1);
|
|
332
|
+
if (a === "for") {
|
|
327
333
|
t.for(n, o, e, r);
|
|
328
334
|
return;
|
|
329
335
|
}
|
|
330
|
-
if (
|
|
336
|
+
if (a === "text")
|
|
331
337
|
t.text(n, o, e, r);
|
|
332
|
-
else if (
|
|
338
|
+
else if (a === "html")
|
|
333
339
|
t.html(n, o, e, r);
|
|
334
|
-
else if (
|
|
340
|
+
else if (a === "if")
|
|
335
341
|
t.if(n, o, e, r);
|
|
336
|
-
else if (
|
|
342
|
+
else if (a === "show")
|
|
337
343
|
t.show(n, o, e, r);
|
|
338
|
-
else if (
|
|
344
|
+
else if (a === "class")
|
|
339
345
|
t.class(n, o, e, r);
|
|
340
|
-
else if (
|
|
346
|
+
else if (a === "style")
|
|
341
347
|
t.style(n, o, e, r);
|
|
342
|
-
else if (
|
|
348
|
+
else if (a === "model")
|
|
343
349
|
t.model(n, o, e, r);
|
|
344
|
-
else if (
|
|
350
|
+
else if (a === "ref")
|
|
345
351
|
t.ref(n, o, e, r);
|
|
346
|
-
else if (
|
|
347
|
-
const
|
|
348
|
-
t.bind(
|
|
349
|
-
} else if (
|
|
350
|
-
const
|
|
351
|
-
t.on(
|
|
352
|
+
else if (a.startsWith("bind:")) {
|
|
353
|
+
const u = a.slice(5);
|
|
354
|
+
t.bind(u)(n, o, e, r);
|
|
355
|
+
} else if (a.startsWith("on:")) {
|
|
356
|
+
const u = a.slice(3);
|
|
357
|
+
t.on(u)(n, o, e, r);
|
|
352
358
|
}
|
|
353
359
|
}
|
|
354
|
-
},
|
|
355
|
-
const
|
|
356
|
-
for (const i of
|
|
357
|
-
i.hasAttribute(`${s}-for`) ?
|
|
358
|
-
},
|
|
359
|
-
const { prefix: r = "bq", sanitize: t = !0 } = s,
|
|
360
|
-
if (!
|
|
360
|
+
}, T = (n, e, s, r, t) => {
|
|
361
|
+
const l = Array.from(n.children);
|
|
362
|
+
for (const i of l)
|
|
363
|
+
i.hasAttribute(`${s}-for`) ? W(i, e, s, r, t) : (W(i, e, s, r, t), T(i, e, s, r, t));
|
|
364
|
+
}, le = (n, e, s = {}) => {
|
|
365
|
+
const { prefix: r = "bq", sanitize: t = !0 } = s, l = typeof n == "string" ? document.querySelector(n) : n;
|
|
366
|
+
if (!l)
|
|
361
367
|
throw new Error(`bQuery view: Element "${n}" not found.`);
|
|
362
|
-
if (
|
|
368
|
+
if (l.hasAttribute(`${r}-for`))
|
|
363
369
|
throw new Error(
|
|
364
370
|
`bQuery view: Cannot mount on element with ${r}-for directive. Wrap the ${r}-for element in a container instead.`
|
|
365
371
|
);
|
|
@@ -374,24 +380,24 @@ const re = (n, e, s, r) => {
|
|
|
374
380
|
ref: re,
|
|
375
381
|
for: Y({
|
|
376
382
|
prefix: r,
|
|
377
|
-
processElement: (
|
|
378
|
-
processChildren: (
|
|
383
|
+
processElement: (a, u, h, f) => W(a, u, h, f, c),
|
|
384
|
+
processChildren: (a, u, h, f) => T(a, u, h, f, c)
|
|
379
385
|
}),
|
|
380
386
|
bind: X,
|
|
381
387
|
on: ne
|
|
382
388
|
};
|
|
383
|
-
return ((
|
|
384
|
-
const f =
|
|
385
|
-
|
|
386
|
-
})(
|
|
387
|
-
el:
|
|
389
|
+
return ((a, u, h) => {
|
|
390
|
+
const f = a.hasAttribute(`${r}-for`);
|
|
391
|
+
W(a, u, r, h, c), f || T(a, u, r, h, c);
|
|
392
|
+
})(l, e, i), {
|
|
393
|
+
el: l,
|
|
388
394
|
context: e,
|
|
389
|
-
update: (
|
|
390
|
-
Object.assign(e,
|
|
395
|
+
update: (a) => {
|
|
396
|
+
Object.assign(e, a);
|
|
391
397
|
},
|
|
392
398
|
destroy: () => {
|
|
393
|
-
for (const
|
|
394
|
-
|
|
399
|
+
for (const a of i)
|
|
400
|
+
a();
|
|
395
401
|
i.length = 0;
|
|
396
402
|
}
|
|
397
403
|
};
|
|
@@ -405,22 +411,22 @@ const re = (n, e, s, r) => {
|
|
|
405
411
|
throw new Error(
|
|
406
412
|
`bQuery view: Template must contain exactly one root element, found ${r.childElementCount}.`
|
|
407
413
|
);
|
|
408
|
-
const { prefix:
|
|
409
|
-
if (t.hasAttribute(`${
|
|
410
|
-
const i = t.hasAttribute(`${
|
|
414
|
+
const { prefix: l = "bq" } = e;
|
|
415
|
+
if (t.hasAttribute(`${l}-for`) || t.hasAttribute(`${l}-if`)) {
|
|
416
|
+
const i = t.hasAttribute(`${l}-for`) ? "for" : "if";
|
|
411
417
|
throw new Error(
|
|
412
|
-
`bQuery view: Template root element cannot have ${
|
|
418
|
+
`bQuery view: Template root element cannot have ${l}-${i} directive. Wrap the ${l}-${i} element in a container instead.`
|
|
413
419
|
);
|
|
414
420
|
}
|
|
415
|
-
return
|
|
421
|
+
return le(t, s, e);
|
|
416
422
|
};
|
|
417
423
|
export {
|
|
418
|
-
|
|
424
|
+
ge as batch,
|
|
419
425
|
de as clearExpressionCache,
|
|
420
426
|
ye as computed,
|
|
421
427
|
me as createTemplate,
|
|
422
428
|
E as effect,
|
|
423
|
-
|
|
429
|
+
le as mount,
|
|
424
430
|
P as signal
|
|
425
431
|
};
|
|
426
432
|
//# sourceMappingURL=view.es.mjs.map
|