@10yun/cv-mobile-ui 0.4.12 → 0.5.2

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 (61) hide show
  1. package/extend/permission.js +44 -45
  2. package/package.json +4 -4
  3. package/plugins/MessageTip.js +4 -4
  4. package/plugins/request.js +54 -39
  5. package/plugins/storage.js +1 -4
  6. package/plugins/utils.js +13 -0
  7. package/ui-cv/cv-draw-barcode/barcode.js +225 -202
  8. package/ui-cv/cv-draw-barcode/barcodes/Barcode.js +14 -17
  9. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128.js +202 -164
  10. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128A.js +58 -35
  11. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128B.js +58 -36
  12. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128C.js +58 -34
  13. package/ui-cv/cv-draw-barcode/barcodes/CODE128/CODE128_AUTO.js +50 -41
  14. package/ui-cv/cv-draw-barcode/barcodes/CODE128/auto.js +43 -57
  15. package/ui-cv/cv-draw-barcode/barcodes/CODE128/constants.js +71 -30
  16. package/ui-cv/cv-draw-barcode/barcodes/CODE128/index.js +11 -29
  17. package/ui-cv/cv-draw-barcode/barcodes/CODE39/index.js +150 -77
  18. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN.js +122 -90
  19. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN13.js +169 -111
  20. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN2.js +77 -56
  21. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN5.js +84 -60
  22. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/EAN8.js +133 -74
  23. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/UPC.js +174 -156
  24. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/UPCE.js +220 -174
  25. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/constants.js +80 -21
  26. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/encoder.js +18 -24
  27. package/ui-cv/cv-draw-barcode/barcodes/EAN_UPC/index.js +15 -39
  28. package/ui-cv/cv-draw-barcode/barcodes/GenericBarcode/index.js +80 -55
  29. package/ui-cv/cv-draw-barcode/barcodes/ITF/ITF.js +99 -69
  30. package/ui-cv/cv-draw-barcode/barcodes/ITF/ITF14.js +73 -45
  31. package/ui-cv/cv-draw-barcode/barcodes/ITF/constants.js +8 -8
  32. package/ui-cv/cv-draw-barcode/barcodes/ITF/index.js +6 -18
  33. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI.js +86 -66
  34. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI10.js +40 -33
  35. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI1010.js +41 -35
  36. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI11.js +42 -33
  37. package/ui-cv/cv-draw-barcode/barcodes/MSI/MSI1110.js +37 -35
  38. package/ui-cv/cv-draw-barcode/barcodes/MSI/checksums.js +22 -25
  39. package/ui-cv/cv-draw-barcode/barcodes/MSI/index.js +13 -34
  40. package/ui-cv/cv-draw-barcode/barcodes/codabar/index.js +120 -90
  41. package/ui-cv/cv-draw-barcode/barcodes/common.js +0 -0
  42. package/ui-cv/cv-draw-barcode/barcodes/index.js +32 -33
  43. package/ui-cv/cv-draw-barcode/barcodes/index.tmp.js +32 -33
  44. package/ui-cv/cv-draw-barcode/barcodes/pharmacode/index.js +93 -71
  45. package/ui-cv/cv-draw-barcode/cv-draw-barcode.vue +4 -4
  46. package/ui-cv/cv-icons/icons/default-icons.js +132 -0
  47. package/ui-cv/cv-icons/icons/icons-action.js +72 -0
  48. package/ui-cv/cv-icons/icons/icons-arrow.js +46 -0
  49. package/ui-cv/cv-icons/icons/icons-base.js +89 -0
  50. package/ui-cv/cv-icons/icons/icons-mall.js +34 -0
  51. package/ui-cv/cv-icons/icons/icons-media.js +44 -0
  52. package/ui-cv/cv-icons/icons/icons-order.js +33 -0
  53. package/ui-cv/cv-icons/icons/icons-people.js +46 -0
  54. package/ui-cv/cv-icons/icons/icons-status.js +32 -0
  55. package/ui-cv/cv-icons/icons/icons-wallet.js +15 -0
  56. package/ui-cv/cv-icons/icons.js +13 -13
  57. package/ui-cv/cv-lists-base/cv-lists-base.vue +0 -2
  58. package/ui-cv/cv-tab-lists/cv-tab-lists.vue +0 -2
  59. package/ui-uni/u-charts/u-charts.js +1093 -744
  60. package/ui-uni/uni-list/uni-refresh.wxs +1 -1
  61. package/ui-uni/uni-swipe-action-item/index.wxs +6 -6
