ant-design/components/config-provider/renderEmpty.tsx

32 lines
852 B
TypeScript
Raw Normal View History

2018-12-26 16:01:00 +08:00
import * as React from 'react';
import Empty from '../empty';
import type { ConfigConsumerProps } from '.';
import { ConfigConsumer } from '.';
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={Empty.PRESENTED_IMAGE_SIMPLE} />;
2018-12-26 16:01:00 +08:00
case 'Select':
case 'TreeSelect':
case 'Cascader':
case 'Transfer':
case 'Mentions':
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-small`} />;
2018-12-26 16:01:00 +08:00
default:
return <Empty />;
}
}}
</ConfigConsumer>
);
export type RenderEmptyHandler = typeof renderEmpty;
export default renderEmpty;