function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _extends() { _extends = Object.assign || 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); }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Select from '../select';
import Cascader from '../cascader';
import Menu from '../menu';
import { func, obj, dom, KEYCODE } from '../util';
var bindCtx = func.bindCtx;
var pickOthers = obj.pickOthers;
var getStyle = dom.getStyle;
/**
 * CascaderSelect
 */

var CascaderSelect =
/*#__PURE__*/
function (_Component) {
  _inherits(CascaderSelect, _Component);

  function CascaderSelect(props, context) {
    var _this;

    _classCallCheck(this, CascaderSelect);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(CascaderSelect).call(this, props, context));
    _this.state = {
      value: _this.normalizeValue('value' in props ? props.value : props.defaultValue),
      searchValue: '',
      visible: typeof props.visible === 'undefined' ? props.defaultVisible : props.visible
    };
    bindCtx(_assertThisInitialized(_this), ['handleVisibleChange', 'handleAfterOpen', 'handleChange', 'handleClear', 'handleRemove', 'handleSearch', 'getPopup', 'saveSelectRef', 'saveCascaderRef', 'handleKeyDown']);
    return _this;
  }

  _createClass(CascaderSelect, [{
    key: "UNSAFE_componentWillReceiveProps",
    value: function UNSAFE_componentWillReceiveProps(nextProps) {
      var st = {};

      if ('value' in nextProps) {
        st.value = this.normalizeValue(nextProps.value);
      }

      if ('visible' in nextProps) {
        st.visible = nextProps.visible;
      }

      if (Object.keys(st).length) {
        this.setState(st);
      }
    }
  }, {
    key: "normalizeValue",
    value: function normalizeValue(value) {
      if (value) {
        if (Array.isArray(value)) {
          return value;
        }

        return [value];
      }

      return [];
    }
  }, {
    key: "updateCache",
    value: function updateCache(dataSource) {
      var _this2 = this;

      this._v2n = {};
      this._p2n = {};

      var loop = function loop(data) {
        var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0';
        return data.forEach(function (item, index) {
          var value = item.value,
              children = item.children;
          var pos = "".concat(prefix, "-").concat(index);
          _this2._v2n[value] = _this2._p2n[pos] = _objectSpread({}, item, {
            pos: pos
          });

          if (children && children.length) {
            loop(children, pos);
          }
        });
      };

      loop(dataSource);
    }
  }, {
    key: "flatValue",
    value: function flatValue(value) {
      var _this3 = this;

      var getDepth = function getDepth(v) {
        var pos = _this3.getPos(v);

        if (!pos) {
          return 0;
        }

        return pos.split('-').length;
      };

      var newValue = value.slice(0).sort(function (prev, next) {
        return getDepth(prev) - getDepth(next);
      });

      for (var i = 0; i < newValue.length; i++) {
        for (var j = 0; j < newValue.length; j++) {
          if (i !== j && this.isDescendantOrSelf(this.getPos(newValue[i]), this.getPos(newValue[j]))) {
            newValue.splice(j, 1);
            j--;
          }
        }
      }

      return newValue;
    }
  }, {
    key: "isDescendantOrSelf",
    value: function isDescendantOrSelf(currentPos, targetPos) {
      if (!currentPos || !targetPos) {
        return false;
      }

      var currentNums = currentPos.split('-');
      var targetNums = targetPos.split('-');
      return currentNums.length <= targetNums.length && currentNums.every(function (num, index) {
        return num === targetNums[index];
      });
    }
  }, {
    key: "getValue",
    value: function getValue(pos) {
      return this._p2n[pos] ? this._p2n[pos].value : null;
    }
  }, {
    key: "getPos",
    value: function getPos(value) {
      return this._v2n[value] ? this._v2n[value].pos : null;
    }
  }, {
    key: "getData",
    value: function getData(value) {
      var _this4 = this;

      return value.map(function (v) {
        return _this4._v2n[v];
      });
    }
  }, {
    key: "getLabelPath",
    value: function getLabelPath(data) {
      var _this5 = this;

      var nums = data.pos.split('-');
      return nums.slice(1).reduce(function (ret, num, index) {
        var p = nums.slice(0, index + 2).join('-');
        ret.push(_this5._p2n[p].label);
        return ret;
      }, []);
    }
  }, {
    key: "getSignleData",
    value: function getSignleData(value) {
      if (!value.length) {
        return null;
      }

      if (Array.isArray(value)) value = value[0];
      var data = this._v2n[value];

      if (!data) {
        return {
          value: value
        };
      }

      var labelPath = this.getLabelPath(data);

      var displayRender = this.props.displayRender || function (labels) {
        return labels.join(' / ');
      };

      return _objectSpread({}, data, {
        label: displayRender(labelPath, data)
      });
    }
  }, {
    key: "getMultipleData",
    value: function getMultipleData(value) {
      var _this6 = this;

      if (!value.length) {
        return null;
      }

      var _this$props = this.props,
          checkStrictly = _this$props.checkStrictly,
          canOnlyCheckLeaf = _this$props.canOnlyCheckLeaf,
          displayRender = _this$props.displayRender;
      var data = (checkStrictly || canOnlyCheckLeaf ? value : this.flatValue(value)).map(function (v) {
        return _this6._v2n[v] || {
          value: v
        };
      });

      if (displayRender) {
        data = data.map(function (item) {
          if (!item.pos) {
            return item;
          }

          var labelPath = _this6.getLabelPath(item);

          return _objectSpread({}, item, {
            label: displayRender(labelPath, item)
          });
        });
      }

      return data;
    }
  }, {
    key: "getIndeterminate",
    value: function getIndeterminate(value) {
      var _this7 = this;

      var indeterminate = [];
      var positions = value.map(this.getPos.bind(this));
      positions.forEach(function (pos) {
        if (!pos) {
          return false;
        }

        var nums = pos.split('-');

        for (var i = nums.length; i > 2; i--) {
          var parentPos = nums.slice(0, i - 1).join('-');

          var parentValue = _this7.getValue(parentPos);

          if (indeterminate.indexOf(parentValue) === -1) {
            indeterminate.push(parentValue);
          }
        }
      });
      return indeterminate;
    }
  }, {
    key: "saveSelectRef",
    value: function saveSelectRef(ref) {
      this.select = ref;
    }
  }, {
    key: "saveCascaderRef",
    value: function saveCascaderRef(ref) {
      this.cascader = ref;
    }
  }, {
    key: "completeValue",
    value: function completeValue(value) {
      var newValue = [];
      var flatValue = this.flatValue(value).reverse();
      var ps = Object.keys(this._p2n);

      for (var i = 0; i < ps.length; i++) {
        for (var j = 0; j < flatValue.length; j++) {
          var v = flatValue[j];

          if (this.isDescendantOrSelf(this.getPos(v), ps[i])) {
            newValue.push(this.getValue(ps[i]));
            ps.splice(i, 1);
            i--;
            break;
          }
        }
      }

      return newValue;
    }
  }, {
    key: "isLeaf",
    value: function isLeaf(data) {
      return !(data.children && data.children.length || !!this.props.loadData && !data.isLeaf);
    }
  }, {
    key: "handleVisibleChange",
    value: function handleVisibleChange(visible, type) {
      if (!('visible' in this.props)) {
        this.setState({
          visible: visible
        });
      }

      if (['fromCascader', 'keyboard'].indexOf(type) !== -1 && !visible) {
        this.select.focusInput();
      }

      this.props.onVisibleChange(visible, type);
    }
  }, {
    key: "handleKeyDown",
    value: function handleKeyDown(e) {
      var onKeyDown = this.props.onKeyDown;
      var visible = this.state.visible;

      if (onKeyDown) {
        onKeyDown(e);
      }

      if (!visible) {
        return;
      }

      switch (e.keyCode) {
        case KEYCODE.UP:
        case KEYCODE.DOWN:
          this.cascader.setFocusValue();
          e.preventDefault();
          break;

        default:
          break;
      }
    }
  }, {
    key: "getPopup",
    value: function getPopup(ref) {
      this.popup = ref;

      if (typeof this.props.popupProps.ref === 'function') {
        this.props.popupProps.ref(ref);
      }
    }
  }, {
    key: "handleAfterOpen",
    value: function handleAfterOpen() {
      if (!this.popup) {
        return;
      }

      var _this$props2 = this.props,
          prefix = _this$props2.prefix,
          popupProps = _this$props2.popupProps;
      var dropDownNode = this.popup.getInstance().overlay.getInstance().getContentNode();
      var cascaderNode = dropDownNode.querySelector(".".concat(prefix, "cascader"));

      if (cascaderNode) {
        this.cascaderHeight = getStyle(cascaderNode, 'height');
      }

      if (typeof popupProps.afterOpen === 'function') {
        popupProps.afterOpen();
      }
    }
  }, {
    key: "handleChange",
    value: function handleChange(value, data, extra) {
      var _this$props3 = this.props,
          multiple = _this$props3.multiple,
          changeOnSelect = _this$props3.changeOnSelect,
          onChange = _this$props3.onChange;
      var _this$state = this.state,
          visible = _this$state.visible,
          searchValue = _this$state.searchValue;
      var st = {};

      if (!multiple && (!changeOnSelect || this.isLeaf(data) || !!searchValue)) {
        this.handleVisibleChange(!visible, 'fromCascader');
      }

      if (!('value' in this.props)) {
        st.value = value;
      }

      if (!multiple && searchValue) {
        st.searchValue = '';
      }

      if (Object.keys(st).length) {
        this.setState(st);
      }

      if (onChange) {
        onChange(value, data, extra);
      }

      if (searchValue && this.select) {
        this.select.handleSearchClear();
      }
    }
  }, {
    key: "handleClear",
    value: function handleClear() {
      // 单选时点击清空按钮
      var _this$props4 = this.props,
          hasClear = _this$props4.hasClear,
          multiple = _this$props4.multiple,
          treeCheckable = _this$props4.treeCheckable;

      if (hasClear && (!multiple || !treeCheckable)) {
        if (!('value' in this.props)) {
          this.setState({
            value: []
          });
        }

        this.props.onChange(null, null);
      }
    }
  }, {
    key: "handleRemove",
    value: function handleRemove(currentData) {
      var currentValue = currentData.value;
      var value;
      var _this$props5 = this.props,
          multiple = _this$props5.multiple,
          checkStrictly = _this$props5.checkStrictly,
          onChange = _this$props5.onChange;

      if (multiple) {
        value = _toConsumableArray(this.state.value);
        value.splice(value.indexOf(currentValue), 1);

        if (this.props.onChange) {
          var data = this.getData(value);
          var checked = false;

          if (checkStrictly) {
            this.props.onChange(value, data, {
              checked: checked,
              currentData: currentData,
              checkedData: data
            });
          } else {
            var checkedValue = this.completeValue(value);
            var checkedData = this.getData(checkedValue);
            var indeterminateValue = this.getIndeterminate(value);
            var indeterminateData = this.getData(indeterminateValue);
            this.props.onChange(value, data, {
              checked: checked,
              currentData: currentData,
              checkedData: checkedData,
              indeterminateData: indeterminateData
            });
          }
        }
      } else {
        value = [];
        onChange(null, null);
      }

      if (!('value' in this.props)) {
        this.setState({
          value: value
        });
      }
    }
  }, {
    key: "handleSearch",
    value: function handleSearch(searchValue) {
      this.setState({
        searchValue: searchValue
      });
    }
  }, {
    key: "getPath",
    value: function getPath(pos) {
      var items = [];
      var nums = pos.split('-');

      if (nums === 2) {
        items.push(this._p2n[pos]);
      } else {
        for (var i = 1; i < nums.length; i++) {
          var p = nums.slice(0, i + 1).join('-');
          items.push(this._p2n[p]);
        }
      }

      return items;
    }
  }, {
    key: "filterItems",
    value: function filterItems() {
      var _this8 = this;

      var _this$props6 = this.props,
          multiple = _this$props6.multiple,
          changeOnSelect = _this$props6.changeOnSelect,
          canOnlyCheckLeaf = _this$props6.canOnlyCheckLeaf,
          filter = _this$props6.filter;
      var searchValue = this.state.searchValue;
      var items = Object.keys(this._p2n).map(function (p) {
        return _this8._p2n[p];
      });

      if (!multiple && !changeOnSelect || multiple && canOnlyCheckLeaf) {
        items = items.filter(function (item) {
          return !item.children || !item.children.length;
        });
      }

      return items.map(function (item) {
        return _this8.getPath(item.pos);
      }).filter(function (path) {
        return filter(searchValue, path);
      });
    }
  }, {
    key: "renderNotFound",
    value: function renderNotFound() {
      var _this$props7 = this.props,
          prefix = _this$props7.prefix,
          notFoundContent = _this$props7.notFoundContent;
      return React.createElement(Menu, {
        className: "".concat(prefix, "cascader-select-not-found")
      }, React.createElement(Menu.Item, null, notFoundContent));
    }
  }, {
    key: "renderCascader",
    value: function renderCascader() {
      var dataSource = this.props.dataSource;

      if (dataSource.length === 0) {
        return this.renderNotFound();
      }

      var searchValue = this.state.searchValue;
      var filteredPaths = [];

      if (searchValue) {
        filteredPaths = this.filterItems();

        if (filteredPaths.length === 0) {
          return this.renderNotFound();
        }
      }

      var _this$props8 = this.props,
          multiple = _this$props8.multiple,
          useVirtual = _this$props8.useVirtual,
          changeOnSelect = _this$props8.changeOnSelect,
          checkStrictly = _this$props8.checkStrictly,
          canOnlyCheckLeaf = _this$props8.canOnlyCheckLeaf,
          defaultExpandedValue = _this$props8.defaultExpandedValue,
          expandTriggerType = _this$props8.expandTriggerType,
          onExpand = _this$props8.onExpand,
          listStyle = _this$props8.listStyle,
          listClassName = _this$props8.listClassName,
          loadData = _this$props8.loadData,
          showSearch = _this$props8.showSearch,
          resultRender = _this$props8.resultRender,
          readOnly = _this$props8.readOnly,
          itemRender = _this$props8.itemRender;
      var value = this.state.value;
      var props = {
        dataSource: dataSource,
        value: value,
        multiple: multiple,
        useVirtual: useVirtual,
        canOnlySelectLeaf: !changeOnSelect,
        checkStrictly: checkStrictly,
        canOnlyCheckLeaf: canOnlyCheckLeaf,
        defaultExpandedValue: defaultExpandedValue,
        expandTriggerType: expandTriggerType,
        ref: this.saveCascaderRef,
        onExpand: onExpand,
        listStyle: listStyle,
        listClassName: listClassName,
        loadData: loadData,
        itemRender: itemRender
      };

      if (!readOnly) {
        props.onChange = this.handleChange;
      }

      if (showSearch) {
        props.searchValue = searchValue;
        props.filteredPaths = filteredPaths;
        props.resultRender = resultRender;
        props.filteredListStyle = {
          height: this.cascaderHeight
        };
      }

      return React.createElement(Cascader, props);
    }
  }, {
    key: "renderPopupContent",
    value: function renderPopupContent() {
      var _this$props9 = this.props,
          prefix = _this$props9.prefix,
          header = _this$props9.header,
          footer = _this$props9.footer;
      return React.createElement("div", {
        className: "".concat(prefix, "cascader-select-dropdown")
      }, header, this.renderCascader(), footer);
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props10 = this.props,
          prefix = _this$props10.prefix,
          size = _this$props10.size,
          hasArrow = _this$props10.hasArrow,
          hasBorder = _this$props10.hasBorder,
          hasClear = _this$props10.hasClear,
          label = _this$props10.label,
          readOnly = _this$props10.readOnly,
          placeholder = _this$props10.placeholder,
          dataSource = _this$props10.dataSource,
          disabled = _this$props10.disabled,
          multiple = _this$props10.multiple,
          className = _this$props10.className,
          showSearch = _this$props10.showSearch,
          popupStyle = _this$props10.popupStyle,
          popupClassName = _this$props10.popupClassName,
          popupContainer = _this$props10.popupContainer,
          popupProps = _this$props10.popupProps,
          followTrigger = _this$props10.followTrigger;
      var _this$state2 = this.state,
          value = _this$state2.value,
          searchValue = _this$state2.searchValue,
          visible = _this$state2.visible;
      var others = pickOthers(Object.keys(CascaderSelect.propTypes), this.props);
      var popupContent = this.renderPopupContent();
      this.updateCache(dataSource);
      var props = {
        prefix: prefix,
        className: className,
        size: size,
        placeholder: placeholder,
        disabled: disabled,
        hasArrow: hasArrow,
        hasBorder: hasBorder,
        hasClear: hasClear,
        label: label,
        readOnly: readOnly,
        ref: this.saveSelectRef,
        autoWidth: false,
        mode: multiple ? 'multiple' : 'single',
        value: multiple ? this.getMultipleData(value) : this.getSignleData(value),
        onChange: this.handleClear,
        onRemove: this.handleRemove,
        visible: visible,
        onVisibleChange: this.handleVisibleChange,
        showSearch: showSearch,
        // searchValue,
        onSearch: this.handleSearch,
        onKeyDown: this.handleKeyDown,
        popupContent: popupContent,
        popupStyle: popupStyle,
        popupClassName: popupClassName,
        popupContainer: popupContainer,
        popupProps: popupProps,
        followTrigger: followTrigger
      };

      if (showSearch) {
        props.popupProps = _objectSpread({}, popupProps, {
          ref: this.getPopup,
          afterOpen: this.handleAfterOpen
        });
        props.autoWidth = showSearch && !!searchValue;
      }

      return React.createElement(Select, _extends({}, props, others));
    }
  }]);

  return CascaderSelect;
}(Component);

