intl-tel-input 27.1.0 → 27.1.2

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.
@@ -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
  [
@@ -3602,6 +3603,9 @@ var Iti = class _Iti {
3602
3603
  this.#updateSelectedCountry(US.ISO2);
3603
3604
  }
3604
3605
  } else {
3606
+ if (isValidInitialCountry) {
3607
+ this.#updateSelectedCountry(resolvedInitialCountry);
3608
+ }
3605
3609
  this.#updateCountryFromNumber(value);
3606
3610
  }
3607
3611
  } else if (isValidInitialCountry) {
@@ -3684,6 +3688,14 @@ var Iti = class _Iti {
3684
3688
  this.#openDropdown();
3685
3689
  this.#ui.prefillSearchWithPlus();
3686
3690
  }
3691
+ //* Delete the character just typed (the one immediately before the caret). Used by Android workarounds where we can't preventDefault on keydown.
3692
+ #removeJustTypedChar(inputValue) {
3693
+ const currentCaretPos = this.#ui.telInputEl.selectionStart || 0;
3694
+ const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
3695
+ const valueAfterCaret = inputValue.substring(currentCaretPos);
3696
+ this.#setTelInputValue(valueBeforeCaret + valueAfterCaret);
3697
+ return currentCaretPos - 1;
3698
+ }
3687
3699
  //* Initialize the tel input listeners.
3688
3700
  #bindAllTelInputListeners() {
3689
3701
  this.#bindInputListener();
@@ -3708,13 +3720,20 @@ var Iti = class _Iti {
3708
3720
  }
3709
3721
  const inputValue = this.#getTelInputValue();
3710
3722
  if (this.#isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
3711
- const currentCaretPos = this.#ui.telInputEl.selectionStart || 0;
3712
- const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
3713
- const valueAfterCaret = inputValue.substring(currentCaretPos);
3714
- this.#setTelInputValue(valueBeforeCaret + valueAfterCaret);
3723
+ this.#removeJustTypedChar(inputValue);
3715
3724
  this.#openDropdownWithPlus();
3716
3725
  return;
3717
3726
  }
3727
+ if (this.#isAndroid && strictMode && (e?.data === " " || e?.data === "-" || e?.data === ".")) {
3728
+ const newCaretPos = this.#removeJustTypedChar(inputValue);
3729
+ this.#ui.telInputEl.setSelectionRange(newCaretPos, newCaretPos);
3730
+ this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3731
+ source: "key",
3732
+ rejectedInput: e.data,
3733
+ reason: "invalid"
3734
+ });
3735
+ return;
3736
+ }
3718
3737
  if (this.#updateCountryFromNumber(inputValue)) {
3719
3738
  this.#dispatchCountryChangeEvent();
3720
3739
  }
@@ -4487,7 +4506,7 @@ var attachUtils = (source) => {
4487
4506
  } else {
4488
4507
  return Promise.reject(
4489
4508
  new TypeError(
4490
- `The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`
4509
+ `The argument passed to attachUtils must be a function that returns a promise for the utils module, not ${typeof source}`
4491
4510
  )
4492
4511
  );
4493
4512
  }
@@ -4532,7 +4551,7 @@ var intlTelInput = Object.assign(
4532
4551
  attachUtils,
4533
4552
  startedLoadingUtils: false,
4534
4553
  startedLoadingAutoCountry: false,
4535
- version: "27.1.0"
4554
+ version: "27.1.2"
4536
4555
  }
4537
4556
  );
4538
4557
  var intlTelInput_default = intlTelInput;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * International Telephone Input v27.1.0
2
+ * International Telephone Input v27.1.2
3
3
  * git+https://github.com/jackocnr/intl-tel-input.git
4
4
  * Licensed under the MIT license
5
5
  */
@@ -41,11 +41,12 @@ var _factory = (() => {
41
41
  ],
42
42
  [
43
43
  "ax",
44
- // Åland Islands
44
+ // Åland Islands (AKA Aland Islands)
45
45
  "358",
46
46
  1,
47
47
  ["18", "4"],
48
48
  // (4 is a mobile range shared with FI)
49
+ // 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.
49
50
  "0"
50
51
  ],
51
52
  [
@@ -3633,6 +3634,9 @@ var _factory = (() => {
3633
3634
  this.#updateSelectedCountry(US.ISO2);
3634
3635
  }
3635
3636
  } else {
3637
+ if (isValidInitialCountry) {
3638
+ this.#updateSelectedCountry(resolvedInitialCountry);
3639
+ }
3636
3640
  this.#updateCountryFromNumber(value);
3637
3641
  }
3638
3642
  } else if (isValidInitialCountry) {
@@ -3715,6 +3719,14 @@ var _factory = (() => {
3715
3719
  this.#openDropdown();
3716
3720
  this.#ui.prefillSearchWithPlus();
3717
3721
  }
3722
+ //* Delete the character just typed (the one immediately before the caret). Used by Android workarounds where we can't preventDefault on keydown.
3723
+ #removeJustTypedChar(inputValue) {
3724
+ const currentCaretPos = this.#ui.telInputEl.selectionStart || 0;
3725
+ const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
3726
+ const valueAfterCaret = inputValue.substring(currentCaretPos);
3727
+ this.#setTelInputValue(valueBeforeCaret + valueAfterCaret);
3728
+ return currentCaretPos - 1;
3729
+ }
3718
3730
  //* Initialize the tel input listeners.
3719
3731
  #bindAllTelInputListeners() {
3720
3732
  this.#bindInputListener();
@@ -3739,13 +3751,20 @@ var _factory = (() => {
3739
3751
  }
3740
3752
  const inputValue = this.#getTelInputValue();
3741
3753
  if (this.#isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
3742
- const currentCaretPos = this.#ui.telInputEl.selectionStart || 0;
3743
- const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
3744
- const valueAfterCaret = inputValue.substring(currentCaretPos);
3745
- this.#setTelInputValue(valueBeforeCaret + valueAfterCaret);
3754
+ this.#removeJustTypedChar(inputValue);
3746
3755
  this.#openDropdownWithPlus();
3747
3756
  return;
3748
3757
  }
3758
+ if (this.#isAndroid && strictMode && (e?.data === " " || e?.data === "-" || e?.data === ".")) {
3759
+ const newCaretPos = this.#removeJustTypedChar(inputValue);
3760
+ this.#ui.telInputEl.setSelectionRange(newCaretPos, newCaretPos);
3761
+ this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3762
+ source: "key",
3763
+ rejectedInput: e.data,
3764
+ reason: "invalid"
3765
+ });
3766
+ return;
3767
+ }
3749
3768
  if (this.#updateCountryFromNumber(inputValue)) {
3750
3769
  this.#dispatchCountryChangeEvent();
3751
3770
  }
@@ -4518,7 +4537,7 @@ var _factory = (() => {
4518
4537
  } else {
4519
4538
  return Promise.reject(
4520
4539
  new TypeError(
4521
- `The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`
4540
+ `The argument passed to attachUtils must be a function that returns a promise for the utils module, not ${typeof source}`
4522
4541
  )
4523
4542
  );
4524
4543
  }
@@ -4563,7 +4582,7 @@ var _factory = (() => {
4563
4582
  attachUtils,
4564
4583
  startedLoadingUtils: false,
4565
4584
  startedLoadingAutoCountry: false,
4566
- version: "27.1.0"
4585
+ version: "27.1.2"
4567
4586
  }
4568
4587
  );
4569
4588
  var intlTelInput_default = intlTelInput;