create-mohit-next 0.0.0-stage → 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.
Files changed (202) hide show
  1. package/README.md +139 -2
  2. package/index.js +399 -0
  3. package/lib/features.js +358 -0
  4. package/lib/scaffold.js +471 -0
  5. package/package.json +40 -4
  6. package/templates/common/_editorconfig +12 -0
  7. package/templates/common/_gitattributes +5 -0
  8. package/templates/common/_github/dependabot.yml +14 -0
  9. package/templates/common/_github/workflows/ci.yml +66 -0
  10. package/templates/common/_husky/commit-msg +1 -0
  11. package/templates/common/_husky/pre-commit +1 -0
  12. package/templates/common/_nvmrc +1 -0
  13. package/templates/common/_prettierignore +15 -0
  14. package/templates/common/commitlint.config.mjs +10 -0
  15. package/templates/next/AGENTS.md +9 -0
  16. package/templates/next/Dockerfile +48 -0
  17. package/templates/next/README.md +328 -0
  18. package/templates/next/_dockerignore +13 -0
  19. package/templates/next/_env.example +20 -0
  20. package/templates/next/_gitignore +50 -0
  21. package/templates/next/docker-compose.yml +33 -0
  22. package/templates/next/e2e/rbac.spec.ts +69 -0
  23. package/templates/next/e2e/server.mjs +35 -0
  24. package/templates/next/eslint.config.mjs +33 -0
  25. package/templates/next/next.config.ts +47 -0
  26. package/templates/next/package.json +68 -0
  27. package/templates/next/playwright.config.ts +30 -0
  28. package/templates/next/public/robots.txt +6 -0
  29. package/templates/next/scripts/seed.ts +111 -0
  30. package/templates/next/src/app/(app)/admin/audit/page.tsx +99 -0
  31. package/templates/next/src/app/(app)/admin/page.tsx +92 -0
  32. package/templates/next/src/app/(app)/dashboard/page.tsx +120 -0
  33. package/templates/next/src/app/(app)/error.tsx +28 -0
  34. package/templates/next/src/app/(app)/layout.tsx +58 -0
  35. package/templates/next/src/app/(app)/loading.tsx +5 -0
  36. package/templates/next/src/app/(app)/reports/page.tsx +128 -0
  37. package/templates/next/src/app/(app)/settings/page.tsx +66 -0
  38. package/templates/next/src/app/(auth)/forgot-password/page.tsx +17 -0
  39. package/templates/next/src/app/(auth)/layout.tsx +18 -0
  40. package/templates/next/src/app/(auth)/login/page.tsx +18 -0
  41. package/templates/next/src/app/(auth)/register/page.tsx +18 -0
  42. package/templates/next/src/app/(auth)/reset-password/page.tsx +18 -0
  43. package/templates/next/src/app/api/account/password/route.ts +45 -0
  44. package/templates/next/src/app/api/account/route.ts +25 -0
  45. package/templates/next/src/app/api/account/sessions/route.ts +12 -0
  46. package/templates/next/src/app/api/admin/audit/route.ts +13 -0
  47. package/templates/next/src/app/api/admin/users/[id]/route.ts +61 -0
  48. package/templates/next/src/app/api/admin/users/route.ts +18 -0
  49. package/templates/next/src/app/api/auth/forgot-password/route.ts +47 -0
  50. package/templates/next/src/app/api/auth/login/route.ts +43 -0
  51. package/templates/next/src/app/api/auth/logout/route.ts +21 -0
  52. package/templates/next/src/app/api/auth/me/route.ts +21 -0
  53. package/templates/next/src/app/api/auth/register/route.ts +74 -0
  54. package/templates/next/src/app/api/auth/resend-verification/route.ts +25 -0
  55. package/templates/next/src/app/api/auth/reset-password/route.ts +43 -0
  56. package/templates/next/src/app/api/auth/verify-email/route.ts +29 -0
  57. package/templates/next/src/app/api/health/route.ts +27 -0
  58. package/templates/next/src/app/favicon.ico +0 -0
  59. package/templates/next/src/app/forbidden/page.tsx +47 -0
  60. package/templates/next/src/app/layout.tsx +55 -0
  61. package/templates/next/src/app/not-found.tsx +20 -0
  62. package/templates/next/src/app/opengraph-image.tsx +49 -0
  63. package/templates/next/src/app/page.tsx +165 -0
  64. package/templates/next/src/app/robots.ts +15 -0
  65. package/templates/next/src/app/sitemap.ts +13 -0
  66. package/templates/next/src/app/verify-email/page.tsx +23 -0
  67. package/templates/next/src/components/admin/user-actions.tsx +124 -0
  68. package/templates/next/src/components/admin/users-data-table.tsx +221 -0
  69. package/templates/next/src/components/admin/users-table.tsx +67 -0
  70. package/templates/next/src/components/auth/auth-card.tsx +41 -0
  71. package/templates/next/src/components/auth/can.tsx +34 -0
  72. package/templates/next/src/components/auth/forgot-password-form.tsx +76 -0
  73. package/templates/next/src/components/auth/form-field.tsx +40 -0
  74. package/templates/next/src/components/auth/login-form.tsx +87 -0
  75. package/templates/next/src/components/auth/password-input.tsx +43 -0
  76. package/templates/next/src/components/auth/register-form.tsx +117 -0
  77. package/templates/next/src/components/auth/reset-password-form.tsx +80 -0
  78. package/templates/next/src/components/auth/session-refresher.tsx +44 -0
  79. package/templates/next/src/components/auth/verify-email-banner.tsx +43 -0
  80. package/templates/next/src/components/auth/verify-email-status.tsx +44 -0
  81. package/templates/next/src/components/layout/nav-links.tsx +37 -0
  82. package/templates/next/src/components/layout/navbar.tsx +27 -0
  83. package/templates/next/src/components/layout/page-header.tsx +21 -0
  84. package/templates/next/src/components/layout/sidebar.tsx +83 -0
  85. package/templates/next/src/components/layout/skeletons.tsx +57 -0
  86. package/templates/next/src/components/layout/user-menu.tsx +118 -0
  87. package/templates/next/src/components/logo.tsx +16 -0
  88. package/templates/next/src/components/motion/fade-in.tsx +19 -0
  89. package/templates/next/src/components/providers/user-provider.tsx +60 -0
  90. package/templates/next/src/components/reports/animated-bar.tsx +24 -0
  91. package/templates/next/src/components/reports/role-chart.tsx +61 -0
  92. package/templates/next/src/components/reports/signups-chart.tsx +64 -0
  93. package/templates/next/src/components/role-badge.tsx +11 -0
  94. package/templates/next/src/components/settings/password-form.tsx +80 -0
  95. package/templates/next/src/components/settings/profile-form.tsx +63 -0
  96. package/templates/next/src/components/settings/sessions-card.tsx +70 -0
  97. package/templates/next/src/components/theme-toggle.tsx +61 -0
  98. package/templates/next/src/config/rbac.test.ts +89 -0
  99. package/templates/next/src/config/rbac.ts +170 -0
  100. package/templates/next/src/config/site.ts +4 -0
  101. package/templates/next/src/lib/api.ts +179 -0
  102. package/templates/next/src/lib/audit.ts +66 -0
  103. package/templates/next/src/lib/auth.ts +50 -0
  104. package/templates/next/src/lib/dal.ts +63 -0
  105. package/templates/next/src/lib/db.ts +35 -0
  106. package/templates/next/src/lib/email-templates.ts +55 -0
  107. package/templates/next/src/lib/email.ts +53 -0
  108. package/templates/next/src/lib/env.ts +90 -0
  109. package/templates/next/src/lib/http.ts +57 -0
  110. package/templates/next/src/lib/password-strength.test.ts +20 -0
  111. package/templates/next/src/lib/password-strength.ts +24 -0
  112. package/templates/next/src/lib/rate-limit.test.ts +47 -0
  113. package/templates/next/src/lib/rate-limit.ts +70 -0
  114. package/templates/next/src/lib/redirect.test.ts +23 -0
  115. package/templates/next/src/lib/redirect.ts +21 -0
  116. package/templates/next/src/lib/session.ts +71 -0
  117. package/templates/next/src/lib/theme.ts +32 -0
  118. package/templates/next/src/lib/tokens.ts +63 -0
  119. package/templates/next/src/lib/users.ts +196 -0
  120. package/templates/next/src/lib/validations/account.ts +20 -0
  121. package/templates/next/src/lib/validations/auth.test.ts +39 -0
  122. package/templates/next/src/lib/validations/auth.ts +66 -0
  123. package/templates/next/src/lib/validations/user.ts +13 -0
  124. package/templates/next/src/models/audit-log.ts +33 -0
  125. package/templates/next/src/models/auth-token.ts +26 -0
  126. package/templates/next/src/models/user.ts +35 -0
  127. package/templates/next/src/proxy.ts +57 -0
  128. package/templates/next/src/styles/app.css +1092 -0
  129. package/templates/next/src/types/user.ts +13 -0
  130. package/templates/next/tsconfig.json +34 -0
  131. package/templates/next/vitest.config.mts +13 -0
  132. package/templates/styles/css.css +580 -0
  133. package/templates/styles/shadcn.css +142 -0
  134. package/templates/styles/tailwind.css +140 -0
  135. package/templates/ui/css/components/alert-dialog.tsx +172 -0
  136. package/templates/ui/css/components/avatar.tsx +17 -0
  137. package/templates/ui/css/components/badge.tsx +18 -0
  138. package/templates/ui/css/components/button.tsx +41 -0
  139. package/templates/ui/css/components/card.tsx +33 -0
  140. package/templates/ui/css/components/dropdown-menu.tsx +230 -0
  141. package/templates/ui/css/components/input.tsx +7 -0
  142. package/templates/ui/css/components/label.tsx +7 -0
  143. package/templates/ui/css/components/native-select.tsx +23 -0
  144. package/templates/ui/css/components/skeleton.tsx +7 -0
  145. package/templates/ui/css/components/slot.tsx +30 -0
  146. package/templates/ui/css/components/table.tsx +31 -0
  147. package/templates/ui/css/utils.ts +16 -0
  148. package/templates/ui/shadcn/components/alert-dialog.tsx +199 -0
  149. package/templates/ui/shadcn/components/avatar.tsx +111 -0
  150. package/templates/ui/shadcn/components/badge.tsx +44 -0
  151. package/templates/ui/shadcn/components/button.tsx +66 -0
  152. package/templates/ui/shadcn/components/card.tsx +87 -0
  153. package/templates/ui/shadcn/components/dropdown-menu.tsx +268 -0
  154. package/templates/ui/shadcn/components/input.tsx +18 -0
  155. package/templates/ui/shadcn/components/label.tsx +20 -0
  156. package/templates/ui/shadcn/components/native-select.tsx +54 -0
  157. package/templates/ui/shadcn/components/skeleton.tsx +13 -0
  158. package/templates/ui/shadcn/components/table.tsx +115 -0
  159. package/templates/ui/shadcn/utils.ts +1 -0
  160. package/templates/ui/tailwind/components/alert-dialog.tsx +177 -0
  161. package/templates/ui/tailwind/components/avatar.tsx +36 -0
  162. package/templates/ui/tailwind/components/badge.tsx +29 -0
  163. package/templates/ui/tailwind/components/button.tsx +65 -0
  164. package/templates/ui/tailwind/components/card.tsx +70 -0
  165. package/templates/ui/tailwind/components/dropdown-menu.tsx +236 -0
  166. package/templates/ui/tailwind/components/input.tsx +17 -0
  167. package/templates/ui/tailwind/components/label.tsx +16 -0
  168. package/templates/ui/tailwind/components/native-select.tsx +32 -0
  169. package/templates/ui/tailwind/components/skeleton.tsx +13 -0
  170. package/templates/ui/tailwind/components/slot.tsx +34 -0
  171. package/templates/ui/tailwind/components/table.tsx +56 -0
  172. package/templates/ui/tailwind/utils.ts +1 -0
  173. package/templates/vite/Dockerfile +29 -0
  174. package/templates/vite/README.md +142 -0
  175. package/templates/vite/_dockerignore +14 -0
  176. package/templates/vite/_env.example +8 -0
  177. package/templates/vite/_gitignore +37 -0
  178. package/templates/vite/e2e/app.spec.ts +41 -0
  179. package/templates/vite/index.html +32 -0
  180. package/templates/vite/nginx.conf +26 -0
  181. package/templates/vite/package.json +61 -0
  182. package/templates/vite/playwright.config.ts +27 -0
  183. package/templates/vite/public/favicon.svg +1 -0
  184. package/templates/vite/src/App.test.tsx +28 -0
  185. package/templates/vite/src/App.tsx +26 -0
  186. package/templates/vite/src/components/home.tsx +121 -0
  187. package/templates/vite/src/components/layout/root-layout.tsx +18 -0
  188. package/templates/vite/src/components/layout/site-footer.tsx +10 -0
  189. package/templates/vite/src/components/layout/site-header.tsx +49 -0
  190. package/templates/vite/src/components/theme-toggle.tsx +90 -0
  191. package/templates/vite/src/env.ts +36 -0
  192. package/templates/vite/src/lib/theme.ts +26 -0
  193. package/templates/vite/src/main.tsx +13 -0
  194. package/templates/vite/src/pages/about.tsx +52 -0
  195. package/templates/vite/src/pages/not-found.tsx +33 -0
  196. package/templates/vite/src/router.ts +24 -0
  197. package/templates/vite/src/styles/app.css +281 -0
  198. package/templates/vite/src/test/setup.ts +21 -0
  199. package/templates/vite/tsconfig.app.json +31 -0
  200. package/templates/vite/tsconfig.json +7 -0
  201. package/templates/vite/tsconfig.node.json +23 -0
  202. package/templates/vite/vite.config.ts +30 -0
