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.
- package/dist/cjs/index.js +38 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/PhoneInput/PhoneInput.d.ts +4 -3
- package/dist/esm/index.js +38 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/PhoneInput/PhoneInput.d.ts +4 -3
- package/dist/index.d.ts +3 -3
- package/package.json +5 -1
- package/dist/cjs/types/components/button/Button.d.ts +0 -7
- package/dist/cjs/types/components/button/index.d.ts +0 -1
- package/dist/esm/types/components/button/Button.d.ts +0 -7
- package/dist/esm/types/components/button/index.d.ts +0 -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",
|
|
@@ -4024,7 +4054,7 @@ const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
|
|
|
4024
4054
|
};
|
|
4025
4055
|
|
|
4026
4056
|
function useOnClickOutside(ref, handler) {
|
|
4027
|
-
|
|
4057
|
+
React.useEffect(() => {
|
|
4028
4058
|
const listener = (event) => {
|
|
4029
4059
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
4030
4060
|
return;
|
|
@@ -4041,11 +4071,11 @@ function useOnClickOutside(ref, handler) {
|
|
|
4041
4071
|
}
|
|
4042
4072
|
|
|
4043
4073
|
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] =
|
|
4045
|
-
const [isDropdown, setDropdown] =
|
|
4046
|
-
const [inputValue, setInputValue] =
|
|
4047
|
-
const [countryDataInfo, setCountryData] =
|
|
4048
|
-
const ref =
|
|
4074
|
+
const [selected, setSelected] = React.useState({});
|
|
4075
|
+
const [isDropdown, setDropdown] = React.useState(false);
|
|
4076
|
+
const [inputValue, setInputValue] = React.useState(value || "");
|
|
4077
|
+
const [countryDataInfo, setCountryData] = React.useState(countryData);
|
|
4078
|
+
const ref = React.useRef();
|
|
4049
4079
|
useOnClickOutside(ref, () => setDropdown(false));
|
|
4050
4080
|
//Handler
|
|
4051
4081
|
const handleChange = (e) => {
|
|
@@ -4075,7 +4105,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
|
|
|
4075
4105
|
setSelected(item);
|
|
4076
4106
|
setDropdown(false);
|
|
4077
4107
|
};
|
|
4078
|
-
|
|
4108
|
+
React.useMemo(() => {
|
|
4079
4109
|
if (dialCodeInputField) {
|
|
4080
4110
|
const result = inputValue === null || inputValue === void 0 ? void 0 : inputValue.replace(selected.callingCode, getDefaultCountry(country).callingCode);
|
|
4081
4111
|
console.log(result);
|
|
@@ -4083,7 +4113,7 @@ const PhoneInput = ({ placeholder, country, onChange, value, iconComponent, inpu
|
|
|
4083
4113
|
}
|
|
4084
4114
|
setSelected(getDefaultCountry(country));
|
|
4085
4115
|
}, [country, dialCodeInputField]);
|
|
4086
|
-
|
|
4116
|
+
React.useMemo(() => {
|
|
4087
4117
|
setCountryData(getCountryByFilter(onlyCountries, excludeCountries, preferredCountries));
|
|
4088
4118
|
}, [onlyCountries, excludeCountries, preferredCountries]);
|
|
4089
4119
|
return (React.createElement("div", { className: "simple-phone-input-sri198-container" },
|