mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
type: fix Modal styles typing (#49055)
This commit is contained in:
parent
86abdb9918
commit
9db0fc7440
@ -4,8 +4,28 @@ import Modal from '..';
|
||||
|
||||
describe('Modal.typescript', () => {
|
||||
it('Modal.okType', () => {
|
||||
const form = <Modal okType="danger" />;
|
||||
const modal = <Modal okType="danger" />;
|
||||
|
||||
expect(form).toBeTruthy();
|
||||
expect(modal).toBeTruthy();
|
||||
});
|
||||
|
||||
it('Modal.styles', () => {
|
||||
const style: React.CSSProperties = {
|
||||
position: 'absolute',
|
||||
};
|
||||
const modal = (
|
||||
<Modal
|
||||
styles={{
|
||||
header: style,
|
||||
body: style,
|
||||
footer: style,
|
||||
mask: style,
|
||||
wrapper: style,
|
||||
content: style,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(modal).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
@ -32,16 +32,14 @@ const BlockModal = (props: ModalProps) => {
|
||||
<Modal
|
||||
getContainer={() => divRef.current!}
|
||||
{...props}
|
||||
styles={
|
||||
{
|
||||
mask: {
|
||||
position: 'absolute',
|
||||
},
|
||||
wrapper: {
|
||||
position: 'absolute',
|
||||
},
|
||||
} as any
|
||||
}
|
||||
styles={{
|
||||
mask: {
|
||||
position: 'absolute',
|
||||
},
|
||||
wrapper: {
|
||||
position: 'absolute',
|
||||
},
|
||||
}}
|
||||
style={{
|
||||
top: '50%',
|
||||
transform: 'translateY(-50%)',
|
||||
|
@ -5,13 +5,12 @@ import type { ClosableType } from '../_util/hooks/useClosable';
|
||||
import type { ButtonProps, LegacyButtonType } from '../button/button';
|
||||
import type { DirectionType } from '../config-provider';
|
||||
|
||||
export type ModalFooterRender = (
|
||||
originNode: React.ReactNode,
|
||||
extra: { OkBtn: FC; CancelBtn: FC },
|
||||
) => React.ReactNode;
|
||||
interface ModalCommonProps {
|
||||
styles?: Omit<NonNullable<DialogProps['styles']>, 'wrapper'>;
|
||||
interface ModalCommonProps extends Omit<DialogProps, 'footer'> {
|
||||
footer?:
|
||||
| React.ReactNode
|
||||
| ((originNode: React.ReactNode, extra: { OkBtn: FC; CancelBtn: FC }) => React.ReactNode);
|
||||
}
|
||||
|
||||
export interface ModalProps extends ModalCommonProps {
|
||||
/** Whether the modal dialog is visible or not */
|
||||
open?: boolean;
|
||||
@ -32,8 +31,6 @@ export interface ModalProps extends ModalCommonProps {
|
||||
centered?: boolean;
|
||||
/** Width of the modal dialog */
|
||||
width?: string | number;
|
||||
/** Footer content */
|
||||
footer?: ModalFooterRender | React.ReactNode;
|
||||
/** Text of the OK button */
|
||||
okText?: React.ReactNode;
|
||||
/** Button `type` of the OK button */
|
||||
|
Loading…
Reference in New Issue
Block a user