fix(image-group): props definition (#6621)
* fix(image-group): props definition * feat: add ImageGroupProps type definitionpull/6657/head
parent
1001ff3834
commit
80edf86d18
|
@ -1,4 +1,5 @@
|
||||||
import PreviewGroup from '../vc-image/src/PreviewGroup';
|
import PreviewGroup, { imageGroupProps } from '../vc-image/src/PreviewGroup';
|
||||||
|
import type { ExtractPropTypes } from 'vue';
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
|
|
||||||
|
@ -20,11 +21,13 @@ export const icons = {
|
||||||
right: <RightOutlined />,
|
right: <RightOutlined />,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ImageGroupProps = Partial<ExtractPropTypes<ReturnType<typeof imageGroupProps>>>;
|
||||||
|
|
||||||
const InternalPreviewGroup = defineComponent({
|
const InternalPreviewGroup = defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'AImagePreviewGroup',
|
name: 'AImagePreviewGroup',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: { previewPrefixCls: String },
|
props: imageGroupProps(),
|
||||||
setup(props, { attrs, slots }) {
|
setup(props, { attrs, slots }) {
|
||||||
const { getPrefixCls } = useConfigInject('image', props);
|
const { getPrefixCls } = useConfigInject('image', props);
|
||||||
const prefixCls = computed(() => getPrefixCls('image-preview', props.previewPrefixCls));
|
const prefixCls = computed(() => getPrefixCls('image-preview', props.previewPrefixCls));
|
||||||
|
|
|
@ -56,21 +56,23 @@ export const context = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const imageGroupProps = () => ({
|
||||||
|
previewPrefixCls: String,
|
||||||
|
preview: {
|
||||||
|
type: [Boolean, Object] as PropType<boolean | ImagePreviewType>,
|
||||||
|
default: true as boolean | ImagePreviewType,
|
||||||
|
},
|
||||||
|
icons: {
|
||||||
|
type: Object as PropType<PreviewProps['icons']>,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const Group = defineComponent({
|
const Group = defineComponent({
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
name: 'PreviewGroup',
|
name: 'PreviewGroup',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
props: {
|
props: imageGroupProps(),
|
||||||
previewPrefixCls: String,
|
|
||||||
preview: {
|
|
||||||
type: [Boolean, Object] as PropType<boolean | ImagePreviewType>,
|
|
||||||
default: true as boolean | ImagePreviewType,
|
|
||||||
},
|
|
||||||
icons: {
|
|
||||||
type: Object as PropType<PreviewProps['icons']>,
|
|
||||||
default: () => ({}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup(props, { slots }) {
|
setup(props, { slots }) {
|
||||||
const preview = computed<PreviewGroupPreview>(() => {
|
const preview = computed<PreviewGroupPreview>(() => {
|
||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
|
|
Loading…
Reference in New Issue