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/cjs/index.js
CHANGED
|
@@ -2802,6 +2802,36 @@ function requireReact_development () {
|
|
|
2802
2802
|
|
|
2803
2803
|
var React = /*@__PURE__*/getDefaultExportFromCjs(react.exports);
|
|
2804
2804
|
|
|
2805
|
+
function styleInject(css, ref) {
|
|
2806
|
+
if ( ref === void 0 ) ref = {};
|
|
2807
|
+
var insertAt = ref.insertAt;
|
|
2808
|
+
|
|
2809
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
2810
|
+
|
|
2811
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
2812
|
+
var style = document.createElement('style');
|
|
2813
|
+
style.type = 'text/css';
|
|
2814
|
+
|
|
2815
|
+
if (insertAt === 'top') {
|
|
2816
|
+
if (head.firstChild) {
|
|
2817
|
+
head.insertBefore(style, head.firstChild);
|
|
2818
|
+
} else {
|
|
2819
|
+
head.appendChild(style);
|
|
2820
|
+
}
|
|
2821
|
+
} else {
|
|
2822
|
+
head.appendChild(style);
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
if (style.styleSheet) {
|
|
2826
|
+
style.styleSheet.cssText = css;
|
|
2827
|
+
} else {
|
|
2828
|
+
style.appendChild(document.createTextNode(css));
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
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}";
|
|
2833
|
+
styleInject(css_248z);
|
|
2834
|
+
|
|
2805
2835
|
const countryData = [
|
|
2806
2836
|
{
|
|
2807
2837
|
country: "Afghanistan",
|
|
@@ -4023,30 +4053,11 @@ const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
|
|
|
4023
4053
|
return result;
|
|
4024
4054
|
};
|
|
4025
4055
|
|
|
4026
|
-
function useOnClickOutside(ref, handler) {
|
|
4027
|
-
React.useEffect(() => {
|
|
4028
|
-
const listener = (event) => {
|
|
4029
|
-
if (!ref.current || ref.current.contains(event.target)) {
|
|
4030
|
-
return;
|
|
4031
|
-
}
|
|
4032
|
-
handler(event);
|
|
4033
|
-
};
|
|
4034
|
-
document.addEventListener("mousedown", listener);
|
|
4035
|
-
document.addEventListener("touchstart", listener);
|
|
4036
|
-
return () => {
|
|
4037
|
-
document.removeEventListener("mousedown", listener);
|
|
4038
|
-
document.removeEventListener("touchstart", listener);
|
|
4039
|
-
};
|
|
4040
|
-
}, [ref, handler]);
|
|
4041
|
-
}
|
|
4042
|
-
|
|
4043
4056
|
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
4057
|
const [selected, setSelected] = React.useState({});
|
|
4045
4058
|
const [isDropdown, setDropdown] = React.useState(false);
|
|
4046
4059
|
const [inputValue, setInputValue] = React.useState(value || "");
|
|
4047
4060
|
const [countryDataInfo, setCountryData] = React.useState(countryData);
|
|
4048
|
-
const ref = React.useRef();
|
|
4049
|
-
useOnClickOutside(ref, () => setDropdown(false));
|
|
4050
4061
|
//Handler
|
|
4051
4062
|
const handleChange = (e) => {
|
|
4052
4063
|
const onlyNumber = e.target.value.replace(/\D/g, '');
|
|
@@ -4088,7 +4099,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
|
|
|
4088
4099
|
}, [onlyCountries, excludeCountries, preferredCountries]);
|
|
4089
4100
|
return (React.createElement("div", { className: "simple-phone-input-sri198-container" },
|
|
4090
4101
|
React.createElement("div", { className: "simple-phone-input-sri198-main" },
|
|
4091
|
-
React.createElement("div", { className: "simple-phone-input-sri198-dropdown-container"
|
|
4102
|
+
React.createElement("div", { className: "simple-phone-input-sri198-dropdown-container" },
|
|
4092
4103
|
React.createElement("div", { onClick: () => setDropdown(!isDropdown), className: dialCodeInputField ? "simple-phone-input-sri198-dropdown-container-button dial" : "simple-phone-input-sri198-dropdown-container-button" },
|
|
4093
4104
|
React.createElement("img", { src: "https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/" + selected.countryCode + ".svg", alt: selected.country, width: "20px" }),
|
|
4094
4105
|
!dialCodeInputField &&
|