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