UNPKG

vue-ant-patterns

Version:

vue-ant-patterns

86 lines (80 loc) 2.26 kB
import _extends from 'babel-runtime/helpers/extends'; import _defineProperty from 'babel-runtime/helpers/defineProperty'; import cx from 'classnames'; import { Avatar } from 'ant-design-vue'; import PropTypes from 'ant-design-vue/es/_util/vue-types'; import { filterEmpty } from 'ant-design-vue/es/_util/props-util'; var preClass = 'depot-avatar'; export default { name: 'DAvatar', props: { prefixCls: PropTypes.string.def('depot-avatar'), size: { validator: function validator(val) { return typeof val === 'number' || ['xl', 'xxl', 'large', 'small', 'default'].includes(val); }, 'default': 'default' }, shape: { validator: function validator(val) { return ['circle', 'square'].includes(val); }, 'default': 'circle' }, src: String, /** Srcset of image avatar */ srcSet: String, icon: String, alt: String, loadError: Function }, data: function data() { var src = this.$props.src; return { imgSrc: src }; }, watch: { src: function src(newVal) { this.imgSrc = newVal; } }, methods: {}, render: function render() { var _sizeCls; var h = arguments[0]; var $slots = this.$slots, $listeners = this.$listeners, $props = this.$props, imgSrc = this.imgSrc; var icon = $props.icon, alt = $props.alt, srcSet = $props.srcSet, size = $props.size, shape = $props.shape, prefixCls = $props.prefixCls; var children = filterEmpty($slots['default']); children = children.length === 0 ? undefined : children; var sizeCls = (_sizeCls = {}, _defineProperty(_sizeCls, prefixCls + '-xxl', size === 'xxl'), _defineProperty(_sizeCls, prefixCls + '-xl', size === 'xl'), _sizeCls); var AvatarProps = { 'class': cx(_extends(_defineProperty({}, 'depot-avatar', 1), sizeCls)), // attrs: { // ...$attrs, // }, props: { src: imgSrc, icon: icon, alt: alt, srcSet: srcSet, size: size === 'xl' ? 80 : size === 'xxl' ? 120 : size, shape: shape }, on: _extends({}, $listeners) }; return h( Avatar, AvatarProps, [children] ); } };