import { Component, createRef, ReactNode } from "react"; import { PickerList, IDisplayItem } from "../PickerList/PickerList"; import { TextField, ITextFieldProps } from "../TextField/TextField"; import { Icon } from "@fluentui/react"; import { Localization } from "@Component/Localization/Localization"; import "./ComboInput.scss"; interface IComboInputProps extends ITextFieldProps { allOption?: IDisplayItem[]; value?: IDisplayItem; valueChange?: (value: IDisplayItem) => any; } interface IComboInputState { isPickerVisible: boolean; } class ComboInput extends Component { public constructor(props: IComboInputProps) { super(props); this.state = { isPickerVisible: false } } private pickerTarget = createRef(); private renderPicker() { return { return item.key === this.props.value?.key ? {...item, mark: true} : item; })} clickDisplayItems={((item) => { if (this.props.valueChange) { this.props.valueChange(item); } this.setState({ isPickerVisible: false }) })} dismiss={() => { this.setState({ isPickerVisible: false }) }} /> } public render(): ReactNode { return <> { this.setState({ isPickerVisible: true }) }} >
{ this.props.value ? : null }
{this.state.isPickerVisible ? this.renderPicker(): null} } } export { ComboInput, IDisplayItem };