intl-tel-input 23.7.4 → 23.8.1
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 +49 -43
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +3 -0
- package/build/js/intlTelInput.js +31 -6
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +31 -6
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +1 -1
- package/react/README.md +21 -17
- package/react/build/IntlTelInput.cjs +37 -6
- package/react/build/IntlTelInput.d.ts +5 -0
- package/react/build/IntlTelInput.js +37 -6
- package/react/build/IntlTelInputWithUtils.cjs +37 -6
- package/react/build/IntlTelInputWithUtils.js +37 -6
package/package.json
CHANGED
package/react/README.md
CHANGED
|
@@ -27,45 +27,49 @@ import "intl-tel-input/styles";
|
|
|
27
27
|
/>
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/ValidationApp.tsx) for a more fleshed
|
|
30
|
+
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.
|
|
31
31
|
|
|
32
|
-
A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/reactWithUtils"` instead, 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 - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@23.
|
|
32
|
+
A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/reactWithUtils"` instead, 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 - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@23.8.1/build/js/utils.js"`.
|
|
33
33
|
|
|
34
34
|
## Props
|
|
35
35
|
Here's a list of all of the current props you can pass to the IntlTelInput react component.
|
|
36
36
|
|
|
37
|
+
**disabled**
|
|
38
|
+
Type: `Boolean`, Default: `false`
|
|
39
|
+
Sets the disabled attribute of both the telephone input and selected country button. _Note: we recommend using this instead of `inputProps.disabled`._
|
|
40
|
+
|
|
37
41
|
**initialValue**
|
|
38
42
|
Type: `String`
|
|
39
43
|
The initial value to put in the input. This will get auto-formatted on init (according to `formatOnDisplay` initialisation option). IntlTelInput is an uncontrolled input, and so will ignore any changes to this value.
|
|
40
44
|
|
|
41
|
-
**
|
|
42
|
-
Type: `
|
|
43
|
-
|
|
45
|
+
**initOptions**
|
|
46
|
+
Type: `Object`
|
|
47
|
+
An object containing all of the [initialisation options](https://github.com/jackocnr/intl-tel-input?tab=readme-ov-file#initialisation-options) to pass to the plugin. You can use these exactly the same as when using the plugin with pure JavaScript.
|
|
48
|
+
|
|
49
|
+
**inputProps**
|
|
50
|
+
Type: `Object`
|
|
51
|
+
The props to pass to the input element e.g. `className`, `placeholder`, `required`, `onBlur` etc. _Note: we recommend using the separate `disabled` prop instead of `inputProps.disabled`._
|
|
44
52
|
|
|
45
53
|
**onChangeCountry**
|
|
46
54
|
Type: `Function`
|
|
47
55
|
A handler to be called when the selected country changes. It will be passed the new country iso2 code e.g. "gb" for UK.
|
|
48
56
|
|
|
49
|
-
**onChangeValidity**
|
|
50
|
-
Type: `Function`
|
|
51
|
-
A handler to be called when the number validity changes e.g. to true/false. It will be passed the new isValid boolean.
|
|
52
|
-
|
|
53
57
|
**onChangeErrorCode**
|
|
54
58
|
Type: `Function`
|
|
55
59
|
A handler to be called when the number validation error changes. It will be passed the new error code (or `null`).
|
|
56
60
|
|
|
61
|
+
**onChangeNumber**
|
|
62
|
+
Type: `Function`
|
|
63
|
+
A handler to be called when the number changes. It will be passed the new number.
|
|
64
|
+
|
|
65
|
+
**onChangeValidity**
|
|
66
|
+
Type: `Function`
|
|
67
|
+
A handler to be called when the number validity changes e.g. to true/false. It will be passed the new isValid boolean.
|
|
68
|
+
|
|
57
69
|
**usePreciseValidation**
|
|
58
70
|
Type: `Boolean`, Default: `false`
|
|
59
71
|
By default we use `isValidNumber` for validation, but if you'd rather use `isValidNumberPrecise` you can set this to `true`.
|
|
60
72
|
|
|
61
|
-
**initOptions**
|
|
62
|
-
Type: `Object`
|
|
63
|
-
An object containing all of the [initialisation options](https://github.com/jackocnr/intl-tel-input?tab=readme-ov-file#initialisation-options) to pass to the plugin. You can use these exactly the same as when using the plugin with pure JavaScript.
|
|
64
|
-
|
|
65
|
-
**inputProps**
|
|
66
|
-
Type: `Object`
|
|
67
|
-
The props to pass to the input element e.g. `className`, `placeholder`, `required`, `disabled`, `onBlur` etc.
|
|
68
|
-
|
|
69
73
|
## Accessing Instance Methods
|
|
70
74
|
|
|
71
75
|
You can access all of the plugin's [instance methods](https://github.com/jackocnr/intl-tel-input/blob/master/README.md#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()`.
|
|
@@ -1992,6 +1992,9 @@ var Iti = class {
|
|
|
1992
1992
|
_initTelInputListeners() {
|
|
1993
1993
|
const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
|
|
1994
1994
|
let userOverrideFormatting = false;
|
|
1995
|
+
if (/\p{L}/u.test(this.telInput.value)) {
|
|
1996
|
+
userOverrideFormatting = true;
|
|
1997
|
+
}
|
|
1995
1998
|
const openDropdownWithPlus = () => {
|
|
1996
1999
|
this._openDropdown();
|
|
1997
2000
|
this.searchInput.value = "+";
|
|
@@ -2732,17 +2735,31 @@ var Iti = class {
|
|
|
2732
2735
|
//* Validate the input val
|
|
2733
2736
|
isValidNumber() {
|
|
2734
2737
|
const val = this._getFullNumber();
|
|
2735
|
-
|
|
2736
|
-
|
|
2738
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2739
|
+
if (alphaCharPosition > -1) {
|
|
2740
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2741
|
+
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
|
|
2742
|
+
const isValid = this._utilsIsPossibleNumber(val);
|
|
2743
|
+
return beforeAlphaIsValid && isValid;
|
|
2737
2744
|
}
|
|
2745
|
+
return this._utilsIsPossibleNumber(val);
|
|
2746
|
+
}
|
|
2747
|
+
_utilsIsPossibleNumber(val) {
|
|
2738
2748
|
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
|
|
2739
2749
|
}
|
|
2740
2750
|
//* Validate the input val (precise)
|
|
2741
2751
|
isValidNumberPrecise() {
|
|
2742
2752
|
const val = this._getFullNumber();
|
|
2743
|
-
|
|
2744
|
-
|
|
2753
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2754
|
+
if (alphaCharPosition > -1) {
|
|
2755
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2756
|
+
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
|
|
2757
|
+
const isValid = this._utilsIsValidNumber(val);
|
|
2758
|
+
return beforeAlphaIsValid && isValid;
|
|
2745
2759
|
}
|
|
2760
|
+
return this._utilsIsValidNumber(val);
|
|
2761
|
+
}
|
|
2762
|
+
_utilsIsValidNumber(val) {
|
|
2746
2763
|
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
2747
2764
|
}
|
|
2748
2765
|
//* Update the selected country, and update the input val accordingly.
|
|
@@ -2770,6 +2787,14 @@ var Iti = class {
|
|
|
2770
2787
|
this.options.placeholderNumberType = type;
|
|
2771
2788
|
this._updatePlaceholder();
|
|
2772
2789
|
}
|
|
2790
|
+
setDisabled(disabled) {
|
|
2791
|
+
this.telInput.disabled = disabled;
|
|
2792
|
+
if (disabled) {
|
|
2793
|
+
this.selectedCountry.setAttribute("disabled", "true");
|
|
2794
|
+
} else {
|
|
2795
|
+
this.selectedCountry.removeAttribute("disabled");
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2773
2798
|
};
|
|
2774
2799
|
var loadUtils = (path) => {
|
|
2775
2800
|
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
@@ -2813,7 +2838,7 @@ var intlTelInput = Object.assign(
|
|
|
2813
2838
|
//* A map from instance ID to instance object.
|
|
2814
2839
|
instances: {},
|
|
2815
2840
|
loadUtils,
|
|
2816
|
-
version: "23.
|
|
2841
|
+
version: "23.8.1"
|
|
2817
2842
|
}
|
|
2818
2843
|
);
|
|
2819
2844
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -2832,7 +2857,8 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
|
|
|
2832
2857
|
},
|
|
2833
2858
|
usePreciseValidation = false,
|
|
2834
2859
|
initOptions = {},
|
|
2835
|
-
inputProps = {}
|
|
2860
|
+
inputProps = {},
|
|
2861
|
+
disabled = void 0
|
|
2836
2862
|
}, ref) {
|
|
2837
2863
|
const inputRef = (0, import_react.useRef)(null);
|
|
2838
2864
|
const itiRef = (0, import_react.useRef)(null);
|
|
@@ -2877,6 +2903,11 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
|
|
|
2877
2903
|
}
|
|
2878
2904
|
};
|
|
2879
2905
|
}, [update]);
|
|
2906
|
+
(0, import_react.useEffect)(() => {
|
|
2907
|
+
if (itiRef.current && disabled !== void 0) {
|
|
2908
|
+
itiRef.current.setDisabled(disabled);
|
|
2909
|
+
}
|
|
2910
|
+
}, [disabled]);
|
|
2880
2911
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
2881
2912
|
"input",
|
|
2882
2913
|
{
|
|
@@ -969,10 +969,13 @@ declare module "intl-tel-input" {
|
|
|
969
969
|
getSelectedCountryData(): SelectedCountryData;
|
|
970
970
|
getValidationError(): number;
|
|
971
971
|
isValidNumber(): boolean | null;
|
|
972
|
+
private _utilsIsPossibleNumber;
|
|
972
973
|
isValidNumberPrecise(): boolean | null;
|
|
974
|
+
private _utilsIsValidNumber;
|
|
973
975
|
setCountry(iso2: string): void;
|
|
974
976
|
setNumber(number: string): void;
|
|
975
977
|
setPlaceholderNumberType(type: NumberType): void;
|
|
978
|
+
setDisabled(disabled: boolean): void;
|
|
976
979
|
}
|
|
977
980
|
const intlTelInput: IntlTelInputInterface;
|
|
978
981
|
export default intlTelInput;
|
|
@@ -991,6 +994,7 @@ declare module "intl-tel-input/react" {
|
|
|
991
994
|
usePreciseValidation?: boolean;
|
|
992
995
|
initOptions?: SomeOptions;
|
|
993
996
|
inputProps?: object;
|
|
997
|
+
disabled?: boolean | undefined;
|
|
994
998
|
};
|
|
995
999
|
export type IntlTelInputRef = {
|
|
996
1000
|
getInstance: () => Iti | null;
|
|
@@ -1021,6 +1025,7 @@ declare module "intl-tel-input/reactWithUtils" {
|
|
|
1021
1025
|
usePreciseValidation?: boolean;
|
|
1022
1026
|
initOptions?: SomeOptions;
|
|
1023
1027
|
inputProps?: object;
|
|
1028
|
+
disabled?: boolean | undefined;
|
|
1024
1029
|
};
|
|
1025
1030
|
export type IntlTelInputRef = {
|
|
1026
1031
|
getInstance: () => Iti | null;
|
|
@@ -1956,6 +1956,9 @@ var Iti = class {
|
|
|
1956
1956
|
_initTelInputListeners() {
|
|
1957
1957
|
const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
|
|
1958
1958
|
let userOverrideFormatting = false;
|
|
1959
|
+
if (/\p{L}/u.test(this.telInput.value)) {
|
|
1960
|
+
userOverrideFormatting = true;
|
|
1961
|
+
}
|
|
1959
1962
|
const openDropdownWithPlus = () => {
|
|
1960
1963
|
this._openDropdown();
|
|
1961
1964
|
this.searchInput.value = "+";
|
|
@@ -2696,17 +2699,31 @@ var Iti = class {
|
|
|
2696
2699
|
//* Validate the input val
|
|
2697
2700
|
isValidNumber() {
|
|
2698
2701
|
const val = this._getFullNumber();
|
|
2699
|
-
|
|
2700
|
-
|
|
2702
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2703
|
+
if (alphaCharPosition > -1) {
|
|
2704
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2705
|
+
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
|
|
2706
|
+
const isValid = this._utilsIsPossibleNumber(val);
|
|
2707
|
+
return beforeAlphaIsValid && isValid;
|
|
2701
2708
|
}
|
|
2709
|
+
return this._utilsIsPossibleNumber(val);
|
|
2710
|
+
}
|
|
2711
|
+
_utilsIsPossibleNumber(val) {
|
|
2702
2712
|
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
|
|
2703
2713
|
}
|
|
2704
2714
|
//* Validate the input val (precise)
|
|
2705
2715
|
isValidNumberPrecise() {
|
|
2706
2716
|
const val = this._getFullNumber();
|
|
2707
|
-
|
|
2708
|
-
|
|
2717
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2718
|
+
if (alphaCharPosition > -1) {
|
|
2719
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2720
|
+
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
|
|
2721
|
+
const isValid = this._utilsIsValidNumber(val);
|
|
2722
|
+
return beforeAlphaIsValid && isValid;
|
|
2709
2723
|
}
|
|
2724
|
+
return this._utilsIsValidNumber(val);
|
|
2725
|
+
}
|
|
2726
|
+
_utilsIsValidNumber(val) {
|
|
2710
2727
|
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
2711
2728
|
}
|
|
2712
2729
|
//* Update the selected country, and update the input val accordingly.
|
|
@@ -2734,6 +2751,14 @@ var Iti = class {
|
|
|
2734
2751
|
this.options.placeholderNumberType = type;
|
|
2735
2752
|
this._updatePlaceholder();
|
|
2736
2753
|
}
|
|
2754
|
+
setDisabled(disabled) {
|
|
2755
|
+
this.telInput.disabled = disabled;
|
|
2756
|
+
if (disabled) {
|
|
2757
|
+
this.selectedCountry.setAttribute("disabled", "true");
|
|
2758
|
+
} else {
|
|
2759
|
+
this.selectedCountry.removeAttribute("disabled");
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2737
2762
|
};
|
|
2738
2763
|
var loadUtils = (path) => {
|
|
2739
2764
|
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
@@ -2777,7 +2802,7 @@ var intlTelInput = Object.assign(
|
|
|
2777
2802
|
//* A map from instance ID to instance object.
|
|
2778
2803
|
instances: {},
|
|
2779
2804
|
loadUtils,
|
|
2780
|
-
version: "23.
|
|
2805
|
+
version: "23.8.1"
|
|
2781
2806
|
}
|
|
2782
2807
|
);
|
|
2783
2808
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -2796,7 +2821,8 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
|
|
|
2796
2821
|
},
|
|
2797
2822
|
usePreciseValidation = false,
|
|
2798
2823
|
initOptions = {},
|
|
2799
|
-
inputProps = {}
|
|
2824
|
+
inputProps = {},
|
|
2825
|
+
disabled = void 0
|
|
2800
2826
|
}, ref) {
|
|
2801
2827
|
const inputRef = useRef(null);
|
|
2802
2828
|
const itiRef = useRef(null);
|
|
@@ -2841,6 +2867,11 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
|
|
|
2841
2867
|
}
|
|
2842
2868
|
};
|
|
2843
2869
|
}, [update]);
|
|
2870
|
+
useEffect(() => {
|
|
2871
|
+
if (itiRef.current && disabled !== void 0) {
|
|
2872
|
+
itiRef.current.setDisabled(disabled);
|
|
2873
|
+
}
|
|
2874
|
+
}, [disabled]);
|
|
2844
2875
|
return /* @__PURE__ */ React.createElement(
|
|
2845
2876
|
"input",
|
|
2846
2877
|
{
|
|
@@ -1992,6 +1992,9 @@ var Iti = class {
|
|
|
1992
1992
|
_initTelInputListeners() {
|
|
1993
1993
|
const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
|
|
1994
1994
|
let userOverrideFormatting = false;
|
|
1995
|
+
if (/\p{L}/u.test(this.telInput.value)) {
|
|
1996
|
+
userOverrideFormatting = true;
|
|
1997
|
+
}
|
|
1995
1998
|
const openDropdownWithPlus = () => {
|
|
1996
1999
|
this._openDropdown();
|
|
1997
2000
|
this.searchInput.value = "+";
|
|
@@ -2732,17 +2735,31 @@ var Iti = class {
|
|
|
2732
2735
|
//* Validate the input val
|
|
2733
2736
|
isValidNumber() {
|
|
2734
2737
|
const val = this._getFullNumber();
|
|
2735
|
-
|
|
2736
|
-
|
|
2738
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2739
|
+
if (alphaCharPosition > -1) {
|
|
2740
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2741
|
+
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
|
|
2742
|
+
const isValid = this._utilsIsPossibleNumber(val);
|
|
2743
|
+
return beforeAlphaIsValid && isValid;
|
|
2737
2744
|
}
|
|
2745
|
+
return this._utilsIsPossibleNumber(val);
|
|
2746
|
+
}
|
|
2747
|
+
_utilsIsPossibleNumber(val) {
|
|
2738
2748
|
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
|
|
2739
2749
|
}
|
|
2740
2750
|
//* Validate the input val (precise)
|
|
2741
2751
|
isValidNumberPrecise() {
|
|
2742
2752
|
const val = this._getFullNumber();
|
|
2743
|
-
|
|
2744
|
-
|
|
2753
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2754
|
+
if (alphaCharPosition > -1) {
|
|
2755
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2756
|
+
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
|
|
2757
|
+
const isValid = this._utilsIsValidNumber(val);
|
|
2758
|
+
return beforeAlphaIsValid && isValid;
|
|
2745
2759
|
}
|
|
2760
|
+
return this._utilsIsValidNumber(val);
|
|
2761
|
+
}
|
|
2762
|
+
_utilsIsValidNumber(val) {
|
|
2746
2763
|
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
2747
2764
|
}
|
|
2748
2765
|
//* Update the selected country, and update the input val accordingly.
|
|
@@ -2770,6 +2787,14 @@ var Iti = class {
|
|
|
2770
2787
|
this.options.placeholderNumberType = type;
|
|
2771
2788
|
this._updatePlaceholder();
|
|
2772
2789
|
}
|
|
2790
|
+
setDisabled(disabled) {
|
|
2791
|
+
this.telInput.disabled = disabled;
|
|
2792
|
+
if (disabled) {
|
|
2793
|
+
this.selectedCountry.setAttribute("disabled", "true");
|
|
2794
|
+
} else {
|
|
2795
|
+
this.selectedCountry.removeAttribute("disabled");
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2773
2798
|
};
|
|
2774
2799
|
var loadUtils = (path) => {
|
|
2775
2800
|
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
@@ -2813,7 +2838,7 @@ var intlTelInput = Object.assign(
|
|
|
2813
2838
|
//* A map from instance ID to instance object.
|
|
2814
2839
|
instances: {},
|
|
2815
2840
|
loadUtils,
|
|
2816
|
-
version: "23.
|
|
2841
|
+
version: "23.8.1"
|
|
2817
2842
|
}
|
|
2818
2843
|
);
|
|
2819
2844
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -9048,7 +9073,8 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
|
|
|
9048
9073
|
},
|
|
9049
9074
|
usePreciseValidation = false,
|
|
9050
9075
|
initOptions = {},
|
|
9051
|
-
inputProps = {}
|
|
9076
|
+
inputProps = {},
|
|
9077
|
+
disabled = void 0
|
|
9052
9078
|
}, ref) {
|
|
9053
9079
|
const inputRef = (0, import_react.useRef)(null);
|
|
9054
9080
|
const itiRef = (0, import_react.useRef)(null);
|
|
@@ -9093,6 +9119,11 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
|
|
|
9093
9119
|
}
|
|
9094
9120
|
};
|
|
9095
9121
|
}, [update]);
|
|
9122
|
+
(0, import_react.useEffect)(() => {
|
|
9123
|
+
if (itiRef.current && disabled !== void 0) {
|
|
9124
|
+
itiRef.current.setDisabled(disabled);
|
|
9125
|
+
}
|
|
9126
|
+
}, [disabled]);
|
|
9096
9127
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
9097
9128
|
"input",
|
|
9098
9129
|
{
|
|
@@ -1956,6 +1956,9 @@ var Iti = class {
|
|
|
1956
1956
|
_initTelInputListeners() {
|
|
1957
1957
|
const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
|
|
1958
1958
|
let userOverrideFormatting = false;
|
|
1959
|
+
if (/\p{L}/u.test(this.telInput.value)) {
|
|
1960
|
+
userOverrideFormatting = true;
|
|
1961
|
+
}
|
|
1959
1962
|
const openDropdownWithPlus = () => {
|
|
1960
1963
|
this._openDropdown();
|
|
1961
1964
|
this.searchInput.value = "+";
|
|
@@ -2696,17 +2699,31 @@ var Iti = class {
|
|
|
2696
2699
|
//* Validate the input val
|
|
2697
2700
|
isValidNumber() {
|
|
2698
2701
|
const val = this._getFullNumber();
|
|
2699
|
-
|
|
2700
|
-
|
|
2702
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2703
|
+
if (alphaCharPosition > -1) {
|
|
2704
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2705
|
+
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
|
|
2706
|
+
const isValid = this._utilsIsPossibleNumber(val);
|
|
2707
|
+
return beforeAlphaIsValid && isValid;
|
|
2701
2708
|
}
|
|
2709
|
+
return this._utilsIsPossibleNumber(val);
|
|
2710
|
+
}
|
|
2711
|
+
_utilsIsPossibleNumber(val) {
|
|
2702
2712
|
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
|
|
2703
2713
|
}
|
|
2704
2714
|
//* Validate the input val (precise)
|
|
2705
2715
|
isValidNumberPrecise() {
|
|
2706
2716
|
const val = this._getFullNumber();
|
|
2707
|
-
|
|
2708
|
-
|
|
2717
|
+
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2718
|
+
if (alphaCharPosition > -1) {
|
|
2719
|
+
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2720
|
+
const beforeAlphaIsValid = this._utilsIsValidNumber(beforeAlphaChar);
|
|
2721
|
+
const isValid = this._utilsIsValidNumber(val);
|
|
2722
|
+
return beforeAlphaIsValid && isValid;
|
|
2709
2723
|
}
|
|
2724
|
+
return this._utilsIsValidNumber(val);
|
|
2725
|
+
}
|
|
2726
|
+
_utilsIsValidNumber(val) {
|
|
2710
2727
|
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
2711
2728
|
}
|
|
2712
2729
|
//* Update the selected country, and update the input val accordingly.
|
|
@@ -2734,6 +2751,14 @@ var Iti = class {
|
|
|
2734
2751
|
this.options.placeholderNumberType = type;
|
|
2735
2752
|
this._updatePlaceholder();
|
|
2736
2753
|
}
|
|
2754
|
+
setDisabled(disabled) {
|
|
2755
|
+
this.telInput.disabled = disabled;
|
|
2756
|
+
if (disabled) {
|
|
2757
|
+
this.selectedCountry.setAttribute("disabled", "true");
|
|
2758
|
+
} else {
|
|
2759
|
+
this.selectedCountry.removeAttribute("disabled");
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2737
2762
|
};
|
|
2738
2763
|
var loadUtils = (path) => {
|
|
2739
2764
|
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
@@ -2777,7 +2802,7 @@ var intlTelInput = Object.assign(
|
|
|
2777
2802
|
//* A map from instance ID to instance object.
|
|
2778
2803
|
instances: {},
|
|
2779
2804
|
loadUtils,
|
|
2780
|
-
version: "23.
|
|
2805
|
+
version: "23.8.1"
|
|
2781
2806
|
}
|
|
2782
2807
|
);
|
|
2783
2808
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -9012,7 +9037,8 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
|
|
|
9012
9037
|
},
|
|
9013
9038
|
usePreciseValidation = false,
|
|
9014
9039
|
initOptions = {},
|
|
9015
|
-
inputProps = {}
|
|
9040
|
+
inputProps = {},
|
|
9041
|
+
disabled = void 0
|
|
9016
9042
|
}, ref) {
|
|
9017
9043
|
const inputRef = useRef(null);
|
|
9018
9044
|
const itiRef = useRef(null);
|
|
@@ -9057,6 +9083,11 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
|
|
|
9057
9083
|
}
|
|
9058
9084
|
};
|
|
9059
9085
|
}, [update]);
|
|
9086
|
+
useEffect(() => {
|
|
9087
|
+
if (itiRef.current && disabled !== void 0) {
|
|
9088
|
+
itiRef.current.setDisabled(disabled);
|
|
9089
|
+
}
|
|
9090
|
+
}, [disabled]);
|
|
9060
9091
|
return /* @__PURE__ */ React.createElement(
|
|
9061
9092
|
"input",
|
|
9062
9093
|
{
|