flarecms 0.1.0 → 0.1.2

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