var _excluded = ["portal", "visible", "value", "onBeforeChange", "onChange", "onVisibleChange", "color", "backgroundColor", "mainProps"];
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); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { useImperativeHandle, forwardRef, useRef } from 'react';
import { createPortal } from 'react-dom';
import Main from "./../Main";

// 内库使用-start
import Layout from "./../../Layout";
// 内库使用-end

/* 测试使用-start
import { Layout } from 'seedsui-react'
测试使用-end */

// Modal
var Modal = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var portal = _ref.portal,
    visible = _ref.visible,
    value = _ref.value,
    onBeforeChange = _ref.onBeforeChange,
    onChange = _ref.onChange,
    onVisibleChange = _ref.onVisibleChange,
    color = _ref.color,
    backgroundColor = _ref.backgroundColor,
    mainProps = _ref.mainProps,
    props = _objectWithoutProperties(_ref, _excluded);
  // Expose
  var modalRef = useRef(null);
  useImperativeHandle(ref, function () {
    var _modalRef$current, _modalRef$current2, _modalRef$current3;
    return {
      modalDOM: (modalRef === null || modalRef === void 0 || (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.rootDOM) || (modalRef === null || modalRef === void 0 ? void 0 : modalRef.current),
      getModalDOM: modalRef !== null && modalRef !== void 0 && (_modalRef$current2 = modalRef.current) !== null && _modalRef$current2 !== void 0 && _modalRef$current2.getRootDOM ? modalRef === null || modalRef === void 0 || (_modalRef$current3 = modalRef.current) === null || _modalRef$current3 === void 0 ? void 0 : _modalRef$current3.getRootDOM : function () {
        return modalRef.current;
      }
    };
  });
  return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(Layout, _extends({
    ref: modalRef
  }, props, {
    className: "signature-modal".concat(props !== null && props !== void 0 && props.className ? ' ' + props.className : '').concat(visible === true ? '' : ' hide')
  }), visible && /*#__PURE__*/React.createElement(Main, _extends({}, mainProps || {}, {
    value: value,
    onBeforeChange: onBeforeChange,
    onChange: onChange,
    onCancel: function onCancel() {
      onVisibleChange && onVisibleChange(false);
    }
    // 绘画配置
    ,
    color: color,
    backgroundColor: backgroundColor
  }))), portal || document.getElementById('root') || document.body);
});
export default Modal;