@onioneko/boardkit-blocks 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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/chart.d.ts +19 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +24 -0
- package/dist/chart.js.map +1 -0
- package/dist/checklist.d.ts +24 -0
- package/dist/checklist.d.ts.map +1 -0
- package/dist/checklist.js +97 -0
- package/dist/checklist.js.map +1 -0
- package/dist/form.d.ts +26 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +74 -0
- package/dist/form.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/metric.d.ts +22 -0
- package/dist/metric.d.ts.map +1 -0
- package/dist/metric.js +34 -0
- package/dist/metric.js.map +1 -0
- package/dist/rule.d.ts +19 -0
- package/dist/rule.d.ts.map +1 -0
- package/dist/rule.js +44 -0
- package/dist/rule.js.map +1 -0
- package/dist/status.d.ts +22 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +82 -0
- package/dist/status.js.map +1 -0
- package/package.json +64 -0
- package/src/chart.ts +43 -0
- package/src/checklist.ts +123 -0
- package/src/form.ts +101 -0
- package/src/index.ts +45 -0
- package/src/metric.ts +58 -0
- package/src/rule.ts +64 -0
- package/src/status.ts +103 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BoardKit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @onioneko/boardkit-blocks
|
|
2
|
+
|
|
3
|
+
BoardKit's reference block pack: six stateful document
|
|
4
|
+
components you register yourself, like any block type — pass `starterBlocks`
|
|
5
|
+
via `createEngine({ blocks })`, or add individual types with
|
|
6
|
+
`engine.registerBlock`. Nothing registers by default; hosts may trim or
|
|
7
|
+
replace this pack wholesale — it is not part of the core API.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createEngine } from "@onioneko/boardkit-core";
|
|
11
|
+
import { starterBlocks } from "@onioneko/boardkit-blocks";
|
|
12
|
+
|
|
13
|
+
const engine = createEngine({
|
|
14
|
+
storage,
|
|
15
|
+
blocks: starterBlocks,
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Blocks
|
|
20
|
+
|
|
21
|
+
| Block | State (attrs) | Transition events | Affordances | text projection | html projection |
|
|
22
|
+
|---|---|---|---|---|---|
|
|
23
|
+
| `checklist` | `items[{id,label,done}]` | `checklist.item.done` / `.undone` | `toggle(itemId)` | `- [ ]` / `- [x]` list | interactive checkboxes (`data-intent`) |
|
|
24
|
+
| `status` | `states[]` (ordered), `value`, `note` | `status.changed` | `transition(to)` | `**STATUS**: pending` | badge + transition buttons (`data-intent`); current value in `data-state` |
|
|
25
|
+
| `metric` | `label`, `source`, `view`, `thresholds?` | — | — | `label: value` (live via source id) | labeled value |
|
|
26
|
+
| `chart` | `type`, `source`, `spec` (opaque chart-source DSL) | — | — | spec verbatim (machine-readable) | `<pre>` fallback |
|
|
27
|
+
| `form` | `fields[{id,label,type,options?}]`, `status`, `answer?` | `form.answered` | `answer(values)` | question text + options | form fields |
|
|
28
|
+
| `rule` | `when`, `do` (opaque strings), `enabled` | `rule.enabled` | `toggle()` | rule text with state | switch (`data-intent`) |
|
|
29
|
+
|
|
30
|
+
## Notes and deviations
|
|
31
|
+
|
|
32
|
+
1. **The `checklist` item transition is directional.** `items[].done` emits
|
|
33
|
+
`checklist.item.done` on `false→true` and `checklist.item.undone` on
|
|
34
|
+
`true→false`; both events also carry the `from`/`to` booleans.
|
|
35
|
+
2. **`chart` renders as `<pre>` in html.** The library does not know chart
|
|
36
|
+
libraries; hosts register their own block type (or renderer) to replace the
|
|
37
|
+
fallback. The text projection always emits the spec verbatim.
|
|
38
|
+
3. **Schemas are plain JSON Schema literals** (no @sinclair/typebox in this
|
|
39
|
+
package) — one artifact, zero codegen, contributor-friendly.
|
|
40
|
+
4. Interactive html hooks annotate elements with `data-intent` payloads; the
|
|
41
|
+
html projection's sanitize schema allows `className`, `id`, `data-intent`,
|
|
42
|
+
`data-source` and `data-state`. View adapters translate those annotations
|
|
43
|
+
into Intents. The blocks in this pack never put attr values into
|
|
44
|
+
`className`: the `status` block renders `<div class="status" data-state="…">`,
|
|
45
|
+
so style a state with `.status[data-state="approved"]`.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
[MIT](https://github.com/onioneko/boardkit/blob/main/packages/blocks/LICENSE)
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BlockType } from "@onioneko/boardkit-core";
|
|
2
|
+
/**
|
|
3
|
+
* starter block: chart — an opaque chart source. The text hook emits the spec
|
|
4
|
+
* verbatim (machine-readable); the html hook falls back to a `<pre>` because
|
|
5
|
+
* the library does not know chart libraries — hosts register their own block
|
|
6
|
+
* type (or renderer) to replace this fallback.
|
|
7
|
+
*
|
|
8
|
+
* Usage: a chart body carries `{ id, type, source, spec }`; `spec` is the
|
|
9
|
+
* chart's own DSL and is rendered untouched.
|
|
10
|
+
*/
|
|
11
|
+
/** Attrs for the `chart` block, mirroring its JSON Schema. */
|
|
12
|
+
export type ChartAttrs = {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly type: string;
|
|
15
|
+
readonly source: string;
|
|
16
|
+
readonly spec: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const chartBlock: BlockType<ChartAttrs>;
|
|
19
|
+
//# sourceMappingURL=chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../src/chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;;;;;GAQG;AAEH,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,SAAS,CAAC,UAAU,CAsB5C,CAAC"}
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const chartBlock = {
|
|
2
|
+
type: "chart",
|
|
3
|
+
schema: {
|
|
4
|
+
type: "object",
|
|
5
|
+
required: ["id", "type", "source", "spec"],
|
|
6
|
+
properties: {
|
|
7
|
+
id: { type: "string" },
|
|
8
|
+
type: { type: "string" },
|
|
9
|
+
source: { type: "string" },
|
|
10
|
+
spec: { type: "string" },
|
|
11
|
+
},
|
|
12
|
+
additionalProperties: false,
|
|
13
|
+
},
|
|
14
|
+
project: {
|
|
15
|
+
text: (attrs) => String(attrs.spec),
|
|
16
|
+
html: (attrs) => ({
|
|
17
|
+
type: "element",
|
|
18
|
+
tagName: "pre",
|
|
19
|
+
properties: { className: ["chart"], "data-source": String(attrs.source) },
|
|
20
|
+
children: [{ type: "text", value: String(attrs.spec) }],
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.js","sourceRoot":"","sources":["../src/chart.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,UAAU,GAA0B;IAC/C,IAAI,EAAE,OAAO;IACb,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC;QAC1C,UAAU,EAAE;YACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACtB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzB;QACD,oBAAoB,EAAE,KAAK;KAC5B;IACD,OAAO,EAAE;QACP,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;QACnC,IAAI,EAAE,CAAC,KAAK,EAAwB,EAAE,CAAC,CAAC;YACtC,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;YACzE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;SACxD,CAAC;KACH;CACF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BlockType } from "@onioneko/boardkit-core";
|
|
2
|
+
/**
|
|
3
|
+
* starter block: checklist — a list of labeled checkbox items. Each item is
|
|
4
|
+
* `{ id, label, done }`; the `toggle` affordance flips one item's `done` flag.
|
|
5
|
+
*
|
|
6
|
+
* The item-toggle transition names events by direction: checking a box emits
|
|
7
|
+
* `checklist.item.done` (false→true), unchecking it emits
|
|
8
|
+
* `checklist.item.undone` (true→false); both carry the `from`/`to` booleans.
|
|
9
|
+
*
|
|
10
|
+
* Usage: include in `createEngine({ blocks })` and add `"checklist"` to the
|
|
11
|
+
* parse options' `blockTypes` set so checklist fences are parsed as blocks.
|
|
12
|
+
*/
|
|
13
|
+
/** Attrs for the `checklist` block, mirroring its JSON Schema. */
|
|
14
|
+
export type ChecklistAttrs = {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly title?: string;
|
|
17
|
+
readonly items: readonly {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly label: string;
|
|
20
|
+
readonly done: boolean;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
export declare const checklistBlock: BlockType<ChecklistAttrs>;
|
|
24
|
+
//# sourceMappingURL=checklist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checklist.d.ts","sourceRoot":"","sources":["../src/checklist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;;;;;;;GAUG;AAEH,kEAAkE;AAClE,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS;QACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;KACxB,EAAE,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,cAAc,CAiGpD,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export const checklistBlock = {
|
|
2
|
+
type: "checklist",
|
|
3
|
+
schema: {
|
|
4
|
+
type: "object",
|
|
5
|
+
required: ["id", "items"],
|
|
6
|
+
properties: {
|
|
7
|
+
id: { type: "string" },
|
|
8
|
+
title: { type: "string" },
|
|
9
|
+
items: {
|
|
10
|
+
type: "array",
|
|
11
|
+
items: {
|
|
12
|
+
type: "object",
|
|
13
|
+
required: ["id", "label", "done"],
|
|
14
|
+
properties: {
|
|
15
|
+
id: { type: "string" },
|
|
16
|
+
label: { type: "string" },
|
|
17
|
+
done: { type: "boolean" },
|
|
18
|
+
},
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
},
|
|
25
|
+
transitions: [
|
|
26
|
+
{
|
|
27
|
+
attr: "items[].done",
|
|
28
|
+
events: {
|
|
29
|
+
"false→true": "checklist.item.done",
|
|
30
|
+
"true→false": "checklist.item.undone",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
affordances: [
|
|
35
|
+
{
|
|
36
|
+
name: "toggle",
|
|
37
|
+
params: {
|
|
38
|
+
type: "object",
|
|
39
|
+
required: ["itemId"],
|
|
40
|
+
properties: { itemId: { type: "string" } },
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
},
|
|
43
|
+
patch: (attrs, params) => {
|
|
44
|
+
const itemId = params.itemId;
|
|
45
|
+
const items = attrs.items.map((item) => item.id === itemId ? { ...item, done: !item.done } : item);
|
|
46
|
+
return { items };
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
project: {
|
|
51
|
+
text: (attrs) => {
|
|
52
|
+
const items = attrs.items;
|
|
53
|
+
return items.map((item) => `- [${item.done ? "x" : " "}] ${item.label}`).join("\n");
|
|
54
|
+
},
|
|
55
|
+
html: (attrs) => {
|
|
56
|
+
const items = attrs.items;
|
|
57
|
+
return {
|
|
58
|
+
type: "element",
|
|
59
|
+
tagName: "ul",
|
|
60
|
+
properties: { className: ["checklist"] },
|
|
61
|
+
// Each item's input and label text are wrapped in a `<label>` so a
|
|
62
|
+
// click anywhere on the item — not just the tiny box — toggles it
|
|
63
|
+
// natively; `data-intent` stays on the `<input>` itself (the existing
|
|
64
|
+
// contract the page's `closest('[data-intent]')` handler reads).
|
|
65
|
+
children: items.map((item) => ({
|
|
66
|
+
type: "element",
|
|
67
|
+
tagName: "li",
|
|
68
|
+
properties: {},
|
|
69
|
+
children: [
|
|
70
|
+
{
|
|
71
|
+
type: "element",
|
|
72
|
+
tagName: "label",
|
|
73
|
+
properties: {},
|
|
74
|
+
children: [
|
|
75
|
+
{
|
|
76
|
+
type: "element",
|
|
77
|
+
tagName: "input",
|
|
78
|
+
properties: {
|
|
79
|
+
type: "checkbox",
|
|
80
|
+
...(item.done ? { checked: true } : {}),
|
|
81
|
+
"data-intent": JSON.stringify({
|
|
82
|
+
affordance: "toggle",
|
|
83
|
+
params: { itemId: item.id },
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
children: [],
|
|
87
|
+
},
|
|
88
|
+
{ type: "text", value: item.label },
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
})),
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=checklist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checklist.js","sourceRoot":"","sources":["../src/checklist.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,cAAc,GAA8B;IACvD,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC;QACzB,UAAU,EAAE;YACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;oBACjC,UAAU,EAAE;wBACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACzB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;qBAC1B;oBACD,oBAAoB,EAAE,KAAK;iBAC5B;aACF;SACF;QACD,oBAAoB,EAAE,KAAK;KAC5B;IACD,WAAW,EAAE;QACX;YACE,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE;gBACN,YAAY,EAAE,qBAAqB;gBACnC,YAAY,EAAE,uBAAuB;aACtC;SACF;KACF;IACD,WAAW,EAAE;QACX;YACE,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,CAAC,QAAQ,CAAC;gBACpB,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;gBAC1C,oBAAoB,EAAE,KAAK;aAC5B;YACD,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;gBACv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E,IAAI,EAAE,SAAS;oCACf,OAAO,EAAE,OAAO;oCAChB,UAAU,EAAE;wCACV,IAAI,EAAE,UAAU;wCAChB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wCACvC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC;4CAC5B,UAAU,EAAE,QAAQ;4CACpB,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;yCAC5B,CAAC;qCACH;oCACD,QAAQ,EAAE,EAAE;iCACb;gCACD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;6BACpC;yBACF;qBACF;iBACF,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
|
package/dist/form.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BlockType } from "@onioneko/boardkit-core";
|
|
2
|
+
/**
|
|
3
|
+
* starter block: form — a question with typed fields. Answering is the `answer`
|
|
4
|
+
* affordance; the view adapter assembles entered values into the intent params
|
|
5
|
+
* at interaction time (outside the block's concern).
|
|
6
|
+
*
|
|
7
|
+
* Usage: a form has `fields` (each with `id`, `label`, `type`, and optional
|
|
8
|
+
* `options`) and a `status` of `open` or `answered`. The `answer` affordance
|
|
9
|
+
* stores the assembled values in `answer`, flips `status` to `answered`, and
|
|
10
|
+
* emits `form.answered`.
|
|
11
|
+
*/
|
|
12
|
+
/** Attrs for the `form` block, mirroring its JSON Schema. */
|
|
13
|
+
export type FormAttrs = {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly title?: string;
|
|
16
|
+
readonly fields: readonly {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly label: string;
|
|
19
|
+
readonly type: "text" | "select" | "number";
|
|
20
|
+
readonly options?: readonly string[];
|
|
21
|
+
}[];
|
|
22
|
+
readonly status: "open" | "answered";
|
|
23
|
+
readonly answer?: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
export declare const formBlock: BlockType<FormAttrs>;
|
|
26
|
+
//# sourceMappingURL=form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;;;;;;GASG;AAEH,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS;QACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;QAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KACtC,EAAE,CAAC;IACJ,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,SAAS,CAyE1C,CAAC"}
|
package/dist/form.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const formBlock = {
|
|
2
|
+
type: "form",
|
|
3
|
+
schema: {
|
|
4
|
+
type: "object",
|
|
5
|
+
required: ["id", "fields", "status"],
|
|
6
|
+
properties: {
|
|
7
|
+
id: { type: "string" },
|
|
8
|
+
title: { type: "string" },
|
|
9
|
+
fields: {
|
|
10
|
+
type: "array",
|
|
11
|
+
items: {
|
|
12
|
+
type: "object",
|
|
13
|
+
required: ["id", "label", "type"],
|
|
14
|
+
properties: {
|
|
15
|
+
id: { type: "string" },
|
|
16
|
+
label: { type: "string" },
|
|
17
|
+
type: { enum: ["text", "select", "number"] },
|
|
18
|
+
options: { type: "array", items: { type: "string" } },
|
|
19
|
+
},
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
status: { enum: ["open", "answered"] },
|
|
24
|
+
answer: { type: "object" },
|
|
25
|
+
},
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
},
|
|
28
|
+
transitions: [{ attr: "status", event: "form.answered" }],
|
|
29
|
+
affordances: [
|
|
30
|
+
{
|
|
31
|
+
name: "answer",
|
|
32
|
+
params: { type: "object" },
|
|
33
|
+
patch: (_attrs, params) => ({
|
|
34
|
+
answer: params,
|
|
35
|
+
status: "answered",
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
project: {
|
|
40
|
+
text: (attrs) => {
|
|
41
|
+
const fields = attrs.fields;
|
|
42
|
+
const lines = fields.map((field) => {
|
|
43
|
+
const suffix = field.options !== undefined && field.options.length > 0
|
|
44
|
+
? ` (${field.options.join("/")})`
|
|
45
|
+
: "";
|
|
46
|
+
return `- ${field.label}${suffix}`;
|
|
47
|
+
});
|
|
48
|
+
return lines.join("\n");
|
|
49
|
+
},
|
|
50
|
+
html: (attrs) => {
|
|
51
|
+
const fields = attrs.fields;
|
|
52
|
+
return {
|
|
53
|
+
type: "element",
|
|
54
|
+
tagName: "div",
|
|
55
|
+
properties: { className: ["form"] },
|
|
56
|
+
children: fields.map((field) => ({
|
|
57
|
+
type: "element",
|
|
58
|
+
tagName: "label",
|
|
59
|
+
properties: {},
|
|
60
|
+
children: [
|
|
61
|
+
{ type: "text", value: field.label },
|
|
62
|
+
{
|
|
63
|
+
type: "element",
|
|
64
|
+
tagName: "input",
|
|
65
|
+
properties: { type: field.type === "number" ? "number" : "text", name: field.id },
|
|
66
|
+
children: [],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
})),
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=form.js.map
|
package/dist/form.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,SAAS,GAAyB;IAC7C,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC;QACpC,UAAU,EAAE;YACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,MAAM,EAAE;gBACN,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;oBACjC,UAAU,EAAE;wBACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACzB,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE;wBAC5C,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;qBACtD;oBACD,oBAAoB,EAAE,KAAK;iBAC5B;aACF;YACD,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE;YACtC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC3B;QACD,oBAAoB,EAAE,KAAK;KAC5B;IACD,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ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,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;wBACpC;4BACE,IAAI,EAAE,SAAS;4BACf,OAAO,EAAE,OAAO;4BAChB,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;4BACjF,QAAQ,EAAE,EAAE;yBACb;qBACF;iBACF,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The starter block pack: six ready-made block types, exported together for
|
|
3
|
+
* convenience. Hosts that do not want every block may build their own array
|
|
4
|
+
* from the individual exports.
|
|
5
|
+
*/
|
|
6
|
+
export type { ChartAttrs } from "./chart.js";
|
|
7
|
+
export { chartBlock } from "./chart.js";
|
|
8
|
+
export type { ChecklistAttrs } from "./checklist.js";
|
|
9
|
+
export { checklistBlock } from "./checklist.js";
|
|
10
|
+
export type { FormAttrs } from "./form.js";
|
|
11
|
+
export { formBlock } from "./form.js";
|
|
12
|
+
export type { MetricAttrs } from "./metric.js";
|
|
13
|
+
export { metricBlock } from "./metric.js";
|
|
14
|
+
export type { RuleAttrs } from "./rule.js";
|
|
15
|
+
export { ruleBlock } from "./rule.js";
|
|
16
|
+
export type { StatusAttrs } from "./status.js";
|
|
17
|
+
export { statusBlock } from "./status.js";
|
|
18
|
+
import type { AnyBlockType } from "@onioneko/boardkit-core";
|
|
19
|
+
/**
|
|
20
|
+
* All six starter blocks, ready to pass to `createEngine({ blocks })`.
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const engine = createEngine({
|
|
24
|
+
* storage: createMemStorage(),
|
|
25
|
+
* blocks: starterBlocks,
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const starterBlocks: readonly AnyBlockType[];
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAQ5D;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,YAAY,EAOhD,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The starter block pack: six ready-made block types, exported together for
|
|
3
|
+
* convenience. Hosts that do not want every block may build their own array
|
|
4
|
+
* from the individual exports.
|
|
5
|
+
*/
|
|
6
|
+
export { chartBlock } from "./chart.js";
|
|
7
|
+
export { checklistBlock } from "./checklist.js";
|
|
8
|
+
export { formBlock } from "./form.js";
|
|
9
|
+
export { metricBlock } from "./metric.js";
|
|
10
|
+
export { ruleBlock } from "./rule.js";
|
|
11
|
+
export { statusBlock } from "./status.js";
|
|
12
|
+
import { chartBlock } from "./chart.js";
|
|
13
|
+
import { checklistBlock } from "./checklist.js";
|
|
14
|
+
import { formBlock } from "./form.js";
|
|
15
|
+
import { metricBlock } from "./metric.js";
|
|
16
|
+
import { ruleBlock } from "./rule.js";
|
|
17
|
+
import { statusBlock } from "./status.js";
|
|
18
|
+
/**
|
|
19
|
+
* All six starter blocks, ready to pass to `createEngine({ blocks })`.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const engine = createEngine({
|
|
23
|
+
* storage: createMemStorage(),
|
|
24
|
+
* blocks: starterBlocks,
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export const starterBlocks = [
|
|
29
|
+
checklistBlock,
|
|
30
|
+
statusBlock,
|
|
31
|
+
metricBlock,
|
|
32
|
+
chartBlock,
|
|
33
|
+
formBlock,
|
|
34
|
+
ruleBlock,
|
|
35
|
+
];
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAA4B;IACpD,cAAc;IACd,WAAW;IACX,WAAW;IACX,UAAU;IACV,SAAS;IACT,SAAS;CACV,CAAC"}
|
package/dist/metric.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BlockType } from "@onioneko/boardkit-core";
|
|
2
|
+
/**
|
|
3
|
+
* starter block: metric — a labeled live value backed by a source. Hooks
|
|
4
|
+
* receive resolved values keyed by source id, so the metric's value is injected
|
|
5
|
+
* at projection time and never persisted.
|
|
6
|
+
*
|
|
7
|
+
* Usage: a metric's `source` field names a source id; the block declares it
|
|
8
|
+
* through `sources`, so the value is resolved from the block alone — the
|
|
9
|
+
* document needs no `{{source:…}}` prose ref. The resolved value (optionally
|
|
10
|
+
* annotated by `view`/`thresholds`) is rendered next to its `label`; an
|
|
11
|
+
* unresolved (absent or stale) value falls back to the source id.
|
|
12
|
+
*/
|
|
13
|
+
/** Attrs for the `metric` block, mirroring its JSON Schema. */
|
|
14
|
+
export type MetricAttrs = {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly label: string;
|
|
17
|
+
readonly source: string;
|
|
18
|
+
readonly view?: "value" | "sparkline" | "chart";
|
|
19
|
+
readonly thresholds?: readonly number[];
|
|
20
|
+
};
|
|
21
|
+
export declare const metricBlock: BlockType<MetricAttrs>;
|
|
22
|
+
//# sourceMappingURL=metric.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metric.d.ts","sourceRoot":"","sources":["../src/metric.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;;;;;;;GAUG;AAEH,+DAA+D;AAC/D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO,CAAC;IAChD,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,WAAW,CAkC9C,CAAC"}
|
package/dist/metric.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const metricBlock = {
|
|
2
|
+
type: "metric",
|
|
3
|
+
schema: {
|
|
4
|
+
type: "object",
|
|
5
|
+
required: ["id", "label", "source"],
|
|
6
|
+
properties: {
|
|
7
|
+
id: { type: "string" },
|
|
8
|
+
label: { type: "string" },
|
|
9
|
+
source: { type: "string" },
|
|
10
|
+
view: { enum: ["value", "sparkline", "chart"] },
|
|
11
|
+
thresholds: { type: "array", items: { type: "number" } },
|
|
12
|
+
},
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
},
|
|
15
|
+
sources: (attrs) => typeof attrs.source === "string" ? [{ kind: "source", source: attrs.source, params: {} }] : [],
|
|
16
|
+
project: {
|
|
17
|
+
text: (attrs, values) => `${String(attrs.label)}: ${values[String(attrs.source)] ?? String(attrs.source)}`,
|
|
18
|
+
html: (attrs, values) => ({
|
|
19
|
+
type: "element",
|
|
20
|
+
tagName: "span",
|
|
21
|
+
properties: { className: ["metric"] },
|
|
22
|
+
children: [
|
|
23
|
+
{
|
|
24
|
+
type: "element",
|
|
25
|
+
tagName: "strong",
|
|
26
|
+
properties: {},
|
|
27
|
+
children: [{ type: "text", value: String(attrs.label) }],
|
|
28
|
+
},
|
|
29
|
+
{ type: "text", value: ` ${values[String(attrs.source)] ?? String(attrs.source)}` },
|
|
30
|
+
],
|
|
31
|
+
}),
|
|
32
|
+
},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AI,EAAE,SAAS;YACf,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE;YACrC,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,QAAQ;oBACjB,UAAU,EAAE,EAAE;oBACd,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;iBACzD;gBACD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE;aACpF;SACF,CAAC;KACH;CACF,CAAC"}
|
package/dist/rule.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BlockType } from "@onioneko/boardkit-core";
|
|
2
|
+
/**
|
|
3
|
+
* starter block: rule — an opaque when/do automation with an enabled switch.
|
|
4
|
+
* The library validates only presence and type; the semantics of `when`/`do`
|
|
5
|
+
* belong to the host.
|
|
6
|
+
*
|
|
7
|
+
* Usage: the `toggle` affordance flips `enabled`, emitting `rule.enabled`; the
|
|
8
|
+
* host observes that event (or reads the block) to execute the rule.
|
|
9
|
+
*/
|
|
10
|
+
/** Attrs for the `rule` block, mirroring its JSON Schema. */
|
|
11
|
+
export type RuleAttrs = {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly title?: string;
|
|
14
|
+
readonly when: string;
|
|
15
|
+
readonly do: string;
|
|
16
|
+
readonly enabled: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const ruleBlock: BlockType<RuleAttrs>;
|
|
19
|
+
//# sourceMappingURL=rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;;;;GAOG;AAEH,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,SAAS,CA2C1C,CAAC"}
|
package/dist/rule.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const ruleBlock = {
|
|
2
|
+
type: "rule",
|
|
3
|
+
schema: {
|
|
4
|
+
type: "object",
|
|
5
|
+
required: ["id", "when", "do", "enabled"],
|
|
6
|
+
properties: {
|
|
7
|
+
id: { type: "string" },
|
|
8
|
+
title: { type: "string" },
|
|
9
|
+
when: { type: "string" },
|
|
10
|
+
do: { type: "string" },
|
|
11
|
+
enabled: { type: "boolean" },
|
|
12
|
+
},
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
},
|
|
15
|
+
transitions: [{ attr: "enabled", event: "rule.enabled" }],
|
|
16
|
+
affordances: [
|
|
17
|
+
{
|
|
18
|
+
name: "toggle",
|
|
19
|
+
patch: (attrs) => ({ enabled: !attrs.enabled }),
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
project: {
|
|
23
|
+
text: (attrs) => `- rule ${attrs.enabled === true ? "(enabled)" : "(disabled)"}: when ${String(attrs.when)} do ${String(attrs.do)}`,
|
|
24
|
+
html: (attrs) => ({
|
|
25
|
+
type: "element",
|
|
26
|
+
tagName: "div",
|
|
27
|
+
properties: { className: ["rule"] },
|
|
28
|
+
children: [
|
|
29
|
+
{
|
|
30
|
+
type: "element",
|
|
31
|
+
tagName: "input",
|
|
32
|
+
properties: {
|
|
33
|
+
type: "checkbox",
|
|
34
|
+
...(attrs.enabled === true ? { checked: "" } : {}),
|
|
35
|
+
"data-intent": JSON.stringify({ affordance: "toggle" }),
|
|
36
|
+
},
|
|
37
|
+
children: [],
|
|
38
|
+
},
|
|
39
|
+
{ type: "text", value: ` when ${String(attrs.when)} do ${String(attrs.do)}` },
|
|
40
|
+
],
|
|
41
|
+
}),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=rule.js.map
|
package/dist/rule.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../src/rule.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,SAAS,GAAyB;IAC7C,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC;QACzC,UAAU,EAAE;YACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACtB,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAC7B;QACD,oBAAoB,EAAE,KAAK;KAC5B;IACD,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;IACzD,WAAW,EAAE;QACX;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;SAChD;KACF;IACD,OAAO,EAAE;QACP,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,UAAU,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,UAAU,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;QACpH,IAAI,EAAE,CAAC,KAAK,EAAwB,EAAE,CAAC,CAAC;YACtC,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,EAAE,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE;YACnC,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,OAAO;oBAChB,UAAU,EAAE;wBACV,IAAI,EAAE,UAAU;wBAChB,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wBAClD,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;qBACxD;oBACD,QAAQ,EAAE,EAAE;iBACb;gBACD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE;aAC9E;SACF,CAAC;KACH;CACF,CAAC"}
|
package/dist/status.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BlockType } from "@onioneko/boardkit-core";
|
|
2
|
+
/**
|
|
3
|
+
* starter block: status — an ordered state machine with a current value. The
|
|
4
|
+
* cross-field rule "value must be a member of states" is exactly what
|
|
5
|
+
* BlockType.validate exists for (JSON Schema cannot express it).
|
|
6
|
+
*
|
|
7
|
+
* Usage: `states` is an ordered list of allowed values; the `transition`
|
|
8
|
+
* affordance moves `value` to a new state, emitting `status.changed` with
|
|
9
|
+
* `from`/`to`. The html hook renders `<div class="status" data-state="…">`
|
|
10
|
+
* (style a state with `.status[data-state="…"]`) holding a badge and a button
|
|
11
|
+
* for every state other than the current one.
|
|
12
|
+
*/
|
|
13
|
+
/** Attrs for the `status` block, mirroring its JSON Schema. */
|
|
14
|
+
export type StatusAttrs = {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly title?: string;
|
|
17
|
+
readonly states: readonly string[];
|
|
18
|
+
readonly value: string;
|
|
19
|
+
readonly note?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const statusBlock: BlockType<StatusAttrs>;
|
|
22
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;;;;;;;GAUG;AAEH,+DAA+D;AAC/D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,SAAS,CAAC,WAAW,CA+E9C,CAAC"}
|