UNPKG

tdesign-vue

Version:
194 lines (190 loc) 6.93 kB
/** * tdesign v1.12.1 * (c) 2025 tdesign * @license MIT */ import { h as helper } from '../_chunks/dep-323b993c.js'; import { defineComponent, toRefs, computed } from '@vue/composition-api'; import { isString, isPlainObject } from 'lodash-es'; import { useConfig, usePrefixClass } from '../config-provider/useConfig.js'; import { useCommonClassName } from '../hooks/useConfig.js'; import props from './props.js'; import { Image } from '../image/index.js'; import { renderTNodeJSX } from '../utils/render-tnode.js'; import MaintenanceSvg from './assets/MaintenanceSvg.js'; import NetworkErrorSvg from './assets/NetworkErrorSvg.js'; import EmptySvg from './assets/EmptySvg.js'; import FailSvg from './assets/FailSvg.js'; import SuccessSvg from './assets/SuccessSvg.js'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-c44a474d.js'; import '@babel/runtime/helpers/typeof'; import '../_chunks/dep-d639fbd7.js'; import 'dayjs'; import '../_chunks/dep-3c66615e.js'; import '../config-provider/type.js'; import '../_common/js/global-config/t.js'; import '@babel/runtime/helpers/slicedToArray'; import '../image/image.js'; import 'tdesign-icons-vue'; import '../_common/js/utils/observe.js'; import '../image/props.js'; import '../space/index.js'; import '../space/space.js'; import '@babel/runtime/helpers/defineProperty'; import '../space/props.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import '@babel/runtime/helpers/readOnlyError'; import 'vue'; import '../utils/withInstall.js'; import './style/css.js'; import '../space/type.js'; import '../hooks/index.js'; import '../hooks/slots.js'; import '../hooks/useCommonClassName.js'; import '../hooks/useDefaultValue.js'; import '../hooks/useDestroyOnClose.js'; import '../hooks/useElementLazyRender.js'; import '../hooks/useFormDisabled.js'; import '../hooks/useGlobalIcon.js'; import '../hooks/useLazyLoad.js'; import '../hooks/useResizeObserver.js'; import '../hooks/useVirtualScrollNew.js'; import '../hooks/useVModel.js'; import '../hooks/useImagePreviewUrl.js'; import '../_common/js/upload/utils.js'; import '../_common/js/log/log.js'; import '../image/type.js'; var _Empty = defineComponent({ name: "TEmpty", components: { TImage: Image }, props: props, setup: function setup(props2, _ref) { var slots = _ref.slots; var _toRefs = toRefs(props2), size = _toRefs.size, propsImage = _toRefs.image, propsDescription = _toRefs.description, propsTitle = _toRefs.title, type = _toRefs.type; var _useConfig = useConfig("empty"), globalConfig = _useConfig.globalConfig; var componentName = usePrefixClass("empty"); var showAction = computed(function () { return props2.action || slots.action; }); var _useCommonClassName = useCommonClassName(), SIZE = _useCommonClassName.SIZE; var defaultMaps = { maintenance: { image: globalConfig.value.image.maintenance || MaintenanceSvg, title: globalConfig.value.titleText.maintenance }, success: { image: globalConfig.value.image.success || SuccessSvg, title: globalConfig.value.titleText.success }, fail: { image: globalConfig.value.image.fail || FailSvg, title: globalConfig.value.titleText.fail }, "network-error": { image: globalConfig.value.image.networkError || NetworkErrorSvg, title: globalConfig.value.titleText.networkError }, empty: { image: globalConfig.value.image.empty || EmptySvg, title: globalConfig.value.titleText.empty } }; var emptyClasses = computed(function () { return [componentName.value, SIZE.value[size.value]]; }); var titleClasses = ["".concat(componentName.value, "__title")]; var imageClasses = ["".concat(componentName.value, "__image")]; var descriptionClasses = ["".concat(componentName.value, "__description")]; var actionClass = ["".concat(componentName.value, "__action")]; var typeImageProps = computed(function () { var _defaultMaps$type$val; return (_defaultMaps$type$val = defaultMaps[type.value]) !== null && _defaultMaps$type$val !== void 0 ? _defaultMaps$type$val : null; }); var showImage = computed(function () { var _typeImageProps$value; return propsImage.value || slots.image || ((_typeImageProps$value = typeImageProps.value) === null || _typeImageProps$value === void 0 ? void 0 : _typeImageProps$value.image); }); var showTitle = computed(function () { var _typeImageProps$value2; return propsTitle.value || slots.title || ((_typeImageProps$value2 = typeImageProps.value) === null || _typeImageProps$value2 === void 0 ? void 0 : _typeImageProps$value2.title); }); var showDescription = computed(function () { return propsDescription.value || slots.description; }); return { emptyClasses: emptyClasses, imageClasses: imageClasses, titleClasses: titleClasses, descriptionClasses: descriptionClasses, actionClass: actionClass, showImage: showImage, showTitle: showTitle, showDescription: showDescription, showAction: showAction }; }, methods: { renderTitle: function renderTitle() { var h = this.$createElement; if (!this.showTitle) { return null; } return h("div", { "class": this.titleClasses }, [this.showTitle]); }, renderDescription: function renderDescription() { var h = this.$createElement; if (!this.showDescription) { return null; } return h("div", { "class": this.descriptionClasses }, [this.showDescription]); }, getImageIns: function getImageIns() { var h = this.$createElement; var data = this.showImage; var result = null; if (isString(data)) { result = h(Image, { "attrs": { "src": data } }); } else if (data && Reflect.has(data, "render")) { result = h(data); } else if (isPlainObject(data)) { result = h(Image, helper([{}, data])); } return data ? result : null; } }, render: function render() { var h = arguments[0]; return h("div", { "class": this.emptyClasses }, [this.showImage ? h("div", { "class": this.imageClasses, "style": this.imageStyle }, [this.$slots.image ? renderTNodeJSX(this, "image") : this.getImageIns()]) : null, this.renderTitle(), this.renderDescription(), this.showAction ? h("div", { "class": this.actionClass }, [renderTNodeJSX(this, "action")]) : null]); } }); export { _Empty as default }; //# sourceMappingURL=empty.js.map