import React, { useState } from "react"; import styles from "./itemSelect.module.css" export interface SelectItemIE{ name:string value: string|number } interface SelectIE{ onChange: (value:string|number) => void items: SelectItemIE[] value?:number } export const ItemSelect: React.FC = (props) =>{ const [selected, setSelected] = useState(props.items[0]) const [open, setOpen] = useState(false) let options = new Array() props.items.map((item:SelectItemIE)=>{ options.push(
onItemChange(item)}>{item.name}
) }) const onItemChange = (item:SelectItemIE) =>{ setSelected(item) props.onChange(item.value) } return(
setOpen(!open)}>Выберите документ
{ open?
{options}
: "" }
) }