yh-hiprint 2.3.6 → 2.4.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/HiprintDesigner.vue +494 -86
- package/hooks/useHiprint.js +48 -27
- package/libs/hiprint.bundle.js +11 -1
- package/libs/jquery.js +1 -0
- package/libs/jsbarcode/JsBarcode.js +64 -72
- package/libs/jsbarcode/barcodes/Barcode.js +9 -17
- package/libs/jsbarcode/barcodes/CODE128/CODE128.js +93 -133
- package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +10 -36
- package/libs/jsbarcode/barcodes/CODE128/auto.js +32 -37
- package/libs/jsbarcode/barcodes/CODE128/constants.js +47 -30
- package/libs/jsbarcode/barcodes/CODE128/index.js +5 -28
- package/libs/jsbarcode/barcodes/CODE39/index.js +61 -61
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +58 -78
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +66 -95
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +22 -50
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +29 -54
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +42 -66
- package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +92 -125
- package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +134 -142
- package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +32 -21
- package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +11 -18
- package/libs/jsbarcode/barcodes/EAN_UPC/index.js +8 -39
- package/libs/jsbarcode/barcodes/GenericBarcode/index.js +16 -49
- package/libs/jsbarcode/barcodes/ITF/ITF.js +31 -63
- package/libs/jsbarcode/barcodes/ITF/ITF14.js +18 -40
- package/libs/jsbarcode/barcodes/ITF/constants.js +6 -8
- package/libs/jsbarcode/barcodes/ITF/index.js +3 -18
- package/libs/jsbarcode/barcodes/MSI/MSI.js +31 -57
- package/libs/jsbarcode/barcodes/MSI/MSI10.js +7 -30
- package/libs/jsbarcode/barcodes/MSI/MSI1010.js +10 -33
- package/libs/jsbarcode/barcodes/MSI/MSI11.js +7 -30
- package/libs/jsbarcode/barcodes/MSI/MSI1110.js +10 -33
- package/libs/jsbarcode/barcodes/MSI/checksums.js +11 -17
- package/libs/jsbarcode/barcodes/MSI/index.js +6 -33
- package/libs/jsbarcode/barcodes/codabar/index.js +49 -78
- package/libs/jsbarcode/barcodes/index.js +20 -33
- package/libs/jsbarcode/barcodes/pharmacode/index.js +32 -62
- package/libs/jsbarcode/exceptions/ErrorHandler.js +28 -43
- package/libs/jsbarcode/exceptions/exceptions.js +21 -59
- package/libs/jsbarcode/help/fixOptions.js +3 -9
- package/libs/jsbarcode/help/getOptionsFromElement.js +10 -23
- package/libs/jsbarcode/help/getRenderProperties.js +63 -69
- package/libs/jsbarcode/help/linearizeEncodings.js +8 -13
- package/libs/jsbarcode/help/merge.js +1 -11
- package/libs/jsbarcode/help/optionsFromStrings.js +19 -15
- package/libs/jsbarcode/options/defaults.js +2 -7
- package/libs/jsbarcode/renderers/canvas.js +106 -127
- package/libs/jsbarcode/renderers/index.js +4 -20
- package/libs/jsbarcode/renderers/object.js +7 -23
- package/libs/jsbarcode/renderers/shared.js +32 -39
- package/libs/jsbarcode/renderers/svg.js +136 -154
- package/package.json +1 -1
- package/libs/jsbarcode/barcodes/index.tmp.js +0 -33
|
@@ -1,189 +1,171 @@
|
|
|
1
|
-
|
|
1
|
+
import merge from "../help/merge.js";
|
|
2
|
+
import {calculateEncodingAttributes, getTotalWidthOfEncodings, getMaximumHeightOfEncodings} from "./shared.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
4
|
+
var svgns = "http://www.w3.org/2000/svg";
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
class SVGRenderer{
|
|
7
|
+
constructor(svg, encodings, options){
|
|
8
|
+
this.svg = svg;
|
|
9
|
+
this.encodings = encodings;
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.document = options.xmlDocument || document;
|
|
12
|
+
}
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
render(){
|
|
15
|
+
var currentX = this.options.marginLeft;
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
this.prepareSVG();
|
|
18
|
+
for(let i = 0; i < this.encodings.length; i++){
|
|
19
|
+
var encoding = this.encodings[i];
|
|
20
|
+
var encodingOptions = merge(this.options, encoding.options);
|
|
12
21
|
|
|
13
|
-
var
|
|
22
|
+
var group = this.createGroup(currentX, encodingOptions.marginTop, this.svg);
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
this.setGroupOptions(group, encodingOptions);
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
this.drawSvgBarcode(group, encodingOptions, encoding);
|
|
27
|
+
this.drawSVGText(group, encodingOptions, encoding);
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
currentX += encoding.width;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
20
32
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
prepareSVG(){
|
|
34
|
+
// Clear the SVG
|
|
35
|
+
while (this.svg.firstChild) {
|
|
36
|
+
this.svg.removeChild(this.svg.firstChild);
|
|
37
|
+
}
|
|
24
38
|
|
|
25
|
-
this.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.document = options.xmlDocument || document;
|
|
29
|
-
}
|
|
39
|
+
calculateEncodingAttributes(this.encodings, this.options);
|
|
40
|
+
var totalWidth = getTotalWidthOfEncodings(this.encodings);
|
|
41
|
+
var maxHeight = getMaximumHeightOfEncodings(this.encodings);
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
value: function render() {
|
|
34
|
-
var currentX = this.options.marginLeft;
|
|
43
|
+
var width = totalWidth + this.options.marginLeft + this.options.marginRight;
|
|
44
|
+
this.setSvgAttributes(width, maxHeight);
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
if(this.options.background){
|
|
47
|
+
this.drawRect(0, 0, width, maxHeight, this.svg).setAttribute(
|
|
48
|
+
"style", "fill:" + this.options.background + ";"
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
40
52
|
|
|
41
|
-
|
|
53
|
+
drawSvgBarcode(parent, options, encoding){
|
|
54
|
+
var binary = encoding.data;
|
|
42
55
|
|
|
43
|
-
|
|
56
|
+
// Creates the barcode out of the encoded binary
|
|
57
|
+
var yFrom;
|
|
58
|
+
if(options.textPosition == "top"){
|
|
59
|
+
yFrom = options.fontSize + options.textMargin;
|
|
60
|
+
}
|
|
61
|
+
else{
|
|
62
|
+
yFrom = 0;
|
|
63
|
+
}
|
|
44
64
|
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
var barWidth = 0;
|
|
66
|
+
var x = 0;
|
|
67
|
+
for(var b = 0; b < binary.length; b++){
|
|
68
|
+
x = b * options.width + encoding.barcodePadding;
|
|
47
69
|
|
|
48
|
-
|
|
70
|
+
if(binary[b] === "1"){
|
|
71
|
+
barWidth++;
|
|
49
72
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
value: function prepareSVG() {
|
|
54
|
-
// Clear the SVG
|
|
55
|
-
while (this.svg.firstChild) {
|
|
56
|
-
this.svg.removeChild(this.svg.firstChild);
|
|
73
|
+
else if(barWidth > 0){
|
|
74
|
+
this.drawRect(x - options.width * barWidth, yFrom, options.width * barWidth, options.height, parent);
|
|
75
|
+
barWidth = 0;
|
|
57
76
|
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Last draw is needed since the barcode ends with 1
|
|
80
|
+
if(barWidth > 0){
|
|
81
|
+
this.drawRect(x - options.width * (barWidth - 1), yFrom, options.width * barWidth, options.height, parent);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
drawSVGText(parent, options, encoding){
|
|
86
|
+
var textElem = this.document.createElementNS(svgns, 'text');
|
|
58
87
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var
|
|
88
|
+
// Draw the text if displayValue is set
|
|
89
|
+
if(options.displayValue){
|
|
90
|
+
var x, y;
|
|
62
91
|
|
|
63
|
-
|
|
64
|
-
|
|
92
|
+
textElem.setAttribute("style",
|
|
93
|
+
"font:" + options.fontOptions + " " + options.fontSize + "px " + options.font
|
|
94
|
+
);
|
|
65
95
|
|
|
66
|
-
if
|
|
67
|
-
|
|
96
|
+
if(options.textPosition == "top"){
|
|
97
|
+
y = options.fontSize - options.textMargin;
|
|
68
98
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
key: "drawSvgBarcode",
|
|
72
|
-
value: function drawSvgBarcode(parent, options, encoding) {
|
|
73
|
-
var binary = encoding.data;
|
|
74
|
-
|
|
75
|
-
// Creates the barcode out of the encoded binary
|
|
76
|
-
var yFrom;
|
|
77
|
-
if (options.textPosition == "top") {
|
|
78
|
-
yFrom = options.fontSize + options.textMargin;
|
|
79
|
-
} else {
|
|
80
|
-
yFrom = 0;
|
|
99
|
+
else{
|
|
100
|
+
y = options.height + options.textMargin + options.fontSize;
|
|
81
101
|
}
|
|
82
102
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (binary[b] === "1") {
|
|
89
|
-
barWidth++;
|
|
90
|
-
} else if (barWidth > 0) {
|
|
91
|
-
this.drawRect(x - options.width * barWidth, yFrom, options.width * barWidth, options.height, parent);
|
|
92
|
-
barWidth = 0;
|
|
93
|
-
}
|
|
103
|
+
// Draw the text in the correct X depending on the textAlign option
|
|
104
|
+
if(options.textAlign == "left" || encoding.barcodePadding > 0){
|
|
105
|
+
x = 0;
|
|
106
|
+
textElem.setAttribute("text-anchor", "start");
|
|
94
107
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.drawRect(x - options.width * (barWidth - 1), yFrom, options.width * barWidth, options.height, parent);
|
|
108
|
+
else if(options.textAlign == "right"){
|
|
109
|
+
x = encoding.width - 1;
|
|
110
|
+
textElem.setAttribute("text-anchor", "end");
|
|
99
111
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var textElem = this.document.createElementNS(svgns, 'text');
|
|
105
|
-
|
|
106
|
-
// Draw the text if displayValue is set
|
|
107
|
-
if (options.displayValue) {
|
|
108
|
-
var x, y;
|
|
109
|
-
|
|
110
|
-
textElem.setAttribute("style", "font:" + options.fontOptions + " " + options.fontSize + "px " + options.font);
|
|
111
|
-
|
|
112
|
-
if (options.textPosition == "top") {
|
|
113
|
-
y = options.fontSize - options.textMargin;
|
|
114
|
-
} else {
|
|
115
|
-
y = options.height + options.textMargin + options.fontSize;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Draw the text in the correct X depending on the textAlign option
|
|
119
|
-
if (options.textAlign == "left" || encoding.barcodePadding > 0) {
|
|
120
|
-
x = 0;
|
|
121
|
-
textElem.setAttribute("text-anchor", "start");
|
|
122
|
-
} else if (options.textAlign == "right") {
|
|
123
|
-
x = encoding.width - 1;
|
|
124
|
-
textElem.setAttribute("text-anchor", "end");
|
|
125
|
-
}
|
|
126
|
-
// In all other cases, center the text
|
|
127
|
-
else {
|
|
128
|
-
x = encoding.width / 2;
|
|
129
|
-
textElem.setAttribute("text-anchor", "middle");
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
textElem.setAttribute("x", x);
|
|
133
|
-
textElem.setAttribute("y", y);
|
|
134
|
-
|
|
135
|
-
textElem.appendChild(this.document.createTextNode(encoding.text));
|
|
136
|
-
|
|
137
|
-
parent.appendChild(textElem);
|
|
112
|
+
// In all other cases, center the text
|
|
113
|
+
else{
|
|
114
|
+
x = encoding.width / 2;
|
|
115
|
+
textElem.setAttribute("text-anchor", "middle");
|
|
138
116
|
}
|
|
139
|
-
}
|
|
140
|
-
}, {
|
|
141
|
-
key: "setSvgAttributes",
|
|
142
|
-
value: function setSvgAttributes(width, height) {
|
|
143
|
-
var svg = this.svg;
|
|
144
|
-
svg.setAttribute("width", width + "px");
|
|
145
|
-
svg.setAttribute("height", height + "px");
|
|
146
|
-
svg.setAttribute("x", "0px");
|
|
147
|
-
svg.setAttribute("y", "0px");
|
|
148
|
-
svg.setAttribute("viewBox", "0 0 " + width + " " + height);
|
|
149
|
-
|
|
150
|
-
svg.setAttribute("xmlns", svgns);
|
|
151
|
-
svg.setAttribute("version", "1.1");
|
|
152
|
-
|
|
153
|
-
svg.setAttribute("style", "transform: translate(0,0)");
|
|
154
|
-
}
|
|
155
|
-
}, {
|
|
156
|
-
key: "createGroup",
|
|
157
|
-
value: function createGroup(x, y, parent) {
|
|
158
|
-
var group = this.document.createElementNS(svgns, 'g');
|
|
159
|
-
group.setAttribute("transform", "translate(" + x + ", " + y + ")");
|
|
160
117
|
|
|
161
|
-
|
|
118
|
+
textElem.setAttribute("x", x);
|
|
119
|
+
textElem.setAttribute("y", y);
|
|
162
120
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
key: "setGroupOptions",
|
|
167
|
-
value: function setGroupOptions(group, options) {
|
|
168
|
-
group.setAttribute("style", "fill:" + options.lineColor + ";");
|
|
121
|
+
textElem.appendChild(this.document.createTextNode(encoding.text));
|
|
122
|
+
|
|
123
|
+
parent.appendChild(textElem);
|
|
169
124
|
}
|
|
170
|
-
}
|
|
171
|
-
key: "drawRect",
|
|
172
|
-
value: function drawRect(x, y, width, height, parent) {
|
|
173
|
-
var rect = this.document.createElementNS(svgns, 'rect');
|
|
125
|
+
}
|
|
174
126
|
|
|
175
|
-
rect.setAttribute("x", x);
|
|
176
|
-
rect.setAttribute("y", y);
|
|
177
|
-
rect.setAttribute("width", width);
|
|
178
|
-
rect.setAttribute("height", height);
|
|
179
127
|
|
|
180
|
-
|
|
128
|
+
setSvgAttributes(width, height){
|
|
129
|
+
var svg = this.svg;
|
|
130
|
+
svg.setAttribute("width", width + "px");
|
|
131
|
+
svg.setAttribute("height", height + "px");
|
|
132
|
+
svg.setAttribute("x", "0px");
|
|
133
|
+
svg.setAttribute("y", "0px");
|
|
134
|
+
svg.setAttribute("viewBox", "0 0 " + width + " " + height);
|
|
181
135
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}]);
|
|
136
|
+
svg.setAttribute("xmlns", svgns);
|
|
137
|
+
svg.setAttribute("version", "1.1");
|
|
185
138
|
|
|
186
|
-
|
|
187
|
-
}
|
|
139
|
+
svg.setAttribute("style", "transform: translate(0,0)");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
createGroup(x, y, parent){
|
|
143
|
+
var group = this.document.createElementNS(svgns, 'g');
|
|
144
|
+
group.setAttribute("transform", "translate(" + x + ", " + y + ")");
|
|
145
|
+
|
|
146
|
+
parent.appendChild(group);
|
|
147
|
+
|
|
148
|
+
return group;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
setGroupOptions(group, options){
|
|
152
|
+
group.setAttribute("style",
|
|
153
|
+
"fill:" + options.lineColor + ";"
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
drawRect(x, y, width, height, parent){
|
|
158
|
+
var rect = this.document.createElementNS(svgns, 'rect');
|
|
159
|
+
|
|
160
|
+
rect.setAttribute("x", x);
|
|
161
|
+
rect.setAttribute("y", y);
|
|
162
|
+
rect.setAttribute("width", width);
|
|
163
|
+
rect.setAttribute("height", height);
|
|
164
|
+
|
|
165
|
+
parent.appendChild(rect);
|
|
166
|
+
|
|
167
|
+
return rect;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
188
170
|
|
|
189
|
-
|
|
171
|
+
export default SVGRenderer;
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _CODE = require('./CODE39/');
|
|
8
|
-
|
|
9
|
-
var _CODE2 = require('./CODE128/');
|
|
10
|
-
|
|
11
|
-
var _EAN_UPC = require('./EAN_UPC/');
|
|
12
|
-
|
|
13
|
-
var _ITF = require('./ITF/');
|
|
14
|
-
|
|
15
|
-
var _MSI = require('./MSI/');
|
|
16
|
-
|
|
17
|
-
var _pharmacode = require('./pharmacode/');
|
|
18
|
-
|
|
19
|
-
var _codabar = require('./codabar');
|
|
20
|
-
|
|
21
|
-
var _GenericBarcode = require('./GenericBarcode/');
|
|
22
|
-
|
|
23
|
-
exports.default = {
|
|
24
|
-
CODE39: _CODE.CODE39,
|
|
25
|
-
CODE128: _CODE2.CODE128, CODE128A: _CODE2.CODE128A, CODE128B: _CODE2.CODE128B, CODE128C: _CODE2.CODE128C,
|
|
26
|
-
EAN13: _EAN_UPC.EAN13, EAN8: _EAN_UPC.EAN8, EAN5: _EAN_UPC.EAN5, EAN2: _EAN_UPC.EAN2, UPC: _EAN_UPC.UPC, UPCE: _EAN_UPC.UPCE,
|
|
27
|
-
ITF14: _ITF.ITF14,
|
|
28
|
-
ITF: _ITF.ITF,
|
|
29
|
-
MSI: _MSI.MSI, MSI10: _MSI.MSI10, MSI11: _MSI.MSI11, MSI1010: _MSI.MSI1010, MSI1110: _MSI.MSI1110,
|
|
30
|
-
pharmacode: _pharmacode.pharmacode,
|
|
31
|
-
codabar: _codabar.codabar,
|
|
32
|
-
GenericBarcode: _GenericBarcode.GenericBarcode
|
|
33
|
-
};
|