intl-tel-input 27.1.1 → 27.1.3

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  See the Github Releases page for changelog: https://github.com/jackocnr/intl-tel-input/releases
2
2
 
3
- Or to view a specific version, e.g. v27.1.1, update the URL accordingly, e.g. https://github.com/jackocnr/intl-tel-input/releases/tag/v27.1.1
3
+ Or to view a specific version, e.g. v27.1.3, update the URL accordingly, e.g. https://github.com/jackocnr/intl-tel-input/releases/tag/v27.1.3
4
4
 
5
5
  ## Breaking changes
6
6
 
@@ -58,6 +58,7 @@ declare class IntlTelInput implements AfterViewInit, OnDestroy, OnChanges, Contr
58
58
  private lastEmittedValidity?;
59
59
  private lastEmittedErrorCode?;
60
60
  private pendingWriteValue?;
61
+ private pendingUpdate;
61
62
  private onChange;
62
63
  private onTouched;
63
64
  private onValidatorChange;
@@ -10,11 +10,12 @@ var rawCountryData = [
10
10
  ],
11
11
  [
12
12
  "ax",
13
- // Åland Islands
13
+ // Åland Islands (AKA Aland Islands)
14
14
  "358",
15
15
  1,
16
16
  ["18", "4"],
17
17
  // (4 is a mobile range shared with FI)
18
+ // NOTE: https://en.wikipedia.org/wiki/Telephone%20numbers%20in%20%C3%85land says some 4XXX ranges (e.g. 4570) are specific to AX, but LPN doesn't respect this (https://libphonenumber.appspot.com/phonenumberparser?number=%2B3584570123456 says region=FI) so we won't either. Also it's too much of a maintenance burden to keep track of. Keep the 4 area code range here so that if the user selects AX and types this kind of number, we wont change the flag to FI. Whereas if they type a FI-only range then we will.
18
19
  "0"
19
20
  ],
20
21
  [
@@ -2974,7 +2975,7 @@ var UI = class _UI {
2974
2975
  this.#selectedCountryEl.focus();
2975
2976
  }
2976
2977
  }
