Viewing File: /home/ubuntu/misabloom-frontend-base/node_modules/react-country-state-city/dist/cjs/index.js
"use strict";var e=require("react"),t=function(){return t=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}function a(e,t,n,a){return new(n||(n=Promise))((function(o,r){function i(e){try{s(a.next(e))}catch(e){r(e)}}function c(e){try{s(a.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((a=a.apply(e,t||[])).next())}))}function o(e,t){var n,a,o,r,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,c[0]&&(i=0)),i;)try{if(n=1,a&&(o=2&c[0]?a.return:c[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,c[1])).done)return o;switch(a=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,a=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],a=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}var r=function(e){return a(void 0,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/regionsminified.json",e&&(t=e+"/regionsminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return[2,n.sent()]}}))}))},i=function(e,t){return a(void 0,void 0,void 0,(function(){var n,a,r;return o(this,(function(o){switch(o.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",t&&(n=t+"/countriesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return a=o.sent(),r=a,e&&(r=r.filter((function(t){return t.region===e}))),[2,r]}}))}))},c=function(e){return a(void 0,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",e&&(t=e+"/countriesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return[2,n.sent()]}}))}))},s=function(e){return a(void 0,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/languagesminified.json",e&&(t=e+"/languagesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return[2,n.sent()]}}))}))},u=function(e,t){return a(void 0,void 0,void 0,(function(){var n,a,r;return o(this,(function(o){switch(o.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/statesminified.json",t&&(n=t+"/statesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return a=o.sent(),r=a.find((function(t){return t.id===e})),[2,r&&r.states?r.states:[]]}}))}))},l=function(e,t,n){return a(void 0,void 0,void 0,(function(){var a,r,i,c,s;return o(this,(function(o){switch(o.label){case 0:return a="https://venkatmcajj.github.io/react-country-state-city/data/citiesminified.json",n&&(a=n+"/citiesminified.json"),[4,fetch(a).then((function(e){return e.json()}))];case 1:return r=o.sent(),(i=r.find((function(t){return t.id===e})))?(c=i&&i.states?i.states:[],[2,(s=c.find((function(e){return e.id===t})))&&s.cities?s.cities:[]]):[2,[]]}}))}))},f=function(){return e.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},e.createElement("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},d=function(a){var o=a.placeHolder,r=a.options,i=a.onChange,c=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.showFlag,d=void 0===l||l,m=n(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),h=e.useState(!1),p=h[0],v=h[1],g=e.useState(),C=g[0],w=g[1],E=e.useState(""),N=E[0],y=E[1],j=e.useRef(null),x=e.useRef(null);e.useEffect((function(){u&&w(u)}),[u]),e.useEffect((function(){y(""),p&&j.current&&j.current.focus()}),[p]),e.useEffect((function(){var e=function(e){x.current&&!x.current.contains(e.target)&&v(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var b=function(e){return!!C&&C.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:x,onClick:function(){v(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",t({},m,{className:c,onChange:function(e){y(e.target.value),w(void 0),s&&s(e)},value:C?"".concat(d&&"emoji"in C?C.emoji+" ":"").concat(C.name):N||"",placeholder:o,ref:j})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(f,null)))),p&&e.createElement("div",{className:"stdropdown-menu"},(N?r.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0})):r).map((function(t){return e.createElement("div",{onClick:function(){return function(e){w(e),i(e)}(t)},key:t.id,className:"".concat("stdropdown-item"," ").concat(b(t)&&"selected")},d&&e.createElement("span",{className:"stdropdown-flag"},"emoji"in t?t.emoji:""," "),t.name)}))))},m=function(){return e.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},e.createElement("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},h=function(a){var o=a.placeHolder,r=a.options,i=a.onChange,c=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.displayNative,f=n(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","displayNative"]),d=e.useState(!1),h=d[0],p=d[1],v=e.useState(),g=v[0],C=v[1],w=e.useState(""),E=w[0],N=w[1],y=e.useRef(null),j=e.useRef(null);e.useEffect((function(){u&&C(u)}),[u]),e.useEffect((function(){N(""),h&&y.current&&y.current.focus()}),[h]),e.useEffect((function(){var e=function(e){j.current&&!j.current.contains(e.target)&&p(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var x=function(e){return!!g&&g.code===e.code};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:j,onClick:function(){p(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",t({},f,{className:c,onChange:function(e){N(e.target.value),C(void 0),s&&s(e)},value:g?"".concat(l?g.native:g.name):E||"",placeholder:o,ref:y})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(m,null)))),h&&e.createElement("div",{className:"stdropdown-menu"},(E?r.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0||e.native.toLowerCase().indexOf(E.toLowerCase())>=0})):r).map((function(t){return e.createElement("div",{onClick:function(){return function(e){C(e),i(e)}(t)},key:t.code,className:"".concat("stdropdown-item"," ").concat(x(t)&&"selected")},l?t.native:t.name)}))))},p=function(){return e.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},e.createElement("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},v=function(a){var o=a.placeHolder,r=a.options,i=a.onChange,c=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.showFlag,f=void 0===l||l,d=n(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),m=e.useState(!1),h=m[0],v=m[1],g=e.useState(),C=g[0],w=g[1],E=e.useState(""),N=E[0],y=E[1],j=e.useRef(null),x=e.useRef(null);e.useEffect((function(){u&&w(u)}),[u]),e.useEffect((function(){y(""),h&&j.current&&j.current.focus()}),[h]),e.useEffect((function(){var e=function(e){x.current&&!x.current.contains(e.target)&&v(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var b=function(e){return!!C&&C.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:x,onClick:function(){v(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",t({},d,{className:c,onChange:function(e){y(e.target.value),w(void 0),s&&s(e)},value:C?"".concat(f&&"emoji"in C?C.emoji+" ":"","+").concat(C.phone_code):N||"",placeholder:o,ref:j})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(p,null)))),h&&e.createElement("div",{className:"stdropdown-menu"},(N?r.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0||e.phone_code.indexOf(N)>=0||("+"+e.phone_code).indexOf(N)>=0})):r).map((function(t){return e.createElement("div",{onClick:function(){return function(e){w(e),i(e)}(t)},key:t.id,className:"".concat("stdropdown-item"," ").concat(b(t)&&"selected")},f&&e.createElement("span",{className:"stdropdown-flag"},"emoji"in t?t.emoji:""," "),"+",t.phone_code)}))))};exports.CitySelect=function(a){var o=a.containerClassName,r=a.inputClassName,i=a.onTextChange,c=a.defaultValue,s=a.onChange,u=a.countryid,f=a.stateid,m=a.placeHolder,h=a.src,p=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder","src"]),v=e.useState([]),g=v[0],C=v[1];return e.useEffect((function(){u&&l(u,f,h).then((function(e){C(e)}))}),[u,f,h]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,t({},p,{placeHolder:m,options:g,onChange:function(e){s&&s(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))},exports.CountrySelect=function(a){var o=a.containerClassName,r=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.onChange,f=a.placeHolder,m=a.showFlag,h=a.region,p=a.src,v=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region","src"]),g=e.useState([]),C=g[0],w=g[1];return e.useEffect((function(){h?i(h,p).then((function(e){w(e)})):c(p).then((function(e){w(e)}))}),[h,p]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,t({},v,{placeHolder:f,options:C,onChange:function(e){l&&l(e)},showFlag:m,onTextChange:s,defaultValue:u,inputClassName:r}))))},exports.GetAllCities=function(e){return a(void 0,void 0,void 0,(function(){var t,n,a,r,i,c,s,u,l,f,d,m;return o(this,(function(o){switch(o.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/citiesminified.json",e&&(t=e+"/citiesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:for(n=o.sent(),a=[],r=0,i=n;r<i.length;r++)for(c=i[r],s=0,u=c.states;s<u.length;s++)for(l=u[s],f=0,d=l.cities;f<d.length;f++)m=d[f],a.push(m);return[2,a]}}))}))},exports.GetCity=l,exports.GetCountries=c,exports.GetCountriesByRegion=i,exports.GetLanguages=s,exports.GetPhonecodes=function(e){return a(void 0,void 0,void 0,(function(){var t,n;return o(this,(function(a){switch(a.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",e&&(t=e+"/countriesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return n=a.sent(),[2,n.map((function(e){return{id:e.id,name:e.name,phone_code:e.phone_code,region:e.region}}))]}}))}))},exports.GetPhonecodesByRegion=function(e,t){return a(void 0,void 0,void 0,(function(){var n,a,r;return o(this,(function(o){switch(o.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",t&&(n=t+"/countriesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return a=o.sent(),r=a,e&&(r=r.filter((function(t){return t.region===e}))),[2,r.map((function(e){return{id:e.id,name:e.name,phone_code:e.phone_code,region:e.region}}))]}}))}))},exports.GetRegions=r,exports.GetState=u,exports.LanguageSelect=function(a){var o=a.containerClassName,r=a.inputClassName,i=a.onTextChange,c=a.defaultValue,u=a.onChange,l=a.placeHolder,f=a.displayNative,d=a.src,m=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","displayNative","src"]),p=e.useState([]),v=p[0],g=p[1];return e.useEffect((function(){s(d).then((function(e){g(e)}))}),[d]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(h,t({},m,{placeHolder:l,options:v,onChange:function(e){u&&u(e)},displayNative:f,onTextChange:i,defaultValue:c,inputClassName:r}))))},exports.PhonecodeSelect=function(a){var o=a.containerClassName,r=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.onChange,f=a.placeHolder,d=a.showFlag,m=a.region,h=a.src,p=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region","src"]),g=e.useState([]),C=g[0],w=g[1];return e.useEffect((function(){m?i(m,h).then((function(e){w(e)})):c(h).then((function(e){w(e)}))}),[m,h]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(v,t({},p,{placeHolder:f,options:C,onChange:function(e){l&&l(e)},showFlag:d,onTextChange:s,defaultValue:u,inputClassName:r}))))},exports.RegionSelect=function(a){var o=a.containerClassName,i=a.inputClassName,c=a.onTextChange,s=a.defaultValue,u=a.onChange,l=a.placeHolder,f=a.src,m=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","src"]),h=e.useState([]),p=h[0],v=h[1];return e.useEffect((function(){r(f).then((function(e){v(e)}))}),[f]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,t({},m,{placeHolder:l,options:p,onChange:function(e){u&&u(e)},onTextChange:c,defaultValue:s,inputClassName:i}))))},exports.StateSelect=function(a){var o=a.containerClassName,r=a.inputClassName,i=a.onTextChange,c=a.defaultValue,s=a.onChange,l=a.countryid,f=a.placeHolder,m=a.src,h=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder","src"]),p=e.useState([]),v=p[0],g=p[1];return e.useEffect((function(){l&&u(l,m).then((function(e){g(e)}))}),[l,m]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,t({},h,{placeHolder:f,options:v,onChange:function(e){s&&s(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))};
//# sourceMappingURL=index.js.map
Back to Directory
File Manager