tdesign-vue
Version:
104 lines (98 loc) • 3.71 kB
JavaScript
/**
* tdesign v1.15.0
* (c) 2026 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var VueCompositionAPI = require('@vue/composition-api');
var qrcode_components_props = require('./props.js');
var _common_js_qrcode_utils = require('../../_common/js/qrcode/utils.js');
var qrcode_hooks_useQRCode = require('../hooks/useQRCode.js');
require('../../_common/js/qrcode/qrcodegen.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('@babel/runtime/helpers/defineProperty');
var QRCodeSVG = VueCompositionAPI.defineComponent({
name: "QRCodeSVG",
props: qrcode_components_props.QRCodeSubComponentProps,
setup: function setup(props) {
var qrCodeData = VueCompositionAPI.computed(function () {
return qrcode_hooks_useQRCode.useQRCode({
value: props.value,
level: props.level,
minVersion: _common_js_qrcode_utils.DEFAULT_MINVERSION,
includeMargin: _common_js_qrcode_utils.DEFAULT_NEED_MARGIN,
marginSize: props.marginSize,
imageSettings: props.imageSettings,
size: props.size
});
});
var cellsToDraw = VueCompositionAPI.computed(function () {
var _calculatedImageSetti;
var _qrCodeData$value = qrCodeData.value,
cells = _qrCodeData$value.cells,
calculatedImageSettings2 = _qrCodeData$value.calculatedImageSettings;
if (props.imageSettings && ((_calculatedImageSetti = calculatedImageSettings2.value) === null || _calculatedImageSetti === void 0 ? void 0 : _calculatedImageSetti.excavation) != null) {
return _common_js_qrcode_utils.excavateModules(cells.value, calculatedImageSettings2.value.excavation);
}
return cells.value;
});
var calculatedImageSettings = VueCompositionAPI.computed(function () {
return qrCodeData.value.calculatedImageSettings.value;
});
var margin = VueCompositionAPI.computed(function () {
return qrCodeData.value.margin.value;
});
var numCells = VueCompositionAPI.computed(function () {
return qrCodeData.value.numCells.value;
});
return {
cellsToDraw: cellsToDraw,
calculatedImageSettings: calculatedImageSettings,
margin: margin,
numCells: numCells
};
},
render: function render() {
var _this = this;
var h = arguments[0];
var fgPath = _common_js_qrcode_utils.generatePath(this.cellsToDraw, this.margin);
var imageNode = function imageNode() {
if (!_this.imageSettings || !_this.calculatedImageSettings) return null;
return h("image", {
"attrs": {
"href": _this.imageSettings.src,
"height": _this.calculatedImageSettings.h,
"width": _this.calculatedImageSettings.w,
"x": _this.calculatedImageSettings.x + _this.margin,
"y": _this.calculatedImageSettings.y + _this.margin,
"crossOrigin": _this.calculatedImageSettings.crossOrigin
}
});
};
return h("svg", {
"attrs": {
"height": this.size,
"width": this.size,
"viewBox": "0 0 ".concat(this.numCells, " ").concat(this.numCells),
"role": "img"
},
"style": this.style
}, [!!this.title && h("title", [this.title]), h("path", {
"attrs": {
"fill": this.bgColor,
"d": "M0,0 h".concat(this.numCells, "v").concat(this.numCells, "H0z"),
"shape-rendering": "crispEdges"
}
}), h("path", {
"attrs": {
"fill": this.fgColor,
"d": fgPath,
"shape-rendering": "crispEdges"
}
}), imageNode()]);
}
});
exports["default"] = QRCodeSVG;
//# sourceMappingURL=qrcode-svg.js.map