formcn 1.0.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 +294 -0
- package/bin/index.js +71 -0
- package/generators/form-generator.js +152 -0
- package/generators/form-ui-templates.js +183 -0
- package/generators/multi-form-generator.js +257 -0
- package/generators/schema-generator.js +89 -0
- package/package.json +46 -0
- package/test/README.md +73 -0
- package/test/components.json +22 -0
- package/test/eslint.config.js +23 -0
- package/test/index.html +13 -0
- package/test/package-lock.json +4759 -0
- package/test/package.json +46 -0
- package/test/public/vite.svg +1 -0
- package/test/src/App.css +42 -0
- package/test/src/App.tsx +7 -0
- package/test/src/assets/react.svg +1 -0
- package/test/src/components/ui/button.tsx +62 -0
- package/test/src/components/ui/checkbox.tsx +32 -0
- package/test/src/components/ui/field.tsx +246 -0
- package/test/src/components/ui/input-group.tsx +170 -0
- package/test/src/components/ui/input.tsx +21 -0
- package/test/src/components/ui/label.tsx +22 -0
- package/test/src/components/ui/radio-group.tsx +43 -0
- package/test/src/components/ui/select.tsx +188 -0
- package/test/src/components/ui/separator.tsx +28 -0
- package/test/src/components/ui/textarea.tsx +18 -0
- package/test/src/index.css +123 -0
- package/test/src/lib/utils.ts +6 -0
- package/test/src/main.tsx +10 -0
- package/test/tsconfig.app.json +33 -0
- package/test/tsconfig.json +13 -0
- package/test/tsconfig.node.json +26 -0
- package/test/vite.config.ts +14 -0
- package/utils/ensurePackages.js +62 -0
- package/utils/lib.js +22 -0
- package/utils/prompts.js +200 -0
- package/utils/tailwind-presets.js +132 -0
- package/utils/templates.js +103 -0
- package/utils/test.js +136 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
|
3
|
+
import { CircleIcon } from "lucide-react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
function RadioGroup({
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
|
|
11
|
+
return (
|
|
12
|
+
<RadioGroupPrimitive.Root
|
|
13
|
+
data-slot="radio-group"
|
|
14
|
+
className={cn("grid gap-3", className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function RadioGroupItem({
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
|
|
24
|
+
return (
|
|
25
|
+
<RadioGroupPrimitive.Item
|
|
26
|
+
data-slot="radio-group-item"
|
|
27
|
+
className={cn(
|
|
28
|
+
"border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
<RadioGroupPrimitive.Indicator
|
|
34
|
+
data-slot="radio-group-indicator"
|
|
35
|
+
className="relative flex items-center justify-center"
|
|
36
|
+
>
|
|
37
|
+
<CircleIcon className="fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" />
|
|
38
|
+
</RadioGroupPrimitive.Indicator>
|
|
39
|
+
</RadioGroupPrimitive.Item>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { RadioGroup, RadioGroupItem }
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as SelectPrimitive from "@radix-ui/react-select"
|
|
3
|
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
function Select({
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
|
10
|
+
return <SelectPrimitive.Root data-slot="select" {...props} />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function SelectGroup({
|
|
14
|
+
...props
|
|
15
|
+
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
|
|
16
|
+
return <SelectPrimitive.Group data-slot="select-group" {...props} />
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function SelectValue({
|
|
20
|
+
...props
|
|
21
|
+
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
|
|
22
|
+
return <SelectPrimitive.Value data-slot="select-value" {...props} />
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function SelectTrigger({
|
|
26
|
+
className,
|
|
27
|
+
size = "default",
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
31
|
+
size?: "sm" | "default"
|
|
32
|
+
}) {
|
|
33
|
+
return (
|
|
34
|
+
<SelectPrimitive.Trigger
|
|
35
|
+
data-slot="select-trigger"
|
|
36
|
+
data-size={size}
|
|
37
|
+
className={cn(
|
|
38
|
+
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
39
|
+
className
|
|
40
|
+
)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
<SelectPrimitive.Icon asChild>
|
|
45
|
+
<ChevronDownIcon className="size-4 opacity-50" />
|
|
46
|
+
</SelectPrimitive.Icon>
|
|
47
|
+
</SelectPrimitive.Trigger>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function SelectContent({
|
|
52
|
+
className,
|
|
53
|
+
children,
|
|
54
|
+
position = "item-aligned",
|
|
55
|
+
align = "center",
|
|
56
|
+
...props
|
|
57
|
+
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
|
|
58
|
+
return (
|
|
59
|
+
<SelectPrimitive.Portal>
|
|
60
|
+
<SelectPrimitive.Content
|
|
61
|
+
data-slot="select-content"
|
|
62
|
+
className={cn(
|
|
63
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
|
64
|
+
position === "popper" &&
|
|
65
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
66
|
+
className
|
|
67
|
+
)}
|
|
68
|
+
position={position}
|
|
69
|
+
align={align}
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
<SelectScrollUpButton />
|
|
73
|
+
<SelectPrimitive.Viewport
|
|
74
|
+
className={cn(
|
|
75
|
+
"p-1",
|
|
76
|
+
position === "popper" &&
|
|
77
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
|
78
|
+
)}
|
|
79
|
+
>
|
|
80
|
+
{children}
|
|
81
|
+
</SelectPrimitive.Viewport>
|
|
82
|
+
<SelectScrollDownButton />
|
|
83
|
+
</SelectPrimitive.Content>
|
|
84
|
+
</SelectPrimitive.Portal>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function SelectLabel({
|
|
89
|
+
className,
|
|
90
|
+
...props
|
|
91
|
+
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
|
|
92
|
+
return (
|
|
93
|
+
<SelectPrimitive.Label
|
|
94
|
+
data-slot="select-label"
|
|
95
|
+
className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function SelectItem({
|
|
102
|
+
className,
|
|
103
|
+
children,
|
|
104
|
+
...props
|
|
105
|
+
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
|
|
106
|
+
return (
|
|
107
|
+
<SelectPrimitive.Item
|
|
108
|
+
data-slot="select-item"
|
|
109
|
+
className={cn(
|
|
110
|
+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
111
|
+
className
|
|
112
|
+
)}
|
|
113
|
+
{...props}
|
|
114
|
+
>
|
|
115
|
+
<span
|
|
116
|
+
data-slot="select-item-indicator"
|
|
117
|
+
className="absolute right-2 flex size-3.5 items-center justify-center"
|
|
118
|
+
>
|
|
119
|
+
<SelectPrimitive.ItemIndicator>
|
|
120
|
+
<CheckIcon className="size-4" />
|
|
121
|
+
</SelectPrimitive.ItemIndicator>
|
|
122
|
+
</span>
|
|
123
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
124
|
+
</SelectPrimitive.Item>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function SelectSeparator({
|
|
129
|
+
className,
|
|
130
|
+
...props
|
|
131
|
+
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
|
|
132
|
+
return (
|
|
133
|
+
<SelectPrimitive.Separator
|
|
134
|
+
data-slot="select-separator"
|
|
135
|
+
className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
|
|
136
|
+
{...props}
|
|
137
|
+
/>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function SelectScrollUpButton({
|
|
142
|
+
className,
|
|
143
|
+
...props
|
|
144
|
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
|
|
145
|
+
return (
|
|
146
|
+
<SelectPrimitive.ScrollUpButton
|
|
147
|
+
data-slot="select-scroll-up-button"
|
|
148
|
+
className={cn(
|
|
149
|
+
"flex cursor-default items-center justify-center py-1",
|
|
150
|
+
className
|
|
151
|
+
)}
|
|
152
|
+
{...props}
|
|
153
|
+
>
|
|
154
|
+
<ChevronUpIcon className="size-4" />
|
|
155
|
+
</SelectPrimitive.ScrollUpButton>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function SelectScrollDownButton({
|
|
160
|
+
className,
|
|
161
|
+
...props
|
|
162
|
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
|
|
163
|
+
return (
|
|
164
|
+
<SelectPrimitive.ScrollDownButton
|
|
165
|
+
data-slot="select-scroll-down-button"
|
|
166
|
+
className={cn(
|
|
167
|
+
"flex cursor-default items-center justify-center py-1",
|
|
168
|
+
className
|
|
169
|
+
)}
|
|
170
|
+
{...props}
|
|
171
|
+
>
|
|
172
|
+
<ChevronDownIcon className="size-4" />
|
|
173
|
+
</SelectPrimitive.ScrollDownButton>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
Select,
|
|
179
|
+
SelectContent,
|
|
180
|
+
SelectGroup,
|
|
181
|
+
SelectItem,
|
|
182
|
+
SelectLabel,
|
|
183
|
+
SelectScrollDownButton,
|
|
184
|
+
SelectScrollUpButton,
|
|
185
|
+
SelectSeparator,
|
|
186
|
+
SelectTrigger,
|
|
187
|
+
SelectValue,
|
|
188
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@/lib/utils"
|
|
7
|
+
|
|
8
|
+
function Separator({
|
|
9
|
+
className,
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
decorative = true,
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
|
|
14
|
+
return (
|
|
15
|
+
<SeparatorPrimitive.Root
|
|
16
|
+
data-slot="separator"
|
|
17
|
+
decorative={decorative}
|
|
18
|
+
orientation={orientation}
|
|
19
|
+
className={cn(
|
|
20
|
+
"bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { Separator }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
6
|
+
return (
|
|
7
|
+
<textarea
|
|
8
|
+
data-slot="textarea"
|
|
9
|
+
className={cn(
|
|
10
|
+
"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
11
|
+
className
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Textarea }
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@import "tw-animate-css";
|
|
3
|
+
|
|
4
|
+
@custom-variant dark (&:is(.dark *));
|
|
5
|
+
|
|
6
|
+
@theme inline {
|
|
7
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
8
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
9
|
+
--radius-lg: var(--radius);
|
|
10
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
11
|
+
--radius-2xl: calc(var(--radius) + 8px);
|
|
12
|
+
--radius-3xl: calc(var(--radius) + 12px);
|
|
13
|
+
--radius-4xl: calc(var(--radius) + 16px);
|
|
14
|
+
--color-background: var(--background);
|
|
15
|
+
--color-foreground: var(--foreground);
|
|
16
|
+
--color-card: var(--card);
|
|
17
|
+
--color-card-foreground: var(--card-foreground);
|
|
18
|
+
--color-popover: var(--popover);
|
|
19
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
20
|
+
--color-primary: var(--primary);
|
|
21
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
22
|
+
--color-secondary: var(--secondary);
|
|
23
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
24
|
+
--color-muted: var(--muted);
|
|
25
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
26
|
+
--color-accent: var(--accent);
|
|
27
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
28
|
+
--color-destructive: var(--destructive);
|
|
29
|
+
--color-border: var(--border);
|
|
30
|
+
--color-input: var(--input);
|
|
31
|
+
--color-ring: var(--ring);
|
|
32
|
+
--color-chart-1: var(--chart-1);
|
|
33
|
+
--color-chart-2: var(--chart-2);
|
|
34
|
+
--color-chart-3: var(--chart-3);
|
|
35
|
+
--color-chart-4: var(--chart-4);
|
|
36
|
+
--color-chart-5: var(--chart-5);
|
|
37
|
+
--color-sidebar: var(--sidebar);
|
|
38
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
39
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
40
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
41
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
42
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
43
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
44
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:root {
|
|
48
|
+
--radius: 0.625rem;
|
|
49
|
+
--background: oklch(1 0 0);
|
|
50
|
+
--foreground: oklch(0.145 0 0);
|
|
51
|
+
--card: oklch(1 0 0);
|
|
52
|
+
--card-foreground: oklch(0.145 0 0);
|
|
53
|
+
--popover: oklch(1 0 0);
|
|
54
|
+
--popover-foreground: oklch(0.145 0 0);
|
|
55
|
+
--primary: oklch(0.205 0 0);
|
|
56
|
+
--primary-foreground: oklch(0.985 0 0);
|
|
57
|
+
--secondary: oklch(0.97 0 0);
|
|
58
|
+
--secondary-foreground: oklch(0.205 0 0);
|
|
59
|
+
--muted: oklch(0.97 0 0);
|
|
60
|
+
--muted-foreground: oklch(0.556 0 0);
|
|
61
|
+
--accent: oklch(0.97 0 0);
|
|
62
|
+
--accent-foreground: oklch(0.205 0 0);
|
|
63
|
+
--destructive: oklch(0.577 0.245 27.325);
|
|
64
|
+
--border: oklch(0.922 0 0);
|
|
65
|
+
--input: oklch(0.922 0 0);
|
|
66
|
+
--ring: oklch(0.708 0 0);
|
|
67
|
+
--chart-1: oklch(0.646 0.222 41.116);
|
|
68
|
+
--chart-2: oklch(0.6 0.118 184.704);
|
|
69
|
+
--chart-3: oklch(0.398 0.07 227.392);
|
|
70
|
+
--chart-4: oklch(0.828 0.189 84.429);
|
|
71
|
+
--chart-5: oklch(0.769 0.188 70.08);
|
|
72
|
+
--sidebar: oklch(0.985 0 0);
|
|
73
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
74
|
+
--sidebar-primary: oklch(0.205 0 0);
|
|
75
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
76
|
+
--sidebar-accent: oklch(0.97 0 0);
|
|
77
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
78
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
79
|
+
--sidebar-ring: oklch(0.708 0 0);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.dark {
|
|
83
|
+
--background: oklch(0.145 0 0);
|
|
84
|
+
--foreground: oklch(0.985 0 0);
|
|
85
|
+
--card: oklch(0.205 0 0);
|
|
86
|
+
--card-foreground: oklch(0.985 0 0);
|
|
87
|
+
--popover: oklch(0.205 0 0);
|
|
88
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
89
|
+
--primary: oklch(0.922 0 0);
|
|
90
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
91
|
+
--secondary: oklch(0.269 0 0);
|
|
92
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
93
|
+
--muted: oklch(0.269 0 0);
|
|
94
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
95
|
+
--accent: oklch(0.269 0 0);
|
|
96
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
97
|
+
--destructive: oklch(0.704 0.191 22.216);
|
|
98
|
+
--border: oklch(1 0 0 / 10%);
|
|
99
|
+
--input: oklch(1 0 0 / 15%);
|
|
100
|
+
--ring: oklch(0.556 0 0);
|
|
101
|
+
--chart-1: oklch(0.488 0.243 264.376);
|
|
102
|
+
--chart-2: oklch(0.696 0.17 162.48);
|
|
103
|
+
--chart-3: oklch(0.769 0.188 70.08);
|
|
104
|
+
--chart-4: oklch(0.627 0.265 303.9);
|
|
105
|
+
--chart-5: oklch(0.645 0.246 16.439);
|
|
106
|
+
--sidebar: oklch(0.205 0 0);
|
|
107
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
108
|
+
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
109
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
110
|
+
--sidebar-accent: oklch(0.269 0 0);
|
|
111
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
112
|
+
--sidebar-border: oklch(1 0 0 / 10%);
|
|
113
|
+
--sidebar-ring: oklch(0.556 0 0);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@layer base {
|
|
117
|
+
* {
|
|
118
|
+
@apply border-border outline-ring/50;
|
|
119
|
+
}
|
|
120
|
+
body {
|
|
121
|
+
@apply bg-background text-foreground;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"useDefineForClassFields": true,
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"types": ["vite/client"],
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
|
|
11
|
+
/* Bundler mode */
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"moduleDetection": "force",
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"jsx": "react-jsx",
|
|
18
|
+
|
|
19
|
+
/* Linting */
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": true,
|
|
23
|
+
"erasableSyntaxOnly": true,
|
|
24
|
+
"noFallthroughCasesInSwitch": true,
|
|
25
|
+
"noUncheckedSideEffectImports": true,
|
|
26
|
+
|
|
27
|
+
"baseUrl": ".",
|
|
28
|
+
"paths": {
|
|
29
|
+
"@/*": ["./src/*"]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"include": ["src"]
|
|
33
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
+
"target": "ES2023",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"erasableSyntaxOnly": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noUncheckedSideEffectImports": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["vite.config.ts"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
3
|
+
import react from "@vitejs/plugin-react";
|
|
4
|
+
import { defineConfig } from "vite";
|
|
5
|
+
|
|
6
|
+
// https://vite.dev/config/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [react(), tailwindcss()],
|
|
9
|
+
resolve: {
|
|
10
|
+
alias: {
|
|
11
|
+
"@": path.resolve(__dirname, "./src"),
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { confirm } from "@clack/prompts";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
|
|
7
|
+
export async function ensurePackages() {
|
|
8
|
+
const packages = ["react-hook-form", "@hookform/resolvers", "zod"];
|
|
9
|
+
const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
10
|
+
let allInstalled = true;
|
|
11
|
+
|
|
12
|
+
for (const pkg of packages) {
|
|
13
|
+
let installed = true;
|
|
14
|
+
try {
|
|
15
|
+
const require = createRequire(join(process.cwd(), "package.json"));
|
|
16
|
+
require.resolve(pkg);
|
|
17
|
+
console.log(`✅ ${pkg} is already installed`);
|
|
18
|
+
} catch {
|
|
19
|
+
installed = false;
|
|
20
|
+
allInstalled = false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!installed) {
|
|
24
|
+
const install = await confirm({
|
|
25
|
+
message: `${pkg} is not installed. Do you want to install it?`,
|
|
26
|
+
initialValue: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (install) {
|
|
30
|
+
console.log(`Installing ${pkg}...`);
|
|
31
|
+
execSync(`${npmCmd} install ${pkg}`, { stdio: "inherit" });
|
|
32
|
+
console.log(`✅ ${pkg} installed successfully!`);
|
|
33
|
+
} else {
|
|
34
|
+
console.warn(`⚠️ ${pkg} is required for this CLI.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const componentsJsonPath = join(process.cwd(), "components.json");
|
|
40
|
+
|
|
41
|
+
if (fs.existsSync(componentsJsonPath)) {
|
|
42
|
+
console.log("✅ ShadCN components detected");
|
|
43
|
+
} else {
|
|
44
|
+
const setup = await confirm({
|
|
45
|
+
message:
|
|
46
|
+
"ShadCN components not found (components.json missing). Did you run 'npx shadcn@latest init'?",
|
|
47
|
+
initialValue: true,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (setup) {
|
|
51
|
+
console.log(
|
|
52
|
+
"Please run 'npx shadcn@latest init' to set up components before using this CLI."
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
console.warn("⚠️ ShadCN is required for generating forms.");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (allInstalled) {
|
|
60
|
+
console.log("\n🎉 All required packages are already installed!");
|
|
61
|
+
}
|
|
62
|
+
}
|
package/utils/lib.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function toPascalCaseForm(name) {
|
|
2
|
+
const base = name
|
|
3
|
+
.replace(/[-_]/g, " ")
|
|
4
|
+
.replace(/\w+/g, (w) => w[0].toUpperCase() + w.slice(1))
|
|
5
|
+
.replace(/\s/g, "");
|
|
6
|
+
|
|
7
|
+
return `${base}Form`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function toCamelCaseForm(str) {
|
|
11
|
+
return str
|
|
12
|
+
.replace(/\s(.)/g, (_, c) => c.toUpperCase())
|
|
13
|
+
.replace(/\s/g, "")
|
|
14
|
+
.replace(/^(.)/, (_, c) => c.toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function toKebabCaseForm(str) {
|
|
18
|
+
return str
|
|
19
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
20
|
+
.replace(/[\s_]+/g, "-")
|
|
21
|
+
.toLowerCase();
|
|
22
|
+
}
|