libphonenumber-js 1.10.8 → 1.10.11
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/build/AsYouType.js +1 -1
- package/build/AsYouType.js.map +1 -1
- package/build/AsYouType.test.js +6 -0
- package/build/AsYouType.test.js.map +1 -1
- package/build/AsYouTypeParser.js +12 -4
- package/build/AsYouTypeParser.js.map +1 -1
- package/build/AsYouTypeState.js +3 -3
- package/build/AsYouTypeState.js.map +1 -1
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/es6/AsYouType.js +1 -1
- package/es6/AsYouType.js.map +1 -1
- package/es6/AsYouType.test.js +6 -0
- package/es6/AsYouType.test.js.map +1 -1
- package/es6/AsYouTypeParser.js +12 -4
- package/es6/AsYouTypeParser.js.map +1 -1
- package/es6/AsYouTypeState.js +3 -3
- package/es6/AsYouTypeState.js.map +1 -1
- package/metadata.full.json +1 -1
- package/metadata.full.json.js +1 -1
- package/metadata.max.json +1 -1
- package/metadata.max.json.js +1 -1
- package/metadata.min.json +1 -1
- package/metadata.min.json.js +1 -1
- package/metadata.mobile.json +1 -1
- package/metadata.mobile.json.js +1 -1
- package/package.json +1 -1
- package/source/AsYouType.js +1 -1
- package/source/AsYouType.test.js +7 -0
- package/source/AsYouTypeParser.js +10 -4
- package/source/AsYouTypeState.js +3 -3
- package/types.d.ts +1 -1
package/package.json
CHANGED
package/source/AsYouType.js
CHANGED
|
@@ -97,7 +97,7 @@ export default class AsYouType {
|
|
|
97
97
|
// with the old versions.
|
|
98
98
|
this.country = country
|
|
99
99
|
},
|
|
100
|
-
onCallingCodeChange: (
|
|
100
|
+
onCallingCodeChange: (callingCode, country) => {
|
|
101
101
|
this.metadata.selectNumberingPlan(country, callingCode)
|
|
102
102
|
this.formatter.reset(this.metadata.numberingPlan, this.state)
|
|
103
103
|
this.parser.reset(this.metadata.numberingPlan)
|
package/source/AsYouType.test.js
CHANGED
|
@@ -1356,6 +1356,13 @@ describe('AsYouType.getNumberValue()', () => {
|
|
|
1356
1356
|
formatter.reset()
|
|
1357
1357
|
formatter.input('059').should.equal('059')
|
|
1358
1358
|
})
|
|
1359
|
+
|
|
1360
|
+
it('should work for SK phone numbers (2)', function() {
|
|
1361
|
+
// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/69
|
|
1362
|
+
const formatter = new AsYouType('SK')
|
|
1363
|
+
formatter.input('421901222333').should.equal('421 901 222 333')
|
|
1364
|
+
formatter.getTemplate().should.equal('xxx xxx xxx xxx')
|
|
1365
|
+
})
|
|
1359
1366
|
})
|
|
1360
1367
|
|
|
1361
1368
|
function type(something) {
|
|
@@ -385,7 +385,10 @@ export default class AsYouTypeParser {
|
|
|
385
385
|
state.update({
|
|
386
386
|
IDDPrefix: digits.slice(0, digits.length - numberWithoutIDD.length)
|
|
387
387
|
})
|
|
388
|
-
this.startInternationalNumber(state
|
|
388
|
+
this.startInternationalNumber(state, {
|
|
389
|
+
country: undefined,
|
|
390
|
+
callingCode: undefined
|
|
391
|
+
})
|
|
389
392
|
return true
|
|
390
393
|
}
|
|
391
394
|
}
|
|
@@ -405,14 +408,17 @@ export default class AsYouTypeParser {
|
|
|
405
408
|
state.update({
|
|
406
409
|
missingPlus: true
|
|
407
410
|
})
|
|
408
|
-
this.startInternationalNumber(state
|
|
411
|
+
this.startInternationalNumber(state, {
|
|
412
|
+
country: state.country,
|
|
413
|
+
callingCode: newCallingCode
|
|
414
|
+
})
|
|
409
415
|
return true
|
|
410
416
|
}
|
|
411
417
|
}
|
|
412
418
|
}
|
|
413
419
|
|
|
414
|
-
startInternationalNumber(state) {
|
|
415
|
-
state.startInternationalNumber()
|
|
420
|
+
startInternationalNumber(state, { country, callingCode }) {
|
|
421
|
+
state.startInternationalNumber(country, callingCode)
|
|
416
422
|
// If a national (significant) number has been extracted before, reset it.
|
|
417
423
|
if (state.nationalSignificantNumber) {
|
|
418
424
|
state.resetNationalSignificantNumber()
|
package/source/AsYouTypeState.js
CHANGED
|
@@ -40,16 +40,16 @@ export default class AsYouTypeState {
|
|
|
40
40
|
|
|
41
41
|
setCallingCode(callingCode) {
|
|
42
42
|
this.callingCode = callingCode
|
|
43
|
-
|
|
43
|
+
this.onCallingCodeChange(callingCode, this.country)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
startInternationalNumber() {
|
|
46
|
+
startInternationalNumber(country, callingCode) {
|
|
47
47
|
// Prepend the `+` to parsed input.
|
|
48
48
|
this.international = true
|
|
49
49
|
// If a default country was set then reset it
|
|
50
50
|
// because an explicitly international phone
|
|
51
51
|
// number is being entered.
|
|
52
|
-
this.initCountryAndCallingCode()
|
|
52
|
+
this.initCountryAndCallingCode(country, callingCode)
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
appendDigits(nextDigits) {
|
package/types.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type Countries = {
|
|
|
24
24
|
// `in` operator docs:
|
|
25
25
|
// https://www.typescriptlang.org/docs/handbook/advanced-types.html#mapped-types
|
|
26
26
|
// `country in CountryCode` means "for each and every CountryCode".
|
|
27
|
-
[country in CountryCode]
|
|
27
|
+
[country in CountryCode]?: any[];
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export type MetadataJson = {
|