@dinachi/cli 0.8.1 → 0.9.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/CHANGELOG.md +87 -0
- package/README.md +2 -0
- package/dist/index.js +131 -4
- package/package.json +14 -10
- package/templates/accordion/accordion.tsx +5 -8
- package/templates/badge/badge.tsx +4 -4
- package/templates/json-render/catalog.ts +483 -0
- package/templates/json-render/components.tsx +958 -0
- package/templates/json-render/index.ts +36 -0
- package/templates/json-render/registry.ts +21 -0
- package/templates/link/index.ts +2 -0
- package/templates/link/link.tsx +94 -0
- package/templates/otp-field/index.ts +1 -0
- package/templates/otp-field/otp-field.tsx +72 -0
- package/templates/select/select.tsx +4 -2
- package/templates/slider/slider.tsx +1 -1
- package/templates/text/index.ts +2 -0
- package/templates/text/text.tsx +70 -0
- package/templates/tsconfig.json +2 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// Shared validation schema for form components
|
|
5
|
+
// =============================================================================
|
|
6
|
+
|
|
7
|
+
const validationSchema = {
|
|
8
|
+
checks: z.array(z.object({
|
|
9
|
+
type: z.string(),
|
|
10
|
+
message: z.string(),
|
|
11
|
+
args: z.record(z.string(), z.unknown()).optional(),
|
|
12
|
+
})).optional(),
|
|
13
|
+
validateOn: z.enum(["change", "blur", "submit"]).optional(),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// Component + Action Definitions
|
|
18
|
+
// =============================================================================
|
|
19
|
+
|
|
20
|
+
const dinachiComponentDefinitions = {
|
|
21
|
+
Box: {
|
|
22
|
+
props: z.object({
|
|
23
|
+
display: z.enum(["flex", "grid"]).optional(),
|
|
24
|
+
direction: z.enum(["row", "column"]).optional(),
|
|
25
|
+
gap: z.enum(["none", "xs", "sm", "md", "lg", "xl"]).optional(),
|
|
26
|
+
align: z.enum(["start", "center", "end", "stretch", "baseline"]).optional(),
|
|
27
|
+
justify: z.enum(["start", "center", "end", "between", "around", "evenly"]).optional(),
|
|
28
|
+
wrap: z.boolean().optional(),
|
|
29
|
+
padding: z.enum(["none", "xs", "sm", "md", "lg", "xl"]).optional(),
|
|
30
|
+
columns: z.enum(["1", "2", "3", "4"]).optional(),
|
|
31
|
+
}),
|
|
32
|
+
slots: ["default"],
|
|
33
|
+
description:
|
|
34
|
+
"Layout container. Default display=flex, direction=column. Set display=grid with columns for card grids, metric dashboards, and equal-width layouts. Use flex direction=row for inline groups (button rows, avatar+text). Gap: xs=tight, sm=related, md=standard, lg=sections.",
|
|
35
|
+
example: { display: "grid", columns: "3", gap: "md" },
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
Text: {
|
|
39
|
+
props: z.object({
|
|
40
|
+
content: z.string(),
|
|
41
|
+
variant: z.enum(["h1", "h2", "h3", "h4", "p", "large", "small", "lead", "muted", "blockquote", "code", "span"]).optional(),
|
|
42
|
+
}),
|
|
43
|
+
description:
|
|
44
|
+
"Text display. h2=page title (one per page), h3=section/card title, h4=sub-section, p=body (default), large=emphasized body, small=captions/metadata, lead=intro paragraph after heading, muted=helper/secondary/timestamps, blockquote=quotes/testimonials, code=inline code, span=inline.",
|
|
45
|
+
example: { content: "Hello World", variant: "h2" },
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
Button: {
|
|
49
|
+
props: z.object({
|
|
50
|
+
label: z.string(),
|
|
51
|
+
variant: z
|
|
52
|
+
.enum(["default", "destructive", "outline", "secondary", "ghost", "link"])
|
|
53
|
+
.optional(),
|
|
54
|
+
size: z.enum(["default", "sm", "lg", "icon"]).optional(),
|
|
55
|
+
disabled: z.boolean().optional(),
|
|
56
|
+
}),
|
|
57
|
+
description:
|
|
58
|
+
"Clickable button. default=primary CTA (one per section), outline/secondary=secondary action, ghost=tertiary/cancel, destructive=dangerous (pair with confirmation), link=navigation only. Emits 'press'.",
|
|
59
|
+
example: { label: "Submit", variant: "default" },
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
Input: {
|
|
63
|
+
props: z.object({
|
|
64
|
+
label: z.string().optional(),
|
|
65
|
+
name: z.string().optional(),
|
|
66
|
+
type: z.enum(["text", "email", "password", "number", "tel", "url"]).optional(),
|
|
67
|
+
placeholder: z.string().optional(),
|
|
68
|
+
value: z.string().optional(),
|
|
69
|
+
disabled: z.boolean().optional(),
|
|
70
|
+
required: z.boolean().optional(),
|
|
71
|
+
...validationSchema,
|
|
72
|
+
}),
|
|
73
|
+
description:
|
|
74
|
+
"Text input. Always set label — never rely on placeholder alone. Match type to content: email, tel, number, url, password. Bind value with $bindState for two-way binding. Supports validation via checks array.",
|
|
75
|
+
example: { label: "Email", type: "email", placeholder: "you@example.com", value: { $bindState: "/form/email" } },
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
Textarea: {
|
|
79
|
+
props: z.object({
|
|
80
|
+
label: z.string().optional(),
|
|
81
|
+
name: z.string().optional(),
|
|
82
|
+
placeholder: z.string().optional(),
|
|
83
|
+
rows: z.number().optional(),
|
|
84
|
+
value: z.string().optional(),
|
|
85
|
+
disabled: z.boolean().optional(),
|
|
86
|
+
...validationSchema,
|
|
87
|
+
}),
|
|
88
|
+
description:
|
|
89
|
+
"Multi-line text input. Use for comments, messages, descriptions, or any long-form text. Always set label. Bind value with $bindState for two-way binding. Supports validation via checks array.",
|
|
90
|
+
example: { label: "Message", placeholder: "Type your message..." },
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
Checkbox: {
|
|
94
|
+
props: z.object({
|
|
95
|
+
label: z.string(),
|
|
96
|
+
name: z.string().optional(),
|
|
97
|
+
checked: z.boolean().optional(),
|
|
98
|
+
disabled: z.boolean().optional(),
|
|
99
|
+
required: z.boolean().optional(),
|
|
100
|
+
...validationSchema,
|
|
101
|
+
}),
|
|
102
|
+
description:
|
|
103
|
+
"Checkbox for boolean choices: agreements, opt-ins, multi-select options. Use Switch instead for on/off settings. Bind checked with $bindState. Supports validation.",
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
Switch: {
|
|
107
|
+
props: z.object({
|
|
108
|
+
label: z.string(),
|
|
109
|
+
name: z.string().optional(),
|
|
110
|
+
checked: z.boolean().optional(),
|
|
111
|
+
disabled: z.boolean().optional(),
|
|
112
|
+
}),
|
|
113
|
+
description:
|
|
114
|
+
"Toggle switch for on/off settings (notifications, features, preferences). Use Checkbox instead for agreements or multi-select. Bind checked with $bindState.",
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
Radio: {
|
|
118
|
+
props: z.object({
|
|
119
|
+
label: z.string().optional(),
|
|
120
|
+
name: z.string().optional(),
|
|
121
|
+
options: z.array(
|
|
122
|
+
z.object({
|
|
123
|
+
label: z.string(),
|
|
124
|
+
value: z.string(),
|
|
125
|
+
disabled: z.boolean().optional(),
|
|
126
|
+
})
|
|
127
|
+
),
|
|
128
|
+
value: z.string().optional(),
|
|
129
|
+
...validationSchema,
|
|
130
|
+
}),
|
|
131
|
+
description:
|
|
132
|
+
"Radio group for single selection from 2-5 visible options. Use Select for 6+ options. Use ToggleGroup for compact visual selection. Bind value with $bindState. Supports validation.",
|
|
133
|
+
example: {
|
|
134
|
+
label: "Size",
|
|
135
|
+
options: [
|
|
136
|
+
{ label: "Small", value: "sm" },
|
|
137
|
+
{ label: "Medium", value: "md" },
|
|
138
|
+
{ label: "Large", value: "lg" },
|
|
139
|
+
],
|
|
140
|
+
value: { $bindState: "/form/size" },
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
Select: {
|
|
145
|
+
props: z.object({
|
|
146
|
+
label: z.string().optional(),
|
|
147
|
+
name: z.string().optional(),
|
|
148
|
+
placeholder: z.string().optional(),
|
|
149
|
+
disabled: z.boolean().optional(),
|
|
150
|
+
options: z.array(
|
|
151
|
+
z.object({
|
|
152
|
+
label: z.string(),
|
|
153
|
+
value: z.string(),
|
|
154
|
+
disabled: z.boolean().optional(),
|
|
155
|
+
})
|
|
156
|
+
),
|
|
157
|
+
value: z.string().optional(),
|
|
158
|
+
...validationSchema,
|
|
159
|
+
}),
|
|
160
|
+
description:
|
|
161
|
+
"Dropdown select for single selection from many options (6+). Use Radio for 2-5 visible options. Always set label and a descriptive placeholder. Bind value with $bindState. Supports validation.",
|
|
162
|
+
example: {
|
|
163
|
+
label: "Country",
|
|
164
|
+
placeholder: "Select country",
|
|
165
|
+
options: [
|
|
166
|
+
{ label: "United States", value: "us" },
|
|
167
|
+
{ label: "Canada", value: "ca" },
|
|
168
|
+
],
|
|
169
|
+
value: { $bindState: "/form/country" },
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
Slider: {
|
|
174
|
+
props: z.object({
|
|
175
|
+
label: z.string().optional(),
|
|
176
|
+
min: z.number().optional(),
|
|
177
|
+
max: z.number().optional(),
|
|
178
|
+
step: z.number().optional(),
|
|
179
|
+
value: z.number().optional(),
|
|
180
|
+
disabled: z.boolean().optional(),
|
|
181
|
+
}),
|
|
182
|
+
description:
|
|
183
|
+
"Range slider for numeric selection within a range (ratings, volume, budget). Use NumberField for precise numeric input. Always set label, min, max. Bind value with $bindState.",
|
|
184
|
+
example: { label: "Volume", min: 0, max: 100, step: 1 },
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
Toggle: {
|
|
188
|
+
props: z.object({
|
|
189
|
+
label: z.string(),
|
|
190
|
+
variant: z.enum(["default", "outline"]).optional(),
|
|
191
|
+
size: z.enum(["default", "sm", "lg"]).optional(),
|
|
192
|
+
pressed: z.boolean().optional(),
|
|
193
|
+
}),
|
|
194
|
+
description:
|
|
195
|
+
"Pressable toggle button for binary on/off states (bold, italic, favorite). Use Switch for settings, Checkbox for form agreements. Bind pressed with $bindState.",
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
Label: {
|
|
199
|
+
props: z.object({
|
|
200
|
+
text: z.string(),
|
|
201
|
+
htmlFor: z.string().optional(),
|
|
202
|
+
}),
|
|
203
|
+
description: "Standalone form label. Most form components (Input, Select, Checkbox, etc.) have a built-in label prop — use that instead. Only use Label for custom field layouts.",
|
|
204
|
+
example: { text: "Email address" },
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
Badge: {
|
|
208
|
+
props: z.object({
|
|
209
|
+
text: z.string(),
|
|
210
|
+
variant: z
|
|
211
|
+
.enum(["default", "secondary", "destructive", "outline", "success", "warning", "info"])
|
|
212
|
+
.optional(),
|
|
213
|
+
size: z.enum(["sm", "default", "lg"]).optional(),
|
|
214
|
+
rounded: z.enum(["default", "sm", "md", "lg", "none"]).optional(),
|
|
215
|
+
}),
|
|
216
|
+
description:
|
|
217
|
+
"Status indicator. success=active/approved/complete, warning=pending/caution, destructive=error/blocked, info=neutral update, secondary=metadata/low-emphasis, outline=counts/tags. Keep text short (1-2 words).",
|
|
218
|
+
example: { text: "Active", variant: "success" },
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
Separator: {
|
|
222
|
+
props: z.object({
|
|
223
|
+
orientation: z.enum(["horizontal", "vertical"]).optional(),
|
|
224
|
+
}),
|
|
225
|
+
description: "Visual divider between major content blocks. Use sparingly — prefer gap spacing over separators. Best between sections with different content types (e.g., header vs body, totals vs line items).",
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
Skeleton: {
|
|
229
|
+
props: z.object({
|
|
230
|
+
width: z.string().optional(),
|
|
231
|
+
height: z.string().optional(),
|
|
232
|
+
}),
|
|
233
|
+
description: "Loading placeholder that mimics content shape. Set width/height to match the content it replaces (e.g. '200px', '1rem'). Use multiple Skeletons to represent a loading card or list.",
|
|
234
|
+
example: { width: "200px", height: "20px" },
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
Progress: {
|
|
238
|
+
props: z.object({
|
|
239
|
+
value: z.number(),
|
|
240
|
+
label: z.string().optional(),
|
|
241
|
+
}),
|
|
242
|
+
description: "Progress bar for completion tracking (uploads, onboarding, goals). Value 0-100. Always set label for context. Pair with a Text(variant='muted') showing the percentage.",
|
|
243
|
+
example: { value: 65, label: "Upload progress" },
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
Card: {
|
|
247
|
+
props: z.object({
|
|
248
|
+
title: z.string().optional(),
|
|
249
|
+
description: z.string().optional(),
|
|
250
|
+
}),
|
|
251
|
+
slots: ["default"],
|
|
252
|
+
description:
|
|
253
|
+
"Content group with visual boundary. Always set title for context. Use description for subtitle/context. Ideal for: metrics, form sections, profile blocks, list items, feature highlights.",
|
|
254
|
+
example: { title: "Overview", description: "Your account summary" },
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
Tabs: {
|
|
258
|
+
props: z.object({
|
|
259
|
+
tabs: z.array(
|
|
260
|
+
z.object({
|
|
261
|
+
label: z.string(),
|
|
262
|
+
value: z.string(),
|
|
263
|
+
disabled: z.boolean().optional(),
|
|
264
|
+
})
|
|
265
|
+
),
|
|
266
|
+
defaultValue: z.string().optional(),
|
|
267
|
+
value: z.string().optional(),
|
|
268
|
+
}),
|
|
269
|
+
slots: ["default"],
|
|
270
|
+
description:
|
|
271
|
+
"Tab navigation for mutually exclusive views (e.g., Profile/Security/Billing). Use for 2-6 sections. Always set defaultValue. Bind value with $bindState to track active tab.",
|
|
272
|
+
example: {
|
|
273
|
+
tabs: [
|
|
274
|
+
{ label: "Overview", value: "overview" },
|
|
275
|
+
{ label: "Settings", value: "settings" },
|
|
276
|
+
],
|
|
277
|
+
defaultValue: "overview",
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
Accordion: {
|
|
282
|
+
props: z.object({
|
|
283
|
+
items: z.array(
|
|
284
|
+
z.object({
|
|
285
|
+
title: z.string(),
|
|
286
|
+
content: z.string(),
|
|
287
|
+
value: z.string(),
|
|
288
|
+
disabled: z.boolean().optional(),
|
|
289
|
+
})
|
|
290
|
+
),
|
|
291
|
+
multiple: z.boolean().optional(),
|
|
292
|
+
collapsible: z.boolean().optional(),
|
|
293
|
+
}),
|
|
294
|
+
description:
|
|
295
|
+
"Collapsible sections for FAQ, details, or grouped info. Always set collapsible=true. Use multiple=true when sections are independent. Items as [{title, content, value}].",
|
|
296
|
+
example: {
|
|
297
|
+
items: [
|
|
298
|
+
{ title: "What is Dinachi?", content: "An accessible UI library.", value: "q1" },
|
|
299
|
+
{ title: "How to install?", content: "Run dinachi init.", value: "q2" },
|
|
300
|
+
],
|
|
301
|
+
collapsible: true,
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
Dialog: {
|
|
306
|
+
props: z.object({
|
|
307
|
+
title: z.string(),
|
|
308
|
+
description: z.string().optional(),
|
|
309
|
+
open: z.boolean().optional(),
|
|
310
|
+
}),
|
|
311
|
+
slots: ["default"],
|
|
312
|
+
description:
|
|
313
|
+
"Centered modal for focused tasks or critical decisions. Use for confirmations, short forms, important messages. Prefer Drawer for longer content or side panels. Bind open with $bindState.",
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
AlertDialog: {
|
|
317
|
+
props: z.object({
|
|
318
|
+
title: z.string(),
|
|
319
|
+
description: z.string().optional(),
|
|
320
|
+
open: z.boolean().optional(),
|
|
321
|
+
actionLabel: z.string().optional(),
|
|
322
|
+
cancelLabel: z.string().optional(),
|
|
323
|
+
}),
|
|
324
|
+
slots: ["default"],
|
|
325
|
+
description:
|
|
326
|
+
"Confirmation dialog for destructive or irreversible actions (delete, discard, cancel subscription). Always pair with destructive Button triggers. Set clear actionLabel (e.g., 'Delete') and cancelLabel. Bind open with $bindState.",
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
Tooltip: {
|
|
330
|
+
props: z.object({
|
|
331
|
+
content: z.string(),
|
|
332
|
+
text: z.string(),
|
|
333
|
+
side: z.enum(["top", "right", "bottom", "left"]).optional(),
|
|
334
|
+
align: z.enum(["start", "center", "end"]).optional(),
|
|
335
|
+
}),
|
|
336
|
+
description: "Hover tooltip for supplementary help text or definitions. Keep content brief (one sentence). Use for non-essential info that doesn't need to be always visible.",
|
|
337
|
+
example: { content: "More information", text: "Hover me", side: "top" },
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
Avatar: {
|
|
341
|
+
props: z.object({
|
|
342
|
+
src: z.string().optional(),
|
|
343
|
+
fallback: z.string().optional(),
|
|
344
|
+
alt: z.string().optional(),
|
|
345
|
+
size: z.enum(["sm", "md", "lg"]).optional(),
|
|
346
|
+
}),
|
|
347
|
+
description:
|
|
348
|
+
"User avatar. Always set fallback initials (2 chars). Pair with Text in Box(direction='row', align='center', gap='sm') for user references. sm=inline/lists, md=cards, lg=profiles.",
|
|
349
|
+
example: { src: "https://example.com/avatar.jpg", fallback: "JD", size: "md" },
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
Drawer: {
|
|
353
|
+
props: z.object({
|
|
354
|
+
title: z.string(),
|
|
355
|
+
description: z.string().optional(),
|
|
356
|
+
side: z.enum(["top", "right", "bottom", "left"]).optional(),
|
|
357
|
+
open: z.boolean().optional(),
|
|
358
|
+
}),
|
|
359
|
+
slots: ["default"],
|
|
360
|
+
description:
|
|
361
|
+
"Slide-in side panel for filters, detailed forms, settings, or secondary content. Use instead of Dialog for longer content. Default side=right. Bind open with $bindState.",
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
Popover: {
|
|
365
|
+
props: z.object({
|
|
366
|
+
triggerText: z.string(),
|
|
367
|
+
side: z.enum(["top", "right", "bottom", "left"]).optional(),
|
|
368
|
+
align: z.enum(["start", "center", "end"]).optional(),
|
|
369
|
+
}),
|
|
370
|
+
slots: ["default"],
|
|
371
|
+
description:
|
|
372
|
+
"Click-triggered floating panel for contextual info, quick actions, or mini-forms. Use for content that's too complex for a Tooltip but doesn't need a full Dialog.",
|
|
373
|
+
example: { triggerText: "More info", side: "bottom" },
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
NumberField: {
|
|
377
|
+
props: z.object({
|
|
378
|
+
label: z.string().optional(),
|
|
379
|
+
min: z.number().optional(),
|
|
380
|
+
max: z.number().optional(),
|
|
381
|
+
step: z.number().optional(),
|
|
382
|
+
value: z.number().optional(),
|
|
383
|
+
disabled: z.boolean().optional(),
|
|
384
|
+
...validationSchema,
|
|
385
|
+
}),
|
|
386
|
+
description:
|
|
387
|
+
"Numeric input with +/- buttons for precise values (quantity, guests, items). Use Slider instead for approximate ranges. Always set label, min, max. Bind value with $bindState. Supports validation.",
|
|
388
|
+
example: { label: "Quantity", min: 0, max: 100, step: 1 },
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
ToggleGroup: {
|
|
392
|
+
props: z.object({
|
|
393
|
+
options: z.array(
|
|
394
|
+
z.object({
|
|
395
|
+
label: z.string(),
|
|
396
|
+
value: z.string(),
|
|
397
|
+
})
|
|
398
|
+
),
|
|
399
|
+
variant: z.enum(["default", "outline"]).optional(),
|
|
400
|
+
size: z.enum(["default", "sm", "lg"]).optional(),
|
|
401
|
+
value: z.string().optional(),
|
|
402
|
+
}),
|
|
403
|
+
description:
|
|
404
|
+
"Compact visual selector for 2-4 options (view modes, themes, sizes). Use Radio for more options or when labels are long. Bind value with $bindState.",
|
|
405
|
+
example: {
|
|
406
|
+
options: [
|
|
407
|
+
{ label: "Grid", value: "grid" },
|
|
408
|
+
{ label: "List", value: "list" },
|
|
409
|
+
{ label: "Board", value: "board" },
|
|
410
|
+
],
|
|
411
|
+
value: { $bindState: "/view/mode" },
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
|
|
415
|
+
Collapsible: {
|
|
416
|
+
props: z.object({
|
|
417
|
+
triggerText: z.string(),
|
|
418
|
+
defaultOpen: z.boolean().optional(),
|
|
419
|
+
}),
|
|
420
|
+
slots: ["default"],
|
|
421
|
+
description:
|
|
422
|
+
"Single expandable section for show/hide content (details, advanced options). Use Accordion for multiple collapsible items. Set triggerText to describe hidden content.",
|
|
423
|
+
example: { triggerText: "Show details", defaultOpen: false },
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
ScrollArea: {
|
|
427
|
+
props: z.object({
|
|
428
|
+
maxHeight: z.string().optional(),
|
|
429
|
+
orientation: z.enum(["vertical", "horizontal", "both"]).optional(),
|
|
430
|
+
}),
|
|
431
|
+
slots: ["default"],
|
|
432
|
+
description:
|
|
433
|
+
"Scrollable container for long lists or content. Use when list exceeds 5 items or content is taller than the viewport. Always set maxHeight (e.g. '300px', '400px').",
|
|
434
|
+
example: { maxHeight: "300px", orientation: "vertical" },
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
Fieldset: {
|
|
438
|
+
props: z.object({
|
|
439
|
+
legend: z.string().optional(),
|
|
440
|
+
disabled: z.boolean().optional(),
|
|
441
|
+
}),
|
|
442
|
+
slots: ["default"],
|
|
443
|
+
description:
|
|
444
|
+
"Form field group. Always set legend to describe the group (e.g., 'Personal Information', 'Notification Settings'). Use to semantically group related inputs within a form.",
|
|
445
|
+
example: { legend: "Personal Information" },
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
const dinachiActionDefinitions = {
|
|
450
|
+
navigate: {
|
|
451
|
+
params: z.object({
|
|
452
|
+
url: z.string(),
|
|
453
|
+
target: z.enum(["_self", "_blank"]).optional(),
|
|
454
|
+
}),
|
|
455
|
+
description: "Navigate to a URL. Use target='_blank' for external links. Bind to Button(variant='link') or link-style elements.",
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
submit: {
|
|
459
|
+
params: z.object({
|
|
460
|
+
formId: z.string().optional(),
|
|
461
|
+
}),
|
|
462
|
+
description: "Submit a form. Bind to the primary submit Button at the end of a form. Optionally specify formId.",
|
|
463
|
+
},
|
|
464
|
+
|
|
465
|
+
showToast: {
|
|
466
|
+
params: z.object({
|
|
467
|
+
title: z.string(),
|
|
468
|
+
description: z.string().optional(),
|
|
469
|
+
variant: z.enum(["default", "success", "error", "warning"]).optional(),
|
|
470
|
+
timeout: z.number().optional(),
|
|
471
|
+
}),
|
|
472
|
+
description: "Show a toast notification. Use success for completions, error for failures, warning for cautions. Keep title short (3-5 words), add description for details.",
|
|
473
|
+
},
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
// =============================================================================
|
|
477
|
+
// Exports — raw definitions only, no framework dependency
|
|
478
|
+
// =============================================================================
|
|
479
|
+
|
|
480
|
+
export type DinachiComponentName = keyof typeof dinachiComponentDefinitions;
|
|
481
|
+
export type DinachiActionName = keyof typeof dinachiActionDefinitions;
|
|
482
|
+
|
|
483
|
+
export { dinachiComponentDefinitions, dinachiActionDefinitions };
|