yh-hiprint 2.3.5 → 2.4.0

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 (55) hide show
  1. package/HiprintDesigner.vue +494 -86
  2. package/hooks/useHiprint.js +48 -27
  3. package/libs/jquery.js +1 -0
  4. package/libs/jsbarcode/JsBarcode.js +225 -251
  5. package/libs/jsbarcode/barcodes/Barcode.js +9 -17
  6. package/libs/jsbarcode/barcodes/CODE128/CODE128.js +93 -133
  7. package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +10 -38
  8. package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +10 -38
  9. package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +10 -38
  10. package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +10 -36
  11. package/libs/jsbarcode/barcodes/CODE128/auto.js +32 -37
  12. package/libs/jsbarcode/barcodes/CODE128/constants.js +47 -30
  13. package/libs/jsbarcode/barcodes/CODE128/index.js +5 -28
  14. package/libs/jsbarcode/barcodes/CODE39/index.js +61 -61
  15. package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +58 -78
  16. package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +66 -95
  17. package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +22 -50
  18. package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +29 -54
  19. package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +42 -66
  20. package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +92 -125
  21. package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +134 -142
  22. package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +32 -21
  23. package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +11 -18
  24. package/libs/jsbarcode/barcodes/EAN_UPC/index.js +8 -39
  25. package/libs/jsbarcode/barcodes/GenericBarcode/index.js +16 -49
  26. package/libs/jsbarcode/barcodes/ITF/ITF.js +31 -63
  27. package/libs/jsbarcode/barcodes/ITF/ITF14.js +18 -40
  28. package/libs/jsbarcode/barcodes/ITF/constants.js +6 -8
  29. package/libs/jsbarcode/barcodes/ITF/index.js +3 -18
  30. package/libs/jsbarcode/barcodes/MSI/MSI.js +31 -57
  31. package/libs/jsbarcode/barcodes/MSI/MSI10.js +7 -30
  32. package/libs/jsbarcode/barcodes/MSI/MSI1010.js +10 -33
  33. package/libs/jsbarcode/barcodes/MSI/MSI11.js +7 -30
  34. package/libs/jsbarcode/barcodes/MSI/MSI1110.js +10 -33
  35. package/libs/jsbarcode/barcodes/MSI/checksums.js +11 -17
  36. package/libs/jsbarcode/barcodes/MSI/index.js +6 -33
  37. package/libs/jsbarcode/barcodes/codabar/index.js +49 -78
  38. package/libs/jsbarcode/barcodes/index.js +20 -33
  39. package/libs/jsbarcode/barcodes/pharmacode/index.js +32 -62
  40. package/libs/jsbarcode/exceptions/ErrorHandler.js +28 -43
  41. package/libs/jsbarcode/exceptions/exceptions.js +21 -59
  42. package/libs/jsbarcode/help/fixOptions.js +3 -9
  43. package/libs/jsbarcode/help/getOptionsFromElement.js +10 -23
  44. package/libs/jsbarcode/help/getRenderProperties.js +63 -69
  45. package/libs/jsbarcode/help/linearizeEncodings.js +8 -13
  46. package/libs/jsbarcode/help/merge.js +1 -11
  47. package/libs/jsbarcode/help/optionsFromStrings.js +19 -15
  48. package/libs/jsbarcode/options/defaults.js +2 -7
  49. package/libs/jsbarcode/renderers/canvas.js +106 -127
  50. package/libs/jsbarcode/renderers/index.js +4 -20
  51. package/libs/jsbarcode/renderers/object.js +7 -23
  52. package/libs/jsbarcode/renderers/shared.js +32 -39
  53. package/libs/jsbarcode/renderers/svg.js +136 -154
  54. package/package.json +1 -1
  55. package/libs/jsbarcode/barcodes/index.tmp.js +0 -33
@@ -1,58 +1,30 @@
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:
1
+ // Encoding documentation:
26
2
  // https://en.wikipedia.org/wiki/EAN_2#Encoding
27
3
 
