@crossangle-org/cs-ui 0.2.5 → 0.2.7
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/components/accordion/cs-accordion.js +116 -0
- package/dist/components/accordion/cs-accordion.js.map +1 -0
- package/dist/components/alert-dialog/cs-alert-dialog.js +148 -0
- package/dist/components/alert-dialog/cs-alert-dialog.js.map +1 -0
- package/dist/components/avatar/cs-avatar.js +44 -0
- package/dist/components/avatar/cs-avatar.js.map +1 -0
- package/dist/components/badge/cs-badge.js +40 -0
- package/dist/components/badge/cs-badge.js.map +1 -0
- package/dist/components/box/cs-box.js +37 -0
- package/dist/components/box/cs-box.js.map +1 -0
- package/dist/components/button/cs-button.js +91 -0
- package/dist/components/button/cs-button.js.map +1 -0
- package/dist/components/calendar/cs-calendar.js +199 -0
- package/dist/components/calendar/cs-calendar.js.map +1 -0
- package/dist/components/card/cs-card.js +95 -0
- package/dist/components/card/cs-card.js.map +1 -0
- package/dist/components/chart/cs-chart.js +88 -0
- package/dist/components/chart/cs-chart.js.map +1 -0
- package/dist/components/checkbox/cs-checkbox.js +55 -0
- package/dist/components/checkbox/cs-checkbox.js.map +1 -0
- package/dist/components/code-block/cs-code-block.js +39 -0
- package/dist/components/code-block/cs-code-block.js.map +1 -0
- package/dist/components/code-block/cs-code-highlighter.js +59 -0
- package/dist/components/code-block/cs-code-highlighter.js.map +1 -0
- package/dist/components/collapsible/cs-collapsible.js +36 -0
- package/dist/components/collapsible/cs-collapsible.js.map +1 -0
- package/dist/components/date-picker/cs-date-picker.js +25 -0
- package/dist/components/date-picker/cs-date-picker.js.map +1 -0
- package/dist/components/dialog/cs-dialog.js +131 -0
- package/dist/components/dialog/cs-dialog.js.map +1 -0
- package/dist/components/drawer/cs-drawer.js +131 -0
- package/dist/components/drawer/cs-drawer.js.map +1 -0
- package/dist/components/dropdown-menu/cs-dropdown-menu.js +247 -0
- package/dist/components/dropdown-menu/cs-dropdown-menu.js.map +1 -0
- package/dist/components/dropzone/cs-dropzone.js +147 -0
- package/dist/components/dropzone/cs-dropzone.js.map +1 -0
- package/dist/components/empty/cs-empty.js +107 -0
- package/dist/components/empty/cs-empty.js.map +1 -0
- package/dist/components/field/cs-field.js +218 -0
- package/dist/components/field/cs-field.js.map +1 -0
- package/dist/components/input/cs-input-group.js +207 -0
- package/dist/components/input/cs-input-group.js.map +1 -0
- package/dist/components/input/cs-input.js +40 -0
- package/dist/components/input/cs-input.js.map +1 -0
- package/dist/components/label/cs-label.js +26 -0
- package/dist/components/label/cs-label.js.map +1 -0
- package/dist/components/navigation-menu/cs-navigation-menu.js +214 -0
- package/dist/components/navigation-menu/cs-navigation-menu.js.map +1 -0
- package/dist/components/pagination/cs-pagination.js +124 -0
- package/dist/components/pagination/cs-pagination.js.map +1 -0
- package/dist/components/popover/cs-popover.js +60 -0
- package/dist/components/popover/cs-popover.js.map +1 -0
- package/dist/components/progress/cs-progress.js +62 -0
- package/dist/components/progress/cs-progress.js.map +1 -0
- package/dist/components/scroll-area/cs-scroll-area.js +61 -0
- package/dist/components/scroll-area/cs-scroll-area.js.map +1 -0
- package/dist/components/select/cs-select.js +195 -0
- package/dist/components/select/cs-select.js.map +1 -0
- package/dist/components/select/cs-simple-select.js +32 -0
- package/dist/components/select/cs-simple-select.js.map +1 -0
- package/dist/components/separator/cs-separator.js +28 -0
- package/dist/components/separator/cs-separator.js.map +1 -0
- package/dist/components/sheet/cs-sheet.js +128 -0
- package/dist/components/sheet/cs-sheet.js.map +1 -0
- package/dist/components/sidebar/cs-sidebar.js +657 -0
- package/dist/components/sidebar/cs-sidebar.js.map +1 -0
- package/dist/components/skeleton/cs-skeleton.js +32 -0
- package/dist/components/skeleton/cs-skeleton.js.map +1 -0
- package/dist/components/sonner/cs-sonner.js +76 -0
- package/dist/components/sonner/cs-sonner.js.map +1 -0
- package/dist/components/spinner/cs-spinner.js +34 -0
- package/dist/components/spinner/cs-spinner.js.map +1 -0
- package/dist/components/switch/cs-switch.js +38 -0
- package/dist/components/switch/cs-switch.js.map +1 -0
- package/dist/components/table/cs-data-base-table.js +108 -0
- package/dist/components/table/cs-data-base-table.js.map +1 -0
- package/dist/components/table/cs-data-table.js +32 -0
- package/dist/components/table/cs-data-table.js.map +1 -0
- package/dist/components/table/cs-skeleton-table.js +41 -0
- package/dist/components/table/cs-skeleton-table.js.map +1 -0
- package/dist/components/table/cs-table.js +120 -0
- package/dist/components/table/cs-table.js.map +1 -0
- package/dist/components/tabs/cs-simple-tabs.js +24 -0
- package/dist/components/tabs/cs-simple-tabs.js.map +1 -0
- package/dist/components/tabs/cs-tabs.js +114 -0
- package/dist/components/tabs/cs-tabs.js.map +1 -0
- package/dist/components/toggle/cs-toggle-group.js +65 -0
- package/dist/components/toggle/cs-toggle-group.js.map +1 -0
- package/dist/components/toggle/cs-toggle.js +46 -0
- package/dist/components/toggle/cs-toggle.js.map +1 -0
- package/dist/components/tooltip/cs-simple-tooltip.js +16 -0
- package/dist/components/tooltip/cs-simple-tooltip.js.map +1 -0
- package/dist/components/tooltip/cs-tooltip.js +72 -0
- package/dist/components/tooltip/cs-tooltip.js.map +1 -0
- package/dist/constants/cs-chart-option.constant.js +105 -0
- package/dist/constants/cs-chart-option.constant.js.map +1 -0
- package/dist/cs-ui.css +73 -108
- package/dist/hooks/use-accordion.js +54 -0
- package/dist/hooks/use-accordion.js.map +1 -0
- package/dist/hooks/use-infinite-scroll.js +40 -0
- package/dist/hooks/use-infinite-scroll.js.map +1 -0
- package/dist/hooks/use-laptop.js +20 -0
- package/dist/hooks/use-laptop.js.map +1 -0
- package/dist/hooks/use-mobile.js +20 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/index.d.ts +19 -6
- package/dist/index.js +287 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/chart.util.js +48 -0
- package/dist/lib/chart.util.js.map +1 -0
- package/dist/lib/style.util.js +19 -0
- package/dist/lib/style.util.js.map +1 -0
- package/dist/lib/utils.js +27 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +4 -5
- package/dist/index.cjs.js +0 -147659
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -147624
- package/dist/index.es.js.map +0 -1
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { ChevronDownIcon, PanelLeftIcon } from "lucide-react";
|
|
6
|
+
import { useIsMobile } from "../../hooks/use-mobile.js";
|
|
7
|
+
import { cn } from "../../lib/utils.js";
|
|
8
|
+
import { CsSheet, CsSheetContent, CsSheetHeader, CsSheetTitle, CsSheetDescription } from "../sheet/cs-sheet.js";
|
|
9
|
+
import { CsCollapsible, CsCollapsibleTrigger, CsCollapsibleContent } from "../collapsible/cs-collapsible.js";
|
|
10
|
+
import { csNavigationMenuTriggerStyle, csNavigationMenuLinkVariants } from "../navigation-menu/cs-navigation-menu.js";
|
|
11
|
+
import { CsInput } from "../input/cs-input.js";
|
|
12
|
+
import { CsTooltip, CsTooltipTrigger, CsTooltipContent, CsTooltipProvider } from "../tooltip/cs-tooltip.js";
|
|
13
|
+
import { CsSkeleton } from "../skeleton/cs-skeleton.js";
|
|
14
|
+
import { CsSeparator } from "../separator/cs-separator.js";
|
|
15
|
+
import { CsButton } from "../button/cs-button.js";
|
|
16
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
17
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
18
|
+
const SIDEBAR_WIDTH = "16rem";
|
|
19
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
20
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
21
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
22
|
+
const SidebarGroupContext = React.createContext(false);
|
|
23
|
+
const SidebarContext = React.createContext(null);
|
|
24
|
+
function useSidebar() {
|
|
25
|
+
const context = React.useContext(SidebarContext);
|
|
26
|
+
if (!context) {
|
|
27
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
28
|
+
}
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
31
|
+
function CsSidebarProvider({
|
|
32
|
+
defaultOpen = true,
|
|
33
|
+
open: openProp,
|
|
34
|
+
onOpenChange: setOpenProp,
|
|
35
|
+
variant = "solid-ghost",
|
|
36
|
+
className,
|
|
37
|
+
style,
|
|
38
|
+
children,
|
|
39
|
+
...props
|
|
40
|
+
}) {
|
|
41
|
+
const isMobile = useIsMobile();
|
|
42
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
43
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
44
|
+
const open = openProp ?? _open;
|
|
45
|
+
const setOpen = React.useCallback(
|
|
46
|
+
(value) => {
|
|
47
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
48
|
+
if (setOpenProp) {
|
|
49
|
+
setOpenProp(openState);
|
|
50
|
+
} else {
|
|
51
|
+
_setOpen(openState);
|
|
52
|
+
}
|
|
53
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
54
|
+
},
|
|
55
|
+
[setOpenProp, open]
|
|
56
|
+
);
|
|
57
|
+
const toggleSidebar = React.useCallback(() => {
|
|
58
|
+
return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
|
|
59
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
const handleKeyDown = (event) => {
|
|
62
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
toggleSidebar();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
68
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
69
|
+
}, [toggleSidebar]);
|
|
70
|
+
const state = open ? "expanded" : "collapsed";
|
|
71
|
+
const contextValue = React.useMemo(
|
|
72
|
+
() => ({
|
|
73
|
+
state,
|
|
74
|
+
open,
|
|
75
|
+
setOpen,
|
|
76
|
+
isMobile,
|
|
77
|
+
openMobile,
|
|
78
|
+
setOpenMobile,
|
|
79
|
+
toggleSidebar,
|
|
80
|
+
variant
|
|
81
|
+
}),
|
|
82
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar, variant]
|
|
83
|
+
);
|
|
84
|
+
return /* @__PURE__ */ jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(CsTooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsx(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
"data-slot": "sidebar-wrapper",
|
|
88
|
+
style: {
|
|
89
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
90
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
91
|
+
...style
|
|
92
|
+
},
|
|
93
|
+
className: cn(
|
|
94
|
+
"group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
|
|
95
|
+
className
|
|
96
|
+
),
|
|
97
|
+
...props,
|
|
98
|
+
children
|
|
99
|
+
}
|
|
100
|
+
) }) });
|
|
101
|
+
}
|
|
102
|
+
function CsSidebar({
|
|
103
|
+
side = "left",
|
|
104
|
+
variant = "sidebar",
|
|
105
|
+
collapsible = "offcanvas",
|
|
106
|
+
className,
|
|
107
|
+
children,
|
|
108
|
+
...props
|
|
109
|
+
}) {
|
|
110
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
111
|
+
if (collapsible === "none") {
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
"div",
|
|
114
|
+
{
|
|
115
|
+
"data-slot": "sidebar",
|
|
116
|
+
className: cn(
|
|
117
|
+
"flex h-full w-(--sidebar-width) flex-col",
|
|
118
|
+
className
|
|
119
|
+
),
|
|
120
|
+
...props,
|
|
121
|
+
children
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
if (isMobile) {
|
|
126
|
+
return /* @__PURE__ */ jsx(CsSheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxs(
|
|
127
|
+
CsSheetContent,
|
|
128
|
+
{
|
|
129
|
+
"data-sidebar": "sidebar",
|
|
130
|
+
"data-slot": "sidebar",
|
|
131
|
+
"data-mobile": "true",
|
|
132
|
+
className: "bg-(--color-bg-overlay-default) w-(--sidebar-width) p-0 [&>button]:hidden",
|
|
133
|
+
style: {
|
|
134
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE
|
|
135
|
+
},
|
|
136
|
+
side,
|
|
137
|
+
children: [
|
|
138
|
+
/* @__PURE__ */ jsxs(CsSheetHeader, { className: "sr-only", children: [
|
|
139
|
+
/* @__PURE__ */ jsx(CsSheetTitle, { children: "Sidebar" }),
|
|
140
|
+
/* @__PURE__ */ jsx(CsSheetDescription, { children: "Displays the mobile sidebar." })
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-full w-full flex-col p-layout-md gap-layout-md bg-(--color-bg-surface-default) boxshadow-lg", children })
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
) });
|
|
146
|
+
}
|
|
147
|
+
return /* @__PURE__ */ jsxs(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: "group peer text-sidebar-foreground hidden mobile:block",
|
|
151
|
+
"data-state": state,
|
|
152
|
+
"data-collapsible": state === "collapsed" ? collapsible : "",
|
|
153
|
+
"data-variant": variant,
|
|
154
|
+
"data-side": side,
|
|
155
|
+
"data-slot": "sidebar",
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ jsx(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
"data-slot": "sidebar-gap",
|
|
161
|
+
className: cn(
|
|
162
|
+
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
|
163
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
164
|
+
"group-data-[side=right]:rotate-180",
|
|
165
|
+
variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
/* @__PURE__ */ jsx(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
"data-slot": "sidebar-container",
|
|
173
|
+
className: cn(
|
|
174
|
+
"fixed shadow-none inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear mobile:flex",
|
|
175
|
+
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)]",
|
|
176
|
+
variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
|
|
177
|
+
className
|
|
178
|
+
),
|
|
179
|
+
...props,
|
|
180
|
+
children: /* @__PURE__ */ jsx(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
"data-sidebar": "sidebar",
|
|
184
|
+
"data-slot": "sidebar-inner",
|
|
185
|
+
className: "bg-(--color-bg-surface-default) flex h-full w-full flex-col p-layout-md gap-layout-md boxshadow-lg",
|
|
186
|
+
children
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function CsSidebarTrigger({
|
|
196
|
+
className,
|
|
197
|
+
onClick,
|
|
198
|
+
children,
|
|
199
|
+
...props
|
|
200
|
+
}) {
|
|
201
|
+
const { toggleSidebar } = useSidebar();
|
|
202
|
+
return /* @__PURE__ */ jsxs(
|
|
203
|
+
CsButton,
|
|
204
|
+
{
|
|
205
|
+
"data-sidebar": "trigger",
|
|
206
|
+
"data-slot": "sidebar-trigger",
|
|
207
|
+
variant: "ghost",
|
|
208
|
+
className,
|
|
209
|
+
onClick: (event) => {
|
|
210
|
+
onClick?.(event);
|
|
211
|
+
toggleSidebar();
|
|
212
|
+
},
|
|
213
|
+
...props,
|
|
214
|
+
children: [
|
|
215
|
+
children ?? /* @__PURE__ */ jsx(PanelLeftIcon, {}),
|
|
216
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
function CsSidebarRail({ className, ...props }) {
|
|
222
|
+
const { toggleSidebar } = useSidebar();
|
|
223
|
+
return /* @__PURE__ */ jsx(
|
|
224
|
+
"button",
|
|
225
|
+
{
|
|
226
|
+
"data-sidebar": "rail",
|
|
227
|
+
"data-slot": "sidebar-rail",
|
|
228
|
+
"aria-label": "Toggle Sidebar",
|
|
229
|
+
tabIndex: -1,
|
|
230
|
+
onClick: toggleSidebar,
|
|
231
|
+
title: "Toggle Sidebar",
|
|
232
|
+
className: cn(
|
|
233
|
+
"hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] mobile:flex",
|
|
234
|
+
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
|
|
235
|
+
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
236
|
+
"hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
|
|
237
|
+
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
238
|
+
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
239
|
+
className
|
|
240
|
+
),
|
|
241
|
+
...props
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
function CsSidebarInset({ className, ...props }) {
|
|
246
|
+
return /* @__PURE__ */ jsx(
|
|
247
|
+
"main",
|
|
248
|
+
{
|
|
249
|
+
"data-slot": "sidebar-inset",
|
|
250
|
+
className: cn(
|
|
251
|
+
"bg-background relative flex w-full flex-1 flex-col",
|
|
252
|
+
"mobile:peer-data-[variant=inset]:m-2 mobile:peer-data-[variant=inset]:ml-0 mobile:peer-data-[variant=inset]:rounded-xl mobile:peer-data-[variant=inset]:shadow-sm mobile:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
253
|
+
className
|
|
254
|
+
),
|
|
255
|
+
...props
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
function CsSidebarInput({
|
|
260
|
+
className,
|
|
261
|
+
...props
|
|
262
|
+
}) {
|
|
263
|
+
return /* @__PURE__ */ jsx(
|
|
264
|
+
CsInput,
|
|
265
|
+
{
|
|
266
|
+
"data-slot": "sidebar-input",
|
|
267
|
+
"data-sidebar": "input",
|
|
268
|
+
className: cn("bg-background h-8 w-full shadow-none", className),
|
|
269
|
+
...props
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
function CsSidebarHeader({ className, ...props }) {
|
|
274
|
+
return /* @__PURE__ */ jsx(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
"data-slot": "sidebar-header",
|
|
278
|
+
"data-sidebar": "header",
|
|
279
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
280
|
+
...props
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
function CsSidebarFooter({ className, ...props }) {
|
|
285
|
+
return /* @__PURE__ */ jsx(
|
|
286
|
+
"div",
|
|
287
|
+
{
|
|
288
|
+
"data-slot": "sidebar-footer",
|
|
289
|
+
"data-sidebar": "footer",
|
|
290
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
291
|
+
...props
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
function CsSidebarSeparator({
|
|
296
|
+
className,
|
|
297
|
+
...props
|
|
298
|
+
}) {
|
|
299
|
+
return /* @__PURE__ */ jsx(
|
|
300
|
+
CsSeparator,
|
|
301
|
+
{
|
|
302
|
+
"data-slot": "sidebar-separator",
|
|
303
|
+
"data-sidebar": "separator",
|
|
304
|
+
className: cn("bg-sidebar-border mx-2 w-auto", className),
|
|
305
|
+
...props
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
function CsSidebarContent({ className, ...props }) {
|
|
310
|
+
return /* @__PURE__ */ jsx(
|
|
311
|
+
"div",
|
|
312
|
+
{
|
|
313
|
+
"data-slot": "sidebar-content",
|
|
314
|
+
"data-sidebar": "content",
|
|
315
|
+
className: cn(
|
|
316
|
+
"flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
317
|
+
className
|
|
318
|
+
),
|
|
319
|
+
...props
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
function CsSidebarGroup({ className, ...props }) {
|
|
324
|
+
return /* @__PURE__ */ jsx(
|
|
325
|
+
"div",
|
|
326
|
+
{
|
|
327
|
+
"data-slot": "sidebar-group",
|
|
328
|
+
"data-sidebar": "group",
|
|
329
|
+
className: cn("relative flex w-full min-w-0 flex-col", className),
|
|
330
|
+
...props
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
function CsSidebarGroupCollapsible({
|
|
335
|
+
title,
|
|
336
|
+
icon,
|
|
337
|
+
children,
|
|
338
|
+
className,
|
|
339
|
+
variant = "solid-ghost",
|
|
340
|
+
...props
|
|
341
|
+
}) {
|
|
342
|
+
return /* @__PURE__ */ jsx(CsCollapsible, { className: "group/collapsible", children: /* @__PURE__ */ jsxs(CsSidebarGroup, { className: cn("gap-layout-sm", className), ...props, children: [
|
|
343
|
+
/* @__PURE__ */ jsxs(
|
|
344
|
+
CsCollapsibleTrigger,
|
|
345
|
+
{
|
|
346
|
+
className: cn(
|
|
347
|
+
csNavigationMenuTriggerStyle({ variant }),
|
|
348
|
+
"w-full justify-start",
|
|
349
|
+
className
|
|
350
|
+
),
|
|
351
|
+
children: [
|
|
352
|
+
icon,
|
|
353
|
+
title,
|
|
354
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-180" })
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
),
|
|
358
|
+
/* @__PURE__ */ jsx(CsCollapsibleContent, { children: /* @__PURE__ */ jsx(CsSidebarGroupContent, { className: "flex flex-col gap-layout-sm", children }) })
|
|
359
|
+
] }) });
|
|
360
|
+
}
|
|
361
|
+
function CsSidebarGroupLabel({
|
|
362
|
+
className,
|
|
363
|
+
asChild = false,
|
|
364
|
+
...props
|
|
365
|
+
}) {
|
|
366
|
+
const Comp = asChild ? Slot : "div";
|
|
367
|
+
return /* @__PURE__ */ jsx(
|
|
368
|
+
Comp,
|
|
369
|
+
{
|
|
370
|
+
"data-slot": "sidebar-group-label",
|
|
371
|
+
"data-sidebar": "group-label",
|
|
372
|
+
className: cn(
|
|
373
|
+
"text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
374
|
+
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
|
375
|
+
className
|
|
376
|
+
),
|
|
377
|
+
...props
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
function CsSidebarGroupAction({
|
|
382
|
+
className,
|
|
383
|
+
asChild = false,
|
|
384
|
+
...props
|
|
385
|
+
}) {
|
|
386
|
+
const Comp = asChild ? Slot : "button";
|
|
387
|
+
return /* @__PURE__ */ jsx(
|
|
388
|
+
Comp,
|
|
389
|
+
{
|
|
390
|
+
"data-slot": "sidebar-group-action",
|
|
391
|
+
"data-sidebar": "group-action",
|
|
392
|
+
className: cn(
|
|
393
|
+
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
394
|
+
// Increases the hit area of the button on mobile.
|
|
395
|
+
"after:absolute after:-inset-2 mobile:after:hidden",
|
|
396
|
+
"group-data-[collapsible=icon]:hidden",
|
|
397
|
+
className
|
|
398
|
+
),
|
|
399
|
+
...props
|
|
400
|
+
}
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
function CsSidebarGroupContent({
|
|
404
|
+
className,
|
|
405
|
+
...props
|
|
406
|
+
}) {
|
|
407
|
+
return /* @__PURE__ */ jsx(SidebarGroupContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
|
|
408
|
+
"div",
|
|
409
|
+
{
|
|
410
|
+
"data-slot": "sidebar-group-content",
|
|
411
|
+
"data-sidebar": "group-content",
|
|
412
|
+
className: cn("w-full px-layout-sm", className),
|
|
413
|
+
...props
|
|
414
|
+
}
|
|
415
|
+
) });
|
|
416
|
+
}
|
|
417
|
+
function CsSidebarMenu({ className, ...props }) {
|
|
418
|
+
return /* @__PURE__ */ jsx(
|
|
419
|
+
"ul",
|
|
420
|
+
{
|
|
421
|
+
"data-slot": "sidebar-menu",
|
|
422
|
+
"data-sidebar": "menu",
|
|
423
|
+
className: cn("flex w-full min-w-0 flex-col gap-1", className),
|
|
424
|
+
...props
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
function CsSidebarMenuItem({ className, ...props }) {
|
|
429
|
+
return /* @__PURE__ */ jsx(
|
|
430
|
+
"li",
|
|
431
|
+
{
|
|
432
|
+
"data-slot": "sidebar-menu-item",
|
|
433
|
+
"data-sidebar": "menu-item",
|
|
434
|
+
className: cn("group/menu-item relative", className),
|
|
435
|
+
...props
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
const SIDEBAR_MENU_BUTTON_BASE = "peer/menu-button w-full justify-start overflow-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! [&>span:last-child]:truncate";
|
|
440
|
+
function CsSidebarMenuButton({
|
|
441
|
+
asChild = false,
|
|
442
|
+
isActive = false,
|
|
443
|
+
tooltip,
|
|
444
|
+
className,
|
|
445
|
+
onClick,
|
|
446
|
+
...props
|
|
447
|
+
}) {
|
|
448
|
+
const Comp = asChild ? Slot : "button";
|
|
449
|
+
const { isMobile, state, variant, setOpenMobile } = useSidebar();
|
|
450
|
+
const isInsideGroup = React.useContext(SidebarGroupContext);
|
|
451
|
+
const handleClick = (e) => {
|
|
452
|
+
if (isMobile) {
|
|
453
|
+
setOpenMobile(false);
|
|
454
|
+
}
|
|
455
|
+
onClick?.(e);
|
|
456
|
+
};
|
|
457
|
+
const button = /* @__PURE__ */ jsx(
|
|
458
|
+
Comp,
|
|
459
|
+
{
|
|
460
|
+
"data-slot": "sidebar-menu-button",
|
|
461
|
+
"data-sidebar": "menu-button",
|
|
462
|
+
"data-active": isActive,
|
|
463
|
+
className: cn(
|
|
464
|
+
SIDEBAR_MENU_BUTTON_BASE,
|
|
465
|
+
isInsideGroup ? csNavigationMenuLinkVariants({ variant: "item" }) : csNavigationMenuTriggerStyle({ variant }),
|
|
466
|
+
"w-full justify-start",
|
|
467
|
+
isActive && isInsideGroup && "bg-(--navigation-item-hover-bg) text-(--navigation-item-hover-font)",
|
|
468
|
+
className
|
|
469
|
+
),
|
|
470
|
+
onClick: handleClick,
|
|
471
|
+
...props
|
|
472
|
+
}
|
|
473
|
+
);
|
|
474
|
+
if (!tooltip) {
|
|
475
|
+
return button;
|
|
476
|
+
}
|
|
477
|
+
if (typeof tooltip === "string") {
|
|
478
|
+
tooltip = {
|
|
479
|
+
children: tooltip
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
return /* @__PURE__ */ jsxs(CsTooltip, { children: [
|
|
483
|
+
/* @__PURE__ */ jsx(CsTooltipTrigger, { asChild: true, children: button }),
|
|
484
|
+
/* @__PURE__ */ jsx(
|
|
485
|
+
CsTooltipContent,
|
|
486
|
+
{
|
|
487
|
+
side: "right",
|
|
488
|
+
align: "center",
|
|
489
|
+
hidden: state !== "collapsed" || isMobile,
|
|
490
|
+
...tooltip
|
|
491
|
+
}
|
|
492
|
+
)
|
|
493
|
+
] });
|
|
494
|
+
}
|
|
495
|
+
function CsSidebarMenuAction({
|
|
496
|
+
className,
|
|
497
|
+
asChild = false,
|
|
498
|
+
showOnHover = false,
|
|
499
|
+
...props
|
|
500
|
+
}) {
|
|
501
|
+
const Comp = asChild ? Slot : "button";
|
|
502
|
+
return /* @__PURE__ */ jsx(
|
|
503
|
+
Comp,
|
|
504
|
+
{
|
|
505
|
+
"data-slot": "sidebar-menu-action",
|
|
506
|
+
"data-sidebar": "menu-action",
|
|
507
|
+
className: cn(
|
|
508
|
+
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
509
|
+
"after:absolute after:-inset-2 mobile:after:hidden",
|
|
510
|
+
"group-data-[collapsible=icon]:hidden",
|
|
511
|
+
showOnHover && "peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 mobile:opacity-0",
|
|
512
|
+
className
|
|
513
|
+
),
|
|
514
|
+
...props
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
function CsSidebarMenuBadge({
|
|
519
|
+
className,
|
|
520
|
+
...props
|
|
521
|
+
}) {
|
|
522
|
+
return /* @__PURE__ */ jsx(
|
|
523
|
+
"div",
|
|
524
|
+
{
|
|
525
|
+
"data-slot": "sidebar-menu-badge",
|
|
526
|
+
"data-sidebar": "menu-badge",
|
|
527
|
+
className: cn(
|
|
528
|
+
"text-sidebar-foreground pointer-events-none absolute top-1.5 right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none",
|
|
529
|
+
"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
|
|
530
|
+
"group-data-[collapsible=icon]:hidden",
|
|
531
|
+
className
|
|
532
|
+
),
|
|
533
|
+
...props
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
function CsSidebarMenuSkeleton({
|
|
538
|
+
className,
|
|
539
|
+
showIcon = false,
|
|
540
|
+
...props
|
|
541
|
+
}) {
|
|
542
|
+
const width = React.useMemo(() => {
|
|
543
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
544
|
+
}, []);
|
|
545
|
+
return /* @__PURE__ */ jsxs(
|
|
546
|
+
"div",
|
|
547
|
+
{
|
|
548
|
+
"data-slot": "sidebar-menu-skeleton",
|
|
549
|
+
"data-sidebar": "menu-skeleton",
|
|
550
|
+
className: cn("flex h-8 items-center gap-2 rounded-md px-2", className),
|
|
551
|
+
...props,
|
|
552
|
+
children: [
|
|
553
|
+
showIcon && /* @__PURE__ */ jsx(
|
|
554
|
+
CsSkeleton,
|
|
555
|
+
{
|
|
556
|
+
className: "size-4 rounded-md",
|
|
557
|
+
"data-sidebar": "menu-skeleton-icon"
|
|
558
|
+
}
|
|
559
|
+
),
|
|
560
|
+
/* @__PURE__ */ jsx(
|
|
561
|
+
CsSkeleton,
|
|
562
|
+
{
|
|
563
|
+
className: "h-4 max-w-(--skeleton-width) flex-1",
|
|
564
|
+
"data-sidebar": "menu-skeleton-text",
|
|
565
|
+
style: {
|
|
566
|
+
"--skeleton-width": width
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
)
|
|
570
|
+
]
|
|
571
|
+
}
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
function CsSidebarMenuSub({ className, ...props }) {
|
|
575
|
+
return /* @__PURE__ */ jsx(
|
|
576
|
+
"ul",
|
|
577
|
+
{
|
|
578
|
+
"data-slot": "sidebar-menu-sub",
|
|
579
|
+
"data-sidebar": "menu-sub",
|
|
580
|
+
className: cn(
|
|
581
|
+
"border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5",
|
|
582
|
+
"group-data-[collapsible=icon]:hidden",
|
|
583
|
+
className
|
|
584
|
+
),
|
|
585
|
+
...props
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
function CsSidebarMenuSubItem({
|
|
590
|
+
className,
|
|
591
|
+
...props
|
|
592
|
+
}) {
|
|
593
|
+
return /* @__PURE__ */ jsx(
|
|
594
|
+
"li",
|
|
595
|
+
{
|
|
596
|
+
"data-slot": "sidebar-menu-sub-item",
|
|
597
|
+
"data-sidebar": "menu-sub-item",
|
|
598
|
+
className: cn("group/menu-sub-item relative", className),
|
|
599
|
+
...props
|
|
600
|
+
}
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
function CsSidebarMenuSubButton({
|
|
604
|
+
asChild = false,
|
|
605
|
+
size = "md",
|
|
606
|
+
isActive = false,
|
|
607
|
+
className,
|
|
608
|
+
...props
|
|
609
|
+
}) {
|
|
610
|
+
const Comp = asChild ? Slot : "a";
|
|
611
|
+
return /* @__PURE__ */ jsx(
|
|
612
|
+
Comp,
|
|
613
|
+
{
|
|
614
|
+
"data-slot": "sidebar-menu-sub-button",
|
|
615
|
+
"data-sidebar": "menu-sub-button",
|
|
616
|
+
"data-size": size,
|
|
617
|
+
"data-active": isActive,
|
|
618
|
+
className: cn(
|
|
619
|
+
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
|
|
620
|
+
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
|
|
621
|
+
size === "sm" && "text-xs",
|
|
622
|
+
size === "md" && "text-sm",
|
|
623
|
+
"group-data-[collapsible=icon]:hidden",
|
|
624
|
+
className
|
|
625
|
+
),
|
|
626
|
+
...props
|
|
627
|
+
}
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
export {
|
|
631
|
+
CsSidebar,
|
|
632
|
+
CsSidebarContent,
|
|
633
|
+
CsSidebarFooter,
|
|
634
|
+
CsSidebarGroup,
|
|
635
|
+
CsSidebarGroupAction,
|
|
636
|
+
CsSidebarGroupCollapsible,
|
|
637
|
+
CsSidebarGroupContent,
|
|
638
|
+
CsSidebarGroupLabel,
|
|
639
|
+
CsSidebarHeader,
|
|
640
|
+
CsSidebarInput,
|
|
641
|
+
CsSidebarInset,
|
|
642
|
+
CsSidebarMenu,
|
|
643
|
+
CsSidebarMenuAction,
|
|
644
|
+
CsSidebarMenuBadge,
|
|
645
|
+
CsSidebarMenuButton,
|
|
646
|
+
CsSidebarMenuItem,
|
|
647
|
+
CsSidebarMenuSkeleton,
|
|
648
|
+
CsSidebarMenuSub,
|
|
649
|
+
CsSidebarMenuSubButton,
|
|
650
|
+
CsSidebarMenuSubItem,
|
|
651
|
+
CsSidebarProvider,
|
|
652
|
+
CsSidebarRail,
|
|
653
|
+
CsSidebarSeparator,
|
|
654
|
+
CsSidebarTrigger,
|
|
655
|
+
useSidebar
|
|
656
|
+
};
|
|
657
|
+
//# sourceMappingURL=cs-sidebar.js.map
|