@rhi-zone/rainbow-ui 0.2.0-alpha.4 → 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 CHANGED
@@ -1,8 +1,8 @@
1
- import { h as u } 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, h as L, inputWidget as N, map as B, match as D, mount as J, narrow as T, numberInputWidget as V, on as j, prop as q, register as z, selectWidget as G, show as H, slot as M, stack as O, subscribe as P, subscribeNow as Q, template as R, textareaWidget as U, watchAll as X, withScope as Y } from "./widget.js";
3
- import { createForm as _, createFormState as $, isDirty as ee, isFormValid as te, shouldShowError as ne } from "./form-state.js";
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 ie, attrJson as re, attrNumber as se, attrString as ae, attrsFrom as ce, defineElement as de } from "./elements.js";
5
+ import { attrBoolean as re, attrJson as se, attrNumber as ae, attrString as ce, attrsFrom as de, defineElement as be } from "./elements.js";
6
6
  function d(e, n, t, r, o) {
7
7
  const i = e(
8
8
  n,
@@ -23,12 +23,12 @@ function b(e) {
23
23
  return e.addEventListener("change", t), [n, () => e.removeEventListener("change", t)];
24
24
  }
25
25
  export {
26
- l as above,
27
- ie as attrBoolean,
28
- re as attrJson,
29
- se as attrNumber,
30
- ae as attrString,
31
- ce as attrsFrom,
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,37 +40,38 @@ export {
40
40
  b as bindingsStoreSignal,
41
41
  k as checkboxWidget,
42
42
  C as concat,
43
- _ as createForm,
44
- $ as createFormState,
45
- de as defineElement,
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
51
  L as h,
52
- u as html,
52
+ l as html,
53
53
  N as inputWidget,
54
- ee as isDirty,
55
- te as isFormValid,
54
+ te as isDirty,
55
+ ne as isFormValid,
56
56
  d as keybindsContext,
57
- B as map,
58
- D as match,
59
- J as mount,
60
- T as narrow,
61
- V as numberInputWidget,
62
- j as on,
63
- q as prop,
64
- z as register,
65
- G as selectWidget,
66
- ne as shouldShowError,
67
- H as show,
68
- M as slot,
69
- O as stack,
70
- P as subscribe,
71
- Q as subscribeNow,
72
- R as template,
73
- U as textareaWidget,
74
- X as watchAll,
75
- Y as withScope
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
76
77
  };
package/dist/widget.d.ts CHANGED
@@ -458,19 +458,35 @@ export declare function selectWidget(options: {
458
458
  label: string;
459
459
  }[], attrs?: SelectAttrs): Widget<string, SelectEl>;
460
460
  /**
461
- * A reactive child: either a static element, a string, or a widget that
462
- * accepts the same signal type `T` and returns any element.
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.
463
479
  */
464
- export type RChild<T> = AnyEl | string | Widget<T, AnyEl>;
480
+ export declare function lift<T, E extends AnyEl>(el: E): Widget<T, E>;
465
481
  /**
466
482
  * Reactive hyperscript factories — the same element tags as `html.ts` but
467
483
  * returning `Widget<T, El>` instead of `El`. Import as:
468
484
  *
469
485
  * import { h } from '@rhi-zone/rainbow-ui/widget'
470
486
  *
471
- * Widget children receive the same signal as their parent. Static children
472
- * (`AnyEl`) are deep-cloned on each widget invocation so that the same static
473
- * node can be safely reused across multiple widget instances.
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.
474
490
  */
475
491
  export declare const h: {
476
492
  readonly div: <T>(attrs: GlobalAttrs, ...children: RChild<T>[]) => (s: Signal<T>) => El<"div", HTMLDivElement>;
package/dist/widget.js CHANGED
@@ -1,350 +1,353 @@
1
1
  import { index as E, stateful as L, field as W, lens as B, tagged as $, signal as j } from "@rhi-zone/rainbow";
2
2
  import { i as _, s as F, o as I, t as O } from "./html-C8SnQjvU.js";
3
- let y = null;
3
+ let k = null;
4
4
  function l(e) {
5
- y == null || y.push(e);
5
+ k == null || k.push(e);
6
6
  }
7
- function g(e) {
8
- const n = y, o = [];
9
- y = o;
10
- const t = e();
11
- return y = n, [t, () => {
7
+ function m(e) {
8
+ const t = k, o = [];
9
+ k = o;
10
+ const n = e();
11
+ return k = t, [n, () => {
12
12
  for (const c of o) c();
13
13
  }];
14
14
  }
15
15
  function V(e) {
16
- return g(e);
16
+ return m(e);
17
17
  }
18
- function w(e, n) {
19
- l(e.subscribe(n));
18
+ function w(e, t) {
19
+ l(e.subscribe(t));
20
20
  }
21
21
  function H(e) {
22
22
  l(e);
23
23
  }
24
- function R(e, n, o) {
25
- const [t, c] = g(() => e(n));
26
- return o.appendChild(t.node), () => {
27
- t.node.remove(), c();
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 P(e, n) {
31
- return (o) => e(o.focus(n));
30
+ function P(e, t) {
31
+ return (o) => e(o.focus(t));
32
32
  }
33
- function U(e, n) {
34
- return P(e, W(n));
33
+ function U(e, t) {
34
+ return P(e, W(t));
35
35
  }
36
- function z(e, n) {
36
+ function z(e, t) {
37
37
  return (o) => {
38
- const t = document.createElement("div");
39
- t.dataset.narrow = "";
38
+ const n = document.createElement("div");
39
+ n.dataset.narrow = "";
40
40
  let c = null, r = null;
41
- const d = o, u = () => {
42
- r = d.narrow(n);
43
- const [a, f] = g(() => e(r));
44
- c = f, t.appendChild(a.node);
41
+ const u = o, d = () => {
42
+ r = u.narrow(t);
43
+ const [a, f] = m(() => e(r));
44
+ c = f, n.appendChild(a.node);
45
45
  };
46
46
  return w(o, (a) => {
47
- const f = n.view(a);
48
- f !== void 0 && c === null ? u() : f === void 0 && c !== null && (c(), c = null, r = null, t.replaceChildren());
49
- }), n.view(o.get()) !== void 0 && u(), l(() => c == null ? void 0 : c()), { _tag: "div", node: t };
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 };
50
50
  };
51
51
  }
52
52
  function D(e) {
53
- return (n) => {
54
- const o = n, t = document.createElement("div");
55
- t.dataset.each = "";
53
+ return (t) => {
54
+ const o = t, n = document.createElement("div");
55
+ n.dataset.each = "";
56
56
  let c = [];
57
- const r = (u) => {
57
+ const r = (d) => {
58
58
  for (const s of c) s();
59
- c = [], t.replaceChildren();
60
- for (let s = 0; s < u.length; s++) {
59
+ c = [], n.replaceChildren();
60
+ for (let s = 0; s < d.length; s++) {
61
61
  const a = s, f = B(
62
62
  (p) => p[a],
63
63
  (p, h) => {
64
- const b = [...h];
65
- return b[a] = p, b;
64
+ const g = [...h];
65
+ return g[a] = p, g;
66
66
  }
67
- ), m = o.focus(f), [v, C] = g(() => e(m));
68
- c.push(C), t.appendChild(v.node);
67
+ ), b = o.focus(f), [v, C] = m(() => e(b));
68
+ c.push(C), n.appendChild(v.node);
69
69
  }
70
70
  };
71
- r(n.get());
72
- const d = n.map((u) => u.length);
73
- return w(d, () => r(n.get())), l(() => {
74
- for (const u of c) u();
75
- }), { _tag: "div", node: t };
71
+ r(t.get());
72
+ const u = t.map((d) => d.length);
73
+ return w(u, () => r(t.get())), l(() => {
74
+ for (const d of c) d();
75
+ }), { _tag: "div", node: n };
76
76
  };
77
77
  }
78
- function G(e, n) {
78
+ function G(e, t) {
79
79
  return (o) => {
80
- const t = o, c = document.createElement("div");
80
+ const n = o, c = document.createElement("div");
81
81
  c.dataset.beside = "";
82
- const r = t.focus(E(0)), d = t.focus(E(1)), [u, s] = g(() => e(r)), [a, f] = g(() => n(d));
83
- return c.appendChild(u.node), c.appendChild(a.node), l(s), l(f), { _tag: "div", node: c };
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 };
84
84
  };
85
85
  }
86
- function J(e, n) {
86
+ function J(e, t) {
87
87
  return (o) => {
88
- const t = o, c = document.createElement("div");
88
+ const n = o, c = document.createElement("div");
89
89
  c.dataset.above = "";
90
- const r = t.focus(E(0)), d = t.focus(E(1)), [u, s] = g(() => e(r)), [a, f] = g(() => n(d));
91
- return c.appendChild(u.node), c.appendChild(a.node), l(s), l(f), { _tag: "div", node: c };
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 };
92
92
  };
93
93
  }
94
- function Q(e, n) {
94
+ function Q(e, t) {
95
95
  return (o) => {
96
- const t = L(e, o);
97
- return n(t);
96
+ const n = L(e, o);
97
+ return t(n);
98
98
  };
99
99
  }
100
- function X(e, n) {
100
+ function X(e, t) {
101
101
  return (o) => {
102
- const t = o.narrow(n);
103
- return e(t);
102
+ const n = o.narrow(t);
103
+ return e(n);
104
104
  };
105
105
  }
106
- function Y(e, n) {
106
+ function Y(e, t) {
107
107
  return (o) => {
108
- const t = document.createElement("div");
109
- t.dataset.show = "";
110
- const [c, r] = g(() => e(o));
111
- t.appendChild(c.node), l(r);
112
- const d = (u) => {
113
- t.style.display = n(u) ? "" : "none";
108
+ const n = document.createElement("div");
109
+ n.dataset.show = "";
110
+ const [c, r] = m(() => e(o));
111
+ n.appendChild(c.node), l(r);
112
+ const u = (d) => {
113
+ n.style.display = t(d) ? "" : "none";
114
114
  };
115
- return d(o.get()), w(o, d), { _tag: "div", node: t };
115
+ return u(o.get()), w(o, u), { _tag: "div", node: n };
116
116
  };
117
117
  }
118
- function Z(e, n) {
118
+ function Z(e, t) {
119
119
  return (o) => {
120
- const t = document.createElement("div");
121
- t.dataset.concat = "";
122
- const [c, r] = g(() => e(o)), [d, u] = g(() => n(o));
123
- return t.appendChild(c.node), t.appendChild(d.node), l(r), l(u), { _tag: "div", node: t };
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 };
124
124
  };
125
125
  }
126
126
  function ee(...e) {
127
- return (n) => {
127
+ return (t) => {
128
128
  const o = document.createElement("div");
129
129
  o.dataset.stack = "";
130
- for (const t of e) {
131
- const [c, r] = g(() => t(n));
130
+ for (const n of e) {
131
+ const [c, r] = m(() => n(t));
132
132
  o.appendChild(c.node), l(r);
133
133
  }
134
134
  return { _tag: "div", node: o };
135
135
  };
136
136
  }
137
- function te(e, n, o) {
138
- const t = document.createElement("template");
139
- return t.innerHTML = e, (c) => {
137
+ function te(e, t, o) {
138
+ const n = document.createElement("template");
139
+ return n.innerHTML = e, (c) => {
140
140
  const r = document.createElement("div");
141
- r.dataset.templ = "", r.appendChild(t.content.cloneNode(!0));
142
- const d = {};
143
- for (const u of Object.keys(n)) {
144
- const s = n[u], a = r.querySelector(`${s}[data-ref="${u}"]`);
141
+ r.dataset.templ = "", r.appendChild(n.content.cloneNode(!0));
142
+ const u = {};
143
+ for (const d of Object.keys(t)) {
144
+ const s = t[d], a = r.querySelector(`${s}[data-ref="${d}"]`);
145
145
  if (a === null)
146
146
  throw new Error(
147
- `templ: ref "${u}" not found — expected <${s} data-ref="${u}"> in template`
147
+ `templ: ref "${d}" not found — expected <${s} data-ref="${d}"> in template`
148
148
  );
149
- d[u] = { _tag: s, node: a };
149
+ u[d] = { _tag: s, node: a };
150
150
  }
151
- return o(c, d), { _tag: "div", node: r };
151
+ return o(c, u), { _tag: "div", node: r };
152
152
  };
153
153
  }
154
- function ne(e, n, o, t) {
155
- const c = (t == null ? void 0 : t.container) ?? "div", r = document.createElement(c);
154
+ function ne(e, t, o, n) {
155
+ const c = (n == null ? void 0 : n.container) ?? "div", r = document.createElement(c);
156
156
  r.dataset.eachKeyed = "";
157
- const d = /* @__PURE__ */ new Map(), u = (a, f) => {
158
- const m = j(f);
157
+ const u = /* @__PURE__ */ new Map(), d = (a, f) => {
158
+ const b = j(f);
159
159
  let v = !1, C = () => {
160
160
  };
161
- "set" in e && (C = m.subscribe((b) => {
161
+ "set" in e && (C = b.subscribe((g) => {
162
162
  if (v) return;
163
- const x = e.get(), N = x.findIndex((k) => n(k) === a);
164
- if (N !== -1 && !Object.is(x[N], b)) {
165
- const k = [...x];
166
- k[N] = b, e.set(k);
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);
167
167
  }
168
168
  }));
169
- const [p, h] = g(() => o(m));
169
+ const [p, h] = m(() => o(b));
170
170
  return {
171
- itemSignal: m,
171
+ itemSignal: b,
172
172
  childNode: p.node,
173
173
  cleanup: () => {
174
174
  h(), C();
175
175
  },
176
- setFromParent: (b) => {
177
- v = !0, m.set(b), v = !1;
176
+ setFromParent: (g) => {
177
+ v = !0, b.set(g), v = !1;
178
178
  }
179
179
  };
180
180
  }, s = (a) => {
181
181
  var C;
182
- const f = a.map(n), m = new Set(f);
183
- for (const [p, h] of d)
184
- m.has(p) || (h.cleanup(), (C = h.childNode.parentNode) == null || C.removeChild(h.childNode), d.delete(p));
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
185
  for (let p = 0; p < a.length; p++) {
186
- const h = f[p], b = a[p];
187
- d.has(h) ? d.get(h).setFromParent(b) : d.set(h, u(h, b));
186
+ const h = f[p], g = a[p];
187
+ u.has(h) ? u.get(h).setFromParent(g) : u.set(h, d(h, g));
188
188
  }
189
189
  let v = null;
190
190
  for (let p = a.length - 1; p >= 0; p--) {
191
- const h = d.get(f[p]);
191
+ const h = u.get(f[p]);
192
192
  (h.childNode.parentNode !== r || h.childNode.nextSibling !== v) && r.insertBefore(h.childNode, v), v = h.childNode;
193
193
  }
194
194
  };
195
195
  return s(e.get()), w(e, s), l(() => {
196
- for (const a of d.values()) a.cleanup();
196
+ for (const a of u.values()) a.cleanup();
197
197
  }), { _tag: c, node: r };
198
198
  }
199
- function A(e, n, o) {
200
- const t = o;
201
- e.addEventListener(n, t), l(() => e.removeEventListener(n, t));
199
+ function A(e, t, o) {
200
+ const n = o;
201
+ e.addEventListener(t, n), l(() => e.removeEventListener(t, n));
202
202
  }
203
- function S(e, n) {
204
- e.value = n.get();
205
- const o = () => n.set(e.value);
203
+ function S(e, t) {
204
+ e.value = t.get();
205
+ const o = () => t.set(e.value);
206
206
  e.addEventListener("input", o);
207
- const t = n.subscribe((r) => {
207
+ const n = t.subscribe((r) => {
208
208
  e.value !== r && (e.value = r);
209
209
  }), c = () => {
210
- e.removeEventListener("input", o), t();
210
+ e.removeEventListener("input", o), n();
211
211
  };
212
212
  return l(c), c;
213
213
  }
214
- function T(e, n) {
215
- A(e, "change", () => n.set(e.value)), w(n, (o) => {
214
+ function T(e, t) {
215
+ A(e, "change", () => t.set(e.value)), w(t, (o) => {
216
216
  e.value !== o && (e.value = o);
217
217
  });
218
218
  }
219
- function q(e, n) {
220
- A(e, "change", () => n.set(e.checked)), w(n, (o) => {
219
+ function q(e, t) {
220
+ A(e, "change", () => t.set(e.checked)), w(t, (o) => {
221
221
  e.checked !== o && (e.checked = o);
222
222
  });
223
223
  }
224
- function oe(e, n) {
225
- n(e.get()), l(e.subscribe(n));
224
+ function oe(e, t) {
225
+ t(e.get()), l(e.subscribe(t));
226
226
  }
227
- function ce(e, n) {
228
- e.textContent = n.get(), l(n.subscribe((o) => {
227
+ function ce(e, t) {
228
+ e.textContent = t.get(), l(t.subscribe((o) => {
229
229
  e.textContent = o;
230
230
  }));
231
231
  }
232
- function re(e, n, o) {
233
- e.setAttribute(n, o.get()), l(o.subscribe((t) => {
234
- e.setAttribute(n, t);
232
+ function re(e, t, o) {
233
+ e.setAttribute(t, o.get()), l(o.subscribe((n) => {
234
+ e.setAttribute(t, n);
235
235
  }));
236
236
  }
237
- function de(e, n, o) {
238
- e.classList.toggle(n, o.get()), l(o.subscribe((t) => {
239
- e.classList.toggle(n, t);
237
+ function ue(e, t, o) {
238
+ e.classList.toggle(t, o.get()), l(o.subscribe((n) => {
239
+ e.classList.toggle(t, n);
240
240
  }));
241
241
  }
242
- function ue(e, n) {
243
- n();
244
- const o = e.map((t) => t.subscribe(n));
242
+ function de(e, t) {
243
+ t();
244
+ const o = e.map((n) => n.subscribe(t));
245
245
  return () => {
246
- for (const t of o) t();
246
+ for (const n of o) n();
247
247
  };
248
248
  }
249
- function ie(e, n) {
250
- return e.style.display = n.get() ? "" : "none", n.subscribe((o) => {
249
+ function ie(e, t) {
250
+ return e.style.display = t.get() ? "" : "none", t.subscribe((o) => {
251
251
  e.style.display = o ? "" : "none";
252
252
  });
253
253
  }
254
- function ae(e, n) {
254
+ function ae(e, t) {
255
255
  return (o) => {
256
- const t = document.createElement("div");
257
- t.dataset.match = "";
256
+ const n = document.createElement("div");
257
+ n.dataset.match = "";
258
258
  let c = null, r = null;
259
- const d = (u) => {
260
- const s = u[e];
259
+ const u = (d) => {
260
+ const s = d[e];
261
261
  if (s === r) return;
262
- c == null || c(), c = null, t.replaceChildren(), r = s;
263
- const a = n[s];
262
+ c == null || c(), c = null, n.replaceChildren(), r = s;
263
+ const a = t[s];
264
264
  if (a == null) return;
265
265
  const f = o.narrow($(e, s));
266
- let m;
267
- [m, c] = g(
266
+ let b;
267
+ [b, c] = m(
268
268
  () => a(f)
269
- ), t.appendChild(m.node);
269
+ ), n.appendChild(b.node);
270
270
  };
271
- return w(o, d), d(o.get()), l(() => c == null ? void 0 : c()), { _tag: "div", node: t };
271
+ return w(o, u), u(o.get()), l(() => c == null ? void 0 : c()), { _tag: "div", node: n };
272
272
  };
273
273
  }
274
- function se(e, n) {
274
+ function se(e, t) {
275
275
  const o = document.createElement("div");
276
276
  o.dataset.foldWidget = "";
277
- let t = null;
277
+ let n = null;
278
278
  const c = (r) => {
279
- t !== null && (t(), t = null), o.replaceChildren();
280
- let d = null;
279
+ n !== null && (n(), n = null), o.replaceChildren();
280
+ let u = null;
281
281
  switch (r.status) {
282
282
  case "notAsked":
283
- d = n.notAsked ?? null;
283
+ u = t.notAsked ?? null;
284
284
  break;
285
285
  case "loading":
286
- d = n.loading ?? null;
286
+ u = t.loading ?? null;
287
287
  break;
288
288
  case "failure":
289
- d = n.failure ? () => n.failure(r.error) : null;
289
+ u = t.failure ? () => t.failure(r.error) : null;
290
290
  break;
291
291
  case "success":
292
- d = n.success ? () => n.success(r.value) : null;
292
+ u = t.success ? () => t.success(r.value) : null;
293
293
  break;
294
294
  }
295
- if (d !== null) {
296
- let u;
297
- [u, t] = g(d), o.appendChild(u.node);
295
+ if (u !== null) {
296
+ let d;
297
+ [d, n] = m(u), o.appendChild(d.node);
298
298
  }
299
299
  };
300
- return c(e.get()), l(e.subscribe(c)), l(() => t == null ? void 0 : t()), { _tag: "div", node: o };
300
+ return c(e.get()), l(e.subscribe(c)), l(() => n == null ? void 0 : n()), { _tag: "div", node: o };
301
301
  }
302
302
  function le(e) {
303
- return (n) => {
304
- const o = n, t = _(e ?? {});
305
- return t.node.value = o.get(), S(t.node, o), t;
303
+ return (t) => {
304
+ const o = t, n = _(e ?? {});
305
+ return n.node.value = o.get(), S(n.node, o), n;
306
306
  };
307
307
  }
308
308
  function fe(e) {
309
- return (n) => {
310
- const o = n, t = O(e ?? {});
311
- return t.node.value = o.get(), S(t.node, o), t;
309
+ return (t) => {
310
+ const o = t, n = O(e ?? {});
311
+ return n.node.value = o.get(), S(n.node, o), n;
312
312
  };
313
313
  }
314
314
  function pe(e) {
315
- return (n) => {
316
- const o = n, t = _({ ...e, type: "checkbox" });
317
- return t.node.checked = o.get(), q(t.node, o), t;
315
+ return (t) => {
316
+ const o = t, n = _({ ...e, type: "checkbox" });
317
+ return n.node.checked = o.get(), q(n.node, o), n;
318
318
  };
319
319
  }
320
320
  function he(e) {
321
- return (n) => {
322
- const o = n, t = _({ ...e, type: "number" });
323
- return t.node.value = String(o.get()), A(t.node, "input", () => {
324
- const c = t.node.valueAsNumber;
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;
325
325
  isNaN(c) || o.set(c);
326
- }), w(n, (c) => {
327
- t.node.valueAsNumber !== c && (t.node.value = String(c));
328
- }), t;
326
+ }), w(t, (c) => {
327
+ n.node.valueAsNumber !== c && (n.node.value = String(c));
328
+ }), n;
329
329
  };
330
330
  }
331
- function ge(e, n) {
331
+ function me(e, t) {
332
332
  return (o) => {
333
- const t = o, c = F(n ?? {}, ...e.map((r) => I({ value: r.value }, r.label)));
334
- return c.node.value = t.get(), T(c.node, t), c;
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
335
  };
336
336
  }
337
+ function be(e) {
338
+ return (t) => e;
339
+ }
337
340
  function i(e) {
338
- return (n, ...o) => (t) => {
341
+ return (t, ...o) => (n) => {
339
342
  const c = document.createElement(e);
340
- for (const [r, d] of Object.entries(n))
341
- d == null || d === !1 || c.setAttribute(r, d === !0 ? "" : String(d));
343
+ for (const [r, u] of Object.entries(t))
344
+ u == null || u === !1 || c.setAttribute(r, u === !0 ? "" : String(u));
342
345
  for (const r of o)
343
- typeof r == "function" ? c.appendChild(r(t).node) : typeof r == "string" ? c.appendChild(document.createTextNode(r)) : c.appendChild(r.node.cloneNode(!0));
346
+ typeof r == "function" ? c.appendChild(r(n).node) : c.appendChild(document.createTextNode(r));
344
347
  return { _tag: e, node: c };
345
348
  };
346
349
  }
347
- const me = {
350
+ const ge = {
348
351
  // Sectioning / flow
349
352
  div: i("div"),
350
353
  section: i("section"),
@@ -378,13 +381,13 @@ const me = {
378
381
  form: i("form"),
379
382
  fieldset: i("fieldset")
380
383
  };
381
- function be(e, n, o, t) {
382
- const c = o(n.get());
384
+ function ve(e, t, o, n) {
385
+ const c = o(t.get());
383
386
  if (c === void 0) {
384
387
  e.remove();
385
388
  return;
386
389
  }
387
- const r = c(t ?? n);
390
+ const r = c(n ?? t);
388
391
  e.replaceWith(r.node);
389
392
  }
390
393
  export {
@@ -392,7 +395,7 @@ export {
392
395
  G as beside,
393
396
  re as bindAttr,
394
397
  q as bindCheckbox,
395
- de as bindClass,
398
+ ue as bindClass,
396
399
  S as bindInput,
397
400
  T as bindSelect,
398
401
  ie as bindShow,
@@ -404,8 +407,9 @@ export {
404
407
  ne as eachKeyed,
405
408
  P as focus,
406
409
  se as foldWidget,
407
- me as h,
410
+ ge as h,
408
411
  le as inputWidget,
412
+ be as lift,
409
413
  X as map,
410
414
  ae as match,
411
415
  R as mount,
@@ -414,14 +418,14 @@ export {
414
418
  A as on,
415
419
  U as prop,
416
420
  H as register,
417
- ge as selectWidget,
421
+ me as selectWidget,
418
422
  Y as show,
419
- be as slot,
423
+ ve as slot,
420
424
  ee as stack,
421
425
  w as subscribe,
422
426
  oe as subscribeNow,
423
427
  te as template,
424
428
  fe as textareaWidget,
425
- ue as watchAll,
429
+ de as watchAll,
426
430
  V as withScope
427
431
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhi-zone/rainbow-ui",
3
- "version": "0.2.0-alpha.4",
3
+ "version": "0.2.0-alpha.5",
4
4
  "description": "Type-safe DOM factories and algebraic widget combinators for rainbow",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",