intl-tel-input 23.0.5 → 23.0.7

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.5",
3
+ "version": "23.0.7",
4
4
  "description": "A JavaScript plugin for entering and validating international telephone numbers",
5
5
  "keywords": [
6
6
  "international",
@@ -56,8 +56,8 @@
56
56
  "jquery": "^3.1.1",
57
57
  "load-grunt-config": "^4.0.1",
58
58
  "prettier": "^3.2.5",
59
- "react": "^18.2.0",
60
- "react-dom": "^18.2.0",
59
+ "react": "^18.3.1",
60
+ "react-dom": "^18.3.1",
61
61
  "region-flags": "https://github.com/fonttools/region-flags/archive/refs/tags/1.2.1.tar.gz",
62
62
  "sass": "^1.74.1",
63
63
  "time-grunt": "^2.0.0",
@@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // react/src/intl-tel-input/react.tsx
30
30
  var react_exports = {};
31
31
  __export(react_exports, {
32
- default: () => react_default
32
+ default: () => react_default,
33
+ intlTelInput: () => intl_tel_input_default
33
34
  });
34
35
  module.exports = __toCommonJS(react_exports);
35
36
 
@@ -2773,14 +2774,14 @@ var intlTelInput = Object.assign(
2773
2774
  //* A map from instance ID to instance object.
2774
2775
  instances: {},
2775
2776
  loadUtils,
2776
- version: "23.0.5"
2777
+ version: "23.0.7"
2777
2778
  }
2778
2779
  );
2779
2780
  var intl_tel_input_default = intlTelInput;
2780
2781
 
2781
2782
  // react/src/intl-tel-input/react.tsx
2782
2783
  var import_react = __toESM(require("react"));
2783
- var IntlTelInput = ({
2784
+ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
2784
2785
  initialValue = "",
2785
2786
  onChangeNumber = () => {
2786
2787
  },
@@ -2793,9 +2794,20 @@ var IntlTelInput = ({
2793
2794
  usePreciseValidation = false,
2794
2795
  initOptions = {},
2795
2796
  inputProps = {}
2796
- }) => {
2797
+ }, ref) {
2797
2798
  const inputRef = (0, import_react.useRef)(null);
2798
2799
  const itiRef = (0, import_react.useRef)(null);
2800
+ (0, import_react.useImperativeHandle)(ref, () => ({
2801
+ getInstance: () => ({
2802
+ setCountry: (country) => itiRef.current?.setCountry(country),
2803
+ // override setNumber to also call update, to trigger onChangeNumber etc
2804
+ setNumber: (num) => {
2805
+ itiRef.current?.setNumber(num);
2806
+ update();
2807
+ }
2808
+ }),
2809
+ getInput: () => inputRef.current
2810
+ }));
2799
2811
  const update = () => {
2800
2812
  const num = itiRef.current?.getNumber() || "";
2801
2813
  const countryIso = itiRef.current?.getSelectedCountryData().iso2 || "";
@@ -2837,5 +2849,5 @@ var IntlTelInput = ({
2837
2849
  ...inputProps
2838
2850
  }
2839
2851
  );
2840
- };
2852
+ });
2841
2853
  var react_default = IntlTelInput;
@@ -974,9 +974,11 @@ declare module "intl-tel-input" {
974
974
  export default intlTelInput;
975
975
  }
