import { Chip } from '../../data-display'; import { StyledChipEditor, Input } from '../../inputs/chip-editor/styled-chip-editor'; import { useState } from 'react'; import * as React from 'react'; interface ChipContent { title: string; } interface Props { chips: ChipContent[]; inputValue: string; onChangeInput: (e: { target: { value: string}}) => void; id?: string; addChip: (chip: string) => void; removeChip: (chip: string) => void; style?: React.CSSProperties; } const ChipEditor = (props: Props) => { const handleKeyDown = (e: { charCode: number }) => { if (e.charCode === 13) { props.addChip(props.inputValue); props.onChangeInput({ target: { value: ''}}) } }; const [myInput, setInput] = useState(''); const focusInput = () => { if((myInput || myInput !== undefined) && myInput.focus){ myInput.focus(); } }; return( {props.chips.map(chip => ( props.removeChip(chip.title)} > {chip.title} ))} { setInput(input); }} name='chip-input' type='text' value={props.inputValue} onChange={props.onChangeInput} /> ); }; export default ChipEditor;