@progress/kendo-charts 1.19.0 → 1.20.0-dev.202111081615

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 (63) hide show
  1. package/dist/cdn/js/kendo-charts.js +1 -1
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/chart/chart.js +13 -5
  4. package/dist/es/chart/constants.js +3 -1
  5. package/dist/es/chart/pan-and-zoom/mousewheel-zoom.js +8 -4
  6. package/dist/es/chart/selection.js +41 -1
  7. package/dist/es/common/create-hash-set.js +11 -1
  8. package/dist/es/common/mousewheel-delta.js +4 -7
  9. package/dist/es/core/axis.js +35 -0
  10. package/dist/es/core/category-axis.js +23 -17
  11. package/dist/es/core/date-category-axis.js +26 -38
  12. package/dist/es/core/date-value-axis.js +32 -33
  13. package/dist/es/core/logarithmic-axis.js +30 -27
  14. package/dist/es/core/numeric-axis.js +24 -20
  15. package/dist/es/main.js +1 -0
  16. package/dist/es/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +103 -0
  17. package/dist/es/qrcode/encodings/data-modes/byte-data-mode.js +51 -0
  18. package/dist/es/qrcode/encodings/data-modes/data-mode-instances.js +12 -0
  19. package/dist/es/qrcode/encodings/data-modes/numeric-data-mode.js +49 -0
  20. package/dist/es/qrcode/encodings/data-modes/qr-data-mode.js +50 -0
  21. package/dist/es/qrcode/encodings/encoders/iso-encoder.js +29 -0
  22. package/dist/es/qrcode/encodings/encoders/utf8-encoder.js +91 -0
  23. package/dist/es/qrcode/encodings/encoding-result.js +16 -0
  24. package/dist/es/qrcode/encodings/encoding.js +701 -0
  25. package/dist/es/qrcode/encodings/free-cell-visitor.js +57 -0
  26. package/dist/es/qrcode/encodings/version-codewords.js +1289 -0
  27. package/dist/es/qrcode/qrcode.js +403 -0
  28. package/dist/es/qrcode/utils.js +28 -0
  29. package/dist/es/qrcode.js +1 -0
  30. package/dist/es/stock/navigator.js +3 -2
  31. package/dist/es2015/chart/chart.js +13 -5
  32. package/dist/es2015/chart/constants.js +3 -1
  33. package/dist/es2015/chart/pan-and-zoom/mousewheel-zoom.js +6 -4
  34. package/dist/es2015/chart/selection.js +40 -1
  35. package/dist/es2015/common/create-hash-set.js +11 -1
  36. package/dist/es2015/common/mousewheel-delta.js +4 -7
  37. package/dist/es2015/core/axis.js +28 -0
  38. package/dist/es2015/core/category-axis.js +21 -15
  39. package/dist/es2015/core/date-category-axis.js +27 -36
  40. package/dist/es2015/core/date-value-axis.js +33 -33
  41. package/dist/es2015/core/logarithmic-axis.js +29 -26
  42. package/dist/es2015/core/numeric-axis.js +24 -20
  43. package/dist/es2015/main.js +1 -0
  44. package/dist/es2015/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +91 -0
  45. package/dist/es2015/qrcode/encodings/data-modes/byte-data-mode.js +41 -0
  46. package/dist/es2015/qrcode/encodings/data-modes/data-mode-instances.js +13 -0
  47. package/dist/es2015/qrcode/encodings/data-modes/numeric-data-mode.js +39 -0
  48. package/dist/es2015/qrcode/encodings/data-modes/qr-data-mode.js +44 -0
  49. package/dist/es2015/qrcode/encodings/encoders/iso-encoder.js +19 -0
  50. package/dist/es2015/qrcode/encodings/encoders/utf8-encoder.js +83 -0
  51. package/dist/es2015/qrcode/encodings/encoding-result.js +10 -0
  52. package/dist/es2015/qrcode/encodings/encoding.js +701 -0
  53. package/dist/es2015/qrcode/encodings/free-cell-visitor.js +49 -0
  54. package/dist/es2015/qrcode/encodings/version-codewords.js +1289 -0
  55. package/dist/es2015/qrcode/qrcode.js +395 -0
  56. package/dist/es2015/qrcode/utils.js +28 -0
  57. package/dist/es2015/qrcode.js +1 -0
  58. package/dist/es2015/stock/navigator.js +3 -2
  59. package/dist/npm/main.d.ts +1 -0
  60. package/dist/npm/main.js +3058 -149
  61. package/dist/npm/qrcode.d.ts +5 -0
  62. package/dist/systemjs/kendo-charts.js +1 -1
  63. package/package.json +1 -1
