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