@betterstart/cli 0.1.3 → 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 (234) hide show
  1. package/README.md +133 -0
  2. package/dist/cli.d.ts +1 -9
  3. package/dist/cli.js +13585 -367
  4. package/dist/cli.js.map +1 -1
  5. package/dist/index.d.ts +24 -266
  6. package/dist/index.js +4 -11378
  7. package/dist/index.js.map +1 -1
  8. package/package.json +29 -42
  9. package/templates/schema.json +959 -0
  10. package/templates/tiptap/hooks/use-composed-ref.ts +43 -0
  11. package/templates/tiptap/hooks/use-cursor-visibility.ts +68 -0
  12. package/templates/tiptap/hooks/use-element-rect.ts +166 -0
  13. package/templates/tiptap/hooks/use-is-breakpoint.ts +32 -0
  14. package/templates/tiptap/hooks/use-menu-navigation.ts +182 -0
  15. package/templates/tiptap/hooks/use-scrolling.ts +64 -0
  16. package/templates/tiptap/hooks/use-throttled-callback.ts +146 -0
  17. package/templates/tiptap/hooks/use-tiptap-editor.ts +46 -0
  18. package/templates/tiptap/hooks/use-unmount.ts +21 -0
  19. package/templates/tiptap/hooks/use-window-size.ts +87 -0
  20. package/templates/tiptap/lib/tiptap-utils.ts +587 -0
  21. package/templates/tiptap/styles/_keyframe-animations.scss +91 -0
  22. package/templates/tiptap/styles/_variables.scss +296 -0
  23. package/templates/tiptap/tiptap-extension/node-background-extension.ts +138 -0
  24. package/templates/tiptap/tiptap-icons/align-center-icon.tsx +38 -0
  25. package/templates/tiptap/tiptap-icons/align-justify-icon.tsx +38 -0
  26. package/templates/tiptap/tiptap-icons/align-left-icon.tsx +38 -0
  27. package/templates/tiptap/tiptap-icons/align-right-icon.tsx +38 -0
  28. package/templates/tiptap/tiptap-icons/arrow-left-icon.tsx +24 -0
  29. package/templates/tiptap/tiptap-icons/ban-icon.tsx +26 -0
  30. package/templates/tiptap/tiptap-icons/blockquote-icon.tsx +44 -0
  31. package/templates/tiptap/tiptap-icons/bold-icon.tsx +26 -0
  32. package/templates/tiptap/tiptap-icons/chevron-down-icon.tsx +26 -0
  33. package/templates/tiptap/tiptap-icons/close-icon.tsx +24 -0
  34. package/templates/tiptap/tiptap-icons/code-block-icon.tsx +38 -0
  35. package/templates/tiptap/tiptap-icons/code2-icon.tsx +32 -0
  36. package/templates/tiptap/tiptap-icons/corner-down-left-icon.tsx +26 -0
  37. package/templates/tiptap/tiptap-icons/external-link-icon.tsx +28 -0
  38. package/templates/tiptap/tiptap-icons/heading-five-icon.tsx +28 -0
  39. package/templates/tiptap/tiptap-icons/heading-four-icon.tsx +28 -0
  40. package/templates/tiptap/tiptap-icons/heading-icon.tsx +24 -0
  41. package/templates/tiptap/tiptap-icons/heading-one-icon.tsx +28 -0
  42. package/templates/tiptap/tiptap-icons/heading-six-icon.tsx +30 -0
  43. package/templates/tiptap/tiptap-icons/heading-three-icon.tsx +36 -0
  44. package/templates/tiptap/tiptap-icons/heading-two-icon.tsx +28 -0
  45. package/templates/tiptap/tiptap-icons/highlighter-icon.tsx +26 -0
  46. package/templates/tiptap/tiptap-icons/image-plus-icon.tsx +26 -0
  47. package/templates/tiptap/tiptap-icons/italic-icon.tsx +24 -0
  48. package/templates/tiptap/tiptap-icons/link-icon.tsx +28 -0
  49. package/templates/tiptap/tiptap-icons/list-icon.tsx +56 -0
  50. package/templates/tiptap/tiptap-icons/list-ordered-icon.tsx +56 -0
  51. package/templates/tiptap/tiptap-icons/list-todo-icon.tsx +50 -0
  52. package/templates/tiptap/tiptap-icons/moon-star-icon.tsx +30 -0
  53. package/templates/tiptap/tiptap-icons/redo2-icon.tsx +26 -0
  54. package/templates/tiptap/tiptap-icons/strike-icon.tsx +28 -0
  55. package/templates/tiptap/tiptap-icons/subscript-icon.tsx +38 -0
  56. package/templates/tiptap/tiptap-icons/sun-icon.tsx +58 -0
  57. package/templates/tiptap/tiptap-icons/superscript-icon.tsx +38 -0
  58. package/templates/tiptap/tiptap-icons/trash-icon.tsx +26 -0
  59. package/templates/tiptap/tiptap-icons/underline-icon.tsx +26 -0
  60. package/templates/tiptap/tiptap-icons/undo2-icon.tsx +26 -0
  61. package/templates/tiptap/tiptap-node/blockquote-node/blockquote-node.scss +37 -0
  62. package/templates/tiptap/tiptap-node/code-block-node/code-block-node.scss +54 -0
  63. package/templates/tiptap/tiptap-node/heading-node/heading-node.scss +45 -0
  64. package/templates/tiptap/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.ts +10 -0
  65. package/templates/tiptap/tiptap-node/horizontal-rule-node/horizontal-rule-node.scss +25 -0
  66. package/templates/tiptap/tiptap-node/image-node/image-node.scss +35 -0
  67. package/templates/tiptap/tiptap-node/image-upload-node/image-upload-node-extension.ts +154 -0
  68. package/templates/tiptap/tiptap-node/image-upload-node/image-upload-node.scss +249 -0
  69. package/templates/tiptap/tiptap-node/image-upload-node/image-upload-node.tsx +522 -0
  70. package/templates/tiptap/tiptap-node/image-upload-node/index.tsx +1 -0
  71. package/templates/tiptap/tiptap-node/list-node/list-node.scss +208 -0
  72. package/templates/tiptap/tiptap-node/paragraph-node/paragraph-node.scss +273 -0
  73. package/templates/tiptap/tiptap-ui/blockquote-button/blockquote-button.tsx +104 -0
  74. package/templates/tiptap/tiptap-ui/blockquote-button/index.tsx +2 -0
  75. package/templates/tiptap/tiptap-ui/blockquote-button/use-blockquote.ts +252 -0
  76. package/templates/tiptap/tiptap-ui/code-block-button/code-block-button.tsx +106 -0
  77. package/templates/tiptap/tiptap-ui/code-block-button/index.tsx +2 -0
  78. package/templates/tiptap/tiptap-ui/code-block-button/use-code-block.ts +261 -0
  79. package/templates/tiptap/tiptap-ui/color-highlight-button/color-highlight-button.scss +49 -0
  80. package/templates/tiptap/tiptap-ui/color-highlight-button/color-highlight-button.tsx +153 -0
  81. package/templates/tiptap/tiptap-ui/color-highlight-button/index.tsx +2 -0
  82. package/templates/tiptap/tiptap-ui/color-highlight-button/use-color-highlight.ts +345 -0
  83. package/templates/tiptap/tiptap-ui/color-highlight-popover/color-highlight-popover.tsx +207 -0
  84. package/templates/tiptap/tiptap-ui/color-highlight-popover/index.tsx +1 -0
  85. package/templates/tiptap/tiptap-ui/heading-button/heading-button.tsx +107 -0
  86. package/templates/tiptap/tiptap-ui/heading-button/index.tsx +2 -0
  87. package/templates/tiptap/tiptap-ui/heading-button/use-heading.ts +314 -0
  88. package/templates/tiptap/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.tsx +131 -0
  89. package/templates/tiptap/tiptap-ui/heading-dropdown-menu/index.tsx +2 -0
  90. package/templates/tiptap/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.ts +130 -0
  91. package/templates/tiptap/tiptap-ui/image-upload-button/image-upload-button.tsx +114 -0
  92. package/templates/tiptap/tiptap-ui/image-upload-button/index.tsx +2 -0
  93. package/templates/tiptap/tiptap-ui/image-upload-button/use-image-upload.ts +192 -0
  94. package/templates/tiptap/tiptap-ui/link-popover/index.tsx +2 -0
  95. package/templates/tiptap/tiptap-ui/link-popover/link-popover.tsx +285 -0
  96. package/templates/tiptap/tiptap-ui/link-popover/use-link-popover.ts +286 -0
  97. package/templates/tiptap/tiptap-ui/list-button/index.tsx +2 -0
  98. package/templates/tiptap/tiptap-ui/list-button/list-button.tsx +108 -0
  99. package/templates/tiptap/tiptap-ui/list-button/use-list.ts +329 -0
  100. package/templates/tiptap/tiptap-ui/list-dropdown-menu/index.tsx +1 -0
  101. package/templates/tiptap/tiptap-ui/list-dropdown-menu/list-dropdown-menu.tsx +123 -0
  102. package/templates/tiptap/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.ts +203 -0
  103. package/templates/tiptap/tiptap-ui/mark-button/index.tsx +2 -0
  104. package/templates/tiptap/tiptap-ui/mark-button/mark-button.tsx +107 -0
  105. package/templates/tiptap/tiptap-ui/mark-button/use-mark.ts +206 -0
  106. package/templates/tiptap/tiptap-ui/text-align-button/index.tsx +2 -0
  107. package/templates/tiptap/tiptap-ui/text-align-button/text-align-button.tsx +118 -0
  108. package/templates/tiptap/tiptap-ui/text-align-button/use-text-align.ts +212 -0
  109. package/templates/tiptap/tiptap-ui/undo-redo-button/index.tsx +2 -0
  110. package/templates/tiptap/tiptap-ui/undo-redo-button/undo-redo-button.tsx +105 -0
  111. package/templates/tiptap/tiptap-ui/undo-redo-button/use-undo-redo.ts +173 -0
  112. package/templates/tiptap/tiptap-ui-primitive/badge/badge-colors.scss +395 -0
  113. package/templates/tiptap/tiptap-ui-primitive/badge/badge-group.scss +16 -0
  114. package/templates/tiptap/tiptap-ui-primitive/badge/badge.scss +99 -0
  115. package/templates/tiptap/tiptap-ui-primitive/badge/badge.tsx +46 -0
  116. package/templates/tiptap/tiptap-ui-primitive/badge/index.tsx +1 -0
  117. package/templates/tiptap/tiptap-ui-primitive/button/button-colors.scss +429 -0
  118. package/templates/tiptap/tiptap-ui-primitive/button/button-group.scss +22 -0
  119. package/templates/tiptap/tiptap-ui-primitive/button/button.scss +314 -0
  120. package/templates/tiptap/tiptap-ui-primitive/button/button.tsx +102 -0
  121. package/templates/tiptap/tiptap-ui-primitive/button/index.tsx +1 -0
  122. package/templates/tiptap/tiptap-ui-primitive/card/card.scss +77 -0
  123. package/templates/tiptap/tiptap-ui-primitive/card/card.tsx +59 -0
  124. package/templates/tiptap/tiptap-ui-primitive/card/index.tsx +1 -0
  125. package/templates/tiptap/tiptap-ui-primitive/dropdown-menu/dropdown-menu.scss +63 -0
  126. package/templates/tiptap/tiptap-ui-primitive/dropdown-menu/dropdown-menu.tsx +95 -0
  127. package/templates/tiptap/tiptap-ui-primitive/dropdown-menu/index.tsx +1 -0
  128. package/templates/tiptap/tiptap-ui-primitive/input/index.tsx +1 -0
  129. package/templates/tiptap/tiptap-ui-primitive/input/input.scss +45 -0
  130. package/templates/tiptap/tiptap-ui-primitive/input/input.tsx +18 -0
  131. package/templates/tiptap/tiptap-ui-primitive/popover/index.tsx +1 -0
  132. package/templates/tiptap/tiptap-ui-primitive/popover/popover.scss +63 -0
  133. package/templates/tiptap/tiptap-ui-primitive/popover/popover.tsx +33 -0
  134. package/templates/tiptap/tiptap-ui-primitive/separator/index.tsx +1 -0
  135. package/templates/tiptap/tiptap-ui-primitive/separator/separator.scss +23 -0
  136. package/templates/tiptap/tiptap-ui-primitive/separator/separator.tsx +33 -0
  137. package/templates/tiptap/tiptap-ui-primitive/spacer/index.tsx +1 -0
  138. package/templates/tiptap/tiptap-ui-primitive/spacer/spacer.tsx +21 -0
  139. package/templates/tiptap/tiptap-ui-primitive/toolbar/index.tsx +1 -0
  140. package/templates/tiptap/tiptap-ui-primitive/toolbar/toolbar.scss +98 -0
  141. package/templates/tiptap/tiptap-ui-primitive/toolbar/toolbar.tsx +113 -0
  142. package/templates/tiptap/tiptap-ui-primitive/tooltip/index.tsx +1 -0
  143. package/templates/tiptap/tiptap-ui-primitive/tooltip/tooltip.scss +43 -0
  144. package/templates/tiptap/tiptap-ui-primitive/tooltip/tooltip.tsx +223 -0
  145. package/templates/ui/accordion.tsx +52 -0
  146. package/templates/ui/alert-dialog.tsx +116 -0
  147. package/templates/ui/alert.tsx +48 -0
  148. package/templates/ui/aspect-ratio.tsx +7 -0
  149. package/templates/ui/avatar.tsx +46 -0
  150. package/templates/ui/badge.tsx +32 -0
  151. package/templates/ui/breadcrumb.tsx +98 -0
  152. package/templates/ui/button-group.tsx +77 -0
  153. package/templates/ui/button.tsx +48 -0
  154. package/templates/ui/calendar.tsx +176 -0
  155. package/templates/ui/card.tsx +54 -0
  156. package/templates/ui/carousel.tsx +234 -0
  157. package/templates/ui/chart.tsx +349 -0
  158. package/templates/ui/checkbox.tsx +27 -0
  159. package/templates/ui/collapsible.tsx +11 -0
  160. package/templates/ui/command.tsx +142 -0
  161. package/templates/ui/context-menu.tsx +188 -0
  162. package/templates/ui/curriculum-editor.tsx +601 -0
  163. package/templates/ui/date-picker.tsx +70 -0
  164. package/templates/ui/dialog.tsx +103 -0
  165. package/templates/ui/drawer.tsx +99 -0
  166. package/templates/ui/dropdown-menu.tsx +185 -0
  167. package/templates/ui/dynamic-list-field.tsx +95 -0
  168. package/templates/ui/empty.tsx +90 -0
  169. package/templates/ui/field.tsx +231 -0
  170. package/templates/ui/file-upload-example.tsx +113 -0
  171. package/templates/ui/form.tsx +172 -0
  172. package/templates/ui/hover-card.tsx +28 -0
  173. package/templates/ui/icon-picker.tsx +435 -0
  174. package/templates/ui/icons-data.ts +6 -0
  175. package/templates/ui/image-upload-field.tsx +360 -0
  176. package/templates/ui/input-group.tsx +160 -0
  177. package/templates/ui/input-otp.tsx +70 -0
  178. package/templates/ui/input.tsx +21 -0
  179. package/templates/ui/item.tsx +171 -0
  180. package/templates/ui/kbd.tsx +28 -0
  181. package/templates/ui/label.tsx +20 -0
  182. package/templates/ui/logo.tsx +113 -0
  183. package/templates/ui/markdown-editor.tsx +303 -0
  184. package/templates/ui/markdown-utils.ts +128 -0
  185. package/templates/ui/media-upload-field.tsx +255 -0
  186. package/templates/ui/menubar.tsx +230 -0
  187. package/templates/ui/navigation-menu.tsx +119 -0
  188. package/templates/ui/pagination.tsx +96 -0
  189. package/templates/ui/placeholder.tsx +25 -0
  190. package/templates/ui/popover.tsx +32 -0
  191. package/templates/ui/progress.tsx +24 -0
  192. package/templates/ui/radio-group.tsx +37 -0
  193. package/templates/ui/resizable.tsx +41 -0
  194. package/templates/ui/rich-text-editor.tsx +374 -0
  195. package/templates/ui/scroll-area.tsx +45 -0
  196. package/templates/ui/select.tsx +151 -0
  197. package/templates/ui/separator.tsx +25 -0
  198. package/templates/ui/sheet.tsx +120 -0
  199. package/templates/ui/sidebar.tsx +687 -0
  200. package/templates/ui/skeleton.tsx +7 -0
  201. package/templates/ui/slider.tsx +24 -0
  202. package/templates/ui/sonner.tsx +29 -0
  203. package/templates/ui/spinner.tsx +15 -0
  204. package/templates/ui/switch.tsx +28 -0
  205. package/templates/ui/table.tsx +93 -0
  206. package/templates/ui/tabs.tsx +54 -0
  207. package/templates/ui/textarea.tsx +20 -0
  208. package/templates/ui/toast.tsx +127 -0
  209. package/templates/ui/toggle-group.tsx +56 -0
  210. package/templates/ui/toggle.tsx +43 -0
  211. package/templates/ui/tooltip.tsx +31 -0
  212. package/templates/ui/use-mobile.tsx +19 -0
  213. package/templates/ui/video-upload-field.tsx +368 -0
  214. package/dist/chunk-EIH4RRIJ.js +0 -183
  215. package/dist/chunk-EIH4RRIJ.js.map +0 -1
  216. package/dist/chunk-NKRQYAS6.js +0 -260
  217. package/dist/chunk-NKRQYAS6.js.map +0 -1
  218. package/dist/chunk-QLVSHP7X.js +0 -235
  219. package/dist/chunk-QLVSHP7X.js.map +0 -1
  220. package/dist/chunk-WY6BC55D.js +0 -357
  221. package/dist/chunk-WY6BC55D.js.map +0 -1
  222. package/dist/config/index.d.ts +0 -93
  223. package/dist/config/index.js +0 -58
  224. package/dist/config/index.js.map +0 -1
  225. package/dist/core/index.d.ts +0 -415
  226. package/dist/core/index.js +0 -906
  227. package/dist/core/index.js.map +0 -1
  228. package/dist/import-resolver-BaZ-rzkH.d.ts +0 -123
  229. package/dist/logger-awLb347n.d.ts +0 -81
  230. package/dist/plugins/index.d.ts +0 -213
  231. package/dist/plugins/index.js +0 -365
  232. package/dist/plugins/index.js.map +0 -1
  233. package/dist/types-ByX_gl6y.d.ts +0 -232
  234. package/dist/types-eI549DEG.d.ts +0 -331
