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,54 +1,71 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _SET_BY_CODE;
|
|
8
|
-
|
|
9
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
-
|
|
11
1
|
// constants for internal usage
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
export const SET_A = 0;
|
|
3
|
+
export const SET_B = 1;
|
|
4
|
+
export const SET_C = 2;
|
|
15
5
|
|
|
16
6
|
// Special characters
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
export const SHIFT = 98;
|
|
8
|
+
export const START_A = 103;
|
|
9
|
+
export const START_B = 104;
|
|
10
|
+
export const START_C = 105;
|
|
11
|
+
export const MODULO = 103;
|
|
12
|
+
export const STOP = 106;
|
|
13
|
+
export const FNC1 = 207;
|
|
24
14
|
|
|
25
15
|
// Get set by start code
|
|
26
|
-
|
|
16
|
+
export const SET_BY_CODE = {
|
|
17
|
+
[START_A]: SET_A,
|
|
18
|
+
[START_B]: SET_B,
|
|
19
|
+
[START_C]: SET_C,
|
|
20
|
+
};
|
|
27
21
|
|
|
28
22
|
// Get next set by code
|
|
29
|
-
|
|
23
|
+
export const SWAP = {
|
|
30
24
|
101: SET_A,
|
|
31
25
|
100: SET_B,
|
|
32
|
-
99: SET_C
|
|
26
|
+
99: SET_C,
|
|
33
27
|
};
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
export const A_START_CHAR = String.fromCharCode(208); // START_A + 105
|
|
30
|
+
export const B_START_CHAR = String.fromCharCode(209); // START_B + 105
|
|
31
|
+
export const C_START_CHAR = String.fromCharCode(210); // START_C + 105
|
|
38
32
|
|
|
39
33
|
// 128A (Code Set A)
|
|
40
34
|
// ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4
|
|
41
|
-
|
|
35
|
+
export const A_CHARS = "[\x00-\x5F\xC8-\xCF]";
|
|
42
36
|
|
|
43
37
|
// 128B (Code Set B)
|
|
44
38
|
// ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4
|
|
45
|
-
|
|
39
|
+
export const B_CHARS = "[\x20-\x7F\xC8-\xCF]";
|
|
46
40
|
|
|
47
41
|
// 128C (Code Set C)
|
|
48
42
|
// 00–99 (encodes two digits with a single code point) and FNC1
|
|
49
|
-
|
|
43
|
+
export const C_CHARS = "(\xCF*[0-9]{2}\xCF*)";
|
|
50
44
|
|
|
51
45
|
// CODE128 includes 107 symbols:
|
|
52
46
|
// 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one)
|
|
53
47
|
// Each symbol consist of three black bars (1) and three white spaces (0).
|
|
54
|
-
|
|
48
|
+
export const BARS = [
|
|
49
|
+
11011001100, 11001101100, 11001100110, 10010011000, 10010001100,
|
|
50
|
+
10001001100, 10011001000, 10011000100, 10001100100, 11001001000,
|
|
51
|
+
11001000100, 11000100100, 10110011100, 10011011100, 10011001110,
|
|
52
|
+
10111001100, 10011101100, 10011100110, 11001110010, 11001011100,
|
|
53
|
+
11001001110, 11011100100, 11001110100, 11101101110, 11101001100,
|
|
54
|
+
11100101100, 11100100110, 11101100100, 11100110100, 11100110010,
|
|
55
|
+
11011011000, 11011000110, 11000110110, 10100011000, 10001011000,
|
|
56
|
+
10001000110, 10110001000, 10001101000, 10001100010, 11010001000,
|
|
57
|
+
11000101000, 11000100010, 10110111000, 10110001110, 10001101110,
|
|
58
|
+
10111011000, 10111000110, 10001110110, 11101110110, 11010001110,
|
|
59
|
+
11000101110, 11011101000, 11011100010, 11011101110, 11101011000,
|
|
60
|
+
11101000110, 11100010110, 11101101000, 11101100010, 11100011010,
|
|
61
|
+
11101111010, 11001000010, 11110001010, 10100110000, 10100001100,
|
|
62
|
+
10010110000, 10010000110, 10000101100, 10000100110, 10110010000,
|
|
63
|
+
10110000100, 10011010000, 10011000010, 10000110100, 10000110010,
|
|
64
|
+
11000010010, 11001010000, 11110111010, 11000010100, 10001111010,
|
|
65
|
+
10100111100, 10010111100, 10010011110, 10111100100, 10011110100,
|
|
66
|
+
10011110010, 11110100100, 11110010100, 11110010010, 11011011110,
|
|
67
|
+
11011110110, 11110110110, 10101111000, 10100011110, 10001011110,
|
|
68
|
+
10111101000, 10111100010, 11110101000, 11110100010, 10111011110,
|
|
69
|
+
10111101110, 11101011110, 11110101110, 11010000100, 11010010000,
|
|
70
|
+
11010011100, 1100011101011
|
|
71
|
+
];
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import CODE128 from './CODE128_AUTO.js';
|
|
2
|
+
import CODE128A from './CODE128A.js';
|
|
3
|
+
import CODE128B from './CODE128B.js';
|
|
4
|
+
import CODE128C from './CODE128C.js';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CODE128C = exports.CODE128B = exports.CODE128A = exports.CODE128 = undefined;
|
|
7
|
-
|
|
8
|
-
var _CODE128_AUTO = require('./CODE128_AUTO.js');
|
|
9
|
-
|
|
10
|
-
var _CODE128_AUTO2 = _interopRequireDefault(_CODE128_AUTO);
|
|
11
|
-
|
|
12
|
-
var _CODE128A = require('./CODE128A.js');
|
|
13
|
-
|
|
14
|
-
var _CODE128A2 = _interopRequireDefault(_CODE128A);
|
|
15
|
-
|
|
16
|
-
var _CODE128B = require('./CODE128B.js');
|
|
17
|
-
|
|
18
|
-
var _CODE128B2 = _interopRequireDefault(_CODE128B);
|
|
19
|
-
|
|
20
|
-
var _CODE128C = require('./CODE128C.js');
|
|
21
|
-
|
|
22
|
-
var _CODE128C2 = _interopRequireDefault(_CODE128C);
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
exports.CODE128 = _CODE128_AUTO2.default;
|
|
27
|
-
exports.CODE128A = _CODE128A2.default;
|
|
28
|
-
exports.CODE128B = _CODE128B2.default;
|
|
29
|
-
exports.CODE128C = _CODE128C2.default;
|
|
6
|
+
export {CODE128, CODE128A, CODE128B, CODE128C};
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CODE39 = undefined;
|
|
7
|
-
|
|
8
|
-
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; }; }();
|
|
9
|
-
|
|
10
|
-
var _Barcode2 = require("../Barcode.js");
|
|
11
|
-
|
|
12
|
-
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
19
|
-
|
|
20
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
|
1
|
+
// Encoding documentation:
|
|
21
2
|
// https://en.wikipedia.org/wiki/Code_39#Encoding
|
|
22
3
|
|
|
23
|
-
|
|
24
|
-
_inherits(CODE39, _Barcode);
|
|
25
|
-
|
|
26
|
-
function CODE39(data, options) {
|
|
27
|
-
_classCallCheck(this, CODE39);
|
|
4
|
+
import Barcode from "../Barcode.js";
|
|
28
5
|
|
|
6
|
+
class CODE39 extends Barcode {
|
|
7
|
+
constructor(data, options){
|
|
29
8
|
data = data.toUpperCase();
|
|
30
9
|
|
|
31
10
|
// Calculate mod43 checksum if enabled
|
|
32
|
-
if
|
|
11
|
+
if(options.mod43){
|
|
33
12
|
data += getCharacter(mod43checksum(data));
|
|
34
13
|
}
|
|
35
14
|
|
|
36
|
-
|
|
15
|
+
super(data, options);
|
|
37
16
|
}
|
|
38
17
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
18
|
+
encode(){
|
|
19
|
+
// First character is always a *
|
|
20
|
+
var result = getEncoding("*");
|
|
21
|
+
|
|
22
|
+
// Take every character and add the binary representation to the result
|
|
23
|
+
for(let i = 0; i < this.data.length; i++){
|
|
24
|
+
result += getEncoding(this.data[i]) + "0";
|
|
25
|
+
}
|
|
44
26
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
result += getEncoding(this.data[i]) + "0";
|
|
48
|
-
}
|
|
27
|
+
// Last character is always a *
|
|
28
|
+
result += getEncoding("*");
|
|
49
29
|
|
|
50
|
-
|
|
51
|
-
result
|
|
30
|
+
return {
|
|
31
|
+
data: result,
|
|
32
|
+
text: this.text
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
valid(){
|
|
37
|
+
return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
52
40
|
|
|
53
|
-
return {
|
|
54
|
-
data: result,
|
|
55
|
-
text: this.text
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
key: "valid",
|
|
60
|
-
value: function valid() {
|
|
61
|
-
return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;
|
|
62
|
-
}
|
|
63
|
-
}]);
|
|
64
41
|
|
|
65
|
-
return CODE39;
|
|
66
|
-
}(_Barcode3.default);
|
|
67
42
|
|
|
68
|
-
// All characters. The position in the array is the (checksum) value
|
|
69
43
|
|
|
70
44
|
|
|
71
|
-
|
|
45
|
+
|
|
46
|
+
// All characters. The position in the array is the (checksum) value
|
|
47
|
+
var characters = [
|
|
48
|
+
"0", "1", "2", "3",
|
|
49
|
+
"4", "5", "6", "7",
|
|
50
|
+
"8", "9", "A", "B",
|
|
51
|
+
"C", "D", "E", "F",
|
|
52
|
+
"G", "H", "I", "J",
|
|
53
|
+
"K", "L", "M", "N",
|
|
54
|
+
"O", "P", "Q", "R",
|
|
55
|
+
"S", "T", "U", "V",
|
|
56
|
+
"W", "X", "Y", "Z",
|
|
57
|
+
"-", ".", " ", "$",
|
|
58
|
+
"/", "+", "%", "*"
|
|
59
|
+
];
|
|
72
60
|
|
|
73
61
|
// The decimal representation of the characters, is converted to the
|
|
74
62
|
// corresponding binary with the getEncoding function
|
|
75
|
-
var encodings = [
|
|
63
|
+
var encodings = [
|
|
64
|
+
20957, 29783, 23639, 30485,
|
|
65
|
+
20951, 29813, 23669, 20855,
|
|
66
|
+
29789, 23645, 29975, 23831,
|
|
67
|
+
30533, 22295, 30149, 24005,
|
|
68
|
+
21623, 29981, 23837, 22301,
|
|
69
|
+
30023, 23879, 30545, 22343,
|
|
70
|
+
30161, 24017, 21959, 30065,
|
|
71
|
+
23921, 22385, 29015, 18263,
|
|
72
|
+
29141, 17879, 29045, 18293,
|
|
73
|
+
17783, 29021, 18269, 17477,
|
|
74
|
+
17489, 17681, 20753, 35770
|
|
75
|
+
];
|
|
76
76
|
|
|
77
77
|
// Get the binary representation of a character by converting the encodings
|
|
78
78
|
// from decimal to binary
|
|
79
|
-
function getEncoding(character)
|
|
79
|
+
function getEncoding(character){
|
|
80
80
|
return getBinary(characterValue(character));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
function getBinary(characterValue)
|
|
83
|
+
function getBinary(characterValue){
|
|
84
84
|
return encodings[characterValue].toString(2);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function getCharacter(characterValue)
|
|
87
|
+
function getCharacter(characterValue){
|
|
88
88
|
return characters[characterValue];
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function characterValue(character)
|
|
91
|
+
function characterValue(character){
|
|
92
92
|
return characters.indexOf(character);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
function mod43checksum(data)
|
|
95
|
+
function mod43checksum(data){
|
|
96
96
|
var checksum = 0;
|
|
97
|
-
for
|
|
97
|
+
for(let i = 0; i < data.length; i++){
|
|
98
98
|
checksum += characterValue(data[i]);
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -102,4 +102,4 @@ function mod43checksum(data) {
|
|
|
102
102
|
return checksum;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
export {CODE39};
|
|
@@ -1,92 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
import { SIDE_BIN, MIDDLE_BIN } from './constants';
|
|
2
|
+
import encode from './encoder';
|
|
3
|
+
import Barcode from '../Barcode';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
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; }; }();
|
|
8
|
-
|
|
9
|
-
var _constants = require('./constants');
|
|
10
|
-
|
|
11
|
-
var _encoder = require('./encoder');
|
|
12
|
-
|
|
13
|
-
var _encoder2 = _interopRequireDefault(_encoder);
|
|
14
|
-
|
|
15
|
-
var _Barcode2 = require('../Barcode');
|
|
16
|
-
|
|
17
|
-
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
// Base class for EAN8 & EAN13
|
|
6
|
+
class EAN extends Barcode {
|
|
22
7
|
|
|
23
|
-
|
|
8
|
+
constructor(data, options) {
|
|
9
|
+
super(data, options);
|
|
24
10
|
|
|
25
|
-
|
|
11
|
+
// Make sure the font is not bigger than the space between the guard bars
|
|
12
|
+
this.fontSize = !options.flat && options.fontSize > options.width * 10
|
|
13
|
+
? options.width * 10
|
|
14
|
+
: options.fontSize;
|
|
26
15
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
// Make the guard bars go down half the way of the text
|
|
17
|
+
this.guardHeight = options.height + this.fontSize / 2 + options.textMargin;
|
|
18
|
+
}
|
|
30
19
|
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
encode() {
|
|
21
|
+
return this.options.flat
|
|
22
|
+
? this.encodeFlat()
|
|
23
|
+
: this.encodeGuarded();
|
|
24
|
+
}
|
|
33
25
|
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
leftText(from, to) {
|
|
27
|
+
return this.text.substr(from, to);
|
|
28
|
+
}
|
|
36
29
|
|
|
37
|
-
|
|
30
|
+
leftEncode(data, structure) {
|
|
31
|
+
return encode(data, structure);
|
|
32
|
+
}
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return _this;
|
|
34
|
+
rightText(from, to) {
|
|
35
|
+
return this.text.substr(from, to);
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return this.options.flat ? this.encodeFlat() : this.encodeGuarded();
|
|
48
|
-
}
|
|
49
|
-
}, {
|
|
50
|
-
key: 'leftText',
|
|
51
|
-
value: function leftText(from, to) {
|
|
52
|
-
return this.text.substr(from, to);
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: 'leftEncode',
|
|
56
|
-
value: function leftEncode(data, structure) {
|
|
57
|
-
return (0, _encoder2.default)(data, structure);
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: 'rightText',
|
|
61
|
-
value: function rightText(from, to) {
|
|
62
|
-
return this.text.substr(from, to);
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: 'rightEncode',
|
|
66
|
-
value: function rightEncode(data, structure) {
|
|
67
|
-
return (0, _encoder2.default)(data, structure);
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: 'encodeGuarded',
|
|
71
|
-
value: function encodeGuarded() {
|
|
72
|
-
var textOptions = { fontSize: this.fontSize };
|
|
73
|
-
var guardOptions = { height: this.guardHeight };
|
|
38
|
+
rightEncode(data, structure) {
|
|
39
|
+
return encode(data, structure);
|
|
40
|
+
}
|
|
74
41
|
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
42
|
+
encodeGuarded() {
|
|
43
|
+
const textOptions = { fontSize: this.fontSize };
|
|
44
|
+
const guardOptions = { height: this.guardHeight };
|
|
45
|
+
|
|
46
|
+
return [
|
|
47
|
+
{ data: SIDE_BIN, options: guardOptions },
|
|
48
|
+
{ data: this.leftEncode(), text: this.leftText(), options: textOptions },
|
|
49
|
+
{ data: MIDDLE_BIN, options: guardOptions },
|
|
50
|
+
{ data: this.rightEncode(), text: this.rightText(), options: textOptions },
|
|
51
|
+
{ data: SIDE_BIN, options: guardOptions },
|
|
52
|
+
];
|
|
53
|
+
}
|
|
81
54
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
55
|
+
encodeFlat() {
|
|
56
|
+
const data = [
|
|
57
|
+
SIDE_BIN,
|
|
58
|
+
this.leftEncode(),
|
|
59
|
+
MIDDLE_BIN,
|
|
60
|
+
this.rightEncode(),
|
|
61
|
+
SIDE_BIN
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
data: data.join(''),
|
|
66
|
+
text: this.text
|
|
67
|
+
};
|
|
68
|
+
}
|
|
88
69
|
|
|
89
|
-
|
|
90
|
-
}(_Barcode3.default);
|
|
70
|
+
}
|
|
91
71
|
|
|
92
|
-
|
|
72
|
+
export default EAN;
|
|
@@ -1,119 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
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; }; }();
|
|
8
|
-
|
|
9
|
-
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
10
|
-
|
|
11
|
-
var _constants = require('./constants');
|
|
12
|
-
|
|
13
|
-
var _EAN2 = require('./EAN');
|
|
14
|
-
|
|
15
|
-
var _EAN3 = _interopRequireDefault(_EAN2);
|
|
16
|
-
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
-
|
|
21
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
22
|
-
|
|
23
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
|
1
|
+
// Encoding documentation:
|
|
24
2
|
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode
|
|
25
3
|
|
|
4
|
+
import { EAN13_STRUCTURE } from './constants';
|
|
5
|
+
import EAN from './EAN';
|
|
6
|
+
|
|
26
7
|
// Calculate the checksum digit
|
|
27
8
|
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
const checksum = (number) => {
|
|
10
|
+
const res = number
|
|
11
|
+
.substr(0, 12)
|
|
12
|
+
.split('')
|
|
13
|
+
.map((n) => +n)
|
|
14
|
+
.reduce((sum, a, idx) => (
|
|
15
|
+
idx % 2 ? sum + a * 3 : sum + a
|
|
16
|
+
), 0);
|
|
17
|
+
|
|
18
|
+
return (10 - (res % 10)) % 10;
|
|
36
19
|
};
|
|
37
20
|
|
|
38
|
-
|
|
39
|
-
_inherits(EAN13, _EAN);
|
|
40
|
-
|
|
41
|
-
function EAN13(data, options) {
|
|
42
|
-
_classCallCheck(this, EAN13);
|
|
21
|
+
class EAN13 extends EAN {
|
|
43
22
|
|
|
23
|
+
constructor(data, options) {
|
|
44
24
|
// Add checksum if it does not exist
|
|
45
25
|
if (data.search(/^[0-9]{12}$/) !== -1) {
|
|
46
26
|
data += checksum(data);
|
|
47
27
|
}
|
|
48
28
|
|
|
29
|
+
super(data, options);
|
|
30
|
+
|
|
49
31
|
// Adds a last character to the end of the barcode
|
|
50
|
-
|
|
32
|
+
this.lastChar = options.lastChar;
|
|
33
|
+
}
|
|
51
34
|
|
|
52
|
-
|
|
53
|
-
return
|
|
35
|
+
valid() {
|
|
36
|
+
return (
|
|
37
|
+
this.data.search(/^[0-9]{13}$/) !== -1 &&
|
|
38
|
+
+this.data[12] === checksum(this.data)
|
|
39
|
+
);
|
|
54
40
|
}
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
}, {
|
|
67
|
-
key: 'leftEncode',
|
|
68
|
-
value: function leftEncode() {
|
|
69
|
-
var data = this.data.substr(1, 6);
|
|
70
|
-
var structure = _constants.EAN13_STRUCTURE[this.data[0]];
|
|
71
|
-
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftEncode', this).call(this, data, structure);
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: 'rightText',
|
|
75
|
-
value: function rightText() {
|
|
76
|
-
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightText', this).call(this, 7, 6);
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
key: 'rightEncode',
|
|
80
|
-
value: function rightEncode() {
|
|
81
|
-
var data = this.data.substr(7, 6);
|
|
82
|
-
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightEncode', this).call(this, data, 'RRRRRR');
|
|
83
|
-
}
|
|
42
|
+
leftText() {
|
|
43
|
+
return super.leftText(1, 6);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
leftEncode() {
|
|
47
|
+
const data = this.data.substr(1, 6);
|
|
48
|
+
const structure = EAN13_STRUCTURE[this.data[0]];
|
|
49
|
+
return super.leftEncode(data, structure);
|
|
50
|
+
}
|
|
84
51
|
|
|
85
|
-
|
|
52
|
+
rightText() {
|
|
53
|
+
return super.rightText(7, 6);
|
|
54
|
+
}
|
|
86
55
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
56
|
+
rightEncode() {
|
|
57
|
+
const data = this.data.substr(7, 6);
|
|
58
|
+
return super.rightEncode(data, 'RRRRRR');
|
|
59
|
+
}
|
|
91
60
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
61
|
+
// The "standard" way of printing EAN13 barcodes with guard bars
|
|
62
|
+
encodeGuarded() {
|
|
63
|
+
const data = super.encodeGuarded();
|
|
64
|
+
|
|
65
|
+
// Extend data with left digit & last character
|
|
66
|
+
if (this.options.displayValue) {
|
|
67
|
+
data.unshift({
|
|
68
|
+
data: '000000000000',
|
|
69
|
+
text: this.text.substr(0, 1),
|
|
70
|
+
options: { textAlign: 'left', fontSize: this.fontSize }
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (this.options.lastChar) {
|
|
74
|
+
data.push({
|
|
75
|
+
data: '00'
|
|
76
|
+
});
|
|
77
|
+
data.push({
|
|
78
|
+
data: '00000',
|
|
79
|
+
text: this.options.lastChar,
|
|
80
|
+
options: { fontSize: this.fontSize }
|
|
98
81
|
});
|
|
99
|
-
|
|
100
|
-
if (this.options.lastChar) {
|
|
101
|
-
data.push({
|
|
102
|
-
data: '00'
|
|
103
|
-
});
|
|
104
|
-
data.push({
|
|
105
|
-
data: '00000',
|
|
106
|
-
text: this.options.lastChar,
|
|
107
|
-
options: { fontSize: this.fontSize }
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
82
|
}
|
|
111
|
-
|
|
112
|
-
return data;
|
|
113
83
|
}
|
|
114
|
-
}]);
|
|
115
84
|
|
|
116
|
-
|
|
117
|
-
}
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
118
89
|
|
|
119
|
-
|
|
90
|
+
export default EAN13;
|