All files / src/modal Modal.tsx

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104                                                        9x                                                                                                                                                      
import { Modal as ModalMain, ModalProps } from "./ModalMain";
import {
  confirm,
  ModalConfirm,
  ModalConfirmProps,
  ConfirmOptions,
} from "./ModalConfirm";
import {
  success,
  error,
  alert,
  ModalAlert,
  ModalAlertProps,
  AlertOptions,
} from "./ModalAlert";
import { show } from "./ModalShow";
import { withStatics } from "../_util/with-statics";
 
export {
  ModalProps,
  ModalConfirm,
  ModalConfirmProps,
  ConfirmOptions,
  ModalAlert,
  ModalAlertProps,
  AlertOptions,
};
 
export const Modal = withStatics(ModalMain, {
  /**
   * 渲染对话框的主要内容
   */
  Body: ModalMain.Body,
 
  /**
   * 渲染对话框的底部内容
   */
  Footer: ModalMain.Footer,
 
  /**
   * 对话框消息内容,可置于 ModalMain..Body 中
   */
  Message: ModalMain.Message,
 
  /**
   * API 的方式唤起一个确认对话框
   * @returns 异步返回布尔值,为 `true` 则表示用户确认,为 `false` 则表示用户取消
   */
  confirm,
 
  /**
   * API 的方式唤起一个对话框显示成功信息
   */
  success,
 
  /**
   * API 的方式唤起一个对话框显示失败信息
   */
  error,
 
  /**
   * API 的方式唤起一个对话框显示提醒信息
   */
  alert,
 
  /**
   * API 的方式唤起一个对话框
   */
  show,
});
 
export interface ModalStaticAPI {
  /**
   * API 的方式唤起一个确认对话框
   * @param options
   * @returns 异步返回布尔值,为 true 则表示用户确认,为 false 则表示用户取消
   */
  confirm: typeof confirm;
 
  /**
   * API 的方式唤起一个对话框显示成功信息
   */
  success: typeof success;
 
  /**
   * API 的方式唤起一个对话框显示失败信息
   */
  error: typeof error;
 
  /**
   * API 的方式唤起一个告警对话框
   * @param options
   * @returns 异步返回布尔值,为 true 则表示用户确认,为 false 则表示用户取消
   */
  alert: typeof alert;
 
  /**
   * API 的方式唤起一个对话框
   *
   * 对于部分极端场景,没有可用于渲染对话框的文档流的情况下,可以采取 API 打开对话框。**但是这个功能开发者应该慎用,因为使用 API 打开对话框,实际上会断掉数据流,并不是一个好的实践。**
   */
  show: typeof show;
}