import React, { useRef } from 'react';
import { Select } from 'antd';
import { onBlurFn } from '../onBlurFn';
import { ApolloSelectProps } from '../editInterface';
import { antiAssign } from '../../../../utils/utils';
import styles from './styles.less';
export const ApolloSelect = (props: ApolloSelectProps) => {
const { options = [], onChange, isMultiple, origin } = props;
const selfProps = antiAssign(props, ['columnConfig', 'onChange', 'isMultiple', 'options']);
const isOpen = useRef();
if (isMultiple) {
selfProps.mode = 'multiple';
}
const changeValue = (value: any, option: any) => {
if (typeof onChange === 'function') {
if (typeof onBlurFn === 'function' && !isOpen.current) {
onBlurFn({ ...props, value });
}
onChange(value, option);
}
};
const singleBlurFn = (e: boolean) => {
isOpen.current = e;
};
const multipleBlurFn = (e: boolean) => {
isOpen.current = e;
if (typeof onBlurFn === 'function' && !e) {
onBlurFn(props);
}
};
return (origin === 'editForm' ?
:
);
};