intl-tel-input 25.4.5 → 25.4.8
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/README.md +5 -5
- package/angular/build/IntlTelInput.cjs +13 -10
- package/angular/build/IntlTelInput.d.ts +373 -1
- package/angular/build/IntlTelInput.js +13 -10
- package/angular/build/IntlTelInputWithUtils.cjs +13 -10
- package/angular/build/IntlTelInputWithUtils.js +13 -10
- package/angular/build/intl-tel-input/angular.js +205 -0
- package/angular/build/intl-tel-input/angularWithUtils.js +206 -0
- package/angular/build/intl-tel-input/data.js +1096 -0
- package/angular/build/intl-tel-input/i18n/ar/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/ar/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/ar/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/bg/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/bg/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/bg/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/bn/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/bn/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/bn/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/bs/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/bs/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/bs/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/ca/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/ca/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/ca/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/cs/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/cs/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/cs/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/da/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/da/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/da/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/de/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/de/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/de/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/ee/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/ee/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/ee/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/el/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/el/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/el/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/en/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/en/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/en/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/es/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/es/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/es/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/fa/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/fa/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/fa/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/fi/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/fi/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/fi/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/fr/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/fr/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/fr/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/hi/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/hi/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/hi/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/hr/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/hr/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/hr/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/hu/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/hu/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/hu/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/id/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/id/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/id/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/index.js +40 -0
- package/angular/build/intl-tel-input/i18n/it/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/it/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/it/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/ja/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/ja/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/ja/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/ko/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/ko/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/ko/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/mr/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/mr/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/mr/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/nl/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/nl/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/nl/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/no/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/no/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/no/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/pl/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/pl/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/pl/interface.js +24 -0
- package/angular/build/intl-tel-input/i18n/pt/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/pt/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/pt/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/ro/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/ro/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/ro/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/ru/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/ru/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/ru/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/sk/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/sk/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/sk/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/sv/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/sv/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/sv/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/te/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/te/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/te/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/th/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/th/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/th/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/tr/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/tr/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/tr/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/types.js +1 -0
- package/angular/build/intl-tel-input/i18n/uk/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/uk/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/uk/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/ur/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/ur/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/ur/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/uz/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/uz/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/uz/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/vi/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/vi/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/vi/interface.js +13 -0
- package/angular/build/intl-tel-input/i18n/zh/countries.js +245 -0
- package/angular/build/intl-tel-input/i18n/zh/index.js +5 -0
- package/angular/build/intl-tel-input/i18n/zh/interface.js +13 -0
- package/angular/build/intl-tel-input/intlTelInputWithUtils.js +4 -0
- package/angular/build/intl-tel-input/utils.js +1341 -0
- package/angular/build/intl-tel-input.js +1780 -0
- package/angular/build/types/intl-tel-input/angular.d.ts +40 -0
- package/angular/build/types/intl-tel-input/angularWithUtils.d.ts +40 -0
- package/angular/build/types/intl-tel-input/data.d.ts +11 -0
- package/angular/build/types/intl-tel-input/i18n/ar/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ar/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/ar/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/bg/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/bg/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/bg/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/bn/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/bn/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/bn/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/bs/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/bs/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/bs/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ca/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ca/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/ca/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/cs/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/cs/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/cs/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/da/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/da/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/da/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/de/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/de/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/de/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ee/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ee/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/ee/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/el/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/el/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/el/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/en/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/en/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/en/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/es/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/es/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/es/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/fa/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/fa/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/fa/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/fi/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/fi/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/fi/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/fr/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/fr/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/fr/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/hi/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/hi/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/hi/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/hr/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/hr/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/hr/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/hu/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/hu/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/hu/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/id/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/id/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/id/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/index.d.ts +39 -0
- package/angular/build/types/intl-tel-input/i18n/it/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/it/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/it/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ja/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ja/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/ja/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ko/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ko/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/ko/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/mr/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/mr/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/mr/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/nl/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/nl/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/nl/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/no/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/no/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/no/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/pl/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/pl/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/pl/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/pt/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/pt/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/pt/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ro/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ro/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/ro/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ru/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ru/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/ru/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/sk/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/sk/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/sk/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/sv/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/sv/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/sv/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/te/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/te/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/te/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/th/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/th/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/th/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/tr/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/tr/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/tr/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/types.d.ts +254 -0
- package/angular/build/types/intl-tel-input/i18n/uk/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/uk/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/uk/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ur/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/ur/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/ur/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/uz/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/uz/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/uz/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/vi/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/vi/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/vi/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/zh/countries.d.ts +3 -0
- package/angular/build/types/intl-tel-input/i18n/zh/index.d.ts +6 -0
- package/angular/build/types/intl-tel-input/i18n/zh/interface.d.ts +3 -0
- package/angular/build/types/intl-tel-input/intlTelInputWithUtils.d.ts +2 -0
- package/angular/build/types/intl-tel-input/utils.d.ts +2 -0
- package/angular/build/types/intl-tel-input.d.ts +199 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +1 -1
- package/build/js/intlTelInput.js +14 -11
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +14 -11
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +7 -8
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +13 -10
- package/react/build/IntlTelInput.d.ts +1 -1
- package/react/build/IntlTelInput.js +13 -10
- package/react/build/IntlTelInputWithUtils.cjs +13 -10
- package/react/build/IntlTelInputWithUtils.js +13 -10
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +71 -73
- package/vue/build/IntlTelInputWithUtils.mjs +265 -267
|
@@ -2031,6 +2031,9 @@ var Iti = class {
|
|
|
2031
2031
|
}
|
|
2032
2032
|
if (dropdownContainer) {
|
|
2033
2033
|
let dropdownClasses = "iti iti--container";
|
|
2034
|
+
if (containerClass) {
|
|
2035
|
+
dropdownClasses += ` ${containerClass}`;
|
|
2036
|
+
}
|
|
2034
2037
|
if (useFullscreenPopup) {
|
|
2035
2038
|
dropdownClasses += " iti--fullscreen-popup";
|
|
2036
2039
|
} else {
|
|
@@ -2306,12 +2309,8 @@ var Iti = class {
|
|
|
2306
2309
|
const newFullNumber = this._getFullNumber(newValue);
|
|
2307
2310
|
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
2308
2311
|
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
const currentCountry = this.selectedCountryData.iso2;
|
|
2312
|
-
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2313
|
-
isChangingDialCode = newCountry !== currentCountry;
|
|
2314
|
-
}
|
|
2312
|
+
const newCountry = this._getNewCountryFromNumber(newFullNumber);
|
|
2313
|
+
const isChangingDialCode = newCountry !== null;
|
|
2315
2314
|
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
2316
2315
|
e.preventDefault();
|
|
2317
2316
|
}
|
|
@@ -2547,7 +2546,7 @@ var Iti = class {
|
|
|
2547
2546
|
//* Check if need to select a new country based on the given number
|
|
2548
2547
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
2549
2548
|
_updateCountryFromNumber(fullNumber) {
|
|
2550
|
-
const iso2 = this.
|
|
2549
|
+
const iso2 = this._getNewCountryFromNumber(fullNumber);
|
|
2551
2550
|
if (iso2 !== null) {
|
|
2552
2551
|
return this._setCountry(iso2);
|
|
2553
2552
|
}
|
|
@@ -2563,7 +2562,10 @@ var Iti = class {
|
|
|
2563
2562
|
const cleanNumber = hasPrefix ? number.substring(1) : number;
|
|
2564
2563
|
return `+${dialCode}${cleanNumber}`;
|
|
2565
2564
|
}
|
|
2566
|
-
|
|
2565
|
+
// Get the country ISO2 code from the given number
|
|
2566
|
+
// BUT ONLY IF ITS CHANGED FROM THE CURRENTLY SELECTED COUNTRY
|
|
2567
|
+
// NOTE: consider refactoring this to be more clear
|
|
2568
|
+
_getNewCountryFromNumber(fullNumber) {
|
|
2567
2569
|
const plusIndex = fullNumber.indexOf("+");
|
|
2568
2570
|
let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
|
|
2569
2571
|
const selectedIso2 = this.selectedCountryData.iso2;
|
|
@@ -2577,7 +2579,8 @@ var Iti = class {
|
|
|
2577
2579
|
if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
|
|
2578
2580
|
return this.defaultCountry;
|
|
2579
2581
|
}
|
|
2580
|
-
const
|
|
2582
|
+
const hasAreaCodesButNoneMatched = this.selectedCountryData.areaCodes && numeric.length > dialCodeMatchNumeric.length;
|
|
2583
|
+
const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
|
|
2581
2584
|
const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
|
|
2582
2585
|
if (!isRegionlessNanpNumber && !alreadySelected) {
|
|
2583
2586
|
for (let j = 0; j < iso2Codes.length; j++) {
|
|
@@ -3145,7 +3148,7 @@ var intlTelInput = Object.assign(
|
|
|
3145
3148
|
attachUtils,
|
|
3146
3149
|
startedLoadingUtilsScript: false,
|
|
3147
3150
|
startedLoadingAutoCountry: false,
|
|
3148
|
-
version: "25.4.
|
|
3151
|
+
version: "25.4.7"
|
|
3149
3152
|
}
|
|
3150
3153
|
);
|
|
3151
3154
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -2055,6 +2055,9 @@ var Iti = class {
|
|
|
2055
2055
|
}
|
|
2056
2056
|
if (dropdownContainer) {
|
|
2057
2057
|
let dropdownClasses = "iti iti--container";
|
|
2058
|
+
if (containerClass) {
|
|
2059
|
+
dropdownClasses += ` ${containerClass}`;
|
|
2060
|
+
}
|
|
2058
2061
|
if (useFullscreenPopup) {
|
|
2059
2062
|
dropdownClasses += " iti--fullscreen-popup";
|
|
2060
2063
|
} else {
|
|
@@ -2330,12 +2333,8 @@ var Iti = class {
|
|
|
2330
2333
|
const newFullNumber = this._getFullNumber(newValue);
|
|
2331
2334
|
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
2332
2335
|
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
const currentCountry = this.selectedCountryData.iso2;
|
|
2336
|
-
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2337
|
-
isChangingDialCode = newCountry !== currentCountry;
|
|
2338
|
-
}
|
|
2336
|
+
const newCountry = this._getNewCountryFromNumber(newFullNumber);
|
|
2337
|
+
const isChangingDialCode = newCountry !== null;
|
|
2339
2338
|
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
2340
2339
|
e.preventDefault();
|
|
2341
2340
|
}
|
|
@@ -2571,7 +2570,7 @@ var Iti = class {
|
|
|
2571
2570
|
//* Check if need to select a new country based on the given number
|
|
2572
2571
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
2573
2572
|
_updateCountryFromNumber(fullNumber) {
|
|
2574
|
-
const iso2 = this.
|
|
2573
|
+
const iso2 = this._getNewCountryFromNumber(fullNumber);
|
|
2575
2574
|
if (iso2 !== null) {
|
|
2576
2575
|
return this._setCountry(iso2);
|
|
2577
2576
|
}
|
|
@@ -2587,7 +2586,10 @@ var Iti = class {
|
|
|
2587
2586
|
const cleanNumber = hasPrefix ? number.substring(1) : number;
|
|
2588
2587
|
return `+${dialCode}${cleanNumber}`;
|
|
2589
2588
|
}
|
|
2590
|
-
|
|
2589
|
+
// Get the country ISO2 code from the given number
|
|
2590
|
+
// BUT ONLY IF ITS CHANGED FROM THE CURRENTLY SELECTED COUNTRY
|
|
2591
|
+
// NOTE: consider refactoring this to be more clear
|
|
2592
|
+
_getNewCountryFromNumber(fullNumber) {
|
|
2591
2593
|
const plusIndex = fullNumber.indexOf("+");
|
|
2592
2594
|
let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
|
|
2593
2595
|
const selectedIso2 = this.selectedCountryData.iso2;
|
|
@@ -2601,7 +2603,8 @@ var Iti = class {
|
|
|
2601
2603
|
if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
|
|
2602
2604
|
return this.defaultCountry;
|
|
2603
2605
|
}
|
|
2604
|
-
const
|
|
2606
|
+
const hasAreaCodesButNoneMatched = this.selectedCountryData.areaCodes && numeric.length > dialCodeMatchNumeric.length;
|
|
2607
|
+
const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
|
|
2605
2608
|
const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
|
|
2606
2609
|
if (!isRegionlessNanpNumber && !alreadySelected) {
|
|
2607
2610
|
for (let j = 0; j < iso2Codes.length; j++) {
|
|
@@ -3169,7 +3172,7 @@ var intlTelInput = Object.assign(
|
|
|
3169
3172
|
attachUtils,
|
|
3170
3173
|
startedLoadingUtilsScript: false,
|
|
3171
3174
|
startedLoadingAutoCountry: false,
|
|
3172
|
-
version: "25.4.
|
|
3175
|
+
version: "25.4.7"
|
|
3173
3176
|
}
|
|
3174
3177
|
);
|
|
3175
3178
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -2031,6 +2031,9 @@ var Iti = class {
|
|
|
2031
2031
|
}
|
|
2032
2032
|
if (dropdownContainer) {
|
|
2033
2033
|
let dropdownClasses = "iti iti--container";
|
|
2034
|
+
if (containerClass) {
|
|
2035
|
+
dropdownClasses += ` ${containerClass}`;
|
|
2036
|
+
}
|
|
2034
2037
|
if (useFullscreenPopup) {
|
|
2035
2038
|
dropdownClasses += " iti--fullscreen-popup";
|
|
2036
2039
|
} else {
|
|
@@ -2306,12 +2309,8 @@ var Iti = class {
|
|
|
2306
2309
|
const newFullNumber = this._getFullNumber(newValue);
|
|
2307
2310
|
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
2308
2311
|
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
const currentCountry = this.selectedCountryData.iso2;
|
|
2312
|
-
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2313
|
-
isChangingDialCode = newCountry !== currentCountry;
|
|
2314
|
-
}
|
|
2312
|
+
const newCountry = this._getNewCountryFromNumber(newFullNumber);
|
|
2313
|
+
const isChangingDialCode = newCountry !== null;
|
|
2315
2314
|
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
2316
2315
|
e.preventDefault();
|
|
2317
2316
|
}
|
|
@@ -2547,7 +2546,7 @@ var Iti = class {
|
|
|
2547
2546
|
//* Check if need to select a new country based on the given number
|
|
2548
2547
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
2549
2548
|
_updateCountryFromNumber(fullNumber) {
|
|
2550
|
-
const iso2 = this.
|
|
2549
|
+
const iso2 = this._getNewCountryFromNumber(fullNumber);
|
|
2551
2550
|
if (iso2 !== null) {
|
|
2552
2551
|
return this._setCountry(iso2);
|
|
2553
2552
|
}
|
|
@@ -2563,7 +2562,10 @@ var Iti = class {
|
|
|
2563
2562
|
const cleanNumber = hasPrefix ? number.substring(1) : number;
|
|
2564
2563
|
return `+${dialCode}${cleanNumber}`;
|
|
2565
2564
|
}
|
|
2566
|
-
|
|
2565
|
+
// Get the country ISO2 code from the given number
|
|
2566
|
+
// BUT ONLY IF ITS CHANGED FROM THE CURRENTLY SELECTED COUNTRY
|
|
2567
|
+
// NOTE: consider refactoring this to be more clear
|
|
2568
|
+
_getNewCountryFromNumber(fullNumber) {
|
|
2567
2569
|
const plusIndex = fullNumber.indexOf("+");
|
|
2568
2570
|
let number = plusIndex ? fullNumber.substring(plusIndex) : fullNumber;
|
|
2569
2571
|
const selectedIso2 = this.selectedCountryData.iso2;
|
|
@@ -2577,7 +2579,8 @@ var Iti = class {
|
|
|
2577
2579
|
if (!selectedIso2 && this.defaultCountry && iso2Codes.includes(this.defaultCountry)) {
|
|
2578
2580
|
return this.defaultCountry;
|
|
2579
2581
|
}
|
|
2580
|
-
const
|
|
2582
|
+
const hasAreaCodesButNoneMatched = this.selectedCountryData.areaCodes && numeric.length > dialCodeMatchNumeric.length;
|
|
2583
|
+
const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
|
|
2581
2584
|
const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
|
|
2582
2585
|
if (!isRegionlessNanpNumber && !alreadySelected) {
|
|
2583
2586
|
for (let j = 0; j < iso2Codes.length; j++) {
|
|
@@ -3145,7 +3148,7 @@ var intlTelInput = Object.assign(
|
|
|
3145
3148
|
attachUtils,
|
|
3146
3149
|
startedLoadingUtilsScript: false,
|
|
3147
3150
|
startedLoadingAutoCountry: false,
|
|
3148
|
-
version: "25.4.
|
|
3151
|
+
version: "25.4.7"
|
|
3149
3152
|
}
|
|
3150
3153
|
);
|
|
3151
3154
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import intlTelInput from "../intl-tel-input";
|
|
2
|
+
import { Component, Input, ViewChild, ElementRef, Output, EventEmitter, forwardRef } from "@angular/core";
|
|
3
|
+
import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from "@angular/forms";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
const _c0 = ["inputRef"];
|
|
6
|
+
export { intlTelInput };
|
|
7
|
+
export const PHONE_ERROR_MESSAGES = [
|
|
8
|
+
"invalid",
|
|
9
|
+
"invalid-country-code",
|
|
10
|
+
"too-short",
|
|
11
|
+
"too-long",
|
|
12
|
+
"invalid-format",
|
|
13
|
+
];
|
|
14
|
+
export class IntlTelInputComponent {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.initialValue = "";
|
|
17
|
+
this.usePreciseValidation = false;
|
|
18
|
+
this.inputProps = {};
|
|
19
|
+
this.disabled = undefined;
|
|
20
|
+
this.initOptions = {};
|
|
21
|
+
this.numberChange = new EventEmitter();
|
|
22
|
+
this.countryChange = new EventEmitter();
|
|
23
|
+
this.validityChange = new EventEmitter();
|
|
24
|
+
this.errorCodeChange = new EventEmitter();
|
|
25
|
+
this.iti = null;
|
|
26
|
+
this.countryChangeHandler = () => this.handleInput();
|
|
27
|
+
// eslint-disable-next-line class-methods-use-this
|
|
28
|
+
this.onChange = () => { };
|
|
29
|
+
// eslint-disable-next-line class-methods-use-this
|
|
30
|
+
this.onTouched = () => { };
|
|
31
|
+
// eslint-disable-next-line class-methods-use-this
|
|
32
|
+
this.onValidatorChange = () => { };
|
|
33
|
+
}
|
|
34
|
+
ngOnInit() {
|
|
35
|
+
if (this.inputRef.nativeElement) {
|
|
36
|
+
this.iti = intlTelInput(this.inputRef.nativeElement, this.initOptions);
|
|
37
|
+
}
|
|
38
|
+
this.inputRef.nativeElement.addEventListener("countrychange", this.countryChangeHandler);
|
|
39
|
+
this.applyInputProps();
|
|
40
|
+
for (const key in this.inputProps) {
|
|
41
|
+
if (this.inputProps.hasOwnProperty(key)) {
|
|
42
|
+
this.inputRef.nativeElement.setAttribute(key, this.inputProps[key]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
ngAfterViewInit() {
|
|
47
|
+
var _a;
|
|
48
|
+
if (this.initialValue) {
|
|
49
|
+
(_a = this.iti) === null || _a === void 0 ? void 0 : _a.setNumber(this.initialValue);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
handleInput() {
|
|
53
|
+
if (!this.iti)
|
|
54
|
+
return;
|
|
55
|
+
const num = this.iti.getNumber() || "";
|
|
56
|
+
const countryIso = this.iti.getSelectedCountryData().iso2 || "";
|
|
57
|
+
this.numberChange.emit(num);
|
|
58
|
+
this.countryChange.emit(countryIso);
|
|
59
|
+
const isValid = this.usePreciseValidation
|
|
60
|
+
? this.iti.isValidNumberPrecise()
|
|
61
|
+
: this.iti.isValidNumber();
|
|
62
|
+
if (isValid) {
|
|
63
|
+
this.validityChange.emit(true);
|
|
64
|
+
this.errorCodeChange.emit(null);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.validityChange.emit(false);
|
|
68
|
+
this.errorCodeChange.emit(this.iti.getValidationError());
|
|
69
|
+
}
|
|
70
|
+
this.onChange(num);
|
|
71
|
+
this.onValidatorChange();
|
|
72
|
+
}
|
|
73
|
+
handleBlur() {
|
|
74
|
+
this.onTouched();
|
|
75
|
+
}
|
|
76
|
+
getInstance() {
|
|
77
|
+
return this.iti;
|
|
78
|
+
}
|
|
79
|
+
getInput() {
|
|
80
|
+
return this.inputRef.nativeElement;
|
|
81
|
+
}
|
|
82
|
+
ngOnDestroy() {
|
|
83
|
+
var _a;
|
|
84
|
+
(_a = this.iti) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
85
|
+
this.inputRef.nativeElement.removeEventListener("countrychange", this.countryChangeHandler);
|
|
86
|
+
}
|
|
87
|
+
applyInputProps() {
|
|
88
|
+
const props = this.inputProps;
|
|
89
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
90
|
+
this.inputRef.nativeElement.setAttribute(key, value);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// ============ ControlValueAccessor Implementation ============
|
|
94
|
+
writeValue(value) {
|
|
95
|
+
if (this.iti && value) {
|
|
96
|
+
this.iti.setNumber(value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
registerOnChange(fn) {
|
|
100
|
+
this.onChange = fn;
|
|
101
|
+
}
|
|
102
|
+
registerOnTouched(fn) {
|
|
103
|
+
this.onTouched = fn;
|
|
104
|
+
}
|
|
105
|
+
setDisabledState(isDisabled) {
|
|
106
|
+
this.disabled = isDisabled;
|
|
107
|
+
}
|
|
108
|
+
// ============ Validator Implementation ============
|
|
109
|
+
validate(control) {
|
|
110
|
+
if (!control.value || !this.iti) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const isValid = this.usePreciseValidation
|
|
114
|
+
? this.iti.isValidNumberPrecise()
|
|
115
|
+
: this.iti.isValidNumber();
|
|
116
|
+
if (isValid) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const errorCode = this.iti.getValidationError();
|
|
120
|
+
return {
|
|
121
|
+
invalidPhone: {
|
|
122
|
+
errorCode,
|
|
123
|
+
errorMessage: PHONE_ERROR_MESSAGES[errorCode],
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
registerOnValidatorChange(fn) {
|
|
128
|
+
this.onValidatorChange = fn;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
IntlTelInputComponent.ɵfac = function IntlTelInputComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || IntlTelInputComponent)(); };
|
|
132
|
+
IntlTelInputComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: IntlTelInputComponent, selectors: [["intl-tel-input"]], viewQuery: function IntlTelInputComponent_Query(rf, ctx) { if (rf & 1) {
|
|
133
|
+
i0.ɵɵviewQuery(_c0, 7);
|
|
134
|
+
} if (rf & 2) {
|
|
135
|
+
let _t;
|
|
136
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.inputRef = _t.first);
|
|
137
|
+
} }, inputs: { initialValue: "initialValue", usePreciseValidation: "usePreciseValidation", inputProps: "inputProps", disabled: "disabled", initOptions: "initOptions" }, outputs: { numberChange: "numberChange", countryChange: "countryChange", validityChange: "validityChange", errorCodeChange: "errorCodeChange" }, features: [i0.ɵɵProvidersFeature([
|
|
138
|
+
{
|
|
139
|
+
provide: NG_VALUE_ACCESSOR,
|
|
140
|
+
useExisting: forwardRef(() => IntlTelInputComponent),
|
|
141
|
+
multi: true,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
provide: NG_VALIDATORS,
|
|
145
|
+
useExisting: forwardRef(() => IntlTelInputComponent),
|
|
146
|
+
multi: true,
|
|
147
|
+
},
|
|
148
|
+
])], decls: 2, vars: 1, consts: [["inputRef", ""], ["type", "tel", 3, "input", "blur", "disabled"]], template: function IntlTelInputComponent_Template(rf, ctx) { if (rf & 1) {
|
|
149
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
150
|
+
i0.ɵɵelementStart(0, "input", 1, 0);
|
|
151
|
+
i0.ɵɵlistener("input", function IntlTelInputComponent_Template_input_input_0_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.handleInput()); })("blur", function IntlTelInputComponent_Template_input_blur_0_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.handleBlur()); });
|
|
152
|
+
i0.ɵɵelementEnd();
|
|
153
|
+
} if (rf & 2) {
|
|
154
|
+
i0.ɵɵproperty("disabled", ctx.disabled);
|
|
155
|
+
} }, encapsulation: 2 });
|
|
156
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IntlTelInputComponent, [{
|
|
157
|
+
type: Component,
|
|
158
|
+
args: [{
|
|
159
|
+
selector: "intl-tel-input",
|
|
160
|
+
standalone: true,
|
|
161
|
+
template: `
|
|
162
|
+
<input
|
|
163
|
+
type="tel"
|
|
164
|
+
#inputRef
|
|
165
|
+
(input)="handleInput()"
|
|
166
|
+
(blur)="handleBlur()"
|
|
167
|
+
[disabled]="disabled"
|
|
168
|
+
/>
|
|
169
|
+
`,
|
|
170
|
+
providers: [
|
|
171
|
+
{
|
|
172
|
+
provide: NG_VALUE_ACCESSOR,
|
|
173
|
+
useExisting: forwardRef(() => IntlTelInputComponent),
|
|
174
|
+
multi: true,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
provide: NG_VALIDATORS,
|
|
178
|
+
useExisting: forwardRef(() => IntlTelInputComponent),
|
|
179
|
+
multi: true,
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
}]
|
|
183
|
+
}], null, { inputRef: [{
|
|
184
|
+
type: ViewChild,
|
|
185
|
+
args: ["inputRef", { static: true }]
|
|
186
|
+
}], initialValue: [{
|
|
187
|
+
type: Input
|
|
188
|
+
}], usePreciseValidation: [{
|
|
189
|
+
type: Input
|
|
190
|
+
}], inputProps: [{
|
|
191
|
+
type: Input
|
|
192
|
+
}], disabled: [{
|
|
193
|
+
type: Input
|
|
194
|
+
}], initOptions: [{
|
|
195
|
+
type: Input
|
|
196
|
+
}], numberChange: [{
|
|
197
|
+
type: Output
|
|
198
|
+
}], countryChange: [{
|
|
199
|
+
type: Output
|
|
200
|
+
}], validityChange: [{
|
|
201
|
+
type: Output
|
|
202
|
+
}], errorCodeChange: [{
|
|
203
|
+
type: Output
|
|
204
|
+
}] }); })();
|
|
205
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(IntlTelInputComponent, { className: "IntlTelInputComponent", filePath: "intl-tel-input/angular.ts", lineNumber: 42 }); })();
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
//* THIS FILE IS AUTO-GENERATED. DO NOT EDIT.
|
|
2
|
+
import intlTelInput from "./intlTelInputWithUtils";
|
|
3
|
+
import { Component, Input, ViewChild, ElementRef, Output, EventEmitter, forwardRef } from "@angular/core";
|
|
4
|
+
import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from "@angular/forms";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
const _c0 = ["inputRef"];
|
|
7
|
+
export { intlTelInput };
|
|
8
|
+
export const PHONE_ERROR_MESSAGES = [
|
|
9
|
+
"invalid",
|
|
10
|
+
"invalid-country-code",
|
|
11
|
+
"too-short",
|
|
12
|
+
"too-long",
|
|
13
|
+
"invalid-format",
|
|
14
|
+
];
|
|
15
|
+
export class IntlTelInputComponent {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.initialValue = "";
|
|
18
|
+
this.usePreciseValidation = false;
|
|
19
|
+
this.inputProps = {};
|
|
20
|
+
this.disabled = undefined;
|
|
21
|
+
this.initOptions = {};
|
|
22
|
+
this.numberChange = new EventEmitter();
|
|
23
|
+
this.countryChange = new EventEmitter();
|
|
24
|
+
this.validityChange = new EventEmitter();
|
|
25
|
+
this.errorCodeChange = new EventEmitter();
|
|
26
|
+
this.iti = null;
|
|
27
|
+
this.countryChangeHandler = () => this.handleInput();
|
|
28
|
+
// eslint-disable-next-line class-methods-use-this
|
|
29
|
+
this.onChange = () => { };
|
|
30
|
+
// eslint-disable-next-line class-methods-use-this
|
|
31
|
+
this.onTouched = () => { };
|
|
32
|
+
// eslint-disable-next-line class-methods-use-this
|
|
33
|
+
this.onValidatorChange = () => { };
|
|
34
|
+
}
|
|
35
|
+
ngOnInit() {
|
|
36
|
+
if (this.inputRef.nativeElement) {
|
|
37
|
+
this.iti = intlTelInput(this.inputRef.nativeElement, this.initOptions);
|
|
38
|
+
}
|
|
39
|
+
this.inputRef.nativeElement.addEventListener("countrychange", this.countryChangeHandler);
|
|
40
|
+
this.applyInputProps();
|
|
41
|
+
for (const key in this.inputProps) {
|
|
42
|
+
if (this.inputProps.hasOwnProperty(key)) {
|
|
43
|
+
this.inputRef.nativeElement.setAttribute(key, this.inputProps[key]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
ngAfterViewInit() {
|
|
48
|
+
var _a;
|
|
49
|
+
if (this.initialValue) {
|
|
50
|
+
(_a = this.iti) === null || _a === void 0 ? void 0 : _a.setNumber(this.initialValue);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
handleInput() {
|
|
54
|
+
if (!this.iti)
|
|
55
|
+
return;
|
|
56
|
+
const num = this.iti.getNumber() || "";
|
|
57
|
+
const countryIso = this.iti.getSelectedCountryData().iso2 || "";
|
|
58
|
+
this.numberChange.emit(num);
|
|
59
|
+
this.countryChange.emit(countryIso);
|
|
60
|
+
const isValid = this.usePreciseValidation
|
|
61
|
+
? this.iti.isValidNumberPrecise()
|
|
62
|
+
: this.iti.isValidNumber();
|
|
63
|
+
if (isValid) {
|
|
64
|
+
this.validityChange.emit(true);
|
|
65
|
+
this.errorCodeChange.emit(null);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.validityChange.emit(false);
|
|
69
|
+
this.errorCodeChange.emit(this.iti.getValidationError());
|
|
70
|
+
}
|
|
71
|
+
this.onChange(num);
|
|
72
|
+
this.onValidatorChange();
|
|
73
|
+
}
|
|
74
|
+
handleBlur() {
|
|
75
|
+
this.onTouched();
|
|
76
|
+
}
|
|
77
|
+
getInstance() {
|
|
78
|
+
return this.iti;
|
|
79
|
+
}
|
|
80
|
+
getInput() {
|
|
81
|
+
return this.inputRef.nativeElement;
|
|
82
|
+
}
|
|
83
|
+
ngOnDestroy() {
|
|
84
|
+
var _a;
|
|
85
|
+
(_a = this.iti) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
86
|
+
this.inputRef.nativeElement.removeEventListener("countrychange", this.countryChangeHandler);
|
|
87
|
+
}
|
|
88
|
+
applyInputProps() {
|
|
89
|
+
const props = this.inputProps;
|
|
90
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
91
|
+
this.inputRef.nativeElement.setAttribute(key, value);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// ============ ControlValueAccessor Implementation ============
|
|
95
|
+
writeValue(value) {
|
|
96
|
+
if (this.iti && value) {
|
|
97
|
+
this.iti.setNumber(value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
registerOnChange(fn) {
|
|
101
|
+
this.onChange = fn;
|
|
102
|
+
}
|
|
103
|
+
registerOnTouched(fn) {
|
|
104
|
+
this.onTouched = fn;
|
|
105
|
+
}
|
|
106
|
+
setDisabledState(isDisabled) {
|
|
107
|
+
this.disabled = isDisabled;
|
|
108
|
+
}
|
|
109
|
+
// ============ Validator Implementation ============
|
|
110
|
+
validate(control) {
|
|
111
|
+
if (!control.value || !this.iti) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const isValid = this.usePreciseValidation
|
|
115
|
+
? this.iti.isValidNumberPrecise()
|
|
116
|
+
: this.iti.isValidNumber();
|
|
117
|
+
if (isValid) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const errorCode = this.iti.getValidationError();
|
|
121
|
+
return {
|
|
122
|
+
invalidPhone: {
|
|
123
|
+
errorCode,
|
|
124
|
+
errorMessage: PHONE_ERROR_MESSAGES[errorCode],
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
registerOnValidatorChange(fn) {
|
|
129
|
+
this.onValidatorChange = fn;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
IntlTelInputComponent.ɵfac = function IntlTelInputComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || IntlTelInputComponent)(); };
|
|
133
|
+
IntlTelInputComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: IntlTelInputComponent, selectors: [["intl-tel-input"]], viewQuery: function IntlTelInputComponent_Query(rf, ctx) { if (rf & 1) {
|
|
134
|
+
i0.ɵɵviewQuery(_c0, 7);
|
|
135
|
+
} if (rf & 2) {
|
|
136
|
+
let _t;
|
|
137
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.inputRef = _t.first);
|
|
138
|
+
} }, inputs: { initialValue: "initialValue", usePreciseValidation: "usePreciseValidation", inputProps: "inputProps", disabled: "disabled", initOptions: "initOptions" }, outputs: { numberChange: "numberChange", countryChange: "countryChange", validityChange: "validityChange", errorCodeChange: "errorCodeChange" }, features: [i0.ɵɵProvidersFeature([
|
|
139
|
+
{
|
|
140
|
+
provide: NG_VALUE_ACCESSOR,
|
|
141
|
+
useExisting: forwardRef(() => IntlTelInputComponent),
|
|
142
|
+
multi: true,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
provide: NG_VALIDATORS,
|
|
146
|
+
useExisting: forwardRef(() => IntlTelInputComponent),
|
|
147
|
+
multi: true,
|
|
148
|
+
},
|
|
149
|
+
])], decls: 2, vars: 1, consts: [["inputRef", ""], ["type", "tel", 3, "input", "blur", "disabled"]], template: function IntlTelInputComponent_Template(rf, ctx) { if (rf & 1) {
|
|
150
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
151
|
+
i0.ɵɵelementStart(0, "input", 1, 0);
|
|
152
|
+
i0.ɵɵlistener("input", function IntlTelInputComponent_Template_input_input_0_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.handleInput()); })("blur", function IntlTelInputComponent_Template_input_blur_0_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.handleBlur()); });
|
|
153
|
+
i0.ɵɵelementEnd();
|
|
154
|
+
} if (rf & 2) {
|
|
155
|
+
i0.ɵɵproperty("disabled", ctx.disabled);
|
|
156
|
+
} }, encapsulation: 2 });
|
|
157
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(IntlTelInputComponent, [{
|
|
158
|
+
type: Component,
|
|
159
|
+
args: [{
|
|
160
|
+
selector: "intl-tel-input",
|
|
161
|
+
standalone: true,
|
|
162
|
+
template: `
|
|
163
|
+
<input
|
|
164
|
+
type="tel"
|
|
165
|
+
#inputRef
|
|
166
|
+
(input)="handleInput()"
|
|
167
|
+
(blur)="handleBlur()"
|
|
168
|
+
[disabled]="disabled"
|
|
169
|
+
/>
|
|
170
|
+
`,
|
|
171
|
+
providers: [
|
|
172
|
+
{
|
|
173
|
+
provide: NG_VALUE_ACCESSOR,
|
|
174
|
+
useExisting: forwardRef(() => IntlTelInputComponent),
|
|
175
|
+
multi: true,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
provide: NG_VALIDATORS,
|
|
179
|
+
useExisting: forwardRef(() => IntlTelInputComponent),
|
|
180
|
+
multi: true,
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
}]
|
|
184
|
+
}], null, { inputRef: [{
|
|
185
|
+
type: ViewChild,
|
|
186
|
+
args: ["inputRef", { static: true }]
|
|
187
|
+
}], initialValue: [{
|
|
188
|
+
type: Input
|
|
189
|
+
}], usePreciseValidation: [{
|
|
190
|
+
type: Input
|
|
191
|
+
}], inputProps: [{
|
|
192
|
+
type: Input
|
|
193
|
+
}], disabled: [{
|
|
194
|
+
type: Input
|
|
195
|
+
}], initOptions: [{
|
|
196
|
+
type: Input
|
|
197
|
+
}], numberChange: [{
|
|
198
|
+
type: Output
|
|
199
|
+
}], countryChange: [{
|
|
200
|
+
type: Output
|
|
201
|
+
}], validityChange: [{
|
|
202
|
+
type: Output
|
|
203
|
+
}], errorCodeChange: [{
|
|
204
|
+
type: Output
|
|
205
|
+
}] }); })();
|
|
206
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(IntlTelInputComponent, { className: "IntlTelInputComponent", filePath: "intl-tel-input/angularwithutils.ts", lineNumber: 43 }); })();
|