@rhi-zone/rainbow-ui 0.2.0-alpha.1 → 0.2.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements.d.ts +15 -3
- package/dist/elements.js +47 -35
- package/dist/index.d.ts +1 -1
- package/dist/index.js +31 -30
- package/dist/widget.d.ts +24 -0
- package/dist/widget.js +223 -202
- package/package.json +1 -1
package/dist/elements.d.ts
CHANGED
|
@@ -18,15 +18,27 @@ import type { Optic } from "@rhi-zone/rainbow";
|
|
|
18
18
|
import type { AnyEl } from "./html.js";
|
|
19
19
|
import type { Widget } from "./widget.js";
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* An entry in `AttrSchema<T>`. Either a plain optic (attribute name = prop name)
|
|
22
|
+
* or a named entry `{ name, optic }` where `name` is the HTML attribute name
|
|
23
|
+
* (e.g. `"requires-review"`) and the TypeScript key remains the camelCase prop.
|
|
23
24
|
*
|
|
24
25
|
* - `optic.view(raw)` — parse attribute string into `T[K]`;
|
|
25
26
|
* `undefined` means use `defaults[K]`
|
|
26
27
|
* - `optic.review(v, _)` — serialise `T[K]` back to a string for reflection
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Simple: attr name = prop name
|
|
31
|
+
* attrs: { label: attrString, score: attrNumber }
|
|
32
|
+
*
|
|
33
|
+
* // Alias: HTML "requires-review" → TS prop "requiresReview"
|
|
34
|
+
* attrs: { requiresReview: { name: "requires-review", optic: attrBoolean } }
|
|
27
35
|
*/
|
|
36
|
+
export type AttrEntry<V> = Optic<string | null, V> | {
|
|
37
|
+
name: string;
|
|
38
|
+
optic: Optic<string | null, V>;
|
|
39
|
+
};
|
|
28
40
|
export type AttrSchema<T> = {
|
|
29
|
-
[K in keyof T]?:
|
|
41
|
+
[K in keyof T]?: AttrEntry<T[K]>;
|
|
30
42
|
};
|
|
31
43
|
/**
|
|
32
44
|
* Pass-through: `view` returns the raw string, or `undefined` when absent.
|
package/dist/elements.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { signal as
|
|
5
|
-
import { mount as
|
|
6
|
-
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var S = (t, e, n) => e in t ? v(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var f = (t, e, n) => S(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { signal as w } from "@rhi-zone/rainbow";
|
|
5
|
+
import { mount as k } from "./widget.js";
|
|
6
|
+
function N(t, e) {
|
|
7
|
+
if ("name" in e && typeof e.name == "string") {
|
|
8
|
+
const n = e;
|
|
9
|
+
return { attrName: n.name, optic: n.optic };
|
|
10
|
+
}
|
|
11
|
+
return { attrName: t, optic: e };
|
|
12
|
+
}
|
|
13
|
+
const O = {
|
|
7
14
|
view(t) {
|
|
8
15
|
return t ?? void 0;
|
|
9
16
|
},
|
|
10
17
|
review(t) {
|
|
11
18
|
return t;
|
|
12
19
|
}
|
|
13
|
-
},
|
|
20
|
+
}, C = {
|
|
14
21
|
view(t) {
|
|
15
22
|
if (t == null) return;
|
|
16
23
|
const e = Number(t);
|
|
@@ -19,7 +26,7 @@ const w = {
|
|
|
19
26
|
review(t) {
|
|
20
27
|
return String(t);
|
|
21
28
|
}
|
|
22
|
-
},
|
|
29
|
+
}, E = {
|
|
23
30
|
view(t) {
|
|
24
31
|
if (t != null)
|
|
25
32
|
return t !== "false" && t !== "0";
|
|
@@ -28,7 +35,7 @@ const w = {
|
|
|
28
35
|
return String(t);
|
|
29
36
|
}
|
|
30
37
|
};
|
|
31
|
-
function
|
|
38
|
+
function K() {
|
|
32
39
|
return {
|
|
33
40
|
view(t) {
|
|
34
41
|
if (t != null)
|
|
@@ -43,15 +50,15 @@ function A() {
|
|
|
43
50
|
}
|
|
44
51
|
};
|
|
45
52
|
}
|
|
46
|
-
function
|
|
53
|
+
function M(t) {
|
|
47
54
|
const e = {};
|
|
48
55
|
for (const n of Object.keys(t)) {
|
|
49
56
|
const s = typeof t[n];
|
|
50
|
-
s === "string" ? e[n] =
|
|
57
|
+
s === "string" ? e[n] = O : s === "number" ? e[n] = C : s === "boolean" && (e[n] = E);
|
|
51
58
|
}
|
|
52
59
|
return e;
|
|
53
60
|
}
|
|
54
|
-
function
|
|
61
|
+
function m(t) {
|
|
55
62
|
if (typeof t == "string") {
|
|
56
63
|
const e = new CSSStyleSheet();
|
|
57
64
|
return e.replaceSync(t), e;
|
|
@@ -62,57 +69,62 @@ function x(t, e) {
|
|
|
62
69
|
const {
|
|
63
70
|
widget: n,
|
|
64
71
|
defaults: s,
|
|
65
|
-
attrs:
|
|
66
|
-
shadow:
|
|
72
|
+
attrs: p = {},
|
|
73
|
+
shadow: c = "open",
|
|
67
74
|
styles: i
|
|
68
|
-
} = e,
|
|
69
|
-
|
|
75
|
+
} = e, u = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const o of Object.keys(p)) {
|
|
77
|
+
const a = p[o], { attrName: r, optic: g } = N(o, a);
|
|
78
|
+
u.set(r, { propKey: o, optic: g });
|
|
79
|
+
}
|
|
80
|
+
const h = [...u.keys()], b = i == null ? [] : Array.isArray(i) ? i.map(m) : [m(i)];
|
|
81
|
+
class d extends HTMLElement {
|
|
70
82
|
constructor() {
|
|
71
83
|
super(...arguments);
|
|
72
84
|
// Use underscore prefix rather than # so Object.defineProperty below can
|
|
73
85
|
// access instance state from outside the class body.
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
f(this, "_rb_signal", w({ ...s }));
|
|
87
|
+
f(this, "_rb_cleanup", null);
|
|
76
88
|
}
|
|
77
89
|
static get observedAttributes() {
|
|
78
|
-
return
|
|
90
|
+
return h;
|
|
79
91
|
}
|
|
80
92
|
connectedCallback() {
|
|
81
|
-
const r =
|
|
82
|
-
|
|
93
|
+
const r = c !== !1 ? this.shadowRoot ?? this.attachShadow({ mode: c }) : this;
|
|
94
|
+
c !== !1 && b.length > 0 && (r.adoptedStyleSheets = b), this._rb_cleanup = k(n, this._rb_signal, r);
|
|
83
95
|
}
|
|
84
96
|
disconnectedCallback() {
|
|
85
97
|
var r;
|
|
86
98
|
(r = this._rb_cleanup) == null || r.call(this), this._rb_cleanup = null;
|
|
87
99
|
}
|
|
88
|
-
attributeChangedCallback(r,
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
this._rb_signal.set({ ...this._rb_signal.get(), [
|
|
100
|
+
attributeChangedCallback(r, g, y) {
|
|
101
|
+
const l = u.get(r);
|
|
102
|
+
if (l == null) return;
|
|
103
|
+
const _ = l.optic.view(y) ?? s[l.propKey];
|
|
104
|
+
this._rb_signal.set({ ...this._rb_signal.get(), [l.propKey]: _ });
|
|
93
105
|
}
|
|
94
106
|
}
|
|
95
107
|
for (const o of Object.keys(s))
|
|
96
|
-
Object.defineProperty(
|
|
108
|
+
Object.defineProperty(d.prototype, o, {
|
|
97
109
|
get() {
|
|
98
110
|
return this._rb_signal.get()[o];
|
|
99
111
|
},
|
|
100
|
-
set(
|
|
112
|
+
set(a) {
|
|
101
113
|
this._rb_signal.set({
|
|
102
114
|
...this._rb_signal.get(),
|
|
103
|
-
[o]:
|
|
115
|
+
[o]: a
|
|
104
116
|
});
|
|
105
117
|
},
|
|
106
118
|
configurable: !0,
|
|
107
119
|
enumerable: !0
|
|
108
120
|
});
|
|
109
|
-
customElements.define(t,
|
|
121
|
+
customElements.define(t, d);
|
|
110
122
|
}
|
|
111
123
|
export {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
E as attrBoolean,
|
|
125
|
+
K as attrJson,
|
|
126
|
+
C as attrNumber,
|
|
127
|
+
O as attrString,
|
|
128
|
+
M as attrsFrom,
|
|
117
129
|
x as defineElement
|
|
118
130
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export * from "./widget.js";
|
|
|
3
3
|
export * from "./form-state.js";
|
|
4
4
|
export * from "./keybinds.js";
|
|
5
5
|
export { attrString, attrNumber, attrBoolean, attrJson, attrsFrom, defineElement } from "./elements.js";
|
|
6
|
-
export type { AttrSchema, PrimitiveAttrSchema } from "./elements.js";
|
|
6
|
+
export type { AttrEntry, AttrSchema, PrimitiveAttrSchema } from "./elements.js";
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { h as g } from "./html-C8SnQjvU.js";
|
|
2
|
-
import { above as l, 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, inputWidget as L, map as N,
|
|
3
|
-
import { createForm as
|
|
2
|
+
import { above as l, 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, inputWidget as L, map as N, match as B, mount as D, narrow as J, numberInputWidget as T, on as V, register as j, selectWidget as q, show as z, stack as G, subscribe as H, subscribeNow as M, template as O, textareaWidget as P, watchAll as Q, withScope as R } from "./widget.js";
|
|
3
|
+
import { createForm as X, createFormState as Y, isDirty as Z, isFormValid as _, shouldShowError as $ } from "./form-state.js";
|
|
4
4
|
import { signal as a } from "@rhi-zone/rainbow";
|
|
5
|
-
import { attrBoolean as
|
|
6
|
-
function
|
|
5
|
+
import { attrBoolean as te, attrJson as ne, attrNumber as ie, attrString as oe, attrsFrom as re, defineElement as se } from "./elements.js";
|
|
6
|
+
function d(e, n, t, r, i) {
|
|
7
7
|
const o = e(
|
|
8
8
|
n,
|
|
9
9
|
() => r(t.get()),
|
|
@@ -24,11 +24,11 @@ function b(e) {
|
|
|
24
24
|
}
|
|
25
25
|
export {
|
|
26
26
|
l as above,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
te as attrBoolean,
|
|
28
|
+
ne as attrJson,
|
|
29
|
+
ie as attrNumber,
|
|
30
|
+
oe as attrString,
|
|
31
|
+
re as attrsFrom,
|
|
32
32
|
p as beside,
|
|
33
33
|
f as bindAttr,
|
|
34
34
|
x as bindCheckbox,
|
|
@@ -40,9 +40,9 @@ export {
|
|
|
40
40
|
b as bindingsStoreSignal,
|
|
41
41
|
k as checkboxWidget,
|
|
42
42
|
C as concat,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
X as createForm,
|
|
44
|
+
Y as createFormState,
|
|
45
|
+
se as defineElement,
|
|
46
46
|
E as dynamic,
|
|
47
47
|
F as each,
|
|
48
48
|
A as eachKeyed,
|
|
@@ -50,23 +50,24 @@ export {
|
|
|
50
50
|
K as foldWidget,
|
|
51
51
|
g as html,
|
|
52
52
|
L as inputWidget,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
Z as isDirty,
|
|
54
|
+
_ as isFormValid,
|
|
55
|
+
d as keybindsContext,
|
|
56
56
|
N as map,
|
|
57
|
-
B as
|
|
58
|
-
D as
|
|
59
|
-
J as
|
|
60
|
-
T as
|
|
61
|
-
V as
|
|
62
|
-
j as
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
z as
|
|
66
|
-
G as
|
|
67
|
-
H as
|
|
68
|
-
M as
|
|
69
|
-
O as
|
|
70
|
-
P as
|
|
71
|
-
Q as
|
|
57
|
+
B as match,
|
|
58
|
+
D as mount,
|
|
59
|
+
J as narrow,
|
|
60
|
+
T as numberInputWidget,
|
|
61
|
+
V as on,
|
|
62
|
+
j as register,
|
|
63
|
+
q as selectWidget,
|
|
64
|
+
$ as shouldShowError,
|
|
65
|
+
z as show,
|
|
66
|
+
G as stack,
|
|
67
|
+
H as subscribe,
|
|
68
|
+
M as subscribeNow,
|
|
69
|
+
O as template,
|
|
70
|
+
P as textareaWidget,
|
|
71
|
+
Q as watchAll,
|
|
72
|
+
R as withScope
|
|
72
73
|
};
|
package/dist/widget.d.ts
CHANGED
|
@@ -379,6 +379,30 @@ export declare function bindShow(el: HTMLElement, s: ReadonlySignal<boolean>): (
|
|
|
379
379
|
* success: (data) => renderData(data),
|
|
380
380
|
* })
|
|
381
381
|
*/
|
|
382
|
+
/**
|
|
383
|
+
* Render a discriminated union by tag. Exhaustively maps each variant to a
|
|
384
|
+
* widget; swaps the rendered child when the tag changes.
|
|
385
|
+
*
|
|
386
|
+
* Compared to N `narrow` + `stack` calls:
|
|
387
|
+
* - Single container div (not N+1)
|
|
388
|
+
* - Exhaustiveness checked at compile time — missing variant = type error
|
|
389
|
+
* - No `tagged()` declarations at the call site
|
|
390
|
+
*
|
|
391
|
+
* Must be called during a widget call context.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* type Screen =
|
|
395
|
+
* | { screen: 'list'; items: Item[] }
|
|
396
|
+
* | { screen: 'detail'; item: Item }
|
|
397
|
+
*
|
|
398
|
+
* match('screen', {
|
|
399
|
+
* list: (s) => listWidget(s),
|
|
400
|
+
* detail: (s) => detailWidget(s),
|
|
401
|
+
* })
|
|
402
|
+
*/
|
|
403
|
+
export declare function match<S extends Record<K, string>, K extends keyof S & string>(key: K, cases: {
|
|
404
|
+
[V in S[K] & string]: Widget<Extract<S, Record<K, V>>, FlowContent>;
|
|
405
|
+
}): Widget<S, DivEl>;
|
|
382
406
|
export declare function foldWidget<T, E>(s: Signal<AsyncData<T, E>> | ReadonlySignal<AsyncData<T, E>>, cases: {
|
|
383
407
|
notAsked?: () => AnyEl;
|
|
384
408
|
loading?: () => AnyEl;
|
package/dist/widget.js
CHANGED
|
@@ -1,347 +1,368 @@
|
|
|
1
|
-
import { index as C, stateful as S, lens as L,
|
|
2
|
-
import { i as N, s as
|
|
1
|
+
import { index as C, stateful as S, lens as L, tagged as W, signal as B } from "@rhi-zone/rainbow";
|
|
2
|
+
import { i as N, s as $, o as F, t as I } from "./html-C8SnQjvU.js";
|
|
3
3
|
let k = null;
|
|
4
4
|
function i(e) {
|
|
5
5
|
k == null || k.push(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
const
|
|
7
|
+
function h(e) {
|
|
8
|
+
const n = k, o = [];
|
|
9
9
|
k = o;
|
|
10
|
-
const
|
|
11
|
-
return k =
|
|
10
|
+
const t = e();
|
|
11
|
+
return k = n, [t, () => {
|
|
12
12
|
for (const c of o) c();
|
|
13
13
|
}];
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function M(e) {
|
|
16
|
+
return h(e);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
i(e.subscribe(
|
|
18
|
+
function v(e, n) {
|
|
19
|
+
i(e.subscribe(n));
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function O(e) {
|
|
22
22
|
i(e);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const [
|
|
26
|
-
return o.appendChild(
|
|
27
|
-
|
|
24
|
+
function T(e, n, o) {
|
|
25
|
+
const [t, c] = h(() => e(n));
|
|
26
|
+
return o.appendChild(t.node), () => {
|
|
27
|
+
t.node.remove(), c();
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return (o) => e(o.focus(
|
|
30
|
+
function V(e, n) {
|
|
31
|
+
return (o) => e(o.focus(n));
|
|
32
32
|
}
|
|
33
|
-
function H(e,
|
|
33
|
+
function H(e, n) {
|
|
34
34
|
return (o) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const t = document.createElement("div");
|
|
36
|
+
t.dataset.narrow = "";
|
|
37
37
|
let c = null, r = null;
|
|
38
38
|
const u = o, d = () => {
|
|
39
|
-
r = u.narrow(
|
|
40
|
-
const [
|
|
41
|
-
c =
|
|
39
|
+
r = u.narrow(n);
|
|
40
|
+
const [a, l] = h(() => e(r));
|
|
41
|
+
c = l, t.appendChild(a.node);
|
|
42
42
|
};
|
|
43
|
-
return
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}),
|
|
43
|
+
return v(o, (a) => {
|
|
44
|
+
const l = n.view(a);
|
|
45
|
+
l !== void 0 && c === null ? d() : l === void 0 && c !== null && (c(), c = null, r = null, t.replaceChildren());
|
|
46
|
+
}), n.view(o.get()) !== void 0 && d(), i(() => c == null ? void 0 : c()), { _tag: "div", node: t };
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
function R(e) {
|
|
50
|
-
return (
|
|
51
|
-
const o =
|
|
52
|
-
|
|
50
|
+
return (n) => {
|
|
51
|
+
const o = n, t = document.createElement("div");
|
|
52
|
+
t.dataset.each = "";
|
|
53
53
|
let c = [];
|
|
54
54
|
const r = (d) => {
|
|
55
|
-
for (const
|
|
56
|
-
c = [],
|
|
57
|
-
for (let
|
|
58
|
-
const
|
|
59
|
-
(
|
|
60
|
-
(
|
|
61
|
-
const
|
|
62
|
-
return
|
|
55
|
+
for (const s of c) s();
|
|
56
|
+
c = [], t.replaceChildren();
|
|
57
|
+
for (let s = 0; s < d.length; s++) {
|
|
58
|
+
const a = s, l = L(
|
|
59
|
+
(f) => f[a],
|
|
60
|
+
(f, p) => {
|
|
61
|
+
const b = [...p];
|
|
62
|
+
return b[a] = f, b;
|
|
63
63
|
}
|
|
64
|
-
),
|
|
65
|
-
c.push(
|
|
64
|
+
), g = o.focus(l), [m, w] = h(() => e(g));
|
|
65
|
+
c.push(w), t.appendChild(m.node);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
r(
|
|
69
|
-
const u =
|
|
70
|
-
return
|
|
68
|
+
r(n.get());
|
|
69
|
+
const u = n.map((d) => d.length);
|
|
70
|
+
return v(u, () => r(n.get())), i(() => {
|
|
71
71
|
for (const d of c) d();
|
|
72
|
-
}), { _tag: "div", node:
|
|
72
|
+
}), { _tag: "div", node: t };
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
function U(e,
|
|
75
|
+
function U(e, n) {
|
|
76
76
|
return (o) => {
|
|
77
|
-
const
|
|
77
|
+
const t = o, c = document.createElement("div");
|
|
78
78
|
c.dataset.beside = "";
|
|
79
|
-
const r =
|
|
80
|
-
return c.appendChild(d.node), c.appendChild(
|
|
79
|
+
const r = t.focus(C(0)), u = t.focus(C(1)), [d, s] = h(() => e(r)), [a, l] = h(() => n(u));
|
|
80
|
+
return c.appendChild(d.node), c.appendChild(a.node), i(s), i(l), { _tag: "div", node: c };
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function z(e, n) {
|
|
84
84
|
return (o) => {
|
|
85
|
-
const
|
|
85
|
+
const t = o, c = document.createElement("div");
|
|
86
86
|
c.dataset.above = "";
|
|
87
|
-
const r =
|
|
88
|
-
return c.appendChild(d.node), c.appendChild(
|
|
87
|
+
const r = t.focus(C(0)), u = t.focus(C(1)), [d, s] = h(() => e(r)), [a, l] = h(() => n(u));
|
|
88
|
+
return c.appendChild(d.node), c.appendChild(a.node), i(s), i(l), { _tag: "div", node: c };
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function D(e, n) {
|
|
92
92
|
return (o) => {
|
|
93
|
-
const
|
|
94
|
-
return t
|
|
93
|
+
const t = S(e, o);
|
|
94
|
+
return n(t);
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function G(e, n) {
|
|
98
98
|
return (o) => {
|
|
99
|
-
const
|
|
100
|
-
return e(
|
|
99
|
+
const t = o.narrow(n);
|
|
100
|
+
return e(t);
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function J(e, n) {
|
|
104
104
|
return (o) => {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const [c, r] =
|
|
108
|
-
|
|
105
|
+
const t = document.createElement("div");
|
|
106
|
+
t.dataset.show = "";
|
|
107
|
+
const [c, r] = h(() => e(o));
|
|
108
|
+
t.appendChild(c.node), i(r);
|
|
109
109
|
const u = (d) => {
|
|
110
|
-
|
|
110
|
+
t.style.display = n(d) ? "" : "none";
|
|
111
111
|
};
|
|
112
|
-
return u(o.get()),
|
|
112
|
+
return u(o.get()), v(o, u), { _tag: "div", node: t };
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function Q(e, n) {
|
|
116
116
|
return (o) => {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
const [c, r] =
|
|
120
|
-
return
|
|
117
|
+
const t = document.createElement("div");
|
|
118
|
+
t.dataset.concat = "";
|
|
119
|
+
const [c, r] = h(() => e(o)), [u, d] = h(() => n(o));
|
|
120
|
+
return t.appendChild(c.node), t.appendChild(u.node), i(r), i(d), { _tag: "div", node: t };
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
return (
|
|
123
|
+
function X(...e) {
|
|
124
|
+
return (n) => {
|
|
125
125
|
const o = document.createElement("div");
|
|
126
126
|
o.dataset.stack = "";
|
|
127
|
-
for (const
|
|
128
|
-
const [c, r] =
|
|
127
|
+
for (const t of e) {
|
|
128
|
+
const [c, r] = h(() => t(n));
|
|
129
129
|
o.appendChild(c.node), i(r);
|
|
130
130
|
}
|
|
131
131
|
return { _tag: "div", node: o };
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
const
|
|
136
|
-
return
|
|
134
|
+
function Y(e, n, o) {
|
|
135
|
+
const t = document.createElement("template");
|
|
136
|
+
return t.innerHTML = e, (c) => {
|
|
137
137
|
const r = document.createElement("div");
|
|
138
|
-
r.dataset.templ = "", r.appendChild(
|
|
138
|
+
r.dataset.templ = "", r.appendChild(t.content.cloneNode(!0));
|
|
139
139
|
const u = {};
|
|
140
|
-
for (const d of Object.keys(
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
140
|
+
for (const d of Object.keys(n)) {
|
|
141
|
+
const s = n[d], a = r.querySelector(`${s}[data-ref="${d}"]`);
|
|
142
|
+
if (a === null)
|
|
143
143
|
throw new Error(
|
|
144
|
-
`templ: ref "${d}" not found — expected <${
|
|
144
|
+
`templ: ref "${d}" not found — expected <${s} data-ref="${d}"> in template`
|
|
145
145
|
);
|
|
146
|
-
u[d] = { _tag:
|
|
146
|
+
u[d] = { _tag: s, node: a };
|
|
147
147
|
}
|
|
148
148
|
return o(c, u), { _tag: "div", node: r };
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
const c = (
|
|
151
|
+
function Z(e, n, o, t) {
|
|
152
|
+
const c = (t == null ? void 0 : t.container) ?? "div", r = document.createElement(c);
|
|
153
153
|
r.dataset.eachKeyed = "";
|
|
154
|
-
const u = /* @__PURE__ */ new Map(), d = (
|
|
155
|
-
const
|
|
156
|
-
let
|
|
154
|
+
const u = /* @__PURE__ */ new Map(), d = (a, l) => {
|
|
155
|
+
const g = B(l);
|
|
156
|
+
let m = !1, w = () => {
|
|
157
157
|
};
|
|
158
|
-
"set" in e && (
|
|
159
|
-
if (
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
const y = [...
|
|
163
|
-
y[
|
|
158
|
+
"set" in e && (w = g.subscribe((b) => {
|
|
159
|
+
if (m) return;
|
|
160
|
+
const E = e.get(), x = E.findIndex((y) => n(y) === a);
|
|
161
|
+
if (x !== -1 && !Object.is(E[x], b)) {
|
|
162
|
+
const y = [...E];
|
|
163
|
+
y[x] = b, e.set(y);
|
|
164
164
|
}
|
|
165
165
|
}));
|
|
166
|
-
const [
|
|
166
|
+
const [f, p] = h(() => o(g));
|
|
167
167
|
return {
|
|
168
|
-
itemSignal:
|
|
169
|
-
childNode:
|
|
168
|
+
itemSignal: g,
|
|
169
|
+
childNode: f.node,
|
|
170
170
|
cleanup: () => {
|
|
171
|
-
|
|
171
|
+
p(), w();
|
|
172
172
|
},
|
|
173
|
-
setFromParent: (
|
|
174
|
-
|
|
173
|
+
setFromParent: (b) => {
|
|
174
|
+
m = !0, g.set(b), m = !1;
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
|
-
},
|
|
178
|
-
var
|
|
179
|
-
const
|
|
180
|
-
for (const [
|
|
181
|
-
|
|
182
|
-
for (let
|
|
183
|
-
const
|
|
184
|
-
u.has(
|
|
177
|
+
}, s = (a) => {
|
|
178
|
+
var w;
|
|
179
|
+
const l = a.map(n), g = new Set(l);
|
|
180
|
+
for (const [f, p] of u)
|
|
181
|
+
g.has(f) || (p.cleanup(), (w = p.childNode.parentNode) == null || w.removeChild(p.childNode), u.delete(f));
|
|
182
|
+
for (let f = 0; f < a.length; f++) {
|
|
183
|
+
const p = l[f], b = a[f];
|
|
184
|
+
u.has(p) ? u.get(p).setFromParent(b) : u.set(p, d(p, b));
|
|
185
185
|
}
|
|
186
|
-
let
|
|
187
|
-
for (let
|
|
188
|
-
const
|
|
189
|
-
(
|
|
186
|
+
let m = null;
|
|
187
|
+
for (let f = a.length - 1; f >= 0; f--) {
|
|
188
|
+
const p = u.get(l[f]);
|
|
189
|
+
(p.childNode.parentNode !== r || p.childNode.nextSibling !== m) && r.insertBefore(p.childNode, m), m = p.childNode;
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
|
-
return
|
|
193
|
-
for (const
|
|
192
|
+
return s(e.get()), v(e, s), i(() => {
|
|
193
|
+
for (const a of u.values()) a.cleanup();
|
|
194
194
|
}), { _tag: c, node: r };
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
const
|
|
198
|
-
e.addEventListener(
|
|
196
|
+
function _(e, n, o) {
|
|
197
|
+
const t = o;
|
|
198
|
+
e.addEventListener(n, t), i(() => e.removeEventListener(n, t));
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
e.value =
|
|
202
|
-
const o = () =>
|
|
200
|
+
function A(e, n) {
|
|
201
|
+
e.value = n.get();
|
|
202
|
+
const o = () => n.set(e.value);
|
|
203
203
|
e.addEventListener("input", o);
|
|
204
|
-
const
|
|
204
|
+
const t = n.subscribe((r) => {
|
|
205
205
|
e.value !== r && (e.value = r);
|
|
206
206
|
}), c = () => {
|
|
207
|
-
e.removeEventListener("input", o),
|
|
207
|
+
e.removeEventListener("input", o), t();
|
|
208
208
|
};
|
|
209
209
|
return i(c), c;
|
|
210
210
|
}
|
|
211
|
-
function
|
|
212
|
-
|
|
211
|
+
function P(e, n) {
|
|
212
|
+
_(e, "change", () => n.set(e.value)), v(n, (o) => {
|
|
213
213
|
e.value !== o && (e.value = o);
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
216
|
+
function j(e, n) {
|
|
217
|
+
_(e, "change", () => n.set(e.checked)), v(n, (o) => {
|
|
218
218
|
e.checked !== o && (e.checked = o);
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
221
|
+
function ee(e, n) {
|
|
222
|
+
n(e.get()), i(e.subscribe(n));
|
|
223
223
|
}
|
|
224
|
-
function
|
|
225
|
-
e.textContent =
|
|
224
|
+
function te(e, n) {
|
|
225
|
+
e.textContent = n.get(), i(n.subscribe((o) => {
|
|
226
226
|
e.textContent = o;
|
|
227
227
|
}));
|
|
228
228
|
}
|
|
229
|
-
function ne(e,
|
|
230
|
-
e.setAttribute(
|
|
231
|
-
e.setAttribute(
|
|
229
|
+
function ne(e, n, o) {
|
|
230
|
+
e.setAttribute(n, o.get()), i(o.subscribe((t) => {
|
|
231
|
+
e.setAttribute(n, t);
|
|
232
232
|
}));
|
|
233
233
|
}
|
|
234
|
-
function
|
|
235
|
-
e.classList.toggle(
|
|
236
|
-
e.classList.toggle(
|
|
234
|
+
function oe(e, n, o) {
|
|
235
|
+
e.classList.toggle(n, o.get()), i(o.subscribe((t) => {
|
|
236
|
+
e.classList.toggle(n, t);
|
|
237
237
|
}));
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
const o = e.map((
|
|
239
|
+
function ce(e, n) {
|
|
240
|
+
n();
|
|
241
|
+
const o = e.map((t) => t.subscribe(n));
|
|
242
242
|
return () => {
|
|
243
|
-
for (const
|
|
243
|
+
for (const t of o) t();
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
|
-
function
|
|
247
|
-
return e.style.display =
|
|
246
|
+
function re(e, n) {
|
|
247
|
+
return e.style.display = n.get() ? "" : "none", n.subscribe((o) => {
|
|
248
248
|
e.style.display = o ? "" : "none";
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function ue(e, n) {
|
|
252
|
+
return (o) => {
|
|
253
|
+
const t = document.createElement("div");
|
|
254
|
+
t.dataset.match = "";
|
|
255
|
+
let c = null, r = null;
|
|
256
|
+
const u = (d) => {
|
|
257
|
+
const s = d[e];
|
|
258
|
+
if (s === r) return;
|
|
259
|
+
c == null || c(), c = null, t.replaceChildren(), r = s;
|
|
260
|
+
const a = n[s];
|
|
261
|
+
if (a == null) return;
|
|
262
|
+
const l = o.narrow(W(e, s));
|
|
263
|
+
let g;
|
|
264
|
+
[g, c] = h(
|
|
265
|
+
() => a(l)
|
|
266
|
+
), t.appendChild(g.node);
|
|
267
|
+
};
|
|
268
|
+
return v(o, u), u(o.get()), i(() => c == null ? void 0 : c()), { _tag: "div", node: t };
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function de(e, n) {
|
|
252
272
|
const o = document.createElement("div");
|
|
253
273
|
o.dataset.foldWidget = "";
|
|
254
|
-
let
|
|
274
|
+
let t = null;
|
|
255
275
|
const c = (r) => {
|
|
256
|
-
|
|
276
|
+
t !== null && (t(), t = null), o.replaceChildren();
|
|
257
277
|
let u = null;
|
|
258
278
|
switch (r.status) {
|
|
259
279
|
case "notAsked":
|
|
260
|
-
u =
|
|
280
|
+
u = n.notAsked ?? null;
|
|
261
281
|
break;
|
|
262
282
|
case "loading":
|
|
263
|
-
u =
|
|
283
|
+
u = n.loading ?? null;
|
|
264
284
|
break;
|
|
265
285
|
case "failure":
|
|
266
|
-
u =
|
|
286
|
+
u = n.failure ? () => n.failure(r.error) : null;
|
|
267
287
|
break;
|
|
268
288
|
case "success":
|
|
269
|
-
u =
|
|
289
|
+
u = n.success ? () => n.success(r.value) : null;
|
|
270
290
|
break;
|
|
271
291
|
}
|
|
272
292
|
if (u !== null) {
|
|
273
293
|
let d;
|
|
274
|
-
[d,
|
|
294
|
+
[d, t] = h(u), o.appendChild(d.node);
|
|
275
295
|
}
|
|
276
296
|
};
|
|
277
|
-
return c(e.get()), i(e.subscribe(c)), i(() =>
|
|
278
|
-
}
|
|
279
|
-
function ue(e) {
|
|
280
|
-
return (t) => {
|
|
281
|
-
const o = t, n = N(e ?? {});
|
|
282
|
-
return n.node.value = o.get(), _(n.node, o), n;
|
|
283
|
-
};
|
|
297
|
+
return c(e.get()), i(e.subscribe(c)), i(() => t == null ? void 0 : t()), { _tag: "div", node: o };
|
|
284
298
|
}
|
|
285
|
-
function
|
|
286
|
-
return (
|
|
287
|
-
const o =
|
|
288
|
-
return
|
|
299
|
+
function ae(e) {
|
|
300
|
+
return (n) => {
|
|
301
|
+
const o = n, t = N(e ?? {});
|
|
302
|
+
return t.node.value = o.get(), A(t.node, o), t;
|
|
289
303
|
};
|
|
290
304
|
}
|
|
291
305
|
function se(e) {
|
|
292
|
-
return (
|
|
293
|
-
const o =
|
|
294
|
-
return
|
|
306
|
+
return (n) => {
|
|
307
|
+
const o = n, t = I(e ?? {});
|
|
308
|
+
return t.node.value = o.get(), A(t.node, o), t;
|
|
295
309
|
};
|
|
296
310
|
}
|
|
297
311
|
function ie(e) {
|
|
298
|
-
return (
|
|
299
|
-
const o =
|
|
300
|
-
return
|
|
301
|
-
|
|
312
|
+
return (n) => {
|
|
313
|
+
const o = n, t = N({ ...e, type: "checkbox" });
|
|
314
|
+
return t.node.checked = o.get(), j(t.node, o), t;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function le(e) {
|
|
318
|
+
return (n) => {
|
|
319
|
+
const o = n, t = N({ ...e, type: "number" });
|
|
320
|
+
return t.node.value = String(o.get()), _(t.node, "input", () => {
|
|
321
|
+
const c = t.node.valueAsNumber;
|
|
302
322
|
isNaN(c) || o.set(c);
|
|
303
|
-
}),
|
|
304
|
-
|
|
305
|
-
}),
|
|
323
|
+
}), v(n, (c) => {
|
|
324
|
+
t.node.valueAsNumber !== c && (t.node.value = String(c));
|
|
325
|
+
}), t;
|
|
306
326
|
};
|
|
307
327
|
}
|
|
308
|
-
function
|
|
328
|
+
function fe(e, n) {
|
|
309
329
|
return (o) => {
|
|
310
|
-
const
|
|
311
|
-
return c.node.value =
|
|
330
|
+
const t = o, c = $(n ?? {}, ...e.map((r) => F({ value: r.value }, r.label)));
|
|
331
|
+
return c.node.value = t.get(), P(c.node, t), c;
|
|
312
332
|
};
|
|
313
333
|
}
|
|
314
334
|
export {
|
|
315
|
-
|
|
335
|
+
z as above,
|
|
316
336
|
U as beside,
|
|
317
337
|
ne as bindAttr,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
338
|
+
j as bindCheckbox,
|
|
339
|
+
oe as bindClass,
|
|
340
|
+
A as bindInput,
|
|
341
|
+
P as bindSelect,
|
|
342
|
+
re as bindShow,
|
|
343
|
+
te as bindText,
|
|
344
|
+
ie as checkboxWidget,
|
|
345
|
+
Q as concat,
|
|
346
|
+
D as dynamic,
|
|
327
347
|
R as each,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
348
|
+
Z as eachKeyed,
|
|
349
|
+
V as focus,
|
|
350
|
+
de as foldWidget,
|
|
351
|
+
ae as inputWidget,
|
|
352
|
+
G as map,
|
|
353
|
+
ue as match,
|
|
354
|
+
T as mount,
|
|
334
355
|
H as narrow,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
356
|
+
le as numberInputWidget,
|
|
357
|
+
_ as on,
|
|
358
|
+
O as register,
|
|
359
|
+
fe as selectWidget,
|
|
360
|
+
J as show,
|
|
361
|
+
X as stack,
|
|
362
|
+
v as subscribe,
|
|
363
|
+
ee as subscribeNow,
|
|
364
|
+
Y as template,
|
|
365
|
+
se as textareaWidget,
|
|
366
|
+
ce as watchAll,
|
|
367
|
+
M as withScope
|
|
347
368
|
};
|