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
package/libs/jquery.js
CHANGED
|
@@ -10617,5 +10617,4 @@ jQuery.trim = function (text) {
|
|
|
10617
10617
|
};
|
|
10618
10618
|
|
|
10619
10619
|
|
|
10620
|
-
|
|
10621
|
-
export default jQuery;
|
|
10620
|
+
window.hiprintJQuery = jQuery;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
var hiprintJQuery = require("../jquery.js");
|
|
2
|
+
var _barcodes = require('./barcodes/');
|
|
3
|
+
|
|
4
|
+
var _barcodes2 = _interopRequireDefault(_barcodes);
|
|
5
|
+
|
|
6
|
+
var _merge = require('./help/merge.js');
|
|
7
|
+
|
|
8
|
+
var _merge2 = _interopRequireDefault(_merge);
|
|
9
|
+
|
|
10
|
+
var _linearizeEncodings = require('./help/linearizeEncodings.js');
|
|
11
|
+
|
|
12
|
+
var _linearizeEncodings2 = _interopRequireDefault(_linearizeEncodings);
|
|
13
|
+
|
|
14
|
+
var _fixOptions = require('./help/fixOptions.js');
|
|
15
|
+
|
|
16
|
+
var _fixOptions2 = _interopRequireDefault(_fixOptions);
|
|
17
|
+
|
|
18
|
+
var _getRenderProperties = require('./help/getRenderProperties.js');
|
|
19
|
+
|
|
20
|
+
var _getRenderProperties2 = _interopRequireDefault(_getRenderProperties);
|
|
21
|
+
|
|
22
|
+
var _optionsFromStrings = require('./help/optionsFromStrings.js');
|
|
23
|
+
|
|
24
|
+
var _optionsFromStrings2 = _interopRequireDefault(_optionsFromStrings);
|
|
25
|
+
|
|
26
|
+
var _ErrorHandler = require('./exceptions/ErrorHandler.js');
|
|
27
|
+
|
|
28
|
+
var _ErrorHandler2 = _interopRequireDefault(_ErrorHandler);
|
|
29
|
+
|
|
30
|
+
var _exceptions = require('./exceptions/exceptions.js');
|
|
31
|
+
|
|
32
|
+
var _defaults = require('./options/defaults.js');
|
|
33
|
+
|
|
34
|
+
var _defaults2 = _interopRequireDefault(_defaults);
|
|
35
|
+
|
|
36
|
+
function _interopRequireDefault (obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
|
|
38
|
+
// The protype of the object returned from the JsBarcode() call
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// Help functions
|
|
42
|
+
var API = function API () {};
|
|
43
|
+
|
|
44
|
+
// The first call of the library API
|
|
45
|
+
// Will return an object with all barcodes calls and the data that is used
|
|
46
|
+
// by the renderers
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// Default values
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// Exceptions
|
|
53
|
+
// Import all the barcodes
|
|
54
|
+
var JsBarcode = function JsBarcode (element, text, options) {
|
|
55
|
+
var api = new API();
|
|
56
|
+
|
|
57
|
+
if (typeof element === "undefined") {
|
|
58
|
+
throw Error("No element to render on was provided.");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Variables that will be pased through the API calls
|
|
62
|
+
api._renderProperties = (0, _getRenderProperties2.default)(element);
|
|
63
|
+
api._encodings = [];
|
|
64
|
+
api._options = _defaults2.default;
|
|
65
|
+
api._errorHandler = new _ErrorHandler2.default(api);
|
|
66
|
+
|
|
67
|
+
// If text is set, use the simple syntax (render the barcode directly)
|
|
68
|
+
if (typeof text !== "undefined") {
|
|
69
|
+
options = options || {};
|
|
70
|
+
|
|
71
|
+
if (!options.format) {
|
|
72
|
+
options.format = autoSelectBarcode();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
api.options(options)[options.format](text, options).render();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return api;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// To make tests work TODO: remove
|
|
82
|
+
JsBarcode.getModule = function (name) {
|
|
83
|
+
return _barcodes2.default[name];
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Register all barcodes
|
|
87
|
+
for (var name in _barcodes2.default) {
|
|
88
|
+
if (_barcodes2.default.hasOwnProperty(name)) {
|
|
89
|
+
// Security check if the propery is a prototype property
|
|
90
|
+
registerBarcode(_barcodes2.default, name);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function registerBarcode (barcodes, name) {
|
|
94
|
+
API.prototype[name] = API.prototype[name.toUpperCase()] = API.prototype[name.toLowerCase()] = function (text, options) {
|
|
95
|
+
var api = this;
|
|
96
|
+
return api._errorHandler.wrapBarcodeCall(function () {
|
|
97
|
+
// Ensure text is options.text
|
|
98
|
+
options.text = typeof options.text === 'undefined' ? undefined : '' + options.text;
|
|
99
|
+
|
|
100
|
+
var newOptions = (0, _merge2.default)(api._options, options);
|
|
101
|
+
newOptions = (0, _optionsFromStrings2.default)(newOptions);
|
|
102
|
+
var Encoder = barcodes[name];
|
|
103
|
+
var encoded = encode(text, Encoder, newOptions);
|
|
104
|
+
api._encodings.push(encoded);
|
|
105
|
+
|
|
106
|
+
return api;
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// encode() handles the Encoder call and builds the binary string to be rendered
|
|
112
|
+
function encode (text, Encoder, options) {
|
|
113
|
+
// Ensure that text is a string
|
|
114
|
+
text = "" + text;
|
|
115
|
+
|
|
116
|
+
var encoder = new Encoder(text, options);
|
|
117
|
+
|
|
118
|
+
// If the input is not valid for the encoder, throw error.
|
|
119
|
+
// If the valid callback option is set, call it instead of throwing error
|
|
120
|
+
if (!encoder.valid()) {
|
|
121
|
+
throw new _exceptions.InvalidInputException(encoder.constructor.name, text);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Make a request for the binary data (and other infromation) that should be rendered
|
|
125
|
+
var encoded = encoder.encode();
|
|
126
|
+
|
|
127
|
+
// Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
|
|
128
|
+
// Convert to [1-1, 1-2, 2, 3-1, 3-2]
|
|
129
|
+
encoded = (0, _linearizeEncodings2.default)(encoded);
|
|
130
|
+
|
|
131
|
+
// Merge
|
|
132
|
+
for (var i = 0; i < encoded.length; i++) {
|
|
133
|
+
encoded[i].options = (0, _merge2.default)(options, encoded[i].options);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return encoded;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function autoSelectBarcode () {
|
|
140
|
+
// If CODE128 exists. Use it
|
|
141
|
+
if (_barcodes2.default["CODE128"]) {
|
|
142
|
+
return "CODE128";
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Else, take the first (probably only) barcode
|
|
146
|
+
return Object.keys(_barcodes2.default)[0];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Sets global encoder options
|
|
150
|
+
// Added to the api by the JsBarcode function
|
|
151
|
+
API.prototype.options = function (options) {
|
|
152
|
+
this._options = (0, _merge2.default)(this._options, options);
|
|
153
|
+
return this;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// Will create a blank space (usually in between barcodes)
|
|
157
|
+
API.prototype.blank = function (size) {
|
|
158
|
+
var zeroes = new Array(size + 1).join("0");
|
|
159
|
+
this._encodings.push({ data: zeroes });
|
|
160
|
+
return this;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// Initialize JsBarcode on all HTML elements defined.
|
|
164
|
+
API.prototype.init = function () {
|
|
165
|
+
// Should do nothing if no elements where found
|
|
166
|
+
if (!this._renderProperties) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Make sure renderProperies is an array
|
|
171
|
+
if (!Array.isArray(this._renderProperties)) {
|
|
172
|
+
this._renderProperties = [this._renderProperties];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var renderProperty;
|
|
176
|
+
for (var i in this._renderProperties) {
|
|
177
|
+
renderProperty = this._renderProperties[i];
|
|
178
|
+
var options = (0, _merge2.default)(this._options, renderProperty.options);
|
|
179
|
+
|
|
180
|
+
if (options.format == "auto") {
|
|
181
|
+
options.format = autoSelectBarcode();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
this._errorHandler.wrapBarcodeCall(function () {
|
|
185
|
+
var text = options.value;
|
|
186
|
+
var Encoder = _barcodes2.default[options.format.toUpperCase()];
|
|
187
|
+
var encoded = encode(text, Encoder, options);
|
|
188
|
+
|
|
189
|
+
render(renderProperty, encoded, options);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// The render API call. Calls the real render function.
|
|
195
|
+
API.prototype.render = function () {
|
|
196
|
+
if (!this._renderProperties) {
|
|
197
|
+
throw new _exceptions.NoElementException();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (Array.isArray(this._renderProperties)) {
|
|
201
|
+
for (var i = 0; i < this._renderProperties.length; i++) {
|
|
202
|
+
render(this._renderProperties[i], this._encodings, this._options);
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
render(this._renderProperties, this._encodings, this._options);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return this;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
API.prototype._defaults = _defaults2.default;
|
|
212
|
+
|
|
213
|
+
// Prepares the encodings and calls the renderer
|
|
214
|
+
function render (renderProperties, encodings, options) {
|
|
215
|
+
encodings = (0, _linearizeEncodings2.default)(encodings);
|
|
216
|
+
|
|
217
|
+
for (var i = 0; i < encodings.length; i++) {
|
|
218
|
+
encodings[i].options = (0, _merge2.default)(options, encodings[i].options);
|
|
219
|
+
(0, _fixOptions2.default)(encodings[i].options);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
(0, _fixOptions2.default)(options);
|
|
223
|
+
|
|
224
|
+
var Renderer = renderProperties.renderer;
|
|
225
|
+
var renderer = new Renderer(renderProperties.element, encodings, options);
|
|
226
|
+
renderer.render();
|
|
227
|
+
|
|
228
|
+
if (renderProperties.afterRender) {
|
|
229
|
+
renderProperties.afterRender();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Export to browser
|
|
234
|
+
if (typeof window !== "undefined") {
|
|
235
|
+
window.JsBarcode = JsBarcode;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Export to jQuery
|
|
239
|
+
/*global jQuery */
|
|
240
|
+
if (typeof hiprintJQuery !== 'undefined') {
|
|
241
|
+
hiprintJQuery.fn.JsBarcode = function (content, options) {
|
|
242
|
+
var elementArray = [];
|
|
243
|
+
hiprintJQuery(this).each(function () {
|
|
244
|
+
elementArray.push(this);
|
|
245
|
+
});
|
|
246
|
+
return JsBarcode(elementArray, content, options);
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Export to commonJS
|
|
251
|
+
module.exports = JsBarcode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
|
|
9
|
+
var Barcode = function Barcode(data, options) {
|
|
10
|
+
_classCallCheck(this, Barcode);
|
|
11
|
+
|
|
12
|
+
this.data = data;
|
|
13
|
+
this.text = options.text || data;
|
|
14
|
+
this.options = options;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.default = Barcode;
|
|
@@ -0,0 +1,167 @@
|
|
|
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 _Barcode2 = require('../Barcode.js');
|
|
10
|
+
|
|
11
|
+
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
|
12
|
+
|
|
13
|
+
var _constants = require('./constants');
|
|
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; }
|
|
22
|
+
|
|
23
|
+
// This is the master class,
|
|
24
|
+
// it does require the start code to be included in the string
|
|
25
|
+
var CODE128 = function (_Barcode) {
|
|
26
|
+
_inherits(CODE128, _Barcode);
|
|
27
|
+
|
|
28
|
+
function CODE128(data, options) {
|
|
29
|
+
_classCallCheck(this, CODE128);
|
|
30
|
+
|
|
31
|
+
// Get array of ascii codes from data
|
|
32
|
+
var _this = _possibleConstructorReturn(this, (CODE128.__proto__ || Object.getPrototypeOf(CODE128)).call(this, data.substring(1), options));
|
|
33
|
+
|
|
34
|
+
_this.bytes = data.split('').map(function (char) {
|
|
35
|
+
return char.charCodeAt(0);
|
|
36
|
+
});
|
|
37
|
+
return _this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_createClass(CODE128, [{
|
|
41
|
+
key: 'valid',
|
|
42
|
+
value: function valid() {
|
|
43
|
+
// ASCII value ranges 0-127, 200-211
|
|
44
|
+
return (/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// The public encoding function
|
|
49
|
+
|
|
50
|
+
}, {
|
|
51
|
+
key: 'encode',
|
|
52
|
+
value: function encode() {
|
|
53
|
+
var bytes = this.bytes;
|
|
54
|
+
// Remove the start code from the bytes and set its index
|
|
55
|
+
var startIndex = bytes.shift() - 105;
|
|
56
|
+
// Get start set by index
|
|
57
|
+
var startSet = _constants.SET_BY_CODE[startIndex];
|
|
58
|
+
|
|
59
|
+
if (startSet === undefined) {
|
|
60
|
+
throw new RangeError('The encoding does not start with a start character.');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (this.shouldEncodeAsEan128() === true) {
|
|
64
|
+
bytes.unshift(_constants.FNC1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Start encode with the right type
|
|
68
|
+
var encodingResult = CODE128.next(bytes, 1, startSet);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
text: this.text === this.data ? this.text.replace(/[^\x20-\x7E]/g, '') : this.text,
|
|
72
|
+
data:
|
|
73
|
+
// Add the start bits
|
|
74
|
+
CODE128.getBar(startIndex) +
|
|
75
|
+
// Add the encoded bits
|
|
76
|
+
encodingResult.result +
|
|
77
|
+
// Add the checksum
|
|
78
|
+
CODE128.getBar((encodingResult.checksum + startIndex) % _constants.MODULO) +
|
|
79
|
+
// Add the end bits
|
|
80
|
+
CODE128.getBar(_constants.STOP)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// GS1-128/EAN-128
|
|
85
|
+
|
|
86
|
+
}, {
|
|
87
|
+
key: 'shouldEncodeAsEan128',
|
|
88
|
+
value: function shouldEncodeAsEan128() {
|
|
89
|
+
var isEAN128 = this.options.ean128 || false;
|
|
90
|
+
if (typeof isEAN128 === 'string') {
|
|
91
|
+
isEAN128 = isEAN128.toLowerCase() === 'true';
|
|
92
|
+
}
|
|
93
|
+
return isEAN128;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Get a bar symbol by index
|
|
97
|
+
|
|
98
|
+
}], [{
|
|
99
|
+
key: 'getBar',
|
|
100
|
+
value: function getBar(index) {
|
|
101
|
+
return _constants.BARS[index] ? _constants.BARS[index].toString() : '';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Correct an index by a set and shift it from the bytes array
|
|
105
|
+
|
|
106
|
+
}, {
|
|
107
|
+
key: 'correctIndex',
|
|
108
|
+
value: function correctIndex(bytes, set) {
|
|
109
|
+
if (set === _constants.SET_A) {
|
|
110
|
+
var charCode = bytes.shift();
|
|
111
|
+
return charCode < 32 ? charCode + 64 : charCode - 32;
|
|
112
|
+
} else if (set === _constants.SET_B) {
|
|
113
|
+
return bytes.shift() - 32;
|
|
114
|
+
} else {
|
|
115
|
+
return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: 'next',
|
|
120
|
+
value: function next(bytes, pos, set) {
|
|
121
|
+
if (!bytes.length) {
|
|
122
|
+
return { result: '', checksum: 0 };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
var nextCode = void 0,
|
|
126
|
+
index = void 0;
|
|
127
|
+
|
|
128
|
+
// Special characters
|
|
129
|
+
if (bytes[0] >= 200) {
|
|
130
|
+
index = bytes.shift() - 105;
|
|
131
|
+
var nextSet = _constants.SWAP[index];
|
|
132
|
+
|
|
133
|
+
// Swap to other set
|
|
134
|
+
if (nextSet !== undefined) {
|
|
135
|
+
nextCode = CODE128.next(bytes, pos + 1, nextSet);
|
|
136
|
+
}
|
|
137
|
+
// Continue on current set but encode a special character
|
|
138
|
+
else {
|
|
139
|
+
// Shift
|
|
140
|
+
if ((set === _constants.SET_A || set === _constants.SET_B) && index === _constants.SHIFT) {
|
|
141
|
+
// Convert the next character so that is encoded correctly
|
|
142
|
+
bytes[0] = set === _constants.SET_A ? bytes[0] > 95 ? bytes[0] - 96 : bytes[0] : bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
|
|
143
|
+
}
|
|
144
|
+
nextCode = CODE128.next(bytes, pos + 1, set);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Continue encoding
|
|
148
|
+
else {
|
|
149
|
+
index = CODE128.correctIndex(bytes, set);
|
|
150
|
+
nextCode = CODE128.next(bytes, pos + 1, set);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Get the correct binary encoding and calculate the weight
|
|
154
|
+
var enc = CODE128.getBar(index);
|
|
155
|
+
var weight = index * pos;
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
result: enc + nextCode.result,
|
|
159
|
+
checksum: weight + nextCode.checksum
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}]);
|
|
163
|
+
|
|
164
|
+
return CODE128;
|
|
165
|
+
}(_Barcode3.default);
|
|
166
|
+
|
|
167
|
+
exports.default = CODE128;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 _CODE2 = require('./CODE128.js');
|
|
10
|
+
|
|
11
|
+
var _CODE3 = _interopRequireDefault(_CODE2);
|
|
12
|
+
|
|
13
|
+
var _constants = require('./constants');
|
|
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; }
|
|
22
|
+
|
|
23
|
+
var CODE128A = function (_CODE) {
|
|
24
|
+
_inherits(CODE128A, _CODE);
|
|
25
|
+
|
|
26
|
+
function CODE128A(string, options) {
|
|
27
|
+
_classCallCheck(this, CODE128A);
|
|
28
|
+
|
|
29
|
+
return _possibleConstructorReturn(this, (CODE128A.__proto__ || Object.getPrototypeOf(CODE128A)).call(this, _constants.A_START_CHAR + string, options));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_createClass(CODE128A, [{
|
|
33
|
+
key: 'valid',
|
|
34
|
+
value: function valid() {
|
|
35
|
+
return new RegExp('^' + _constants.A_CHARS + '+$').test(this.data);
|
|
36
|
+
}
|
|
37
|
+
}]);
|
|
38
|
+
|
|
39
|
+
return CODE128A;
|
|
40
|
+
}(_CODE3.default);
|
|
41
|
+
|
|
42
|
+
exports.default = CODE128A;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 _CODE2 = require('./CODE128.js');
|
|
10
|
+
|
|
11
|
+
var _CODE3 = _interopRequireDefault(_CODE2);
|
|
12
|
+
|
|
13
|
+
var _constants = require('./constants');
|
|
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; }
|
|
22
|
+
|
|
23
|
+
var CODE128B = function (_CODE) {
|
|
24
|
+
_inherits(CODE128B, _CODE);
|
|
25
|
+
|
|
26
|
+
function CODE128B(string, options) {
|
|
27
|
+
_classCallCheck(this, CODE128B);
|
|
28
|
+
|
|
29
|
+
return _possibleConstructorReturn(this, (CODE128B.__proto__ || Object.getPrototypeOf(CODE128B)).call(this, _constants.B_START_CHAR + string, options));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_createClass(CODE128B, [{
|
|
33
|
+
key: 'valid',
|
|
34
|
+
value: function valid() {
|
|
35
|
+
return new RegExp('^' + _constants.B_CHARS + '+$').test(this.data);
|
|
36
|
+
}
|
|
37
|
+
}]);
|
|
38
|
+
|
|
39
|
+
return CODE128B;
|
|
40
|
+
}(_CODE3.default);
|
|
41
|
+
|
|
42
|
+
exports.default = CODE128B;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 _CODE2 = require('./CODE128.js');
|
|
10
|
+
|
|
11
|
+
var _CODE3 = _interopRequireDefault(_CODE2);
|
|
12
|
+
|
|
13
|
+
var _constants = require('./constants');
|
|
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; }
|
|
22
|
+
|
|
23
|
+
var CODE128C = function (_CODE) {
|
|
24
|
+
_inherits(CODE128C, _CODE);
|
|
25
|
+
|
|
26
|
+
function CODE128C(string, options) {
|
|
27
|
+
_classCallCheck(this, CODE128C);
|
|
28
|
+
|
|
29
|
+
return _possibleConstructorReturn(this, (CODE128C.__proto__ || Object.getPrototypeOf(CODE128C)).call(this, _constants.C_START_CHAR + string, options));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_createClass(CODE128C, [{
|
|
33
|
+
key: 'valid',
|
|
34
|
+
value: function valid() {
|
|
35
|
+
return new RegExp('^' + _constants.C_CHARS + '+$').test(this.data);
|
|
36
|
+
}
|
|
37
|
+
}]);
|
|
38
|
+
|
|
39
|
+
return CODE128C;
|
|
40
|
+
}(_CODE3.default);
|
|
41
|
+
|
|
42
|
+
exports.default = CODE128C;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _CODE2 = require('./CODE128');
|
|
8
|
+
|
|
9
|
+
var _CODE3 = _interopRequireDefault(_CODE2);
|
|
10
|
+
|
|
11
|
+
var _auto = require('./auto');
|
|
12
|
+
|
|
13
|
+
var _auto2 = _interopRequireDefault(_auto);
|
|
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; }
|
|
22
|
+
|
|
23
|
+
var CODE128AUTO = function (_CODE) {
|
|
24
|
+
_inherits(CODE128AUTO, _CODE);
|
|
25
|
+
|
|
26
|
+
function CODE128AUTO(data, options) {
|
|
27
|
+
_classCallCheck(this, CODE128AUTO);
|
|
28
|
+
|
|
29
|
+
// ASCII value ranges 0-127, 200-211
|
|
30
|
+
if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) {
|
|
31
|
+
var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, (0, _auto2.default)(data), options));
|
|
32
|
+
} else {
|
|
33
|
+
var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, data, options));
|
|
34
|
+
}
|
|
35
|
+
return _possibleConstructorReturn(_this);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return CODE128AUTO;
|
|
39
|
+
}(_CODE3.default);
|
|
40
|
+
|
|
41
|
+
exports.default = CODE128AUTO;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _constants = require('./constants');
|
|
8
|
+
|
|
9
|
+
// Match Set functions
|
|
10
|
+
var matchSetALength = function matchSetALength(string) {
|
|
11
|
+
return string.match(new RegExp('^' + _constants.A_CHARS + '*'))[0].length;
|
|
12
|
+
};
|
|
13
|
+
var matchSetBLength = function matchSetBLength(string) {
|
|
14
|
+
return string.match(new RegExp('^' + _constants.B_CHARS + '*'))[0].length;
|
|
15
|
+
};
|
|
16
|
+
var matchSetC = function matchSetC(string) {
|
|
17
|
+
return string.match(new RegExp('^' + _constants.C_CHARS + '*'))[0];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// CODE128A or CODE128B
|
|
21
|
+
function autoSelectFromAB(string, isA) {
|
|
22
|
+
var ranges = isA ? _constants.A_CHARS : _constants.B_CHARS;
|
|
23
|
+
var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
|
|
24
|
+
|
|
25
|
+
if (untilC) {
|
|
26
|
+
return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var chars = string.match(new RegExp('^' + ranges + '+'))[0];
|
|
30
|
+
|
|
31
|
+
if (chars.length === string.length) {
|
|
32
|
+
return string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// CODE128C
|
|
39
|
+
function autoSelectFromC(string) {
|
|
40
|
+
var cMatch = matchSetC(string);
|
|
41
|
+
var length = cMatch.length;
|
|
42
|
+
|
|
43
|
+
if (length === string.length) {
|
|
44
|
+
return string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
string = string.substring(length);
|
|
48
|
+
|
|
49
|
+
// Select A/B depending on the longest match
|
|
50
|
+
var isA = matchSetALength(string) >= matchSetBLength(string);
|
|
51
|
+
return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Detect Code Set (A, B or C) and format the string
|
|
55
|
+
|
|
56
|
+
exports.default = function (string) {
|
|
57
|
+
var newString = void 0;
|
|
58
|
+
var cLength = matchSetC(string).length;
|
|
59
|
+
|
|
60
|
+
// Select 128C if the string start with enough digits
|
|
61
|
+
if (cLength >= 2) {
|
|
62
|
+
newString = _constants.C_START_CHAR + autoSelectFromC(string);
|
|
63
|
+
} else {
|
|
64
|
+
// Select A/B depending on the longest match
|
|
65
|
+
var isA = matchSetALength(string) > matchSetBLength(string);
|
|
66
|
+
newString = (isA ? _constants.A_START_CHAR : _constants.B_START_CHAR) + autoSelectFromAB(string, isA);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
|
|
70
|
+
function (match, char) {
|
|
71
|
+
return String.fromCharCode(203) + char;
|
|
72
|
+
});
|
|
73
|
+
};
|