@waveso/ui 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -52
- package/dist/accordion.js +1 -1
- package/dist/badge.d.ts +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.d.ts +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{chunk-PGXELRT4.js → chunk-45VQAWIM.js} +3 -3
- package/dist/{chunk-PGXELRT4.js.map → chunk-45VQAWIM.js.map} +1 -1
- package/dist/{chunk-ZOKFCJWM.js → chunk-6Y7LPQMO.js} +3 -3
- package/dist/{chunk-ZOKFCJWM.js.map → chunk-6Y7LPQMO.js.map} +1 -1
- package/dist/chunk-7F4MPMLJ.js +17 -0
- package/dist/chunk-7F4MPMLJ.js.map +1 -0
- package/dist/chunk-7OIQ6YBK.js +66 -0
- package/dist/chunk-7OIQ6YBK.js.map +1 -0
- package/dist/{chunk-WJDWQFO3.js → chunk-DIGOLJIR.js} +9 -3
- package/dist/chunk-DIGOLJIR.js.map +1 -0
- package/dist/chunk-PVX4VQFJ.js +143 -0
- package/dist/chunk-PVX4VQFJ.js.map +1 -0
- package/dist/chunk-ZZZH3JGW.js +23 -0
- package/dist/chunk-ZZZH3JGW.js.map +1 -0
- package/dist/combobox.js +1 -1
- package/dist/context-menu.js +1 -1
- package/dist/dialog.js +1 -1
- package/dist/drawer.js +4 -141
- package/dist/drawer.js.map +1 -1
- package/dist/hooks/use-mobile.d.ts +6 -1
- package/dist/hooks/use-mobile.js +1 -18
- package/dist/hooks/use-mobile.js.map +1 -1
- package/dist/infinite-scroll.js +2 -2
- package/dist/input-otp.js +1 -1
- package/dist/item.d.ts +1 -1
- package/dist/masonry.js +1 -1
- package/dist/menu.js +2 -2
- package/dist/menubar.js +2 -2
- package/dist/pagination.js +1 -1
- package/dist/select.js +1 -1
- package/dist/sidebar.d.ts +112 -0
- package/dist/sidebar.js +619 -0
- package/dist/sidebar.js.map +1 -0
- package/dist/skeleton.js +2 -15
- package/dist/skeleton.js.map +1 -1
- package/dist/spinner.js +2 -2
- package/dist/styles.css +201 -0
- package/dist/tabs.d.ts +1 -1
- package/dist/toast.js +1 -1
- package/dist/tooltip.js +2 -64
- package/dist/tooltip.js.map +1 -1
- package/package.json +6 -3
- package/dist/chunk-WJDWQFO3.js.map +0 -1
package/dist/sidebar.js
ADDED
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { TooltipTrigger, Tooltip, TooltipContent } from './chunk-7OIQ6YBK.js';
|
|
2
|
+
import { useIsMobile } from './chunk-ZZZH3JGW.js';
|
|
3
|
+
import { Skeleton } from './chunk-7F4MPMLJ.js';
|
|
4
|
+
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription } from './chunk-PVX4VQFJ.js';
|
|
5
|
+
import { Separator } from './chunk-RPQHL6C5.js';
|
|
6
|
+
import { Input } from './chunk-QFSEK4M6.js';
|
|
7
|
+
import { Button } from './chunk-OUFYQLVN.js';
|
|
8
|
+
import { SidebarPanelIcon } from './chunk-DIGOLJIR.js';
|
|
9
|
+
import { cn } from './chunk-76UQO56T.js';
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
import { Collapsible } from '@base-ui/react/collapsible';
|
|
12
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
13
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
14
|
+
import { cva } from 'class-variance-authority';
|
|
15
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
16
|
+
|
|
17
|
+
var SIDEBAR_WIDTH = "16rem";
|
|
18
|
+
var SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
19
|
+
var SIDEBAR_WIDTH_ICON = "3rem";
|
|
20
|
+
var SIDEBAR_DEFAULT_KEYBOARD_SHORTCUT = "b";
|
|
21
|
+
function cookiePersist(name = "sidebar-state", maxAge = 60 * 60 * 24 * 7) {
|
|
22
|
+
return (open) => {
|
|
23
|
+
document.cookie = `${name}=${open}; path=/; max-age=${maxAge}`;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function localStoragePersist(key = "sidebar-state") {
|
|
27
|
+
return (open) => {
|
|
28
|
+
try {
|
|
29
|
+
localStorage.setItem(key, String(open));
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var SidebarContext = React.createContext(null);
|
|
35
|
+
function useSidebar() {
|
|
36
|
+
const context = React.useContext(SidebarContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
39
|
+
}
|
|
40
|
+
return context;
|
|
41
|
+
}
|
|
42
|
+
function SidebarProvider({
|
|
43
|
+
defaultOpen = true,
|
|
44
|
+
open: openProp,
|
|
45
|
+
onOpenChange: setOpenProp,
|
|
46
|
+
persist,
|
|
47
|
+
keyboardShortcut = SIDEBAR_DEFAULT_KEYBOARD_SHORTCUT,
|
|
48
|
+
mobileBreakpoint,
|
|
49
|
+
className,
|
|
50
|
+
style,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
}) {
|
|
54
|
+
const isMobile = useIsMobile(mobileBreakpoint);
|
|
55
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
56
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
57
|
+
const open = openProp ?? _open;
|
|
58
|
+
const persistRef = React.useRef(persist);
|
|
59
|
+
persistRef.current = persist;
|
|
60
|
+
const setOpen = React.useCallback(
|
|
61
|
+
(value) => {
|
|
62
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
63
|
+
if (setOpenProp) {
|
|
64
|
+
setOpenProp(openState);
|
|
65
|
+
} else {
|
|
66
|
+
_setOpen(openState);
|
|
67
|
+
}
|
|
68
|
+
persistRef.current?.(openState);
|
|
69
|
+
},
|
|
70
|
+
[setOpenProp, open]
|
|
71
|
+
);
|
|
72
|
+
const toggleSidebar = React.useCallback(() => {
|
|
73
|
+
return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
|
|
74
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
if (keyboardShortcut === false) return;
|
|
77
|
+
const handleKeyDown = (event) => {
|
|
78
|
+
if (event.key === keyboardShortcut && (event.metaKey || event.ctrlKey)) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
toggleSidebar();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
84
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
85
|
+
}, [toggleSidebar, keyboardShortcut]);
|
|
86
|
+
const state = open ? "expanded" : "collapsed";
|
|
87
|
+
const contextValue = React.useMemo(
|
|
88
|
+
() => ({
|
|
89
|
+
state,
|
|
90
|
+
open,
|
|
91
|
+
setOpen,
|
|
92
|
+
isMobile,
|
|
93
|
+
openMobile,
|
|
94
|
+
setOpenMobile,
|
|
95
|
+
toggleSidebar
|
|
96
|
+
}),
|
|
97
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
98
|
+
);
|
|
99
|
+
return /* @__PURE__ */ jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
"data-slot": "sidebar-wrapper",
|
|
103
|
+
style: {
|
|
104
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
105
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
106
|
+
...style
|
|
107
|
+
},
|
|
108
|
+
className: cn(
|
|
109
|
+
"group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
|
|
110
|
+
className
|
|
111
|
+
),
|
|
112
|
+
...props,
|
|
113
|
+
children
|
|
114
|
+
}
|
|
115
|
+
) });
|
|
116
|
+
}
|
|
117
|
+
function Sidebar({
|
|
118
|
+
side = "left",
|
|
119
|
+
variant = "sidebar",
|
|
120
|
+
collapsible = "offcanvas",
|
|
121
|
+
className,
|
|
122
|
+
children,
|
|
123
|
+
...props
|
|
124
|
+
}) {
|
|
125
|
+
const { isMobile, state, open, setOpen, openMobile, setOpenMobile } = useSidebar();
|
|
126
|
+
if (collapsible === "none") {
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
"data-slot": "sidebar",
|
|
131
|
+
className: cn(
|
|
132
|
+
"bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
|
|
133
|
+
className
|
|
134
|
+
),
|
|
135
|
+
...props,
|
|
136
|
+
children
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (isMobile) {
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
Drawer,
|
|
143
|
+
{
|
|
144
|
+
open: openMobile,
|
|
145
|
+
onOpenChange: setOpenMobile,
|
|
146
|
+
swipeDirection: side,
|
|
147
|
+
children: /* @__PURE__ */ jsxs(
|
|
148
|
+
DrawerContent,
|
|
149
|
+
{
|
|
150
|
+
"data-slot": "sidebar",
|
|
151
|
+
"data-mobile": "true",
|
|
152
|
+
className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) max-w-none rounded-none border-0 p-0 sm:max-w-none",
|
|
153
|
+
style: {
|
|
154
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE
|
|
155
|
+
},
|
|
156
|
+
children: [
|
|
157
|
+
/* @__PURE__ */ jsxs(DrawerHeader, { className: "sr-only", children: [
|
|
158
|
+
/* @__PURE__ */ jsx(DrawerTitle, { children: "Sidebar" }),
|
|
159
|
+
/* @__PURE__ */ jsx(DrawerDescription, { children: "Displays the mobile sidebar." })
|
|
160
|
+
] }),
|
|
161
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-full w-full flex-col", children })
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return /* @__PURE__ */ jsxs(
|
|
169
|
+
Collapsible.Root,
|
|
170
|
+
{
|
|
171
|
+
open,
|
|
172
|
+
onOpenChange: setOpen,
|
|
173
|
+
className: "group peer text-sidebar-foreground hidden md:block",
|
|
174
|
+
"data-state": state,
|
|
175
|
+
"data-collapsible": state === "collapsed" ? collapsible : "",
|
|
176
|
+
"data-variant": variant,
|
|
177
|
+
"data-side": side,
|
|
178
|
+
"data-slot": "sidebar",
|
|
179
|
+
children: [
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
"data-slot": "sidebar-gap",
|
|
184
|
+
className: cn(
|
|
185
|
+
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
|
186
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
187
|
+
"group-data-[side=right]:rotate-180",
|
|
188
|
+
variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
193
|
+
"div",
|
|
194
|
+
{
|
|
195
|
+
"data-slot": "sidebar-container",
|
|
196
|
+
className: cn(
|
|
197
|
+
"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
|
|
198
|
+
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)]",
|
|
199
|
+
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",
|
|
200
|
+
className
|
|
201
|
+
),
|
|
202
|
+
...props,
|
|
203
|
+
children: /* @__PURE__ */ jsx(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
"data-slot": "sidebar-inner",
|
|
207
|
+
className: "bg-sidebar group-data-[variant=floating]:ring-sidebar-border group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 flex size-full flex-col",
|
|
208
|
+
children
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function SidebarTrigger({
|
|
218
|
+
className,
|
|
219
|
+
onClick,
|
|
220
|
+
...props
|
|
221
|
+
}) {
|
|
222
|
+
const { toggleSidebar } = useSidebar();
|
|
223
|
+
return /* @__PURE__ */ jsxs(
|
|
224
|
+
Button,
|
|
225
|
+
{
|
|
226
|
+
"data-slot": "sidebar-trigger",
|
|
227
|
+
variant: "ghost",
|
|
228
|
+
size: "icon-sm",
|
|
229
|
+
className: cn(className),
|
|
230
|
+
onClick: (event) => {
|
|
231
|
+
onClick?.(event);
|
|
232
|
+
toggleSidebar();
|
|
233
|
+
},
|
|
234
|
+
...props,
|
|
235
|
+
children: [
|
|
236
|
+
/* @__PURE__ */ jsx(SidebarPanelIcon, {}),
|
|
237
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
function SidebarRail({ className, ...props }) {
|
|
243
|
+
const { toggleSidebar } = useSidebar();
|
|
244
|
+
return /* @__PURE__ */ jsx(
|
|
245
|
+
"button",
|
|
246
|
+
{
|
|
247
|
+
"data-slot": "sidebar-rail",
|
|
248
|
+
"aria-label": "Toggle Sidebar",
|
|
249
|
+
tabIndex: -1,
|
|
250
|
+
onClick: toggleSidebar,
|
|
251
|
+
title: "Toggle Sidebar",
|
|
252
|
+
className: cn(
|
|
253
|
+
"hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
|
|
254
|
+
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
|
|
255
|
+
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
256
|
+
"hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
|
|
257
|
+
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
258
|
+
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
259
|
+
className
|
|
260
|
+
),
|
|
261
|
+
...props
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
function SidebarInset({ className, ...props }) {
|
|
266
|
+
return /* @__PURE__ */ jsx(
|
|
267
|
+
"main",
|
|
268
|
+
{
|
|
269
|
+
"data-slot": "sidebar-inset",
|
|
270
|
+
className: cn(
|
|
271
|
+
"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 relative flex min-w-0 w-full flex-1 flex-col",
|
|
272
|
+
className
|
|
273
|
+
),
|
|
274
|
+
...props
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
function SidebarInput({
|
|
279
|
+
className,
|
|
280
|
+
...props
|
|
281
|
+
}) {
|
|
282
|
+
return /* @__PURE__ */ jsx(
|
|
283
|
+
Input,
|
|
284
|
+
{
|
|
285
|
+
"data-slot": "sidebar-input",
|
|
286
|
+
className: cn("bg-background h-8 w-full shadow-none", className),
|
|
287
|
+
...props
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
function SidebarHeader({ className, ...props }) {
|
|
292
|
+
return /* @__PURE__ */ jsx(
|
|
293
|
+
"div",
|
|
294
|
+
{
|
|
295
|
+
"data-slot": "sidebar-header",
|
|
296
|
+
className: cn("gap-2 p-2 flex flex-col", className),
|
|
297
|
+
...props
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
function SidebarFooter({ className, ...props }) {
|
|
302
|
+
return /* @__PURE__ */ jsx(
|
|
303
|
+
"div",
|
|
304
|
+
{
|
|
305
|
+
"data-slot": "sidebar-footer",
|
|
306
|
+
className: cn("gap-2 p-2 flex flex-col", className),
|
|
307
|
+
...props
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
function SidebarSeparator({
|
|
312
|
+
className,
|
|
313
|
+
...props
|
|
314
|
+
}) {
|
|
315
|
+
return /* @__PURE__ */ jsx(
|
|
316
|
+
Separator,
|
|
317
|
+
{
|
|
318
|
+
"data-slot": "sidebar-separator",
|
|
319
|
+
className: cn("bg-sidebar-border mx-2 data-[orientation=horizontal]:w-auto", className),
|
|
320
|
+
...props
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
function SidebarContent({ className, ...props }) {
|
|
325
|
+
return /* @__PURE__ */ jsx(
|
|
326
|
+
"div",
|
|
327
|
+
{
|
|
328
|
+
"data-slot": "sidebar-content",
|
|
329
|
+
className: cn(
|
|
330
|
+
"gap-2 flex min-h-0 flex-1 flex-col overflow-auto scrollbar-none group-data-[collapsible=icon]:overflow-hidden",
|
|
331
|
+
className
|
|
332
|
+
),
|
|
333
|
+
...props
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
function SidebarGroup({ className, ...props }) {
|
|
338
|
+
return /* @__PURE__ */ jsx(
|
|
339
|
+
"div",
|
|
340
|
+
{
|
|
341
|
+
"data-slot": "sidebar-group",
|
|
342
|
+
className: cn(
|
|
343
|
+
"p-2 relative flex w-full min-w-0 flex-col",
|
|
344
|
+
className
|
|
345
|
+
),
|
|
346
|
+
...props
|
|
347
|
+
}
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
function SidebarGroupLabel({
|
|
351
|
+
className,
|
|
352
|
+
render,
|
|
353
|
+
...props
|
|
354
|
+
}) {
|
|
355
|
+
return useRender({
|
|
356
|
+
defaultTagName: "div",
|
|
357
|
+
props: mergeProps(
|
|
358
|
+
{
|
|
359
|
+
className: cn(
|
|
360
|
+
"text-sidebar-foreground/70 ring-sidebar-ring h-8 rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 flex shrink-0 items-center outline-hidden [&>svg]:shrink-0",
|
|
361
|
+
className
|
|
362
|
+
)
|
|
363
|
+
},
|
|
364
|
+
props
|
|
365
|
+
),
|
|
366
|
+
render,
|
|
367
|
+
state: {
|
|
368
|
+
slot: "sidebar-group-label"
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function SidebarGroupAction({
|
|
373
|
+
className,
|
|
374
|
+
render,
|
|
375
|
+
...props
|
|
376
|
+
}) {
|
|
377
|
+
return useRender({
|
|
378
|
+
defaultTagName: "button",
|
|
379
|
+
props: mergeProps(
|
|
380
|
+
{
|
|
381
|
+
className: cn(
|
|
382
|
+
"text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 w-5 rounded-md p-0 focus-visible:ring-2 [&>svg]:size-4 flex aspect-square items-center justify-center outline-hidden transition-transform [&>svg]:shrink-0 after:absolute after:-inset-2 md:after:hidden group-data-[collapsible=icon]:hidden",
|
|
383
|
+
className
|
|
384
|
+
)
|
|
385
|
+
},
|
|
386
|
+
props
|
|
387
|
+
),
|
|
388
|
+
render,
|
|
389
|
+
state: {
|
|
390
|
+
slot: "sidebar-group-action"
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
function SidebarGroupContent({
|
|
395
|
+
className,
|
|
396
|
+
...props
|
|
397
|
+
}) {
|
|
398
|
+
return /* @__PURE__ */ jsx(
|
|
399
|
+
"div",
|
|
400
|
+
{
|
|
401
|
+
"data-slot": "sidebar-group-content",
|
|
402
|
+
className: cn("text-sm w-full", className),
|
|
403
|
+
...props
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
function SidebarMenu({ className, ...props }) {
|
|
408
|
+
return /* @__PURE__ */ jsx(
|
|
409
|
+
"ul",
|
|
410
|
+
{
|
|
411
|
+
"data-slot": "sidebar-menu",
|
|
412
|
+
className: cn("gap-1 flex w-full min-w-0 flex-col", className),
|
|
413
|
+
...props
|
|
414
|
+
}
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
418
|
+
return /* @__PURE__ */ jsx(
|
|
419
|
+
"li",
|
|
420
|
+
{
|
|
421
|
+
"data-slot": "sidebar-menu-item",
|
|
422
|
+
className: cn("group/menu-item relative has-data-[slot=sidebar-menu-sub]:mb-[-0.25rem]", className),
|
|
423
|
+
...props
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
var sidebarMenuButtonVariants = cva(
|
|
428
|
+
"ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground gap-2 rounded-lg p-2 text-left text-sm transition-[width,height,padding] group-has-data-[slot=sidebar-menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 data-active:font-medium peer/menu-button flex w-full items-center overflow-hidden outline-hidden group/menu-button 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",
|
|
429
|
+
{
|
|
430
|
+
variants: {
|
|
431
|
+
variant: {
|
|
432
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
433
|
+
outline: "bg-background hover:bg-sidebar-accent hover:text-sidebar-accent-foreground ring-1 ring-sidebar-border hover:ring-sidebar-accent"
|
|
434
|
+
},
|
|
435
|
+
size: {
|
|
436
|
+
default: "h-9 text-sm",
|
|
437
|
+
sm: "h-8 text-xs",
|
|
438
|
+
lg: "h-12 text-sm"
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
defaultVariants: {
|
|
442
|
+
variant: "default",
|
|
443
|
+
size: "default"
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
function SidebarMenuButton({
|
|
448
|
+
render,
|
|
449
|
+
isActive = false,
|
|
450
|
+
variant = "default",
|
|
451
|
+
size = "default",
|
|
452
|
+
tooltip,
|
|
453
|
+
className,
|
|
454
|
+
...props
|
|
455
|
+
}) {
|
|
456
|
+
const { isMobile, state } = useSidebar();
|
|
457
|
+
if (process.env.NODE_ENV === "development" && tooltip && render) {
|
|
458
|
+
console.warn(
|
|
459
|
+
"[SidebarMenuButton] Both `render` and `tooltip` were provided. When `tooltip` is set, the button is wrapped in a TooltipTrigger and the `render` prop is ignored."
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
const comp = useRender({
|
|
463
|
+
defaultTagName: "button",
|
|
464
|
+
props: mergeProps(
|
|
465
|
+
{
|
|
466
|
+
className: cn(sidebarMenuButtonVariants({ variant, size }), className)
|
|
467
|
+
},
|
|
468
|
+
props
|
|
469
|
+
),
|
|
470
|
+
render: !tooltip ? render : TooltipTrigger,
|
|
471
|
+
state: {
|
|
472
|
+
slot: "sidebar-menu-button",
|
|
473
|
+
size,
|
|
474
|
+
active: isActive
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
if (!tooltip) {
|
|
478
|
+
return comp;
|
|
479
|
+
}
|
|
480
|
+
if (typeof tooltip === "string") {
|
|
481
|
+
tooltip = {
|
|
482
|
+
children: tooltip
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
486
|
+
comp,
|
|
487
|
+
/* @__PURE__ */ jsx(
|
|
488
|
+
TooltipContent,
|
|
489
|
+
{
|
|
490
|
+
side: "right",
|
|
491
|
+
align: "center",
|
|
492
|
+
hidden: state !== "collapsed" || isMobile,
|
|
493
|
+
...tooltip
|
|
494
|
+
}
|
|
495
|
+
)
|
|
496
|
+
] });
|
|
497
|
+
}
|
|
498
|
+
function SidebarMenuAction({
|
|
499
|
+
className,
|
|
500
|
+
render,
|
|
501
|
+
showOnHover = false,
|
|
502
|
+
...props
|
|
503
|
+
}) {
|
|
504
|
+
return useRender({
|
|
505
|
+
defaultTagName: "button",
|
|
506
|
+
props: mergeProps(
|
|
507
|
+
{
|
|
508
|
+
className: cn(
|
|
509
|
+
"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 aspect-square w-5 rounded-md p-0 peer-data-[size=default]/menu-button:top-2 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 focus-visible:ring-2 [&>svg]:size-4 flex items-center justify-center outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 md:after:hidden [&>svg]:shrink-0",
|
|
510
|
+
showOnHover && "peer-data-active/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-open:opacity-100 md:opacity-0",
|
|
511
|
+
className
|
|
512
|
+
)
|
|
513
|
+
},
|
|
514
|
+
props
|
|
515
|
+
),
|
|
516
|
+
render,
|
|
517
|
+
state: {
|
|
518
|
+
slot: "sidebar-menu-action"
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
function SidebarMenuBadge({
|
|
523
|
+
className,
|
|
524
|
+
...props
|
|
525
|
+
}) {
|
|
526
|
+
return /* @__PURE__ */ jsx(
|
|
527
|
+
"div",
|
|
528
|
+
{
|
|
529
|
+
"data-slot": "sidebar-menu-badge",
|
|
530
|
+
className: cn(
|
|
531
|
+
"text-sidebar-foreground peer-hover/menu-button:text-sidebar-accent-foreground peer-data-active/menu-button:text-sidebar-accent-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none 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 group-data-[collapsible=icon]:hidden",
|
|
532
|
+
className
|
|
533
|
+
),
|
|
534
|
+
...props
|
|
535
|
+
}
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
function SidebarMenuSkeleton({
|
|
539
|
+
className,
|
|
540
|
+
showIcon = false,
|
|
541
|
+
...props
|
|
542
|
+
}) {
|
|
543
|
+
const [width] = React.useState(() => {
|
|
544
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
545
|
+
});
|
|
546
|
+
return /* @__PURE__ */ jsxs(
|
|
547
|
+
"div",
|
|
548
|
+
{
|
|
549
|
+
"data-slot": "sidebar-menu-skeleton",
|
|
550
|
+
className: cn("h-8 gap-2 rounded-md px-2 flex items-center", className),
|
|
551
|
+
...props,
|
|
552
|
+
children: [
|
|
553
|
+
showIcon && /* @__PURE__ */ jsx(Skeleton, { className: "size-4 rounded-md" }),
|
|
554
|
+
/* @__PURE__ */ jsx(
|
|
555
|
+
Skeleton,
|
|
556
|
+
{
|
|
557
|
+
className: "h-4 max-w-(--skeleton-width) flex-1",
|
|
558
|
+
style: {
|
|
559
|
+
"--skeleton-width": width
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
)
|
|
563
|
+
]
|
|
564
|
+
}
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
function SidebarMenuSub({ className, ...props }) {
|
|
568
|
+
return /* @__PURE__ */ jsx(
|
|
569
|
+
"ul",
|
|
570
|
+
{
|
|
571
|
+
"data-slot": "sidebar-menu-sub",
|
|
572
|
+
className: cn("border-sidebar-border ml-3.5 mr-0 translate-x-px gap-0.5 border-l pl-2.5 pr-0 py-0.5 group-data-[collapsible=icon]:hidden flex min-w-0 flex-col", className),
|
|
573
|
+
...props
|
|
574
|
+
}
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
function SidebarMenuSubItem({
|
|
578
|
+
className,
|
|
579
|
+
...props
|
|
580
|
+
}) {
|
|
581
|
+
return /* @__PURE__ */ jsx(
|
|
582
|
+
"li",
|
|
583
|
+
{
|
|
584
|
+
"data-slot": "sidebar-menu-sub-item",
|
|
585
|
+
className: cn("group/menu-sub-item relative", className),
|
|
586
|
+
...props
|
|
587
|
+
}
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
function SidebarMenuSubButton({
|
|
591
|
+
render,
|
|
592
|
+
size = "md",
|
|
593
|
+
isActive = false,
|
|
594
|
+
className,
|
|
595
|
+
...props
|
|
596
|
+
}) {
|
|
597
|
+
return useRender({
|
|
598
|
+
defaultTagName: "a",
|
|
599
|
+
props: mergeProps(
|
|
600
|
+
{
|
|
601
|
+
className: cn(
|
|
602
|
+
"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 data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground h-7 gap-2 rounded-md px-2 focus-visible:ring-2 data-[size=md]:text-sm data-[size=sm]:text-xs [&>svg]:size-4 flex min-w-0 -translate-x-px items-center overflow-hidden outline-hidden group-data-[collapsible=icon]:hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:shrink-0",
|
|
603
|
+
className
|
|
604
|
+
)
|
|
605
|
+
},
|
|
606
|
+
props
|
|
607
|
+
),
|
|
608
|
+
render,
|
|
609
|
+
state: {
|
|
610
|
+
slot: "sidebar-menu-sub-button",
|
|
611
|
+
size,
|
|
612
|
+
active: isActive
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, cookiePersist, localStoragePersist, useSidebar };
|
|
618
|
+
//# sourceMappingURL=sidebar.js.map
|
|
619
|
+
//# sourceMappingURL=sidebar.js.map
|