"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; 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); }

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

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

var _propTypes = _interopRequireDefault(require("prop-types"));

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

var _mkuiFd = require("mkui-fd");

var _layout = _interopRequireDefault(require("../_layout"));

var _util = _interopRequireDefault(require("../_layout/util"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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 _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 _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

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

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

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

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

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; }

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

  var _super = _createSuper(Layout);

  function Layout() {
    var _this;

    _classCallCheck(this, Layout);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));

    _defineProperty(_assertThisInitialized(_this), "handleCancel", function (e) {
      var onCancel = _this.props.onCancel;

      if (onCancel) {
        onCancel(e);
      }
    });

    _defineProperty(_assertThisInitialized(_this), "handleOk", function (e) {
      var onOk = _this.props.onOk;

      if (onOk) {
        onOk(e);
      }
    });

    _defineProperty(_assertThisInitialized(_this), "renderFooter", function () {
      var _this$props = _this.props,
          prefixCls = _this$props.prefixCls,
          okText = _this$props.okText,
          cancelText = _this$props.cancelText,
          confirmLoading = _this$props.confirmLoading;
      return /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-footer")
      }, /*#__PURE__*/React.createElement(_mkuiFd.Button, {
        size: "large",
        type: "secondary",
        onClick: _this.handleCancel
      }, cancelText), /*#__PURE__*/React.createElement(_mkuiFd.Button, {
        size: "large",
        type: "primary",
        loading: confirmLoading,
        onClick: _this.handleOk,
        className: "mkui-btn-primary"
      }, okText));
    });

    _defineProperty(_assertThisInitialized(_this), "renderHeader", function () {
      var _this$props2 = _this.props,
          title = _this$props2.title,
          prefixCls = _this$props2.prefixCls,
          afterClose = _this$props2.afterClose;
      return /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-header")
      }, /*#__PURE__*/React.createElement("span", {
        className: "".concat(prefixCls, "-header-title")
      }, title), /*#__PURE__*/React.createElement("button", {
        className: "".concat(prefixCls, "-header-close")
      }, /*#__PURE__*/React.createElement("span", {
        className: "".concat(prefixCls, "-header-close-x")
      }, /*#__PURE__*/React.createElement(_mkuiFd.Icon, {
        className: "".concat(prefixCls, "-header-close-icon"),
        onClick: afterClose,
        type: 'close'
      }))));
    });

    return _this;
  }

  _createClass(Layout, [{
    key: "render",
    value: function render() {
      var _this$props3 = this.props,
          prefixCls = _this$props3.prefixCls,
          className = _this$props3.className,
          children = _this$props3.children;
      var divCls = (0, _classnames["default"])(className, prefixCls);
      return /*#__PURE__*/React.createElement("div", {
        className: divCls
      }, this.renderHeader(), /*#__PURE__*/React.createElement("div", {
        className: "".concat(prefixCls, "-body")
      }, children), this.renderFooter());
    }
  }]);

  return Layout;
}(React.PureComponent);

_defineProperty(Layout, "defaultProps", {
  prefixCls: 'mkui-layout-inner-modal',
  okText: '确定',
  cancelText: '取消'
});

_defineProperty(Layout, "propTypes", {
  prefixCls: _propTypes["default"].string,
  title: _propTypes["default"].node,
  afterClose: _propTypes["default"].func,
  onOk: _propTypes["default"].func,
  onCancel: _propTypes["default"].func,
  okText: _propTypes["default"].string,
  cancelText: _propTypes["default"].string
});

var Toolbar = (0, _util["default"])({
  prefixCls: 'mkui-layout-inner-modal-body-toolbar'
})(_layout["default"]);
var Content = (0, _util["default"])({
  prefixCls: 'mkui-layout-inner-modal-body-content'
})(_layout["default"]);
Layout.Toolbar = Toolbar;
Layout.Content = Content;
var _default = Layout;
exports["default"] = _default;
//# sourceMappingURL=LayoutInnerModal.js.map
