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,140 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
|
|
3
|
+
@custom-variant dark (&:is(.dark *));
|
|
4
|
+
|
|
5
|
+
@theme inline {
|
|
6
|
+
--color-background: var(--background);
|
|
7
|
+
--color-foreground: var(--foreground);
|
|
8
|
+
--font-sans: var(--font-geist-sans);
|
|
9
|
+
--font-mono: var(--font-geist-mono);
|
|
10
|
+
--font-heading: var(--font-geist-sans);
|
|
11
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
12
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
13
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
14
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
15
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
16
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
17
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
18
|
+
--color-sidebar: var(--sidebar);
|
|
19
|
+
--color-chart-5: var(--chart-5);
|
|
20
|
+
--color-chart-4: var(--chart-4);
|
|
21
|
+
--color-chart-3: var(--chart-3);
|
|
22
|
+
--color-chart-2: var(--chart-2);
|
|
23
|
+
--color-chart-1: var(--chart-1);
|
|
24
|
+
--color-ring: var(--ring);
|
|
25
|
+
--color-input: var(--input);
|
|
26
|
+
--color-border: var(--border);
|
|
27
|
+
--color-destructive: var(--destructive);
|
|
28
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
29
|
+
--color-accent: var(--accent);
|
|
30
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
31
|
+
--color-muted: var(--muted);
|
|
32
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
33
|
+
--color-secondary: var(--secondary);
|
|
34
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
35
|
+
--color-primary: var(--primary);
|
|
36
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
37
|
+
--color-popover: var(--popover);
|
|
38
|
+
--color-card-foreground: var(--card-foreground);
|
|
39
|
+
--color-card: var(--card);
|
|
40
|
+
--radius-sm: calc(var(--radius) * 0.6);
|
|
41
|
+
--radius-md: calc(var(--radius) * 0.8);
|
|
42
|
+
--radius-lg: var(--radius);
|
|
43
|
+
--radius-xl: calc(var(--radius) * 1.4);
|
|
44
|
+
--radius-2xl: calc(var(--radius) * 1.8);
|
|
45
|
+
--radius-3xl: calc(var(--radius) * 2.2);
|
|
46
|
+
--radius-4xl: calc(var(--radius) * 2.6);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:root {
|
|
50
|
+
--background: oklch(1 0 0);
|
|
51
|
+
--foreground: oklch(0.145 0 0);
|
|
52
|
+
--card: oklch(1 0 0);
|
|
53
|
+
--card-foreground: oklch(0.145 0 0);
|
|
54
|
+
--popover: oklch(1 0 0);
|
|
55
|
+
--popover-foreground: oklch(0.145 0 0);
|
|
56
|
+
--primary: oklch(0.205 0 0);
|
|
57
|
+
--primary-foreground: oklch(0.985 0 0);
|
|
58
|
+
--secondary: oklch(0.97 0 0);
|
|
59
|
+
--secondary-foreground: oklch(0.205 0 0);
|
|
60
|
+
--muted: oklch(0.97 0 0);
|
|
61
|
+
--muted-foreground: oklch(0.556 0 0);
|
|
62
|
+
--accent: oklch(0.97 0 0);
|
|
63
|
+
--accent-foreground: oklch(0.205 0 0);
|
|
64
|
+
--destructive: oklch(0.577 0.245 27.325);
|
|
65
|
+
--border: oklch(0.922 0 0);
|
|
66
|
+
--input: oklch(0.922 0 0);
|
|
67
|
+
--ring: oklch(0.708 0 0);
|
|
68
|
+
--chart-1: oklch(0.87 0 0);
|
|
69
|
+
--chart-2: oklch(0.556 0 0);
|
|
70
|
+
--chart-3: oklch(0.439 0 0);
|
|
71
|
+
--chart-4: oklch(0.371 0 0);
|
|
72
|
+
--chart-5: oklch(0.269 0 0);
|
|
73
|
+
--radius: 0.625rem;
|
|
74
|
+
--sidebar: oklch(0.985 0 0);
|
|
75
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
76
|
+
--sidebar-primary: oklch(0.205 0 0);
|
|
77
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
78
|
+
--sidebar-accent: oklch(0.97 0 0);
|
|
79
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
80
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
81
|
+
--sidebar-ring: oklch(0.708 0 0);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.dark {
|
|
85
|
+
--background: oklch(0.145 0 0);
|
|
86
|
+
--foreground: oklch(0.985 0 0);
|
|
87
|
+
--card: oklch(0.205 0 0);
|
|
88
|
+
--card-foreground: oklch(0.985 0 0);
|
|
89
|
+
--popover: oklch(0.205 0 0);
|
|
90
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
91
|
+
--primary: oklch(0.922 0 0);
|
|
92
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
93
|
+
--secondary: oklch(0.269 0 0);
|
|
94
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
95
|
+
--muted: oklch(0.269 0 0);
|
|
96
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
97
|
+
--accent: oklch(0.269 0 0);
|
|
98
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
99
|
+
--destructive: oklch(0.704 0.191 22.216);
|
|
100
|
+
--border: oklch(1 0 0 / 10%);
|
|
101
|
+
--input: oklch(1 0 0 / 15%);
|
|
102
|
+
--ring: oklch(0.556 0 0);
|
|
103
|
+
--chart-1: oklch(0.87 0 0);
|
|
104
|
+
--chart-2: oklch(0.556 0 0);
|
|
105
|
+
--chart-3: oklch(0.439 0 0);
|
|
106
|
+
--chart-4: oklch(0.371 0 0);
|
|
107
|
+
--chart-5: oklch(0.269 0 0);
|
|
108
|
+
--sidebar: oklch(0.205 0 0);
|
|
109
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
110
|
+
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
111
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
112
|
+
--sidebar-accent: oklch(0.269 0 0);
|
|
113
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
114
|
+
--sidebar-border: oklch(1 0 0 / 10%);
|
|
115
|
+
--sidebar-ring: oklch(0.556 0 0);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@layer base {
|
|
119
|
+
* {
|
|
120
|
+
@apply border-border outline-ring/50;
|
|
121
|
+
}
|
|
122
|
+
body {
|
|
123
|
+
@apply bg-background text-foreground;
|
|
124
|
+
}
|
|
125
|
+
html {
|
|
126
|
+
@apply font-sans;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
@layer base {
|
|
130
|
+
html {
|
|
131
|
+
color-scheme: light;
|
|
132
|
+
}
|
|
133
|
+
html.dark {
|
|
134
|
+
color-scheme: dark;
|
|
135
|
+
}
|
|
136
|
+
button:not(:disabled),
|
|
137
|
+
[role="button"]:not(:disabled) {
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
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: "dialog",
|
|
23
|
+
inner: "dialog-inner",
|
|
24
|
+
header: "dialog-header",
|
|
25
|
+
footer: "dialog-footer",
|
|
26
|
+
title: "dialog-title",
|
|
27
|
+
description: "dialog-description",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type DialogContextValue = {
|
|
31
|
+
open: boolean;
|
|
32
|
+
setOpen: (open: boolean) => void;
|
|
33
|
+
titleId: string;
|
|
34
|
+
descriptionId: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const DialogContext = createContext<DialogContextValue | null>(null);
|
|
38
|
+
|
|
39
|
+
function useDialog() {
|
|
40
|
+
const ctx = use(DialogContext);
|
|
41
|
+
if (!ctx) throw new Error("AlertDialog parts must be used inside <AlertDialog>");
|
|
42
|
+
return ctx;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A confirmation dialog built on the native <dialog> element (same API as shadcn/ui's). */
|
|
46
|
+
export function AlertDialog({
|
|
47
|
+
children,
|
|
48
|
+
open: openProp,
|
|
49
|
+
onOpenChange,
|
|
50
|
+
}: {
|
|
51
|
+
children: ReactNode;
|
|
52
|
+
open?: boolean;
|
|
53
|
+
onOpenChange?: (open: boolean) => void;
|
|
54
|
+
}) {
|
|
55
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
56
|
+
const open = openProp ?? uncontrolledOpen;
|
|
57
|
+
const setOpen = useCallback(
|
|
58
|
+
(next: boolean) => {
|
|
59
|
+
setUncontrolledOpen(next);
|
|
60
|
+
onOpenChange?.(next);
|
|
61
|
+
},
|
|
62
|
+
[onOpenChange],
|
|
63
|
+
);
|
|
64
|
+
const titleId = useId();
|
|
65
|
+
const descriptionId = useId();
|
|
66
|
+
const value = useMemo(
|
|
67
|
+
() => ({ open, setOpen, titleId, descriptionId }),
|
|
68
|
+
[open, setOpen, titleId, descriptionId],
|
|
69
|
+
);
|
|
70
|
+
return <DialogContext value={value}>{children}</DialogContext>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function AlertDialogTrigger({
|
|
74
|
+
asChild = false,
|
|
75
|
+
...props
|
|
76
|
+
}: ComponentProps<"button"> & { asChild?: boolean }) {
|
|
77
|
+
const { setOpen } = useDialog();
|
|
78
|
+
const Comp = asChild ? Slot : "button";
|
|
79
|
+
return (
|
|
80
|
+
<Comp
|
|
81
|
+
type={asChild ? undefined : "button"}
|
|
82
|
+
aria-haspopup="dialog"
|
|
83
|
+
{...props}
|
|
84
|
+
onClick={() => setOpen(true)}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function AlertDialogContent({ className, children, ...props }: ComponentProps<"dialog">) {
|
|
90
|
+
const { open, setOpen, titleId, descriptionId } = useDialog();
|
|
91
|
+
const ref = useRef<HTMLDialogElement>(null);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const dialog = ref.current;
|
|
95
|
+
if (!dialog) return;
|
|
96
|
+
if (open && !dialog.open) dialog.showModal();
|
|
97
|
+
if (!open && dialog.open) dialog.close();
|
|
98
|
+
}, [open]);
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<dialog
|
|
102
|
+
ref={ref}
|
|
103
|
+
role="alertdialog"
|
|
104
|
+
aria-labelledby={titleId}
|
|
105
|
+
aria-describedby={descriptionId}
|
|
106
|
+
data-slot="alert-dialog-content"
|
|
107
|
+
className={cn(classes.content, className)}
|
|
108
|
+
// Escape: close through state so the parent stays in sync.
|
|
109
|
+
onCancel={(e) => {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
setOpen(false);
|
|
112
|
+
}}
|
|
113
|
+
onClose={() => open && setOpen(false)}
|
|
114
|
+
{...props}
|
|
115
|
+
>
|
|
116
|
+
{open && <div className={classes.inner}>{children}</div>}
|
|
117
|
+
</dialog>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function AlertDialogHeader({ className, ...props }: ComponentProps<"div">) {
|
|
122
|
+
return <div data-slot="alert-dialog-header" className={cn(classes.header, className)} {...props} />;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function AlertDialogFooter({ className, ...props }: ComponentProps<"div">) {
|
|
126
|
+
return <div data-slot="alert-dialog-footer" className={cn(classes.footer, className)} {...props} />;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function AlertDialogTitle({ className, ...props }: ComponentProps<"h2">) {
|
|
130
|
+
const { titleId } = useDialog();
|
|
131
|
+
return <h2 id={titleId} className={cn(classes.title, className)} {...props} />;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function AlertDialogDescription({ className, ...props }: ComponentProps<"p">) {
|
|
135
|
+
const { descriptionId } = useDialog();
|
|
136
|
+
return <p id={descriptionId} className={cn(classes.description, className)} {...props} />;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
type ActionProps = Omit<ComponentProps<"button">, "onClick"> & {
|
|
140
|
+
variant?: ButtonVariant;
|
|
141
|
+
size?: ButtonSize;
|
|
142
|
+
/** Call event.preventDefault() to keep the dialog open (e.g. while a request runs). */
|
|
143
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export function AlertDialogAction({ variant = "default", onClick, ...props }: ActionProps) {
|
|
147
|
+
const { setOpen } = useDialog();
|
|
148
|
+
return (
|
|
149
|
+
<Button
|
|
150
|
+
variant={variant}
|
|
151
|
+
onClick={(e) => {
|
|
152
|
+
onClick?.(e);
|
|
153
|
+
if (!e.defaultPrevented) setOpen(false);
|
|
154
|
+
}}
|
|
155
|
+
{...props}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function AlertDialogCancel({ variant = "outline", onClick, ...props }: ActionProps) {
|
|
161
|
+
const { setOpen } = useDialog();
|
|
162
|
+
return (
|
|
163
|
+
<Button
|
|
164
|
+
variant={variant}
|
|
165
|
+
onClick={(e) => {
|
|
166
|
+
onClick?.(e);
|
|
167
|
+
setOpen(false);
|
|
168
|
+
}}
|
|
169
|
+
{...props}
|
|
170
|
+
/>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
export function Avatar({
|
|
6
|
+
className,
|
|
7
|
+
size = "default",
|
|
8
|
+
...props
|
|
9
|
+
}: ComponentProps<"span"> & { size?: "sm" | "default" | "lg" }) {
|
|
10
|
+
return (
|
|
11
|
+
<span data-slot="avatar" className={cn("avatar", `avatar--${size}`, className)} {...props} />
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function AvatarFallback({ className, ...props }: ComponentProps<"span">) {
|
|
16
|
+
return <span data-slot="avatar-fallback" className={cn("avatar-fallback", className)} {...props} />;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
export function Badge({
|
|
6
|
+
className,
|
|
7
|
+
variant = "default",
|
|
8
|
+
...props
|
|
9
|
+
}: ComponentProps<"span"> & { variant?: "default" | "secondary" | "destructive" | "outline" }) {
|
|
10
|
+
return (
|
|
11
|
+
<span
|
|
12
|
+
data-slot="badge"
|
|
13
|
+
data-variant={variant}
|
|
14
|
+
className={cn("badge", `badge--${variant}`, className)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { Slot } from "@/components/ui/slot";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
export type ButtonVariant = "default" | "outline" | "secondary" | "ghost" | "destructive" | "link";
|
|
7
|
+
export type ButtonSize = "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg";
|
|
8
|
+
|
|
9
|
+
/** Class names for a button look (styles live in src/app/globals.css or src/index.css). */
|
|
10
|
+
export function buttonVariants({
|
|
11
|
+
variant = "default",
|
|
12
|
+
size = "default",
|
|
13
|
+
className,
|
|
14
|
+
}: { variant?: ButtonVariant; size?: ButtonSize; className?: string } = {}) {
|
|
15
|
+
return cn("btn", `btn--${variant}`, `btn--size-${size}`, className);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type ButtonProps = ComponentProps<"button"> & {
|
|
19
|
+
variant?: ButtonVariant;
|
|
20
|
+
size?: ButtonSize;
|
|
21
|
+
/** Render the child element (e.g. a <Link>) with button styles instead of a <button>. */
|
|
22
|
+
asChild?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function Button({
|
|
26
|
+
variant = "default",
|
|
27
|
+
size = "default",
|
|
28
|
+
asChild = false,
|
|
29
|
+
className,
|
|
30
|
+
...props
|
|
31
|
+
}: ButtonProps) {
|
|
32
|
+
const Comp = asChild ? Slot : "button";
|
|
33
|
+
return (
|
|
34
|
+
<Comp
|
|
35
|
+
data-slot="button"
|
|
36
|
+
data-variant={variant}
|
|
37
|
+
className={buttonVariants({ variant, size, className })}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
export function Card({ className, ...props }: ComponentProps<"div">) {
|
|
6
|
+
return <div data-slot="card" className={cn("card", className)} {...props} />;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function CardHeader({ className, ...props }: ComponentProps<"div">) {
|
|
10
|
+
return <div data-slot="card-header" className={cn("card-header", className)} {...props} />;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function CardTitle({ className, ...props }: ComponentProps<"div">) {
|
|
14
|
+
return <div data-slot="card-title" className={cn("card-title", className)} {...props} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function CardDescription({ className, ...props }: ComponentProps<"div">) {
|
|
18
|
+
return (
|
|
19
|
+
<div data-slot="card-description" className={cn("card-description", className)} {...props} />
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function CardAction({ className, ...props }: ComponentProps<"div">) {
|
|
24
|
+
return <div data-slot="card-action" className={cn("card-action", className)} {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function CardContent({ className, ...props }: ComponentProps<"div">) {
|
|
28
|
+
return <div data-slot="card-content" className={cn("card-content", className)} {...props} />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function CardFooter({ className, ...props }: ComponentProps<"div">) {
|
|
32
|
+
return <div data-slot="card-footer" className={cn("card-footer", className)} {...props} />;
|
|
33
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
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 KeyboardEvent,
|
|
14
|
+
type MouseEvent,
|
|
15
|
+
type ReactNode,
|
|
16
|
+
type RefObject,
|
|
17
|
+
} from "react";
|
|
18
|
+
|
|
19
|
+
import { Slot } from "@/components/ui/slot";
|
|
20
|
+
import { cn } from "@/lib/utils";
|
|
21
|
+
|
|
22
|
+
const classes = {
|
|
23
|
+
root: "menu",
|
|
24
|
+
content: "menu-content",
|
|
25
|
+
alignStart: "menu-content--start",
|
|
26
|
+
alignEnd: "menu-content--end",
|
|
27
|
+
sideBottom: "menu-content--bottom",
|
|
28
|
+
sideTop: "menu-content--top",
|
|
29
|
+
item: "menu-item",
|
|
30
|
+
label: "menu-label",
|
|
31
|
+
separator: "menu-separator",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
type MenuContextValue = {
|
|
35
|
+
open: boolean;
|
|
36
|
+
setOpen: (open: boolean) => void;
|
|
37
|
+
triggerRef: RefObject<HTMLButtonElement | null>;
|
|
38
|
+
contentId: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const MenuContext = createContext<MenuContextValue | null>(null);
|
|
42
|
+
|
|
43
|
+
function useMenu() {
|
|
44
|
+
const ctx = use(MenuContext);
|
|
45
|
+
if (!ctx) throw new Error("DropdownMenu parts must be used inside <DropdownMenu>");
|
|
46
|
+
return ctx;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A dependency-free dropdown menu with the same API as shadcn/ui's (the parts this app uses). */
|
|
50
|
+
export function DropdownMenu({
|
|
51
|
+
children,
|
|
52
|
+
open: openProp,
|
|
53
|
+
onOpenChange,
|
|
54
|
+
}: {
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
open?: boolean;
|
|
57
|
+
onOpenChange?: (open: boolean) => void;
|
|
58
|
+
}) {
|
|
59
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
60
|
+
const open = openProp ?? uncontrolledOpen;
|
|
61
|
+
const setOpen = useCallback(
|
|
62
|
+
(next: boolean) => {
|
|
63
|
+
setUncontrolledOpen(next);
|
|
64
|
+
onOpenChange?.(next);
|
|
65
|
+
},
|
|
66
|
+
[onOpenChange],
|
|
67
|
+
);
|
|
68
|
+
// Typed as a button, but with asChild it may point at any element (e.g. a link).
|
|
69
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
70
|
+
const contentId = useId();
|
|
71
|
+
const value = useMemo(() => ({ open, setOpen, triggerRef, contentId }), [open, setOpen, contentId]);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<MenuContext value={value}>
|
|
75
|
+
<div data-slot="dropdown-menu" className={classes.root}>
|
|
76
|
+
{children}
|
|
77
|
+
</div>
|
|
78
|
+
</MenuContext>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function DropdownMenuTrigger({
|
|
83
|
+
asChild = false,
|
|
84
|
+
...props
|
|
85
|
+
}: ComponentProps<"button"> & { asChild?: boolean }) {
|
|
86
|
+
const { open, setOpen, triggerRef, contentId } = useMenu();
|
|
87
|
+
const Comp = asChild ? Slot : "button";
|
|
88
|
+
return (
|
|
89
|
+
<Comp
|
|
90
|
+
ref={triggerRef}
|
|
91
|
+
type={asChild ? undefined : "button"}
|
|
92
|
+
aria-haspopup="menu"
|
|
93
|
+
aria-expanded={open}
|
|
94
|
+
aria-controls={open ? contentId : undefined}
|
|
95
|
+
data-state={open ? "open" : "closed"}
|
|
96
|
+
{...props}
|
|
97
|
+
onClick={() => setOpen(!open)}
|
|
98
|
+
onKeyDown={(e: KeyboardEvent) => {
|
|
99
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
setOpen(true);
|
|
102
|
+
}
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function menuItems(container: HTMLElement | null) {
|
|
109
|
+
return Array.from(
|
|
110
|
+
container?.querySelectorAll<HTMLElement>('[role="menuitem"]:not([aria-disabled="true"])') ?? [],
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function DropdownMenuContent({
|
|
115
|
+
className,
|
|
116
|
+
align = "start",
|
|
117
|
+
side = "bottom",
|
|
118
|
+
children,
|
|
119
|
+
...props
|
|
120
|
+
}: ComponentProps<"div"> & { align?: "start" | "center" | "end"; side?: "top" | "bottom" }) {
|
|
121
|
+
const { open, setOpen, triggerRef, contentId } = useMenu();
|
|
122
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (!open) return;
|
|
126
|
+
menuItems(ref.current)[0]?.focus();
|
|
127
|
+
|
|
128
|
+
const onPointerDown = (e: PointerEvent) => {
|
|
129
|
+
const target = e.target as Node;
|
|
130
|
+
if (!ref.current?.contains(target) && !triggerRef.current?.contains(target)) setOpen(false);
|
|
131
|
+
};
|
|
132
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
133
|
+
return () => document.removeEventListener("pointerdown", onPointerDown);
|
|
134
|
+
}, [open, setOpen, triggerRef]);
|
|
135
|
+
|
|
136
|
+
if (!open) return null;
|
|
137
|
+
|
|
138
|
+
function onKeyDown(e: KeyboardEvent<HTMLDivElement>) {
|
|
139
|
+
const items = menuItems(ref.current);
|
|
140
|
+
const index = items.indexOf(document.activeElement as HTMLElement);
|
|
141
|
+
const focus = (i: number) => items[(i + items.length) % items.length]?.focus();
|
|
142
|
+
if (e.key === "ArrowDown") focus(index + 1);
|
|
143
|
+
else if (e.key === "ArrowUp") focus(index - 1);
|
|
144
|
+
else if (e.key === "Home") focus(0);
|
|
145
|
+
else if (e.key === "End") focus(items.length - 1);
|
|
146
|
+
else if (e.key === "Escape") {
|
|
147
|
+
setOpen(false);
|
|
148
|
+
triggerRef.current?.focus();
|
|
149
|
+
} else if (e.key === "Tab") setOpen(false);
|
|
150
|
+
else return;
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<div
|
|
156
|
+
ref={ref}
|
|
157
|
+
id={contentId}
|
|
158
|
+
role="menu"
|
|
159
|
+
data-slot="dropdown-menu-content"
|
|
160
|
+
className={cn(
|
|
161
|
+
classes.content,
|
|
162
|
+
align === "end" ? classes.alignEnd : classes.alignStart,
|
|
163
|
+
side === "top" ? classes.sideTop : classes.sideBottom,
|
|
164
|
+
className,
|
|
165
|
+
)}
|
|
166
|
+
onKeyDown={onKeyDown}
|
|
167
|
+
{...props}
|
|
168
|
+
>
|
|
169
|
+
{children}
|
|
170
|
+
</div>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function DropdownMenuGroup(props: ComponentProps<"div">) {
|
|
175
|
+
return <div role="group" data-slot="dropdown-menu-group" {...props} />;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function DropdownMenuItem({
|
|
179
|
+
className,
|
|
180
|
+
variant = "default",
|
|
181
|
+
disabled = false,
|
|
182
|
+
asChild = false,
|
|
183
|
+
onSelect,
|
|
184
|
+
onClick,
|
|
185
|
+
...props
|
|
186
|
+
}: Omit<ComponentProps<"button">, "onSelect"> & {
|
|
187
|
+
variant?: "default" | "destructive";
|
|
188
|
+
asChild?: boolean;
|
|
189
|
+
/** Called when the item is chosen. Call event.preventDefault() to keep the menu open. */
|
|
190
|
+
onSelect?: (event: MouseEvent) => void;
|
|
191
|
+
}) {
|
|
192
|
+
const { setOpen } = useMenu();
|
|
193
|
+
const Comp = asChild ? Slot : "button";
|
|
194
|
+
return (
|
|
195
|
+
<Comp
|
|
196
|
+
role="menuitem"
|
|
197
|
+
tabIndex={-1}
|
|
198
|
+
type={asChild ? undefined : "button"}
|
|
199
|
+
data-slot="dropdown-menu-item"
|
|
200
|
+
data-variant={variant}
|
|
201
|
+
aria-disabled={disabled || undefined}
|
|
202
|
+
className={cn(classes.item, className)}
|
|
203
|
+
onClick={(e: MouseEvent) => {
|
|
204
|
+
if (disabled) {
|
|
205
|
+
e.preventDefault();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
onClick?.(e as MouseEvent<HTMLButtonElement>);
|
|
209
|
+
onSelect?.(e);
|
|
210
|
+
if (!e.defaultPrevented || asChild) setOpen(false);
|
|
211
|
+
}}
|
|
212
|
+
{...props}
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function DropdownMenuLabel({ className, ...props }: ComponentProps<"div">) {
|
|
218
|
+
return <div data-slot="dropdown-menu-label" className={cn(classes.label, className)} {...props} />;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function DropdownMenuSeparator({ className, ...props }: ComponentProps<"div">) {
|
|
222
|
+
return (
|
|
223
|
+
<div
|
|
224
|
+
role="separator"
|
|
225
|
+
data-slot="dropdown-menu-separator"
|
|
226
|
+
className={cn(classes.separator, className)}
|
|
227
|
+
{...props}
|
|
228
|
+
/>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChevronDown } from "lucide-react";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
type NativeSelectProps = Omit<ComponentProps<"select">, "size"> & { size?: "sm" | "default" };
|
|
7
|
+
|
|
8
|
+
export function NativeSelect({ className, size = "default", ...props }: NativeSelectProps) {
|
|
9
|
+
return (
|
|
10
|
+
<div data-slot="native-select-wrapper" className={cn("select", className)}>
|
|
11
|
+
<select
|
|
12
|
+
data-slot="native-select"
|
|
13
|
+
className={cn("select-control", size === "sm" && "select-control--sm")}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
<ChevronDown aria-hidden className="select-icon" size={16} />
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function NativeSelectOption(props: ComponentProps<"option">) {
|
|
22
|
+
return <option data-slot="native-select-option" {...props} />;
|
|
23
|
+
}
|