@lionlang/ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,33 @@
1
- # Temporary Holding Version
1
+ # @lionlang/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Declarative, interactive, and streaming UI bindings and DOM renderer for Lion.
4
+
5
+ - **Pure Lion data:** every `ui/*` call (`ui/stack`, `ui/card`, `ui/metric`, `ui/alert`, `ui/table`, `ui/slider`, `ui/select`, `ui/toggle`, `ui/why`, `ui/proof`, ...) returns plain JSON-serializable nodes with zero DOM dependency.
6
+ - **Reactive state via Lion's logic database:** interactive controls carry quoted Lion actions (`onChange`, `onClick`) that update keyed facts and re-derive the view in memory.
7
+ - **Streaming UI:** stream newline-delimited Lion forms (`fact`, `rule`, `define`) into `createUiSession()` and re-render automatically as rules fire.
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { Effect } from "effect";
13
+ import { createUiSession } from "@lionlang/ui";
14
+ import { renderUi } from "@lionlang/ui/dom";
15
+ import "@lionlang/ui/styles.css";
16
+
17
+ const session = createUiSession();
18
+ const tree = await Effect.runPromise(session.load(program));
19
+ renderUi(tree, container, {
20
+ onAction: async (action, value) => {
21
+ const next = await Effect.runPromise(session.dispatch(action, value));
22
+ renderUi(next, container, { onAction });
23
+ },
24
+ });
25
+ ```
26
+
27
+ ## Customizing CSS
28
+
29
+ `@lionlang/ui` supports three levels of styling control:
30
+
31
+ 1. **CSS custom properties (`@lionlang/ui/styles.css`):** override `--lion-ui-bg`, `--lion-ui-surface`, `--lion-ui-surface-elevated`, `--lion-ui-border`, `--lion-ui-fg`, `--lion-ui-muted`, `--lion-ui-accent`, `--lion-ui-radius`, `--lion-ui-font-sans`, `--lion-ui-font-mono`, etc., or pass `theme: "light"` (`data-lion-theme="light"`).
32
+ 2. **Per-slot class overrides:** pass `classes: { card: "...", button: "...", selectTrigger: "...", selectMenu: "..." }` to `renderUi()` (and optionally `unstyled: true` to omit default `lion-ui-*` classes for Tailwind or CSS Modules).
33
+ 3. **Per-node classes:** any `ui/*` node accepts `{"className": "..."}` in its props.
package/dist/dom.d.mts ADDED
@@ -0,0 +1,20 @@
1
+ import { UiNode } from "./types.mjs";
2
+
3
+ //#region src/dom.d.ts
4
+ interface RenderUiOptions {
5
+ /** Extra or replacement class names keyed by slot (e.g. `"card"`, `"selectTrigger"`, `"selectMenu"`). */
6
+ readonly classes?: Readonly<Partial<Record<string, string>>>;
7
+ /** Called when the user interacts with a control that carries an action. */
8
+ readonly onAction?: (action: unknown, value?: unknown) => void;
9
+ /** Optional theme preset applied as `data-lion-theme` on the container. */
10
+ readonly theme?: "dark" | "light";
11
+ /** Omit default `lion-ui-*` class names when using custom `classes` only. */
12
+ readonly unstyled?: boolean;
13
+ }
14
+ /**
15
+ * Renders (or patches in place) a Lion UI node into `container`.
16
+ */
17
+ declare const renderUi: (node: UiNode, container: HTMLElement, options?: RenderUiOptions) => void;
18
+ //#endregion
19
+ export { RenderUiOptions, renderUi };
20
+ //# sourceMappingURL=dom.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.mts","names":[],"sources":["../src/dom.ts"],"mappings":";;;UAiBiB,eAAA;EAIuB;EAAA,SAF7B,OAAA,GAAU,QAAA,CAAS,OAAA,CAAQ,MAAA;EAM3B;EAAA,SAJA,QAAA,IAAY,MAAA,WAAiB,KAAA;EAIrB;EAAA,SAFR,KAAA;EA+pCV;EAAA,SA7pCU,QAAA;AAAA;;;;cAqoCE,QAAA,GACX,IAAA,EAAM,MAAA,EACN,SAAA,EAAW,WAAA,EACX,OAAA,GAAS,eAAA"}