@luanthnh/cntt-ui 0.1.5

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 (255) hide show
  1. package/.storybook/globals.d.ts +1 -0
  2. package/.storybook/main.ts +29 -0
  3. package/.storybook/preview.ts +32 -0
  4. package/README.md +86 -0
  5. package/assets/fonts/Montserrat-Black.eot +0 -0
  6. package/assets/fonts/Montserrat-Black.ttf +0 -0
  7. package/assets/fonts/Montserrat-Black.woff +0 -0
  8. package/assets/fonts/Montserrat-Black.woff2 +0 -0
  9. package/assets/fonts/Montserrat-BlackItalic.eot +0 -0
  10. package/assets/fonts/Montserrat-BlackItalic.ttf +0 -0
  11. package/assets/fonts/Montserrat-BlackItalic.woff +0 -0
  12. package/assets/fonts/Montserrat-BlackItalic.woff2 +0 -0
  13. package/assets/fonts/Montserrat-Bold.eot +0 -0
  14. package/assets/fonts/Montserrat-Bold.ttf +0 -0
  15. package/assets/fonts/Montserrat-Bold.woff +0 -0
  16. package/assets/fonts/Montserrat-Bold.woff2 +0 -0
  17. package/assets/fonts/Montserrat-BoldItalic.eot +0 -0
  18. package/assets/fonts/Montserrat-BoldItalic.ttf +0 -0
  19. package/assets/fonts/Montserrat-BoldItalic.woff +0 -0
  20. package/assets/fonts/Montserrat-BoldItalic.woff2 +0 -0
  21. package/assets/fonts/Montserrat-ExtraBold.eot +0 -0
  22. package/assets/fonts/Montserrat-ExtraBold.ttf +0 -0
  23. package/assets/fonts/Montserrat-ExtraBold.woff +0 -0
  24. package/assets/fonts/Montserrat-ExtraBold.woff2 +0 -0
  25. package/assets/fonts/Montserrat-ExtraBoldItalic.eot +0 -0
  26. package/assets/fonts/Montserrat-ExtraBoldItalic.ttf +0 -0
  27. package/assets/fonts/Montserrat-ExtraBoldItalic.woff +0 -0
  28. package/assets/fonts/Montserrat-ExtraBoldItalic.woff2 +0 -0
  29. package/assets/fonts/Montserrat-ExtraLight.eot +0 -0
  30. package/assets/fonts/Montserrat-ExtraLight.ttf +0 -0
  31. package/assets/fonts/Montserrat-ExtraLight.woff +0 -0
  32. package/assets/fonts/Montserrat-ExtraLight.woff2 +0 -0
  33. package/assets/fonts/Montserrat-ExtraLightItalic.eot +0 -0
  34. package/assets/fonts/Montserrat-ExtraLightItalic.ttf +0 -0
  35. package/assets/fonts/Montserrat-ExtraLightItalic.woff +0 -0
  36. package/assets/fonts/Montserrat-ExtraLightItalic.woff2 +0 -0
  37. package/assets/fonts/Montserrat-Italic.eot +0 -0
  38. package/assets/fonts/Montserrat-Italic.ttf +0 -0
  39. package/assets/fonts/Montserrat-Italic.woff +0 -0
  40. package/assets/fonts/Montserrat-Italic.woff2 +0 -0
  41. package/assets/fonts/Montserrat-Light.eot +0 -0
  42. package/assets/fonts/Montserrat-Light.ttf +0 -0
  43. package/assets/fonts/Montserrat-Light.woff +0 -0
  44. package/assets/fonts/Montserrat-Light.woff2 +0 -0
  45. package/assets/fonts/Montserrat-LightItalic.eot +0 -0
  46. package/assets/fonts/Montserrat-LightItalic.ttf +0 -0
  47. package/assets/fonts/Montserrat-LightItalic.woff +0 -0
  48. package/assets/fonts/Montserrat-LightItalic.woff2 +0 -0
  49. package/assets/fonts/Montserrat-Medium.eot +0 -0
  50. package/assets/fonts/Montserrat-Medium.ttf +0 -0
  51. package/assets/fonts/Montserrat-Medium.woff +0 -0
  52. package/assets/fonts/Montserrat-Medium.woff2 +0 -0
  53. package/assets/fonts/Montserrat-MediumItalic.eot +0 -0
  54. package/assets/fonts/Montserrat-MediumItalic.ttf +0 -0
  55. package/assets/fonts/Montserrat-MediumItalic.woff +0 -0
  56. package/assets/fonts/Montserrat-MediumItalic.woff2 +0 -0
  57. package/assets/fonts/Montserrat-Regular.eot +0 -0
  58. package/assets/fonts/Montserrat-Regular.ttf +0 -0
  59. package/assets/fonts/Montserrat-Regular.woff +0 -0
  60. package/assets/fonts/Montserrat-Regular.woff2 +0 -0
  61. package/assets/fonts/Montserrat-SemiBold.eot +0 -0
  62. package/assets/fonts/Montserrat-SemiBold.ttf +0 -0
  63. package/assets/fonts/Montserrat-SemiBold.woff +0 -0
  64. package/assets/fonts/Montserrat-SemiBold.woff2 +0 -0
  65. package/assets/fonts/Montserrat-SemiBoldItalic.eot +0 -0
  66. package/assets/fonts/Montserrat-SemiBoldItalic.ttf +0 -0
  67. package/assets/fonts/Montserrat-SemiBoldItalic.woff +0 -0
  68. package/assets/fonts/Montserrat-SemiBoldItalic.woff2 +0 -0
  69. package/assets/fonts/Montserrat-Thin.eot +0 -0
  70. package/assets/fonts/Montserrat-Thin.ttf +0 -0
  71. package/assets/fonts/Montserrat-Thin.woff +0 -0
  72. package/assets/fonts/Montserrat-Thin.woff2 +0 -0
  73. package/assets/fonts/Montserrat-ThinItalic.eot +0 -0
  74. package/assets/fonts/Montserrat-ThinItalic.ttf +0 -0
  75. package/assets/fonts/Montserrat-ThinItalic.woff +0 -0
  76. package/assets/fonts/Montserrat-ThinItalic.woff2 +0 -0
  77. package/assets/fonts/Montserrat-Variable.eot +0 -0
  78. package/assets/fonts/Montserrat-Variable.ttf +0 -0
  79. package/assets/fonts/Montserrat-Variable.woff +0 -0
  80. package/assets/fonts/Montserrat-Variable.woff2 +0 -0
  81. package/assets/fonts/Montserrat-VariableItalic.eot +0 -0
  82. package/assets/fonts/Montserrat-VariableItalic.ttf +0 -0
  83. package/assets/fonts/Montserrat-VariableItalic.woff +0 -0
  84. package/assets/fonts/Montserrat-VariableItalic.woff2 +0 -0
  85. package/assets/icons/arrow-left.svg +1 -0
  86. package/assets/icons/file.svg +1 -0
  87. package/assets/icons/globe.svg +1 -0
  88. package/assets/icons/logo-line.svg +1 -0
  89. package/assets/icons/next.svg +1 -0
  90. package/assets/icons/panel-left-expand.svg +1 -0
  91. package/assets/icons/placeholder.svg +57 -0
  92. package/assets/icons/vercel.svg +1 -0
  93. package/assets/icons/window.svg +1 -0
  94. package/assets/lotties/error-404.json +19642 -0
  95. package/assets/lotties/error.json +2414 -0
  96. package/assets/lotties/loader.json +305 -0
  97. package/components/Welcome.mdx +74 -0
  98. package/components/lenis/index.tsx +48 -0
  99. package/components/motion/auto-height.tsx +56 -0
  100. package/components/motion/cursor.tsx +108 -0
  101. package/components/motion/highlight.tsx +605 -0
  102. package/components/motion/number-ticker.tsx +55 -0
  103. package/components/motion/slot.tsx +106 -0
  104. package/components/motion/waves.tsx +417 -0
  105. package/components/primitives/tabs.tsx +174 -0
  106. package/components/ui/Accordion/index.stories.tsx +39 -0
  107. package/components/ui/Accordion/index.tsx +170 -0
  108. package/components/ui/Alert/index.stories.tsx +39 -0
  109. package/components/ui/Alert/index.tsx +60 -0
  110. package/components/ui/AlertDialog/index.stories.tsx +47 -0
  111. package/components/ui/AlertDialog/index.tsx +172 -0
  112. package/components/ui/AspectRatio/index.stories.tsx +40 -0
  113. package/components/ui/AspectRatio/index.tsx +9 -0
  114. package/components/ui/Avatar/index.stories.tsx +39 -0
  115. package/components/ui/Avatar/index.tsx +44 -0
  116. package/components/ui/Badge/index.stories.tsx +64 -0
  117. package/components/ui/Badge/index.tsx +46 -0
  118. package/components/ui/Breadcrumb/index.stories.tsx +64 -0
  119. package/components/ui/Breadcrumb/index.tsx +102 -0
  120. package/components/ui/Button/index.stories.tsx +232 -0
  121. package/components/ui/Button/index.tsx +114 -0
  122. package/components/ui/Calendar/index.stories.tsx +20 -0
  123. package/components/ui/Calendar/index.tsx +149 -0
  124. package/components/ui/Card/index.stories.tsx +39 -0
  125. package/components/ui/Card/index.tsx +65 -0
  126. package/components/ui/Carousel/index.stories.tsx +37 -0
  127. package/components/ui/Carousel/index.tsx +242 -0
  128. package/components/ui/Chart/index.stories.tsx +53 -0
  129. package/components/ui/Chart/index.tsx +322 -0
  130. package/components/ui/Checkbox/index.stories.tsx +56 -0
  131. package/components/ui/Checkbox/index.tsx +167 -0
  132. package/components/ui/CircleProcess/index.stories.tsx +29 -0
  133. package/components/ui/CircleProcess/index.tsx +50 -0
  134. package/components/ui/Collapsible/index.stories.tsx +33 -0
  135. package/components/ui/Collapsible/index.tsx +124 -0
  136. package/components/ui/Command/index.stories.tsx +65 -0
  137. package/components/ui/Command/index.tsx +161 -0
  138. package/components/ui/Container/index.stories.tsx +22 -0
  139. package/components/ui/Container/index.tsx +30 -0
  140. package/components/ui/ContextMenu/index.stories.tsx +51 -0
  141. package/components/ui/ContextMenu/index.tsx +224 -0
  142. package/components/ui/Dialog/index.stories.tsx +44 -0
  143. package/components/ui/Dialog/index.tsx +156 -0
  144. package/components/ui/Drawer/index.stories.tsx +54 -0
  145. package/components/ui/Drawer/index.tsx +124 -0
  146. package/components/ui/DropdownMenu/index.stories.tsx +83 -0
  147. package/components/ui/DropdownMenu/index.tsx +231 -0
  148. package/components/ui/Dropzone/index.stories.tsx +18 -0
  149. package/components/ui/Dropzone/index.tsx +47 -0
  150. package/components/ui/Form/date-field.tsx +77 -0
  151. package/components/ui/Form/index.stories.tsx +67 -0
  152. package/components/ui/Form/index.tsx +188 -0
  153. package/components/ui/Form/select-field.tsx +55 -0
  154. package/components/ui/Form/text-area-field.tsx +37 -0
  155. package/components/ui/Form/text-field.tsx +72 -0
  156. package/components/ui/HStack/index.stories.tsx +48 -0
  157. package/components/ui/HStack/index.tsx +73 -0
  158. package/components/ui/HoverCard/index.stories.tsx +38 -0
  159. package/components/ui/HoverCard/index.tsx +38 -0
  160. package/components/ui/Icons/index.stories.tsx +27 -0
  161. package/components/ui/Icons/index.tsx +33 -0
  162. package/components/ui/ImageWithFallback/index.stories.tsx +32 -0
  163. package/components/ui/ImageWithFallback/index.tsx +34 -0
  164. package/components/ui/Input/index.stories.tsx +47 -0
  165. package/components/ui/Input/index.tsx +21 -0
  166. package/components/ui/InputOtp/index.stories.tsx +35 -0
  167. package/components/ui/InputOtp/index.tsx +70 -0
  168. package/components/ui/Label/index.stories.tsx +18 -0
  169. package/components/ui/Label/index.tsx +21 -0
  170. package/components/ui/Marquee/index.stories.tsx +71 -0
  171. package/components/ui/Marquee/index.tsx +65 -0
  172. package/components/ui/Menubar/index.stories.tsx +116 -0
  173. package/components/ui/Menubar/index.tsx +252 -0
  174. package/components/ui/NavigationMenu/index.stories.tsx +112 -0
  175. package/components/ui/NavigationMenu/index.tsx +185 -0
  176. package/components/ui/NoData/index.stories.tsx +24 -0
  177. package/components/ui/NoData/index.tsx +19 -0
  178. package/components/ui/Pagination/index.stories.tsx +53 -0
  179. package/components/ui/Pagination/index.tsx +114 -0
  180. package/components/ui/Popover/index.stories.tsx +31 -0
  181. package/components/ui/Popover/index.tsx +42 -0
  182. package/components/ui/Progress/index.stories.tsx +35 -0
  183. package/components/ui/Progress/index.tsx +28 -0
  184. package/components/ui/RadioGroup/index.stories.tsx +28 -0
  185. package/components/ui/RadioGroup/index.tsx +45 -0
  186. package/components/ui/Resizable/index.stories.tsx +44 -0
  187. package/components/ui/Resizable/index.tsx +54 -0
  188. package/components/ui/ScrollArea/index.stories.tsx +31 -0
  189. package/components/ui/ScrollArea/index.tsx +56 -0
  190. package/components/ui/Select/index.stories.tsx +64 -0
  191. package/components/ui/Select/index.tsx +170 -0
  192. package/components/ui/Separator/index.stories.tsx +31 -0
  193. package/components/ui/Separator/index.tsx +28 -0
  194. package/components/ui/Sheet/index.stories.tsx +45 -0
  195. package/components/ui/Sheet/index.tsx +130 -0
  196. package/components/ui/Sidebar/index.stories.tsx +82 -0
  197. package/components/ui/Sidebar/index.tsx +676 -0
  198. package/components/ui/Skeleton/index.stories.tsx +36 -0
  199. package/components/ui/Skeleton/index.tsx +13 -0
  200. package/components/ui/Slider/index.stories.tsx +48 -0
  201. package/components/ui/Slider/index.tsx +82 -0
  202. package/components/ui/Slot/index.stories.tsx +29 -0
  203. package/components/ui/Slot/index.tsx +106 -0
  204. package/components/ui/Sonner/index.stories.tsx +36 -0
  205. package/components/ui/Sonner/index.tsx +31 -0
  206. package/components/ui/Switch/index.stories.tsx +33 -0
  207. package/components/ui/Switch/index.tsx +28 -0
  208. package/components/ui/Table/index.stories.tsx +74 -0
  209. package/components/ui/Table/index.tsx +95 -0
  210. package/components/ui/Tabs/index.stories.tsx +38 -0
  211. package/components/ui/Tabs/index.tsx +78 -0
  212. package/components/ui/Text/index.stories.tsx +53 -0
  213. package/components/ui/Text/index.tsx +138 -0
  214. package/components/ui/Textarea/index.stories.tsx +25 -0
  215. package/components/ui/Textarea/index.tsx +18 -0
  216. package/components/ui/Toggle/index.stories.tsx +52 -0
  217. package/components/ui/Toggle/index.tsx +46 -0
  218. package/components/ui/ToggleGroup/index.stories.tsx +52 -0
  219. package/components/ui/ToggleGroup/index.tsx +69 -0
  220. package/components/ui/Tooltip/index.stories.tsx +29 -0
  221. package/components/ui/Tooltip/index.tsx +35 -0
  222. package/components/ui/VStack/index.stories.tsx +45 -0
  223. package/components/ui/VStack/index.tsx +69 -0
  224. package/components/ui/colors.stories.tsx +148 -0
  225. package/dist/arrow-left-46B4CAEY.svg +1 -0
  226. package/dist/file-4IXBJF4J.svg +1 -0
  227. package/dist/globe-KVAXBN2U.svg +1 -0
  228. package/dist/index.cjs +6001 -0
  229. package/dist/index.cjs.map +1 -0
  230. package/dist/index.d.cts +693 -0
  231. package/dist/index.d.ts +693 -0
  232. package/dist/index.js +5714 -0
  233. package/dist/index.js.map +1 -0
  234. package/dist/logo-line-QLUD5DAV.svg +1 -0
  235. package/dist/next-HOXZBJQP.svg +1 -0
  236. package/dist/panel-left-expand-SIPFBG4J.svg +1 -0
  237. package/dist/placeholder-H3V4XYVI.svg +57 -0
  238. package/dist/vercel-KFYFHF3A.svg +1 -0
  239. package/dist/window-JNUL4Q2E.svg +1 -0
  240. package/eslint.config.js +10 -0
  241. package/globals.css +994 -0
  242. package/hooks/index.ts +3 -0
  243. package/hooks/use-auto-height.tsx +99 -0
  244. package/hooks/use-controlled-state.tsx +32 -0
  245. package/hooks/use-mobile.ts +19 -0
  246. package/index.ts +58 -0
  247. package/lib/get-strict-context.ts +15 -0
  248. package/lib/utils.ts +10 -0
  249. package/package.json +107 -0
  250. package/scripts/generate-exports.ts +32 -0
  251. package/tsconfig.json +12 -0
  252. package/tsconfig.tsbuildinfo +1 -0
  253. package/tsup.config.ts +11 -0
  254. package/types/svg.d.ts +10 -0
  255. package/vercel.json +5 -0
