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

34 lines
998 B
TypeScript
Raw Normal View History

import React, { useContext } from 'react';
import { ConfigContext } from '.';
import type { ConfigConsumerProps } from '.';
2022-06-22 14:57:09 +08:00
import Empty from '../empty';
2018-12-26 16:01:00 +08:00
interface EmptyProps {
componentName?: string;
}
2018-12-26 16:01:00 +08:00
const DefaultRenderEmpty: React.FC<EmptyProps> = (props) => {
const { componentName } = props;
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext);
const prefix = getPrefixCls('empty');
switch (componentName) {
case 'Table':
case 'List':
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
case 'Select':
case 'TreeSelect':
case 'Cascader':
case 'Transfer':
case 'Mentions':
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-small`} />;
/* istanbul ignore next */
default:
// Should never hit if we take all the component into consider.
return <Empty />;
}
};
2018-12-26 16:01:00 +08:00
export type RenderEmptyHandler = (componentName?: string) => React.ReactNode;
export default DefaultRenderEmpty;