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