2020-10-16 10:47:28 +00:00
|
|
|
import { inject, VNodeChild } from 'vue';
|
2019-03-08 05:48:55 +00:00
|
|
|
import Empty from '../empty';
|
2020-09-30 02:47:18 +00:00
|
|
|
import { defaultConfigProvider } from '.';
|
2019-03-08 05:48:55 +00:00
|
|
|
|
2020-08-23 08:45:55 +00:00
|
|
|
export interface RenderEmptyProps {
|
|
|
|
componentName?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const RenderEmpty = (props: RenderEmptyProps) => {
|
2020-09-30 02:47:18 +00:00
|
|
|
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} />;
|
2019-03-08 05:48:55 +00:00
|
|
|
|
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`} />;
|
2019-03-08 05:48:55 +00:00
|
|
|
|
2020-08-23 08:45:55 +00:00
|
|
|
default:
|
|
|
|
return <Empty />;
|
2019-03-08 05:48:55 +00:00
|
|
|
}
|
2020-08-23 08:45:55 +00:00
|
|
|
};
|
2020-10-12 07:47:32 +00:00
|
|
|
return renderHtml(props.componentName);
|
2019-03-08 05:48:55 +00:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2019-03-08 05:48:55 +00:00
|
|
|
export default renderEmpty;
|