2019-03-08 13:48:55 +08:00
|
|
|
import Empty from '../empty';
|
2021-12-16 17:20:18 +08:00
|
|
|
import type { VueNode } from '../_util/type';
|
2022-03-12 09:56:32 +08:00
|
|
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
2019-03-08 13:48:55 +08:00
|
|
|
|
2020-08-23 16:45:55 +08:00
|
|
|
export interface RenderEmptyProps {
|
|
|
|
componentName?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const RenderEmpty = (props: RenderEmptyProps) => {
|
2022-03-12 09:56:32 +08:00
|
|
|
const { prefixCls } = useConfigInject('empty', props);
|
2020-08-23 16:45:55 +08:00
|
|
|
const renderHtml = (componentName?: string) => {
|
|
|
|
switch (componentName) {
|
|
|
|
case 'Table':
|
|
|
|
case 'List':
|
|
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
2019-03-08 13:48:55 +08:00
|
|
|
|
2020-08-23 16:45:55 +08:00
|
|
|
case 'Select':
|
|
|
|
case 'TreeSelect':
|
|
|
|
case 'Cascader':
|
|
|
|
case 'Transfer':
|
|
|
|
case 'Mentions':
|
2022-03-12 09:56:32 +08:00
|
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} class={`${prefixCls.value}-small`} />;
|
2019-03-08 13:48:55 +08:00
|
|
|
|
2020-08-23 16:45:55 +08:00
|
|
|
default:
|
|
|
|
return <Empty />;
|
2019-03-08 13:48:55 +08:00
|
|
|
}
|
2020-08-23 16:45:55 +08:00
|
|
|
};
|
2020-10-12 15:47:32 +08:00
|
|
|
return renderHtml(props.componentName);
|
2019-03-08 13:48:55 +08:00
|
|
|
};
|
|
|
|
|
2021-12-16 17:20:18 +08:00
|
|
|
function renderEmpty(componentName?: string): VueNode {
|
2019-03-15 10:04:14 +08:00
|
|
|
return <RenderEmpty componentName={componentName} />;
|
|
|
|
}
|
|
|
|
|
2020-09-29 22:06:01 +08:00
|
|
|
export type RenderEmptyHandler = typeof renderEmpty;
|
|
|
|
|
2019-03-08 13:48:55 +08:00
|
|
|
export default renderEmpty;
|