@texuli/blocks 0.0.0-stage → 0.1.0-next.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 +77 -2
- package/dist/code/CodeBlockView.svelte +135 -0
- package/dist/code/CodeBlockView.svelte.d.ts +5 -0
- package/dist/code/check.d.ts +15 -0
- package/dist/code/check.js +14 -0
- package/dist/code/code.css +201 -0
- package/dist/code/code.css.d.ts +1 -0
- package/dist/code/engine-entry.d.ts +10 -0
- package/dist/code/engine-entry.js +10 -0
- package/dist/code/engine.d.ts +18 -0
- package/dist/code/engine.js +18 -0
- package/dist/code/family-engine.d.ts +23 -0
- package/dist/code/family-engine.js +4 -0
- package/dist/code/family.d.ts +7 -0
- package/dist/code/family.js +5 -0
- package/dist/code/grammars.d.ts +12 -0
- package/dist/code/grammars.js +83 -0
- package/dist/code/highlight.d.ts +15 -0
- package/dist/code/highlight.js +53 -0
- package/dist/code/index.d.ts +13 -0
- package/dist/code/index.js +12 -0
- package/dist/code/labels.d.ts +27 -0
- package/dist/code/labels.js +24 -0
- package/dist/code/languages/bash.d.ts +3 -0
- package/dist/code/languages/bash.js +48 -0
- package/dist/code/languages/css.d.ts +10 -0
- package/dist/code/languages/css.js +67 -0
- package/dist/code/languages/html.d.ts +6 -0
- package/dist/code/languages/html.js +35 -0
- package/dist/code/languages/javascript.d.ts +3 -0
- package/dist/code/languages/javascript.js +113 -0
- package/dist/code/languages/json.d.ts +3 -0
- package/dist/code/languages/json.js +24 -0
- package/dist/code/languages/python.d.ts +3 -0
- package/dist/code/languages/python.js +35 -0
- package/dist/code/languages/shared.d.ts +22 -0
- package/dist/code/languages/shared.js +37 -0
- package/dist/code/languages/sql.d.ts +3 -0
- package/dist/code/languages/sql.js +32 -0
- package/dist/code/languages/yaml.d.ts +7 -0
- package/dist/code/languages/yaml.js +36 -0
- package/dist/code/renderers.d.ts +5 -0
- package/dist/code/renderers.js +5 -0
- package/dist/code/token-styles.d.ts +25 -0
- package/dist/code/token-styles.js +51 -0
- package/dist/code/tokenize-code.d.ts +17 -0
- package/dist/code/tokenize-code.js +34 -0
- package/dist/code/tokenizer.d.ts +76 -0
- package/dist/code/tokenizer.js +171 -0
- package/dist/core/catalog/entries.d.ts +10 -0
- package/dist/core/catalog/entries.js +589 -0
- package/dist/core/catalog/index.d.ts +4 -0
- package/dist/core/catalog/index.js +2 -0
- package/dist/core/catalog/types.d.ts +36 -0
- package/dist/core/catalog/types.js +1 -0
- package/dist/core/catalog/validate.d.ts +15 -0
- package/dist/core/catalog/validate.js +46 -0
- package/dist/core/formula/evaluate.d.ts +14 -0
- package/dist/core/formula/evaluate.js +181 -0
- package/dist/core/formula/index.d.ts +8 -0
- package/dist/core/formula/index.js +6 -0
- package/dist/core/formula/parse.d.ts +19 -0
- package/dist/core/formula/parse.js +452 -0
- package/dist/core/formula/types.d.ts +76 -0
- package/dist/core/formula/types.js +7 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.js +13 -0
- package/dist/core/limits.d.ts +27 -0
- package/dist/core/limits.js +26 -0
- package/dist/core/safety.d.ts +30 -0
- package/dist/core/safety.js +110 -0
- package/dist/core/schema/blocks.d.ts +138 -0
- package/dist/core/schema/blocks.js +181 -0
- package/dist/core/schema/code-family.d.ts +4 -0
- package/dist/core/schema/code-family.js +75 -0
- package/dist/core/schema/line-spec.d.ts +7 -0
- package/dist/core/schema/line-spec.js +19 -0
- package/dist/core/schema/media-family.d.ts +4 -0
- package/dist/core/schema/media-family.js +260 -0
- package/dist/core/schema/parse-family.d.ts +14 -0
- package/dist/core/schema/parse-family.js +37 -0
- package/dist/core/schema/primitives.d.ts +73 -0
- package/dist/core/schema/primitives.js +140 -0
- package/dist/core/schema/text-family.d.ts +4 -0
- package/dist/core/schema/text-family.js +121 -0
- package/dist/core/schema/vocabulary.d.ts +20 -0
- package/dist/core/schema/vocabulary.js +33 -0
- package/dist/core/text.d.ts +31 -0
- package/dist/core/text.js +139 -0
- package/dist/core/untrusted.d.ts +20 -0
- package/dist/core/untrusted.js +377 -0
- package/dist/css-modules.d.ts +1 -0
- package/dist/css.d.ts +1 -0
- package/dist/data/ChartBlockView.svelte +77 -0
- package/dist/data/ChartBlockView.svelte.d.ts +10 -0
- package/dist/data/DataBlockView.svelte +109 -0
- package/dist/data/DataBlockView.svelte.d.ts +5 -0
- package/dist/data/check.d.ts +10 -0
- package/dist/data/check.js +9 -0
- package/dist/data/engine.d.ts +18 -0
- package/dist/data/engine.js +10 -0
- package/dist/data/family.d.ts +6 -0
- package/dist/data/family.js +4 -0
- package/dist/data/index.d.ts +9 -0
- package/dist/data/index.js +8 -0
- package/dist/data/labels.d.ts +8 -0
- package/dist/data/labels.js +8 -0
- package/dist/data/renderers.d.ts +2 -0
- package/dist/data/renderers.js +2 -0
- package/dist/data/schema.d.ts +84 -0
- package/dist/data/schema.js +385 -0
- package/dist/diagram/BoardDiagram.svelte +48 -0
- package/dist/diagram/BoardDiagram.svelte.d.ts +8 -0
- package/dist/diagram/DiagramFamily.svelte +46 -0
- package/dist/diagram/DiagramFamily.svelte.d.ts +10 -0
- package/dist/diagram/FlowDiagram.svelte +108 -0
- package/dist/diagram/FlowDiagram.svelte.d.ts +8 -0
- package/dist/diagram/TerminalDiagram.svelte +38 -0
- package/dist/diagram/TerminalDiagram.svelte.d.ts +8 -0
- package/dist/diagram/TreeDiagram.svelte +149 -0
- package/dist/diagram/TreeDiagram.svelte.d.ts +8 -0
- package/dist/diagram/diagram.css +287 -0
- package/dist/diagram/diagram.css.d.ts +1 -0
- package/dist/diagram/engine.d.ts +16 -0
- package/dist/diagram/engine.js +14 -0
- package/dist/diagram/family.d.ts +7 -0
- package/dist/diagram/family.js +5 -0
- package/dist/diagram/index.d.ts +10 -0
- package/dist/diagram/index.js +9 -0
- package/dist/diagram/layout.d.ts +26 -0
- package/dist/diagram/layout.js +165 -0
- package/dist/diagram/schema.d.ts +74 -0
- package/dist/diagram/schema.js +358 -0
- package/dist/diagram/tones.d.ts +6 -0
- package/dist/diagram/tones.js +16 -0
- package/dist/embed/EmbedApp.svelte +138 -0
- package/dist/embed/EmbedApp.svelte.d.ts +17 -0
- package/dist/embed/EmbedBlockView.svelte +32 -0
- package/dist/embed/EmbedBlockView.svelte.d.ts +5 -0
- package/dist/embed/LinkPreview.svelte +48 -0
- package/dist/embed/LinkPreview.svelte.d.ts +10 -0
- package/dist/embed/engine.d.ts +30 -0
- package/dist/embed/engine.js +17 -0
- package/dist/embed/family.d.ts +7 -0
- package/dist/embed/family.js +5 -0
- package/dist/embed/index.d.ts +5 -0
- package/dist/embed/index.js +3 -0
- package/dist/embed/renderers.d.ts +3 -0
- package/dist/embed/renderers.js +3 -0
- package/dist/embed/sandbox.d.ts +86 -0
- package/dist/embed/sandbox.js +114 -0
- package/dist/embed/schema.d.ts +30 -0
- package/dist/embed/schema.js +217 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +15 -0
- package/dist/interactive/CalculatorBlock.svelte +61 -0
- package/dist/interactive/CalculatorBlock.svelte.d.ts +10 -0
- package/dist/interactive/ChecklistBlock.svelte +44 -0
- package/dist/interactive/ChecklistBlock.svelte.d.ts +10 -0
- package/dist/interactive/InteractiveBlockView.svelte +31 -0
- package/dist/interactive/InteractiveBlockView.svelte.d.ts +5 -0
- package/dist/interactive/PollBlock.svelte +111 -0
- package/dist/interactive/PollBlock.svelte.d.ts +10 -0
- package/dist/interactive/QuizBlock.svelte +75 -0
- package/dist/interactive/QuizBlock.svelte.d.ts +10 -0
- package/dist/interactive/check.d.ts +10 -0
- package/dist/interactive/check.js +9 -0
- package/dist/interactive/engine.d.ts +19 -0
- package/dist/interactive/engine.js +12 -0
- package/dist/interactive/family.d.ts +6 -0
- package/dist/interactive/family.js +4 -0
- package/dist/interactive/index.d.ts +13 -0
- package/dist/interactive/index.js +13 -0
- package/dist/interactive/interactive.css +97 -0
- package/dist/interactive/interactive.css.d.ts +1 -0
- package/dist/interactive/labels.d.ts +16 -0
- package/dist/interactive/labels.js +16 -0
- package/dist/interactive/renderers.d.ts +9 -0
- package/dist/interactive/renderers.js +9 -0
- package/dist/interactive/schema.d.ts +76 -0
- package/dist/interactive/schema.js +324 -0
- package/dist/map/MapBlockView.svelte +465 -0
- package/dist/map/MapBlockView.svelte.d.ts +5 -0
- package/dist/map/check.d.ts +11 -0
- package/dist/map/check.js +6 -0
- package/dist/map/engine.d.ts +19 -0
- package/dist/map/engine.js +8 -0
- package/dist/map/family.d.ts +7 -0
- package/dist/map/family.js +5 -0
- package/dist/map/index.d.ts +11 -0
- package/dist/map/index.js +10 -0
- package/dist/map/labels.d.ts +27 -0
- package/dist/map/labels.js +21 -0
- package/dist/map/renderers.d.ts +2 -0
- package/dist/map/renderers.js +2 -0
- package/dist/map/schema.d.ts +41 -0
- package/dist/map/schema.js +176 -0
- package/dist/map/view-model.d.ts +55 -0
- package/dist/map/view-model.js +168 -0
- package/dist/media/MediaBlockView.svelte +258 -0
- package/dist/media/MediaBlockView.svelte.d.ts +5 -0
- package/dist/media/check.d.ts +14 -0
- package/dist/media/check.js +13 -0
- package/dist/media/engine.d.ts +18 -0
- package/dist/media/engine.js +10 -0
- package/dist/media/family.d.ts +7 -0
- package/dist/media/family.js +5 -0
- package/dist/media/index.d.ts +11 -0
- package/dist/media/index.js +10 -0
- package/dist/media/labels.d.ts +7 -0
- package/dist/media/labels.js +12 -0
- package/dist/media/renderers.d.ts +5 -0
- package/dist/media/renderers.js +5 -0
- package/dist/media/resolve.d.ts +6 -0
- package/dist/media/resolve.js +15 -0
- package/dist/structure/NestedBlocks.svelte +65 -0
- package/dist/structure/NestedBlocks.svelte.d.ts +11 -0
- package/dist/structure/SafeBody.svelte +13 -0
- package/dist/structure/SafeBody.svelte.d.ts +7 -0
- package/dist/structure/StructureFamily.svelte +157 -0
- package/dist/structure/StructureFamily.svelte.d.ts +5 -0
- package/dist/structure/check.d.ts +14 -0
- package/dist/structure/check.js +27 -0
- package/dist/structure/engine.d.ts +18 -0
- package/dist/structure/engine.js +18 -0
- package/dist/structure/family.d.ts +7 -0
- package/dist/structure/family.js +5 -0
- package/dist/structure/index.d.ts +11 -0
- package/dist/structure/index.js +10 -0
- package/dist/structure/labels.d.ts +11 -0
- package/dist/structure/labels.js +11 -0
- package/dist/structure/renderers.d.ts +5 -0
- package/dist/structure/renderers.js +5 -0
- package/dist/structure/schema.d.ts +71 -0
- package/dist/structure/schema.js +327 -0
- package/dist/structure/structure.css +182 -0
- package/dist/structure/structure.css.d.ts +1 -0
- package/dist/text/RichText.svelte +169 -0
- package/dist/text/RichText.svelte.d.ts +13 -0
- package/dist/text/TextBlockView.svelte +177 -0
- package/dist/text/TextBlockView.svelte.d.ts +5 -0
- package/dist/text/check.d.ts +14 -0
- package/dist/text/check.js +13 -0
- package/dist/text/engine.d.ts +17 -0
- package/dist/text/engine.js +10 -0
- package/dist/text/family.d.ts +7 -0
- package/dist/text/family.js +5 -0
- package/dist/text/index.d.ts +12 -0
- package/dist/text/index.js +11 -0
- package/dist/text/labels.d.ts +22 -0
- package/dist/text/labels.js +29 -0
- package/dist/text/markdown.d.ts +80 -0
- package/dist/text/markdown.js +361 -0
- package/dist/text/renderers.d.ts +6 -0
- package/dist/text/renderers.js +6 -0
- package/package.json +167 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference path="../css-modules.d.ts" />
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { ChartBlock } from '../core/index.js';
|
|
4
|
+
type $$ComponentProps = {
|
|
5
|
+
block: ChartBlock;
|
|
6
|
+
mode?: 'light' | 'dark';
|
|
7
|
+
};
|
|
8
|
+
declare const ChartBlockView: Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type ChartBlockView = ReturnType<typeof ChartBlockView>;
|
|
10
|
+
export default ChartBlockView;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Stat } from 'texuli/stat';
|
|
3
|
+
import {
|
|
4
|
+
Table,
|
|
5
|
+
TableBody,
|
|
6
|
+
TableCaption,
|
|
7
|
+
TableCell,
|
|
8
|
+
TableEmpty,
|
|
9
|
+
TableHead,
|
|
10
|
+
TableHeader,
|
|
11
|
+
TableRow,
|
|
12
|
+
} from 'texuli/table';
|
|
13
|
+
import ChartBlockView from './ChartBlockView.svelte';
|
|
14
|
+
import { checkDataBlock } from './check.js';
|
|
15
|
+
import type { DataBlockViewProps } from './family.js';
|
|
16
|
+
import { resolveDataBlockLabels } from './labels.js';
|
|
17
|
+
|
|
18
|
+
let { block, labels, oninvalid, mode = 'light' }: DataBlockViewProps = $props();
|
|
19
|
+
|
|
20
|
+
const check = $derived(checkDataBlock(block));
|
|
21
|
+
const text = $derived(resolveDataBlockLabels(labels));
|
|
22
|
+
|
|
23
|
+
$effect(() => {
|
|
24
|
+
if (!check.ok) oninvalid?.(check.issues);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
function cellText(value: string | number | null): string {
|
|
28
|
+
if (value === null) return '—';
|
|
29
|
+
return typeof value === 'number'
|
|
30
|
+
? new Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format(value)
|
|
31
|
+
: value;
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
{#if !check.ok}
|
|
36
|
+
<p class="tx-block tx-block-invalid" role="note" data-tx-block="invalid">{text.invalid}</p>
|
|
37
|
+
{:else}
|
|
38
|
+
{@const b = check.block}
|
|
39
|
+
{#if b.type === 'table'}
|
|
40
|
+
<div class="tx-block tx-block-table" data-tx-block="table" data-tone={b.tone}>
|
|
41
|
+
<Table>
|
|
42
|
+
{#if b.caption}
|
|
43
|
+
<TableCaption>{b.caption}</TableCaption>
|
|
44
|
+
{/if}
|
|
45
|
+
<TableHeader>
|
|
46
|
+
<TableRow>
|
|
47
|
+
{#each b.columns as column (column.id)}
|
|
48
|
+
<TableHead>{column.label}</TableHead>
|
|
49
|
+
{/each}
|
|
50
|
+
</TableRow>
|
|
51
|
+
</TableHeader>
|
|
52
|
+
<TableBody>
|
|
53
|
+
{#if b.rows.length === 0}
|
|
54
|
+
<TableEmpty colspan={b.columns.length}>{text.emptyTable}</TableEmpty>
|
|
55
|
+
{:else}
|
|
56
|
+
{#each b.rows as row, ri (ri)}
|
|
57
|
+
<TableRow>
|
|
58
|
+
{#each b.columns as column (column.id)}
|
|
59
|
+
<TableCell>{cellText(row[column.id] ?? null)}</TableCell>
|
|
60
|
+
{/each}
|
|
61
|
+
</TableRow>
|
|
62
|
+
{/each}
|
|
63
|
+
{/if}
|
|
64
|
+
</TableBody>
|
|
65
|
+
</Table>
|
|
66
|
+
</div>
|
|
67
|
+
{:else if b.type === 'stat' || b.type === 'kpi'}
|
|
68
|
+
<div
|
|
69
|
+
class="tx-block"
|
|
70
|
+
class:tx-block-stat={b.type === 'stat'}
|
|
71
|
+
class:tx-block-kpi={b.type === 'kpi'}
|
|
72
|
+
data-tx-block={b.type}
|
|
73
|
+
data-tone={b.tone}
|
|
74
|
+
role="group"
|
|
75
|
+
aria-label={b.type === 'kpi' ? 'Key performance indicators' : 'Statistics'}
|
|
76
|
+
>
|
|
77
|
+
<div class="tx-stat-grid">
|
|
78
|
+
{#each b.items as item, i (i)}
|
|
79
|
+
<Stat label={item.label} value={item.value} hint={item.hint} delta={item.delta} />
|
|
80
|
+
{/each}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
{:else}
|
|
84
|
+
<div class="tx-block tx-block-chart" data-tx-block="chart" data-tone={b.tone}>
|
|
85
|
+
<ChartBlockView block={b} {mode} />
|
|
86
|
+
</div>
|
|
87
|
+
{/if}
|
|
88
|
+
{/if}
|
|
89
|
+
|
|
90
|
+
<style>
|
|
91
|
+
.tx-block {
|
|
92
|
+
margin: 0;
|
|
93
|
+
overflow-wrap: anywhere;
|
|
94
|
+
}
|
|
95
|
+
.tx-block-invalid {
|
|
96
|
+
color: var(--tx-muted-foreground, GrayText);
|
|
97
|
+
font-size: 0.875rem;
|
|
98
|
+
}
|
|
99
|
+
.tx-stat-grid {
|
|
100
|
+
display: grid;
|
|
101
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
|
|
102
|
+
gap: 0.75rem;
|
|
103
|
+
}
|
|
104
|
+
.tx-block-table,
|
|
105
|
+
.tx-block-chart {
|
|
106
|
+
max-inline-size: 100%;
|
|
107
|
+
overflow-x: auto;
|
|
108
|
+
}
|
|
109
|
+
</style>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference path="../css-modules.d.ts" />
|
|
2
|
+
import type { DataBlockViewProps } from './family.js';
|
|
3
|
+
declare const DataBlockView: import("svelte").Component<DataBlockViewProps, {}, "">;
|
|
4
|
+
type DataBlockView = ReturnType<typeof DataBlockView>;
|
|
5
|
+
export default DataBlockView;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FieldIssue } from '../core/schema/primitives.js';
|
|
2
|
+
import type { DataFamilyBlock } from './engine.js';
|
|
3
|
+
export type DataBlockCheck = {
|
|
4
|
+
ok: true;
|
|
5
|
+
block: DataFamilyBlock;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
issues: FieldIssue[];
|
|
9
|
+
};
|
|
10
|
+
export declare function checkDataBlock(value: unknown): DataBlockCheck;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parseFamilyBlock } from "../core/schema/parse-family.js";
|
|
2
|
+
import { parseDataBlock } from "./schema.js";
|
|
3
|
+
export function checkDataBlock(value) {
|
|
4
|
+
// Only this family's parser: the renderer does not bundle every family's rules.
|
|
5
|
+
const parsed = parseFamilyBlock(value, [parseDataBlock], 'data');
|
|
6
|
+
if (!parsed.success)
|
|
7
|
+
return { ok: false, issues: parsed.issues };
|
|
8
|
+
return { ok: true, block: parsed.data };
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@texuli/blocks/data/engine` — Svelte-free table/stat/kpi/chart parsers and labels.
|
|
3
|
+
*/
|
|
4
|
+
import type { Block, ChartBlock, FieldIssue, KpiBlock, StatBlock, TableBlock } from '../core/index.js';
|
|
5
|
+
import type { DataBlockLabelOverrides } from './labels.js';
|
|
6
|
+
export { checkDataBlock, type DataBlockCheck } from './check.js';
|
|
7
|
+
export { type DataBlockLabelOverrides, type DataBlockLabels, DEFAULT_DATA_BLOCK_LABELS, resolveDataBlockLabels, } from './labels.js';
|
|
8
|
+
export { CHART_KINDS, type ChartBlock, type ChartHeatCell, type ChartKind, type ChartScatterPoint, type ChartSeries, type ChartSeriesPoint, type DataBlock, type DataBlockType, type KpiBlock, type KpiItem, parseChartBlock, parseDataBlock, parseKpiBlock, parseStatBlock, parseTableBlock, type StatBlock, type StatItem, type TableBlock, type TableCellValue, type TableColumn, type TableRow, } from './schema.js';
|
|
9
|
+
export declare const DATA_BLOCK_TYPES: readonly ["table", "stat", "kpi", "chart"];
|
|
10
|
+
export type DataFamilyBlockType = (typeof DATA_BLOCK_TYPES)[number];
|
|
11
|
+
export type DataFamilyBlock = TableBlock | StatBlock | KpiBlock | ChartBlock;
|
|
12
|
+
export declare function isDataFamilyBlock(block: Block): block is DataFamilyBlock;
|
|
13
|
+
export interface DataBlockViewProps {
|
|
14
|
+
block: unknown;
|
|
15
|
+
labels?: DataBlockLabelOverrides;
|
|
16
|
+
oninvalid?: (issues: FieldIssue[]) => void;
|
|
17
|
+
mode?: 'light' | 'dark';
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@texuli/blocks/data/engine` — Svelte-free table/stat/kpi/chart parsers and labels.
|
|
3
|
+
*/
|
|
4
|
+
export { checkDataBlock } from "./check.js";
|
|
5
|
+
export { DEFAULT_DATA_BLOCK_LABELS, resolveDataBlockLabels, } from "./labels.js";
|
|
6
|
+
export { CHART_KINDS, parseChartBlock, parseDataBlock, parseKpiBlock, parseStatBlock, parseTableBlock, } from "./schema.js";
|
|
7
|
+
export const DATA_BLOCK_TYPES = ['table', 'stat', 'kpi', 'chart'];
|
|
8
|
+
export function isDataFamilyBlock(block) {
|
|
9
|
+
return DATA_BLOCK_TYPES.includes(block.type);
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
import type { DataBlockViewProps } from './engine.js';
|
|
3
|
+
export { DATA_BLOCK_TYPES, type DataBlockViewProps, type DataFamilyBlock, type DataFamilyBlockType, isDataFamilyBlock, } from './engine.js';
|
|
4
|
+
export declare function loadDataFamily(): Promise<{
|
|
5
|
+
default: Component<DataBlockViewProps>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference path="../css-modules.d.ts" />
|
|
2
|
+
/**
|
|
3
|
+
* `@texuli/blocks` data family (T-blocks-data): table, stat, kpi and chart.
|
|
4
|
+
* Renderers load through `loadDataFamily()` or `@texuli/blocks/data/renderers`.
|
|
5
|
+
*/
|
|
6
|
+
export { checkDataBlock, type DataBlockCheck } from './check.js';
|
|
7
|
+
export { DATA_BLOCK_TYPES, type DataBlockViewProps, type DataFamilyBlock, type DataFamilyBlockType, isDataFamilyBlock, loadDataFamily, } from './family.js';
|
|
8
|
+
export { type DataBlockLabelOverrides, type DataBlockLabels, DEFAULT_DATA_BLOCK_LABELS, resolveDataBlockLabels, } from './labels.js';
|
|
9
|
+
export { CHART_KINDS, type ChartBlock, type ChartHeatCell, type ChartKind, type ChartScatterPoint, type ChartSeries, type ChartSeriesPoint, type DataBlock, type DataBlockType, type KpiBlock, type KpiItem, parseChartBlock, parseDataBlock, parseKpiBlock, parseStatBlock, parseTableBlock, type StatBlock, type StatItem, type TableBlock, type TableCellValue, type TableColumn, type TableRow, } from './schema.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@texuli/blocks` data family (T-blocks-data): table, stat, kpi and chart.
|
|
3
|
+
* Renderers load through `loadDataFamily()` or `@texuli/blocks/data/renderers`.
|
|
4
|
+
*/
|
|
5
|
+
export { checkDataBlock } from "./check.js";
|
|
6
|
+
export { DATA_BLOCK_TYPES, isDataFamilyBlock, loadDataFamily, } from "./family.js";
|
|
7
|
+
export { DEFAULT_DATA_BLOCK_LABELS, resolveDataBlockLabels, } from "./labels.js";
|
|
8
|
+
export { CHART_KINDS, parseChartBlock, parseDataBlock, parseKpiBlock, parseStatBlock, parseTableBlock, } from "./schema.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface DataBlockLabels {
|
|
2
|
+
invalid: string;
|
|
3
|
+
emptyTable: string;
|
|
4
|
+
tableSummary: string;
|
|
5
|
+
}
|
|
6
|
+
export type DataBlockLabelOverrides = Partial<DataBlockLabels>;
|
|
7
|
+
export declare const DEFAULT_DATA_BLOCK_LABELS: DataBlockLabels;
|
|
8
|
+
export declare function resolveDataBlockLabels(overrides?: DataBlockLabelOverrides): DataBlockLabels;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data-family block shapes and parsers (table, stat, chart, kpi).
|
|
3
|
+
* Wired into the core `safeParseBlock` switch via `parseDataBlock`.
|
|
4
|
+
*/
|
|
5
|
+
import { type BlockBase, type ParseResult } from '../core/schema/primitives.js';
|
|
6
|
+
import { type BlockTone } from '../core/schema/vocabulary.js';
|
|
7
|
+
export type TableColumn = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
};
|
|
11
|
+
export type TableCellValue = string | number | null;
|
|
12
|
+
export type TableRow = Record<string, TableCellValue>;
|
|
13
|
+
export type TableBlock = BlockBase & {
|
|
14
|
+
type: 'table';
|
|
15
|
+
caption?: string;
|
|
16
|
+
columns: TableColumn[];
|
|
17
|
+
rows: TableRow[];
|
|
18
|
+
};
|
|
19
|
+
export type StatItem = {
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
hint?: string;
|
|
23
|
+
delta?: string;
|
|
24
|
+
tone?: BlockTone;
|
|
25
|
+
};
|
|
26
|
+
export type StatBlock = BlockBase & {
|
|
27
|
+
type: 'stat';
|
|
28
|
+
items: StatItem[];
|
|
29
|
+
};
|
|
30
|
+
export type KpiItem = {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
hint?: string;
|
|
34
|
+
delta?: string;
|
|
35
|
+
tone?: BlockTone;
|
|
36
|
+
};
|
|
37
|
+
export type KpiBlock = BlockBase & {
|
|
38
|
+
type: 'kpi';
|
|
39
|
+
items: KpiItem[];
|
|
40
|
+
};
|
|
41
|
+
export type ChartKind = 'line' | 'area' | 'bar' | 'stacked-bar' | 'heatmap' | 'scatter' | 'bubble';
|
|
42
|
+
export type ChartSeriesPoint = {
|
|
43
|
+
x: string | number;
|
|
44
|
+
y: number | null;
|
|
45
|
+
};
|
|
46
|
+
export type ChartSeries = {
|
|
47
|
+
id: string;
|
|
48
|
+
label: string;
|
|
49
|
+
points: ChartSeriesPoint[];
|
|
50
|
+
color?: string;
|
|
51
|
+
};
|
|
52
|
+
export type ChartHeatCell = {
|
|
53
|
+
x: string;
|
|
54
|
+
y: string;
|
|
55
|
+
value: number;
|
|
56
|
+
};
|
|
57
|
+
export type ChartScatterPoint = {
|
|
58
|
+
id: string;
|
|
59
|
+
label: string;
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
r?: number;
|
|
63
|
+
seriesId?: string;
|
|
64
|
+
};
|
|
65
|
+
export type ChartBlock = BlockBase & {
|
|
66
|
+
type: 'chart';
|
|
67
|
+
kind: ChartKind;
|
|
68
|
+
title: string;
|
|
69
|
+
/** Accessible description (required). */
|
|
70
|
+
description: string;
|
|
71
|
+
series?: ChartSeries[];
|
|
72
|
+
cells?: ChartHeatCell[];
|
|
73
|
+
points?: ChartScatterPoint[];
|
|
74
|
+
};
|
|
75
|
+
export type DataBlock = TableBlock | StatBlock | KpiBlock | ChartBlock;
|
|
76
|
+
export type DataBlockType = DataBlock['type'];
|
|
77
|
+
export declare const DATA_BLOCK_TYPES: readonly ["table", "stat", "kpi", "chart"];
|
|
78
|
+
export declare const CHART_KINDS: readonly ["line", "area", "bar", "stacked-bar", "heatmap", "scatter", "bubble"];
|
|
79
|
+
export declare function parseTableBlock(record: Record<string, unknown>, path: (string | number)[], base: BlockBase): ParseResult<TableBlock>;
|
|
80
|
+
export declare function parseStatBlock(record: Record<string, unknown>, path: (string | number)[], base: BlockBase): ParseResult<StatBlock>;
|
|
81
|
+
export declare function parseKpiBlock(record: Record<string, unknown>, path: (string | number)[], base: BlockBase): ParseResult<KpiBlock>;
|
|
82
|
+
export declare function parseChartBlock(record: Record<string, unknown>, path: (string | number)[], base: BlockBase): ParseResult<ChartBlock>;
|
|
83
|
+
/** Dispatch for the four data block types; returns null when type is not data. */
|
|
84
|
+
export declare function parseDataBlock(type: string, record: Record<string, unknown>, path: (string | number)[], base: BlockBase): ParseResult<DataBlock> | null;
|