better-ts-stack 2.1.2 → 2.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/README.md +16 -8
- package/dist/args.js +2 -1
- package/dist/builder/buildPlanner.js +7 -1
- package/dist/builder/configGenerator.js +28 -3
- package/dist/builder/index.js +2 -1
- package/dist/builder/readmeGenerator.js +2 -2
- package/dist/output/nextSteps.js +2 -4
- package/dist/prompts/stack.js +3 -5
- package/dist/types/index.js +1 -1
- package/package.json +1 -1
- package/templates/backend/express/src/env.ts.hbs +13 -2
- package/templates/backend/express/src/index.ts.hbs +31 -2
- package/templates/backend/nestjs/src/app.module.ts.hbs +4 -1
- package/templates/backend/nestjs/src/env.ts.hbs +13 -2
- package/templates/backend/nestjs/src/health/health.controller.ts.hbs +7 -0
- package/templates/backend/nestjs/src/{main.ts → main.ts.hbs} +11 -0
- package/templates/frontend/nextjs/app/globals.css +119 -79
- package/templates/frontend/nextjs/app/layout.tsx +13 -11
- package/templates/frontend/nextjs/app/page.tsx.hbs +63 -43
- package/templates/frontend/nextjs/components/ui/alert.tsx +75 -0
- package/templates/frontend/nextjs/components/ui/badge.tsx +51 -0
- package/templates/frontend/nextjs/components/ui/button.tsx +33 -27
- package/templates/frontend/nextjs/components/ui/card.tsx +76 -34
- package/templates/frontend/nextjs/components/ui/field.tsx +203 -32
- package/templates/frontend/nextjs/components/ui/input.tsx +8 -7
- package/templates/frontend/nextjs/components/ui/label.tsx +19 -0
- package/templates/frontend/nextjs/components/ui/separator.tsx +24 -0
- package/templates/frontend/nextjs/components/ui/skeleton.tsx +13 -0
- package/templates/frontend/nextjs/components/ui/spinner.tsx +10 -0
- package/templates/frontend/nextjs/components.json +11 -5
- package/templates/frontend/nextjs/config.json +4 -3
- package/templates/frontend/nextjs/lib/utils.ts +1 -6
- package/templates/frontend/tanstack/components.json +12 -5
- package/templates/frontend/tanstack/config.json +5 -2
- package/templates/frontend/tanstack/src/components/ui/alert.tsx +75 -0
- package/templates/frontend/tanstack/src/components/ui/badge.tsx +51 -0
- package/templates/frontend/tanstack/src/components/ui/button.tsx +33 -27
- package/templates/frontend/tanstack/src/components/ui/card.tsx +76 -34
- package/templates/frontend/tanstack/src/components/ui/field.tsx +201 -32
- package/templates/frontend/tanstack/src/components/ui/input.tsx +8 -7
- package/templates/frontend/tanstack/src/components/ui/label.tsx +17 -0
- package/templates/frontend/tanstack/src/components/ui/separator.tsx +24 -0
- package/templates/frontend/tanstack/src/components/ui/skeleton.tsx +13 -0
- package/templates/frontend/tanstack/src/components/ui/spinner.tsx +10 -0
- package/templates/frontend/tanstack/src/lib/utils.ts +1 -6
- package/templates/frontend/tanstack/src/routes/index.tsx.hbs +64 -45
- package/templates/frontend/tanstack/src/styles/app.css +100 -55
- package/templates/modules/agents/AGENTS.md.hbs +29 -21
- package/templates/modules/auth/express/config.json +12 -11
- package/templates/modules/auth/express/src/lib/auth.ts.hbs +143 -0
- package/templates/modules/auth/express/src/lib/email.ts +37 -0
- package/templates/modules/auth/express/src/middleware/requireAuth.ts +29 -0
- package/templates/modules/auth/express/src/routes/me.ts +13 -0
- package/templates/modules/auth/nestjs/config.json +13 -11
- package/templates/modules/auth/nestjs/src/auth/auth.module.ts.hbs +64 -14
- package/templates/modules/auth/nestjs/src/auth/auth.ts.hbs +152 -0
- package/templates/modules/auth/nestjs/src/auth/email.ts +37 -0
- package/templates/modules/auth/nestjs/src/me/me.controller.ts +15 -0
- package/templates/modules/auth/nextjs/app/dashboard/page.tsx +101 -45
- package/templates/modules/auth/nextjs/app/forgot-password/page.tsx +11 -0
- package/templates/modules/auth/nextjs/app/reset-password/page.tsx +17 -0
- package/templates/modules/auth/nextjs/app/sign-in/page.tsx +23 -17
- package/templates/modules/auth/nextjs/app/sign-up/page.tsx +25 -19
- package/templates/modules/auth/nextjs/components/auth/change-password-form.tsx +125 -0
- package/templates/modules/auth/nextjs/components/auth/email-verification-card.tsx +91 -0
- package/templates/modules/auth/nextjs/components/auth/forgot-password-form.tsx +133 -0
- package/templates/modules/auth/nextjs/components/auth/reset-password-form.tsx +155 -0
- package/templates/modules/auth/nextjs/components/auth/sign-in-form.tsx +46 -32
- package/templates/modules/auth/nextjs/components/auth/sign-out-button.tsx +6 -5
- package/templates/modules/auth/nextjs/components/auth/sign-up-form.tsx +36 -30
- package/templates/modules/auth/nextjs/components/auth/social-buttons.tsx +73 -0
- package/templates/modules/auth/nextjs/config.json +8 -2
- package/templates/modules/auth/nextjs/lib/auth-schema.ts +27 -2
- package/templates/modules/auth/nextjs/lib/auth.ts.hbs +65 -0
- package/templates/modules/auth/nextjs/lib/email.ts +43 -0
- package/templates/modules/auth/nextjs/lib/session.ts +12 -0
- package/templates/modules/auth/tanstack/config.json +9 -3
- package/templates/modules/auth/tanstack/src/components/auth/change-password-form.tsx +123 -0
- package/templates/modules/auth/tanstack/src/components/auth/email-verification-card.tsx +89 -0
- package/templates/modules/auth/tanstack/src/components/auth/forgot-password-form.tsx +131 -0
- package/templates/modules/auth/tanstack/src/components/auth/reset-password-form.tsx +149 -0
- package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +44 -35
- package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +7 -6
- package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +37 -34
- package/templates/modules/auth/tanstack/src/components/auth/social-buttons.tsx +71 -0
- package/templates/modules/auth/tanstack/src/lib/auth-functions.ts +7 -1
- package/templates/modules/auth/tanstack/src/lib/auth-schema.ts +27 -2
- package/templates/modules/auth/tanstack/src/lib/auth.ts.hbs +61 -1
- package/templates/modules/auth/tanstack/src/lib/email.ts +43 -0
- package/templates/modules/auth/tanstack/src/routeTree.gen.ts +61 -3
- package/templates/modules/auth/tanstack/src/routes/dashboard.tsx +40 -32
- package/templates/modules/auth/tanstack/src/routes/forgot-password.tsx +17 -0
- package/templates/modules/auth/tanstack/src/routes/reset-password.tsx +25 -0
- package/templates/modules/auth/tanstack/src/routes/sign-in.tsx +19 -12
- package/templates/modules/auth/tanstack/src/routes/sign-up.tsx +21 -14
- package/templates/modules/drizzle/express/src/lib/schema.ts.hbs +90 -0
- package/templates/modules/drizzle/nestjs/src/database/schema.ts.hbs +90 -0
- package/templates/modules/mongoose/nestjs/config.json +2 -1
- package/templates/modules/prisma/express/prisma/schema.prisma.hbs +92 -0
- package/templates/modules/prisma/nestjs/prisma/schema.prisma.hbs +91 -0
- package/templates/modules/rate-limit/express/src/middleware/rateLimit.ts +0 -8
- package/templates/modules/auth/express/src/controllers/authController.ts.hbs +0 -116
- package/templates/modules/auth/express/src/lib/jwt.ts.hbs +0 -27
- package/templates/modules/auth/express/src/middleware/requireAuth.ts.hbs +0 -25
- package/templates/modules/auth/express/src/routes/auth.ts.hbs +0 -27
- package/templates/modules/auth/express/src/services/userStore.ts.hbs +0 -117
- package/templates/modules/auth/nestjs/src/auth/auth.controller.ts.hbs +0 -61
- package/templates/modules/auth/nestjs/src/auth/auth.guard.ts +0 -36
- package/templates/modules/auth/nestjs/src/auth/auth.schemas.ts +0 -35
- package/templates/modules/auth/nestjs/src/auth/auth.service.ts +0 -70
- package/templates/modules/auth/nestjs/src/auth/jwt.ts +0 -27
- package/templates/modules/auth/nestjs/src/auth/users.service.ts.hbs +0 -144
- package/templates/modules/auth/nestjs/src/auth/zod-validation.pipe.ts +0 -16
- package/templates/modules/drizzle/express/src/lib/schema.ts +0 -12
- package/templates/modules/drizzle/nestjs/src/database/schema.ts +0 -12
- package/templates/modules/prisma/express/prisma/schema.prisma +0 -24
- package/templates/modules/prisma/nestjs/prisma/schema.prisma +0 -23
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
-
|
|
4
|
-
import { cn } from "~/lib/utils";
|
|
1
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { cn } from "cn"
|
|
5
4
|
|
|
6
5
|
const buttonVariants = cva(
|
|
7
|
-
"inline-flex items-center justify-center
|
|
6
|
+
"group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
8
7
|
{
|
|
9
8
|
variants: {
|
|
10
9
|
variant: {
|
|
11
|
-
default:
|
|
12
|
-
"bg-slate-950 text-white shadow-sm hover:bg-slate-800",
|
|
10
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
13
11
|
outline:
|
|
14
|
-
"border
|
|
15
|
-
|
|
12
|
+
"border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
13
|
+
secondary:
|
|
14
|
+
"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
15
|
+
ghost:
|
|
16
|
+
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
17
|
+
destructive:
|
|
18
|
+
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
19
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
16
20
|
},
|
|
17
21
|
size: {
|
|
18
|
-
default:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
default:
|
|
23
|
+
"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
24
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
25
|
+
sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
|
|
26
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
27
|
+
icon: "size-9",
|
|
28
|
+
"icon-xs":
|
|
29
|
+
"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
30
|
+
"icon-sm":
|
|
31
|
+
"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
32
|
+
"icon-lg": "size-10",
|
|
22
33
|
},
|
|
23
34
|
},
|
|
24
35
|
defaultVariants: {
|
|
@@ -26,26 +37,21 @@ const buttonVariants = cva(
|
|
|
26
37
|
size: "default",
|
|
27
38
|
},
|
|
28
39
|
}
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
export interface ButtonProps
|
|
32
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
33
|
-
VariantProps<typeof buttonVariants> {}
|
|
40
|
+
)
|
|
34
41
|
|
|
35
42
|
function Button({
|
|
36
43
|
className,
|
|
37
|
-
variant,
|
|
38
|
-
size,
|
|
39
|
-
type = "button",
|
|
44
|
+
variant = "default",
|
|
45
|
+
size = "default",
|
|
40
46
|
...props
|
|
41
|
-
}:
|
|
47
|
+
}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
|
|
42
48
|
return (
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
className={cn(buttonVariants({ variant, size
|
|
49
|
+
<ButtonPrimitive
|
|
50
|
+
data-slot="button"
|
|
51
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
46
52
|
{...props}
|
|
47
53
|
/>
|
|
48
|
-
)
|
|
54
|
+
)
|
|
49
55
|
}
|
|
50
56
|
|
|
51
|
-
export { Button, buttonVariants }
|
|
57
|
+
export { Button, buttonVariants }
|
|
@@ -1,60 +1,102 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
|
|
3
|
-
import { cn } from "~/lib/utils";
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cn } from "cn"
|
|
4
3
|
|
|
5
4
|
function Card({
|
|
6
5
|
className,
|
|
6
|
+
size = "default",
|
|
7
7
|
...props
|
|
8
|
-
}: React.
|
|
8
|
+
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
|
9
9
|
return (
|
|
10
10
|
<div
|
|
11
|
+
data-slot="card"
|
|
12
|
+
data-size={size}
|
|
11
13
|
className={cn(
|
|
12
|
-
"
|
|
14
|
+
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
13
15
|
className
|
|
14
16
|
)}
|
|
15
17
|
{...props}
|
|
16
18
|
/>
|
|
17
|
-
)
|
|
19
|
+
)
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
function CardHeader({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
23
|
+
return (
|
|
24
|
+
<div
|
|
25
|
+
data-slot="card-header"
|
|
26
|
+
className={cn(
|
|
27
|
+
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
|
28
|
+
className
|
|
29
|
+
)}
|
|
30
|
+
{...props}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
25
33
|
}
|
|
26
34
|
|
|
27
|
-
function CardTitle({
|
|
28
|
-
className,
|
|
29
|
-
...props
|
|
30
|
-
}: React.HTMLAttributes<HTMLHeadingElement>) {
|
|
35
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
31
36
|
return (
|
|
32
|
-
<
|
|
33
|
-
|
|
37
|
+
<div
|
|
38
|
+
data-slot="card-title"
|
|
39
|
+
className={cn(
|
|
40
|
+
"font-heading text-base leading-normal font-medium group-data-[size=sm]/card:text-sm",
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
34
43
|
{...props}
|
|
35
44
|
/>
|
|
36
|
-
)
|
|
45
|
+
)
|
|
37
46
|
}
|
|
38
47
|
|
|
39
|
-
function CardDescription({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
49
|
+
return (
|
|
50
|
+
<div
|
|
51
|
+
data-slot="card-description"
|
|
52
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
44
56
|
}
|
|
45
57
|
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
data-slot="card-action"
|
|
62
|
+
className={cn(
|
|
63
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
64
|
+
className
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
51
69
|
}
|
|
52
70
|
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
data-slot="card-content"
|
|
75
|
+
className={cn("flex flex-col gap-3 px-(--card-spacing)", className)}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
)
|
|
58
79
|
}
|
|
59
80
|
|
|
60
|
-
|
|
81
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
data-slot="card-footer"
|
|
85
|
+
className={cn(
|
|
86
|
+
"flex items-center rounded-b-xl px-(--card-spacing) [.border-t]:pt-(--card-spacing)",
|
|
87
|
+
className
|
|
88
|
+
)}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
Card,
|
|
96
|
+
CardHeader,
|
|
97
|
+
CardFooter,
|
|
98
|
+
CardTitle,
|
|
99
|
+
CardAction,
|
|
100
|
+
CardDescription,
|
|
101
|
+
CardContent,
|
|
102
|
+
}
|
|
@@ -1,67 +1,236 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { cn } from "cn"
|
|
2
4
|
|
|
3
|
-
import {
|
|
5
|
+
import { Label } from "~/components/ui/label"
|
|
6
|
+
import { Separator } from "~/components/ui/separator"
|
|
4
7
|
|
|
5
|
-
function
|
|
8
|
+
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
9
|
+
return (
|
|
10
|
+
<fieldset
|
|
11
|
+
data-slot="field-set"
|
|
12
|
+
className={cn(
|
|
13
|
+
"flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function FieldLegend({
|
|
6
22
|
className,
|
|
23
|
+
variant = "legend",
|
|
7
24
|
...props
|
|
8
|
-
}: React.
|
|
9
|
-
return
|
|
25
|
+
}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
|
|
26
|
+
return (
|
|
27
|
+
<legend
|
|
28
|
+
data-slot="field-legend"
|
|
29
|
+
data-variant={variant}
|
|
30
|
+
className={cn(
|
|
31
|
+
"mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
data-slot="field-group"
|
|
43
|
+
className={cn(
|
|
44
|
+
"group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
|
|
45
|
+
className
|
|
46
|
+
)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
10
50
|
}
|
|
11
51
|
|
|
12
|
-
|
|
13
|
-
"data-invalid"
|
|
14
|
-
|
|
52
|
+
const fieldVariants = cva(
|
|
53
|
+
"group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
54
|
+
{
|
|
55
|
+
variants: {
|
|
56
|
+
orientation: {
|
|
57
|
+
vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
|
|
58
|
+
horizontal:
|
|
59
|
+
"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
60
|
+
responsive:
|
|
61
|
+
"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
defaultVariants: {
|
|
65
|
+
orientation: "vertical",
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
)
|
|
15
69
|
|
|
16
70
|
function Field({
|
|
17
71
|
className,
|
|
18
|
-
"
|
|
72
|
+
orientation = "vertical",
|
|
19
73
|
...props
|
|
20
|
-
}:
|
|
74
|
+
}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
|
|
21
75
|
return (
|
|
22
76
|
<div
|
|
23
|
-
|
|
24
|
-
|
|
77
|
+
role="group"
|
|
78
|
+
data-slot="field"
|
|
79
|
+
data-orientation={orientation}
|
|
80
|
+
className={cn(fieldVariants({ orientation }), className)}
|
|
25
81
|
{...props}
|
|
26
82
|
/>
|
|
27
|
-
)
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
87
|
+
return (
|
|
88
|
+
<div
|
|
89
|
+
data-slot="field-content"
|
|
90
|
+
className={cn(
|
|
91
|
+
"group/field-content flex flex-1 flex-col gap-1 leading-snug",
|
|
92
|
+
className
|
|
93
|
+
)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
)
|
|
28
97
|
}
|
|
29
98
|
|
|
30
99
|
function FieldLabel({
|
|
31
100
|
className,
|
|
32
101
|
...props
|
|
33
|
-
}: React.
|
|
102
|
+
}: React.ComponentProps<typeof Label>) {
|
|
34
103
|
return (
|
|
35
|
-
<
|
|
36
|
-
|
|
104
|
+
<Label
|
|
105
|
+
data-slot="field-label"
|
|
106
|
+
className={cn(
|
|
107
|
+
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-3 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10",
|
|
108
|
+
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
|
|
109
|
+
className
|
|
110
|
+
)}
|
|
37
111
|
{...props}
|
|
38
112
|
/>
|
|
39
|
-
)
|
|
113
|
+
)
|
|
40
114
|
}
|
|
41
115
|
|
|
42
|
-
function
|
|
116
|
+
function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
117
|
+
return (
|
|
118
|
+
<div
|
|
119
|
+
data-slot="field-label"
|
|
120
|
+
className={cn(
|
|
121
|
+
"flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
|
|
122
|
+
className
|
|
123
|
+
)}
|
|
124
|
+
{...props}
|
|
125
|
+
/>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
130
|
+
return (
|
|
131
|
+
<p
|
|
132
|
+
data-slot="field-description"
|
|
133
|
+
className={cn(
|
|
134
|
+
"text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
|
|
135
|
+
"last:mt-0 nth-last-2:-mt-1",
|
|
136
|
+
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
|
137
|
+
className
|
|
138
|
+
)}
|
|
139
|
+
{...props}
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function FieldSeparator({
|
|
145
|
+
children,
|
|
43
146
|
className,
|
|
44
147
|
...props
|
|
45
|
-
}: React.
|
|
46
|
-
|
|
148
|
+
}: React.ComponentProps<"div"> & {
|
|
149
|
+
children?: React.ReactNode
|
|
150
|
+
}) {
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
data-slot="field-separator"
|
|
154
|
+
data-content={!!children}
|
|
155
|
+
className={cn(
|
|
156
|
+
"relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
|
|
157
|
+
className
|
|
158
|
+
)}
|
|
159
|
+
{...props}
|
|
160
|
+
>
|
|
161
|
+
<Separator className="absolute inset-0 top-1/2" />
|
|
162
|
+
{children && (
|
|
163
|
+
<span
|
|
164
|
+
className="relative mx-auto block w-fit bg-background px-2 text-muted-foreground"
|
|
165
|
+
data-slot="field-separator-content"
|
|
166
|
+
>
|
|
167
|
+
{children}
|
|
168
|
+
</span>
|
|
169
|
+
)}
|
|
170
|
+
</div>
|
|
171
|
+
)
|
|
47
172
|
}
|
|
48
173
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
174
|
+
function FieldError({
|
|
175
|
+
className,
|
|
176
|
+
children,
|
|
177
|
+
errors,
|
|
178
|
+
...props
|
|
179
|
+
}: React.ComponentProps<"div"> & {
|
|
180
|
+
errors?: Array<{ message?: string } | undefined>
|
|
181
|
+
}) {
|
|
182
|
+
const content = useMemo(() => {
|
|
183
|
+
if (children) {
|
|
184
|
+
return children
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (!errors?.length) {
|
|
188
|
+
return null
|
|
189
|
+
}
|
|
52
190
|
|
|
53
|
-
|
|
54
|
-
|
|
191
|
+
const uniqueErrors = [
|
|
192
|
+
...new Map(errors.map((error) => [error?.message, error])).values(),
|
|
193
|
+
]
|
|
55
194
|
|
|
56
|
-
|
|
57
|
-
|
|
195
|
+
if (uniqueErrors?.length == 1) {
|
|
196
|
+
return uniqueErrors[0]?.message
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<ul className="ml-4 flex list-disc flex-col gap-1">
|
|
201
|
+
{uniqueErrors.map(
|
|
202
|
+
(error, index) =>
|
|
203
|
+
error?.message && <li key={index}>{error.message}</li>
|
|
204
|
+
)}
|
|
205
|
+
</ul>
|
|
206
|
+
)
|
|
207
|
+
}, [children, errors])
|
|
208
|
+
|
|
209
|
+
if (!content) {
|
|
210
|
+
return null
|
|
58
211
|
}
|
|
59
212
|
|
|
60
213
|
return (
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
214
|
+
<div
|
|
215
|
+
role="alert"
|
|
216
|
+
data-slot="field-error"
|
|
217
|
+
className={cn("text-sm font-normal text-destructive", className)}
|
|
218
|
+
{...props}
|
|
219
|
+
>
|
|
220
|
+
{content}
|
|
221
|
+
</div>
|
|
222
|
+
)
|
|
65
223
|
}
|
|
66
224
|
|
|
67
|
-
export {
|
|
225
|
+
export {
|
|
226
|
+
Field,
|
|
227
|
+
FieldLabel,
|
|
228
|
+
FieldDescription,
|
|
229
|
+
FieldError,
|
|
230
|
+
FieldGroup,
|
|
231
|
+
FieldLegend,
|
|
232
|
+
FieldSeparator,
|
|
233
|
+
FieldSet,
|
|
234
|
+
FieldContent,
|
|
235
|
+
FieldTitle,
|
|
236
|
+
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
|
|
3
|
-
import { cn } from "
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Input as InputPrimitive } from "@base-ui/react/input"
|
|
3
|
+
import { cn } from "cn"
|
|
4
4
|
|
|
5
5
|
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
6
6
|
return (
|
|
7
|
-
<
|
|
7
|
+
<InputPrimitive
|
|
8
8
|
type={type}
|
|
9
|
+
data-slot="input"
|
|
9
10
|
className={cn(
|
|
10
|
-
"
|
|
11
|
+
"h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
11
12
|
className
|
|
12
13
|
)}
|
|
13
14
|
{...props}
|
|
14
15
|
/>
|
|
15
|
-
)
|
|
16
|
+
)
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export { Input }
|
|
19
|
+
export { Input }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cn } from "cn"
|
|
3
|
+
|
|
4
|
+
function Label({ className, ...props }: React.ComponentProps<"label">) {
|
|
5
|
+
return (
|
|
6
|
+
<label
|
|
7
|
+
data-slot="label"
|
|
8
|
+
className={cn(
|
|
9
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
10
|
+
className
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Label }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
|
|
4
|
+
import { cn } from "cn"
|
|
5
|
+
|
|
6
|
+
function Separator({
|
|
7
|
+
className,
|
|
8
|
+
orientation = "horizontal",
|
|
9
|
+
...props
|
|
10
|
+
}: SeparatorPrimitive.Props) {
|
|
11
|
+
return (
|
|
12
|
+
<SeparatorPrimitive
|
|
13
|
+
data-slot="separator"
|
|
14
|
+
orientation={orientation}
|
|
15
|
+
className={cn(
|
|
16
|
+
"shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { Separator }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cn } from "cn"
|
|
2
|
+
|
|
3
|
+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
4
|
+
return (
|
|
5
|
+
<div
|
|
6
|
+
data-slot="skeleton"
|
|
7
|
+
className={cn("animate-pulse rounded-md bg-muted", className)}
|
|
8
|
+
{...props}
|
|
9
|
+
/>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { Skeleton }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cn } from "cn"
|
|
2
|
+
import { Loader2Icon } from "lucide-react"
|
|
3
|
+
|
|
4
|
+
function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
|
|
5
|
+
return (
|
|
6
|
+
<Loader2Icon data-slot="spinner" role="status" aria-label="Loading" className={cn("size-4 animate-spin", className)} {...props} />
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { Spinner }
|