'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var reactDom = require('react-dom');
var index = require('../index-8029e07a.js');
var LocalizationContext = require('../LocalizationContext-8cc9717d.js');
var ui_Button = require('./Button.js');
var ui_Icon = require('./Icon.js');
var ui_IconButton = require('./IconButton.js');
var ui_Label = require('../index-35633fb6.js');
var MediaQueryContext = require('../MediaQueryContext-fad211ad.js');
require('../stringSet-ce782136.js');
require('../index-d749c4c2.js');
require('prop-types');
require('../_rollupPluginBabelHelpers-acf412a3.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const ModalHeader = _ref => {
  let {
    titleText
  } = _ref;
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__header"
  }, /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.H_1,
    color: ui_Label.LabelColors.ONBACKGROUND_1
  }, titleText));
};
const ModalBody = _ref2 => {
  let {
    children
  } = _ref2;
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__body"
  }, /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.SUBTITLE_1,
    color: ui_Label.LabelColors.ONBACKGROUND_2
  }, children));
};
const ModalFooter = _ref3 => {
  let {
    submitText,
    disabled = false,
    type = ui_Button.ButtonTypes.DANGER,
    onSubmit,
    onCancel
  } = _ref3;
  const {
    stringSet
  } = React.useContext(LocalizationContext.LocalizationContext);
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__footer"
  }, /*#__PURE__*/React__default["default"].createElement(ui_Button["default"], {
    type: ui_Button.ButtonTypes.SECONDARY,
    onClick: onCancel
  }, /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.BUTTON_1,
    color: ui_Label.LabelColors.ONBACKGROUND_1
  }, stringSet.BUTTON__CANCEL)), /*#__PURE__*/React__default["default"].createElement(ui_Button["default"], {
    type: type,
    disabled: disabled,
    onClick: onSubmit
  }, submitText));
};
function Modal(props) {
  const {
    children = null,
    className = '',
    isCloseOnClickOutside = false,
    isFullScreenOnMobile = false,
    titleText,
    submitText,
    disabled = false,
    hideFooter = false,
    type = ui_Button.ButtonTypes.DANGER,
    onCancel = () => {/* noop */},
    onSubmit = () => {/* noop */},
    renderHeader
  } = props;
  const {
    isMobile
  } = MediaQueryContext.useMediaQueryContext();
  return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement("div", {
    className: `
      sendbird-modal ${className}
      ${isFullScreenOnMobile && isMobile ? 'sendbird-modal--full-mobile' : ''}
    `
  }, /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__content"
  }, (renderHeader === null || renderHeader === void 0 ? void 0 : renderHeader()) || /*#__PURE__*/React__default["default"].createElement(ModalHeader, {
    titleText: titleText
  }), /*#__PURE__*/React__default["default"].createElement(ModalBody, null, children), !hideFooter && /*#__PURE__*/React__default["default"].createElement(ModalFooter, {
    disabled: disabled,
    onCancel: onCancel,
    onSubmit: onSubmit,
    submitText: submitText,
    type: type
  }), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__close"
  }, /*#__PURE__*/React__default["default"].createElement(ui_IconButton, {
    width: "32px",
    height: "32px",
    onClick: onCancel
  }, /*#__PURE__*/React__default["default"].createElement(ui_Icon["default"], {
    type: ui_Icon.IconTypes.CLOSE,
    fillColor: ui_Icon.IconColors.DEFAULT,
    width: "24px",
    height: "24px"
  })))), /*#__PURE__*/React__default["default"].createElement("div", {
    className: `
          sendbird-modal__backdrop
          ${isCloseOnClickOutside && 'sendbird-modal__backdrop--clickoutside'}
        `,
    onClick: e => {
      e === null || e === void 0 ? void 0 : e.stopPropagation();
      if (isCloseOnClickOutside) {
        onCancel();
      }
    }
  })), document.getElementById(index.MODAL_ROOT));
}

exports.ModalBody = ModalBody;
exports.ModalFooter = ModalFooter;
exports.ModalHeader = ModalHeader;
exports["default"] = Modal;
//# sourceMappingURL=Modal.js.map
