ranui 0.2.1-alpha.3 → 0.2.1-alpha.4
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/builder.js +1 -1
- package/dist/{builtin-BkM0LLof.js → builtin-1lUEp_ro.js} +1 -1
- package/dist/{button-D0zcnKnG.js → button-Cj-XSCsd.js} +1 -1
- package/dist/button.js +1 -1
- package/dist/{card-CygMndQS.js → card-BHN9Xp4S.js} +1 -1
- package/dist/card.js +1 -1
- package/dist/{checkbox-D5om9aJO.js → checkbox-O_J_n1_W.js} +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{colorpicker-qWnaTlYX.js → colorpicker-mebH0XLm.js} +4 -4
- package/dist/colorpicker.js +1 -1
- package/dist/{content-Rry-U6ir.js → content-YOKzMoc7.js} +1 -1
- package/dist/content.js +1 -1
- package/dist/{dropdown-DzdAR1nI.js → dropdown-CzGAVWYC.js} +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/{factory-BkvRcCOx.js → factory-ZNhcQ4tf.js} +127 -127
- package/dist/{form-CUJpeQ7Q.js → form-B8afuJlF.js} +1 -1
- package/dist/form.js +1 -1
- package/dist/{glass-Bj1Zf8Hy.js → glass-BniIptBE.js} +1 -1
- package/dist/glass.js +1 -1
- package/dist/{icon-CtlZJISZ.js → icon-GZrfSeon.js} +1 -1
- package/dist/icon.js +1 -1
- package/dist/icons.js +1 -1
- package/dist/iife/button.iife.js +1 -1
- package/dist/iife/card.iife.js +1 -1
- package/dist/iife/checkbox.iife.js +1 -1
- package/dist/iife/colorpicker.iife.js +2 -2
- package/dist/iife/content.iife.js +1 -1
- package/dist/iife/dropdown.iife.js +1 -1
- package/dist/iife/form.iife.js +1 -1
- package/dist/iife/glass.iife.js +1 -1
- package/dist/iife/icon.iife.js +1 -1
- package/dist/iife/image.iife.js +1 -1
- package/dist/iife/input.iife.js +1 -1
- package/dist/iife/loading.iife.js +1 -1
- package/dist/iife/math.iife.js +1 -1
- package/dist/iife/mermaid.iife.js +1 -1
- package/dist/iife/message.iife.js +1 -1
- package/dist/iife/modal.iife.js +1 -1
- package/dist/iife/player.iife.js +1 -1
- package/dist/iife/popover.iife.js +1 -1
- package/dist/iife/progress.iife.js +1 -1
- package/dist/iife/radar.iife.js +1 -1
- package/dist/iife/route.iife.js +1 -1
- package/dist/iife/router.iife.js +1 -1
- package/dist/iife/scratch.iife.js +1 -1
- package/dist/iife/section.iife.js +1 -1
- package/dist/iife/select.iife.js +2 -2
- package/dist/iife/skeleton.iife.js +1 -1
- package/dist/iife/tab.iife.js +1 -1
- package/dist/iife/tabpane.iife.js +1 -1
- package/dist/iife/theme-switch.iife.js +1 -1
- package/dist/{image-ILZNlaGc.js → image-CqoQfJoV.js} +1 -1
- package/dist/image.js +1 -1
- package/dist/index.cjs +17 -17
- package/dist/index.iife.js +204 -204
- package/dist/index.js +29 -29
- package/dist/{input-CDH6zY9I.js → input-BlwAXu7I.js} +2 -2
- package/dist/input.js +1 -1
- package/dist/{loading-DJWGih1g.js → loading-M6gWxLbm.js} +1 -1
- package/dist/loading.js +1 -1
- package/dist/{math-DRmkEDSQ.js → math-8E-45Y8e.js} +1 -1
- package/dist/math.js +1 -1
- package/dist/{mermaid-CMhm7npE.js → mermaid-C1oQyPE3.js} +2 -2
- package/dist/mermaid.js +1 -1
- package/dist/{message-BpYJBvYn.js → message-CNdmbeLf.js} +2 -2
- package/dist/message.js +1 -1
- package/dist/{modal-BeQlDYDP.js → modal-gRagDkTb.js} +1 -1
- package/dist/modal.js +1 -1
- package/dist/{player-CQ4e3Yeo.js → player-CAQ5Og2P.js} +2 -2
- package/dist/player.js +1 -1
- package/dist/{popover-eZMnL1F3.js → popover-BZKSLe3D.js} +3 -3
- package/dist/popover.js +1 -1
- package/dist/{progress-DyHgW4Ep.js → progress-vk40tuhm.js} +1 -1
- package/dist/progress.js +1 -1
- package/dist/{radar-D21Rccap.js → radar-Bg0cexzU.js} +1 -1
- package/dist/radar.js +1 -1
- package/dist/{route-pR5P4ann.js → route-CGwS0cd_.js} +1 -1
- package/dist/route.js +1 -1
- package/dist/{router-CewzSH7O.js → router-BK6DEkcN.js} +1 -1
- package/dist/router.js +1 -1
- package/dist/{scratch-BFVsgl-7.js → scratch-ClF1awGi.js} +1 -1
- package/dist/scratch.js +1 -1
- package/dist/{section-DSPCsIxv.js → section-BL0V7Kjf.js} +1 -1
- package/dist/section.js +1 -1
- package/dist/{select-B58nMfB1.js → select-BIFVbQIj.js} +4 -4
- package/dist/select.js +1 -1
- package/dist/{skeleton-DoHYMsTn.js → skeleton-D7JIbROq.js} +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/{tab-BRPdZ9Ws.js → tab-DFVtDJb2.js} +1 -1
- package/dist/tab.js +1 -1
- package/dist/{tabpane-Owf72hw_.js → tabpane-C3qZGN-D.js} +1 -1
- package/dist/tabpane.js +1 -1
- package/dist/test/ssr/stream.test.d.ts +1 -0
- package/dist/{theme-switch-CZDIIonc.js → theme-switch-BXNH5uPD.js} +44 -44
- package/dist/theme-switch.js +1 -1
- package/dist/utils/builder/core.d.ts +15 -13
- package/docs/BUILDER.md +15 -0
- package/package.json +1 -1
package/dist/skeleton.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as b, c, n as f, o as v, r as d, t as p } from "./utils-D1iZnChu.js";
|
|
2
2
|
import { t as u } from "./events-C59wGdni.js";
|
|
3
|
-
import { _ as g, i as h, p as y } from "./factory-
|
|
3
|
+
import { _ as g, i as h, p as y } from "./factory-ZNhcQ4tf.js";
|
|
4
4
|
import { a as A, n as _ } from "./ssr-DSGwPtEd.js";
|
|
5
5
|
var w = '.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.ran-tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.ran-tab-header-nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.ran-tab-header-nav::-webkit-scrollbar{display:none}.ran-tab-header-nav-item{flex-shrink:0}.ran-tab-header-nav .active{color:var(--ran-tab-active-color, var(--ran-color-primary, #006bff))}.ran-tab-header-line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--ran-tab-line-color, var(--ran-color-primary, #006bff));transition:var(--ran-tab-line-transition, left .2s, width .2s, transform .2s)}.ran-tab-content{overflow:hidden}.ran-tab-content-wrap{display:flex;width:100%;height:100%;transition:var(--ran-tab-content-transition, transform .2s)}:host([type="line"]) .ran-tab-header-nav-item{border:solid 1px transparent}:host([type="line"]) .ran-tab-header-nav .active{color:var(--ran-tab-line-color, var(--ran-color-primary, #006bff));border:solid 1px transparent;border-color:var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2))) var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2))) transparent;border-radius:var(--ran-tab-border-radius, var(--ran-radius-sm, .25em)) var(--ran-tab-border-radius, var(--ran-radius-sm, .25em)) 0 0}:host([type="line"]) .ran-tab-header-line{transition:none;visibility:hidden}:host([type="line"]) .ran-tab-header-line:after,:host([type="line"]) .ran-tab-header-line:before{content:"";position:absolute;visibility:visible;width:9999px;height:1px;bottom:0;background:var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2)))}:host([type="line"]) .ran-tab-header-line:after{left:100%}:host([type="line"]) .ran-tab-header-line:before{right:100%}:host([align="center"]) .ran-tab-header-nav{justify-content:center}:host([align="center"]) .ran-tab-header-line{left:50%}:host([align="end"]) .ran-tab-header-nav{justify-content:flex-end}', x = 0, m = class extends _ {
|
|
6
6
|
static get observedAttributes() {
|
package/dist/tab.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as s, n as r, o as a, t as n } from "./utils-D1iZnChu.js";
|
|
2
2
|
import { t as h } from "./events-C59wGdni.js";
|
|
3
|
-
import { p as o } from "./factory-
|
|
3
|
+
import { p as o } from "./factory-ZNhcQ4tf.js";
|
|
4
4
|
import { a as b, n as c } from "./ssr-DSGwPtEd.js";
|
|
5
5
|
var u = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}", d = class extends c {
|
|
6
6
|
static get observedAttributes() {
|
package/dist/tabpane.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { a as i, n as o, o as h, r as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { i as
|
|
5
|
-
|
|
1
|
+
import { a as i, n as o, o as h, r as l, t as c } from "./utils-D1iZnChu.js";
|
|
2
|
+
import { c as d } from "./mocks-CMGoftIc.js";
|
|
3
|
+
import { t as u } from "./events-C59wGdni.js";
|
|
4
|
+
import { i as m, n as b } from "./factory-ZNhcQ4tf.js";
|
|
5
|
+
import { a as v, n as p } from "./ssr-DSGwPtEd.js";
|
|
6
|
+
import { i as g, n as w } from "./theme-kOWZbKCq.js";
|
|
7
|
+
var f = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-theme-switch-display, inline-flex);box-sizing:border-box}.ran-theme-switch{display:inline-flex;align-items:center;gap:var(--ran-theme-switch-gap, 2px);padding:var(--ran-theme-switch-padding, 2px);border-width:var(--ran-skin-border-width, 1px);border-style:var(--ran-skin-border-style, solid);border-color:var(--ran-theme-switch-border-color, var(--ran-color-border, #eaeaea));border-radius:var(--ran-theme-switch-radius, var(--ran-radius-full, 9999px));background:var(--ran-theme-switch-background, transparent);box-sizing:border-box}.ran-theme-switch button{width:var(--ran-theme-switch-button-size, 28px);height:var(--ran-theme-switch-button-size, 28px);display:grid;place-items:center;border:none;border-radius:var(--ran-theme-switch-radius, var(--ran-radius-full, 9999px));background:transparent;color:var(--ran-theme-switch-color, var(--ran-color-text-secondary, #4d4d4d));cursor:pointer;padding:0}.ran-theme-switch button:hover{color:var(--ran-theme-switch-hover-color, var(--ran-color-text, #171717))}.ran-theme-switch button[aria-pressed=true]{background:var(--ran-theme-switch-active-background, var(--ran-color-bg-hover, #ebebeb));color:var(--ran-theme-switch-active-color, var(--ran-color-text, #171717))}.ran-theme-switch button:focus-visible{outline:var(--ran-theme-switch-focus-outline, 2px solid var(--ran-color-primary, #006bff));outline-offset:2px}.ran-theme-switch svg{width:var(--ran-theme-switch-icon-size, 16px);height:var(--ran-theme-switch-icon-size, 16px)}", a = [
|
|
6
8
|
"system",
|
|
7
9
|
"light",
|
|
8
10
|
"dark"
|
|
9
|
-
],
|
|
11
|
+
], y = {
|
|
10
12
|
system: '<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="1.5" y="2.5" width="13" height="9" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M5.5 14h5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
11
13
|
light: '<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M8 1v1.8M8 13.2V15M15 8h-1.8M2.8 8H1m11.4-4.4-1.3 1.3M4.9 11.1l-1.3 1.3m9.8 0-1.3-1.3M4.9 4.9 3.6 3.6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
12
14
|
dark: '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M13.5 9.5A6 6 0 0 1 6.5 2.5a6 6 0 1 0 7 7z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>'
|
|
13
|
-
}, s = "ran-theme-switch-sync",
|
|
15
|
+
}, s = "ran-theme-switch-sync", _ = class extends p {
|
|
14
16
|
static get observedAttributes() {
|
|
15
17
|
return [
|
|
16
18
|
"label-system",
|
|
@@ -19,70 +21,68 @@ var g = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transpar
|
|
|
19
21
|
"sheet"
|
|
20
22
|
];
|
|
21
23
|
}
|
|
22
|
-
_events = new
|
|
24
|
+
_events = new u();
|
|
23
25
|
_shadowDom;
|
|
24
26
|
_group;
|
|
25
27
|
constructor() {
|
|
26
|
-
super(), this._shadowDom = o(this,
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
return e;
|
|
28
|
+
super(), this._shadowDom = o(this, f), this._group = c(this._shadowDom, ".ran-theme-switch", () => {
|
|
29
|
+
const t = a.map((e) => {
|
|
30
|
+
const r = b().attr("type", "button").data("choice", e).attr("part", `button ${e}`).aria("pressed", "false").build();
|
|
31
|
+
return d || (r.innerHTML = y[e]), r;
|
|
32
|
+
});
|
|
33
|
+
return m().class("ran-theme-switch").attr("part", "switch").role("group").children(t).build();
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
get sheet() {
|
|
37
|
-
return
|
|
37
|
+
return l(this, "sheet");
|
|
38
38
|
}
|
|
39
|
-
set sheet(
|
|
40
|
-
i(this, "sheet",
|
|
39
|
+
set sheet(t) {
|
|
40
|
+
i(this, "sheet", t);
|
|
41
41
|
}
|
|
42
42
|
get value() {
|
|
43
|
-
return
|
|
43
|
+
return w() || "system";
|
|
44
44
|
}
|
|
45
|
-
set value(
|
|
46
|
-
a.includes(
|
|
45
|
+
set value(t) {
|
|
46
|
+
a.includes(t) && this._select(t);
|
|
47
47
|
}
|
|
48
|
-
_label(
|
|
49
|
-
const
|
|
48
|
+
_label(t) {
|
|
49
|
+
const e = {
|
|
50
50
|
system: "System theme",
|
|
51
51
|
light: "Light theme",
|
|
52
52
|
dark: "Dark theme"
|
|
53
|
-
}[
|
|
54
|
-
return this.getAttribute(`label-${
|
|
53
|
+
}[t];
|
|
54
|
+
return this.getAttribute(`label-${t}`) || e;
|
|
55
55
|
}
|
|
56
56
|
_syncLabels() {
|
|
57
57
|
this._group.setAttribute("aria-label", this.getAttribute("label") || "Theme");
|
|
58
|
-
for (const
|
|
58
|
+
for (const t of this._group.querySelectorAll("button")) t.setAttribute("aria-label", this._label(t.dataset.choice));
|
|
59
59
|
}
|
|
60
60
|
_reflect() {
|
|
61
|
-
const
|
|
62
|
-
for (const
|
|
61
|
+
const t = this.value;
|
|
62
|
+
for (const e of this._group.querySelectorAll("button")) e.setAttribute("aria-pressed", e.dataset.choice === t ? "true" : "false");
|
|
63
63
|
}
|
|
64
|
-
_select(
|
|
65
|
-
|
|
66
|
-
detail: { theme:
|
|
64
|
+
_select(t) {
|
|
65
|
+
g(t), this._reflect(), this._syncMeta(t), document.dispatchEvent(new CustomEvent(s)), this.dispatchEvent(new CustomEvent("change", {
|
|
66
|
+
detail: { theme: t },
|
|
67
67
|
bubbles: !0,
|
|
68
68
|
composed: !0
|
|
69
69
|
}));
|
|
70
70
|
}
|
|
71
|
-
_syncMeta(
|
|
71
|
+
_syncMeta(t) {
|
|
72
72
|
if (typeof requestAnimationFrame > "u") return;
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
for (const r of
|
|
76
|
-
if (r.dataset.ranOriginalContent === void 0 && (r.dataset.ranOriginalContent = r.getAttribute("content") || ""),
|
|
73
|
+
const e = document.querySelectorAll('meta[name="theme-color"]');
|
|
74
|
+
e.length && requestAnimationFrame(() => {
|
|
75
|
+
for (const r of e)
|
|
76
|
+
if (r.dataset.ranOriginalContent === void 0 && (r.dataset.ranOriginalContent = r.getAttribute("content") || ""), t === "system") r.setAttribute("content", r.dataset.ranOriginalContent);
|
|
77
77
|
else {
|
|
78
78
|
const n = getComputedStyle(document.documentElement).getPropertyValue("--ran-color-bg").trim() || getComputedStyle(document.body).backgroundColor;
|
|
79
79
|
r.setAttribute("content", n);
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
_handleClick = (
|
|
84
|
-
const
|
|
85
|
-
|
|
83
|
+
_handleClick = (t) => {
|
|
84
|
+
const e = t.target.closest?.("button")?.dataset.choice;
|
|
85
|
+
e && a.includes(e) && this._select(e);
|
|
86
86
|
};
|
|
87
87
|
_handleSync = () => this._reflect();
|
|
88
88
|
handlerExternalCss = () => {
|
|
@@ -94,11 +94,11 @@ var g = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transpar
|
|
|
94
94
|
disconnectedCallback() {
|
|
95
95
|
this._events.abort(), document.removeEventListener(s, this._handleSync), typeof window < "u" && window.removeEventListener("storage", this._handleSync);
|
|
96
96
|
}
|
|
97
|
-
attributeChangedCallback(
|
|
98
|
-
|
|
97
|
+
attributeChangedCallback(t, e, r) {
|
|
98
|
+
e !== r && (t === "sheet" && this.handlerExternalCss(), t.startsWith("label") && this._syncLabels());
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
|
|
101
|
+
v("r-theme-switch", _);
|
|
102
102
|
export {
|
|
103
|
-
|
|
103
|
+
_ as t
|
|
104
104
|
};
|
package/dist/theme-switch.js
CHANGED
|
@@ -8,13 +8,14 @@ export declare const createRef: <T extends HTMLElement = HTMLElement>() => Ref<T
|
|
|
8
8
|
* Internal helper — the public, general type is {@link Child}. */
|
|
9
9
|
type StaticChild = HTMLElement | string | ElementBuilder<any> | undefined | null;
|
|
10
10
|
/**
|
|
11
|
-
* The one type every `children()` / `replaceChildren()` argument accepts
|
|
12
|
-
* a node, text, nested builder, `null`/`undefined`,
|
|
13
|
-
* a
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* The one type every `children()` / `replaceChildren()` argument accepts —
|
|
12
|
+
* fully composable (recursive): a node, text, nested builder, `null`/`undefined`,
|
|
13
|
+
* a (nested) array, a {@link For}/{@link Index} handle for a keyed list, or a
|
|
14
|
+
* getter `() => Child` marking a reactive region. A getter (or `Show`/`Switch`
|
|
15
|
+
* branch) may itself return any `Child`, including a `For`/`Index` or another
|
|
16
|
+
* getter — control-flow nests freely. On SSR getters / `For` / `Index` render once.
|
|
16
17
|
*/
|
|
17
|
-
export type Child = StaticChild |
|
|
18
|
+
export type Child = StaticChild | ForHandle | IndexHandle | Child[] | (() => Child);
|
|
18
19
|
declare const FOR_BRAND = "__ranFor";
|
|
19
20
|
/** Options for {@link For}. */
|
|
20
21
|
export interface ForOptions<T> {
|
|
@@ -54,11 +55,12 @@ export declare function For<T>(options: ForOptions<T>): ForHandle;
|
|
|
54
55
|
export interface ShowOptions<T> {
|
|
55
56
|
/** Condition source. Truthy → `children`, falsy → `fallback`. */
|
|
56
57
|
when: () => T;
|
|
57
|
-
/** Built when `when` is truthy.
|
|
58
|
+
/** Built when `when` is truthy. May return any {@link Child} — a `For`/`Index`
|
|
59
|
+
* list, a nested `Show`, etc. Receives an accessor to the narrowed value —
|
|
58
60
|
* read it inside a binding (`.text(() => v())`) to update without rebuilding. */
|
|
59
|
-
children: (value: () => NonNullable<T>) =>
|
|
61
|
+
children: (value: () => NonNullable<T>) => Child;
|
|
60
62
|
/** Built when `when` is falsy. Omitted → nothing is rendered. */
|
|
61
|
-
fallback?: () =>
|
|
63
|
+
fallback?: () => Child;
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
66
|
* Fine-grained conditional child. Unlike a raw getter child (which re-runs on
|
|
@@ -76,11 +78,11 @@ export interface ShowOptions<T> {
|
|
|
76
78
|
* `Show` returns a getter, so it is accepted anywhere `children()` takes a child.
|
|
77
79
|
* Must be created inside a `createRoot` (it owns a memo + the branch effect).
|
|
78
80
|
*/
|
|
79
|
-
export declare function Show<T>(options: ShowOptions<T>): () =>
|
|
81
|
+
export declare function Show<T>(options: ShowOptions<T>): () => Child;
|
|
80
82
|
/** One branch of a {@link Switch}; build with {@link Match}. */
|
|
81
83
|
export interface MatchClause<T> {
|
|
82
84
|
when: () => T;
|
|
83
|
-
children: (value: () => NonNullable<T>) =>
|
|
85
|
+
children: (value: () => NonNullable<T>) => Child;
|
|
84
86
|
}
|
|
85
87
|
/** Declare one `Switch` branch (identity helper — gives per-clause type inference). */
|
|
86
88
|
export declare function Match<T>(clause: MatchClause<T>): MatchClause<T>;
|
|
@@ -90,7 +92,7 @@ export interface SwitchOptions {
|
|
|
90
92
|
* heterogeneous (each `Match<T>` carries its own `T`), hence `any` here. */
|
|
91
93
|
children: MatchClause<any>[];
|
|
92
94
|
/** Rendered when no branch matches. Omitted → nothing. */
|
|
93
|
-
fallback?: () =>
|
|
95
|
+
fallback?: () => Child;
|
|
94
96
|
}
|
|
95
97
|
/**
|
|
96
98
|
* Fine-grained multi-branch conditional (the n-way `Show`). Renders the first
|
|
@@ -107,7 +109,7 @@ export interface SwitchOptions {
|
|
|
107
109
|
* ],
|
|
108
110
|
* })
|
|
109
111
|
*/
|
|
110
|
-
export declare function Switch(options: SwitchOptions): () =>
|
|
112
|
+
export declare function Switch(options: SwitchOptions): () => Child;
|
|
111
113
|
declare const INDEX_BRAND = "__ranIndex";
|
|
112
114
|
/** Options for {@link Index}. */
|
|
113
115
|
export interface IndexOptions<T> {
|
package/docs/BUILDER.md
CHANGED
|
@@ -195,6 +195,21 @@ Div().children(
|
|
|
195
195
|
binding so it updates without rebuilding. `Show` returns a getter, so it slots
|
|
196
196
|
into `children()` anywhere.
|
|
197
197
|
|
|
198
|
+
**Control flow composes.** A `Show`/`Switch` branch (and any reactive getter) may
|
|
199
|
+
return **any `Child`** — including a `For`/`Index` list or a nested `Show` — no
|
|
200
|
+
wrapper element needed:
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
Show({
|
|
204
|
+
when: () => loaded(),
|
|
205
|
+
children: () => For({ each: () => rows(), key: (r) => r.id, render: (r) => Li().text(r.title) }),
|
|
206
|
+
fallback: () => Spinner(),
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
When the branch flips away, the nested list's scope (its effects) is disposed and
|
|
211
|
+
its nodes removed; re-entering rebuilds fresh from the current source.
|
|
212
|
+
|
|
198
213
|
### Multi-branch — `Switch` / `Match`
|
|
199
214
|
|
|
200
215
|
`Switch` is the n-way `Show`: it renders the **first** `Match` whose `when` is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranui",
|
|
3
|
-
"version": "0.2.1-alpha.
|
|
3
|
+
"version": "0.2.1-alpha.4",
|
|
4
4
|
"description": "A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|