@silicajs/ui 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/components.json +23 -0
- package/package.json +51 -0
- package/postcss.config.mjs +6 -0
- package/src/components/badge.tsx +52 -0
- package/src/components/breadcrumb.tsx +125 -0
- package/src/components/button.tsx +58 -0
- package/src/components/card.tsx +103 -0
- package/src/components/collapsible.tsx +21 -0
- package/src/components/command.tsx +196 -0
- package/src/components/dialog.tsx +157 -0
- package/src/components/dropdown-menu.tsx +268 -0
- package/src/components/input-group.tsx +158 -0
- package/src/components/input.tsx +20 -0
- package/src/components/scroll-area.tsx +55 -0
- package/src/components/separator.tsx +25 -0
- package/src/components/sheet.tsx +135 -0
- package/src/components/sidebar.tsx +723 -0
- package/src/components/skeleton.tsx +13 -0
- package/src/components/tag-badge.tsx +33 -0
- package/src/components/textarea.tsx +18 -0
- package/src/components/toc-list.tsx +45 -0
- package/src/components/tooltip.tsx +66 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/globals.css +168 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@silicajs/ui/lib/utils"
|
|
7
|
+
import { Button } from "@silicajs/ui/components/button"
|
|
8
|
+
import { XIcon } from "lucide-react"
|
|
9
|
+
|
|
10
|
+
function Dialog({ ...props }: DialogPrimitive.Root.Props) {
|
|
11
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {
|
|
15
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function DialogPortal({ ...props }: DialogPrimitive.Portal.Props) {
|
|
19
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function DialogClose({ ...props }: DialogPrimitive.Close.Props) {
|
|
23
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function DialogOverlay({
|
|
27
|
+
className,
|
|
28
|
+
...props
|
|
29
|
+
}: DialogPrimitive.Backdrop.Props) {
|
|
30
|
+
return (
|
|
31
|
+
<DialogPrimitive.Backdrop
|
|
32
|
+
data-slot="dialog-overlay"
|
|
33
|
+
className={cn(
|
|
34
|
+
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
35
|
+
className
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function DialogContent({
|
|
43
|
+
className,
|
|
44
|
+
children,
|
|
45
|
+
showCloseButton = true,
|
|
46
|
+
...props
|
|
47
|
+
}: DialogPrimitive.Popup.Props & {
|
|
48
|
+
showCloseButton?: boolean
|
|
49
|
+
}) {
|
|
50
|
+
return (
|
|
51
|
+
<DialogPortal>
|
|
52
|
+
<DialogOverlay />
|
|
53
|
+
<DialogPrimitive.Popup
|
|
54
|
+
data-slot="dialog-content"
|
|
55
|
+
className={cn(
|
|
56
|
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
57
|
+
className
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
{showCloseButton && (
|
|
63
|
+
<DialogPrimitive.Close
|
|
64
|
+
data-slot="dialog-close"
|
|
65
|
+
render={
|
|
66
|
+
<Button
|
|
67
|
+
variant="ghost"
|
|
68
|
+
className="absolute top-4 right-4"
|
|
69
|
+
size="icon-sm"
|
|
70
|
+
/>
|
|
71
|
+
}
|
|
72
|
+
>
|
|
73
|
+
<XIcon
|
|
74
|
+
/>
|
|
75
|
+
<span className="sr-only">Close</span>
|
|
76
|
+
</DialogPrimitive.Close>
|
|
77
|
+
)}
|
|
78
|
+
</DialogPrimitive.Popup>
|
|
79
|
+
</DialogPortal>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
data-slot="dialog-header"
|
|
87
|
+
className={cn("flex flex-col gap-2", className)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function DialogFooter({
|
|
94
|
+
className,
|
|
95
|
+
showCloseButton = false,
|
|
96
|
+
children,
|
|
97
|
+
...props
|
|
98
|
+
}: React.ComponentProps<"div"> & {
|
|
99
|
+
showCloseButton?: boolean
|
|
100
|
+
}) {
|
|
101
|
+
return (
|
|
102
|
+
<div
|
|
103
|
+
data-slot="dialog-footer"
|
|
104
|
+
className={cn(
|
|
105
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
106
|
+
className
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
>
|
|
110
|
+
{children}
|
|
111
|
+
{showCloseButton && (
|
|
112
|
+
<DialogPrimitive.Close render={<Button variant="outline" />}>
|
|
113
|
+
Close
|
|
114
|
+
</DialogPrimitive.Close>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {
|
|
121
|
+
return (
|
|
122
|
+
<DialogPrimitive.Title
|
|
123
|
+
data-slot="dialog-title"
|
|
124
|
+
className={cn("font-heading leading-none font-medium", className)}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function DialogDescription({
|
|
131
|
+
className,
|
|
132
|
+
...props
|
|
133
|
+
}: DialogPrimitive.Description.Props) {
|
|
134
|
+
return (
|
|
135
|
+
<DialogPrimitive.Description
|
|
136
|
+
data-slot="dialog-description"
|
|
137
|
+
className={cn(
|
|
138
|
+
"text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
139
|
+
className
|
|
140
|
+
)}
|
|
141
|
+
{...props}
|
|
142
|
+
/>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
Dialog,
|
|
148
|
+
DialogClose,
|
|
149
|
+
DialogContent,
|
|
150
|
+
DialogDescription,
|
|
151
|
+
DialogFooter,
|
|
152
|
+
DialogHeader,
|
|
153
|
+
DialogOverlay,
|
|
154
|
+
DialogPortal,
|
|
155
|
+
DialogTitle,
|
|
156
|
+
DialogTrigger,
|
|
157
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Menu as MenuPrimitive } from "@base-ui/react/menu"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@silicajs/ui/lib/utils"
|
|
7
|
+
import { ChevronRightIcon, CheckIcon } from "lucide-react"
|
|
8
|
+
|
|
9
|
+
function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {
|
|
10
|
+
return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {
|
|
14
|
+
return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {
|
|
18
|
+
return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DropdownMenuContent({
|
|
22
|
+
align = "start",
|
|
23
|
+
alignOffset = 0,
|
|
24
|
+
side = "bottom",
|
|
25
|
+
sideOffset = 4,
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}: MenuPrimitive.Popup.Props &
|
|
29
|
+
Pick<
|
|
30
|
+
MenuPrimitive.Positioner.Props,
|
|
31
|
+
"align" | "alignOffset" | "side" | "sideOffset"
|
|
32
|
+
>) {
|
|
33
|
+
return (
|
|
34
|
+
<MenuPrimitive.Portal>
|
|
35
|
+
<MenuPrimitive.Positioner
|
|
36
|
+
className="isolate z-50 outline-none"
|
|
37
|
+
align={align}
|
|
38
|
+
alignOffset={alignOffset}
|
|
39
|
+
side={side}
|
|
40
|
+
sideOffset={sideOffset}
|
|
41
|
+
>
|
|
42
|
+
<MenuPrimitive.Popup
|
|
43
|
+
data-slot="dropdown-menu-content"
|
|
44
|
+
className={cn("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
</MenuPrimitive.Positioner>
|
|
48
|
+
</MenuPrimitive.Portal>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {
|
|
53
|
+
return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function DropdownMenuLabel({
|
|
57
|
+
className,
|
|
58
|
+
inset,
|
|
59
|
+
...props
|
|
60
|
+
}: MenuPrimitive.GroupLabel.Props & {
|
|
61
|
+
inset?: boolean
|
|
62
|
+
}) {
|
|
63
|
+
return (
|
|
64
|
+
<MenuPrimitive.GroupLabel
|
|
65
|
+
data-slot="dropdown-menu-label"
|
|
66
|
+
data-inset={inset}
|
|
67
|
+
className={cn(
|
|
68
|
+
"px-2 py-1.5 text-xs font-medium text-muted-foreground data-inset:pl-8",
|
|
69
|
+
className
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function DropdownMenuItem({
|
|
77
|
+
className,
|
|
78
|
+
inset,
|
|
79
|
+
variant = "default",
|
|
80
|
+
...props
|
|
81
|
+
}: MenuPrimitive.Item.Props & {
|
|
82
|
+
inset?: boolean
|
|
83
|
+
variant?: "default" | "destructive"
|
|
84
|
+
}) {
|
|
85
|
+
return (
|
|
86
|
+
<MenuPrimitive.Item
|
|
87
|
+
data-slot="dropdown-menu-item"
|
|
88
|
+
data-inset={inset}
|
|
89
|
+
data-variant={variant}
|
|
90
|
+
className={cn(
|
|
91
|
+
"group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
|
92
|
+
className
|
|
93
|
+
)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {
|
|
100
|
+
return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function DropdownMenuSubTrigger({
|
|
104
|
+
className,
|
|
105
|
+
inset,
|
|
106
|
+
children,
|
|
107
|
+
...props
|
|
108
|
+
}: MenuPrimitive.SubmenuTrigger.Props & {
|
|
109
|
+
inset?: boolean
|
|
110
|
+
}) {
|
|
111
|
+
return (
|
|
112
|
+
<MenuPrimitive.SubmenuTrigger
|
|
113
|
+
data-slot="dropdown-menu-sub-trigger"
|
|
114
|
+
data-inset={inset}
|
|
115
|
+
className={cn(
|
|
116
|
+
"flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
117
|
+
className
|
|
118
|
+
)}
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
<ChevronRightIcon className="ml-auto" />
|
|
123
|
+
</MenuPrimitive.SubmenuTrigger>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function DropdownMenuSubContent({
|
|
128
|
+
align = "start",
|
|
129
|
+
alignOffset = -3,
|
|
130
|
+
side = "right",
|
|
131
|
+
sideOffset = 0,
|
|
132
|
+
className,
|
|
133
|
+
...props
|
|
134
|
+
}: React.ComponentProps<typeof DropdownMenuContent>) {
|
|
135
|
+
return (
|
|
136
|
+
<DropdownMenuContent
|
|
137
|
+
data-slot="dropdown-menu-sub-content"
|
|
138
|
+
className={cn("w-auto min-w-[96px] rounded-md bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
|
139
|
+
align={align}
|
|
140
|
+
alignOffset={alignOffset}
|
|
141
|
+
side={side}
|
|
142
|
+
sideOffset={sideOffset}
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function DropdownMenuCheckboxItem({
|
|
149
|
+
className,
|
|
150
|
+
children,
|
|
151
|
+
checked,
|
|
152
|
+
inset,
|
|
153
|
+
...props
|
|
154
|
+
}: MenuPrimitive.CheckboxItem.Props & {
|
|
155
|
+
inset?: boolean
|
|
156
|
+
}) {
|
|
157
|
+
return (
|
|
158
|
+
<MenuPrimitive.CheckboxItem
|
|
159
|
+
data-slot="dropdown-menu-checkbox-item"
|
|
160
|
+
data-inset={inset}
|
|
161
|
+
className={cn(
|
|
162
|
+
"relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
163
|
+
className
|
|
164
|
+
)}
|
|
165
|
+
checked={checked}
|
|
166
|
+
{...props}
|
|
167
|
+
>
|
|
168
|
+
<span
|
|
169
|
+
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
170
|
+
data-slot="dropdown-menu-checkbox-item-indicator"
|
|
171
|
+
>
|
|
172
|
+
<MenuPrimitive.CheckboxItemIndicator>
|
|
173
|
+
<CheckIcon
|
|
174
|
+
/>
|
|
175
|
+
</MenuPrimitive.CheckboxItemIndicator>
|
|
176
|
+
</span>
|
|
177
|
+
{children}
|
|
178
|
+
</MenuPrimitive.CheckboxItem>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {
|
|
183
|
+
return (
|
|
184
|
+
<MenuPrimitive.RadioGroup
|
|
185
|
+
data-slot="dropdown-menu-radio-group"
|
|
186
|
+
{...props}
|
|
187
|
+
/>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function DropdownMenuRadioItem({
|
|
192
|
+
className,
|
|
193
|
+
children,
|
|
194
|
+
inset,
|
|
195
|
+
...props
|
|
196
|
+
}: MenuPrimitive.RadioItem.Props & {
|
|
197
|
+
inset?: boolean
|
|
198
|
+
}) {
|
|
199
|
+
return (
|
|
200
|
+
<MenuPrimitive.RadioItem
|
|
201
|
+
data-slot="dropdown-menu-radio-item"
|
|
202
|
+
data-inset={inset}
|
|
203
|
+
className={cn(
|
|
204
|
+
"relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
205
|
+
className
|
|
206
|
+
)}
|
|
207
|
+
{...props}
|
|
208
|
+
>
|
|
209
|
+
<span
|
|
210
|
+
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
211
|
+
data-slot="dropdown-menu-radio-item-indicator"
|
|
212
|
+
>
|
|
213
|
+
<MenuPrimitive.RadioItemIndicator>
|
|
214
|
+
<CheckIcon
|
|
215
|
+
/>
|
|
216
|
+
</MenuPrimitive.RadioItemIndicator>
|
|
217
|
+
</span>
|
|
218
|
+
{children}
|
|
219
|
+
</MenuPrimitive.RadioItem>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function DropdownMenuSeparator({
|
|
224
|
+
className,
|
|
225
|
+
...props
|
|
226
|
+
}: MenuPrimitive.Separator.Props) {
|
|
227
|
+
return (
|
|
228
|
+
<MenuPrimitive.Separator
|
|
229
|
+
data-slot="dropdown-menu-separator"
|
|
230
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
231
|
+
{...props}
|
|
232
|
+
/>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function DropdownMenuShortcut({
|
|
237
|
+
className,
|
|
238
|
+
...props
|
|
239
|
+
}: React.ComponentProps<"span">) {
|
|
240
|
+
return (
|
|
241
|
+
<span
|
|
242
|
+
data-slot="dropdown-menu-shortcut"
|
|
243
|
+
className={cn(
|
|
244
|
+
"ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
|
|
245
|
+
className
|
|
246
|
+
)}
|
|
247
|
+
{...props}
|
|
248
|
+
/>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export {
|
|
253
|
+
DropdownMenu,
|
|
254
|
+
DropdownMenuPortal,
|
|
255
|
+
DropdownMenuTrigger,
|
|
256
|
+
DropdownMenuContent,
|
|
257
|
+
DropdownMenuGroup,
|
|
258
|
+
DropdownMenuLabel,
|
|
259
|
+
DropdownMenuItem,
|
|
260
|
+
DropdownMenuCheckboxItem,
|
|
261
|
+
DropdownMenuRadioGroup,
|
|
262
|
+
DropdownMenuRadioItem,
|
|
263
|
+
DropdownMenuSeparator,
|
|
264
|
+
DropdownMenuShortcut,
|
|
265
|
+
DropdownMenuSub,
|
|
266
|
+
DropdownMenuSubTrigger,
|
|
267
|
+
DropdownMenuSubContent,
|
|
268
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@silicajs/ui/lib/utils"
|
|
7
|
+
import { Button } from "@silicajs/ui/components/button"
|
|
8
|
+
import { Input } from "@silicajs/ui/components/input"
|
|
9
|
+
import { Textarea } from "@silicajs/ui/components/textarea"
|
|
10
|
+
|
|
11
|
+
function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
data-slot="input-group"
|
|
15
|
+
role="group"
|
|
16
|
+
className={cn(
|
|
17
|
+
"group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const inputGroupAddonVariants = cva(
|
|
26
|
+
"flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
|
|
27
|
+
{
|
|
28
|
+
variants: {
|
|
29
|
+
align: {
|
|
30
|
+
"inline-start":
|
|
31
|
+
"order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]",
|
|
32
|
+
"inline-end":
|
|
33
|
+
"order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]",
|
|
34
|
+
"block-start":
|
|
35
|
+
"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
|
|
36
|
+
"block-end":
|
|
37
|
+
"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
align: "inline-start",
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
function InputGroupAddon({
|
|
47
|
+
className,
|
|
48
|
+
align = "inline-start",
|
|
49
|
+
...props
|
|
50
|
+
}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
role="group"
|
|
54
|
+
data-slot="input-group-addon"
|
|
55
|
+
data-align={align}
|
|
56
|
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
57
|
+
onClick={(e) => {
|
|
58
|
+
if ((e.target as HTMLElement).closest("button")) {
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
e.currentTarget.parentElement?.querySelector("input")?.focus()
|
|
62
|
+
}}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const inputGroupButtonVariants = cva(
|
|
69
|
+
"flex items-center gap-2 text-sm shadow-none",
|
|
70
|
+
{
|
|
71
|
+
variants: {
|
|
72
|
+
size: {
|
|
73
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
|
74
|
+
sm: "",
|
|
75
|
+
"icon-xs":
|
|
76
|
+
"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
77
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
defaultVariants: {
|
|
81
|
+
size: "xs",
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
function InputGroupButton({
|
|
87
|
+
className,
|
|
88
|
+
type = "button",
|
|
89
|
+
variant = "ghost",
|
|
90
|
+
size = "xs",
|
|
91
|
+
...props
|
|
92
|
+
}: Omit<React.ComponentProps<typeof Button>, "size" | "type"> &
|
|
93
|
+
VariantProps<typeof inputGroupButtonVariants> & {
|
|
94
|
+
type?: "button" | "submit" | "reset"
|
|
95
|
+
}) {
|
|
96
|
+
return (
|
|
97
|
+
<Button
|
|
98
|
+
type={type}
|
|
99
|
+
data-size={size}
|
|
100
|
+
variant={variant}
|
|
101
|
+
className={cn(inputGroupButtonVariants({ size }), className)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
|
|
108
|
+
return (
|
|
109
|
+
<span
|
|
110
|
+
className={cn(
|
|
111
|
+
"flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
|
112
|
+
className
|
|
113
|
+
)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function InputGroupInput({
|
|
120
|
+
className,
|
|
121
|
+
...props
|
|
122
|
+
}: React.ComponentProps<"input">) {
|
|
123
|
+
return (
|
|
124
|
+
<Input
|
|
125
|
+
data-slot="input-group-control"
|
|
126
|
+
className={cn(
|
|
127
|
+
"flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",
|
|
128
|
+
className
|
|
129
|
+
)}
|
|
130
|
+
{...props}
|
|
131
|
+
/>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function InputGroupTextarea({
|
|
136
|
+
className,
|
|
137
|
+
...props
|
|
138
|
+
}: React.ComponentProps<"textarea">) {
|
|
139
|
+
return (
|
|
140
|
+
<Textarea
|
|
141
|
+
data-slot="input-group-control"
|
|
142
|
+
className={cn(
|
|
143
|
+
"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",
|
|
144
|
+
className
|
|
145
|
+
)}
|
|
146
|
+
{...props}
|
|
147
|
+
/>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
InputGroup,
|
|
153
|
+
InputGroupAddon,
|
|
154
|
+
InputGroupButton,
|
|
155
|
+
InputGroupText,
|
|
156
|
+
InputGroupInput,
|
|
157
|
+
InputGroupTextarea,
|
|
158
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Input as InputPrimitive } from "@base-ui/react/input"
|
|
3
|
+
|
|
4
|
+
import { cn } from "@silicajs/ui/lib/utils"
|
|
5
|
+
|
|
6
|
+
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
7
|
+
return (
|
|
8
|
+
<InputPrimitive
|
|
9
|
+
type={type}
|
|
10
|
+
data-slot="input"
|
|
11
|
+
className={cn(
|
|
12
|
+
"h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none 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",
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { Input }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
|
|
5
|
+
|
|
6
|
+
import { cn } from "@silicajs/ui/lib/utils"
|
|
7
|
+
|
|
8
|
+
function ScrollArea({
|
|
9
|
+
className,
|
|
10
|
+
children,
|
|
11
|
+
...props
|
|
12
|
+
}: ScrollAreaPrimitive.Root.Props) {
|
|
13
|
+
return (
|
|
14
|
+
<ScrollAreaPrimitive.Root
|
|
15
|
+
data-slot="scroll-area"
|
|
16
|
+
className={cn("relative", className)}
|
|
17
|
+
{...props}
|
|
18
|
+
>
|
|
19
|
+
<ScrollAreaPrimitive.Viewport
|
|
20
|
+
data-slot="scroll-area-viewport"
|
|
21
|
+
className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1"
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</ScrollAreaPrimitive.Viewport>
|
|
25
|
+
<ScrollBar />
|
|
26
|
+
<ScrollAreaPrimitive.Corner />
|
|
27
|
+
</ScrollAreaPrimitive.Root>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ScrollBar({
|
|
32
|
+
className,
|
|
33
|
+
orientation = "vertical",
|
|
34
|
+
...props
|
|
35
|
+
}: ScrollAreaPrimitive.Scrollbar.Props) {
|
|
36
|
+
return (
|
|
37
|
+
<ScrollAreaPrimitive.Scrollbar
|
|
38
|
+
data-slot="scroll-area-scrollbar"
|
|
39
|
+
data-orientation={orientation}
|
|
40
|
+
orientation={orientation}
|
|
41
|
+
className={cn(
|
|
42
|
+
"flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
{...props}
|
|
46
|
+
>
|
|
47
|
+
<ScrollAreaPrimitive.Thumb
|
|
48
|
+
data-slot="scroll-area-thumb"
|
|
49
|
+
className="relative flex-1 rounded-full bg-border"
|
|
50
|
+
/>
|
|
51
|
+
</ScrollAreaPrimitive.Scrollbar>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { ScrollArea, ScrollBar }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@silicajs/ui/lib/utils"
|
|
6
|
+
|
|
7
|
+
function Separator({
|
|
8
|
+
className,
|
|
9
|
+
orientation = "horizontal",
|
|
10
|
+
...props
|
|
11
|
+
}: SeparatorPrimitive.Props) {
|
|
12
|
+
return (
|
|
13
|
+
<SeparatorPrimitive
|
|
14
|
+
data-slot="separator"
|
|
15
|
+
orientation={orientation}
|
|
16
|
+
className={cn(
|
|
17
|
+
"shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Separator }
|