/** @jsx jsx */ import { jsx, css } from '@emotion/react' import { Fragment } from 'react' import ReactSelect, { components, Props } from 'react-select' import AsyncSelect from 'react-select/async' import { wrapperStyle, labelStyle, textStyle } from './Input' const Select: React.FC = ({ async, shapeValue, menuListStyle, style, label, error, ...props }) => { const defaultValue = ({ options, value, }: { options?: [OptionProps] value?: string }) => { return options ? props.isMulti ? props.options .flatMap((v: any) => (v.options ? v.options : v)) .filter((v: any) => value?.includes(v.value)) : props.options .flatMap((v: any) => (v.options ? v.options : v)) .find((option: OptionProps) => option.value === value) : '' } const Comp = async ? AsyncSelect : ReactSelect return ( ) } export function Indicator(props: any) { return ( ) } function DropdownIndicator(props: any) { return ( ) } const selectComponents = { DropdownIndicator, } export type SelectProps = Props & { label?: string placeholder?: string error?: boolean onClear?: () => void isClearable?: boolean loading?: boolean hasValue?: boolean async?: boolean style?: React.CSSProperties menuListStyle?: {} shapeValue?: any options?: any value?: string } export type OptionProps = { value?: string label?: string } export interface Option { readonly label: string readonly value: string } export default Select