Skip to content

Commit 80edf86

Browse files
authored
fix(image-group): props definition (#6621)
* fix(image-group): props definition * feat: add ImageGroupProps type definition
1 parent 1001ff3 commit 80edf86

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

components/image/PreviewGroup.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import PreviewGroup from '../vc-image/src/PreviewGroup';
1+
import PreviewGroup, { imageGroupProps } from '../vc-image/src/PreviewGroup';
2+
import type { ExtractPropTypes } from 'vue';
23
import { computed, defineComponent } from 'vue';
34
import useConfigInject from '../_util/hooks/useConfigInject';
45

@@ -20,11 +21,13 @@ export const icons = {
2021
right: <RightOutlined />,
2122
};
2223

24+
export type ImageGroupProps = Partial<ExtractPropTypes<ReturnType<typeof imageGroupProps>>>;
25+
2326
const InternalPreviewGroup = defineComponent({
2427
compatConfig: { MODE: 3 },
2528
name: 'AImagePreviewGroup',
2629
inheritAttrs: false,
27-
props: { previewPrefixCls: String },
30+
props: imageGroupProps(),
2831
setup(props, { attrs, slots }) {
2932
const { getPrefixCls } = useConfigInject('image', props);
3033
const prefixCls = computed(() => getPrefixCls('image-preview', props.previewPrefixCls));

components/vc-image/src/PreviewGroup.tsx

+13-11
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,23 @@ export const context = {
5656
},
5757
};
5858

59+
export const imageGroupProps = () => ({
60+
previewPrefixCls: String,
61+
preview: {
62+
type: [Boolean, Object] as PropType<boolean | ImagePreviewType>,
63+
default: true as boolean | ImagePreviewType,
64+
},
65+
icons: {
66+
type: Object as PropType<PreviewProps['icons']>,
67+
default: () => ({}),
68+
},
69+
});
70+
5971
const Group = defineComponent({
6072
compatConfig: { MODE: 3 },
6173
name: 'PreviewGroup',
6274
inheritAttrs: false,
63-
props: {
64-
previewPrefixCls: String,
65-
preview: {
66-
type: [Boolean, Object] as PropType<boolean | ImagePreviewType>,
67-
default: true as boolean | ImagePreviewType,
68-
},
69-
icons: {
70-
type: Object as PropType<PreviewProps['icons']>,
71-
default: () => ({}),
72-
},
73-
},
75+
props: imageGroupProps(),
7476
setup(props, { slots }) {
7577
const preview = computed<PreviewGroupPreview>(() => {
7678
const defaultValues = {

0 commit comments

Comments
 (0)