diff --git a/README.md b/README.md index 0d3a9039..202e0e2c 100644 --- a/README.md +++ b/README.md @@ -54,10 +54,9 @@ ReactDOM.render( | prefixCls | String | rc-dialog | The dialog dom node's prefixCls | | | className | String | | additional className for dialog | | | classNames | { mask?: string; wrapper?: string; header?: string; body?: string; footer?: string} | | pass className to target area | | +| styles | { mask?: CSSProperties; wrapper?: CSSProperties; header?: CSSProperties; body?: CSSProperties; footer?: CSSProperties} | | pass styles to target area | | | style | Object | {} | Root style for dialog element.Such as width, height | | | zIndex | Number | | | | -| bodyStyle | Object | {} | body style for dialog body element.Such as height | | -| maskStyle | Object | {} | style for mask element | | | visible | Boolean | false | current dialog's visible status | | | animation | String | | part of dialog animation css class name | | | maskAnimation | String | | part of dialog's mask animation css class name | | diff --git a/src/Dialog/Content/Panel.tsx b/src/Dialog/Content/Panel.tsx index 7fedcd28..6c7609ee 100644 --- a/src/Dialog/Content/Panel.tsx +++ b/src/Dialog/Content/Panel.tsx @@ -43,6 +43,7 @@ const Panel = React.forwardRef((props, ref) => { width, height, classNames: modalClassNames, + styles: modalStyles, } = props; // ================================= Refs ================================= @@ -79,13 +80,13 @@ const Panel = React.forwardRef((props, ref) => { // ================================ Render ================================ let footerNode: React.ReactNode; if (footer) { - footerNode =
{footer}
; + footerNode =
{footer}
; } let headerNode: React.ReactNode; if (title) { headerNode = ( -
+
{title}
@@ -106,7 +107,7 @@ const Panel = React.forwardRef((props, ref) => {
{closer} {headerNode} -
+
{children}
{footerNode} diff --git a/src/Dialog/index.tsx b/src/Dialog/index.tsx index 9440de50..3b9f78bc 100644 --- a/src/Dialog/index.tsx +++ b/src/Dialog/index.tsx @@ -10,6 +10,7 @@ import { getMotionName } from '../util'; import Content from './Content'; import type { ContentRef } from './Content/Panel'; import Mask from './Mask'; +import { warning } from 'rc-util'; export default function Dialog(props: IDialogPropTypes) { const { @@ -42,8 +43,19 @@ export default function Dialog(props: IDialogPropTypes) { maskProps, rootClassName, classNames: modalClassNames, + styles: modalStyles, } = props; + if (process.env.NODE_ENV !== 'production') { + ["wrapStyle", "bodyStyle", "maskStyle"].forEach((prop) => { + // (prop in props) && console.error(`Warning: ${prop} is deprecated, please use styles instead.`) + warning(!(prop in props), `${prop} is deprecated, please use styles instead.`) + }); + if ("wrapClassName" in props) { + warning(false, `wrapClassName is deprecated, please use classNames instead.`) + } + } + const lastOutSideActiveElementRef = useRef(); const wrapperRef = useRef(); const contentRef = useRef(); @@ -168,6 +180,7 @@ export default function Dialog(props: IDialogPropTypes) { style={{ zIndex, ...maskStyle, + ...modalStyles?.mask, }} maskProps={maskProps} className={modalClassNames?.mask} @@ -178,7 +191,7 @@ export default function Dialog(props: IDialogPropTypes) { className={classNames(`${prefixCls}-wrap`, wrapClassName, modalClassNames?.wrapper)} ref={wrapperRef} onClick={onWrapperClick} - style={{ zIndex, ...wrapStyle, display: !animatedVisible ? 'none' : null }} + style={{ zIndex, ...wrapStyle, ...modalStyles?.wrapper, display: !animatedVisible ? 'none' : null }} {...wrapProps} >
`; + +exports[`dialog should support styles 1`] = ` +
+
+
+