2977
- if (!this.#options.countrySearch && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
2978
+ if (!this.#options.countrySearch && e.target !== this.telInputEl && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
2978
2979
  e.stopPropagation();
2979
2980
  if (queryTimer) {
2980
2981
  clearTimeout(queryTimer);
@@ -3482,6 +3483,8 @@ var Iti = class _Iti {
3482
3483
  #isActive = true;
3483
3484
  #abortController;
3484
3485
  #numerals;
3486
+ //* Tracks whether the user has typed/pasted their own formatting chars, so AYT-formatting should back off.
3487
+ #userOverrideFormatting = false;
3485
3488
  #autoCountryDeferred;
3486
3489
  #utilsDeferred;
3487
3490
  constructor(input, customOptions = {}) {
@@ -3572,6 +3575,9 @@ var Iti = class _Iti {
3572
3575
  this.#updateSelectedCountry(US.ISO2);
3573
3576
  }
3574
3577
  } else {
3578
+ if (isValidInitialCountry) {
3579
+ this.#updateSelectedCountry(resolvedInitialCountry);
3580
+ }
3575
3581
  this.#updateCountryFromNumber(value);
3576
3582
  }
3577
3583
  } else if (isValidInitialCountry) {
@@ -3668,176 +3674,211 @@ var Iti = class _Iti {
3668
3674
  this.#bindKeydownListener();
3669
3675
  this.#bindPasteListener();
3670
3676
  }
3671
- #bindInputListener() {
3672
- const {
3673
- strictMode,
3674
- formatAsYouType,
3675
- separateDialCode,
3676
- allowDropdown,
3677
- countrySearch
3678
- } = this.#options;
3679
- let userOverrideFormatting = false;
3680
- if (REGEX.ALPHA_UNICODE.test(this.#getTelInputValue())) {
3681
- userOverrideFormatting = true;
3677
+ //* Android workaround for handling plus when separateDialCode enabled (as impossible to handle with keydown/keyup, for which e.key always returns "Unidentified", see https://stackoverflow.com/q/59584061/217866)
3678
+ #handleAndroidPlusKey(inputValue) {
3679
+ this.#removeJustTypedChar(inputValue);
3680
+ this.#openDropdownWithPlus();
3681
+ }
3682
+ //* Android strictMode workaround: the keydown-based filter can't block these because e.key is "Unidentified" on Android virtual keyboards, so strip them here on input.
3683
+ #handleAndroidStrictReject(inputValue, rejectedInput) {
3684
+ const newCaretPos = this.#removeJustTypedChar(inputValue);
3685
+ this.#ui.telInputEl.setSelectionRange(newCaretPos, newCaretPos);
3686
+ this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3687
+ source: "key",
3688
+ rejectedInput,
3689
+ reason: "invalid"
3690
+ });
3691
+ }
3692
+ //* Format the input value using libphonenumber's AYT formatter, preserving caret position (called after an input event).
3693
+ #formatAsYouType(inputValue, isDeleteForwards) {
3694
+ const currentCaretPos = this.#ui.telInputEl.selectionStart || 0;
3695
+ const valueBeforeCaret = inputValue.substring(0, currentCaretPos);
3696
+ const relevantCharsBeforeCaret = valueBeforeCaret.replace(
3697
+ REGEX.NON_PLUS_NUMERIC_GLOBAL,
3698
+ ""
3699
+ ).length;
3700
+ const fullNumber = this.#getFullNumber();
3701
+ const formattedValue = formatNumberAsYouType(
3702
+ fullNumber,
3703
+ inputValue,
3704
+ intlTelInput.utils,
3705
+ this.#selectedCountry,
3706
+ this.#options.separateDialCode
3707
+ );
3708
+ const newCaretPos = computeNewCaretPosition(
3709
+ relevantCharsBeforeCaret,
3710
+ formattedValue,
3711
+ currentCaretPos,
3712
+ isDeleteForwards
3713
+ );
3714
+ this.#setTelInputValue(formattedValue);
3715
+ this.#ui.telInputEl.setSelectionRange(newCaretPos, newCaretPos);
3716
+ }
3717
+ //* If separateDialCode AND typed dial code (e.g. from paste or autofill, or from typing a dial code when countrySearch disabled), then remove the typed dial code.
3718
+ //* Only strip when a full dial code is actually present — otherwise a lone typed "+" (or partial prefix) would get erased.
3719
+ #stripTypedDialCode(inputValue) {
3720
+ if (inputValue.startsWith("+") && this.#selectedCountry && this.#getDialCode(inputValue)) {
3721
+ const cleanNumber = stripSeparateDialCode(
3722
+ inputValue,
3723
+ true,
3724
+ true,
3725
+ this.#selectedCountry
3726
+ );
3727
+ this.#setTelInputValue(cleanNumber);
3682
3728
  }
3683
- const handleInputEvent = (e) => {
3684
- if (e?.detail && e.detail["isCountryChange"]) {
3685
- return;
3686
- }
3687
- const inputValue = this.#getTelInputValue();
3688
- if (this.#isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
3689
- this.#removeJustTypedChar(inputValue);
3690
- this.#openDropdownWithPlus();
3691
- return;
3692
- }
3693
- if (this.#isAndroid && strictMode && (e?.data === " " || e?.data === "-" || e?.data === ".")) {
3694
- const newCaretPos = this.#removeJustTypedChar(inputValue);
3695
- this.#ui.telInputEl.setSelectionRange(newCaretPos, newCaretPos);
3696
- this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3697
- source: "key",
3698
- rejectedInput: e.data,
3699
- reason: "invalid"
3700
- });
3701
- return;
3702
- }
3703
- if (this.#updateCountryFromNumber(inputValue)) {
3704
- this.#dispatchCountryChangeEvent();
3705
- }
3706
- const isFormattingChar = e?.data && REGEX.NON_PLUS_NUMERIC.test(e.data);
3707
- const isPaste = e?.inputType === INPUT_TYPES.PASTE && inputValue;
3708
- if (isFormattingChar || isPaste && !strictMode) {
3709
- userOverrideFormatting = true;
3710
- } else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
3711
- userOverrideFormatting = false;
3712
- }
3713
- const isSetNumber = e?.detail && e.detail["isSetNumber"];
3714
- const isAscii = this.#numerals.isAscii();
3715
- if (formatAsYouType && !userOverrideFormatting && !isSetNumber && isAscii) {
3716
- const currentCaretPos = this.#ui.telInputEl.selectionStart || 0;
3717
- const valueBeforeCaret = inputValue.substring(0, currentCaretPos);
3718
- const relevantCharsBeforeCaret = valueBeforeCaret.replace(
3719
- REGEX.NON_PLUS_NUMERIC_GLOBAL,
3720
- ""
3721
- ).length;
3722
- const isDeleteForwards = e?.inputType === INPUT_TYPES.DELETE_FORWARD;
3723
- const fullNumber = this.#getFullNumber();
3724
- const formattedValue = formatNumberAsYouType(
3725
- fullNumber,
3726
- inputValue,
3727
- intlTelInput.utils,
3728
- this.#selectedCountry,
3729
- separateDialCode
3730
- );
3731
- const newCaretPos = computeNewCaretPosition(
3732
- relevantCharsBeforeCaret,
3733
- formattedValue,
3734
- currentCaretPos,
3735
- isDeleteForwards
3736
- );
3737
- this.#setTelInputValue(formattedValue);
3738
- this.#ui.telInputEl.setSelectionRange(newCaretPos, newCaretPos);
3739
- }
3740
- if (separateDialCode && inputValue.startsWith("+") && this.#selectedCountry?.dialCode) {
3741
- const cleanNumber = stripSeparateDialCode(
3742
- inputValue,
3743
- true,
3744
- separateDialCode,
3745
- this.#selectedCountry
3746
- );
3747
- this.#setTelInputValue(cleanNumber);
3748
- }
3749
- };
3729
+ }
3730
+ #bindInputListener() {
3731
+ this.#userOverrideFormatting = REGEX.ALPHA_UNICODE.test(
3732
+ this.#getTelInputValue()
3733
+ );
3750
3734
  this.#ui.telInputEl.addEventListener(
