/** @jsx jsx */ import { jsx, css } from '@emotion/react'; import { Fragment, useState } from 'react'; import CreatableSelect from 'react-select/creatable'; import { wrapperStyle, labelStyle, textStyle } from './Input'; import { SelectProps, Option } from './Select'; const Tags: React.FC & { value: Option[]; }> = ({ async, shapeValue, menuListStyle, style, label, error, ...props }) => { const [inputValue, setInputValue] = useState(''); function handleInputChange(value: string) { setInputValue(value); } const handleKeyDown: React.KeyboardEventHandler = (event: { key: any; preventDefault: () => void; }) => { if (!inputValue) return; switch (event.key) { case 'Enter': case 'Tab': setInputValue(''); if (props.onChange) { const option = createOption(inputValue); props.onChange([...props.value, option], { action: 'create-option', option, }); } event.preventDefault(); } }; return ( ); }; export function Indicator(props: any) { return ( ); } const components = { DropdownIndicator: null }; export default Tags; const createOption = (label: string) => ({ label, value: label, });