@progress/kendo-charts 1.20.0 → 1.21.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.
- package/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/barcode/barcode.js +13 -5
- package/dist/es/barcode/encodings/code39.js +3 -3
- package/dist/es/barcode/encodings/code93.js +4 -3
- package/dist/es/barcode/encodings/encoding.js +1 -1
- package/dist/es/barcode/encodings/postnet.js +1 -1
- package/dist/es/common/default-error-handler.js +3 -0
- package/dist/es/common/get-template.js +2 -2
- package/dist/es/common.js +1 -0
- package/dist/es/qrcode/encodings/data-modes/byte-data-mode.js +1 -1
- package/dist/es/qrcode/qrcode.js +30 -22
- package/dist/es2015/barcode/barcode.js +11 -5
- package/dist/es2015/barcode/encodings/code39.js +3 -3
- package/dist/es2015/barcode/encodings/code93.js +4 -3
- package/dist/es2015/barcode/encodings/encoding.js +1 -1
- package/dist/es2015/barcode/encodings/postnet.js +1 -1
- package/dist/es2015/common/default-error-handler.js +3 -0
- package/dist/es2015/common/get-template.js +2 -2
- package/dist/es2015/common.js +1 -0
- package/dist/es2015/qrcode/encodings/data-modes/byte-data-mode.js +1 -1
- package/dist/es2015/qrcode/qrcode.js +28 -22
- package/dist/npm/barcode.d.ts +2 -6
- package/dist/npm/main.js +186 -166
- package/dist/npm/qrcode.d.ts +1 -1
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +2 -2
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
setDefaultOptions,
|
|
11
11
|
deepExtend,
|
|
12
12
|
getSpacing,
|
|
13
|
-
isObject
|
|
13
|
+
isObject,
|
|
14
|
+
defaultErrorHandler
|
|
14
15
|
} from '../common';
|
|
15
16
|
|
|
16
17
|
import {
|
|
@@ -24,11 +25,14 @@ var DEFAULT_BARCODE_WIDTH = 300;
|
|
|
24
25
|
var DEFAULT_BARCODE_HEIGHT = 100;
|
|
25
26
|
|
|
26
27
|
var Barcode = (function (Class) {
|
|
27
|
-
function Barcode(element, options) {
|
|
28
|
+
function Barcode(element, options, errorHandler) {
|
|
29
|
+
if ( errorHandler === void 0 ) errorHandler = defaultErrorHandler;
|
|
30
|
+
|
|
28
31
|
Class.call(this);
|
|
29
32
|
|
|
30
33
|
this.options = deepExtend({}, this.options, options);
|
|
31
34
|
this.element = element;
|
|
35
|
+
this.onError = errorHandler;
|
|
32
36
|
|
|
33
37
|
this._initElement();
|
|
34
38
|
this._initSurface();
|
|
@@ -49,7 +53,6 @@ var Barcode = (function (Class) {
|
|
|
49
53
|
|
|
50
54
|
Barcode.prototype._initElement = function _initElement () {
|
|
51
55
|
addClass(this.element, "k-barcode");
|
|
52
|
-
this.element.style.display = "block";
|
|
53
56
|
};
|
|
54
57
|
|
|
55
58
|
Barcode.prototype._initSurface = function _initSurface () {
|
|
@@ -151,7 +154,12 @@ var Barcode = (function (Class) {
|
|
|
151
154
|
barHeight -= textHeight + textMargin.top + textMargin.bottom;
|
|
152
155
|
}
|
|
153
156
|
|
|
154
|
-
|
|
157
|
+
try {
|
|
158
|
+
encodedValue = encoding.encode(value, contentBox.width(), barHeight);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
this.onError(error);
|
|
161
|
+
return visual;
|
|
162
|
+
}
|
|
155
163
|
|
|
156
164
|
if (textOptions.visible) {
|
|
157
165
|
textToDisplay = value;
|
|
@@ -296,7 +304,7 @@ var Barcode = (function (Class) {
|
|
|
296
304
|
}
|
|
297
305
|
|
|
298
306
|
if (!Encodings[this.type]) {
|
|
299
|
-
throw new Error("Encoding " + this.type + " is not supported.");
|
|
307
|
+
throw new Error(("Encoding '" + (this.type) + "' is not supported."));
|
|
300
308
|
}
|
|
301
309
|
|
|
302
310
|
this.encoding = new Encodings[this.type]();
|
|
@@ -142,12 +142,12 @@ export var Code39 = (function (Code39Base) {
|
|
|
142
142
|
|
|
143
143
|
var minBaseUnit = this.minBaseUnitLength;
|
|
144
144
|
var minRatio = this.minRatio;
|
|
145
|
-
var minHeight = Math.max(0.15 * this.width, 24);
|
|
145
|
+
var minHeight = Math.ceil(Math.max(0.15 * this.width, 24));
|
|
146
146
|
var baseUnit;
|
|
147
147
|
var ratio = this.maxRatio;
|
|
148
148
|
|
|
149
149
|
if (this.height < minHeight) {
|
|
150
|
-
throw new Error("Insufficient
|
|
150
|
+
throw new Error(("Insufficient height for Code39 encoding: the current height is " + (this.height) + "px and the minimum height is " + minHeight + "px."));
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
baseUnit = this.getBaseUnit(ratio);
|
|
@@ -159,7 +159,7 @@ export var Code39 = (function (Code39Base) {
|
|
|
159
159
|
|
|
160
160
|
if (baseUnit < minBaseUnit) {
|
|
161
161
|
var minWidth = Math.ceil(this.getBaseWidth(minRatio) * minBaseUnit);
|
|
162
|
-
throw new Error("Insufficient width.
|
|
162
|
+
throw new Error(("Insufficient width for Code39 encoding: the current width is " + (this.width) + "px and the minimum width for value \"" + (this.value) + "\" is " + minWidth + "px."));
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
this.ratio = ratio;
|
|
@@ -83,16 +83,17 @@ export var Code93 = (function (Code39Base) {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
Code93.prototype.prepareValues = function prepareValues () {
|
|
86
|
-
var minHeight = Math.max(0.15 * this.width, 24);
|
|
86
|
+
var minHeight = Math.ceil(Math.max(0.15 * this.width, 24));
|
|
87
87
|
|
|
88
88
|
if (this.height < minHeight) {
|
|
89
|
-
throw new Error("Insufficient
|
|
89
|
+
throw new Error(("Insufficient height for Code93 encoding: the current height is " + (this.height) + "px, the minimum required height is " + minHeight + "px."));
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
this.setBaseUnit();
|
|
93
93
|
|
|
94
94
|
if (this.baseUnit < this.minBaseUnitLength) {
|
|
95
|
-
|
|
95
|
+
var minWidth = Math.ceil(this.minBaseUnitLength * (this.width / this.baseUnit));
|
|
96
|
+
throw new Error(("Insufficient width for Code93 encoding: the current width is " + (this.width) + "px and the minimum required width for value \"" + (this.value) + "\" is " + minWidth + "px."));
|
|
96
97
|
}
|
|
97
98
|
};
|
|
98
99
|
|
|
@@ -54,7 +54,7 @@ export var Encoding = (function (Class) {
|
|
|
54
54
|
Encoding.prototype.addData = function addData () { };
|
|
55
55
|
|
|
56
56
|
Encoding.prototype.invalidCharacterError = function invalidCharacterError (character) {
|
|
57
|
-
throw new Error("Character
|
|
57
|
+
throw new Error(("Character \"" + character + "\" is not valid for symbology " + (this.name) + "."));
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
return Encoding;
|
|
@@ -78,7 +78,7 @@ export var Postnet = (function (Encoding) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
if (!inArray(value.length, this.VALID_CODE_LENGTHS)) {
|
|
81
|
-
throw new Error("Invalid value length. Valid lengths for the Postnet symbology are " + this.VALID_CODE_LENGTHS.join(","));
|
|
81
|
+
throw new Error("Invalid value length. Valid lengths for the Postnet symbology are " + this.VALID_CODE_LENGTHS.join(",") + ".");
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TemplateService from '../services/template-service';
|
|
2
2
|
import isFunction from './is-function';
|
|
3
3
|
|
|
4
4
|
export default function getTemplate(options) {
|
|
@@ -12,4 +12,4 @@ export default function getTemplate(options) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
return template;
|
|
15
|
-
}
|
|
15
|
+
}
|
package/dist/es/common.js
CHANGED
|
@@ -29,5 +29,6 @@ export { default as find } from './common/find';
|
|
|
29
29
|
export { default as elementScale } from './common/element-scale';
|
|
30
30
|
export { default as autoTextColor } from './common/auto-text-color';
|
|
31
31
|
export { default as createHashSet } from './common/create-hash-set';
|
|
32
|
+
export { default as defaultErrorHandler } from './common/default-error-handler';
|
|
32
33
|
|
|
33
34
|
export * from './drawing-utils';
|
|
@@ -29,7 +29,7 @@ export var ByteQRDataMode = (function (QRDataMode) {
|
|
|
29
29
|
return code;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
throw new Error("Unsupported character: " + character);
|
|
32
|
+
throw new Error(("Unsupported character in QR Code: \"" + character + "\"."));
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
ByteQRDataMode.prototype.encode = function encode (str, version) {
|
package/dist/es/qrcode/qrcode.js
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
Class,
|
|
8
8
|
addClass,
|
|
9
9
|
setDefaultOptions,
|
|
10
|
-
deepExtend
|
|
10
|
+
deepExtend,
|
|
11
|
+
defaultErrorHandler
|
|
11
12
|
} from '../common';
|
|
12
13
|
|
|
13
14
|
import { Box } from '../core';
|
|
@@ -29,12 +30,15 @@ var QRCodeDefaults = {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
var QRCode = (function (Class) {
|
|
32
|
-
function QRCode(element, options) {
|
|
33
|
+
function QRCode(element, options, errorHandler) {
|
|
34
|
+
if ( errorHandler === void 0 ) errorHandler = defaultErrorHandler;
|
|
35
|
+
|
|
33
36
|
Class.call(this);
|
|
34
37
|
|
|
35
38
|
this.options = deepExtend({}, this.options, options);
|
|
36
39
|
this.element = element;
|
|
37
40
|
this.wrapper = this.element;
|
|
41
|
+
this.onError = errorHandler;
|
|
38
42
|
|
|
39
43
|
this._initElement();
|
|
40
44
|
this._initSurface();
|
|
@@ -52,7 +56,6 @@ var QRCode = (function (Class) {
|
|
|
52
56
|
|
|
53
57
|
QRCode.prototype._initElement = function _initElement () {
|
|
54
58
|
addClass(this.element, "k-qrcode");
|
|
55
|
-
this.element.style.display = "block";
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
QRCode.prototype._initSurface = function _initSurface () {
|
|
@@ -156,22 +159,26 @@ var QRCode = (function (Class) {
|
|
|
156
159
|
|
|
157
160
|
var visual = new draw.Group();
|
|
158
161
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
162
|
+
try {
|
|
163
|
+
if (value) {
|
|
164
|
+
matrix = encodeData(value, this.options.errorCorrection, this.options.encoding);
|
|
165
|
+
size = this._getSize();
|
|
166
|
+
contentSize = size - 2 * (borderWidth + padding);
|
|
167
|
+
baseUnit = this._calculateBaseUnit(contentSize, matrix.length);
|
|
168
|
+
dataSize = matrix.length * baseUnit;
|
|
169
|
+
quietZoneSize = borderWidth + padding + (contentSize - dataSize) / 2;
|
|
170
|
+
|
|
171
|
+
visual.append(this._renderBackground(size, border));
|
|
172
|
+
visual.append(this._renderMatrix(matrix, baseUnit, quietZoneSize));
|
|
173
|
+
|
|
174
|
+
if (this._hasCustomLogo()) {
|
|
175
|
+
visual.append(this._renderLogo(size, baseUnit));
|
|
176
|
+
} else if (this._isSwiss()) {
|
|
177
|
+
visual.append(this._renderSwissCode(size, baseUnit));
|
|
178
|
+
}
|
|
174
179
|
}
|
|
180
|
+
} catch (error) {
|
|
181
|
+
this.onError(error);
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
return visual;
|
|
@@ -262,10 +269,11 @@ var QRCode = (function (Class) {
|
|
|
262
269
|
var baseUnit = Math.floor(size / matrixSize);
|
|
263
270
|
|
|
264
271
|
if (baseUnit < QRCodeDefaults.MIN_BASE_UNIT_SIZE) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
272
|
+
var minSize = Math.ceil(matrixSize * QRCodeDefaults.MIN_BASE_UNIT_SIZE);
|
|
273
|
+
this.onError(new Error(
|
|
274
|
+
("Insufficient size for QR Code: the current size is " + size + "px and the minimum size is " + minSize + "px.")
|
|
275
|
+
));
|
|
276
|
+
} else if (baseUnit * matrixSize >= size &&
|
|
269
277
|
baseUnit - 1 >= QRCodeDefaults.MIN_BASE_UNIT_SIZE) {
|
|
270
278
|
baseUnit--;
|
|
271
279
|
}
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
setDefaultOptions,
|
|
11
11
|
deepExtend,
|
|
12
12
|
getSpacing,
|
|
13
|
-
isObject
|
|
13
|
+
isObject,
|
|
14
|
+
defaultErrorHandler
|
|
14
15
|
} from '../common';
|
|
15
16
|
|
|
16
17
|
import {
|
|
@@ -24,11 +25,12 @@ const DEFAULT_BARCODE_WIDTH = 300;
|
|
|
24
25
|
const DEFAULT_BARCODE_HEIGHT = 100;
|
|
25
26
|
|
|
26
27
|
class Barcode extends Class {
|
|
27
|
-
constructor(element, options) {
|
|
28
|
+
constructor(element, options, errorHandler = defaultErrorHandler) {
|
|
28
29
|
super();
|
|
29
30
|
|
|
30
31
|
this.options = deepExtend({}, this.options, options);
|
|
31
32
|
this.element = element;
|
|
33
|
+
this.onError = errorHandler;
|
|
32
34
|
|
|
33
35
|
this._initElement();
|
|
34
36
|
this._initSurface();
|
|
@@ -45,7 +47,6 @@ class Barcode extends Class {
|
|
|
45
47
|
|
|
46
48
|
_initElement() {
|
|
47
49
|
addClass(this.element, "k-barcode");
|
|
48
|
-
this.element.style.display = "block";
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
_initSurface() {
|
|
@@ -145,7 +146,12 @@ class Barcode extends Class {
|
|
|
145
146
|
barHeight -= textHeight + textMargin.top + textMargin.bottom;
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
try {
|
|
150
|
+
encodedValue = encoding.encode(value, contentBox.width(), barHeight);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
this.onError(error);
|
|
153
|
+
return visual;
|
|
154
|
+
}
|
|
149
155
|
|
|
150
156
|
if (textOptions.visible) {
|
|
151
157
|
textToDisplay = value;
|
|
@@ -288,7 +294,7 @@ class Barcode extends Class {
|
|
|
288
294
|
}
|
|
289
295
|
|
|
290
296
|
if (!Encodings[this.type]) {
|
|
291
|
-
throw new Error(
|
|
297
|
+
throw new Error(`Encoding '${this.type}' is not supported.`);
|
|
292
298
|
}
|
|
293
299
|
|
|
294
300
|
this.encoding = new Encodings[this.type]();
|
|
@@ -120,12 +120,12 @@ export class Code39 extends Code39Base {
|
|
|
120
120
|
prepareValues() {
|
|
121
121
|
const minBaseUnit = this.minBaseUnitLength;
|
|
122
122
|
const minRatio = this.minRatio;
|
|
123
|
-
const minHeight = Math.max(0.15 * this.width, 24);
|
|
123
|
+
const minHeight = Math.ceil(Math.max(0.15 * this.width, 24));
|
|
124
124
|
let baseUnit;
|
|
125
125
|
let ratio = this.maxRatio;
|
|
126
126
|
|
|
127
127
|
if (this.height < minHeight) {
|
|
128
|
-
throw new Error(
|
|
128
|
+
throw new Error(`Insufficient height for Code39 encoding: the current height is ${this.height}px and the minimum height is ${minHeight}px.`);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
baseUnit = this.getBaseUnit(ratio);
|
|
@@ -137,7 +137,7 @@ export class Code39 extends Code39Base {
|
|
|
137
137
|
|
|
138
138
|
if (baseUnit < minBaseUnit) {
|
|
139
139
|
let minWidth = Math.ceil(this.getBaseWidth(minRatio) * minBaseUnit);
|
|
140
|
-
throw new Error(
|
|
140
|
+
throw new Error(`Insufficient width for Code39 encoding: the current width is ${this.width}px and the minimum width for value "${this.value}" is ${minWidth}px.`);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
this.ratio = ratio;
|
|
@@ -75,16 +75,17 @@ export class Code93 extends Code39Base {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
prepareValues() {
|
|
78
|
-
let minHeight = Math.max(0.15 * this.width, 24);
|
|
78
|
+
let minHeight = Math.ceil(Math.max(0.15 * this.width, 24));
|
|
79
79
|
|
|
80
80
|
if (this.height < minHeight) {
|
|
81
|
-
throw new Error(
|
|
81
|
+
throw new Error(`Insufficient height for Code93 encoding: the current height is ${this.height}px, the minimum required height is ${minHeight}px.`);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
this.setBaseUnit();
|
|
85
85
|
|
|
86
86
|
if (this.baseUnit < this.minBaseUnitLength) {
|
|
87
|
-
|
|
87
|
+
const minWidth = Math.ceil(this.minBaseUnitLength * (this.width / this.baseUnit));
|
|
88
|
+
throw new Error(`Insufficient width for Code93 encoding: the current width is ${this.width}px and the minimum required width for value "${this.value}" is ${minWidth}px.`);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
@@ -50,7 +50,7 @@ export class Encoding extends Class {
|
|
|
50
50
|
addData() { }
|
|
51
51
|
|
|
52
52
|
invalidCharacterError(character) {
|
|
53
|
-
throw new Error(
|
|
53
|
+
throw new Error(`Character "${character}" is not valid for symbology ${this.name}.`);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -68,7 +68,7 @@ export class Postnet extends Encoding {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (!inArray(value.length, this.VALID_CODE_LENGTHS)) {
|
|
71
|
-
throw new Error("Invalid value length. Valid lengths for the Postnet symbology are " + this.VALID_CODE_LENGTHS.join(","));
|
|
71
|
+
throw new Error("Invalid value length. Valid lengths for the Postnet symbology are " + this.VALID_CODE_LENGTHS.join(",") + ".");
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TemplateService from '../services/template-service';
|
|
2
2
|
import isFunction from './is-function';
|
|
3
3
|
|
|
4
4
|
export default function getTemplate(options = {}) {
|
|
@@ -10,4 +10,4 @@ export default function getTemplate(options = {}) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
return template;
|
|
13
|
-
}
|
|
13
|
+
}
|
package/dist/es2015/common.js
CHANGED
|
@@ -29,5 +29,6 @@ export { default as find } from './common/find';
|
|
|
29
29
|
export { default as elementScale } from './common/element-scale';
|
|
30
30
|
export { default as autoTextColor } from './common/auto-text-color';
|
|
31
31
|
export { default as createHashSet } from './common/create-hash-set';
|
|
32
|
+
export { default as defaultErrorHandler } from './common/default-error-handler';
|
|
32
33
|
|
|
33
34
|
export * from './drawing-utils';
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
Class,
|
|
8
8
|
addClass,
|
|
9
9
|
setDefaultOptions,
|
|
10
|
-
deepExtend
|
|
10
|
+
deepExtend,
|
|
11
|
+
defaultErrorHandler
|
|
11
12
|
} from '../common';
|
|
12
13
|
|
|
13
14
|
import { Box } from '../core';
|
|
@@ -29,12 +30,13 @@ const QRCodeDefaults = {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
class QRCode extends Class {
|
|
32
|
-
constructor(element, options) {
|
|
33
|
+
constructor(element, options, errorHandler = defaultErrorHandler) {
|
|
33
34
|
super();
|
|
34
35
|
|
|
35
36
|
this.options = deepExtend({}, this.options, options);
|
|
36
37
|
this.element = element;
|
|
37
38
|
this.wrapper = this.element;
|
|
39
|
+
this.onError = errorHandler;
|
|
38
40
|
|
|
39
41
|
this._initElement();
|
|
40
42
|
this._initSurface();
|
|
@@ -48,7 +50,6 @@ class QRCode extends Class {
|
|
|
48
50
|
|
|
49
51
|
_initElement() {
|
|
50
52
|
addClass(this.element, "k-qrcode");
|
|
51
|
-
this.element.style.display = "block";
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
_initSurface() {
|
|
@@ -150,22 +151,26 @@ class QRCode extends Class {
|
|
|
150
151
|
|
|
151
152
|
let visual = new draw.Group();
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
154
|
+
try {
|
|
155
|
+
if (value) {
|
|
156
|
+
matrix = encodeData(value, this.options.errorCorrection, this.options.encoding);
|
|
157
|
+
size = this._getSize();
|
|
158
|
+
contentSize = size - 2 * (borderWidth + padding);
|
|
159
|
+
baseUnit = this._calculateBaseUnit(contentSize, matrix.length);
|
|
160
|
+
dataSize = matrix.length * baseUnit;
|
|
161
|
+
quietZoneSize = borderWidth + padding + (contentSize - dataSize) / 2;
|
|
162
|
+
|
|
163
|
+
visual.append(this._renderBackground(size, border));
|
|
164
|
+
visual.append(this._renderMatrix(matrix, baseUnit, quietZoneSize));
|
|
165
|
+
|
|
166
|
+
if (this._hasCustomLogo()) {
|
|
167
|
+
visual.append(this._renderLogo(size, baseUnit));
|
|
168
|
+
} else if (this._isSwiss()) {
|
|
169
|
+
visual.append(this._renderSwissCode(size, baseUnit));
|
|
170
|
+
}
|
|
168
171
|
}
|
|
172
|
+
} catch (error) {
|
|
173
|
+
this.onError(error);
|
|
169
174
|
}
|
|
170
175
|
|
|
171
176
|
return visual;
|
|
@@ -256,10 +261,11 @@ class QRCode extends Class {
|
|
|
256
261
|
let baseUnit = Math.floor(size / matrixSize);
|
|
257
262
|
|
|
258
263
|
if (baseUnit < QRCodeDefaults.MIN_BASE_UNIT_SIZE) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
264
|
+
const minSize = Math.ceil(matrixSize * QRCodeDefaults.MIN_BASE_UNIT_SIZE);
|
|
265
|
+
this.onError(new Error(
|
|
266
|
+
`Insufficient size for QR Code: the current size is ${size}px and the minimum size is ${minSize}px.`
|
|
267
|
+
));
|
|
268
|
+
} else if (baseUnit * matrixSize >= size &&
|
|
263
269
|
baseUnit - 1 >= QRCodeDefaults.MIN_BASE_UNIT_SIZE) {
|
|
264
270
|
baseUnit--;
|
|
265
271
|
}
|
package/dist/npm/barcode.d.ts
CHANGED
|
@@ -79,8 +79,6 @@ export interface BarcodeOptions {
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* The height of the Barcode in pixels.
|
|
82
|
-
*
|
|
83
|
-
* @default 100
|
|
84
82
|
*/
|
|
85
83
|
height?: number;
|
|
86
84
|
|
|
@@ -98,7 +96,7 @@ export interface BarcodeOptions {
|
|
|
98
96
|
* * "canvas" - renders the component as a Canvas element.
|
|
99
97
|
* * "svg" - renders the component as an inline SVG document.
|
|
100
98
|
*
|
|
101
|
-
|
|
99
|
+
* @default "svg"
|
|
102
100
|
*/
|
|
103
101
|
renderAs?: RenderMode;
|
|
104
102
|
|
|
@@ -121,14 +119,12 @@ export interface BarcodeOptions {
|
|
|
121
119
|
|
|
122
120
|
/**
|
|
123
121
|
* The width of the Barcode in pixels.
|
|
124
|
-
*
|
|
125
|
-
* @default 300
|
|
126
122
|
*/
|
|
127
123
|
width?: number;
|
|
128
124
|
}
|
|
129
125
|
|
|
130
126
|
export class Barcode {
|
|
131
|
-
constructor(element: Element, options: BarcodeOptions);
|
|
127
|
+
constructor(element: Element, options: BarcodeOptions, errorHandler?: (error: Error) => void);
|
|
132
128
|
|
|
133
129
|
public redraw(): void;
|
|
134
130
|
public setOptions(options: BarcodeOptions): void;
|