import { type ReactElement } from "react"; import * as React from "react"; import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"; import { Select as SelectPrimitive } from "@base-ui/react/select"; import { cn } from "@/lib/utils"; import { useThemeVars } from "@/lib/theme-provider"; /** * Provides a DOM container for Select portals so they render inside the * DrawerContent element (which has pointer-events:auto from Radix * DismissableLayer) rather than at document.body (which Radix sets to * pointer-events:none when a modal dialog is open). * * Usage inside a Vaul Drawer: * const [portalEl, setPortalEl] = useState(); * *
el && setPortalEl(el)} /> ← place inside DrawerContent */ const SelectPortalContext = React.createContext( undefined, ); export type SelectPortalProviderProps = { container: HTMLElement | undefined; children: React.ReactNode; }; function SelectPortalProvider({ container, children, }: SelectPortalProviderProps): ReactElement { return ( {children} ); } export type SelectProps< Value = string, Multiple extends boolean | undefined = false, > = SelectPrimitive.Root.Props; function Select({ ...props }: SelectProps): ReactElement { return ; } export type SelectGroupProps = React.ComponentProps< typeof SelectPrimitive.Group >; function SelectGroup({ ...props }: SelectGroupProps): ReactElement { return ; } export type SelectValueProps = React.ComponentProps< typeof SelectPrimitive.Value >; function SelectValue({ ...props }: SelectValueProps): ReactElement { return ; } export type SelectTriggerProps = React.ComponentProps< typeof SelectPrimitive.Trigger > & { size?: "sm" | "default"; }; function SelectTrigger({ className, size = "default", children, ...props }: SelectTriggerProps): ReactElement { return ( {children} ); } export type SelectContentProps = React.ComponentProps< typeof SelectPrimitive.Popup >; function SelectContent({ className, children, style, ...props }: SelectContentProps): ReactElement { const themeVars = useThemeVars(); const portalContainer = React.useContext(SelectPortalContext); return ( {children} ); } export type SelectLabelProps = React.ComponentProps< typeof SelectPrimitive.GroupLabel >; function SelectLabel({ className, ...props }: SelectLabelProps): ReactElement { return ( ); } export type SelectItemProps = React.ComponentProps; function SelectItem({ className, children, ...props }: SelectItemProps): ReactElement { return ( {children} ); } export type SelectSeparatorProps = React.ComponentProps<"div">; function SelectSeparator({ className, ...props }: SelectSeparatorProps): ReactElement { return (
); } export type SelectScrollUpButtonProps = React.ComponentProps< typeof SelectPrimitive.ScrollUpArrow >; function SelectScrollUpButton({ className, ...props }: SelectScrollUpButtonProps): ReactElement { return ( ); } export type SelectScrollDownButtonProps = React.ComponentProps< typeof SelectPrimitive.ScrollDownArrow >; function SelectScrollDownButton({ className, ...props }: SelectScrollDownButtonProps): ReactElement { return ( ); } export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectPortalProvider, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, };