import * as SelectPrimitive from "@radix-ui/react-select"; import { cva, type VariantProps } from "class-variance-authority"; import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"; import { type ComponentProps, createContext, type ReactNode, useContext } from "react"; import { cn } from "../hooks"; const SelectContext = createContext<{ font: "standard" | "mono"; align: "left" | "center" | "right"; }>({ font: "mono", align: "left" }); interface SelectRootProps extends ComponentProps { font?: "standard" | "mono"; align?: "left" | "center" | "right"; } /** * Select root primitive. */ export function Select({ font = "mono", align = "left", ...props }: SelectRootProps) { return ( ); } /** * Group container for related select items. */ export function SelectGroup({ className, ...props }: ComponentProps) { return ( ); } /** * Displays the selected value inside the trigger. */ export function SelectValue({ ...props }: ComponentProps) { return ; } export const selectTriggerVariants = cva( [ "flex", "items-center", "gap-2", "bg-select-secondary", "whitespace-nowrap", "shadow-xs", "transition-[color,box-shadow]", "outline-none", "*:data-[slot=select-value]:line-clamp-1", "*:data-[slot=select-value]:flex", "*:data-[slot=select-value]:items-center", "*:data-[slot=select-value]:gap-2", "[&_svg]:shrink-0", "[&_svg]:pointer-events-none", "[&_svg:not([class*='text-'])]:text-muted-foreground", "[type=number]:font-number-input", ], { variants: { state: { default: ["hover:bg-bg-secondary/80", "has-[input:focus]:bg-bg-secondary"], disabled: ["disabled:cursor-not-allowed", "bg-bg-tertiary", "text-text-tertiary"], error: ["hover:bg-danger-primary/10", "bg-danger-primary/20"], }, size: { sm: "px-sm py-xs text-uk-sm h-6 [&_svg:not([class*='size-'])]:size-3 rounded-uk-md", md: "px-md py-sm text-uk-md h-8 [&_svg:not([class*='size-'])]:size-4 rounded-uk-lg", lg: "px-lg py-sm text-uk-lg h-9 [&_svg:not([class*='size-'])]:size-5 rounded-uk-xl", }, font: { standard: "font-sans", mono: "font-number-input", }, align: { left: "justify-between", center: "justify-center *:data-[slot=select-value]:flex-1 *:data-[slot=select-value]:justify-center", right: "justify-between *:data-[slot=select-value]:flex-1 *:data-[slot=select-value]:justify-end", }, }, defaultVariants: { state: "default", size: "md", font: "mono", align: "left", }, }, ); interface SelectTriggerProps extends Omit, "ref">, VariantProps { icon?: ReactNode; } /** * Trigger button for the select. */ export function SelectTrigger({ className, size, children, disabled, state, font, align, icon, ...props }: SelectTriggerProps) { return ( {children} {icon || } ); } /** * Floating panel containing options. */ export function SelectContent({ className, children, position = "item-aligned", ...props }: ComponentProps) { const { font } = useContext(SelectContext); return ( {children} ); } /** * Section label for options. */ export function SelectLabel({ className, ...props }: ComponentProps) { return ( ); } interface SelectItemProps extends Omit, "prefix"> { prefix?: ReactNode; suffix?: ReactNode; } /** * Single option row with optional prefix/suffix content. */ export function SelectItem({ className, children, prefix, suffix, disabled, ...props }: SelectItemProps) { return ( {prefix && (

{prefix}

)} {children} {suffix && (

{suffix}

)}
); } /** * Visual separator between groups. */ export function SelectSeparator({ className, ...props }: ComponentProps) { return ( ); } /** * Scroll button at top of list. */ export function SelectScrollUpButton({ className, ...props }: ComponentProps) { return ( ); } /** * Scroll button at bottom of list. */ export function SelectScrollDownButton({ className, ...props }: ComponentProps) { return ( ); }