2022-05-16 19:44:42 +03:00

41 lines
911 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { SelectProps } from 'antd';
import { Form, Select } from 'antd';
import type { BaseElementProps, BaseOption } from './types';
const { Item: FormItem } = Form;
type ElementProps = BaseElementProps<string | null> & {
options: BaseOption[];
};
export default function Element({
value = null,
setValue,
options,
status,
isValid,
help,
...props
}: ElementProps) {
return (
<FormItem hasFeedback validateStatus={isValid === false ? 'error' : ''} help={help}>
<Select
defaultValue={value}
onChange={(val) => setValue(val)}
disabled={status === 'Disabled'}
loading={status === 'Loading'}
optionFilterProp="children"
options={[
{
label: 'Не выбрано',
value: null,
},
].concat(options)}
{...props}
/>
</FormItem>
);
}
export type { SelectProps };