tokka 0.2.0 → 0.2.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 (80) hide show
  1. package/compiler/generators/css.ts +146 -0
  2. package/compiler/generators/figma.ts +147 -0
  3. package/compiler/generators/tailwind.ts +106 -0
  4. package/compiler/generators/typescript.ts +113 -0
  5. package/compiler/index.ts +45 -0
  6. package/compiler/loader.ts +92 -0
  7. package/compiler/resolver.ts +177 -0
  8. package/compiler/types.ts +118 -0
  9. package/compiler/validator.ts +194 -0
  10. package/components/accordion.tsx +55 -0
  11. package/components/alert-dialog.tsx +138 -0
  12. package/components/alert.tsx +58 -0
  13. package/components/aspect-ratio.tsx +5 -0
  14. package/components/avatar.tsx +47 -0
  15. package/components/badge.tsx +35 -0
  16. package/components/breadcrumb.tsx +114 -0
  17. package/components/button.tsx +56 -0
  18. package/components/calendar.tsx +63 -0
  19. package/components/card.tsx +74 -0
  20. package/components/carousel.tsx +259 -0
  21. package/components/chart.tsx +9 -0
  22. package/components/checkbox.tsx +27 -0
  23. package/components/collapsible.tsx +9 -0
  24. package/components/combobox.tsx +8 -0
  25. package/components/command.tsx +152 -0
  26. package/components/context-menu.tsx +197 -0
  27. package/components/data-table.tsx +9 -0
  28. package/components/date-picker.tsx +8 -0
  29. package/components/dialog.tsx +119 -0
  30. package/components/drawer.tsx +115 -0
  31. package/components/dropdown-menu.tsx +197 -0
  32. package/components/form.tsx +175 -0
  33. package/components/hover-card.tsx +26 -0
  34. package/components/input-otp.tsx +68 -0
  35. package/components/input.tsx +48 -0
  36. package/components/label.tsx +23 -0
  37. package/components/lib/utils.ts +6 -0
  38. package/components/menubar.tsx +233 -0
  39. package/components/native-select.tsx +29 -0
  40. package/components/navigation-menu.tsx +127 -0
  41. package/components/pagination.tsx +116 -0
  42. package/components/popover.tsx +28 -0
  43. package/components/progress.tsx +25 -0
  44. package/components/radio-group.tsx +41 -0
  45. package/components/resizable.tsx +42 -0
  46. package/components/scroll-area.tsx +45 -0
  47. package/components/select.tsx +157 -0
  48. package/components/separator.tsx +28 -0
  49. package/components/sheet.tsx +137 -0
  50. package/components/sidebar.tsx +249 -0
  51. package/components/skeleton.tsx +15 -0
  52. package/components/slider.tsx +25 -0
  53. package/components/sonner.tsx +25 -0
  54. package/components/spinner.tsx +33 -0
  55. package/components/switch.tsx +26 -0
  56. package/components/table.tsx +116 -0
  57. package/components/tabs.tsx +52 -0
  58. package/components/textarea.tsx +23 -0
  59. package/components/toggle-group.tsx +58 -0
  60. package/components/toggle.tsx +42 -0
  61. package/components/tooltip.tsx +27 -0
  62. package/package.json +5 -3
  63. package/systems/README.md +56 -0
  64. package/systems/accessible/system.json +17 -0
  65. package/systems/accessible/tokens/primitives.json +9 -0
  66. package/systems/accessible/tokens/semantics.json +11 -0
  67. package/systems/brutalist/system.json +17 -0
  68. package/systems/brutalist/tokens/primitives.json +10 -0
  69. package/systems/brutalist/tokens/semantics.json +12 -0
  70. package/systems/corporate/system.json +20 -0
  71. package/systems/corporate/tokens/primitives.json +60 -0
  72. package/systems/corporate/tokens/semantics.json +68 -0
  73. package/systems/dark-mode/system.json +17 -0
  74. package/systems/dark-mode/tokens/primitives.json +10 -0
  75. package/systems/dark-mode/tokens/semantics.json +11 -0
  76. package/systems/package.json +14 -0
  77. package/systems/soft-saas/system.json +20 -0
  78. package/systems/soft-saas/tokens/primitives.json +235 -0
  79. package/systems/soft-saas/tokens/semantics.json +190 -0
  80. package/dist/index.js +0 -434