@@ -6,6 +6,7 @@ import { defined, isNumber, last, limitValue, round, setDefaultOptions, valueOrD
6
6
  import { dateEquals } from '../date-utils';
7
7
 
8
8
  const MIN_CATEGORY_POINTS_RANGE = 0.01;
9
+ const MIN_CATEGORY_RANGE = 0.1;
9
10
 
10
11
  function indexOf(value, arr) {
11
12
  if (value instanceof Date) {
@@ -375,27 +376,32 @@ class CategoryAxis extends Axis {
375
376
  };
376
377
  }
377
378
 
378
- zoomRange(rate) {
379
+ scaleRange(scale, cursor) {
380
+ const position = Math.abs(this.pointOffset(cursor));
379
381
  const rangeIndices = this.totalRangeIndices();
380
- const { min: totalMin, max: totalMax } = this.totalRange();
381
- const min = limitValue(rangeIndices.min + rate, totalMin, totalMax);
382
- const max = limitValue(rangeIndices.max - rate, totalMin, totalMax);
383
-
384
- if (max - min > 0) {
385
- return {
386
- min: min,
387
- max: max
388
- };
382
+ const delta = (rangeIndices.max - rangeIndices.min) * Math.min(1, scale);
383
+ const minDelta = position * delta;
384
+ const maxDelta = (1 - position) * delta;
385
+ const min = rangeIndices.min + minDelta;
386
+ let max = rangeIndices.max - maxDelta;
387
+
388
+ if (max - min < MIN_CATEGORY_RANGE) {
389
+ max = min + MIN_CATEGORY_RANGE;
389
390
  }
391
+
392
+ return {
393
+ min: min,
394
+ max: max
395
+ };
390
396
  }
391
397
 
392
- scaleRange(scale) {
393
- const range = this.options.categories.length;
394
- const delta = scale * range;
398
+ zoomRange(scale, cursor) {
399
+ const { min: totalMin, max: totalMax } = this.totalRange();
400
+ const range = this.scaleRange(scale, cursor);
395
401
 
396
402
  return {
397
- min: -delta,
398
- max: range + delta
403
+ min: limitValue(range.min, totalMin, totalMax),
404
+ max: limitValue(range.max, totalMin, totalMax)
399
405
  };
400
406
  }
401
407
 
@@ -459,30 +459,6 @@ class DateCategoryAxis extends CategoryAxis {
459
459
  return range;
460
460
  }
461
461
 
462
- scaleRange(delta) {
463
- let rounds = Math.abs(delta);
464
- let result = this.range();
465
- let { min: from, max: to } = result;
466
-
467
- if (from && to) {
468
- while (rounds--) {
469
- const range = dateDiff(from, to);
470
- const step = Math.round(range * 0.1);
471
- if (delta < 0) {
472
- from = addTicks(from, step);
473
- to = addTicks(to, -step);
474
- } else {
475
- from = addTicks(from, -step);
476
- to = addTicks(to, step);
477
- }
478
- }
479
-
480
- result = { min: from, max: to };
481
- }
482
-
483
- return result;
484
- }
485
-
486
462
  labelsRange() {
487
463
  return {
488
464
  min: this.options.labels.skip,
@@ -541,18 +517,24 @@ class DateCategoryAxis extends CategoryAxis {
541
517
  };
542
518
  }
543
519
 
544
- zoomRange(delta) {
520
+ scaleRange(scale, cursor) {
545
521
  if (this.isEmpty()) {
546
- return null;
522
+ return {};
547
523
  }
548
524
 
549
525
  const options = this.options;
550
526
  const fit = options.userSetBaseUnit === FIT;
551
527
  const totalLimits = this.dataRange.total();
552
528
  const { min: rangeMin, max: rangeMax } = this.dataRange.displayRange();
553
- let { weekStartDay, baseUnit, baseUnitStep } = this.dataRange.options;
554
- let min = addDuration(rangeMin, delta * baseUnitStep, baseUnit, weekStartDay);
555
- let max = addDuration(rangeMax, -delta * baseUnitStep, baseUnit, weekStartDay);
529
+
530
+ const position = Math.abs(this.pointOffset(cursor));
531
+ const delta = (rangeMax - rangeMin) * scale;
532
+ const minDelta = Math.round(position * delta);
533
+ const maxDelta = Math.round((1 - position) * delta);
534
+
535
+ let { baseUnit } = this.dataRange.options;
536
+ let min = new Date(rangeMin.getTime() + minDelta);
537
+ let max = new Date(rangeMax.getTime() - maxDelta);
556
538
 
557
539
  if (fit) {
558
540
  const { autoBaseUnitSteps, maxDateGroups } = options;
@@ -594,13 +576,6 @@ class DateCategoryAxis extends CategoryAxis {
594
576
  }
595
577
  }
596
578
 
597
- if (min < totalLimits.min) {
598
- min = totalLimits.min;
599
- }
600
- if (max > totalLimits.max) {
601
- max = totalLimits.max;
602
- }
603
-
604
579
  if (min && max && dateDiff(max, min) > 0) {
605
580
  return {
606
581
  min: min,
@@ -611,6 +586,22 @@ class DateCategoryAxis extends CategoryAxis {
611
586
  }
612
587
  }
613
588
 
589
+ zoomRange(scale, cursor) {
590
+ const totalLimits = this.dataRange.total();
591
+ const range = this.scaleRange(scale, cursor);
592
+
593
+ if (range) {
594
+ if (range.min < totalLimits.min) {
595
+ range.min = totalLimits.min;
596
+ }
597
+ if (range.max > totalLimits.max) {
598
+ range.max = totalLimits.max;
599
+ }
600
+ }
601
+
602
+ return range;
603
+ }
604
+
614
605
  range() {
615
606
  return this.dataRange.displayRange();
616
607
  }
@@ -12,6 +12,8 @@ import ceil from './utils/ceil';
12
12
  import { toDate, toTime, floorDate, ceilDate, duration, addDuration, addTicks, dateDiff, absoluteDateDiff, dateComparer, parseDate, parseDates, firstDay } from '../date-utils';
13
13
  import { HOURS, DAYS, WEEKS, MONTHS, YEARS, TIME_PER_DAY, TIME_PER_WEEK, TIME_PER_MONTH, TIME_PER_YEAR, TIME_PER_UNIT } from '../date-utils/constants';
14
14
 
15
+ const MIN_VALUE_RANGE = 1000;
16
+
15
17
  class DateValueAxis extends Axis {
16
18
  constructor(seriesMin, seriesMax, axisOptions, chartService) {
17
19
  const min = toDate(seriesMin);
@@ -120,23 +122,22 @@ class DateValueAxis extends Axis {
120
122
  return new AxisLabel(date, text, index, null, labelOptions);
121
123
  }
122
124
 
123
- translateRange(delta, exact) {
125
+ translateRange(delta) {
124
126
  const options = this.options;
125
- const baseUnit = options.baseUnit;
126
- const weekStartDay = options.weekStartDay || 0;
127
127
  const lineBox = this.lineBox();
128
- const size = options.vertical ? lineBox.height() : lineBox.width();
128
+ const { vertical, reverse } = options;
129
+ const size = vertical ? lineBox.height() : lineBox.width();
129
130
  const range = this.range();
130
131
  const scale = size / dateDiff(range.max, range.min);
131
- const offset = round(delta / scale, DEFAULT_PRECISION) * (options.reverse ? -1 : 1);
132
- let from = addTicks(options.min, offset);
133
- let to = addTicks(options.max, offset);
134
132
 
135
- if (!exact) {
136
- from = addDuration(from, 0, baseUnit, weekStartDay);
137
- to = addDuration(to, 0, baseUnit, weekStartDay);
133
+ let offset = round(delta / scale, DEFAULT_PRECISION);
134
+ if ((vertical || reverse) && !(vertical && reverse )) {
135
+ offset = -offset;
138
136
  }
139
137
 
138
+ let from = addTicks(options.min, offset);
139
+ let to = addTicks(options.max, offset);
140
+
140
141
  return {
141
142
  min: from,
142
143
  max: to,
@@ -144,25 +145,6 @@ class DateValueAxis extends Axis {
144
145
  };
145
146
  }
146
147
 
147
- scaleRange(delta) {
148
- let { min: from, max: to } = this.options;
149
- let rounds = Math.abs(delta);
150
-
151
- while (rounds--) {
152
- const range = dateDiff(from, to);
153
- const step = Math.round(range * 0.1);
154
- if (delta < 0) {
155
- from = addTicks(from, step);
156
- to = addTicks(to, -step);
157
- } else {
158
- from = addTicks(from, -step);
159
- to = addTicks(to, step);
160
- }
161
- }
162
-
163
- return { min: from, max: to };
164
- }
165
-
166
148
  shouldRenderNote(value) {
167
149
  const range = this.range();
168
150
 
@@ -193,16 +175,34 @@ class DateValueAxis extends Axis {
193
175
  };
194
176
  }
195
177
 
196
- zoomRange(delta) {
197
- const range = this.scaleRange(delta);
198
- const min = toDate(limitValue(toTime(range.min), this.totalMin, this.totalMax));
199
- const max = toDate(limitValue(toTime(range.max), this.totalMin, this.totalMax));
178
+ scaleRange(scale, cursor) {
179
+ const position = Math.abs(this.pointOffset(cursor));
180
+ const delta = (this.options.max - this.options.min) * Math.min(1, scale);
181
+ const minDelta = position * delta;
182
+ const maxDelta = (1 - position) * delta;
183
+ const min = toDate(toTime(this.options.min) + minDelta);
184
+ let max = toDate(toTime(this.options.max) - maxDelta);
185
+
186
+ if (max - min < MIN_VALUE_RANGE) {
187
+ max = toDate(toTime(min) + MIN_VALUE_RANGE);
188
+ }
200
189
 
201
190
  return {
202
191
  min: min,
203
192
  max: max
204
193
  };
205
194
  }
195
+
196
+ zoomRange(scale, cursor) {
197
+ const range = this.scaleRange(scale, cursor);
198
+ const min = toDate(limitValue(toTime(range.min), this.totalMin, this.totalMax));
199
+ const max = toDate(limitValue(toTime(range.max), this.totalMin, this.totalMax));
200
+
201
+ return {
202
+ min,
203
+ max
204
+ };
205
+ }
206
206
  }
207
207
 
208
208
  function timeUnits(delta) {
@@ -11,6 +11,7 @@ import { DEFAULT_PRECISION, BLACK, X, Y } from '../common/constants';
11
11
  import { deepExtend, defined, inArray, limitValue, round, setDefaultOptions } from '../common';
12
12
 
13
13
  const DEFAULT_MAJOR_UNIT = 10;
14
+ const MIN_VALUE_RANGE = 1e-6;
14
15
 
15
16
  class LogarithmicAxis extends Axis {
16
17
  constructor(seriesMin, seriesMax, options, chartService) {
@@ -126,16 +127,6 @@ class LogarithmicAxis extends Axis {
126
127
  return { min: options.min, max: options.max };
127
128
  }
128
129
 
129
- scaleRange(delta) {
130
- const base = this.options.majorUnit;
131
- const offset = -delta;
132
-
133
- return {
134
- min: Math.pow(base, this.logMin - offset),
135
- max: Math.pow(base, this.logMax + offset)
136
- };
137
- }
138
-
139
130
  translateRange(delta) {
140
131
  const { options, logMin, logMax } = this;
141
132
  const { reverse, vertical, majorUnit: base } = options;
@@ -296,21 +287,33 @@ class LogarithmicAxis extends Axis {
296
287
  };
297
288
  }
298
289
 
299
- zoomRange(delta) {
300
- const { options, totalMin, totalMax } = this;
301
- const newRange = this.scaleRange(delta);
302
- const min = limitValue(newRange.min, totalMin, totalMax);
303
- const max = limitValue(newRange.max, totalMin, totalMax);
304
- const base = options.majorUnit;
305
- const acceptOptionsRange = max > min && options.min && options.max && (round(log(options.max, base) - log(options.min, base), DEFAULT_PRECISION) < 1);
306
- const acceptNewRange = !(options.min === totalMin && options.max === totalMax) && round(log(max, base) - log(min, base), DEFAULT_PRECISION) >= 1;
307
-
308
- if (acceptOptionsRange || acceptNewRange) {
309
- return {
310
- min: min,
311
- max: max
312
- };
290
+ scaleRange(scale, cursor) {
291
+ const { majorUnit: base } = this.options;
292
+ const logMin = log(this.options.min, base);
293
+ const logMax = log(this.options.max, base);
294
+ const position = Math.abs(this.pointOffset(cursor));
295
+ const delta = (logMax - logMin) * Math.min(1, scale);
296
+ const min = Math.pow(base, logMin + position * delta);
297
+ let max = Math.pow(base, logMax - (1 - position) * delta);
298
+
299
+ if (max - min < MIN_VALUE_RANGE) {
300
+ max = min + MIN_VALUE_RANGE;
313
301
  }
302
+
303
+ return {
304
+ min: min,
305
+ max: max
306
+ };
307
+ }
308
+
309
+ zoomRange(scale, cursor) {
310
+ const range = this.scaleRange(scale, cursor);
311
+ const { totalMin, totalMax } = this;
312
+
313
+ return {
314
+ min: limitValue(range.min, totalMin, totalMax),
315
+ max: limitValue(range.max, totalMin, totalMax)
316
+ };
314
317
  }
315
318
 
316
319
  _minorIntervalOptions(power) {
@@ -398,8 +401,8 @@ function throwNegativeValuesError() {
398
401
  throw new Error("Non positive values cannot be used for a logarithmic axis");
399
402
  }
400
403
 
401
- function log(y, x) {
402
- return Math.log(y) / Math.log(x);
404
+ function log(x, base) {
405
+ return Math.log(x) / Math.log(base);
403
406
  }
404
407
 
405
408
  setDefaultOptions(LogarithmicAxis, {
@@ -194,16 +194,6 @@ class NumericAxis extends Axis {
194
194
  };
195
195
  }
196
196
 
197
- scaleRange(delta) {
198
- const options = this.options;
199
- const offset = -delta * options.majorUnit;
200
-
201
- return {
202
- min: options.min - offset,
203
- max: options.max + offset
204
- };
205
- }
206
-
207
197
  labelsCount() {
208
198
  return this.getDivisions(this.options.majorUnit);
209
199
  }
@@ -240,18 +230,32 @@ class NumericAxis extends Axis {
240
230
  }
241
231
  }
242
232
 
243
- zoomRange(delta) {
244
- const { totalMin, totalMax } = this;
245
- const newRange = this.scaleRange(delta);
246
- const min = limitValue(newRange.min, totalMin, totalMax);
247
- const max = limitValue(newRange.max, totalMin, totalMax);
233
+ scaleRange(scale, cursor) {
234
+ const position = Math.abs(this.pointOffset(cursor));
235
+ const delta = (this.options.max - this.options.min) * Math.min(1, scale);
236
+ const minDelta = position * delta;
237
+ const maxDelta = (1 - position) * delta;
238
+ const min = this.options.min + minDelta;
239
+ let max = this.options.max - maxDelta;
248
240
 
249
- if (this.isValidRange(min, max)) {
250
- return {
251
- min: min,
252
- max: max
253
- };
241
+ if (max - min < MIN_VALUE_RANGE) {
242
+ max = min + MIN_VALUE_RANGE;
254
243
  }
244
+
245
+ return {
246
+ min: min,
247
+ max: max
248
+ };
249
+ }
250
+
251
+ zoomRange(scale, cursor) {
252
+ const { totalMin, totalMax } = this;
253
+ const range = this.scaleRange(scale, cursor);
254
+
255
+ return {
256
+ min: limitValue(range.min, totalMin, totalMax),
257
+ max: limitValue(range.max, totalMin, totalMax)
258
+ };
255
259
  }
256
260
 
257
261
  isValidRange(min, max) {
@@ -5,6 +5,7 @@ export * from './sparkline';
5
5
  export * from './stock';
6
6
  export * from './gauges';
7
7
  export * from './barcode';
8
+ export * from './qrcode';
8
9
  export * from './common';
9
10
 
10
11
  export { baseTheme as chartBaseTheme } from './chart/base-theme';
@@ -0,0 +1,91 @@
1
+ import { QRDataMode } from './qr-data-mode';
2
+ import { extend } from '../../utils';
3
+ import {
4
+ toBitsString,
5
+ splitInto
6
+ } from '../../utils';
7
+
8
+ export class AlphaNumericQRDataMode extends QRDataMode {
9
+ initProperties() {
10
+ super.initProperties();
11
+
12
+ extend(this, {
13
+ characters: {
14
+ "0": 0,
15
+ "1": 1,
16
+ "2": 2,
17
+ "3": 3,
18
+ "4": 4,
19
+ "5": 5,
20
+ "6": 6,
21
+ "7": 7,
22
+ "8": 8,
23
+ "9": 9,
24
+ "A": 10,
25
+ "B": 11,
26
+ "C": 12,
27
+ "D": 13,
28
+ "E": 14,
29
+ "F": 15,
30
+ "G": 16,
31
+ "H": 17,
32
+ "I": 18,
33
+ "J": 19,
34
+ "K": 20,
35
+ "L": 21,
36
+ "M": 22,
37
+ "N": 23,
38
+ "O": 24,
39
+ "P": 25,
40
+ "Q": 26,
41
+ "R": 27,
42
+ "S": 28,
43
+ "T": 29,
44
+ "U": 30,
45
+ "V": 31,
46
+ "W": 32,
47
+ "X": 33,
48
+ "Y": 34,
49
+ "Z": 35,
50
+ " ": 36,
51
+ "$": 37,
52
+ "%": 38,
53
+ "*": 39,
54
+ "+": 40,
55
+ "-": 41,
56
+ ".": 42,
57
+ "/": 43,
58
+ ":": 44
59
+ },
60
+ bitsInCharacterCount: [9, 11, 13],
61
+ modeIndicator: "0010"
62
+ });
63
+ }
64
+
65
+ getValue(character) {
66
+ return this.characters[character];
67
+ }
68
+
69
+ encode(str, version) {
70
+ let
71
+ parts = splitInto(str, 2),
72
+ result = this.getModeCountString(str.length, version),
73
+ value;
74
+ let i;
75
+
76
+ for (i = 0; i < parts.length - 1; i++) {
77
+ value = 45 * this.getValue(parts[i].charAt(0)) + this.getValue(parts[i].charAt(1));
78
+ result += toBitsString(value, 11);
79
+ }
80
+
81
+ value = parts[i].length === 2 ?
82
+ 45 * this.getValue(parts[i].charAt(0)) + this.getValue(parts[i].charAt(1)) :
83
+ this.getValue(parts[i].charAt(0));
84
+
85
+ return result + toBitsString(value, 1 + 5 * parts[i].length);
86
+ }
87
+
88
+ getStringBitsLength(inputLength, version) {
89
+ return 4 + this.getBitsCharacterCount(version) + 11 * Math.floor(inputLength / 2) + 6 * (inputLength % 2);
90
+ }
91
+ }
@@ -0,0 +1,41 @@
1
+ import { QRDataMode } from './qr-data-mode';
2
+ import { extend } from '../../utils';
3
+ import {
4
+ toBitsString
5
+ } from '../../utils';
6
+
7
+ export class ByteQRDataMode extends QRDataMode {
8
+ initProperties() {
9
+ super.initProperties();
10
+
11
+ extend(this, {
12
+ bitsInCharacterCount: [8, 16, 16],
13
+ modeIndicator: "0100"
14
+ });
15
+ }
16
+
17
+ getValue(character) {
18
+ let code = character.charCodeAt(0);
19
+
20
+ if (code <= 127 || (160 <= code && code <= 255)) {
21
+ return code;
22
+ }
23
+
24
+ throw new Error("Unsupported character: " + character);
25
+ }
26
+
27
+ encode(str, version) {
28
+ let mode = this,
29
+ result = mode.getModeCountString(str.length, version);
30
+
31
+ for (let i = 0; i < str.length; i++) {
32
+ result += toBitsString(mode.getValue(str.charAt(i)), 8);
33
+ }
34
+
35
+ return result;
36
+ }
37
+
38
+ getStringBitsLength(inputLength, version) {
39
+ return 4 + this.getBitsCharacterCount(version) + 8 * inputLength;
40
+ }
41
+ }
@@ -0,0 +1,13 @@
1
+ import { NumericQRDataMode } from './numeric-data-mode';
2
+ import { AlphaNumericQRDataMode } from './alpha-numeric-data-mode';
3
+ import { ByteQRDataMode } from './byte-data-mode';
4
+
5
+ const NUMERIC = "numeric";
6
+ const ALPHA_NUMERIC = "alphanumeric";
7
+ const BYTE = "byte";
8
+
9
+ export let DataModeInstances = {
10
+ [NUMERIC]: new NumericQRDataMode(),
11
+ [ALPHA_NUMERIC]: new AlphaNumericQRDataMode(),
12
+ [BYTE]: new ByteQRDataMode()
13
+ };
@@ -0,0 +1,39 @@
1
+ import { QRDataMode } from './qr-data-mode';
2
+ import { extend } from '../../utils';
3
+ import {
4
+ toBitsString,
5
+ splitInto
6
+ } from '../../utils';
7
+
8
+ export class NumericQRDataMode extends QRDataMode {
9
+ initProperties() {
10
+ super.initProperties();
11
+
12
+ extend(this, {
13
+ bitsInCharacterCount: [10, 12, 14],
14
+ modeIndicator: "0001"
15
+ });
16
+ }
17
+
18
+ getValue(character) {
19
+ return parseInt(character, 10);
20
+ }
21
+
22
+ encode(str, version) {
23
+ let mode = this,
24
+ parts = splitInto(str, 3),
25
+ result = mode.getModeCountString(str.length, version);
26
+ let i;
27
+
28
+ for (i = 0; i < parts.length - 1; i++) {
29
+ result += toBitsString(parts[i], 10);
30
+ }
31
+
32
+ return result + toBitsString(parts[i], 1 + 3 * parts[i].length);
33
+ }
34
+
35
+ getStringBitsLength(inputLength, version) {
36
+ let mod3 = inputLength % 3;
37
+ return 4 + this.getBitsCharacterCount(version) + 10 * Math.floor(inputLength / 3) + 3 * mod3 + (mod3 === 0 ? 0 : 1);
38
+ }
39
+ }
@@ -0,0 +1,44 @@
1
+ import { Class } from '../../../common';
2
+ import { extend } from '../../utils';
3
+ import {
4
+ toBitsString
5
+ } from '../../utils';
6
+
7
+ export class QRDataMode extends Class {
8
+ constructor() {
9
+ super();
10
+
11
+ this.initProperties();
12
+ }
13
+
14
+ initProperties() {
15
+ extend(this, {
16
+ modeIndicator: "",
17
+ bitsInCharacterCount: []
18
+ });
19
+ }
20
+
21
+ getVersionIndex(version) {
22
+ if (version < 10) {
23
+ return 0;
24
+ } else if (version > 26) {
25
+ return 2;
26
+ }
27
+
28
+ return 1;
29
+ }
30
+
31
+ getBitsCharacterCount(version) {
32
+ return this.bitsInCharacterCount[this.getVersionIndex(version || 40)];
33
+ }
34
+
35
+ getModeCountString(length, version) {
36
+ return this.modeIndicator + toBitsString(length, this.getBitsCharacterCount(version));
37
+ }
38
+
39
+ encode() { }
40
+
41
+ getStringBitsLength() { }
42
+
43
+ getValue() { }
44
+ }
@@ -0,0 +1,19 @@
1
+ import { Class } from '../../../common';
2
+ import { EncodingResult } from '../encoding-result';
3
+ import {
4
+ getModes,
5
+ getVersion,
6
+ getDataCodewordsCount,
7
+ getDataString
8
+ } from '../encoding';
9
+
10
+ export class IsoEncoder extends Class {
11
+ getEncodingResult(inputString, errorCorrectionLevel) {
12
+ let modes = getModes(inputString),
13
+ dataCodewordsCount = getDataCodewordsCount(modes),
14
+ version = getVersion(dataCodewordsCount, errorCorrectionLevel),
15
+ dataString = getDataString(modes, version);
16
+
17
+ return new EncodingResult(dataString, version);
18
+ }
19
+ }