ngx-mask 16.0.3 → 16.0.4
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/fesm2022/ngx-mask.mjs
CHANGED
|
@@ -388,7 +388,13 @@ class NgxMaskApplierService {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
if (maskExpression[cursor] === 'h') {
|
|
391
|
-
if (result === '2' && Number(inputSymbol) > 3)
|
|
391
|
+
if ((result === '2' && Number(inputSymbol) > 3) ||
|
|
392
|
+
((result.slice(cursor - 2, cursor) === '2' ||
|
|
393
|
+
result.slice(cursor - 3, cursor) === '2' ||
|
|
394
|
+
result.slice(cursor - 4, cursor) === '2' ||
|
|
395
|
+
result.slice(cursor - 1, cursor) === '2') &&
|
|
396
|
+
Number(inputSymbol) > 3 &&
|
|
397
|
+
cursor > 10)) {
|
|
392
398
|
// eslint-disable-next-line no-param-reassign
|
|
393
399
|
position = position + 1;
|
|
394
400
|
cursor += 1;
|
|
@@ -410,31 +416,32 @@ class NgxMaskApplierService {
|
|
|
410
416
|
}
|
|
411
417
|
}
|
|
412
418
|
const daysCount = 31;
|
|
419
|
+
const inputValueCursor = inputValue[cursor];
|
|
420
|
+
const inputValueCursorPlusOne = inputValue[cursor + 1];
|
|
421
|
+
const inputValueCursorPlusTwo = inputValue[cursor + 2];
|
|
422
|
+
const inputValueCursorMinusOne = inputValue[cursor - 1];
|
|
423
|
+
const inputValueCursorMinusTwo = inputValue[cursor - 2];
|
|
424
|
+
const inputValueCursorMinusThree = inputValue[cursor - 3];
|
|
425
|
+
const inputValueSliceMinusThreeMinusOne = inputValue.slice(cursor - 3, cursor - 1);
|
|
426
|
+
const inputValueSliceMinusOnePlusOne = inputValue.slice(cursor - 1, cursor + 1);
|
|
427
|
+
const inputValueSliceCursorPlusTwo = inputValue.slice(cursor, cursor + 2);
|
|
428
|
+
const inputValueSliceMinusTwoCursor = inputValue.slice(cursor - 2, cursor);
|
|
413
429
|
if (maskExpression[cursor] === 'd') {
|
|
414
430
|
const maskStartWithMonth = maskExpression.slice(0, 2) === 'M0';
|
|
415
431
|
const startWithMonthInput = maskExpression.slice(0, 2) === 'M0' &&
|
|
416
|
-
(
|
|
417
|
-
inputValue[cursor - 2] === '.' ||
|
|
418
|
-
inputValue[cursor - 2] === '-');
|
|
432
|
+
this.specialCharacters.includes(inputValueCursorMinusTwo);
|
|
419
433
|
if ((Number(inputSymbol) > 3 && this.leadZeroDateTime) ||
|
|
420
434
|
(!maskStartWithMonth &&
|
|
421
|
-
(Number(
|
|
422
|
-
Number(
|
|
423
|
-
|
|
424
|
-
inputValue[cursor + 1] === '-')) ||
|
|
435
|
+
(Number(inputValueSliceCursorPlusTwo) > daysCount ||
|
|
436
|
+
Number(inputValueSliceMinusOnePlusOne) > daysCount ||
|
|
437
|
+
this.specialCharacters.includes(inputValueCursorPlusOne))) ||
|
|
425
438
|
(startWithMonthInput
|
|
426
|
-
? Number(
|
|
427
|
-
(
|
|
428
|
-
(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
inputValue[cursor] === '/' ||
|
|
433
|
-
inputValue[cursor] === '-'
|
|
434
|
-
: Number(inputValue.slice(cursor, cursor + 2)) > daysCount ||
|
|
435
|
-
inputValue[cursor + 1] === '/' ||
|
|
436
|
-
inputValue[cursor + 1] === '-' ||
|
|
437
|
-
inputValue[cursor + 1] === '.')) {
|
|
439
|
+
? Number(inputValueSliceMinusOnePlusOne) > daysCount ||
|
|
440
|
+
(!this.specialCharacters.includes(inputValueCursor) &&
|
|
441
|
+
this.specialCharacters.includes(inputValueCursorPlusTwo)) ||
|
|
442
|
+
this.specialCharacters.includes(inputValueCursor)
|
|
443
|
+
: Number(inputValueSliceCursorPlusTwo) > daysCount ||
|
|
444
|
+
this.specialCharacters.includes(inputValueCursorPlusOne))) {
|
|
438
445
|
// eslint-disable-next-line no-param-reassign
|
|
439
446
|
position = position + 1;
|
|
440
447
|
cursor += 1;
|
|
@@ -451,43 +458,39 @@ class NgxMaskApplierService {
|
|
|
451
458
|
// mask without day
|
|
452
459
|
const withoutDays = cursor === 0 &&
|
|
453
460
|
(Number(inputSymbol) > 2 ||
|
|
454
|
-
Number(
|
|
455
|
-
|
|
461
|
+
Number(inputValueSliceCursorPlusTwo) > monthsCount ||
|
|
462
|
+
this.specialCharacters.includes(inputValueCursorPlusOne));
|
|
456
463
|
// day<10 && month<12 for input
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
(
|
|
464
|
-
Number(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
inputValue[cursor - 1] === '-');
|
|
464
|
+
const specialChart = maskExpression.slice(cursor + 2, cursor + 3);
|
|
465
|
+
const day1monthInput = inputValueSliceMinusThreeMinusOne.includes(specialChart) &&
|
|
466
|
+
((this.specialCharacters.includes(inputValueCursorMinusTwo) &&
|
|
467
|
+
Number(inputValueSliceMinusOnePlusOne) > monthsCount &&
|
|
468
|
+
!this.specialCharacters.includes(inputValueCursor)) ||
|
|
469
|
+
this.specialCharacters.includes(inputValueCursor) ||
|
|
470
|
+
(this.specialCharacters.includes(inputValueCursorMinusThree) &&
|
|
471
|
+
Number(inputValueSliceMinusTwoCursor) > monthsCount &&
|
|
472
|
+
!this.specialCharacters.includes(inputValueCursorMinusOne)) ||
|
|
473
|
+
this.specialCharacters.includes(inputValueCursorMinusOne));
|
|
468
474
|
// month<12 && day<10 for input
|
|
469
|
-
const day2monthInput = Number(
|
|
470
|
-
!
|
|
471
|
-
(
|
|
472
|
-
(Number(
|
|
473
|
-
|
|
474
|
-
inputValue[cursor + 1] === '-');
|
|
475
|
+
const day2monthInput = Number(inputValueSliceMinusThreeMinusOne) <= daysCount &&
|
|
476
|
+
!this.specialCharacters.includes(inputValueSliceMinusThreeMinusOne) &&
|
|
477
|
+
this.specialCharacters.includes(inputValueCursorMinusOne) &&
|
|
478
|
+
(Number(inputValueSliceCursorPlusTwo) > monthsCount ||
|
|
479
|
+
this.specialCharacters.includes(inputValueCursorPlusOne));
|
|
475
480
|
// cursor === 5 && without days
|
|
476
|
-
const day2monthInputDot = (Number(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
!inputValue.slice(cursor - 2, cursor).includes('/') &&
|
|
485
|
-
Number(inputValue.slice(cursor - 2, cursor)) > monthsCount;
|
|
481
|
+
const day2monthInputDot = (Number(inputValueSliceCursorPlusTwo) > monthsCount && cursor === 5) ||
|
|
482
|
+
(this.specialCharacters.includes(inputValueCursorPlusOne) &&
|
|
483
|
+
cursor === 5);
|
|
484
|
+
// // day<10 && month<12 for paste whole data
|
|
485
|
+
const day1monthPaste = Number(inputValueSliceMinusThreeMinusOne) > daysCount &&
|
|
486
|
+
!this.specialCharacters.includes(inputValueSliceMinusThreeMinusOne) &&
|
|
487
|
+
!this.specialCharacters.includes(inputValueSliceMinusTwoCursor) &&
|
|
488
|
+
Number(inputValueSliceMinusTwoCursor) > monthsCount;
|
|
486
489
|
// 10<day<31 && month<12 for paste whole data
|
|
487
|
-
const day2monthPaste = Number(
|
|
488
|
-
!
|
|
489
|
-
|
|
490
|
-
Number(
|
|
490
|
+
const day2monthPaste = Number(inputValueSliceMinusThreeMinusOne) <= daysCount &&
|
|
491
|
+
!this.specialCharacters.includes(inputValueSliceMinusThreeMinusOne) &&
|
|
492
|
+
!this.specialCharacters.includes(inputValueCursorMinusOne) &&
|
|
493
|
+
Number(inputValueSliceMinusOnePlusOne) > monthsCount;
|
|
491
494
|
if ((Number(inputSymbol) > 1 && this.leadZeroDateTime) ||
|
|
492
495
|
withoutDays ||
|
|
493
496
|
day1monthInput ||
|