intl-tel-input 23.0.9 → 23.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-tel-input",
3
- "version": "23.0.9",
3
+ "version": "23.0.10",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "keywords": [
6
6
  "international",
@@ -37,6 +37,7 @@
37
37
  "eslint-plugin-jasmine": "^4.1.3",
38
38
  "eslint-plugin-jest": "^28.5.0",
39
39
  "eslint-plugin-react": "^7.34.1",
40
+ "eslint-plugin-react-hooks": "^4.6.2",
40
41
  "evenizer": "^0.1.17",
41
42
  "google-closure-compiler": "^20240317.0.0",
42
43
  "google-closure-library": "^20230802.0.0",
@@ -123,6 +124,7 @@
123
124
  },
124
125
  "./i18n": "./build/js/i18n/index.js",
125
126
  "./i18n/*": "./build/js/i18n/*/index.js",
127
+ "./styles": "./build/css/intlTelInput.css",
126
128
  "./*": "./*"
127
129
  },
128
130
  "typesVersions": {
@@ -136,6 +138,9 @@
136
138
  }
137
139
  },
138
140
  "jest": {
139
- "moduleDirectories": ["node_modules", "build/js"]
141
+ "moduleDirectories": [
142
+ "node_modules",
143
+ "build/js"
144
+ ]
140
145
  }
141
146
  }