@@ -0,0 +1,687 @@
1
+ 'use client'
2
+
3
+ import { cn } from '@cms/utils/cn'
4
+ import { Slot } from '@radix-ui/react-slot'
5
+ import { cva, type VariantProps } from 'class-variance-authority'
6
+ import { PanelLeftIcon } from 'lucide-react'
7
+ import * as React from 'react'
8
+ import { Button } from './button'
9
+ import { Input } from './input'
10
+ import { Separator } from './separator'
11
+ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from './sheet'
12
+ import { Skeleton } from './skeleton'
13
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './tooltip'
14
+ import { useIsMobile } from './use-mobile'
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])
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, 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('group/sidebar-wrapper bg-background flex min-h-svh w-full', className)}
127
+ {...props}
128
+ >
129
+ {children}
130
+ </div>
131
+ </TooltipProvider>
132
+ </SidebarContext.Provider>
133
+ )
134
+ }
135
+
136
+ function Sidebar({
137
+ side = 'left',
138
+ variant = 'sidebar',
139
+ collapsible = 'offcanvas',
140
+ className,
141
+ children,
142
+ ...props
143
+ }: React.ComponentProps<'div'> & {
144
+ side?: 'left' | 'right'
145
+ variant?: 'sidebar' | 'floating' | 'inset'
146
+ collapsible?: 'offcanvas' | 'icon' | 'none'
147
+ }) {
148
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
149
+
150
+ if (collapsible === 'none') {
151
+ return (
152
+ <div
153
+ data-slot="sidebar"
154
+ className={cn(
155
+ 'bg-sidebar text-default flex h-full w-(--sidebar-width) flex-col',
156
+ className
157
+ )}
158
+ {...props}
159
+ >
160
+ {children}
161
+ </div>
162
+ )
163
+ }
164
+
165
+ if (isMobile) {
166
+ return (
167
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
168
+ <SheetContent
169
+ data-sidebar="sidebar"
170
+ data-slot="sidebar"
171
+ data-mobile="true"
172
+ className="bg-white text-default w-(--sidebar-width) p-0 [&>button]:hidden"
173
+ style={
174
+ {
175
+ '--sidebar-width': SIDEBAR_WIDTH_MOBILE
176
+ } as React.CSSProperties
177
+ }
178
+ side={side}
179
+ >
180
+ <SheetHeader className="sr-only">
181
+ <SheetTitle>Sidebar</SheetTitle>
182
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
183
+ </SheetHeader>
184
+ <div className="flex h-full w-full flex-col">{children}</div>
185
+ </SheetContent>
186
+ </Sheet>
187
+ )
188
+ }
189
+
190
+ return (
191
+ <div
192
+ className="group peer text-sidebar-foreground bg-background hidden md:block"
193
+ data-state={state}
194
+ data-collapsible={state === 'collapsed' ? collapsible : ''}
195
+ data-variant={variant}
196
+ data-side={side}
197
+ data-slot="sidebar"
198
+ >
199
+ {/* This is what handles the sidebar gap on desktop */}
200
+ <div
201
+ data-slot="sidebar-gap"
202
+ className={cn(
203
+ 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',
204
+ 'group-data-[collapsible=offcanvas]:w-0',
205
+ 'group-data-[side=right]:rotate-180',
206
+ variant === 'floating' || variant === 'inset'
207
+ ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
208
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)'
209
+ )}
210
+ />
211
+ <div
212
+ data-slot="sidebar-container"
213
+ className={cn(
214
+ 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',
215
+ side === 'left'
216
+ ? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
217
+ : 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
218
+ // Adjust the padding for floating and inset variants.
219
+ variant === 'floating' || variant === 'inset'
220
+ ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
221
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
222
+ className
223
+ )}
224
+ {...props}
225
+ >
226
+ <div
227
+ data-sidebar="sidebar"
228
+ data-slot="sidebar-inner"
229
+ className="bg-sidebar text-default group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg corner-squircle group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"
230
+ >
231
+ {children}
232
+ </div>
233
+ </div>
234
+ </div>
235
+ )
236
+ }
237
+
238
+ function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
239
+ const { toggleSidebar } = useSidebar()
240
+
241
+ return (
242
+ <Button
243
+ data-sidebar="trigger"
244
+ data-slot="sidebar-trigger"
245
+ variant="ghost"
246
+ size="icon"
247
+ className={cn('size-7', className)}
248
+ onClick={(event) => {
249
+ onClick?.(event)
250
+ toggleSidebar()
251
+ }}
252
+ {...props}
253
+ suppressHydrationWarning
254
+ >
255
+ <PanelLeftIcon />
256
+ <span className="sr-only">Toggle Sidebar</span>
257
+ </Button>
258
+ )
259
+ }
260
+
261
+ function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
262
+ const { toggleSidebar } = useSidebar()
263
+
264
+ return (
265
+ <button
266
+ data-sidebar="rail"
267
+ data-slot="sidebar-rail"
268
+ aria-label="Toggle Sidebar"
269
+ tabIndex={-1}
270
+ onClick={toggleSidebar}
271
+ title="Toggle Sidebar"
272
+ className={cn(
273
+ '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',
274
+ 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
275
+ '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
276
+ 'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full',
277
+ '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
278
+ '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
279
+ className
280
+ )}
281
+ {...props}
282
+ />
283
+ )
284
+ }
285
+
286
+ function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
287
+ return (
288
+ <main
289
+ data-slot="sidebar-inset"
290
+ className={cn(
291
+ 'bg-background relative flex w-full flex-1 flex-col',
292
+ 'md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-2xl corner-squircle md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2',
293
+ className
294
+ )}
295
+ {...props}
296
+ />
297
+ )
298
+ }
299
+
300
+ function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
301
+ return (
302
+ <Input
303
+ data-slot="sidebar-input"
304
+ data-sidebar="input"
305
+ className={cn('bg-background h-8 w-full shadow-none', className)}
306
+ {...props}
307
+ />
308
+ )
309
+ }
310
+
311
+ function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
312
+ return (
313
+ <div
314
+ data-slot="sidebar-header"
315
+ data-sidebar="header"
316
+ className={cn('flex flex-col gap-2 p-2', className)}
317
+ {...props}
318
+ />
319
+ )
320
+ }
321
+
322
+ function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
323
+ return (
324
+ <div
325
+ data-slot="sidebar-footer"
326
+ data-sidebar="footer"
327
+ className={cn('flex flex-col gap-2 p-2', className)}
328
+ {...props}
329
+ />
330
+ )
331
+ }
332
+
333
+ function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
334
+ return (
335
+ <Separator
336
+ data-slot="sidebar-separator"
337
+ data-sidebar="separator"
338
+ className={cn('bg-sidebar-border mx-2 w-auto', className)}
339
+ {...props}
340
+ />
341
+ )
342
+ }
343
+
344
+ function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
345
+ return (
346
+ <div
347
+ data-slot="sidebar-content"
348
+ data-sidebar="content"
349
+ className={cn(
350
+ 'flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',
351
+ className
352
+ )}
353
+ {...props}
354
+ />
355
+ )
356
+ }
357
+
358
+ function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
359
+ return (
360
+ <div
361
+ data-slot="sidebar-group"
362
+ data-sidebar="group"
363
+ className={cn('relative flex w-full min-w-0 flex-col p-2', className)}
364
+ {...props}
365
+ />
366
+ )
367
+ }
368
+
369
+ function SidebarGroupLabel({
370
+ className,
371
+ asChild = false,
372
+ ...props
373
+ }: React.ComponentProps<'div'> & { asChild?: boolean }) {
374
+ const Comp = asChild ? Slot : 'div'
375
+
376
+ return (
377
+ <Comp
378
+ data-slot="sidebar-group-label"
379
+ data-sidebar="group-label"
380
+ className={cn(
381
+ 'text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md corner-squircle px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
382
+ 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
383
+ className
384
+ )}
385
+ {...props}
386
+ />
387
+ )
388
+ }
389
+
390
+ function SidebarGroupAction({
391
+ className,
392
+ asChild = false,
393
+ ...props
394
+ }: React.ComponentProps<'button'> & { asChild?: boolean }) {
395
+ const Comp = asChild ? Slot : 'button'
396
+
397
+ return (
398
+ <Comp
399
+ data-slot="sidebar-group-action"
400
+ data-sidebar="group-action"
401
+ className={cn(
402
+ 'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md corner-squircle p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
403
+ // Increases the hit area of the button on mobile.
404
+ 'after:absolute after:-inset-2 md:after:hidden',
405
+ 'group-data-[collapsible=icon]:hidden',
406
+ className
407
+ )}
408
+ {...props}
409
+ />
410
+ )
411
+ }
412
+
413
+ function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {
414
+ return (
415
+ <div
416
+ data-slot="sidebar-group-content"
417
+ data-sidebar="group-content"
418
+ className={cn('w-full text-sm', className)}
419
+ {...props}
420
+ />
421
+ )
422
+ }
423
+
424
+ function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {
425
+ return (
426
+ <ul
427
+ data-slot="sidebar-menu"
428
+ data-sidebar="menu"
429
+ className={cn('flex w-full min-w-0 flex-col gap-1', className)}
430
+ {...props}
431
+ />
432
+ )
433
+ }
434
+
435
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
436
+ return (
437
+ <li
438
+ data-slot="sidebar-menu-item"
439
+ data-sidebar="menu-item"
440
+ className={cn('group/menu-item relative', className)}
441
+ {...props}
442
+ />
443
+ )
444
+ }
445
+
446
+ const sidebarMenuButtonVariants = cva(
447
+ 'peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md corner-squircle p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] 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 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
448
+ {
449
+ variants: {
450
+ variant: {
451
+ default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
452
+ outline:
453
+ '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))]'
454
+ },
455
+ size: {
456
+ default: 'h-8 text-sm',
457
+ sm: 'h-7 text-xs',
458
+ lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!'
459
+ }
460
+ },
461
+ defaultVariants: {
462
+ variant: 'default',
463
+ size: 'default'
464
+ }
465
+ }
466
+ )
467
+
468
+ function SidebarMenuButton({
469
+ asChild = false,
470
+ isActive = false,
471
+ variant = 'default',
472
+ size = 'default',
473
+ tooltip,
474
+ className,
475
+ ...props
476
+ }: React.ComponentProps<'button'> & {
477
+ asChild?: boolean
478
+ isActive?: boolean
479
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>
480
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
481
+ const Comp = asChild ? Slot : 'button'
482
+ const { isMobile, state } = useSidebar()
483
+
484
+ const button = (
485
+ <Comp
486
+ data-slot="sidebar-menu-button"
487
+ data-sidebar="menu-button"
488
+ data-size={size}
489
+ data-active={isActive}
490
+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
491
+ {...props}
492
+ />
493
+ )
494
+
495
+ if (!tooltip) {
496
+ return button
497
+ }
498
+
499
+ if (typeof tooltip === 'string') {
500
+ tooltip = {
501
+ children: tooltip
502
+ }
503
+ }
504
+
505
+ return (
506
+ <Tooltip>
507
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
508
+ <TooltipContent
509
+ side="right"
510
+ align="center"
511
+ hidden={state !== 'collapsed' || isMobile}
512
+ {...tooltip}
513
+ />
514
+ </Tooltip>
515
+ )
516
+ }
517
+
518
+ function SidebarMenuAction({
519
+ className,
520
+ asChild = false,
521
+ showOnHover = false,
522
+ ...props
523
+ }: React.ComponentProps<'button'> & {
524
+ asChild?: boolean
525
+ showOnHover?: boolean
526
+ }) {
527
+ const Comp = asChild ? Slot : 'button'
528
+
529
+ return (
530
+ <Comp
531
+ data-slot="sidebar-menu-action"
532
+ data-sidebar="menu-action"
533
+ className={cn(
534
+ 'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md corner-squircle p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
535
+ // Increases the hit area of the button on mobile.
536
+ 'after:absolute after:-inset-2 md:after:hidden',
537
+ 'peer-data-[size=sm]/menu-button:top-1',
538
+ 'peer-data-[size=default]/menu-button:top-1.5',
539
+ 'peer-data-[size=lg]/menu-button:top-2.5',
540
+ 'group-data-[collapsible=icon]:hidden',
541
+ showOnHover &&
542
+ 'peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0',
543
+ className
544
+ )}
545
+ {...props}
546
+ />
547
+ )
548
+ }
549
+
550
+ function SidebarMenuBadge({ className, ...props }: React.ComponentProps<'div'>) {
551
+ return (
552
+ <div
553
+ data-slot="sidebar-menu-badge"
554
+ data-sidebar="menu-badge"
555
+ className={cn(
556
+ 'text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md corner-squircle px-1 text-xs font-medium tabular-nums select-none',
557
+ 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground',
558
+ 'peer-data-[size=sm]/menu-button:top-1',
559
+ 'peer-data-[size=default]/menu-button:top-1.5',
560
+ 'peer-data-[size=lg]/menu-button:top-2.5',
561
+ 'group-data-[collapsible=icon]:hidden',
562
+ className
563
+ )}
564
+ {...props}
565
+ />
566
+ )
567
+ }
568
+
569
+ function SidebarMenuSkeleton({
570
+ className,
571
+ showIcon = false,
572
+ ...props
573
+ }: React.ComponentProps<'div'> & {
574
+ showIcon?: boolean
575
+ }) {
576
+ // Random width between 50 to 90%.
577
+ const width = React.useMemo(() => {
578
+ return `${Math.floor(Math.random() * 40) + 50}%`
579
+ }, [])
580
+
581
+ return (
582
+ <div
583
+ data-slot="sidebar-menu-skeleton"
584
+ data-sidebar="menu-skeleton"
585
+ className={cn('flex h-8 items-center gap-2 rounded-md corner-squircle px-2', className)}
586
+ {...props}
587
+ >
588
+ {showIcon && (
589
+ <Skeleton className="size-4 rounded-md corner-squircle" data-sidebar="menu-skeleton-icon" />
590
+ )}
591
+ <Skeleton
592
+ className="h-4 max-w-(--skeleton-width) flex-1"
593
+ data-sidebar="menu-skeleton-text"
594
+ style={
595
+ {
596
+ '--skeleton-width': width
597
+ } as React.CSSProperties
598
+ }
599
+ />
600
+ </div>
601
+ )
602
+ }
603
+
604
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
605
+ return (
606
+ <ul
607
+ data-slot="sidebar-menu-sub"
608
+ data-sidebar="menu-sub"
609
+ className={cn(
610
+ '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',
611
+ 'group-data-[collapsible=icon]:hidden',
612
+ className
613
+ )}
614
+ {...props}
615
+ />
616
+ )
617
+ }
618
+
619
+ function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) {
620
+ return (
621
+ <li
622
+ data-slot="sidebar-menu-sub-item"
623
+ data-sidebar="menu-sub-item"
624
+ className={cn('group/menu-sub-item relative', className)}
625
+ {...props}
626
+ />
627
+ )
628
+ }
629
+
630
+ function SidebarMenuSubButton({
631
+ asChild = false,
632
+ size = 'md',
633
+ isActive = false,
634
+ className,
635
+ ...props
636
+ }: React.ComponentProps<'a'> & {
637
+ asChild?: boolean
638
+ size?: 'sm' | 'md'
639
+ isActive?: boolean
640
+ }) {
641
+ const Comp = asChild ? Slot : 'a'
642
+
643
+ return (
644
+ <Comp
645
+ data-slot="sidebar-menu-sub-button"
646
+ data-sidebar="menu-sub-button"
647
+ data-size={size}
648
+ data-active={isActive}
649
+ className={cn(
650
+ 'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md corner-squircle px-2 outline-hidden 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',
651
+ 'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground',
652
+ size === 'sm' && 'text-xs',
653
+ size === 'md' && 'text-sm',
654
+ 'group-data-[collapsible=icon]:hidden',
655
+ className
656
+ )}
657
+ {...props}
658
+ />
659
+ )
660
+ }
661
+
662
+ export {
663
+ Sidebar,
664
+ SidebarContent,
665
+ SidebarFooter,
666
+ SidebarGroup,
667
+ SidebarGroupAction,
668
+ SidebarGroupContent,
669
+ SidebarGroupLabel,
670
+ SidebarHeader,
671
+ SidebarInput,
672
+ SidebarInset,
673
+ SidebarMenu,
674
+ SidebarMenuAction,
675
+ SidebarMenuBadge,
676
+ SidebarMenuButton,
677
+ SidebarMenuItem,
678
+ SidebarMenuSkeleton,
679
+ SidebarMenuSub,
680
+ SidebarMenuSubButton,
681
+ SidebarMenuSubItem,
682
+ SidebarProvider,
683
+ SidebarRail,
684
+ SidebarSeparator,
685
+ SidebarTrigger,
686
+ useSidebar
687
+ }
@@ -0,0 +1,7 @@
1
+ import { cn } from '@cms/utils/cn'
2
+
3
+ function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
4
+ return <div className={cn('animate-pulse rounded-md bg-primary/10', className)} {...props} />
5
+ }
6
+
7
+ export { Skeleton }