@codefast/ui 0.3.11-canary.1 → 0.3.11
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/CHANGELOG.md +36 -0
- package/README.md +34 -14
- package/dist/components/accordion.d.ts +29 -10
- package/dist/components/accordion.js +38 -37
- package/dist/components/alert-dialog.d.ts +60 -24
- package/dist/components/alert-dialog.js +69 -72
- package/dist/components/alert.d.ts +27 -15
- package/dist/components/alert.js +29 -31
- package/dist/components/aspect-ratio.d.ts +8 -4
- package/dist/components/aspect-ratio.js +7 -5
- package/dist/components/avatar.d.ts +17 -6
- package/dist/components/avatar.js +19 -17
- package/dist/components/badge.d.ts +21 -14
- package/dist/components/badge.js +19 -22
- package/dist/components/breadcrumb.d.ts +35 -12
- package/dist/components/breadcrumb.js +48 -54
- package/dist/components/button-group.d.ts +29 -14
- package/dist/components/button-group.js +27 -32
- package/dist/components/button.d.ts +35 -25
- package/dist/components/button.js +50 -48
- package/dist/components/calendar.d.ts +24 -9
- package/dist/components/calendar.js +92 -98
- package/dist/components/card.d.ts +34 -10
- package/dist/components/card.js +39 -37
- package/dist/components/carousel.d.ts +55 -24
- package/dist/components/carousel.js +113 -130
- package/dist/components/chart.d.ts +72 -36
- package/dist/components/chart.js +154 -166
- package/dist/components/checkbox-cards.d.ts +15 -8
- package/dist/components/checkbox-cards.js +22 -25
- package/dist/components/checkbox-group.d.ts +16 -8
- package/dist/components/checkbox-group.js +19 -19
- package/dist/components/checkbox.d.ts +9 -4
- package/dist/components/checkbox.js +14 -14
- package/dist/components/collapsible.d.ts +14 -6
- package/dist/components/collapsible.js +18 -16
- package/dist/components/command.d.ts +55 -23
- package/dist/components/command.js +70 -85
- package/dist/components/context-menu.d.ts +72 -22
- package/dist/components/context-menu.js +88 -109
- package/dist/components/dialog.d.ts +53 -22
- package/dist/components/dialog.js +71 -85
- package/dist/components/drawer.d.ts +60 -28
- package/dist/components/drawer.js +59 -67
- package/dist/components/dropdown-menu.d.ts +73 -22
- package/dist/components/dropdown-menu.js +95 -112
- package/dist/components/empty.d.ts +37 -15
- package/dist/components/empty.js +43 -45
- package/dist/components/field.d.ts +63 -25
- package/dist/components/field.js +88 -104
- package/dist/components/form.d.ts +37 -15
- package/dist/components/form.js +65 -70
- package/dist/components/hover-card.d.ts +21 -7
- package/dist/components/hover-card.js +24 -24
- package/dist/components/input-group.d.ts +53 -28
- package/dist/components/input-group.js +63 -77
- package/dist/components/input-number.d.ts +28 -7
- package/dist/components/input-number.js +55 -59
- package/dist/components/input-otp.d.ts +24 -10
- package/dist/components/input-otp.js +33 -37
- package/dist/components/input-password.d.ts +12 -5
- package/dist/components/input-password.js +31 -32
- package/dist/components/input-search.d.ts +18 -8
- package/dist/components/input-search.js +43 -41
- package/dist/components/input.d.ts +10 -4
- package/dist/components/input.js +9 -7
- package/dist/components/item.d.ts +69 -32
- package/dist/components/item.js +89 -92
- package/dist/components/kbd.d.ts +13 -5
- package/dist/components/kbd.js +13 -11
- package/dist/components/label.d.ts +9 -4
- package/dist/components/label.js +9 -7
- package/dist/components/menubar.d.ts +80 -23
- package/dist/components/menubar.js +97 -118
- package/dist/components/native-select.d.ts +16 -6
- package/dist/components/native-select.js +25 -26
- package/dist/components/navigation-menu.d.ts +36 -12
- package/dist/components/navigation-menu.js +60 -75
- package/dist/components/pagination.d.ts +35 -14
- package/dist/components/pagination.js +54 -69
- package/dist/components/popover.d.ts +24 -8
- package/dist/components/popover.js +28 -28
- package/dist/components/progress-circle.d.ts +106 -88
- package/dist/components/progress-circle.js +106 -138
- package/dist/components/progress.d.ts +10 -4
- package/dist/components/progress.js +14 -14
- package/dist/components/radio-cards.d.ts +10 -4
- package/dist/components/radio-cards.js +22 -23
- package/dist/components/radio-group.d.ts +13 -5
- package/dist/components/radio-group.js +18 -16
- package/dist/components/radio.d.ts +12 -5
- package/dist/components/radio.js +10 -8
- package/dist/components/resizable.d.ts +18 -7
- package/dist/components/resizable.js +22 -22
- package/dist/components/scroll-area.d.ts +33 -20
- package/dist/components/scroll-area.js +84 -88
- package/dist/components/select.d.ts +50 -16
- package/dist/components/select.js +77 -96
- package/dist/components/separator.d.ts +29 -19
- package/dist/components/separator.js +36 -34
- package/dist/components/sheet.d.ts +62 -29
- package/dist/components/sheet.js +79 -100
- package/dist/components/sidebar.d.ts +160 -66
- package/dist/components/sidebar.js +294 -336
- package/dist/components/skeleton.d.ts +9 -4
- package/dist/components/skeleton.js +8 -6
- package/dist/components/slider.d.ts +13 -4
- package/dist/components/slider.js +34 -40
- package/dist/components/sonner.d.ts +10 -7
- package/dist/components/sonner.js +16 -14
- package/dist/components/spinner.d.ts +12 -5
- package/dist/components/spinner.js +33 -35
- package/dist/components/switch.d.ts +9 -4
- package/dist/components/switch.js +13 -11
- package/dist/components/table.d.ts +37 -11
- package/dist/components/table.js +47 -45
- package/dist/components/tabs.d.ts +21 -7
- package/dist/components/tabs.js +24 -22
- package/dist/components/textarea.d.ts +9 -4
- package/dist/components/textarea.js +8 -6
- package/dist/components/toggle-group.d.ts +24 -9
- package/dist/components/toggle-group.js +41 -42
- package/dist/components/toggle.d.ts +25 -17
- package/dist/components/toggle.js +30 -28
- package/dist/components/tooltip.d.ts +24 -8
- package/dist/components/tooltip.js +29 -32
- package/dist/hooks/use-animated-value.d.ts +4 -1
- package/dist/hooks/use-animated-value.js +57 -36
- package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
- package/dist/hooks/use-copy-to-clipboard.js +39 -20
- package/dist/hooks/use-is-mobile.d.ts +4 -1
- package/dist/hooks/use-is-mobile.js +21 -1
- package/dist/hooks/use-media-query.d.ts +4 -1
- package/dist/hooks/use-media-query.js +45 -18
- package/dist/hooks/use-mutation-observer.d.ts +6 -2
- package/dist/hooks/use-mutation-observer.js +34 -16
- package/dist/hooks/use-pagination.d.ts +22 -14
- package/dist/hooks/use-pagination.js +100 -49
- package/dist/index.d.ts +69 -130
- package/dist/index.js +11 -11
- package/dist/primitives/checkbox-group.d.ts +105 -83
- package/dist/primitives/checkbox-group.js +111 -84
- package/dist/primitives/input-number.d.ts +51 -40
- package/dist/primitives/input-number.js +483 -350
- package/dist/primitives/input.d.ts +48 -42
- package/dist/primitives/input.js +65 -43
- package/dist/primitives/progress-circle.d.ts +79 -48
- package/dist/primitives/progress-circle.js +154 -105
- package/package.json +6 -7
|
@@ -1,401 +1,359 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { cn, tv } from "@codefast/tailwind-variants";
|
|
4
|
-
import { createContext } from "@radix-ui/react-context";
|
|
5
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
6
|
-
import { PanelLeftIcon } from "lucide-react";
|
|
7
|
-
import { useCallback, useEffect, useState } from "react";
|
|
8
2
|
import { Button } from "./button.js";
|
|
9
|
-
import { Input } from "./input.js";
|
|
10
3
|
import { Separator } from "./separator.js";
|
|
4
|
+
import { Input } from "./input.js";
|
|
11
5
|
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "./sheet.js";
|
|
12
6
|
import { Skeleton } from "./skeleton.js";
|
|
13
7
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
|
|
14
8
|
import { useIsMobile } from "../hooks/use-is-mobile.js";
|
|
9
|
+
import { cn, tv } from "@codefast/tailwind-variants";
|
|
10
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
11
|
+
import { PanelLeftIcon } from "lucide-react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useCallback, useEffect, useState } from "react";
|
|
14
|
+
import { createContext } from "@radix-ui/react-context";
|
|
15
|
+
//#region src/components/sidebar.tsx
|
|
15
16
|
const sidebarMenuButtonVariants = tv({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
base: "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-3 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-[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 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: "md",
|
|
20
|
+
variant: "default"
|
|
21
|
+
},
|
|
22
|
+
variants: {
|
|
23
|
+
size: {
|
|
24
|
+
sm: "h-7 text-xs",
|
|
25
|
+
md: "h-8 text-sm",
|
|
26
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
|
|
27
|
+
},
|
|
28
|
+
variant: {
|
|
29
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
30
|
+
outline: "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))]"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
32
33
|
});
|
|
33
34
|
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
34
|
-
const SIDEBAR_COOKIE_MAX_AGE =
|
|
35
|
+
const SIDEBAR_COOKIE_MAX_AGE = 3600 * 24 * 7;
|
|
35
36
|
const SIDEBAR_WIDTH = "16rem";
|
|
36
37
|
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
37
38
|
const SIDEBAR_WIDTH_ICON = "3.0625rem";
|
|
38
39
|
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
39
|
-
const
|
|
40
|
-
const [SidebarContextProvider, useSidebar] = createContext(SIDEBAR_PROVIDER_NAME);
|
|
40
|
+
const [SidebarContextProvider, useSidebar] = createContext("SidebarProvider");
|
|
41
41
|
function SidebarProvider({ children, className, defaultOpen = true, onOpenChange: setOpenProperty, open: openProperty, style, ...props }) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"--sidebar-width": SIDEBAR_WIDTH,
|
|
92
|
-
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
93
|
-
...style
|
|
94
|
-
},
|
|
95
|
-
...props,
|
|
96
|
-
children: children
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
});
|
|
42
|
+
const isMobile = useIsMobile();
|
|
43
|
+
const [openMobile, setOpenMobile] = useState(false);
|
|
44
|
+
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
45
|
+
const open = openProperty ?? isOpen;
|
|
46
|
+
const setOpen = useCallback((value) => {
|
|
47
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
48
|
+
if (setOpenProperty) setOpenProperty(openState);
|
|
49
|
+
else setIsOpen(openState);
|
|
50
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState.toString()}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE.toString()}`;
|
|
51
|
+
}, [setOpenProperty, open]);
|
|
52
|
+
const toggleSidebar = useCallback(() => {
|
|
53
|
+
if (isMobile) setOpenMobile((currentValue) => !currentValue);
|
|
54
|
+
else setOpen((currentValue) => !currentValue);
|
|
55
|
+
}, [isMobile, setOpen]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const handleKeyDown = (event) => {
|
|
58
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
toggleSidebar();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
64
|
+
return () => {
|
|
65
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
66
|
+
};
|
|
67
|
+
}, [toggleSidebar]);
|
|
68
|
+
return /* @__PURE__ */ jsx(SidebarContextProvider, {
|
|
69
|
+
isMobile,
|
|
70
|
+
open,
|
|
71
|
+
openMobile,
|
|
72
|
+
setOpen,
|
|
73
|
+
setOpenMobile,
|
|
74
|
+
state: open ? "expanded" : "collapsed",
|
|
75
|
+
toggleSidebar,
|
|
76
|
+
children: /* @__PURE__ */ jsx(TooltipProvider, {
|
|
77
|
+
delayDuration: 0,
|
|
78
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
79
|
+
className: cn("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar", className),
|
|
80
|
+
"data-slot": "sidebar-wrapper",
|
|
81
|
+
style: {
|
|
82
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
83
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
84
|
+
...style
|
|
85
|
+
},
|
|
86
|
+
...props,
|
|
87
|
+
children
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
});
|
|
100
91
|
}
|
|
101
92
|
const SIDEBAR_NAME = "Sidebar";
|
|
102
93
|
function Sidebar({ children, className, collapsible = "offcanvas", side = "left", variant = "sidebar", ...props }) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
"data-slot": "sidebar-gap"
|
|
153
|
-
}),
|
|
154
|
-
/*#__PURE__*/ jsx("div", {
|
|
155
|
-
className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex", "left" === side ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]", "floating" === variant || "inset" === variant ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l", className),
|
|
156
|
-
"data-slot": "sidebar-container",
|
|
157
|
-
...props,
|
|
158
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
159
|
-
className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm",
|
|
160
|
-
"data-sidebar": "sidebar",
|
|
161
|
-
"data-slot": "sidebar-inner",
|
|
162
|
-
children: children
|
|
163
|
-
})
|
|
164
|
-
})
|
|
165
|
-
]
|
|
166
|
-
});
|
|
94
|
+
const { isMobile, openMobile, setOpenMobile, state } = useSidebar(SIDEBAR_NAME);
|
|
95
|
+
if (collapsible === "none") return /* @__PURE__ */ jsx("div", {
|
|
96
|
+
className: cn("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground", className),
|
|
97
|
+
"data-slot": "sidebar",
|
|
98
|
+
...props,
|
|
99
|
+
children
|
|
100
|
+
});
|
|
101
|
+
if (isMobile) return /* @__PURE__ */ jsx(Sheet, {
|
|
102
|
+
open: openMobile,
|
|
103
|
+
onOpenChange: setOpenMobile,
|
|
104
|
+
...props,
|
|
105
|
+
children: /* @__PURE__ */ jsxs(SheetContent, {
|
|
106
|
+
className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",
|
|
107
|
+
"data-mobile": "true",
|
|
108
|
+
"data-sidebar": "sidebar",
|
|
109
|
+
"data-slot": "sidebar",
|
|
110
|
+
side,
|
|
111
|
+
style: { "--sidebar-width": SIDEBAR_WIDTH_MOBILE },
|
|
112
|
+
children: [/* @__PURE__ */ jsxs(SheetHeader, {
|
|
113
|
+
className: "sr-only",
|
|
114
|
+
children: [/* @__PURE__ */ jsx(SheetTitle, { children: "Sidebar" }), /* @__PURE__ */ jsx(SheetDescription, { children: "Displays the mobile sidebar." })]
|
|
115
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
116
|
+
className: "flex h-full w-full flex-col",
|
|
117
|
+
children
|
|
118
|
+
})]
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
122
|
+
className: cn("group peer hidden text-sidebar-foreground md:block", className),
|
|
123
|
+
"data-collapsible": state === "collapsed" ? collapsible : "",
|
|
124
|
+
"data-side": side,
|
|
125
|
+
"data-slot": "sidebar",
|
|
126
|
+
"data-state": state,
|
|
127
|
+
"data-variant": variant,
|
|
128
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
129
|
+
className: cn("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear group-data-[collapsible=offcanvas]:w-0 group-data-[side=right]:rotate-180", variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"),
|
|
130
|
+
"data-slot": "sidebar-gap"
|
|
131
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
132
|
+
className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex", side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]", variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l", className),
|
|
133
|
+
"data-slot": "sidebar-container",
|
|
134
|
+
...props,
|
|
135
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
136
|
+
className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm",
|
|
137
|
+
"data-sidebar": "sidebar",
|
|
138
|
+
"data-slot": "sidebar-inner",
|
|
139
|
+
children
|
|
140
|
+
})
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
167
143
|
}
|
|
168
144
|
const SIDEBAR_TRIGGER_NAME = "SidebarTrigger";
|
|
169
145
|
function SidebarTrigger({ className, onClick, ...props }) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
})
|
|
188
|
-
]
|
|
189
|
-
});
|
|
146
|
+
const { toggleSidebar } = useSidebar(SIDEBAR_TRIGGER_NAME);
|
|
147
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
148
|
+
className: cn("size-7", className),
|
|
149
|
+
"data-sidebar": "trigger",
|
|
150
|
+
"data-slot": "sidebar-trigger",
|
|
151
|
+
size: "icon",
|
|
152
|
+
variant: "ghost",
|
|
153
|
+
onClick: (event) => {
|
|
154
|
+
onClick?.(event);
|
|
155
|
+
toggleSidebar();
|
|
156
|
+
},
|
|
157
|
+
...props,
|
|
158
|
+
children: [/* @__PURE__ */ jsx(PanelLeftIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
159
|
+
className: "sr-only",
|
|
160
|
+
children: "Toggle Sidebar"
|
|
161
|
+
})]
|
|
162
|
+
});
|
|
190
163
|
}
|
|
191
164
|
const SIDEBAR_RAIL_NAME = "SidebarRail";
|
|
192
165
|
function SidebarRail({ className, ...props }) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
166
|
+
const { toggleSidebar } = useSidebar(SIDEBAR_RAIL_NAME);
|
|
167
|
+
return /* @__PURE__ */ jsx("button", {
|
|
168
|
+
className: cn("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[collapsible=offcanvas]:translate-x-0 group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-0.5 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar hover:after:bg-sidebar-border in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize sm:flex [[data-side=left][data-collapsible=offcanvas]_&]:-right-2 [[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-collapsible=offcanvas]_&]:-left-2 [[data-side=right][data-state=collapsed]_&]:cursor-w-resize", className),
|
|
169
|
+
"data-sidebar": "rail",
|
|
170
|
+
"data-slot": "sidebar-rail",
|
|
171
|
+
title: "Toggle Sidebar",
|
|
172
|
+
type: "button",
|
|
173
|
+
onClick: toggleSidebar,
|
|
174
|
+
...props
|
|
175
|
+
});
|
|
203
176
|
}
|
|
204
177
|
function SidebarInset({ className, ...props }) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
178
|
+
return /* @__PURE__ */ jsx("main", {
|
|
179
|
+
className: cn("relative flex w-full min-w-0 flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2", className),
|
|
180
|
+
"data-slot": "sidebar-inset",
|
|
181
|
+
...props
|
|
182
|
+
});
|
|
210
183
|
}
|
|
211
184
|
function SidebarInput({ className, ...props }) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
185
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
186
|
+
className: cn("h-8 w-full bg-background shadow-none", className),
|
|
187
|
+
"data-sidebar": "input",
|
|
188
|
+
"data-slot": "sidebar-input",
|
|
189
|
+
...props
|
|
190
|
+
});
|
|
218
191
|
}
|
|
219
192
|
function SidebarHeader({ className, ...props }) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
193
|
+
return /* @__PURE__ */ jsx("div", {
|
|
194
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
195
|
+
"data-sidebar": "header",
|
|
196
|
+
"data-slot": "sidebar-header",
|
|
197
|
+
...props
|
|
198
|
+
});
|
|
226
199
|
}
|
|
227
200
|
function SidebarFooter({ className, ...props }) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
201
|
+
return /* @__PURE__ */ jsx("div", {
|
|
202
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
203
|
+
"data-sidebar": "footer",
|
|
204
|
+
"data-slot": "sidebar-footer",
|
|
205
|
+
...props
|
|
206
|
+
});
|
|
234
207
|
}
|
|
235
208
|
function SidebarSeparator({ className, ...props }) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
209
|
+
return /* @__PURE__ */ jsx(Separator, {
|
|
210
|
+
className: cn("mx-2 w-auto bg-sidebar-border", className),
|
|
211
|
+
"data-sidebar": "separator",
|
|
212
|
+
"data-slot": "sidebar-separator",
|
|
213
|
+
...props
|
|
214
|
+
});
|
|
242
215
|
}
|
|
243
216
|
function SidebarContent({ className, ...props }) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
217
|
+
return /* @__PURE__ */ jsx("div", {
|
|
218
|
+
className: cn("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden", className),
|
|
219
|
+
"data-sidebar": "content",
|
|
220
|
+
"data-slot": "sidebar-content",
|
|
221
|
+
...props
|
|
222
|
+
});
|
|
250
223
|
}
|
|
251
224
|
function SidebarGroup({ className, ...props }) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
225
|
+
return /* @__PURE__ */ jsx("div", {
|
|
226
|
+
className: cn("relative flex w-full min-w-0 flex-col p-2", className),
|
|
227
|
+
"data-sidebar": "group",
|
|
228
|
+
"data-slot": "sidebar-group",
|
|
229
|
+
...props
|
|
230
|
+
});
|
|
258
231
|
}
|
|
259
232
|
function SidebarGroupLabel({ asChild = false, className, ...props }) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
});
|
|
233
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "div", {
|
|
234
|
+
className: cn("flex h-8 shrink-0 items-center truncate rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-3 [&>svg]:size-4 [&>svg]:shrink-0", className),
|
|
235
|
+
"data-sidebar": "group-label",
|
|
236
|
+
"data-slot": "sidebar-group-label",
|
|
237
|
+
...props
|
|
238
|
+
});
|
|
267
239
|
}
|
|
268
240
|
function SidebarGroupAction({ asChild = false, className, ...props }) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
});
|
|
241
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
242
|
+
className: cn("absolute top-3.5 right-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-3 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0", className),
|
|
243
|
+
"data-sidebar": "group-action",
|
|
244
|
+
"data-slot": "sidebar-group-action",
|
|
245
|
+
...props
|
|
246
|
+
});
|
|
276
247
|
}
|
|
277
248
|
function SidebarGroupContent({ className, ...props }) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
249
|
+
return /* @__PURE__ */ jsx("div", {
|
|
250
|
+
className: cn("w-full text-sm", className),
|
|
251
|
+
"data-sidebar": "group-content",
|
|
252
|
+
"data-slot": "sidebar-group-content",
|
|
253
|
+
...props
|
|
254
|
+
});
|
|
284
255
|
}
|
|
285
256
|
function SidebarMenu({ className, ...props }) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
257
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
258
|
+
className: cn("flex w-full min-w-0 flex-col gap-1", className),
|
|
259
|
+
"data-sidebar": "menu",
|
|
260
|
+
"data-slot": "sidebar-menu",
|
|
261
|
+
...props
|
|
262
|
+
});
|
|
292
263
|
}
|
|
293
264
|
function SidebarMenuItem({ className, ...props }) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
265
|
+
return /* @__PURE__ */ jsx("li", {
|
|
266
|
+
className: cn("group/menu-item relative", className),
|
|
267
|
+
"data-sidebar": "menu-item",
|
|
268
|
+
"data-slot": "sidebar-menu-item",
|
|
269
|
+
...props
|
|
270
|
+
});
|
|
300
271
|
}
|
|
301
272
|
const SIDEBAR_MENU_BUTTON_NAME = "SidebarMenuButton";
|
|
302
273
|
function SidebarMenuButton({ asChild = false, className, isActive = false, size = "md", tooltip, variant = "default", ...props }) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
align: "center",
|
|
328
|
-
hidden: "collapsed" !== state || isMobile,
|
|
329
|
-
side: "right",
|
|
330
|
-
...tooltip
|
|
331
|
-
})
|
|
332
|
-
]
|
|
333
|
-
});
|
|
274
|
+
const Component = asChild ? Slot : "button";
|
|
275
|
+
const { isMobile, state } = useSidebar(SIDEBAR_MENU_BUTTON_NAME);
|
|
276
|
+
const button = /* @__PURE__ */ jsx(Component, {
|
|
277
|
+
className: cn(sidebarMenuButtonVariants({
|
|
278
|
+
size,
|
|
279
|
+
variant
|
|
280
|
+
}), className),
|
|
281
|
+
"data-active": isActive,
|
|
282
|
+
"data-sidebar": "menu-button",
|
|
283
|
+
"data-size": size,
|
|
284
|
+
"data-slot": "sidebar-menu-button",
|
|
285
|
+
...props
|
|
286
|
+
});
|
|
287
|
+
if (!tooltip) return button;
|
|
288
|
+
if (typeof tooltip === "string") tooltip = { children: tooltip };
|
|
289
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
290
|
+
asChild: true,
|
|
291
|
+
children: button
|
|
292
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
293
|
+
align: "center",
|
|
294
|
+
hidden: state !== "collapsed" || isMobile,
|
|
295
|
+
side: "right",
|
|
296
|
+
...tooltip
|
|
297
|
+
})] });
|
|
334
298
|
}
|
|
335
299
|
function SidebarMenuAction({ asChild = false, className, showOnHover = false, ...props }) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
});
|
|
300
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
301
|
+
className: cn("absolute top-1.5 right-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-3 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0", showOnHover && "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground data-[state=open]:opacity-100 md:opacity-0", className),
|
|
302
|
+
"data-sidebar": "menu-action",
|
|
303
|
+
"data-slot": "sidebar-menu-action",
|
|
304
|
+
...props
|
|
305
|
+
});
|
|
343
306
|
}
|
|
344
307
|
function SidebarMenuBadge({ className, ...props }) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
308
|
+
return /* @__PURE__ */ jsx("div", {
|
|
309
|
+
className: cn("pointer-events-none absolute right-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-[active=true]/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", className),
|
|
310
|
+
"data-sidebar": "menu-badge",
|
|
311
|
+
"data-slot": "sidebar-menu-badge",
|
|
312
|
+
...props
|
|
313
|
+
});
|
|
351
314
|
}
|
|
352
315
|
function SidebarMenuSkeleton({ className, showIcon = false, ...props }) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
"--skeleton-width": width
|
|
369
|
-
}
|
|
370
|
-
})
|
|
371
|
-
]
|
|
372
|
-
});
|
|
316
|
+
const [width] = useState(() => `${String(Math.floor(Math.random() * 40) + 50)}%`);
|
|
317
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
318
|
+
className: cn("flex h-8 items-center gap-2 rounded-md px-2", className),
|
|
319
|
+
"data-sidebar": "menu-skeleton",
|
|
320
|
+
"data-slot": "sidebar-menu-skeleton",
|
|
321
|
+
...props,
|
|
322
|
+
children: [showIcon ? /* @__PURE__ */ jsx(Skeleton, {
|
|
323
|
+
className: "size-4 rounded-md",
|
|
324
|
+
"data-sidebar": "menu-skeleton-icon"
|
|
325
|
+
}) : null, /* @__PURE__ */ jsx(Skeleton, {
|
|
326
|
+
className: "h-4 max-w-(--skeleton-width) flex-1",
|
|
327
|
+
"data-sidebar": "menu-skeleton-text",
|
|
328
|
+
style: { "--skeleton-width": width }
|
|
329
|
+
})]
|
|
330
|
+
});
|
|
373
331
|
}
|
|
374
332
|
function SidebarMenuSub({ className, ...props }) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
333
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
334
|
+
className: cn("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden", className),
|
|
335
|
+
"data-sidebar": "menu-sub",
|
|
336
|
+
"data-slot": "sidebar-menu-sub",
|
|
337
|
+
...props
|
|
338
|
+
});
|
|
381
339
|
}
|
|
382
340
|
function SidebarMenuSubItem({ className, ...props }) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
341
|
+
return /* @__PURE__ */ jsx("li", {
|
|
342
|
+
className: cn("group/menu-sub-item relative", className),
|
|
343
|
+
"data-sidebar": "menu-sub-item",
|
|
344
|
+
"data-slot": "sidebar-menu-sub-item",
|
|
345
|
+
...props
|
|
346
|
+
});
|
|
389
347
|
}
|
|
390
348
|
function SidebarMenuSubButton({ asChild = false, className, isActive = false, size = "md", ...props }) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
});
|
|
349
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "a", {
|
|
350
|
+
className: cn("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-3 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-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", size === "sm" && "text-xs", size === "md" && "text-sm", "group-data-[collapsible=icon]:hidden", className),
|
|
351
|
+
"data-active": isActive,
|
|
352
|
+
"data-sidebar": "menu-sub-button",
|
|
353
|
+
"data-size": size,
|
|
354
|
+
"data-slot": "sidebar-menu-sub-button",
|
|
355
|
+
...props
|
|
356
|
+
});
|
|
400
357
|
}
|
|
358
|
+
//#endregion
|
|
401
359
|
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, sidebarMenuButtonVariants, useSidebar };
|