11import React , { useMemo } from 'react' ;
22import { Resizable , type ResizableProps } from 'react-resizable' ;
3- import { Alert , type AlertProps , Modal , type ModalProps } from 'antd' ;
3+ import { Alert , type AlertProps , Modal , type ModalProps as AntdModalProps , Spin } from 'antd' ;
44import classNames from 'classnames' ;
55import { omit } from 'lodash-es' ;
66
@@ -12,18 +12,19 @@ import './index.scss';
1212
1313export type RectState = { width : number ; height : number } ;
1414
15- export interface IModalProps extends ModalProps {
15+ export interface ModalProps extends AntdModalProps {
1616 size ?: 'small' | 'default' | 'middle' | 'large' ;
1717 banner ?: AlertProps [ 'message' ] | Omit < AlertProps , 'banner' > ;
1818 draggable ?: IFloatProps [ 'draggable' ] ;
1919 resizable ?: MergeOption < Partial < ResizableProps > > ;
2020 rect ?: RectState ;
2121 position ?: IFloatProps [ 'position' ] ;
22+ loading ?: boolean ;
2223 onPositionChange ?: ( data : NonNullable < IFloatProps [ 'position' ] > ) => void ;
2324 onRectChange ?: ( data : RectState ) => void ;
2425}
2526
26- const getWidthFromSize = ( size : IModalProps [ 'size' ] ) => {
27+ const getWidthFromSize = ( size : ModalProps [ 'size' ] ) => {
2728 if ( size === 'small' ) return 400 ;
2829 if ( size === 'middle' ) return 640 ;
2930 if ( size === 'large' ) return 900 ;
@@ -41,11 +42,12 @@ export default function InternalModal({
4142 position,
4243 resizable = false ,
4344 rect,
45+ loading,
4446 onRectChange,
4547 onPositionChange,
4648 modalRender,
4749 ...rest
48- } : IModalProps ) {
50+ } : ModalProps ) {
4951 const mergedDraggable = useMergeOption ( draggable , { handle : '.ant-modal-header' } ) ;
5052 const mergedResizable = useMergeOption ( resizable , {
5153 axis : 'both' ,
@@ -139,7 +141,9 @@ export default function InternalModal({
139141 { ...( isAlertObjectProps ( banner ) ? omit ( banner , 'message' ) : { } ) }
140142 />
141143 ) }
142- < section className = "dtc-modal-body" > { children } </ section >
144+ < section className = "dtc-modal-body" >
145+ < Spin spinning = { loading } > { children } </ Spin >
146+ </ section >
143147 </ Modal >
144148 ) ;
145149}
0 commit comments