import { forwardRef, useMemo, type ReactNode } from 'react'; import { Text, type TextProps, View, type ViewProps } from 'react-native'; import { KeyboardArrowDown, KeyboardArrowUp } from '@cdx-ui/icons'; import { SelectContent as SelectContentPrimitive, SelectItem as SelectItemPrimitive, SelectRoot as SelectRootPrimitive, SelectTrigger as SelectTriggerPrimitive, Slot, dataAttributes, mergeDataAttributes, useSelectContext, useSelectItemContext, type ISelectContentProps, type ISelectItemLabelProps, type ISelectItemProps, type ISelectProps, type ISelectTriggerProps, type ISelectValueProps, } from '@cdx-ui/primitives'; import { cn, ParentContext, useParentContext, useStyleContext } from '@cdx-ui/utils'; import { Icon, IconProps } from '../Icon'; import { positionToDataIcon, type IconSlotPosition } from '../../utils/positionToDataIcon'; import { type SelectVariantProps, selectContentVariants, selectIconVariants, selectItemLabelVariants, selectItemVariants, selectTriggerVariants, selectValueVariants, } from './styles'; const SCOPE = 'SELECT'; const useSelectStyleContext = () => useStyleContext(SCOPE) as SelectVariantProps; // ============================================================================= // STYLED ROOT // ============================================================================= export interface SelectProps extends ViewProps, ISelectProps, SelectVariantProps { className?: string; } const SelectRoot = forwardRef( ({ variant = 'outline', size = 'default', className, children, style, ...props }, ref) => { const parent = useParentContext(); const ctx = useMemo(() => ({ ...parent, [SCOPE]: { variant, size } }), [parent, variant, size]); return ( {children} ); }, ); SelectRoot.displayName = 'Select'; // ============================================================================= // STYLED TRIGGER // ============================================================================= export interface SelectTriggerProps extends ISelectTriggerProps { /** * Substitute the rendered trigger element with the single child. The child must * be another Forge primitive (IconButton, Chip, Button) — anything whose * underlying Pressable accepts Pressable-shaped handlers. When set, the * auto-injected arrow indicator is skipped and `selectTriggerVariants` is not * applied so the substituted component's own appearance wins. * * On web, `