import _Select from "@alifd/next/es/select";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import * as React from "react";
var formateOptions = function formateOptions(options) {
  if (typeof options === 'function') {
    return options();
  }
  return options.map(function (item) {
    if (item.children) {
      var children = item.children.map(function (child) {
        return {
          label: child.title || child.label || '-',
          value: child.value,
          disabled: child.disabled || false
        };
      });
      return {
        label: item.title || item.label || '-',
        children: children
      };
    } else {
      return {
        label: item.title || item.label || '-',
        value: item.value,
        disabled: item.disabled || false
      };
    }
  });
};
var CSelectSetter = /*#__PURE__*/function (_React$PureComponent) {
  function CSelectSetter() {
    return _React$PureComponent.apply(this, arguments) || this;
  }
  _inheritsLoose(CSelectSetter, _React$PureComponent);
  var _proto = CSelectSetter.prototype;
  _proto.render = function render() {
    var _this$props = this.props,
      options = _this$props.options,
      _onChange = _this$props.onChange,
      mode = _this$props.mode,
      value = _this$props.value,
      showSearch = _this$props.showSearch;
    var str = value || "";
    return /*#__PURE__*/React.createElement(_Select, {
      autoWidth: false,
      size: "small",
      value: value,
      hasClear: true,
      dataSource: formateOptions(options),
      mode: mode,
      onChange: function onChange(val) {
        _onChange && _onChange(val);
      },
      style: {
        width: '100%'
      },
      showSearch: showSearch
    });
  };
  return CSelectSetter;
}(React.PureComponent);
CSelectSetter.displayName = "BlSelectSetter";
export { CSelectSetter as default };