create-next-imagicma 0.0.1

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.
Files changed (86) hide show
  1. package/README.md +42 -0
  2. package/bin/create-next-imagicma.mjs +220 -0
  3. package/package.json +19 -0
  4. package/template/.env.example +10 -0
  5. package/template/AGENTS.md +146 -0
  6. package/template/README.md +36 -0
  7. package/template/app/_components/DevPreviewShield.tsx +638 -0
  8. package/template/app/api/greeting/route.ts +27 -0
  9. package/template/app/error.tsx +93 -0
  10. package/template/app/favicon.ico +0 -0
  11. package/template/app/globals.css +145 -0
  12. package/template/app/hello/_components/HelloClient.tsx +94 -0
  13. package/template/app/hello/page.tsx +23 -0
  14. package/template/app/layout.tsx +29 -0
  15. package/template/app/page.tsx +49 -0
  16. package/template/app/providers.tsx +25 -0
  17. package/template/components/ui/accordion.tsx +58 -0
  18. package/template/components/ui/alert-dialog.tsx +141 -0
  19. package/template/components/ui/alert.tsx +61 -0
  20. package/template/components/ui/aspect-ratio.tsx +7 -0
  21. package/template/components/ui/avatar.tsx +51 -0
  22. package/template/components/ui/badge.tsx +40 -0
  23. package/template/components/ui/breadcrumb.tsx +117 -0
  24. package/template/components/ui/button.tsx +64 -0
  25. package/template/components/ui/calendar.tsx +72 -0
  26. package/template/components/ui/card.tsx +87 -0
  27. package/template/components/ui/carousel.tsx +262 -0
  28. package/template/components/ui/chart.tsx +365 -0
  29. package/template/components/ui/checkbox.tsx +30 -0
  30. package/template/components/ui/collapsible.tsx +11 -0
  31. package/template/components/ui/command.tsx +153 -0
  32. package/template/components/ui/context-menu.tsx +200 -0
  33. package/template/components/ui/dialog.tsx +122 -0
  34. package/template/components/ui/drawer.tsx +118 -0
  35. package/template/components/ui/dropdown-menu.tsx +200 -0
  36. package/template/components/ui/form.tsx +178 -0
  37. package/template/components/ui/hover-card.tsx +29 -0
  38. package/template/components/ui/input-otp.tsx +71 -0
  39. package/template/components/ui/input.tsx +25 -0
  40. package/template/components/ui/label.tsx +26 -0
  41. package/template/components/ui/menubar.tsx +256 -0
  42. package/template/components/ui/navigation-menu.tsx +130 -0
  43. package/template/components/ui/pagination.tsx +119 -0
  44. package/template/components/ui/popover.tsx +31 -0
  45. package/template/components/ui/progress.tsx +28 -0
  46. package/template/components/ui/radio-group.tsx +44 -0
  47. package/template/components/ui/resizable.tsx +45 -0
  48. package/template/components/ui/scroll-area.tsx +48 -0
  49. package/template/components/ui/select.tsx +160 -0
  50. package/template/components/ui/separator.tsx +31 -0
  51. package/template/components/ui/sheet.tsx +140 -0
  52. package/template/components/ui/sidebar.tsx +732 -0
  53. package/template/components/ui/skeleton.tsx +17 -0
  54. package/template/components/ui/slider.tsx +28 -0
  55. package/template/components/ui/switch.tsx +29 -0
  56. package/template/components/ui/table.tsx +119 -0
  57. package/template/components/ui/tabs.tsx +55 -0
  58. package/template/components/ui/textarea.tsx +24 -0
  59. package/template/components/ui/toast.tsx +129 -0
  60. package/template/components/ui/toaster.tsx +35 -0
  61. package/template/components/ui/toggle-group.tsx +61 -0
  62. package/template/components/ui/toggle.tsx +45 -0
  63. package/template/components/ui/tooltip.tsx +30 -0
  64. package/template/drizzle.config.ts +50 -0
  65. package/template/eslint.config.mjs +18 -0
  66. package/template/hooks/use-greeting.ts +15 -0
  67. package/template/hooks/use-mobile.ts +21 -0
  68. package/template/hooks/use-toast.ts +194 -0
  69. package/template/lib/queryClient.ts +59 -0
  70. package/template/lib/utils.ts +6 -0
  71. package/template/next.config.ts +8 -0
  72. package/template/package.json +81 -0
  73. package/template/pnpm-lock.yaml +6937 -0
  74. package/template/postcss.config.mjs +7 -0
  75. package/template/public/file.svg +1 -0
  76. package/template/public/globe.svg +1 -0
  77. package/template/public/next.svg +1 -0
  78. package/template/public/vercel.svg +1 -0
  79. package/template/public/window.svg +1 -0
  80. package/template/server/db.ts +24 -0
  81. package/template/server/storage.ts +41 -0
  82. package/template/shared/routes.ts +13 -0
  83. package/template/shared/schema.ts +17 -0
  84. package/template/tailwind.config.mjs +96 -0
  85. package/template/tsconfig.json +35 -0
  86. package/template/types/pg.d.ts +19 -0
