@clubedge/create-clubedge-app 0.2.0 → 0.3.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 (154) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +50 -35
  3. package/bin/create.mjs +2 -466
  4. package/dist/cli/args.js +49 -0
  5. package/dist/cli/ui.js +85 -0
  6. package/dist/core/customize.js +56 -0
  7. package/dist/core/execute.js +60 -0
  8. package/dist/core/manifest.js +81 -0
  9. package/dist/core/plan.js +67 -0
  10. package/dist/core/source.js +107 -0
  11. package/dist/index.js +125 -0
  12. package/dist/package-info.js +8 -0
  13. package/dist/steps/git.js +11 -0
  14. package/dist/steps/install.js +19 -0
  15. package/dist/utils/fs.js +97 -0
  16. package/dist/utils/names.js +14 -0
  17. package/dist/utils/process.js +49 -0
  18. package/package.json +21 -5
  19. package/template/.dockerignore +8 -0
  20. package/template/.env.example +25 -0
  21. package/template/.gitattributes +6 -0
  22. package/template/.github/ISSUE_TEMPLATE/bug_report.yml +35 -0
  23. package/template/.github/ISSUE_TEMPLATE/config.yml +8 -0
  24. package/template/.github/ISSUE_TEMPLATE/feature_request.yml +24 -0
  25. package/template/.github/pull_request_template.md +20 -0
  26. package/template/.github/workflows/ci.yml +49 -0
  27. package/template/.prettierignore +1 -0
  28. package/template/.prettierrc.json +1 -0
  29. package/template/AGENTS.md +31 -0
  30. package/template/CODE_OF_CONDUCT.md +22 -0
  31. package/template/CONTRIBUTING.md +53 -0
  32. package/template/Dockerfile +32 -0
  33. package/template/LICENSE +201 -0
  34. package/template/NOTICE +6 -0
  35. package/template/PUBLISHING.md +27 -0
  36. package/template/README.md +157 -0
  37. package/template/SECURITY.md +15 -0
  38. package/template/SETUP.md +174 -0
  39. package/template/SUPPORT.md +8 -0
  40. package/template/_gitignore +13 -0
  41. package/template/apps/web/AGENTS.md +9 -0
  42. package/template/apps/web/components.json +21 -0
  43. package/template/apps/web/e2e/auth.spec.ts +37 -0
  44. package/template/apps/web/e2e/home.spec.ts +15 -0
  45. package/template/apps/web/next-env.d.ts +7 -0
  46. package/template/apps/web/next.config.ts +32 -0
  47. package/template/apps/web/package.json +33 -0
  48. package/template/apps/web/postcss.config.mjs +3 -0
  49. package/template/apps/web/public/.gitkeep +0 -0
  50. package/template/apps/web/public/.well-known/logo.svg +1 -0
  51. package/template/apps/web/src/app/actions/auth.ts +85 -0
  52. package/template/apps/web/src/app/api/health/route.ts +11 -0
  53. package/template/apps/web/src/app/auth/callback/route.ts +21 -0
  54. package/template/apps/web/src/app/dashboard/_components/account-button.tsx +34 -0
  55. package/template/apps/web/src/app/dashboard/_components/app-sidebar.tsx +91 -0
  56. package/template/apps/web/src/app/dashboard/page.tsx +352 -0
  57. package/template/apps/web/src/app/favicon.ico +0 -0
  58. package/template/apps/web/src/app/layout.tsx +36 -0
  59. package/template/apps/web/src/app/login/_components/auth-form-controls.tsx +88 -0
  60. package/template/apps/web/src/app/login/page.tsx +149 -0
  61. package/template/apps/web/src/app/page.tsx +229 -0
  62. package/template/apps/web/src/app/theme-provider.tsx +43 -0
  63. package/template/apps/web/src/app/theme-toggle.tsx +23 -0
  64. package/template/apps/web/src/components/branding/clubedge-mark.tsx +25 -0
  65. package/template/apps/web/src/components/landing/copy-command.tsx +48 -0
  66. package/template/apps/web/src/config/site.json +11 -0
  67. package/template/apps/web/src/config/site.ts +20 -0
  68. package/template/apps/web/src/env/client.ts +22 -0
  69. package/template/apps/web/src/env/server.test.ts +35 -0
  70. package/template/apps/web/src/env/server.ts +45 -0
  71. package/template/apps/web/src/lib/login-url.test.ts +16 -0
  72. package/template/apps/web/src/lib/login-url.ts +16 -0
  73. package/template/apps/web/src/lib/utils.ts +1 -0
  74. package/template/apps/web/src/proxy.ts +31 -0
  75. package/template/apps/web/src/server/auth.ts +69 -0
  76. package/template/apps/web/src/server/cache.ts +38 -0
  77. package/template/apps/web/src/server/db.ts +16 -0
  78. package/template/apps/web/src/server/storage.ts +39 -0
  79. package/template/apps/web/src/server/users.ts +17 -0
  80. package/template/apps/web/tsconfig.json +36 -0
  81. package/template/clubedge.template.json +13 -0
  82. package/template/docker-compose.yml +8 -0
  83. package/template/eslint.config.mjs +63 -0
  84. package/template/package.json +47 -0
  85. package/template/packages/auth/package.json +23 -0
  86. package/template/packages/auth/src/index.ts +9 -0
  87. package/template/packages/auth/src/supabase.test.ts +126 -0
  88. package/template/packages/auth/src/supabase.ts +65 -0
  89. package/template/packages/auth/src/types.ts +59 -0
  90. package/template/packages/auth/tsconfig.json +4 -0
  91. package/template/packages/cache/package.json +20 -0
  92. package/template/packages/cache/src/index.test.ts +67 -0
  93. package/template/packages/cache/src/index.ts +19 -0
  94. package/template/packages/cache/src/rate-limit.test.ts +52 -0
  95. package/template/packages/cache/src/rate-limit.ts +74 -0
  96. package/template/packages/cache/src/redis.ts +106 -0
  97. package/template/packages/cache/tsconfig.json +4 -0
  98. package/template/packages/core/package.json +17 -0
  99. package/template/packages/core/src/client-ip.test.ts +19 -0
  100. package/template/packages/core/src/client-ip.ts +11 -0
  101. package/template/packages/core/src/errors.test.ts +20 -0
  102. package/template/packages/core/src/errors.ts +20 -0
  103. package/template/packages/core/src/index.ts +4 -0
  104. package/template/packages/core/src/redirect.test.ts +27 -0
  105. package/template/packages/core/src/redirect.ts +20 -0
  106. package/template/packages/core/src/result.ts +10 -0
  107. package/template/packages/core/tsconfig.json +4 -0
  108. package/template/packages/db/drizzle/0000_initial.sql +10 -0
  109. package/template/packages/db/drizzle/meta/_journal.json +13 -0
  110. package/template/packages/db/drizzle.config.ts +9 -0
  111. package/template/packages/db/package.json +30 -0
  112. package/template/packages/db/scripts/load-env.ts +14 -0
  113. package/template/packages/db/scripts/migrate.ts +11 -0
  114. package/template/packages/db/scripts/seed.ts +14 -0
  115. package/template/packages/db/src/client.ts +22 -0
  116. package/template/packages/db/src/index.ts +4 -0
  117. package/template/packages/db/src/schema/index.ts +1 -0
  118. package/template/packages/db/src/schema/users.ts +14 -0
  119. package/template/packages/db/src/users.ts +16 -0
  120. package/template/packages/db/tsconfig.json +4 -0
  121. package/template/packages/storage/package.json +24 -0
  122. package/template/packages/storage/src/index.ts +1 -0
  123. package/template/packages/storage/src/s3.test.ts +86 -0
  124. package/template/packages/storage/src/s3.ts +86 -0
  125. package/template/packages/storage/src/supabase.ts +69 -0
  126. package/template/packages/storage/src/types.ts +18 -0
  127. package/template/packages/storage/tsconfig.json +4 -0
  128. package/template/packages/ui/components.json +21 -0
  129. package/template/packages/ui/package.json +32 -0
  130. package/template/packages/ui/src/components/badge.tsx +48 -0
  131. package/template/packages/ui/src/components/breadcrumb.tsx +102 -0
  132. package/template/packages/ui/src/components/button.tsx +57 -0
  133. package/template/packages/ui/src/components/card.tsx +87 -0
  134. package/template/packages/ui/src/components/input.tsx +19 -0
  135. package/template/packages/ui/src/components/label.tsx +19 -0
  136. package/template/packages/ui/src/components/separator.tsx +20 -0
  137. package/template/packages/ui/src/components/sheet.tsx +125 -0
  138. package/template/packages/ui/src/components/sidebar.tsx +692 -0
  139. package/template/packages/ui/src/components/skeleton.tsx +13 -0
  140. package/template/packages/ui/src/components/switch.tsx +31 -0
  141. package/template/packages/ui/src/components/table.tsx +88 -0
  142. package/template/packages/ui/src/components/tooltip.tsx +53 -0
  143. package/template/packages/ui/src/hooks/use-mobile.ts +19 -0
  144. package/template/packages/ui/src/lib/utils.ts +1 -0
  145. package/template/packages/ui/src/styles/globals.css +126 -0
  146. package/template/packages/ui/tsconfig.json +19 -0
  147. package/template/playwright.config.ts +19 -0
  148. package/template/pnpm-lock.yaml +3624 -0
  149. package/template/pnpm-workspace.yaml +3 -0
  150. package/template/scripts/start-standalone.mjs +37 -0
  151. package/template/tsconfig.base.json +16 -0
  152. package/template/turbo.json +17 -0
  153. package/template/vitest.config.ts +8 -0
  154. package/template.lock.json +142 -0
