react-simple-phone-input 3.2.6 → 4.0.1

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/esm/index.js CHANGED
@@ -1,11 +1,1368 @@
1
- import o from"react";var e,n={exports:{}},r={};var t,c,a={};
2
- /**
3
- * @license React
4
- * react-jsx-runtime.development.js
5
- *
6
- * Copyright (c) Facebook, Inc. and its affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */function l(){return t||(t=1,"production"!==process.env.NODE_ENV&&function(){var e=o,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),i=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),s=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),f=Symbol.iterator;var m=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(o){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];v("error",o,n)}function v(o,e,n){var r=m.ReactDebugCurrentFrame.getStackAddendum();""!==r&&(e+="%s",n=n.concat([r]));var t=n.map((function(o){return String(o)}));t.unshift("Warning: "+e),Function.prototype.apply.call(console[o],console,t)}var b;function S(o){return o.displayName||"Context"}function w(o){if(null==o)return null;if("number"==typeof o.tag&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof o)return o.displayName||o.name||null;if("string"==typeof o)return o;switch(o){case t:return"Fragment";case r:return"Portal";case l:return"Profiler";case c:return"StrictMode";case y:return"Suspense";case s:return"SuspenseList"}if("object"==typeof o)switch(o.$$typeof){case i:return S(o)+".Consumer";case u:return S(o._context)+".Provider";case d:return function(o,e,n){var r=o.displayName;if(r)return r;var t=e.displayName||e.name||"";return""!==t?n+"("+t+")":n}(o,o.render,"ForwardRef");case C:var e=o.displayName||null;return null!==e?e:w(o.type)||"Memo";case g:var n=o,a=n._payload,p=n._init;try{return w(p(a))}catch(o){return null}}return null}b=Symbol.for("react.module.reference");var x,N,T,E,R,j,k,M=Object.assign,P=0;function _(){}_.__reactDisabledLog=!0;var I,O=m.ReactCurrentDispatcher;function A(o,e,n){if(void 0===I)try{throw Error()}catch(o){var r=o.stack.trim().match(/\n( *(at )?)/);I=r&&r[1]||""}return"\n"+I+o}var B,F=!1,G="function"==typeof WeakMap?WeakMap:Map;function D(o,e){if(!o||F)return"";var n,r=B.get(o);if(void 0!==r)return r;F=!0;var t,c=Error.prepareStackTrace;Error.prepareStackTrace=void 0,t=O.current,O.current=null,function(){if(0===P){x=console.log,N=console.info,T=console.warn,E=console.error,R=console.group,j=console.groupCollapsed,k=console.groupEnd;var o={configurable:!0,enumerable:!0,value:_,writable:!0};Object.defineProperties(console,{info:o,log:o,warn:o,error:o,group:o,groupCollapsed:o,groupEnd:o})}P++}();try{if(e){var a=function(){throw Error()};if(Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(a,[])}catch(o){n=o}Reflect.construct(o,[],a)}else{try{a.call()}catch(o){n=o}o.call(a.prototype)}}else{try{throw Error()}catch(o){n=o}o()}}catch(e){if(e&&n&&"string"==typeof e.stack){for(var l=e.stack.split("\n"),u=n.stack.split("\n"),i=l.length-1,d=u.length-1;i>=1&&d>=0&&l[i]!==u[d];)d--;for(;i>=1&&d>=0;i--,d--)if(l[i]!==u[d]){if(1!==i||1!==d)do{if(i--,--d<0||l[i]!==u[d]){var y="\n"+l[i].replace(" at new "," at ");return o.displayName&&y.includes("<anonymous>")&&(y=y.replace("<anonymous>",o.displayName)),"function"==typeof o&&B.set(o,y),y}}while(i>=1&&d>=0);break}}}finally{F=!1,O.current=t,function(){if(0==--P){var o={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},o,{value:x}),info:M({},o,{value:N}),warn:M({},o,{value:T}),error:M({},o,{value:E}),group:M({},o,{value:R}),groupCollapsed:M({},o,{value:j}),groupEnd:M({},o,{value:k})})}P<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=c}var s=o?o.displayName||o.name:"",C=s?A(s):"";return"function"==typeof o&&B.set(o,C),C}function L(o,e,n){if(null==o)return"";if("function"==typeof o)return D(o,!(!(r=o.prototype)||!r.isReactComponent));var r;if("string"==typeof o)return A(o);switch(o){case y:return A("Suspense");case s:return A("SuspenseList")}if("object"==typeof o)switch(o.$$typeof){case d:return D(o.render,!1);case C:return L(o.type,e,n);case g:var t=o,c=t._payload,a=t._init;try{return L(a(c),e,n)}catch(o){}}return""}B=new G;var U=Object.prototype.hasOwnProperty,K={},$=m.ReactDebugCurrentFrame;function V(o){if(o){var e=o._owner,n=L(o.type,o._source,e?e.type:null);$.setExtraStackFrame(n)}else $.setExtraStackFrame(null)}var W=Array.isArray;function z(o){return W(o)}function H(o){return""+o}function Y(o){if(function(o){try{return H(o),!1}catch(o){return!0}}(o))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(o){return"function"==typeof Symbol&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object"}(o)),H(o)}var Z,J,q,Q=m.ReactCurrentOwner,X={key:!0,ref:!0,__self:!0,__source:!0};q={};function oo(o,e,r,t,c){var a,l={},u=null,i=null;for(a in void 0!==r&&(Y(r),u=""+r),function(o){if(U.call(o,"key")){var e=Object.getOwnPropertyDescriptor(o,"key").get;if(e&&e.isReactWarning)return!1}return void 0!==o.key}(e)&&(Y(e.key),u=""+e.key),function(o){if(U.call(o,"ref")){var e=Object.getOwnPropertyDescriptor(o,"ref").get;if(e&&e.isReactWarning)return!1}return void 0!==o.ref}(e)&&(i=e.ref,function(o,e){if("string"==typeof o.ref&&Q.current&&e&&Q.current.stateNode!==e){var n=w(Q.current.type);q[n]||(h('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',w(Q.current.type),o.ref),q[n]=!0)}}(e,c)),e)U.call(e,a)&&!X.hasOwnProperty(a)&&(l[a]=e[a]);if(o&&o.defaultProps){var d=o.defaultProps;for(a in d)void 0===l[a]&&(l[a]=d[a])}if(u||i){var y="function"==typeof o?o.displayName||o.name||"Unknown":o;u&&function(o,e){var n=function(){Z||(Z=!0,h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",e))};n.isReactWarning=!0,Object.defineProperty(o,"key",{get:n,configurable:!0})}(l,y),i&&function(o,e){var n=function(){J||(J=!0,h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",e))};n.isReactWarning=!0,Object.defineProperty(o,"ref",{get:n,configurable:!0})}(l,y)}return function(o,e,r,t,c,a,l){var u={$$typeof:n,type:o,key:e,ref:r,props:l,_owner:a,_store:{}};return Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(u,"_self",{configurable:!1,enumerable:!1,writable:!1,value:t}),Object.defineProperty(u,"_source",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u}(o,u,i,c,t,Q.current,l)}var eo,no=m.ReactCurrentOwner,ro=m.ReactDebugCurrentFrame;function to(o){if(o){var e=o._owner,n=L(o.type,o._source,e?e.type:null);ro.setExtraStackFrame(n)}else ro.setExtraStackFrame(null)}function co(o){return"object"==typeof o&&null!==o&&o.$$typeof===n}function ao(){if(no.current){var o=w(no.current.type);if(o)return"\n\nCheck the render method of `"+o+"`."}return""}eo=!1;var lo={};function uo(o,e){if(o._store&&!o._store.validated&&null==o.key){o._store.validated=!0;var n=function(o){var e=ao();if(!e){var n="string"==typeof o?o:o.displayName||o.name;n&&(e="\n\nCheck the top-level render call using <"+n+">.")}return e}(e);if(!lo[n]){lo[n]=!0;var r="";o&&o._owner&&o._owner!==no.current&&(r=" It was passed a child from "+w(o._owner.type)+"."),to(o),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),to(null)}}}function io(o,e){if("object"==typeof o)if(z(o))for(var n=0;n<o.length;n++){var r=o[n];co(r)&&uo(r,e)}else if(co(o))o._store&&(o._store.validated=!0);else if(o){var t=function(o){if(null===o||"object"!=typeof o)return null;var e=f&&o[f]||o["@@iterator"];return"function"==typeof e?e:null}(o);if("function"==typeof t&&t!==o.entries)for(var c,a=t.call(o);!(c=a.next()).done;)co(c.value)&&uo(c.value,e)}}function yo(o){var e,n=o.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)e=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==d&&n.$$typeof!==C)return;e=n.propTypes}if(e){var r=w(n);!function(o,e,n,r,t){var c=Function.call.bind(U);for(var a in o)if(c(o,a)){var l=void 0;try{if("function"!=typeof o[a]){var u=Error((r||"React class")+": "+n+" type `"+a+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[a]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}l=o[a](e,a,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(o){l=o}!l||l instanceof Error||(V(t),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",n,a,typeof l),V(null)),l instanceof Error&&!(l.message in K)&&(K[l.message]=!0,V(t),h("Failed %s type: %s",n,l.message),V(null))}}(e,o.props,"prop",r,o)}else if(void 0!==n.PropTypes&&!eo){eo=!0,h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w(n)||"Unknown")}"function"!=typeof n.getDefaultProps||n.getDefaultProps.isReactClassApproved||h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function so(o,e,r,a,f,m){var v=function(o){return"string"==typeof o||"function"==typeof o||o===t||o===l||o===c||o===y||o===s||o===p||"object"==typeof o&&null!==o&&(o.$$typeof===g||o.$$typeof===C||o.$$typeof===u||o.$$typeof===i||o.$$typeof===d||o.$$typeof===b||void 0!==o.getModuleId)}(o);if(!v){var S="";(void 0===o||"object"==typeof o&&null!==o&&0===Object.keys(o).length)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var x,N=function(o){return void 0!==o?"\n\nCheck your code at "+o.fileName.replace(/^.*[\\\/]/,"")+":"+o.lineNumber+".":""}(f);S+=N||ao(),null===o?x="null":z(o)?x="array":void 0!==o&&o.$$typeof===n?(x="<"+(w(o.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):x=typeof o,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",x,S)}var T=oo(o,e,r,f,m);if(null==T)return T;if(v){var E=e.children;if(void 0!==E)if(a)if(z(E)){for(var R=0;R<E.length;R++)io(E[R],o);Object.freeze&&Object.freeze(E)}else h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else io(E,o)}return o===t?function(o){for(var e=Object.keys(o.props),n=0;n<e.length;n++){var r=e[n];if("children"!==r&&"key"!==r){to(o),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),to(null);break}}null!==o.ref&&(to(o),h("Invalid attribute `ref` supplied to `React.Fragment`."),to(null))}(T):yo(T),T}var Co=function(o,e,n){return so(o,e,n,!1)},go=function(o,e,n){return so(o,e,n,!0)};a.Fragment=t,a.jsx=Co,a.jsxs=go}()),a}c=n,"production"===process.env.NODE_ENV?c.exports=function(){if(e)return r;e=1;var n=o,t=Symbol.for("react.element"),c=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function i(o,e,n){var r,c={},i=null,d=null;for(r in void 0!==n&&(i=""+n),void 0!==e.key&&(i=""+e.key),void 0!==e.ref&&(d=e.ref),e)a.call(e,r)&&!u.hasOwnProperty(r)&&(c[r]=e[r]);if(o&&o.defaultProps)for(r in e=o.defaultProps)void 0===c[r]&&(c[r]=e[r]);return{$$typeof:t,type:o,key:i,ref:d,props:c,_owner:l.current}}return r.Fragment=c,r.jsx=i,r.jsxs=i,r}():c.exports=l();const u=[{country:"Afghanistan",countryCode:"AF",callingCode:"+93"},{country:"Albania",countryCode:"AL",callingCode:"+355"},{country:"Algeria",countryCode:"DZ",callingCode:"+213"},{country:"American Samoa",countryCode:"AS",callingCode:"+1684"},{country:"Andorra",countryCode:"AD",callingCode:"+376"},{country:"Angola",countryCode:"AO",callingCode:"+244"},{country:"Anguilla",countryCode:"AI",callingCode:"+1264"},{country:"Antarctica",countryCode:"AQ",callingCode:"+672"},{country:"Antigua and Barbuda",countryCode:"AG",callingCode:"+1268"},{country:"Argentina",countryCode:"AR",callingCode:"+54"},{country:"Armenia",countryCode:"AM",callingCode:"+374"},{country:"Aruba",countryCode:"AW",callingCode:"+297"},{country:"Australia",countryCode:"AU",callingCode:"+61"},{country:"Austria",countryCode:"AT",callingCode:"+43"},{country:"Azerbaijan",countryCode:"AZ",callingCode:"+994"},{country:"Bahamas",countryCode:"BS",callingCode:"+1242"},{country:"Bahrain",countryCode:"BH",callingCode:"+973"},{country:"Bangladesh",countryCode:"BD",callingCode:"+880"},{country:"Barbados",countryCode:"BB",callingCode:"+1246"},{country:"Belarus",countryCode:"BY",callingCode:"+375"},{country:"Belgium",countryCode:"BE",callingCode:"+32"},{country:"Belize",countryCode:"BZ",callingCode:"+501"},{country:"Benin",countryCode:"BJ",callingCode:"+229"},{country:"Bermuda",countryCode:"BM",callingCode:"+1441"},{country:"Bhutan",countryCode:"BT",callingCode:"+975"},{country:"Bolivia",countryCode:"BO",callingCode:"+591"},{country:"Bosnia and Herzegovina",countryCode:"BA",callingCode:"+387"},{country:"Botswana",countryCode:"BW",callingCode:"+267"},{country:"Bouvet Island",countryCode:"BV",callingCode:"+47"},{country:"Brazil",countryCode:"BR",callingCode:"+55"},{country:"British Indian Ocean Territory",countryCode:"IO",callingCode:"+246"},{country:"British Virgin Islands",countryCode:"VG",callingCode:"+1284"},{country:"Brunei",countryCode:"BN",callingCode:"+673"},{country:"Bulgaria",countryCode:"BG",callingCode:"+359"},{country:"Burkina Faso",countryCode:"BF",callingCode:"+226"},{country:"Burundi",countryCode:"BI",callingCode:"+257"},{country:"Cambodia",countryCode:"KH",callingCode:"+855"},{country:"Cameroon",countryCode:"CM",callingCode:"+237"},{country:"Canada",countryCode:"CA",callingCode:"+1"},{country:"Cape Verde",countryCode:"CV",callingCode:"+238"},{country:"Cayman Islands",countryCode:"KY",callingCode:"+1345"},{country:"Central African Republic",countryCode:"CF",callingCode:"+236"},{country:"Chad",countryCode:"TD",callingCode:"+235"},{country:"Chile",countryCode:"CL",callingCode:"+56"},{country:"China",countryCode:"CN",callingCode:"+86"},{country:"Christmas Island",countryCode:"CX",callingCode:"+61"},{country:"Cocos Islands",countryCode:"CC",callingCode:"+61"},{country:"Colombia",countryCode:"CO",callingCode:"+57"},{country:"Comoros",countryCode:"KM",callingCode:"+269"},{country:"Cook Islands",countryCode:"CK",callingCode:"+682"},{country:"Costa Rica",countryCode:"CR",callingCode:"+506"},{country:"Croatia",countryCode:"HR",callingCode:"+385"},{country:"Cuba",countryCode:"CU",callingCode:"+53"},{country:"Cyprus",countryCode:"CY",callingCode:"+357"},{country:"Czech Republic",countryCode:"CZ",callingCode:"+420"},{country:"Democratic Republic of the Congo",countryCode:"CD",callingCode:"+243"},{country:"Denmark",countryCode:"DK",callingCode:"+45"},{country:"Djibouti",countryCode:"DJ",callingCode:"+253"},{country:"Dominica",countryCode:"DM",callingCode:"+1767"},{country:"Dominican Republic",countryCode:"DO",callingCode:"+1"},{country:"East Timor",countryCode:"TL",callingCode:"+670"},{country:"Ecuador",countryCode:"EC",callingCode:"+593"},{country:"Egypt",countryCode:"EG",callingCode:"+20"},{country:"El Salvador",countryCode:"SV",callingCode:"+503"},{country:"Equatorial Guinea",countryCode:"GQ",callingCode:"+240"},{country:"Eritrea",countryCode:"ER",callingCode:"+291"},{country:"Estonia",countryCode:"EE",callingCode:"+372"},{country:"Ethiopia",countryCode:"ET",callingCode:"+251"},{country:"Falkland Islands",countryCode:"FK",callingCode:"+500"},{country:"Faroe Islands",countryCode:"FO",callingCode:"+298"},{country:"Fiji",countryCode:"FJ",callingCode:"+679"},{country:"Finland",countryCode:"FI",callingCode:"+358"},{country:"France",countryCode:"FR",callingCode:"+33"},{country:"French Guiana",countryCode:"GF",callingCode:"+594"},{country:"French Polynesia",countryCode:"PF",callingCode:"+689"},{country:"French Southern Territories",countryCode:"TF",callingCode:"+262"},{country:"Gabon",countryCode:"GA",callingCode:"+241"},{country:"Gambia",countryCode:"GM",callingCode:"+220"},{country:"Georgia",countryCode:"GE",callingCode:"+995"},{country:"Germany",countryCode:"DE",callingCode:"+49"},{country:"Ghana",countryCode:"GH",callingCode:"+233"},{country:"Gibraltar",countryCode:"GI",callingCode:"+350"},{country:"Greece",countryCode:"GR",callingCode:"+30"},{country:"Greenland",countryCode:"GL",callingCode:"+299"},{country:"Grenada",countryCode:"GD",callingCode:"+473"},{country:"Guadeloupe",countryCode:"GP",callingCode:"+590"},{country:"Guam",countryCode:"GU",callingCode:"+1671"},{country:"Guatemala",countryCode:"GT",callingCode:"+502"},{country:"Guinea",countryCode:"GN",callingCode:"+224"},{country:"Guinea-Bissau",countryCode:"GW",callingCode:"+245"},{country:"Guyana",countryCode:"GY",callingCode:"+592"},{country:"Haiti",countryCode:"HT",callingCode:"+509"},{country:"Honduras",countryCode:"HN",callingCode:"+504"},{country:"Hong Kong",countryCode:"HK",callingCode:"+852"},{country:"Hungary",countryCode:"HU",callingCode:"+36"},{country:"Iceland",countryCode:"IS",callingCode:"+354"},{country:"India",countryCode:"IN",callingCode:"+91"},{country:"Indonesia",countryCode:"ID",callingCode:"+62"},{country:"Iran",countryCode:"IR",callingCode:"+98"},{country:"Iraq",countryCode:"IQ",callingCode:"+964"},{country:"Ireland",countryCode:"IE",callingCode:"+353"},{country:"Israel",countryCode:"IL",callingCode:"+972"},{country:"Italy",countryCode:"IT",callingCode:"+39"},{country:"Ivory Coast",countryCode:"CI",callingCode:"+225"},{country:"Jamaica",countryCode:"JM",callingCode:"+1876"},{country:"Japan",countryCode:"JP",callingCode:"+81"},{country:"Jordan",countryCode:"JO",callingCode:"+962"},{country:"Kazakhstan",countryCode:"KZ",callingCode:"+7"},{country:"Kenya",countryCode:"KE",callingCode:"+254"},{country:"Kiribati",countryCode:"KI",callingCode:"+686"},{country:"Kuwait",countryCode:"KW",callingCode:"+965"},{country:"Kyrgyzstan",countryCode:"KG",callingCode:"+996"},{country:"Laos",countryCode:"LA",callingCode:"+856"},{country:"Latvia",countryCode:"LV",callingCode:"+371"},{country:"Lebanon",countryCode:"LB",callingCode:"+961"},{country:"Lesotho",countryCode:"LS",callingCode:"+266"},{country:"Liberia",countryCode:"LR",callingCode:"+231"},{country:"Libya",countryCode:"LY",callingCode:"+218"},{country:"Liechtenstein",countryCode:"LI",callingCode:"+423"},{country:"Lithuania",countryCode:"LT",callingCode:"+370"},{country:"Luxembourg",countryCode:"LU",callingCode:"+352"},{country:"Macao",countryCode:"MO",callingCode:"+853"},{country:"Macedonia",countryCode:"MK",callingCode:"+389"},{country:"Madagascar",countryCode:"MG",callingCode:"+261"},{country:"Malawi",countryCode:"MW",callingCode:"+265"},{country:"Malaysia",countryCode:"MY",callingCode:"+60"},{country:"Maldives",countryCode:"MV",callingCode:"+960"},{country:"Mali",countryCode:"ML",callingCode:"+223"},{country:"Malta",countryCode:"MT",callingCode:"+356"},{country:"Marshall Islands",countryCode:"MH",callingCode:"+692"},{country:"Martinique",countryCode:"MQ",callingCode:"+596"},{country:"Mauritania",countryCode:"MR",callingCode:"+222"},{country:"Mauritius",countryCode:"MU",callingCode:"+230"},{country:"Mayotte",countryCode:"YT",callingCode:"+262"},{country:"Mexico",countryCode:"MX",callingCode:"+52"},{country:"Micronesia",countryCode:"FM",callingCode:"+691"},{country:"Moldova",countryCode:"MD",callingCode:"+373"},{country:"Monaco",countryCode:"MC",callingCode:"+377"},{country:"Mongolia",countryCode:"MN",callingCode:"+976"},{country:"Montserrat",countryCode:"MS",callingCode:"+1664"},{country:"Morocco",countryCode:"MA",callingCode:"+212"},{country:"Mozambique",countryCode:"MZ",callingCode:"+258"},{country:"Myanmar",countryCode:"MM",callingCode:"+95"},{country:"Namibia",countryCode:"NA",callingCode:"+264"},{country:"Nauru",countryCode:"NR",callingCode:"+674"},{country:"Nepal",countryCode:"NP",callingCode:"+977"},{country:"Netherlands",countryCode:"NL",callingCode:"+31"},{country:"New Caledonia",countryCode:"NC",callingCode:"+687"},{country:"New Zealand",countryCode:"NZ",callingCode:"+64"},{country:"Nicaragua",countryCode:"NI",callingCode:"+505"},{country:"Niger",countryCode:"NE",callingCode:"+227"},{country:"Nigeria",countryCode:"NG",callingCode:"+234"},{country:"Niue",countryCode:"NU",callingCode:"+683"},{country:"Norfolk Island",countryCode:"NF",callingCode:"+672"},{country:"North Korea",countryCode:"KP",callingCode:"+850"},{country:"Northern Mariana Islands",countryCode:"MP",callingCode:"+1670"},{country:"Norway",countryCode:"NO",callingCode:"+47"},{country:"Oman",countryCode:"OM",callingCode:"+968"},{country:"Pakistan",countryCode:"PK",callingCode:"+92"},{country:"Palau",countryCode:"PW",callingCode:"+680"},{country:"Palestinian Territory",countryCode:"PS",callingCode:"+970"},{country:"Panama",countryCode:"PA",callingCode:"+507"},{country:"Papua New Guinea",countryCode:"PG",callingCode:"+675"},{country:"Paraguay",countryCode:"PY",callingCode:"+595"},{country:"Peru",countryCode:"PE",callingCode:"+51"},{country:"Philippines",countryCode:"PH",callingCode:"+63"},{country:"Pitcairn",countryCode:"PN",callingCode:"+872"},{country:"Poland",countryCode:"PL",callingCode:"+48"},{country:"Portugal",countryCode:"PT",callingCode:"+351"},{country:"Puerto Rico",countryCode:"PR",callingCode:"+1"},{country:"Qatar",countryCode:"QA",callingCode:"+974"},{country:"Republic of the Congo",countryCode:"CG",callingCode:"+242"},{country:"Reunion",countryCode:"RE",callingCode:"+262"},{country:"Romania",countryCode:"RO",callingCode:"+40"},{country:"Russia",countryCode:"RU",callingCode:"+7"},{country:"Rwanda",countryCode:"RW",callingCode:"+250"},{country:"Saint Helena",countryCode:"SH",callingCode:"+290"},{country:"Saint Kitts and Nevis",countryCode:"KN",callingCode:"+1869"},{country:"Saint Lucia",countryCode:"LC",callingCode:"+1758"},{country:"Saint Pierre and Miquelon",countryCode:"PM",callingCode:"+508"},{country:"Saint Vincent and the Grenadines",countryCode:"VC",callingCode:"+1784"},{country:"Samoa",countryCode:"WS",callingCode:"+685"},{country:"San Marino",countryCode:"SM",callingCode:"+378"},{country:"Sao Tome and Principe",countryCode:"ST",callingCode:"+239"},{country:"Saudi Arabia",countryCode:"SA",callingCode:"+966"},{country:"Senegal",countryCode:"SN",callingCode:"+221"},{country:"Seychelles",countryCode:"SC",callingCode:"+248"},{country:"Sierra Leone",countryCode:"SL",callingCode:"+232"},{country:"Singapore",countryCode:"SG",callingCode:"+65"},{country:"Slovakia",countryCode:"SK",callingCode:"+421"},{country:"Slovenia",countryCode:"SI",callingCode:"+386"},{country:"Solomon Islands",countryCode:"SB",callingCode:"+677"},{country:"Somalia",countryCode:"SO",callingCode:"+252"},{country:"South Africa",countryCode:"ZA",callingCode:"+27"},{country:"South Georgia and the South Sandwich Islands",countryCode:"GS",callingCode:"+500"},{country:"South Korea",countryCode:"KR",callingCode:"+82"},{country:"Spain",countryCode:"ES",callingCode:"+34"},{country:"Sri Lanka",countryCode:"LK",callingCode:"+94"},{country:"Sudan",countryCode:"SD",callingCode:"+249"},{country:"Suriname",countryCode:"SR",callingCode:"+597"},{country:"Svalbard and Jan Mayen",countryCode:"SJ",callingCode:"+47"},{country:"Swaziland",countryCode:"SZ",callingCode:"+268"},{country:"Sweden",countryCode:"SE",callingCode:"+46"},{country:"Switzerland",countryCode:"CH",callingCode:"+41"},{country:"Syria",countryCode:"SY",callingCode:"+963"},{country:"Taiwan",countryCode:"TW",callingCode:"+886"},{country:"Tajikistan",countryCode:"TJ",callingCode:"+992"},{country:"Tanzania",countryCode:"TZ",callingCode:"+255"},{country:"Thailand",countryCode:"TH",callingCode:"+66"},{country:"Togo",countryCode:"TG",callingCode:"+228"},{country:"Tokelau",countryCode:"TK",callingCode:"+690"},{country:"Tonga",countryCode:"TO",callingCode:"+676"},{country:"Trinidad and Tobago",countryCode:"TT",callingCode:"+1868"},{country:"Tunisia",countryCode:"TN",callingCode:"+216"},{country:"Turkey",countryCode:"TR",callingCode:"+90"},{country:"Turkmenistan",countryCode:"TM",callingCode:"+993"},{country:"Turks and Caicos Islands",countryCode:"TC",callingCode:"+1649"},{country:"Tuvalu",countryCode:"TV",callingCode:"+688"},{country:"U.S. Virgin Islands",countryCode:"VI",callingCode:"+1340"},{country:"Uganda",countryCode:"UG",callingCode:"+256"},{country:"Ukraine",countryCode:"UA",callingCode:"+380"},{country:"United Arab Emirates",countryCode:"AE",callingCode:"+971"},{country:"United Kingdom",countryCode:"GB",callingCode:"+44"},{country:"United States",countryCode:"US",callingCode:"+1"},{country:"United States Minor Outlying Islands",countryCode:"UM",callingCode:"+1"},{country:"Uruguay",countryCode:"UY",callingCode:"+598"},{country:"Uzbekistan",countryCode:"UZ",callingCode:"+998"},{country:"Vanuatu",countryCode:"VU",callingCode:"+678"},{country:"Vatican",countryCode:"VA",callingCode:"+379"},{country:"Venezuela",countryCode:"VE",callingCode:"+58"},{country:"Vietnam",countryCode:"VN",callingCode:"+84"},{country:"Wallis and Futuna",countryCode:"WF",callingCode:"+681"},{country:"Western Sahara",countryCode:"EH",callingCode:"+212"},{country:"Yemen",countryCode:"YE",callingCode:"+967"},{country:"Zambia",countryCode:"ZM",callingCode:"+260"},{country:"Zimbabwe",countryCode:"ZW",callingCode:"+263"}],i=o=>u.find((e=>e.countryCode===o));const d=({placeholder:e,country:r,onChange:t,value:c,iconComponent:a,inputProps:l,onlyCountries:d,excludeCountries:y,preferredCountries:s,showDropdownIcon:C=!0,dialCodeInputField:g=!1,search:p=!0,searchPlaceholder:f="Search country",showSearchIcon:m=!0,searchIconComponent:h,searchProps:v,searchNotFound:b="Not found"})=>{const[S,w]=o.useState({}),[x,N]=o.useState(!1),[T,E]=o.useState(c||""),[R,j]=o.useState(u),[k,M]=o.useState(0),P=o.useRef(null),_=o.useRef(null);var I,O;I=P,O=()=>N(!1),o.useEffect((()=>{const o=o=>{I.current&&!I.current.contains(o.target)&&O(o)};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o)}}),[I,O]);const A=o=>{x&&("ArrowDown"===o.key&&(o.preventDefault(),M((o=>o<R.length-1?o+1:o))),"ArrowUp"===o.key&&(o.preventDefault(),M((o=>o>0?o-1:0))),"Escape"===o.key&&N(!1),"Enter"===o.key&&k>=0&&(w(R[k]),N(!1)))};return o.useEffect((()=>{if(k<0||k>R.length||!_)return()=>{};if(x&&_&&R.length>0){let e=Array.from(_.current?.children);e[k]&&(o=e[k].offsetTop-65,p&&R.length>0&&_.current?.scrollTo({top:o,behavior:"smooth"}))}var o}),[k]),o.useMemo((()=>{if(g){const o=T?.replace(S.callingCode,i(r).callingCode);console.log(o),E(o.length>0?o:i(r).callingCode)}w(i(r))}),[r,g]),o.useMemo((()=>{j(((o,e,n)=>{let r=[];return r=e&&e.length>0?u.filter((o=>!e?.includes(o.countryCode))):o&&o?.length>0?u.filter((e=>o?.includes(e.countryCode))):u,r.sort(((o,e)=>Number(n?.includes(e.countryCode))-Number(n?.includes(o.countryCode))||n?.indexOf(o.countryCode)-n?.indexOf(e.countryCode)))})(d,y,s))}),[d,y,s]),n.exports.jsx("div",{className:"simple-phone-input-sri198-container",onKeyDown:o=>A(o),tabIndex:-1,children:n.exports.jsxs("div",{className:"simple-phone-input-sri198-main",children:[n.exports.jsxs("div",{className:"simple-phone-input-sri198-dropdown-container",ref:P,children:[n.exports.jsxs("div",{onClick:()=>N(!x),className:g?"simple-phone-input-sri198-dropdown-container-button dial":"simple-phone-input-sri198-dropdown-container-button",children:[n.exports.jsx("img",{src:"https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/"+S.countryCode+".svg",alt:S.country,width:"20px"}),!g&&n.exports.jsx("span",{className:"simple-phone-input-sri198-selected-code",children:S.callingCode}),C&&n.exports.jsx("div",{className:x?"simple-phone-input-sri198-dropdown-icon":"simple-phone-input-sri198-dropdown-icon active",children:a||n.exports.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",children:n.exports.jsx("path",{fill:"currentColor",d:"m7 10l5 5l5-5z"})})})]}),n.exports.jsxs("ul",{className:x?"simple-phone-input-sri198-dropdown active":"simple-phone-input-sri198-dropdown",ref:_,children:[p&&n.exports.jsxs("div",{className:"simple-phone-input-sri198-search-container",children:[n.exports.jsx("input",{placeholder:f,...v,onChange:o=>{const e=o.target.value;j(((o,e,n)=>{let r=[];return r=n&&n.length>0?u.filter((o=>!n?.includes(o.countryCode))):e&&e?.length>0?u.filter((o=>e?.includes(o.countryCode))):u,r.filter((e=>{const n=new RegExp(o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),"gi");return e.country.match(n)}))})(e,d,y))}}),m&&n.exports.jsx("div",{className:"simple-phone-input-sri198-search-icon",children:h??n.exports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 48 48",children:[n.exports.jsxs("g",{fill:"#616161",children:[n.exports.jsx("path",{d:"m29.175 31.99l2.828-2.827l12.019 12.019l-2.828 2.827z"}),n.exports.jsx("circle",{cx:"20",cy:"20",r:"16"})]}),n.exports.jsx("path",{fill:"#37474F",d:"m32.45 35.34l2.827-2.828l8.696 8.696l-2.828 2.828z"}),n.exports.jsx("circle",{cx:"20",cy:"20",r:"13",fill:"#64B5F6"}),n.exports.jsx("path",{fill:"#BBDEFB",d:"M26.9 14.2c-1.7-2-4.2-3.2-6.9-3.2s-5.2 1.2-6.9 3.2c-.4.4-.3 1.1.1 1.4c.4.4 1.1.3 1.4-.1C16 13.9 17.9 13 20 13s4 .9 5.4 2.5c.2.2.5.4.8.4c.2 0 .5-.1.6-.2c.4-.4.4-1.1.1-1.5z"})]})})]}),0===R.length&&n.exports.jsx("div",{className:"simple-phone-input-sri198-not-found",children:b}),R.map(((o,e)=>n.exports.jsxs("li",{onClick:()=>((o,e)=>{if(g){const e=T?.replace(S.callingCode,o.callingCode);E(e.length>0?e:o.callingCode),t(e.length>0?e:o.callingCode)}else t(o.callingCode+T);w(o),N(!1),M(e)})(o,e),className:e===k?"active":"",children:[n.exports.jsx("img",{src:"https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/"+o.countryCode+".svg",alt:o.country,width:"20px"}),n.exports.jsx("span",{className:"simple-phone-input-sri198-dropdown-text",children:o.country}),n.exports.jsx("span",{className:"simple-phone-input-sri198-dropdown-country-code",children:o.callingCode})]},e)))]})]}),n.exports.jsx("input",{className:"simple-phone-input-sri198-input",placeholder:e,onChange:o=>{const e=o.target.value.replace(/\D/g,"");g?(t("+"+e),E("+"+e)):(E(e),t(S.callingCode+e))},type:"tel",onInput:o=>{if(g){const e=T.slice(S.callingCode.length);o.target.value.startsWith(S.callingCode)?o.target.value=o.target.value:o.target.value=S.callingCode+e}},onKeyDown:o=>A(o),value:T,...l})]})})};export{d as PhoneInput};
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import React from 'react';
3
+
4
+ const countryData = [
5
+ {
6
+ country: "Afghanistan",
7
+ countryCode: "AF",
8
+ callingCode: "+93"
9
+ },
10
+ {
11
+ country: "Albania",
12
+ countryCode: "AL",
13
+ callingCode: "+355"
14
+ },
15
+ {
16
+ country: "Algeria",
17
+ countryCode: "DZ",
18
+ callingCode: "+213"
19
+ },
20
+ {
21
+ country: "American Samoa",
22
+ countryCode: "AS",
23
+ callingCode: "+1684"
24
+ },
25
+ {
26
+ country: "Andorra",
27
+ countryCode: "AD",
28
+ callingCode: "+376"
29
+ },
30
+ {
31
+ country: "Angola",
32
+ countryCode: "AO",
33
+ callingCode: "+244"
34
+ },
35
+ {
36
+ country: "Anguilla",
37
+ countryCode: "AI",
38
+ callingCode: "+1264"
39
+ },
40
+ {
41
+ country: "Antarctica",
42
+ countryCode: "AQ",
43
+ callingCode: "+672"
44
+ },
45
+ {
46
+ country: "Antigua and Barbuda",
47
+ countryCode: "AG",
48
+ callingCode: "+1268"
49
+ },
50
+ {
51
+ country: "Argentina",
52
+ countryCode: "AR",
53
+ callingCode: "+54"
54
+ },
55
+ {
56
+ country: "Armenia",
57
+ countryCode: "AM",
58
+ callingCode: "+374"
59
+ },
60
+ {
61
+ country: "Aruba",
62
+ countryCode: "AW",
63
+ callingCode: "+297"
64
+ },
65
+ {
66
+ country: "Australia",
67
+ countryCode: "AU",
68
+ callingCode: "+61"
69
+ },
70
+ {
71
+ country: "Austria",
72
+ countryCode: "AT",
73
+ callingCode: "+43"
74
+ },
75
+ {
76
+ country: "Azerbaijan",
77
+ countryCode: "AZ",
78
+ callingCode: "+994"
79
+ },
80
+ {
81
+ country: "Bahamas",
82
+ countryCode: "BS",
83
+ callingCode: "+1242"
84
+ },
85
+ {
86
+ country: "Bahrain",
87
+ countryCode: "BH",
88
+ callingCode: "+973"
89
+ },
90
+ {
91
+ country: "Bangladesh",
92
+ countryCode: "BD",
93
+ callingCode: "+880"
94
+ },
95
+ {
96
+ country: "Barbados",
97
+ countryCode: "BB",
98
+ callingCode: "+1246"
99
+ },
100
+ {
101
+ country: "Belarus",
102
+ countryCode: "BY",
103
+ callingCode: "+375"
104
+ },
105
+ {
106
+ country: "Belgium",
107
+ countryCode: "BE",
108
+ callingCode: "+32"
109
+ },
110
+ {
111
+ country: "Belize",
112
+ countryCode: "BZ",
113
+ callingCode: "+501"
114
+ },
115
+ {
116
+ country: "Benin",
117
+ countryCode: "BJ",
118
+ callingCode: "+229"
119
+ },
120
+ {
121
+ country: "Bermuda",
122
+ countryCode: "BM",
123
+ callingCode: "+1441"
124
+ },
125
+ {
126
+ country: "Bhutan",
127
+ countryCode: "BT",
128
+ callingCode: "+975"
129
+ },
130
+ {
131
+ country: "Bolivia",
132
+ countryCode: "BO",
133
+ callingCode: "+591"
134
+ },
135
+ {
136
+ country: "Bosnia and Herzegovina",
137
+ countryCode: "BA",
138
+ callingCode: "+387"
139
+ },
140
+ {
141
+ country: "Botswana",
142
+ countryCode: "BW",
143
+ callingCode: "+267"
144
+ },
145
+ {
146
+ country: "Bouvet Island",
147
+ countryCode: "BV",
148
+ callingCode: "+47"
149
+ },
150
+ {
151
+ country: "Brazil",
152
+ countryCode: "BR",
153
+ callingCode: "+55"
154
+ },
155
+ {
156
+ country: "British Indian Ocean Territory",
157
+ countryCode: "IO",
158
+ callingCode: "+246"
159
+ },
160
+ {
161
+ country: "British Virgin Islands",
162
+ countryCode: "VG",
163
+ callingCode: "+1284"
164
+ },
165
+ {
166
+ country: "Brunei",
167
+ countryCode: "BN",
168
+ callingCode: "+673"
169
+ },
170
+ {
171
+ country: "Bulgaria",
172
+ countryCode: "BG",
173
+ callingCode: "+359"
174
+ },
175
+ {
176
+ country: "Burkina Faso",
177
+ countryCode: "BF",
178
+ callingCode: "+226"
179
+ },
180
+ {
181
+ country: "Burundi",
182
+ countryCode: "BI",
183
+ callingCode: "+257"
184
+ },
185
+ {
186
+ country: "Cambodia",
187
+ countryCode: "KH",
188
+ callingCode: "+855"
189
+ },
190
+ {
191
+ country: "Cameroon",
192
+ countryCode: "CM",
193
+ callingCode: "+237"
194
+ },
195
+ {
196
+ country: "Canada",
197
+ countryCode: "CA",
198
+ callingCode: "+1"
199
+ },
200
+ {
201
+ country: "Cape Verde",
202
+ countryCode: "CV",
203
+ callingCode: "+238"
204
+ },
205
+ {
206
+ country: "Cayman Islands",
207
+ countryCode: "KY",
208
+ callingCode: "+1345"
209
+ },
210
+ {
211
+ country: "Central African Republic",
212
+ countryCode: "CF",
213
+ callingCode: "+236"
214
+ },
215
+ {
216
+ country: "Chad",
217
+ countryCode: "TD",
218
+ callingCode: "+235"
219
+ },
220
+ {
221
+ country: "Chile",
222
+ countryCode: "CL",
223
+ callingCode: "+56"
224
+ },
225
+ {
226
+ country: "China",
227
+ countryCode: "CN",
228
+ callingCode: "+86"
229
+ },
230
+ {
231
+ country: "Christmas Island",
232
+ countryCode: "CX",
233
+ callingCode: "+61"
234
+ },
235
+ {
236
+ country: "Cocos Islands",
237
+ countryCode: "CC",
238
+ callingCode: "+61"
239
+ },
240
+ {
241
+ country: "Colombia",
242
+ countryCode: "CO",
243
+ callingCode: "+57"
244
+ },
245
+ {
246
+ country: "Comoros",
247
+ countryCode: "KM",
248
+ callingCode: "+269"
249
+ },
250
+ {
251
+ country: "Cook Islands",
252
+ countryCode: "CK",
253
+ callingCode: "+682"
254
+ },
255
+ {
256
+ country: "Costa Rica",
257
+ countryCode: "CR",
258
+ callingCode: "+506"
259
+ },
260
+ {
261
+ country: "Croatia",
262
+ countryCode: "HR",
263
+ callingCode: "+385"
264
+ },
265
+ {
266
+ country: "Cuba",
267
+ countryCode: "CU",
268
+ callingCode: "+53"
269
+ },
270
+ {
271
+ country: "Cyprus",
272
+ countryCode: "CY",
273
+ callingCode: "+357"
274
+ },
275
+ {
276
+ country: "Czech Republic",
277
+ countryCode: "CZ",
278
+ callingCode: "+420"
279
+ },
280
+ {
281
+ country: "Democratic Republic of the Congo",
282
+ countryCode: "CD",
283
+ callingCode: "+243"
284
+ },
285
+ {
286
+ country: "Denmark",
287
+ countryCode: "DK",
288
+ callingCode: "+45"
289
+ },
290
+ {
291
+ country: "Djibouti",
292
+ countryCode: "DJ",
293
+ callingCode: "+253"
294
+ },
295
+ {
296
+ country: "Dominica",
297
+ countryCode: "DM",
298
+ callingCode: "+1767"
299
+ },
300
+ {
301
+ country: "Dominican Republic",
302
+ countryCode: "DO",
303
+ callingCode: "+1"
304
+ },
305
+ {
306
+ country: "East Timor",
307
+ countryCode: "TL",
308
+ callingCode: "+670"
309
+ },
310
+ {
311
+ country: "Ecuador",
312
+ countryCode: "EC",
313
+ callingCode: "+593"
314
+ },
315
+ {
316
+ country: "Egypt",
317
+ countryCode: "EG",
318
+ callingCode: "+20"
319
+ },
320
+ {
321
+ country: "El Salvador",
322
+ countryCode: "SV",
323
+ callingCode: "+503"
324
+ },
325
+ {
326
+ country: "Equatorial Guinea",
327
+ countryCode: "GQ",
328
+ callingCode: "+240"
329
+ },
330
+ {
331
+ country: "Eritrea",
332
+ countryCode: "ER",
333
+ callingCode: "+291"
334
+ },
335
+ {
336
+ country: "Estonia",
337
+ countryCode: "EE",
338
+ callingCode: "+372"
339
+ },
340
+ {
341
+ country: "Ethiopia",
342
+ countryCode: "ET",
343
+ callingCode: "+251"
344
+ },
345
+ {
346
+ country: "Falkland Islands",
347
+ countryCode: "FK",
348
+ callingCode: "+500"
349
+ },
350
+ {
351
+ country: "Faroe Islands",
352
+ countryCode: "FO",
353
+ callingCode: "+298"
354
+ },
355
+ {
356
+ country: "Fiji",
357
+ countryCode: "FJ",
358
+ callingCode: "+679"
359
+ },
360
+ {
361
+ country: "Finland",
362
+ countryCode: "FI",
363
+ callingCode: "+358"
364
+ },
365
+ {
366
+ country: "France",
367
+ countryCode: "FR",
368
+ callingCode: "+33"
369
+ },
370
+ {
371
+ country: "French Guiana",
372
+ countryCode: "GF",
373
+ callingCode: "+594"
374
+ },
375
+ {
376
+ country: "French Polynesia",
377
+ countryCode: "PF",
378
+ callingCode: "+689"
379
+ },
380
+ {
381
+ country: "French Southern Territories",
382
+ countryCode: "TF",
383
+ callingCode: "+262"
384
+ },
385
+ {
386
+ country: "Gabon",
387
+ countryCode: "GA",
388
+ callingCode: "+241"
389
+ },
390
+ {
391
+ country: "Gambia",
392
+ countryCode: "GM",
393
+ callingCode: "+220"
394
+ },
395
+ {
396
+ country: "Georgia",
397
+ countryCode: "GE",
398
+ callingCode: "+995"
399
+ },
400
+ {
401
+ country: "Germany",
402
+ countryCode: "DE",
403
+ callingCode: "+49"
404
+ },
405
+ {
406
+ country: "Ghana",
407
+ countryCode: "GH",
408
+ callingCode: "+233"
409
+ },
410
+ {
411
+ country: "Gibraltar",
412
+ countryCode: "GI",
413
+ callingCode: "+350"
414
+ },
415
+ {
416
+ country: "Greece",
417
+ countryCode: "GR",
418
+ callingCode: "+30"
419
+ },
420
+ {
421
+ country: "Greenland",
422
+ countryCode: "GL",
423
+ callingCode: "+299"
424
+ },
425
+ {
426
+ country: "Grenada",
427
+ countryCode: "GD",
428
+ callingCode: "+473"
429
+ },
430
+ {
431
+ country: "Guadeloupe",
432
+ countryCode: "GP",
433
+ callingCode: "+590"
434
+ },
435
+ {
436
+ country: "Guam",
437
+ countryCode: "GU",
438
+ callingCode: "+1671"
439
+ },
440
+ {
441
+ country: "Guatemala",
442
+ countryCode: "GT",
443
+ callingCode: "+502"
444
+ },
445
+ {
446
+ country: "Guinea",
447
+ countryCode: "GN",
448
+ callingCode: "+224"
449
+ },
450
+ {
451
+ country: "Guinea-Bissau",
452
+ countryCode: "GW",
453
+ callingCode: "+245"
454
+ },
455
+ {
456
+ country: "Guyana",
457
+ countryCode: "GY",
458
+ callingCode: "+592"
459
+ },
460
+ {
461
+ country: "Haiti",
462
+ countryCode: "HT",
463
+ callingCode: "+509"
464
+ },
465
+ {
466
+ country: "Honduras",
467
+ countryCode: "HN",
468
+ callingCode: "+504"
469
+ },
470
+ {
471
+ country: "Hong Kong",
472
+ countryCode: "HK",
473
+ callingCode: "+852"
474
+ },
475
+ {
476
+ country: "Hungary",
477
+ countryCode: "HU",
478
+ callingCode: "+36"
479
+ },
480
+ {
481
+ country: "Iceland",
482
+ countryCode: "IS",
483
+ callingCode: "+354"
484
+ },
485
+ {
486
+ country: "India",
487
+ countryCode: "IN",
488
+ callingCode: "+91"
489
+ },
490
+ {
491
+ country: "Indonesia",
492
+ countryCode: "ID",
493
+ callingCode: "+62"
494
+ },
495
+ {
496
+ country: "Iran",
497
+ countryCode: "IR",
498
+ callingCode: "+98"
499
+ },
500
+ {
501
+ country: "Iraq",
502
+ countryCode: "IQ",
503
+ callingCode: "+964"
504
+ },
505
+ {
506
+ country: "Ireland",
507
+ countryCode: "IE",
508
+ callingCode: "+353"
509
+ },
510
+ {
511
+ country: "Israel",
512
+ countryCode: "IL",
513
+ callingCode: "+972"
514
+ },
515
+ {
516
+ country: "Italy",
517
+ countryCode: "IT",
518
+ callingCode: "+39"
519
+ },
520
+ {
521
+ country: "Ivory Coast",
522
+ countryCode: "CI",
523
+ callingCode: "+225"
524
+ },
525
+ {
526
+ country: "Jamaica",
527
+ countryCode: "JM",
528
+ callingCode: "+1876"
529
+ },
530
+ {
531
+ country: "Japan",
532
+ countryCode: "JP",
533
+ callingCode: "+81"
534
+ },
535
+ {
536
+ country: "Jordan",
537
+ countryCode: "JO",
538
+ callingCode: "+962"
539
+ },
540
+ {
541
+ country: "Kazakhstan",
542
+ countryCode: "KZ",
543
+ callingCode: "+7"
544
+ },
545
+ {
546
+ country: "Kenya",
547
+ countryCode: "KE",
548
+ callingCode: "+254"
549
+ },
550
+ {
551
+ country: "Kiribati",
552
+ countryCode: "KI",
553
+ callingCode: "+686"
554
+ },
555
+ {
556
+ country: "Kuwait",
557
+ countryCode: "KW",
558
+ callingCode: "+965"
559
+ },
560
+ {
561
+ country: "Kyrgyzstan",
562
+ countryCode: "KG",
563
+ callingCode: "+996"
564
+ },
565
+ {
566
+ country: "Laos",
567
+ countryCode: "LA",
568
+ callingCode: "+856"
569
+ },
570
+ {
571
+ country: "Latvia",
572
+ countryCode: "LV",
573
+ callingCode: "+371"
574
+ },
575
+ {
576
+ country: "Lebanon",
577
+ countryCode: "LB",
578
+ callingCode: "+961"
579
+ },
580
+ {
581
+ country: "Lesotho",
582
+ countryCode: "LS",
583
+ callingCode: "+266"
584
+ },
585
+ {
586
+ country: "Liberia",
587
+ countryCode: "LR",
588
+ callingCode: "+231"
589
+ },
590
+ {
591
+ country: "Libya",
592
+ countryCode: "LY",
593
+ callingCode: "+218"
594
+ },
595
+ {
596
+ country: "Liechtenstein",
597
+ countryCode: "LI",
598
+ callingCode: "+423"
599
+ },
600
+ {
601
+ country: "Lithuania",
602
+ countryCode: "LT",
603
+ callingCode: "+370"
604
+ },
605
+ {
606
+ country: "Luxembourg",
607
+ countryCode: "LU",
608
+ callingCode: "+352"
609
+ },
610
+ {
611
+ country: "Macao",
612
+ countryCode: "MO",
613
+ callingCode: "+853"
614
+ },
615
+ {
616
+ country: "Macedonia",
617
+ countryCode: "MK",
618
+ callingCode: "+389"
619
+ },
620
+ {
621
+ country: "Madagascar",
622
+ countryCode: "MG",
623
+ callingCode: "+261"
624
+ },
625
+ {
626
+ country: "Malawi",
627
+ countryCode: "MW",
628
+ callingCode: "+265"
629
+ },
630
+ {
631
+ country: "Malaysia",
632
+ countryCode: "MY",
633
+ callingCode: "+60"
634
+ },
635
+ {
636
+ country: "Maldives",
637
+ countryCode: "MV",
638
+ callingCode: "+960"
639
+ },
640
+ {
641
+ country: "Mali",
642
+ countryCode: "ML",
643
+ callingCode: "+223"
644
+ },
645
+ {
646
+ country: "Malta",
647
+ countryCode: "MT",
648
+ callingCode: "+356"
649
+ },
650
+ {
651
+ country: "Marshall Islands",
652
+ countryCode: "MH",
653
+ callingCode: "+692"
654
+ },
655
+ {
656
+ country: "Martinique",
657
+ countryCode: "MQ",
658
+ callingCode: "+596"
659
+ },
660
+ {
661
+ country: "Mauritania",
662
+ countryCode: "MR",
663
+ callingCode: "+222"
664
+ },
665
+ {
666
+ country: "Mauritius",
667
+ countryCode: "MU",
668
+ callingCode: "+230"
669
+ },
670
+ {
671
+ country: "Mayotte",
672
+ countryCode: "YT",
673
+ callingCode: "+262"
674
+ },
675
+ {
676
+ country: "Mexico",
677
+ countryCode: "MX",
678
+ callingCode: "+52"
679
+ },
680
+ {
681
+ country: "Micronesia",
682
+ countryCode: "FM",
683
+ callingCode: "+691"
684
+ },
685
+ {
686
+ country: "Moldova",
687
+ countryCode: "MD",
688
+ callingCode: "+373"
689
+ },
690
+ {
691
+ country: "Monaco",
692
+ countryCode: "MC",
693
+ callingCode: "+377"
694
+ },
695
+ {
696
+ country: "Mongolia",
697
+ countryCode: "MN",
698
+ callingCode: "+976"
699
+ },
700
+ {
701
+ country: "Montserrat",
702
+ countryCode: "MS",
703
+ callingCode: "+1664"
704
+ },
705
+ {
706
+ country: "Morocco",
707
+ countryCode: "MA",
708
+ callingCode: "+212"
709
+ },
710
+ {
711
+ country: "Mozambique",
712
+ countryCode: "MZ",
713
+ callingCode: "+258"
714
+ },
715
+ {
716
+ country: "Myanmar",
717
+ countryCode: "MM",
718
+ callingCode: "+95"
719
+ },
720
+ {
721
+ country: "Namibia",
722
+ countryCode: "NA",
723
+ callingCode: "+264"
724
+ },
725
+ {
726
+ country: "Nauru",
727
+ countryCode: "NR",
728
+ callingCode: "+674"
729
+ },
730
+ {
731
+ country: "Nepal",
732
+ countryCode: "NP",
733
+ callingCode: "+977"
734
+ },
735
+ {
736
+ country: "Netherlands",
737
+ countryCode: "NL",
738
+ callingCode: "+31"
739
+ },
740
+ {
741
+ country: "New Caledonia",
742
+ countryCode: "NC",
743
+ callingCode: "+687"
744
+ },
745
+ {
746
+ country: "New Zealand",
747
+ countryCode: "NZ",
748
+ callingCode: "+64"
749
+ },
750
+ {
751
+ country: "Nicaragua",
752
+ countryCode: "NI",
753
+ callingCode: "+505"
754
+ },
755
+ {
756
+ country: "Niger",
757
+ countryCode: "NE",
758
+ callingCode: "+227"
759
+ },
760
+ {
761
+ country: "Nigeria",
762
+ countryCode: "NG",
763
+ callingCode: "+234"
764
+ },
765
+ {
766
+ country: "Niue",
767
+ countryCode: "NU",
768
+ callingCode: "+683"
769
+ },
770
+ {
771
+ country: "Norfolk Island",
772
+ countryCode: "NF",
773
+ callingCode: "+672"
774
+ },
775
+ {
776
+ country: "North Korea",
777
+ countryCode: "KP",
778
+ callingCode: "+850"
779
+ },
780
+ {
781
+ country: "Northern Mariana Islands",
782
+ countryCode: "MP",
783
+ callingCode: "+1670"
784
+ },
785
+ {
786
+ country: "Norway",
787
+ countryCode: "NO",
788
+ callingCode: "+47"
789
+ },
790
+ {
791
+ country: "Oman",
792
+ countryCode: "OM",
793
+ callingCode: "+968"
794
+ },
795
+ {
796
+ country: "Pakistan",
797
+ countryCode: "PK",
798
+ callingCode: "+92"
799
+ },
800
+ {
801
+ country: "Palau",
802
+ countryCode: "PW",
803
+ callingCode: "+680"
804
+ },
805
+ {
806
+ country: "Palestinian Territory",
807
+ countryCode: "PS",
808
+ callingCode: "+970"
809
+ },
810
+ {
811
+ country: "Panama",
812
+ countryCode: "PA",
813
+ callingCode: "+507"
814
+ },
815
+ {
816
+ country: "Papua New Guinea",
817
+ countryCode: "PG",
818
+ callingCode: "+675"
819
+ },
820
+ {
821
+ country: "Paraguay",
822
+ countryCode: "PY",
823
+ callingCode: "+595"
824
+ },
825
+ {
826
+ country: "Peru",
827
+ countryCode: "PE",
828
+ callingCode: "+51"
829
+ },
830
+ {
831
+ country: "Philippines",
832
+ countryCode: "PH",
833
+ callingCode: "+63"
834
+ },
835
+ {
836
+ country: "Pitcairn",
837
+ countryCode: "PN",
838
+ callingCode: "+872"
839
+ },
840
+ {
841
+ country: "Poland",
842
+ countryCode: "PL",
843
+ callingCode: "+48"
844
+ },
845
+ {
846
+ country: "Portugal",
847
+ countryCode: "PT",
848
+ callingCode: "+351"
849
+ },
850
+ {
851
+ country: "Puerto Rico",
852
+ countryCode: "PR",
853
+ callingCode: "+1"
854
+ },
855
+ {
856
+ country: "Qatar",
857
+ countryCode: "QA",
858
+ callingCode: "+974"
859
+ },
860
+ {
861
+ country: "Republic of the Congo",
862
+ countryCode: "CG",
863
+ callingCode: "+242"
864
+ },
865
+ {
866
+ country: "Reunion",
867
+ countryCode: "RE",
868
+ callingCode: "+262"
869
+ },
870
+ {
871
+ country: "Romania",
872
+ countryCode: "RO",
873
+ callingCode: "+40"
874
+ },
875
+ {
876
+ country: "Russia",
877
+ countryCode: "RU",
878
+ callingCode: "+7"
879
+ },
880
+ {
881
+ country: "Rwanda",
882
+ countryCode: "RW",
883
+ callingCode: "+250"
884
+ },
885
+ {
886
+ country: "Saint Helena",
887
+ countryCode: "SH",
888
+ callingCode: "+290"
889
+ },
890
+ {
891
+ country: "Saint Kitts and Nevis",
892
+ countryCode: "KN",
893
+ callingCode: "+1869"
894
+ },
895
+ {
896
+ country: "Saint Lucia",
897
+ countryCode: "LC",
898
+ callingCode: "+1758"
899
+ },
900
+ {
901
+ country: "Saint Pierre and Miquelon",
902
+ countryCode: "PM",
903
+ callingCode: "+508"
904
+ },
905
+ {
906
+ country: "Saint Vincent and the Grenadines",
907
+ countryCode: "VC",
908
+ callingCode: "+1784"
909
+ },
910
+ {
911
+ country: "Samoa",
912
+ countryCode: "WS",
913
+ callingCode: "+685"
914
+ },
915
+ {
916
+ country: "San Marino",
917
+ countryCode: "SM",
918
+ callingCode: "+378"
919
+ },
920
+ {
921
+ country: "Sao Tome and Principe",
922
+ countryCode: "ST",
923
+ callingCode: "+239"
924
+ },
925
+ {
926
+ country: "Saudi Arabia",
927
+ countryCode: "SA",
928
+ callingCode: "+966"
929
+ },
930
+ {
931
+ country: "Senegal",
932
+ countryCode: "SN",
933
+ callingCode: "+221"
934
+ },
935
+ {
936
+ country: "Seychelles",
937
+ countryCode: "SC",
938
+ callingCode: "+248"
939
+ },
940
+ {
941
+ country: "Sierra Leone",
942
+ countryCode: "SL",
943
+ callingCode: "+232"
944
+ },
945
+ {
946
+ country: "Singapore",
947
+ countryCode: "SG",
948
+ callingCode: "+65"
949
+ },
950
+ {
951
+ country: "Slovakia",
952
+ countryCode: "SK",
953
+ callingCode: "+421"
954
+ },
955
+ {
956
+ country: "Slovenia",
957
+ countryCode: "SI",
958
+ callingCode: "+386"
959
+ },
960
+ {
961
+ country: "Solomon Islands",
962
+ countryCode: "SB",
963
+ callingCode: "+677"
964
+ },
965
+ {
966
+ country: "Somalia",
967
+ countryCode: "SO",
968
+ callingCode: "+252"
969
+ },
970
+ {
971
+ country: "South Africa",
972
+ countryCode: "ZA",
973
+ callingCode: "+27"
974
+ },
975
+ {
976
+ country: "South Georgia and the South Sandwich Islands",
977
+ countryCode: "GS",
978
+ callingCode: "+500"
979
+ },
980
+ {
981
+ country: "South Korea",
982
+ countryCode: "KR",
983
+ callingCode: "+82"
984
+ },
985
+ {
986
+ country: "Spain",
987
+ countryCode: "ES",
988
+ callingCode: "+34"
989
+ },
990
+ {
991
+ country: "Sri Lanka",
992
+ countryCode: "LK",
993
+ callingCode: "+94"
994
+ },
995
+ {
996
+ country: "Sudan",
997
+ countryCode: "SD",
998
+ callingCode: "+249"
999
+ },
1000
+ {
1001
+ country: "Suriname",
1002
+ countryCode: "SR",
1003
+ callingCode: "+597"
1004
+ },
1005
+ {
1006
+ country: "Svalbard and Jan Mayen",
1007
+ countryCode: "SJ",
1008
+ callingCode: "+47"
1009
+ },
1010
+ {
1011
+ country: "Swaziland",
1012
+ countryCode: "SZ",
1013
+ callingCode: "+268"
1014
+ },
1015
+ {
1016
+ country: "Sweden",
1017
+ countryCode: "SE",
1018
+ callingCode: "+46"
1019
+ },
1020
+ {
1021
+ country: "Switzerland",
1022
+ countryCode: "CH",
1023
+ callingCode: "+41"
1024
+ },
1025
+ {
1026
+ country: "Syria",
1027
+ countryCode: "SY",
1028
+ callingCode: "+963"
1029
+ },
1030
+ {
1031
+ country: "Taiwan",
1032
+ countryCode: "TW",
1033
+ callingCode: "+886"
1034
+ },
1035
+ {
1036
+ country: "Tajikistan",
1037
+ countryCode: "TJ",
1038
+ callingCode: "+992"
1039
+ },
1040
+ {
1041
+ country: "Tanzania",
1042
+ countryCode: "TZ",
1043
+ callingCode: "+255"
1044
+ },
1045
+ {
1046
+ country: "Thailand",
1047
+ countryCode: "TH",
1048
+ callingCode: "+66"
1049
+ },
1050
+ {
1051
+ country: "Togo",
1052
+ countryCode: "TG",
1053
+ callingCode: "+228"
1054
+ },
1055
+ {
1056
+ country: "Tokelau",
1057
+ countryCode: "TK",
1058
+ callingCode: "+690"
1059
+ },
1060
+ {
1061
+ country: "Tonga",
1062
+ countryCode: "TO",
1063
+ callingCode: "+676"
1064
+ },
1065
+ {
1066
+ country: "Trinidad and Tobago",
1067
+ countryCode: "TT",
1068
+ callingCode: "+1868"
1069
+ },
1070
+ {
1071
+ country: "Tunisia",
1072
+ countryCode: "TN",
1073
+ callingCode: "+216"
1074
+ },
1075
+ {
1076
+ country: "Turkey",
1077
+ countryCode: "TR",
1078
+ callingCode: "+90"
1079
+ },
1080
+ {
1081
+ country: "Turkmenistan",
1082
+ countryCode: "TM",
1083
+ callingCode: "+993"
1084
+ },
1085
+ {
1086
+ country: "Turks and Caicos Islands",
1087
+ countryCode: "TC",
1088
+ callingCode: "+1649"
1089
+ },
1090
+ {
1091
+ country: "Tuvalu",
1092
+ countryCode: "TV",
1093
+ callingCode: "+688"
1094
+ },
1095
+ {
1096
+ country: "U.S. Virgin Islands",
1097
+ countryCode: "VI",
1098
+ callingCode: "+1340"
1099
+ },
1100
+ {
1101
+ country: "Uganda",
1102
+ countryCode: "UG",
1103
+ callingCode: "+256"
1104
+ },
1105
+ {
1106
+ country: "Ukraine",
1107
+ countryCode: "UA",
1108
+ callingCode: "+380"
1109
+ },
1110
+ {
1111
+ country: "United Arab Emirates",
1112
+ countryCode: "AE",
1113
+ callingCode: "+971"
1114
+ },
1115
+ {
1116
+ country: "United Kingdom",
1117
+ countryCode: "GB",
1118
+ callingCode: "+44"
1119
+ },
1120
+ {
1121
+ country: "United States",
1122
+ countryCode: "US",
1123
+ callingCode: "+1"
1124
+ },
1125
+ {
1126
+ country: "United States Minor Outlying Islands",
1127
+ countryCode: "UM",
1128
+ callingCode: "+1"
1129
+ },
1130
+ {
1131
+ country: "Uruguay",
1132
+ countryCode: "UY",
1133
+ callingCode: "+598"
1134
+ },
1135
+ {
1136
+ country: "Uzbekistan",
1137
+ countryCode: "UZ",
1138
+ callingCode: "+998"
1139
+ },
1140
+ {
1141
+ country: "Vanuatu",
1142
+ countryCode: "VU",
1143
+ callingCode: "+678"
1144
+ },
1145
+ {
1146
+ country: "Vatican",
1147
+ countryCode: "VA",
1148
+ callingCode: "+379"
1149
+ },
1150
+ {
1151
+ country: "Venezuela",
1152
+ countryCode: "VE",
1153
+ callingCode: "+58"
1154
+ },
1155
+ {
1156
+ country: "Vietnam",
1157
+ countryCode: "VN",
1158
+ callingCode: "+84"
1159
+ },
1160
+ {
1161
+ country: "Wallis and Futuna",
1162
+ countryCode: "WF",
1163
+ callingCode: "+681"
1164
+ },
1165
+ {
1166
+ country: "Western Sahara",
1167
+ countryCode: "EH",
1168
+ callingCode: "+212"
1169
+ },
1170
+ {
1171
+ country: "Yemen",
1172
+ countryCode: "YE",
1173
+ callingCode: "+967"
1174
+ },
1175
+ {
1176
+ country: "Zambia",
1177
+ countryCode: "ZM",
1178
+ callingCode: "+260"
1179
+ },
1180
+ {
1181
+ country: "Zimbabwe",
1182
+ countryCode: "ZW",
1183
+ callingCode: "+263"
1184
+ }
1185
+ ];
1186
+
1187
+ //Get default country function
1188
+ const getDefaultCountry = (code) => {
1189
+ const result = countryData.find((item) => item.countryCode === code);
1190
+ return result;
1191
+ };
1192
+ //Get country data by search
1193
+ const getBySearch = (search, onlyCountry, excludeCountry) => {
1194
+ let countries = [];
1195
+ if (excludeCountry && excludeCountry.length > 0) {
1196
+ countries = countryData.filter((item) => !excludeCountry?.includes(item.countryCode));
1197
+ }
1198
+ else if (onlyCountry && onlyCountry?.length > 0) {
1199
+ countries = countryData.filter((item) => onlyCountry?.includes(item.countryCode));
1200
+ }
1201
+ else {
1202
+ countries = countryData;
1203
+ }
1204
+ const result = countries.filter((item) => {
1205
+ const escapeRegExp = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
1206
+ const regex = new RegExp(escapeRegExp(search), "gi");
1207
+ return item.country.match(regex);
1208
+ });
1209
+ return result;
1210
+ };
1211
+ //Get country data by filter
1212
+ const getCountryByFilter = (onlyCountry, excludeCountry, preferredCountry) => {
1213
+ let countries = [];
1214
+ if (excludeCountry && excludeCountry.length > 0) {
1215
+ countries = countryData.filter((item) => !excludeCountry?.includes(item.countryCode));
1216
+ }
1217
+ else if (onlyCountry && onlyCountry?.length > 0) {
1218
+ countries = countryData.filter((item) => onlyCountry?.includes(item.countryCode));
1219
+ }
1220
+ else {
1221
+ countries = countryData;
1222
+ }
1223
+ const result = countries.sort((a, b) => (Number(preferredCountry?.includes(b.countryCode)) - Number(preferredCountry?.includes(a.countryCode)))
1224
+ || (preferredCountry?.indexOf(a.countryCode) - preferredCountry?.indexOf(b.countryCode)));
1225
+ return result;
1226
+ };
1227
+
1228
+ //Click out side hook
1229
+ function useOnClickOutside(ref, handler) {
1230
+ React.useEffect(() => {
1231
+ const listener = (event) => {
1232
+ if (!ref.current || ref.current.contains(event.target)) {
1233
+ return;
1234
+ }
1235
+ handler(event);
1236
+ };
1237
+ document.addEventListener("mousedown", listener);
1238
+ document.addEventListener("touchstart", listener);
1239
+ return () => {
1240
+ document.removeEventListener("mousedown", listener);
1241
+ document.removeEventListener("touchstart", listener);
1242
+ };
1243
+ }, [ref, handler]);
1244
+ }
1245
+
1246
+ //Component
1247
+ 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" }) => {
1248
+ //State
1249
+ const [selected, setSelected] = React.useState({});
1250
+ const [isDropdown, setDropdown] = React.useState(false);
1251
+ const [inputValue, setInputValue] = React.useState(value || "");
1252
+ const [countryDataInfo, setCountryData] = React.useState(countryData);
1253
+ const [cursor, setCursor] = React.useState(0);
1254
+ //Ref
1255
+ const dropdownRef = React.useRef(null);
1256
+ const listRef = React.useRef(null);
1257
+ //Custom Hook Call
1258
+ useOnClickOutside(dropdownRef, () => setDropdown(false));
1259
+ //Handler
1260
+ //---Input Onchange Handler//
1261
+ const handleChange = (e) => {
1262
+ const onlyNumber = e.target.value.replace(/\D/g, '');
1263
+ if (dialCodeInputField) {
1264
+ onChange("+" + onlyNumber);
1265
+ setInputValue("+" + onlyNumber);
1266
+ }
1267
+ else {
1268
+ setInputValue(onlyNumber);
1269
+ onChange(selected.callingCode + onlyNumber);
1270
+ }
1271
+ };
1272
+ //---Search Input Onchange Handler//
1273
+ const onSearchHandler = (e) => {
1274
+ const search = e.target.value;
1275
+ setCountryData(getBySearch(search, onlyCountries, excludeCountries));
1276
+ };
1277
+ //---Set Selected Handler//
1278
+ const handleSelected = (item, i) => {
1279
+ if (dialCodeInputField) {
1280
+ const result = inputValue?.replace(selected.callingCode, item.callingCode);
1281
+ setInputValue(result.length > 0 ? result : item.callingCode);
1282
+ onChange(result.length > 0 ? result : item.callingCode);
1283
+ }
1284
+ else {
1285
+ onChange(item.callingCode + inputValue);
1286
+ }
1287
+ setSelected(item);
1288
+ setDropdown(false);
1289
+ setCursor(i);
1290
+ };
1291
+ //---Scroll To View Handler//
1292
+ const scrollIntoView = (position) => {
1293
+ if (search) {
1294
+ if (countryDataInfo.length > 0) {
1295
+ listRef.current?.scrollTo({
1296
+ top: position,
1297
+ behavior: "smooth"
1298
+ });
1299
+ }
1300
+ }
1301
+ };
1302
+ //---Keyboard Navigation//
1303
+ const keyBoardNav = (e) => {
1304
+ if (isDropdown) {
1305
+ if (e.key === "ArrowDown") {
1306
+ e.preventDefault();
1307
+ setCursor(c => (c < countryDataInfo.length - 1 ? c + 1 : c));
1308
+ }
1309
+ if (e.key === "ArrowUp") {
1310
+ e.preventDefault();
1311
+ setCursor(c => (c > 0 ? c - 1 : 0));
1312
+ }
1313
+ if (e.key === "Escape") {
1314
+ setDropdown(false);
1315
+ }
1316
+ if (e.key === "Enter" && cursor >= 0) {
1317
+ setSelected(countryDataInfo[cursor]);
1318
+ setDropdown(false);
1319
+ }
1320
+ }
1321
+ };
1322
+ //React Hook
1323
+ //---Scroll to view hook//
1324
+ React.useEffect(() => {
1325
+ if (cursor < 0 || cursor > countryDataInfo.length || !listRef) {
1326
+ return () => {
1327
+ };
1328
+ }
1329
+ if (isDropdown && listRef) {
1330
+ if (countryDataInfo.length > 0) {
1331
+ let listItems = Array.from(listRef.current?.children);
1332
+ listItems[cursor] && scrollIntoView(listItems[cursor].offsetTop - 65);
1333
+ }
1334
+ }
1335
+ }, [cursor]);
1336
+ //---Dial Code Field Effect//
1337
+ React.useMemo(() => {
1338
+ if (dialCodeInputField) {
1339
+ const result = inputValue?.replace(selected.callingCode, getDefaultCountry(country).callingCode);
1340
+ console.log(result);
1341
+ setInputValue(result.length > 0 ? result : getDefaultCountry(country).callingCode);
1342
+ }
1343
+ setSelected(getDefaultCountry(country));
1344
+ }, [country, dialCodeInputField]);
1345
+ //---Country search hook//
1346
+ React.useMemo(() => {
1347
+ setCountryData(getCountryByFilter(onlyCountries, excludeCountries, preferredCountries));
1348
+ }, [onlyCountries, excludeCountries, preferredCountries]);
1349
+ return (jsx("div", { className: "simple-phone-input-sri198-container", onKeyDown: (e) => keyBoardNav(e), tabIndex: -1, children: jsxs("div", { className: "simple-phone-input-sri198-main", children: [jsxs("div", { className: "simple-phone-input-sri198-dropdown-container", ref: dropdownRef, children: [jsxs("div", { onClick: () => setDropdown(!isDropdown), className: dialCodeInputField ? "simple-phone-input-sri198-dropdown-container-button dial" : "simple-phone-input-sri198-dropdown-container-button", children: [jsx("img", { src: "https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/" + selected.countryCode + ".svg", alt: selected.country, width: "20px" }), !dialCodeInputField &&
1350
+ jsx("span", { className: "simple-phone-input-sri198-selected-code", children: selected.callingCode }), showDropdownIcon &&
1351
+ jsx("div", { className: isDropdown ? "simple-phone-input-sri198-dropdown-icon" : "simple-phone-input-sri198-dropdown-icon active", children: iconComponent ? iconComponent : (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 24 24", children: jsx("path", { fill: "currentColor", d: "m7 10l5 5l5-5z" }) })) })] }), jsxs("ul", { className: isDropdown ? "simple-phone-input-sri198-dropdown active" : "simple-phone-input-sri198-dropdown", ref: listRef, children: [search &&
1352
+ jsxs("div", { className: "simple-phone-input-sri198-search-container", children: [jsx("input", { placeholder: searchPlaceholder, ...searchProps, onChange: onSearchHandler }), showSearchIcon &&
1353
+ jsx("div", { className: "simple-phone-input-sri198-search-icon", children: searchIconComponent ?? (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 48 48", children: [jsxs("g", { fill: "#616161", children: [jsx("path", { d: "m29.175 31.99l2.828-2.827l12.019 12.019l-2.828 2.827z" }), jsx("circle", { cx: "20", cy: "20", r: "16" })] }), jsx("path", { fill: "#37474F", d: "m32.45 35.34l2.827-2.828l8.696 8.696l-2.828 2.828z" }), jsx("circle", { cx: "20", cy: "20", r: "13", fill: "#64B5F6" }), jsx("path", { fill: "#BBDEFB", d: "M26.9 14.2c-1.7-2-4.2-3.2-6.9-3.2s-5.2 1.2-6.9 3.2c-.4.4-.3 1.1.1 1.4c.4.4 1.1.3 1.4-.1C16 13.9 17.9 13 20 13s4 .9 5.4 2.5c.2.2.5.4.8.4c.2 0 .5-.1.6-.2c.4-.4.4-1.1.1-1.5z" })] })) })] }), countryDataInfo.length === 0 &&
1354
+ jsx("div", { className: "simple-phone-input-sri198-not-found", children: searchNotFound }), countryDataInfo.map((item, i) => (jsxs("li", { onClick: () => handleSelected(item, i), className: i === cursor ? "active" : "", children: [jsx("img", { src: "https://cdn.jsdelivr.net/gh/siamahnaf198/country-flags@main/img/" + item.countryCode + ".svg", alt: item.country, width: "20px" }), jsx("span", { className: "simple-phone-input-sri198-dropdown-text", children: item.country }), jsx("span", { className: "simple-phone-input-sri198-dropdown-country-code", children: item.callingCode })] }, i)))] })] }), jsx("input", { className: "simple-phone-input-sri198-input", placeholder: placeholder, onChange: handleChange, type: "tel", onInput: (e) => {
1355
+ if (dialCodeInputField) {
1356
+ const oldVal = inputValue.slice(selected.callingCode.length);
1357
+ if (e.target.value.startsWith(selected.callingCode)) {
1358
+ e.target.value = e.target.value;
1359
+ }
1360
+ else {
1361
+ e.target.value = selected.callingCode + oldVal;
1362
+ }
1363
+ }
1364
+ }, onKeyDown: (e) => keyBoardNav(e), value: inputValue, ...inputProps })] }) }));
1365
+ };
1366
+
1367
+ export { PhoneInput };
11
1368
  //# sourceMappingURL=index.js.map