3751
3735
  "input",
3752
- handleInputEvent,
3736
+ this.#handleInputEvent,
3753
3737
  {
3754
3738
  signal: this.#abortController.signal
3755
3739
  }
3756
3740
  );
3757
3741
  }
3742
+ //* On input event: (1) Update selected country, (2) Format-as-you-type.
3743
+ //* Note that this fires AFTER the input is updated.
3744
+ #handleInputEvent = (e) => {
3745
+ const { strictMode, formatAsYouType, separateDialCode, allowDropdown, countrySearch } = this.#options;
3746
+ const detail = e?.detail;
3747
+ if (detail?.["isCountryChange"]) {
3748
+ return;
3749
+ }
3750
+ const inputValue = this.#getTelInputValue();
3751
+ if (this.#isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
3752
+ this.#handleAndroidPlusKey(inputValue);
3753
+ return;
3754
+ }
3755
+ if (this.#isAndroid && strictMode && (e?.data === " " || e?.data === "-" || e?.data === ".")) {
3756
+ this.#handleAndroidStrictReject(inputValue, e.data);
3757
+ return;
3758
+ }
3759
+ if (this.#updateCountryFromNumber(inputValue)) {
3760
+ this.#dispatchCountryChangeEvent();
3761
+ }
3762
+ const isFormattingChar = e?.data && REGEX.NON_PLUS_NUMERIC.test(e.data);
3763
+ const isPaste = e?.inputType === INPUT_TYPES.PASTE && inputValue;
3764
+ if (isFormattingChar || isPaste && !strictMode) {
3765
+ this.#userOverrideFormatting = true;
3766
+ } else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
3767
+ this.#userOverrideFormatting = false;
3768
+ }
3769
+ if (formatAsYouType && !this.#userOverrideFormatting && !detail?.["isSetNumber"] && this.#numerals.isAscii()) {
3770
+ this.#formatAsYouType(
3771
+ inputValue,
3772
+ e?.inputType === INPUT_TYPES.DELETE_FORWARD
3773
+ );
3774
+ }
3775
+ if (separateDialCode) {
3776
+ this.#stripTypedDialCode(inputValue);
3777
+ }
3778
+ };
3758
3779
  #bindKeydownListener() {
3759
- const { strictMode, separateDialCode, allowDropdown, countrySearch } = this.#options;
3780
+ const { strictMode, separateDialCode } = this.#options;
3760
3781
  if (!strictMode && !separateDialCode) {
3761
3782
  return;
3762
3783
  }
