libphonenumber-js 1.12.43 → 1.13.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.
Files changed (310) hide show
  1. package/CHANGELOG.md +131 -104
  2. package/README.md +141 -81
  3. package/core/es6/index.d.cts +2 -0
  4. package/core/es6/index.d.ts +2 -0
  5. package/core/es6/index.js +39 -0
  6. package/core/es6/package.json +12 -0
  7. package/core/index.cjs +5 -0
  8. package/core/index.cjs.js +5 -0
  9. package/core/index.d.cts +3 -1
  10. package/core/index.d.ts +3 -1
  11. package/core/index.js +5 -0
  12. package/custom.d.ts +6 -4
  13. package/custom.js +5 -5
  14. package/es6-modern/AsYouType.js +445 -0
  15. package/es6-modern/AsYouType.js.map +1 -0
  16. package/es6-modern/AsYouType.test.js.map +1 -0
  17. package/es6-modern/AsYouTypeFormatter.PatternMatcher.js +195 -0
  18. package/es6-modern/AsYouTypeFormatter.PatternMatcher.js.map +1 -0
  19. package/es6-modern/AsYouTypeFormatter.PatternMatcher.test.js.map +1 -0
  20. package/es6-modern/AsYouTypeFormatter.PatternParser.js +184 -0
  21. package/es6-modern/AsYouTypeFormatter.PatternParser.js.map +1 -0
  22. package/es6-modern/AsYouTypeFormatter.PatternParser.test.js.map +1 -0
  23. package/es6-modern/AsYouTypeFormatter.complete.js +120 -0
  24. package/es6-modern/AsYouTypeFormatter.complete.js.map +1 -0
  25. package/es6-modern/AsYouTypeFormatter.js +659 -0
  26. package/es6-modern/AsYouTypeFormatter.js.map +1 -0
  27. package/es6-modern/AsYouTypeFormatter.util.js +96 -0
  28. package/es6-modern/AsYouTypeFormatter.util.js.map +1 -0
  29. package/es6-modern/AsYouTypeFormatter.util.test.js.map +1 -0
  30. package/es6-modern/AsYouTypeParser.js +435 -0
  31. package/es6-modern/AsYouTypeParser.js.map +1 -0
  32. package/es6-modern/AsYouTypeState.js +104 -0
  33. package/es6-modern/AsYouTypeState.js.map +1 -0
  34. package/es6-modern/ParseError.js +15 -0
  35. package/es6-modern/ParseError.js.map +1 -0
  36. package/es6-modern/PhoneNumber.js +166 -0
  37. package/es6-modern/PhoneNumber.js.map +1 -0
  38. package/es6-modern/PhoneNumber.test.js.map +1 -0
  39. package/es6-modern/PhoneNumberMatcher.js +330 -0
  40. package/es6-modern/PhoneNumberMatcher.js.map +1 -0
  41. package/es6-modern/PhoneNumberMatcher.test.js.map +1 -0
  42. package/es6-modern/constants.js +31 -0
  43. package/es6-modern/constants.js.map +1 -0
  44. package/es6-modern/findNumbers/LRUCache.js +98 -0
  45. package/es6-modern/findNumbers/LRUCache.js.map +1 -0
  46. package/es6-modern/findNumbers/Leniency.js +311 -0
  47. package/es6-modern/findNumbers/Leniency.js.map +1 -0
  48. package/es6-modern/findNumbers/RegExpCache.js +20 -0
  49. package/es6-modern/findNumbers/RegExpCache.js.map +1 -0
  50. package/es6-modern/findNumbers/isValidCandidate.js +66 -0
  51. package/es6-modern/findNumbers/isValidCandidate.js.map +1 -0
  52. package/es6-modern/findNumbers/isValidPreCandidate.js +26 -0
  53. package/es6-modern/findNumbers/isValidPreCandidate.js.map +1 -0
  54. package/es6-modern/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js +63 -0
  55. package/es6-modern/findNumbers/matchPhoneNumberStringAgainstPhoneNumber.js.map +1 -0
  56. package/es6-modern/findNumbers/parsePreCandidate.js +18 -0
  57. package/es6-modern/findNumbers/parsePreCandidate.js.map +1 -0
  58. package/es6-modern/findNumbers/utf-8.js +63 -0
  59. package/es6-modern/findNumbers/utf-8.js.map +1 -0
  60. package/es6-modern/findNumbers/util.js +26 -0
  61. package/es6-modern/findNumbers/util.js.map +1 -0
  62. package/es6-modern/findNumbers/util.test.js.map +1 -0
  63. package/es6-modern/findPhoneNumbersInText.js +19 -0
  64. package/es6-modern/findPhoneNumbersInText.js.map +1 -0
  65. package/es6-modern/findPhoneNumbersInText.test.js.map +1 -0
  66. package/es6-modern/format.js +204 -0
  67. package/es6-modern/format.js.map +1 -0
  68. package/es6-modern/format.test.js.map +1 -0
  69. package/es6-modern/formatIncompletePhoneNumber.js +18 -0
  70. package/es6-modern/formatIncompletePhoneNumber.js.map +1 -0
  71. package/es6-modern/formatIncompletePhoneNumber.test.js.map +1 -0
  72. package/es6-modern/formatPhoneNumberForMobileDialing.js +190 -0
  73. package/es6-modern/formatPhoneNumberForMobileDialing.js.map +1 -0
  74. package/es6-modern/getCountries.js +5 -0
  75. package/es6-modern/getCountries.js.map +1 -0
  76. package/es6-modern/getCountries.test.js.map +1 -0
  77. package/es6-modern/getCountryCallingCode.js +3 -0
  78. package/es6-modern/getCountryCallingCode.js.map +1 -0
  79. package/es6-modern/getCountryCallingCode.test.js.map +1 -0
  80. package/es6-modern/getExampleNumber.js +7 -0
  81. package/es6-modern/getExampleNumber.js.map +1 -0
  82. package/es6-modern/getExampleNumber.test.js.map +1 -0
  83. package/es6-modern/helpers/RFC3966.js +63 -0
  84. package/es6-modern/helpers/RFC3966.js.map +1 -0
  85. package/es6-modern/helpers/RFC3966.test.js.map +1 -0
  86. package/es6-modern/helpers/applyInternationalSeparatorStyle.js +36 -0
  87. package/es6-modern/helpers/applyInternationalSeparatorStyle.js.map +1 -0
  88. package/es6-modern/helpers/applyInternationalSeparatorStyle.test.js.map +1 -0
  89. package/es6-modern/helpers/checkNumberLength.js +112 -0
  90. package/es6-modern/helpers/checkNumberLength.js.map +1 -0
  91. package/es6-modern/helpers/checkNumberLength.test.js.map +1 -0
  92. package/es6-modern/helpers/extension/createExtensionPattern.js +93 -0
  93. package/es6-modern/helpers/extension/createExtensionPattern.js.map +1 -0
  94. package/es6-modern/helpers/extension/extractExtension.js +30 -0
  95. package/es6-modern/helpers/extension/extractExtension.js.map +1 -0
  96. package/es6-modern/helpers/extractCountryCallingCode.js +142 -0
  97. package/es6-modern/helpers/extractCountryCallingCode.js.map +1 -0
  98. package/es6-modern/helpers/extractCountryCallingCode.test.js.map +1 -0
  99. package/es6-modern/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +49 -0
  100. package/es6-modern/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map +1 -0
  101. package/es6-modern/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +66 -0
  102. package/es6-modern/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js.map +1 -0
  103. package/es6-modern/helpers/extractNationalNumber.js +117 -0
  104. package/es6-modern/helpers/extractNationalNumber.js.map +1 -0
  105. package/es6-modern/helpers/extractNationalNumber.test.js.map +1 -0
  106. package/es6-modern/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +102 -0
  107. package/es6-modern/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js.map +1 -0
  108. package/es6-modern/helpers/extractNationalNumberFromPossiblyIncompleteNumber.test.js.map +1 -0
  109. package/es6-modern/helpers/extractPhoneContext.js +82 -0
  110. package/es6-modern/helpers/extractPhoneContext.js.map +1 -0
  111. package/es6-modern/helpers/extractPhoneContext.test.js.map +1 -0
  112. package/es6-modern/helpers/formatNationalNumberUsingFormat.js +34 -0
  113. package/es6-modern/helpers/formatNationalNumberUsingFormat.js.map +1 -0
  114. package/es6-modern/helpers/getCountryByCallingCode.js +30 -0
  115. package/es6-modern/helpers/getCountryByCallingCode.js.map +1 -0
  116. package/es6-modern/helpers/getCountryByNationalNumber.js +76 -0
  117. package/es6-modern/helpers/getCountryByNationalNumber.js.map +1 -0
  118. package/es6-modern/helpers/getIddPrefix.js +26 -0
  119. package/es6-modern/helpers/getIddPrefix.js.map +1 -0
  120. package/es6-modern/helpers/getNumberType.js +81 -0
  121. package/es6-modern/helpers/getNumberType.js.map +1 -0
  122. package/es6-modern/helpers/getNumberType.test.js.map +1 -0
  123. package/es6-modern/helpers/getPossibleCountriesForNumber.js +28 -0
  124. package/es6-modern/helpers/getPossibleCountriesForNumber.js.map +1 -0
  125. package/es6-modern/helpers/isObject.js +5 -0
  126. package/es6-modern/helpers/isObject.js.map +1 -0
  127. package/es6-modern/helpers/isViablePhoneNumber.js +77 -0
  128. package/es6-modern/helpers/isViablePhoneNumber.js.map +1 -0
  129. package/es6-modern/helpers/matchesEntirely.js +12 -0
  130. package/es6-modern/helpers/matchesEntirely.js.map +1 -0
  131. package/es6-modern/helpers/matchesEntirely.test.js.map +1 -0
  132. package/es6-modern/helpers/mergeArrays.js +23 -0
  133. package/es6-modern/helpers/mergeArrays.js.map +1 -0
  134. package/es6-modern/helpers/mergeArrays.test.js.map +1 -0
  135. package/es6-modern/helpers/parseDigits.js +111 -0
  136. package/es6-modern/helpers/parseDigits.js.map +1 -0
  137. package/es6-modern/helpers/parseDigits.test.js.map +1 -0
  138. package/es6-modern/helpers/stripIddPrefix.js +29 -0
  139. package/es6-modern/helpers/stripIddPrefix.js.map +1 -0
  140. package/es6-modern/helpers/stripIddPrefix.test.js.map +1 -0
  141. package/es6-modern/isPossible.js +77 -0
  142. package/es6-modern/isPossible.js.map +1 -0
  143. package/es6-modern/isPossible.test.js.map +1 -0
  144. package/es6-modern/isPossiblePhoneNumber.js +16 -0
  145. package/es6-modern/isPossiblePhoneNumber.js.map +1 -0
  146. package/es6-modern/isPossiblePhoneNumber.test.js.map +1 -0
  147. package/es6-modern/isValid.js +57 -0
  148. package/es6-modern/isValid.js.map +1 -0
  149. package/es6-modern/isValid.test.js.map +1 -0
  150. package/es6-modern/isValidPhoneNumber.js +16 -0
  151. package/es6-modern/isValidPhoneNumber.js.map +1 -0
  152. package/es6-modern/isValidPhoneNumber.test.js.map +1 -0
  153. package/es6-modern/legacy/PhoneNumberSearch.js +109 -0
  154. package/es6-modern/legacy/PhoneNumberSearch.js.map +1 -0
  155. package/es6-modern/legacy/findNumbers.js +16 -0
  156. package/es6-modern/legacy/findNumbers.js.map +1 -0
  157. package/es6-modern/legacy/findNumbers.test.js.map +1 -0
  158. package/es6-modern/legacy/findPhoneNumbers.js +26 -0
  159. package/es6-modern/legacy/findPhoneNumbers.js.map +1 -0
  160. package/es6-modern/legacy/findPhoneNumbers.test.js.map +1 -0
  161. package/es6-modern/legacy/findPhoneNumbersInitialImplementation.js +79 -0
  162. package/es6-modern/legacy/findPhoneNumbersInitialImplementation.js.map +1 -0
  163. package/es6-modern/legacy/format.js +97 -0
  164. package/es6-modern/legacy/format.js.map +1 -0
  165. package/es6-modern/legacy/format.test.js.map +1 -0
  166. package/es6-modern/legacy/getNumberType.js +104 -0
  167. package/es6-modern/legacy/getNumberType.js.map +1 -0
  168. package/es6-modern/legacy/getNumberType.test.js.map +1 -0
  169. package/es6-modern/legacy/isPossibleNumber.js +30 -0
  170. package/es6-modern/legacy/isPossibleNumber.js.map +1 -0
  171. package/es6-modern/legacy/isPossibleNumber.test.js.map +1 -0
  172. package/es6-modern/legacy/isValidNumber.js +17 -0
  173. package/es6-modern/legacy/isValidNumber.js.map +1 -0
  174. package/es6-modern/legacy/isValidNumber.test.js.map +1 -0
  175. package/es6-modern/legacy/isValidNumberForRegion.js +65 -0
  176. package/es6-modern/legacy/isValidNumberForRegion.js.map +1 -0
  177. package/es6-modern/legacy/isValidNumberForRegion.test.js.map +1 -0
  178. package/es6-modern/legacy/isValidNumberForRegion_.js +14 -0
  179. package/es6-modern/legacy/isValidNumberForRegion_.js.map +1 -0
  180. package/es6-modern/legacy/parse.js +11 -0
  181. package/es6-modern/legacy/parse.js.map +1 -0
  182. package/es6-modern/legacy/parse.test.js.map +1 -0
  183. package/es6-modern/legacy/searchNumbers.js +32 -0
  184. package/es6-modern/legacy/searchNumbers.js.map +1 -0
  185. package/es6-modern/legacy/searchNumbers.test.js.map +1 -0
  186. package/es6-modern/metadata.js +494 -0
  187. package/es6-modern/metadata.js.map +1 -0
  188. package/es6-modern/metadata.test.js.map +1 -0
  189. package/es6-modern/normalizeArguments.js +52 -0
  190. package/es6-modern/normalizeArguments.js.map +1 -0
  191. package/es6-modern/parse.js +341 -0
  192. package/es6-modern/parse.js.map +1 -0
  193. package/es6-modern/parse.test.js.map +1 -0
  194. package/es6-modern/parseIncompletePhoneNumber.js +70 -0
  195. package/es6-modern/parseIncompletePhoneNumber.js.map +1 -0
  196. package/es6-modern/parseIncompletePhoneNumber.test.js.map +1 -0
  197. package/es6-modern/parsePhoneNumber.js +11 -0
  198. package/es6-modern/parsePhoneNumber.js.map +1 -0
  199. package/es6-modern/parsePhoneNumber.test.js.map +1 -0
  200. package/es6-modern/parsePhoneNumberWithError.js +11 -0
  201. package/es6-modern/parsePhoneNumberWithError.js.map +1 -0
  202. package/es6-modern/parsePhoneNumberWithError.test.js.map +1 -0
  203. package/es6-modern/parsePhoneNumberWithError_.js +8 -0
  204. package/es6-modern/parsePhoneNumberWithError_.js.map +1 -0
  205. package/es6-modern/parsePhoneNumber_.js +24 -0
  206. package/es6-modern/parsePhoneNumber_.js.map +1 -0
  207. package/es6-modern/searchPhoneNumbersInText.js +31 -0
  208. package/es6-modern/searchPhoneNumbersInText.js.map +1 -0
  209. package/es6-modern/searchPhoneNumbersInText.test.js.map +1 -0
  210. package/es6-modern/tools/semver-compare.js +27 -0
  211. package/es6-modern/tools/semver-compare.js.map +1 -0
  212. package/es6-modern/tools/semver-compare.test.js.map +1 -0
  213. package/es6-modern/validatePhoneNumberLength.js +35 -0
  214. package/es6-modern/validatePhoneNumberLength.js.map +1 -0
  215. package/es6-modern/validatePhoneNumberLength.test.js.map +1 -0
  216. package/index.cjs +4 -0
  217. package/index.cjs.js +4 -0
  218. package/index.d.cts +5 -3
  219. package/index.d.ts +5 -3
  220. package/index.js +5 -0
  221. package/max/es6/exports/AsYouType.js +11 -0
  222. package/max/es6/exports/Metadata.js +11 -0
  223. package/max/es6/exports/PhoneNumber.js +11 -0
  224. package/max/es6/exports/PhoneNumberMatcher.js +11 -0
  225. package/max/es6/exports/findNumbers.js +6 -0
  226. package/max/es6/exports/findPhoneNumbersInText.js +6 -0
  227. package/max/es6/exports/formatIncompletePhoneNumber.js +6 -0
  228. package/max/es6/exports/getCountries.js +6 -0
  229. package/max/es6/exports/getCountryCallingCode.js +6 -0
  230. package/max/es6/exports/getExampleNumber.js +6 -0
  231. package/max/es6/exports/getExtPrefix.js +6 -0
  232. package/max/es6/exports/isPossiblePhoneNumber.js +6 -0
  233. package/max/es6/exports/isSupportedCountry.js +6 -0
  234. package/max/es6/exports/isValidPhoneNumber.js +6 -0
  235. package/max/es6/exports/parsePhoneNumber.js +7 -0
  236. package/max/es6/exports/parsePhoneNumberWithError.js +7 -0
  237. package/max/es6/exports/searchNumbers.js +6 -0
  238. package/max/es6/exports/searchPhoneNumbersInText.js +6 -0
  239. package/max/es6/exports/validatePhoneNumberLength.js +6 -0
  240. package/max/es6/exports/withMetadataArgument.js +13 -0
  241. package/max/es6/index.d.cts +2 -0
  242. package/max/es6/index.d.ts +2 -0
  243. package/max/es6/index.js +44 -0
  244. package/max/es6/package.json +12 -0
  245. package/max/index.cjs +5 -0
  246. package/max/index.cjs.js +5 -0
  247. package/max/index.d.cts +3 -1
  248. package/max/index.d.ts +3 -1
  249. package/max/index.js +4 -0
  250. package/min/es6/exports/AsYouType.js +11 -0
  251. package/min/es6/exports/Metadata.js +11 -0
  252. package/min/es6/exports/PhoneNumber.js +11 -0
  253. package/min/es6/exports/PhoneNumberMatcher.js +11 -0
  254. package/min/es6/exports/findNumbers.js +6 -0
  255. package/min/es6/exports/findPhoneNumbersInText.js +6 -0
  256. package/min/es6/exports/formatIncompletePhoneNumber.js +6 -0
  257. package/min/es6/exports/getCountries.js +6 -0
  258. package/min/es6/exports/getCountryCallingCode.js +6 -0
  259. package/min/es6/exports/getExampleNumber.js +6 -0
  260. package/min/es6/exports/getExtPrefix.js +6 -0
  261. package/min/es6/exports/isPossiblePhoneNumber.js +6 -0
  262. package/min/es6/exports/isSupportedCountry.js +6 -0
  263. package/min/es6/exports/isValidPhoneNumber.js +6 -0
  264. package/min/es6/exports/parsePhoneNumber.js +7 -0
  265. package/min/es6/exports/parsePhoneNumberWithError.js +7 -0
  266. package/min/es6/exports/searchNumbers.js +6 -0
  267. package/min/es6/exports/searchPhoneNumbersInText.js +6 -0
  268. package/min/es6/exports/validatePhoneNumberLength.js +6 -0
  269. package/min/es6/exports/withMetadataArgument.js +13 -0
  270. package/min/es6/index.d.cts +2 -0
  271. package/min/es6/index.d.ts +2 -0
  272. package/min/es6/index.js +44 -0
  273. package/min/es6/package.json +12 -0
  274. package/min/index.cjs +5 -0
  275. package/min/index.cjs.js +5 -0
  276. package/min/index.d.cts +3 -1
  277. package/min/index.d.ts +3 -1
  278. package/min/index.js +3 -0
  279. package/mobile/es6/exports/AsYouType.js +11 -0
  280. package/mobile/es6/exports/Metadata.js +11 -0
  281. package/mobile/es6/exports/PhoneNumber.js +11 -0
  282. package/mobile/es6/exports/PhoneNumberMatcher.js +11 -0
  283. package/mobile/es6/exports/findNumbers.js +6 -0
  284. package/mobile/es6/exports/findPhoneNumbersInText.js +6 -0
  285. package/mobile/es6/exports/formatIncompletePhoneNumber.js +6 -0
  286. package/mobile/es6/exports/getCountries.js +6 -0
  287. package/mobile/es6/exports/getCountryCallingCode.js +6 -0
  288. package/mobile/es6/exports/getExampleNumber.js +6 -0
  289. package/mobile/es6/exports/getExtPrefix.js +6 -0
  290. package/mobile/es6/exports/isPossiblePhoneNumber.js +6 -0
  291. package/mobile/es6/exports/isSupportedCountry.js +6 -0
  292. package/mobile/es6/exports/isValidPhoneNumber.js +6 -0
  293. package/mobile/es6/exports/parsePhoneNumber.js +7 -0
  294. package/mobile/es6/exports/parsePhoneNumberWithError.js +7 -0
  295. package/mobile/es6/exports/searchNumbers.js +6 -0
  296. package/mobile/es6/exports/searchPhoneNumbersInText.js +6 -0
  297. package/mobile/es6/exports/validatePhoneNumberLength.js +6 -0
  298. package/mobile/es6/exports/withMetadataArgument.js +13 -0
  299. package/mobile/es6/index.d.cts +2 -0
  300. package/mobile/es6/index.d.ts +2 -0
  301. package/mobile/es6/index.js +44 -0
  302. package/mobile/es6/package.json +12 -0
  303. package/mobile/index.cjs +5 -0
  304. package/mobile/index.cjs.js +5 -0
  305. package/mobile/index.d.cts +3 -1
  306. package/mobile/index.d.ts +3 -1
  307. package/mobile/index.js +4 -0
  308. package/package.json +28 -9
  309. package/types.d.cts +54 -21
  310. package/types.d.ts +54 -21