@@ -0,0 +1,93 @@
1
+ "use client";
2
+
3
+ import { useEffect } from "react";
4
+
5
+ export default function Error({
6
+ error,
7
+ reset,
8
+ }: {
9
+ error: Error & { digest?: string };
10
+ reset: () => void;
11
+ }) {
12
+ useEffect(() => {
13
+ // 保持 Next.js 默认的错误日志行为
14
+ console.error(error);
15
+ }, [error]);
16
+
17
+ const isDev = process.env.NODE_ENV === "development";
18
+ const digest = error?.digest;
19
+ const message = isDev ? (error?.message || "发生未知错误").trim() : "";
20
+
21
+ return (
22
+ <div
23
+ className="relative flex min-h-screen items-center justify-center overflow-hidden bg-gradient-to-br from-indigo-600 via-purple-600 to-sky-600 px-6 py-16 text-white"
24
+ role="alert"
25
+ >
26
+ <div className="absolute inset-0 bg-[radial-gradient(60%_60%_at_50%_40%,rgba(255,255,255,0.20),transparent_60%)]" />
27
+ <main className="relative w-full max-w-xl rounded-3xl border border-white/15 bg-white/10 p-10 shadow-2xl backdrop-blur-xl">
28
+ <div className="flex flex-col items-center text-center">
29
+ <div className="flex h-16 w-16 items-center justify-center rounded-2xl bg-white/10">
30
+ <svg
31
+ viewBox="0 0 24 24"
32
+ className="h-9 w-9 text-white/90"
33
+ fill="none"
34
+ aria-hidden="true"
35
+ >
36
+ <path
37
+ d="M12 9v5"
38
+ stroke="currentColor"
39
+ strokeWidth="1.8"
40
+ strokeLinecap="round"
41
+ />
42
+ <path
43
+ d="M12 17.5h.01"
44
+ stroke="currentColor"
45
+ strokeWidth="2.2"
46
+ strokeLinecap="round"
47
+ />
48
+ <path
49
+ d="M10.3 4.7 2.4 18.3a1.3 1.3 0 0 0 1.1 2h16.9a1.3 1.3 0 0 0 1.1-2L13.7 4.7a1.3 1.3 0 0 0-2.3 0Z"
50
+ stroke="currentColor"
51
+ strokeWidth="1.2"
52
+ strokeLinejoin="round"
53
+ opacity="0.85"
54
+ />
55
+ </svg>
56
+ </div>
57
+
58
+ <h1 className="mt-6 text-3xl font-semibold tracking-tight">
59
+ 预览暂时不可用
60
+ </h1>
61
+ <p className="mt-4 max-w-md text-base leading-7 text-white/80">
62
+ 检测到错误。修复后可点击“重试”恢复,或直接刷新页面。
63
+ </p>
64
+
65
+ {isDev && message ? (
66
+ <pre className="mt-6 w-full max-h-40 overflow-auto rounded-2xl border border-white/10 bg-black/25 p-4 text-left text-sm leading-6 text-white/85 shadow-inner">
67
+ <code>{message}</code>
68
+ </pre>
69
+ ) : digest ? (
70
+ <p className="mt-6 text-sm text-white/70">{`Digest: ${digest}`}</p>
71
+ ) : null}
72
+
73
+ <div className="mt-8 flex w-full flex-col gap-3 sm:flex-row sm:justify-center">
74
+ <button
75
+ type="button"
76
+ className="inline-flex h-11 w-full items-center justify-center rounded-full bg-white px-5 text-sm font-medium text-black transition-colors hover:bg-white/90 sm:w-auto"
77
+ onClick={() => reset()}
78
+ >
79
+ 重试
80
+ </button>
81
+ <button
82
+ type="button"
83
+ className="inline-flex h-11 w-full items-center justify-center rounded-full border border-white/20 bg-white/10 px-5 text-sm font-medium text-white transition-colors hover:bg-white/15 sm:w-auto"
84
+ onClick={() => window.location.reload()}
85
+ >
86
+ 刷新页面
87
+ </button>
88
+ </div>
89
+ </div>
90
+ </main>
91
+ </div>
92
+ );
93
+ }
Binary file
@@ -0,0 +1,145 @@
1
+ @config "../tailwind.config.mjs";
2
+ @import "tailwindcss";
3
+
4
+ :root {
5
+ /* Fonts */
6
+ --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
7
+ "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
8
+ "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji",
9
+ "Segoe UI Symbol", sans-serif;
10
+ --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
11
+ --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
12
+ "Liberation Mono", "Courier New", monospace;
13
+
14
+ /* Core theme tokens (HSL triples) */
15
+ --background: 0 0% 100%;
16
+ --foreground: 240 10% 3.9%;
17
+
18
+ --card: 0 0% 100%;
19
+ --card-foreground: 240 10% 3.9%;
20
+
21
+ --popover: 0 0% 100%;
22
+ --popover-foreground: 240 10% 3.9%;
23
+
24
+ --primary: 240 5.9% 10%;
25
+ --primary-foreground: 0 0% 98%;
26
+
27
+ --secondary: 240 4.8% 95.9%;
28
+ --secondary-foreground: 240 5.9% 10%;
29
+
30
+ --muted: 240 4.8% 95.9%;
31
+ --muted-foreground: 240 3.8% 46.1%;
32
+
33
+ --accent: 240 4.8% 95.9%;
34
+ --accent-foreground: 240 5.9% 10%;
35
+
36
+ --destructive: 0 84.2% 60.2%;
37
+ --destructive-foreground: 0 0% 98%;
38
+
39
+ --border: 240 5.9% 90%;
40
+ --input: 240 5.9% 90%;
41
+ --ring: 240 5.9% 10%;
42
+
43
+ --radius: 0.5rem;
44
+
45
+ /* Extra tokens used by the migrated shadcn components */
46
+ --card-border: var(--border);
47
+ --popover-border: var(--border);
48
+ --sidebar: var(--background);
49
+ --sidebar-foreground: var(--foreground);
50
+ --sidebar-border: var(--border);
51
+ --sidebar-ring: var(--ring);
52
+
53
+ --chart-1: 220 70% 50%;
54
+ --chart-2: 160 60% 45%;
55
+ --chart-3: 30 80% 55%;
56
+ --chart-4: 280 65% 60%;
57
+ --chart-5: 340 75% 55%;
58
+
59
+ /* Border colors expected by template classnames */
60
+ --primary-border: hsl(var(--primary) / 0.18);
61
+ --secondary-border: hsl(var(--border));
62
+ --muted-border: hsl(var(--border));
63
+ --accent-border: hsl(var(--border));
64
+ --destructive-border: hsl(var(--destructive) / 0.25);
65
+
66
+ --button-outline: hsl(var(--border));
67
+ --badge-outline: hsl(var(--border));
68
+ }
69
+
70
+ .dark {
71
+ --background: 240 10% 3.9%;
72
+ --foreground: 0 0% 98%;
73
+
74
+ --card: 240 10% 3.9%;
75
+ --card-foreground: 0 0% 98%;
76
+
77
+ --popover: 240 10% 3.9%;
78
+ --popover-foreground: 0 0% 98%;
79
+
80
+ --primary: 0 0% 98%;
81
+ --primary-foreground: 240 5.9% 10%;
82
+
83
+ --secondary: 240 3.7% 15.9%;
84
+ --secondary-foreground: 0 0% 98%;
85
+
86
+ --muted: 240 3.7% 15.9%;
87
+ --muted-foreground: 240 5% 64.9%;
88
+
89
+ --accent: 240 3.7% 15.9%;
90
+ --accent-foreground: 0 0% 98%;
91
+
92
+ --destructive: 0 62.8% 30.6%;
93
+ --destructive-foreground: 0 0% 98%;
94
+
95
+ --border: 240 3.7% 15.9%;
96
+ --input: 240 3.7% 15.9%;
97
+ --ring: 240 4.9% 83.9%;
98
+
99
+ --card-border: var(--border);
100
+ --popover-border: var(--border);
101
+ --sidebar: var(--background);
102
+ --sidebar-foreground: var(--foreground);
103
+ --sidebar-border: var(--border);
104
+ --sidebar-ring: var(--ring);
105
+
106
+ --primary-border: hsl(var(--primary) / 0.15);
107
+ --secondary-border: hsl(var(--border));
108
+ --muted-border: hsl(var(--border));
109
+ --accent-border: hsl(var(--border));
110
+ --destructive-border: hsl(var(--destructive) / 0.35);
111
+
112
+ --button-outline: hsl(var(--border));
113
+ --badge-outline: hsl(var(--border));
114
+ }
115
+
116
+ @layer base {
117
+ * {
118
+ border-color: hsl(var(--border));
119
+ }
120
+
121
+ body {
122
+ @apply bg-background text-foreground antialiased;
123
+ font-family: var(--font-sans);
124
+ }
125
+ }
126
+
127
+ @layer utilities {
128
+ .hover-elevate {
129
+ transition: transform 150ms ease, box-shadow 150ms ease;
130
+ }
131
+ .hover-elevate:hover {
132
+ transform: translateY(-1px);
133
+ box-shadow: 0 12px 30px rgb(0 0 0 / 0.08);
134
+ }
135
+
136
+ .active-elevate-2:active {
137
+ transform: translateY(0px);
138
+ box-shadow: 0 6px 18px rgb(0 0 0 / 0.08);
139
+ }
140
+ }
141
+
142
+ html[data-preview-shield="on"] nextjs-portal,
143
+ html[data-preview-shield="on"] script[data-nextjs-dev-overlay] {
144
+ display: none !important;
145
+ }
@@ -0,0 +1,94 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+
5
+ import { useGreeting } from "@/hooks/use-greeting";
6
+ import { toast } from "@/hooks/use-toast";
7
+ import { Badge } from "@/components/ui/badge";
8
+ import { Button } from "@/components/ui/button";
9
+ import {
10
+ Card,
11
+ CardContent,
12
+ CardDescription,
13
+ CardHeader,
14
+ CardTitle,
15
+ } from "@/components/ui/card";
16
+
17
+ export default function HelloClient() {
18
+ const { data, isLoading, error, refetch, isFetching } = useGreeting();
19
+
20
+ const status = isLoading
21
+ ? "loading"
22
+ : error
23
+ ? "error"
24
+ : "ready";
25
+
26
+ return (
27
+ <Card>
28
+ <CardHeader>
29
+ <div className="flex items-center justify-between gap-4">
30
+ <div className="space-y-1">
31
+ <CardTitle>GET /api/greeting</CardTitle>
32
+ <CardDescription>
33
+ 响应会被 Zod 校验,并展示到 UI 中。
34
+ </CardDescription>
35
+ </div>
36
+ <Badge
37
+ variant={status === "error" ? "destructive" : "secondary"}
38
+ >
39
+ {status}
40
+ </Badge>
41
+ </div>
42
+ </CardHeader>
43
+ <CardContent className="space-y-4">
44
+ <div className="rounded-lg border bg-card p-4">
45
+ {isLoading ? (
46
+ <p className="text-sm text-muted-foreground">加载中…</p>
47
+ ) : error ? (
48
+ <p className="text-sm text-destructive">
49
+ {error instanceof Error ? error.message : "请求失败"}
50
+ </p>
51
+ ) : (
52
+ <p className="text-lg leading-7">“{data?.message}”</p>
53
+ )}
54
+ </div>
55
+
56
+ <div className="flex flex-wrap gap-2">
57
+ <Button
58
+ type="button"
59
+ onClick={() => refetch()}
60
+ disabled={isFetching}
61
+ >
62
+ {isFetching ? "刷新中…" : "刷新"}
63
+ </Button>
64
+ <Button
65
+ type="button"
66
+ variant="outline"
67
+ onClick={() =>
68
+ toast({
69
+ title: "Toast 正常工作",
70
+ description: "如果你能看到我,说明 shadcn/toast 已接入。",
71
+ })
72
+ }
73
+ >
74
+ 触发 Toast
75
+ </Button>
76
+ </div>
77
+
78
+ <EnvHint />
79
+ </CardContent>
80
+ </Card>
81
+ );
82
+ }
83
+
84
+ function EnvHint() {
85
+ return (
86
+ <div className="text-sm text-muted-foreground">
87
+ <p>
88
+ 若 API 报错请检查:是否已在 <code>.env.local</code> 设置{" "}
89
+ <code>DATABASE_URL</code>,并执行 <code>npm run db:push</code>。
90
+ </p>
91
+ </div>
92
+ );
93
+ }
94
+
@@ -0,0 +1,23 @@
1
+ import HelloClient from "./_components/HelloClient";
2
+
3
+ export default function HelloPage() {
4
+ return (
5
+ <div className="min-h-screen bg-background text-foreground">
6
+ <div className="mx-auto max-w-3xl px-6 py-12">
7
+ <div className="space-y-2">
8
+ <h1 className="text-3xl font-semibold tracking-tight">
9
+ Replit 模板精华迁移验证
10
+ </h1>
11
+ <p className="text-sm text-muted-foreground">
12
+ 该页面用于验证:shadcn/ui、React Query、Next Route Handler、Drizzle/Postgres。
13
+ </p>
14
+ </div>
15
+
16
+ <div className="mt-8">
17
+ <HelloClient />
18
+ </div>
19
+ </div>
20
+ </div>
21
+ );
22
+ }
23
+
@@ -0,0 +1,29 @@
1
+ import type { Metadata } from "next";
2
+ import "./globals.css";
3
+ import { DevPreviewShield } from "./_components/DevPreviewShield";
4
+ import { Providers } from "./providers";
5
+
6
+ export const metadata: Metadata = {
7
+ title: "Create Next App",
8
+ description: "Generated by create next app",
9
+ };
10
+
11
+ export default function RootLayout({
12
+ children,
13
+ }: Readonly<{
14
+ children: React.ReactNode;
15
+ }>) {
16
+ return (
17
+ <html lang="zh-CN" suppressHydrationWarning>
18
+ <body className="antialiased">
19
+ <Providers>
20
+ {process.env.NODE_ENV === "development" ? (
21
+ <DevPreviewShield>{children}</DevPreviewShield>
22
+ ) : (
23
+ children
24
+ )}
25
+ </Providers>
26
+ </body>
27
+ </html>
28
+ );
29
+ }
@@ -0,0 +1,49 @@
1
+ export default function Home() {
2
+ return (
3
+ <div className="relative flex min-h-screen items-center justify-center overflow-hidden bg-gradient-to-br from-indigo-600 via-purple-600 to-sky-600 px-6 py-16 text-white">
4
+ <div className="absolute inset-0 bg-[radial-gradient(60%_60%_at_50%_40%,rgba(255,255,255,0.20),transparent_60%)]" />
5
+ <main className="relative w-full max-w-xl rounded-3xl border border-white/15 bg-white/10 p-10 shadow-2xl backdrop-blur-xl">
6
+ <div className="flex flex-col items-center text-center">
7
+ <div className="flex h-16 w-16 items-center justify-center rounded-2xl bg-white/10">
8
+ <svg
9
+ viewBox="0 0 24 24"
10
+ className="h-9 w-9 text-white/90"
11
+ fill="none"
12
+ aria-hidden="true"
13
+ >
14
+ <path
15
+ d="M12 15.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Z"
16
+ stroke="currentColor"
17
+ strokeWidth="1.8"
18
+ />
19
+ <path
20
+ d="M19.4 13.1a7.8 7.8 0 0 0 0-2.2l2-1.6a.7.7 0 0 0 .2-.9l-1.9-3.2a.7.7 0 0 0-.8-.3l-2.4 1a8.3 8.3 0 0 0-1.9-1.1l-.4-2.5a.7.7 0 0 0-.7-.6H8.5a.7.7 0 0 0-.7.6l-.4 2.5a8.3 8.3 0 0 0-1.9 1.1l-2.4-1a.7.7 0 0 0-.8.3L.4 8.4a.7.7 0 0 0 .2.9l2 1.6a7.8 7.8 0 0 0 0 2.2l-2 1.6a.7.7 0 0 0-.2.9l1.9 3.2c.2.3.5.4.8.3l2.4-1a8.3 8.3 0 0 0 1.9 1.1l.4 2.5c.1.3.3.6.7.6h3.7c.3 0 .6-.2.7-.6l.4-2.5a8.3 8.3 0 0 0 1.9-1.1l2.4 1c.3.1.6 0 .8-.3l1.9-3.2a.7.7 0 0 0-.2-.9l-2-1.6Z"
21
+ stroke="currentColor"
22
+ strokeWidth="1.2"
23
+ strokeLinejoin="round"
24
+ opacity="0.85"
25
+ />
26
+ </svg>
27
+ </div>
28
+
29
+ <h1 className="mt-6 text-4xl font-semibold tracking-tight">
30
+ 项目构建中
31
+ </h1>
32
+ <p className="mt-4 max-w-md text-base leading-7 text-white/80">
33
+ 我们正在努力为你构建预览服务,请稍后再试。
34
+ </p>
35
+
36
+ <div
37
+ className="mt-10 flex items-center gap-3 text-sm text-white/70"
38
+ role="status"
39
+ aria-live="polite"
40
+ >
41
+ <span className="sr-only">加载中</span>
42
+ <div className="h-5 w-5 rounded-full border-2 border-white/25 border-t-white/90 motion-reduce:animate-none animate-spin" />
43
+ <span>准备中…</span>
44
+ </div>
45
+ </div>
46
+ </main>
47
+ </div>
48
+ );
49
+ }
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { QueryClientProvider } from "@tanstack/react-query";
5
+ import { ThemeProvider } from "next-themes";
6
+
7
+ import { makeQueryClient } from "@/lib/queryClient";
8
+ import { Toaster } from "@/components/ui/toaster";
9
+ import { TooltipProvider } from "@/components/ui/tooltip";
10
+
11
+ export function Providers({ children }: { children: React.ReactNode }) {
12
+ const [queryClient] = React.useState(() => makeQueryClient());
13
+
14
+ return (
15
+ <ThemeProvider attribute="class" defaultTheme="system" enableSystem>
16
+ <QueryClientProvider client={queryClient}>
17
+ <TooltipProvider>
18
+ <Toaster />
19
+ {children}
20
+ </TooltipProvider>
21
+ </QueryClientProvider>
22
+ </ThemeProvider>
23
+ );
24
+ }
25
+
@@ -0,0 +1,58 @@
1
+ "use client";
2
+
3
+ import * as React from "react"
4
+ import * as AccordionPrimitive from "@radix-ui/react-accordion"
5
+ import { ChevronDown } from "lucide-react"
6
+
7
+ import { cn } from "@/lib/utils"
8
+
9
+ const Accordion = AccordionPrimitive.Root
10
+
11
+ const AccordionItem = React.forwardRef<
12
+ React.ElementRef<typeof AccordionPrimitive.Item>,
13
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
14
+ >(({ className, ...props }, ref) => (
15
+ <AccordionPrimitive.Item
16
+ ref={ref}
17
+ className={cn("border-b", className)}
18
+ {...props}
19
+ />
20
+ ))
21
+ AccordionItem.displayName = "AccordionItem"
22
+
23
+ const AccordionTrigger = React.forwardRef<
24
+ React.ElementRef<typeof AccordionPrimitive.Trigger>,
25
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
26
+ >(({ className, children, ...props }, ref) => (
27
+ <AccordionPrimitive.Header className="flex">
28
+ <AccordionPrimitive.Trigger
29
+ ref={ref}
30
+ className={cn(
31
+ "flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
32
+ className
33
+ )}
34
+ {...props}
35
+ >
36
+ {children}
37
+ <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
38
+ </AccordionPrimitive.Trigger>
39
+ </AccordionPrimitive.Header>
40
+ ))
41
+ AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
42
+
43
+ const AccordionContent = React.forwardRef<
44
+ React.ElementRef<typeof AccordionPrimitive.Content>,
45
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
46
+ >(({ className, children, ...props }, ref) => (
47
+ <AccordionPrimitive.Content
48
+ ref={ref}
49
+ className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
50
+ {...props}
51
+ >
52
+ <div className={cn("pb-4 pt-0", className)}>{children}</div>
53
+ </AccordionPrimitive.Content>
54
+ ))
55
+
56
+ AccordionContent.displayName = AccordionPrimitive.Content.displayName
57
+
58
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
@@ -0,0 +1,141 @@
1
+ "use client";
2
+
3
+ import * as React from "react"
4
+ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
5
+
6
+ import { cn } from "@/lib/utils"
7
+ import { buttonVariants } from "@/components/ui/button"
8
+
9
+ const AlertDialog = AlertDialogPrimitive.Root
10
+
11
+ const AlertDialogTrigger = AlertDialogPrimitive.Trigger
12
+
13
+ const AlertDialogPortal = AlertDialogPrimitive.Portal
14
+
15
+ const AlertDialogOverlay = React.forwardRef<
16
+ React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
17
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
18
+ >(({ className, ...props }, ref) => (
19
+ <AlertDialogPrimitive.Overlay
20
+ className={cn(
21
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
22
+ className
23
+ )}
24
+ {...props}
25
+ ref={ref}
26
+ />
27
+ ))
28
+ AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
29
+
30
+ const AlertDialogContent = React.forwardRef<
31
+ React.ElementRef<typeof AlertDialogPrimitive.Content>,
32
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
33
+ >(({ className, ...props }, ref) => (
34
+ <AlertDialogPortal>
35
+ <AlertDialogOverlay />
36
+ <AlertDialogPrimitive.Content
37
+ ref={ref}
38
+ className={cn(
39
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
40
+ className
41
+ )}
42
+ {...props}
43
+ />
44
+ </AlertDialogPortal>
45
+ ))
46
+ AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
47
+
48
+ const AlertDialogHeader = ({
49
+ className,
50
+ ...props
51
+ }: React.HTMLAttributes<HTMLDivElement>) => (
52
+ <div
53
+ className={cn(
54
+ "flex flex-col space-y-2 text-center sm:text-left",
55
+ className
56
+ )}
57
+ {...props}
58
+ />
59
+ )
60
+ AlertDialogHeader.displayName = "AlertDialogHeader"
61
+
62
+ const AlertDialogFooter = ({
63
+ className,
64
+ ...props
65
+ }: React.HTMLAttributes<HTMLDivElement>) => (
66
+ <div
67
+ className={cn(
68
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
69
+ className
70
+ )}
71
+ {...props}
72
+ />
73
+ )
74
+ AlertDialogFooter.displayName = "AlertDialogFooter"
75
+
76
+ const AlertDialogTitle = React.forwardRef<
77
+ React.ElementRef<typeof AlertDialogPrimitive.Title>,
78
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
79
+ >(({ className, ...props }, ref) => (
80
+ <AlertDialogPrimitive.Title
81
+ ref={ref}
82
+ className={cn("text-lg font-semibold", className)}
83
+ {...props}
84
+ />
85
+ ))
86
+ AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
87
+
88
+ const AlertDialogDescription = React.forwardRef<
89
+ React.ElementRef<typeof AlertDialogPrimitive.Description>,
90
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
91
+ >(({ className, ...props }, ref) => (
92
+ <AlertDialogPrimitive.Description
93
+ ref={ref}
94
+ className={cn("text-sm text-muted-foreground", className)}
95
+ {...props}
96
+ />
97
+ ))
98
+ AlertDialogDescription.displayName =
99
+ AlertDialogPrimitive.Description.displayName
100
+
101
+ const AlertDialogAction = React.forwardRef<
102
+ React.ElementRef<typeof AlertDialogPrimitive.Action>,
103
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
104
+ >(({ className, ...props }, ref) => (
105
+ <AlertDialogPrimitive.Action
106
+ ref={ref}
107
+ className={cn(buttonVariants(), className)}
108
+ {...props}
109
+ />
110
+ ))
111
+ AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
112
+
113
+ const AlertDialogCancel = React.forwardRef<
114
+ React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
115
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
116
+ >(({ className, ...props }, ref) => (
117
+ <AlertDialogPrimitive.Cancel
118
+ ref={ref}
119
+ className={cn(
120
+ buttonVariants({ variant: "outline" }),
121
+ "mt-2 sm:mt-0",
122
+ className
123
+ )}
124
+ {...props}
125
+ />
126
+ ))
127
+ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
128
+
129
+ export {
130
+ AlertDialog,
131
+ AlertDialogPortal,
132
+ AlertDialogOverlay,
133
+ AlertDialogTrigger,
134
+ AlertDialogContent,
135
+ AlertDialogHeader,
136
+ AlertDialogFooter,
137
+ AlertDialogTitle,
138
+ AlertDialogDescription,
139
+ AlertDialogAction,
140
+ AlertDialogCancel,
141
+ }