tdesign-vue
Version:
223 lines (219 loc) • 6.94 kB
JavaScript
/**
* tdesign v1.14.1
* (c) 2025 tdesign
* @license MIT
*/
import { defineComponent, computed } from '@vue/composition-api';
import { MirrorIcon, RotationIcon, ZoomOutIcon, ZoomInIcon, ImageIcon, DownloadIcon } from 'tdesign-icons-vue';
import TImageViewerIcon from './ImageModalIcon.js';
import { Tooltip } from '../../tooltip/index.js';
import '../../hooks/useConfig.js';
import '../../hooks/index.js';
import { largeNumberToFixed } from '../../_common/js/input-number/large-number.js';
import { useConfig } from '../../config-provider/useConfig.js';
import { useImagePreviewUrl } from '../../hooks/useImagePreviewUrl.js';
import '@babel/runtime/helpers/defineProperty';
import '../../hooks/tnode.js';
import 'lodash-es';
import '../../hooks/render-tnode.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-d2f11e9e.js';
import '@babel/runtime/helpers/typeof';
import '../../_chunks/dep-05dc6583.js';
import 'dayjs';
import '../../_chunks/dep-62386ed0.js';
import '../../config-provider/type.js';
import '../../_common/js/global-config/t.js';
import '@babel/runtime/helpers/slicedToArray';
import '../../tooltip/tooltip.js';
import '../../_chunks/dep-e77071c7.js';
import '../../tooltip/props.js';
import '../../popup/props.js';
import '../../popup/popup.js';
import '@popperjs/core';
import '../../utils/dom.js';
import 'vue';
import 'raf';
import '../../utils/easing.js';
import '../../utils/render-tnode.js';
import '@babel/runtime/helpers/readOnlyError';
import '../../utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '../../_common/js/utils/setStyle.js';
import '../../popup/container.js';
import '../../config-provider/config-receiver.js';
import '../../utils/mixins.js';
import '../../utils/event.js';
import '../../popup/utils.js';
import '../../utils/map-props.js';
import '../../utils/withInstall.js';
import './style/css.js';
import '../../tooltip/type.js';
import '../../hooks/slots.js';
import '../../hooks/useCommonClassName.js';
import '../../hooks/useDefaultValue.js';
import '../../hooks/useDestroyOnClose.js';
import '../../hooks/useElementLazyRender.js';
import '../../_common/js/utils/observe.js';
import '../../hooks/useFormDisabled.js';
import '../../hooks/useGlobalIcon.js';
import '../../hooks/useLazyLoad.js';
import '../../hooks/useResizeObserver.js';
import '../../hooks/useVirtualScrollNew.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../../hooks/useVModel.js';
import '../../hooks/useMutationObservable.js';
import '../../hooks/useVariables.js';
import '../../_common/js/utils/getColorTokenColor.js';
import '../../_common/js/common.js';
import '../../_common/js/upload/utils.js';
import '../../_common/js/log/log.js';
var currentImage = {
type: Object,
"default": function _default() {
return {};
}
};
var TImageViewerUtils = defineComponent({
name: "TImageViewerUtils",
props: {
scale: Number,
rotateHandler: Function,
zoomInHandler: Function,
zoomOutHandler: Function,
mirrorHandler: Function,
resetHandler: Function,
downloadHandler: Function,
globalConfig: Object,
currentImage: currentImage
},
setup: function setup(props) {
var _useConfig = useConfig("imageViewer"),
classPrefix = _useConfig.classPrefix;
var imageUrl = computed(function () {
return props.currentImage.mainImage;
});
var _useImagePreviewUrl = useImagePreviewUrl(imageUrl),
previewUrl = _useImagePreviewUrl.previewUrl;
return {
classPrefix: classPrefix,
previewUrl: previewUrl
};
},
render: function render() {
var _this = this;
var h = arguments[0];
return h("div", {
"class": "".concat(this.classPrefix, "-image-viewer__utils")
}, [h("div", {
"class": "".concat(this.classPrefix, "-image-viewer__utils-content")
}, [h(Tooltip, {
"attrs": {
"overlayClassName": "".concat(this.classPrefix, "-image-viewer__utils--tip"),
"content": this.globalConfig.mirrorTipText,
"destroyOnClose": true,
"placement": "top",
"showArrow": true,
"theme": "default"
}
}, [h(TImageViewerIcon, {
"attrs": {
"clickHandler": this.mirrorHandler,
"icon": function icon() {
return h(MirrorIcon, {
"attrs": {
"size": "medium"
}
});
}
}
})]), h(Tooltip, {
"attrs": {
"overlayClassName": "".concat(this.classPrefix, "-image-viewer__utils--tip"),
"content": this.globalConfig.rotateTipText,
"destroyOnClose": true,
"placement": "top",
"showArrow": true,
"theme": "default"
}
}, [h(TImageViewerIcon, {
"attrs": {
"clickHandler": this.rotateHandler,
"icon": function icon() {
return h(RotationIcon, {
"attrs": {
"size": "medium"
}
});
}
}
})]), h(TImageViewerIcon, {
"attrs": {
"icon": function icon() {
return h(ZoomOutIcon, {
"attrs": {
"size": "medium"
}
});
},
"clickHandler": this.zoomOutHandler
}
}), h(TImageViewerIcon, {
"class": "".concat(this.classPrefix, "-image-viewer__utils-scale"),
"attrs": {
"size": "medium",
"label": "".concat(largeNumberToFixed(String(this.scale * 100)), "%")
}
}), h(TImageViewerIcon, {
"attrs": {
"icon": function icon() {
return h(ZoomInIcon, {
"attrs": {
"size": "medium"
}
});
},
"clickHandler": this.zoomInHandler
}
}), h(Tooltip, {
"attrs": {
"overlayClassName": "".concat(this.classPrefix, "-image-viewer__utils--tip"),
"content": this.globalConfig.originalSizeTipText,
"destroyOnClose": true,
"placement": "top",
"showArrow": true,
"theme": "default"
}
}, [h("div", {
"class": "".concat(this.classPrefix, "-image-viewer__modal-icon")
}, [h(TImageViewerIcon, {
"attrs": {
"icon": function icon() {
return h(ImageIcon, {
"attrs": {
"size": "medium"
}
});
},
"clickHandler": this.resetHandler
}
})])]), this.currentImage.download && h(TImageViewerIcon, {
"attrs": {
"icon": function icon() {
return h(DownloadIcon, {
"attrs": {
"size": "medium"
}
});
},
"clickHandler": function clickHandler() {
_this.downloadHandler(_this.previewUrl);
}
}
})])]);
}
});
export { TImageViewerUtils as default };
//# sourceMappingURL=ImageViewerUtils.js.map