package/custom.js CHANGED
@@ -57,11 +57,11 @@ exports.parseDigits = require('./build/helpers/parseDigits.js').default
57
57
 
58
58
  // Deprecated: `DIGITS` were used by `react-phone-number-input`.
59
59
  // Replaced by `parseDigits()`.
60
- //
61
- // Deprecated: `DIGIT_PLACEHOLDER` was used by `react-phone-number-input`.
62
- // Not used anymore.
63
- //
64
- exports.DIGITS = require('./build/helpers/parseDigits.js').DIGITS
60
+ exports.DIGITS = require('./build/helpers/parseDigits.js').DIGITS
61
+ // Deprecated:
62
+ // `DIGIT_PLACEHOLDER` is the character that `AsYouType` formatter uses in a phone number template.
63
+ // It's basically an "x" character. I guess, there's no point in exporting it as a constant
64
+ // because the established convention is that it's an "x" character so everyone just assumes "x".
65
65
  exports.DIGIT_PLACEHOLDER = require('./build/AsYouTypeFormatter.js').DIGIT_PLACEHOLDER
66
66
 
67
67
  exports.getCountries = require('./build/getCountries.js').default
@@ -0,0 +1,445 @@
1
+ import Metadata from './metadata.js';
2
+ import PhoneNumber from './PhoneNumber.js';
3
+ import AsYouTypeState from './AsYouTypeState.js';
4
+ import AsYouTypeFormatter, { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.js';
5
+ import AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser.js';
6
+ import getCountryByCallingCode from './helpers/getCountryByCallingCode.js';
7
+ import getCountryByNationalNumber from './helpers/getCountryByNationalNumber.js';
8
+ import isObject from './helpers/isObject.js';
9
+ const USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
10
+ export default class AsYouType {
11
+ /**
12
+ * @param {(string|object)?} [optionsOrDefaultCountry] - The default country used for parsing non-international phone numbers. Can also be an `options` object.
13
+ * @param {Object} metadata
14
+ */
15
+ constructor(optionsOrDefaultCountry, metadata) {
16
+ this.metadata = new Metadata(metadata);
17
+ const [defaultCountry, defaultCallingCode] = this.getCountryAndCallingCode(optionsOrDefaultCountry);
18
+ // `this.defaultCountry` and `this.defaultCallingCode` aren't required to be in sync.
19
+ // For example, `this.defaultCountry` could be `"AR"` and `this.defaultCallingCode` could be `undefined`.
20
+ // So `this.defaultCountry` and `this.defaultCallingCode` are totally independent.
21
+ this.defaultCountry = defaultCountry;
22
+ this.defaultCallingCode = defaultCallingCode;
23
+ this.reset();
24
+ }
25
+ getCountryAndCallingCode(optionsOrDefaultCountry) {
26
+ // Set `defaultCountry` and `defaultCallingCode` options.
27
+ let defaultCountry;
28
+ let defaultCallingCode;
29
+ // Turns out `null` also has type "object". Weird.
30
+ if (optionsOrDefaultCountry) {
31
+ if (isObject(optionsOrDefaultCountry)) {
32
+ defaultCountry = optionsOrDefaultCountry.defaultCountry;
33
+ defaultCallingCode = optionsOrDefaultCountry.defaultCallingCode;
34
+ } else {
35
+ defaultCountry = optionsOrDefaultCountry;
36
+ }
37
+ }
38
+ if (defaultCountry && !this.metadata.hasCountry(defaultCountry)) {
39
+ defaultCountry = undefined;
40
+ }
41
+ if (defaultCallingCode) {
42
+ /* istanbul ignore if */
43
+ if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
44
+ if (this.metadata.isNonGeographicCallingCode(defaultCallingCode)) {
45
+ defaultCountry = '001';
46
+ }
47
+ }
48
+ }
49
+ return [defaultCountry, defaultCallingCode];
50
+ }
51
+
52
+ /**
53
+ * Inputs "next" phone number characters.
54
+ * @param {string} text
55
+ * @return {string} Formatted phone number characters that have been input so far.
56
+ */
57
+ input(text) {
58
+ const {
59
+ digits,
60
+ justLeadingPlus
61
+ } = this.parser.input(text, this.state);
62
+ if (justLeadingPlus) {
63
+ this.formattedOutput = '+';
64
+ } else if (digits) {
65
+ this.determineTheCountryIfNeeded();
66
+ // Match the available formats by the currently available leading digits.
67
+ if (this.state.nationalSignificantNumber) {
68
+ this.formatter.narrowDownMatchingFormats(this.state);
69
+ }
70
+ let formattedNationalNumber;
71
+ if (this.metadata.hasSelectedNumberingPlan()) {
72
+ formattedNationalNumber = this.formatter.format(digits, this.state);
73
+ }
74
+ if (formattedNationalNumber === undefined) {
75
+ // See if another national (significant) number could be re-extracted.
76
+ if (this.parser.reExtractNationalSignificantNumber(this.state)) {
77
+ this.determineTheCountryIfNeeded();
78
+ // If it could, then re-try formatting the new national (significant) number.
79
+ const nationalDigits = this.state.getNationalDigits();
80
+ if (nationalDigits) {
81
+ formattedNationalNumber = this.formatter.format(nationalDigits, this.state);
82
+ }
83
+ }
84
+ }
85
+ this.formattedOutput = formattedNationalNumber ? this.getFullNumber(formattedNationalNumber) : this.getNonFormattedNumber();
86
+ }
87
+ return this.formattedOutput;
88
+ }
89
+ reset() {
90
+ this.state = new AsYouTypeState({
91
+ onCountryChange: country => {
92
+ // Before version `1.6.0`, the official `AsYouType` formatter API
93
+ // included a `.country` property on an `AsYouType` instance.
94
+ // Since that property (along with the others) have been moved to
95
+ // `this.state`, `this.country` property is emulated for compatibility
96
+ // with the old versions.
97
+ this.country = country;
98
+ },
99
+ onCallingCodeChange: (callingCode, country) => {
100
+ this.metadata.selectNumberingPlan(country, callingCode);
101
+ this.formatter.reset(this.metadata.numberingPlan, this.state);
102
+ this.parser.reset(this.metadata.numberingPlan);
103
+ }
104
+ });
105
+ this.formatter = new AsYouTypeFormatter({
106
+ state: this.state,
107
+ metadata: this.metadata
108
+ });
109
+ this.parser = new AsYouTypeParser({
110
+ defaultCountry: this.defaultCountry,
111
+ defaultCallingCode: this.defaultCallingCode,
112
+ metadata: this.metadata,
113
+ state: this.state,
114
+ onNationalSignificantNumberChange: () => {
115
+ this.determineTheCountryIfNeeded();
116
+ this.formatter.reset(this.metadata.numberingPlan, this.state);
117
+ }
118
+ });
119
+ this.state.reset({
120
+ country: this.defaultCountry,
121
+ callingCode: this.defaultCallingCode
122
+ });
123
+ this.formattedOutput = '';
124
+ return this;
125
+ }
126
+
127
+ /**
128
+ * Returns `true` if the phone number is being input in international format.
129
+ * In other words, returns `true` if and only if the parsed phone number starts with a `"+"`.
130
+ * @return {boolean}
131
+ */
132
+ isInternational() {
133
+ return this.state.international;
134
+ }
135
+
136
+ /**
137
+ * Returns the "calling code" part of the phone number when it's being input
138
+ * in an international format.
139
+ * If no valid calling code has been entered so far, returns `undefined`.
140
+ * @return {string} [callingCode]
141
+ */
142
+ getCallingCode() {
143
+ // If the number is being input in national format and some "default calling code"
144
+ // has been passed to `AsYouType` constructor, then `this.state.callingCode`
145
+ // is equal to that "default calling code".
146
+ //
147
+ // If the number is being input in national format and no "default calling code"
148
+ // has been passed to `AsYouType` constructor, then returns `undefined`,
149
+ // even if a "default country" has been passed to `AsYouType` constructor.
150
+ //
151
+ if (this.isInternational()) {
152
+ return this.state.callingCode;
153
+ }
154
+ }
155
+
156
+ // A legacy alias.
157
+ getCountryCallingCode() {
158
+ return this.getCallingCode();
159
+ }
160
+
161
+ /**
162
+ * Returns a two-letter country code of the phone number.
163
+ * Returns `undefined` for "non-geographic" phone numbering plans.
164
+ * Returns `undefined` if no phone number has been input yet.
165
+ * @return {string} [country]
166
+ */
167
+ getCountry() {
168
+ const {
169
+ digits
170
+ } = this.state;
171
+ // Return `undefined` if no digits have been input yet.
172
+ if (digits) {
173
+ return this._getCountry();
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Returns a two-letter country code of the phone number.
179
+ * Returns `undefined` for "non-geographic" phone numbering plans.
180
+ * @return {string} [country]
181
+ */
182
+ _getCountry() {
183
+ const {
184
+ country
185
+ } = this.state;
186
+ /* istanbul ignore if */
187
+ if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
188
+ // `AsYouType.getCountry()` returns `undefined`
189
+ // for "non-geographic" phone numbering plans.
190
+ if (country === '001') {
191
+ return;
192
+ }
193
+ }
194
+ return country;
195
+ }
196
+ determineTheCountryIfNeeded() {
197
+ // Suppose a user enters a phone number in international format,
198
+ // and there're several countries corresponding to that country calling code,
199
+ // and a country has been derived from the number, and then
200
+ // a user enters one more digit and the number is no longer
201
+ // valid for the derived country, so the country should be re-derived
202
+ // on every new digit in those cases.
203
+ //
204
+ // If the phone number is being input in national format,
205
+ // then it could be a case when `defaultCountry` wasn't specified
206
+ // when creating `AsYouType` instance, and just `defaultCallingCode` was specified,
207
+ // and that "calling code" could correspond to a "non-geographic entity",
208
+ // or there could be several countries corresponding to that country calling code.
209
+ // In those cases, `this.country` is `undefined` and should be derived
210
+ // from the number. Again, if country calling code is ambiguous, then
211
+ // `this.country` should be re-derived with each new digit.
212
+ //
213
+ if (!this.state.country || this.isCountryCallingCodeAmbiguous()) {
214
+ this.determineTheCountry();
215
+ }
216
+ }
217
+
218
+ // Prepends `+CountryCode ` in case of an international phone number
219
+ getFullNumber(formattedNationalNumber) {
220
+ if (this.isInternational()) {
221
+ const prefix = text => this.formatter.getInternationalPrefixBeforeCountryCallingCode(this.state, {
222
+ spacing: text ? true : false
223
+ }) + text;
224
+ const {
225
+ callingCode
226
+ } = this.state;
227
+ if (!callingCode) {
228
+ return prefix(`${this.state.getDigitsWithoutInternationalPrefix()}`);
229
+ }
230
+ if (!formattedNationalNumber) {
231
+ return prefix(callingCode);
232
+ }
233
+ return prefix(`${callingCode} ${formattedNationalNumber}`);
234
+ }
235
+ return formattedNationalNumber;
236
+ }
237
+ getNonFormattedNationalNumberWithPrefix() {
238
+ const {
239
+ nationalSignificantNumber,
240
+ prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,
241
+ nationalPrefix
242
+ } = this.state;
243
+ let number = nationalSignificantNumber;
244
+ const prefix = prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix || nationalPrefix;
245
+ if (prefix) {
246
+ number = prefix + number;
247
+ }
248
+ return number;
249
+ }
250
+ getNonFormattedNumber() {
251
+ const {
252
+ nationalSignificantNumberIsModified
253
+ } = this.state;
254
+ return this.getFullNumber(nationalSignificantNumberIsModified ? this.state.getNationalDigits() : this.getNonFormattedNationalNumberWithPrefix());
255
+ }
256
+ getNonFormattedTemplate() {
257
+ const number = this.getNonFormattedNumber();
258
+ if (number) {
259
+ return number.replace(/[\+\d]/g, DIGIT_PLACEHOLDER);
260
+ }
261
+ }
262
+ isCountryCallingCodeAmbiguous() {
263
+ const {
264
+ callingCode
265
+ } = this.state;
266
+ const countryCodes = this.metadata.getCountryCodesForCallingCode(callingCode);
267
+ return countryCodes && countryCodes.length > 1;
268
+ }
269
+
270
+ // Determines the exact country of the phone number
271
+ // entered so far based on the country phone code
272
+ // and the national phone number.
273
+ determineTheCountry() {
274
+ this.state.setCountry(getCountryByCallingCode(this.isInternational() ? this.state.callingCode : this.defaultCallingCode, {
275
+ nationalNumber: this.state.nationalSignificantNumber,
276
+ metadata: this.metadata
277
+ }));
278
+ }
279
+
280
+ /**
281
+ * Returns a E.164 phone number value for the user's input.
282
+ *
283
+ * For example, for country `"US"` and input `"(222) 333-4444"`
284
+ * it will return `"+12223334444"`.
285
+ *
286
+ * For international phone number input, it will also auto-correct
287
+ * some minor errors such as using a national prefix when writing
288
+ * an international phone number. For example, if the user inputs
289
+ * `"+44 0 7400 000000"` then it will return an auto-corrected
290
+ * `"+447400000000"` phone number value.
291
+ *
292
+ * Will return `undefined` if no digits have been input,
293
+ * or when inputting a phone number in national format and no
294
+ * default country or default "country calling code" have been set.
295
+ *
296
+ * @return {string} [value]
297
+ */
298
+ getNumberValue() {
299
+ const {
300
+ digits,
301
+ callingCode,
302
+ country,
303
+ nationalSignificantNumber
304
+ } = this.state;
305
+
306
+ // Will return `undefined` if no digits have been input.
307
+ if (!digits) {
308
+ return;
309
+ }
310
+ if (this.isInternational()) {
311
+ if (callingCode) {
312
+ return '+' + callingCode + nationalSignificantNumber;
313
+ } else {
314
+ return '+' + digits;
315
+ }
316
+ } else {
317
+ if (country || callingCode) {
318
+ const callingCode_ = country ? this.metadata.countryCallingCode() : callingCode;
319
+ return '+' + callingCode_ + nationalSignificantNumber;
320
+ }
321
+ }
322
+ }
323
+
324
+ /**
325
+ * Returns an instance of `PhoneNumber` class.
326
+ * Will return `undefined` if no national (significant) number
327
+ * digits have been entered so far, or if no `defaultCountry` has been
328
+ * set and the user enters a phone number not in international format.
329
+ */
330
+ getNumber() {
331
+ const {
332
+ nationalSignificantNumber,
333
+ carrierCode,
334
+ callingCode
335
+ } = this.state;
336
+
337
+ // `this._getCountry()` is basically same as `this.state.country`
338
+ // with the only change that it return `undefined` in case of a
339
+ // "non-geographic" numbering plan instead of `"001"` "internal use" value.
340
+ let country = this._getCountry();
341
+ if (!nationalSignificantNumber) {
342
+ return;
343
+ }
344
+
345
+ // `state.country` and `state.callingCode` aren't required to be in sync.
346
+ // For example, `country` could be `"AR"` and `callingCode` could be `undefined`.
347
+ // So `country` and `callingCode` are totally independent.
348
+
349
+ if (!country && !callingCode) {
350
+ return;
351
+ }
352
+
353
+ // By default, if `defaultCountry` parameter was passed when
354
+ // creating `AsYouType` instance, `state.country` is gonna be
355
+ // that `defaultCountry`, which doesn't entirely conform with
356
+ // `parsePhoneNumber()`'s behavior where it attempts to determine
357
+ // the country more precisely in cases when multiple countries
358
+ // could correspond to the same `countryCallingCode`.
359
+ // https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/103#note_1417192969
360
+ //
361
+ // Because `AsYouType.getNumber()` method is supposed to be a 1:1
362
+ // equivalent for `parsePhoneNumber(AsYouType.getNumberValue())`,
363
+ // then it should also behave accordingly in cases of `country` ambiguity.
364
+ // That's how users of this library would expect it to behave anyway.
365
+ //
366
+ if (country) {
367
+ if (country === this.defaultCountry) {
368
+ // `state.country` and `state.callingCode` aren't required to be in sync.
369
+ // For example, `state.country` could be `"AR"` and `state.callingCode` could be `undefined`.
370
+ // So `state.country` and `state.callingCode` are totally independent.
371
+ const metadata = new Metadata(this.metadata.metadata);
372
+ metadata.selectNumberingPlan(country);
373
+ const _callingCode = metadata.numberingPlan.callingCode();
374
+ const ambiguousCountries = this.metadata.getCountryCodesForCallingCode(_callingCode);
375
+ if (ambiguousCountries.length > 1) {
376
+ const exactCountry = getCountryByNationalNumber(nationalSignificantNumber, {
377
+ countries: ambiguousCountries,
378
+ metadata: this.metadata.metadata
379
+ });
380
+ if (exactCountry) {
381
+ country = exactCountry;
382
+ }
383
+ }
384
+ }
385
+ }
386
+ const phoneNumber = new PhoneNumber(country || callingCode, nationalSignificantNumber, this.metadata.metadata);
387
+ if (carrierCode) {
388
+ phoneNumber.carrierCode = carrierCode;
389
+ }
390
+ // Phone number extensions are not supported by "As You Type" formatter.
391
+ return phoneNumber;
392
+ }
393
+
394
+ /**
395
+ * Returns `true` if the phone number is "possible".
396
+ * Is just a shortcut for `PhoneNumber.isPossible()`.
397
+ * @return {boolean}
398
+ */
399
+ isPossible() {
400
+ const phoneNumber = this.getNumber();
401
+ if (!phoneNumber) {
402
+ return false;
403
+ }
404
+ return phoneNumber.isPossible();
405
+ }
406
+
407
+ /**
408
+ * Returns `true` if the phone number is "valid".
409
+ * Is just a shortcut for `PhoneNumber.isValid()`.
410
+ * @return {boolean}
411
+ */
412
+ isValid() {
413
+ const phoneNumber = this.getNumber();
414
+ if (!phoneNumber) {
415
+ return false;
416
+ }
417
+ return phoneNumber.isValid();
418
+ }
419
+
420
+ /**
421
+ * @deprecated
422
+ * This method is used in `react-phone-number-input/source/input-control.js`
423
+ * in versions before `3.0.16`.
424
+ */
425
+ getNationalNumber() {
426
+ return this.state.nationalSignificantNumber;
427
+ }
428
+
429
+ /**
430
+ * Returns the phone number characters entered by the user.
431
+ * @return {string}
432
+ */
433
+ getChars() {
434
+ return (this.state.international ? '+' : '') + this.state.digits;
435
+ }
436
+
437
+ /**
438
+ * Returns the template for the formatted phone number.
439
+ * @return {string}
440
+ */
441
+ getTemplate() {
442
+ return this.formatter.getTemplate(this.state) || this.getNonFormattedTemplate() || '';
443
+ }
444
+ }
445
+ //# sourceMappingURL=AsYouType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsYouType.js","names":["Metadata","PhoneNumber","AsYouTypeState","AsYouTypeFormatter","DIGIT_PLACEHOLDER","AsYouTypeParser","extractFormattedDigitsAndPlus","getCountryByCallingCode","getCountryByNationalNumber","isObject","USE_NON_GEOGRAPHIC_COUNTRY_CODE","AsYouType","constructor","optionsOrDefaultCountry","metadata","defaultCountry","defaultCallingCode","getCountryAndCallingCode","reset","hasCountry","undefined","isNonGeographicCallingCode","input","text","digits","justLeadingPlus","parser","state","formattedOutput","determineTheCountryIfNeeded","nationalSignificantNumber","formatter","narrowDownMatchingFormats","formattedNationalNumber","hasSelectedNumberingPlan","format","reExtractNationalSignificantNumber","nationalDigits","getNationalDigits","getFullNumber","getNonFormattedNumber","onCountryChange","country","onCallingCodeChange","callingCode","selectNumberingPlan","numberingPlan","onNationalSignificantNumberChange","isInternational","international","getCallingCode","getCountryCallingCode","getCountry","_getCountry","isCountryCallingCodeAmbiguous","determineTheCountry","prefix","getInternationalPrefixBeforeCountryCallingCode","spacing","getDigitsWithoutInternationalPrefix","getNonFormattedNationalNumberWithPrefix","prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix","nationalPrefix","number","nationalSignificantNumberIsModified","getNonFormattedTemplate","replace","countryCodes","getCountryCodesForCallingCode","length","setCountry","nationalNumber","getNumberValue","callingCode_","countryCallingCode","getNumber","carrierCode","ambiguousCountries","exactCountry","countries","phoneNumber","isPossible","isValid","getNationalNumber","getChars","getTemplate"],"sources":["../source/AsYouType.js"],"sourcesContent":["import Metadata from './metadata.js'\r\nimport PhoneNumber from './PhoneNumber.js'\r\nimport AsYouTypeState from './AsYouTypeState.js'\r\nimport AsYouTypeFormatter, { DIGIT_PLACEHOLDER } from './AsYouTypeFormatter.js'\r\nimport AsYouTypeParser, { extractFormattedDigitsAndPlus } from './AsYouTypeParser.js'\r\nimport getCountryByCallingCode from './helpers/getCountryByCallingCode.js'\r\nimport getCountryByNationalNumber from './helpers/getCountryByNationalNumber.js'\r\nimport isObject from './helpers/isObject.js'\r\n\r\nconst USE_NON_GEOGRAPHIC_COUNTRY_CODE = false\r\n\r\nexport default class AsYouType {\r\n\t/**\r\n\t * @param {(string|object)?} [optionsOrDefaultCountry] - The default country used for parsing non-international phone numbers. Can also be an `options` object.\r\n\t * @param {Object} metadata\r\n\t */\r\n\tconstructor(optionsOrDefaultCountry, metadata) {\r\n\t\tthis.metadata = new Metadata(metadata)\r\n\t\tconst [defaultCountry, defaultCallingCode] = this.getCountryAndCallingCode(optionsOrDefaultCountry)\r\n\t\t// `this.defaultCountry` and `this.defaultCallingCode` aren't required to be in sync.\r\n\t\t// For example, `this.defaultCountry` could be `\"AR\"` and `this.defaultCallingCode` could be `undefined`.\r\n\t\t// So `this.defaultCountry` and `this.defaultCallingCode` are totally independent.\r\n\t\tthis.defaultCountry = defaultCountry\r\n\t\tthis.defaultCallingCode = defaultCallingCode\r\n\t\tthis.reset()\r\n\t}\r\n\r\n\tgetCountryAndCallingCode(optionsOrDefaultCountry) {\r\n\t\t// Set `defaultCountry` and `defaultCallingCode` options.\r\n\t\tlet defaultCountry\r\n\t\tlet defaultCallingCode\r\n\t\t// Turns out `null` also has type \"object\". Weird.\r\n\t\tif (optionsOrDefaultCountry) {\r\n\t\t\tif (isObject(optionsOrDefaultCountry)) {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry.defaultCountry\r\n\t\t\t\tdefaultCallingCode = optionsOrDefaultCountry.defaultCallingCode\r\n\t\t\t} else {\r\n\t\t\t\tdefaultCountry = optionsOrDefaultCountry\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (defaultCountry && !this.metadata.hasCountry(defaultCountry)) {\r\n\t\t\tdefaultCountry = undefined\r\n\t\t}\r\n\t\tif (defaultCallingCode) {\r\n\t\t\t/* istanbul ignore if */\r\n\t\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t\tif (this.metadata.isNonGeographicCallingCode(defaultCallingCode)) {\r\n\t\t\t\t\tdefaultCountry = '001'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn [defaultCountry, defaultCallingCode]\r\n\t}\r\n\r\n\t/**\r\n\t * Inputs \"next\" phone number characters.\r\n\t * @param {string} text\r\n\t * @return {string} Formatted phone number characters that have been input so far.\r\n\t */\r\n\tinput(text) {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tjustLeadingPlus\r\n\t\t} = this.parser.input(text, this.state)\r\n\t\tif (justLeadingPlus) {\r\n\t\t\tthis.formattedOutput = '+'\r\n\t\t} else if (digits) {\r\n\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t// Match the available formats by the currently available leading digits.\r\n\t\t\tif (this.state.nationalSignificantNumber) {\r\n\t\t\t\tthis.formatter.narrowDownMatchingFormats(this.state)\r\n\t\t\t}\r\n\t\t\tlet formattedNationalNumber\r\n\t\t\tif (this.metadata.hasSelectedNumberingPlan()) {\r\n\t\t\t\tformattedNationalNumber = this.formatter.format(digits, this.state)\r\n\t\t\t}\r\n\t\t\tif (formattedNationalNumber === undefined) {\r\n\t\t\t\t// See if another national (significant) number could be re-extracted.\r\n\t\t\t\tif (this.parser.reExtractNationalSignificantNumber(this.state)) {\r\n\t\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\t\t// If it could, then re-try formatting the new national (significant) number.\r\n\t\t\t\t\tconst nationalDigits = this.state.getNationalDigits()\r\n\t\t\t\t\tif (nationalDigits) {\r\n\t\t\t\t\t\tformattedNationalNumber = this.formatter.format(nationalDigits, this.state)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.formattedOutput = formattedNationalNumber\r\n\t\t\t\t? this.getFullNumber(formattedNationalNumber)\r\n\t\t\t\t: this.getNonFormattedNumber()\r\n\t\t}\r\n\t\treturn this.formattedOutput\r\n\t}\r\n\r\n\treset() {\r\n\t\tthis.state = new AsYouTypeState({\r\n\t\t\tonCountryChange: (country) => {\r\n\t\t\t\t// Before version `1.6.0`, the official `AsYouType` formatter API\r\n\t\t\t\t// included a `.country` property on an `AsYouType` instance.\r\n\t\t\t\t// Since that property (along with the others) have been moved to\r\n\t\t\t\t// `this.state`, `this.country` property is emulated for compatibility\r\n\t\t\t\t// with the old versions.\r\n\t\t\t\tthis.country = country\r\n\t\t\t},\r\n\t\t\tonCallingCodeChange: (callingCode, country) => {\r\n\t\t\t\tthis.metadata.selectNumberingPlan(country, callingCode)\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t\tthis.parser.reset(this.metadata.numberingPlan)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.formatter = new AsYouTypeFormatter({\r\n\t\t\tstate: this.state,\r\n\t\t\tmetadata: this.metadata\r\n\t\t})\r\n\t\tthis.parser = new AsYouTypeParser({\r\n\t\t\tdefaultCountry: this.defaultCountry,\r\n\t\t\tdefaultCallingCode: this.defaultCallingCode,\r\n\t\t\tmetadata: this.metadata,\r\n\t\t\tstate: this.state,\r\n\t\t\tonNationalSignificantNumberChange: () => {\r\n\t\t\t\tthis.determineTheCountryIfNeeded()\r\n\t\t\t\tthis.formatter.reset(this.metadata.numberingPlan, this.state)\r\n\t\t\t}\r\n\t\t})\r\n\t\tthis.state.reset({\r\n\t\t\tcountry: this.defaultCountry,\r\n\t\t\tcallingCode: this.defaultCallingCode\r\n\t\t})\r\n\t\tthis.formattedOutput = ''\r\n\t\treturn this\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is being input in international format.\r\n\t * In other words, returns `true` if and only if the parsed phone number starts with a `\"+\"`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisInternational() {\r\n\t\treturn this.state.international\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the \"calling code\" part of the phone number when it's being input\r\n\t * in an international format.\r\n\t * If no valid calling code has been entered so far, returns `undefined`.\r\n\t * @return {string} [callingCode]\r\n\t */\r\n\tgetCallingCode() {\r\n\t\t // If the number is being input in national format and some \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then `this.state.callingCode`\r\n\t\t // is equal to that \"default calling code\".\r\n\t\t //\r\n\t\t // If the number is being input in national format and no \"default calling code\"\r\n\t\t // has been passed to `AsYouType` constructor, then returns `undefined`,\r\n\t\t // even if a \"default country\" has been passed to `AsYouType` constructor.\r\n\t\t //\r\n\t\tif (this.isInternational()) {\r\n\t\t\treturn this.state.callingCode\r\n\t\t}\r\n\t}\r\n\r\n\t// A legacy alias.\r\n\tgetCountryCallingCode() {\r\n\t\treturn this.getCallingCode()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * Returns `undefined` if no phone number has been input yet.\r\n\t * @return {string} [country]\r\n\t */\r\n\tgetCountry() {\r\n\t\tconst { digits } = this.state\r\n\t\t// Return `undefined` if no digits have been input yet.\r\n\t\tif (digits) {\r\n\t\t\treturn this._getCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a two-letter country code of the phone number.\r\n\t * Returns `undefined` for \"non-geographic\" phone numbering plans.\r\n\t * @return {string} [country]\r\n\t */\r\n\t_getCountry() {\r\n\t\tconst { country } = this.state\r\n\t\t/* istanbul ignore if */\r\n\t\tif (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {\r\n\t\t\t// `AsYouType.getCountry()` returns `undefined`\r\n\t\t\t// for \"non-geographic\" phone numbering plans.\r\n\t\t\tif (country === '001') {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn country\r\n\t}\r\n\r\n\tdetermineTheCountryIfNeeded() {\r\n\t\t// Suppose a user enters a phone number in international format,\r\n\t\t// and there're several countries corresponding to that country calling code,\r\n\t\t// and a country has been derived from the number, and then\r\n\t\t// a user enters one more digit and the number is no longer\r\n\t\t// valid for the derived country, so the country should be re-derived\r\n\t\t// on every new digit in those cases.\r\n\t\t//\r\n\t\t// If the phone number is being input in national format,\r\n\t\t// then it could be a case when `defaultCountry` wasn't specified\r\n\t\t// when creating `AsYouType` instance, and just `defaultCallingCode` was specified,\r\n\t\t// and that \"calling code\" could correspond to a \"non-geographic entity\",\r\n\t\t// or there could be several countries corresponding to that country calling code.\r\n\t\t// In those cases, `this.country` is `undefined` and should be derived\r\n\t\t// from the number. Again, if country calling code is ambiguous, then\r\n\t\t// `this.country` should be re-derived with each new digit.\r\n\t\t//\r\n\t\tif (!this.state.country || this.isCountryCallingCodeAmbiguous()) {\r\n\t\t\tthis.determineTheCountry()\r\n\t\t}\r\n\t}\r\n\r\n\t// Prepends `+CountryCode ` in case of an international phone number\r\n\tgetFullNumber(formattedNationalNumber) {\r\n\t\tif (this.isInternational()) {\r\n\t\t\tconst prefix = (text) => this.formatter.getInternationalPrefixBeforeCountryCallingCode(this.state, {\r\n\t\t\t\tspacing: text ? true : false\r\n\t\t\t}) + text\r\n\t\t\tconst { callingCode } = this.state\r\n\t\t\tif (!callingCode) {\r\n\t\t\t\treturn prefix(`${this.state.getDigitsWithoutInternationalPrefix()}`)\r\n\t\t\t}\r\n\t\t\tif (!formattedNationalNumber) {\r\n\t\t\t\treturn prefix(callingCode)\r\n\t\t\t}\r\n\t\t\treturn prefix(`${callingCode} ${formattedNationalNumber}`)\r\n\t\t}\r\n\t\treturn formattedNationalNumber\r\n\t}\r\n\r\n\tgetNonFormattedNationalNumberWithPrefix() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tprefixBeforeNationalSignificantNumberThatIsNotNationalPrefix,\r\n\t\t\tnationalPrefix\r\n\t\t} = this.state\r\n\t\tlet number = nationalSignificantNumber\r\n\t\tconst prefix = prefixBeforeNationalSignificantNumberThatIsNotNationalPrefix || nationalPrefix\r\n\t\tif (prefix) {\r\n\t\t\tnumber = prefix + number\r\n\t\t}\r\n\t\treturn number\r\n\t}\r\n\r\n\tgetNonFormattedNumber() {\r\n\t\tconst { nationalSignificantNumberIsModified } = this.state\r\n\t\treturn this.getFullNumber(\r\n\t\t\tnationalSignificantNumberIsModified\r\n\t\t\t\t? this.state.getNationalDigits()\r\n\t\t\t\t: this.getNonFormattedNationalNumberWithPrefix()\r\n\t\t)\r\n\t}\r\n\r\n\tgetNonFormattedTemplate() {\r\n\t\tconst number = this.getNonFormattedNumber()\r\n\t\tif (number) {\r\n\t\t\treturn number.replace(/[\\+\\d]/g, DIGIT_PLACEHOLDER)\r\n\t\t}\r\n\t}\r\n\r\n\tisCountryCallingCodeAmbiguous() {\r\n\t\tconst { callingCode } = this.state\r\n\t\tconst countryCodes = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\treturn countryCodes && countryCodes.length > 1\r\n\t}\r\n\r\n\t// Determines the exact country of the phone number\r\n\t// entered so far based on the country phone code\r\n\t// and the national phone number.\r\n\tdetermineTheCountry() {\r\n\t\tthis.state.setCountry(getCountryByCallingCode(\r\n\t\t\tthis.isInternational() ? this.state.callingCode : this.defaultCallingCode,\r\n\t\t\t{\r\n\t\t\t\tnationalNumber: this.state.nationalSignificantNumber,\r\n\t\t\t\tmetadata: this.metadata\r\n\t\t\t}\r\n\t\t))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a E.164 phone number value for the user's input.\r\n\t *\r\n\t * For example, for country `\"US\"` and input `\"(222) 333-4444\"`\r\n\t * it will return `\"+12223334444\"`.\r\n\t *\r\n\t * For international phone number input, it will also auto-correct\r\n\t * some minor errors such as using a national prefix when writing\r\n\t * an international phone number. For example, if the user inputs\r\n\t * `\"+44 0 7400 000000\"` then it will return an auto-corrected\r\n\t * `\"+447400000000\"` phone number value.\r\n\t *\r\n\t * Will return `undefined` if no digits have been input,\r\n\t * or when inputting a phone number in national format and no\r\n\t * default country or default \"country calling code\" have been set.\r\n\t *\r\n\t * @return {string} [value]\r\n\t */\r\n\tgetNumberValue() {\r\n\t\tconst {\r\n\t\t\tdigits,\r\n\t\t\tcallingCode,\r\n\t\t\tcountry,\r\n\t\t\tnationalSignificantNumber\r\n\t\t} = this.state\r\n\r\n\t \t// Will return `undefined` if no digits have been input.\r\n\t\tif (!digits) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (this.isInternational()) {\r\n\t\t\tif (callingCode) {\r\n\t\t\t\treturn '+' + callingCode + nationalSignificantNumber\r\n\t\t\t} else {\r\n\t\t\t\treturn '+' + digits\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tif (country || callingCode) {\r\n\t\t\t\tconst callingCode_ = country ? this.metadata.countryCallingCode() : callingCode\r\n\t\t\t\treturn '+' + callingCode_ + nationalSignificantNumber\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an instance of `PhoneNumber` class.\r\n\t * Will return `undefined` if no national (significant) number\r\n\t * digits have been entered so far, or if no `defaultCountry` has been\r\n\t * set and the user enters a phone number not in international format.\r\n\t */\r\n\tgetNumber() {\r\n\t\tconst {\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tcarrierCode,\r\n\t\t\tcallingCode\r\n\t\t} = this.state\r\n\r\n\t\t// `this._getCountry()` is basically same as `this.state.country`\r\n\t\t// with the only change that it return `undefined` in case of a\r\n\t\t// \"non-geographic\" numbering plan instead of `\"001\"` \"internal use\" value.\r\n\t\tlet country = this._getCountry()\r\n\r\n\t\tif (!nationalSignificantNumber) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// `state.country` and `state.callingCode` aren't required to be in sync.\r\n\t\t// For example, `country` could be `\"AR\"` and `callingCode` could be `undefined`.\r\n\t\t// So `country` and `callingCode` are totally independent.\r\n\r\n\t\tif (!country && !callingCode) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// By default, if `defaultCountry` parameter was passed when\r\n\t\t// creating `AsYouType` instance, `state.country` is gonna be\r\n\t\t// that `defaultCountry`, which doesn't entirely conform with\r\n\t\t// `parsePhoneNumber()`'s behavior where it attempts to determine\r\n\t\t// the country more precisely in cases when multiple countries\r\n\t\t// could correspond to the same `countryCallingCode`.\r\n\t\t// https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/103#note_1417192969\r\n\t\t//\r\n\t\t// Because `AsYouType.getNumber()` method is supposed to be a 1:1\r\n\t\t// equivalent for `parsePhoneNumber(AsYouType.getNumberValue())`,\r\n\t\t// then it should also behave accordingly in cases of `country` ambiguity.\r\n\t\t// That's how users of this library would expect it to behave anyway.\r\n\t\t//\r\n\t\tif (country) {\r\n\t\t\tif (country === this.defaultCountry) {\r\n\t\t\t\t// `state.country` and `state.callingCode` aren't required to be in sync.\r\n\t\t\t\t// For example, `state.country` could be `\"AR\"` and `state.callingCode` could be `undefined`.\r\n\t\t\t\t// So `state.country` and `state.callingCode` are totally independent.\r\n\t\t\t\tconst metadata = new Metadata(this.metadata.metadata)\r\n\t\t\t\tmetadata.selectNumberingPlan(country)\r\n\t\t\t\tconst callingCode = metadata.numberingPlan.callingCode()\r\n\t\t\t\tconst ambiguousCountries = this.metadata.getCountryCodesForCallingCode(callingCode)\r\n\t\t\t\tif (ambiguousCountries.length > 1) {\r\n\t\t\t\t\tconst exactCountry = getCountryByNationalNumber(nationalSignificantNumber, {\r\n\t\t\t\t\t\tcountries: ambiguousCountries,\r\n\t\t\t\t\t\tmetadata: this.metadata.metadata\r\n\t\t\t\t\t})\r\n\t\t\t\t\tif (exactCountry) {\r\n\t\t\t\t\t\tcountry = exactCountry\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst phoneNumber = new PhoneNumber(\r\n\t\t\tcountry || callingCode,\r\n\t\t\tnationalSignificantNumber,\r\n\t\t\tthis.metadata.metadata\r\n\t\t)\r\n\t\tif (carrierCode) {\r\n\t\t\tphoneNumber.carrierCode = carrierCode\r\n\t\t}\r\n\t\t// Phone number extensions are not supported by \"As You Type\" formatter.\r\n\t\treturn phoneNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"possible\".\r\n\t * Is just a shortcut for `PhoneNumber.isPossible()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisPossible() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isPossible()\r\n\t}\r\n\r\n\t/**\r\n\t * Returns `true` if the phone number is \"valid\".\r\n\t * Is just a shortcut for `PhoneNumber.isValid()`.\r\n\t * @return {boolean}\r\n\t */\r\n\tisValid() {\r\n\t\tconst phoneNumber = this.getNumber()\r\n\t\tif (!phoneNumber) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\treturn phoneNumber.isValid()\r\n\t}\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * This method is used in `react-phone-number-input/source/input-control.js`\r\n\t * in versions before `3.0.16`.\r\n\t */\r\n\tgetNationalNumber() {\r\n\t\treturn this.state.nationalSignificantNumber\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the phone number characters entered by the user.\r\n\t * @return {string}\r\n\t */\r\n\tgetChars() {\r\n\t\treturn (this.state.international ? '+' : '') + this.state.digits\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the template for the formatted phone number.\r\n\t * @return {string}\r\n\t */\r\n\tgetTemplate() {\r\n\t\treturn this.formatter.getTemplate(this.state) || this.getNonFormattedTemplate() || ''\r\n\t}\r\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,eAAe;AACpC,OAAOC,WAAW,MAAM,kBAAkB;AAC1C,OAAOC,cAAc,MAAM,qBAAqB;AAChD,OAAOC,kBAAkB,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC/E,OAAOC,eAAe,IAAIC,6BAA6B,QAAQ,sBAAsB;AACrF,OAAOC,uBAAuB,MAAM,sCAAsC;AAC1E,OAAOC,0BAA0B,MAAM,yCAAyC;AAChF,OAAOC,QAAQ,MAAM,uBAAuB;AAE5C,MAAMC,+BAA+B,GAAG,KAAK;AAE7C,eAAe,MAAMC,SAAS,CAAC;EAC9B;AACD;AACA;AACA;EACCC,WAAWA,CAACC,uBAAuB,EAAEC,QAAQ,EAAE;IAC9C,IAAI,CAACA,QAAQ,GAAG,IAAId,QAAQ,CAACc,QAAQ,CAAC;IACtC,MAAM,CAACC,cAAc,EAAEC,kBAAkB,CAAC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