"use strict";

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

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

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

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

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

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

var _context = require("../config-provider/context");

var Divider = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
  var customizePrefix = props.prefix,
      className = props.className,
      direction = props.direction,
      dashed = props.dashed,
      spacing = props.spacing,
      style = props.style;

  var _React$useContext = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var dividerCls = getPrefixClassName('divider', customizePrefix);
  var cls = (0, _classnames.default)(dividerCls, "".concat(dividerCls, "-").concat(direction), className, (0, _defineProperty2.default)({}, "".concat(dividerCls, "-dashed"), dashed));
  var endPorps = {
    className: cls,
    style: style
  };
  var dividerStyle = {};

  if ('length' in props) {
    if (direction === 'row') {
      dividerStyle.width = props.length;
      dividerStyle.marginTop = props.spacing;
      dividerStyle.marginBottom = props.spacing;
    } else {
      dividerStyle.height = props.length;
      dividerStyle.marginLeft = props.spacing;
      dividerStyle.marginRight = props.spacing;
    }

    endPorps.style = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, dividerStyle), style);
  }

  return /*#__PURE__*/_react.default.createElement("div", Object.assign({
    ref: ref
  }, endPorps));
});

Divider.defaultProps = {
  direction: 'row'
};
var _default = Divider;
exports.default = _default;