keits 0.0.3 → 0.1.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 +93 -79
- package/dist/dev/api.js +275 -0
- package/dist/dev/forms.js +330 -0
- package/dist/dev/index.js +26 -326
- package/dist/dev/router.js +24 -5
- package/dist/dev/shared/computed-DrF8O8b4.js +40 -0
- package/dist/dev/shared/{element-C4DfKtZW.js → element-DXwmUAnz.js} +32 -111
- package/dist/dev/shared/{graph-D6-x_CWC.js → graph-SIvYLXSv.js} +62 -3
- package/dist/dev/shared/hydrate-C8cOsDDH.js +588 -0
- package/dist/dev/shared/mount-CDB2HgN5.js +23 -0
- package/dist/dev/shared/namespaces-Cz82B0Pr.js +84 -0
- package/dist/dev/shared/owner-BuwIoI4j.js +72 -0
- package/dist/dev/shared/render-context-k2uu_dM_.js +34 -0
- package/dist/dev/shared/render-effect-Uk9dDmuU.js +32 -0
- package/dist/dev/shared/resource-DlgzdtcG.js +145 -0
- package/dist/dev/shared/signal-B3xOKbVm.js +24 -0
- package/dist/dev/shared/store-0vEg2bQV.js +152 -0
- package/dist/dev/shared/unsafe-keys-CB1P22No.js +8 -0
- package/dist/dev/static.js +76 -0
- package/dist/dev/svg.js +2 -1
- package/dist/dev/testing.js +216 -0
- package/dist/dev/vite.js +141 -0
- package/dist/prod/api.js +215 -0
- package/dist/prod/forms.js +240 -0
- package/dist/prod/index.js +110 -327
- package/dist/prod/router.js +83 -68
- package/dist/prod/shared/computed-BjqJ6Pps.js +33 -0
- package/dist/prod/shared/element-DCit4-3e.js +129 -0
- package/dist/prod/shared/{graph-C_aA46c6.js → graph-CR2WKbwr.js} +107 -63
- package/dist/prod/shared/hydrate-kKnJbkV7.js +480 -0
- package/dist/prod/shared/mount-DbeKIoyD.js +18 -0
- package/dist/prod/shared/namespaces-BSRrBJIU.js +71 -0
- package/dist/prod/shared/owner-DBi3odT4.js +67 -0
- package/dist/prod/shared/render-context-DF8lr1uu.js +30 -0
- package/dist/prod/shared/render-effect-UFDi2Pfh.js +25 -0
- package/dist/prod/shared/resource-Ch5tVseZ.js +91 -0
- package/dist/prod/shared/signal-BDMlfa0Z.js +16 -0
- package/dist/prod/shared/store-CvW0DbmK.js +110 -0
- package/dist/prod/shared/unsafe-keys-C5PMlerl.js +7 -0
- package/dist/prod/static.js +48 -0
- package/dist/prod/svg.js +3 -2
- package/dist/prod/testing.js +144 -0
- package/dist/prod/vite.js +106 -0
- package/dist/types/api/cache.d.ts +16 -0
- package/dist/types/api/client.d.ts +42 -0
- package/dist/types/api/error.d.ts +16 -0
- package/dist/types/api/index.d.ts +3 -0
- package/dist/types/api/url.d.ts +5 -0
- package/dist/types/async/render-context.d.ts +10 -0
- package/dist/types/core/effect.d.ts +1 -0
- package/dist/types/core/graph.d.ts +11 -0
- package/dist/types/core/owner.d.ts +1 -0
- package/dist/types/core/unsafe-keys.d.ts +2 -0
- package/dist/types/dom/hooks.d.ts +4 -0
- package/dist/types/dom/types.d.ts +5 -0
- package/dist/types/forms/form.d.ts +55 -0
- package/dist/types/forms/index.d.ts +2 -0
- package/dist/types/forms/paths.d.ts +6 -0
- package/dist/types/forms/types.d.ts +38 -0
- package/dist/types/router/index.d.ts +1 -0
- package/dist/types/router/match.d.ts +1 -0
- package/dist/types/router/types.d.ts +1 -0
- package/dist/types/static/head.d.ts +36 -0
- package/dist/types/static/hydrate.d.ts +3 -0
- package/dist/types/static/index.d.ts +4 -0
- package/dist/types/static/island.d.ts +14 -0
- package/dist/types/static/json.d.ts +1 -0
- package/dist/types/static/render.d.ts +11 -0
- package/dist/types/static/server-dom.d.ts +100 -0
- package/dist/types/testing/index.d.ts +62 -0
- package/dist/types/vite/index.d.ts +24 -0
- package/package.json +46 -5
- package/dist/dev/shared/owner-DlUsXKXE.js +0 -122
- package/dist/prod/shared/element-DUtXb3px.js +0 -187
- package/dist/prod/shared/owner-DgJNPM0P.js +0 -104
package/dist/prod/router.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as e } from "./shared/computed-BjqJ6Pps.js";
|
|
2
|
+
import { t } from "./shared/signal-BDMlfa0Z.js";
|
|
3
|
+
import { g as n, i as r, l as i, n as a, s as o, x as s } from "./shared/graph-CR2WKbwr.js";
|
|
4
|
+
import { a as c } from "./shared/owner-DBi3odT4.js";
|
|
3
5
|
// src/router/history.ts
|
|
4
6
|
var l = () => Math.random().toString(36).slice(2, 10), u = () => window.history.state?.keitsKey ?? "start";
|
|
5
7
|
function d(e = "") {
|
|
@@ -7,7 +9,7 @@ function d(e = "") {
|
|
|
7
9
|
return {
|
|
8
10
|
read() {
|
|
9
11
|
let e = window.location.pathname;
|
|
10
|
-
return t !== "" && e.startsWith(t) && (e = e.slice(t.length)), {
|
|
12
|
+
return t !== "" && (e === t || e.startsWith(`${t}/`)) && (e = e.slice(t.length)), {
|
|
11
13
|
path: e || "/",
|
|
12
14
|
search: window.location.search,
|
|
13
15
|
hash: window.location.hash
|
|
@@ -183,8 +185,21 @@ function w(e, t) {
|
|
|
183
185
|
return encodeURIComponent(String(r));
|
|
184
186
|
});
|
|
185
187
|
}
|
|
188
|
+
async function T(e) {
|
|
189
|
+
let t = [];
|
|
190
|
+
for (let n of _(e)) {
|
|
191
|
+
if (n.keys.includes("*")) continue;
|
|
192
|
+
if (n.keys.length === 0) {
|
|
193
|
+
t.push(n.path);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
let e = [...n.routes].reverse().find((e) => e.paths !== void 0);
|
|
197
|
+
if (e !== void 0) for (let r of await e.paths()) t.push(w(n.path, r));
|
|
198
|
+
}
|
|
199
|
+
return [...new Set(t)];
|
|
200
|
+
}
|
|
186
201
|
// src/router/scroll.ts
|
|
187
|
-
function
|
|
202
|
+
function E() {
|
|
188
203
|
let e = /* @__PURE__ */ new Map();
|
|
189
204
|
return "scrollRestoration" in window.history && (window.history.scrollRestoration = "manual"), {
|
|
190
205
|
save(t) {
|
|
@@ -195,7 +210,7 @@ function T() {
|
|
|
195
210
|
if (o !== void 0) window.scrollTo(o[0], o[1]);
|
|
196
211
|
else {
|
|
197
212
|
if (i !== "" && (r || a)) {
|
|
198
|
-
let e = document.getElementById(
|
|
213
|
+
let e = document.getElementById(D(i));
|
|
199
214
|
if (e !== null) {
|
|
200
215
|
e.scrollIntoView();
|
|
201
216
|
return;
|
|
@@ -206,7 +221,7 @@ function T() {
|
|
|
206
221
|
}
|
|
207
222
|
};
|
|
208
223
|
}
|
|
209
|
-
function
|
|
224
|
+
function D(e) {
|
|
210
225
|
try {
|
|
211
226
|
return decodeURIComponent(e.slice(1));
|
|
212
227
|
} catch {
|
|
@@ -214,100 +229,100 @@ function E(e) {
|
|
|
214
229
|
}
|
|
215
230
|
}
|
|
216
231
|
// src/router/router.ts
|
|
217
|
-
function
|
|
218
|
-
let u = typeof l.history == "object" ? l.history : l.history === "hash" ? f() : d(l.base),
|
|
232
|
+
function O(l) {
|
|
233
|
+
let u = typeof l.history == "object" ? l.history : l.history === "hash" ? f() : typeof window > "u" ? p() : d(l.base), g = o(), v = _(l.routes), b = t(u.read(), { equals: (e, t) => e.path === t.path && e.search === t.search && e.hash === t.hash }), T = t(!1), D = t(!1), O = /* @__PURE__ */ new Set(), M = 0, N = l.scroll ?? typeof window < "u" ? E() : null, P = u.key(), F = e(() => T() ? y(v, b().path) : null), I = e(() => F()?.params ?? {}, { equals: j }), L = e(() => S(x(F()), b().search), { equals: j }), R = (e, t) => {
|
|
219
234
|
let n = w(e, t?.params), r = t?.query ? C(t.query) : "", i = t?.hash ? `#${t.hash.replace(/^#/, "")}` : "";
|
|
220
235
|
return n + r + i;
|
|
221
236
|
};
|
|
222
|
-
function
|
|
223
|
-
let c = ++
|
|
224
|
-
d !== null &&
|
|
225
|
-
let
|
|
226
|
-
return
|
|
227
|
-
if (
|
|
228
|
-
let e = d.path !== l.path,
|
|
229
|
-
|
|
237
|
+
function z(e, t, o = 0) {
|
|
238
|
+
let c = ++M, l = m(e), d = s(T) ? s(b) : null, f = () => {
|
|
239
|
+
d !== null && N?.save(P), t === "push" ? u.push(e) : (t === "replace" || o > 0) && u.replace(e), P = u.key();
|
|
240
|
+
let i = P;
|
|
241
|
+
return r(() => {
|
|
242
|
+
if (D.set(!1), T.set(!0), b.set(u.read()), N !== null && d !== null) {
|
|
243
|
+
let e = d.path !== l.path, r = d.hash !== l.hash;
|
|
244
|
+
n(null, () => a(() => N.restore(i, t === "pop", e, l.hash, r)));
|
|
230
245
|
}
|
|
231
246
|
}), !0;
|
|
232
247
|
};
|
|
233
248
|
if (d !== null && d.path === l.path) return Promise.resolve(f());
|
|
234
|
-
let
|
|
249
|
+
let p = y(v, l.path), h = {
|
|
235
250
|
path: l.path,
|
|
236
|
-
route:
|
|
237
|
-
params:
|
|
251
|
+
route: p?.path ?? null,
|
|
252
|
+
params: p?.params ?? {},
|
|
238
253
|
search: l.search,
|
|
239
254
|
from: d?.path ?? null
|
|
240
|
-
},
|
|
241
|
-
if (d !== null) for (let e of
|
|
242
|
-
for (let e of
|
|
255
|
+
}, _ = [];
|
|
256
|
+
if (d !== null) for (let e of O) _.push(() => e(h));
|
|
257
|
+
for (let e of p?.routes ?? []) {
|
|
243
258
|
let t = e.guard;
|
|
244
|
-
t &&
|
|
259
|
+
t && _.push(() => t(h));
|
|
245
260
|
}
|
|
246
|
-
let
|
|
247
|
-
if (c !==
|
|
261
|
+
let x = (e) => {
|
|
262
|
+
if (c !== M) return !1;
|
|
248
263
|
if (e === !0) return f();
|
|
249
|
-
if (
|
|
250
|
-
if (
|
|
251
|
-
return
|
|
264
|
+
if (D.set(!1), typeof e == "string") {
|
|
265
|
+
if (o >= 10) throw Error("[keits/router] redirect loop");
|
|
266
|
+
return z(e, t === "pop" ? "replace" : t, o + 1);
|
|
252
267
|
}
|
|
253
|
-
return t === "pop" && d !== null && (u.push(d.path + d.search + d.hash),
|
|
254
|
-
},
|
|
255
|
-
c ===
|
|
268
|
+
return t === "pop" && d !== null && (u.push(d.path + d.search + d.hash), P = u.key()), !1;
|
|
269
|
+
}, S = (e) => {
|
|
270
|
+
c === M && D.set(!1);
|
|
256
271
|
try {
|
|
257
|
-
return
|
|
272
|
+
return i(e, g), Promise.resolve(!1);
|
|
258
273
|
} catch (e) {
|
|
259
274
|
return Promise.reject(e);
|
|
260
275
|
}
|
|
261
|
-
},
|
|
276
|
+
}, C = (e) => {
|
|
262
277
|
try {
|
|
263
|
-
return Promise.resolve(
|
|
278
|
+
return Promise.resolve(x(e));
|
|
264
279
|
} catch (e) {
|
|
265
|
-
return
|
|
280
|
+
return S(e);
|
|
266
281
|
}
|
|
267
|
-
},
|
|
282
|
+
}, w;
|
|
268
283
|
try {
|
|
269
|
-
|
|
284
|
+
w = k(_, 0);
|
|
270
285
|
} catch (e) {
|
|
271
|
-
return
|
|
286
|
+
return S(e);
|
|
272
287
|
}
|
|
273
|
-
return
|
|
288
|
+
return A(w) ? (D.set(!0), w.then(C, S)) : C(w);
|
|
274
289
|
}
|
|
275
|
-
let
|
|
290
|
+
let B = u.listen(() => {
|
|
276
291
|
let e = u.read();
|
|
277
|
-
|
|
278
|
-
}),
|
|
279
|
-
|
|
280
|
-
let
|
|
292
|
+
z(e.path + e.search + e.hash, "pop");
|
|
293
|
+
}), V = u.read();
|
|
294
|
+
z(V.path + V.search + V.hash, "start");
|
|
295
|
+
let H = (e) => {
|
|
281
296
|
let t = h(e, (e) => u.toAppUrl(e));
|
|
282
297
|
if (t === null) return;
|
|
283
298
|
e.preventDefault();
|
|
284
|
-
let n =
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
return
|
|
288
|
-
location: () =>
|
|
289
|
-
match: () =>
|
|
290
|
-
params: () =>
|
|
291
|
-
query: () =>
|
|
292
|
-
pending: () =>
|
|
293
|
-
navigate: (e, t) =>
|
|
294
|
-
href: (e, t) => u.href(
|
|
299
|
+
let n = s(b);
|
|
300
|
+
z(t, t === n.path + n.search + n.hash ? "replace" : "push");
|
|
301
|
+
}, U = l.links !== !1 && typeof document < "u";
|
|
302
|
+
return U && document.addEventListener("click", H), {
|
|
303
|
+
location: () => b(),
|
|
304
|
+
match: () => F(),
|
|
305
|
+
params: () => I(),
|
|
306
|
+
query: () => L(),
|
|
307
|
+
pending: () => D(),
|
|
308
|
+
navigate: (e, t) => z(e.includes(":") || t?.query || t?.hash ? R(e, t) : e, t?.replace ? "replace" : "push"),
|
|
309
|
+
href: (e, t) => u.href(R(e, t)),
|
|
295
310
|
setQuery(e, t) {
|
|
296
|
-
let n =
|
|
311
|
+
let n = s(b), r = {
|
|
297
312
|
...Object.fromEntries(new URLSearchParams(n.search)),
|
|
298
313
|
...e
|
|
299
314
|
};
|
|
300
|
-
|
|
315
|
+
z(n.path + C(r) + n.hash, t?.push ? "push" : "replace");
|
|
301
316
|
},
|
|
302
317
|
onLeave(e) {
|
|
303
|
-
|
|
318
|
+
O.add(e), c(() => O.delete(e));
|
|
304
319
|
},
|
|
305
320
|
view() {
|
|
306
321
|
let t = (n, r) => {
|
|
307
|
-
let
|
|
322
|
+
let i = e(() => F()?.routes[n] ?? null);
|
|
308
323
|
return () => {
|
|
309
|
-
let e =
|
|
310
|
-
return
|
|
324
|
+
let e = i();
|
|
325
|
+
return s(() => {
|
|
311
326
|
if (e === null) return r?.component ? r.component() : null;
|
|
312
327
|
let i = t(n + 1, e);
|
|
313
328
|
return e.layout ? e.layout({ children: i }) : i;
|
|
@@ -317,27 +332,27 @@ function D(l) {
|
|
|
317
332
|
return t(0, null);
|
|
318
333
|
},
|
|
319
334
|
isActive(e, t = !1) {
|
|
320
|
-
let n =
|
|
335
|
+
let n = b().path.replace(/\/$/, "") || "/", r = m(e).path.replace(/\/$/, "") || "/";
|
|
321
336
|
return t ? n === r : n === r || n.startsWith(`${r}/`);
|
|
322
337
|
},
|
|
323
338
|
dispose() {
|
|
324
|
-
|
|
339
|
+
B(), U && document.removeEventListener("click", H);
|
|
325
340
|
}
|
|
326
341
|
};
|
|
327
342
|
}
|
|
328
|
-
function
|
|
343
|
+
function k(e, t) {
|
|
329
344
|
for (let n = t; n < e.length; n++) {
|
|
330
345
|
let t = e[n]();
|
|
331
|
-
if (
|
|
346
|
+
if (A(t)) return Promise.resolve(t).then((t) => t === !0 ? k(e, n + 1) : t);
|
|
332
347
|
if (t !== !0) return t;
|
|
333
348
|
}
|
|
334
349
|
return !0;
|
|
335
350
|
}
|
|
336
|
-
function
|
|
351
|
+
function A(e) {
|
|
337
352
|
return typeof e?.then == "function";
|
|
338
353
|
}
|
|
339
|
-
function
|
|
354
|
+
function j(e, t) {
|
|
340
355
|
let n = Object.keys(e);
|
|
341
356
|
return n.length === Object.keys(t).length && n.every((n) => Object.is(e[n], t[n]));
|
|
342
357
|
}
|
|
343
|
-
export { d as browserHistory,
|
|
358
|
+
export { d as browserHistory, O as createRouter, f as hashHistory, p as memoryHistory, T as staticPaths };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { S as e, b as t, r as n } from "./graph-CR2WKbwr.js";
|
|
2
|
+
// src/core/computed.ts
|
|
3
|
+
function r(r, a) {
|
|
4
|
+
let o = {
|
|
5
|
+
kind: 2,
|
|
6
|
+
fn: r,
|
|
7
|
+
value: void 0,
|
|
8
|
+
equals: a?.equals ?? Object.is,
|
|
9
|
+
hasValue: !1,
|
|
10
|
+
hasError: !1,
|
|
11
|
+
error: void 0,
|
|
12
|
+
computing: !1,
|
|
13
|
+
state: 2,
|
|
14
|
+
sources: [],
|
|
15
|
+
observers: [],
|
|
16
|
+
seenBy: 0,
|
|
17
|
+
flushId: 0,
|
|
18
|
+
flushRuns: 0,
|
|
19
|
+
owner: null,
|
|
20
|
+
children: null,
|
|
21
|
+
cleanups: null,
|
|
22
|
+
disposed: !1
|
|
23
|
+
};
|
|
24
|
+
return n(o), () => {
|
|
25
|
+
if (o.computing) throw i(o);
|
|
26
|
+
if (o.state !== 0 && e(o), t(o), o.hasError) throw o.error;
|
|
27
|
+
return o.value;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function i(e) {
|
|
31
|
+
return /* @__PURE__ */ Error("[keits] cycle detected");
|
|
32
|
+
}
|
|
33
|
+
export { r as t };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { a as e, n as t } from "./namespaces-BSRrBJIU.js";
|
|
2
|
+
import { d as n, g as r, i, l as a, s as o } from "./graph-CR2WKbwr.js";
|
|
3
|
+
import { t as s } from "./unsafe-keys-C5PMlerl.js";
|
|
4
|
+
import { t as c } from "./render-effect-UFDi2Pfh.js";
|
|
5
|
+
// src/dom/events.ts
|
|
6
|
+
function l(e, t, r) {
|
|
7
|
+
let i = r, a;
|
|
8
|
+
if (Array.isArray(r) && ([i, a] = r), typeof i != "function") throw Error("[keits] bad handler");
|
|
9
|
+
n() || u(e, t.slice(2), i, a);
|
|
10
|
+
}
|
|
11
|
+
function u(e, t, n, s) {
|
|
12
|
+
let c = o();
|
|
13
|
+
e.addEventListener(t, (e) => {
|
|
14
|
+
i(() => {
|
|
15
|
+
try {
|
|
16
|
+
let t = r(c, () => n(e));
|
|
17
|
+
d(t) && t.then(void 0, (e) => i(() => a(e, c)));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
a(e, c);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}, s);
|
|
23
|
+
}
|
|
24
|
+
function d(e) {
|
|
25
|
+
return typeof e?.then == "function";
|
|
26
|
+
}
|
|
27
|
+
// src/dom/props.ts
|
|
28
|
+
var f = /* @__PURE__ */ new Set([
|
|
29
|
+
"innerhtml",
|
|
30
|
+
"outerhtml",
|
|
31
|
+
"srcdoc"
|
|
32
|
+
]), p = /* @__PURE__ */ new Set([
|
|
33
|
+
"href",
|
|
34
|
+
"src",
|
|
35
|
+
"action",
|
|
36
|
+
"formaction",
|
|
37
|
+
"poster",
|
|
38
|
+
"cite",
|
|
39
|
+
"data",
|
|
40
|
+
"xlink:href",
|
|
41
|
+
"to",
|
|
42
|
+
"from",
|
|
43
|
+
"values"
|
|
44
|
+
]), m = "about:invalid#keits-blocked";
|
|
45
|
+
function h(e, t) {
|
|
46
|
+
for (let n in t) {
|
|
47
|
+
let r = t[n];
|
|
48
|
+
n !== "ref" && (n === "class" ? b(e, r) : n === "style" ? w(e, r) : n.toLowerCase().startsWith("on") ? l(e, n, r) : typeof r == "function" ? c(() => g(e, n, r())) : g(e, n, r));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function g(e, t, r) {
|
|
52
|
+
let i = t.toLowerCase();
|
|
53
|
+
if (f.has(i) || s.has(t) || i.startsWith("on") && typeof r == "string") throw Error("[keits] unsafe prop");
|
|
54
|
+
p.has(i) && r != null && r !== !1 && _(String(r)) && (r = m), t in e && e.namespaceURI !== "http://www.w3.org/2000/svg" ? (e[t] = r, n() && v(e, t, r)) : t.startsWith("aria-") && typeof r == "boolean" ? e.setAttribute(t, String(r)) : r == null || r === !1 ? e.removeAttribute(t) : e.setAttribute(t, r === !0 ? "" : String(r));
|
|
55
|
+
}
|
|
56
|
+
function _(e) {
|
|
57
|
+
return e.replace(/[\u0000-\u0020]/g, "").toLowerCase().split(";").some((e) => e.startsWith("javascript:"));
|
|
58
|
+
}
|
|
59
|
+
function v(e, t, n) {
|
|
60
|
+
t === "value" ? e.localName === "textarea" ? e.textContent = n == null ? "" : String(n) : e.localName === "select" ? y(e, n == null ? "" : String(n)) : n == null ? e.removeAttribute("value") : e.setAttribute("value", String(n)) : (t === "checked" || t === "selected") && e.toggleAttribute(t, n === !0);
|
|
61
|
+
}
|
|
62
|
+
function y(e, t) {
|
|
63
|
+
for (let n = e.firstChild; n !== null; n = n.nextSibling) {
|
|
64
|
+
if (n.nodeType !== 1) continue;
|
|
65
|
+
let e = n;
|
|
66
|
+
e.localName === "option" ? e.toggleAttribute("selected", (e.getAttribute("value") ?? e.textContent) === t) : y(e, t);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function b(e, t) {
|
|
70
|
+
if (typeof t == "function") {
|
|
71
|
+
c(() => x(e, C(t())));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
let n = [], r = [];
|
|
75
|
+
S(t, n, (e, t) => r.push([e, t])), n.length > 0 && e.classList.add(...n);
|
|
76
|
+
for (let [t, n] of r) c(() => e.classList.toggle(t, n()));
|
|
77
|
+
}
|
|
78
|
+
function x(e, t) {
|
|
79
|
+
t === "" ? e.removeAttribute("class") : e.setAttribute("class", t);
|
|
80
|
+
}
|
|
81
|
+
function S(e, t, n) {
|
|
82
|
+
if (e) {
|
|
83
|
+
if (typeof e == "string") for (let n of e.split(/\s+/)) n && t.push(n);
|
|
84
|
+
else if (Array.isArray(e)) for (let r of e) S(r, t, n);
|
|
85
|
+
else for (let [r, i] of Object.entries(e)) typeof i == "function" ? n ? n(r, i) : i() && t.push(r) : i && t.push(r);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function C(e) {
|
|
89
|
+
let t = [];
|
|
90
|
+
return S(e, t), t.join(" ");
|
|
91
|
+
}
|
|
92
|
+
function w(e, t) {
|
|
93
|
+
let n = e.style;
|
|
94
|
+
if (typeof t == "function") {
|
|
95
|
+
let e = [];
|
|
96
|
+
c(() => {
|
|
97
|
+
let r = t();
|
|
98
|
+
if (typeof r == "string" || r == null) {
|
|
99
|
+
n.cssText = r ?? "", e = [];
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let i = Object.keys(r);
|
|
103
|
+
for (let t of e) t in r || n.removeProperty(t);
|
|
104
|
+
for (let e of i) E(n, e, T(r[e]));
|
|
105
|
+
e = i;
|
|
106
|
+
});
|
|
107
|
+
} else if (typeof t == "string") n.cssText = t;
|
|
108
|
+
else if (t != null) for (let [e, r] of Object.entries(t)) typeof r == "function" ? c(() => E(n, e, r())) : E(n, e, r);
|
|
109
|
+
}
|
|
110
|
+
function T(e) {
|
|
111
|
+
return typeof e == "function" ? e() : e;
|
|
112
|
+
}
|
|
113
|
+
function E(e, t, n) {
|
|
114
|
+
n == null || n === "" ? e.removeProperty(t) : e.setProperty(t, String(n));
|
|
115
|
+
}
|
|
116
|
+
// src/dom/element.ts
|
|
117
|
+
function D(e) {
|
|
118
|
+
return O(e, null);
|
|
119
|
+
}
|
|
120
|
+
function O(n, r) {
|
|
121
|
+
return (i, a) => {
|
|
122
|
+
let o = e.element(n, r);
|
|
123
|
+
return k(i) ? (t(o, a), h(o, i), typeof i.ref == "function" && i.ref(o)) : i == null ? t(o, a) : t(o, i), o;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function k(e) {
|
|
127
|
+
return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.nodeType != "number";
|
|
128
|
+
}
|
|
129
|
+
export { D as n, O as t };
|