@@ -0,0 +1,692 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { mergeProps } from "@base-ui/react/merge-props";
5
+ import { useRender } from "@base-ui/react/use-render";
6
+ import { cva, type VariantProps } from "class-variance-authority";
7
+ import { cn } from "cn";
8
+
9
+ import { useIsMobile } from "../hooks/use-mobile";
10
+ import { Button } from "@clubedge/ui/components/button";
11
+ import { Input } from "@clubedge/ui/components/input";
12
+ import { Separator } from "@clubedge/ui/components/separator";
13
+ import {
14
+ Sheet,
15
+ SheetContent,
16
+ SheetDescription,
17
+ SheetHeader,
18
+ SheetTitle,
19
+ } from "@clubedge/ui/components/sheet";
20
+ import { Skeleton } from "@clubedge/ui/components/skeleton";
21
+ import { Tooltip, TooltipContent, TooltipTrigger } from "@clubedge/ui/components/tooltip";
22
+ import { PanelLeftIcon } from "lucide-react";
23
+
24
+ const SIDEBAR_COOKIE_NAME = "sidebar_state";
25
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
26
+ const SIDEBAR_WIDTH = "16rem";
27
+ const SIDEBAR_WIDTH_MOBILE = "18rem";
28
+ const SIDEBAR_WIDTH_ICON = "3rem";
29
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b";
30
+
31
+ type SidebarContextProps = {
32
+ state: "expanded" | "collapsed";
33
+ open: boolean;
34
+ setOpen: (open: boolean) => void;
35
+ openMobile: boolean;
36
+ setOpenMobile: (open: boolean) => void;
37
+ isMobile: boolean;
38
+ toggleSidebar: () => void;
39
+ };
40
+
41
+ const SidebarContext = React.createContext<SidebarContextProps | null>(null);
42
+
43
+ function useSidebar() {
44
+ const context = React.useContext(SidebarContext);
45
+ if (!context) {
46
+ throw new Error("useSidebar must be used within a SidebarProvider.");
47
+ }
48
+
49
+ return context;
50
+ }
51
+
52
+ function SidebarProvider({
53
+ defaultOpen = true,
54
+ open: openProp,
55
+ onOpenChange: setOpenProp,
56
+ className,
57
+ style,
58
+ children,
59
+ ...props
60
+ }: React.ComponentProps<"div"> & {
61
+ defaultOpen?: boolean;
62
+ open?: boolean;
63
+ onOpenChange?: (open: boolean) => void;
64
+ }) {
65
+ const isMobile = useIsMobile();
66
+ const [openMobile, setOpenMobile] = React.useState(false);
67
+
68
+ // This is the internal state of the sidebar.
69
+ // We use openProp and setOpenProp for control from outside the component.
70
+ const [_open, _setOpen] = React.useState(defaultOpen);
71
+ const open = openProp ?? _open;
72
+ const setOpen = React.useCallback(
73
+ (value: boolean | ((value: boolean) => boolean)) => {
74
+ const openState = typeof value === "function" ? value(open) : value;
75
+ if (setOpenProp) {
76
+ setOpenProp(openState);
77
+ } else {
78
+ _setOpen(openState);
79
+ }
80
+
81
+ // This sets the cookie to keep the sidebar state.
82
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
83
+ },
84
+ [setOpenProp, open],
85
+ );
86
+
87
+ // Helper to toggle the sidebar.
88
+ const toggleSidebar = React.useCallback(() => {
89
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
90
+ }, [isMobile, setOpen, setOpenMobile]);
91
+
92
+ // Adds a keyboard shortcut to toggle the sidebar.
93
+ React.useEffect(() => {
94
+ const handleKeyDown = (event: KeyboardEvent) => {
95
+ if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
96
+ event.preventDefault();
97
+ toggleSidebar();
98
+ }
99
+ };
100
+
101
+ window.addEventListener("keydown", handleKeyDown);
102
+ return () => window.removeEventListener("keydown", handleKeyDown);
103
+ }, [toggleSidebar]);
104
+
105
+ // We add a state so that we can do data-state="expanded" or "collapsed".
106
+ // This makes it easier to style the sidebar with Tailwind classes.
107
+ const state = open ? "expanded" : "collapsed";
108
+
109
+ const contextValue = React.useMemo<SidebarContextProps>(
110
+ () => ({
111
+ state,
112
+ open,
113
+ setOpen,
114
+ isMobile,
115
+ openMobile,
116
+ setOpenMobile,
117
+ toggleSidebar,
118
+ }),
119
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
120
+ );
121
+
122
+ return (
123
+ <SidebarContext.Provider value={contextValue}>
124
+ <div
125
+ data-slot="sidebar-wrapper"
126
+ style={
127
+ {
128
+ "--sidebar-width": SIDEBAR_WIDTH,
129
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
130
+ ...style,
131
+ } as React.CSSProperties
132
+ }
133
+ className={cn(
134
+ "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
135
+ className,
136
+ )}
137
+ {...props}
138
+ >
139
+ {children}
140
+ </div>
141
+ </SidebarContext.Provider>
142
+ );
143
+ }
144
+
145
+ function Sidebar({
146
+ side = "left",
147
+ variant = "sidebar",
148
+ collapsible = "offcanvas",
149
+ className,
150
+ children,
151
+ dir,
152
+ ...props
153
+ }: React.ComponentProps<"div"> & {
154
+ side?: "left" | "right";
155
+ variant?: "sidebar" | "floating" | "inset";
156
+ collapsible?: "offcanvas" | "icon" | "none";
157
+ }) {
158
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
159
+
160
+ if (collapsible === "none") {
161
+ return (
162
+ <div
163
+ data-slot="sidebar"
164
+ className={cn(
165
+ "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
166
+ className,
167
+ )}
168
+ {...props}
169
+ >
170
+ {children}
171
+ </div>
172
+ );
173
+ }
174
+
175
+ if (isMobile) {
176
+ return (
177
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
178
+ <SheetContent
179
+ dir={dir}
180
+ data-sidebar="sidebar"
181
+ data-slot="sidebar"
182
+ data-mobile="true"
183
+ className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
184
+ style={
185
+ {
186
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
187
+ } as React.CSSProperties
188
+ }
189
+ side={side}
190
+ >
191
+ <SheetHeader className="sr-only">
192
+ <SheetTitle>Sidebar</SheetTitle>
193
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
194
+ </SheetHeader>
195
+ <div className="flex h-full w-full flex-col">{children}</div>
196
+ </SheetContent>
197
+ </Sheet>
198
+ );
199
+ }
200
+
201
+ return (
202
+ <div
203
+ className="group peer hidden text-sidebar-foreground md:block"
204
+ data-state={state}
205
+ data-collapsible={state === "collapsed" ? collapsible : ""}
206
+ data-variant={variant}
207
+ data-side={side}
208
+ data-slot="sidebar"
209
+ >
210
+ {/* This is what handles the sidebar gap on desktop */}
211
+ <div
212
+ data-slot="sidebar-gap"
213
+ className={cn(
214
+ "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
215
+ "group-data-[collapsible=offcanvas]:w-0",
216
+ "group-data-[side=right]:rotate-180",
217
+ variant === "floating" || variant === "inset"
218
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
219
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
220
+ )}
221
+ />
222
+ <div
223
+ data-slot="sidebar-container"
224
+ data-side={side}
225
+ className={cn(
226
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
227
+ // Adjust the padding for floating and inset variants.
228
+ variant === "floating" || variant === "inset"
229
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
230
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-e group-data-[side=right]:border-s",
231
+ className,
232
+ )}
233
+ {...props}
234
+ >
235
+ <div
236
+ data-sidebar="sidebar"
237
+ data-slot="sidebar-inner"
238
+ className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
239
+ >
240
+ {children}
241
+ </div>
242
+ </div>
243
+ </div>
244
+ );
245
+ }
246
+
247
+ function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
248
+ const { toggleSidebar } = useSidebar();
249
+
250
+ return (
251
+ <Button
252
+ data-sidebar="trigger"
253
+ data-slot="sidebar-trigger"
254
+ variant="ghost"
255
+ size="icon-sm"
256
+ className={cn(className)}
257
+ onClick={(event) => {
258
+ onClick?.(event);
259
+ toggleSidebar();
260
+ }}
261
+ {...props}
262
+ >
263
+ <PanelLeftIcon className="rtl:rotate-180" />
264
+ <span className="sr-only">Toggle Sidebar</span>
265
+ </Button>
266
+ );
267
+ }
268
+
269
+ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
270
+ const { toggleSidebar } = useSidebar();
271
+
272
+ return (
273
+ <button
274
+ data-sidebar="rail"
275
+ data-slot="sidebar-rail"
276
+ aria-label="Toggle Sidebar"
277
+ tabIndex={-1}
278
+ onClick={toggleSidebar}
279
+ title="Toggle Sidebar"
280
+ className={cn(
281
+ "absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
282
+ "in-data-[side=left]:cursor-w-resize rtl:in-data-[side=left]:cursor-e-resize in-data-[side=right]:cursor-e-resize rtl:in-data-[side=right]:cursor-w-resize",
283
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize rtl:[[data-side=left][data-state=collapsed]_&]:cursor-w-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize rtl:[[data-side=right][data-state=collapsed]_&]:cursor-e-resize",
284
+ "group-data-[collapsible=offcanvas]:translate-x-0 rtl:group-data-[collapsible=offcanvas]:-translate-x-0 group-data-[collapsible=offcanvas]:after:start-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
285
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-end-2",
286
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-start-2",
287
+ className,
288
+ )}
289
+ {...props}
290
+ />
291
+ );
292
+ }
293
+
294
+ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
295
+ return (
296
+ <main
297
+ data-slot="sidebar-inset"
298
+ className={cn(
299
+ "relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ms-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ms-2",
300
+ className,
301
+ )}
302
+ {...props}
303
+ />
304
+ );
305
+ }
306
+
307
+ function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
308
+ return (
309
+ <Input
310
+ data-slot="sidebar-input"
311
+ data-sidebar="input"
312
+ className={cn("h-8 w-full bg-background shadow-none", className)}
313
+ {...props}
314
+ />
315
+ );
316
+ }
317
+
318
+ function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
319
+ return (
320
+ <div
321
+ data-slot="sidebar-header"
322
+ data-sidebar="header"
323
+ className={cn("flex flex-col gap-2 p-2", className)}
324
+ {...props}
325
+ />
326
+ );
327
+ }
328
+
329
+ function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
330
+ return (
331
+ <div
332
+ data-slot="sidebar-footer"
333
+ data-sidebar="footer"
334
+ className={cn("flex flex-col gap-2 p-2", className)}
335
+ {...props}
336
+ />
337
+ );
338
+ }
339
+
340
+ function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
341
+ return (
342
+ <Separator
343
+ data-slot="sidebar-separator"
344
+ data-sidebar="separator"
345
+ className={cn("mx-2 w-auto bg-sidebar-border", className)}
346
+ {...props}
347
+ />
348
+ );
349
+ }
350
+
351
+ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
352
+ return (
353
+ <div
354
+ data-slot="sidebar-content"
355
+ data-sidebar="content"
356
+ className={cn(
357
+ "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
358
+ className,
359
+ )}
360
+ {...props}
361
+ />
362
+ );
363
+ }
364
+
365
+ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
366
+ return (
367
+ <div
368
+ data-slot="sidebar-group"
369
+ data-sidebar="group"
370
+ className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
371
+ {...props}
372
+ />
373
+ );
374
+ }
375
+
376
+ function SidebarGroupLabel({
377
+ className,
378
+ render,
379
+ ...props
380
+ }: useRender.ComponentProps<"div"> & React.ComponentProps<"div">) {
381
+ return useRender({
382
+ defaultTagName: "div",
383
+ props: mergeProps<"div">(
384
+ {
385
+ className: cn(
386
+ "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
387
+ className,
388
+ ),
389
+ },
390
+ props,
391
+ ),
392
+ render,
393
+ state: {
394
+ slot: "sidebar-group-label",
395
+ sidebar: "group-label",
396
+ },
397
+ });
398
+ }
399
+
400
+ function SidebarGroupAction({
401
+ className,
402
+ render,
403
+ ...props
404
+ }: useRender.ComponentProps<"button"> & React.ComponentProps<"button">) {
405
+ return useRender({
406
+ defaultTagName: "button",
407
+ props: mergeProps<"button">(
408
+ {
409
+ className: cn(
410
+ "absolute top-3.5 end-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
411
+ className,
412
+ ),
413
+ },
414
+ props,
415
+ ),
416
+ render,
417
+ state: {
418
+ slot: "sidebar-group-action",
419
+ sidebar: "group-action",
420
+ },
421
+ });
422
+ }
423
+
424
+ function SidebarGroupContent({ className, ...props }: React.ComponentProps<"div">) {
425
+ return (
426
+ <div
427
+ data-slot="sidebar-group-content"
428
+ data-sidebar="group-content"
429
+ className={cn("w-full text-sm", className)}
430
+ {...props}
431
+ />
432
+ );
433
+ }
434
+
435
+ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
436
+ return (
437
+ <ul
438
+ data-slot="sidebar-menu"
439
+ data-sidebar="menu"
440
+ className={cn("flex w-full min-w-0 flex-col gap-0", className)}
441
+ {...props}
442
+ />
443
+ );
444
+ }
445
+
446
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
447
+ return (
448
+ <li
449
+ data-slot="sidebar-menu-item"
450
+ data-sidebar="menu-item"
451
+ className={cn("group/menu-item relative", className)}
452
+ {...props}
453
+ />
454
+ );
455
+ }
456
+
457
+ const sidebarMenuButtonVariants = cva(
458
+ "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-start text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pe-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
459
+ {
460
+ variants: {
461
+ variant: {
462
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
463
+ outline:
464
+ "bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]",
465
+ },
466
+ size: {
467
+ default: "h-8 text-sm",
468
+ sm: "h-7 text-xs",
469
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
470
+ },
471
+ },
472
+ defaultVariants: {
473
+ variant: "default",
474
+ size: "default",
475
+ },
476
+ },
477
+ );
478
+
479
+ function SidebarMenuButton({
480
+ render,
481
+ isActive = false,
482
+ variant = "default",
483
+ size = "default",
484
+ tooltip,
485
+ className,
486
+ ...props
487
+ }: useRender.ComponentProps<"button"> &
488
+ React.ComponentProps<"button"> & {
489
+ isActive?: boolean;
490
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>;
491
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
492
+ const { isMobile, state } = useSidebar();
493
+ const comp = useRender({
494
+ defaultTagName: "button",
495
+ props: mergeProps<"button">(
496
+ {
497
+ className: cn(sidebarMenuButtonVariants({ variant, size }), className),
498
+ },
499
+ props,
500
+ ),
501
+ render: !tooltip ? render : <TooltipTrigger render={render} />,
502
+ state: {
503
+ slot: "sidebar-menu-button",
504
+ sidebar: "menu-button",
505
+ size,
506
+ active: isActive,
507
+ },
508
+ });
509
+
510
+ if (!tooltip) {
511
+ return comp;
512
+ }
513
+
514
+ if (typeof tooltip === "string") {
515
+ tooltip = {
516
+ children: tooltip,
517
+ };
518
+ }
519
+
520
+ return (
521
+ <Tooltip>
522
+ {comp}
523
+ <TooltipContent
524
+ side="right"
525
+ align="center"
526
+ hidden={state !== "collapsed" || isMobile}
527
+ {...tooltip}
528
+ />
529
+ </Tooltip>
530
+ );
531
+ }
532
+
533
+ function SidebarMenuAction({
534
+ className,
535
+ render,
536
+ showOnHover = false,
537
+ ...props
538
+ }: useRender.ComponentProps<"button"> &
539
+ React.ComponentProps<"button"> & {
540
+ showOnHover?: boolean;
541
+ }) {
542
+ return useRender({
543
+ defaultTagName: "button",
544
+ props: mergeProps<"button">(
545
+ {
546
+ className: cn(
547
+ "absolute top-1.5 end-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
548
+ showOnHover &&
549
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
550
+ className,
551
+ ),
552
+ },
553
+ props,
554
+ ),
555
+ render,
556
+ state: {
557
+ slot: "sidebar-menu-action",
558
+ sidebar: "menu-action",
559
+ },
560
+ });
561
+ }
562
+
563
+ function SidebarMenuBadge({ className, ...props }: React.ComponentProps<"div">) {
564
+ return (
565
+ <div
566
+ data-slot="sidebar-menu-badge"
567
+ data-sidebar="menu-badge"
568
+ className={cn(
569
+ "pointer-events-none absolute end-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
570
+ className,
571
+ )}
572
+ {...props}
573
+ />
574
+ );
575
+ }
576
+
577
+ function SidebarMenuSkeleton({
578
+ className,
579
+ showIcon = false,
580
+ ...props
581
+ }: React.ComponentProps<"div"> & {
582
+ showIcon?: boolean;
583
+ }) {
584
+ // Random width between 50 to 90%.
585
+ const [width] = React.useState(() => {
586
+ return `${Math.floor(Math.random() * 40) + 50}%`;
587
+ });
588
+
589
+ return (
590
+ <div
591
+ data-slot="sidebar-menu-skeleton"
592
+ data-sidebar="menu-skeleton"
593
+ className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
594
+ {...props}
595
+ >
596
+ {showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
597
+ <Skeleton
598
+ className="h-4 max-w-(--skeleton-width) flex-1"
599
+ data-sidebar="menu-skeleton-text"
600
+ style={
601
+ {
602
+ "--skeleton-width": width,
603
+ } as React.CSSProperties
604
+ }
605
+ />
606
+ </div>
607
+ );
608
+ }
609
+
610
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
611
+ return (
612
+ <ul
613
+ data-slot="sidebar-menu-sub"
614
+ data-sidebar="menu-sub"
615
+ className={cn(
616
+ "mx-3.5 flex min-w-0 translate-x-px rtl:-translate-x-px flex-col gap-1 border-s border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
617
+ className,
618
+ )}
619
+ {...props}
620
+ />
621
+ );
622
+ }
623
+
624
+ function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<"li">) {
625
+ return (
626
+ <li
627
+ data-slot="sidebar-menu-sub-item"
628
+ data-sidebar="menu-sub-item"
629
+ className={cn("group/menu-sub-item relative", className)}
630
+ {...props}
631
+ />
632
+ );
633
+ }
634
+
635
+ function SidebarMenuSubButton({
636
+ render,
637
+ size = "md",
638
+ isActive = false,
639
+ className,
640
+ ...props
641
+ }: useRender.ComponentProps<"a"> &
642
+ React.ComponentProps<"a"> & {
643
+ size?: "sm" | "md";
644
+ isActive?: boolean;
645
+ }) {
646
+ return useRender({
647
+ defaultTagName: "a",
648
+ props: mergeProps<"a">(
649
+ {
650
+ className: cn(
651
+ "flex h-7 min-w-0 -translate-x-px rtl:translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
652
+ className,
653
+ ),
654
+ },
655
+ props,
656
+ ),
657
+ render,
658
+ state: {
659
+ slot: "sidebar-menu-sub-button",
660
+ sidebar: "menu-sub-button",
661
+ size,
662
+ active: isActive,
663
+ },
664
+ });
665
+ }
666
+
667
+ export {
668
+ Sidebar,
669
+ SidebarContent,
670
+ SidebarFooter,
671
+ SidebarGroup,
672
+ SidebarGroupAction,
673
+ SidebarGroupContent,
674
+ SidebarGroupLabel,
675
+ SidebarHeader,
676
+ SidebarInput,
677
+ SidebarInset,
678
+ SidebarMenu,
679
+ SidebarMenuAction,
680
+ SidebarMenuBadge,
681
+ SidebarMenuButton,
682
+ SidebarMenuItem,
683
+ SidebarMenuSkeleton,
684
+ SidebarMenuSub,
685
+ SidebarMenuSubButton,
686
+ SidebarMenuSubItem,
687
+ SidebarProvider,
688
+ SidebarRail,
689
+ SidebarSeparator,
690
+ SidebarTrigger,
691
+ useSidebar,
692
+ };
@@ -0,0 +1,13 @@
1
+ import { cn } from "cn";
2
+
3
+ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
+ return (
5
+ <div
6
+ data-slot="skeleton"
7
+ className={cn("animate-pulse rounded-md bg-muted", className)}
8
+ {...props}
9
+ />
10
+ );
11
+ }
12
+
13
+ export { Skeleton };