@cntyclub/ui-react 0.1.0
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/dist/chunk-HDGMSYQS.js +26461 -0
- package/dist/chunk-HDGMSYQS.js.map +1 -0
- package/dist/chunk-PR4QN5HX.js +39 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/form.d.ts +175 -0
- package/dist/form.js +5207 -0
- package/dist/form.js.map +1 -0
- package/dist/index.d.ts +1462 -0
- package/dist/index.js +81862 -0
- package/dist/index.js.map +1 -0
- package/dist/input-CZvh825j.d.ts +24 -0
- package/dist/qr-code-styling-3Y6LZH6V.js +1123 -0
- package/dist/qr-code-styling-3Y6LZH6V.js.map +1 -0
- package/package.json +79 -0
- package/src/components/form/checkbox-group-field.tsx +101 -0
- package/src/components/form/date-field.tsx +79 -0
- package/src/components/form/date-range-field.tsx +106 -0
- package/src/components/form/form-context.ts +10 -0
- package/src/components/form/form.tsx +54 -0
- package/src/components/form/number-field.tsx +69 -0
- package/src/components/form/select-field.tsx +76 -0
- package/src/components/form/submit-button.tsx +28 -0
- package/src/components/form/text-field.tsx +107 -0
- package/src/components/layout/dashboard-header.tsx +54 -0
- package/src/components/layout/dashboard-panel.tsx +34 -0
- package/src/components/theme-provider.tsx +403 -0
- package/src/components/ui/accordion.tsx +69 -0
- package/src/components/ui/alert-dialog.tsx +169 -0
- package/src/components/ui/alert.tsx +80 -0
- package/src/components/ui/animated-theme-toggler.tsx +265 -0
- package/src/components/ui/app-store-buttons.tsx +182 -0
- package/src/components/ui/aspect-ratio.tsx +23 -0
- package/src/components/ui/autocomplete.tsx +296 -0
- package/src/components/ui/avatar-group.tsx +95 -0
- package/src/components/ui/avatar.tsx +285 -0
- package/src/components/ui/badge-group.tsx +160 -0
- package/src/components/ui/badge.tsx +172 -0
- package/src/components/ui/breadcrumb.tsx +112 -0
- package/src/components/ui/button.tsx +77 -0
- package/src/components/ui/calendar.tsx +137 -0
- package/src/components/ui/card.tsx +244 -0
- package/src/components/ui/carousel.tsx +258 -0
- package/src/components/ui/chart.tsx +379 -0
- package/src/components/ui/checkbox-group.tsx +16 -0
- package/src/components/ui/checkbox.tsx +82 -0
- package/src/components/ui/collapsible.tsx +45 -0
- package/src/components/ui/combobox.tsx +411 -0
- package/src/components/ui/command.tsx +264 -0
- package/src/components/ui/context-menu.tsx +271 -0
- package/src/components/ui/credit-card.tsx +214 -0
- package/src/components/ui/dialog.tsx +196 -0
- package/src/components/ui/drawer.tsx +135 -0
- package/src/components/ui/empty.tsx +127 -0
- package/src/components/ui/featured-icon.tsx +149 -0
- package/src/components/ui/field.tsx +88 -0
- package/src/components/ui/fieldset.tsx +29 -0
- package/src/components/ui/form.tsx +17 -0
- package/src/components/ui/frame.tsx +82 -0
- package/src/components/ui/generic-empty.tsx +142 -0
- package/src/components/ui/group.tsx +97 -0
- package/src/components/ui/horizontal-scroll-fader.tsx +228 -0
- package/src/components/ui/input-group.tsx +102 -0
- package/src/components/ui/input-otp.tsx +96 -0
- package/src/components/ui/input.tsx +66 -0
- package/src/components/ui/item.tsx +198 -0
- package/src/components/ui/kbd.tsx +30 -0
- package/src/components/ui/label.tsx +28 -0
- package/src/components/ui/menu.tsx +312 -0
- package/src/components/ui/menubar.tsx +93 -0
- package/src/components/ui/meter.tsx +67 -0
- package/src/components/ui/multi-select.tsx +308 -0
- package/src/components/ui/navigation-menu.tsx +143 -0
- package/src/components/ui/number-field.tsx +160 -0
- package/src/components/ui/pagination-controls.tsx +74 -0
- package/src/components/ui/pagination.tsx +149 -0
- package/src/components/ui/popover.tsx +119 -0
- package/src/components/ui/preview-card.tsx +55 -0
- package/src/components/ui/progress.tsx +289 -0
- package/src/components/ui/qr-code.tsx +150 -0
- package/src/components/ui/radio-group.tsx +103 -0
- package/src/components/ui/resizable.tsx +56 -0
- package/src/components/ui/scroll-area.tsx +90 -0
- package/src/components/ui/scroller.tsx +38 -0
- package/src/components/ui/section-header.tsx +118 -0
- package/src/components/ui/select.tsx +181 -0
- package/src/components/ui/separator.tsx +23 -0
- package/src/components/ui/sheet.tsx +224 -0
- package/src/components/ui/sidebar.tsx +744 -0
- package/src/components/ui/skeleton.tsx +16 -0
- package/src/components/ui/slider.tsx +108 -0
- package/src/components/ui/smooth-scroll.tsx +143 -0
- package/src/components/ui/social-button.tsx +247 -0
- package/src/components/ui/spinner-on-demand.tsx +32 -0
- package/src/components/ui/spinner.tsx +18 -0
- package/src/components/ui/stat.tsx +187 -0
- package/src/components/ui/stepper.tsx +167 -0
- package/src/components/ui/switch.tsx +56 -0
- package/src/components/ui/table.tsx +126 -0
- package/src/components/ui/tabs.tsx +90 -0
- package/src/components/ui/tag.tsx +229 -0
- package/src/components/ui/target-countdown.tsx +46 -0
- package/src/components/ui/text-editor.tsx +313 -0
- package/src/components/ui/textarea.tsx +51 -0
- package/src/components/ui/timeline.tsx +116 -0
- package/src/components/ui/toast.tsx +268 -0
- package/src/components/ui/toggle-group.tsx +101 -0
- package/src/components/ui/toggle.tsx +45 -0
- package/src/components/ui/toolbar.tsx +89 -0
- package/src/components/ui/tooltip.tsx +102 -0
- package/src/components/ui/vertical-scroll-fader.tsx +250 -0
- package/src/components/ui/video-player.tsx +275 -0
- package/src/components/upload/avatar-upload-base.tsx +131 -0
- package/src/components/upload/image-upload-base.tsx +112 -0
- package/src/form.ts +17 -0
- package/src/index.ts +125 -0
- package/src/lib/hooks/use-callback-ref.ts +15 -0
- package/src/lib/hooks/use-first-render.ts +11 -0
- package/src/lib/hooks/use-hover.ts +53 -0
- package/src/lib/hooks/use-is-tab-active.ts +17 -0
- package/src/lib/hooks/use-media-query.ts +164 -0
- package/src/lib/utils/css.ts +6 -0
- package/src/styles.css +300 -0
- package/src/types/helpers.ts +24 -0
- package/src/types/react.d.ts +7 -0
|
@@ -0,0 +1,744 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
4
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
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 { ScrollArea } from "./scroll-area";
|
|
11
|
+
import { Separator } from "./separator";
|
|
12
|
+
import {
|
|
13
|
+
Sheet,
|
|
14
|
+
SheetDescription,
|
|
15
|
+
SheetHeader,
|
|
16
|
+
SheetPopup,
|
|
17
|
+
SheetTitle,
|
|
18
|
+
} from "./sheet";
|
|
19
|
+
import { Skeleton } from "./skeleton";
|
|
20
|
+
import { Tooltip, TooltipPopup, TooltipTrigger } from "./tooltip";
|
|
21
|
+
import { cn } from "../../lib/utils/css";
|
|
22
|
+
|
|
23
|
+
// Runs before paint on the client (so the mobile/desktop sidebar is correct on
|
|
24
|
+
// the first frame — no pop-in), but degrades to useEffect during SSR.
|
|
25
|
+
const useIsomorphicLayoutEffect =
|
|
26
|
+
typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
27
|
+
|
|
28
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
29
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
30
|
+
const SIDEBAR_WIDTH_LG = "18.5rem";
|
|
31
|
+
const SIDEBAR_WIDTH_MD = "14.5rem";
|
|
32
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
33
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
34
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
35
|
+
|
|
36
|
+
type SidebarContextProps = {
|
|
37
|
+
state: "expanded" | "collapsed";
|
|
38
|
+
open: boolean;
|
|
39
|
+
setOpen: (open: boolean) => void;
|
|
40
|
+
openMobile: boolean;
|
|
41
|
+
setOpenMobile: (open: boolean) => void;
|
|
42
|
+
isMobile: boolean;
|
|
43
|
+
toggleSidebar: () => void;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const SidebarContext = React.createContext<SidebarContextProps | null>(null);
|
|
47
|
+
|
|
48
|
+
function useSidebar() {
|
|
49
|
+
const context = React.useContext(SidebarContext);
|
|
50
|
+
if (!context) {
|
|
51
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return context;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function SidebarProvider({
|
|
58
|
+
defaultOpen = true,
|
|
59
|
+
open: openProp,
|
|
60
|
+
onOpenChange: setOpenProp,
|
|
61
|
+
className,
|
|
62
|
+
style,
|
|
63
|
+
children,
|
|
64
|
+
...props
|
|
65
|
+
}: React.ComponentProps<"div"> & {
|
|
66
|
+
defaultOpen?: boolean;
|
|
67
|
+
open?: boolean;
|
|
68
|
+
onOpenChange?: (open: boolean) => void;
|
|
69
|
+
}) {
|
|
70
|
+
// Self-contained breakpoint check (md = 48rem). Resolved in a layout effect
|
|
71
|
+
// before the first paint so the sidebar never flashes from mobile to desktop.
|
|
72
|
+
const [isMobile, setIsMobile] = React.useState(false);
|
|
73
|
+
useIsomorphicLayoutEffect(() => {
|
|
74
|
+
const mql = window.matchMedia("(max-width: 47.999rem)");
|
|
75
|
+
const onChange = () => setIsMobile(mql.matches);
|
|
76
|
+
onChange();
|
|
77
|
+
mql.addEventListener("change", onChange);
|
|
78
|
+
return () => mql.removeEventListener("change", onChange);
|
|
79
|
+
}, []);
|
|
80
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
81
|
+
|
|
82
|
+
// This is the internal state of the sidebar.
|
|
83
|
+
// We use openProp and setOpenProp for control from outside the component.
|
|
84
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
85
|
+
const open = openProp ?? _open;
|
|
86
|
+
const setOpen = React.useCallback(
|
|
87
|
+
(value: boolean | ((value: boolean) => boolean)) => {
|
|
88
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
89
|
+
if (setOpenProp) {
|
|
90
|
+
setOpenProp(openState);
|
|
91
|
+
} else {
|
|
92
|
+
_setOpen(openState);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Persist the sidebar state. document.cookie works in every browser
|
|
96
|
+
// (cookieStore is Chromium-only and throws elsewhere).
|
|
97
|
+
try {
|
|
98
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
99
|
+
} catch {
|
|
100
|
+
// Ignore — persistence is best-effort.
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
[setOpenProp, open],
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Helper to toggle the sidebar.
|
|
107
|
+
const toggleSidebar = React.useCallback(() => {
|
|
108
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
109
|
+
}, [isMobile, setOpen]);
|
|
110
|
+
|
|
111
|
+
// Adds a keyboard shortcut to toggle the sidebar.
|
|
112
|
+
React.useEffect(() => {
|
|
113
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
114
|
+
if (
|
|
115
|
+
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
116
|
+
(event.metaKey || event.ctrlKey)
|
|
117
|
+
) {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
toggleSidebar();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
124
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
125
|
+
}, [toggleSidebar]);
|
|
126
|
+
|
|
127
|
+
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
128
|
+
// This makes it easier to style the sidebar with Tailwind classes.
|
|
129
|
+
const state = open ? "expanded" : "collapsed";
|
|
130
|
+
|
|
131
|
+
const contextValue = React.useMemo<SidebarContextProps>(
|
|
132
|
+
() => ({
|
|
133
|
+
isMobile,
|
|
134
|
+
open,
|
|
135
|
+
openMobile,
|
|
136
|
+
setOpen,
|
|
137
|
+
setOpenMobile,
|
|
138
|
+
state,
|
|
139
|
+
toggleSidebar,
|
|
140
|
+
}),
|
|
141
|
+
[state, open, setOpen, isMobile, openMobile, toggleSidebar],
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<SidebarContext.Provider value={contextValue}>
|
|
146
|
+
<div
|
|
147
|
+
className={cn(
|
|
148
|
+
"group/sidebar-wrapper flex h-full w-full",
|
|
149
|
+
"[--sidebar-width:var(--sidebar-width-md)] lg:[--sidebar-width:var(--sidebar-width-lg)]",
|
|
150
|
+
className,
|
|
151
|
+
)}
|
|
152
|
+
data-slot="sidebar-wrapper"
|
|
153
|
+
style={{
|
|
154
|
+
"--sidebar-width-lg": SIDEBAR_WIDTH_LG,
|
|
155
|
+
"--sidebar-width-md": SIDEBAR_WIDTH_MD,
|
|
156
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
157
|
+
...style,
|
|
158
|
+
}}
|
|
159
|
+
{...props}
|
|
160
|
+
>
|
|
161
|
+
{children}
|
|
162
|
+
</div>
|
|
163
|
+
</SidebarContext.Provider>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function Sidebar({
|
|
168
|
+
side = "left",
|
|
169
|
+
variant = "sidebar",
|
|
170
|
+
collapsible = "offcanvas",
|
|
171
|
+
className,
|
|
172
|
+
children,
|
|
173
|
+
...props
|
|
174
|
+
}: React.ComponentProps<"div"> & {
|
|
175
|
+
side?: "left" | "right";
|
|
176
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
177
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
178
|
+
}) {
|
|
179
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
180
|
+
|
|
181
|
+
if (collapsible === "none") {
|
|
182
|
+
return (
|
|
183
|
+
<div
|
|
184
|
+
className={cn(
|
|
185
|
+
"flex h-full w-(--sidebar-width) flex-col bg-sidebar md:bg-transparent text-sidebar-foreground",
|
|
186
|
+
className,
|
|
187
|
+
)}
|
|
188
|
+
data-slot="sidebar"
|
|
189
|
+
{...props}
|
|
190
|
+
>
|
|
191
|
+
{children}
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (isMobile) {
|
|
197
|
+
return (
|
|
198
|
+
<Sheet onOpenChange={setOpenMobile} open={openMobile} {...props}>
|
|
199
|
+
<SheetPopup
|
|
200
|
+
className="w-(--sidebar-width) bg-sidebar md:bg-transparent p-0 text-sidebar-foreground [&>button]:hidden"
|
|
201
|
+
data-mobile="true"
|
|
202
|
+
data-sidebar="sidebar"
|
|
203
|
+
data-slot="sidebar"
|
|
204
|
+
side={side}
|
|
205
|
+
style={{
|
|
206
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
207
|
+
}}
|
|
208
|
+
>
|
|
209
|
+
<SheetHeader className="sr-only">
|
|
210
|
+
<SheetTitle>Sidebar</SheetTitle>
|
|
211
|
+
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
|
212
|
+
</SheetHeader>
|
|
213
|
+
<div className="flex h-full w-full flex-col">{children}</div>
|
|
214
|
+
</SheetPopup>
|
|
215
|
+
</Sheet>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<div
|
|
221
|
+
className="group peer hidden text-sidebar-foreground md:block"
|
|
222
|
+
data-collapsible={state === "collapsed" ? collapsible : ""}
|
|
223
|
+
data-side={side}
|
|
224
|
+
data-slot="sidebar"
|
|
225
|
+
data-state={state}
|
|
226
|
+
data-variant={variant}
|
|
227
|
+
>
|
|
228
|
+
{/* This is what handles the sidebar gap on desktop */}
|
|
229
|
+
<div
|
|
230
|
+
className={cn(
|
|
231
|
+
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)]",
|
|
232
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
233
|
+
"group-data-[side=right]:rotate-180",
|
|
234
|
+
variant === "floating" || variant === "inset"
|
|
235
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
236
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
|
|
237
|
+
)}
|
|
238
|
+
data-slot="sidebar-gap"
|
|
239
|
+
/>
|
|
240
|
+
<div
|
|
241
|
+
className={cn(
|
|
242
|
+
"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] md:flex",
|
|
243
|
+
side === "left"
|
|
244
|
+
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
|
|
245
|
+
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
246
|
+
// Adjust the padding for floating and inset variants.
|
|
247
|
+
variant === "floating" || variant === "inset"
|
|
248
|
+
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
249
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
250
|
+
className,
|
|
251
|
+
)}
|
|
252
|
+
data-slot="sidebar-container"
|
|
253
|
+
{...props}
|
|
254
|
+
>
|
|
255
|
+
<div
|
|
256
|
+
className="flex h-full w-full flex-col bg-sidebar md:bg-transparent group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm/5"
|
|
257
|
+
data-sidebar="sidebar"
|
|
258
|
+
data-slot="sidebar-inner"
|
|
259
|
+
>
|
|
260
|
+
{children}
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function SidebarTrigger({
|
|
268
|
+
className,
|
|
269
|
+
onClick,
|
|
270
|
+
...props
|
|
271
|
+
}: React.ComponentProps<typeof Button>) {
|
|
272
|
+
const { toggleSidebar } = useSidebar();
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<Button
|
|
276
|
+
className={cn("size-7", className)}
|
|
277
|
+
data-sidebar="trigger"
|
|
278
|
+
data-slot="sidebar-trigger"
|
|
279
|
+
onClick={(event) => {
|
|
280
|
+
onClick?.(event);
|
|
281
|
+
toggleSidebar();
|
|
282
|
+
}}
|
|
283
|
+
size="icon"
|
|
284
|
+
variant="ghost"
|
|
285
|
+
{...props}
|
|
286
|
+
>
|
|
287
|
+
<PanelLeftIcon />
|
|
288
|
+
<span className="sr-only">Toggle Sidebar</span>
|
|
289
|
+
</Button>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
|
|
294
|
+
const { toggleSidebar } = useSidebar();
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<button
|
|
298
|
+
aria-label="Toggle Sidebar"
|
|
299
|
+
className={cn(
|
|
300
|
+
"-translate-x-1/2 group-data-[side=left]:-right-4 absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=right]:left-0 sm:flex",
|
|
301
|
+
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
|
|
302
|
+
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
303
|
+
"group-data-[collapsible=offcanvas]:translate-x-0 hover:group-data-[collapsible=offcanvas]:bg-sidebar md:bg-transparent group-data-[collapsible=offcanvas]:after:left-full",
|
|
304
|
+
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
305
|
+
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
306
|
+
className,
|
|
307
|
+
)}
|
|
308
|
+
data-sidebar="rail"
|
|
309
|
+
data-slot="sidebar-rail"
|
|
310
|
+
onClick={toggleSidebar}
|
|
311
|
+
tabIndex={-1}
|
|
312
|
+
title="Toggle Sidebar"
|
|
313
|
+
type="button"
|
|
314
|
+
{...props}
|
|
315
|
+
/>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
|
|
320
|
+
return (
|
|
321
|
+
<main
|
|
322
|
+
className={cn(
|
|
323
|
+
"relative flex w-full flex-1 flex-col bg-background",
|
|
324
|
+
"md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ms-2 md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ms-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm/5",
|
|
325
|
+
className,
|
|
326
|
+
)}
|
|
327
|
+
data-slot="sidebar-inset"
|
|
328
|
+
{...props}
|
|
329
|
+
/>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function SidebarInput({
|
|
334
|
+
className,
|
|
335
|
+
...props
|
|
336
|
+
}: React.ComponentProps<typeof Input>) {
|
|
337
|
+
return (
|
|
338
|
+
<Input
|
|
339
|
+
className={cn("h-8 w-full bg-background shadow-none", className)}
|
|
340
|
+
data-sidebar="input"
|
|
341
|
+
data-slot="sidebar-input"
|
|
342
|
+
{...props}
|
|
343
|
+
/>
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
348
|
+
return (
|
|
349
|
+
<div
|
|
350
|
+
className={cn("flex flex-col gap-2 p-2", className)}
|
|
351
|
+
data-sidebar="header"
|
|
352
|
+
data-slot="sidebar-header"
|
|
353
|
+
{...props}
|
|
354
|
+
/>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
359
|
+
return (
|
|
360
|
+
<div
|
|
361
|
+
className={cn("flex flex-col gap-2 p-2", className)}
|
|
362
|
+
data-sidebar="footer"
|
|
363
|
+
data-slot="sidebar-footer"
|
|
364
|
+
{...props}
|
|
365
|
+
/>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function SidebarSeparator({
|
|
370
|
+
className,
|
|
371
|
+
...props
|
|
372
|
+
}: React.ComponentProps<typeof Separator>) {
|
|
373
|
+
return (
|
|
374
|
+
<Separator
|
|
375
|
+
className={cn("mx-2 w-auto bg-sidebar-border", className)}
|
|
376
|
+
data-sidebar="separator"
|
|
377
|
+
data-slot="sidebar-separator"
|
|
378
|
+
{...props}
|
|
379
|
+
/>
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
384
|
+
return (
|
|
385
|
+
<ScrollArea className="pr-1.5 -mr-1.5" scrollFade>
|
|
386
|
+
<div
|
|
387
|
+
className={cn(
|
|
388
|
+
"flex flex-1 flex-col group-data-[collapsible=icon]:overflow-hidden",
|
|
389
|
+
className,
|
|
390
|
+
)}
|
|
391
|
+
data-sidebar="content"
|
|
392
|
+
data-slot="sidebar-content"
|
|
393
|
+
{...props}
|
|
394
|
+
/>
|
|
395
|
+
</ScrollArea>
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
400
|
+
return (
|
|
401
|
+
<div
|
|
402
|
+
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
|
403
|
+
data-sidebar="group"
|
|
404
|
+
data-slot="sidebar-group"
|
|
405
|
+
{...props}
|
|
406
|
+
/>
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function SidebarGroupLabel({
|
|
411
|
+
className,
|
|
412
|
+
render,
|
|
413
|
+
...props
|
|
414
|
+
}: useRender.ComponentProps<"div">) {
|
|
415
|
+
const defaultProps = {
|
|
416
|
+
className: cn(
|
|
417
|
+
"flex h-8 shrink-0 items-center rounded-lg px-2 font-medium text-sidebar-foreground/70 text-xs outline-hidden ring-sidebar-ring transition-[margin,opacity] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
418
|
+
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
|
419
|
+
className,
|
|
420
|
+
),
|
|
421
|
+
"data-sidebar": "group-label",
|
|
422
|
+
"data-slot": "sidebar-group-label",
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
return useRender({
|
|
426
|
+
defaultTagName: "div",
|
|
427
|
+
props: mergeProps(defaultProps, props),
|
|
428
|
+
render,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function SidebarGroupAction({
|
|
433
|
+
className,
|
|
434
|
+
render,
|
|
435
|
+
...props
|
|
436
|
+
}: useRender.ComponentProps<"button">) {
|
|
437
|
+
const defaultProps = {
|
|
438
|
+
className: cn(
|
|
439
|
+
"absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-lg p-0 text-sidebar-foreground outline-hidden ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0",
|
|
440
|
+
// Increases the hit area of the button on mobile.
|
|
441
|
+
"after:-inset-2 after:absolute md:after:hidden",
|
|
442
|
+
"group-data-[collapsible=icon]:hidden",
|
|
443
|
+
className,
|
|
444
|
+
),
|
|
445
|
+
"data-sidebar": "group-action",
|
|
446
|
+
"data-slot": "sidebar-group-action",
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
return useRender({
|
|
450
|
+
defaultTagName: "button",
|
|
451
|
+
props: mergeProps(defaultProps, props),
|
|
452
|
+
render,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function SidebarGroupContent({
|
|
457
|
+
className,
|
|
458
|
+
...props
|
|
459
|
+
}: React.ComponentProps<"div">) {
|
|
460
|
+
return (
|
|
461
|
+
<div
|
|
462
|
+
className={cn("w-full text-sm", className)}
|
|
463
|
+
data-sidebar="group-content"
|
|
464
|
+
data-slot="sidebar-group-content"
|
|
465
|
+
{...props}
|
|
466
|
+
/>
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
|
|
471
|
+
return (
|
|
472
|
+
<ul
|
|
473
|
+
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
|
|
474
|
+
data-sidebar="menu"
|
|
475
|
+
data-slot="sidebar-menu"
|
|
476
|
+
{...props}
|
|
477
|
+
/>
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
482
|
+
return (
|
|
483
|
+
<li
|
|
484
|
+
className={cn("group/menu-item relative", className)}
|
|
485
|
+
data-sidebar="menu-item"
|
|
486
|
+
data-slot="sidebar-menu-item"
|
|
487
|
+
{...props}
|
|
488
|
+
/>
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const sidebarMenuButtonVariants = cva(
|
|
493
|
+
"peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-lg border border-transparent text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding,background-color] duration-300 ease-[cubic-bezier(0.32,0.72,0,1)] hover:bg-secondary focus-visible:ring-2 active:bg-secondary disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pe-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[status=active]:bg-background data-[status=active]:font-medium data-[status=active]:text-sidebar-accent-foreground data-[active=true]:bg-background data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-background data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-3! [&>span:last-child]:truncate [&>span:last-child]:transition-opacity [&>span:last-child]:duration-200 [&>span:last-child]:ease-out group-data-[collapsible=icon]:[&>span:last-child]:opacity-0 [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0 data-[status=active]:border-border data-[status=active]:shadow-xs data-[status=active]:hover:bg-background data-[status=active]:hover:text-sidebar-accent-foreground",
|
|
494
|
+
{
|
|
495
|
+
defaultVariants: {
|
|
496
|
+
size: "default",
|
|
497
|
+
variant: "default",
|
|
498
|
+
},
|
|
499
|
+
variants: {
|
|
500
|
+
size: {
|
|
501
|
+
default: "h-9 font-normal p-2 text-sm",
|
|
502
|
+
lg: "h-11 p-3 font-medium text-sm group-data-[collapsible=icon]:p-0!",
|
|
503
|
+
sm: "h-7 p-2 font-normal text-xs",
|
|
504
|
+
},
|
|
505
|
+
variant: {
|
|
506
|
+
default: "hover:bg-secondary",
|
|
507
|
+
outline: "bg-sidebar-accent text-foreground shadow-xs border",
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
function SidebarMenuButton({
|
|
514
|
+
isActive = false,
|
|
515
|
+
variant = "default",
|
|
516
|
+
size = "default",
|
|
517
|
+
tooltip,
|
|
518
|
+
className,
|
|
519
|
+
render,
|
|
520
|
+
...props
|
|
521
|
+
}: useRender.ComponentProps<"button"> & {
|
|
522
|
+
isActive?: boolean;
|
|
523
|
+
tooltip?: string | React.ComponentProps<typeof TooltipPopup>;
|
|
524
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
|
525
|
+
const { isMobile, state } = useSidebar();
|
|
526
|
+
|
|
527
|
+
const defaultProps = {
|
|
528
|
+
className: cn(sidebarMenuButtonVariants({ size, variant }), className),
|
|
529
|
+
"data-active": isActive,
|
|
530
|
+
"data-sidebar": "menu-button",
|
|
531
|
+
"data-size": size,
|
|
532
|
+
"data-slot": "sidebar-menu-button",
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
const buttonProps = mergeProps<"button">(defaultProps, props);
|
|
536
|
+
|
|
537
|
+
const buttonElement = useRender({
|
|
538
|
+
defaultTagName: "button",
|
|
539
|
+
props: buttonProps,
|
|
540
|
+
render,
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
if (!tooltip) {
|
|
544
|
+
return buttonElement;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (typeof tooltip === "string") {
|
|
548
|
+
tooltip = {
|
|
549
|
+
children: tooltip,
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return (
|
|
554
|
+
<Tooltip>
|
|
555
|
+
<TooltipTrigger
|
|
556
|
+
render={buttonElement as React.ReactElement<Record<string, unknown>>}
|
|
557
|
+
/>
|
|
558
|
+
<TooltipPopup
|
|
559
|
+
align="center"
|
|
560
|
+
hidden={state !== "collapsed" || isMobile}
|
|
561
|
+
side="right"
|
|
562
|
+
{...tooltip}
|
|
563
|
+
/>
|
|
564
|
+
</Tooltip>
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function SidebarMenuAction({
|
|
569
|
+
className,
|
|
570
|
+
showOnHover = false,
|
|
571
|
+
render,
|
|
572
|
+
...props
|
|
573
|
+
}: useRender.ComponentProps<"button"> & {
|
|
574
|
+
showOnHover?: boolean;
|
|
575
|
+
}) {
|
|
576
|
+
const defaultProps = {
|
|
577
|
+
className: cn(
|
|
578
|
+
"absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-lg p-0 text-sidebar-foreground outline-hidden ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0",
|
|
579
|
+
// Increases the hit area of the button on mobile.
|
|
580
|
+
"after:-inset-2 after:absolute md:after:hidden",
|
|
581
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
582
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
583
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
584
|
+
"group-data-[collapsible=icon]:hidden",
|
|
585
|
+
showOnHover &&
|
|
586
|
+
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground peer-data-[status=active]/menu-button:text-sidebar-accent-foreground md:opacity-0",
|
|
587
|
+
className,
|
|
588
|
+
),
|
|
589
|
+
"data-sidebar": "menu-action",
|
|
590
|
+
"data-slot": "sidebar-menu-action",
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
return useRender({
|
|
594
|
+
defaultTagName: "button",
|
|
595
|
+
props: mergeProps<"button">(defaultProps, props),
|
|
596
|
+
render,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function SidebarMenuBadge({
|
|
601
|
+
className,
|
|
602
|
+
...props
|
|
603
|
+
}: React.ComponentProps<"div">) {
|
|
604
|
+
return (
|
|
605
|
+
<div
|
|
606
|
+
className={cn(
|
|
607
|
+
"pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-lg px-1 font-medium text-sidebar-foreground text-xs tabular-nums",
|
|
608
|
+
"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground peer-data-[status=active]/menu-button:text-sidebar-accent-foreground",
|
|
609
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
610
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
611
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
612
|
+
"group-data-[collapsible=icon]:hidden",
|
|
613
|
+
className,
|
|
614
|
+
)}
|
|
615
|
+
data-sidebar="menu-badge"
|
|
616
|
+
data-slot="sidebar-menu-badge"
|
|
617
|
+
{...props}
|
|
618
|
+
/>
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function SidebarMenuSkeleton({
|
|
623
|
+
className,
|
|
624
|
+
showIcon = false,
|
|
625
|
+
...props
|
|
626
|
+
}: React.ComponentProps<"div"> & {
|
|
627
|
+
showIcon?: boolean;
|
|
628
|
+
}) {
|
|
629
|
+
// Random width between 50 to 90%.
|
|
630
|
+
const width = React.useMemo(() => {
|
|
631
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
632
|
+
}, []);
|
|
633
|
+
|
|
634
|
+
return (
|
|
635
|
+
<div
|
|
636
|
+
className={cn("flex h-8 items-center gap-2 rounded-lg px-2", className)}
|
|
637
|
+
data-sidebar="menu-skeleton"
|
|
638
|
+
data-slot="sidebar-menu-skeleton"
|
|
639
|
+
{...props}
|
|
640
|
+
>
|
|
641
|
+
{showIcon && (
|
|
642
|
+
<Skeleton
|
|
643
|
+
className="size-4 rounded-lg"
|
|
644
|
+
data-sidebar="menu-skeleton-icon"
|
|
645
|
+
/>
|
|
646
|
+
)}
|
|
647
|
+
<Skeleton
|
|
648
|
+
className="h-4 max-w-(--skeleton-width) flex-1"
|
|
649
|
+
data-sidebar="menu-skeleton-text"
|
|
650
|
+
style={{
|
|
651
|
+
"--skeleton-width": width,
|
|
652
|
+
}}
|
|
653
|
+
/>
|
|
654
|
+
</div>
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
|
|
659
|
+
return (
|
|
660
|
+
<ul
|
|
661
|
+
className={cn(
|
|
662
|
+
"mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-sidebar-border border-l px-2.5 py-0.5",
|
|
663
|
+
"group-data-[collapsible=icon]:hidden",
|
|
664
|
+
className,
|
|
665
|
+
)}
|
|
666
|
+
data-sidebar="menu-sub"
|
|
667
|
+
data-slot="sidebar-menu-sub"
|
|
668
|
+
{...props}
|
|
669
|
+
/>
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function SidebarMenuSubItem({
|
|
674
|
+
className,
|
|
675
|
+
...props
|
|
676
|
+
}: React.ComponentProps<"li">) {
|
|
677
|
+
return (
|
|
678
|
+
<li
|
|
679
|
+
className={cn("group/menu-sub-item relative", className)}
|
|
680
|
+
data-sidebar="menu-sub-item"
|
|
681
|
+
data-slot="sidebar-menu-sub-item"
|
|
682
|
+
{...props}
|
|
683
|
+
/>
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function SidebarMenuSubButton({
|
|
688
|
+
size = "md",
|
|
689
|
+
isActive = false,
|
|
690
|
+
className,
|
|
691
|
+
render,
|
|
692
|
+
...props
|
|
693
|
+
}: useRender.ComponentProps<"a"> & {
|
|
694
|
+
size?: "sm" | "md";
|
|
695
|
+
isActive?: boolean;
|
|
696
|
+
}) {
|
|
697
|
+
const defaultProps = {
|
|
698
|
+
className: cn(
|
|
699
|
+
"-translate-x-px flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-lg px-2 text-sidebar-foreground outline-hidden ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-secondary active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
|
|
700
|
+
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground data-[status=active]:bg-sidebar-accent data-[status=active]:text-sidebar-accent-foreground",
|
|
701
|
+
size === "sm" && "text-xs",
|
|
702
|
+
size === "md" && "text-sm",
|
|
703
|
+
"group-data-[collapsible=icon]:hidden",
|
|
704
|
+
className,
|
|
705
|
+
),
|
|
706
|
+
"data-active": isActive,
|
|
707
|
+
"data-sidebar": "menu-sub-button",
|
|
708
|
+
"data-size": size,
|
|
709
|
+
"data-slot": "sidebar-menu-sub-button",
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
return useRender({
|
|
713
|
+
defaultTagName: "a",
|
|
714
|
+
props: mergeProps<"a">(defaultProps, props),
|
|
715
|
+
render,
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
export {
|
|
720
|
+
Sidebar,
|
|
721
|
+
SidebarContent,
|
|
722
|
+
SidebarFooter,
|
|
723
|
+
SidebarGroup,
|
|
724
|
+
SidebarGroupAction,
|
|
725
|
+
SidebarGroupContent,
|
|
726
|
+
SidebarGroupLabel,
|
|
727
|
+
SidebarHeader,
|
|
728
|
+
SidebarInput,
|
|
729
|
+
SidebarInset,
|
|
730
|
+
SidebarMenu,
|
|
731
|
+
SidebarMenuAction,
|
|
732
|
+
SidebarMenuBadge,
|
|
733
|
+
SidebarMenuButton,
|
|
734
|
+
SidebarMenuItem,
|
|
735
|
+
SidebarMenuSkeleton,
|
|
736
|
+
SidebarMenuSub,
|
|
737
|
+
SidebarMenuSubButton,
|
|
738
|
+
SidebarMenuSubItem,
|
|
739
|
+
SidebarProvider,
|
|
740
|
+
SidebarRail,
|
|
741
|
+
SidebarSeparator,
|
|
742
|
+
SidebarTrigger,
|
|
743
|
+
useSidebar,
|
|
744
|
+
};
|