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