// This file is part of Coog. The COPYRIGHT file at the top level of // this repository contains the full copyright notices and license terms. import React, { FC, useState } from 'react'; import ReactSelect from 'react-select'; import { SelectProps } from './Select.types'; import { Field } from '../Select/Select.types'; import { getInitialValue, getOptions } from './Select.service'; import { getSelectedValue } from '../utils'; import { styleCustom } from './Select.utils'; import './Select.scss'; /** * @description Select - made for Formik * @param {function} eventEmitter * @param {FormikField} field * @param {boolean} isMulti - optionnal / default false * @returns Select component */ const Select: FC = ({ eventEmitter, field, isMulti = false, options, placeholder = null, disabled, width, height, minWidthMenu, }: SelectProps): JSX.Element => { const [localValue, setLocalValue] = useState(getInitialValue(field, isMulti, options)); const [localOptions, setLocalOptions] = useState(getOptions(options)); const changeHandler = (selectedOption: Field, actionMeta: Record) => { const value = getSelectedValue({ value: selectedOption, isMulti }); setLocalValue(selectedOption); eventEmitter(value, actionMeta); }; return (
); }; export default Select;