diff --git a/src/modal/__tests__/__snapshots__/modal.test.tsx.snap b/src/modal/__tests__/__snapshots__/modal.test.tsx.snap index 2cdec5a4a..30ffb72b0 100644 --- a/src/modal/__tests__/__snapshots__/modal.test.tsx.snap +++ b/src/modal/__tests__/__snapshots__/modal.test.tsx.snap @@ -74,8 +74,40 @@ exports[`Test Modal Component Should Match snapshot 1`] = `
-
- test +
+
+
+ + + + + + +
+
+
+
+ test +
+
@@ -189,7 +221,39 @@ exports[`Test Modal Component Should support banner Should match snapshot for dr
- test +
+
+
+ + + + + + +
+
+
+ test +
+
- test +
+
+
+ + + + + + +
+
+
+ test +
+
+ setVisible(false)} + onOk={() => setVisible(false)} + > +
    + {Array.from({ length: 100 }).map((_, i) => ( +
  • + {i} +
  • + ))} +
+
+ + + + + + ); +} diff --git a/src/modal/demos/size.tsx b/src/modal/demos/size.tsx index 894f9f21f..2b2fb7384 100644 --- a/src/modal/demos/size.tsx +++ b/src/modal/demos/size.tsx @@ -1,11 +1,11 @@ import React, { useState } from 'react'; import { Button, Space } from 'antd'; import { Modal } from 'dt-react-component'; -import type { IModalProps } from 'dt-react-component/modal'; +import type { ModalProps } from 'dt-react-component/modal'; export default function Size() { const [visible, setVisible] = useState(false); - const [size, setSize] = useState('default'); + const [size, setSize] = useState('default'); return ( <> diff --git a/src/modal/index.md b/src/modal/index.md index 71aa6d799..ba4d38bb0 100644 --- a/src/modal/index.md +++ b/src/modal/index.md @@ -23,6 +23,7 @@ toc: content + ## API @@ -31,6 +32,7 @@ toc: content | size | 尺寸 | `'small' \| 'default' \| 'middle' \| 'large'` | `default` | | banner | 提示 | `React.ReactNode \| AlertProps` | | | draggable | 是否可拖拽 | `IFloatProps['draggable']` | `false` | +| loading | 是否加载中 | `boolean` | `false` | | resizable | 是否可调整大小 | `MergeOption>` | `false` | | rect | 初始宽高(仅开启 resizable 的情况下生效) | `{ width: number; height: number }` | | | position | 初始位置(仅开启 draggable 的情况下生效) | `{ x: number; y: number}` | | diff --git a/src/modal/index.tsx b/src/modal/index.tsx index 0bbbeb4dc..aa0fc5de7 100644 --- a/src/modal/index.tsx +++ b/src/modal/index.tsx @@ -69,7 +69,7 @@ Object.assign(Modal, { config, }); -export type { IModalProps, RectState } from './modal'; +export type { ModalProps, RectState } from './modal'; export type { ResizeHandle } from 'react-resizable'; export default Modal; diff --git a/src/modal/modal.tsx b/src/modal/modal.tsx index 5e67a2e80..b93e5c884 100644 --- a/src/modal/modal.tsx +++ b/src/modal/modal.tsx @@ -1,6 +1,6 @@ import React, { useMemo } from 'react'; import { Resizable, type ResizableProps } from 'react-resizable'; -import { Alert, type AlertProps, Modal, type ModalProps } from 'antd'; +import { Alert, type AlertProps, Modal, type ModalProps as AntdModalProps, Spin } from 'antd'; import classNames from 'classnames'; import { omit } from 'lodash-es'; @@ -12,18 +12,19 @@ import './index.scss'; export type RectState = { width: number; height: number }; -export interface IModalProps extends ModalProps { +export interface ModalProps extends AntdModalProps { size?: 'small' | 'default' | 'middle' | 'large'; banner?: AlertProps['message'] | Omit; draggable?: IFloatProps['draggable']; resizable?: MergeOption>; rect?: RectState; position?: IFloatProps['position']; + loading?: boolean; onPositionChange?: (data: NonNullable) => void; onRectChange?: (data: RectState) => void; } -const getWidthFromSize = (size: IModalProps['size']) => { +const getWidthFromSize = (size: ModalProps['size']) => { if (size === 'small') return 400; if (size === 'middle') return 640; if (size === 'large') return 900; @@ -41,11 +42,12 @@ export default function InternalModal({ position, resizable = false, rect, + loading, onRectChange, onPositionChange, modalRender, ...rest -}: IModalProps) { +}: ModalProps) { const mergedDraggable = useMergeOption(draggable, { handle: '.ant-modal-header' }); const mergedResizable = useMergeOption(resizable, { axis: 'both', @@ -139,7 +141,9 @@ export default function InternalModal({ {...(isAlertObjectProps(banner) ? omit(banner, 'message') : {})} /> )} -
{children}
+
+ {children} +
); }