import React__default, { useRef } from 'react';
import { Drawer as Drawer$1, Button } from 'antd';

const Drawer = ({
  className = '',
  hasFooter = true,
  customFooter,
  onClose,
  onOk,
  cancelText = '取消',
  okText = '确认',
  style = {},
  ...props
}) => {
  const domRef = useRef(null);
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
    ref: domRef,
    style: {
      position: 'fixed',
      zIndex: 200,
      left: 0,
      top: 0
    }
  }), /*#__PURE__*/React__default.cloneElement(/*#__PURE__*/React__default.createElement(Drawer$1, {
    style: {
      ...style,
      textAlign: 'left'
    }
  }), {
    onClose,
    className,
    getContainer: () => domRef.current,
    footer: customFooter ? customFooter : /*#__PURE__*/React__default.createElement(Footer, {
      hasFooter: hasFooter,
      onClose: onClose,
      onOk: onOk,
      cancelText: cancelText,
      okText: okText
    }),
    ...props
  }));
};
function Footer({
  hasFooter,
  onClose,
  cancelText,
  okText,
  onOk
}) {
  return hasFooter ? /*#__PURE__*/React__default.createElement("div", {
    style: {
      textAlign: 'right'
    }
  }, /*#__PURE__*/React__default.createElement(Button, {
    onClick: onClose,
    style: {
      marginRight: 8
    }
  }, cancelText), /*#__PURE__*/React__default.createElement(Button, {
    onClick: onOk,
    type: "primary"
  }, okText)) : null;
}

export { Drawer as default };
//# sourceMappingURL=index.js.map