3763
- const handleKeydownEvent = (e) => {
3764
- if (!e.key || e.key.length !== 1 || e.altKey || e.ctrlKey || e.metaKey) {
3765
- return;
3766
- }
3767
- if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
3768
- e.preventDefault();
3769
- this.#openDropdownWithPlus();
3770
- return;
3771
- }
3772
- if (!strictMode) {
3773
- return;
3774
- }
3775
- const inputValue = this.#getTelInputValue();
3776
- const alreadyHasPlus = inputValue.startsWith("+");
3777
- const isInitialPlus = !alreadyHasPlus && this.#ui.telInputEl.selectionStart === 0 && e.key === "+";
3778
- const normalisedKey = this.#numerals.normalise(e.key);
3779
- const isNumeric = /^[0-9]$/.test(normalisedKey);
3780
- const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
3781
- const input = this.#ui.telInputEl;
3782
- const selStart = input.selectionStart;
3783
- const selEnd = input.selectionEnd;
3784
- const before = inputValue.slice(0, selStart ?? void 0);
3785
- const after = inputValue.slice(selEnd ?? void 0);
3786
- const newValue = before + normalisedKey + after;
3787
- const newFullNumber = this.#buildFullNumber(newValue);
3788
- let hasExceededMaxLength = false;
3789
- if (intlTelInput.utils && this.#maxCoreNumberLength) {
3790
- const coreNumber = intlTelInput.utils.getCoreNumber(
3791
- newFullNumber,
3792
- this.#selectedCountry?.iso2
3793
- );
3794
- hasExceededMaxLength = coreNumber.length > this.#maxCoreNumberLength;
3795
- }
3796
- const newCountry = this.#resolveCountryChangeFromNumber(newFullNumber);
3797
- const isChangingDialCode = newCountry !== null;
3798
- if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
3799
- this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3800
- source: "key",
3801
- rejectedInput: e.key,
3802
- reason: !isAllowedChar ? "invalid" : "max-length"
3803
- });
3804
- e.preventDefault();
3805
- }
3806
- };
3807
- this.#ui.telInputEl.addEventListener("keydown", handleKeydownEvent, {
3784
+ this.#ui.telInputEl.addEventListener("keydown", this.#handleKeydownEvent, {
3808
3785
  signal: this.#abortController.signal
3809
3786
  });
3810
3787
  }
3788
+ //* On keydown event: (1) if strictMode then prevent invalid characters, (2) if separateDialCode then handle plus key
3789
+ //* Note that this fires BEFORE the input is updated.
3790
+ #handleKeydownEvent = (e) => {
3791
+ const { strictMode, separateDialCode, allowDropdown, countrySearch } = this.#options;
3792
+ if (!e.key || e.key.length !== 1 || e.altKey || e.ctrlKey || e.metaKey) {
3793
+ return;
3794
+ }
3795
+ if (separateDialCode && allowDropdown && countrySearch && e.key === "+") {
3796
+ e.preventDefault();
3797
+ this.#openDropdownWithPlus();
3798
+ return;
3799
+ }
3800
+ if (!strictMode) {
3801
+ return;
3802
+ }
3803
+ const inputValue = this.#getTelInputValue();
3804
+ const alreadyHasPlus = inputValue.startsWith("+");
3805
+ const isInitialPlus = !alreadyHasPlus && this.#ui.telInputEl.selectionStart === 0 && e.key === "+";
3806
+ const normalisedKey = this.#numerals.normalise(e.key);
3807
+ const isNumeric = /^[0-9]$/.test(normalisedKey);
3808
+ const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
3809
+ const input = this.#ui.telInputEl;
3810
+ const selStart = input.selectionStart;
3811
+ const selEnd = input.selectionEnd;
3812
+ const before = inputValue.slice(0, selStart ?? void 0);
3813
+ const after = inputValue.slice(selEnd ?? void 0);
3814
+ const newValue = before + normalisedKey + after;
3815
+ const newFullNumber = this.#buildFullNumber(newValue);
3816
+ let hasExceededMaxLength = false;
3817
+ if (intlTelInput.utils && this.#maxCoreNumberLength) {
3818
+ const coreNumber = intlTelInput.utils.getCoreNumber(
3819
+ newFullNumber,
3820
+ this.#selectedCountry?.iso2
3821
+ );
3822
+ hasExceededMaxLength = coreNumber.length > this.#maxCoreNumberLength;
3823
+ }
3824
+ const newCountry = this.#resolveCountryChangeFromNumber(newFullNumber);
3825
+ const isChangingDialCode = newCountry !== null;
3826
+ if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
3827
+ this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3828
+ source: "key",
3829
+ rejectedInput: e.key,
3830
+ reason: !isAllowedChar ? "invalid" : "max-length"
3831
+ });
3832
+ e.preventDefault();
3833
+ }
3834
+ };
3811
3835
  #bindPasteListener() {