@@ -1,81 +1,140 @@
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; }
1
+ import EAN_FUNC from './EAN.js';
2
+
3
+ var _createClass = (function () {
4
+ function defineProperties(target, props) {
5
+ for (var i = 0; i < props.length; i++) {
6
+ var descriptor = props[i];
7
+ descriptor.enumerable = descriptor.enumerable || false;
8
+ descriptor.configurable = true;
9
+ if ('value' in descriptor) descriptor.writable = true;
10
+ Object.defineProperty(target, descriptor.key, descriptor);
11
+ }
12
+ }
13
+ return function (Constructor, protoProps, staticProps) {
14
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
15
+ if (staticProps) defineProperties(Constructor, staticProps);
16
+ return Constructor;
17
+ };
18
+ })();
19
+
20
+ var _get = function get(object, property, receiver) {
21
+ if (object === null) object = Function.prototype;
22
+ var desc = Object.getOwnPropertyDescriptor(object, property);
23
+ if (desc === undefined) {
24
+ var parent = Object.getPrototypeOf(object);
25
+ if (parent === null) {
26
+ return undefined;
27
+ } else {
28
+ return get(parent, property, receiver);
29
+ }
30
+ } else if ('value' in desc) {
31
+ return desc.value;
32
+ } else {
33
+ var getter = desc.get;
34
+ if (getter === undefined) {
35
+ return undefined;
36
+ }
37
+ return getter.call(receiver);
38
+ }
39
+ };
20
40
 
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:
41
+ function _classCallCheck(instance, Constructor) {
42
+ if (!(instance instanceof Constructor)) {
43
+ throw new TypeError('Cannot call a class as a function');
44
+ }
45
+ }
46
+
47
+ function _possibleConstructorReturn(self, call) {
48
+ if (!self) {
49
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
50
+ }
51
+ return call && (typeof call === 'object' || typeof call === 'function') ? call : self;
52
+ }
53
+
54
+ function _inherits(subClass, superClass) {
55
+ if (typeof superClass !== 'function' && superClass !== null) {
56
+ throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
57
+ }
58
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
59
+ constructor: { value: subClass, enumerable: false, writable: true, configurable: true }
60
+ });
61
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : (subClass.__proto__ = superClass);
62
+ } // Encoding documentation:
22
63
  // http://www.barcodeisland.com/ean8.phtml
23
64
 
24
65
  // Calculate the checksum digit
25
66
  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;
67
+ var res = number
68
+ .substr(0, 7)
69
+ .split('')
70
+ .map(function (n) {
71
+ return +n;
72
+ })
73
+ .reduce(function (sum, a, idx) {
74
+ return idx % 2 ? sum + a : sum + a * 3;
75
+ }, 0);
76
+
77
+ return (10 - (res % 10)) % 10;
33
78
  };
