intl-tel-input 28.0.8 → 28.1.0

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 (64) hide show
  1. package/dist/js/data.js +1 -1
  2. package/dist/js/data.min.js +1 -1
  3. package/dist/js/i18n/ar.js +3 -3
  4. package/dist/js/i18n/bg.js +2 -2
  5. package/dist/js/i18n/bn.js +2 -2
  6. package/dist/js/i18n/bs.js +2 -2
  7. package/dist/js/i18n/ca.js +2 -2
  8. package/dist/js/i18n/cs.js +2 -2
  9. package/dist/js/i18n/da.js +2 -2
  10. package/dist/js/i18n/de.js +2 -2
  11. package/dist/js/i18n/el.js +2 -2
  12. package/dist/js/i18n/es.js +2 -2
  13. package/dist/js/i18n/et.js +2 -2
  14. package/dist/js/i18n/fa.js +2 -5
  15. package/dist/js/i18n/fi.js +2 -2
  16. package/dist/js/i18n/fil.js +16 -0
  17. package/dist/js/i18n/fr.js +2 -2
  18. package/dist/js/i18n/he.js +19 -0
  19. package/dist/js/i18n/hi.js +2 -2
  20. package/dist/js/i18n/hr.js +2 -2
  21. package/dist/js/i18n/hu.js +2 -5
  22. package/dist/js/i18n/hy.js +19 -0
  23. package/dist/js/i18n/id.js +2 -5
  24. package/dist/js/i18n/index.js +9 -0
  25. package/dist/js/i18n/is.js +21 -0
  26. package/dist/js/i18n/it.js +2 -2
  27. package/dist/js/i18n/ja.js +2 -5
  28. package/dist/js/i18n/kn.js +2 -2
  29. package/dist/js/i18n/ko.js +2 -5
  30. package/dist/js/i18n/lt.js +2 -2
  31. package/dist/js/i18n/lv.js +24 -0
  32. package/dist/js/i18n/mk.js +21 -0
  33. package/dist/js/i18n/mr.js +2 -2
  34. package/dist/js/i18n/ms.js +16 -0
  35. package/dist/js/i18n/nl.js +2 -2
  36. package/dist/js/i18n/no.js +2 -2
  37. package/dist/js/i18n/pl.js +2 -2
  38. package/dist/js/i18n/pt.js +2 -2
  39. package/dist/js/i18n/ro.js +4 -4
  40. package/dist/js/i18n/ru.js +2 -2
  41. package/dist/js/i18n/sk.js +5 -8
  42. package/dist/js/i18n/sl.js +2 -2
  43. package/dist/js/i18n/sq.js +2 -2
  44. package/dist/js/i18n/sr.js +2 -2
  45. package/dist/js/i18n/sv.js +2 -5
  46. package/dist/js/i18n/sw.js +19 -0
  47. package/dist/js/i18n/ta.js +19 -0
  48. package/dist/js/i18n/te.js +2 -2
  49. package/dist/js/i18n/th.js +2 -5
  50. package/dist/js/i18n/tr.js +2 -5
  51. package/dist/js/i18n/uk.js +2 -2
  52. package/dist/js/i18n/ur.js +2 -2
  53. package/dist/js/i18n/uz.js +2 -5
  54. package/dist/js/i18n/vi.js +2 -5
  55. package/dist/js/i18n/zh-hk.js +2 -5
  56. package/dist/js/i18n/zh.js +2 -5
  57. package/dist/js/i18n.d.ts +49 -31
  58. package/dist/js/intlTelInput.js +90 -47
  59. package/dist/js/intlTelInput.min.js +2 -2
  60. package/dist/js/intlTelInput.mjs +89 -46
  61. package/dist/js/intlTelInputWithUtils.js +90 -47
  62. package/dist/js/intlTelInputWithUtils.min.js +2 -2
  63. package/dist/js/intlTelInputWithUtils.mjs +89 -46
  64. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * International Telephone Input v28.0.8
2
+ * International Telephone Input v28.1.0
3
3
  * git+https://github.com/jackocnr/intl-tel-input.git
