"use strict";

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

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

var _Button = require("../../components/Button");

var _CloseIcon = _interopRequireDefault(require("mdi-react/CloseIcon"));

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

require("./index.css");

var _Spinner = _interopRequireDefault(require("../../components/Spinner"));

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

function getSubmitButtonText(submitButtonText, showSubmitButtonSpinner) {
  if (showSubmitButtonSpinner) {
    return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_Spinner.default, {
      size: "button"
    }), " ", submitButtonText);
  }

  return submitButtonText;
}

var DialogLayout = function DialogLayout(_ref) {
  var className = _ref.className,
      title = _ref.title,
      cancelButtonText = _ref.cancelButtonText,
      submitButtonText = _ref.submitButtonText,
      disableSubmit = _ref.disableSubmit,
      showSubmitButtonSpinner = _ref.showSubmitButtonSpinner,
      contentSize = _ref.contentSize,
      logo = _ref.logo,
      onCancel = _ref.onCancel,
      onSubmit = _ref.onSubmit,
      children = _ref.children;
  return _react.default.createElement("div", {
    className: (0, _classnames.default)("vs-dialog-layout", className)
  }, _react.default.createElement("div", {
    className: "vs-dialog-layout-header vs-dialog-layout-page-title"
  }, _react.default.createElement("div", {
    className: "vs-dialog-layout-logo-title-container"
  }, _react.default.createElement("div", {
    className: "vs-dialog-layout-logo-container"
  }, _react.default.createElement("span", {
    className: "vs-cj-logo"
  }, logo)), _react.default.createElement("h1", {
    className: "vs-dialog-layout-title"
  }, title)), _react.default.createElement("div", {
    className: "vs-dialog-layout-button-bar"
  }, cancelButtonText && _react.default.createElement(_Button.Button, {
    id: "vs-dialog-layout-cancel",
    type: "text",
    onClick: onCancel
  }, cancelButtonText), submitButtonText && _react.default.createElement(_Button.Button, {
    id: "vs-dialog-layout-submit",
    type: "solid-primary",
    disabled: disableSubmit === true,
    onClick: onSubmit
  }, getSubmitButtonText(submitButtonText, showSubmitButtonSpinner)), !submitButtonText && !cancelButtonText && _react.default.createElement(_CloseIcon.default, {
    className: "vs-dialog-layout-icon-close",
    onClick: onCancel
  }))), _react.default.createElement("div", {
    className: (0, _classnames.default)('vs-dialog-layout-content', "vs-dialog-layout-content-".concat(contentSize ? contentSize : 'normal'))
  }, children));
};

exports.DialogLayout = DialogLayout;
var _default = DialogLayout;
exports.default = _default;