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

44 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 10:04:14 +08:00
const RenderEmpty = {
functional: true,
2019-03-15 10:04:14 +08:00
inject: {
configProvider: { default: () => ({}) },
},
props: {
componentName: PropTypes.string,
},
render(createElement, context) {
const { props, injections } = context;
function renderHtml(componentName) {
2019-05-28 11:37:38 +08:00
const getPrefixCls =
injections.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls;
2019-03-15 10:04:14 +08:00
const prefix = getPrefixCls('empty');
switch (componentName) {
case 'Table':
case 'List':
2019-03-15 10:04:14 +08:00
return <Empty image={emptyImg} class={`${prefix}-normal`} />;
case 'Select':
case 'TreeSelect':
case 'Cascader':
case 'Transfer':
2019-03-15 10:04:14 +08:00
return <Empty image={emptyImg} class={`${prefix}-small`} />;
default:
return <Empty />;
}
}
return renderHtml(props.componentName);
},
};
2019-03-15 10:04:14 +08:00
function renderEmpty(h, componentName) {
return <RenderEmpty componentName={componentName} />;
}
export default renderEmpty;