react-simple-phone-input 1.0.8-beta → 1.0.9-beta
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/dist/cjs/index.js +8 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/PhoneInput/PhoneInput.d.ts +3 -3
- package/dist/esm/index.js +8 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/PhoneInput/PhoneInput.d.ts +3 -3
- package/dist/index.d.ts +3 -3
- package/package.json +1 -1
- package/dist/cjs/types/components/button/Button.d.ts +0 -7
- package/dist/cjs/types/components/button/index.d.ts +0 -1
- package/dist/esm/types/components/button/Button.d.ts +0 -7
- package/dist/esm/types/components/button/index.d.ts +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
interface Props {
|
|
3
3
|
placeholder: string;
|
|
4
4
|
country: string;
|
|
5
5
|
onChange: (e: string) => void;
|
|
6
6
|
value?: string;
|
|
7
|
-
iconComponent?: ReactNode;
|
|
7
|
+
iconComponent?: React.ReactNode;
|
|
8
8
|
inputProps?: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
9
9
|
onlyCountries?: string[];
|
|
10
10
|
excludeCountries?: string[];
|
|
@@ -14,7 +14,7 @@ interface Props {
|
|
|
14
14
|
search?: boolean;
|
|
15
15
|
searchPlaceholder?: string;
|
|
16
16
|
showSearchIcon?: boolean;
|
|
17
|
-
searchIconComponent?: ReactNode;
|
|
17
|
+
searchIconComponent?: React.ReactNode;
|
|
18
18
|
searchProps?: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
19
19
|
searchNotFound?: string;
|
|
20
20
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -4022,7 +4022,7 @@ const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
|
|
|
4022
4022
|
};
|
|
4023
4023
|
|
|
4024
4024
|
function useOnClickOutside(ref, handler) {
|
|
4025
|
-
|
|
4025
|
+
React.useEffect(() => {
|
|
4026
4026
|
const listener = (event) => {
|
|
4027
4027
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
4028
4028
|
return;
|
|
@@ -4039,11 +4039,11 @@ function useOnClickOutside(ref, handler) {
|
|
|
4039
4039
|
}
|
|
4040
4040
|
|
|
4041
4041
|
const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inputProps, onlyCountries, excludeCountries, preferredCountries, showDropdownIcon = true, dialCodeInputField = false, search = true, searchPlaceholder = "Search country", showSearchIcon = true, searchIconComponent, searchProps, searchNotFound = "Not found" }) => {
|
|
4042
|
-
const [selected, setSelected] =
|
|
4043
|
-
const [isDropdown, setDropdown] =
|
|
4044
|
-
const [inputValue, setInputValue] =
|
|
4045
|
-
const [countryDataInfo, setCountryData] =
|
|
4046
|
-
const ref =
|
|
4042
|
+
const [selected, setSelected] = React.useState({});
|
|
4043
|
+
const [isDropdown, setDropdown] = React.useState(false);
|
|
4044
|
+
const [inputValue, setInputValue] = React.useState(value || "");
|
|
4045
|
+
const [countryDataInfo, setCountryData] = React.useState(countryData);
|
|
4046
|
+
const ref = React.useRef();
|
|
4047
4047
|
useOnClickOutside(ref, () => setDropdown(false));
|
|
4048
4048
|
//Handler
|
|
4049
4049
|
const handleChange = (e) => {
|
|
@@ -4073,7 +4073,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
|
|
|
4073
4073
|
setSelected(item);
|
|
4074
4074
|
setDropdown(false);
|
|
4075
4075
|
};
|
|
4076
|
-
|
|
4076
|
+
React.useMemo(() => {
|
|
4077
4077
|
if (dialCodeInputField) {
|
|
4078
4078
|
const result = inputValue === null || inputValue === void 0 ? void 0 : inputValue.replace(selected.callingCode, getDefaultCountry(country).callingCode);
|
|
4079
4079
|
console.log(result);
|
|
@@ -4081,7 +4081,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
|
|
|
4081
4081
|
}
|
|
4082
4082
|
setSelected(getDefaultCountry(country));
|
|
4083
4083
|
}, [country, dialCodeInputField]);
|
|
4084
|
-
|
|
4084
|
+
React.useMemo(() => {
|
|
4085
4085
|
setCountryData(getCountryByFilter(onlyCountries, excludeCountries, preferredCountries));
|
|
4086
4086
|
}, [onlyCountries, excludeCountries, preferredCountries]);
|
|
4087
4087
|
return (React.createElement("div", { className: "simple-phone-input-sri198-container" },
|