34
79
 
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;
80
+ var EAN8 = (function (_EAN) {
81
+ _inherits(EAN8, _EAN);
82
+
83
+ function EAN8(data, options) {
84
+ _classCallCheck(this, EAN8);
85
+
86
+ // Add checksum if it does not exist
87
+ if (data.search(/^[0-9]{7}$/) !== -1) {
88
+ data += checksum(data);
89
+ }
90
+
91
+ return _possibleConstructorReturn(this, (EAN8.__proto__ || Object.getPrototypeOf(EAN8)).call(this, data, options));
92
+ }
93
+
94
+ _createClass(EAN8, [
95
+ {
96
+ key: 'valid',
97
+ value: function valid() {
98
+ return this.data.search(/^[0-9]{8}$/) !== -1 && +this.data[7] === checksum(this.data);
99
+ }
100
+ },
101
+ {
102
+ key: 'leftText',
103
+ value: function leftText() {
104
+ return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftText', this).call(this, 0, 4);
105
+ }
106
+ },
107
+ {
108
+ key: 'leftEncode',
109
+ value: function leftEncode() {
110
+ var data = this.data.substr(0, 4);
111
+ return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftEncode', this).call(
112
+ this,
113
+ data,
114
+ 'LLLL'
115
+ );
116
+ }
117
+ },
118
+ {
119
+ key: 'rightText',
120
+ value: function rightText() {
121
+ return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightText', this).call(this, 4, 4);
122
+ }
123
+ },
124
+ {
125
+ key: 'rightEncode',
126
+ value: function rightEncode() {
127
+ var data = this.data.substr(4, 4);
128
+ return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightEncode', this).call(
129
+ this,
130
+ data,
131
+ 'RRRR'
132
+ );
133
+ }
134
+ }
135
+ ]);
136
+
137
+ return EAN8;
138
+ })(EAN_FUNC);
139
+
140
+ export default EAN8;
@@ -1,165 +1,183 @@
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"); } }
1
+ import _constants from './constants.js';
2
+ import { BarcodeFunc } from '../Barcode.js';
3
+ import { encoderFunc } from './encoder.js';
4
+
5
+ var _createClass = (function () {
6
+ function defineProperties(target, props) {
7
+ for (var i = 0; i < props.length; i++) {
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ('value' in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
13
+ }
14
+ }
15
+ return function (Constructor, protoProps, staticProps) {
16
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ };
20
+ })();
21
+
22
+ function _classCallCheck(instance, Constructor) {
23
+ if (!(instance instanceof Constructor)) {
24
+ throw new TypeError('Cannot call a class as a function');
25
+ }
26
+ }
22
27
 
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; }
28
+ function _possibleConstructorReturn(self, call) {
29
+ if (!self) {
30
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
31
+ }
32
+ return call && (typeof call === 'object' || typeof call === 'function') ? call : self;
33
+ }
24
34
 
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:
35
+ function _inherits(subClass, superClass) {
36
+ if (typeof superClass !== 'function' && superClass !== null) {
37
+ throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
38
+ }
39
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
40
+ constructor: { value: subClass, enumerable: false, writable: true, configurable: true }
41
+ });
42
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : (subClass.__proto__ = superClass);
43
+ } // Encoding documentation:
26
44
  // https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
27
45
 
