import React from 'react'; import { InputBase, MenuItem, Select as MuiSelect, SelectProps } from '@mui/material'; const variants = { flat: { root: 'ds-font-w3d ds-w-auto ds-inline-block ds-bg-[#f9f9f9] ds-rounded ds-border ds-border-solid ds-border-dark-100', input: 'ds-font-w3d ds-w-full !ds-pr-4 ds-text-dark-500', icon: '' }, raised: { root: 'ds-font-w3d ds-w-auto ds-inline-block ds-bg-light-500 ds-shadow-w3d ds-rounded ds-border ds-border-solid ds-border-[#f0f0f0]', input: 'ds-font-w3d ds-w-full !ds-pr-4 ds-text-dark-500', icon: '' }, outlined: { root: 'ds-font-w3d ds-w-auto ds-inline-block ds-bg-transparent ds-border ds-border-solid ds-border-current', input: 'ds-font-w3d ds-w-full !ds-pr-4 ds-text-current', icon: 'ds-text-current' } }; const sizes = { regular: { input: 'ds-p-1' }, small: { input: '' } } as const; export const Select: React.FC< React.PropsWithChildren< Partial< Omit< SelectProps, 'size' | 'value' | 'onChange' | 'className' | 'variant' | 'classes' | 'textFieldProps' | 'placeholder' > > & { value: any; onChange: (newValue: any) => any; className?: string; variant?: 'flat' | 'raised' | 'outlined'; size?: 'regular' | 'small'; classes?: { icon?: string; root?: string; input?: string; }; textFieldProps?: any; placeholder?: string; avoidNative?: boolean; } > > = ({ value, onChange, children, className = null, variant = 'raised', size = 'regular', classes = {}, textFieldProps = null, placeholder = null, avoidNative = true, ...others }) => { return ( } onChange={(e) => onChange?.(e.target.value)} {...others} > {avoidNative && placeholder && ( {placeholder} )} {!avoidNative && ( <> {placeholder && ( )} {React.Children.toArray(children) .filter(Boolean) .map((child: any, index) => { if (!child) { return null; } return ( ); })} )} {avoidNative && children} ); };