_defineProperty(CascaderSelect, "propTypes", {
  prefix: PropTypes.string,
  pure: PropTypes.bool,
  className: PropTypes.string,

  /**
   * 选择框大小
   */
  size: PropTypes.oneOf(['small', 'medium', 'large']),

  /**
   * 选择框占位符
   */
  placeholder: PropTypes.string,

  /**
   * 是否禁用
   */
  disabled: PropTypes.bool,

  /**
   * 是否有下拉箭头
   */
  hasArrow: PropTypes.bool,

  /**
   * 是否有边框
   */
  hasBorder: PropTypes.bool,

  /**
   * 是否有清除按钮
   */
  hasClear: PropTypes.bool,

  /**
   * 自定义内联 label
   */
  label: PropTypes.node,

  /**
   * 是否只读，只读模式下可以展开弹层但不能选
   */
  readOnly: PropTypes.bool,

  /**
   * 数据源，结构可参考下方说明
   */
  dataSource: PropTypes.arrayOf(PropTypes.object),

  /**
   * （非受控）默认值
   */
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),

  /**
   * （受控）当前值
   */
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),

  /**
   * 选中值改变时触发的回调函数
   * @param {String|Array} value 选中的值，单选时返回单个值，多选时返回数组
   * @param {Object|Array} data 选中的数据，包括 value 和 label，单选时返回单个值，多选时返回数组，父子节点选中关联时，同时选中，只返回父节点
   * @param {Object} extra 额外参数
   * @param {Array} extra.selectedPath 单选时选中的数据的路径
   * @param {Boolean} extra.checked 多选时当前的操作是选中还是取消选中
   * @param {Object} extra.currentData 多选时当前操作的数据
   * @param {Array} extra.checkedData 多选时所有被选中的数据
   * @param {Array} extra.indeterminateData 多选时半选的数据
   */
  onChange: PropTypes.func,

  /**
   * 默认展开值，如果不设置，组件内部会根据 defaultValue/value 进行自动设置
   */
  defaultExpandedValue: PropTypes.arrayOf(PropTypes.string),

  /**
   * 展开触发的方式
   */
  expandTriggerType: PropTypes.oneOf(['click', 'hover']),
  onExpand: PropTypes.func,

  /**
   * 是否开启虚拟滚动
   */
  useVirtual: PropTypes.bool,

  /**
   * 是否多选
   */
  multiple: PropTypes.bool,

  /**
   * 是否选中即发生改变, 该属性仅在单选模式下有效
   */
  changeOnSelect: PropTypes.bool,

  /**
   * 是否只能勾选叶子项的checkbox，该属性仅在多选模式下有效
   */
  canOnlyCheckLeaf: PropTypes.bool,

  /**
   * 父子节点是否选中不关联
   */
  checkStrictly: PropTypes.bool,

  /**
   * 每列列表样式对象
   */
  listStyle: PropTypes.object,

  /**
   * 每列列表类名
   */
  listClassName: PropTypes.string,

  /**
   * 选择框单选时展示结果的自定义渲染函数
   * @param {Array} label 选中路径的文本数组
   * @return {ReactNode} 渲染在选择框中的内容
   * @default 单选时：labelPath => labelPath.join(' / ')；多选时：labelPath => labelPath[labelPath.length - 1]
   */
  displayRender: PropTypes.func,

  /**
   * 渲染 item 内容的方法
   * @param {Object} item 渲染节点的item
   * @return {ReactNode} item node
   */
  itemRender: PropTypes.func,

  /**
   * 是否显示搜索框
   */
  showSearch: PropTypes.bool,

  /**
   * 自定义搜索函数
   * @param {String} searchValue 搜索的关键字
   * @param {Array} path 节点路径
   * @return {Boolean} 是否匹配
   * @default 根据路径所有节点的文本值模糊匹配
   */
  filter: PropTypes.func,

  /**
   * 搜索结果自定义渲染函数
   * @param {String} searchValue 搜索的关键字
   * @param {Array} path 匹配到的节点路径
   * @return {ReactNode} 渲染的内容
   * @default 按照节点文本 a / b / c 的模式渲染
   */
  resultRender: PropTypes.func,

  /**
   * 搜索结果列表是否和选择框等宽
   */
  resultAutoWidth: PropTypes.bool,

  /**
   * 无数据时显示内容
   */
  notFoundContent: PropTypes.node,

  /**
   * 异步加载数据函数
   * @param {Object} data 当前点击异步加载的数据
   */
  loadData: PropTypes.func,

  /**
   * 自定义下拉框头部
   */
  header: PropTypes.node,

  /**
   * 自定义下拉框底部
   */
  footer: PropTypes.node,

  /**
   * 初始下拉框是否显示
   */
  defaultVisible: PropTypes.bool,

  /**
   * 当前下拉框是否显示
   */
  visible: PropTypes.bool,

  /**
   * 下拉框显示或关闭时触发事件的回调函数
   * @param {Boolean} visible 是否显示
   * @param {String} type 触发显示关闭的操作类型, fromTrigger 表示由trigger的点击触发； docClick 表示由document的点击触发
   */
  onVisibleChange: PropTypes.func,

  /**
   * 下拉框自定义样式对象
   */
  popupStyle: PropTypes.object,

  /**
   * 下拉框样式自定义类名
   */
  popupClassName: PropTypes.string,

  /**
   * 下拉框挂载的容器节点
   */
  popupContainer: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),

  /**
   * 透传到 Popup 的属性对象
   */
  popupProps: PropTypes.object,

  /**
   * 是否跟随滚动
   */
  followTrigger: PropTypes.bool
});

