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