monkey-style-guide-v2 0.0.59 → 0.0.61
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.
|
@@ -16,8 +16,9 @@ import { HttpClient } from '@angular/common/http';
|
|
|
16
16
|
import { format, parseISO, addYears, subYears, subMonths, addMonths, getMonth, getYear, startOfWeek, startOfMonth, endOfWeek, endOfMonth, isSameMonth, isBefore, isAfter, isToday, addDays, isWithinInterval, subDays } from 'date-fns';
|
|
17
17
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
18
18
|
import { getSupportedInputTypes } from '@angular/cdk/platform';
|
|
19
|
-
import parsePhoneNumberFromString, { getCountries, getCountryCallingCode, getExampleNumber, AsYouType
|
|
19
|
+
import parsePhoneNumberFromString, { getCountries, getCountryCallingCode, getExampleNumber, AsYouType } from 'libphonenumber-js';
|
|
20
20
|
import examples from 'libphonenumber-js/examples.mobile.json';
|
|
21
|
+
import { isValidPhoneNumber } from 'libphonenumber-js/max';
|
|
21
22
|
import { hasModifierKey } from '@angular/cdk/keycodes';
|
|
22
23
|
|
|
23
24
|
const counters = {};
|
|
@@ -5690,39 +5691,29 @@ class MonkeyInputPhoneComponent {
|
|
|
5690
5691
|
}
|
|
5691
5692
|
}
|
|
5692
5693
|
formatValue(value, changedCountry = false) {
|
|
5693
|
-
console.log(value);
|
|
5694
5694
|
if (!value) {
|
|
5695
5695
|
this.phoneFormatted = '';
|
|
5696
5696
|
this.phoneValid = false;
|
|
5697
5697
|
this.validateValue();
|
|
5698
5698
|
return;
|
|
5699
5699
|
}
|
|
5700
|
-
console.log('--1');
|
|
5701
5700
|
const detectedCallingCode = this.getCountryFromPhoneNumber(value, changedCountry);
|
|
5702
|
-
console.log('--2', detectedCallingCode);
|
|
5703
5701
|
const isCountryChanged = changedCountry || detectedCallingCode !== this.selectedCallingCode;
|
|
5704
|
-
console.log('--3', isCountryChanged);
|
|
5705
5702
|
if (isCountryChanged && detectedCallingCode) {
|
|
5706
5703
|
this.selectedCallingCode = detectedCallingCode;
|
|
5707
5704
|
}
|
|
5708
|
-
console.log('--4', this.selectedCallingCode);
|
|
5709
5705
|
const countryCode = this.getCountryByCallingCode(this.selectedCallingCode);
|
|
5710
|
-
console.log('--5', countryCode);
|
|
5711
5706
|
if (!countryCode) {
|
|
5712
5707
|
this.phoneFormatted = value;
|
|
5713
5708
|
this.phoneValid = false;
|
|
5714
5709
|
this.validateValue();
|
|
5715
5710
|
return;
|
|
5716
5711
|
}
|
|
5717
|
-
console.log('--6');
|
|
5718
5712
|
const nationalPart = value.replace(this.selectedCallingCode, '').replace(/[^\d+]/g, '');
|
|
5719
|
-
console.log(nationalPart);
|
|
5720
|
-
console.log(countryCode);
|
|
5721
5713
|
const formatter = new AsYouType(countryCode);
|
|
5722
5714
|
this.phoneFormatted = formatter.input(nationalPart);
|
|
5723
5715
|
this.performValue(nationalPart);
|
|
5724
5716
|
this.phoneValid = isValidPhoneNumber(nationalPart, countryCode);
|
|
5725
|
-
console.log(isValidPhoneNumber(nationalPart, countryCode));
|
|
5726
5717
|
this.validateValue();
|
|
5727
5718
|
}
|
|
5728
5719
|
ngAfterContentInit() { }
|
|
@@ -5757,7 +5748,6 @@ class MonkeyInputPhoneComponent {
|
|
|
5757
5748
|
}
|
|
5758
5749
|
onInputChange(event) {
|
|
5759
5750
|
const { value } = event.target;
|
|
5760
|
-
console.log('=======', value);
|
|
5761
5751
|
this.formatValue(value);
|
|
5762
5752
|
}
|
|
5763
5753
|
onCountryChange() {
|