@silicajs/ui 0.1.1 → 0.1.3
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/package.json +5 -5
- package/postcss.config.mjs +1 -1
- package/src/components/avatar.tsx +109 -0
- package/src/components/badge.tsx +9 -9
- package/src/components/breadcrumb.tsx +18 -21
- package/src/components/button.tsx +7 -7
- package/src/components/card.tsx +15 -15
- package/src/components/collapsible.tsx +6 -6
- package/src/components/command.tsx +47 -49
- package/src/components/dialog.tsx +24 -25
- package/src/components/dropdown-menu.tsx +47 -43
- package/src/components/input-group.tsx +25 -25
- package/src/components/input.tsx +6 -6
- package/src/components/scroll-area.tsx +8 -8
- package/src/components/separator.tsx +6 -6
- package/src/components/sheet.tsx +22 -23
- package/src/components/sidebar.tsx +124 -124
- package/src/components/skeleton.tsx +3 -3
- package/src/components/textarea.tsx +5 -5
- package/src/components/toc-list.tsx +5 -2
- package/src/components/tooltip.tsx +9 -9
- package/src/hooks/use-mobile.ts +13 -11
- package/src/lib/utils.ts +3 -3
- package/src/styles/globals.css +100 -2
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import { mergeProps } from "@base-ui/react/merge-props"
|
|
5
|
-
import { useRender } from "@base-ui/react/use-render"
|
|
6
|
-
import { cva, type VariantProps } from "class-variance-authority"
|
|
7
|
-
|
|
8
|
-
import { useIsMobile } from "@silicajs/ui/hooks/use-mobile"
|
|
9
|
-
import { cn } from "@silicajs/ui/lib/utils"
|
|
10
|
-
import { Button } from "@silicajs/ui/components/button"
|
|
11
|
-
import { Input } from "@silicajs/ui/components/input"
|
|
12
|
-
import { Separator } from "@silicajs/ui/components/separator"
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
7
|
+
|
|
8
|
+
import { useIsMobile } from "@silicajs/ui/hooks/use-mobile";
|
|
9
|
+
import { cn } from "@silicajs/ui/lib/utils";
|
|
10
|
+
import { Button } from "@silicajs/ui/components/button";
|
|
11
|
+
import { Input } from "@silicajs/ui/components/input";
|
|
12
|
+
import { Separator } from "@silicajs/ui/components/separator";
|
|
13
13
|
import {
|
|
14
14
|
Sheet,
|
|
15
15
|
SheetContent,
|
|
16
16
|
SheetDescription,
|
|
17
17
|
SheetHeader,
|
|
18
18
|
SheetTitle,
|
|
19
|
-
} from "@silicajs/ui/components/sheet"
|
|
20
|
-
import { Skeleton } from "@silicajs/ui/components/skeleton"
|
|
19
|
+
} from "@silicajs/ui/components/sheet";
|
|
20
|
+
import { Skeleton } from "@silicajs/ui/components/skeleton";
|
|
21
21
|
import {
|
|
22
22
|
Tooltip,
|
|
23
23
|
TooltipContent,
|
|
24
24
|
TooltipTrigger,
|
|
25
|
-
} from "@silicajs/ui/components/tooltip"
|
|
26
|
-
import { PanelLeftIcon } from "lucide-react"
|
|
25
|
+
} from "@silicajs/ui/components/tooltip";
|
|
26
|
+
import { PanelLeftIcon } from "lucide-react";
|
|
27
27
|
|
|
28
|
-
const SIDEBAR_COOKIE_NAME = "sidebar_state"
|
|
29
|
-
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
|
|
30
|
-
const SIDEBAR_WIDTH = "16rem"
|
|
31
|
-
const SIDEBAR_WIDTH_MOBILE = "18rem"
|
|
32
|
-
const SIDEBAR_WIDTH_ICON = "3rem"
|
|
33
|
-
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
|
|
28
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
29
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
30
|
+
const SIDEBAR_WIDTH = "16rem";
|
|
31
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
32
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
33
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
34
34
|
|
|
35
35
|
type SidebarContextProps = {
|
|
36
|
-
state: "expanded" | "collapsed"
|
|
37
|
-
open: boolean
|
|
38
|
-
setOpen: (open: boolean) => void
|
|
39
|
-
openMobile: boolean
|
|
40
|
-
setOpenMobile: (open: boolean) => void
|
|
41
|
-
isMobile: boolean
|
|
42
|
-
toggleSidebar: () => void
|
|
43
|
-
}
|
|
36
|
+
state: "expanded" | "collapsed";
|
|
37
|
+
open: boolean;
|
|
38
|
+
setOpen: (open: boolean) => void;
|
|
39
|
+
openMobile: boolean;
|
|
40
|
+
setOpenMobile: (open: boolean) => void;
|
|
41
|
+
isMobile: boolean;
|
|
42
|
+
toggleSidebar: () => void;
|
|
43
|
+
};
|
|
44
44
|
|
|
45
|
-
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
|
|
45
|
+
const SidebarContext = React.createContext<SidebarContextProps | null>(null);
|
|
46
46
|
|
|
47
47
|
function useSidebar() {
|
|
48
|
-
const context = React.useContext(SidebarContext)
|
|
48
|
+
const context = React.useContext(SidebarContext);
|
|
49
49
|
if (!context) {
|
|
50
|
-
throw new Error("useSidebar must be used within a SidebarProvider.")
|
|
50
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
return context
|
|
53
|
+
return context;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function SidebarProvider({
|
|
@@ -62,36 +62,36 @@ function SidebarProvider({
|
|
|
62
62
|
children,
|
|
63
63
|
...props
|
|
64
64
|
}: React.ComponentProps<"div"> & {
|
|
65
|
-
defaultOpen?: boolean
|
|
66
|
-
open?: boolean
|
|
67
|
-
onOpenChange?: (open: boolean) => void
|
|
65
|
+
defaultOpen?: boolean;
|
|
66
|
+
open?: boolean;
|
|
67
|
+
onOpenChange?: (open: boolean) => void;
|
|
68
68
|
}) {
|
|
69
|
-
const isMobile = useIsMobile()
|
|
70
|
-
const [openMobile, setOpenMobile] = React.useState(false)
|
|
69
|
+
const isMobile = useIsMobile();
|
|
70
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
71
71
|
|
|
72
72
|
// This is the internal state of the sidebar.
|
|
73
73
|
// We use openProp and setOpenProp for control from outside the component.
|
|
74
|
-
const [_open, _setOpen] = React.useState(defaultOpen)
|
|
75
|
-
const open = openProp ?? _open
|
|
74
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
75
|
+
const open = openProp ?? _open;
|
|
76
76
|
const setOpen = React.useCallback(
|
|
77
77
|
(value: boolean | ((value: boolean) => boolean)) => {
|
|
78
|
-
const openState = typeof value === "function" ? value(open) : value
|
|
78
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
79
79
|
if (setOpenProp) {
|
|
80
|
-
setOpenProp(openState)
|
|
80
|
+
setOpenProp(openState);
|
|
81
81
|
} else {
|
|
82
|
-
_setOpen(openState)
|
|
82
|
+
_setOpen(openState);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// This sets the cookie to keep the sidebar state.
|
|
86
|
-
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}
|
|
86
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
87
87
|
},
|
|
88
|
-
[setOpenProp, open]
|
|
89
|
-
)
|
|
88
|
+
[setOpenProp, open],
|
|
89
|
+
);
|
|
90
90
|
|
|
91
91
|
// Helper to toggle the sidebar.
|
|
92
92
|
const toggleSidebar = React.useCallback(() => {
|
|
93
|
-
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
|
|
94
|
-
}, [isMobile, setOpen, setOpenMobile])
|
|
93
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
94
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
95
95
|
|
|
96
96
|
// Adds a keyboard shortcut to toggle the sidebar.
|
|
97
97
|
React.useEffect(() => {
|
|
@@ -100,18 +100,18 @@ function SidebarProvider({
|
|
|
100
100
|
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
101
101
|
(event.metaKey || event.ctrlKey)
|
|
102
102
|
) {
|
|
103
|
-
event.preventDefault()
|
|
104
|
-
toggleSidebar()
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
toggleSidebar();
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
};
|
|
107
107
|
|
|
108
|
-
window.addEventListener("keydown", handleKeyDown)
|
|
109
|
-
return () => window.removeEventListener("keydown", handleKeyDown)
|
|
110
|
-
}, [toggleSidebar])
|
|
108
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
109
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
110
|
+
}, [toggleSidebar]);
|
|
111
111
|
|
|
112
112
|
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
113
113
|
// This makes it easier to style the sidebar with Tailwind classes.
|
|
114
|
-
const state = open ? "expanded" : "collapsed"
|
|
114
|
+
const state = open ? "expanded" : "collapsed";
|
|
115
115
|
|
|
116
116
|
const contextValue = React.useMemo<SidebarContextProps>(
|
|
117
117
|
() => ({
|
|
@@ -123,8 +123,8 @@ function SidebarProvider({
|
|
|
123
123
|
setOpenMobile,
|
|
124
124
|
toggleSidebar,
|
|
125
125
|
}),
|
|
126
|
-
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
127
|
-
)
|
|
126
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
|
|
127
|
+
);
|
|
128
128
|
|
|
129
129
|
return (
|
|
130
130
|
<SidebarContext.Provider value={contextValue}>
|
|
@@ -139,14 +139,14 @@ function SidebarProvider({
|
|
|
139
139
|
}
|
|
140
140
|
className={cn(
|
|
141
141
|
"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
|
|
142
|
-
className
|
|
142
|
+
className,
|
|
143
143
|
)}
|
|
144
144
|
{...props}
|
|
145
145
|
>
|
|
146
146
|
{children}
|
|
147
147
|
</div>
|
|
148
148
|
</SidebarContext.Provider>
|
|
149
|
-
)
|
|
149
|
+
);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
function Sidebar({
|
|
@@ -158,11 +158,11 @@ function Sidebar({
|
|
|
158
158
|
dir,
|
|
159
159
|
...props
|
|
160
160
|
}: React.ComponentProps<"div"> & {
|
|
161
|
-
side?: "left" | "right"
|
|
162
|
-
variant?: "sidebar" | "floating" | "inset"
|
|
163
|
-
collapsible?: "offcanvas" | "icon" | "none"
|
|
161
|
+
side?: "left" | "right";
|
|
162
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
163
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
164
164
|
}) {
|
|
165
|
-
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
|
|
165
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
166
166
|
|
|
167
167
|
if (collapsible === "none") {
|
|
168
168
|
return (
|
|
@@ -170,13 +170,13 @@ function Sidebar({
|
|
|
170
170
|
data-slot="sidebar"
|
|
171
171
|
className={cn(
|
|
172
172
|
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
|
173
|
-
className
|
|
173
|
+
className,
|
|
174
174
|
)}
|
|
175
175
|
{...props}
|
|
176
176
|
>
|
|
177
177
|
{children}
|
|
178
178
|
</div>
|
|
179
|
-
)
|
|
179
|
+
);
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
if (isMobile) {
|
|
@@ -202,7 +202,7 @@ function Sidebar({
|
|
|
202
202
|
<div className="flex h-full w-full flex-col">{children}</div>
|
|
203
203
|
</SheetContent>
|
|
204
204
|
</Sheet>
|
|
205
|
-
)
|
|
205
|
+
);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
return (
|
|
@@ -223,7 +223,7 @@ function Sidebar({
|
|
|
223
223
|
"group-data-[side=right]:rotate-180",
|
|
224
224
|
variant === "floating" || variant === "inset"
|
|
225
225
|
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
226
|
-
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
|
|
226
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
|
|
227
227
|
)}
|
|
228
228
|
/>
|
|
229
229
|
<div
|
|
@@ -235,7 +235,7 @@ function Sidebar({
|
|
|
235
235
|
variant === "floating" || variant === "inset"
|
|
236
236
|
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
237
237
|
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
238
|
-
className
|
|
238
|
+
className,
|
|
239
239
|
)}
|
|
240
240
|
{...props}
|
|
241
241
|
>
|
|
@@ -248,7 +248,7 @@ function Sidebar({
|
|
|
248
248
|
</div>
|
|
249
249
|
</div>
|
|
250
250
|
</div>
|
|
251
|
-
)
|
|
251
|
+
);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
function SidebarTrigger({
|
|
@@ -256,7 +256,7 @@ function SidebarTrigger({
|
|
|
256
256
|
onClick,
|
|
257
257
|
...props
|
|
258
258
|
}: React.ComponentProps<typeof Button>) {
|
|
259
|
-
const { toggleSidebar } = useSidebar()
|
|
259
|
+
const { toggleSidebar } = useSidebar();
|
|
260
260
|
|
|
261
261
|
return (
|
|
262
262
|
<Button
|
|
@@ -266,19 +266,19 @@ function SidebarTrigger({
|
|
|
266
266
|
size="icon-sm"
|
|
267
267
|
className={cn(className)}
|
|
268
268
|
onClick={(event) => {
|
|
269
|
-
onClick?.(event)
|
|
270
|
-
toggleSidebar()
|
|
269
|
+
onClick?.(event);
|
|
270
|
+
toggleSidebar();
|
|
271
271
|
}}
|
|
272
272
|
{...props}
|
|
273
273
|
>
|
|
274
274
|
<PanelLeftIcon />
|
|
275
275
|
<span className="sr-only">Toggle Sidebar</span>
|
|
276
276
|
</Button>
|
|
277
|
-
)
|
|
277
|
+
);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
|
|
281
|
-
const { toggleSidebar } = useSidebar()
|
|
281
|
+
const { toggleSidebar } = useSidebar();
|
|
282
282
|
|
|
283
283
|
return (
|
|
284
284
|
<button
|
|
@@ -295,11 +295,11 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
|
|
|
295
295
|
"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
|
|
296
296
|
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
297
297
|
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
298
|
-
className
|
|
298
|
+
className,
|
|
299
299
|
)}
|
|
300
300
|
{...props}
|
|
301
301
|
/>
|
|
302
|
-
)
|
|
302
|
+
);
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
|
|
@@ -308,11 +308,11 @@ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
|
|
|
308
308
|
data-slot="sidebar-inset"
|
|
309
309
|
className={cn(
|
|
310
310
|
"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",
|
|
311
|
-
className
|
|
311
|
+
className,
|
|
312
312
|
)}
|
|
313
313
|
{...props}
|
|
314
314
|
/>
|
|
315
|
-
)
|
|
315
|
+
);
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
function SidebarInput({
|
|
@@ -326,7 +326,7 @@ function SidebarInput({
|
|
|
326
326
|
className={cn("h-8 w-full bg-background shadow-none", className)}
|
|
327
327
|
{...props}
|
|
328
328
|
/>
|
|
329
|
-
)
|
|
329
|
+
);
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -337,7 +337,7 @@ function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
337
337
|
className={cn("flex flex-col gap-2 p-2", className)}
|
|
338
338
|
{...props}
|
|
339
339
|
/>
|
|
340
|
-
)
|
|
340
|
+
);
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -348,7 +348,7 @@ function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
348
348
|
className={cn("flex flex-col gap-2 p-2", className)}
|
|
349
349
|
{...props}
|
|
350
350
|
/>
|
|
351
|
-
)
|
|
351
|
+
);
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
function SidebarSeparator({
|
|
@@ -362,7 +362,7 @@ function SidebarSeparator({
|
|
|
362
362
|
className={cn("mx-2 w-auto bg-sidebar-border", className)}
|
|
363
363
|
{...props}
|
|
364
364
|
/>
|
|
365
|
-
)
|
|
365
|
+
);
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -372,11 +372,11 @@ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
372
372
|
data-sidebar="content"
|
|
373
373
|
className={cn(
|
|
374
374
|
"no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
375
|
-
className
|
|
375
|
+
className,
|
|
376
376
|
)}
|
|
377
377
|
{...props}
|
|
378
378
|
/>
|
|
379
|
-
)
|
|
379
|
+
);
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -387,7 +387,7 @@ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
387
387
|
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
|
388
388
|
{...props}
|
|
389
389
|
/>
|
|
390
|
-
)
|
|
390
|
+
);
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
function SidebarGroupLabel({
|
|
@@ -401,17 +401,17 @@ function SidebarGroupLabel({
|
|
|
401
401
|
{
|
|
402
402
|
className: cn(
|
|
403
403
|
"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 group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
404
|
-
className
|
|
404
|
+
className,
|
|
405
405
|
),
|
|
406
406
|
},
|
|
407
|
-
props
|
|
407
|
+
props,
|
|
408
408
|
),
|
|
409
409
|
render,
|
|
410
410
|
state: {
|
|
411
411
|
slot: "sidebar-group-label",
|
|
412
412
|
sidebar: "group-label",
|
|
413
413
|
},
|
|
414
|
-
})
|
|
414
|
+
});
|
|
415
415
|
}
|
|
416
416
|
|
|
417
417
|
function SidebarGroupAction({
|
|
@@ -425,17 +425,17 @@ function SidebarGroupAction({
|
|
|
425
425
|
{
|
|
426
426
|
className: cn(
|
|
427
427
|
"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",
|
|
428
|
-
className
|
|
428
|
+
className,
|
|
429
429
|
),
|
|
430
430
|
},
|
|
431
|
-
props
|
|
431
|
+
props,
|
|
432
432
|
),
|
|
433
433
|
render,
|
|
434
434
|
state: {
|
|
435
435
|
slot: "sidebar-group-action",
|
|
436
436
|
sidebar: "group-action",
|
|
437
437
|
},
|
|
438
|
-
})
|
|
438
|
+
});
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
function SidebarGroupContent({
|
|
@@ -449,7 +449,7 @@ function SidebarGroupContent({
|
|
|
449
449
|
className={cn("w-full text-sm", className)}
|
|
450
450
|
{...props}
|
|
451
451
|
/>
|
|
452
|
-
)
|
|
452
|
+
);
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
|
|
@@ -460,7 +460,7 @@ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
|
|
|
460
460
|
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
|
|
461
461
|
{...props}
|
|
462
462
|
/>
|
|
463
|
-
)
|
|
463
|
+
);
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
@@ -471,7 +471,7 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
|
471
471
|
className={cn("group/menu-item relative", className)}
|
|
472
472
|
{...props}
|
|
473
473
|
/>
|
|
474
|
-
)
|
|
474
|
+
);
|
|
475
475
|
}
|
|
476
476
|
|
|
477
477
|
const sidebarMenuButtonVariants = cva(
|
|
@@ -493,8 +493,8 @@ const sidebarMenuButtonVariants = cva(
|
|
|
493
493
|
variant: "default",
|
|
494
494
|
size: "default",
|
|
495
495
|
},
|
|
496
|
-
}
|
|
497
|
-
)
|
|
496
|
+
},
|
|
497
|
+
);
|
|
498
498
|
|
|
499
499
|
function SidebarMenuButton({
|
|
500
500
|
render,
|
|
@@ -506,17 +506,17 @@ function SidebarMenuButton({
|
|
|
506
506
|
...props
|
|
507
507
|
}: useRender.ComponentProps<"button"> &
|
|
508
508
|
React.ComponentProps<"button"> & {
|
|
509
|
-
isActive?: boolean
|
|
510
|
-
tooltip?: string | React.ComponentProps<typeof TooltipContent
|
|
509
|
+
isActive?: boolean;
|
|
510
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
511
511
|
} & VariantProps<typeof sidebarMenuButtonVariants>) {
|
|
512
|
-
const { isMobile, state } = useSidebar()
|
|
512
|
+
const { isMobile, state } = useSidebar();
|
|
513
513
|
const comp = useRender({
|
|
514
514
|
defaultTagName: "button",
|
|
515
515
|
props: mergeProps<"button">(
|
|
516
516
|
{
|
|
517
517
|
className: cn(sidebarMenuButtonVariants({ variant, size }), className),
|
|
518
518
|
},
|
|
519
|
-
props
|
|
519
|
+
props,
|
|
520
520
|
),
|
|
521
521
|
render: !tooltip ? render : <TooltipTrigger render={render} />,
|
|
522
522
|
state: {
|
|
@@ -525,16 +525,16 @@ function SidebarMenuButton({
|
|
|
525
525
|
size,
|
|
526
526
|
active: isActive,
|
|
527
527
|
},
|
|
528
|
-
})
|
|
528
|
+
});
|
|
529
529
|
|
|
530
530
|
if (!tooltip) {
|
|
531
|
-
return comp
|
|
531
|
+
return comp;
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
if (typeof tooltip === "string") {
|
|
535
535
|
tooltip = {
|
|
536
536
|
children: tooltip,
|
|
537
|
-
}
|
|
537
|
+
};
|
|
538
538
|
}
|
|
539
539
|
|
|
540
540
|
return (
|
|
@@ -547,7 +547,7 @@ function SidebarMenuButton({
|
|
|
547
547
|
{...tooltip}
|
|
548
548
|
/>
|
|
549
549
|
</Tooltip>
|
|
550
|
-
)
|
|
550
|
+
);
|
|
551
551
|
}
|
|
552
552
|
|
|
553
553
|
function SidebarMenuAction({
|
|
@@ -557,7 +557,7 @@ function SidebarMenuAction({
|
|
|
557
557
|
...props
|
|
558
558
|
}: useRender.ComponentProps<"button"> &
|
|
559
559
|
React.ComponentProps<"button"> & {
|
|
560
|
-
showOnHover?: boolean
|
|
560
|
+
showOnHover?: boolean;
|
|
561
561
|
}) {
|
|
562
562
|
return useRender({
|
|
563
563
|
defaultTagName: "button",
|
|
@@ -567,17 +567,17 @@ function SidebarMenuAction({
|
|
|
567
567
|
"absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
|
|
568
568
|
showOnHover &&
|
|
569
569
|
"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",
|
|
570
|
-
className
|
|
570
|
+
className,
|
|
571
571
|
),
|
|
572
572
|
},
|
|
573
|
-
props
|
|
573
|
+
props,
|
|
574
574
|
),
|
|
575
575
|
render,
|
|
576
576
|
state: {
|
|
577
577
|
slot: "sidebar-menu-action",
|
|
578
578
|
sidebar: "menu-action",
|
|
579
579
|
},
|
|
580
|
-
})
|
|
580
|
+
});
|
|
581
581
|
}
|
|
582
582
|
|
|
583
583
|
function SidebarMenuBadge({
|
|
@@ -590,11 +590,11 @@ function SidebarMenuBadge({
|
|
|
590
590
|
data-sidebar="menu-badge"
|
|
591
591
|
className={cn(
|
|
592
592
|
"pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[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",
|
|
593
|
-
className
|
|
593
|
+
className,
|
|
594
594
|
)}
|
|
595
595
|
{...props}
|
|
596
596
|
/>
|
|
597
|
-
)
|
|
597
|
+
);
|
|
598
598
|
}
|
|
599
599
|
|
|
600
600
|
function SidebarMenuSkeleton({
|
|
@@ -602,12 +602,12 @@ function SidebarMenuSkeleton({
|
|
|
602
602
|
showIcon = false,
|
|
603
603
|
...props
|
|
604
604
|
}: React.ComponentProps<"div"> & {
|
|
605
|
-
showIcon?: boolean
|
|
605
|
+
showIcon?: boolean;
|
|
606
606
|
}) {
|
|
607
607
|
// Random width between 50 to 90%.
|
|
608
608
|
const [width] = React.useState(() => {
|
|
609
|
-
return `${Math.floor(Math.random() * 40) + 50}
|
|
610
|
-
})
|
|
609
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
610
|
+
});
|
|
611
611
|
|
|
612
612
|
return (
|
|
613
613
|
<div
|
|
@@ -632,7 +632,7 @@ function SidebarMenuSkeleton({
|
|
|
632
632
|
}
|
|
633
633
|
/>
|
|
634
634
|
</div>
|
|
635
|
-
)
|
|
635
|
+
);
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
|
|
@@ -642,11 +642,11 @@ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
|
|
|
642
642
|
data-sidebar="menu-sub"
|
|
643
643
|
className={cn(
|
|
644
644
|
"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",
|
|
645
|
-
className
|
|
645
|
+
className,
|
|
646
646
|
)}
|
|
647
647
|
{...props}
|
|
648
648
|
/>
|
|
649
|
-
)
|
|
649
|
+
);
|
|
650
650
|
}
|
|
651
651
|
|
|
652
652
|
function SidebarMenuSubItem({
|
|
@@ -660,7 +660,7 @@ function SidebarMenuSubItem({
|
|
|
660
660
|
className={cn("group/menu-sub-item relative", className)}
|
|
661
661
|
{...props}
|
|
662
662
|
/>
|
|
663
|
-
)
|
|
663
|
+
);
|
|
664
664
|
}
|
|
665
665
|
|
|
666
666
|
function SidebarMenuSubButton({
|
|
@@ -671,8 +671,8 @@ function SidebarMenuSubButton({
|
|
|
671
671
|
...props
|
|
672
672
|
}: useRender.ComponentProps<"a"> &
|
|
673
673
|
React.ComponentProps<"a"> & {
|
|
674
|
-
size?: "sm" | "md"
|
|
675
|
-
isActive?: boolean
|
|
674
|
+
size?: "sm" | "md";
|
|
675
|
+
isActive?: boolean;
|
|
676
676
|
}) {
|
|
677
677
|
return useRender({
|
|
678
678
|
defaultTagName: "a",
|
|
@@ -680,10 +680,10 @@ function SidebarMenuSubButton({
|
|
|
680
680
|
{
|
|
681
681
|
className: cn(
|
|
682
682
|
"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-sm 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",
|
|
683
|
-
className
|
|
683
|
+
className,
|
|
684
684
|
),
|
|
685
685
|
},
|
|
686
|
-
props
|
|
686
|
+
props,
|
|
687
687
|
),
|
|
688
688
|
render,
|
|
689
689
|
state: {
|
|
@@ -692,7 +692,7 @@ function SidebarMenuSubButton({
|
|
|
692
692
|
size,
|
|
693
693
|
active: isActive,
|
|
694
694
|
},
|
|
695
|
-
})
|
|
695
|
+
});
|
|
696
696
|
}
|
|
697
697
|
|
|
698
698
|
export {
|
|
@@ -720,4 +720,4 @@ export {
|
|
|
720
720
|
SidebarSeparator,
|
|
721
721
|
SidebarTrigger,
|
|
722
722
|
useSidebar,
|
|
723
|
-
}
|
|
723
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn } from "@silicajs/ui/lib/utils"
|
|
1
|
+
import { cn } from "@silicajs/ui/lib/utils";
|
|
2
2
|
|
|
3
3
|
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
4
4
|
return (
|
|
@@ -7,7 +7,7 @@ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
7
7
|
className={cn("animate-pulse rounded-md bg-muted", className)}
|
|
8
8
|
{...props}
|
|
9
9
|
/>
|
|
10
|
-
)
|
|
10
|
+
);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export { Skeleton }
|
|
13
|
+
export { Skeleton };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as React from "react"
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import { cn } from "@silicajs/ui/lib/utils"
|
|
3
|
+
import { cn } from "@silicajs/ui/lib/utils";
|
|
4
4
|
|
|
5
5
|
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
6
6
|
return (
|
|
@@ -8,11 +8,11 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|
|
8
8
|
data-slot="textarea"
|
|
9
9
|
className={cn(
|
|
10
10
|
"flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
11
|
-
className
|
|
11
|
+
className,
|
|
12
12
|
)}
|
|
13
13
|
{...props}
|
|
14
14
|
/>
|
|
15
|
-
)
|
|
15
|
+
);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export { Textarea }
|
|
18
|
+
export { Textarea };
|