Files
planet/frontend/src/admin-next/components/ui/select.tsx
T
linkong fbca381512
ci / backend (push) Has been cancelled
ci / frontend (push) Has been cancelled
ci / delivery (push) Has been cancelled
release / images (push) Has been cancelled
release: bump version to 0.62.0
2026-05-21 01:37:32 +08:00

47 lines
1.6 KiB
TypeScript

import * as SelectPrimitive from '@radix-ui/react-select'
import { Check, ChevronDown } from 'lucide-react'
import { cn } from '../../lib/utils'
export interface SelectOption {
value: string
label: string
}
interface SelectProps {
value: string
onValueChange: (value: string) => void
options: SelectOption[]
placeholder?: string
disabled?: boolean
className?: string
}
export function Select({ value, onValueChange, options, placeholder, disabled, className }: SelectProps) {
return (
<SelectPrimitive.Root value={value} onValueChange={onValueChange} disabled={disabled}>
<SelectPrimitive.Trigger className={cn('an-select', className)}>
<span className="an-select__value">
<SelectPrimitive.Value placeholder={placeholder} />
</span>
<SelectPrimitive.Icon>
<ChevronDown size={16} />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
<SelectPrimitive.Portal>
<SelectPrimitive.Content className="an-select__content" position="popper">
<SelectPrimitive.Viewport>
{options.map((option) => (
<SelectPrimitive.Item key={option.value} value={option.value} className="an-select__item">
<SelectPrimitive.ItemText>{option.label}</SelectPrimitive.ItemText>
<SelectPrimitive.ItemIndicator>
<Check size={14} />
</SelectPrimitive.ItemIndicator>
</SelectPrimitive.Item>
))}
</SelectPrimitive.Viewport>
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
</SelectPrimitive.Root>
)
}