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

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-10-16 10:47:28 +00:00
import { inject, VNodeChild } 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-16 10:47:28 +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;