import EyeOutlined from '@ant-design/icons/EyeOutlined';
import RcImage, { ImageProps } from 'rc-image';
import * as React from 'react';
import { useContext } from 'react';
import { ConfigContext } from '../config-provider';
import defaultLocale from '../locale/en_US';
import { getTransitionName } from '../_util/motion';
import PreviewGroup, { icons } from './PreviewGroup';
export interface CompositionImage
extends React.FC
{
PreviewGroup: typeof PreviewGroup;
}
const Image: CompositionImage = ({
prefixCls: customizePrefixCls,
preview,
...otherProps
}) => {
const { getPrefixCls, locale: contextLocale = defaultLocale } = useContext(ConfigContext);
const prefixCls = getPrefixCls('image', customizePrefixCls);
const rootPrefixCls = getPrefixCls();
const imageLocale = contextLocale.Image || defaultLocale.Image;
const mergedPreview = React.useMemo(() => {
if (preview === false) {
return preview;
}
const _preview = typeof preview === 'object' ? preview : {};
return {
mask: (
{imageLocale?.preview}
),
icons,
..._preview,
transitionName: getTransitionName(rootPrefixCls, 'zoom', _preview.transitionName),
maskTransitionName: getTransitionName(rootPrefixCls, 'fade', _preview.maskTransitionName),
};
}, [preview, imageLocale]);
return ;
};
export { ImageProps };
Image.PreviewGroup = PreviewGroup;
export default Image;