@@ -0,0 +1,676 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { Slot } from '@radix-ui/react-slot';
5
+ import { cva, VariantProps } from 'class-variance-authority';
6
+ import { PanelLeftIcon } from 'lucide-react';
7
+
8
+ import { cn } from '@/lib/utils';
9
+ import { useIsMobile } from '@/hooks/use-mobile';
10
+ import { Button } from '@/components/ui/Button';
11
+ import { Input } from '@/components/ui/Input';
12
+ import { Separator } from '@/components/ui/Separator';
13
+ import { Skeleton } from '@/components/ui/Skeleton';
14
+ import { Tooltip, TooltipProvider } from '@/components/ui/Tooltip';
15
+
16
+ const SIDEBAR_COOKIE_NAME = 'sidebar_state';
17
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
18
+ const SIDEBAR_WIDTH = '16rem';
19
+ // const SIDEBAR_WIDTH_MOBILE = '18rem';
20
+ const SIDEBAR_WIDTH_ICON = '3rem';
21
+ const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
22
+
23
+ type SidebarContextProps = {
24
+ state: 'expanded' | 'collapsed';
25
+ open: boolean;
26
+ setOpen: (open: boolean) => void;
27
+ openMobile: boolean;
28
+ setOpenMobile: (open: boolean) => void;
29
+ isMobile: boolean;
30
+ toggleSidebar: () => void;
31
+ };
32
+
33
+ const SidebarContext = React.createContext<SidebarContextProps | null>(null);
34
+
35
+ function useSidebar() {
36
+ const context = React.useContext(SidebarContext);
37
+ if (!context) {
38
+ throw new Error('useSidebar must be used within a SidebarProvider.');
39
+ }
40
+
41
+ return context;
42
+ }
43
+
44
+ function SidebarProvider({
45
+ defaultOpen = true,
46
+ open: openProp,
47
+ onOpenChange: setOpenProp,
48
+ className,
49
+ style,
50
+ children,
51
+ ...props
52
+ }: React.ComponentProps<'div'> & {
53
+ defaultOpen?: boolean;
54
+ open?: boolean;
55
+ onOpenChange?: (open: boolean) => void;
56
+ }) {
57
+ const isMobile = useIsMobile();
58
+ const [openMobile, setOpenMobile] = React.useState(false);
59
+
60
+ // This is the internal state of the sidebar.
61
+ // We use openProp and setOpenProp for control from outside the component.
62
+ const [_open, _setOpen] = React.useState(defaultOpen);
63
+ const open = openProp ?? _open;
64
+ const setOpen = React.useCallback(
65
+ (value: boolean | ((value: boolean) => boolean)) => {
66
+ const openState = typeof value === 'function' ? value(open) : value;
67
+ if (setOpenProp) {
68
+ setOpenProp(openState);
69
+ } else {
70
+ _setOpen(openState);
71
+ }
72
+
73
+ // This sets the cookie to keep the sidebar state.
74
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
75
+ },
76
+ [setOpenProp, open],
77
+ );
78
+
79
+ // Helper to toggle the sidebar.
80
+ const toggleSidebar = React.useCallback(() => {
81
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
82
+ }, [isMobile, setOpen, setOpenMobile]);
83
+
84
+ // Adds a keyboard shortcut to toggle the sidebar.
85
+ React.useEffect(() => {
86
+ const handleKeyDown = (event: KeyboardEvent) => {
87
+ if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
88
+ event.preventDefault();
89
+ toggleSidebar();
90
+ }
91
+ };
92
+
93
+ window.addEventListener('keydown', handleKeyDown);
94
+ return () => window.removeEventListener('keydown', handleKeyDown);
95
+ }, [toggleSidebar]);
96
+
97
+ // We add a state so that we can do data-state="expanded" or "collapsed".
98
+ // This makes it easier to style the sidebar with Tailwind classes.
99
+ const state = open ? 'expanded' : 'collapsed';
100
+
101
+ const contextValue = React.useMemo<SidebarContextProps>(
102
+ () => ({
103
+ state,
104
+ open,
105
+ setOpen,
106
+ isMobile,
107
+ openMobile,
108
+ setOpenMobile,
109
+ toggleSidebar,
110
+ }),
111
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
112
+ );
113
+
114
+ return (
115
+ <SidebarContext.Provider value={contextValue}>
116
+ <TooltipProvider delayDuration={0}>
117
+ <div
118
+ data-slot="sidebar-wrapper"
119
+ style={
120
+ {
121
+ '--sidebar-width': SIDEBAR_WIDTH,
122
+ '--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
123
+ ...style,
124
+ } as React.CSSProperties
125
+ }
126
+ className={cn(
127
+ 'group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex w-full',
128
+ className,
129
+ )}
130
+ {...props}
131
+ >
132
+ {children}
133
+ </div>
134
+ </TooltipProvider>
135
+ </SidebarContext.Provider>
136
+ );
137
+ }
138
+
139
+ function Sidebar({
140
+ side = 'left',
141
+ variant = 'sidebar',
142
+ collapsible = 'offcanvas',
143
+ className,
144
+ children,
145
+ ...props
146
+ }: React.ComponentProps<'div'> & {
147
+ side?: 'left' | 'right';
148
+ variant?: 'sidebar' | 'floating' | 'inset';
149
+ collapsible?: 'offcanvas' | 'icon' | 'none';
150
+ }) {
151
+ const { state } = useSidebar();
152
+
153
+ if (collapsible === 'none') {
154
+ return (
155
+ <div
156
+ data-slot="sidebar"
157
+ className={cn(
158
+ 'bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col',
159
+ className,
160
+ )}
161
+ {...props}
162
+ >
163
+ {children}
164
+ </div>
165
+ );
166
+ }
167
+
168
+ // if (isMobile) {
169
+ // return (
170
+ // <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
171
+ // <SheetContent
172
+ // data-sidebar="sidebar"
173
+ // data-slot="sidebar"
174
+ // data-mobile="true"
175
+ // className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
176
+ // style={
177
+ // {
178
+ // '--sidebar-width': SIDEBAR_WIDTH_MOBILE,
179
+ // } as React.CSSProperties
180
+ // }
181
+ // side={side}
182
+ // >
183
+ // <SheetHeader className="sr-only">
184
+ // <SheetTitle>Sidebar</SheetTitle>
185
+ // <SheetDescription>Displays the mobile sidebar.</SheetDescription>
186
+ // </SheetHeader>
187
+ // <div className="flex h-full w-full flex-col">{children}</div>
188
+ // </SheetContent>
189
+ // </Sheet>
190
+ // );
191
+ // }
192
+
193
+ return (
194
+ <div
195
+ className="group peer text-sidebar-foreground w-full lg:sticky lg:top-6 lg:w-fit"
196
+ data-state={state}
197
+ data-collapsible={state === 'collapsed' ? collapsible : ''}
198
+ data-variant={variant}
199
+ data-side={side}
200
+ data-slot="sidebar"
201
+ >
202
+ {/* This is what handles the sidebar gap on desktop */}
203
+ <div
204
+ data-slot="sidebar-gap"
205
+ className={cn(
206
+ 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',
207
+ 'group-data-[collapsible=offcanvas]:w-0',
208
+ 'group-data-[side=right]:rotate-180',
209
+ variant === 'floating' || variant === 'inset'
210
+ ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
211
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',
212
+ )}
213
+ />
214
+ <div
215
+ data-slot="sidebar-container"
216
+ className={cn(
217
+ 'fixed inset-y-0 z-10 h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear',
218
+ side === 'left'
219
+ ? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
220
+ : 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
221
+ // Adjust the padding for floating and inset variants.
222
+ variant === 'floating' || variant === 'inset'
223
+ ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
224
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
225
+ className,
226
+ )}
227
+ {...props}
228
+ >
229
+ <div
230
+ data-sidebar="sidebar"
231
+ data-slot="sidebar-inner"
232
+ className="bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"
233
+ >
234
+ {children}
235
+ </div>
236
+ </div>
237
+ </div>
238
+ );
239
+ }
240
+
241
+ function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
242
+ const { toggleSidebar } = useSidebar();
243
+
244
+ return (
245
+ <Button
246
+ data-sidebar="trigger"
247
+ data-slot="sidebar-trigger"
248
+ variant="ghost"
249
+ size="icon"
250
+ className={cn('size-7', className)}
251
+ onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
252
+ onClick?.(event);
253
+ toggleSidebar();
254
+ }}
255
+ {...props}
256
+ >
257
+ <PanelLeftIcon />
258
+ <span className="sr-only">Toggle Sidebar</span>
259
+ </Button>
260
+ );
261
+ }
262
+
263
+ function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
264
+ const { toggleSidebar } = useSidebar();
265
+
266
+ return (
267
+ <button
268
+ data-sidebar="rail"
269
+ data-slot="sidebar-rail"
270
+ aria-label="Toggle Sidebar"
271
+ tabIndex={-1}
272
+ onClick={toggleSidebar}
273
+ title="Toggle Sidebar"
274
+ className={cn(
275
+ 'hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex',
276
+ 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
277
+ '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
278
+ 'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full',
279
+ '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
280
+ '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
281
+ className,
282
+ )}
283
+ {...props}
284
+ />
285
+ );
286
+ }
287
+
288
+ function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
289
+ return (
290
+ <main
291
+ data-slot="sidebar-inset"
292
+ className={cn(
293
+ 'bg-background relative flex w-full flex-1 flex-col',
294
+ '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',
295
+ className,
296
+ )}
297
+ {...props}
298
+ />
299
+ );
300
+ }
301
+
302
+ function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
303
+ return (
304
+ <Input
305
+ data-slot="sidebar-input"
306
+ data-sidebar="input"
307
+ className={cn('bg-background h-8 w-full shadow-none', className)}
308
+ {...props}
309
+ />
310
+ );
311
+ }
312
+
313
+ function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
314
+ return (
315
+ <div
316
+ data-slot="sidebar-header"
317
+ data-sidebar="header"
318
+ className={cn('flex flex-col gap-2 p-2', className)}
319
+ {...props}
320
+ />
321
+ );
322
+ }
323
+
324
+ function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
325
+ return (
326
+ <div
327
+ data-slot="sidebar-footer"
328
+ data-sidebar="footer"
329
+ className={cn('flex flex-col gap-2 p-2', className)}
330
+ {...props}
331
+ />
332
+ );
333
+ }
334
+
335
+ function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
336
+ return (
337
+ <Separator
338
+ data-slot="sidebar-separator"
339
+ data-sidebar="separator"
340
+ className={cn('bg-sidebar-border mx-2 w-auto', className)}
341
+ {...props}
342
+ />
343
+ );
344
+ }
345
+
346
+ function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
347
+ return (
348
+ <div
349
+ data-slot="sidebar-content"
350
+ data-sidebar="content"
351
+ className={cn(
352
+ 'flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',
353
+ className,
354
+ )}
355
+ {...props}
356
+ />
357
+ );
358
+ }
359
+
360
+ function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
361
+ return (
362
+ <div
363
+ data-slot="sidebar-group"
364
+ data-sidebar="group"
365
+ className={cn('relative flex w-full min-w-0 flex-col p-2', className)}
366
+ {...props}
367
+ />
368
+ );
369
+ }
370
+
371
+ function SidebarGroupLabel({
372
+ className,
373
+ asChild = false,
374
+ ...props
375
+ }: React.ComponentProps<'div'> & { asChild?: boolean }) {
376
+ const Comp = asChild ? Slot : 'div';
377
+
378
+ return (
379
+ <Comp
380
+ data-slot="sidebar-group-label"
381
+ data-sidebar="group-label"
382
+ className={cn(
383
+ 'text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-sm font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
384
+ 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
385
+ className,
386
+ )}
387
+ {...props}
388
+ />
389
+ );
390
+ }
391
+
392
+ function SidebarGroupAction({
393
+ className,
394
+ asChild = false,
395
+ ...props
396
+ }: React.ComponentProps<'button'> & { asChild?: boolean }) {
397
+ const Comp = asChild ? Slot : 'button';
398
+
399
+ return (
400
+ <Comp
401
+ data-slot="sidebar-group-action"
402
+ data-sidebar="group-action"
403
+ className={cn(
404
+ 'text-sidebar-foreground ring-sidebar-ring hover:bg-primary-50 dark:hover:bg-primary-900/30 absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
405
+ // Increases the hit area of the button on mobile.
406
+ 'after:absolute after:-inset-2 md:after:hidden',
407
+ 'group-data-[collapsible=icon]:hidden',
408
+ className,
409
+ )}
410
+ {...props}
411
+ />
412
+ );
413
+ }
414
+
415
+ function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {
416
+ return (
417
+ <div
418
+ data-slot="sidebar-group-content"
419
+ data-sidebar="group-content"
420
+ className={cn('w-full text-base', className)}
421
+ {...props}
422
+ />
423
+ );
424
+ }
425
+
426
+ function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {
427
+ return (
428
+ <ul
429
+ data-slot="sidebar-menu"
430
+ data-sidebar="menu"
431
+ className={cn('flex w-full min-w-0 flex-col gap-1', className)}
432
+ {...props}
433
+ />
434
+ );
435
+ }
436
+
437
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
438
+ return (
439
+ <li
440
+ data-slot="sidebar-menu-item"
441
+ data-sidebar="menu-item"
442
+ className={cn('group/menu-item relative', className)}
443
+ {...props}
444
+ />
445
+ );
446
+ }
447
+
448
+ const sidebarMenuButtonVariants = cva(
449
+ 'peer/menu-button ring-sidebar-ring hover:bg-primary-50 dark:hover:bg-primary-900/30 active:bg-primary-50 dark:active:bg-primary-900/30 data-[active=true]:bg-primary data-[active=true]:text-primary-foreground data-[state=open]:hover:bg-primary-50 dark:data-[state=open]:hover:bg-primary-900/30 data-[state=open]:hover:text-primary-foreground flex w-full items-center gap-2 overflow-hidden rounded-lg p-4 text-left text-base 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! focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:font-medium [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
450
+ {
451
+ variants: {
452
+ variant: {
453
+ default: 'hover:bg-primary-50 dark:hover:bg-primary-900/30',
454
+ outline:
455
+ 'bg-background hover:bg-primary-50 dark:hover:bg-primary-900/30 shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]',
456
+ },
457
+ size: {
458
+ default: 'h-8 text-base',
459
+ sm: 'h-7 text-sm',
460
+ lg: 'h-12 text-base group-data-[collapsible=icon]:p-0!',
461
+ },
462
+ },
463
+ defaultVariants: {
464
+ variant: 'default',
465
+ size: 'default',
466
+ },
467
+ },
468
+ );
469
+
470
+ function SidebarMenuButton({
471
+ asChild = false,
472
+ isActive = false,
473
+ variant = 'default',
474
+ size = 'default',
475
+ tooltip,
476
+ className,
477
+ ...props
478
+ }: React.ComponentProps<'button'> & {
479
+ asChild?: boolean;
480
+ isActive?: boolean;
481
+ tooltip?: string | React.ComponentProps<typeof Tooltip>;
482
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
483
+ const Comp = asChild ? Slot : 'button';
484
+ const { isMobile, state } = useSidebar();
485
+
486
+ const button = (
487
+ <Comp
488
+ data-slot="sidebar-menu-button"
489
+ data-sidebar="menu-button"
490
+ data-size={size}
491
+ data-active={isActive}
492
+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
493
+ {...props}
494
+ />
495
+ );
496
+
497
+ if (!tooltip) {
498
+ return button;
499
+ }
500
+
501
+ if (state !== 'collapsed' || isMobile) {
502
+ return button;
503
+ }
504
+
505
+ return (
506
+ <Tooltip label={typeof tooltip === 'string' ? tooltip : tooltip.children}>{button}</Tooltip>
507
+ );
508
+ }
509
+
510
+ function SidebarMenuAction({
511
+ className,
512
+ asChild = false,
513
+ showOnHover = false,
514
+ ...props
515
+ }: React.ComponentProps<'button'> & {
516
+ asChild?: boolean;
517
+ showOnHover?: boolean;
518
+ }) {
519
+ const Comp = asChild ? Slot : 'button';
520
+
521
+ return (
522
+ <Comp
523
+ data-slot="sidebar-menu-action"
524
+ data-sidebar="menu-action"
525
+ className={cn(
526
+ 'text-sidebar-foreground ring-sidebar-ring hover:bg-primary-50 dark:hover:bg-primary-900/30 peer-hover/menu-button:text-primary-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
527
+ 'after:absolute after:-inset-2 md:after:hidden',
528
+ 'peer-data-[size=sm]/menu-button:top-1',
529
+ 'peer-data-[size=default]/menu-button:top-1.5',
530
+ 'peer-data-[size=lg]/menu-button:top-2.5',
531
+ 'group-data-[collapsible=icon]:hidden',
532
+ showOnHover &&
533
+ 'peer-data-[active=true]/menu-button:text-primary-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0',
534
+ className,
535
+ )}
536
+ {...props}
537
+ />
538
+ );
539
+ }
540
+
541
+ function SidebarMenuBadge({ className, ...props }: React.ComponentProps<'div'>) {
542
+ return (
543
+ <div
544
+ data-slot="sidebar-menu-badge"
545
+ data-sidebar="menu-badge"
546
+ className={cn(
547
+ 'text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-sm font-medium tabular-nums select-none',
548
+ 'peer-hover/menu-button:text-primary-foreground peer-data-[active=true]/menu-button:text-primary-foreground',
549
+ 'peer-data-[size=sm]/menu-button:top-1',
550
+ 'peer-data-[size=default]/menu-button:top-1.5',
551
+ 'peer-data-[size=lg]/menu-button:top-2.5',
552
+ 'group-data-[collapsible=icon]:hidden',
553
+ className,
554
+ )}
555
+ {...props}
556
+ />
557
+ );
558
+ }
559
+
560
+ function SidebarMenuSkeleton({
561
+ className,
562
+ showIcon = false,
563
+ ...props
564
+ }: React.ComponentProps<'div'> & {
565
+ showIcon?: boolean;
566
+ }) {
567
+ // Random width between 50 to 90%.
568
+ const [width] = React.useState(() => {
569
+ return `${Math.floor(Math.random() * 40) + 50}%`;
570
+ });
571
+
572
+ return (
573
+ <div
574
+ data-slot="sidebar-menu-skeleton"
575
+ data-sidebar="menu-skeleton"
576
+ className={cn('flex h-8 items-center gap-2 rounded-md px-2', className)}
577
+ {...props}
578
+ >
579
+ {showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
580
+ <Skeleton
581
+ className="h-4 max-w-(--skeleton-width) flex-1"
582
+ data-sidebar="menu-skeleton-text"
583
+ style={
584
+ {
585
+ '--skeleton-width': width,
586
+ } as React.CSSProperties
587
+ }
588
+ />
589
+ </div>
590
+ );
591
+ }
592
+
593
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
594
+ return (
595
+ <ul
596
+ data-slot="sidebar-menu-sub"
597
+ data-sidebar="menu-sub"
598
+ className={cn(
599
+ 'border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5',
600
+ 'group-data-[collapsible=icon]:hidden',
601
+ className,
602
+ )}
603
+ {...props}
604
+ />
605
+ );
606
+ }
607
+
608
+ function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) {
609
+ return (
610
+ <li
611
+ data-slot="sidebar-menu-sub-item"
612
+ data-sidebar="menu-sub-item"
613
+ className={cn('group/menu-sub-item relative', className)}
614
+ {...props}
615
+ />
616
+ );
617
+ }
618
+
619
+ function SidebarMenuSubButton({
620
+ asChild = false,
621
+ size = 'md',
622
+ isActive = false,
623
+ className,
624
+ ...props
625
+ }: React.ComponentProps<'a'> & {
626
+ asChild?: boolean;
627
+ size?: 'sm' | 'md';
628
+ isActive?: boolean;
629
+ }) {
630
+ const Comp = asChild ? Slot : 'a';
631
+
632
+ return (
633
+ <Comp
634
+ data-slot="sidebar-menu-sub-button"
635
+ data-sidebar="menu-sub-button"
636
+ data-size={size}
637
+ data-active={isActive}
638
+ className={cn(
639
+ 'text-sidebar-foreground ring-sidebar-ring hover:bg-primary-50 dark:hover:bg-primary-900/30 active:bg-primary-50 dark:active:bg-primary-900/30 [&>svg]:text-muted-foreground flex min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 py-2 outline-hidden transition-all duration-300 ease-in-out focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
640
+ 'data-[active=true]:bg-primary data-[active=true]:text-primary-foreground',
641
+ size === 'sm' && 'text-sm',
642
+ size === 'md' && 'text-base',
643
+ 'group-data-[collapsible=icon]:hidden',
644
+ className,
645
+ )}
646
+ {...props}
647
+ />
648
+ );
649
+ }
650
+
651
+ export {
652
+ Sidebar,
653
+ SidebarContent,
654
+ SidebarFooter,
655
+ SidebarGroup,
656
+ SidebarGroupAction,
657
+ SidebarGroupContent,
658
+ SidebarGroupLabel,
659
+ SidebarHeader,
660
+ SidebarInput,
661
+ SidebarInset,
662
+ SidebarMenu,
663
+ SidebarMenuAction,
664
+ SidebarMenuBadge,
665
+ SidebarMenuButton,
666
+ SidebarMenuItem,
667
+ SidebarMenuSkeleton,
668
+ SidebarMenuSub,
669
+ SidebarMenuSubButton,
670
+ SidebarMenuSubItem,
671
+ SidebarProvider,
672
+ SidebarRail,
673
+ SidebarSeparator,
674
+ SidebarTrigger,
675
+ useSidebar,
676
+ };
@@ -0,0 +1,36 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { Skeleton } from './index';
4
+
5
+ const meta: Meta<typeof Skeleton> = {
6
+ title: 'UI/Skeleton',
7
+ component: Skeleton,
8
+ tags: ['autodocs'],
9
+ };
10
+
11
+ export default meta;
12
+ type Story = StoryObj<typeof Skeleton>;
13
+
14
+ export const Default: Story = {
15
+ render: (args) => (
16
+ <div className="flex items-center space-x-4">
17
+ <Skeleton {...args} className="h-12 w-12 rounded-full" />
18
+ <div className="space-y-2">
19
+ <Skeleton {...args} className="h-4 w-62.5" />
20
+ <Skeleton {...args} className="h-4 w-50" />
21
+ </div>
22
+ </div>
23
+ ),
24
+ };
25
+
26
+ export const CardSkeleton: Story = {
27
+ render: (args) => (
28
+ <div className="flex flex-col space-y-3">
29
+ <Skeleton {...args} className="h-31.25 w-62.5 rounded-xl" />
30
+ <div className="space-y-2">
31
+ <Skeleton {...args} className="h-4 w-62.5" />
32
+ <Skeleton {...args} className="h-4 w-50" />
33
+ </div>
34
+ </div>
35
+ ),
36
+ };