/* Copyright 2026 Marimo. All rights reserved. */ import type { VariantProps } from "class-variance-authority"; import { CheckIcon, ChevronDown, ChevronDownIcon, ChevronUpIcon, XIcon, } from "lucide-react"; import { Select as SelectPrimitive } from "radix-ui"; import * as React from "react"; import { StyleNamespace } from "@/theme/namespace"; import { cn } from "@/utils/cn"; import { withFullScreenAsRoot, withSmartCollisionBoundary } from "./fullscreen"; import { MENU_ITEM_DISABLED } from "./menu-items"; import { selectStyles } from "./native-select"; const Select = SelectPrimitive.Root; const SelectGroup = SelectPrimitive.Group; const SelectPortal = withFullScreenAsRoot(SelectPrimitive.Portal); const SelectValue = SelectPrimitive.Value; const SelectTrigger = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { onClear?: () => void; hideChevron?: boolean; } & VariantProps >( ( { className, children, onClear, variant, hideChevron = false, ...props }, ref, ) => ( {children} {onClear ? ( { e.preventDefault(); e.stopPropagation(); onClear(); }} > ) : ( !hideChevron && )} ), ); SelectTrigger.displayName = SelectPrimitive.Trigger.displayName; const InternalSelectContent = withSmartCollisionBoundary( SelectPrimitive.Content, ); const SelectContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, children, position = "popper", ...props }, ref) => ( {children} )); SelectContent.displayName = SelectPrimitive.Content.displayName; const SelectLabel = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); SelectLabel.displayName = SelectPrimitive.Label.displayName; const SelectItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { subtitle?: React.ReactNode; // Subtitle is not displayed in input field } >(({ className, children, subtitle, ...props }, ref) => ( {children} {subtitle} )); SelectItem.displayName = SelectPrimitive.Item.displayName; const SelectSeparator = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); SelectSeparator.displayName = SelectPrimitive.Separator.displayName; export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, };