react-simple-phone-input 1.0.7-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.
@@ -1,10 +1,10 @@
1
- import React, { ReactNode } from "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
@@ -3988,12 +3988,12 @@ const getDefaultCountry = (code) => {
3988
3988
  return result;
3989
3989
  };
3990
3990
  const getBySearch = (search, onlyCountry, excludeCountry) => {
3991
- let countries = [];
3991
+ var countries = [];
3992
3992
  if (excludeCountry && excludeCountry.length > 0) {
3993
- countries = countryData.filter((item) => !(excludeCountry === null || excludeCountry === void 0 ? void 0 : excludeCountry.includes(item.countryCode)));
3993
+ countries = countryData.filter((item) => (excludeCountry === null || excludeCountry === void 0 ? void 0 : excludeCountry.indexOf(item.countryCode)) === -1);
3994
3994
  }
3995
3995
  else if (onlyCountry && (onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.length) > 0) {
3996
- countries = countryData.filter((item) => onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.includes(item.countryCode));
3996
+ countries = countryData.filter((item) => (onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.indexOf(item.countryCode)) !== -1);
3997
3997
  }
3998
3998
  else {
3999
3999
  countries = countryData;
@@ -4006,23 +4006,23 @@ const getBySearch = (search, onlyCountry, excludeCountry) => {
4006
4006
  return result;
4007
4007
  };
4008
4008
  const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
4009
- let countries = [];
4009
+ var countries = [];
4010
4010
  if (excludeCountry && excludeCountry.length > 0) {
4011
- countries = countryData.filter((item) => !(excludeCountry === null || excludeCountry === void 0 ? void 0 : excludeCountry.includes(item.countryCode)));
4011
+ countries = countryData.filter((item) => (excludeCountry === null || excludeCountry === void 0 ? void 0 : excludeCountry.indexOf(item.countryCode)) === -1);
4012
4012
  }
4013
4013
  else if (onlyCountry && (onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.length) > 0) {
4014
- countries = countryData.filter((item) => onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.includes(item.countryCode));
4014
+ countries = countryData.filter((item) => (onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.indexOf(item.countryCode)) !== -1);
4015
4015
  }
4016
4016
  else {
4017
4017
  countries = countryData;
4018
4018
  }
4019
- const result = countries.sort((a, b) => (Number(preferredCountry === null || preferredCountry === void 0 ? void 0 : preferredCountry.includes(b.countryCode)) - Number(preferredCountry === null || preferredCountry === void 0 ? void 0 : preferredCountry.includes(a.countryCode)))
4019
+ const result = countries.sort((a, b) => (Number(preferredCountry === null || preferredCountry === void 0 ? void 0 : preferredCountry.indexOf(b.countryCode)) - Number(preferredCountry === null || preferredCountry === void 0 ? void 0 : preferredCountry.indexOf(a.countryCode)))
4020
4020
  || ((preferredCountry === null || preferredCountry === void 0 ? void 0 : preferredCountry.indexOf(a.countryCode)) - (preferredCountry === null || preferredCountry === void 0 ? void 0 : preferredCountry.indexOf(b.countryCode))));
4021
4021
  return result;
4022
4022
  };
4023
4023
 
4024
4024
  function useOnClickOutside(ref, handler) {
4025
- react.exports.useEffect(() => {
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] = react.exports.useState({});
4043
- const [isDropdown, setDropdown] = react.exports.useState(false);
4044
- const [inputValue, setInputValue] = react.exports.useState(value || "");
4045
- const [countryDataInfo, setCountryData] = react.exports.useState(countryData);
4046
- const ref = react.exports.useRef();
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
- react.exports.useMemo(() => {
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
- react.exports.useMemo(() => {
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" },