|
@ -2,9 +2,9 @@ import EyeOutlined from '@ant-design/icons/EyeOutlined'; |
|
|
import classNames from 'classnames'; |
|
|
import classNames from 'classnames'; |
|
|
import RcImage, { type ImageProps } from 'rc-image'; |
|
|
import RcImage, { type ImageProps } from 'rc-image'; |
|
|
import * as React from 'react'; |
|
|
import * as React from 'react'; |
|
|
|
|
|
import { getTransitionName } from '../_util/motion'; |
|
|
import { ConfigContext } from '../config-provider'; |
|
|
import { ConfigContext } from '../config-provider'; |
|
|
import defaultLocale from '../locale/en_US'; |
|
|
import defaultLocale from '../locale/en_US'; |
|
|
import { getTransitionName } from '../_util/motion'; |
|
|
|
|
|
// CSSINJS
|
|
|
// CSSINJS
|
|
|
import PreviewGroup, { icons } from './PreviewGroup'; |
|
|
import PreviewGroup, { icons } from './PreviewGroup'; |
|
|
import useStyle from './style'; |
|
|
import useStyle from './style'; |
|
@ -16,13 +16,16 @@ export interface CompositionImage<P> extends React.FC<P> { |
|
|
const Image: CompositionImage<ImageProps> = ({ |
|
|
const Image: CompositionImage<ImageProps> = ({ |
|
|
prefixCls: customizePrefixCls, |
|
|
prefixCls: customizePrefixCls, |
|
|
preview, |
|
|
preview, |
|
|
|
|
|
className, |
|
|
rootClassName, |
|
|
rootClassName, |
|
|
|
|
|
style, |
|
|
...otherProps |
|
|
...otherProps |
|
|
}) => { |
|
|
}) => { |
|
|
const { |
|
|
const { |
|
|
getPrefixCls, |
|
|
getPrefixCls, |
|
|
locale: contextLocale = defaultLocale, |
|
|
locale: contextLocale = defaultLocale, |
|
|
getPopupContainer: getContextPopupContainer, |
|
|
getPopupContainer: getContextPopupContainer, |
|
|
|
|
|
image, |
|
|
} = React.useContext(ConfigContext); |
|
|
} = React.useContext(ConfigContext); |
|
|
|
|
|
|
|
|
const prefixCls = getPrefixCls('image', customizePrefixCls); |
|
|
const prefixCls = getPrefixCls('image', customizePrefixCls); |
|
@ -33,6 +36,9 @@ const Image: CompositionImage<ImageProps> = ({ |
|
|
const [wrapSSR, hashId] = useStyle(prefixCls); |
|
|
const [wrapSSR, hashId] = useStyle(prefixCls); |
|
|
|
|
|
|
|
|
const mergedRootClassName = classNames(rootClassName, hashId); |
|
|
const mergedRootClassName = classNames(rootClassName, hashId); |
|
|
|
|
|
|
|
|
|
|
|
const mergedClassName = classNames(className, hashId, image?.className); |
|
|
|
|
|
|
|
|
const mergedPreview = React.useMemo(() => { |
|
|
const mergedPreview = React.useMemo(() => { |
|
|
if (preview === false) { |
|
|
if (preview === false) { |
|
|
return preview; |
|
|
return preview; |
|
@ -54,11 +60,15 @@ const Image: CompositionImage<ImageProps> = ({ |
|
|
}; |
|
|
}; |
|
|
}, [preview, imageLocale]); |
|
|
}, [preview, imageLocale]); |
|
|
|
|
|
|
|
|
|
|
|
const mergedStyle: React.CSSProperties = { ...image?.style, ...style }; |
|
|
|
|
|
|
|
|
return wrapSSR( |
|
|
return wrapSSR( |
|
|
<RcImage |
|
|
<RcImage |
|
|
prefixCls={`${prefixCls}`} |
|
|
prefixCls={`${prefixCls}`} |
|
|
preview={mergedPreview} |
|
|
preview={mergedPreview} |
|
|
rootClassName={mergedRootClassName} |
|
|
rootClassName={mergedRootClassName} |
|
|
|
|
|
className={mergedClassName} |
|
|
|
|
|
style={mergedStyle} |
|
|
{...otherProps} |
|
|
{...otherProps} |
|
|
/>, |
|
|
/>, |
|
|
); |
|
|
); |
|
|