UNPKG

tdesign-vue

Version:
220 lines (212 loc) 8.76 kB
/** * tdesign v1.15.0 * (c) 2026 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var helper = require('../_chunks/dep-4009cfe4.js'); var _defineProperty = require('@babel/runtime/helpers/defineProperty'); var Vue = require('vue'); var avatar_props = require('./props.js'); var utils_renderTnode = require('../utils/render-tnode.js'); var configProvider_configReceiver = require('../config-provider/config-receiver.js'); var image_index = require('../image/index.js'); var utils_mixins = require('../utils/mixins.js'); require('@babel/runtime/helpers/readOnlyError'); require('@babel/runtime/helpers/typeof'); require('@vue/composition-api'); require('../_chunks/dep-9c5b91d3.js'); require('../_chunks/dep-9a74c2be.js'); require('../_chunks/dep-689d381f.js'); require('../_chunks/dep-3b2292ce.js'); require('../_chunks/dep-10fcb46d.js'); require('../_chunks/dep-803744d9.js'); require('../_chunks/dep-ba7f5924.js'); require('../_chunks/dep-84027b7f.js'); require('../_chunks/dep-49400b00.js'); require('../_chunks/dep-f1081d8e.js'); require('../_chunks/dep-2c592e99.js'); require('../_chunks/dep-8eddb350.js'); require('../_common/js/global-config/default-config.js'); require('../_common/js/global-config/locale/zh_CN.js'); require('../_chunks/dep-0c37520c.js'); require('../_chunks/dep-c13dcbfd.js'); require('dayjs'); require('../_chunks/dep-6f4e680e.js'); require('../_chunks/dep-bb0ececf.js'); require('../_chunks/dep-6eba4d23.js'); require('../_chunks/dep-010db548.js'); require('../_chunks/dep-8d206316.js'); require('../_chunks/dep-2bc87cc8.js'); require('../_chunks/dep-f77d6ad5.js'); require('../_chunks/dep-9dae8101.js'); require('../_chunks/dep-7c84d9a0.js'); require('../_chunks/dep-733a2279.js'); require('../_chunks/dep-d844c9ed.js'); require('../_chunks/dep-c05a9033.js'); require('../_chunks/dep-efe55b82.js'); require('../_chunks/dep-7da70ee1.js'); require('../_chunks/dep-124386d4.js'); require('../_chunks/dep-f5b14344.js'); require('../_chunks/dep-36c2788b.js'); require('../_chunks/dep-fa353fbb.js'); require('../_chunks/dep-d66ab3a4.js'); require('../_chunks/dep-d4d8c513.js'); require('../_common/js/global-config/t.js'); require('@babel/runtime/helpers/slicedToArray'); require('../_chunks/dep-a2217d56.js'); require('../image/image.js'); require('tdesign-icons-vue'); require('../_common/js/utils/observe.js'); require('../config-provider/useConfig.js'); require('../image/props.js'); require('../space/index.js'); require('../space/space.js'); require('../space/props.js'); require('../hooks/useConfig.js'); require('../_common/js/utils/helper.js'); require('@babel/runtime/helpers/toConsumableArray'); require('@babel/runtime/helpers/objectWithoutProperties'); require('../_chunks/dep-721fcdf6.js'); require('../_chunks/dep-591b87f1.js'); require('../_chunks/dep-268c68b1.js'); require('../utils/withInstall.js'); require('../_chunks/dep-2c32d315.js'); require('../_chunks/dep-594e0165.js'); require('../_chunks/dep-7fbd94e9.js'); require('../_chunks/dep-56f568d3.js'); require('../_chunks/dep-82ce56ef.js'); require('../_chunks/dep-4e96e31a.js'); require('../_chunks/dep-1e173c2b.js'); require('../_chunks/dep-da2ef9c3.js'); require('../_chunks/dep-a96e5563.js'); require('../hooks/useImagePreviewUrl.js'); require('../_common/js/upload/utils.js'); require('../_common/js/log/log.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty); var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var classPrefixMixins = configProvider_configReceiver.getClassPrefixMixins("avatar"); var _Avatar = utils_mixins["default"](Vue__default["default"], classPrefixMixins).extend({ name: "TAvatar", props: _objectSpread({}, avatar_props["default"]), data: function data() { return { isImgExist: true, gap: 4, scale: "" }; }, inject: { avatarGroup: { "default": void 0 } }, computed: { sizeValue: function sizeValue() { var _this$avatarGroup; return this.size || ((_this$avatarGroup = this.avatarGroup) === null || _this$avatarGroup === void 0 ? void 0 : _this$avatarGroup.size); }, customAvatarSize: function customAvatarSize() { return this.isCustomSize() ? { width: this.sizeValue, height: this.sizeValue, "font-size": "".concat(Number.parseInt(this.sizeValue, 10) / 2, "px") } : {}; }, customImageSize: function customImageSize() { return this.isCustomSize() ? { height: this.sizeValue, width: this.sizeValue } : {}; }, customCharacterSize: function customCharacterSize() { return { transform: this.scale }; } }, mounted: function mounted() { var _this = this; this.$nextTick(function () { _this.setScaleParams(); }); }, methods: { handleImgLoadError: function handleImgLoadError(context) { var onError = this.onError, hideOnLoadFailed = this.hideOnLoadFailed; this.isImgExist = !hideOnLoadFailed; this.$emit("error", context); onError && onError(context); }, setScaleParams: function setScaleParams() { var avatar = this.$refs.avatar; var avatarChild = this.$refs.avatarChild; var avatarWidth = avatar === null || avatar === void 0 ? void 0 : avatar.offsetWidth; var avatarChildWidth = avatarChild === null || avatarChild === void 0 ? void 0 : avatarChild.offsetWidth; if (this.gap * 2 < avatarWidth) { this.scale = avatarChildWidth > avatarWidth - this.gap * 2 ? "scale(".concat((avatarWidth - this.gap * 2) / avatarChildWidth, ")") : "scale(1)"; } }, isCustomSize: function isCustomSize() { return this.sizeValue && !this.commonSizeClassName[this.sizeValue]; } }, updated: function updated() { var _this2 = this; this.$nextTick(function () { _this2.setScaleParams(); }); }, render: function render() { var h = arguments[0]; var content = utils_renderTnode.renderContent(this, "default", "content"); var icon = utils_renderTnode.renderTNodeJSX(this, "icon"); var isIconOnly = icon && !content; var _this$$props = this.$props, shape = _this$$props.shape, image = _this$$props.image, alt = _this$$props.alt; var avatarClass = [this.componentName, this.commonSizeClassName[this.sizeValue], _defineProperty__default["default"](_defineProperty__default["default"](_defineProperty__default["default"]({}, "".concat(this.componentName, "--circle"), shape === "circle"), "".concat(this.componentName, "--round"), shape === "round"), "".concat(this.componentName, "__icon"), !!isIconOnly)]; content = h("span", { "ref": "avatarChild", "style": _objectSpread({}, this.customCharacterSize) }, [content]); if (icon) { content = [icon, !isIconOnly ? content : ""]; } if (image && this.isImgExist) { var _this$imageProps, _this$imageProps2; content = h(image_index.Image, helper.helper([{ "style": _objectSpread({}, this.customImageSize), "attrs": { "src": image, "alt": alt } }, { "props": this.imageProps }, { "attrs": { "error": !this.$scopedSlots.error && !((_this$imageProps = this.imageProps) !== null && _this$imageProps !== void 0 && _this$imageProps.error) ? " " : void 0, "loading": !this.$scopedSlots.loading && !((_this$imageProps2 = this.imageProps) !== null && _this$imageProps2 !== void 0 && _this$imageProps2.loading) ? " " : void 0 }, "scopedSlots": this.$scopedSlots }, { "on": { error: this.handleImgLoadError } }])); } return h("div", { "ref": "avatar", "class": avatarClass, "style": this.customAvatarSize }, [content]); } }); exports["default"] = _Avatar; //# sourceMappingURL=avatar.js.map