28
- var UPC = function (_Barcode) {
29
- _inherits(UPC, _Barcode);
30
-
31
- function UPC(data, options) {
32
- _classCallCheck(this, UPC);
33
-
34
- // Add checksum if it does not exist
35
- if (data.search(/^[0-9]{11}$/) !== -1) {
36
- data += checksum(data);
37
- }
38
-
39
- var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options));
40
-
41
- _this.displayValue = options.displayValue;
42
-
43
- // 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;
48
- }
49
-
50
- // 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;
53
- }
54
-
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
- }
68
- }
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
- };
84
- }
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
- });
104
-
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
- });
111
-
112
- // Add the middle bits
113
- result.push({
114
- data: "01010",
115
- options: { height: this.guardHeight }
116
- });
117
-
118
- // Add the right side
119
- 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 }
123
- });
124
-
125
- // Add the end bits
126
- result.push({
127
- data: (0, _encoder2.default)(this.data[11], "R") + "101",
128
- options: { height: this.guardHeight }
129
- });
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
- }
142
- }]);
143
-
144
- return UPC;
145
- }(_Barcode3.default);
46
+ var UPC = (function (_Barcode) {
47
+ _inherits(UPC, _Barcode);
48
+
49
+ function UPC(data, options) {
50
+ _classCallCheck(this, UPC);
51
+
52
+ // Add checksum if it does not exist
53
+ if (data.search(/^[0-9]{11}$/) !== -1) {
54
+ data += checksum(data);
55
+ }
56
+
57
+ var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options));
58
+
59
+ _this.displayValue = options.displayValue;
60
+
61
+ // Make sure the font is not bigger than the space between the guard bars
62
+ if (options.fontSize > options.width * 10) {
63
+ _this.fontSize = options.width * 10;
64
+ } else {
65
+ _this.fontSize = options.fontSize;
66
+ }
67
+
68
+ // Make the guard bars go down half the way of the text
69
+ _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
70
+ return _this;
71
+ }
72
+
73
+ _createClass(UPC, [
74
+ {
75
+ key: 'valid',
76
+ value: function valid() {
77
+ return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data);
78
+ }
79
+ },
80
+ {
81
+ key: 'encode',
82
+ value: function encode() {
83
+ if (this.options.flat) {
84
+ return this.flatEncoding();
85
+ } else {
86
+ return this.guardedEncoding();
87
+ }
88
+ }
89
+ },
90
+ {
91
+ key: 'flatEncoding',
92
+ value: function flatEncoding() {
93
+ var result = '';
94
+
95
+ result += '101';
96
+ result += (0, encoderFunc)(this.data.substr(0, 6), 'LLLLLL');
97
+ result += '01010';
98
+ result += (0, encoderFunc)(this.data.substr(6, 6), 'RRRRRR');
99
+ result += '101';
100
+
101
+ return {
102
+ data: result,
103
+ text: this.text
104
+ };
105
+ }
106
+ },
107
+ {
108
+ key: 'guardedEncoding',
109
+ value: function guardedEncoding() {
110
+ var result = [];
111
+
112
+ // Add the first digit
113
+ if (this.displayValue) {
114
+ result.push({
115
+ data: '00000000',
116
+ text: this.text.substr(0, 1),
117
+ options: { textAlign: 'left', fontSize: this.fontSize }
118
+ });
119
+ }
120
+
121
+ // Add the guard bars
122
+ result.push({
123
+ data: '101' + (0, encoderFunc)(this.data[0], 'L'),
124
+ options: { height: this.guardHeight }
125
+ });
126
+
127
+ // Add the left side
128
+ result.push({
129
+ data: (0, encoderFunc)(this.data.substr(1, 5), 'LLLLL'),
130
+ text: this.text.substr(1, 5),
131
+ options: { fontSize: this.fontSize }
132
+ });
133
+
134
+ // Add the middle bits
135
+ result.push({
136
+ data: '01010',
137
+ options: { height: this.guardHeight }
138
+ });
139
+
140
+ // Add the right side
141
+ result.push({
142
+ data: (0, encoderFunc)(this.data.substr(6, 5), 'RRRRR'),
143
+ text: this.text.substr(6, 5),
144
+ options: { fontSize: this.fontSize }
145
+ });
146
+
147
+ // Add the end bits
148
+ result.push({
149
+ data: (0, encoderFunc)(this.data[11], 'R') + '101',
150
+ options: { height: this.guardHeight }
151
+ });
152
+
153
+ // Add the last digit
154
+ if (this.displayValue) {
155
+ result.push({
156
+ data: '00000000',
157
+ text: this.text.substr(11, 1),
158
+ options: { textAlign: 'right', fontSize: this.fontSize }
159
+ });
160
+ }
161
+
162
+ return result;
163
+ }
164
+ }
165
+ ]);
166
+ return UPC;
167
+ })(BarcodeFunc);
146
168
 
147
169
  // Calulate the checksum digit
148
170
  // https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
149
-
150
-
151
- function checksum(number) {
152
- var result = 0;
153
-
154
- var i;
155
- for (i = 1; i < 11; i += 2) {
156
- result += parseInt(number[i]);
157
- }
158
- for (i = 0; i < 11; i += 2) {
159
- result += parseInt(number[i]) * 3;
160
- }
161
-
162
- return (10 - result % 10) % 10;
171
+ export function checksum(number) {
172
+ var result = 0;
173
+ var i;
174
+ for (i = 1; i < 11; i += 2) {
175
+ result += parseInt(number[i]);
176
+ }
177
+ for (i = 0; i < 11; i += 2) {
178
+ result += parseInt(number[i]) * 3;
179
+ }
180
+ return (10 - (result % 10)) % 10;
163
181
  }
164
182
 
165
- exports.default = UPC;
183
+ export default UPC;