@@ -2,11 +2,7 @@ import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
22import classnames from 'classnames' ;
33import * as React from 'react' ;
44import { useContext , useMemo , useState } from 'react' ;
5- import type {
6- InternalPreviewConfig ,
7- InternalPreviewSemanticName ,
8- ToolbarRenderInfoType ,
9- } from './Preview' ;
5+ import type { InternalPreviewConfig , PreviewSemanticName , ToolbarRenderInfoType } from './Preview' ;
106import Preview from './Preview' ;
117import PreviewGroup from './PreviewGroup' ;
128import { COMMON_PROPS } from './common' ;
@@ -25,8 +21,6 @@ export interface ImgInfo {
2521
2622export interface PreviewConfig extends Omit < InternalPreviewConfig , 'countRender' > {
2723 cover ?: React . ReactNode ;
28- classNames ?: Partial < Record < PreviewSemanticName , string > > ;
29- styles ?: Partial < Record < PreviewSemanticName , React . CSSProperties > > ;
3024
3125 // Similar to InternalPreviewConfig but not have `current`
3226 imageRender ?: (
@@ -43,9 +37,7 @@ export interface PreviewConfig extends Omit<InternalPreviewConfig, 'countRender'
4337 onOpenChange ?: ( open : boolean ) => void ;
4438}
4539
46- export type SemanticName = 'root' | 'image' ;
47-
48- export type PreviewSemanticName = InternalPreviewSemanticName | 'cover' ;
40+ export type SemanticName = 'root' | 'image' | 'cover' ;
4941
5042export interface ImageProps
5143 extends Omit < React . ImgHTMLAttributes < HTMLImageElement > , 'placeholder' | 'onClick' > {
@@ -55,8 +47,16 @@ export interface ImageProps
5547
5648 // Styles
5749 rootClassName ?: string ;
58- classNames ?: Partial < Record < SemanticName , string > > ;
59- styles ?: Partial < Record < SemanticName , React . CSSProperties > > ;
50+ classNames ?: Partial <
51+ Record < SemanticName , string > & {
52+ popup ?: Partial < Record < PreviewSemanticName , string > > ;
53+ }
54+ > ;
55+ styles ?: Partial <
56+ Record < SemanticName , React . CSSProperties > & {
57+ popup ?: Partial < Record < PreviewSemanticName , React . CSSProperties > > ;
58+ }
59+ > ;
6060
6161 // Image
6262 src ?: string ;
@@ -117,8 +117,6 @@ const ImageInternal: CompoundedComponent<ImageProps> = props => {
117117 open : previewOpen ,
118118 onOpenChange : onPreviewOpenChange ,
119119 cover,
120- classNames : previewClassNames = { } ,
121- styles : previewStyles = { } ,
122120 rootClassName : previewRootClassName ,
123121 ...restProps
124122 } : PreviewConfig = preview && typeof preview === 'object' ? preview : { } ;
@@ -239,10 +237,10 @@ const ImageInternal: CompoundedComponent<ImageProps> = props => {
239237 { /* Preview Click Mask */ }
240238 { cover !== false && canPreview && (
241239 < div
242- className = { classnames ( `${ prefixCls } -cover` , previewClassNames . cover ) }
240+ className = { classnames ( `${ prefixCls } -cover` , classNames . cover ) }
243241 style = { {
244242 display : style ?. display === 'none' ? 'none' : undefined ,
245- ...previewStyles . cover ,
243+ ...styles . cover ,
246244 } }
247245 >
248246 { cover }
@@ -261,10 +259,10 @@ const ImageInternal: CompoundedComponent<ImageProps> = props => {
261259 imageInfo = { { width, height } }
262260 fallback = { fallback }
263261 imgCommonProps = { imgCommonProps }
264- classNames = { previewClassNames }
265- styles = { previewStyles }
266- rootClassName = { classnames ( previewRootClassName , rootClassName ) }
267262 { ...restProps }
263+ classNames = { classNames ?. popup }
264+ styles = { styles ?. popup }
265+ rootClassName = { classnames ( previewRootClassName , rootClassName ) }
268266 />
269267 ) }
270268 </ >
0 commit comments