intl-tel-input 23.7.3 → 23.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-tel-input",
3
- "version": "23.7.3",
3
+ "version": "23.8.0",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "keywords": [
6
6
  "international",
package/react/README.md CHANGED
@@ -29,7 +29,7 @@ import "intl-tel-input/styles";
29
29
 
30
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.7.3/build/js/utils.js"`.
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.0/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.
@@ -64,7 +64,11 @@ An object containing all of the [initialisation options](https://github.com/jack
64
64
 
65
65
  **inputProps**
66
66
  Type: `Object`
67
- The props to pass to the input element e.g. `className`, `placeholder`, `required`, `disabled`, `onBlur` etc.
67
+ 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`._
68
+
69
+ **disabled**
70
+ Type: `Boolean`, Default: `false`
71
+ Sets the disabled attribute of both the telephone input and selected country button. _Note: we recommend using this instead of `inputProps.disabled`._
68
72
 
69
73
  ## Accessing Instance Methods
70
74
 
@@ -2770,6 +2770,14 @@ var Iti = class {
2770
2770
  this.options.placeholderNumberType = type;
2771
2771
  this._updatePlaceholder();
2772
2772
  }
2773
+ setDisabled(disabled) {
2774
+ this.telInput.disabled = disabled;
2775
+ if (disabled) {
2776
+ this.selectedCountry.setAttribute("disabled", "true");
2777
+ } else {
2778
+ this.selectedCountry.removeAttribute("disabled");
2779
+ }
2780
+ }
2773
2781
  };
2774
2782
  var loadUtils = (path) => {
2775
2783
  if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
@@ -2777,6 +2785,7 @@ var loadUtils = (path) => {
2777
2785
  return new Promise((resolve, reject) => {
2778
2786
  import(
2779
2787
  /* webpackIgnore: true */
2788
+ /* @vite-ignore */
2780
2789
  path
2781
2790
  ).then(({ default: utils }) => {
2782
2791
  intlTelInput.utils = utils;
@@ -2812,7 +2821,7 @@ var intlTelInput = Object.assign(
2812
2821
  //* A map from instance ID to instance object.
2813
2822
  instances: {},
2814
2823
  loadUtils,
2815
- version: "23.7.3"
2824
+ version: "23.8.0"
2816
2825
  }
2817
2826
  );
2818
2827
  var intl_tel_input_default = intlTelInput;
@@ -2831,7 +2840,8 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
2831
2840
  },
2832
2841
  usePreciseValidation = false,
2833
2842
  initOptions = {},
2834
- inputProps = {}
2843
+ inputProps = {},
2844
+ disabled = void 0
2835
2845
  }, ref) {
2836
2846
  const inputRef = (0, import_react.useRef)(null);
2837
2847
  const itiRef = (0, import_react.useRef)(null);
@@ -2876,6 +2886,11 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
2876
2886
  }
2877
2887
  };
2878
2888
  }, [update]);
2889
+ (0, import_react.useEffect)(() => {
2890
+ if (itiRef.current && disabled !== void 0) {
2891
+ itiRef.current.setDisabled(disabled);
2892
+ }
2893
+ }, [disabled]);
2879
2894
  return /* @__PURE__ */ import_react.default.createElement(
2880
2895
  "input",
2881
2896
  {
@@ -973,6 +973,7 @@ declare module "intl-tel-input" {
973
973
  setCountry(iso2: string): void;
974
974
  setNumber(number: string): void;
975
975
  setPlaceholderNumberType(type: NumberType): void;
976
+ setDisabled(disabled: boolean): void;
976
977
  }
977
978
  const intlTelInput: IntlTelInputInterface;
978
979
  export default intlTelInput;
@@ -991,6 +992,7 @@ declare module "intl-tel-input/react" {
991
992
  usePreciseValidation?: boolean;
992
993
  initOptions?: SomeOptions;
993
994
  inputProps?: object;
995
+ disabled?: boolean | undefined;
994
996
  };
995
997
  export type IntlTelInputRef = {
996
998
  getInstance: () => Iti | null;
@@ -1021,6 +1023,7 @@ declare module "intl-tel-input/reactWithUtils" {
1021
1023
  usePreciseValidation?: boolean;
1022
1024
  initOptions?: SomeOptions;
1023
1025
  inputProps?: object;
1026
+ disabled?: boolean | undefined;
1024
1027
  };
1025
1028
  export type IntlTelInputRef = {
1026
1029
  getInstance: () => Iti | null;
@@ -2734,6 +2734,14 @@ var Iti = class {
2734
2734
  this.options.placeholderNumberType = type;
2735
2735
  this._updatePlaceholder();
2736
2736
  }
2737
+ setDisabled(disabled) {
2738
+ this.telInput.disabled = disabled;
2739
+ if (disabled) {
2740
+ this.selectedCountry.setAttribute("disabled", "true");
2741
+ } else {
2742
+ this.selectedCountry.removeAttribute("disabled");
2743
+ }
2744
+ }
2737
2745
  };
2738
2746
  var loadUtils = (path) => {
2739
2747
  if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
@@ -2741,6 +2749,7 @@ var loadUtils = (path) => {
2741
2749
  return new Promise((resolve, reject) => {
2742
2750
  import(
2743
2751
  /* webpackIgnore: true */
2752
+ /* @vite-ignore */
2744
2753
  path
2745
2754
  ).then(({ default: utils }) => {
2746
2755
  intlTelInput.utils = utils;
@@ -2776,7 +2785,7 @@ var intlTelInput = Object.assign(
2776
2785
  //* A map from instance ID to instance object.
2777
2786
  instances: {},
2778
2787
  loadUtils,
2779
- version: "23.7.3"
2788
+ version: "23.8.0"
2780
2789
  }
2781
2790
  );
2782
2791
  var intl_tel_input_default = intlTelInput;
@@ -2795,7 +2804,8 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
2795
2804
  },
2796
2805
  usePreciseValidation = false,
2797
2806
  initOptions = {},
2798
- inputProps = {}
2807
+ inputProps = {},
2808
+ disabled = void 0
2799
2809
  }, ref) {
2800
2810
  const inputRef = useRef(null);
2801
2811
  const itiRef = useRef(null);
@@ -2840,6 +2850,11 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
2840
2850
  }
2841
2851
  };
2842
2852
  }, [update]);
2853
+ useEffect(() => {
2854
+ if (itiRef.current && disabled !== void 0) {
2855
+ itiRef.current.setDisabled(disabled);
2856
+ }
2857
+ }, [disabled]);
2843
2858
  return /* @__PURE__ */ React.createElement(
2844
2859
  "input",
2845
2860
  {
@@ -2770,6 +2770,14 @@ var Iti = class {
2770
2770
  this.options.placeholderNumberType = type;
2771
2771
  this._updatePlaceholder();
2772
2772
  }
2773
+ setDisabled(disabled) {
2774
+ this.telInput.disabled = disabled;
2775
+ if (disabled) {
2776
+ this.selectedCountry.setAttribute("disabled", "true");
2777
+ } else {
2778
+ this.selectedCountry.removeAttribute("disabled");
2779
+ }
2780
+ }
2773
2781
  };
2774
2782
  var loadUtils = (path) => {
2775
2783
  if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
@@ -2777,6 +2785,7 @@ var loadUtils = (path) => {
2777
2785
  return new Promise((resolve, reject) => {
2778
2786
  import_INTENTIONALLY_BROKEN(
2779
2787
  /* webpackIgnore: true */
2788
+ /* @vite-ignore */
2780
2789
  path
2781
2790
  ).then(({ default: utils2 }) => {
2782
2791
  intlTelInput.utils = utils2;
@@ -2812,7 +2821,7 @@ var intlTelInput = Object.assign(
2812
2821
  //* A map from instance ID to instance object.
2813
2822
  instances: {},
2814
2823
  loadUtils,
2815
- version: "23.7.3"
2824
+ version: "23.8.0"
2816
2825
  }
2817
2826
  );
2818
2827
  var intl_tel_input_default = intlTelInput;
@@ -9047,7 +9056,8 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
9047
9056
  },
9048
9057
  usePreciseValidation = false,
9049
9058
  initOptions = {},
9050
- inputProps = {}
9059
+ inputProps = {},
9060
+ disabled = void 0
9051
9061
  }, ref) {
9052
9062
  const inputRef = (0, import_react.useRef)(null);
9053
9063
  const itiRef = (0, import_react.useRef)(null);
@@ -9092,6 +9102,11 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
9092
9102
  }
9093
9103
  };
9094
9104
  }, [update]);
9105
+ (0, import_react.useEffect)(() => {
9106
+ if (itiRef.current && disabled !== void 0) {
9107
+ itiRef.current.setDisabled(disabled);
9108
+ }
9109
+ }, [disabled]);
9095
9110
  return /* @__PURE__ */ import_react.default.createElement(
9096
9111
  "input",
9097
9112
  {
@@ -2734,6 +2734,14 @@ var Iti = class {
2734
2734
  this.options.placeholderNumberType = type;
2735
2735
  this._updatePlaceholder();
2736
2736
  }
2737
+ setDisabled(disabled) {
2738
+ this.telInput.disabled = disabled;
2739
+ if (disabled) {
2740
+ this.selectedCountry.setAttribute("disabled", "true");
2741
+ } else {
2742
+ this.selectedCountry.removeAttribute("disabled");
2743
+ }
2744
+ }
2737
2745
  };
2738
2746
  var loadUtils = (path) => {
2739
2747
  if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
@@ -2741,6 +2749,7 @@ var loadUtils = (path) => {
2741
2749
  return new Promise((resolve, reject) => {
2742
2750
  import_INTENTIONALLY_BROKEN(
2743
2751
  /* webpackIgnore: true */
2752
+ /* @vite-ignore */
2744
2753
  path
2745
2754
  ).then(({ default: utils2 }) => {
2746
2755
  intlTelInput.utils = utils2;
@@ -2776,7 +2785,7 @@ var intlTelInput = Object.assign(
2776
2785
  //* A map from instance ID to instance object.
2777
2786
  instances: {},
2778
2787
  loadUtils,
2779
- version: "23.7.3"
2788
+ version: "23.8.0"
2780
2789
  }
2781
2790
  );
2782
2791
  var intl_tel_input_default = intlTelInput;
@@ -9011,7 +9020,8 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
9011
9020
  },
9012
9021
  usePreciseValidation = false,
9013
9022
  initOptions = {},
9014
- inputProps = {}
9023
+ inputProps = {},
9024
+ disabled = void 0
9015
9025
  }, ref) {
9016
9026
  const inputRef = useRef(null);
9017
9027
  const itiRef = useRef(null);
@@ -9056,6 +9066,11 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
9056
9066
  }
9057
9067
  };
9058
9068
  }, [update]);
9069
+ useEffect(() => {
9070
+ if (itiRef.current && disabled !== void 0) {
9071
+ itiRef.current.setDisabled(disabled);
9072
+ }
9073
+ }, [disabled]);
9059
9074
  return /* @__PURE__ */ React.createElement(
9060
9075
  "input",
9061
9076
  {