interface.d.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import type React from 'react';
  2. import type { DialogProps } from 'rc-dialog';
  3. import { Breakpoint } from '../_util/responsiveObserver';
  4. import type { ButtonProps, LegacyButtonType } from '../button/button';
  5. import type { DirectionType } from '../config-provider';
  6. interface ModalCommonProps extends Omit<DialogProps, 'footer' | 'width' | 'onClose' | 'animation' | 'maskAnimation' | 'transitionName' | 'maskTransitionName'> {
  7. footer?: React.ReactNode | ((originNode: React.ReactNode, extra: {
  8. OkBtn: React.FC;
  9. CancelBtn: React.FC;
  10. }) => React.ReactNode);
  11. }
  12. export interface ModalProps extends ModalCommonProps {
  13. /** Whether the modal dialog is visible or not */
  14. open?: boolean;
  15. /** Whether to apply loading visual effect for OK button or not */
  16. confirmLoading?: boolean;
  17. /** The modal dialog's title */
  18. title?: React.ReactNode;
  19. /** Specify a function that will be called when a user clicks the OK button */
  20. onOk?: (e: React.MouseEvent<HTMLButtonElement>) => void;
  21. /** Specify a function that will be called when a user clicks mask, close button on top right or Cancel button */
  22. onCancel?: (e: React.MouseEvent<HTMLButtonElement>) => void;
  23. afterClose?: () => void;
  24. /** Callback when the animation ends when Modal is turned on and off */
  25. afterOpenChange?: (open: boolean) => void;
  26. /** Centered Modal */
  27. centered?: boolean;
  28. /** Width of the modal dialog */
  29. width?: string | number | Partial<Record<Breakpoint, string | number>>;
  30. /** Text of the OK button */
  31. okText?: React.ReactNode;
  32. /** Button `type` of the OK button */
  33. okType?: LegacyButtonType;
  34. /** Text of the Cancel button */
  35. cancelText?: React.ReactNode;
  36. /** Whether to close the modal dialog when the mask (area outside the modal) is clicked */
  37. maskClosable?: boolean;
  38. /** Force render Modal */
  39. forceRender?: boolean;
  40. okButtonProps?: ButtonProps;
  41. cancelButtonProps?: ButtonProps;
  42. /** @deprecated Please use `destroyOnHidden` instead */
  43. destroyOnClose?: boolean;
  44. /**
  45. * @since 5.25.0
  46. */
  47. destroyOnHidden?: boolean;
  48. style?: React.CSSProperties;
  49. wrapClassName?: string;
  50. maskTransitionName?: string;
  51. transitionName?: string;
  52. className?: string;
  53. rootClassName?: string;
  54. classNames?: NonNullable<DialogProps['classNames']>;
  55. getContainer?: string | HTMLElement | getContainerFunc | false;
  56. zIndex?: number;
  57. /** @deprecated Please use `styles.body` instead */
  58. bodyStyle?: React.CSSProperties;
  59. /** @deprecated Please use `styles.mask` instead */
  60. maskStyle?: React.CSSProperties;
  61. mask?: boolean;
  62. keyboard?: boolean;
  63. wrapProps?: any;
  64. prefixCls?: string;
  65. closeIcon?: React.ReactNode;
  66. modalRender?: (node: React.ReactNode) => React.ReactNode;
  67. focusTriggerAfterClose?: boolean;
  68. children?: React.ReactNode;
  69. mousePosition?: MousePosition;
  70. /** @deprecated Please use `open` instead. */
  71. visible?: boolean;
  72. /**
  73. * @since 5.18.0
  74. */
  75. loading?: boolean;
  76. }
  77. type getContainerFunc = () => HTMLElement;
  78. export interface ModalFuncProps extends ModalCommonProps {
  79. prefixCls?: string;
  80. className?: string;
  81. rootClassName?: string;
  82. open?: boolean;
  83. /** @deprecated Please use `open` instead. */
  84. visible?: boolean;
  85. title?: React.ReactNode;
  86. content?: React.ReactNode;
  87. onOk?: (...args: any[]) => any;
  88. onCancel?: (...args: any[]) => any;
  89. afterClose?: () => void;
  90. okButtonProps?: ButtonProps;
  91. cancelButtonProps?: ButtonProps;
  92. centered?: boolean;
  93. width?: string | number;
  94. okText?: React.ReactNode;
  95. okType?: LegacyButtonType;
  96. cancelText?: React.ReactNode;
  97. icon?: React.ReactNode;
  98. mask?: boolean;
  99. maskClosable?: boolean;
  100. zIndex?: number;
  101. okCancel?: boolean;
  102. style?: React.CSSProperties;
  103. wrapClassName?: string;
  104. /** @deprecated Please use `styles.mask` instead */
  105. maskStyle?: React.CSSProperties;
  106. type?: 'info' | 'success' | 'error' | 'warn' | 'warning' | 'confirm';
  107. keyboard?: boolean;
  108. getContainer?: string | HTMLElement | getContainerFunc | false;
  109. autoFocusButton?: null | 'ok' | 'cancel';
  110. transitionName?: string;
  111. maskTransitionName?: string;
  112. direction?: DirectionType;
  113. /** @deprecated Please use `styles.body` instead */
  114. bodyStyle?: React.CSSProperties;
  115. closeIcon?: React.ReactNode;
  116. footer?: ModalProps['footer'];
  117. modalRender?: (node: React.ReactNode) => React.ReactNode;
  118. focusTriggerAfterClose?: boolean;
  119. }
  120. export interface ModalLocale {
  121. okText: string;
  122. cancelText: string;
  123. justOkText: string;
  124. }
  125. export type MousePosition = {
  126. x: number;
  127. y: number;
  128. } | null;
  129. export {};