import * as React from 'react'; import classNames from 'classnames'; import { classNameModifier, classNameModifierByFlag } from '../shared/utils'; import { ComponentClassNames } from '../shared/constants'; import { Flex } from '../Flex'; import { IconExpandMore } from '../Icon/internal'; import { ForwardRefPrimitive, Primitive } from '../types'; import { BaseSelectProps, SelectProps } from '../types/select'; import { View } from '../View'; const SelectPrimitive: Primitive = ( { autoComplete, className, size, variation, value, defaultValue, hasError, icon = , iconColor, children, placeholder, isDisabled, isRequired, ...rest }, ref ) => { const DEFAULT_PLACEHOLDER_VALUE = ''; // value === undefined is to make sure that component is used in uncontrolled way so that setting defaultValue is valid const shouldSetDefaultPlaceholderValue = value === undefined && defaultValue === undefined && placeholder; const componentClasses = classNames( ComponentClassNames.Select, ComponentClassNames.FieldGroupControl, classNameModifier(ComponentClassNames.Select, size), classNameModifier(ComponentClassNames.Select, variation), classNameModifierByFlag(ComponentClassNames.Select, 'error', hasError), className ); return ( {placeholder && } {children} {icon} ); }; export const Select: ForwardRefPrimitive = React.forwardRef(SelectPrimitive); Select.displayName = 'Select';