2020-11-30 15:54:54 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import RcImage from 'rc-image';
|
2021-01-06 22:23:49 +08:00
|
|
|
import RotateLeftOutlined from '@ant-design/icons/RotateLeftOutlined';
|
|
|
|
import RotateRightOutlined from '@ant-design/icons/RotateRightOutlined';
|
|
|
|
import ZoomInOutlined from '@ant-design/icons/ZoomInOutlined';
|
|
|
|
import ZoomOutOutlined from '@ant-design/icons/ZoomOutOutlined';
|
|
|
|
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
|
|
|
import LeftOutlined from '@ant-design/icons/LeftOutlined';
|
|
|
|
import RightOutlined from '@ant-design/icons/RightOutlined';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { GroupConsumerProps } from 'rc-image/lib/PreviewGroup';
|
2020-11-30 15:54:54 +08:00
|
|
|
import { ConfigContext } from '../config-provider';
|
2021-02-20 22:24:44 +08:00
|
|
|
import { getTransitionName } from '../_util/motion';
|
2020-11-30 15:54:54 +08:00
|
|
|
|
2021-01-06 22:23:49 +08:00
|
|
|
export const icons = {
|
|
|
|
rotateLeft: <RotateLeftOutlined />,
|
|
|
|
rotateRight: <RotateRightOutlined />,
|
|
|
|
zoomIn: <ZoomInOutlined />,
|
|
|
|
zoomOut: <ZoomOutOutlined />,
|
|
|
|
close: <CloseOutlined />,
|
|
|
|
left: <LeftOutlined />,
|
|
|
|
right: <RightOutlined />,
|
|
|
|
};
|
|
|
|
|
2020-12-10 08:17:29 +08:00
|
|
|
const InternalPreviewGroup: React.FC<GroupConsumerProps> = ({
|
2020-11-30 15:54:54 +08:00
|
|
|
previewPrefixCls: customizePrefixCls,
|
2021-02-20 22:24:44 +08:00
|
|
|
preview,
|
2020-11-30 15:54:54 +08:00
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
|
|
const prefixCls = getPrefixCls('image-preview', customizePrefixCls);
|
2021-02-20 22:24:44 +08:00
|
|
|
const rootPrefixCls = getPrefixCls();
|
|
|
|
|
|
|
|
const mergedPreview = React.useMemo(() => {
|
|
|
|
if (preview === false) {
|
|
|
|
return preview;
|
|
|
|
}
|
|
|
|
const _preview = typeof preview === 'object' ? preview : {};
|
|
|
|
|
|
|
|
return {
|
|
|
|
..._preview,
|
|
|
|
transitionName: getTransitionName(rootPrefixCls, 'zoom', _preview.transitionName),
|
|
|
|
maskTransitionName: getTransitionName(rootPrefixCls, 'fade', _preview.maskTransitionName),
|
|
|
|
};
|
|
|
|
}, [preview]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<RcImage.PreviewGroup
|
|
|
|
preview={mergedPreview}
|
|
|
|
previewPrefixCls={prefixCls}
|
|
|
|
icons={icons}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
2020-11-30 15:54:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default InternalPreviewGroup;
|