28
- var EAN2 = function (_Barcode) {
29
- _inherits(EAN2, _Barcode);
4
+ import { EAN2_STRUCTURE } from './constants';
5
+ import encode from './encoder';
6
+ import Barcode from '../Barcode';
30
7
 
31
- function EAN2(data, options) {
32
- _classCallCheck(this, EAN2);
8
+ class EAN2 extends Barcode {
33
9
 
34
- return _possibleConstructorReturn(this, (EAN2.__proto__ || Object.getPrototypeOf(EAN2)).call(this, data, options));
10
+ constructor(data, options) {
11
+ super(data, options);
35
12
  }
36
13
 
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
- }]);
14
+ valid() {
15
+ return this.data.search(/^[0-9]{2}$/) !== -1;
16
+ }
17
+
18
+ encode(){
19
+ // Choose the structure based on the number mod 4
20
+ const structure = EAN2_STRUCTURE[parseInt(this.data) % 4];
21
+ return {
22
+ // Start bits + Encode the two digits with 01 in between
23
+ data: '1011' + encode(this.data, structure, '01'),
24
+ text: this.text
25
+ };
26
+ }
54
27
 
55
- return EAN2;
56
- }(_Barcode3.default);
28
+ }
57
29
 
58
- exports.default = EAN2;
30
+ export default EAN2;
@@ -1,65 +1,40 @@
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:
1
+ // Encoding documentation:
26
2
  // https://en.wikipedia.org/wiki/EAN_5#Encoding
27
3
 
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);
4
+ import { EAN5_STRUCTURE } from './constants';
5
+ import encode from './encoder';
6
+ import Barcode from '../Barcode';
7
+
8
+ const checksum = (data) => {
9
+ const result = data
10
+ .split('')
11
+ .map(n => +n)
12
+ .reduce((sum, a, idx) => {
13
+ return idx % 2
14
+ ? sum + a * 9
15
+ : sum + a * 3;
16
+ }, 0);
34
17
  return result % 10;
35
18
  };
36
19
 
37
- var EAN5 = function (_Barcode) {
38
- _inherits(EAN5, _Barcode);
20
+ class EAN5 extends Barcode {
39
21
 
40
- function EAN5(data, options) {
41
- _classCallCheck(this, EAN5);
22
+ constructor(data, options) {
23
+ super(data, options);
24
+ }
42
25
 
43
- return _possibleConstructorReturn(this, (EAN5.__proto__ || Object.getPrototypeOf(EAN5)).call(this, data, options));
26
+ valid() {
27
+ return this.data.search(/^[0-9]{5}$/) !== -1;
44
28
  }
45
29
 
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
- }]);
30
+ encode() {
31
+ const structure = EAN5_STRUCTURE[checksum(this.data)];
32
+ return {
33
+ data: '1011' + encode(this.data, structure, '01'),
34
+ text: this.text
35
+ };
36
+ }
61
37
 
62
- return EAN5;
63
- }(_Barcode3.default);
38
+ }
64
39
 
65
- exports.default = EAN5;
40
+ export default EAN5;
@@ -1,81 +1,57 @@
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:
1
+ // Encoding documentation:
22
2
  // http://www.barcodeisland.com/ean8.phtml
23
3
 
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);
4
+ import EAN from './EAN';
31
5
 
32
- return (10 - res % 10) % 10;
6
+ // Calculate the checksum digit
7
+ const checksum = (number) => {
8
+ const res = number
9
+ .substr(0, 7)
10
+ .split('')
11
+ .map((n) => +n)
12
+ .reduce((sum, a, idx) => (
13
+ idx % 2 ? sum + a : sum + a * 3
14
+ ), 0);
15
+
16
+ return (10 - (res % 10)) % 10;
33
17
  };
34
18
 
35
- var EAN8 = function (_EAN) {
36
- _inherits(EAN8, _EAN);
37
-
38
- function EAN8(data, options) {
39
- _classCallCheck(this, EAN8);
19
+ class EAN8 extends EAN {
40
20
 
21
+ constructor(data, options) {
41
22
  // Add checksum if it does not exist
42
23
  if (data.search(/^[0-9]{7}$/) !== -1) {
43
24
  data += checksum(data);
44
25
  }
45
26
 
46
- return _possibleConstructorReturn(this, (EAN8.__proto__ || Object.getPrototypeOf(EAN8)).call(this, data, options));
27
+ super(data, options);
47
28
  }
48
29
 
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
- }]);
30
+ valid() {
31
+ return (
32
+ this.data.search(/^[0-9]{8}$/) !== -1 &&
33
+ +this.data[7] === checksum(this.data)
34
+ );
35
+ }
36
+
37
+ leftText() {
38
+ return super.leftText(0, 4);
39
+ }
40
+
41
+ leftEncode() {
42
+ const data = this.data.substr(0, 4);
43
+ return super.leftEncode(data, 'LLLL');
44
+ }
45
+
46
+ rightText() {
47
+ return super.rightText(4, 4);
48
+ }
49
+
50
+ rightEncode() {
51
+ const data = this.data.substr(4, 4);
52
+ return super.rightEncode(data, 'RRRR');
53
+ }
77
54
 
