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.
Files changed (56) hide show
  1. package/HiprintDesigner.vue +494 -86
  2. package/hooks/useHiprint.js +48 -27
  3. package/libs/hiprint.bundle.js +11 -1
  4. package/libs/jquery.js +1 -0
  5. package/libs/jsbarcode/JsBarcode.js +64 -72
  6. package/libs/jsbarcode/barcodes/Barcode.js +9 -17
  7. package/libs/jsbarcode/barcodes/CODE128/CODE128.js +93 -133
  8. package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +10 -38
  9. package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +10 -38
  10. package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +10 -38
  11. package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +10 -36
  12. package/libs/jsbarcode/barcodes/CODE128/auto.js +32 -37
  13. package/libs/jsbarcode/barcodes/CODE128/constants.js +47 -30
  14. package/libs/jsbarcode/barcodes/CODE128/index.js +5 -28
  15. package/libs/jsbarcode/barcodes/CODE39/index.js +61 -61
  16. package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +58 -78
  17. package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +66 -95
  18. package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +22 -50
  19. package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +29 -54
  20. package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +42 -66
  21. package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +92 -125
  22. package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +134 -142
  23. package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +32 -21
  24. package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +11 -18
  25. package/libs/jsbarcode/barcodes/EAN_UPC/index.js +8 -39
  26. package/libs/jsbarcode/barcodes/GenericBarcode/index.js +16 -49
  27. package/libs/jsbarcode/barcodes/ITF/ITF.js +31 -63
  28. package/libs/jsbarcode/barcodes/ITF/ITF14.js +18 -40
  29. package/libs/jsbarcode/barcodes/ITF/constants.js +6 -8
  30. package/libs/jsbarcode/barcodes/ITF/index.js +3 -18
  31. package/libs/jsbarcode/barcodes/MSI/MSI.js +31 -57
  32. package/libs/jsbarcode/barcodes/MSI/MSI10.js +7 -30
  33. package/libs/jsbarcode/barcodes/MSI/MSI1010.js +10 -33
  34. package/libs/jsbarcode/barcodes/MSI/MSI11.js +7 -30
  35. package/libs/jsbarcode/barcodes/MSI/MSI1110.js +10 -33
  36. package/libs/jsbarcode/barcodes/MSI/checksums.js +11 -17
  37. package/libs/jsbarcode/barcodes/MSI/index.js +6 -33
  38. package/libs/jsbarcode/barcodes/codabar/index.js +49 -78
  39. package/libs/jsbarcode/barcodes/index.js +20 -33
  40. package/libs/jsbarcode/barcodes/pharmacode/index.js +32 -62
  41. package/libs/jsbarcode/exceptions/ErrorHandler.js +28 -43
  42. package/libs/jsbarcode/exceptions/exceptions.js +21 -59
  43. package/libs/jsbarcode/help/fixOptions.js +3 -9
  44. package/libs/jsbarcode/help/getOptionsFromElement.js +10 -23
  45. package/libs/jsbarcode/help/getRenderProperties.js +63 -69
  46. package/libs/jsbarcode/help/linearizeEncodings.js +8 -13
  47. package/libs/jsbarcode/help/merge.js +1 -11
  48. package/libs/jsbarcode/help/optionsFromStrings.js +19 -15
  49. package/libs/jsbarcode/options/defaults.js +2 -7
  50. package/libs/jsbarcode/renderers/canvas.js +106 -127
  51. package/libs/jsbarcode/renderers/index.js +4 -20
  52. package/libs/jsbarcode/renderers/object.js +7 -23
  53. package/libs/jsbarcode/renderers/shared.js +32 -39
  54. package/libs/jsbarcode/renderers/svg.js +136 -154
  55. package/package.json +1 -1
  56. package/libs/jsbarcode/barcodes/index.tmp.js +0 -33