3812
3836
  if (!this.#options.strictMode) {
3813
3837
  return;
3814
3838
  }
3815
- const handlePasteEvent = (e) => {
3816
- e.preventDefault();
3817
- const input = this.#ui.telInputEl;
3818
- const selStart = input.selectionStart;
3819
- const selEnd = input.selectionEnd;
3820
- const inputValue = this.#getTelInputValue();
3821
- const before = inputValue.slice(0, selStart ?? void 0);
3822
- const after = inputValue.slice(selEnd ?? void 0);
3823
- const iso2 = this.#selectedCountry?.iso2;
3824
- const pastedRaw = e.clipboardData.getData("text");
3825
- const pasted = this.#numerals.normalise(pastedRaw);
3826
- const initialCharSelected = selStart === 0 && selEnd > 0;
3827
- const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
3828
- const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
3829
- const hasLeadingPlus = allowedChars.startsWith("+");
3830
- const numerics = allowedChars.replace(/\+/g, "");
3831
- const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
3832
- let newValue = before + sanitised + after;
3833
- let rejectReason = sanitised !== pasted ? "invalid" : null;
3834
- if (newValue.length > 5 && intlTelInput.utils) {
3835
- let coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
3836
- while (coreNumber.length === 0 && newValue.length > 0) {
3837
- newValue = newValue.slice(0, -1);
3838
- coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
3839
- }
3840
- if (!coreNumber) {
3839
+ this.#ui.telInputEl.addEventListener("paste", this.#handlePasteEvent, {
3840
+ signal: this.#abortController.signal
3841
+ });
3842
+ }
3843
+ #handlePasteEvent = (e) => {
3844
+ e.preventDefault();
3845
+ const input = this.#ui.telInputEl;
3846
+ const selStart = input.selectionStart;
3847
+ const selEnd = input.selectionEnd;
3848
+ const inputValue = this.#getTelInputValue();
3849
+ const before = inputValue.slice(0, selStart ?? void 0);
3850
+ const after = inputValue.slice(selEnd ?? void 0);
3851
+ const iso2 = this.#selectedCountry?.iso2;
3852
+ const pastedRaw = e.clipboardData.getData("text");
3853
+ const pasted = this.#numerals.normalise(pastedRaw);
3854
+ const initialCharSelected = selStart === 0 && selEnd > 0;
3855
+ const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
3856
+ const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
3857
+ const hasLeadingPlus = allowedChars.startsWith("+");
3858
+ const numerics = allowedChars.replace(/\+/g, "");
3859
+ const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
3860
+ let newValue = before + sanitised + after;
3861
+ let rejectReason = sanitised !== pasted ? "invalid" : null;
3862
+ if (newValue.length > 5 && intlTelInput.utils) {
3863
+ let coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
3864
+ while (coreNumber.length === 0 && newValue.length > 0) {
3865
+ newValue = newValue.slice(0, -1);
3866
+ coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
3867
+ }
3868
+ if (!coreNumber) {
3869
+ this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3870
+ source: "paste",
3871
+ rejectedInput: pastedRaw,
3872
+ reason: "max-length"
3873
+ });
3874
+ return;
3875
+ }
3876
+ if (this.#maxCoreNumberLength && coreNumber.length > this.#maxCoreNumberLength) {
3877
+ if (input.selectionEnd === inputValue.length) {
3878
+ const trimLength = coreNumber.length - this.#maxCoreNumberLength;
3879
+ newValue = newValue.slice(0, newValue.length - trimLength);
3880
+ rejectReason = "max-length";
3881
+ } else {
3841
3882
  this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3842
3883
  source: "paste",
3843
3884
  rejectedInput: pastedRaw,
@@ -3845,37 +3886,20 @@ var Iti = class _Iti {
3845
3886
  });
3846
3887
  return;
3847
3888
  }