package/react/README.md CHANGED
@@ -1,5 +1,36 @@
1
- # Props
1
+ # IntlTelInput React Component
2
+ A React component wrapper for the [intl-tel-input](https://github.com/jackocnr/intl-tel-input) JavaScript plugin. View the source [here](https://github.com/jackocnr/intl-tel-input/blob/master/react/src/intl-tel-input/react.tsx).
2
3
 
4
+ ## Table of Contents
5
+ - [Demo and Examples](#demo-and-examples)
6
+ - [Getting Started](#getting-started)
7
+ - [Props](#props)
8
+ - [Accessing Instance Methods](#accessing-instance-methods)
9
+ - [Troubleshooting](#troubleshooting)
10
+
11
+ ## Demo and Examples
12
+ Check out [Storybook](https://intl-tel-input.com/storybook) where you can play with the various options. Alternatively, try it for yourself by downloading the project and opening /react/demo/validation.html (etc) in a browser.
13
+
14
+ ## Getting Started
15
+ ```js
16
+ import IntlTelInput from "intl-tel-input/react";
17
+ import "intl-tel-input/styles";
18
+
19
+ <IntlTelInput
20
+ onChangeNumber={setNumber}
21
+ onChangeValidity={setIsValid}
22
+ initOptions={{
23
+ initialCountry: "us",
24
+ utilsScript: "path/to/utils.js",
25
+ }}
26
+ />
27
+ ```
28
+
29
+ See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/ValidationApp.tsx) for a more fleshed out example of how to handle validation.
30
+
31
+ A note on the utils script (~250kb): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import `"intl-tel-input/reactWithUtils"` to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` import, then you should couple this with the `utilsScript` initialisation option, and point that to your hosted [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file (or just point it to a CDN e.g. "https://cdn.jsdelivr.net/npm/intl-tel-input@23.0.9/build/js/utils.js").
32
+
33
+ ## Props
3
34
  Here's a list of all of the current props you can pass to the IntlTelInput react component.
4
35
 
5
36
  **initialValue**
@@ -33,3 +64,23 @@ An object containing all of the [initialisation options](https://github.com/jack
33
64
  **inputProps**
34
65
  Type: `Object`
35
66
  The props to pass to the input element e.g. `className`, `placeholder`, `required`, `disabled`, `onBlur` etc.
67
+
68
+ ## Accessing Instance Methods
69
+
70
+ You can access the instance methods (`setNumber`, `setCountry`, `setPlaceholderNumberType` etc) by passing a ref into the IntlTelInput component (using the `ref` prop), and then calling `ref.current.getInstance()` e.g. `ref.current.getInstance().setNumber(...);`. See the [Set Number demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/SetNumberApp.tsx) for a full example. You can also access the input DOM element in a similar way: `ref.current.getInput()`.
71
+
72
+ ## Troubleshooting
73
+
74
+ **Error when toggle presence of IntlTelInput component**
75
+
76
+ Error message: `Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`
77
+
78
+ Solution: wrap the component in a div e.g.
79
+
80
+ ```js
81
+ {showIntlTelInput && (
82
+ <div>
83
+ <IntlTelInput />
84
+ </div>
85
+ )}
86
+ ```
@@ -2017,24 +2017,25 @@ var Iti = class {
2017
2017
  }
2018
2018
  //* Initialize the tel input listeners.
2019
2019
  _initTelInputListeners() {
2020
- const { strictMode, formatAsYouType, separateDialCode } = this.options;
2020
+ const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
2021
2021
  let userOverrideFormatting = false;
2022
2022
  this._handleInputEvent = (e) => {
2023
2023
  if (this._updateCountryFromNumber(this.telInput.value)) {
2024
2024
  this._triggerCountryChange();
2025
2025
  }
2026
- const isFormattingChar = e && e.data && /[^+0-9]/.test(e.data);
2027
- const isPaste = e && e.inputType === "insertFromPaste" && this.telInput.value;
2026
+ const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
2027
+ const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
2028
2028
  if (isFormattingChar || isPaste && !strictMode) {
2029
2029
  userOverrideFormatting = true;
2030
2030
  } else if (!/[^+0-9]/.test(this.telInput.value)) {
2031
2031
  userOverrideFormatting = false;
2032
2032
  }
2033
- if (formatAsYouType && !userOverrideFormatting) {
2033
+ const disableFormatOnSetNumber = e?.detail && e.detail["isSetNumber"] && !formatOnDisplay;
2034
+ if (formatAsYouType && !userOverrideFormatting && !disableFormatOnSetNumber) {
2034
2035
  const currentCaretPos = this.telInput.selectionStart || 0;
2035
2036
  const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
2036
2037
  const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
2037
- const isDeleteForwards = e && e.inputType === "deleteContentForward";
2038
+ const isDeleteForwards = e?.inputType === "deleteContentForward";
2038
2039
  const formattedValue = this._formatNumberAsYouType();
2039
2040
  const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
2040
2041
  this.telInput.value = formattedValue;
@@ -2076,10 +2077,11 @@ var Iti = class {
2076
2077
  return max && number.length > max ? number.substr(0, max) : number;
2077
2078
  }
2078
2079
  //* Trigger a custom event on the input.
2079
- _trigger(name) {
2080
- const e = new Event(name, {
2080
+ _trigger(name, detailProps = {}) {
2081
+ const e = new CustomEvent(name, {
2081
2082
  bubbles: true,
2082
- cancelable: true
2083
+ cancelable: true,
2084
+ detail: detailProps
2083
2085
  });
2084
2086
  this.telInput.dispatchEvent(e);
2085
2087
  }
@@ -2729,7 +2731,7 @@ var Iti = class {
2729
2731
  if (countryChanged) {
2730
2732
  this._triggerCountryChange();
2731
2733
  }
2732
- this._trigger("input");
2734
+ this._trigger("input", { isSetNumber: true });
2733
2735
  }
2734
2736
  //* Set the placeholder number typ
2735
2737
  setPlaceholderNumberType(type) {
@@ -2778,7 +2780,7 @@ var intlTelInput = Object.assign(
2778
2780
  //* A map from instance ID to instance object.
2779
2781
  instances: {},
2780
2782
  loadUtils,
2781
- version: "23.0.9"
2783
+ version: "23.0.10"
2782
2784
  }
2783
2785
  );
2784
2786
  var intl_tel_input_default = intlTelInput;
@@ -2805,7 +2807,7 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
2805
2807
  getInstance: () => itiRef.current,
2806
2808
  getInput: () => inputRef.current
2807
2809
  }));
2808
- const update = () => {
2810
+ const update = (0, import_react.useCallback)(() => {
2809
2811
  const num = itiRef.current?.getNumber() || "";
2810
2812
  const countryIso = itiRef.current?.getSelectedCountryData().iso2 || "";
2811
2813
  onChangeNumber(num);
@@ -2821,11 +2823,18 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
2821
2823
  onChangeErrorCode(errorCode);
2822
2824
  }
2823
2825
  }
2824
- };
2826
+ }, [onChangeCountry, onChangeErrorCode, onChangeNumber, onChangeValidity, usePreciseValidation]);
2827
+ (0, import_react.useEffect)(() => {
2828
+ if (inputRef.current) {
2829
+ itiRef.current = intl_tel_input_default(inputRef.current, initOptions);
2830
+ }
2831
+ return () => {
2832
+ itiRef.current?.destroy();
2833
+ };
2834
+ }, []);
2825
2835
  (0, import_react.useEffect)(() => {
2826
2836
  const inputRefCurrent = inputRef.current;
2827
2837
  if (inputRefCurrent) {
2828
- itiRef.current = intl_tel_input_default(inputRefCurrent, initOptions);
2829
2838
  inputRefCurrent.addEventListener("countrychange", update);
2830
2839
  itiRef.current.promise.then(update);
2831
2840
  }
@@ -2833,9 +2842,8 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
2833
2842
  if (inputRefCurrent) {
2834
2843
  inputRefCurrent.removeEventListener("countrychange", update);
2835
2844
  }
2836
- itiRef.current?.destroy();
2837
2845
  };
2838
- }, []);
2846
+ }, [update]);
2839
2847
  return /* @__PURE__ */ import_react.default.createElement(
2840
2848
  "input",
2841
2849
  {
@@ -1981,24 +1981,25 @@ var Iti = class {
1981
1981
  }
1982
1982
  //* Initialize the tel input listeners.
1983
1983
  _initTelInputListeners() {
1984
- const { strictMode, formatAsYouType, separateDialCode } = this.options;
1984
+ const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
1985
1985
  let userOverrideFormatting = false;
1986
1986
  this._handleInputEvent = (e) => {
1987
1987
  if (this._updateCountryFromNumber(this.telInput.value)) {
1988
1988
  this._triggerCountryChange();
1989
1989
  }
1990
- const isFormattingChar = e && e.data && /[^+0-9]/.test(e.data);
1991
- const isPaste = e && e.inputType === "insertFromPaste" && this.telInput.value;
1990
+ const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
1991
+ const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
1992
1992
  if (isFormattingChar || isPaste && !strictMode) {
1993
1993
  userOverrideFormatting = true;
1994
1994
  } else if (!/[^+0-9]/.test(this.telInput.value)) {
1995
1995
  userOverrideFormatting = false;
1996
1996
  }
1997
- if (formatAsYouType && !userOverrideFormatting) {
1997
+ const disableFormatOnSetNumber = e?.detail && e.detail["isSetNumber"] && !formatOnDisplay;
1998
+ if (formatAsYouType && !userOverrideFormatting && !disableFormatOnSetNumber) {
1998
1999
  const currentCaretPos = this.telInput.selectionStart || 0;
1999
2000
  const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
2000
2001
  const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
2001
- const isDeleteForwards = e && e.inputType === "deleteContentForward";
2002
+ const isDeleteForwards = e?.inputType === "deleteContentForward";
2002
2003
  const formattedValue = this._formatNumberAsYouType();
2003
2004
  const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
2004
2005
  this.telInput.value = formattedValue;
@@ -2040,10 +2041,11 @@ var Iti = class {
2040
2041
  return max && number.length > max ? number.substr(0, max) : number;
2041
2042
  }
2042
2043
  //* Trigger a custom event on the input.
2043
- _trigger(name) {
2044
- const e = new Event(name, {
2044
+ _trigger(name, detailProps = {}) {
2045
+ const e = new CustomEvent(name, {
2045
2046
  bubbles: true,
2046
- cancelable: true
2047
+ cancelable: true,
2048
+ detail: detailProps
2047
2049
  });
2048
2050
  this.telInput.dispatchEvent(e);
2049
2051
  }
@@ -2693,7 +2695,7 @@ var Iti = class {
2693
2695
  if (countryChanged) {
2694
2696
  this._triggerCountryChange();
2695
2697
  }
2696
- this._trigger("input");
2698
+ this._trigger("input", { isSetNumber: true });
2697
2699
  }
2698
2700
  //* Set the placeholder number typ
2699
2701
  setPlaceholderNumberType(type) {
@@ -2742,13 +2744,13 @@ var intlTelInput = Object.assign(
2742
2744
  //* A map from instance ID to instance object.
2743
2745
  instances: {},
2744
2746
  loadUtils,
2745
- version: "23.0.9"
2747
+ version: "23.0.10"
2746
2748
  }
2747
2749
  );
2748
2750
  var intl_tel_input_default = intlTelInput;
2749
2751
 
2750
2752
  // react/src/intl-tel-input/react.tsx
2751
- import React, { useRef, useEffect, forwardRef, useImperativeHandle } from "react";
2753
+ import React, { useRef, useEffect, forwardRef, useImperativeHandle, useCallback } from "react";
2752
2754
  var IntlTelInput = forwardRef(function IntlTelInput2({
2753
2755
  initialValue = "",
2754
2756
  onChangeNumber = () => {
@@ -2769,7 +2771,7 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
2769
2771
  getInstance: () => itiRef.current,
2770
2772
  getInput: () => inputRef.current
2771
2773
  }));
2772
- const update = () => {
2774
+ const update = useCallback(() => {
2773
2775
  const num = itiRef.current?.getNumber() || "";
2774
2776
  const countryIso = itiRef.current?.getSelectedCountryData().iso2 || "";
2775
2777
  onChangeNumber(num);
@@ -2785,11 +2787,18 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
2785
2787
  onChangeErrorCode(errorCode);
2786
2788
  }
2787
2789
  }
2788
- };
2790
+ }, [onChangeCountry, onChangeErrorCode, onChangeNumber, onChangeValidity, usePreciseValidation]);
2791
+ useEffect(() => {
2792
+ if (inputRef.current) {
2793
+ itiRef.current = intl_tel_input_default(inputRef.current, initOptions);
2794
+ }
2795
+ return () => {
2796
+ itiRef.current?.destroy();
2797
+ };
2798
+ }, []);
2789
2799
  useEffect(() => {
2790
2800
  const inputRefCurrent = inputRef.current;
2791
2801
  if (inputRefCurrent) {
2792
- itiRef.current = intl_tel_input_default(inputRefCurrent, initOptions);
2793
2802
  inputRefCurrent.addEventListener("countrychange", update);
2794
2803
  itiRef.current.promise.then(update);
2795
2804
  }
@@ -2797,9 +2806,8 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
2797
2806
  if (inputRefCurrent) {
2798
2807
  inputRefCurrent.removeEventListener("countrychange", update);
2799
2808
  }
2800
- itiRef.current?.destroy();
2801
2809
  };
2802
- }, []);
2810
+ }, [update]);
2803
2811
  return /* @__PURE__ */ React.createElement(
2804
2812
  "input",
2805
2813
  {
@@ -2017,24 +2017,25 @@ var Iti = class {
2017
2017
  }
2018
2018
  //* Initialize the tel input listeners.
2019
2019
  _initTelInputListeners() {
2020
- const { strictMode, formatAsYouType, separateDialCode } = this.options;
2020
+ const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
2021
2021
  let userOverrideFormatting = false;
2022
2022
  this._handleInputEvent = (e) => {
2023
2023
  if (this._updateCountryFromNumber(this.telInput.value)) {
2024
2024
  this._triggerCountryChange();
2025
2025
  }
2026
- const isFormattingChar = e && e.data && /[^+0-9]/.test(e.data);
2027
- const isPaste = e && e.inputType === "insertFromPaste" && this.telInput.value;
2026
+ const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
2027
+ const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
2028
2028
  if (isFormattingChar || isPaste && !strictMode) {
2029
2029
  userOverrideFormatting = true;
2030
2030
  } else if (!/[^+0-9]/.test(this.telInput.value)) {
2031
2031
  userOverrideFormatting = false;
2032
2032
  }
2033
- if (formatAsYouType && !userOverrideFormatting) {
2033
+ const disableFormatOnSetNumber = e?.detail && e.detail["isSetNumber"] && !formatOnDisplay;
2034
+ if (formatAsYouType && !userOverrideFormatting && !disableFormatOnSetNumber) {
2034
2035
  const currentCaretPos = this.telInput.selectionStart || 0;
2035
2036
  const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
2036
2037
  const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
2037
- const isDeleteForwards = e && e.inputType === "deleteContentForward";
2038
+ const isDeleteForwards = e?.inputType === "deleteContentForward";
2038
2039
  const formattedValue = this._formatNumberAsYouType();
2039
2040
  const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
2040
2041
  this.telInput.value = formattedValue;
@@ -2076,10 +2077,11 @@ var Iti = class {
2076
2077
  return max && number.length > max ? number.substr(0, max) : number;
2077
2078
  }
2078
2079
  //* Trigger a custom event on the input.
2079
- _trigger(name) {
2080
- const e = new Event(name, {
2080
+ _trigger(name, detailProps = {}) {
2081
+ const e = new CustomEvent(name, {
2081
2082
  bubbles: true,
2082
- cancelable: true
2083
+ cancelable: true,
2084
+ detail: detailProps
2083
2085
  });
2084
2086
  this.telInput.dispatchEvent(e);
2085
2087
  }
@@ -2729,7 +2731,7 @@ var Iti = class {
2729
2731
  if (countryChanged) {
2730
2732
  this._triggerCountryChange();
2731
2733
  }
2732
- this._trigger("input");
2734
+ this._trigger("input", { isSetNumber: true });
2733
2735
  }
2734
2736
  //* Set the placeholder number typ
2735
2737
  setPlaceholderNumberType(type) {
@@ -2778,7 +2780,7 @@ var intlTelInput = Object.assign(
2778
2780
  //* A map from instance ID to instance object.
2779
2781
  instances: {},
2780
2782
  loadUtils,
2781
- version: "23.0.9"
2783
+ version: "23.0.10"
2782
2784
  }
2783
2785
  );
2784
2786
  var intl_tel_input_default = intlTelInput;
@@ -9003,7 +9005,7 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
9003
9005
  getInstance: () => itiRef.current,
9004
9006
  getInput: () => inputRef.current
9005
9007
  }));
9006
- const update = () => {
9008
+ const update = (0, import_react.useCallback)(() => {
9007
9009
  const num = itiRef.current?.getNumber() || "";
9008
9010
  const countryIso = itiRef.current?.getSelectedCountryData().iso2 || "";
9009
9011
  onChangeNumber(num);
@@ -9019,11 +9021,18 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
9019
9021
  onChangeErrorCode(errorCode);
9020
9022
  }
9021
9023
  }
9022
- };
9024
+ }, [onChangeCountry, onChangeErrorCode, onChangeNumber, onChangeValidity, usePreciseValidation]);
9025
+ (0, import_react.useEffect)(() => {
9026
+ if (inputRef.current) {
9027
+ itiRef.current = intlTelInputWithUtils_default(inputRef.current, initOptions);
9028
+ }
9029
+ return () => {
9030
+ itiRef.current?.destroy();
9031
+ };
9032
+ }, []);
9023
9033
  (0, import_react.useEffect)(() => {
9024
9034
  const inputRefCurrent = inputRef.current;
9025
9035
  if (inputRefCurrent) {
9026
- itiRef.current = intlTelInputWithUtils_default(inputRefCurrent, initOptions);
9027
9036
  inputRefCurrent.addEventListener("countrychange", update);
9028
9037
  itiRef.current.promise.then(update);
9029
9038
  }
@@ -9031,9 +9040,8 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
9031
9040
  if (inputRefCurrent) {
9032
9041
  inputRefCurrent.removeEventListener("countrychange", update);
9033
9042
  }
9034
- itiRef.current?.destroy();
9035
9043
  };
9036
- }, []);
9044
+ }, [update]);
9037
9045
  return /* @__PURE__ */ import_react.default.createElement(
9038
9046
  "input",
9039
9047
  {
@@ -1981,24 +1981,25 @@ var Iti = class {
1981
1981
  }
1982
1982
  //* Initialize the tel input listeners.
1983
1983
  _initTelInputListeners() {
1984
- const { strictMode, formatAsYouType, separateDialCode } = this.options;
1984
+ const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
1985
1985
  let userOverrideFormatting = false;
1986
1986
  this._handleInputEvent = (e) => {
1987
1987
  if (this._updateCountryFromNumber(this.telInput.value)) {
1988
1988
  this._triggerCountryChange();
1989
1989
  }
1990
- const isFormattingChar = e && e.data && /[^+0-9]/.test(e.data);
1991
- const isPaste = e && e.inputType === "insertFromPaste" && this.telInput.value;
1990
+ const isFormattingChar = e?.data && /[^+0-9]/.test(e.data);
1991
+ const isPaste = e?.inputType === "insertFromPaste" && this.telInput.value;
1992
1992
  if (isFormattingChar || isPaste && !strictMode) {
1993
1993
  userOverrideFormatting = true;
1994
1994
  } else if (!/[^+0-9]/.test(this.telInput.value)) {
1995
1995
  userOverrideFormatting = false;
1996
1996
  }
1997
- if (formatAsYouType && !userOverrideFormatting) {
1997
+ const disableFormatOnSetNumber = e?.detail && e.detail["isSetNumber"] && !formatOnDisplay;
1998
+ if (formatAsYouType && !userOverrideFormatting && !disableFormatOnSetNumber) {
1998
1999
  const currentCaretPos = this.telInput.selectionStart || 0;
1999
2000
  const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
2000
2001
  const relevantCharsBeforeCaret = valueBeforeCaret.replace(/[^+0-9]/g, "").length;
2001
- const isDeleteForwards = e && e.inputType === "deleteContentForward";
2002
+ const isDeleteForwards = e?.inputType === "deleteContentForward";
2002
2003
  const formattedValue = this._formatNumberAsYouType();
2003
2004
  const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
2004
2005
  this.telInput.value = formattedValue;
@@ -2040,10 +2041,11 @@ var Iti = class {
2040
2041
  return max && number.length > max ? number.substr(0, max) : number;
2041
2042
  }
2042
2043
  //* Trigger a custom event on the input.
2043
- _trigger(name) {
2044
- const e = new Event(name, {
2044
+ _trigger(name, detailProps = {}) {
2045
+ const e = new CustomEvent(name, {
2045
2046
  bubbles: true,
2046
- cancelable: true
2047
+ cancelable: true,
2048
+ detail: detailProps
2047
2049
  });
2048
2050
  this.telInput.dispatchEvent(e);
2049
2051
  }
@@ -2693,7 +2695,7 @@ var Iti = class {
2693
2695
  if (countryChanged) {
2694
2696
  this._triggerCountryChange();
2695
2697
  }
2696
- this._trigger("input");
2698
+ this._trigger("input", { isSetNumber: true });
2697
2699
  }
2698
2700
  //* Set the placeholder number typ
2699
2701
  setPlaceholderNumberType(type) {
@@ -2742,7 +2744,7 @@ var intlTelInput = Object.assign(
2742
2744
  //* A map from instance ID to instance object.
2743
2745
  instances: {},
2744
2746
  loadUtils,
2745
- version: "23.0.9"
2747
+ version: "23.0.10"
2746
2748
  }
2747
2749
  );
2748
2750
  var intl_tel_input_default = intlTelInput;
@@ -8946,7 +8948,7 @@ intl_tel_input_default.utils = utils_default;
8946
8948
  var intlTelInputWithUtils_default = intl_tel_input_default;
8947
8949
 
8948
8950
  // react/src/intl-tel-input/reactWithUtils.tsx
8949
- import React, { useRef, useEffect, forwardRef, useImperativeHandle } from "react";
8951
+ import React, { useRef, useEffect, forwardRef, useImperativeHandle, useCallback } from "react";
8950
8952
  var IntlTelInput = forwardRef(function IntlTelInput2({
8951
8953
  initialValue = "",
8952
8954
  onChangeNumber = () => {
@@ -8967,7 +8969,7 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
8967
8969
  getInstance: () => itiRef.current,
8968
8970
  getInput: () => inputRef.current
8969
8971
  }));
8970
- const update = () => {
8972
+ const update = useCallback(() => {
8971
8973
  const num = itiRef.current?.getNumber() || "";
8972
8974
  const countryIso = itiRef.current?.getSelectedCountryData().iso2 || "";
8973
8975
  onChangeNumber(num);
@@ -8983,11 +8985,18 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
8983
8985
  onChangeErrorCode(errorCode);
8984
8986
  }
8985
8987
  }
8986
- };
8988
+ }, [onChangeCountry, onChangeErrorCode, onChangeNumber, onChangeValidity, usePreciseValidation]);
8989
+ useEffect(() => {
8990
+ if (inputRef.current) {
8991
+ itiRef.current = intlTelInputWithUtils_default(inputRef.current, initOptions);
8992
+ }
8993
+ return () => {
8994
+ itiRef.current?.destroy();
8995
+ };
8996
+ }, []);
8987
8997
  useEffect(() => {
8988
8998
  const inputRefCurrent = inputRef.current;
8989
8999
  if (inputRefCurrent) {
8990
- itiRef.current = intlTelInputWithUtils_default(inputRefCurrent, initOptions);
8991
9000
  inputRefCurrent.addEventListener("countrychange", update);
8992
9001
  itiRef.current.promise.then(update);
8993
9002
  }
@@ -8995,9 +9004,8 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
8995
9004
  if (inputRefCurrent) {
8996
9005
  inputRefCurrent.removeEventListener("countrychange", update);
8997
9006
  }
8998
- itiRef.current?.destroy();
8999
9007
  };
9000
- }, []);
9008
+ }, [update]);
9001
9009
  return /* @__PURE__ */ React.createElement(
9002
9010
  "input",
9003
9011
  {