ant-design-vue/components/config-provider/renderEmpty.jsx

43 lines
1.1 KiB
Vue
Raw Normal View History

import PropTypes from '../_util/vue-types';
import Empty from '../empty';
import emptyImg from './empty.svg';
import { ConfigConsumerProps } from './';
2019-03-15 02:04:14 +00:00
const RenderEmpty = {
functional: true,
2019-03-15 02:04:14 +00:00
inject: {
2019-09-11 14:35:25 +00:00
configProvider: { default: () => ConfigConsumerProps },
2019-03-15 02:04:14 +00:00
},
props: {
componentName: PropTypes.string,
},
render(createElement, context) {
const { props, injections } = context;
function renderHtml(componentName) {
2019-09-11 14:35:25 +00:00
const getPrefixCls = injections.configProvider.getPrefixCls;
2019-03-15 02:04:14 +00:00
const prefix = getPrefixCls('empty');
switch (componentName) {
case 'Table':
case 'List':
2019-03-15 02:04:14 +00:00
return <Empty image={emptyImg} class={`${prefix}-normal`} />;
case 'Select':
case 'TreeSelect':
case 'Cascader':
case 'Transfer':
2019-03-15 02:04:14 +00:00
return <Empty image={emptyImg} class={`${prefix}-small`} />;
default:
return <Empty />;
}
}
return renderHtml(props.componentName);
},
};
2019-03-15 02:04:14 +00:00
function renderEmpty(h, componentName) {
return <RenderEmpty componentName={componentName} />;
}
export default renderEmpty;