@betterstart/cli 0.1.3 → 0.1.4

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 +13484 -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 +684 -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,684 @@
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('bg-white text-default flex h-full w-(--sidebar-width) flex-col', className)}
155
+ {...props}
156
+ >
157
+ {children}
158
+ </div>
159
+ )
160
+ }
161
+
162
+ if (isMobile) {
163
+ return (
164
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
165
+ <SheetContent
166
+ data-sidebar="sidebar"
167
+ data-slot="sidebar"
168
+ data-mobile="true"
169
+ className="bg-white text-default w-(--sidebar-width) p-0 [&>button]:hidden"
170
+ style={
171
+ {
172
+ '--sidebar-width': SIDEBAR_WIDTH_MOBILE
173
+ } as React.CSSProperties
174
+ }
175
+ side={side}
176
+ >
177
+ <SheetHeader className="sr-only">
178
+ <SheetTitle>Sidebar</SheetTitle>
179
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
180
+ </SheetHeader>
181
+ <div className="flex h-full w-full flex-col">{children}</div>
182
+ </SheetContent>
183
+ </Sheet>
184
+ )
185
+ }
186
+
187
+ return (
188
+ <div
189
+ className="group peer text-sidebar-foreground bg-background hidden md:block"
190
+ data-state={state}
191
+ data-collapsible={state === 'collapsed' ? collapsible : ''}
192
+ data-variant={variant}
193
+ data-side={side}
194
+ data-slot="sidebar"
195
+ >
196
+ {/* This is what handles the sidebar gap on desktop */}
197
+ <div
198
+ data-slot="sidebar-gap"
199
+ className={cn(
200
+ 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',
201
+ 'group-data-[collapsible=offcanvas]:w-0',
202
+ 'group-data-[side=right]:rotate-180',
203
+ variant === 'floating' || variant === 'inset'
204
+ ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
205
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)'
206
+ )}
207
+ />
208
+ <div
209
+ data-slot="sidebar-container"
210
+ className={cn(
211
+ 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex',
212
+ side === 'left'
213
+ ? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
214
+ : 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
215
+ // Adjust the padding for floating and inset variants.
216
+ variant === 'floating' || variant === 'inset'
217
+ ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
218
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
219
+ className
220
+ )}
221
+ {...props}
222
+ >
223
+ <div
224
+ data-sidebar="sidebar"
225
+ data-slot="sidebar-inner"
226
+ className="bg-background 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"
227
+ >
228
+ {children}
229
+ </div>
230
+ </div>
231
+ </div>
232
+ )
233
+ }
234
+
235
+ function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
236
+ const { toggleSidebar } = useSidebar()
237
+
238
+ return (
239
+ <Button
240
+ data-sidebar="trigger"
241
+ data-slot="sidebar-trigger"
242
+ variant="ghost"
243
+ size="icon"
244
+ className={cn('size-7', className)}
245
+ onClick={(event) => {
246
+ onClick?.(event)
247
+ toggleSidebar()
248
+ }}
249
+ {...props}
250
+ suppressHydrationWarning
251
+ >
252
+ <PanelLeftIcon />
253
+ <span className="sr-only">Toggle Sidebar</span>
254
+ </Button>
255
+ )
256
+ }
257
+
258
+ function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
259
+ const { toggleSidebar } = useSidebar()
260
+
261
+ return (
262
+ <button
263
+ data-sidebar="rail"
264
+ data-slot="sidebar-rail"
265
+ aria-label="Toggle Sidebar"
266
+ tabIndex={-1}
267
+ onClick={toggleSidebar}
268
+ title="Toggle Sidebar"
269
+ className={cn(
270
+ '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',
271
+ 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
272
+ '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
273
+ 'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full',
274
+ '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
275
+ '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
276
+ className
277
+ )}
278
+ {...props}
279
+ />
280
+ )
281
+ }
282
+
283
+ function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
284
+ return (
285
+ <main
286
+ data-slot="sidebar-inset"
287
+ className={cn(
288
+ 'bg-background relative flex w-full flex-1 flex-col',
289
+ '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',
290
+ className
291
+ )}
292
+ {...props}
293
+ />
294
+ )
295
+ }
296
+
297
+ function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
298
+ return (
299
+ <Input
300
+ data-slot="sidebar-input"
301
+ data-sidebar="input"
302
+ className={cn('bg-background h-8 w-full shadow-none', className)}
303
+ {...props}
304
+ />
305
+ )
306
+ }
307
+
308
+ function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
309
+ return (
310
+ <div
311
+ data-slot="sidebar-header"
312
+ data-sidebar="header"
313
+ className={cn('flex flex-col gap-2 p-2', className)}
314
+ {...props}
315
+ />
316
+ )
317
+ }
318
+
319
+ function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
320
+ return (
321
+ <div
322
+ data-slot="sidebar-footer"
323
+ data-sidebar="footer"
324
+ className={cn('flex flex-col gap-2 p-2', className)}
325
+ {...props}
326
+ />
327
+ )
328
+ }
329
+
330
+ function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
331
+ return (
332
+ <Separator
333
+ data-slot="sidebar-separator"
334
+ data-sidebar="separator"
335
+ className={cn('bg-sidebar-border mx-2 w-auto', className)}
336
+ {...props}
337
+ />
338
+ )
339
+ }
340
+
341
+ function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
342
+ return (
343
+ <div
344
+ data-slot="sidebar-content"
345
+ data-sidebar="content"
346
+ className={cn(
347
+ 'flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',
348
+ className
349
+ )}
350
+ {...props}
351
+ />
352
+ )
353
+ }
354
+
355
+ function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
356
+ return (
357
+ <div
358
+ data-slot="sidebar-group"
359
+ data-sidebar="group"
360
+ className={cn('relative flex w-full min-w-0 flex-col p-2', className)}
361
+ {...props}
362
+ />
363
+ )
364
+ }
365
+
366
+ function SidebarGroupLabel({
367
+ className,
368
+ asChild = false,
369
+ ...props
370
+ }: React.ComponentProps<'div'> & { asChild?: boolean }) {
371
+ const Comp = asChild ? Slot : 'div'
372
+
373
+ return (
374
+ <Comp
375
+ data-slot="sidebar-group-label"
376
+ data-sidebar="group-label"
377
+ className={cn(
378
+ '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',
379
+ 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0',
380
+ className
381
+ )}
382
+ {...props}
383
+ />
384
+ )
385
+ }
386
+
387
+ function SidebarGroupAction({
388
+ className,
389
+ asChild = false,
390
+ ...props
391
+ }: React.ComponentProps<'button'> & { asChild?: boolean }) {
392
+ const Comp = asChild ? Slot : 'button'
393
+
394
+ return (
395
+ <Comp
396
+ data-slot="sidebar-group-action"
397
+ data-sidebar="group-action"
398
+ className={cn(
399
+ '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',
400
+ // Increases the hit area of the button on mobile.
401
+ 'after:absolute after:-inset-2 md:after:hidden',
402
+ 'group-data-[collapsible=icon]:hidden',
403
+ className
404
+ )}
405
+ {...props}
406
+ />
407
+ )
408
+ }
409
+
410
+ function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {
411
+ return (
412
+ <div
413
+ data-slot="sidebar-group-content"
414
+ data-sidebar="group-content"
415
+ className={cn('w-full text-sm', className)}
416
+ {...props}
417
+ />
418
+ )
419
+ }
420
+
421
+ function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {
422
+ return (
423
+ <ul
424
+ data-slot="sidebar-menu"
425
+ data-sidebar="menu"
426
+ className={cn('flex w-full min-w-0 flex-col gap-1', className)}
427
+ {...props}
428
+ />
429
+ )
430
+ }
431
+
432
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
433
+ return (
434
+ <li
435
+ data-slot="sidebar-menu-item"
436
+ data-sidebar="menu-item"
437
+ className={cn('group/menu-item relative', className)}
438
+ {...props}
439
+ />
440
+ )
441
+ }
442
+
443
+ const sidebarMenuButtonVariants = cva(
444
+ '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',
445
+ {
446
+ variants: {
447
+ variant: {
448
+ default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
449
+ outline:
450
+ '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))]'
451
+ },
452
+ size: {
453
+ default: 'h-8 text-sm',
454
+ sm: 'h-7 text-xs',
455
+ lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!'
456
+ }
457
+ },
458
+ defaultVariants: {
459
+ variant: 'default',
460
+ size: 'default'
461
+ }
462
+ }
463
+ )
464
+
465
+ function SidebarMenuButton({
466
+ asChild = false,
467
+ isActive = false,
468
+ variant = 'default',
469
+ size = 'default',
470
+ tooltip,
471
+ className,
472
+ ...props
473
+ }: React.ComponentProps<'button'> & {
474
+ asChild?: boolean
475
+ isActive?: boolean
476
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>
477
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
478
+ const Comp = asChild ? Slot : 'button'
479
+ const { isMobile, state } = useSidebar()
480
+
481
+ const button = (
482
+ <Comp
483
+ data-slot="sidebar-menu-button"
484
+ data-sidebar="menu-button"
485
+ data-size={size}
486
+ data-active={isActive}
487
+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
488
+ {...props}
489
+ />
490
+ )
491
+
492
+ if (!tooltip) {
493
+ return button
494
+ }
495
+
496
+ if (typeof tooltip === 'string') {
497
+ tooltip = {
498
+ children: tooltip
499
+ }
500
+ }
501
+
502
+ return (
503
+ <Tooltip>
504
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
505
+ <TooltipContent
506
+ side="right"
507
+ align="center"
508
+ hidden={state !== 'collapsed' || isMobile}
509
+ {...tooltip}
510
+ />
511
+ </Tooltip>
512
+ )
513
+ }
514
+
515
+ function SidebarMenuAction({
516
+ className,
517
+ asChild = false,
518
+ showOnHover = false,
519
+ ...props
520
+ }: React.ComponentProps<'button'> & {
521
+ asChild?: boolean
522
+ showOnHover?: boolean
523
+ }) {
524
+ const Comp = asChild ? Slot : 'button'
525
+
526
+ return (
527
+ <Comp
528
+ data-slot="sidebar-menu-action"
529
+ data-sidebar="menu-action"
530
+ className={cn(
531
+ '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',
532
+ // Increases the hit area of the button on mobile.
533
+ 'after:absolute after:-inset-2 md:after:hidden',
534
+ 'peer-data-[size=sm]/menu-button:top-1',
535
+ 'peer-data-[size=default]/menu-button:top-1.5',
536
+ 'peer-data-[size=lg]/menu-button:top-2.5',
537
+ 'group-data-[collapsible=icon]:hidden',
538
+ showOnHover &&
539
+ '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',
540
+ className
541
+ )}
542
+ {...props}
543
+ />
544
+ )
545
+ }
546
+
547
+ function SidebarMenuBadge({ className, ...props }: React.ComponentProps<'div'>) {
548
+ return (
549
+ <div
550
+ data-slot="sidebar-menu-badge"
551
+ data-sidebar="menu-badge"
552
+ className={cn(
553
+ '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',
554
+ 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground',
555
+ 'peer-data-[size=sm]/menu-button:top-1',
556
+ 'peer-data-[size=default]/menu-button:top-1.5',
557
+ 'peer-data-[size=lg]/menu-button:top-2.5',
558
+ 'group-data-[collapsible=icon]:hidden',
559
+ className
560
+ )}
561
+ {...props}
562
+ />
563
+ )
564
+ }
565
+
566
+ function SidebarMenuSkeleton({
567
+ className,
568
+ showIcon = false,
569
+ ...props
570
+ }: React.ComponentProps<'div'> & {
571
+ showIcon?: boolean
572
+ }) {
573
+ // Random width between 50 to 90%.
574
+ const width = React.useMemo(() => {
575
+ return `${Math.floor(Math.random() * 40) + 50}%`
576
+ }, [])
577
+
578
+ return (
579
+ <div
580
+ data-slot="sidebar-menu-skeleton"
581
+ data-sidebar="menu-skeleton"
582
+ className={cn('flex h-8 items-center gap-2 rounded-md corner-squircle px-2', className)}
583
+ {...props}
584
+ >
585
+ {showIcon && (
586
+ <Skeleton className="size-4 rounded-md corner-squircle" data-sidebar="menu-skeleton-icon" />
587
+ )}
588
+ <Skeleton
589
+ className="h-4 max-w-(--skeleton-width) flex-1"
590
+ data-sidebar="menu-skeleton-text"
591
+ style={
592
+ {
593
+ '--skeleton-width': width
594
+ } as React.CSSProperties
595
+ }
596
+ />
597
+ </div>
598
+ )
599
+ }
600
+
601
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
602
+ return (
603
+ <ul
604
+ data-slot="sidebar-menu-sub"
605
+ data-sidebar="menu-sub"
606
+ className={cn(
607
+ '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',
608
+ 'group-data-[collapsible=icon]:hidden',
609
+ className
610
+ )}
611
+ {...props}
612
+ />
613
+ )
614
+ }
615
+
616
+ function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) {
617
+ return (
618
+ <li
619
+ data-slot="sidebar-menu-sub-item"
620
+ data-sidebar="menu-sub-item"
621
+ className={cn('group/menu-sub-item relative', className)}
622
+ {...props}
623
+ />
624
+ )
625
+ }
626
+
627
+ function SidebarMenuSubButton({
628
+ asChild = false,
629
+ size = 'md',
630
+ isActive = false,
631
+ className,
632
+ ...props
633
+ }: React.ComponentProps<'a'> & {
634
+ asChild?: boolean
635
+ size?: 'sm' | 'md'
636
+ isActive?: boolean
637
+ }) {
638
+ const Comp = asChild ? Slot : 'a'
639
+
640
+ return (
641
+ <Comp
642
+ data-slot="sidebar-menu-sub-button"
643
+ data-sidebar="menu-sub-button"
644
+ data-size={size}
645
+ data-active={isActive}
646
+ className={cn(
647
+ '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',
648
+ 'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground',
649
+ size === 'sm' && 'text-xs',
650
+ size === 'md' && 'text-sm',
651
+ 'group-data-[collapsible=icon]:hidden',
652
+ className
653
+ )}
654
+ {...props}
655
+ />
656
+ )
657
+ }
658
+
659
+ export {
660
+ Sidebar,
661
+ SidebarContent,
662
+ SidebarFooter,
663
+ SidebarGroup,
664
+ SidebarGroupAction,
665
+ SidebarGroupContent,
666
+ SidebarGroupLabel,
667
+ SidebarHeader,
668
+ SidebarInput,
669
+ SidebarInset,
670
+ SidebarMenu,
671
+ SidebarMenuAction,
672
+ SidebarMenuBadge,
673
+ SidebarMenuButton,
674
+ SidebarMenuItem,
675
+ SidebarMenuSkeleton,
676
+ SidebarMenuSub,
677
+ SidebarMenuSubButton,
678
+ SidebarMenuSubItem,
679
+ SidebarProvider,
680
+ SidebarRail,
681
+ SidebarSeparator,
682
+ SidebarTrigger,
683
+ useSidebar
684
+ }
@@ -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 }