react-simple-phone-input 1.0.8-beta → 1.0.10-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,11 @@
1
- import React, { ReactNode } from "react";
1
+ import React from "react";
2
+ import "./PhoneInput.css";
2
3
  interface Props {
3
4
  placeholder: string;
4
5
  country: string;
5
6
  onChange: (e: string) => void;
6
7
  value?: string;
7
- iconComponent?: ReactNode;
8
+ iconComponent?: React.ReactNode;
8
9
  inputProps?: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
9
10
  onlyCountries?: string[];
10
11
  excludeCountries?: string[];
@@ -14,7 +15,7 @@ interface Props {
14
15
  search?: boolean;
15
16
  searchPlaceholder?: string;
16
17
  showSearchIcon?: boolean;
17
- searchIconComponent?: ReactNode;
18
+ searchIconComponent?: React.ReactNode;
18
19
  searchProps?: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
19
20
  searchNotFound?: string;
20
21
  }
package/dist/esm/index.js CHANGED
@@ -2800,6 +2800,36 @@ function requireReact_development () {
2800
2800
 
2801
2801
  var React = /*@__PURE__*/getDefaultExportFromCjs(react.exports);
2802
2802
 
2803
+ function styleInject(css, ref) {
2804
+ if ( ref === void 0 ) ref = {};
2805
+ var insertAt = ref.insertAt;
2806
+
2807
+ if (!css || typeof document === 'undefined') { return; }
2808
+
2809
+ var head = document.head || document.getElementsByTagName('head')[0];
2810
+ var style = document.createElement('style');
2811
+ style.type = 'text/css';
2812
+
2813
+ if (insertAt === 'top') {
2814
+ if (head.firstChild) {
2815
+ head.insertBefore(style, head.firstChild);
2816
+ } else {
2817
+ head.appendChild(style);
2818
+ }
2819
+ } else {
2820
+ head.appendChild(style);
2821
+ }
2822
+
2823
+ if (style.styleSheet) {
2824
+ style.styleSheet.cssText = css;
2825
+ } else {
2826
+ style.appendChild(document.createTextNode(css));
2827
+ }
2828
+ }
2829
+
2830
+ var css_248z = ".simple-phone-input-sri198-container {\r\n position: relative;\r\n}\r\n\r\n.simple-phone-input-sri198-main {\r\n display: flex;\r\n border: 1px solid rgba(0, 0, 0, 0.295);\r\n user-select: none;\r\n border-radius: 3px;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-container {\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n background: rgba(0, 0, 0, 0.144);\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-container img {\r\n margin-right: 6px;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown {\r\n background: white;\r\n list-style: none;\r\n padding: 0;\r\n margin: 0;\r\n position: absolute;\r\n top: 100%;\r\n left: 0;\r\n right: 0;\r\n height: 250px;\r\n overflow-y: auto;\r\n box-shadow: 0 0 20px rgb(180, 180, 180);\r\n display: none;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-container-button {\r\n display: flex;\r\n flex: 1;\r\n width: 92px;\r\n padding: 5px 2px 5px 7px;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-container-button.dial {\r\n width: unset;\r\n padding: 8px 3px 8px 8px;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown.active {\r\n display: block;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown li {\r\n margin: 3px 0;\r\n padding: 3px 8px;\r\n display: flex;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown li.active {\r\n background: rgba(0, 0, 0, 0.116);\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown li img {\r\n margin-right: 6px;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-text {\r\n font-size: 15px;\r\n flex: 1;\r\n margin-top: 3px;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-country-code {\r\n opacity: 0.6;\r\n margin-top: 3px;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-icon {\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-icon svg {\r\n transition: 0.3s ease;\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown-icon.active svg {\r\n transform: rotate(-180deg)\r\n}\r\n\r\n.simple-phone-input-sri198-dropdown li:hover {\r\n background: rgba(0, 0, 0, 0.116);\r\n}\r\n\r\n.simple-phone-input-sri198-selected-code {\r\n flex: 1;\r\n font-size: 14px;\r\n margin-top: 3px;\r\n}\r\n\r\n.simple-phone-input-sri198-input {\r\n width: 100%;\r\n border: none;\r\n padding: 0 10px;\r\n}\r\n\r\n.simple-phone-input-sri198-input:focus {\r\n outline: none;\r\n}\r\n\r\n.simple-phone-input-sri198-search-container {\r\n padding: 5px;\r\n position: relative;\r\n}\r\n\r\n.simple-phone-input-sri198-search-container input {\r\n border: 1px solid rgba(0, 0, 0, 0.116);\r\n padding: 8px 10px;\r\n width: 100%;\r\n font-size: 15px;\r\n border-radius: 2px;\r\n}\r\n\r\n.simple-phone-input-sri198-search-icon {\r\n position: absolute;\r\n right: 10px;\r\n top: 50%;\r\n transform: translateY(-50%);\r\n display: flex;\r\n pointer-events: none;\r\n}\r\n\r\n.simple-phone-input-sri198-not-found {\r\n text-align: center;\r\n margin-top: 10px;\r\n font-size: 15px;\r\n color: red;\r\n}\r\n\r\n.simple-phone-input-sri198-search-icon svg {\r\n font-size: 20px;\r\n}\r\n\r\n.simple-phone-input-sri198-search-container input:focus {\r\n outline: none;\r\n}";
2831
+ styleInject(css_248z);
2832
+
2803
2833
  const countryData = [
2804
2834
  {
2805
2835
  country: "Afghanistan",
@@ -4022,7 +4052,7 @@ const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
4022
4052
  };
4023
4053
 
4024
4054
  function useOnClickOutside(ref, handler) {
4025
- react.exports.useEffect(() => {
4055
+ React.useEffect(() => {
4026
4056
  const listener = (event) => {
4027
4057
  if (!ref.current || ref.current.contains(event.target)) {
4028
4058
  return;
@@ -4039,11 +4069,11 @@ function useOnClickOutside(ref, handler) {
4039
4069
  }
4040
4070
 
4041
4071
  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();
4072
+ const [selected, setSelected] = React.useState({});
4073
+ const [isDropdown, setDropdown] = React.useState(false);
4074
+ const [inputValue, setInputValue] = React.useState(value || "");
4075
+ const [countryDataInfo, setCountryData] = React.useState(countryData);
4076
+ const ref = React.useRef();
4047
4077
  useOnClickOutside(ref, () => setDropdown(false));
4048
4078
  //Handler
4049
4079
  const handleChange = (e) => {
@@ -4073,7 +4103,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
4073
4103
  setSelected(item);
4074
4104
  setDropdown(false);
4075
4105
  };
4076
- react.exports.useMemo(() => {
4106
+ React.useMemo(() => {
4077
4107
  if (dialCodeInputField) {
4078
4108
  const result = inputValue === null || inputValue === void 0 ? void 0 : inputValue.replace(selected.callingCode, getDefaultCountry(country).callingCode);
4079
4109
  console.log(result);
@@ -4081,7 +4111,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
4081
4111
  }
4082
4112
  setSelected(getDefaultCountry(country));
4083
4113
  }, [country, dialCodeInputField]);
4084
- react.exports.useMemo(() => {
4114
+ React.useMemo(() => {
4085
4115
  setCountryData(getCountryByFilter(onlyCountries, excludeCountries, preferredCountries));
4086
4116
  }, [onlyCountries, excludeCountries, preferredCountries]);
4087
4117
  return (React.createElement("div", { className: "simple-phone-input-sri198-container" },