@dinachi/cli 0.8.0 → 0.8.2
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/index.js +80 -5
- package/package.json +5 -2
- package/templates/accordion/accordion.tsx +5 -8
- 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/text/index.ts +2 -0
- package/templates/text/text.tsx +70 -0
- package/templates/tsconfig.json +2 -1
package/dist/index.js
CHANGED
|
@@ -209,6 +209,13 @@ function getComponentRegistry() {
|
|
|
209
209
|
dependencies: [],
|
|
210
210
|
utilityDependencies: ["cn"]
|
|
211
211
|
},
|
|
212
|
+
link: {
|
|
213
|
+
name: "link",
|
|
214
|
+
description: "A semantic anchor element with style variants and support for external links and framework router composition.",
|
|
215
|
+
files: [{ name: "link.tsx" }, { name: "index.ts" }],
|
|
216
|
+
dependencies: ["class-variance-authority"],
|
|
217
|
+
utilityDependencies: ["cn"]
|
|
218
|
+
},
|
|
212
219
|
menu: {
|
|
213
220
|
name: "menu",
|
|
214
221
|
description: "A popup menu for actions and options triggered by a button.",
|
|
@@ -321,6 +328,13 @@ function getComponentRegistry() {
|
|
|
321
328
|
dependencies: ["@base-ui/react"],
|
|
322
329
|
utilityDependencies: ["cn"]
|
|
323
330
|
},
|
|
331
|
+
text: {
|
|
332
|
+
name: "text",
|
|
333
|
+
description: "A typography component for headings, paragraphs, and text styles.",
|
|
334
|
+
files: [{ name: "text.tsx" }, { name: "index.ts" }],
|
|
335
|
+
dependencies: ["class-variance-authority"],
|
|
336
|
+
utilityDependencies: ["cn"]
|
|
337
|
+
},
|
|
324
338
|
textarea: {
|
|
325
339
|
name: "textarea",
|
|
326
340
|
description: "A multi-line text input for longer form content.",
|
|
@@ -362,6 +376,52 @@ function getComponentRegistry() {
|
|
|
362
376
|
files: [{ name: "tooltip.tsx" }, { name: "index.ts" }],
|
|
363
377
|
dependencies: ["@base-ui/react"],
|
|
364
378
|
utilityDependencies: ["cn"]
|
|
379
|
+
},
|
|
380
|
+
"json-render": {
|
|
381
|
+
name: "json-render",
|
|
382
|
+
description: "Adapter for @json-render \u2014 renders DinachiUI components from JSON specs with state binding, validation, and actions.",
|
|
383
|
+
files: [
|
|
384
|
+
{ name: "catalog.ts" },
|
|
385
|
+
{ name: "components.tsx" },
|
|
386
|
+
{ name: "registry.ts" },
|
|
387
|
+
{ name: "index.ts" }
|
|
388
|
+
],
|
|
389
|
+
dependencies: ["@json-render/core", "@json-render/react", "zod"],
|
|
390
|
+
componentDependencies: [
|
|
391
|
+
"accordion",
|
|
392
|
+
"alert-dialog",
|
|
393
|
+
"avatar",
|
|
394
|
+
"badge",
|
|
395
|
+
"button",
|
|
396
|
+
"card",
|
|
397
|
+
"checkbox",
|
|
398
|
+
"collapsible",
|
|
399
|
+
"dialog",
|
|
400
|
+
"drawer",
|
|
401
|
+
"fieldset",
|
|
402
|
+
"input",
|
|
403
|
+
"label",
|
|
404
|
+
"number-field",
|
|
405
|
+
"popover",
|
|
406
|
+
"progress",
|
|
407
|
+
"radio",
|
|
408
|
+
"scroll-area",
|
|
409
|
+
"select",
|
|
410
|
+
"separator",
|
|
411
|
+
"skeleton",
|
|
412
|
+
"slider",
|
|
413
|
+
"switch",
|
|
414
|
+
"tabs",
|
|
415
|
+
"text",
|
|
416
|
+
"textarea",
|
|
417
|
+
"toast",
|
|
418
|
+
"toggle",
|
|
419
|
+
"toggle-group",
|
|
420
|
+
"tooltip"
|
|
421
|
+
],
|
|
422
|
+
utilityDependencies: ["cn"],
|
|
423
|
+
targetDir: "json-render",
|
|
424
|
+
integration: true
|
|
365
425
|
}
|
|
366
426
|
};
|
|
367
427
|
}
|
|
@@ -482,13 +542,16 @@ function parseJsonWithComments(content) {
|
|
|
482
542
|
|
|
483
543
|
// src/utils/dependencies.ts
|
|
484
544
|
var DEPENDENCY_VERSION_MAP = {
|
|
485
|
-
"@base-ui/react": "^1.
|
|
545
|
+
"@base-ui/react": "^1.3.0",
|
|
486
546
|
"lucide-react": "^0.552.0",
|
|
487
547
|
"class-variance-authority": "^0.7.1",
|
|
488
548
|
"tailwindcss-animate": "^1.0.7",
|
|
489
549
|
"tw-animate-css": "^1.3.4",
|
|
490
550
|
"clsx": "^2.1.1",
|
|
491
|
-
"tailwind-merge": "^3.3.1"
|
|
551
|
+
"tailwind-merge": "^3.3.1",
|
|
552
|
+
"@json-render/core": "^0.14.0",
|
|
553
|
+
"@json-render/react": "^0.14.0",
|
|
554
|
+
"zod": "^4.0.0"
|
|
492
555
|
};
|
|
493
556
|
function toInstallSpec(dep) {
|
|
494
557
|
const version = DEPENDENCY_VERSION_MAP[dep];
|
|
@@ -831,7 +894,9 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
831
894
|
const registry = getComponentRegistry();
|
|
832
895
|
let componentsToInstall = [];
|
|
833
896
|
if (options.all) {
|
|
834
|
-
const allComponents = Object.keys(registry)
|
|
897
|
+
const allComponents = Object.keys(registry).filter(
|
|
898
|
+
(name) => !registry[name].integration
|
|
899
|
+
);
|
|
835
900
|
spinner.text = `Installing all ${allComponents.length} components...`;
|
|
836
901
|
const allComponentsWithDeps = /* @__PURE__ */ new Set();
|
|
837
902
|
for (const name of allComponents) {
|
|
@@ -910,11 +975,21 @@ var addCommand = new Command("add").description("Add a component to your project
|
|
|
910
975
|
for (const name of componentsToInstall) {
|
|
911
976
|
const comp = registry[name];
|
|
912
977
|
if (!comp) continue;
|
|
978
|
+
const fileTargetDir = comp.targetDir ? path3.join(libDir, comp.targetDir) : componentDir;
|
|
979
|
+
if (comp.targetDir) {
|
|
980
|
+
await fs3.ensureDir(fileTargetDir);
|
|
981
|
+
}
|
|
913
982
|
for (const file of comp.files) {
|
|
914
983
|
const sourcePath = path3.join(__dirname2, "../templates", name, file.name);
|
|
915
|
-
const targetPath = path3.join(
|
|
984
|
+
const targetPath = path3.join(fileTargetDir, file.name);
|
|
916
985
|
if (file.name === "index.ts") {
|
|
917
|
-
|
|
986
|
+
if (comp.targetDir) {
|
|
987
|
+
const templateContent2 = stripTemplateDirective(await fs3.readFile(sourcePath, "utf-8"));
|
|
988
|
+
await fs3.writeFile(targetPath, templateContent2);
|
|
989
|
+
allFilesAdded.push({ name: "index.ts", path: targetPath });
|
|
990
|
+
} else {
|
|
991
|
+
await handleIndexFile(sourcePath, targetPath, allFilesAdded, fileTargetDir);
|
|
992
|
+
}
|
|
918
993
|
continue;
|
|
919
994
|
}
|
|
920
995
|
if (fs3.existsSync(targetPath) && !options.overwrite) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dinachi/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "CLI for adding Dinachi UI components to your project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@base-ui/react": "1.3.0",
|
|
40
|
+
"@json-render/core": "^0.14.0",
|
|
41
|
+
"@json-render/react": "^0.14.0",
|
|
40
42
|
"@types/fs-extra": "^11.0.4",
|
|
41
43
|
"@types/prompts": "^2.4.9",
|
|
42
44
|
"@types/react": "^19.2.14",
|
|
@@ -46,7 +48,8 @@
|
|
|
46
48
|
"react": "19.2.4",
|
|
47
49
|
"tailwind-merge": "^3.5.0",
|
|
48
50
|
"tsup": "^8.0.1",
|
|
49
|
-
"typescript": "^5.5.3"
|
|
51
|
+
"typescript": "^5.5.3",
|
|
52
|
+
"zod": "^4.0.0"
|
|
50
53
|
},
|
|
51
54
|
"peerDependencies": {
|
|
52
55
|
"typescript": ">=4.5.0"
|
|
@@ -64,16 +64,13 @@ const AccordionPanel = React.forwardRef<
|
|
|
64
64
|
<BaseAccordion.Panel
|
|
65
65
|
ref={ref}
|
|
66
66
|
className={cn(
|
|
67
|
-
"overflow-hidden text-sm",
|
|
68
|
-
"
|
|
69
|
-
"data-[
|
|
70
|
-
"
|
|
67
|
+
"overflow-hidden text-sm h-[var(--accordion-panel-height)]",
|
|
68
|
+
"transition-[height] duration-200 ease-in-out",
|
|
69
|
+
"data-[starting-style]:h-0 data-[ending-style]:h-0",
|
|
70
|
+
"data-[open]:animate-in data-[open]:slide-down-from-top",
|
|
71
|
+
"data-[closed]:animate-out data-[closed]:slide-up-to-top",
|
|
71
72
|
className
|
|
72
73
|
)}
|
|
73
|
-
style={{
|
|
74
|
-
"--accordion-panel-height": "var(--accordion-panel-height)",
|
|
75
|
-
"--accordion-panel-width": "var(--accordion-panel-width)",
|
|
76
|
-
} as React.CSSProperties}
|
|
77
74
|
{...props}
|
|
78
75
|
>
|
|
79
76
|
<div className="pb-4 pt-0">{children}</div>
|
|
@@ -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 };
|