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.
package/dist/cjs/index.js CHANGED
@@ -3990,12 +3990,12 @@ const getDefaultCountry = (code) => {
3990
3990
  return result;
3991
3991
  };
3992
3992
  const getBySearch = (search, onlyCountry, excludeCountry) => {
3993
- let countries = [];
3993
+ var countries = [];
3994
3994
  if (excludeCountry && excludeCountry.length > 0) {
3995
- countries = countryData.filter((item) => !(excludeCountry === null || excludeCountry === void 0 ? void 0 : excludeCountry.includes(item.countryCode)));
3995
+ countries = countryData.filter((item) => (excludeCountry === null || excludeCountry === void 0 ? void 0 : excludeCountry.indexOf(item.countryCode)) === -1);
3996
3996
  }
3997
3997
  else if (onlyCountry && (onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.length) > 0) {
3998
- countries = countryData.filter((item) => onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.includes(item.countryCode));
3998
+ countries = countryData.filter((item) => (onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.indexOf(item.countryCode)) !== -1);
3999
3999
  }
4000
4000
  else {
4001
4001
  countries = countryData;
@@ -4008,23 +4008,23 @@ const getBySearch = (search, onlyCountry, excludeCountry) => {
4008
4008
  return result;
4009
4009
  };
4010
4010
  const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
4011
- let countries = [];
4011
+ var countries = [];
4012
4012
  if (excludeCountry && excludeCountry.length > 0) {
4013
- countries = countryData.filter((item) => !(excludeCountry === null || excludeCountry === void 0 ? void 0 : excludeCountry.includes(item.countryCode)));
4013
+ countries = countryData.filter((item) => (excludeCountry === null || excludeCountry === void 0 ? void 0 : excludeCountry.indexOf(item.countryCode)) === -1);
4014
4014
  }
4015
4015
  else if (onlyCountry && (onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.length) > 0) {
4016
- countries = countryData.filter((item) => onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.includes(item.countryCode));
4016
+ countries = countryData.filter((item) => (onlyCountry === null || onlyCountry === void 0 ? void 0 : onlyCountry.indexOf(item.countryCode)) !== -1);
4017
4017
  }
4018
4018
  else {
4019
4019
  countries = countryData;
4020
4020
  }
4021
- 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)))
4021
+ 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)))
4022
4022
  || ((preferredCountry === null || preferredCountry === void 0 ? void 0 : preferredCountry.indexOf(a.countryCode)) - (preferredCountry === null || preferredCountry === void 0 ? void 0 : preferredCountry.indexOf(b.countryCode))));
4023
4023
  return result;
4024
4024
  };
4025
4025
 
4026
4026
  function useOnClickOutside(ref, handler) {
4027
- react.exports.useEffect(() => {
4027
+ React.useEffect(() => {
4028
4028
  const listener = (event) => {
4029
4029
  if (!ref.current || ref.current.contains(event.target)) {
4030
4030
  return;
@@ -4041,11 +4041,11 @@ function useOnClickOutside(ref, handler) {
4041
4041
  }
4042
4042
 
4043
4043
  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" }) => {
4044
- const [selected, setSelected] = react.exports.useState({});
4045
- const [isDropdown, setDropdown] = react.exports.useState(false);
4046
- const [inputValue, setInputValue] = react.exports.useState(value || "");
4047
- const [countryDataInfo, setCountryData] = react.exports.useState(countryData);
4048
- const ref = react.exports.useRef();
4044
+ const [selected, setSelected] = React.useState({});
4045
+ const [isDropdown, setDropdown] = React.useState(false);
4046
+ const [inputValue, setInputValue] = React.useState(value || "");
4047
+ const [countryDataInfo, setCountryData] = React.useState(countryData);
4048
+ const ref = React.useRef();
4049
4049
  useOnClickOutside(ref, () => setDropdown(false));
4050
4050
  //Handler
4051
4051
  const handleChange = (e) => {
@@ -4075,7 +4075,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
4075
4075
  setSelected(item);
4076
4076
  setDropdown(false);
4077
4077
  };
4078
- react.exports.useMemo(() => {
4078
+ React.useMemo(() => {
4079
4079
  if (dialCodeInputField) {
4080
4080
  const result = inputValue === null || inputValue === void 0 ? void 0 : inputValue.replace(selected.callingCode, getDefaultCountry(country).callingCode);
4081
4081
  console.log(result);
@@ -4083,7 +4083,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
4083
4083
  }
4084
4084
  setSelected(getDefaultCountry(country));
4085
4085
  }, [country, dialCodeInputField]);
4086
- react.exports.useMemo(() => {
4086
+ React.useMemo(() => {
4087
4087
  setCountryData(getCountryByFilter(onlyCountries, excludeCountries, preferredCountries));
4088
4088
  }, [onlyCountries, excludeCountries, preferredCountries]);
4089
4089
  return (React.createElement("div", { className: "simple-phone-input-sri198-container" },