qrcode.vue 3.7.1 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/qrcode.vue.browser.js +120 -172
- package/dist/qrcode.vue.browser.min.js +2 -2
- package/dist/qrcode.vue.cjs.js +120 -172
- package/dist/qrcode.vue.esm.js +121 -173
- package/dist/src/index.d.ts +3 -1
- package/package.json +8 -8
package/dist/qrcode.vue.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* qrcode.vue v3.
|
|
2
|
+
* qrcode.vue v3.8.1
|
|
3
3
|
* A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3
|
|
4
4
|
* © 2017-PRESENT @scopewu(https://github.com/scopewu)
|
|
5
5
|
* MIT License.
|
|
6
6
|
*/
|
|
7
|
-
import { defineComponent,
|
|
7
|
+
import { defineComponent, h, ref, onMounted, watchEffect, Fragment, computed } from 'vue';
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -905,10 +905,12 @@ var qrcodegen;
|
|
|
905
905
|
})(qrcodegen || (qrcodegen = {}));
|
|
906
906
|
var QR = qrcodegen;
|
|
907
907
|
|
|
908
|
+
var _uid = 0;
|
|
908
909
|
var defaultErrorCorrectLevel = 'L';
|
|
909
910
|
var DEFAULT_QR_SIZE = 100;
|
|
910
911
|
var DEFAULT_MARGIN = 0;
|
|
911
912
|
var DEFAULT_IMAGE_SIZE_RATIO = 0.1;
|
|
913
|
+
var IMAGE_EXCAVATE_THICKNESS = 2;
|
|
912
914
|
var ErrorCorrectLevelMap = {
|
|
913
915
|
L: QR.QrCode.Ecc.LOW,
|
|
914
916
|
M: QR.QrCode.Ecc.MEDIUM,
|
|
@@ -928,78 +930,43 @@ var SUPPORTS_PATH2D = (function () {
|
|
|
928
930
|
function validErrorCorrectLevel(level) {
|
|
929
931
|
return level in ErrorCorrectLevelMap;
|
|
930
932
|
}
|
|
931
|
-
function isPointInRoundedRect(px, py, rx, ry, rw, rh, r) {
|
|
932
|
-
// Fast check: point outside the bounding box
|
|
933
|
-
if (px < rx || px > rx + rw || py < ry || py > ry + rh) {
|
|
934
|
-
return false;
|
|
935
|
-
}
|
|
936
|
-
// If no border radius or point is in the center rectangle
|
|
937
|
-
if (r <= 0 || (px > rx + r && px < rx + rw - r) || (py > ry + r && py < ry + rh - r)) {
|
|
938
|
-
return true;
|
|
939
|
-
}
|
|
940
|
-
// Check the four corners
|
|
941
|
-
// Top-left corner
|
|
942
|
-
if (px < rx + r && py < ry + r) {
|
|
943
|
-
var dx = px - (rx + r);
|
|
944
|
-
var dy = py - (ry + r);
|
|
945
|
-
return dx * dx + dy * dy <= r * r;
|
|
946
|
-
}
|
|
947
|
-
// Top-right corner
|
|
948
|
-
if (px > rx + rw - r && py < ry + r) {
|
|
949
|
-
var dx = px - (rx + rw - r);
|
|
950
|
-
var dy = py - (ry + r);
|
|
951
|
-
return dx * dx + dy * dy <= r * r;
|
|
952
|
-
}
|
|
953
|
-
// Bottom-left corner
|
|
954
|
-
if (px < rx + r && py > ry + rh - r) {
|
|
955
|
-
var dx = px - (rx + r);
|
|
956
|
-
var dy = py - (ry + rh - r);
|
|
957
|
-
return dx * dx + dy * dy <= r * r;
|
|
958
|
-
}
|
|
959
|
-
// Bottom-right corner
|
|
960
|
-
if (px > rx + rw - r && py > ry + rh - r) {
|
|
961
|
-
var dx = px - (rx + rw - r);
|
|
962
|
-
var dy = py - (ry + rh - r);
|
|
963
|
-
return dx * dx + dy * dy <= r * r;
|
|
964
|
-
}
|
|
965
|
-
return true;
|
|
966
|
-
}
|
|
967
933
|
function generatePath(modules, margin) {
|
|
968
934
|
if (margin === void 0) { margin = 0; }
|
|
969
|
-
var
|
|
970
|
-
|
|
935
|
+
var pathSegments = [];
|
|
936
|
+
for (var y = 0; y < modules.length; y++) {
|
|
937
|
+
var row = modules[y];
|
|
971
938
|
var start = null;
|
|
972
|
-
|
|
939
|
+
for (var x = 0; x < row.length; x++) {
|
|
940
|
+
var cell = row[x];
|
|
973
941
|
if (!cell && start !== null) {
|
|
974
942
|
// M0 0h7v1H0z injects the space with the move and drops the comma,
|
|
975
|
-
|
|
976
|
-
path += "M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z");
|
|
943
|
+
pathSegments.push("M".concat(start + margin, " ").concat(y + margin, "h").concat(x - start, "v1H").concat(start + margin, "z"));
|
|
977
944
|
start = null;
|
|
978
|
-
|
|
945
|
+
continue;
|
|
979
946
|
}
|
|
980
947
|
// end of row, clean up or skip
|
|
981
948
|
if (x === row.length - 1) {
|
|
982
949
|
if (!cell) {
|
|
983
950
|
// We would have closed the op above already so this can only mean
|
|
984
951
|
// 2+ light modules in a row.
|
|
985
|
-
|
|
952
|
+
continue;
|
|
986
953
|
}
|
|
987
954
|
if (start === null) {
|
|
988
955
|
// Just a single dark module.
|
|
989
|
-
|
|
956
|
+
pathSegments.push("M".concat(x + margin, ",").concat(y + margin, " h1v1H").concat(x + margin, "z"));
|
|
990
957
|
}
|
|
991
958
|
else {
|
|
992
959
|
// Otherwise finish the current line.
|
|
993
|
-
|
|
960
|
+
pathSegments.push("M".concat(start + margin, ",").concat(y + margin, " h").concat(x + 1 - start, "v1H").concat(start + margin, "z"));
|
|
994
961
|
}
|
|
995
|
-
|
|
962
|
+
continue;
|
|
996
963
|
}
|
|
997
964
|
if (cell && start === null) {
|
|
998
965
|
start = x;
|
|
999
966
|
}
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
return
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return pathSegments.join('');
|
|
1003
970
|
}
|
|
1004
971
|
function getImageSettings(cells, size, margin, imageSettings) {
|
|
1005
972
|
var width = imageSettings.width, height = imageSettings.height, imageX = imageSettings.x, imageY = imageSettings.y;
|
|
@@ -1021,30 +988,40 @@ function getImageSettings(cells, size, margin, imageSettings) {
|
|
|
1021
988
|
}
|
|
1022
989
|
return { x: x, y: y, h: h, w: w, borderRadius: borderRadius, excavation: excavation };
|
|
1023
990
|
}
|
|
1024
|
-
function
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
991
|
+
function useQRCode(props) {
|
|
992
|
+
var margin = computed(function () { var _a; return ((_a = props.margin) !== null && _a !== void 0 ? _a : DEFAULT_MARGIN) >>> 0; });
|
|
993
|
+
var cells = computed(function () {
|
|
994
|
+
var level = validErrorCorrectLevel(props.level) ? props.level : defaultErrorCorrectLevel;
|
|
995
|
+
return QR.QrCode.encodeText(props.value, ErrorCorrectLevelMap[level]).getModules();
|
|
996
|
+
});
|
|
997
|
+
var numCells = computed(function () { return cells.value.length + margin.value * 2; });
|
|
998
|
+
var fgPath = computed(function () { return generatePath(cells.value, margin.value); });
|
|
999
|
+
var imageProps = computed(function () {
|
|
1000
|
+
if (!props.imageSettings.src) {
|
|
1001
|
+
return { x: 0, y: 0, width: 0, height: 0, borderRadius: 0 };
|
|
1002
|
+
}
|
|
1003
|
+
var settings = getImageSettings(cells.value, props.size, margin.value, props.imageSettings);
|
|
1004
|
+
return {
|
|
1005
|
+
x: settings.x + margin.value,
|
|
1006
|
+
y: settings.y + margin.value,
|
|
1007
|
+
width: settings.w,
|
|
1008
|
+
height: settings.h,
|
|
1009
|
+
borderRadius: settings.borderRadius,
|
|
1010
|
+
};
|
|
1011
|
+
});
|
|
1012
|
+
var imageBorderProps = computed(function () {
|
|
1013
|
+
if (!props.imageSettings.excavate || !props.imageSettings.src)
|
|
1014
|
+
return null;
|
|
1015
|
+
var borderThickness = IMAGE_EXCAVATE_THICKNESS / (props.size / numCells.value);
|
|
1016
|
+
return {
|
|
1017
|
+
x: imageProps.value.x - borderThickness,
|
|
1018
|
+
y: imageProps.value.y - borderThickness,
|
|
1019
|
+
width: imageProps.value.width + borderThickness * 2,
|
|
1020
|
+
height: imageProps.value.height + borderThickness * 2,
|
|
1021
|
+
borderRadius: imageProps.value.borderRadius,
|
|
1022
|
+
};
|
|
1047
1023
|
});
|
|
1024
|
+
return { margin: margin, numCells: numCells, cells: cells, fgPath: fgPath, imageProps: imageProps, imageBorderProps: imageBorderProps };
|
|
1048
1025
|
}
|
|
1049
1026
|
var QRCodeProps = {
|
|
1050
1027
|
value: {
|
|
@@ -1111,37 +1088,10 @@ var QrcodeSvg = defineComponent({
|
|
|
1111
1088
|
name: 'QRCodeSvg',
|
|
1112
1089
|
props: QRCodeProps,
|
|
1113
1090
|
setup: function (props) {
|
|
1114
|
-
var
|
|
1115
|
-
var
|
|
1116
|
-
var
|
|
1117
|
-
var
|
|
1118
|
-
var value = props.value, _level = props.level, _margin = props.margin;
|
|
1119
|
-
var margin = _margin >>> 0;
|
|
1120
|
-
var level = validErrorCorrectLevel(_level) ? _level : defaultErrorCorrectLevel;
|
|
1121
|
-
var cells = QR.QrCode.encodeText(value, ErrorCorrectLevelMap[level]).getModules();
|
|
1122
|
-
numCells.value = cells.length + margin * 2;
|
|
1123
|
-
if (props.imageSettings.src) {
|
|
1124
|
-
var imageSettings = getImageSettings(cells, props.size, margin, props.imageSettings);
|
|
1125
|
-
imageProps.value = {
|
|
1126
|
-
x: imageSettings.x + margin,
|
|
1127
|
-
y: imageSettings.y + margin,
|
|
1128
|
-
width: imageSettings.w,
|
|
1129
|
-
height: imageSettings.h,
|
|
1130
|
-
borderRadius: imageSettings.borderRadius,
|
|
1131
|
-
};
|
|
1132
|
-
if (imageSettings.excavation) {
|
|
1133
|
-
cells = excavateModules(cells, imageSettings.excavation, imageSettings.borderRadius);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
// Drawing strategy: instead of a rect per module, we're going to create a
|
|
1137
|
-
// single path for the dark modules and layer that on top of a light rect,
|
|
1138
|
-
// for a total of 2 DOM nodes. We pay a bit more in string concat but that's
|
|
1139
|
-
// way faster than DOM ops.
|
|
1140
|
-
// For level 1, 441 nodes -> 2
|
|
1141
|
-
// For level 40, 31329 -> 2
|
|
1142
|
-
fgPath.value = generatePath(cells, margin);
|
|
1143
|
-
};
|
|
1144
|
-
var qrGradientId = 'qrcode.vue-gradient';
|
|
1091
|
+
var _a = useQRCode(props), numCells = _a.numCells, fgPath = _a.fgPath, imageProps = _a.imageProps, imageBorderProps = _a.imageBorderProps;
|
|
1092
|
+
var uid = _uid++;
|
|
1093
|
+
var qrGradientId = "qrcode.vue-gradient-".concat(uid);
|
|
1094
|
+
var qrLogoClipPathId = "qrcode.vue-logo-clip-path-".concat(uid);
|
|
1145
1095
|
var renderGradient = function () {
|
|
1146
1096
|
if (!props.gradient)
|
|
1147
1097
|
return null;
|
|
@@ -1170,7 +1120,6 @@ var QrcodeSvg = defineComponent({
|
|
|
1170
1120
|
}),
|
|
1171
1121
|
]);
|
|
1172
1122
|
};
|
|
1173
|
-
var qrLogoClipPathId = 'qrcode.vue-logo-clip-path';
|
|
1174
1123
|
var renderClipPath = function () {
|
|
1175
1124
|
var borderRadius = imageProps.value.borderRadius;
|
|
1176
1125
|
if (!props.imageSettings.src)
|
|
@@ -1188,14 +1137,14 @@ var QrcodeSvg = defineComponent({
|
|
|
1188
1137
|
}),
|
|
1189
1138
|
]);
|
|
1190
1139
|
};
|
|
1191
|
-
generate();
|
|
1192
|
-
watch(props, generate, { deep: true });
|
|
1193
1140
|
return function () { return h('svg', {
|
|
1194
1141
|
width: props.size,
|
|
1195
1142
|
height: props.size,
|
|
1196
1143
|
'shape-rendering': "crispEdges",
|
|
1197
1144
|
xmlns: 'http://www.w3.org/2000/svg',
|
|
1198
1145
|
viewBox: "0 0 ".concat(numCells.value, " ").concat(numCells.value),
|
|
1146
|
+
role: 'img',
|
|
1147
|
+
'aria-label': props.value,
|
|
1199
1148
|
}, [
|
|
1200
1149
|
h('defs', {}, [renderGradient(), renderClipPath()]),
|
|
1201
1150
|
h('rect', {
|
|
@@ -1207,6 +1156,15 @@ var QrcodeSvg = defineComponent({
|
|
|
1207
1156
|
fill: props.gradient ? "url(#".concat(qrGradientId, ")") : props.foreground,
|
|
1208
1157
|
d: fgPath.value,
|
|
1209
1158
|
}),
|
|
1159
|
+
imageBorderProps.value && h('rect', {
|
|
1160
|
+
x: imageBorderProps.value.x,
|
|
1161
|
+
y: imageBorderProps.value.y,
|
|
1162
|
+
width: imageBorderProps.value.width,
|
|
1163
|
+
height: imageBorderProps.value.height,
|
|
1164
|
+
fill: props.background,
|
|
1165
|
+
rx: imageBorderProps.value.borderRadius,
|
|
1166
|
+
ry: imageBorderProps.value.borderRadius,
|
|
1167
|
+
}),
|
|
1210
1168
|
props.imageSettings.src && h('image', __assign(__assign({ href: props.imageSettings.src }, imageProps.value), (imageProps.value.borderRadius > 0 ? { 'clip-path': "url(#".concat(qrLogoClipPathId, ")") } : {}))),
|
|
1211
1169
|
]); };
|
|
1212
1170
|
},
|
|
@@ -1215,97 +1173,88 @@ var QrcodeCanvas = defineComponent({
|
|
|
1215
1173
|
name: 'QRCodeCanvas',
|
|
1216
1174
|
props: QRCodeProps,
|
|
1217
1175
|
setup: function (props, ctx) {
|
|
1176
|
+
var _a = useQRCode(props), margin = _a.margin, cells = _a.cells, numCells = _a.numCells, fgPath = _a.fgPath, imageProps = _a.imageProps, imageBorderProps = _a.imageBorderProps;
|
|
1218
1177
|
var canvasEl = ref(null);
|
|
1219
1178
|
var imageRef = ref(null);
|
|
1179
|
+
var drawRoundedRect = function (ctx, x, y, width, height, radius) {
|
|
1180
|
+
ctx.beginPath();
|
|
1181
|
+
if (ctx.roundRect) {
|
|
1182
|
+
ctx.roundRect(x, y, width, height, radius);
|
|
1183
|
+
}
|
|
1184
|
+
else {
|
|
1185
|
+
ctx.rect(x, y, width, height);
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1220
1188
|
var generate = function () {
|
|
1221
|
-
var
|
|
1222
|
-
var margin = _margin >>> 0;
|
|
1223
|
-
var level = validErrorCorrectLevel(_level) ? _level : defaultErrorCorrectLevel;
|
|
1189
|
+
var size = props.size, background = props.background, foreground = props.foreground, gradient = props.gradient, gradientType = props.gradientType, gradientStartColor = props.gradientStartColor, gradientEndColor = props.gradientEndColor;
|
|
1224
1190
|
var canvas = canvasEl.value;
|
|
1225
1191
|
if (!canvas) {
|
|
1226
1192
|
return;
|
|
1227
1193
|
}
|
|
1228
|
-
var
|
|
1229
|
-
if (!
|
|
1194
|
+
var canvasCtx = canvas.getContext('2d');
|
|
1195
|
+
if (!canvasCtx) {
|
|
1230
1196
|
return;
|
|
1231
1197
|
}
|
|
1232
|
-
var cells = QR.QrCode.encodeText(value, ErrorCorrectLevelMap[level]).getModules();
|
|
1233
|
-
var numCells = cells.length + margin * 2;
|
|
1234
1198
|
var image = imageRef.value;
|
|
1235
|
-
var imageProps = { x: 0, y: 0, width: 0, height: 0, borderRadius: 0 };
|
|
1236
|
-
var showImage = props.imageSettings.src && image != null && image.naturalWidth !== 0 && image.naturalHeight !== 0;
|
|
1237
|
-
if (showImage) {
|
|
1238
|
-
var imageSettings = getImageSettings(cells, props.size, margin, props.imageSettings);
|
|
1239
|
-
imageProps = {
|
|
1240
|
-
x: imageSettings.x + margin,
|
|
1241
|
-
y: imageSettings.y + margin,
|
|
1242
|
-
width: imageSettings.w,
|
|
1243
|
-
height: imageSettings.h,
|
|
1244
|
-
borderRadius: imageSettings.borderRadius,
|
|
1245
|
-
};
|
|
1246
|
-
if (imageSettings.excavation) {
|
|
1247
|
-
cells = excavateModules(cells, imageSettings.excavation, imageSettings.borderRadius);
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
1199
|
var devicePixelRatio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
|
|
1251
|
-
var scale = (size / numCells) * devicePixelRatio;
|
|
1200
|
+
var scale = (size / numCells.value) * devicePixelRatio;
|
|
1252
1201
|
canvas.height = canvas.width = size * devicePixelRatio;
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1202
|
+
canvasCtx.scale(scale, scale);
|
|
1203
|
+
canvasCtx.fillStyle = background;
|
|
1204
|
+
canvasCtx.fillRect(0, 0, numCells.value, numCells.value);
|
|
1256
1205
|
if (gradient) {
|
|
1257
1206
|
var grad = void 0;
|
|
1258
1207
|
if (gradientType === 'linear') {
|
|
1259
|
-
grad =
|
|
1208
|
+
grad = canvasCtx.createLinearGradient(0, 0, numCells.value, numCells.value);
|
|
1260
1209
|
}
|
|
1261
1210
|
else {
|
|
1262
|
-
grad =
|
|
1211
|
+
grad = canvasCtx.createRadialGradient(numCells.value / 2, numCells.value / 2, 0, numCells.value / 2, numCells.value / 2, numCells.value / 2);
|
|
1263
1212
|
}
|
|
1264
1213
|
grad.addColorStop(0, gradientStartColor);
|
|
1265
1214
|
grad.addColorStop(1, gradientEndColor);
|
|
1266
|
-
|
|
1215
|
+
canvasCtx.fillStyle = grad;
|
|
1267
1216
|
}
|
|
1268
1217
|
else {
|
|
1269
|
-
|
|
1218
|
+
canvasCtx.fillStyle = foreground;
|
|
1270
1219
|
}
|
|
1271
1220
|
if (SUPPORTS_PATH2D) {
|
|
1272
|
-
|
|
1221
|
+
canvasCtx.fill(new Path2D(fgPath.value));
|
|
1273
1222
|
}
|
|
1274
1223
|
else {
|
|
1275
|
-
cells.forEach(function (row, rdx) {
|
|
1224
|
+
cells.value.forEach(function (row, rdx) {
|
|
1276
1225
|
row.forEach(function (cell, cdx) {
|
|
1277
1226
|
if (cell) {
|
|
1278
|
-
|
|
1227
|
+
canvasCtx.fillRect(cdx + margin.value, rdx + margin.value, 1, 1);
|
|
1279
1228
|
}
|
|
1280
1229
|
});
|
|
1281
1230
|
});
|
|
1282
1231
|
}
|
|
1232
|
+
var showImage = props.imageSettings.src && image && image.naturalWidth !== 0 && image.naturalHeight !== 0;
|
|
1283
1233
|
if (showImage) {
|
|
1284
|
-
|
|
1234
|
+
if (imageBorderProps.value) {
|
|
1235
|
+
var imageBorder = imageBorderProps.value;
|
|
1236
|
+
canvasCtx.fillStyle = props.background;
|
|
1237
|
+
drawRoundedRect(canvasCtx, imageBorder.x, imageBorder.y, imageBorder.width, imageBorder.height, imageBorder.borderRadius);
|
|
1238
|
+
canvasCtx.fill();
|
|
1239
|
+
}
|
|
1240
|
+
var borderRadius = imageProps.value.borderRadius;
|
|
1285
1241
|
if (borderRadius > 0) {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
else {
|
|
1292
|
-
// Fallback for browsers without roundRect support
|
|
1293
|
-
ctx.rect(imageProps.x, imageProps.y, imageProps.width, imageProps.height);
|
|
1294
|
-
}
|
|
1295
|
-
ctx.clip();
|
|
1296
|
-
ctx.drawImage(image, imageProps.x, imageProps.y, imageProps.width, imageProps.height);
|
|
1297
|
-
ctx.restore();
|
|
1242
|
+
canvasCtx.save();
|
|
1243
|
+
drawRoundedRect(canvasCtx, imageProps.value.x, imageProps.value.y, imageProps.value.width, imageProps.value.height, borderRadius);
|
|
1244
|
+
canvasCtx.clip();
|
|
1245
|
+
canvasCtx.drawImage(image, imageProps.value.x, imageProps.value.y, imageProps.value.width, imageProps.value.height);
|
|
1246
|
+
canvasCtx.restore();
|
|
1298
1247
|
}
|
|
1299
1248
|
else {
|
|
1300
|
-
|
|
1249
|
+
canvasCtx.drawImage(image, imageProps.value.x, imageProps.value.y, imageProps.value.width, imageProps.value.height);
|
|
1301
1250
|
}
|
|
1302
1251
|
}
|
|
1303
1252
|
};
|
|
1304
1253
|
onMounted(generate);
|
|
1305
|
-
|
|
1254
|
+
watchEffect(generate);
|
|
1306
1255
|
var style = ctx.attrs.style;
|
|
1307
1256
|
return function () { return h(Fragment, [
|
|
1308
|
-
h('canvas', __assign(__assign({}, ctx.attrs), { ref: canvasEl, style: __assign(__assign({}, style), { width: "".concat(props.size, "px"), height: "".concat(props.size, "px") }) })),
|
|
1257
|
+
h('canvas', __assign(__assign({}, ctx.attrs), { ref: canvasEl, role: 'img', 'aria-label': props.value, style: __assign(__assign({}, style), { width: "".concat(props.size, "px"), height: "".concat(props.size, "px") }) })),
|
|
1309
1258
|
props.imageSettings.src && h('img', {
|
|
1310
1259
|
ref: imageRef,
|
|
1311
1260
|
src: props.imageSettings.src,
|
|
@@ -1317,23 +1266,22 @@ var QrcodeCanvas = defineComponent({
|
|
|
1317
1266
|
});
|
|
1318
1267
|
var QrcodeVue = defineComponent({
|
|
1319
1268
|
name: 'Qrcode',
|
|
1320
|
-
render: function () {
|
|
1321
|
-
var _a = this.$props, renderAs = _a.renderAs, value = _a.value, size = _a.size, margin = _a.margin, level = _a.level, background = _a.background, foreground = _a.foreground, imageSettings = _a.imageSettings, gradient = _a.gradient, gradientType = _a.gradientType, gradientStartColor = _a.gradientStartColor, gradientEndColor = _a.gradientEndColor;
|
|
1322
|
-
return h(renderAs === 'svg' ? QrcodeSvg : QrcodeCanvas, {
|
|
1323
|
-
value: value,
|
|
1324
|
-
size: size,
|
|
1325
|
-
margin: margin,
|
|
1326
|
-
level: level,
|
|
1327
|
-
background: background,
|
|
1328
|
-
foreground: foreground,
|
|
1329
|
-
imageSettings: imageSettings,
|
|
1330
|
-
gradient: gradient,
|
|
1331
|
-
gradientType: gradientType,
|
|
1332
|
-
gradientStartColor: gradientStartColor,
|
|
1333
|
-
gradientEndColor: gradientEndColor,
|
|
1334
|
-
});
|
|
1335
|
-
},
|
|
1336
1269
|
props: QRCodeVueProps,
|
|
1270
|
+
setup: function (props) {
|
|
1271
|
+
return function () { return h(props.renderAs === 'svg' ? QrcodeSvg : QrcodeCanvas, {
|
|
1272
|
+
value: props.value,
|
|
1273
|
+
size: props.size,
|
|
1274
|
+
margin: props.margin,
|
|
1275
|
+
level: props.level,
|
|
1276
|
+
background: props.background,
|
|
1277
|
+
foreground: props.foreground,
|
|
1278
|
+
imageSettings: props.imageSettings,
|
|
1279
|
+
gradient: props.gradient,
|
|
1280
|
+
gradientType: props.gradientType,
|
|
1281
|
+
gradientStartColor: props.gradientStartColor,
|
|
1282
|
+
gradientEndColor: props.gradientEndColor,
|
|
1283
|
+
}); };
|
|
1284
|
+
},
|
|
1337
1285
|
});
|
|
1338
1286
|
|
|
1339
1287
|
export { QrcodeCanvas, QrcodeSvg, QrcodeVue as default };
|
package/dist/src/index.d.ts
CHANGED
|
@@ -317,7 +317,9 @@ declare const QrcodeVue: import("vue").DefineComponent<import("vue").ExtractProp
|
|
|
317
317
|
required: boolean;
|
|
318
318
|
default: string;
|
|
319
319
|
};
|
|
320
|
-
}>,
|
|
320
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
321
|
+
[key: string]: any;
|
|
322
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
321
323
|
renderAs: {
|
|
322
324
|
type: PropType<RenderAs>;
|
|
323
325
|
required: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qrcode.vue",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "A Vue.js component to generate QRCode. Both support Vue 2 and Vue 3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/qrcode.vue.cjs.js",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@rollup/plugin-terser": "^0.
|
|
53
|
-
"@rsbuild/core": "^
|
|
54
|
-
"@rstest/core": "^0.
|
|
52
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
53
|
+
"@rsbuild/core": "^2.0.0-rc.0",
|
|
54
|
+
"@rstest/core": "^0.9.6",
|
|
55
55
|
"@vue/test-utils": "^2.4.6",
|
|
56
|
-
"happy-dom": "^20.
|
|
57
|
-
"rollup": "^4.
|
|
58
|
-
"rollup-plugin-typescript2": "^0.
|
|
56
|
+
"happy-dom": "^20.8.9",
|
|
57
|
+
"rollup": "^4.60.1",
|
|
58
|
+
"rollup-plugin-typescript2": "^0.37.0",
|
|
59
59
|
"typescript": "^5.9.3",
|
|
60
|
-
"vue": "^3.5.
|
|
60
|
+
"vue": "^3.5.29"
|
|
61
61
|
}
|
|
62
62
|
}
|