71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import * as React from "react"
|
|
import { cn } from "cn"
|
|
|
|
import { IconPlaceholder } from "@/app/(create)/components/icon-placeholder"
|
|
|
|
type NativeSelectProps = Omit<React.ComponentProps<"select">, "size"> & {
|
|
size?: "sm" | "default"
|
|
}
|
|
|
|
function NativeSelect({
|
|
className,
|
|
size = "default",
|
|
...props
|
|
}: NativeSelectProps) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"cn-native-select-wrapper group/native-select relative w-fit has-[select:disabled]:opacity-50",
|
|
className
|
|
)}
|
|
data-slot="native-select-wrapper"
|
|
data-size={size}
|
|
>
|
|
<select
|
|
data-slot="native-select"
|
|
data-size={size}
|
|
className="cn-native-select outline-none disabled:pointer-events-none disabled:cursor-not-allowed"
|
|
{...props}
|
|
/>
|
|
<IconPlaceholder
|
|
lucide="ChevronDownIcon"
|
|
tabler="IconSelector"
|
|
hugeicons="UnfoldMoreIcon"
|
|
phosphor="CaretDownIcon"
|
|
remixicon="RiArrowDownSLine"
|
|
className="cn-native-select-icon pointer-events-none absolute select-none"
|
|
aria-hidden="true"
|
|
data-slot="native-select-icon"
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function NativeSelectOption({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"option">) {
|
|
return (
|
|
<option
|
|
data-slot="native-select-option"
|
|
className={cn("bg-[Canvas] text-[CanvasText]", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function NativeSelectOptGroup({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"optgroup">) {
|
|
return (
|
|
<optgroup
|
|
data-slot="native-select-optgroup"
|
|
className={cn("bg-[Canvas] text-[CanvasText]", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export { NativeSelect, NativeSelectOptGroup, NativeSelectOption }
|