"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _LocaleReceiver = _interopRequireDefault(require("../locale-provider/LocaleReceiver"));

var _warning = _interopRequireDefault(require("../_util/warning"));

var _treeSelect = _interopRequireWildcard(require("../rc-components/tree-select"));

var _enum = require("../_util/enum");

var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));

var _excluded = ["prefixCls", "className", "size", "notFoundContent", "dropdownStyle", "dropdownClassName"];

var TreeSelect = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(TreeSelect, _Component);

  var _super = (0, _createSuper2["default"])(TreeSelect);

  function TreeSelect(props) {
    var _this;

    (0, _classCallCheck2["default"])(this, TreeSelect);
    _this = _super.call(this, props);

    _this.saveTreeSelect = function (node) {
      _this.rcTreeSelect = node;
    };

    _this.renderTreeSelect = function (locale) {
      var _classNames;

      var _this$props = _this.props,
          customizePrefixCls = _this$props.prefixCls,
          className = _this$props.className,
          size = _this$props.size,
          notFoundContent = _this$props.notFoundContent,
          dropdownStyle = _this$props.dropdownStyle,
          dropdownClassName = _this$props.dropdownClassName,
          restProps = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
      var getPrefixCls = _this.context.getPrefixCls;
      var prefixCls = getPrefixCls('select', customizePrefixCls);
      var cls = (0, _classnames["default"])((_classNames = {}, (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-lg"), size === _enum.Size.large), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-sm"), size === _enum.Size.small), _classNames), className);
      var checkable = restProps.treeCheckable;

      if (checkable) {
        checkable = /*#__PURE__*/_react["default"].createElement("span", {
          className: "".concat(prefixCls, "-tree-checkbox-inner")
        });
      }

      return /*#__PURE__*/_react["default"].createElement(_treeSelect["default"], (0, _extends2["default"])({}, restProps, {
        dropdownClassName: (0, _classnames["default"])(dropdownClassName, "".concat(prefixCls, "-tree-dropdown")),
        prefixCls: prefixCls,
        className: cls,
        dropdownStyle: (0, _objectSpread2["default"])({
          maxHeight: '100vh',
          overflow: 'auto'
        }, dropdownStyle),
        treeCheckable: checkable,
        notFoundContent: notFoundContent || locale.notFoundContent,
        ref: _this.saveTreeSelect
      }));
    };

    (0, _warning["default"])(props.multiple !== false || !props.treeCheckable, '`multiple` will alway be `true` when `treeCheckable` is true');
    return _this;
  }

  (0, _createClass2["default"])(TreeSelect, [{
    key: "focus",
    value: function focus() {
      this.rcTreeSelect.focus();
    }
  }, {
    key: "blur",
    value: function blur() {
      this.rcTreeSelect.blur();
    }
  }, {
    key: "render",
    value: function render() {
      return /*#__PURE__*/_react["default"].createElement(_LocaleReceiver["default"], {
        componentName: "Select",
        defaultLocale: {}
      }, this.renderTreeSelect);
    }
  }], [{
    key: "contextType",
    get: function get() {
      return _ConfigContext["default"];
    }
  }]);
  return TreeSelect;
}(_react.Component);

exports["default"] = TreeSelect;
TreeSelect.displayName = 'TreeSelect';
TreeSelect.TreeNode = _treeSelect.TreeNode;
TreeSelect.SHOW_ALL = _treeSelect.SHOW_ALL;
TreeSelect.SHOW_PARENT = _treeSelect.SHOW_PARENT;
TreeSelect.SHOW_CHILD = _treeSelect.SHOW_CHILD;
TreeSelect.defaultProps = {
  transitionName: 'slide-up',
  choiceTransitionName: 'zoom',
  showSearch: false
};
//# sourceMappingURL=index.js.map
