@toon-ui/core 1.0.0 → 1.2.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/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +271 -16
- package/dist/parser.js.map +1 -1
- package/dist/prompts.d.ts +3 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +130 -20
- package/dist/prompts.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +3 -1
- package/dist/runtime.js.map +1 -1
- package/dist/types.d.ts +198 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +54 -5
- package/dist/types.js.map +1 -1
- package/dist/validator.d.ts.map +1 -1
- package/dist/validator.js +155 -4
- package/dist/validator.js.map +1 -1
- package/package.json +1 -1
package/dist/prompts.js
CHANGED
|
@@ -4,7 +4,9 @@ export function createComponentPrompt(rules) {
|
|
|
4
4
|
`Button variants: ${rules.buttonVariants.join(', ')}`,
|
|
5
5
|
`Badge variants: ${rules.badgeVariants.join(', ')}`,
|
|
6
6
|
`Alert variants: ${rules.alertVariants.join(', ')}`,
|
|
7
|
+
`Confirm variants: ${rules.confirmVariants.join(', ')}`,
|
|
7
8
|
`Field types: ${rules.fieldTypes.join(', ')}`,
|
|
9
|
+
`Chart types: ${rules.chartTypes.join(', ')}`,
|
|
8
10
|
].join('\n');
|
|
9
11
|
}
|
|
10
12
|
export function createSyntaxPrompt() {
|
|
@@ -13,14 +15,29 @@ export function createSyntaxPrompt() {
|
|
|
13
15
|
'- text MUST be: text "Visible text"',
|
|
14
16
|
'- card MUST be: card "Title": followed by indented child nodes',
|
|
15
17
|
'- form MUST be: form "Title": followed by one or more field nodes and one submit button',
|
|
16
|
-
'- field MUST be: field <name> <fieldType> "Label" [required]',
|
|
18
|
+
'- field MUST be: field <name> <fieldType> "Label" [placeholder="..."] [required]',
|
|
17
19
|
'- button MUST be: button <variant> "Label" reply="Value" OR button <variant> "Label" submit',
|
|
18
|
-
'- confirm MUST be: confirm "Title": followed by indented child nodes',
|
|
20
|
+
'- confirm MUST be: confirm <variant> "Title": followed by indented child nodes',
|
|
19
21
|
'- list MUST be: list "Title": followed only by item nodes',
|
|
20
22
|
'- item MUST be: item "Title": followed by indented child nodes',
|
|
21
23
|
'- badge MUST be: badge "Label" <variant>',
|
|
22
24
|
'- alert MUST be: alert <variant> "Title": followed by indented child nodes',
|
|
23
25
|
'- table MUST be: table "Title": followed by columns: ... and one or more row: ... lines',
|
|
26
|
+
'- heading MUST be: heading <1-6> "Visible text"',
|
|
27
|
+
'- separator MUST be: separator OR separator horizontal|vertical',
|
|
28
|
+
'- empty MUST be: empty "Title": followed by indented child nodes',
|
|
29
|
+
'- tabs MUST be: tabs "Title": followed by one or more tab "Label": blocks',
|
|
30
|
+
'- accordion MUST be: accordion "Title": followed by one or more section "Title": blocks',
|
|
31
|
+
'- dialog, sheet, and popover MUST be: <component> "Title": followed by indented child nodes',
|
|
32
|
+
'- tooltip MUST be: tooltip "Visible text"',
|
|
33
|
+
'- progress MUST be: progress "Label" value=<number> max=<number>',
|
|
34
|
+
'- loading MUST be: loading "Visible text"',
|
|
35
|
+
'- toast MUST be: toast <variant> "Visible text"',
|
|
36
|
+
'- breadcrumb MUST be: breadcrumb: followed by one or more crumb "Label" [reply="..."] lines',
|
|
37
|
+
'- pagination MUST be: pagination page=<number> totalPages=<number>',
|
|
38
|
+
'- menu and command MUST be: <component> "Title": followed by one or more action "Label" reply="..." or submit lines',
|
|
39
|
+
'- chart MUST be: chart <type> "Title": followed by one or more series "Label": blocks with point "Label" <number> rows',
|
|
40
|
+
'- In tables, quote every column name and every row cell, especially when values may contain commas like currency or large numbers',
|
|
24
41
|
'- card, form, confirm, list, item, alert, and table ALWAYS require a quoted title',
|
|
25
42
|
'- badge NEVER has children and NEVER has a title prop',
|
|
26
43
|
].join('\n');
|
|
@@ -28,10 +45,11 @@ export function createSyntaxPrompt() {
|
|
|
28
45
|
export function createFallbackPrompt() {
|
|
29
46
|
return [
|
|
30
47
|
'Fallback rules:',
|
|
31
|
-
'- If you are unsure, use only: card, text, badge, button, form, field, confirm, list, item, alert, table.',
|
|
32
|
-
'-
|
|
48
|
+
'- If you are unsure, use only: card, text, heading, badge, button, form, field, confirm, list, item, alert, table, empty.',
|
|
49
|
+
'- Use heading for hierarchy instead of inventing header, subtitle, or title props on random nodes.',
|
|
33
50
|
'- If you need secondary information, use more text nodes instead of inventing props or components.',
|
|
34
|
-
'-
|
|
51
|
+
'- Use section only inside accordion, tab only inside tabs, action only inside menu/command, crumb only inside breadcrumb, series only inside chart, and point only inside series.',
|
|
52
|
+
'- NEVER invent components such as header, footer, subtitle, description, input, modal, stack, grid, or divider.',
|
|
35
53
|
].join('\n');
|
|
36
54
|
}
|
|
37
55
|
export function createSafetyPrompt() {
|
|
@@ -42,42 +60,127 @@ export function createSafetyPrompt() {
|
|
|
42
60
|
'- Never invent components or props outside the official ToonUI catalog.',
|
|
43
61
|
'- Never emit raw HTML, script-like content, or arbitrary CSS.',
|
|
44
62
|
'- Do not execute business actions directly. UI interactions must send user intent back to the chat.',
|
|
63
|
+
'- The prompt instructions stay in English, but visible UI labels, titles, button text, and field labels should follow the user language and conversation context.',
|
|
64
|
+
].join('\n');
|
|
65
|
+
}
|
|
66
|
+
export function createCompositionPrompt() {
|
|
67
|
+
return [
|
|
68
|
+
'Composition best practices:',
|
|
69
|
+
'- Lead with the most useful UI, not with an explanation about the UI.',
|
|
70
|
+
'- Use ONE focused ToonUI block per intent unless the user truly needs multiple separate blocks.',
|
|
71
|
+
'- Keep actions close to the data they affect.',
|
|
72
|
+
'- Prefer simple trees over deeply nested trees.',
|
|
73
|
+
'- Use heading and separator to improve scanability when a card or dialog has multiple sections.',
|
|
74
|
+
'- Use empty for zero-result states instead of plain prose.',
|
|
75
|
+
'- Use loading, progress, and toast for system state and feedback when relevant.',
|
|
76
|
+
'- Use breadcrumb and pagination only when the user is navigating a larger result space.',
|
|
77
|
+
'- Use chart only when the user needs trend or comparison understanding; otherwise prefer table for precise values.',
|
|
78
|
+
].join('\n');
|
|
79
|
+
}
|
|
80
|
+
export function createFormBestPracticesPrompt() {
|
|
81
|
+
return [
|
|
82
|
+
'Form and data-capture best practices:',
|
|
83
|
+
'- If the assistant needs 2 or more structured inputs, prefer a form instead of asking one question at a time.',
|
|
84
|
+
'- If the user must fill several loose values, emit one complete form so the user can answer everything at once.',
|
|
85
|
+
'- Prefer field over ad-hoc text instructions whenever the data is structured.',
|
|
86
|
+
'- Use required only for truly mandatory fields.',
|
|
87
|
+
'- Add placeholder when it helps the user understand the expected format.',
|
|
88
|
+
'- Add helper text for constraints, formatting, or business rules that might be missed.',
|
|
89
|
+
'- Use select, radio, checkbox, switch, slider, or multiselect when the valid values are constrained.',
|
|
90
|
+
'- Use combobox when the user must search within a known set of options.',
|
|
91
|
+
'- Use textarea only for long-form text.',
|
|
92
|
+
'- Use otp only for verification codes, not generic numeric input.',
|
|
93
|
+
'- Group related fields in one form instead of scattering separate forms across the response.',
|
|
94
|
+
'- A form should usually end with exactly one primary submit button and optional secondary reply buttons only when needed.',
|
|
95
|
+
].join('\n');
|
|
96
|
+
}
|
|
97
|
+
export function createDecisionPrompt() {
|
|
98
|
+
return [
|
|
99
|
+
'UI decision policy:',
|
|
100
|
+
'- Prefer ToonUI over plain markdown whenever the user needs to choose, confirm, fill structured data, scan structured business results, compare values, or navigate options.',
|
|
101
|
+
'- Default toward UI when it can reduce back-and-forth.',
|
|
102
|
+
'- Use form blocks immediately for create, edit, register, capture, or update flows that need multiple structured fields.',
|
|
103
|
+
'- If collecting several loose pieces of information, do NOT ask for them in separate prose questions; emit a form immediately.',
|
|
104
|
+
'- Use confirm danger blocks for destructive actions, confirm warning blocks for risky actions, and confirm neutral blocks for basic confirmations.',
|
|
105
|
+
'- Use table, list, card, chart, tabs, accordion, dialog, sheet, menu, or command when they are a better semantic fit than prose.',
|
|
106
|
+
'- Do NOT ask the user whether they want a UI if a form, confirm, table, list, card, chart, or command block is clearly useful. Emit the ToonUI directly.',
|
|
107
|
+
'- Do NOT ask for form fields one by one in plain prose when a form can capture them better.',
|
|
108
|
+
'- If tool results return multiple records, prefer table or list instead of markdown bullets or ad-hoc prose.',
|
|
109
|
+
'- If a single entity is found and the user may want a next action, prefer card plus buttons.',
|
|
110
|
+
'- If the user must choose among actions, prefer menu or command over prose bullet lists.',
|
|
111
|
+
'- If the user needs hierarchical or dense detail, prefer tabs or accordion over a wall of text.',
|
|
112
|
+
'- If the user asks for analytics, trends, or comparison, prefer chart plus optional supporting table.',
|
|
45
113
|
].join('\n');
|
|
46
114
|
}
|
|
47
115
|
export function createExamplesPrompt() {
|
|
48
116
|
return [
|
|
49
117
|
'Valid examples:',
|
|
50
118
|
'```toon-ui',
|
|
51
|
-
'form "
|
|
52
|
-
' field name text "
|
|
53
|
-
' field price number "
|
|
54
|
-
' button primary "
|
|
119
|
+
'form "Create product":',
|
|
120
|
+
' field name text "Name" placeholder="Ex: Coca-Cola" required',
|
|
121
|
+
' field price number "Price" placeholder="Ex: 25.50" required',
|
|
122
|
+
' button primary "Create product" submit',
|
|
55
123
|
'```',
|
|
56
124
|
'',
|
|
57
125
|
'```toon-ui',
|
|
58
|
-
'card "
|
|
126
|
+
'card "Customer found":',
|
|
59
127
|
' text "Jefferson Lopez Mendoza"',
|
|
60
|
-
' badge "
|
|
61
|
-
' button secondary "
|
|
128
|
+
' badge "Active" success',
|
|
129
|
+
' button secondary "View history" reply="View customer history"',
|
|
130
|
+
'```',
|
|
131
|
+
'',
|
|
132
|
+
'```toon-ui',
|
|
133
|
+
'confirm danger "Delete customer?":',
|
|
134
|
+
' text "This action cannot be undone."',
|
|
135
|
+
' button secondary "Cancel" reply="Cancel"',
|
|
136
|
+
' button danger "Yes, delete" reply="Yes, delete customer"',
|
|
62
137
|
'```',
|
|
63
138
|
'',
|
|
64
139
|
'```toon-ui',
|
|
65
|
-
'confirm "
|
|
66
|
-
' text "
|
|
67
|
-
' button secondary "
|
|
68
|
-
' button
|
|
140
|
+
'confirm neutral "Continue with selected customer?":',
|
|
141
|
+
' text "We will use this customer for the current sale."',
|
|
142
|
+
' button secondary "Cancel" reply="Cancel"',
|
|
143
|
+
' button primary "Continue" reply="Continue with selected customer"',
|
|
144
|
+
'```',
|
|
145
|
+
'',
|
|
146
|
+
'```toon-ui',
|
|
147
|
+
'table "Sales":',
|
|
148
|
+
' columns: "Date", "Sale number", "Total", "Status"',
|
|
149
|
+
' row: "May 14", "177877222574876", "$ 387.45", "Completed"',
|
|
150
|
+
' row: "May 09", "177836532655064", "$ 8,155.35", "Completed"',
|
|
151
|
+
'```',
|
|
152
|
+
'',
|
|
153
|
+
'```toon-ui',
|
|
154
|
+
'chart bar "Weekly sales" x="Day" y="Revenue":',
|
|
155
|
+
' series "Store A":',
|
|
156
|
+
' point "Mon" 1200',
|
|
157
|
+
' point "Tue" 980',
|
|
158
|
+
'```',
|
|
159
|
+
'',
|
|
160
|
+
'```toon-ui',
|
|
161
|
+
'form "Create product":',
|
|
162
|
+
' field name text "Name" placeholder="Ex: Coca-Cola" required',
|
|
163
|
+
' field sku text "SKU" placeholder="Ex: COCA-355" required',
|
|
164
|
+
' field price number "Price" placeholder="Ex: 25.50" required',
|
|
165
|
+
' field cost number "Cost" placeholder="Ex: 12.00" required',
|
|
166
|
+
' field stock number "Initial stock" placeholder="Ex: 50" required',
|
|
167
|
+
' button primary "Create product" submit',
|
|
69
168
|
'```',
|
|
70
169
|
'',
|
|
71
170
|
'Invalid examples to avoid:',
|
|
72
|
-
'- header "
|
|
171
|
+
'- header "Customer" -> INVALID because header is not an allowed component',
|
|
73
172
|
'- card: -> INVALID because card requires a quoted title',
|
|
74
|
-
'- badge success "
|
|
75
|
-
'-
|
|
173
|
+
'- badge success "Customer" -> INVALID because badge syntax is badge "Label" variant',
|
|
174
|
+
'- confirm "Delete customer?": -> VALID for backward compatibility, but prefer confirm danger|warning|neutral "Title":',
|
|
175
|
+
'- form "Customer": with no submit button -> INVALID',
|
|
176
|
+
'- row: May 09, $ 8,155.35, Completed -> RISKY because commas inside values can break the table unless cells are quoted',
|
|
177
|
+
'- "Do you want me to build a UI for this?" -> BAD when a form, confirm, table, list, or card is already the obvious best response',
|
|
76
178
|
].join('\n');
|
|
77
179
|
}
|
|
78
180
|
export function createPrompt(rules) {
|
|
79
181
|
return [
|
|
80
182
|
'You are generating ToonUI for an AI-native app.',
|
|
183
|
+
'Your job is to reduce friction for the user by turning structured intent into structured UI whenever it helps.',
|
|
81
184
|
createComponentPrompt(rules),
|
|
82
185
|
'',
|
|
83
186
|
createSyntaxPrompt(),
|
|
@@ -85,14 +188,21 @@ export function createPrompt(rules) {
|
|
|
85
188
|
'Interaction rules:',
|
|
86
189
|
'- Every button must include variant, label, and reply="..." or submit.',
|
|
87
190
|
'- Every form must include a title, fields, and a submit button.',
|
|
88
|
-
'-
|
|
191
|
+
'- Prefer confirm danger for destructive actions, confirm warning for risky actions, and confirm neutral for normal confirmations.',
|
|
89
192
|
'- Reply protocol: emit user intent through compact ui_reply messages only.',
|
|
90
193
|
'- Submit protocol: emit compact ui_submit payloads with intent and field values only.',
|
|
194
|
+
'- Visible UI copy must match the user language and the business context.',
|
|
195
|
+
'',
|
|
196
|
+
createCompositionPrompt(),
|
|
197
|
+
'',
|
|
198
|
+
createFormBestPracticesPrompt(),
|
|
91
199
|
'',
|
|
92
200
|
createFallbackPrompt(),
|
|
93
201
|
'',
|
|
94
202
|
createSafetyPrompt(),
|
|
95
203
|
'',
|
|
204
|
+
createDecisionPrompt(),
|
|
205
|
+
'',
|
|
96
206
|
createExamplesPrompt(),
|
|
97
207
|
].join('\n');
|
|
98
208
|
}
|
package/dist/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,qBAAqB,CAAC,KAAgB;IACpD,OAAO;QACL,uBAAuB,KAAK,CAAC,UAAU,CAAC,IAAI,CAA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C,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,OAAO;QACL,iDAAiD;QACjD,gHAAgH;QAChH,qBAAqB,CAAC,KAAK,CAAC;QAC5B,EAAE;QACF,kBAAkB,EAAE;QACpB,EAAE;QACF,oBAAoB;QACpB,wEAAwE;QACxE,iEAAiE;QACjE,mIAAmI;QACnI,4EAA4E;QAC5E,uFAAuF;QACvF,0EAA0E;QAC1E,EAAE;QACF,uBAAuB,EAAE;QACzB,EAAE;QACF,6BAA6B,EAAE;QAC/B,EAAE;QACF,oBAAoB,EAAE;QACtB,EAAE;QACF,kBAAkB,EAAE;QACpB,EAAE;QACF,oBAAoB,EAAE;QACtB,EAAE;QACF,oBAAoB,EAAE;KACvB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwH,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAgB5W,wBAAgB,WAAW,IAAI,SAAS,CAUvC;AAED,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,MAAM,GAAG,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,MAAM,CAiBvI;AAED,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,YAAY,EAAE,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAM,GAAG,MAAM,CAiB1I;AAmBD,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,sBAAsB,EAAE,OAAO,EAAE,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,CAkBvH;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,sBAAsB,EAAE,OAAO,EAAE,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAY3H;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAWjD;AAED,wBAAgB,qBAAqB,CAAC,WAAW,SAAS,qBAAqB,GAAG,qBAAqB,EAAE,OAAO,GAAE,mBAAmB,CAAC,WAAW,CAAM,GAAG,WAAW,CAAC,WAAW,CAAC,CASjL"}
|
package/dist/runtime.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createPrompt } from './prompts';
|
|
|
2
2
|
import { parseToonUI } from './parser';
|
|
3
3
|
import { validateToonUI } from './validator';
|
|
4
4
|
import { extractToonBlocks } from './formatter';
|
|
5
|
-
import { ALERT_VARIANTS, BADGE_VARIANTS, BUTTON_VARIANTS, FIELD_TYPES, OFFICIAL_COMPONENT_KEYS } from './types';
|
|
5
|
+
import { ALERT_VARIANTS, BADGE_VARIANTS, BUTTON_VARIANTS, CHART_TYPES, CONFIRM_VARIANTS, FIELD_TYPES, OFFICIAL_COMPONENT_KEYS } from './types';
|
|
6
6
|
function createEventId(prefix) {
|
|
7
7
|
return `${prefix}_${Math.random().toString(36).slice(2, 10)}`;
|
|
8
8
|
}
|
|
@@ -12,7 +12,9 @@ export function createRules() {
|
|
|
12
12
|
buttonVariants: BUTTON_VARIANTS,
|
|
13
13
|
badgeVariants: BADGE_VARIANTS,
|
|
14
14
|
alertVariants: ALERT_VARIANTS,
|
|
15
|
+
confirmVariants: CONFIRM_VARIANTS,
|
|
15
16
|
fieldTypes: FIELD_TYPES,
|
|
17
|
+
chartTypes: CHART_TYPES,
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
export function formatSubmitMessage(intentOrPayload, values) {
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,uBAAuB,EAA+N,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,uBAAuB,EAA+N,MAAM,SAAS,CAAC;AAE5W,SAAS,aAAa,CAAC,MAAc;IACnC,OAAO,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AAChE,CAAC;AAYD,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,UAAU,EAAE,uBAAuB;QACnC,cAAc,EAAE,eAAe;QAC/B,aAAa,EAAE,cAAc;QAC7B,aAAa,EAAE,cAAc;QA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MAAM,QAAQ,GAAG,kBAAkB,EAAE,CAAC;IACtC,OAAO;QACL,UAAU,EAAE,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAgB;QACrD,GAAG,QAAQ;QACX,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE,cAAc;QACxB,aAAa,EAAE,iBAAiB;KACjC,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,86 +1,230 @@
|
|
|
1
|
-
export declare const OFFICIAL_COMPONENT_KEYS: readonly ["text", "card", "form", "field", "button", "confirm", "list", "item", "badge", "alert", "table"];
|
|
1
|
+
export declare const OFFICIAL_COMPONENT_KEYS: readonly ["text", "heading", "separator", "card", "form", "field", "button", "confirm", "list", "item", "badge", "alert", "table", "empty", "tabs", "accordion", "dialog", "sheet", "popover", "tooltip", "progress", "loading", "toast", "breadcrumb", "pagination", "menu", "command", "chart"];
|
|
2
2
|
export declare const BUTTON_VARIANTS: readonly ["primary", "secondary", "danger", "ghost", "outline"];
|
|
3
3
|
export declare const BADGE_VARIANTS: readonly ["success", "warning", "danger", "neutral", "info"];
|
|
4
4
|
export declare const ALERT_VARIANTS: readonly ["info", "success", "warning", "danger"];
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const CONFIRM_VARIANTS: readonly ["neutral", "info", "warning", "danger", "success"];
|
|
6
|
+
export declare const FIELD_TYPES: readonly ["text", "email", "number", "password", "date", "time", "textarea", "select", "checkbox", "radio", "switch", "combobox", "otp", "slider", "multiselect"];
|
|
7
|
+
export declare const CHART_TYPES: readonly ["bar", "line", "area", "pie"];
|
|
8
|
+
export declare const SHEET_SIDES: readonly ["left", "right", "top", "bottom"];
|
|
9
|
+
export declare const SEPARATOR_ORIENTATIONS: readonly ["horizontal", "vertical"];
|
|
6
10
|
export type ToonComponentKey = (typeof OFFICIAL_COMPONENT_KEYS)[number];
|
|
7
11
|
export type ButtonVariant = (typeof BUTTON_VARIANTS)[number];
|
|
8
12
|
export type BadgeVariant = (typeof BADGE_VARIANTS)[number];
|
|
9
13
|
export type AlertVariant = (typeof ALERT_VARIANTS)[number];
|
|
14
|
+
export type ConfirmVariant = (typeof CONFIRM_VARIANTS)[number];
|
|
10
15
|
export type FieldType = (typeof FIELD_TYPES)[number];
|
|
11
|
-
export type
|
|
12
|
-
export type
|
|
16
|
+
export type ChartType = (typeof CHART_TYPES)[number];
|
|
17
|
+
export type SheetSide = (typeof SHEET_SIDES)[number];
|
|
18
|
+
export type SeparatorOrientation = (typeof SEPARATOR_ORIENTATIONS)[number];
|
|
19
|
+
export type SubmitScalar = string | number | boolean;
|
|
20
|
+
export type SubmitValue = SubmitScalar | SubmitScalar[];
|
|
21
|
+
export type ToonErrorCode = 'INVALID_COMPONENT' | 'INVALID_PROP' | 'INVALID_VARIANT' | 'MISSING_REQUIRED_FIELD' | 'INVALID_NESTING' | 'INVALID_SYNTAX' | 'UNSAFE_CONTENT';
|
|
13
22
|
export interface BaseNode {
|
|
14
|
-
type:
|
|
23
|
+
type: string;
|
|
15
24
|
line: number;
|
|
16
25
|
column: number;
|
|
17
26
|
}
|
|
18
27
|
export interface TextNode extends BaseNode {
|
|
19
|
-
type:
|
|
28
|
+
type: 'text';
|
|
20
29
|
value: string;
|
|
21
30
|
}
|
|
31
|
+
export interface HeadingNode extends BaseNode {
|
|
32
|
+
type: 'heading';
|
|
33
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
34
|
+
text: string;
|
|
35
|
+
}
|
|
36
|
+
export interface SeparatorNode extends BaseNode {
|
|
37
|
+
type: 'separator';
|
|
38
|
+
orientation: SeparatorOrientation;
|
|
39
|
+
}
|
|
22
40
|
export interface BadgeNode extends BaseNode {
|
|
23
|
-
type:
|
|
41
|
+
type: 'badge';
|
|
24
42
|
label: string;
|
|
25
43
|
variant: BadgeVariant;
|
|
26
44
|
}
|
|
27
45
|
export interface ButtonNode extends BaseNode {
|
|
28
|
-
type:
|
|
46
|
+
type: 'button';
|
|
29
47
|
variant: ButtonVariant;
|
|
30
48
|
label: string;
|
|
31
49
|
action: {
|
|
32
|
-
kind:
|
|
50
|
+
kind: 'reply';
|
|
33
51
|
value: string;
|
|
34
52
|
} | {
|
|
35
|
-
kind:
|
|
53
|
+
kind: 'submit';
|
|
36
54
|
};
|
|
37
55
|
}
|
|
38
56
|
export interface FieldNode extends BaseNode {
|
|
39
|
-
type:
|
|
57
|
+
type: 'field';
|
|
40
58
|
name: string;
|
|
41
59
|
fieldType: FieldType;
|
|
42
60
|
label: string;
|
|
61
|
+
placeholder?: string;
|
|
62
|
+
helper?: string;
|
|
43
63
|
required: boolean;
|
|
64
|
+
options?: string[];
|
|
65
|
+
min?: number;
|
|
66
|
+
max?: number;
|
|
67
|
+
step?: number;
|
|
68
|
+
value?: SubmitValue;
|
|
44
69
|
}
|
|
45
70
|
export interface CardNode extends BaseNode {
|
|
46
|
-
type:
|
|
71
|
+
type: 'card';
|
|
47
72
|
title: string;
|
|
48
73
|
children: ToonNode[];
|
|
49
74
|
}
|
|
50
75
|
export interface ConfirmNode extends BaseNode {
|
|
51
|
-
type:
|
|
76
|
+
type: 'confirm';
|
|
77
|
+
variant: ConfirmVariant;
|
|
52
78
|
title: string;
|
|
53
79
|
children: ToonNode[];
|
|
54
80
|
}
|
|
55
81
|
export interface ItemNode extends BaseNode {
|
|
56
|
-
type:
|
|
82
|
+
type: 'item';
|
|
57
83
|
title: string;
|
|
58
84
|
children: ToonNode[];
|
|
59
85
|
}
|
|
60
86
|
export interface ListNode extends BaseNode {
|
|
61
|
-
type:
|
|
87
|
+
type: 'list';
|
|
62
88
|
title: string;
|
|
63
|
-
children:
|
|
89
|
+
children: ToonNode[];
|
|
64
90
|
}
|
|
65
91
|
export interface AlertNode extends BaseNode {
|
|
66
|
-
type:
|
|
92
|
+
type: 'alert';
|
|
67
93
|
variant: AlertVariant;
|
|
68
94
|
title: string;
|
|
69
95
|
children: ToonNode[];
|
|
70
96
|
}
|
|
71
97
|
export interface TableNode extends BaseNode {
|
|
72
|
-
type:
|
|
98
|
+
type: 'table';
|
|
73
99
|
title: string;
|
|
74
100
|
columns: string[];
|
|
75
101
|
rows: string[][];
|
|
76
102
|
}
|
|
77
103
|
export interface FormNode extends BaseNode {
|
|
78
|
-
type:
|
|
104
|
+
type: 'form';
|
|
105
|
+
title: string;
|
|
106
|
+
children: ToonNode[];
|
|
107
|
+
}
|
|
108
|
+
export interface EmptyNode extends BaseNode {
|
|
109
|
+
type: 'empty';
|
|
110
|
+
title: string;
|
|
111
|
+
children: ToonNode[];
|
|
112
|
+
}
|
|
113
|
+
export interface TabNode extends BaseNode {
|
|
114
|
+
type: 'tab';
|
|
115
|
+
label: string;
|
|
116
|
+
children: ToonNode[];
|
|
117
|
+
}
|
|
118
|
+
export interface TabsNode extends BaseNode {
|
|
119
|
+
type: 'tabs';
|
|
120
|
+
title: string;
|
|
121
|
+
children: TabNode[];
|
|
122
|
+
}
|
|
123
|
+
export interface SectionNode extends BaseNode {
|
|
124
|
+
type: 'section';
|
|
79
125
|
title: string;
|
|
80
126
|
children: ToonNode[];
|
|
81
127
|
}
|
|
128
|
+
export interface AccordionNode extends BaseNode {
|
|
129
|
+
type: 'accordion';
|
|
130
|
+
title: string;
|
|
131
|
+
children: SectionNode[];
|
|
132
|
+
}
|
|
133
|
+
export interface DialogNode extends BaseNode {
|
|
134
|
+
type: 'dialog';
|
|
135
|
+
title: string;
|
|
136
|
+
children: ToonNode[];
|
|
137
|
+
}
|
|
138
|
+
export interface SheetNode extends BaseNode {
|
|
139
|
+
type: 'sheet';
|
|
140
|
+
title: string;
|
|
141
|
+
side: SheetSide;
|
|
142
|
+
children: ToonNode[];
|
|
143
|
+
}
|
|
144
|
+
export interface PopoverNode extends BaseNode {
|
|
145
|
+
type: 'popover';
|
|
146
|
+
title: string;
|
|
147
|
+
children: ToonNode[];
|
|
148
|
+
}
|
|
149
|
+
export interface TooltipNode extends BaseNode {
|
|
150
|
+
type: 'tooltip';
|
|
151
|
+
text: string;
|
|
152
|
+
}
|
|
153
|
+
export interface ProgressNode extends BaseNode {
|
|
154
|
+
type: 'progress';
|
|
155
|
+
label: string;
|
|
156
|
+
value: number;
|
|
157
|
+
max: number;
|
|
158
|
+
}
|
|
159
|
+
export interface LoadingNode extends BaseNode {
|
|
160
|
+
type: 'loading';
|
|
161
|
+
text: string;
|
|
162
|
+
}
|
|
163
|
+
export interface ToastNode extends BaseNode {
|
|
164
|
+
type: 'toast';
|
|
165
|
+
variant: AlertVariant;
|
|
166
|
+
text: string;
|
|
167
|
+
}
|
|
168
|
+
export interface CrumbNode extends BaseNode {
|
|
169
|
+
type: 'crumb';
|
|
170
|
+
label: string;
|
|
171
|
+
action?: {
|
|
172
|
+
kind: 'reply';
|
|
173
|
+
value: string;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export interface BreadcrumbNode extends BaseNode {
|
|
177
|
+
type: 'breadcrumb';
|
|
178
|
+
children: CrumbNode[];
|
|
179
|
+
}
|
|
180
|
+
export interface PaginationNode extends BaseNode {
|
|
181
|
+
type: 'pagination';
|
|
182
|
+
page: number;
|
|
183
|
+
totalPages: number;
|
|
184
|
+
}
|
|
185
|
+
export interface ActionNode extends BaseNode {
|
|
186
|
+
type: 'action';
|
|
187
|
+
label: string;
|
|
188
|
+
action: {
|
|
189
|
+
kind: 'reply';
|
|
190
|
+
value: string;
|
|
191
|
+
} | {
|
|
192
|
+
kind: 'submit';
|
|
193
|
+
};
|
|
194
|
+
variant?: ButtonVariant;
|
|
195
|
+
}
|
|
196
|
+
export interface MenuNode extends BaseNode {
|
|
197
|
+
type: 'menu';
|
|
198
|
+
title: string;
|
|
199
|
+
children: ActionNode[];
|
|
200
|
+
}
|
|
201
|
+
export interface CommandNode extends BaseNode {
|
|
202
|
+
type: 'command';
|
|
203
|
+
title: string;
|
|
204
|
+
children: ActionNode[];
|
|
205
|
+
}
|
|
206
|
+
export interface ChartPointNode extends BaseNode {
|
|
207
|
+
type: 'point';
|
|
208
|
+
label: string;
|
|
209
|
+
value: number;
|
|
210
|
+
}
|
|
211
|
+
export interface ChartSeriesNode extends BaseNode {
|
|
212
|
+
type: 'series';
|
|
213
|
+
label: string;
|
|
214
|
+
children: ChartPointNode[];
|
|
215
|
+
}
|
|
216
|
+
export interface ChartNode extends BaseNode {
|
|
217
|
+
type: 'chart';
|
|
218
|
+
chartType: ChartType;
|
|
219
|
+
title: string;
|
|
220
|
+
xLabel?: string;
|
|
221
|
+
yLabel?: string;
|
|
222
|
+
children: ChartSeriesNode[];
|
|
223
|
+
}
|
|
82
224
|
export interface ToonNodeByType {
|
|
83
225
|
text: TextNode;
|
|
226
|
+
heading: HeadingNode;
|
|
227
|
+
separator: SeparatorNode;
|
|
84
228
|
card: CardNode;
|
|
85
229
|
form: FormNode;
|
|
86
230
|
field: FieldNode;
|
|
@@ -91,15 +235,36 @@ export interface ToonNodeByType {
|
|
|
91
235
|
badge: BadgeNode;
|
|
92
236
|
alert: AlertNode;
|
|
93
237
|
table: TableNode;
|
|
238
|
+
empty: EmptyNode;
|
|
239
|
+
tabs: TabsNode;
|
|
240
|
+
tab: TabNode;
|
|
241
|
+
accordion: AccordionNode;
|
|
242
|
+
section: SectionNode;
|
|
243
|
+
dialog: DialogNode;
|
|
244
|
+
sheet: SheetNode;
|
|
245
|
+
popover: PopoverNode;
|
|
246
|
+
tooltip: TooltipNode;
|
|
247
|
+
progress: ProgressNode;
|
|
248
|
+
loading: LoadingNode;
|
|
249
|
+
toast: ToastNode;
|
|
250
|
+
breadcrumb: BreadcrumbNode;
|
|
251
|
+
crumb: CrumbNode;
|
|
252
|
+
pagination: PaginationNode;
|
|
253
|
+
menu: MenuNode;
|
|
254
|
+
command: CommandNode;
|
|
255
|
+
action: ActionNode;
|
|
256
|
+
chart: ChartNode;
|
|
257
|
+
series: ChartSeriesNode;
|
|
258
|
+
point: ChartPointNode;
|
|
94
259
|
}
|
|
95
260
|
export type ToonNode = ToonNodeByType[keyof ToonNodeByType];
|
|
96
261
|
export interface ToonDocument {
|
|
97
|
-
type:
|
|
262
|
+
type: 'document';
|
|
98
263
|
body: ToonNode[];
|
|
99
264
|
}
|
|
100
265
|
export interface ToonBlock {
|
|
101
266
|
raw: string;
|
|
102
|
-
language:
|
|
267
|
+
language: 'toon-ui';
|
|
103
268
|
start: number;
|
|
104
269
|
end: number;
|
|
105
270
|
complete: boolean;
|
|
@@ -120,21 +285,23 @@ export interface ToonRules {
|
|
|
120
285
|
buttonVariants: readonly ButtonVariant[];
|
|
121
286
|
badgeVariants: readonly BadgeVariant[];
|
|
122
287
|
alertVariants: readonly AlertVariant[];
|
|
288
|
+
confirmVariants: readonly ConfirmVariant[];
|
|
123
289
|
fieldTypes: readonly FieldType[];
|
|
290
|
+
chartTypes: readonly ChartType[];
|
|
124
291
|
}
|
|
125
292
|
export interface ReplyPayload {
|
|
126
|
-
kind:
|
|
293
|
+
kind: 'ui_reply';
|
|
127
294
|
eventId: string;
|
|
128
|
-
source:
|
|
295
|
+
source: 'button';
|
|
129
296
|
value: string;
|
|
130
|
-
component:
|
|
297
|
+
component: 'button';
|
|
131
298
|
line?: number;
|
|
132
299
|
context?: Record<string, SubmitValue>;
|
|
133
300
|
}
|
|
134
301
|
export interface SubmitPayload {
|
|
135
|
-
kind:
|
|
302
|
+
kind: 'ui_submit';
|
|
136
303
|
eventId: string;
|
|
137
|
-
source:
|
|
304
|
+
source: 'form';
|
|
138
305
|
intent: string;
|
|
139
306
|
formTitle: string;
|
|
140
307
|
values: Record<string, SubmitValue>;
|
|
@@ -142,23 +309,23 @@ export interface SubmitPayload {
|
|
|
142
309
|
}
|
|
143
310
|
export type ToonInteractionPayload = ReplyPayload | SubmitPayload;
|
|
144
311
|
export interface ToonChatMessage<TPayload extends ToonInteractionPayload = ToonInteractionPayload> {
|
|
145
|
-
role:
|
|
146
|
-
kind: TPayload[
|
|
312
|
+
role: 'user';
|
|
313
|
+
kind: TPayload['kind'];
|
|
147
314
|
content: string;
|
|
148
315
|
displayContent: string;
|
|
149
316
|
payload: TPayload;
|
|
150
317
|
}
|
|
151
318
|
export interface ToonChatUIMessageMetadata<TPayload extends ToonInteractionPayload = ToonInteractionPayload> {
|
|
152
319
|
displayContent: string;
|
|
153
|
-
kind: TPayload[
|
|
320
|
+
kind: TPayload['kind'];
|
|
154
321
|
}
|
|
155
322
|
export interface ToonChatUIMessagePart {
|
|
156
|
-
type:
|
|
323
|
+
type: 'text';
|
|
157
324
|
text: string;
|
|
158
325
|
}
|
|
159
326
|
export interface ToonChatUIMessage<TPayload extends ToonInteractionPayload = ToonInteractionPayload> {
|
|
160
327
|
id: string;
|
|
161
|
-
role:
|
|
328
|
+
role: 'user';
|
|
162
329
|
parts: [ToonChatUIMessagePart];
|
|
163
330
|
metadata: ToonChatUIMessageMetadata<TPayload>;
|
|
164
331
|
}
|