2018-12-26 16:01:00 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
import Empty from '../empty';
|
|
|
|
import { ConfigConsumer, ConfigConsumerProps } from './';
|
2019-01-07 14:43:51 +08:00
|
|
|
import emptyImg from './empty.svg';
|
2018-12-26 16:01:00 +08:00
|
|
|
|
|
|
|
const renderEmpty = (componentName?: string): React.ReactNode => (
|
|
|
|
<ConfigConsumer>
|
|
|
|
{({ getPrefixCls }: ConfigConsumerProps) => {
|
|
|
|
const prefix = getPrefixCls('empty');
|
|
|
|
|
|
|
|
switch (componentName) {
|
|
|
|
case 'Table':
|
|
|
|
case 'List':
|
|
|
|
return <Empty image={emptyImg} className={`${prefix}-normal`} />;
|
|
|
|
|
|
|
|
case 'Select':
|
|
|
|
case 'TreeSelect':
|
|
|
|
case 'Cascader':
|
|
|
|
case 'Transfer':
|
|
|
|
return <Empty image={emptyImg} className={`${prefix}-small`} />;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return <Empty />;
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
</ConfigConsumer>
|
|
|
|
);
|
|
|
|
|
|
|
|
export type RenderEmptyHandler = typeof renderEmpty;
|
|
|
|
|
|
|
|
export default renderEmpty;
|