@rhi-zone/rainbow-ui 0.2.0-alpha.3 → 0.2.0-alpha.5
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.js +45 -41
- package/dist/widget.d.ts +101 -11
- package/dist/widget.js +279 -216
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { above as
|
|
3
|
-
import { createForm as
|
|
1
|
+
import { h as l } from "./html-C8SnQjvU.js";
|
|
2
|
+
import { above as g, beside as p, bindAttr as f, bindCheckbox as x, bindClass as S, bindInput as w, bindSelect as W, bindShow as v, bindText as y, checkboxWidget as k, concat as C, dynamic as E, each as F, eachKeyed as A, focus as I, foldWidget as K, h as L, inputWidget as N, lift as B, map as D, match as J, mount as T, narrow as V, numberInputWidget as j, on as q, prop as z, register as G, selectWidget as H, show as M, slot as O, stack as P, subscribe as Q, subscribeNow as R, template as U, textareaWidget as X, watchAll as Y, withScope as Z } from "./widget.js";
|
|
3
|
+
import { createForm as $, createFormState as ee, isDirty as te, isFormValid as ne, shouldShowError as oe } from "./form-state.js";
|
|
4
4
|
import { signal as a } from "@rhi-zone/rainbow";
|
|
5
|
-
import { attrBoolean as
|
|
6
|
-
function d(e, n, t, r,
|
|
7
|
-
const
|
|
5
|
+
import { attrBoolean as re, attrJson as se, attrNumber as ae, attrString as ce, attrsFrom as de, defineElement as be } from "./elements.js";
|
|
6
|
+
function d(e, n, t, r, o) {
|
|
7
|
+
const i = e(
|
|
8
8
|
n,
|
|
9
9
|
() => r(t.get()),
|
|
10
|
-
|
|
10
|
+
o
|
|
11
11
|
), s = t.subscribe(() => {
|
|
12
12
|
});
|
|
13
13
|
return () => {
|
|
14
|
-
s(),
|
|
14
|
+
s(), i();
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
function b(e) {
|
|
18
18
|
const n = a(e.get());
|
|
19
|
-
function t(
|
|
20
|
-
const
|
|
21
|
-
n.set(
|
|
19
|
+
function t(o) {
|
|
20
|
+
const i = o;
|
|
21
|
+
n.set(i.detail.bindings);
|
|
22
22
|
}
|
|
23
23
|
return e.addEventListener("change", t), [n, () => e.removeEventListener("change", t)];
|
|
24
24
|
}
|
|
25
25
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
g as above,
|
|
27
|
+
re as attrBoolean,
|
|
28
|
+
se as attrJson,
|
|
29
|
+
ae as attrNumber,
|
|
30
|
+
ce as attrString,
|
|
31
|
+
de as attrsFrom,
|
|
32
32
|
p as beside,
|
|
33
33
|
f as bindAttr,
|
|
34
34
|
x as bindCheckbox,
|
|
@@ -40,34 +40,38 @@ export {
|
|
|
40
40
|
b as bindingsStoreSignal,
|
|
41
41
|
k as checkboxWidget,
|
|
42
42
|
C as concat,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
$ as createForm,
|
|
44
|
+
ee as createFormState,
|
|
45
|
+
be as defineElement,
|
|
46
46
|
E as dynamic,
|
|
47
47
|
F as each,
|
|
48
48
|
A as eachKeyed,
|
|
49
49
|
I as focus,
|
|
50
50
|
K as foldWidget,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
L as h,
|
|
52
|
+
l as html,
|
|
53
|
+
N as inputWidget,
|
|
54
|
+
te as isDirty,
|
|
55
|
+
ne as isFormValid,
|
|
55
56
|
d as keybindsContext,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
57
|
+
B as lift,
|
|
58
|
+
D as map,
|
|
59
|
+
J as match,
|
|
60
|
+
T as mount,
|
|
61
|
+
V as narrow,
|
|
62
|
+
j as numberInputWidget,
|
|
63
|
+
q as on,
|
|
64
|
+
z as prop,
|
|
65
|
+
G as register,
|
|
66
|
+
H as selectWidget,
|
|
67
|
+
oe as shouldShowError,
|
|
68
|
+
M as show,
|
|
69
|
+
O as slot,
|
|
70
|
+
P as stack,
|
|
71
|
+
Q as subscribe,
|
|
72
|
+
R as subscribeNow,
|
|
73
|
+
U as template,
|
|
74
|
+
X as textareaWidget,
|
|
75
|
+
Y as watchAll,
|
|
76
|
+
Z as withScope
|
|
73
77
|
};
|
package/dist/widget.d.ts
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* false and rebuild them when it becomes true again.
|
|
32
32
|
*/
|
|
33
33
|
import { type Signal, type ReadonlySignal, type Lens, type Prism, type AsyncData } from "@rhi-zone/rainbow";
|
|
34
|
-
import type { AnyEl, El, FlowContent, DivEl, InputEl, InputAttrs, TextareaEl, TextareaAttrs, SelectEl, SelectAttrs } from "./html.js";
|
|
34
|
+
import type { AnyEl, El, FlowContent, DivEl, InputEl, InputAttrs, TextareaEl, TextareaAttrs, SelectEl, SelectAttrs, GlobalAttrs } from "./html.js";
|
|
35
35
|
/**
|
|
36
36
|
* A widget is a pure function from a reactive signal to a typed DOM node.
|
|
37
37
|
* Calling a widget subscribes it to the signal; the returned node is updated
|
|
@@ -91,6 +91,16 @@ export declare function mount<T, E extends AnyEl>(widget: Widget<T, E>, signal:
|
|
|
91
91
|
* focus(opPicker, field('op'))
|
|
92
92
|
*/
|
|
93
93
|
export declare function focus<A, B, E extends AnyEl>(w: Widget<B, E>, l: Lens<A, B>): Widget<A, E>;
|
|
94
|
+
/**
|
|
95
|
+
* Sugar for `focus(w, field(key))`. Zoom into a named property of the signal.
|
|
96
|
+
* The most common use of `focus` — use this instead when the lens is a simple
|
|
97
|
+
* field access.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* prop(each(rowWidget), 'items') // Widget<{ items: Row[] }>
|
|
101
|
+
* prop(nameWidget, 'name') // Widget<{ name: string }>
|
|
102
|
+
*/
|
|
103
|
+
export declare function prop<T, K extends keyof T & string, E extends AnyEl>(w: Widget<T[K], E>, key: K): Widget<T, E>;
|
|
94
104
|
/**
|
|
95
105
|
* Zoom into a sum variant. The child widget renders when the prism matches;
|
|
96
106
|
* renders an empty container when it doesn't. Container switches on match
|
|
@@ -199,14 +209,21 @@ export type RefsMap<R extends Record<string, keyof HTMLElementTagNameMap>> = {
|
|
|
199
209
|
readonly [K in keyof R]: El<R[K] & string, HTMLElementTagNameMap[R[K]]>;
|
|
200
210
|
};
|
|
201
211
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
212
|
+
* **Performance escape hatch.** Prefer the reactive hyperscript factories
|
|
213
|
+
* (`h.div`, `h.span`, …) for normal widget authoring — they are type-safe,
|
|
214
|
+
* compose naturally with slots and combinators, and avoid the `data-ref`
|
|
215
|
+
* indirection.
|
|
216
|
+
*
|
|
217
|
+
* Use `template` only when instantiation count is high and the clone-vs-create
|
|
218
|
+
* difference is measurable: it parses `innerHTML` once at definition time and
|
|
219
|
+
* calls `cloneNode(true)` on each instantiation, which is faster than N
|
|
220
|
+
* `createElement` calls for large identical subtrees (e.g. a `eachKeyed` row
|
|
221
|
+
* with many static nodes).
|
|
205
222
|
*
|
|
206
223
|
* Refs are queried as `tagName[data-ref="refName"]`, so `{ name: "span" }`
|
|
207
224
|
* expects `<span data-ref="name">` in the template. Using `data-ref` rather
|
|
208
|
-
* than `id` means the same template can be cloned many times
|
|
209
|
-
*
|
|
225
|
+
* than `id` means the same template can be cloned many times without
|
|
226
|
+
* duplicate-ID issues.
|
|
210
227
|
*
|
|
211
228
|
* `bind` is called inside the widget call context, so any `subscribe` calls
|
|
212
229
|
* inside it are tracked and cleaned up by `mount` / parent combinators.
|
|
@@ -214,12 +231,11 @@ export type RefsMap<R extends Record<string, keyof HTMLElementTagNameMap>> = {
|
|
|
214
231
|
* @throws if a declared ref is absent from the cloned template.
|
|
215
232
|
*
|
|
216
233
|
* @example
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
234
|
+
* // High-volume row widget — justified use of template()
|
|
235
|
+
* const rowWidget = template(
|
|
236
|
+
* `<tr><td data-ref="name"></td><td data-ref="score"></td></tr>`,
|
|
237
|
+
* { name: "td", score: "td" } as const,
|
|
220
238
|
* (s, { name, score }) => {
|
|
221
|
-
* name.node.textContent = s.get().label
|
|
222
|
-
* score.node.textContent = String(s.get().value)
|
|
223
239
|
* subscribe(s, v => {
|
|
224
240
|
* name.node.textContent = v.label
|
|
225
241
|
* score.node.textContent = String(v.value)
|
|
@@ -441,4 +457,78 @@ export declare function selectWidget(options: {
|
|
|
441
457
|
value: string;
|
|
442
458
|
label: string;
|
|
443
459
|
}[], attrs?: SelectAttrs): Widget<string, SelectEl>;
|
|
460
|
+
/**
|
|
461
|
+
* A reactive child: either a plain string or a widget that accepts the same
|
|
462
|
+
* signal type `T` and returns any element.
|
|
463
|
+
*
|
|
464
|
+
* `AnyEl` is intentionally excluded. Passing a pre-built element directly would
|
|
465
|
+
* require `cloneNode(true)` on each widget invocation, silently dropping event
|
|
466
|
+
* listeners. Use `lift(el)` to wrap a freshly-built element instead.
|
|
467
|
+
*/
|
|
468
|
+
export type RChild<T> = string | Widget<T, AnyEl>;
|
|
469
|
+
/**
|
|
470
|
+
* Lift a static element into the widget context. Use this to pass a
|
|
471
|
+
* pre-built `AnyEl` as a child to an `h.*` reactive factory:
|
|
472
|
+
*
|
|
473
|
+
* h.div({}, lift(iconEl), reactiveChild)
|
|
474
|
+
*
|
|
475
|
+
* The element is inserted as-is — no cloning — so event listeners are
|
|
476
|
+
* preserved. Only use `lift` when the element is freshly built at widget
|
|
477
|
+
* call time (i.e. inside the widget function body). Do NOT lift a module-
|
|
478
|
+
* level static element — it can only have one parent at a time.
|
|
479
|
+
*/
|
|
480
|
+
export declare function lift<T, E extends AnyEl>(el: E): Widget<T, E>;
|
|
481
|
+
/**
|
|
482
|
+
* Reactive hyperscript factories — the same element tags as `html.ts` but
|
|
483
|
+
* returning `Widget<T, El>` instead of `El`. Import as:
|
|
484
|
+
*
|
|
485
|
+
* import { h } from '@rhi-zone/rainbow-ui/widget'
|
|
486
|
+
*
|
|
487
|
+
* Widget children receive the same signal as their parent. String children
|
|
488
|
+
* create fresh text nodes. To pass a pre-built element, wrap it with `lift(el)`
|
|
489
|
+
* so it is inserted directly without cloning — preserving event listeners.
|
|
490
|
+
*/
|
|
491
|
+
export declare const h: {
|
|
492
|
+
readonly div: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"div", HTMLDivElement>;
|
|
493
|
+
readonly section: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"section", HTMLElement>;
|
|
494
|
+
readonly article: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"article", HTMLElement>;
|
|
495
|
+
readonly header: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"header", HTMLElement>;
|
|
496
|
+
readonly footer: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"footer", HTMLElement>;
|
|
497
|
+
readonly main: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"main", HTMLElement>;
|
|
498
|
+
readonly nav: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"nav", HTMLElement>;
|
|
499
|
+
readonly h1: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"h1", HTMLHeadingElement>;
|
|
500
|
+
readonly h2: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"h2", HTMLHeadingElement>;
|
|
501
|
+
readonly h3: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"h3", HTMLHeadingElement>;
|
|
502
|
+
readonly h4: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"h4", HTMLHeadingElement>;
|
|
503
|
+
readonly h5: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"h5", HTMLHeadingElement>;
|
|
504
|
+
readonly h6: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"h6", HTMLHeadingElement>;
|
|
505
|
+
readonly p: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"p", HTMLParagraphElement>;
|
|
506
|
+
readonly span: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"span", HTMLSpanElement>;
|
|
507
|
+
readonly a: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"a", HTMLAnchorElement>;
|
|
508
|
+
readonly em: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"em", HTMLElement>;
|
|
509
|
+
readonly strong: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"strong", HTMLElement>;
|
|
510
|
+
readonly code: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"code", HTMLElement>;
|
|
511
|
+
readonly pre: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"pre", HTMLPreElement>;
|
|
512
|
+
readonly ul: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"ul", HTMLUListElement>;
|
|
513
|
+
readonly ol: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"ol", HTMLOListElement>;
|
|
514
|
+
readonly li: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"li", HTMLLIElement>;
|
|
515
|
+
readonly button: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"button", HTMLButtonElement>;
|
|
516
|
+
readonly label: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"label", HTMLLabelElement>;
|
|
517
|
+
readonly form: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"form", HTMLFormElement>;
|
|
518
|
+
readonly fieldset: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"fieldset", HTMLFieldSetElement>;
|
|
519
|
+
};
|
|
520
|
+
/** A widget that takes no meaningful signal and renders flow content. */
|
|
521
|
+
export type Slot = Widget<void, FlowContent>;
|
|
522
|
+
/** A widget that takes a typed signal `T` and renders flow content. */
|
|
523
|
+
export type ScopedSlot<T> = Widget<T, FlowContent>;
|
|
524
|
+
/**
|
|
525
|
+
* Mount a slot widget by replacing a placeholder element.
|
|
526
|
+
* If no slot is provided, removes the placeholder.
|
|
527
|
+
* The slot signal defaults to `s` (cast) if `slotSignal` is omitted.
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* slot(placeholder, s, v => v.actionsSlot) // slot signal = s
|
|
531
|
+
* slot(placeholder, s, v => v.rowSlot, s.focus(rowLens)) // slot signal = focused
|
|
532
|
+
*/
|
|
533
|
+
export declare function slot<Props, T>(placeholder: HTMLElement, s: Signal<Props>, extract: (props: Props) => Widget<T, FlowContent> | undefined, slotSignal?: Signal<T>): void;
|
|
444
534
|
export {};
|
package/dist/widget.js
CHANGED
|
@@ -1,144 +1,147 @@
|
|
|
1
|
-
import { index as
|
|
2
|
-
import { i as
|
|
1
|
+
import { index as E, stateful as L, field as W, lens as B, tagged as $, signal as j } from "@rhi-zone/rainbow";
|
|
2
|
+
import { i as _, s as F, o as I, t as O } from "./html-C8SnQjvU.js";
|
|
3
3
|
let k = null;
|
|
4
|
-
function
|
|
4
|
+
function l(e) {
|
|
5
5
|
k == null || k.push(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const
|
|
7
|
+
function m(e) {
|
|
8
|
+
const t = k, o = [];
|
|
9
9
|
k = o;
|
|
10
|
-
const
|
|
11
|
-
return k =
|
|
10
|
+
const n = e();
|
|
11
|
+
return k = t, [n, () => {
|
|
12
12
|
for (const c of o) c();
|
|
13
13
|
}];
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function V(e) {
|
|
16
|
+
return m(e);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
18
|
+
function w(e, t) {
|
|
19
|
+
l(e.subscribe(t));
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
21
|
+
function H(e) {
|
|
22
|
+
l(e);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const [
|
|
26
|
-
return o.appendChild(
|
|
27
|
-
|
|
24
|
+
function R(e, t, o) {
|
|
25
|
+
const [n, c] = m(() => e(t));
|
|
26
|
+
return o.appendChild(n.node), () => {
|
|
27
|
+
n.node.remove(), c();
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return (o) => e(o.focus(
|
|
30
|
+
function P(e, t) {
|
|
31
|
+
return (o) => e(o.focus(t));
|
|
32
|
+
}
|
|
33
|
+
function U(e, t) {
|
|
34
|
+
return P(e, W(t));
|
|
32
35
|
}
|
|
33
|
-
function
|
|
36
|
+
function z(e, t) {
|
|
34
37
|
return (o) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
38
|
+
const n = document.createElement("div");
|
|
39
|
+
n.dataset.narrow = "";
|
|
37
40
|
let c = null, r = null;
|
|
38
41
|
const u = o, d = () => {
|
|
39
|
-
r = u.narrow(
|
|
40
|
-
const [a,
|
|
41
|
-
c =
|
|
42
|
+
r = u.narrow(t);
|
|
43
|
+
const [a, f] = m(() => e(r));
|
|
44
|
+
c = f, n.appendChild(a.node);
|
|
42
45
|
};
|
|
43
|
-
return
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}),
|
|
46
|
+
return w(o, (a) => {
|
|
47
|
+
const f = t.view(a);
|
|
48
|
+
f !== void 0 && c === null ? d() : f === void 0 && c !== null && (c(), c = null, r = null, n.replaceChildren());
|
|
49
|
+
}), t.view(o.get()) !== void 0 && d(), l(() => c == null ? void 0 : c()), { _tag: "div", node: n };
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
|
-
function
|
|
50
|
-
return (
|
|
51
|
-
const o =
|
|
52
|
-
|
|
52
|
+
function D(e) {
|
|
53
|
+
return (t) => {
|
|
54
|
+
const o = t, n = document.createElement("div");
|
|
55
|
+
n.dataset.each = "";
|
|
53
56
|
let c = [];
|
|
54
57
|
const r = (d) => {
|
|
55
58
|
for (const s of c) s();
|
|
56
|
-
c = [],
|
|
59
|
+
c = [], n.replaceChildren();
|
|
57
60
|
for (let s = 0; s < d.length; s++) {
|
|
58
|
-
const a = s,
|
|
59
|
-
(
|
|
60
|
-
(
|
|
61
|
-
const
|
|
62
|
-
return
|
|
61
|
+
const a = s, f = B(
|
|
62
|
+
(p) => p[a],
|
|
63
|
+
(p, h) => {
|
|
64
|
+
const g = [...h];
|
|
65
|
+
return g[a] = p, g;
|
|
63
66
|
}
|
|
64
|
-
),
|
|
65
|
-
c.push(
|
|
67
|
+
), b = o.focus(f), [v, C] = m(() => e(b));
|
|
68
|
+
c.push(C), n.appendChild(v.node);
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
|
-
r(
|
|
69
|
-
const u =
|
|
70
|
-
return
|
|
71
|
+
r(t.get());
|
|
72
|
+
const u = t.map((d) => d.length);
|
|
73
|
+
return w(u, () => r(t.get())), l(() => {
|
|
71
74
|
for (const d of c) d();
|
|
72
|
-
}), { _tag: "div", node:
|
|
75
|
+
}), { _tag: "div", node: n };
|
|
73
76
|
};
|
|
74
77
|
}
|
|
75
|
-
function
|
|
78
|
+
function G(e, t) {
|
|
76
79
|
return (o) => {
|
|
77
|
-
const
|
|
80
|
+
const n = o, c = document.createElement("div");
|
|
78
81
|
c.dataset.beside = "";
|
|
79
|
-
const r =
|
|
80
|
-
return c.appendChild(d.node), c.appendChild(a.node),
|
|
82
|
+
const r = n.focus(E(0)), u = n.focus(E(1)), [d, s] = m(() => e(r)), [a, f] = m(() => t(u));
|
|
83
|
+
return c.appendChild(d.node), c.appendChild(a.node), l(s), l(f), { _tag: "div", node: c };
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
|
-
function
|
|
86
|
+
function J(e, t) {
|
|
84
87
|
return (o) => {
|
|
85
|
-
const
|
|
88
|
+
const n = o, c = document.createElement("div");
|
|
86
89
|
c.dataset.above = "";
|
|
87
|
-
const r =
|
|
88
|
-
return c.appendChild(d.node), c.appendChild(a.node),
|
|
90
|
+
const r = n.focus(E(0)), u = n.focus(E(1)), [d, s] = m(() => e(r)), [a, f] = m(() => t(u));
|
|
91
|
+
return c.appendChild(d.node), c.appendChild(a.node), l(s), l(f), { _tag: "div", node: c };
|
|
89
92
|
};
|
|
90
93
|
}
|
|
91
|
-
function
|
|
94
|
+
function Q(e, t) {
|
|
92
95
|
return (o) => {
|
|
93
|
-
const
|
|
94
|
-
return n
|
|
96
|
+
const n = L(e, o);
|
|
97
|
+
return t(n);
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
|
-
function
|
|
100
|
+
function X(e, t) {
|
|
98
101
|
return (o) => {
|
|
99
|
-
const
|
|
100
|
-
return e(
|
|
102
|
+
const n = o.narrow(t);
|
|
103
|
+
return e(n);
|
|
101
104
|
};
|
|
102
105
|
}
|
|
103
|
-
function
|
|
106
|
+
function Y(e, t) {
|
|
104
107
|
return (o) => {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const [c, r] =
|
|
108
|
-
|
|
108
|
+
const n = document.createElement("div");
|
|
109
|
+
n.dataset.show = "";
|
|
110
|
+
const [c, r] = m(() => e(o));
|
|
111
|
+
n.appendChild(c.node), l(r);
|
|
109
112
|
const u = (d) => {
|
|
110
|
-
|
|
113
|
+
n.style.display = t(d) ? "" : "none";
|
|
111
114
|
};
|
|
112
|
-
return u(o.get()),
|
|
115
|
+
return u(o.get()), w(o, u), { _tag: "div", node: n };
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
|
-
function
|
|
118
|
+
function Z(e, t) {
|
|
116
119
|
return (o) => {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
const [c, r] =
|
|
120
|
-
return
|
|
120
|
+
const n = document.createElement("div");
|
|
121
|
+
n.dataset.concat = "";
|
|
122
|
+
const [c, r] = m(() => e(o)), [u, d] = m(() => t(o));
|
|
123
|
+
return n.appendChild(c.node), n.appendChild(u.node), l(r), l(d), { _tag: "div", node: n };
|
|
121
124
|
};
|
|
122
125
|
}
|
|
123
|
-
function
|
|
124
|
-
return (
|
|
126
|
+
function ee(...e) {
|
|
127
|
+
return (t) => {
|
|
125
128
|
const o = document.createElement("div");
|
|
126
129
|
o.dataset.stack = "";
|
|
127
|
-
for (const
|
|
128
|
-
const [c, r] =
|
|
129
|
-
o.appendChild(c.node),
|
|
130
|
+
for (const n of e) {
|
|
131
|
+
const [c, r] = m(() => n(t));
|
|
132
|
+
o.appendChild(c.node), l(r);
|
|
130
133
|
}
|
|
131
134
|
return { _tag: "div", node: o };
|
|
132
135
|
};
|
|
133
136
|
}
|
|
134
|
-
function
|
|
135
|
-
const
|
|
136
|
-
return
|
|
137
|
+
function te(e, t, o) {
|
|
138
|
+
const n = document.createElement("template");
|
|
139
|
+
return n.innerHTML = e, (c) => {
|
|
137
140
|
const r = document.createElement("div");
|
|
138
|
-
r.dataset.templ = "", r.appendChild(
|
|
141
|
+
r.dataset.templ = "", r.appendChild(n.content.cloneNode(!0));
|
|
139
142
|
const u = {};
|
|
140
|
-
for (const d of Object.keys(
|
|
141
|
-
const s =
|
|
143
|
+
for (const d of Object.keys(t)) {
|
|
144
|
+
const s = t[d], a = r.querySelector(`${s}[data-ref="${d}"]`);
|
|
142
145
|
if (a === null)
|
|
143
146
|
throw new Error(
|
|
144
147
|
`templ: ref "${d}" not found — expected <${s} data-ref="${d}"> in template`
|
|
@@ -148,221 +151,281 @@ function Y(e, n, o) {
|
|
|
148
151
|
return o(c, u), { _tag: "div", node: r };
|
|
149
152
|
};
|
|
150
153
|
}
|
|
151
|
-
function
|
|
152
|
-
const c = (
|
|
154
|
+
function ne(e, t, o, n) {
|
|
155
|
+
const c = (n == null ? void 0 : n.container) ?? "div", r = document.createElement(c);
|
|
153
156
|
r.dataset.eachKeyed = "";
|
|
154
|
-
const u = /* @__PURE__ */ new Map(), d = (a,
|
|
155
|
-
const
|
|
156
|
-
let
|
|
157
|
+
const u = /* @__PURE__ */ new Map(), d = (a, f) => {
|
|
158
|
+
const b = j(f);
|
|
159
|
+
let v = !1, C = () => {
|
|
157
160
|
};
|
|
158
|
-
"set" in e && (
|
|
159
|
-
if (
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
const y = [...
|
|
163
|
-
y[
|
|
161
|
+
"set" in e && (C = b.subscribe((g) => {
|
|
162
|
+
if (v) return;
|
|
163
|
+
const x = e.get(), N = x.findIndex((y) => t(y) === a);
|
|
164
|
+
if (N !== -1 && !Object.is(x[N], g)) {
|
|
165
|
+
const y = [...x];
|
|
166
|
+
y[N] = g, e.set(y);
|
|
164
167
|
}
|
|
165
168
|
}));
|
|
166
|
-
const [
|
|
169
|
+
const [p, h] = m(() => o(b));
|
|
167
170
|
return {
|
|
168
|
-
itemSignal:
|
|
169
|
-
childNode:
|
|
171
|
+
itemSignal: b,
|
|
172
|
+
childNode: p.node,
|
|
170
173
|
cleanup: () => {
|
|
171
|
-
|
|
174
|
+
h(), C();
|
|
172
175
|
},
|
|
173
|
-
setFromParent: (
|
|
174
|
-
|
|
176
|
+
setFromParent: (g) => {
|
|
177
|
+
v = !0, b.set(g), v = !1;
|
|
175
178
|
}
|
|
176
179
|
};
|
|
177
180
|
}, s = (a) => {
|
|
178
|
-
var
|
|
179
|
-
const
|
|
180
|
-
for (const [
|
|
181
|
-
|
|
182
|
-
for (let
|
|
183
|
-
const
|
|
184
|
-
u.has(
|
|
181
|
+
var C;
|
|
182
|
+
const f = a.map(t), b = new Set(f);
|
|
183
|
+
for (const [p, h] of u)
|
|
184
|
+
b.has(p) || (h.cleanup(), (C = h.childNode.parentNode) == null || C.removeChild(h.childNode), u.delete(p));
|
|
185
|
+
for (let p = 0; p < a.length; p++) {
|
|
186
|
+
const h = f[p], g = a[p];
|
|
187
|
+
u.has(h) ? u.get(h).setFromParent(g) : u.set(h, d(h, g));
|
|
185
188
|
}
|
|
186
|
-
let
|
|
187
|
-
for (let
|
|
188
|
-
const
|
|
189
|
-
(
|
|
189
|
+
let v = null;
|
|
190
|
+
for (let p = a.length - 1; p >= 0; p--) {
|
|
191
|
+
const h = u.get(f[p]);
|
|
192
|
+
(h.childNode.parentNode !== r || h.childNode.nextSibling !== v) && r.insertBefore(h.childNode, v), v = h.childNode;
|
|
190
193
|
}
|
|
191
194
|
};
|
|
192
|
-
return s(e.get()),
|
|
195
|
+
return s(e.get()), w(e, s), l(() => {
|
|
193
196
|
for (const a of u.values()) a.cleanup();
|
|
194
197
|
}), { _tag: c, node: r };
|
|
195
198
|
}
|
|
196
|
-
function
|
|
197
|
-
const
|
|
198
|
-
e.addEventListener(
|
|
199
|
+
function A(e, t, o) {
|
|
200
|
+
const n = o;
|
|
201
|
+
e.addEventListener(t, n), l(() => e.removeEventListener(t, n));
|
|
199
202
|
}
|
|
200
|
-
function
|
|
201
|
-
e.value =
|
|
202
|
-
const o = () =>
|
|
203
|
+
function S(e, t) {
|
|
204
|
+
e.value = t.get();
|
|
205
|
+
const o = () => t.set(e.value);
|
|
203
206
|
e.addEventListener("input", o);
|
|
204
|
-
const
|
|
207
|
+
const n = t.subscribe((r) => {
|
|
205
208
|
e.value !== r && (e.value = r);
|
|
206
209
|
}), c = () => {
|
|
207
|
-
e.removeEventListener("input", o),
|
|
210
|
+
e.removeEventListener("input", o), n();
|
|
208
211
|
};
|
|
209
|
-
return
|
|
212
|
+
return l(c), c;
|
|
210
213
|
}
|
|
211
|
-
function
|
|
212
|
-
|
|
214
|
+
function T(e, t) {
|
|
215
|
+
A(e, "change", () => t.set(e.value)), w(t, (o) => {
|
|
213
216
|
e.value !== o && (e.value = o);
|
|
214
217
|
});
|
|
215
218
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
219
|
+
function q(e, t) {
|
|
220
|
+
A(e, "change", () => t.set(e.checked)), w(t, (o) => {
|
|
218
221
|
e.checked !== o && (e.checked = o);
|
|
219
222
|
});
|
|
220
223
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
224
|
+
function oe(e, t) {
|
|
225
|
+
t(e.get()), l(e.subscribe(t));
|
|
223
226
|
}
|
|
224
|
-
function
|
|
225
|
-
e.textContent =
|
|
227
|
+
function ce(e, t) {
|
|
228
|
+
e.textContent = t.get(), l(t.subscribe((o) => {
|
|
226
229
|
e.textContent = o;
|
|
227
230
|
}));
|
|
228
231
|
}
|
|
229
|
-
function
|
|
230
|
-
e.setAttribute(
|
|
231
|
-
e.setAttribute(
|
|
232
|
+
function re(e, t, o) {
|
|
233
|
+
e.setAttribute(t, o.get()), l(o.subscribe((n) => {
|
|
234
|
+
e.setAttribute(t, n);
|
|
232
235
|
}));
|
|
233
236
|
}
|
|
234
|
-
function
|
|
235
|
-
e.classList.toggle(
|
|
236
|
-
e.classList.toggle(
|
|
237
|
+
function ue(e, t, o) {
|
|
238
|
+
e.classList.toggle(t, o.get()), l(o.subscribe((n) => {
|
|
239
|
+
e.classList.toggle(t, n);
|
|
237
240
|
}));
|
|
238
241
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
const o = e.map((
|
|
242
|
+
function de(e, t) {
|
|
243
|
+
t();
|
|
244
|
+
const o = e.map((n) => n.subscribe(t));
|
|
242
245
|
return () => {
|
|
243
|
-
for (const
|
|
246
|
+
for (const n of o) n();
|
|
244
247
|
};
|
|
245
248
|
}
|
|
246
|
-
function
|
|
247
|
-
return e.style.display =
|
|
249
|
+
function ie(e, t) {
|
|
250
|
+
return e.style.display = t.get() ? "" : "none", t.subscribe((o) => {
|
|
248
251
|
e.style.display = o ? "" : "none";
|
|
249
252
|
});
|
|
250
253
|
}
|
|
251
|
-
function
|
|
254
|
+
function ae(e, t) {
|
|
252
255
|
return (o) => {
|
|
253
|
-
const
|
|
254
|
-
|
|
256
|
+
const n = document.createElement("div");
|
|
257
|
+
n.dataset.match = "";
|
|
255
258
|
let c = null, r = null;
|
|
256
259
|
const u = (d) => {
|
|
257
260
|
const s = d[e];
|
|
258
261
|
if (s === r) return;
|
|
259
|
-
c == null || c(), c = null,
|
|
260
|
-
const a =
|
|
262
|
+
c == null || c(), c = null, n.replaceChildren(), r = s;
|
|
263
|
+
const a = t[s];
|
|
261
264
|
if (a == null) return;
|
|
262
|
-
const
|
|
263
|
-
let
|
|
264
|
-
[
|
|
265
|
-
() => a(
|
|
266
|
-
),
|
|
265
|
+
const f = o.narrow($(e, s));
|
|
266
|
+
let b;
|
|
267
|
+
[b, c] = m(
|
|
268
|
+
() => a(f)
|
|
269
|
+
), n.appendChild(b.node);
|
|
267
270
|
};
|
|
268
|
-
return
|
|
271
|
+
return w(o, u), u(o.get()), l(() => c == null ? void 0 : c()), { _tag: "div", node: n };
|
|
269
272
|
};
|
|
270
273
|
}
|
|
271
|
-
function
|
|
274
|
+
function se(e, t) {
|
|
272
275
|
const o = document.createElement("div");
|
|
273
276
|
o.dataset.foldWidget = "";
|
|
274
|
-
let
|
|
277
|
+
let n = null;
|
|
275
278
|
const c = (r) => {
|
|
276
|
-
|
|
279
|
+
n !== null && (n(), n = null), o.replaceChildren();
|
|
277
280
|
let u = null;
|
|
278
281
|
switch (r.status) {
|
|
279
282
|
case "notAsked":
|
|
280
|
-
u =
|
|
283
|
+
u = t.notAsked ?? null;
|
|
281
284
|
break;
|
|
282
285
|
case "loading":
|
|
283
|
-
u =
|
|
286
|
+
u = t.loading ?? null;
|
|
284
287
|
break;
|
|
285
288
|
case "failure":
|
|
286
|
-
u =
|
|
289
|
+
u = t.failure ? () => t.failure(r.error) : null;
|
|
287
290
|
break;
|
|
288
291
|
case "success":
|
|
289
|
-
u =
|
|
292
|
+
u = t.success ? () => t.success(r.value) : null;
|
|
290
293
|
break;
|
|
291
294
|
}
|
|
292
295
|
if (u !== null) {
|
|
293
296
|
let d;
|
|
294
|
-
[d,
|
|
297
|
+
[d, n] = m(u), o.appendChild(d.node);
|
|
295
298
|
}
|
|
296
299
|
};
|
|
297
|
-
return c(e.get()),
|
|
300
|
+
return c(e.get()), l(e.subscribe(c)), l(() => n == null ? void 0 : n()), { _tag: "div", node: o };
|
|
298
301
|
}
|
|
299
|
-
function
|
|
300
|
-
return (
|
|
301
|
-
const o =
|
|
302
|
-
return
|
|
302
|
+
function le(e) {
|
|
303
|
+
return (t) => {
|
|
304
|
+
const o = t, n = _(e ?? {});
|
|
305
|
+
return n.node.value = o.get(), S(n.node, o), n;
|
|
303
306
|
};
|
|
304
307
|
}
|
|
305
|
-
function
|
|
306
|
-
return (
|
|
307
|
-
const o =
|
|
308
|
-
return
|
|
308
|
+
function fe(e) {
|
|
309
|
+
return (t) => {
|
|
310
|
+
const o = t, n = O(e ?? {});
|
|
311
|
+
return n.node.value = o.get(), S(n.node, o), n;
|
|
309
312
|
};
|
|
310
313
|
}
|
|
311
|
-
function
|
|
312
|
-
return (
|
|
313
|
-
const o =
|
|
314
|
-
return
|
|
314
|
+
function pe(e) {
|
|
315
|
+
return (t) => {
|
|
316
|
+
const o = t, n = _({ ...e, type: "checkbox" });
|
|
317
|
+
return n.node.checked = o.get(), q(n.node, o), n;
|
|
315
318
|
};
|
|
316
319
|
}
|
|
317
|
-
function
|
|
318
|
-
return (
|
|
319
|
-
const o =
|
|
320
|
-
return
|
|
321
|
-
const c =
|
|
320
|
+
function he(e) {
|
|
321
|
+
return (t) => {
|
|
322
|
+
const o = t, n = _({ ...e, type: "number" });
|
|
323
|
+
return n.node.value = String(o.get()), A(n.node, "input", () => {
|
|
324
|
+
const c = n.node.valueAsNumber;
|
|
322
325
|
isNaN(c) || o.set(c);
|
|
323
|
-
}),
|
|
324
|
-
|
|
325
|
-
}),
|
|
326
|
+
}), w(t, (c) => {
|
|
327
|
+
n.node.valueAsNumber !== c && (n.node.value = String(c));
|
|
328
|
+
}), n;
|
|
326
329
|
};
|
|
327
330
|
}
|
|
328
|
-
function
|
|
331
|
+
function me(e, t) {
|
|
329
332
|
return (o) => {
|
|
330
|
-
const
|
|
331
|
-
return c.node.value =
|
|
333
|
+
const n = o, c = F(t ?? {}, ...e.map((r) => I({ value: r.value }, r.label)));
|
|
334
|
+
return c.node.value = n.get(), T(c.node, n), c;
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function be(e) {
|
|
338
|
+
return (t) => e;
|
|
339
|
+
}
|
|
340
|
+
function i(e) {
|
|
341
|
+
return (t, ...o) => (n) => {
|
|
342
|
+
const c = document.createElement(e);
|
|
343
|
+
for (const [r, u] of Object.entries(t))
|
|
344
|
+
u == null || u === !1 || c.setAttribute(r, u === !0 ? "" : String(u));
|
|
345
|
+
for (const r of o)
|
|
346
|
+
typeof r == "function" ? c.appendChild(r(n).node) : c.appendChild(document.createTextNode(r));
|
|
347
|
+
return { _tag: e, node: c };
|
|
332
348
|
};
|
|
333
349
|
}
|
|
350
|
+
const ge = {
|
|
351
|
+
// Sectioning / flow
|
|
352
|
+
div: i("div"),
|
|
353
|
+
section: i("section"),
|
|
354
|
+
article: i("article"),
|
|
355
|
+
header: i("header"),
|
|
356
|
+
footer: i("footer"),
|
|
357
|
+
main: i("main"),
|
|
358
|
+
nav: i("nav"),
|
|
359
|
+
// Headings
|
|
360
|
+
h1: i("h1"),
|
|
361
|
+
h2: i("h2"),
|
|
362
|
+
h3: i("h3"),
|
|
363
|
+
h4: i("h4"),
|
|
364
|
+
h5: i("h5"),
|
|
365
|
+
h6: i("h6"),
|
|
366
|
+
// Phrasing
|
|
367
|
+
p: i("p"),
|
|
368
|
+
span: i("span"),
|
|
369
|
+
a: i("a"),
|
|
370
|
+
em: i("em"),
|
|
371
|
+
strong: i("strong"),
|
|
372
|
+
code: i("code"),
|
|
373
|
+
pre: i("pre"),
|
|
374
|
+
// Lists
|
|
375
|
+
ul: i("ul"),
|
|
376
|
+
ol: i("ol"),
|
|
377
|
+
li: i("li"),
|
|
378
|
+
// Forms
|
|
379
|
+
button: i("button"),
|
|
380
|
+
label: i("label"),
|
|
381
|
+
form: i("form"),
|
|
382
|
+
fieldset: i("fieldset")
|
|
383
|
+
};
|
|
384
|
+
function ve(e, t, o, n) {
|
|
385
|
+
const c = o(t.get());
|
|
386
|
+
if (c === void 0) {
|
|
387
|
+
e.remove();
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const r = c(n ?? t);
|
|
391
|
+
e.replaceWith(r.node);
|
|
392
|
+
}
|
|
334
393
|
export {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
394
|
+
J as above,
|
|
395
|
+
G as beside,
|
|
396
|
+
re as bindAttr,
|
|
397
|
+
q as bindCheckbox,
|
|
398
|
+
ue as bindClass,
|
|
399
|
+
S as bindInput,
|
|
400
|
+
T as bindSelect,
|
|
401
|
+
ie as bindShow,
|
|
402
|
+
ce as bindText,
|
|
403
|
+
pe as checkboxWidget,
|
|
404
|
+
Z as concat,
|
|
405
|
+
Q as dynamic,
|
|
406
|
+
D as each,
|
|
407
|
+
ne as eachKeyed,
|
|
408
|
+
P as focus,
|
|
409
|
+
se as foldWidget,
|
|
410
|
+
ge as h,
|
|
411
|
+
le as inputWidget,
|
|
412
|
+
be as lift,
|
|
413
|
+
X as map,
|
|
414
|
+
ae as match,
|
|
415
|
+
R as mount,
|
|
416
|
+
z as narrow,
|
|
417
|
+
he as numberInputWidget,
|
|
418
|
+
A as on,
|
|
419
|
+
U as prop,
|
|
420
|
+
H as register,
|
|
421
|
+
me as selectWidget,
|
|
422
|
+
Y as show,
|
|
423
|
+
ve as slot,
|
|
424
|
+
ee as stack,
|
|
425
|
+
w as subscribe,
|
|
426
|
+
oe as subscribeNow,
|
|
427
|
+
te as template,
|
|
428
|
+
fe as textareaWidget,
|
|
429
|
+
de as watchAll,
|
|
430
|
+
V as withScope
|
|
368
431
|
};
|