ant-design-vue/components/image/index.tsx

43 lines
1.2 KiB
Vue
Raw Normal View History

2021-06-19 22:13:13 +08:00
import { App, defineComponent, ExtractPropTypes, ImgHTMLAttributes, Plugin } from 'vue';
import ImageInternal from '../vc-image';
2021-06-09 22:30:32 +08:00
import { imageProps } from '../vc-image/src/Image';
2021-06-19 22:13:13 +08:00
import useConfigInject from '../_util/hooks/useConfigInject';
import PreviewGroup from './PreviewGroup';
2021-06-09 22:30:32 +08:00
export type ImageProps = Partial<
ExtractPropTypes<typeof imageProps> & Omit<ImgHTMLAttributes, 'placeholder' | 'onClick'>
>;
const Image = defineComponent<ImageProps>({
name: 'AImage',
inheritAttrs: false,
2021-06-09 22:30:32 +08:00
props: imageProps as any,
2021-06-19 22:13:13 +08:00
setup(props, { slots, attrs }) {
const { prefixCls } = useConfigInject('image', props);
return () => {
2021-06-19 22:13:13 +08:00
return (
<ImageInternal
{...{ ...attrs, ...props, prefixCls: prefixCls.value }}
v-slots={slots}
></ImageInternal>
);
};
},
});
2021-06-09 22:30:32 +08:00
export { imageProps };
Image.PreviewGroup = PreviewGroup;
2021-06-23 23:08:16 +08:00
Image.install = function (app: App) {
app.component(Image.name, Image);
app.component(Image.PreviewGroup.name, Image.PreviewGroup);
return app;
};
2021-06-23 21:47:53 +08:00
export { PreviewGroup as ImagePreviewGroup };
export default Image as typeof Image &
Plugin & {
readonly PreviewGroup: typeof PreviewGroup;
};