"use strict";

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

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

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

var _mobxReactLite = require("mobx-react-lite");

var _animate = _interopRequireDefault(require("../../../lib/animate"));

var _icon = _interopRequireDefault(require("../../../lib/icon"));

var ErrorBar = function ErrorBar(props) {
  var dataSet = props.dataSet,
      prefixCls = props.prefixCls;
  var error = dataSet.validationSelfErrors;
  var errorMessage = error && error.length ? error[0].message : undefined;

  var saveRef = function saveRef(node) {
    if (node) {
      node.focus();
    }
  };

  return /*#__PURE__*/_react["default"].createElement(_animate["default"], {
    transitionName: "slide-down",
    className: "".concat(prefixCls, "-error"),
    hiddenProp: "hidden",
    component: "div"
  }, errorMessage && /*#__PURE__*/_react["default"].createElement("div", {
    ref: saveRef,
    hidden: !errorMessage,
    className: "".concat(prefixCls, "-error-content"),
    tabIndex: -1
  }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
    type: "cancel"
  }), errorMessage), /*#__PURE__*/_react["default"].createElement(_icon["default"], {
    type: "close",
    onClick: function onClick() {
      return dataSet.clearValidationError();
    }
  })));
};

ErrorBar.displayName = 'ErrorBar';

var _default = (0, _mobxReactLite.observer)(ErrorBar);

exports["default"] = _default;
//# sourceMappingURL=ErrorBar.js.map
