import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

/**
 * Breadcrumb.jsx
 *
 * @Author: zhangce
 * @Date: 18/1/23 下午2:42
 */
import React, { Children, cloneElement, isValidElement } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
/**
 * Breadcrumb
 * */

var Breadcrumb =
/*#__PURE__*/
function (_React$PureComponent) {
  _inherits(Breadcrumb, _React$PureComponent);

  function Breadcrumb() {
    _classCallCheck(this, Breadcrumb);

    return _possibleConstructorReturn(this, _getPrototypeOf(Breadcrumb).apply(this, arguments));
  }

  _createClass(Breadcrumb, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          prefixCls = _this$props.prefixCls,
          className = _this$props.className,
          separator = _this$props.separator,
          children = _this$props.children,
          other = _objectWithoutProperties(_this$props, ["prefixCls", "className", "separator", "children"]);

      var classes = classNames(prefixCls, className);
      var items = Children.map(children, function (item) {
        if (isValidElement(item)) {
          return cloneElement(item, {
            separator: item.props.className || separator
          });
        }
      });
      return React.createElement("div", _extends({
        className: classes
      }, other), items);
    }
  }]);

  return Breadcrumb;
}(React.PureComponent);

_defineProperty(Breadcrumb, "propTypes", {
  /**
   * 类前缀
   * */
  prefixCls: PropTypes.string,

  /**
   * 分隔符
   * */
  separator: PropTypes.node
});

_defineProperty(Breadcrumb, "defaultProps", {
  prefixCls: 'ne-breadcrumb',
  separator: '/'
});

export default Breadcrumb;