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

35 lines
983 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 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':
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`} />;
/* istanbul ignore next */
2018-12-26 16:01:00 +08:00
default:
// Should never hit if we take all the component into consider.
2018-12-26 16:01:00 +08:00
return <Empty />;
}
}}
</ConfigConsumer>
);
export type RenderEmptyHandler = typeof defaultRenderEmpty;
2018-12-26 16:01:00 +08:00
export default defaultRenderEmpty;