78
- return EAN8;
79
- }(_EAN3.default);
55
+ }
80
56
 
81
- exports.default = EAN8;
57
+ export default EAN8;
@@ -1,165 +1,132 @@
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
- exports.checksum = checksum;
10
-
11
- var _encoder = require("./encoder");
12
-
13
- var _encoder2 = _interopRequireDefault(_encoder);
14
-
15
- var _Barcode2 = require("../Barcode.js");
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:
1
+ // Encoding documentation:
26
2
  // https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
27
3
 
28
- var UPC = function (_Barcode) {
29
- _inherits(UPC, _Barcode);
30
-
31
- function UPC(data, options) {
32
- _classCallCheck(this, UPC);
4
+ import encode from './encoder';
5
+ import Barcode from "../Barcode.js";
33
6
 
7
+ class UPC extends Barcode{
8
+ constructor(data, options){
34
9
  // Add checksum if it does not exist
35
- if (data.search(/^[0-9]{11}$/) !== -1) {
10
+ if(data.search(/^[0-9]{11}$/) !== -1){
36
11
  data += checksum(data);
37
12
  }
38
13
 
39
- var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options));
14
+ super(data, options);
40
15
 
41
- _this.displayValue = options.displayValue;
16
+ this.displayValue = options.displayValue;
42
17
 
43
18
  // Make sure the font is not bigger than the space between the guard bars
44
- if (options.fontSize > options.width * 10) {
45
- _this.fontSize = options.width * 10;
46
- } else {
47
- _this.fontSize = options.fontSize;
19
+ if(options.fontSize > options.width * 10){
20
+ this.fontSize = options.width * 10;
21
+ }
22
+ else{
23
+ this.fontSize = options.fontSize;
48
24
  }
49
25
 
50
26
  // Make the guard bars go down half the way of the text
51
- _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
52
- return _this;
27
+ this.guardHeight = options.height + this.fontSize / 2 + options.textMargin;
53
28
  }
54
29
 
55
- _createClass(UPC, [{
56
- key: "valid",
57
- value: function valid() {
58
- return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data);
59
- }
60
- }, {
61
- key: "encode",
62
- value: function encode() {
63
- if (this.options.flat) {
64
- return this.flatEncoding();
65
- } else {
66
- return this.guardedEncoding();
67
- }
30
+ valid(){
31
+ return this.data.search(/^[0-9]{12}$/) !== -1 &&
32
+ this.data[11] == checksum(this.data);
33
+ }
34
+
35
+ encode(){
36
+ if(this.options.flat){
37
+ return this.flatEncoding();
68
38
  }
69
- }, {
70
- key: "flatEncoding",
71
- value: function flatEncoding() {
72
- var result = "";
73
-
74
- result += "101";
75
- result += (0, _encoder2.default)(this.data.substr(0, 6), "LLLLLL");
76
- result += "01010";
77
- result += (0, _encoder2.default)(this.data.substr(6, 6), "RRRRRR");
78
- result += "101";
79
-
80
- return {
81
- data: result,
82
- text: this.text
83
- };
39
+ else{
40
+ return this.guardedEncoding();
84
41
  }
85
- }, {
86
- key: "guardedEncoding",
87
- value: function guardedEncoding() {
88
- var result = [];
89
-
90
- // Add the first digit
91
- if (this.displayValue) {
92
- result.push({
93
- data: "00000000",
94
- text: this.text.substr(0, 1),
95
- options: { textAlign: "left", fontSize: this.fontSize }
96
- });
97
- }
98
-
99
- // Add the guard bars
100
- result.push({
101
- data: "101" + (0, _encoder2.default)(this.data[0], "L"),
102
- options: { height: this.guardHeight }
103
- });
42
+ }
104
43
 
105
- // Add the left side
106
- result.push({
107
- data: (0, _encoder2.default)(this.data.substr(1, 5), "LLLLL"),
108
- text: this.text.substr(1, 5),
109
- options: { fontSize: this.fontSize }
110
- });
44
+ flatEncoding(){
45
+ var result = "";
111
46
 
112
- // Add the middle bits
113
- result.push({
114
- data: "01010",
115
- options: { height: this.guardHeight }
116
- });
47
+ result += "101";
48
+ result += encode(this.data.substr(0, 6), "LLLLLL");
49
+ result += "01010";
50
+ result += encode(this.data.substr(6, 6), "RRRRRR");
51
+ result += "101";
52
+
53
+ return {
54
+ data: result,
55
+ text: this.text
56
+ };
57
+ }
117
58
 
118
- // Add the right side
59
+ guardedEncoding(){
60
+ var result = [];
61
+
62
+ // Add the first digit
63
+ if(this.displayValue){
119
64
  result.push({
120
- data: (0, _encoder2.default)(this.data.substr(6, 5), "RRRRR"),
121
- text: this.text.substr(6, 5),
122
- options: { fontSize: this.fontSize }
65
+ data: "00000000",
66
+ text: this.text.substr(0, 1),
67
+ options: {textAlign: "left", fontSize: this.fontSize}
123
68
  });
69
+ }
124
70
 
125
- // Add the end bits
71
+ // Add the guard bars
72
+ result.push({
73
+ data: "101" + encode(this.data[0], "L"),
74
+ options: {height: this.guardHeight}
75
+ });
76
+
77
+ // Add the left side
78
+ result.push({
79
+ data: encode(this.data.substr(1, 5), "LLLLL"),
80
+ text: this.text.substr(1, 5),
81
+ options: {fontSize: this.fontSize}
82
+ });
83
+
84
+ // Add the middle bits
85
+ result.push({
86
+ data: "01010",
87
+ options: {height: this.guardHeight}
88
+ });
89
+
90
+ // Add the right side
91
+ result.push({
92
+ data: encode(this.data.substr(6, 5), "RRRRR"),
93
+ text: this.text.substr(6, 5),
94
+ options: {fontSize: this.fontSize}
95
+ });
96
+
97
+ // Add the end bits
98
+ result.push({
99
+ data: encode(this.data[11], "R") + "101",
100
+ options: {height: this.guardHeight}
101
+ });
102
+
103
+ // Add the last digit
104
+ if(this.displayValue){
126
105
  result.push({
127
- data: (0, _encoder2.default)(this.data[11], "R") + "101",
128
- options: { height: this.guardHeight }
106
+ data: "00000000",
107
+ text: this.text.substr(11, 1),
108
+ options: {textAlign: "right", fontSize: this.fontSize}
129
109
  });
130
-
131
- // Add the last digit
132
- if (this.displayValue) {
133
- result.push({
134
- data: "00000000",
135
- text: this.text.substr(11, 1),
136
- options: { textAlign: "right", fontSize: this.fontSize }
137
- });
138
- }
139
-
140
- return result;
141
110
  }
142
- }]);
143
111
 
144
- return UPC;
145
- }(_Barcode3.default);
112
+ return result;
113
+ }
114
+ }
146
115
 
147
116
  // Calulate the checksum digit
148
117
  // https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
149
-
150
-
151
- function checksum(number) {
118
+ export function checksum(number){
152
119
  var result = 0;
153
120
 
154
121
  var i;
155
- for (i = 1; i < 11; i += 2) {
122
+ for(i = 1; i < 11; i += 2){
156
123
  result += parseInt(number[i]);
157
124
  }
158
- for (i = 0; i < 11; i += 2) {
125
+ for(i = 0; i < 11; i += 2){
159
126
  result += parseInt(number[i]) * 3;
160
127
  }
161
128
 
162
- return (10 - result % 10) % 10;
129
+ return (10 - (result % 10)) % 10;
163
130
  }
164
131
 
165
- exports.default = UPC;
132
+ export default UPC;