forked from vueComponent/ant-design-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreviewGroup.tsx
69 lines (65 loc) · 2.39 KB
/
PreviewGroup.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import type { PreviewGroupPreview } from '../vc-image/src/PreviewGroup';
import PreviewGroup from '../vc-image/src/PreviewGroup';
import type { ExtractPropTypes } from 'vue';
import { computed, defineComponent } from 'vue';
import useConfigInject from '../config-provider/hooks/useConfigInject';
import RotateLeftOutlined from '@ant-design/icons-vue/RotateLeftOutlined';
import RotateRightOutlined from '@ant-design/icons-vue/RotateRightOutlined';
import ZoomInOutlined from '@ant-design/icons-vue/ZoomInOutlined';
import ZoomOutOutlined from '@ant-design/icons-vue/ZoomOutOutlined';
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
import LeftOutlined from '@ant-design/icons-vue/LeftOutlined';
import RightOutlined from '@ant-design/icons-vue/RightOutlined';
import SwapOutlined from '@ant-design/icons-vue/SwapOutlined';
import useStyle from './style';
import { anyType } from '../_util/type';
export const icons = {
rotateLeft: <RotateLeftOutlined />,
rotateRight: <RotateRightOutlined />,
zoomIn: <ZoomInOutlined />,
zoomOut: <ZoomOutOutlined />,
close: <CloseOutlined />,
left: <LeftOutlined />,
right: <RightOutlined />,
flipX: <SwapOutlined />,
flipY: <SwapOutlined rotate={90} />,
};
const previewGroupProps = () => ({
previewPrefixCls: String,
preview: anyType<boolean | PreviewGroupPreview>(),
});
export type ImageGroupProps = Partial<ExtractPropTypes<ReturnType<typeof previewGroupProps>>>;
const InternalPreviewGroup = defineComponent({
compatConfig: { MODE: 3 },
name: 'AImagePreviewGroup',
inheritAttrs: false,
props: previewGroupProps(),
setup(props, { attrs, slots }) {
const { prefixCls } = useConfigInject('image', props);
const previewPrefixCls = computed(() => `${prefixCls.value}-preview`);
const [wrapSSR, hashId] = useStyle(prefixCls);
const mergedPreview = computed(() => {
const { preview } = props;
if (preview === false) {
return preview;
}
const _preview = typeof preview === 'object' ? preview : {};
return {
..._preview,
rootClassName: hashId.value,
};
});
return () => {
return wrapSSR(
<PreviewGroup
{...{ ...attrs, ...props }}
preview={mergedPreview.value}
icons={icons}
previewPrefixCls={previewPrefixCls.value}
v-slots={slots}
></PreviewGroup>,
);
};
},
});
export default InternalPreviewGroup;