@@ -0,0 +1,42 @@
1
+ import { GripVertical } from "lucide-react"
2
+ import * as ResizablePrimitive from "react-resizable-panels"
3
+ import { cn } from "./lib/utils"
4
+
5
+ const ResizablePanelGroup = ({
6
+ className,
7
+ ...props
8
+ }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => (
9
+ <ResizablePrimitive.PanelGroup
10
+ className={cn(
11
+ "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
12
+ className
13
+ )}
14
+ {...props}
15
+ />
16
+ )
17
+
18
+ const ResizablePanel = ResizablePrimitive.Panel
19
+
20
+ const ResizableHandle = ({
21
+ withHandle,
22
+ className,
23
+ ...props
24
+ }: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
25
+ withHandle?: boolean
26
+ }) => (
27
+ <ResizablePrimitive.PanelResizeHandle
28
+ className={cn(
29
+ "relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",
30
+ className
31
+ )}
32
+ {...props}
33
+ >
34
+ {withHandle && (
35
+ <div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
36
+ <GripVertical className="size-2.5" />
37
+ </div>
38
+ )}
39
+ </ResizablePrimitive.PanelResizeHandle>
40
+ )
41
+
42
+ export { ResizablePanelGroup, ResizablePanel, ResizableHandle }
@@ -0,0 +1,45 @@
1
+ import * as React from "react"
2
+ import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
3
+ import { cn } from "./lib/utils"
4
+
5
+ const ScrollArea = React.forwardRef<
6
+ React.ElementRef<typeof ScrollAreaPrimitive.Root>,
7
+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
8
+ >(({ className, children, ...props }, ref) => (
9
+ <ScrollAreaPrimitive.Root
10
+ ref={ref}
11
+ className={cn("relative overflow-hidden", className)}
12
+ {...props}
13
+ >
14
+ <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
15
+ {children}
16
+ </ScrollAreaPrimitive.Viewport>
17
+ <ScrollBar />
18
+ <ScrollAreaPrimitive.Corner />
19
+ </ScrollAreaPrimitive.Root>
20
+ ))
21
+ ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
22
+
23
+ const ScrollBar = React.forwardRef<
24
+ React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
25
+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
26
+ >(({ className, orientation = "vertical", ...props }, ref) => (
27
+ <ScrollAreaPrimitive.ScrollAreaScrollbar
28
+ ref={ref}
29
+ orientation={orientation}
30
+ className={cn(
31
+ "flex touch-none select-none transition-colors",
32
+ orientation === "vertical" &&
33
+ "h-full w-2.5 border-l border-l-transparent p-[1px]",
34
+ orientation === "horizontal" &&
35
+ "h-2.5 flex-col border-t border-t-transparent p-[1px]",
36
+ className
37
+ )}
38
+ {...props}
39
+ >
40
+ <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
41
+ </ScrollAreaPrimitive.ScrollAreaScrollbar>
42
+ ))
43
+ ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
44
+
45
+ export { ScrollArea, ScrollBar }
@@ -0,0 +1,157 @@
1
+ import * as React from "react"
2
+ import * as SelectPrimitive from "@radix-ui/react-select"
3
+ import { Check, ChevronDown, ChevronUp } from "lucide-react"
4
+ import { cn } from "./lib/utils"
5
+
6
+ const Select = SelectPrimitive.Root
7
+
8
+ const SelectGroup = SelectPrimitive.Group
9
+
10
+ const SelectValue = SelectPrimitive.Value
11
+
12
+ const SelectTrigger = React.forwardRef<
13
+ React.ElementRef<typeof SelectPrimitive.Trigger>,
14
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
15
+ >(({ className, children, ...props }, ref) => (
16
+ <SelectPrimitive.Trigger
17
+ ref={ref}
18
+ className={cn(
19
+ "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
20
+ className
21
+ )}
22
+ {...props}
23
+ >
24
+ {children}
25
+ <SelectPrimitive.Icon asChild>
26
+ <ChevronDown className="size-4 opacity-50" />
27
+ </SelectPrimitive.Icon>
28
+ </SelectPrimitive.Trigger>
29
+ ))
30
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
31
+
32
+ const SelectScrollUpButton = React.forwardRef<
33
+ React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
34
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
35
+ >(({ className, ...props }, ref) => (
36
+ <SelectPrimitive.ScrollUpButton
37
+ ref={ref}
38
+ className={cn(
39
+ "flex cursor-default items-center justify-center py-1",
40
+ className
41
+ )}
42
+ {...props}
43
+ >
44
+ <ChevronUp className="size-4" />
45
+ </SelectPrimitive.ScrollUpButton>
46
+ ))
47
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
48
+
49
+ const SelectScrollDownButton = React.forwardRef<
50
+ React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
51
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
52
+ >(({ className, ...props }, ref) => (
53
+ <SelectPrimitive.ScrollDownButton
54
+ ref={ref}
55
+ className={cn(
56
+ "flex cursor-default items-center justify-center py-1",
57
+ className
58
+ )}
59
+ {...props}
60
+ >
61
+ <ChevronDown className="size-4" />
62
+ </SelectPrimitive.ScrollDownButton>
63
+ ))
64
+ SelectScrollDownButton.displayName =
65
+ SelectPrimitive.ScrollDownButton.displayName
66
+
67
+ const SelectContent = React.forwardRef<
68
+ React.ElementRef<typeof SelectPrimitive.Content>,
69
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
70
+ >(({ className, children, position = "popper", ...props }, ref) => (
71
+ <SelectPrimitive.Portal>
72
+ <SelectPrimitive.Content
73
+ ref={ref}
74
+ className={cn(
75
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
76
+ position === "popper" &&
77
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
78
+ className
79
+ )}
80
+ position={position}
81
+ {...props}
82
+ >
83
+ <SelectScrollUpButton />
84
+ <SelectPrimitive.Viewport
85
+ className={cn(
86
+ "p-1",
87
+ position === "popper" &&
88
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
89
+ )}
90
+ >
91
+ {children}
92
+ </SelectPrimitive.Viewport>
93
+ <SelectScrollDownButton />
94
+ </SelectPrimitive.Content>
95
+ </SelectPrimitive.Portal>
96
+ ))
97
+ SelectContent.displayName = SelectPrimitive.Content.displayName
98
+
99
+ const SelectLabel = React.forwardRef<
100
+ React.ElementRef<typeof SelectPrimitive.Label>,
101
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
102
+ >(({ className, ...props }, ref) => (
103
+ <SelectPrimitive.Label
104
+ ref={ref}
105
+ className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
106
+ {...props}
107
+ />
108
+ ))
109
+ SelectLabel.displayName = SelectPrimitive.Label.displayName
110
+
111
+ const SelectItem = React.forwardRef<
112
+ React.ElementRef<typeof SelectPrimitive.Item>,
113
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
114
+ >(({ className, children, ...props }, ref) => (
115
+ <SelectPrimitive.Item
116
+ ref={ref}
117
+ className={cn(
118
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
119
+ className
120
+ )}
121
+ {...props}
122
+ >
123
+ <span className="absolute left-2 flex size-3.5 items-center justify-center">
124
+ <SelectPrimitive.ItemIndicator>
125
+ <Check className="size-4" />
126
+ </SelectPrimitive.ItemIndicator>
127
+ </span>
128
+
129
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
130
+ </SelectPrimitive.Item>
131
+ ))
132
+ SelectItem.displayName = SelectPrimitive.Item.displayName
133
+
134
+ const SelectSeparator = React.forwardRef<
135
+ React.ElementRef<typeof SelectPrimitive.Separator>,
136
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
137
+ >(({ className, ...props }, ref) => (
138
+ <SelectPrimitive.Separator
139
+ ref={ref}
140
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
141
+ {...props}
142
+ />
143
+ ))
144
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName
145
+
146
+ export {
147
+ Select,
148
+ SelectGroup,
149
+ SelectValue,
150
+ SelectTrigger,
151
+ SelectContent,
152
+ SelectLabel,
153
+ SelectItem,
154
+ SelectSeparator,
155
+ SelectScrollUpButton,
156
+ SelectScrollDownButton,
157
+ }
@@ -0,0 +1,28 @@
1
+ import * as React from "react"
2
+ import * as SeparatorPrimitive from "@radix-ui/react-separator"
3
+ import { cn } from "./lib/utils"
4
+
5
+ const Separator = React.forwardRef<
6
+ React.ElementRef<typeof SeparatorPrimitive.Root>,
7
+ React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
8
+ >(
9
+ (
10
+ { className, orientation = "horizontal", decorative = true, ...props },
11
+ ref
12
+ ) => (
13
+ <SeparatorPrimitive.Root
14
+ ref={ref}
15
+ decorative={decorative}
16
+ orientation={orientation}
17
+ className={cn(
18
+ "shrink-0 bg-border",
19
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
20
+ className
21
+ )}
22
+ {...props}
23
+ />
24
+ )
25
+ )
26
+ Separator.displayName = SeparatorPrimitive.Root.displayName
27
+
28
+ export { Separator }
@@ -0,0 +1,137 @@
1
+ import * as React from "react"
2
+ import * as SheetPrimitive from "@radix-ui/react-dialog"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+ import { X } from "lucide-react"
5
+ import { cn } from "./lib/utils"
6
+
7
+ const Sheet = SheetPrimitive.Root
8
+
9
+ const SheetTrigger = SheetPrimitive.Trigger
10
+
11
+ const SheetClose = SheetPrimitive.Close
12
+
13
+ const SheetPortal = SheetPrimitive.Portal
14
+
15
+ const SheetOverlay = React.forwardRef<
16
+ React.ElementRef<typeof SheetPrimitive.Overlay>,
17
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
18
+ >(({ className, ...props }, ref) => (
19
+ <SheetPrimitive.Overlay
20
+ className={cn(
21
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
22
+ className
23
+ )}
24
+ {...props}
25
+ ref={ref}
26
+ />
27
+ ))
28
+ SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
29
+
30
+ const sheetVariants = cva(
31
+ "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
32
+ {
33
+ variants: {
34
+ side: {
35
+ top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
36
+ bottom:
37
+ "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
38
+ left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
39
+ right:
40
+ "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
41
+ },
42
+ },
43
+ defaultVariants: {
44
+ side: "right",
45
+ },
46
+ }
47
+ )
48
+
49
+ interface SheetContentProps
50
+ extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
51
+ VariantProps<typeof sheetVariants> {}
52
+
53
+ const SheetContent = React.forwardRef<
54
+ React.ElementRef<typeof SheetPrimitive.Content>,
55
+ SheetContentProps
56
+ >(({ side = "right", className, children, ...props }, ref) => (
57
+ <SheetPortal>
58
+ <SheetOverlay />
59
+ <SheetPrimitive.Content
60
+ ref={ref}
61
+ className={cn(sheetVariants({ side }), className)}
62
+ {...props}
63
+ >
64
+ {children}
65
+ <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
66
+ <X className="size-4" />
67
+ <span className="sr-only">Close</span>
68
+ </SheetPrimitive.Close>
69
+ </SheetPrimitive.Content>
70
+ </SheetPortal>
71
+ ))
72
+ SheetContent.displayName = SheetPrimitive.Content.displayName
73
+
74
+ const SheetHeader = ({
75
+ className,
76
+ ...props
77
+ }: React.HTMLAttributes<HTMLDivElement>) => (
78
+ <div
79
+ className={cn(
80
+ "flex flex-col space-y-2 text-center sm:text-left",
81
+ className
82
+ )}
83
+ {...props}
84
+ />
85
+ )
86
+ SheetHeader.displayName = "SheetHeader"
87
+
88
+ const SheetFooter = ({
89
+ className,
90
+ ...props
91
+ }: React.HTMLAttributes<HTMLDivElement>) => (
92
+ <div
93
+ className={cn(
94
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
95
+ className
96
+ )}
97
+ {...props}
98
+ />
99
+ )
100
+ SheetFooter.displayName = "SheetFooter"
101
+
102
+ const SheetTitle = React.forwardRef<
103
+ React.ElementRef<typeof SheetPrimitive.Title>,
104
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
105
+ >(({ className, ...props }, ref) => (
106
+ <SheetPrimitive.Title
107
+ ref={ref}
108
+ className={cn("text-lg font-semibold text-foreground", className)}
109
+ {...props}
110
+ />
111
+ ))
112
+ SheetTitle.displayName = SheetPrimitive.Title.displayName
113
+
114
+ const SheetDescription = React.forwardRef<
115
+ React.ElementRef<typeof SheetPrimitive.Description>,
116
+ React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
117
+ >(({ className, ...props }, ref) => (
118
+ <SheetPrimitive.Description
119
+ ref={ref}
120
+ className={cn("text-sm text-muted-foreground", className)}
121
+ {...props}
122
+ />
123
+ ))
124
+ SheetDescription.displayName = SheetPrimitive.Description.displayName
125
+
126
+ export {
127
+ Sheet,
128
+ SheetPortal,
129
+ SheetOverlay,
130
+ SheetTrigger,
131
+ SheetClose,
132
+ SheetContent,
133
+ SheetHeader,
134
+ SheetFooter,
135
+ SheetTitle,
136
+ SheetDescription,
137
+ }
@@ -0,0 +1,249 @@
1
+ import * as React from "react"
2
+ import { PanelLeft } from "lucide-react"
3
+ import { cn } from "./lib/utils"
4
+ import { Button } from "./button"
5
+ import { Sheet, SheetContent } from "./sheet"
6
+
7
+ const SIDEBAR_WIDTH = "16rem"
8
+ const SIDEBAR_WIDTH_MOBILE = "18rem"
9
+ const SIDEBAR_WIDTH_ICON = "3rem"
10
+
11
+ type SidebarContext = {
12
+ state: "expanded" | "collapsed"
13
+ open: boolean
14
+ setOpen: (open: boolean) => void
15
+ openMobile: boolean
16
+ setOpenMobile: (open: boolean) => void
17
+ isMobile: boolean
18
+ toggleSidebar: () => void
19
+ }
20
+
21
+ const SidebarContext = React.createContext<SidebarContext | null>(null)
22
+
23
+ function useSidebar() {
24
+ const context = React.useContext(SidebarContext)
25
+ if (!context) {
26
+ throw new Error("useSidebar must be used within a SidebarProvider.")
27
+ }
28
+
29
+ return context
30
+ }
31
+
32
+ const SidebarProvider = React.forwardRef<
33
+ HTMLDivElement,
34
+ React.ComponentProps<"div"> & {
35
+ defaultOpen?: boolean
36
+ open?: boolean
37
+ onOpenChange?: (open: boolean) => void
38
+ }
39
+ >(
40
+ (
41
+ {
42
+ defaultOpen = true,
43
+ open: openProp,
44
+ onOpenChange: setOpenProp,
45
+ className,
46
+ style,
47
+ children,
48
+ ...props
49
+ },
50
+ ref
51
+ ) => {
52
+ const [openMobile, setOpenMobile] = React.useState(false)
53
+ const [_open, _setOpen] = React.useState(defaultOpen)
54
+ const open = openProp ?? _open
55
+ const setOpen = React.useCallback(
56
+ (value: boolean | ((value: boolean) => boolean)) => {
57
+ const openState = typeof value === "function" ? value(open) : value
58
+ if (setOpenProp) {
59
+ setOpenProp(openState)
60
+ } else {
61
+ _setOpen(openState)
62
+ }
63
+ },
64
+ [setOpenProp, open]
65
+ )
66
+
67
+ const isMobile = false // Note: In real implementation, use window.matchMedia
68
+
69
+ const state = open ? "expanded" : "collapsed"
70
+
71
+ const contextValue = React.useMemo<SidebarContext>(
72
+ () => ({
73
+ state,
74
+ open,
75
+ setOpen,
76
+ isMobile,
77
+ openMobile,
78
+ setOpenMobile,
79
+ toggleSidebar: () => setOpen(!open),
80
+ }),
81
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile]
82
+ )
83
+
84
+ return (
85
+ <SidebarContext.Provider value={contextValue}>
86
+ <div
87
+ style={
88
+ {
89
+ "--sidebar-width": SIDEBAR_WIDTH,
90
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
91
+ ...style,
92
+ } as React.CSSProperties
93
+ }
94
+ className={cn(
95
+ "group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",
96
+ className
97
+ )}
98
+ ref={ref}
99
+ {...props}
100
+ >
101
+ {children}
102
+ </div>
103
+ </SidebarContext.Provider>
104
+ )
105
+ }
106
+ )
107
+ SidebarProvider.displayName = "SidebarProvider"
108
+
109
+ const Sidebar = React.forwardRef<
110
+ HTMLDivElement,
111
+ React.ComponentProps<"div"> & {
112
+ side?: "left" | "right"
113
+ variant?: "sidebar" | "floating" | "inset"
114
+ collapsible?: "offcanvas" | "icon" | "none"
115
+ }
116
+ >(
117
+ (
118
+ {
119
+ side = "left",
120
+ variant = "sidebar",
121
+ collapsible = "offcanvas",
122
+ className,
123
+ children,
124
+ ...props
125
+ },
126
+ ref
127
+ ) => {
128
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
129
+
130
+ if (collapsible === "none") {
131
+ return (
132
+ <div
133
+ className={cn(
134
+ "flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",
135
+ className
136
+ )}
137
+ ref={ref}
138
+ {...props}
139
+ >
140
+ {children}
141
+ </div>
142
+ )
143
+ }
144
+
145
+ if (isMobile) {
146
+ return (
147
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
148
+ <SheetContent
149
+ data-sidebar="sidebar"
150
+ data-mobile="true"
151
+ className="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
152
+ style={
153
+ {
154
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
155
+ } as React.CSSProperties
156
+ }
157
+ side={side}
158
+ >
159
+ <div className="flex h-full w-full flex-col">{children}</div>
160
+ </SheetContent>
161
+ </Sheet>
162
+ )
163
+ }
164
+
165
+ return (
166
+ <div
167
+ ref={ref}
168
+ className="group peer hidden md:block"
169
+ data-state={state}
170
+ data-collapsible={state === "collapsed" ? collapsible : ""}
171
+ data-variant={variant}
172
+ data-side={side}
173
+ >
174
+ <div
175
+ className={cn(
176
+ "duration-200 relative h-svh w-[--sidebar-width] bg-sidebar transition-[width] ease-linear",
177
+ "group-data-[collapsible=offcanvas]:w-0",
178
+ "group-data-[side=right]:rotate-180",
179
+ variant === "floating" || variant === "inset"
180
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
181
+ : "group-data-[collapsible=icon]:w-[--sidebar-width-icon]",
182
+ className
183
+ )}
184
+ {...props}
185
+ >
186
+ <div
187
+ data-sidebar="sidebar"
188
+ className="duration-200 flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"
189
+ >
190
+ {children}
191
+ </div>
192
+ </div>
193
+ </div>
194
+ )
195
+ }
196
+ )
197
+ Sidebar.displayName = "Sidebar"
198
+
199
+ const SidebarTrigger = React.forwardRef<
200
+ React.ElementRef<typeof Button>,
201
+ React.ComponentProps<typeof Button>
202
+ >(({ className, onClick, ...props }, ref) => {
203
+ const { toggleSidebar } = useSidebar()
204
+
205
+ return (
206
+ <Button
207
+ ref={ref}
208
+ data-sidebar="trigger"
209
+ variant="ghost"
210
+ size="icon"
211
+ className={cn("size-7", className)}
212
+ onClick={(event) => {
213
+ onClick?.(event)
214
+ toggleSidebar()
215
+ }}
216
+ {...props}
217
+ >
218
+ <PanelLeft />
219
+ <span className="sr-only">Toggle Sidebar</span>
220
+ </Button>
221
+ )
222
+ })
223
+ SidebarTrigger.displayName = "SidebarTrigger"
224
+
225
+ const SidebarContent = React.forwardRef<
226
+ HTMLDivElement,
227
+ React.ComponentProps<"div">
228
+ >(({ className, ...props }, ref) => {
229
+ return (
230
+ <div
231
+ data-sidebar="content"
232
+ ref={ref}
233
+ className={cn(
234
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
235
+ className
236
+ )}
237
+ {...props}
238
+ />
239
+ )
240
+ })
241
+ SidebarContent.displayName = "SidebarContent"
242
+
243
+ export {
244
+ Sidebar,
245
+ SidebarContent,
246
+ SidebarProvider,
247
+ SidebarTrigger,
248
+ useSidebar,
249
+ }
@@ -0,0 +1,15 @@
1
+ import { cn } from "./lib/utils"
2
+
3
+ function Skeleton({
4
+ className,
5
+ ...props
6
+ }: React.HTMLAttributes<HTMLDivElement>) {
7
+ return (
8
+ <div
9
+ className={cn("animate-pulse rounded-md bg-muted", className)}
10
+ {...props}
11
+ />
12
+ )
13
+ }
14
+
15
+ export { Skeleton }
@@ -0,0 +1,25 @@
1
+ import * as React from "react"
2
+ import * as SliderPrimitive from "@radix-ui/react-slider"
3
+ import { cn } from "./lib/utils"
4
+
5
+ const Slider = React.forwardRef<
6
+ React.ElementRef<typeof SliderPrimitive.Root>,
7
+ React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
8
+ >(({ className, ...props }, ref) => (
9
+ <SliderPrimitive.Root
10
+ ref={ref}
11
+ className={cn(
12
+ "relative flex w-full touch-none select-none items-center",
13
+ className
14
+ )}
15
+ {...props}
16
+ >
17
+ <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
18
+ <SliderPrimitive.Range className="absolute h-full bg-primary" />
19
+ </SliderPrimitive.Track>
20
+ <SliderPrimitive.Thumb className="block size-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
21
+ </SliderPrimitive.Root>
22
+ ))
23
+ Slider.displayName = SliderPrimitive.Root.displayName
24
+
25
+ export { Slider }