ant-design-vue/components/config-provider/renderEmpty.tsx

41 lines
1.1 KiB
Vue
Raw Normal View History

2021-06-26 01:35:40 +00:00
import type { VNodeChild } from 'vue';
import { inject } from 'vue';
import Empty from '../empty';
import { defaultConfigProvider } from '.';
2020-08-23 08:45:55 +00:00
export interface RenderEmptyProps {
componentName?: string;
}
const RenderEmpty = (props: RenderEmptyProps) => {
const configProvider = inject('configProvider', defaultConfigProvider);
2020-08-23 08:45:55 +00:00
const renderHtml = (componentName?: string) => {
const { getPrefixCls } = configProvider;
const prefix = getPrefixCls('empty');
switch (componentName) {
case 'Table':
case 'List':
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
2020-08-23 08:45:55 +00:00
case 'Select':
case 'TreeSelect':
case 'Cascader':
case 'Transfer':
case 'Mentions':
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} class={`${prefix}-small`} />;
2020-08-23 08:45:55 +00:00
default:
return <Empty />;
}
2020-08-23 08:45:55 +00:00
};
2020-10-12 07:47:32 +00:00
return renderHtml(props.componentName);
};
2020-10-19 08:43:10 +00:00
function renderEmpty(componentName?: string): VNodeChild | JSX.Element {
2019-03-15 02:04:14 +00:00
return <RenderEmpty componentName={componentName} />;
}
2020-09-29 14:06:01 +00:00
export type RenderEmptyHandler = typeof renderEmpty;
export default renderEmpty;