create-mohit-next 1.0.0 → 2.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/README.md +96 -65
- package/index.js +195 -195
- package/lib/features.js +358 -0
- package/lib/scaffold.js +471 -0
- package/package.json +10 -6
- package/templates/common/_editorconfig +12 -0
- package/templates/common/_gitattributes +5 -0
- package/templates/common/_github/dependabot.yml +14 -0
- package/templates/common/_github/workflows/ci.yml +66 -0
- package/templates/common/_husky/commit-msg +1 -0
- package/templates/common/_husky/pre-commit +1 -0
- package/templates/common/_nvmrc +1 -0
- package/{template → templates/common}/_prettierignore +4 -0
- package/templates/common/commitlint.config.mjs +10 -0
- package/templates/next/README.md +328 -0
- package/{template → templates/next}/_env.example +10 -1
- package/{template → templates/next}/_gitignore +8 -0
- package/templates/next/e2e/rbac.spec.ts +69 -0
- package/templates/next/e2e/server.mjs +35 -0
- package/{template → templates/next}/eslint.config.mjs +12 -0
- package/{template → templates/next}/next.config.ts +2 -0
- package/{template → templates/next}/package.json +18 -3
- package/templates/next/playwright.config.ts +30 -0
- package/templates/next/scripts/seed.ts +111 -0
- package/templates/next/src/app/(app)/admin/audit/page.tsx +99 -0
- package/templates/next/src/app/(app)/admin/page.tsx +92 -0
- package/{template → templates/next}/src/app/(app)/dashboard/page.tsx +22 -29
- package/{template → templates/next}/src/app/(app)/error.tsx +7 -7
- package/{template → templates/next}/src/app/(app)/layout.tsx +25 -2
- package/templates/next/src/app/(app)/reports/page.tsx +128 -0
- package/templates/next/src/app/(app)/settings/page.tsx +66 -0
- package/templates/next/src/app/(auth)/forgot-password/page.tsx +17 -0
- package/templates/next/src/app/(auth)/layout.tsx +18 -0
- package/{template → templates/next}/src/app/(auth)/register/page.tsx +2 -4
- package/templates/next/src/app/(auth)/reset-password/page.tsx +18 -0
- package/templates/next/src/app/api/account/password/route.ts +45 -0
- package/templates/next/src/app/api/account/route.ts +25 -0
- package/templates/next/src/app/api/account/sessions/route.ts +12 -0
- package/templates/next/src/app/api/admin/audit/route.ts +13 -0
- package/{template → templates/next}/src/app/api/admin/users/[id]/route.ts +25 -4
- package/templates/next/src/app/api/auth/forgot-password/route.ts +47 -0
- package/{template → templates/next}/src/app/api/auth/login/route.ts +19 -2
- package/{template → templates/next}/src/app/api/auth/me/route.ts +4 -2
- package/{template → templates/next}/src/app/api/auth/register/route.ts +38 -4
- package/templates/next/src/app/api/auth/resend-verification/route.ts +25 -0
- package/templates/next/src/app/api/auth/reset-password/route.ts +43 -0
- package/templates/next/src/app/api/auth/verify-email/route.ts +29 -0
- package/{template → templates/next}/src/app/forbidden/page.tsx +11 -13
- package/{template → templates/next}/src/app/layout.tsx +9 -6
- package/templates/next/src/app/not-found.tsx +20 -0
- package/templates/next/src/app/opengraph-image.tsx +49 -0
- package/templates/next/src/app/page.tsx +165 -0
- package/templates/next/src/app/robots.ts +15 -0
- package/templates/next/src/app/sitemap.ts +13 -0
- package/templates/next/src/app/verify-email/page.tsx +23 -0
- package/templates/next/src/components/admin/user-actions.tsx +124 -0
- package/templates/next/src/components/admin/users-data-table.tsx +221 -0
- package/templates/next/src/components/admin/users-table.tsx +67 -0
- package/{template → templates/next}/src/components/auth/auth-card.tsx +8 -8
- package/templates/next/src/components/auth/forgot-password-form.tsx +76 -0
- package/templates/next/src/components/auth/form-field.tsx +40 -0
- package/{template → templates/next}/src/components/auth/login-form.tsx +14 -9
- package/templates/next/src/components/auth/password-input.tsx +43 -0
- package/{template → templates/next}/src/components/auth/register-form.tsx +22 -19
- package/templates/next/src/components/auth/reset-password-form.tsx +80 -0
- package/{template → templates/next}/src/components/auth/session-refresher.tsx +1 -1
- package/templates/next/src/components/auth/verify-email-banner.tsx +43 -0
- package/templates/next/src/components/auth/verify-email-status.tsx +44 -0
- package/templates/next/src/components/layout/nav-links.tsx +37 -0
- package/templates/next/src/components/layout/navbar.tsx +27 -0
- package/templates/next/src/components/layout/page-header.tsx +21 -0
- package/templates/next/src/components/layout/sidebar.tsx +83 -0
- package/templates/next/src/components/layout/skeletons.tsx +57 -0
- package/templates/next/src/components/layout/user-menu.tsx +118 -0
- package/{template → templates/next}/src/components/logo.tsx +3 -6
- package/{template → templates/next}/src/components/reports/animated-bar.tsx +1 -5
- package/templates/next/src/components/reports/role-chart.tsx +61 -0
- package/templates/next/src/components/reports/signups-chart.tsx +64 -0
- package/templates/next/src/components/role-badge.tsx +11 -0
- package/templates/next/src/components/settings/password-form.tsx +80 -0
- package/templates/next/src/components/settings/profile-form.tsx +63 -0
- package/templates/next/src/components/settings/sessions-card.tsx +70 -0
- package/templates/next/src/components/theme-toggle.tsx +61 -0
- package/templates/next/src/config/rbac.test.ts +89 -0
- package/{template → templates/next}/src/config/rbac.ts +35 -5
- package/{template → templates/next}/src/lib/api.ts +40 -4
- package/templates/next/src/lib/audit.ts +66 -0
- package/{template → templates/next}/src/lib/auth.ts +10 -2
- package/{template → templates/next}/src/lib/dal.ts +8 -5
- package/templates/next/src/lib/email-templates.ts +55 -0
- package/templates/next/src/lib/email.ts +53 -0
- package/templates/next/src/lib/env.ts +90 -0
- package/templates/next/src/lib/password-strength.test.ts +20 -0
- package/templates/next/src/lib/password-strength.ts +24 -0
- package/templates/next/src/lib/rate-limit.test.ts +47 -0
- package/templates/next/src/lib/rate-limit.ts +70 -0
- package/templates/next/src/lib/redirect.test.ts +23 -0
- package/{template → templates/next}/src/lib/session.ts +5 -1
- package/templates/next/src/lib/theme.ts +32 -0
- package/templates/next/src/lib/tokens.ts +63 -0
- package/{template → templates/next}/src/lib/users.ts +49 -12
- package/templates/next/src/lib/validations/account.ts +20 -0
- package/templates/next/src/lib/validations/auth.test.ts +39 -0
- package/{template → templates/next}/src/lib/validations/auth.ts +24 -2
- package/templates/next/src/models/audit-log.ts +33 -0
- package/templates/next/src/models/auth-token.ts +26 -0
- package/{template → templates/next}/src/models/user.ts +5 -0
- package/{template → templates/next}/src/proxy.ts +1 -1
- package/templates/next/src/styles/app.css +1092 -0
- package/{template → templates/next}/src/types/user.ts +3 -0
- package/templates/next/vitest.config.mts +13 -0
- package/templates/styles/css.css +580 -0
- package/templates/styles/tailwind.css +140 -0
- package/templates/ui/css/components/alert-dialog.tsx +172 -0
- package/templates/ui/css/components/avatar.tsx +17 -0
- package/templates/ui/css/components/badge.tsx +18 -0
- package/templates/ui/css/components/button.tsx +41 -0
- package/templates/ui/css/components/card.tsx +33 -0
- package/templates/ui/css/components/dropdown-menu.tsx +230 -0
- package/templates/ui/css/components/input.tsx +7 -0
- package/templates/ui/css/components/label.tsx +7 -0
- package/templates/ui/css/components/native-select.tsx +23 -0
- package/templates/ui/css/components/skeleton.tsx +7 -0
- package/templates/ui/css/components/slot.tsx +30 -0
- package/templates/ui/css/components/table.tsx +31 -0
- package/templates/ui/css/utils.ts +16 -0
- package/templates/ui/shadcn/components/alert-dialog.tsx +199 -0
- package/templates/ui/shadcn/components/avatar.tsx +111 -0
- package/templates/ui/shadcn/components/dropdown-menu.tsx +268 -0
- package/templates/ui/shadcn/components/table.tsx +115 -0
- package/templates/ui/tailwind/components/alert-dialog.tsx +177 -0
- package/templates/ui/tailwind/components/avatar.tsx +36 -0
- package/templates/ui/tailwind/components/badge.tsx +29 -0
- package/templates/ui/tailwind/components/button.tsx +65 -0
- package/templates/ui/tailwind/components/card.tsx +70 -0
- package/templates/ui/tailwind/components/dropdown-menu.tsx +236 -0
- package/templates/ui/tailwind/components/input.tsx +17 -0
- package/templates/ui/tailwind/components/label.tsx +16 -0
- package/templates/ui/tailwind/components/native-select.tsx +32 -0
- package/templates/ui/tailwind/components/skeleton.tsx +13 -0
- package/templates/ui/tailwind/components/slot.tsx +34 -0
- package/templates/ui/tailwind/components/table.tsx +56 -0
- package/templates/ui/tailwind/utils.ts +1 -0
- package/templates/vite/Dockerfile +29 -0
- package/templates/vite/README.md +142 -0
- package/templates/vite/_dockerignore +14 -0
- package/templates/vite/_env.example +8 -0
- package/templates/vite/_gitignore +37 -0
- package/templates/vite/e2e/app.spec.ts +41 -0
- package/templates/vite/index.html +32 -0
- package/templates/vite/nginx.conf +26 -0
- package/templates/vite/package.json +61 -0
- package/templates/vite/playwright.config.ts +27 -0
- package/templates/vite/public/favicon.svg +1 -0
- package/templates/vite/src/App.test.tsx +28 -0
- package/templates/vite/src/App.tsx +26 -0
- package/templates/vite/src/components/home.tsx +121 -0
- package/templates/vite/src/components/layout/root-layout.tsx +18 -0
- package/templates/vite/src/components/layout/site-footer.tsx +10 -0
- package/templates/vite/src/components/layout/site-header.tsx +49 -0
- package/templates/vite/src/components/theme-toggle.tsx +90 -0
- package/templates/vite/src/env.ts +36 -0
- package/templates/vite/src/lib/theme.ts +26 -0
- package/templates/vite/src/main.tsx +13 -0
- package/templates/vite/src/pages/about.tsx +52 -0
- package/templates/vite/src/pages/not-found.tsx +33 -0
- package/templates/vite/src/router.ts +24 -0
- package/templates/vite/src/styles/app.css +281 -0
- package/templates/vite/src/test/setup.ts +21 -0
- package/templates/vite/tsconfig.app.json +31 -0
- package/templates/vite/tsconfig.json +7 -0
- package/templates/vite/tsconfig.node.json +23 -0
- package/templates/vite/vite.config.ts +30 -0
- package/template/README.md +0 -262
- package/template/_prettierrc +0 -9
- package/template/components.json +0 -25
- package/template/src/app/(app)/admin/page.tsx +0 -53
- package/template/src/app/(app)/reports/page.tsx +0 -109
- package/template/src/app/(auth)/layout.tsx +0 -22
- package/template/src/app/not-found.tsx +0 -18
- package/template/src/app/page.tsx +0 -187
- package/template/src/components/admin/users-table.tsx +0 -162
- package/template/src/components/auth/form-field.tsx +0 -32
- package/template/src/components/layout/logout-button.tsx +0 -34
- package/template/src/components/layout/navbar.tsx +0 -67
- package/template/src/components/layout/page-header.tsx +0 -21
- package/template/src/components/layout/skeletons.tsx +0 -35
- package/template/src/components/role-badge.tsx +0 -17
- package/template/src/components/theme-toggle.tsx +0 -25
- package/template/src/lib/env.ts +0 -36
- package/template/src/lib/theme.ts +0 -8
- /package/{template → templates/next}/AGENTS.md +0 -0
- /package/{template → templates/next}/Dockerfile +0 -0
- /package/{template → templates/next}/_dockerignore +0 -0
- /package/{template → templates/next}/docker-compose.yml +0 -0
- /package/{template → templates/next}/public/robots.txt +0 -0
- /package/{template → templates/next}/src/app/(app)/loading.tsx +0 -0
- /package/{template → templates/next}/src/app/(auth)/login/page.tsx +0 -0
- /package/{template → templates/next}/src/app/api/admin/users/route.ts +0 -0
- /package/{template → templates/next}/src/app/api/auth/logout/route.ts +0 -0
- /package/{template → templates/next}/src/app/api/health/route.ts +0 -0
- /package/{template → templates/next}/src/app/favicon.ico +0 -0
- /package/{template → templates/next}/src/components/auth/can.tsx +0 -0
- /package/{template → templates/next}/src/components/motion/fade-in.tsx +0 -0
- /package/{template → templates/next}/src/components/providers/user-provider.tsx +0 -0
- /package/{template → templates/next}/src/config/site.ts +0 -0
- /package/{template → templates/next}/src/lib/db.ts +0 -0
- /package/{template → templates/next}/src/lib/http.ts +0 -0
- /package/{template → templates/next}/src/lib/redirect.ts +0 -0
- /package/{template → templates/next}/src/lib/validations/user.ts +0 -0
- /package/{template → templates/next}/tsconfig.json +0 -0
- /package/{template/src/app/globals.css → templates/styles/shadcn.css} +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/badge.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/button.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/card.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/input.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/label.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/native-select.tsx +0 -0
- /package/{template/src/components/ui → templates/ui/shadcn/components}/skeleton.tsx +0 -0
- /package/{template/src/lib → templates/ui/shadcn}/utils.ts +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
|
|
6
|
+
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
data-slot="table-container"
|
|
10
|
+
className="relative w-full overflow-x-auto"
|
|
11
|
+
>
|
|
12
|
+
<table
|
|
13
|
+
data-slot="table"
|
|
14
|
+
className={cn("w-full caption-bottom text-sm", className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
|
22
|
+
return (
|
|
23
|
+
<thead
|
|
24
|
+
data-slot="table-header"
|
|
25
|
+
className={cn("[&_tr]:border-b", className)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
|
32
|
+
return (
|
|
33
|
+
<tbody
|
|
34
|
+
data-slot="table-body"
|
|
35
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
42
|
+
return (
|
|
43
|
+
<tfoot
|
|
44
|
+
data-slot="table-footer"
|
|
45
|
+
className={cn(
|
|
46
|
+
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
|
47
|
+
className
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
55
|
+
return (
|
|
56
|
+
<tr
|
|
57
|
+
data-slot="table-row"
|
|
58
|
+
className={cn(
|
|
59
|
+
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
|
|
60
|
+
className
|
|
61
|
+
)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
68
|
+
return (
|
|
69
|
+
<th
|
|
70
|
+
data-slot="table-head"
|
|
71
|
+
className={cn(
|
|
72
|
+
"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
|
|
73
|
+
className
|
|
74
|
+
)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|
81
|
+
return (
|
|
82
|
+
<td
|
|
83
|
+
data-slot="table-cell"
|
|
84
|
+
className={cn(
|
|
85
|
+
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
|
|
86
|
+
className
|
|
87
|
+
)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function TableCaption({
|
|
94
|
+
className,
|
|
95
|
+
...props
|
|
96
|
+
}: React.ComponentProps<"caption">) {
|
|
97
|
+
return (
|
|
98
|
+
<caption
|
|
99
|
+
data-slot="table-caption"
|
|
100
|
+
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
Table,
|
|
108
|
+
TableHeader,
|
|
109
|
+
TableBody,
|
|
110
|
+
TableFooter,
|
|
111
|
+
TableHead,
|
|
112
|
+
TableRow,
|
|
113
|
+
TableCell,
|
|
114
|
+
TableCaption,
|
|
115
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
use,
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
useId,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
type ComponentProps,
|
|
13
|
+
type MouseEvent,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
} from "react";
|
|
16
|
+
|
|
17
|
+
import { Button, type ButtonSize, type ButtonVariant } from "@/components/ui/button";
|
|
18
|
+
import { Slot } from "@/components/ui/slot";
|
|
19
|
+
import { cn } from "@/lib/utils";
|
|
20
|
+
|
|
21
|
+
const classes = {
|
|
22
|
+
content:
|
|
23
|
+
"m-auto w-full max-w-[calc(100%-2rem)] rounded-xl border-0 bg-popover p-0 text-popover-foreground shadow-lg ring-1 ring-foreground/10 backdrop:bg-black/40 sm:max-w-md",
|
|
24
|
+
inner: "grid gap-4 p-5",
|
|
25
|
+
header: "grid gap-1.5",
|
|
26
|
+
footer: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
27
|
+
title: "text-base font-semibold",
|
|
28
|
+
description: "text-sm text-muted-foreground",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type DialogContextValue = {
|
|
32
|
+
open: boolean;
|
|
33
|
+
setOpen: (open: boolean) => void;
|
|
34
|
+
titleId: string;
|
|
35
|
+
descriptionId: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const DialogContext = createContext<DialogContextValue | null>(null);
|
|
39
|
+
|
|
40
|
+
function useDialog() {
|
|
41
|
+
const ctx = use(DialogContext);
|
|
42
|
+
if (!ctx) throw new Error("AlertDialog parts must be used inside <AlertDialog>");
|
|
43
|
+
return ctx;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A confirmation dialog built on the native <dialog> element (same API as shadcn/ui's). */
|
|
47
|
+
export function AlertDialog({
|
|
48
|
+
children,
|
|
49
|
+
open: openProp,
|
|
50
|
+
onOpenChange,
|
|
51
|
+
}: {
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
open?: boolean;
|
|
54
|
+
onOpenChange?: (open: boolean) => void;
|
|
55
|
+
}) {
|
|
56
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
57
|
+
const open = openProp ?? uncontrolledOpen;
|
|
58
|
+
const setOpen = useCallback(
|
|
59
|
+
(next: boolean) => {
|
|
60
|
+
setUncontrolledOpen(next);
|
|
61
|
+
onOpenChange?.(next);
|
|
62
|
+
},
|
|
63
|
+
[onOpenChange],
|
|
64
|
+
);
|
|
65
|
+
const titleId = useId();
|
|
66
|
+
const descriptionId = useId();
|
|
67
|
+
const value = useMemo(
|
|
68
|
+
() => ({ open, setOpen, titleId, descriptionId }),
|
|
69
|
+
[open, setOpen, titleId, descriptionId],
|
|
70
|
+
);
|
|
71
|
+
return <DialogContext value={value}>{children}</DialogContext>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function AlertDialogTrigger({
|
|
75
|
+
asChild = false,
|
|
76
|
+
...props
|
|
77
|
+
}: ComponentProps<"button"> & { asChild?: boolean }) {
|
|
78
|
+
const { setOpen } = useDialog();
|
|
79
|
+
const Comp = asChild ? Slot : "button";
|
|
80
|
+
return (
|
|
81
|
+
<Comp
|
|
82
|
+
type={asChild ? undefined : "button"}
|
|
83
|
+
aria-haspopup="dialog"
|
|
84
|
+
{...props}
|
|
85
|
+
onClick={() => setOpen(true)}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function AlertDialogContent({ className, children, ...props }: ComponentProps<"dialog">) {
|
|
91
|
+
const { open, setOpen, titleId, descriptionId } = useDialog();
|
|
92
|
+
const ref = useRef<HTMLDialogElement>(null);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const dialog = ref.current;
|
|
96
|
+
if (!dialog) return;
|
|
97
|
+
if (open && !dialog.open) dialog.showModal();
|
|
98
|
+
if (!open && dialog.open) dialog.close();
|
|
99
|
+
}, [open]);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<dialog
|
|
103
|
+
ref={ref}
|
|
104
|
+
role="alertdialog"
|
|
105
|
+
aria-labelledby={titleId}
|
|
106
|
+
aria-describedby={descriptionId}
|
|
107
|
+
data-slot="alert-dialog-content"
|
|
108
|
+
className={cn(classes.content, className)}
|
|
109
|
+
// Escape: close through state so the parent stays in sync.
|
|
110
|
+
onCancel={(e) => {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
setOpen(false);
|
|
113
|
+
}}
|
|
114
|
+
onClose={() => open && setOpen(false)}
|
|
115
|
+
{...props}
|
|
116
|
+
>
|
|
117
|
+
{open && <div className={classes.inner}>{children}</div>}
|
|
118
|
+
</dialog>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function AlertDialogHeader({ className, ...props }: ComponentProps<"div">) {
|
|
123
|
+
return (
|
|
124
|
+
<div data-slot="alert-dialog-header" className={cn(classes.header, className)} {...props} />
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function AlertDialogFooter({ className, ...props }: ComponentProps<"div">) {
|
|
129
|
+
return (
|
|
130
|
+
<div data-slot="alert-dialog-footer" className={cn(classes.footer, className)} {...props} />
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function AlertDialogTitle({ className, ...props }: ComponentProps<"h2">) {
|
|
135
|
+
const { titleId } = useDialog();
|
|
136
|
+
return <h2 id={titleId} className={cn(classes.title, className)} {...props} />;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function AlertDialogDescription({ className, ...props }: ComponentProps<"p">) {
|
|
140
|
+
const { descriptionId } = useDialog();
|
|
141
|
+
return <p id={descriptionId} className={cn(classes.description, className)} {...props} />;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
type ActionProps = Omit<ComponentProps<"button">, "onClick"> & {
|
|
145
|
+
variant?: ButtonVariant;
|
|
146
|
+
size?: ButtonSize;
|
|
147
|
+
/** Call event.preventDefault() to keep the dialog open (e.g. while a request runs). */
|
|
148
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export function AlertDialogAction({ variant = "default", onClick, ...props }: ActionProps) {
|
|
152
|
+
const { setOpen } = useDialog();
|
|
153
|
+
return (
|
|
154
|
+
<Button
|
|
155
|
+
variant={variant}
|
|
156
|
+
onClick={(e) => {
|
|
157
|
+
onClick?.(e);
|
|
158
|
+
if (!e.defaultPrevented) setOpen(false);
|
|
159
|
+
}}
|
|
160
|
+
{...props}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function AlertDialogCancel({ variant = "outline", onClick, ...props }: ActionProps) {
|
|
166
|
+
const { setOpen } = useDialog();
|
|
167
|
+
return (
|
|
168
|
+
<Button
|
|
169
|
+
variant={variant}
|
|
170
|
+
onClick={(e) => {
|
|
171
|
+
onClick?.(e);
|
|
172
|
+
setOpen(false);
|
|
173
|
+
}}
|
|
174
|
+
{...props}
|
|
175
|
+
/>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
const sizes = { sm: "size-6 text-xs", default: "size-8 text-sm", lg: "size-10 text-base" };
|
|
6
|
+
|
|
7
|
+
export function Avatar({
|
|
8
|
+
className,
|
|
9
|
+
size = "default",
|
|
10
|
+
...props
|
|
11
|
+
}: ComponentProps<"span"> & { size?: keyof typeof sizes }) {
|
|
12
|
+
return (
|
|
13
|
+
<span
|
|
14
|
+
data-slot="avatar"
|
|
15
|
+
className={cn(
|
|
16
|
+
"relative flex shrink-0 overflow-hidden rounded-full select-none",
|
|
17
|
+
sizes[size],
|
|
18
|
+
className,
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function AvatarFallback({ className, ...props }: ComponentProps<"span">) {
|
|
26
|
+
return (
|
|
27
|
+
<span
|
|
28
|
+
data-slot="avatar-fallback"
|
|
29
|
+
className={cn(
|
|
30
|
+
"flex size-full items-center justify-center rounded-full bg-muted font-medium text-muted-foreground",
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
const variants = {
|
|
6
|
+
default: "bg-primary text-primary-foreground",
|
|
7
|
+
secondary: "bg-secondary text-secondary-foreground",
|
|
8
|
+
destructive: "bg-destructive/10 text-destructive dark:bg-destructive/20",
|
|
9
|
+
outline: "border-border text-foreground",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function Badge({
|
|
13
|
+
className,
|
|
14
|
+
variant = "default",
|
|
15
|
+
...props
|
|
16
|
+
}: ComponentProps<"span"> & { variant?: keyof typeof variants }) {
|
|
17
|
+
return (
|
|
18
|
+
<span
|
|
19
|
+
data-slot="badge"
|
|
20
|
+
data-variant={variant}
|
|
21
|
+
className={cn(
|
|
22
|
+
"inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap [&>svg]:pointer-events-none [&>svg]:size-3!",
|
|
23
|
+
variants[variant],
|
|
24
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { Slot } from "@/components/ui/slot";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
const base =
|
|
7
|
+
"inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-transparent text-sm font-medium whitespace-nowrap transition-colors outline-none select-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4";
|
|
8
|
+
|
|
9
|
+
const variants = {
|
|
10
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/85",
|
|
11
|
+
outline:
|
|
12
|
+
"border-border bg-background hover:bg-muted dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
13
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
14
|
+
ghost: "hover:bg-muted dark:hover:bg-muted/50",
|
|
15
|
+
destructive:
|
|
16
|
+
"bg-destructive/10 text-destructive hover:bg-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30",
|
|
17
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const sizes = {
|
|
21
|
+
default: "h-8 px-2.5",
|
|
22
|
+
xs: "h-6 gap-1 px-2 text-xs",
|
|
23
|
+
sm: "h-7 gap-1 px-2.5 text-[0.8rem]",
|
|
24
|
+
lg: "h-9 px-3",
|
|
25
|
+
icon: "size-8",
|
|
26
|
+
"icon-xs": "size-6",
|
|
27
|
+
"icon-sm": "size-7",
|
|
28
|
+
"icon-lg": "size-9",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ButtonVariant = keyof typeof variants;
|
|
32
|
+
export type ButtonSize = keyof typeof sizes;
|
|
33
|
+
|
|
34
|
+
export function buttonVariants({
|
|
35
|
+
variant = "default",
|
|
36
|
+
size = "default",
|
|
37
|
+
className,
|
|
38
|
+
}: { variant?: ButtonVariant; size?: ButtonSize; className?: string } = {}) {
|
|
39
|
+
return cn(base, variants[variant], sizes[size], className);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ButtonProps = ComponentProps<"button"> & {
|
|
43
|
+
variant?: ButtonVariant;
|
|
44
|
+
size?: ButtonSize;
|
|
45
|
+
/** Render the child element (e.g. a <Link>) with button styles instead of a <button>. */
|
|
46
|
+
asChild?: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export function Button({
|
|
50
|
+
variant = "default",
|
|
51
|
+
size = "default",
|
|
52
|
+
asChild = false,
|
|
53
|
+
className,
|
|
54
|
+
...props
|
|
55
|
+
}: ButtonProps) {
|
|
56
|
+
const Comp = asChild ? Slot : "button";
|
|
57
|
+
return (
|
|
58
|
+
<Comp
|
|
59
|
+
data-slot="button"
|
|
60
|
+
data-variant={variant}
|
|
61
|
+
className={buttonVariants({ variant, size, className })}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
export function Card({ className, ...props }: ComponentProps<"div">) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="card"
|
|
9
|
+
className={cn(
|
|
10
|
+
"flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10",
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function CardHeader({ className, ...props }: ComponentProps<"div">) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="card-header"
|
|
22
|
+
className={cn("grid auto-rows-min items-start gap-1 px-4", className)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function CardTitle({ className, ...props }: ComponentProps<"div">) {
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
data-slot="card-title"
|
|
32
|
+
className={cn("text-base leading-snug font-medium", className)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function CardDescription({ className, ...props }: ComponentProps<"div">) {
|
|
39
|
+
return (
|
|
40
|
+
<div
|
|
41
|
+
data-slot="card-description"
|
|
42
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function CardAction({ className, ...props }: ComponentProps<"div">) {
|
|
49
|
+
return (
|
|
50
|
+
<div
|
|
51
|
+
data-slot="card-action"
|
|
52
|
+
className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function CardContent({ className, ...props }: ComponentProps<"div">) {
|
|
59
|
+
return <div data-slot="card-content" className={cn("px-4", className)} {...props} />;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function CardFooter({ className, ...props }: ComponentProps<"div">) {
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
data-slot="card-footer"
|
|
66
|
+
className={cn("-mb-4 flex items-center border-t bg-muted/50 p-4", className)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|