3848
- if (this.#maxCoreNumberLength && coreNumber.length > this.#maxCoreNumberLength) {
3849
- if (input.selectionEnd === inputValue.length) {
3850
- const trimLength = coreNumber.length - this.#maxCoreNumberLength;
3851
- newValue = newValue.slice(0, newValue.length - trimLength);
3852
- rejectReason = "max-length";
3853
- } else {
3854
- this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3855
- source: "paste",
3856
- rejectedInput: pastedRaw,
3857
- reason: "max-length"
3858
- });
3859
- return;
3860
- }
3861
- }
3862
- }
3863
- this.#setTelInputValue(newValue);
3864
- const caretPos = selStart + sanitised.length;
3865
- input.setSelectionRange(caretPos, caretPos);
3866
- input.dispatchEvent(new InputEvent("input", { bubbles: true }));
3867
- if (rejectReason) {
3868
- this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3869
- source: "paste",
3870
- rejectedInput: pastedRaw,
3871
- reason: rejectReason
3872
- });
3873
3889
  }
3874
- };
3875
- this.#ui.telInputEl.addEventListener("paste", handlePasteEvent, {
3876
- signal: this.#abortController.signal
3877
- });
3878
- }
3890
+ }
3891
+ this.#setTelInputValue(newValue);
3892
+ const caretPos = selStart + sanitised.length;
3893
+ input.setSelectionRange(caretPos, caretPos);
3894
+ input.dispatchEvent(new InputEvent("input", { bubbles: true }));
3895
+ if (rejectReason) {
3896
+ this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3897
+ source: "paste",
3898
+ rejectedInput: pastedRaw,
3899
+ reason: rejectReason
3900
+ });
3901
+ }
3902
+ };
3879
3903
  //* Adhere to the input's maxlength attr.
3880
3904
  #truncateToMaxLength(number) {
3881
3905
  const max = Number(this.#ui.telInputEl.getAttribute("maxlength"));
@@ -4472,7 +4496,7 @@ var attachUtils = (source) => {
4472
4496
  } else {
4473
4497
  return Promise.reject(
4474
4498
  new TypeError(
4475
- `The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`
4499
+ `The argument passed to attachUtils must be a function that returns a promise for the utils module, not ${typeof source}`
4476
4500
  )
4477
4501
  );
4478
4502
  }
@@ -4517,7 +4541,7 @@ var intlTelInput = Object.assign(
4517
4541
  attachUtils,
4518
4542
  startedLoadingUtils: false,
4519
4543
  startedLoadingAutoCountry: false,
4520
- version: "27.1.1"
4544
+ version: "27.1.3"
4521
4545
  }
4522
4546
  );
4523
4547
  var intlTelInput_default = intlTelInput;
@@ -4586,6 +4610,8 @@ var IntlTelInput = class _IntlTelInput {
4586
4610
  lastEmittedErrorCode;
4587
4611
  // writeValue may be called by Angular forms before utils has loaded; queue it until then
4588
4612
  pendingWriteValue;
4613
+ // if an input event fires before utils has loaded, we defer the update until the promise resolves
4614
+ pendingUpdate = false;
4589
4615
  // eslint-disable-next-line class-methods-use-this
4590
4616
  onChange = () => {
4591
4617
  };
@@ -4614,6 +4640,12 @@ var IntlTelInput = class _IntlTelInput {
4614
4640
  } else if (this.initialValue) {
4615
4641
  this.iti.setNumber(this.initialValue);
4616
4642
  }
4643
+ if (this.pendingUpdate) {
4644
+ this.pendingUpdate = false;
4645
+ this.handleInput();
4646
+ } else if (this.inputRef.nativeElement.value) {
4647
+ this.onValidatorChange();
4648
+ }
4617
4649
  });
4618
4650
  }
4619
4651
  buildInitOptions() {
@@ -4665,6 +4697,10 @@ var IntlTelInput = class _IntlTelInput {
4665
4697
  if (!this.iti) {
4666
4698
  return;
4667
4699
  }
4700
+ if (!intlTelInput_default.utils) {
4701
+ this.pendingUpdate = true;
4702
+ return;
4703
+ }
4668
4704
  const num = this.iti.getNumber() ?? "";
4669
4705
  const countryIso = this.iti.getSelectedCountryData()?.iso2 ?? "";
4670
4706
  let hasChanged = false;
@@ -4779,7 +4815,7 @@ var IntlTelInput = class _IntlTelInput {
4779
4815
  }
4780
4816
  // ============ Validator Implementation ============
4781
4817
  validate(_control) {
4782
- if (!this.iti || !this.iti.getNumber()) {
4818
+ if (!this.iti || !intlTelInput_default.utils || !this.iti.getNumber()) {
4783
4819
  return null;
4784
4820
  }
4785
4821
  const isValid = this.usePreciseValidation ? this.iti.isValidNumberPrecise() : this.iti.isValidNumber();