function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React, { forwardRef } from 'react';
import getButtonVisible from "./getButtonVisible";
import Cancel from "./Cancel";
import Ok from "./Ok";
import Title from "./Title";
var Head = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var title = _ref.title,
    titleProps = _ref.titleProps,
    ok = _ref.ok,
    onOk = _ref.onOk,
    okProps = _ref.okProps,
    cancel = _ref.cancel,
    onCancel = _ref.onCancel,
    cancelProps = _ref.cancelProps;
  // 只显示标题
  if (cancel === null && ok === null) {
    return /*#__PURE__*/React.createElement("div", {
      className: "modal-navbar",
      ref: ref
    }, /*#__PURE__*/React.createElement(Title, _extends({
      title: title
    }, titleProps)));
  }

  // 带按钮
  return /*#__PURE__*/React.createElement("div", {
    className: "modal-navbar",
    ref: ref
  }, /*#__PURE__*/React.createElement("div", {
    className: "modal-navbar-button left"
  }, getButtonVisible(ok) && getButtonVisible(cancel) ? /*#__PURE__*/React.createElement(Cancel, _extends({
    text: cancel,
    onClick: onCancel
  }, cancelProps)) : null), /*#__PURE__*/React.createElement(Title, _extends({
    title: title
  }, titleProps)), /*#__PURE__*/React.createElement("div", {
    className: "modal-navbar-button right"
  }, !getButtonVisible(ok) && getButtonVisible(cancel) ? /*#__PURE__*/React.createElement(Cancel, _extends({
    text: cancel,
    onClick: onCancel
  }, cancelProps)) : null, getButtonVisible(ok) && /*#__PURE__*/React.createElement(Ok, _extends({}, okProps, {
    text: ok,
    onClick: onOk
  }))));
});
export default Head;