function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import { forwardRef, useImperativeHandle } from 'react';
import { Select } from 'antd';
var MaxLengthSelect = function MaxLengthSelect(props, ref) {
  useImperativeHandle(ref, function () {
    return {
      onChange: handleChange
    };
  });
  var handleChange = function handleChange(e, _option) {
    if (props.onChange) {
      if ((props.mode === 'multiple' || props.mode === 'tags') && props.maxLength) {
        if (props.value && props.value.length >= props.maxLength && e.length > props.value.length) {
          return;
        }
      }
      props.onChange(e, _option);
    }
  };
  return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
    onChange: handleChange,
    popupMatchSelectWidth: false
    // getPopupContainer={() => document.querySelector('#main') || document.body}
  }), props.children);
};
export default /*#__PURE__*/forwardRef(MaxLengthSelect);