@@ -5,6 +5,7 @@ import { NativeProps } from '../../utils/native-props'
55import { mergeProps } from '../../utils/with-default-props'
66import AutoCenter from '../auto-center'
77import CenterPopup , { CenterPopupProps } from '../center-popup'
8+ import { useConfig } from '../config-provider'
89import Image from '../image'
910import { Action , DialogActionButton } from './dialog-action-button'
1011
@@ -22,6 +23,7 @@ export type DialogProps = Pick<
2223 | 'maskStyle'
2324 | 'stopPropagation'
2425 | 'visible'
26+ | 'prefixCls'
2527> & {
2628 image ?: string
2729 header ?: ReactNode
@@ -49,24 +51,28 @@ const defaultProps = {
4951
5052export const Dialog : FC < DialogProps > = p => {
5153 const props = mergeProps ( defaultProps , p )
54+ const { getPrefixCls } = useConfig ( )
55+ const prefixCls = getPrefixCls ( 'dialog' , props . prefixCls )
5256
5357 const element = (
5458 < >
5559 { ! ! props . image && (
56- < div className = { cls ( ' image-container' ) } >
60+ < div className = { ` ${ prefixCls } - image-container` } >
5761 < Image src = { props . image } alt = 'dialog header image' width = '100%' />
5862 </ div >
5963 ) }
6064 { ! ! props . header && (
61- < div className = { cls ( ' header' ) } >
65+ < div className = { ` ${ prefixCls } - header` } >
6266 < AutoCenter > { props . header } </ AutoCenter >
6367 </ div >
6468 ) }
65- { ! ! props . title && < div className = { cls ( 'title' ) } > { props . title } </ div > }
69+ { ! ! props . title && (
70+ < div className = { `${ prefixCls } -title` } > { props . title } </ div >
71+ ) }
6672 < div
6773 className = { classNames (
68- cls ( ' content' ) ,
69- ! props . content && cls ( ' content-empty' )
74+ ` ${ prefixCls } - content` ,
75+ ! props . content && ` ${ prefixCls } - content-empty`
7076 ) }
7177 >
7278 { typeof props . content === 'string' ? (
@@ -75,11 +81,11 @@ export const Dialog: FC<DialogProps> = p => {
7581 props . content
7682 ) }
7783 </ div >
78- < div className = { cls ( ' footer' ) } >
84+ < div className = { ` ${ prefixCls } - footer` } >
7985 { props . actions . map ( ( row , index ) => {
8086 const actions = Array . isArray ( row ) ? row : [ row ]
8187 return (
82- < div className = { cls ( ' action-row' ) } key = { index } >
88+ < div className = { ` ${ prefixCls } - action-row` } key = { index } >
8389 { actions . map ( ( action , index ) => (
8490 < DialogActionButton
8591 key = { action . key }
@@ -104,7 +110,7 @@ export const Dialog: FC<DialogProps> = p => {
104110
105111 return (
106112 < CenterPopup
107- className = { classNames ( cls ( ) , props . className ) }
113+ className = { classNames ( prefixCls , props . className ) }
108114 style = { props . style }
109115 afterClose = { props . afterClose }
110116 afterShow = { props . afterShow }
@@ -119,8 +125,8 @@ export const Dialog: FC<DialogProps> = p => {
119125 getContainer = { props . getContainer }
120126 bodyStyle = { props . bodyStyle }
121127 bodyClassName = { classNames (
122- cls ( ' body' ) ,
123- props . image && cls ( ' with-image' ) ,
128+ ` ${ prefixCls } - body` ,
129+ props . image && ` ${ prefixCls } - with-image` ,
124130 props . bodyClassName
125131 ) }
126132 maskStyle = { props . maskStyle }
@@ -131,12 +137,9 @@ export const Dialog: FC<DialogProps> = p => {
131137 forceRender = { props . forceRender }
132138 role = 'dialog'
133139 aria-label = { props [ 'aria-label' ] }
140+ prefixCls = { prefixCls }
134141 >
135142 { element }
136143 </ CenterPopup >
137144 )
138145}
139-
140- function cls ( name : string = '' ) {
141- return 'adm-dialog' + ( name && '-' ) + name
142- }
0 commit comments