@@ -1,189 +1,171 @@
1
- "use strict";
1
+ import merge from "../help/merge.js";
2
+ import {calculateEncodingAttributes, getTotalWidthOfEncodings, getMaximumHeightOfEncodings} from "./shared.js";
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
4
+ var svgns = "http://www.w3.org/2000/svg";
6
5
 
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
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
- var _merge = require("../help/merge.js");
14
+ render(){
15
+ var currentX = this.options.marginLeft;
10
16
 
11
- var _merge2 = _interopRequireDefault(_merge);
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 _shared = require("./shared.js");
22
+ var group = this.createGroup(currentX, encodingOptions.marginTop, this.svg);
14
23
 
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ this.setGroupOptions(group, encodingOptions);
16
25
 
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26
+ this.drawSvgBarcode(group, encodingOptions, encoding);
27
+ this.drawSVGText(group, encodingOptions, encoding);
18
28
 
19
- var svgns = "http://www.w3.org/2000/svg";
29
+ currentX += encoding.width;
30
+ }
31
+ }
20
32
 
21
- var SVGRenderer = function () {
22
- function SVGRenderer(svg, encodings, options) {
23
- _classCallCheck(this, SVGRenderer);
33
+ prepareSVG(){
34
+ // Clear the SVG
35
+ while (this.svg.firstChild) {
36
+ this.svg.removeChild(this.svg.firstChild);
37
+ }
24
38
 
25
- this.svg = svg;
26
- this.encodings = encodings;
27
- this.options = options;
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
- _createClass(SVGRenderer, [{
32
- key: "render",
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
- this.prepareSVG();
37
- for (var i = 0; i < this.encodings.length; i++) {
38
- var encoding = this.encodings[i];
39
- var encodingOptions = (0, _merge2.default)(this.options, encoding.options);
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
- var group = this.createGroup(currentX, encodingOptions.marginTop, this.svg);
53
+ drawSvgBarcode(parent, options, encoding){
54
+ var binary = encoding.data;
42
55
 
43
- this.setGroupOptions(group, encodingOptions);
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
- this.drawSvgBarcode(group, encodingOptions, encoding);
46
- this.drawSVGText(group, encodingOptions, encoding);
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
- currentX += encoding.width;
70
+ if(binary[b] === "1"){
71
+ barWidth++;
49
72
  }
50
- }
51
- }, {
52
- key: "prepareSVG",
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
- (0, _shared.calculateEncodingAttributes)(this.encodings, this.options);
60
- var totalWidth = (0, _shared.getTotalWidthOfEncodings)(this.encodings);
61
- var maxHeight = (0, _shared.getMaximumHeightOfEncodings)(this.encodings);
88
+ // Draw the text if displayValue is set
89
+ if(options.displayValue){
90
+ var x, y;
62
91
 
63
- var width = totalWidth + this.options.marginLeft + this.options.marginRight;
64
- this.setSvgAttributes(width, maxHeight);
92
+ textElem.setAttribute("style",
93
+ "font:" + options.fontOptions + " " + options.fontSize + "px " + options.font
94
+ );
65
95
 
66
- if (this.options.background) {
67
- this.drawRect(0, 0, width, maxHeight, this.svg).setAttribute("style", "fill:" + this.options.background + ";");
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
- var barWidth = 0;
84
- var x = 0;
85
- for (var b = 0; b < binary.length; b++) {
86
- x = b * options.width + encoding.barcodePadding;
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
- // Last draw is needed since the barcode ends with 1
97
- if (barWidth > 0) {
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
- key: "drawSVGText",
103
- value: function drawSVGText(parent, options, encoding) {
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
- parent.appendChild(group);
118
+ textElem.setAttribute("x", x);
119
+ textElem.setAttribute("y", y);
162
120
 
163
- return group;
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
- parent.appendChild(rect);
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
- return rect;
183
- }
184
- }]);
136
+ svg.setAttribute("xmlns", svgns);
137
+ svg.setAttribute("version", "1.1");
185
138
 
186
- return SVGRenderer;
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
- exports.default = SVGRenderer;
171
+ export default SVGRenderer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-hiprint",
3
- "version": "2.3.6",
3
+ "version": "2.4.1",
4
4
  "description": "Hiprint for Vue3 by NoahLiu in ForceCon in Hunan Changesha",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -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
- };