4
4
  * Licensed under the MIT license
5
5
  */
@@ -1798,7 +1798,8 @@ var _factory = (() => {
1798
1798
  FLAG: "iti__flag",
1799
1799
  LOADING: "iti__loading",
1800
1800
  COUNTRY_ITEM: "iti__country",
1801
- HIGHLIGHT: "iti__highlight"
1801
+ HIGHLIGHT: "iti__highlight",
1802
+ STRICT_REJECT_ANIMATION: "iti__strict-reject-animation"
1802
1803
  };
1803
1804
  var KEYS = {
1804
1805
  ARROW_UP: "ArrowUp",
@@ -3154,7 +3155,6 @@ var _factory = (() => {
3154
3155
  }
3155
3156
  //* Keyboard navigation while the dropdown is open: arrow keys navigate, hidden-search keys filter,
3156
3157
  //* and enter/escape invoke the caller's callbacks (which handle country selection / dropdown close).
3157
- //* Listens on document because key events go there when no input has focus.
3158
3158
  //* Uses keydown rather than keypress so non-char keys (arrow, esc) fire and so holding a key repeats.
3159
3159
  #bindDropdownKeydownListener(signal, onEnter, onEscape) {
3160
3160
  let query = "";
@@ -3178,7 +3178,7 @@ var _factory = (() => {
3178
3178
  this.#selectedCountryEl.focus();
3179
3179
  }
3180
3180
  }
3181
- if (!this.#options.countrySearch && e.target !== this.telInputEl && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
3181
+ if (!this.#options.countrySearch && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
3182
3182
  e.stopPropagation();
3183
3183
  if (queryTimer) {
3184
3184
  clearTimeout(queryTimer);
@@ -3190,7 +3190,8 @@ var _factory = (() => {
3190
3190
  }, TIMINGS.HIDDEN_SEARCH_RESET_MS);
3191
3191
  }
3192
3192
  };
3193
- document.addEventListener("keydown", handleKeydown, { signal });
3193
+ this.#selectedCountryEl?.addEventListener("keydown", handleKeydown, { signal });
3194
+ this.#dropdownContentEl?.addEventListener("keydown", handleKeydown, { signal });
3194
3195
  }
3195
3196
  //* Wire up country search input listener: typing filters the list, the clear button resets it.
3196
3197
  #bindSearchInputListener(signal) {
@@ -3355,6 +3356,26 @@ var _factory = (() => {
3355
3356
  setLoading(isLoading) {
3356
3357
  this.#selectedFlagEl.classList.toggle(CLASSES.LOADING, isLoading);
3357
3358
  }
3359
+ //* Play the strict-reject animation (shake, or background-colour flash under prefers-reduced-motion) on the wrapper.
3360
+ //* Called when strictMode rejects the whole input (keystroke, or whole paste).
3361
+ //* Uses the wrapper (not the input) so any separateDialCode / country button move together with the input.
3362
+ playStrictRejectAnimation() {
3363
+ if (!this.#options.strictRejectAnimation) {
3364
+ return;
3365
+ }
3366
+ const wrapperEl = this.telInputEl.parentElement;
3367
+ if (!wrapperEl) {
3368
+ return;
3369
+ }
3370
+ wrapperEl.classList.remove(CLASSES.STRICT_REJECT_ANIMATION);
3371
+ void wrapperEl.offsetWidth;
3372
+ wrapperEl.classList.add(CLASSES.STRICT_REJECT_ANIMATION);
3373
+ wrapperEl.addEventListener(
3374
+ "animationend",
3375
+ () => wrapperEl.classList.remove(CLASSES.STRICT_REJECT_ANIMATION),
3376
+ { once: true }
3377
+ );
3378
+ }
3358
3379
  isLoading() {
3359
3380
  return this.#selectedFlagEl.classList.contains(CLASSES.LOADING);
3360
3381
  }
@@ -3660,6 +3681,7 @@ var _factory = (() => {
3660
3681
  #numerals;
3661
3682
  //* Tracks whether the user has typed/pasted their own formatting chars, so AYT-formatting should back off.
3662
3683
  #userOverrideFormatting = false;
3684
+ #strictPasteSnapshot = null;
3663
3685
  #autoCountryDeferred;
3664
3686
  #utilsDeferred;
3665
3687
  constructor(input, customOptions = {}) {
@@ -3870,7 +3892,7 @@ var _factory = (() => {
3870
3892
  #handleAndroidStrictReject(inputValue, rejectedInput) {
3871
3893
  const newCaretPos = this.#removeJustTypedChar(inputValue);
3872
3894
  this.#ui.telInputEl.setSelectionRange(newCaretPos, newCaretPos);
3873
- this.#playStrictRejectAnimation();
3895
+ this.#ui.playStrictRejectAnimation();
3874
3896
  this.#dispatchEvent(EVENTS.STRICT_REJECT, {
3875
3897
  source: "key",
3876
3898
  rejectedInput,
@@ -3941,21 +3963,30 @@ var _factory = (() => {
3941
3963
  if (detail?.["isCountryChange"]) {
3942
3964
  return;
3943
3965
  }
3944
- const inputValue = this.#getTelInputValue();
3945
- if (this.#isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
3966
+ let inputValue = this.#getTelInputValue();
3967
+ const isPaste = e?.inputType === INPUT_TYPES.PASTE;
3968
+ const isStrictPaste = strictMode && isPaste;
3969
+ if (this.#isAndroid && !isPaste && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
3946
3970
  this.#handleAndroidPlusKey(inputValue);
3947
3971
  return;
3948
3972
  }
3949
- if (this.#isAndroid && strictMode && (e?.data === " " || e?.data === "-" || e?.data === ".")) {
3973
+ if (this.#isAndroid && !isPaste && strictMode && (e?.data === " " || e?.data === "-" || e?.data === ".")) {
3950
3974
  this.#handleAndroidStrictReject(inputValue, e.data);
3951
3975
  return;
3952
3976
  }
3977
+ if (isStrictPaste) {
3978
+ const didRejectPaste = this.#handleStrictPasteInputEvent();
3979
+ if (didRejectPaste) {
3980
+ return;
3981
+ }
3982
+ inputValue = this.#getTelInputValue();
3983
+ }
3953
3984
  if (this.#updateCountryFromNumber(inputValue)) {
3954
3985
  this.#dispatchCountryChangeEvent();
3955
3986
  }
3956
- const isFormattingChar = e?.data && REGEX.NON_PLUS_NUMERIC.test(e.data);
3957
- const isPaste = e?.inputType === INPUT_TYPES.PASTE && inputValue;
3958
- if (isFormattingChar || isPaste && !strictMode) {
3987
+ const isFormattingChar = !isStrictPaste && e?.data && REGEX.NON_PLUS_NUMERIC.test(e.data);
3988
+ const isNonStrictPaste = isPaste && inputValue && !strictMode;
3989
+ if (isFormattingChar || isNonStrictPaste) {
3959
3990
  this.#userOverrideFormatting = true;
3960
3991
  } else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
3961
3992
  this.#userOverrideFormatting = false;
@@ -4018,7 +4049,7 @@ var _factory = (() => {
4018
4049
  const newCountry = this.#resolveCountryChangeFromNumber(newFullNumber);
4019
4050
  const isChangingDialCode = newCountry !== null;
4020
4051
  if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
4021
- this.#playStrictRejectAnimation();
4052
+ this.#ui.playStrictRejectAnimation();
4022
4053
  this.#dispatchEvent(EVENTS.STRICT_REJECT, {
4023
4054
  source: "key",
4024
4055
  rejectedInput: e.key,
@@ -4035,20 +4066,37 @@ var _factory = (() => {
4035
4066
  signal: this.#abortController.signal
4036
4067
  });
4037
4068
  }
4038
- // Handle paste events when strictMode is enabled by sanitising the pasted content before it's inserted into the input, and rejecting it entirely if it would result in an invalid number
4069
+ // In strict mode, remember paste details before the browser inserts the pasted text.
4070
+ // The actual sanitisation runs on the following input event so native paste stays enabled.
4039
4071
  #handleStrictPasteEvent = (e) => {
4040
- e.preventDefault();
4041
4072
  const input = this.#ui.telInputEl;
4042
- const selStart = input.selectionStart;
4043
- const selEnd = input.selectionEnd;
4044
4073
  const inputValue = this.#getTelInputValue();
4045
- const before = inputValue.slice(0, selStart ?? void 0);
4046
- const after = inputValue.slice(selEnd ?? void 0);
4074
+ this.#strictPasteSnapshot = {
4075
+ pastedRaw: e.clipboardData?.getData("text") ?? "",
4076
+ value: inputValue,
4077
+ selectionStart: input.selectionStart ?? inputValue.length,
4078
+ selectionEnd: input.selectionEnd ?? inputValue.length
4079
+ };
4080
+ };
4081
+ // Handle paste input events when strictMode is enabled by sanitising the pasted content after
4082
+ // the browser inserts it, and rejecting it entirely if it would result in an invalid number.
4083
+ #handleStrictPasteInputEvent() {
4084
+ const input = this.#ui.telInputEl;
4085
+ const pasteSnapshot = this.#strictPasteSnapshot;
4086
+ this.#strictPasteSnapshot = null;
4087
+ if (!pasteSnapshot) {
4088
+ return false;
4089
+ }
4090
+ const pastedRaw = pasteSnapshot.pastedRaw;
4091
+ const originalValue = pasteSnapshot.value;
4092
+ const selStart = pasteSnapshot.selectionStart;
4093
+ const selEnd = pasteSnapshot.selectionEnd;
4094
+ const before = originalValue.slice(0, selStart);
4095
+ const after = originalValue.slice(selEnd);
4047
4096
  const iso2 = this.#selectedCountry?.iso2;
4048
- const pastedRaw = e.clipboardData.getData("text");
4049
4097
  const pasted = this.#numerals.normalise(pastedRaw);
4050
4098
  const initialCharSelected = selStart === 0 && selEnd > 0;
4051
- const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
4099
+ const allowLeadingPlus = !originalValue.startsWith("+") || initialCharSelected;
4052
4100
  const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
4053
4101
  const hasLeadingPlus = allowedChars.startsWith("+");
4054
4102
  const numerics = allowedChars.replace(/\+/g, "");
@@ -4056,13 +4104,14 @@ var _factory = (() => {
4056
4104
  let newValue = before + sanitised + after;
4057
4105
  let rejectReason = sanitised !== pasted ? "invalid" : null;
4058
4106
  if (newValue.length > 30) {
4059
- this.#playStrictRejectAnimation();
4107
+ this.#ui.playStrictRejectAnimation();
4060
4108
  this.#dispatchEvent(EVENTS.STRICT_REJECT, {
4061
4109
  source: "paste",
4062
4110
  rejectedInput: pastedRaw,
4063
4111
  reason: "max-length"
4064
4112
  });
4065
- return;
4113
+ this.#restoreValueBeforeStrictPaste(pasteSnapshot);
4114
+ return true;
4066
4115
  }
4067
4116
  if (newValue.length > 5 && intlTelInput.utils) {
4068
4117
  let coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
@@ -4071,37 +4120,38 @@ var _factory = (() => {
4071
4120
  coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
4072
4121
  }
4073
4122
  if (!coreNumber) {
4074
- this.#playStrictRejectAnimation();
4123
+ this.#ui.playStrictRejectAnimation();
4075
4124
  this.#dispatchEvent(EVENTS.STRICT_REJECT, {
4076
4125
  source: "paste",
4077
4126
  rejectedInput: pastedRaw,
4078
4127
  reason: "max-length"
4079
4128
  });
4080
- return;
4129
+ this.#restoreValueBeforeStrictPaste(pasteSnapshot);
4130
+ return true;
4081
4131
  }
4082
4132
  if (this.#maxCoreNumberLength && coreNumber.length > this.#maxCoreNumberLength) {
4083
- if (input.selectionEnd === inputValue.length) {
4133
+ if (selEnd === originalValue.length) {
4084
4134
  const trimLength = coreNumber.length - this.#maxCoreNumberLength;
4085
4135
  newValue = newValue.slice(0, newValue.length - trimLength);
4086
4136
  rejectReason = "max-length";
4087
4137
  } else {
4088
- this.#playStrictRejectAnimation();
4138
+ this.#ui.playStrictRejectAnimation();
4089
4139
  this.#dispatchEvent(EVENTS.STRICT_REJECT, {
4090
4140
  source: "paste",
4091
4141
  rejectedInput: pastedRaw,
4092
4142
  reason: "max-length"
4093
4143
  });
4094
- return;
4144
+ this.#restoreValueBeforeStrictPaste(pasteSnapshot);
4145
+ return true;
4095
4146
  }
4096
4147
  }
4097
4148
  }
4098
4149
  this.#setTelInputValue(newValue);
4099
4150
  const caretPos = selStart + sanitised.length;
4100
4151
  input.setSelectionRange(caretPos, caretPos);
4101
- input.dispatchEvent(new InputEvent("input", { bubbles: true }));
4102
4152
  if (rejectReason) {
4103
4153
  if (pasted.length > 0 && sanitised.length === 0) {
4104
- this.#playStrictRejectAnimation();
4154
+ this.#ui.playStrictRejectAnimation();
4105
4155
  }
4106
4156
  this.#dispatchEvent(EVENTS.STRICT_REJECT, {
4107
4157
  source: "paste",
@@ -4109,27 +4159,20 @@ var _factory = (() => {
4109
4159
  reason: rejectReason
4110
4160
  });
4111
4161
  }
4112
- };
4162
+ return false;
4163
+ }
4164
+ #restoreValueBeforeStrictPaste(pasteSnapshot) {
4165
+ this.#setTelInputValue(pasteSnapshot.value);
4166
+ this.#ui.telInputEl.setSelectionRange(
4167
+ pasteSnapshot.selectionStart,
4168
+ pasteSnapshot.selectionEnd
4169
+ );
4170
+ }
4113
4171
  //* Adhere to the input's maxlength attr.
4114
4172
  #truncateToMaxLength(number) {
4115
4173
  const max = Number(this.#ui.telInputEl.getAttribute("maxlength"));
4116
4174
  return max && number.length > max ? number.substring(0, max) : number;
4117
4175
  }
4118
- //* Play the strict-reject animation (shake, or background-colour flash under prefers-reduced-motion) on the wrapper.
4119
- //* Called when strictMode rejects the whole input (keystroke, or whole paste).
4120
- //* Uses the wrapper (not the input) so any separateDialCode / country button move together with the input.
4121
- #playStrictRejectAnimation() {
4122
- if (!this.#options.strictRejectAnimation) {
4123
- return;
4124
- }
4125
- const wrapperEl = this.#ui.telInputEl.parentElement;
4126
- if (!wrapperEl) {
4127
- return;
4128
- }
4129
- wrapperEl.classList.remove("iti__strict-reject-animation");
4130
- void wrapperEl.offsetWidth;
4131
- wrapperEl.classList.add("iti__strict-reject-animation");
4132
- }
4133
4176
  //* Trigger a custom event on the input (typed via ItiEventMap).
4134
4177
  #dispatchEvent(name, detailProps = {}) {
4135
4178
  const e = new CustomEvent(name, {
@@ -4749,7 +4792,7 @@ var _factory = (() => {
4749
4792
  attachUtils,
4750
4793
  startedLoadingUtils: false,
4751
4794
  startedLoadingAutoCountry: false,
4752
- version: "28.0.8",
4795
+ version: "28.1.0",
4753
4796
  NUMBER_FORMAT,
4754
4797
  NUMBER_TYPE,
4755
4798
  VALIDATION_ERROR