react-simple-phone-input 1.0.9-beta → 1.0.11-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 +31 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/PhoneInput/PhoneInput.d.ts +1 -0
- package/dist/esm/index.js +31 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/PhoneInput/PhoneInput.d.ts +1 -0
- package/package.json +5 -1
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",
|
|
@@ -4021,30 +4051,11 @@ const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
|
|
|
4021
4051
|
return result;
|
|
4022
4052
|
};
|
|
4023
4053
|
|
|
4024
|
-
function useOnClickOutside(ref, handler) {
|
|
4025
|
-
React.useEffect(() => {
|
|
4026
|
-
const listener = (event) => {
|
|
4027
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
4028
|
-
return;
|
|
4029
|
-
}
|
|
4030
|
-
handler(event);
|
|
4031
|
-
};
|
|
4032
|
-
document.addEventListener("mousedown", listener);
|
|
4033
|
-
document.addEventListener("touchstart", listener);
|
|
4034
|
-
return () => {
|
|
4035
|
-
document.removeEventListener("mousedown", listener);
|
|
4036
|
-
document.removeEventListener("touchstart", listener);
|
|
4037
|
-
};
|
|
4038
|
-
}, [ref, handler]);
|
|
4039
|
-
}
|
|
4040
|
-
|
|
4041
4054
|
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
4055
|
const [selected, setSelected] = React.useState({});
|
|
4043
4056
|
const [isDropdown, setDropdown] = React.useState(false);
|
|
4044
4057
|
const [inputValue, setInputValue] = React.useState(value || "");
|
|
4045
4058
|
const [countryDataInfo, setCountryData] = React.useState(countryData);
|
|
4046
|
-
const ref = React.useRef();
|
|
4047
|
-
useOnClickOutside(ref, () => setDropdown(false));
|
|
4048
4059
|
//Handler
|
|
4049
4060
|
const handleChange = (e) => {
|
|
4050
4061
|
const onlyNumber = e.target.value.replace(/\D/g, '');
|
|
@@ -4086,7 +4097,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
|
|
|
4086
4097
|
}, [onlyCountries, excludeCountries, preferredCountries]);
|
|
4087
4098
|
return (React.createElement("div", { className: "simple-phone-input-sri198-container" },
|
|
4088
4099
|
React.createElement("div", { className: "simple-phone-input-sri198-main" },
|
|
4089
|
-
React.createElement("div", { className: "simple-phone-input-sri198-dropdown-container"
|
|
4100
|
+
React.createElement("div", { className: "simple-phone-input-sri198-dropdown-container" },
|
|
4090
4101
|
React.createElement("div", { onClick: () => setDropdown(!isDropdown), className: dialCodeInputField ? "simple-phone-input-sri198-dropdown-container-button dial" : "simple-phone-input-sri198-dropdown-container-button" },
|
|
4091
4102
|
React.createElement("img", { src: "https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/" + selected.countryCode + ".svg", alt: selected.country, width: "20px" }),
|
|
4092
4103
|
!dialCodeInputField &&
|