@restranger/repi-lib 0.0.0-stage → 0.0.1-sha.9fd9ba8

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/src/view.ts ADDED
@@ -0,0 +1,142 @@
1
+ export type Tone = "default" | "muted" | "accent" | "success" | "warning" | "danger";
2
+
3
+ export type BorderStyle = "default" | "rounded" | "sharp" | "double" | "minimal" | "none";
4
+
5
+ export type BoxVariant = "card" | "callout" | "minimal";
6
+
7
+ export type BoxSide = "left" | "right" | "top" | "bottom";
8
+
9
+ export interface ActionRef {
10
+ id: string;
11
+ payload?: Record<string, unknown>;
12
+ }
13
+
14
+ export interface ListItem {
15
+ id: string;
16
+ text: string;
17
+ tone?: Tone;
18
+ badge?: string;
19
+ done?: boolean;
20
+ status?: string;
21
+ }
22
+
23
+ export type SlotId = "statusline" | "aboveEditor" | "belowEditor" | "header" | "footer" | "overlay";
24
+
25
+ export interface ColNode {
26
+ t: "col";
27
+ id?: string;
28
+ gap?: number;
29
+ children: ViewNode[];
30
+ }
31
+
32
+ export interface RowNode {
33
+ t: "row";
34
+ id?: string;
35
+ gap?: number;
36
+ children: ViewNode[];
37
+ }
38
+
39
+ export interface BoxNode {
40
+ t: "box";
41
+ id?: string;
42
+ title?: string;
43
+ tone?: Tone;
44
+ border?: BorderStyle;
45
+ variant?: BoxVariant;
46
+ sides?: BoxSide[];
47
+ children: ViewNode[];
48
+ }
49
+
50
+ export interface TextNode {
51
+ t: "text";
52
+ id?: string;
53
+ text: string;
54
+ tone?: Tone;
55
+ bold?: boolean;
56
+ wrap?: boolean;
57
+ }
58
+
59
+ export interface MarkdownNode {
60
+ t: "markdown";
61
+ id?: string;
62
+ md: string;
63
+ }
64
+
65
+ export interface BadgeNode {
66
+ t: "badge";
67
+ id?: string;
68
+ text: string;
69
+ tone?: Tone;
70
+ }
71
+
72
+ export interface KeyValueNode {
73
+ t: "kv";
74
+ id?: string;
75
+ items: Array<[string, string]>;
76
+ }
77
+
78
+ export interface ListNode {
79
+ t: "list";
80
+ id?: string;
81
+ items: ListItem[];
82
+ ordered?: boolean;
83
+ checkbox?: boolean;
84
+ onSelect?: ActionRef;
85
+ }
86
+
87
+ export interface TableNode {
88
+ t: "table";
89
+ id?: string;
90
+ head: string[];
91
+ rows: string[][];
92
+ fallback?: ViewNode[];
93
+ }
94
+
95
+ export interface DiffNode {
96
+ t: "diff";
97
+ id?: string;
98
+ patch: string;
99
+ fallback?: ViewNode[];
100
+ }
101
+
102
+ export interface ProgressNode {
103
+ t: "progress";
104
+ id?: string;
105
+ value: number;
106
+ max?: number;
107
+ label?: string;
108
+ }
109
+
110
+ export interface SpinnerNode {
111
+ t: "spinner";
112
+ id?: string;
113
+ label?: string;
114
+ }
115
+
116
+ export interface ButtonNode {
117
+ t: "button";
118
+ id?: string;
119
+ label: string;
120
+ action: ActionRef;
121
+ tone?: Tone;
122
+ }
123
+
124
+ export type ViewNode =
125
+ | ColNode
126
+ | RowNode
127
+ | BoxNode
128
+ | TextNode
129
+ | MarkdownNode
130
+ | BadgeNode
131
+ | KeyValueNode
132
+ | ListNode
133
+ | TableNode
134
+ | DiffNode
135
+ | ProgressNode
136
+ | SpinnerNode
137
+ | ButtonNode;
138
+
139
+ export interface ViewOptions {
140
+ /** Higher priority wins in composition order (`notes/01` §3.9). Defaults to 0. */
141
+ priority?: number;
142
+ }