@invana/blocks 0.0.32

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 ADDED
@@ -0,0 +1,52 @@
1
+ # @invana/blocks
2
+
3
+ Blocks: reusable drawings built from a JSON spec. The same spec draws in a conversation turn
4
+ (`@invana/assistant`), a board panel (`@invana/boards`) or a page, a report laid out as a
5
+ document. A block renders bare, with no card and no title; the shell around it adds the frame
6
+ and says what its actions mean.
7
+
8
+ ```bash
9
+ pnpm add @invana/blocks
10
+ pnpm add @invana/ui @invana/charts @invana/tables @invana/styling react react-dom
11
+ ```
12
+
13
+ ## A block
14
+
15
+ ```tsx
16
+ import { Block } from "@invana/blocks"
17
+
18
+ <Block
19
+ spec={{ kind: "timeseries", unit: "rounds", series: [{ name: "Rounds", points: [["W1", 0], ["W2", 3]] }] }}
20
+ onAction={(action) => console.log(action)}
21
+ />
22
+ ```
23
+
24
+ Every kind lives here (`BLOCKS` in `kinds.ts`); 24 have a renderer, the rest draw a labelled
25
+ placeholder with their JSON. `BlockOptionsByKind` types each one's options; `BLOCK_RENDERERS` maps a
26
+ kind to what draws it.
27
+
28
+ Every block takes the same props: `spec`, and for a block that returns a value `state` (`pending`
29
+ until answered) and `value`. Whatever the reader does comes back through `onAction(action, value?)`:
30
+ `reply` / `change` / `skip` from an ask, `open` from a table holding rows back, `prompt` from a
31
+ suggested question, `scope` with `{ part, value }`, or an action's own id. The shell says what
32
+ each means: the assistant turns them into conversation events, a board into panel actions.
33
+
34
+ ## A page
35
+
36
+ ```tsx
37
+ import { Page } from "@invana/blocks"
38
+
39
+ <Page
40
+ spec={{
41
+ title: "Top accounts that raised a round",
42
+ sections: [
43
+ { blocks: [{ kind: "narrative", text: "**9 of the top 50** raised in the last 90 days." }] },
44
+ { title: "The accounts", blocks: [{ kind: "table", columns, rows }] },
45
+ ],
46
+ }}
47
+ onAction={(action, at) => console.log(action, at.section, at.block)}
48
+ />
49
+ ```
50
+
51
+ Sections run top to bottom with no cards or borders; a section's title is its rule. A
52
+ conversation's long answer opens as a page with `answerToPage(turn)` from `@invana/assistant`.