976
976
  declare module "intl-tel-input/react" {
977
+ import intlTelInput from "intl-tel-input";
977
978
  import { SomeOptions } from "intl-tel-input";
978
979
  import React from "react";
979
- const IntlTelInput: ({ initialValue, onChangeNumber, onChangeCountry, onChangeValidity, onChangeErrorCode, usePreciseValidation, initOptions, inputProps, }: {
980
+ export { intlTelInput };
981
+ type ItiProps = {
980
982
  initialValue?: string;
981
983
  onChangeNumber?: (number: string) => void;
982
984
  onChangeCountry?: (country: string) => void;
@@ -985,7 +987,8 @@ declare module "intl-tel-input/react" {
985
987
  usePreciseValidation?: boolean;
986
988
  initOptions?: SomeOptions;
987
989
  inputProps?: object;
988
- }) => React.JSX.Element;
990
+ };
991
+ const IntlTelInput: React.ForwardRefExoticComponent<ItiProps & React.RefAttributes<unknown>>;
989
992
  export default IntlTelInput;
990
993
  }
991
994
  declare module "intl-tel-input/utils-compiled" {
@@ -997,9 +1000,11 @@ declare module "intl-tel-input/intlTelInputWithUtils" {
997
1000
  export default intlTelInput;
998
1001
  }
999
1002
  declare module "intl-tel-input/reactWithUtils" {
1003
+ import intlTelInput from "intl-tel-input/intlTelInputWithUtils";
1000
1004
  import { SomeOptions } from "intl-tel-input";
1001
1005
  import React from "react";
1002
- const IntlTelInput: ({ initialValue, onChangeNumber, onChangeCountry, onChangeValidity, onChangeErrorCode, usePreciseValidation, initOptions, inputProps, }: {
1006
+ export { intlTelInput };
1007
+ type ItiProps = {
1003
1008
  initialValue?: string;
1004
1009
  onChangeNumber?: (number: string) => void;
1005
1010
  onChangeCountry?: (country: string) => void;
@@ -1008,6 +1013,7 @@ declare module "intl-tel-input/reactWithUtils" {
1008
1013
  usePreciseValidation?: boolean;
1009
1014
  initOptions?: SomeOptions;
1010
1015
  inputProps?: object;
1011
- }) => React.JSX.Element;
1016
+ };
1017
+ const IntlTelInput: React.ForwardRefExoticComponent<ItiProps & React.RefAttributes<unknown>>;
1012
1018
  export default IntlTelInput;
1013
1019
  }
@@ -2738,14 +2738,14 @@ var intlTelInput = Object.assign(
2738
2738
  //* A map from instance ID to instance object.
2739
2739
  instances: {},
2740
2740
  loadUtils,
2741
- version: "23.0.5"
2741
+ version: "23.0.7"
2742
2742
  }
2743
2743
  );
2744
2744
  var intl_tel_input_default = intlTelInput;
2745
2745
 
2746
2746
  // react/src/intl-tel-input/react.tsx
2747
- import React, { useRef, useEffect } from "react";
2748
- var IntlTelInput = ({
2747
+ import React, { useRef, useEffect, forwardRef, useImperativeHandle } from "react";
2748
+ var IntlTelInput = forwardRef(function IntlTelInput2({
2749
2749
  initialValue = "",
2750
2750
  onChangeNumber = () => {
2751
2751
  },
@@ -2758,9 +2758,20 @@ var IntlTelInput = ({
2758
2758
  usePreciseValidation = false,
2759
2759
  initOptions = {},
2760
2760
  inputProps = {}
2761
- }) => {
2761
+ }, ref) {
2762
2762
  const inputRef = useRef(null);
2763
2763
  const itiRef = useRef(null);
2764
+ useImperativeHandle(ref, () => ({
2765
+ getInstance: () => ({
2766
+ setCountry: (country) => itiRef.current?.setCountry(country),
2767
+ // override setNumber to also call update, to trigger onChangeNumber etc
2768
+ setNumber: (num) => {
2769
+ itiRef.current?.setNumber(num);
2770
+ update();
2771
+ }
2772
+ }),
2773
+ getInput: () => inputRef.current
2774
+ }));
2764
2775
  const update = () => {
2765
2776
  const num = itiRef.current?.getNumber() || "";
2766
2777
  const countryIso = itiRef.current?.getSelectedCountryData().iso2 || "";
@@ -2802,8 +2813,9 @@ var IntlTelInput = ({
2802
2813
  ...inputProps
2803
2814
  }
2804
2815
  );
2805
- };
2816
+ });
2806
2817
  var react_default = IntlTelInput;
2807
2818
  export {
2808
- react_default as default
2819
+ react_default as default,
2820
+ intl_tel_input_default as intlTelInput
2809
2821
  };