@medipass/utils 11.90.0 → 11.90.1

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.
@@ -42,6 +42,35 @@ function getDefaultExportFromCjs (x) {
42
42
 
43
43
  var lib$1 = {exports: {}};
44
44
 
45
+ var implementation;
46
+ var hasRequiredImplementation;
47
+
48
+ function requireImplementation () {
49
+ if (hasRequiredImplementation) return implementation;
50
+ hasRequiredImplementation = 1;
51
+
52
+ implementation = commonjsGlobal;
53
+ return implementation;
54
+ }
55
+
56
+ var polyfill;
57
+ var hasRequiredPolyfill;
58
+
59
+ function requirePolyfill () {
60
+ if (hasRequiredPolyfill) return polyfill;
61
+ hasRequiredPolyfill = 1;
62
+
63
+ var implementation = requireImplementation();
64
+
65
+ polyfill = function getPolyfill() {
66
+ if (typeof commonjsGlobal !== 'object' || !commonjsGlobal || commonjsGlobal.Math !== Math || commonjsGlobal.Array !== Array) {
67
+ return implementation;
68
+ }
69
+ return commonjsGlobal;
70
+ };
71
+ return polyfill;
72
+ }
73
+
45
74
  var lib = {exports: {}};
46
75
 
47
76
  var hasRequiredLib;
@@ -284,11 +313,13 @@ function requireLib () {
284
313
  return lib.exports;
285
314
  }
286
315
 
287
- // Generated by CoffeeScript 1.10.0
316
+ // Generated by CoffeeScript 1.12.7
288
317
  (function() {
289
- var Payment, QJ, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlash, formatMonthExpiry, hasTextSelected, luhnCheck, reFormatCardNumber, restrictCVC, restrictCardNumber, restrictCombinedExpiry, restrictExpiry, restrictMonthExpiry, restrictNumeric, restrictYearExpiry, setCardType,
318
+ var Payment, QJ, cardFromNumber, cardFromType, cards, cursorSafeAssignValue, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlash, formatMonthExpiry, globalThis, hasTextSelected, luhnCheck, reFormatCardNumber, restrictCVC, restrictCardNumber, restrictCombinedExpiry, restrictExpiry, restrictMonthExpiry, restrictNumeric, restrictYearExpiry, setCardType,
290
319
  indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
291
320
 
321
+ globalThis = requirePolyfill()();
322
+
292
323
  QJ = requireLib();
293
324
 
294
325
  defaultFormat = /(\d{1,4})/g;
@@ -308,13 +339,6 @@ function requireLib () {
308
339
  length: [16],
309
340
  cvcLength: [3],
310
341
  luhn: true
311
- }, {
312
- type: 'hipercard',
313
- pattern: /^(384100|384140|384160|606282|637095|637568|60(?!11))/,
314
- format: defaultFormat,
315
- length: [14, 15, 16, 17, 18, 19],
316
- cvcLength: [3],
317
- luhn: true
318
342
  }, {
319
343
  type: 'dinersclub',
320
344
  pattern: /^(36|38|30[0-5])/,
@@ -330,12 +354,26 @@ function requireLib () {
330
354
  cvcLength: [3],
331
355
  luhn: true
332
356
  }, {
333
- type: 'jcb',
334
- pattern: /^35/,
357
+ type: 'elo',
358
+ pattern: /^401178|^401179|^431274|^438935|^451416|^457393|^457631|^457632|^504175|^627780|^636297|^636369|^636368|^(506699|5067[0-6]\d|50677[0-8])|^(50900\d|5090[1-9]\d|509[1-9]\d{2})|^65003[1-3]|^(65003[5-9]|65004\d|65005[0-1])|^(65040[5-9]|6504[1-3]\d)|^(65048[5-9]|65049\d|6505[0-2]\d|65053[0-8])|^(65054[1-9]|6505[5-8]\d|65059[0-8])|^(65070\d|65071[0-8])|^65072[0-7]|^(65090[1-9]|65091\d|650920)|^(65165[2-9]|6516[6-7]\d)|^(65500\d|65501\d)|^(65502[1-9]|6550[3-4]\d|65505[0-8])|^(65092[1-9]|65097[0-8])/,
335
359
  format: defaultFormat,
336
360
  length: [16],
337
361
  cvcLength: [3],
338
362
  luhn: true
363
+ }, {
364
+ type: 'hipercard',
365
+ pattern: /^(384100|384140|384160|606282|637095|637568|60(?!11))/,
366
+ format: defaultFormat,
367
+ length: [14, 15, 16, 17, 18, 19],
368
+ cvcLength: [3],
369
+ luhn: true
370
+ }, {
371
+ type: 'jcb',
372
+ pattern: /^(308[8-9]|309[0-3]|3094[0]{4}|309[6-9]|310[0-2]|311[2-9]|3120|315[8-9]|333[7-9]|334[0-9]|35)/,
373
+ format: defaultFormat,
374
+ length: [16, 19],
375
+ cvcLength: [3],
376
+ luhn: true
339
377
  }, {
340
378
  type: 'laser',
341
379
  pattern: /^(6706|6771|6709)/,
@@ -345,14 +383,28 @@ function requireLib () {
345
383
  luhn: true
346
384
  }, {
347
385
  type: 'maestro',
348
- pattern: /^(5018|5020|5038|6304|6703|6708|6759|676[1-3])/,
386
+ pattern: /^(50|5[6-9]|6007|6220|6304|6703|6708|6759|676[1-3])/,
349
387
  format: defaultFormat,
350
388
  length: [12, 13, 14, 15, 16, 17, 18, 19],
351
389
  cvcLength: [3],
352
390
  luhn: true
353
391
  }, {
354
392
  type: 'mastercard',
355
- pattern: /^(5[1-5]|677189)|^(222[1-9]|2[3-6]\d{2}|27[0-1]\d|2720)/,
393
+ pattern: /^(5[1-5]|677189)|^(22[2-9][1-9]|2[3-6]\d{2}|27[0-1]\d|2720)/,
394
+ format: defaultFormat,
395
+ length: [16],
396
+ cvcLength: [3],
397
+ luhn: true
398
+ }, {
399
+ type: 'mir',
400
+ pattern: /^220[0-4][0-9][0-9]\d{10}$/,
401
+ format: defaultFormat,
402
+ length: [16],
403
+ cvcLength: [3],
404
+ luhn: true
405
+ }, {
406
+ type: 'troy',
407
+ pattern: /^9792/,
356
408
  format: defaultFormat,
357
409
  length: [16],
358
410
  cvcLength: [3],
@@ -371,32 +423,29 @@ function requireLib () {
371
423
  length: [16],
372
424
  cvcLength: [3],
373
425
  luhn: true
374
- }, {
375
- type: 'elo',
376
- pattern: /^(4011(78|79)|43(1274|8935)|45(1416|7393|763(1|2))|50(4175|6699|67[0-7][0-9]|9000)|627780|63(6297|6368)|650(03([^4])|04([0-9])|05(0|1)|4(0[5-9]|3[0-9]|8[5-9]|9[0-9])|5([0-2][0-9]|3[0-8])|9([2-6][0-9]|7[0-8])|541|700|720|901)|651652|655000|655021)/,
377
- format: defaultFormat,
378
- length: [16],
379
- cvcLength: [3],
380
- luhn: true
381
426
  }, {
382
427
  type: 'visa',
383
428
  pattern: /^4/,
384
429
  format: defaultFormat,
385
- length: [13, 16, 19],
430
+ length: [13, 16],
386
431
  cvcLength: [3],
387
432
  luhn: true
388
433
  }
389
434
  ];
390
435
 
391
436
  cardFromNumber = function(num) {
392
- var card, j, len;
437
+ var card, foundCard, j, len, match;
393
438
  num = (num + '').replace(/\D/g, '');
439
+ foundCard = void 0;
394
440
  for (j = 0, len = cards.length; j < len; j++) {
395
441
  card = cards[j];
396
- if (card.pattern.test(num)) {
397
- return card;
442
+ if (match = num.match(card.pattern)) {
443
+ if (!foundCard || match[0].length > foundCard[1][0].length) {
444
+ foundCard = [card, match];
445
+ }
398
446
  }
399
447
  }
448
+ return foundCard && foundCard[0];
400
449
  };
401
450
 
402
451
  cardFromType = function(type) {
@@ -451,7 +500,7 @@ function requireLib () {
451
500
  target = e.target;
452
501
  value = QJ.val(target);
453
502
  value = Payment.fns.formatCardNumber(value);
454
- QJ.val(target, value);
503
+ cursorSafeAssignValue(target, value);
455
504
  return QJ.trigger(target, 'change');
456
505
  };
457
506
  })());
@@ -460,14 +509,19 @@ function requireLib () {
460
509
  formatCardNumber = function(maxLength) {
461
510
  return function(e) {
462
511
  var card, digit, i, j, len, length, re, target, upperLength, upperLengths, value;
463
- digit = String.fromCharCode(e.which);
512
+ if (e.which > 0) {
513
+ digit = String.fromCharCode(e.which);
514
+ value = QJ.val(e.target) + digit;
515
+ } else {
516
+ digit = e.data;
517
+ value = QJ.val(e.target);
518
+ }
464
519
  if (!/^\d+$/.test(digit)) {
465
520
  return;
466
521
  }
467
522
  target = e.target;
468
- value = QJ.val(target);
469
- card = cardFromNumber(value + digit);
470
- length = (value.replace(/\D/g, '') + digit).length;
523
+ card = cardFromNumber(value);
524
+ length = (value.replace(/\D/g, '')).length;
471
525
  upperLengths = [16];
472
526
  if (card) {
473
527
  upperLengths = card.length;
@@ -494,6 +548,7 @@ function requireLib () {
494
548
  } else {
495
549
  re = /(?:^|\s)(\d{4})$/;
496
550
  }
551
+ value = value.substring(0, value.length - 1);
497
552
  if (re.test(value)) {
498
553
  e.preventDefault();
499
554
  QJ.val(target, value + ' ' + digit);
@@ -528,12 +583,17 @@ function requireLib () {
528
583
 
529
584
  formatExpiry = function(e) {
530
585
  var digit, target, val;
531
- digit = String.fromCharCode(e.which);
586
+ target = e.target;
587
+ if (e.which > 0) {
588
+ digit = String.fromCharCode(e.which);
589
+ val = QJ.val(target) + digit;
590
+ } else {
591
+ digit = e.data;
592
+ val = QJ.val(target);
593
+ }
532
594
  if (!/^\d+$/.test(digit)) {
533
595
  return;
534
596
  }
535
- target = e.target;
536
- val = QJ.val(target) + digit;
537
597
  if (/^\d$/.test(val) && (val !== '0' && val !== '1')) {
538
598
  e.preventDefault();
539
599
  QJ.val(target, "0" + val + " / ");
@@ -730,9 +790,20 @@ function requireLib () {
730
790
  }
731
791
  };
732
792
 
793
+ cursorSafeAssignValue = function(target, value) {
794
+ var selectionEnd;
795
+ selectionEnd = target.selectionEnd;
796
+ QJ.val(target, value);
797
+ if (selectionEnd) {
798
+ return target.selectionEnd = selectionEnd;
799
+ }
800
+ };
801
+
733
802
  Payment = (function() {
734
803
  function Payment() {}
735
804
 
805
+ Payment.J = QJ;
806
+
736
807
  Payment.fns = {
737
808
  cardExpiryVal: function(value) {
738
809
  var month, prefix, ref, year;
@@ -840,7 +911,8 @@ function requireLib () {
840
911
  };
841
912
 
842
913
  Payment.restrictNumeric = function(el) {
843
- return QJ.on(el, 'keypress', restrictNumeric);
914
+ QJ.on(el, 'keypress', restrictNumeric);
915
+ return QJ.on(el, 'input', restrictNumeric);
844
916
  };
845
917
 
846
918
  Payment.cardExpiryVal = function(el) {
@@ -850,6 +922,7 @@ function requireLib () {
850
922
  Payment.formatCardCVC = function(el) {
851
923
  Payment.restrictNumeric(el);
852
924
  QJ.on(el, 'keypress', restrictCVC);
925
+ QJ.on(el, 'input', restrictCVC);
853
926
  return el;
854
927
  };
855
928
 
@@ -865,6 +938,7 @@ function requireLib () {
865
938
  QJ.on(el, 'keypress', formatForwardSlash);
866
939
  QJ.on(el, 'keypress', formatForwardExpiry);
867
940
  QJ.on(el, 'keydown', formatBackExpiry);
941
+ QJ.on(el, 'input', formatExpiry);
868
942
  }
869
943
  return el;
870
944
  };
@@ -872,7 +946,9 @@ function requireLib () {
872
946
  Payment.formatCardExpiryMultiple = function(month, year) {
873
947
  QJ.on(month, 'keypress', restrictMonthExpiry);
874
948
  QJ.on(month, 'keypress', formatMonthExpiry);
875
- return QJ.on(year, 'keypress', restrictYearExpiry);
949
+ QJ.on(month, 'input', formatMonthExpiry);
950
+ QJ.on(year, 'keypress', restrictYearExpiry);
951
+ return QJ.on(year, 'input', restrictYearExpiry);
876
952
  };
877
953
 
878
954
  Payment.formatCardNumber = function(el, maxLength) {
@@ -881,8 +957,9 @@ function requireLib () {
881
957
  QJ.on(el, 'keypress', formatCardNumber(maxLength));
882
958
  QJ.on(el, 'keydown', formatBackCardNumber);
883
959
  QJ.on(el, 'keyup blur', setCardType);
960
+ QJ.on(el, 'blur', formatCardNumber(maxLength));
884
961
  QJ.on(el, 'paste', reFormatCardNumber);
885
- QJ.on(el, 'input', reFormatCardNumber);
962
+ QJ.on(el, 'input', formatCardNumber(maxLength));
886
963
  return el;
887
964
  };
888
965
 
@@ -916,7 +993,7 @@ function requireLib () {
916
993
 
917
994
  lib$1.exports = Payment;
918
995
 
919
- commonjsGlobal.Payment = Payment;
996
+ globalThis.Payment = Payment;
920
997
 
921
998
  }).call(commonjsGlobal);
922
999
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medipass/utils",
3
- "version": "11.90.0",
3
+ "version": "11.90.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "core-js": "2.5.7",
29
29
  "date-fns": "2.16.1",
30
30
  "escape-html": "1.0.3",
31
- "google-libphonenumber": "3.2.39",
31
+ "google-libphonenumber": "3.2.44",
32
32
  "jsdom": "22.0.0",
33
33
  "lodash": "4.17.21",
34
34
  "react-places-autocomplete": "7.3.0",
@@ -47,5 +47,5 @@
47
47
  "rimraf": "^2.6.2",
48
48
  "typescript": "4.8.4"
49
49
  },
50
- "gitHead": "b28f3b1fd8e32f6bcc3ccaa053e7579478feb178"
50
+ "gitHead": "d0bbcedc59ac25c2e03acaea37a7884bca20f12d"
51
51
  }