2018-12-26 16:01:00 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import Empty from '../empty';
|
2022-05-07 14:31:54 +08:00
|
|
|
import type { ConfigConsumerProps } from '.';
|
|
|
|
import { ConfigConsumer } from '.';
|
2018-12-26 16:01:00 +08:00
|
|
|
|
2022-05-16 16:34:42 +08:00
|
|
|
const defaultRenderEmpty = (componentName?: string): React.ReactNode => (
|
2018-12-26 16:01:00 +08:00
|
|
|
<ConfigConsumer>
|
|
|
|
{({ getPrefixCls }: ConfigConsumerProps) => {
|
|
|
|
const prefix = getPrefixCls('empty');
|
|
|
|
|
|
|
|
switch (componentName) {
|
|
|
|
case 'Table':
|
|
|
|
case 'List':
|
2019-04-03 18:59:02 +08:00
|
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
2018-12-26 16:01:00 +08:00
|
|
|
|
|
|
|
case 'Select':
|
|
|
|
case 'TreeSelect':
|
|
|
|
case 'Cascader':
|
|
|
|
case 'Transfer':
|
2019-05-17 12:05:03 +08:00
|
|
|
case 'Mentions':
|
2019-03-20 17:45:35 +08:00
|
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-small`} />;
|
2022-05-16 16:34:42 +08:00
|
|
|
|
|
|
|
/* istanbul ignore next */
|
2018-12-26 16:01:00 +08:00
|
|
|
default:
|
2022-05-16 16:34:42 +08:00
|
|
|
// Should never hit if we take all the component into consider.
|
2018-12-26 16:01:00 +08:00
|
|
|
return <Empty />;
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
</ConfigConsumer>
|
|
|
|
);
|
|
|
|
|
2022-05-16 16:34:42 +08:00
|
|
|
export type RenderEmptyHandler = typeof defaultRenderEmpty;
|
2018-12-26 16:01:00 +08:00
|
|
|
|
2022-05-16 16:34:42 +08:00
|
|
|
export default defaultRenderEmpty;
|