2021-06-26 01:35:40 +00:00
|
|
|
import { inject } 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 '.';
|
2021-12-16 09:20:18 +00:00
|
|
|
import type { VueNode } from '../_util/type';
|
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
|
|
|
};
|
|
|
|
|
2021-12-16 09:20:18 +00:00
|
|
|
function renderEmpty(componentName?: string): VueNode {
|
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;
|