_defineProperty(CascaderSelect, "defaultProps", {
  prefix: 'next-',
  pure: false,
  size: 'medium',
  disabled: false,
  hasArrow: true,
  hasBorder: true,
  hasClear: false,
  dataSource: [],
  defaultValue: null,
  expandTriggerType: 'click',
  onExpand: function onExpand() {},
  useVirtual: false,
  multiple: false,
  changeOnSelect: false,
  canOnlyCheckLeaf: false,
  checkStrictly: false,
  showSearch: false,
  filter: function filter(searchValue, path) {
    return path.some(function (item) {
      return item.label.indexOf(searchValue) > -1;
    });
  },
  resultRender: function resultRender(searchValue, path) {
    var parts = [];
    path.forEach(function (item, i) {
      var others = item.label.split(searchValue);
      others.forEach(function (other, j) {
        if (other) {
          parts.push(other);
        }

        if (j < others.length - 1) {
          parts.push(React.createElement("em", {
            key: "".concat(i, "-").concat(j)
          }, searchValue));
        }
      });

      if (i < path.length - 1) {
        parts.push(' / ');
      }
    });
    return React.createElement("span", null, parts);
  },
  resultAutoWidth: true,
  notFoundContent: 'Not Found',
  defaultVisible: false,
  onVisibleChange: function onVisibleChange() {},
  popupProps: {}
});

export { CascaderSelect as default };