@windrun-huaiin/base-ui 3.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 +21 -0
- package/README.md +190 -0
- package/dist/base-ui.css +3 -0
- package/dist/components/index.d.mts +144 -0
- package/dist/components/index.d.ts +144 -0
- package/dist/components/index.js +1699 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +1741 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/index.d.mts +47 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +6055 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5842 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/index.d.mts +24 -0
- package/dist/lib/index.d.ts +24 -0
- package/dist/lib/index.js +1324 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/index.mjs +1372 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/ui/index.d.mts +754 -0
- package/dist/ui/index.d.ts +754 -0
- package/dist/ui/index.js +5796 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/index.mjs +5593 -0
- package/dist/ui/index.mjs.map +1 -0
- package/package.json +120 -0
- package/src/assets/bitcoin.tsx +23 -0
- package/src/assets/clerk.tsx +23 -0
- package/src/assets/css.tsx +21 -0
- package/src/assets/csv.tsx +35 -0
- package/src/assets/d8.tsx +25 -0
- package/src/assets/diff.tsx +23 -0
- package/src/assets/dpa.tsx +22 -0
- package/src/assets/github.tsx +23 -0
- package/src/assets/html.tsx +22 -0
- package/src/assets/http.tsx +23 -0
- package/src/assets/index.ts +61 -0
- package/src/assets/iterm.tsx +23 -0
- package/src/assets/java.tsx +23 -0
- package/src/assets/json.tsx +23 -0
- package/src/assets/last-updated.tsx +23 -0
- package/src/assets/log.tsx +28 -0
- package/src/assets/mac.tsx +23 -0
- package/src/assets/markdown.tsx +24 -0
- package/src/assets/mdx.tsx +98 -0
- package/src/assets/mermaid.tsx +24 -0
- package/src/assets/scheme.tsx +22 -0
- package/src/assets/snippets.tsx +23 -0
- package/src/assets/sql.tsx +31 -0
- package/src/assets/subp.tsx +22 -0
- package/src/assets/t3p.tsx +23 -0
- package/src/assets/test.tsx +23 -0
- package/src/assets/txt.tsx +23 -0
- package/src/assets/xml.tsx +23 -0
- package/src/assets/yaml.tsx +23 -0
- package/src/components/404-page.tsx +106 -0
- package/src/components/global-icon.tsx +193 -0
- package/src/components/go-to-top.tsx +43 -0
- package/src/components/index.ts +10 -0
- package/src/components/language-detector.tsx +175 -0
- package/src/components/language-switcher.tsx +77 -0
- package/src/components/script/google-analytics-script.tsx +56 -0
- package/src/components/script/microsoft-clarity-script.tsx +24 -0
- package/src/index.ts +4 -0
- package/src/lib/icon-context.tsx +57 -0
- package/src/lib/index.ts +3 -0
- package/src/lib/site-icon.tsx +46 -0
- package/src/lib/theme-util.ts +7 -0
- package/src/styles/base-ui.css +2 -0
- package/src/ui/accordion.tsx +58 -0
- package/src/ui/alert-dialog.tsx +141 -0
- package/src/ui/alert.tsx +59 -0
- package/src/ui/aspect-ratio.tsx +7 -0
- package/src/ui/avatar.tsx +50 -0
- package/src/ui/badge.tsx +36 -0
- package/src/ui/breadcrumb.tsx +115 -0
- package/src/ui/button.tsx +76 -0
- package/src/ui/calendar.tsx +66 -0
- package/src/ui/card.tsx +79 -0
- package/src/ui/carousel.tsx +262 -0
- package/src/ui/chart.tsx +365 -0
- package/src/ui/checkbox.tsx +30 -0
- package/src/ui/collapsible.tsx +11 -0
- package/src/ui/command.tsx +153 -0
- package/src/ui/context-menu.tsx +200 -0
- package/src/ui/dialog.tsx +122 -0
- package/src/ui/drawer.tsx +118 -0
- package/src/ui/dropdown-menu.tsx +200 -0
- package/src/ui/form.tsx +178 -0
- package/src/ui/hover-card.tsx +29 -0
- package/src/ui/index.ts +52 -0
- package/src/ui/input-otp.tsx +71 -0
- package/src/ui/input.tsx +22 -0
- package/src/ui/label.tsx +26 -0
- package/src/ui/language-button.tsx +43 -0
- package/src/ui/menubar.tsx +236 -0
- package/src/ui/navigation-menu.tsx +128 -0
- package/src/ui/pagination.tsx +117 -0
- package/src/ui/popover.tsx +31 -0
- package/src/ui/progress.tsx +28 -0
- package/src/ui/radio-group.tsx +44 -0
- package/src/ui/resizable.tsx +45 -0
- package/src/ui/scroll-area.tsx +48 -0
- package/src/ui/select.tsx +160 -0
- package/src/ui/separator.tsx +31 -0
- package/src/ui/sheet.tsx +140 -0
- package/src/ui/sidebar.tsx +763 -0
- package/src/ui/skeleton.tsx +15 -0
- package/src/ui/slider.tsx +28 -0
- package/src/ui/sonner.tsx +31 -0
- package/src/ui/switch.tsx +29 -0
- package/src/ui/table.tsx +117 -0
- package/src/ui/tabs.tsx +55 -0
- package/src/ui/textarea.tsx +22 -0
- package/src/ui/toast.tsx +129 -0
- package/src/ui/toaster.tsx +35 -0
- package/src/ui/toggle-group.tsx +61 -0
- package/src/ui/toggle.tsx +45 -0
- package/src/ui/tooltip.tsx +30 -0
- package/src/ui/use-mobile.tsx +19 -0
- package/src/ui/use-toast.ts +194 -0
@@ -0,0 +1,200 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
import * as React from "react"
|
4
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
5
|
+
import { globalLucideIcons as icons } from "@base-ui/components/global-icon"
|
6
|
+
|
7
|
+
import { cn } from "@lib/utils"
|
8
|
+
|
9
|
+
const DropdownMenu = DropdownMenuPrimitive.Root
|
10
|
+
|
11
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
12
|
+
|
13
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
14
|
+
|
15
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
16
|
+
|
17
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
18
|
+
|
19
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
20
|
+
|
21
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
22
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
23
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
24
|
+
inset?: boolean
|
25
|
+
}
|
26
|
+
>(({ className, inset, children, ...props }, ref) => (
|
27
|
+
<DropdownMenuPrimitive.SubTrigger
|
28
|
+
ref={ref}
|
29
|
+
className={cn(
|
30
|
+
"flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
31
|
+
inset && "pl-8",
|
32
|
+
className
|
33
|
+
)}
|
34
|
+
{...props}
|
35
|
+
>
|
36
|
+
{children}
|
37
|
+
<icons.ChevronRight className="ml-auto" />
|
38
|
+
</DropdownMenuPrimitive.SubTrigger>
|
39
|
+
))
|
40
|
+
DropdownMenuSubTrigger.displayName =
|
41
|
+
DropdownMenuPrimitive.SubTrigger.displayName
|
42
|
+
|
43
|
+
const DropdownMenuSubContent = React.forwardRef<
|
44
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
45
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
46
|
+
>(({ className, ...props }, ref) => (
|
47
|
+
<DropdownMenuPrimitive.SubContent
|
48
|
+
ref={ref}
|
49
|
+
className={cn(
|
50
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
|
51
|
+
className
|
52
|
+
)}
|
53
|
+
{...props}
|
54
|
+
/>
|
55
|
+
))
|
56
|
+
DropdownMenuSubContent.displayName =
|
57
|
+
DropdownMenuPrimitive.SubContent.displayName
|
58
|
+
|
59
|
+
const DropdownMenuContent = React.forwardRef<
|
60
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
61
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
62
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
63
|
+
<DropdownMenuPrimitive.Portal>
|
64
|
+
<DropdownMenuPrimitive.Content
|
65
|
+
ref={ref}
|
66
|
+
sideOffset={sideOffset}
|
67
|
+
className={cn(
|
68
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
|
69
|
+
className
|
70
|
+
)}
|
71
|
+
{...props}
|
72
|
+
/>
|
73
|
+
</DropdownMenuPrimitive.Portal>
|
74
|
+
))
|
75
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
76
|
+
|
77
|
+
const DropdownMenuItem = React.forwardRef<
|
78
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
79
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
80
|
+
inset?: boolean
|
81
|
+
}
|
82
|
+
>(({ className, inset, ...props }, ref) => (
|
83
|
+
<DropdownMenuPrimitive.Item
|
84
|
+
ref={ref}
|
85
|
+
className={cn(
|
86
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
87
|
+
inset && "pl-8",
|
88
|
+
className
|
89
|
+
)}
|
90
|
+
{...props}
|
91
|
+
/>
|
92
|
+
))
|
93
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
94
|
+
|
95
|
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
96
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
97
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
98
|
+
>(({ className, children, checked, ...props }, ref) => (
|
99
|
+
<DropdownMenuPrimitive.CheckboxItem
|
100
|
+
ref={ref}
|
101
|
+
className={cn(
|
102
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
|
103
|
+
className
|
104
|
+
)}
|
105
|
+
checked={checked}
|
106
|
+
{...props}
|
107
|
+
>
|
108
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
109
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
110
|
+
<icons.Check className="h-4 w-4" />
|
111
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
112
|
+
</span>
|
113
|
+
{children}
|
114
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
115
|
+
))
|
116
|
+
DropdownMenuCheckboxItem.displayName =
|
117
|
+
DropdownMenuPrimitive.CheckboxItem.displayName
|
118
|
+
|
119
|
+
const DropdownMenuRadioItem = React.forwardRef<
|
120
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
121
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
122
|
+
>(({ className, children, ...props }, ref) => (
|
123
|
+
<DropdownMenuPrimitive.RadioItem
|
124
|
+
ref={ref}
|
125
|
+
className={cn(
|
126
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
|
127
|
+
className
|
128
|
+
)}
|
129
|
+
{...props}
|
130
|
+
>
|
131
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
132
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
133
|
+
<icons.Circle className="h-2 w-2 fill-current" />
|
134
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
135
|
+
</span>
|
136
|
+
{children}
|
137
|
+
</DropdownMenuPrimitive.RadioItem>
|
138
|
+
))
|
139
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
|
140
|
+
|
141
|
+
const DropdownMenuLabel = React.forwardRef<
|
142
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
143
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
144
|
+
inset?: boolean
|
145
|
+
}
|
146
|
+
>(({ className, inset, ...props }, ref) => (
|
147
|
+
<DropdownMenuPrimitive.Label
|
148
|
+
ref={ref}
|
149
|
+
className={cn(
|
150
|
+
"px-2 py-1.5 text-sm font-semibold",
|
151
|
+
inset && "pl-8",
|
152
|
+
className
|
153
|
+
)}
|
154
|
+
{...props}
|
155
|
+
/>
|
156
|
+
))
|
157
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
158
|
+
|
159
|
+
const DropdownMenuSeparator = React.forwardRef<
|
160
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
161
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
162
|
+
>(({ className, ...props }, ref) => (
|
163
|
+
<DropdownMenuPrimitive.Separator
|
164
|
+
ref={ref}
|
165
|
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
166
|
+
{...props}
|
167
|
+
/>
|
168
|
+
))
|
169
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
170
|
+
|
171
|
+
const DropdownMenuShortcut = ({
|
172
|
+
className,
|
173
|
+
...props
|
174
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
175
|
+
return (
|
176
|
+
<span
|
177
|
+
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
|
178
|
+
{...props}
|
179
|
+
/>
|
180
|
+
)
|
181
|
+
}
|
182
|
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
|
183
|
+
|
184
|
+
export {
|
185
|
+
DropdownMenu,
|
186
|
+
DropdownMenuTrigger,
|
187
|
+
DropdownMenuContent,
|
188
|
+
DropdownMenuItem,
|
189
|
+
DropdownMenuCheckboxItem,
|
190
|
+
DropdownMenuRadioItem,
|
191
|
+
DropdownMenuLabel,
|
192
|
+
DropdownMenuSeparator,
|
193
|
+
DropdownMenuShortcut,
|
194
|
+
DropdownMenuGroup,
|
195
|
+
DropdownMenuPortal,
|
196
|
+
DropdownMenuSub,
|
197
|
+
DropdownMenuSubContent,
|
198
|
+
DropdownMenuSubTrigger,
|
199
|
+
DropdownMenuRadioGroup,
|
200
|
+
}
|
package/src/ui/form.tsx
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
import * as React from "react"
|
4
|
+
import * as LabelPrimitive from "@radix-ui/react-label"
|
5
|
+
import { Slot } from "@radix-ui/react-slot"
|
6
|
+
import {
|
7
|
+
Controller,
|
8
|
+
ControllerProps,
|
9
|
+
FieldPath,
|
10
|
+
FieldValues,
|
11
|
+
FormProvider,
|
12
|
+
useFormContext,
|
13
|
+
} from "react-hook-form"
|
14
|
+
|
15
|
+
import { cn } from "@lib/utils"
|
16
|
+
import { Label } from "@base-ui/ui/label"
|
17
|
+
|
18
|
+
const Form = FormProvider
|
19
|
+
|
20
|
+
type FormFieldContextValue<
|
21
|
+
TFieldValues extends FieldValues = FieldValues,
|
22
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
23
|
+
> = {
|
24
|
+
name: TName
|
25
|
+
}
|
26
|
+
|
27
|
+
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
28
|
+
{} as FormFieldContextValue
|
29
|
+
)
|
30
|
+
|
31
|
+
const FormField = <
|
32
|
+
TFieldValues extends FieldValues = FieldValues,
|
33
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
34
|
+
>({
|
35
|
+
...props
|
36
|
+
}: ControllerProps<TFieldValues, TName>) => {
|
37
|
+
return (
|
38
|
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
39
|
+
<Controller {...props} />
|
40
|
+
</FormFieldContext.Provider>
|
41
|
+
)
|
42
|
+
}
|
43
|
+
|
44
|
+
const useFormField = () => {
|
45
|
+
const fieldContext = React.useContext(FormFieldContext)
|
46
|
+
const itemContext = React.useContext(FormItemContext)
|
47
|
+
const { getFieldState, formState } = useFormContext()
|
48
|
+
|
49
|
+
const fieldState = getFieldState(fieldContext.name, formState)
|
50
|
+
|
51
|
+
if (!fieldContext) {
|
52
|
+
throw new Error("useFormField should be used within <FormField>")
|
53
|
+
}
|
54
|
+
|
55
|
+
const { id } = itemContext
|
56
|
+
|
57
|
+
return {
|
58
|
+
id,
|
59
|
+
name: fieldContext.name,
|
60
|
+
formItemId: `${id}-form-item`,
|
61
|
+
formDescriptionId: `${id}-form-item-description`,
|
62
|
+
formMessageId: `${id}-form-item-message`,
|
63
|
+
...fieldState,
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
type FormItemContextValue = {
|
68
|
+
id: string
|
69
|
+
}
|
70
|
+
|
71
|
+
const FormItemContext = React.createContext<FormItemContextValue>(
|
72
|
+
{} as FormItemContextValue
|
73
|
+
)
|
74
|
+
|
75
|
+
const FormItem = React.forwardRef<
|
76
|
+
HTMLDivElement,
|
77
|
+
React.HTMLAttributes<HTMLDivElement>
|
78
|
+
>(({ className, ...props }, ref) => {
|
79
|
+
const id = React.useId()
|
80
|
+
|
81
|
+
return (
|
82
|
+
<FormItemContext.Provider value={{ id }}>
|
83
|
+
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
84
|
+
</FormItemContext.Provider>
|
85
|
+
)
|
86
|
+
})
|
87
|
+
FormItem.displayName = "FormItem"
|
88
|
+
|
89
|
+
const FormLabel = React.forwardRef<
|
90
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
91
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
92
|
+
>(({ className, ...props }, ref) => {
|
93
|
+
const { error, formItemId } = useFormField()
|
94
|
+
|
95
|
+
return (
|
96
|
+
<Label
|
97
|
+
ref={ref}
|
98
|
+
className={cn(error && "text-destructive", className)}
|
99
|
+
htmlFor={formItemId}
|
100
|
+
{...props}
|
101
|
+
/>
|
102
|
+
)
|
103
|
+
})
|
104
|
+
FormLabel.displayName = "FormLabel"
|
105
|
+
|
106
|
+
const FormControl = React.forwardRef<
|
107
|
+
React.ElementRef<typeof Slot>,
|
108
|
+
React.ComponentPropsWithoutRef<typeof Slot>
|
109
|
+
>(({ ...props }, ref) => {
|
110
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
111
|
+
|
112
|
+
return (
|
113
|
+
<Slot
|
114
|
+
ref={ref}
|
115
|
+
id={formItemId}
|
116
|
+
aria-describedby={
|
117
|
+
!error
|
118
|
+
? `${formDescriptionId}`
|
119
|
+
: `${formDescriptionId} ${formMessageId}`
|
120
|
+
}
|
121
|
+
aria-invalid={!!error}
|
122
|
+
{...props}
|
123
|
+
/>
|
124
|
+
)
|
125
|
+
})
|
126
|
+
FormControl.displayName = "FormControl"
|
127
|
+
|
128
|
+
const FormDescription = React.forwardRef<
|
129
|
+
HTMLParagraphElement,
|
130
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
131
|
+
>(({ className, ...props }, ref) => {
|
132
|
+
const { formDescriptionId } = useFormField()
|
133
|
+
|
134
|
+
return (
|
135
|
+
<p
|
136
|
+
ref={ref}
|
137
|
+
id={formDescriptionId}
|
138
|
+
className={cn("text-sm text-muted-foreground", className)}
|
139
|
+
{...props}
|
140
|
+
/>
|
141
|
+
)
|
142
|
+
})
|
143
|
+
FormDescription.displayName = "FormDescription"
|
144
|
+
|
145
|
+
const FormMessage = React.forwardRef<
|
146
|
+
HTMLParagraphElement,
|
147
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
148
|
+
>(({ className, children, ...props }, ref) => {
|
149
|
+
const { error, formMessageId } = useFormField()
|
150
|
+
const body = error ? String(error?.message) : children
|
151
|
+
|
152
|
+
if (!body) {
|
153
|
+
return null
|
154
|
+
}
|
155
|
+
|
156
|
+
return (
|
157
|
+
<p
|
158
|
+
ref={ref}
|
159
|
+
id={formMessageId}
|
160
|
+
className={cn("text-sm font-medium text-destructive", className)}
|
161
|
+
{...props}
|
162
|
+
>
|
163
|
+
{body}
|
164
|
+
</p>
|
165
|
+
)
|
166
|
+
})
|
167
|
+
FormMessage.displayName = "FormMessage"
|
168
|
+
|
169
|
+
export {
|
170
|
+
useFormField,
|
171
|
+
Form,
|
172
|
+
FormItem,
|
173
|
+
FormLabel,
|
174
|
+
FormControl,
|
175
|
+
FormDescription,
|
176
|
+
FormMessage,
|
177
|
+
FormField,
|
178
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
import * as React from "react"
|
4
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card"
|
5
|
+
|
6
|
+
import { cn } from "@lib/utils"
|
7
|
+
|
8
|
+
const HoverCard = HoverCardPrimitive.Root
|
9
|
+
|
10
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger
|
11
|
+
|
12
|
+
const HoverCardContent = React.forwardRef<
|
13
|
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
14
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
15
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
16
|
+
<HoverCardPrimitive.Content
|
17
|
+
ref={ref}
|
18
|
+
align={align}
|
19
|
+
sideOffset={sideOffset}
|
20
|
+
className={cn(
|
21
|
+
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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",
|
22
|
+
className
|
23
|
+
)}
|
24
|
+
{...props}
|
25
|
+
/>
|
26
|
+
))
|
27
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName
|
28
|
+
|
29
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent }
|
package/src/ui/index.ts
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
// UI Components
|
2
|
+
export * from './accordion';
|
3
|
+
export * from './alert-dialog';
|
4
|
+
export * from './alert';
|
5
|
+
export * from './aspect-ratio';
|
6
|
+
export * from './avatar';
|
7
|
+
export * from './badge';
|
8
|
+
export * from './breadcrumb';
|
9
|
+
export { Button, buttonVariants, type ButtonProps } from './button';
|
10
|
+
export * from './calendar';
|
11
|
+
export * from './card';
|
12
|
+
export * from './carousel';
|
13
|
+
export * from './chart';
|
14
|
+
export * from './checkbox';
|
15
|
+
export * from './collapsible';
|
16
|
+
export * from './command';
|
17
|
+
export * from './context-menu';
|
18
|
+
export * from './dialog';
|
19
|
+
export * from './drawer';
|
20
|
+
export * from './dropdown-menu';
|
21
|
+
export * from './form';
|
22
|
+
export * from './hover-card';
|
23
|
+
export * from './input-otp';
|
24
|
+
export * from './input';
|
25
|
+
export * from './label';
|
26
|
+
export { LanguageButton, type LanguageButtonProps } from './language-button';
|
27
|
+
export * from './menubar';
|
28
|
+
export * from './navigation-menu';
|
29
|
+
export * from './pagination';
|
30
|
+
export * from './popover';
|
31
|
+
export * from './progress';
|
32
|
+
export * from './radio-group';
|
33
|
+
export * from './resizable';
|
34
|
+
export * from './scroll-area';
|
35
|
+
export * from './select';
|
36
|
+
export * from './separator';
|
37
|
+
export * from './sheet';
|
38
|
+
export * from './sidebar';
|
39
|
+
export * from './skeleton';
|
40
|
+
export * from './slider';
|
41
|
+
export { Toaster as SonnerToaster } from './sonner';
|
42
|
+
export * from './switch';
|
43
|
+
export * from './table';
|
44
|
+
export * from './tabs';
|
45
|
+
export * from './textarea';
|
46
|
+
export * from './toast';
|
47
|
+
export { Toaster as ToastToaster } from './toaster';
|
48
|
+
export * from './toggle-group';
|
49
|
+
export * from './toggle';
|
50
|
+
export * from './tooltip';
|
51
|
+
export * from './use-mobile';
|
52
|
+
export * from './use-toast';
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
import * as React from "react"
|
4
|
+
import { OTPInput, OTPInputContext } from "input-otp"
|
5
|
+
import { globalLucideIcons as icons } from "@base-ui/components/global-icon"
|
6
|
+
|
7
|
+
import { cn } from "@lib/utils"
|
8
|
+
|
9
|
+
const InputOTP = React.forwardRef<
|
10
|
+
React.ElementRef<typeof OTPInput>,
|
11
|
+
React.ComponentPropsWithoutRef<typeof OTPInput>
|
12
|
+
>(({ className, containerClassName, ...props }, ref) => (
|
13
|
+
<OTPInput
|
14
|
+
ref={ref}
|
15
|
+
containerClassName={cn(
|
16
|
+
"flex items-center gap-2 has-disabled:opacity-50",
|
17
|
+
containerClassName
|
18
|
+
)}
|
19
|
+
className={cn("disabled:cursor-not-allowed", className)}
|
20
|
+
{...props}
|
21
|
+
/>
|
22
|
+
))
|
23
|
+
InputOTP.displayName = "InputOTP"
|
24
|
+
|
25
|
+
const InputOTPGroup = React.forwardRef<
|
26
|
+
React.ElementRef<"div">,
|
27
|
+
React.ComponentPropsWithoutRef<"div">
|
28
|
+
>(({ className, ...props }, ref) => (
|
29
|
+
<div ref={ref} className={cn("flex items-center", className)} {...props} />
|
30
|
+
))
|
31
|
+
InputOTPGroup.displayName = "InputOTPGroup"
|
32
|
+
|
33
|
+
const InputOTPSlot = React.forwardRef<
|
34
|
+
React.ElementRef<"div">,
|
35
|
+
React.ComponentPropsWithoutRef<"div"> & { index: number }
|
36
|
+
>(({ index, className, ...props }, ref) => {
|
37
|
+
const inputOTPContext = React.useContext(OTPInputContext)
|
38
|
+
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
|
39
|
+
|
40
|
+
return (
|
41
|
+
<div
|
42
|
+
ref={ref}
|
43
|
+
className={cn(
|
44
|
+
"relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",
|
45
|
+
isActive && "z-10 ring-2 ring-ring ring-offset-background",
|
46
|
+
className
|
47
|
+
)}
|
48
|
+
{...props}
|
49
|
+
>
|
50
|
+
{char}
|
51
|
+
{hasFakeCaret && (
|
52
|
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
53
|
+
<div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
|
54
|
+
</div>
|
55
|
+
)}
|
56
|
+
</div>
|
57
|
+
)
|
58
|
+
})
|
59
|
+
InputOTPSlot.displayName = "InputOTPSlot"
|
60
|
+
|
61
|
+
const InputOTPSeparator = React.forwardRef<
|
62
|
+
React.ElementRef<"div">,
|
63
|
+
React.ComponentPropsWithoutRef<"div">
|
64
|
+
>(({ ...props }, ref) => (
|
65
|
+
<div ref={ref} role="separator" {...props}>
|
66
|
+
<icons.Dot />
|
67
|
+
</div>
|
68
|
+
))
|
69
|
+
InputOTPSeparator.displayName = "InputOTPSeparator"
|
70
|
+
|
71
|
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
|
package/src/ui/input.tsx
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
import * as React from "react"
|
2
|
+
|
3
|
+
import { cn } from "@lib/utils"
|
4
|
+
|
5
|
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
6
|
+
({ className, type, ...props }, ref) => {
|
7
|
+
return (
|
8
|
+
<input
|
9
|
+
type={type}
|
10
|
+
className={cn(
|
11
|
+
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
12
|
+
className
|
13
|
+
)}
|
14
|
+
ref={ref}
|
15
|
+
{...props}
|
16
|
+
/>
|
17
|
+
)
|
18
|
+
}
|
19
|
+
)
|
20
|
+
Input.displayName = "Input"
|
21
|
+
|
22
|
+
export { Input }
|
package/src/ui/label.tsx
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
"use client"
|
2
|
+
|
3
|
+
import * as React from "react"
|
4
|
+
import * as LabelPrimitive from "@radix-ui/react-label"
|
5
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
6
|
+
|
7
|
+
import { cn } from "@lib/utils"
|
8
|
+
|
9
|
+
const labelVariants = cva(
|
10
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
11
|
+
)
|
12
|
+
|
13
|
+
const Label = React.forwardRef<
|
14
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
15
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
16
|
+
VariantProps<typeof labelVariants>
|
17
|
+
>(({ className, ...props }, ref) => (
|
18
|
+
<LabelPrimitive.Root
|
19
|
+
ref={ref}
|
20
|
+
className={cn(labelVariants(), className)}
|
21
|
+
{...props}
|
22
|
+
/>
|
23
|
+
))
|
24
|
+
Label.displayName = LabelPrimitive.Root.displayName
|
25
|
+
|
26
|
+
export { Label }
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* MIT License
|
4
|
+
* Copyright (c) 2025 D8ger
|
5
|
+
*
|
6
|
+
* This source code is licensed under the MIT license found in the
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
8
|
+
*/
|
9
|
+
|
10
|
+
import * as React from "react"
|
11
|
+
import { cn } from "@lib/utils"
|
12
|
+
|
13
|
+
export interface LanguageButtonProps
|
14
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
15
|
+
variant?: "default" | "ghost"
|
16
|
+
size?: "default" | "sm" | "lg" | "icon"
|
17
|
+
}
|
18
|
+
|
19
|
+
const LanguageButton = React.forwardRef<HTMLButtonElement, LanguageButtonProps>(
|
20
|
+
({ className, variant = "default", size = "default", ...props }, ref) => {
|
21
|
+
return (
|
22
|
+
<button
|
23
|
+
className={cn(
|
24
|
+
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background",
|
25
|
+
{
|
26
|
+
"bg-primary text-primary-foreground hover:bg-primary/90": variant === "default",
|
27
|
+
"hover:bg-accent hover:text-accent-foreground": variant === "ghost",
|
28
|
+
"h-10 px-4 py-2": size === "default",
|
29
|
+
"h-9 px-3": size === "sm",
|
30
|
+
"h-11 px-8": size === "lg",
|
31
|
+
"h-10 w-10": size === "icon",
|
32
|
+
},
|
33
|
+
className
|
34
|
+
)}
|
35
|
+
ref={ref}
|
36
|
+
{...props}
|
37
|
+
/>
|
38
|
+
)
|
39
|
+
}
|
40
|
+
)
|
41
|
+
LanguageButton.displayName = "Button"
|
42
|
+
|
43
|
+
export { LanguageButton }
|