@@ -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,7 @@
1
+ import type { ComponentProps } from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ export function Input({ className, type, ...props }: ComponentProps<"input">) {
6
+ return <input type={type} data-slot="input" className={cn("input", className)} {...props} />;
7
+ }
@@ -0,0 +1,7 @@
1
+ import type { ComponentProps } from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ export function Label({ className, ...props }: ComponentProps<"label">) {
6
+ return <label data-slot="label" className={cn("label", className)} {...props} />;
7
+ }
@@ -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
+ }
@@ -0,0 +1,7 @@
1
+ import type { ComponentProps } from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ export function Skeleton({ className, ...props }: ComponentProps<"div">) {
6
+ return <div data-slot="skeleton" className={cn("skeleton", className)} {...props} />;
7
+ }
@@ -0,0 +1,30 @@
1
+ import { cloneElement, isValidElement, type ReactElement, type ReactNode } from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ type AnyProps = Record<string, unknown>;
6
+
7
+ /**
8
+ * Renders its only child, merging the given props into it (like Radix's Slot).
9
+ * Used for `asChild`: <Button asChild><Link href="/">Home</Link></Button>.
10
+ */
11
+ export function Slot({ children, ...props }: AnyProps & { children?: ReactNode }) {
12
+ if (!isValidElement(children)) return null;
13
+ const child = children as ReactElement<AnyProps>;
14
+ const childProps = child.props;
15
+ const merged: AnyProps = { ...props, ...childProps };
16
+
17
+ // Compose event handlers so both the slot's and the child's run.
18
+ for (const key of Object.keys(props)) {
19
+ const slotHandler = props[key];
20
+ const childHandler = childProps[key];
21
+ if (/^on[A-Z]/.test(key) && typeof slotHandler === "function" && typeof childHandler === "function") {
22
+ merged[key] = (...args: unknown[]) => {
23
+ childHandler(...args);
24
+ slotHandler(...args);
25
+ };
26
+ }
27
+ }
28
+ merged.className = cn(props.className as string, childProps.className as string);
29
+ return cloneElement(child, merged);
30
+ }
@@ -0,0 +1,31 @@
1
+ import type { ComponentProps } from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ export function Table({ className, ...props }: ComponentProps<"table">) {
6
+ return (
7
+ <div data-slot="table-container" className="table-container">
8
+ <table data-slot="table" className={cn("table", className)} {...props} />
9
+ </div>
10
+ );
11
+ }
12
+
13
+ export function TableHeader(props: ComponentProps<"thead">) {
14
+ return <thead data-slot="table-header" {...props} />;
15
+ }
16
+
17
+ export function TableBody(props: ComponentProps<"tbody">) {
18
+ return <tbody data-slot="table-body" {...props} />;
19
+ }
20
+
21
+ export function TableRow(props: ComponentProps<"tr">) {
22
+ return <tr data-slot="table-row" {...props} />;
23
+ }
24
+
25
+ export function TableHead(props: ComponentProps<"th">) {
26
+ return <th data-slot="table-head" {...props} />;
27
+ }
28
+
29
+ export function TableCell(props: ComponentProps<"td">) {
30
+ return <td data-slot="table-cell" {...props} />;
31
+ }
@@ -0,0 +1,16 @@
1
+ type ClassValue = string | number | false | null | undefined | ClassValue[];
2
+
3
+ /** Joins class names, skipping falsy values (a tiny clsx). */
4
+ export function cn(...values: ClassValue[]): string {
5
+ const out: string[] = [];
6
+ for (const value of values) {
7
+ if (!value) continue;
8
+ if (Array.isArray(value)) {
9
+ const nested = cn(...value);
10
+ if (nested) out.push(nested);
11
+ } else {
12
+ out.push(String(value));
13
+ }
14
+ }
15
+ return out.join(" ");
16
+ }
@@ -0,0 +1,199 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cn } from "@/lib/utils"
5
+ import { AlertDialog as AlertDialogPrimitive } from "radix-ui"
6
+
7
+ import { Button } from "@/components/ui/button"
8
+
9
+ function AlertDialog({
10
+ ...props
11
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
12
+ return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
13
+ }
14
+
15
+ function AlertDialogTrigger({
16
+ ...props
17
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
18
+ return (
19
+ <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
20
+ )
21
+ }
22
+
23
+ function AlertDialogPortal({
24
+ ...props
25
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>) {
26
+ return (
27
+ <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
28
+ )
29
+ }
30
+
31
+ function AlertDialogOverlay({
32
+ className,
33
+ ...props
34
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
35
+ return (
36
+ <AlertDialogPrimitive.Overlay
37
+ data-slot="alert-dialog-overlay"
38
+ className={cn(
39
+ "fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
40
+ className
41
+ )}
42
+ {...props}
43
+ />
44
+ )
45
+ }
46
+
47
+ function AlertDialogContent({
48
+ className,
49
+ size = "default",
50
+ ...props
51
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {
52
+ size?: "default" | "sm"
53
+ }) {
54
+ return (
55
+ <AlertDialogPortal>
56
+ <AlertDialogOverlay />
57
+ <AlertDialogPrimitive.Content
58
+ data-slot="alert-dialog-content"
59
+ data-size={size}
60
+ className={cn(
61
+ "group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
62
+ className
63
+ )}
64
+ {...props}
65
+ />
66
+ </AlertDialogPortal>
67
+ )
68
+ }
69
+
70
+ function AlertDialogHeader({
71
+ className,
72
+ ...props
73
+ }: React.ComponentProps<"div">) {
74
+ return (
75
+ <div
76
+ data-slot="alert-dialog-header"
77
+ className={cn(
78
+ "grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
79
+ className
80
+ )}
81
+ {...props}
82
+ />
83
+ )
84
+ }
85
+
86
+ function AlertDialogFooter({
87
+ className,
88
+ ...props
89
+ }: React.ComponentProps<"div">) {
90
+ return (
91
+ <div
92
+ data-slot="alert-dialog-footer"
93
+ className={cn(
94
+ "-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
95
+ className
96
+ )}
97
+ {...props}
98
+ />
99
+ )
100
+ }
101
+
102
+ function AlertDialogMedia({
103
+ className,
104
+ ...props
105
+ }: React.ComponentProps<"div">) {
106
+ return (
107
+ <div
108
+ data-slot="alert-dialog-media"
109
+ className={cn(
110
+ "mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",
111
+ className
112
+ )}
113
+ {...props}
114
+ />
115
+ )
116
+ }
117
+
118
+ function AlertDialogTitle({
119
+ className,
120
+ ...props
121
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
122
+ return (
123
+ <AlertDialogPrimitive.Title
124
+ data-slot="alert-dialog-title"
125
+ className={cn(
126
+ "font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
127
+ className
128
+ )}
129
+ {...props}
130
+ />
131
+ )
132
+ }
133
+
134
+ function AlertDialogDescription({
135
+ className,
136
+ ...props
137
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
138
+ return (
139
+ <AlertDialogPrimitive.Description
140
+ data-slot="alert-dialog-description"
141
+ className={cn(
142
+ "text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
143
+ className
144
+ )}
145
+ {...props}
146
+ />
147
+ )
148
+ }
149
+
150
+ function AlertDialogAction({
151
+ className,
152
+ variant = "default",
153
+ size = "default",
154
+ ...props
155
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Action> &
156
+ Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
157
+ return (
158
+ <Button variant={variant} size={size} asChild>
159
+ <AlertDialogPrimitive.Action
160
+ data-slot="alert-dialog-action"
161
+ className={cn(className)}
162
+ {...props}
163
+ />
164
+ </Button>
165
+ )
166
+ }
167
+
168
+ function AlertDialogCancel({
169
+ className,
170
+ variant = "outline",
171
+ size = "default",
172
+ ...props
173
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> &
174
+ Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
175
+ return (
176
+ <Button variant={variant} size={size} asChild>
177
+ <AlertDialogPrimitive.Cancel
178
+ data-slot="alert-dialog-cancel"
179
+ className={cn(className)}
180
+ {...props}
181
+ />
182
+ </Button>
183
+ )
184
+ }
185
+
186
+ export {
187
+ AlertDialog,
188
+ AlertDialogAction,
189
+ AlertDialogCancel,
190
+ AlertDialogContent,
191
+ AlertDialogDescription,
192
+ AlertDialogFooter,
193
+ AlertDialogHeader,
194
+ AlertDialogMedia,
195
+ AlertDialogOverlay,
196
+ AlertDialogPortal,
197
+ AlertDialogTitle,
198
+ AlertDialogTrigger,
199
+ }
@@ -0,0 +1,111 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cn } from "@/lib/utils"
5
+ import { Avatar as AvatarPrimitive } from "radix-ui"
6
+
7
+ function Avatar({
8
+ className,
9
+ size = "default",
10
+ ...props
11
+ }: React.ComponentProps<typeof AvatarPrimitive.Root> & {
12
+ size?: "default" | "sm" | "lg"
13
+ }) {
14
+ return (
15
+ <AvatarPrimitive.Root
16
+ data-slot="avatar"
17
+ data-size={size}
18
+ className={cn(
19
+ "group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
20
+ className
21
+ )}
22
+ {...props}
23
+ />
24
+ )
25
+ }
26
+
27
+ function AvatarImage({
28
+ className,
29
+ ...props
30
+ }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
31
+ return (
32
+ <AvatarPrimitive.Image
33
+ data-slot="avatar-image"
34
+ className={cn(
35
+ "aspect-square size-full rounded-full object-cover",
36
+ className
37
+ )}
38
+ {...props}
39
+ />
40
+ )
41
+ }
42
+
43
+ function AvatarFallback({
44
+ className,
45
+ ...props
46
+ }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
47
+ return (
48
+ <AvatarPrimitive.Fallback
49
+ data-slot="avatar-fallback"
50
+ className={cn(
51
+ "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
52
+ className
53
+ )}
54
+ {...props}
55
+ />
56
+ )
57
+ }
58
+
59
+ function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
60
+ return (
61
+ <span
62
+ data-slot="avatar-badge"
63
+ className={cn(
64
+ "absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",
65
+ "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
66
+ "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
67
+ "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
68
+ className
69
+ )}
70
+ {...props}
71
+ />
72
+ )
73
+ }
74
+
75
+ function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
76
+ return (
77
+ <div
78
+ data-slot="avatar-group"
79
+ className={cn(
80
+ "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
81
+ className
82
+ )}
83
+ {...props}
84
+ />
85
+ )
86
+ }
87
+
88
+ function AvatarGroupCount({
89
+ className,
90
+ ...props
91
+ }: React.ComponentProps<"div">) {
92
+ return (
93
+ <div
94
+ data-slot="avatar-group-count"
95
+ className={cn(
96
+ "relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
97
+ className
98
+ )}
99
+ {...props}
100
+ />
101
+ )
102
+ }
103
+
104
+ export {
105
+ Avatar,
106
+ AvatarImage,
107
+ AvatarFallback,
108
+ AvatarGroup,
109
+ AvatarGroupCount,
110
+ AvatarBadge,
111
+ }