Skip to content

Commit

Permalink
React cmp: expose utils, and setCountry
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed May 18, 2024
1 parent edbafc6 commit 2b5babc
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 14 deletions.
5 changes: 3 additions & 2 deletions react/build/IntlTelInput.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
// react/src/intl-tel-input/react.tsx
var react_exports = {};
__export(react_exports, {
default: () => react_default
default: () => react_default,
intlTelInput: () => intl_tel_input_default
});
module.exports = __toCommonJS(react_exports);

Expand Down Expand Up @@ -2798,7 +2799,7 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
const itiRef = (0, import_react.useRef)(null);
(0, import_react.useImperativeHandle)(ref, () => ({
getInstance: () => ({
...itiRef.current,
setCountry: (country) => itiRef.current?.setCountry(country),
// override setNumber to also call update, to trigger onChangeNumber etc
setNumber: (num) => {
itiRef.current?.setNumber(num);
Expand Down
4 changes: 4 additions & 0 deletions react/build/IntlTelInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,10 @@ declare module "intl-tel-input" {
export default intlTelInput;
}
declare module "intl-tel-input/react" {
import intlTelInput from "intl-tel-input";
import { SomeOptions } from "intl-tel-input";
import React from "react";
export { intlTelInput };
type ItiProps = {
initialValue?: string;
onChangeNumber?: (number: string) => void;
Expand All @@ -998,8 +1000,10 @@ declare module "intl-tel-input/intlTelInputWithUtils" {
export default intlTelInput;
}
declare module "intl-tel-input/reactWithUtils" {
import intlTelInput from "intl-tel-input/intlTelInputWithUtils";
import { SomeOptions } from "intl-tel-input";
import React from "react";
export { intlTelInput };
type ItiProps = {
initialValue?: string;
onChangeNumber?: (number: string) => void;
Expand Down
5 changes: 3 additions & 2 deletions react/build/IntlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -2763,7 +2763,7 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
const itiRef = useRef(null);
useImperativeHandle(ref, () => ({
getInstance: () => ({
...itiRef.current,
setCountry: (country) => itiRef.current?.setCountry(country),
// override setNumber to also call update, to trigger onChangeNumber etc
setNumber: (num) => {
itiRef.current?.setNumber(num);
Expand Down Expand Up @@ -2816,5 +2816,6 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
});
var react_default = IntlTelInput;
export {
react_default as default
react_default as default,
intl_tel_input_default as intlTelInput
};
5 changes: 3 additions & 2 deletions react/build/IntlTelInputWithUtils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
// react/src/intl-tel-input/reactWithUtils.tsx
var reactWithUtils_exports = {};
__export(reactWithUtils_exports, {
default: () => reactWithUtils_default
default: () => reactWithUtils_default,
intlTelInput: () => intlTelInputWithUtils_default
});
module.exports = __toCommonJS(reactWithUtils_exports);

Expand Down Expand Up @@ -8996,7 +8997,7 @@ var IntlTelInput = (0, import_react.forwardRef)(function IntlTelInput2({
const itiRef = (0, import_react.useRef)(null);
(0, import_react.useImperativeHandle)(ref, () => ({
getInstance: () => ({
...itiRef.current,
setCountry: (country) => itiRef.current?.setCountry(country),
// override setNumber to also call update, to trigger onChangeNumber etc
setNumber: (num) => {
itiRef.current?.setNumber(num);
Expand Down
5 changes: 3 additions & 2 deletions react/build/IntlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8961,7 +8961,7 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
const itiRef = useRef(null);
useImperativeHandle(ref, () => ({
getInstance: () => ({
...itiRef.current,
setCountry: (country) => itiRef.current?.setCountry(country),
// override setNumber to also call update, to trigger onChangeNumber etc
setNumber: (num) => {
itiRef.current?.setNumber(num);
Expand Down Expand Up @@ -9014,5 +9014,6 @@ var IntlTelInput = forwardRef(function IntlTelInput2({
});
var reactWithUtils_default = IntlTelInput;
export {
reactWithUtils_default as default
reactWithUtils_default as default,
intlTelInputWithUtils_default as intlTelInput
};
2 changes: 1 addition & 1 deletion react/demo/simple-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -32490,7 +32490,7 @@
const itiRef = (0, import_react.useRef)(null);
(0, import_react.useImperativeHandle)(ref, () => ({
getInstance: () => ({
...itiRef.current,
setCountry: (country) => itiRef.current?.setCountry(country),
// override setNumber to also call update, to trigger onChangeNumber etc
setNumber: (num) => {
itiRef.current?.setNumber(num);
Expand Down
2 changes: 1 addition & 1 deletion react/demo/validation-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -32490,7 +32490,7 @@
const itiRef = (0, import_react.useRef)(null);
(0, import_react.useImperativeHandle)(ref, () => ({
getInstance: () => ({
...itiRef.current,
setCountry: (country) => itiRef.current?.setCountry(country),
// override setNumber to also call update, to trigger onChangeNumber etc
setNumber: (num) => {
itiRef.current?.setNumber(num);
Expand Down
7 changes: 5 additions & 2 deletions react/src/intl-tel-input/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import intlTelInput from "../intl-tel-input";
import { Iti, SomeOptions } from "../intl-tel-input";
import React, { useRef, useEffect, forwardRef, useImperativeHandle } from "react";

// make this available as a named export, so react users can access globals like intlTelInput.utils
export { intlTelInput };

type ItiProps = {
initialValue?: string;
onChangeNumber?: (number: string) => void;
Expand Down Expand Up @@ -30,9 +33,9 @@ const IntlTelInput = forwardRef(function IntlTelInput({
// expose the instance and input ref to the parent component
useImperativeHandle(ref, () => ({
getInstance: () => ({
...itiRef.current,
setCountry: (country: string) => itiRef.current?.setCountry(country),
// override setNumber to also call update, to trigger onChangeNumber etc
setNumber: (num) => {
setNumber: (num: string) => {
itiRef.current?.setNumber(num);
update();
},
Expand Down
7 changes: 5 additions & 2 deletions react/src/intl-tel-input/reactWithUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import intlTelInput from "./intlTelInputWithUtils";
import { Iti, SomeOptions } from "../intl-tel-input";
import React, { useRef, useEffect, forwardRef, useImperativeHandle } from "react";

// make this available as a named export, so react users can access globals like intlTelInput.utils
export { intlTelInput };

type ItiProps = {
initialValue?: string;
onChangeNumber?: (number: string) => void;
Expand Down Expand Up @@ -31,9 +34,9 @@ const IntlTelInput = forwardRef(function IntlTelInput({
// expose the instance and input ref to the parent component
useImperativeHandle(ref, () => ({
getInstance: () => ({
...itiRef.current,
setCountry: (country: string) => itiRef.current?.setCountry(country),
// override setNumber to also call update, to trigger onChangeNumber etc
setNumber: (num) => {
setNumber: (num: string) => {
itiRef.current?.setNumber(num);
update();
},
Expand Down

0 comments on commit 2b5babc

Please sign in to comment.