index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use client";
  2. import confirm, { modalGlobalConfig, withConfirm, withError, withInfo, withSuccess, withWarn } from './confirm';
  3. import destroyFns from './destroyFns';
  4. import OriginModal from './Modal';
  5. import PurePanel from './PurePanel';
  6. import useModal from './useModal';
  7. function modalWarn(props) {
  8. return confirm(withWarn(props));
  9. }
  10. const Modal = OriginModal;
  11. Modal.useModal = useModal;
  12. Modal.info = function infoFn(props) {
  13. return confirm(withInfo(props));
  14. };
  15. Modal.success = function successFn(props) {
  16. return confirm(withSuccess(props));
  17. };
  18. Modal.error = function errorFn(props) {
  19. return confirm(withError(props));
  20. };
  21. Modal.warning = modalWarn;
  22. Modal.warn = modalWarn;
  23. Modal.confirm = function confirmFn(props) {
  24. return confirm(withConfirm(props));
  25. };
  26. Modal.destroyAll = function destroyAllFn() {
  27. while (destroyFns.length) {
  28. const close = destroyFns.pop();
  29. if (close) {
  30. close();
  31. }
  32. }
  33. };
  34. Modal.config = modalGlobalConfig;
  35. Modal._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
  36. if (process.env.NODE_ENV !== 'production') {
  37. Modal.displayName = 'Modal';
  38. }
  39. export default Modal;