Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-country-state-city

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-country-state-city - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

2

dist/cjs/index.js

@@ -1,2 +0,2 @@

"use strict";var e=require("react");function t(e,t,n,a){return new(n||(n=Promise))((function(r,o){function c(e){try{u(a.next(e))}catch(e){o(e)}}function i(e){try{u(a.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,i)}u((a=a.apply(e,t||[])).next())}))}function n(e,t){var n,a,r,o,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(c=0)),c;)try{if(n=1,a&&(r=2&i[0]?a.return:i[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,i[1])).done)return r;switch(a=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,a=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=c.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],a=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var a=function(){return t(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},r=function(e){return t(void 0,void 0,void 0,(function(){var t,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/statesminified.json").then((function(e){return e.json()}))];case 1:return t=n.sent(),a=t.find((function(t){return t.id===e})),[2,a&&a.states?a.states:[]]}}))}))},o=function(e,a){return t(void 0,void 0,void 0,(function(){var t,r,o,c;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/citiesminified.json").then((function(e){return e.json()}))];case 1:return t=n.sent(),(r=t.find((function(t){return t.id===e})))?(o=r&&r.states?r.states:[],[2,(c=o.find((function(e){return e.id===a})))&&c.cities?c.cities:[]]):[2,[]]}}))}))},c=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"}))},i=function(t){var n=t.placeHolder,a=t.options,r=t.onChange,o=t.inputClassName,i=t.onTextChange,u=t.defaultValue,s=t.showFlag,l=void 0===s||s,f=e.useState(!1),d=f[0],m=f[1],p=e.useState(),h=p[0],v=p[1],w=e.useState(""),g=w[0],C=w[1],E=e.useRef(null),y=e.useRef(null);e.useEffect((function(){u&&v(u)}),[u]),e.useEffect((function(){C(""),d&&E.current&&E.current.focus()}),[d]),e.useEffect((function(){var e=function(e){y.current&&!y.current.contains(e.target)&&m(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var N=function(e){return!!h&&h.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:y,onClick:function(){m(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",{className:o,onChange:function(e){C(e.target.value),v(void 0),i&&i(e)},value:h?"".concat(l&&"emoji"in h?h.emoji:""," ").concat(h.name):g||"",placeholder:n,ref:E}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(c,null)))),d&&e.createElement("div",{className:"stdropdown-menu"},(g?a.filter((function(e){return e.name.toLowerCase().indexOf(g.toLowerCase())>=0})):a).map((function(t){return e.createElement("div",{onClick:function(){return function(e){v(e),r(e)}(t)},key:t.id,className:"".concat("stdropdown-item"," ").concat(N(t)&&"selected")},l&&e.createElement("span",null,"emoji"in t?t.emoji:"")," ",t.name)}))))},u=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"}))},s=function(t){var n=t.placeHolder,a=t.options,r=t.onChange,o=t.inputClassName,c=t.onTextChange,i=t.defaultValue,s=t.displayNative,l=e.useState(!1),f=l[0],d=l[1],m=e.useState(),p=m[0],h=m[1],v=e.useState(""),w=v[0],g=v[1],C=e.useRef(null),E=e.useRef(null);e.useEffect((function(){i&&h(i)}),[i]),e.useEffect((function(){g(""),f&&C.current&&C.current.focus()}),[f]),e.useEffect((function(){var e=function(e){E.current&&!E.current.contains(e.target)&&d(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var y=function(e){return!!p&&p.code===e.code};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:E,onClick:function(){d(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",{className:o,onChange:function(e){g(e.target.value),h(void 0),c&&c(e)},value:p?"".concat(s?p.native:p.name):w||"",placeholder:n,ref:C}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(u,null)))),f&&e.createElement("div",{className:"stdropdown-menu"},(w?a.filter((function(e){return e.name.toLowerCase().indexOf(w.toLowerCase())>=0})):a).map((function(t){return e.createElement("div",{onClick:function(){return function(e){h(e),r(e)}(t)},key:t.code,className:"".concat("stdropdown-item"," ").concat(y(t)&&"selected")},s?t.native:t.name)}))))};exports.CitySelect=function(t){var n=t.containerClassName,a=t.inputClassName,r=t.onTextChange,c=t.defaultValue,u=t.onChange,s=t.countryid,l=t.stateid,f=t.placeHolder,d=e.useState([]),m=d[0],p=d[1];return e.useEffect((function(){s&&o(s,l).then((function(e){p(e)}))}),[s,l]),e.createElement(e.Fragment,null,e.createElement("div",{className:n,style:{position:"relative"}},e.createElement(i,{placeHolder:f,options:m,onChange:function(e){u&&u(e)},onTextChange:r,defaultValue:c,inputClassName:a})))},exports.CountrySelect=function(t){var n=t.containerClassName,r=t.inputClassName,o=t.onTextChange,c=t.defaultValue,u=t.onChange,s=t.placeHolder,l=t.showFlag,f=e.useState([]),d=f[0],m=f[1];return e.useEffect((function(){a().then((function(e){m(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:n,style:{position:"relative"}},e.createElement(i,{placeHolder:s,options:d,onChange:function(e){u&&u(e)},showFlag:l,onTextChange:o,defaultValue:c,inputClassName:r})))},exports.GetCity=o,exports.GetCountries=a,exports.GetState=r,exports.LanguageSelect=function(a){var r=a.containerClassName,o=a.inputClassName,c=a.onTextChange,i=a.defaultValue,u=a.onChange,l=a.placeHolder,f=a.displayNative,d=e.useState([]),m=d[0],p=d[1];return e.useEffect((function(){t(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/languagesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))})).then((function(e){p(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:r,style:{position:"relative"}},e.createElement(s,{placeHolder:l,options:m,onChange:function(e){u&&u(e)},displayNative:f,onTextChange:c,defaultValue:i,inputClassName:o})))},exports.StateSelect=function(t){var n=t.containerClassName,a=t.inputClassName,o=t.onTextChange,c=t.defaultValue,u=t.onChange,s=t.countryid,l=t.placeHolder,f=e.useState([]),d=f[0],m=f[1];return e.useEffect((function(){s&&r(s).then((function(e){m(e)}))}),[s]),e.createElement(e.Fragment,null,e.createElement("div",{className:n,style:{position:"relative"}},e.createElement(i,{placeHolder:l,options:d,onChange:function(e){u&&u(e)},onTextChange:o,defaultValue:c,inputClassName:a})))};
"use strict";var e=require("react");function t(e,t,n,a){return new(n||(n=Promise))((function(r,o){function c(e){try{u(a.next(e))}catch(e){o(e)}}function i(e){try{u(a.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,i)}u((a=a.apply(e,t||[])).next())}))}function n(e,t){var n,a,r,o,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(c=0)),c;)try{if(n=1,a&&(r=2&i[0]?a.return:i[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,i[1])).done)return r;switch(a=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,a=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=c.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],a=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var a=function(){return t(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},r=function(){return t(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/languagesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},o=function(e){return t(void 0,void 0,void 0,(function(){var t,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/statesminified.json").then((function(e){return e.json()}))];case 1:return t=n.sent(),a=t.find((function(t){return t.id===e})),[2,a&&a.states?a.states:[]]}}))}))},c=function(e,a){return t(void 0,void 0,void 0,(function(){var t,r,o,c;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/citiesminified.json").then((function(e){return e.json()}))];case 1:return t=n.sent(),(r=t.find((function(t){return t.id===e})))?(o=r&&r.states?r.states:[],[2,(c=o.find((function(e){return e.id===a})))&&c.cities?c.cities:[]]):[2,[]]}}))}))},i=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"}))},u=function(t){var n=t.placeHolder,a=t.options,r=t.onChange,o=t.inputClassName,c=t.onTextChange,u=t.defaultValue,s=t.showFlag,l=void 0===s||s,f=e.useState(!1),d=f[0],m=f[1],p=e.useState(),h=p[0],v=p[1],g=e.useState(""),w=g[0],C=g[1],E=e.useRef(null),y=e.useRef(null);e.useEffect((function(){u&&v(u)}),[u]),e.useEffect((function(){C(""),d&&E.current&&E.current.focus()}),[d]),e.useEffect((function(){var e=function(e){y.current&&!y.current.contains(e.target)&&m(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var N=function(e){return!!h&&h.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:y,onClick:function(){m(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",{className:o,onChange:function(e){C(e.target.value),v(void 0),c&&c(e)},value:h?"".concat(l&&"emoji"in h?h.emoji:""," ").concat(h.name):w||"",placeholder:n,ref:E}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(i,null)))),d&&e.createElement("div",{className:"stdropdown-menu"},(w?a.filter((function(e){return e.name.toLowerCase().indexOf(w.toLowerCase())>=0})):a).map((function(t){return e.createElement("div",{onClick:function(){return function(e){v(e),r(e)}(t)},key:t.id,className:"".concat("stdropdown-item"," ").concat(N(t)&&"selected")},l&&e.createElement("span",null,"emoji"in t?t.emoji:"")," ",t.name)}))))},s=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"}))},l=function(t){var n=t.placeHolder,a=t.options,r=t.onChange,o=t.inputClassName,c=t.onTextChange,i=t.defaultValue,u=t.displayNative,l=e.useState(!1),f=l[0],d=l[1],m=e.useState(),p=m[0],h=m[1],v=e.useState(""),g=v[0],w=v[1],C=e.useRef(null),E=e.useRef(null);e.useEffect((function(){i&&h(i)}),[i]),e.useEffect((function(){w(""),f&&C.current&&C.current.focus()}),[f]),e.useEffect((function(){var e=function(e){E.current&&!E.current.contains(e.target)&&d(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var y=function(e){return!!p&&p.code===e.code};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:E,onClick:function(){d(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",{className:o,onChange:function(e){w(e.target.value),h(void 0),c&&c(e)},value:p?"".concat(u?p.native:p.name):g||"",placeholder:n,ref:C}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(s,null)))),f&&e.createElement("div",{className:"stdropdown-menu"},(g?a.filter((function(e){return e.name.toLowerCase().indexOf(g.toLowerCase())>=0})):a).map((function(t){return e.createElement("div",{onClick:function(){return function(e){h(e),r(e)}(t)},key:t.code,className:"".concat("stdropdown-item"," ").concat(y(t)&&"selected")},u?t.native:t.name)}))))};exports.CitySelect=function(t){var n=t.containerClassName,a=t.inputClassName,r=t.onTextChange,o=t.defaultValue,i=t.onChange,s=t.countryid,l=t.stateid,f=t.placeHolder,d=e.useState([]),m=d[0],p=d[1];return e.useEffect((function(){s&&c(s,l).then((function(e){p(e)}))}),[s,l]),e.createElement(e.Fragment,null,e.createElement("div",{className:n,style:{position:"relative"}},e.createElement(u,{placeHolder:f,options:m,onChange:function(e){i&&i(e)},onTextChange:r,defaultValue:o,inputClassName:a})))},exports.CountrySelect=function(t){var n=t.containerClassName,r=t.inputClassName,o=t.onTextChange,c=t.defaultValue,i=t.onChange,s=t.placeHolder,l=t.showFlag,f=e.useState([]),d=f[0],m=f[1];return e.useEffect((function(){a().then((function(e){m(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:n,style:{position:"relative"}},e.createElement(u,{placeHolder:s,options:d,onChange:function(e){i&&i(e)},showFlag:l,onTextChange:o,defaultValue:c,inputClassName:r})))},exports.GetCity=c,exports.GetCountries=a,exports.GetLanguages=r,exports.GetState=o,exports.LanguageSelect=function(t){var n=t.containerClassName,a=t.inputClassName,o=t.onTextChange,c=t.defaultValue,i=t.onChange,u=t.placeHolder,s=t.displayNative,f=e.useState([]),d=f[0],m=f[1];return e.useEffect((function(){r().then((function(e){m(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:n,style:{position:"relative"}},e.createElement(l,{placeHolder:u,options:d,onChange:function(e){i&&i(e)},displayNative:s,onTextChange:o,defaultValue:c,inputClassName:a})))},exports.StateSelect=function(t){var n=t.containerClassName,a=t.inputClassName,r=t.onTextChange,c=t.defaultValue,i=t.onChange,s=t.countryid,l=t.placeHolder,f=e.useState([]),d=f[0],m=f[1];return e.useEffect((function(){s&&o(s).then((function(e){m(e)}))}),[s]),e.createElement(e.Fragment,null,e.createElement("div",{className:n,style:{position:"relative"}},e.createElement(u,{placeHolder:l,options:d,onChange:function(e){i&&i(e)},onTextChange:r,defaultValue:c,inputClassName:a})))};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import e,{useState as n,useRef as t,useEffect as a}from"react";function o(e,n,t,a){return new(t||(t=Promise))((function(o,r){function c(e){try{u(a.next(e))}catch(e){r(e)}}function i(e){try{u(a.throw(e))}catch(e){r(e)}}function u(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,i)}u((a=a.apply(e,n||[])).next())}))}function r(e,n){var t,a,o,r,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(i){return function(u){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;r&&(r=0,i[0]&&(c=0)),c;)try{if(t=1,a&&(o=2&i[0]?a.return:i[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,i[1])).done)return o;switch(a=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,a=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=n.call(e,c)}catch(e){i=[6,e],a=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var c=function(){return o(void 0,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},i=function(e){return o(void 0,void 0,void 0,(function(){var n,t;return r(this,(function(a){switch(a.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/statesminified.json").then((function(e){return e.json()}))];case 1:return n=a.sent(),t=n.find((function(n){return n.id===e})),[2,t&&t.states?t.states:[]]}}))}))},u=function(e,n){return o(void 0,void 0,void 0,(function(){var t,a,o,c;return r(this,(function(r){switch(r.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/citiesminified.json").then((function(e){return e.json()}))];case 1:return t=r.sent(),(a=t.find((function(n){return n.id===e})))?(o=a&&a.states?a.states:[],[2,(c=o.find((function(e){return e.id===n})))&&c.cities?c.cities:[]]):[2,[]]}}))}))},l=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"}))},s=function(o){var r=o.placeHolder,c=o.options,i=o.onChange,u=o.inputClassName,s=o.onTextChange,d=o.defaultValue,f=o.showFlag,m=void 0===f||f,h=n(!1),p=h[0],v=h[1],w=n(),g=w[0],C=w[1],E=n(""),N=E[0],y=E[1],b=t(null),x=t(null);a((function(){d&&C(d)}),[d]),a((function(){y(""),p&&b.current&&b.current.focus()}),[p]),a((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 j=function(e){return!!g&&g.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",{className:u,onChange:function(e){y(e.target.value),C(void 0),s&&s(e)},value:g?"".concat(m&&"emoji"in g?g.emoji:""," ").concat(g.name):N||"",placeholder:r,ref:b}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(l,null)))),p&&e.createElement("div",{className:"stdropdown-menu"},(N?c.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0})):c).map((function(n){return e.createElement("div",{onClick:function(){return function(e){C(e),i(e)}(n)},key:n.id,className:"".concat("stdropdown-item"," ").concat(j(n)&&"selected")},m&&e.createElement("span",null,"emoji"in n?n.emoji:"")," ",n.name)}))))},d=function(t){var o=t.containerClassName,r=t.inputClassName,i=t.onTextChange,u=t.defaultValue,l=t.onChange,d=t.placeHolder,f=t.showFlag,m=n([]),h=m[0],p=m[1];return a((function(){c().then((function(e){p(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(s,{placeHolder:d,options:h,onChange:function(e){l&&l(e)},showFlag:f,onTextChange:i,defaultValue:u,inputClassName:r})))},f=function(t){var o=t.containerClassName,r=t.inputClassName,c=t.onTextChange,u=t.defaultValue,l=t.onChange,d=t.countryid,f=t.placeHolder,m=n([]),h=m[0],p=m[1];return a((function(){d&&i(d).then((function(e){p(e)}))}),[d]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(s,{placeHolder:f,options:h,onChange:function(e){l&&l(e)},onTextChange:c,defaultValue:u,inputClassName:r})))},m=function(t){var o=t.containerClassName,r=t.inputClassName,c=t.onTextChange,i=t.defaultValue,l=t.onChange,d=t.countryid,f=t.stateid,m=t.placeHolder,h=n([]),p=h[0],v=h[1];return a((function(){d&&u(d,f).then((function(e){v(e)}))}),[d,f]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(s,{placeHolder:m,options:p,onChange:function(e){l&&l(e)},onTextChange:c,defaultValue:i,inputClassName:r})))},h=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"}))},p=function(o){var r=o.placeHolder,c=o.options,i=o.onChange,u=o.inputClassName,l=o.onTextChange,s=o.defaultValue,d=o.displayNative,f=n(!1),m=f[0],p=f[1],v=n(),w=v[0],g=v[1],C=n(""),E=C[0],N=C[1],y=t(null),b=t(null);a((function(){s&&g(s)}),[s]),a((function(){N(""),m&&y.current&&y.current.focus()}),[m]),a((function(){var e=function(e){b.current&&!b.current.contains(e.target)&&p(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var x=function(e){return!!w&&w.code===e.code};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:b,onClick:function(){p(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",{className:u,onChange:function(e){N(e.target.value),g(void 0),l&&l(e)},value:w?"".concat(d?w.native:w.name):E||"",placeholder:r,ref:y}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(h,null)))),m&&e.createElement("div",{className:"stdropdown-menu"},(E?c.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0})):c).map((function(n){return e.createElement("div",{onClick:function(){return function(e){g(e),i(e)}(n)},key:n.code,className:"".concat("stdropdown-item"," ").concat(x(n)&&"selected")},d?n.native:n.name)}))))},v=function(t){var c=t.containerClassName,i=t.inputClassName,u=t.onTextChange,l=t.defaultValue,s=t.onChange,d=t.placeHolder,f=t.displayNative,m=n([]),h=m[0],v=m[1];return a((function(){o(void 0,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/languagesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))})).then((function(e){v(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:c,style:{position:"relative"}},e.createElement(p,{placeHolder:d,options:h,onChange:function(e){s&&s(e)},displayNative:f,onTextChange:u,defaultValue:l,inputClassName:i})))};export{m as CitySelect,d as CountrySelect,u as GetCity,c as GetCountries,i as GetState,v as LanguageSelect,f as StateSelect};
import e,{useState as n,useRef as t,useEffect as a}from"react";function o(e,n,t,a){return new(t||(t=Promise))((function(o,r){function c(e){try{u(a.next(e))}catch(e){r(e)}}function i(e){try{u(a.throw(e))}catch(e){r(e)}}function u(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,i)}u((a=a.apply(e,n||[])).next())}))}function r(e,n){var t,a,o,r,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(i){return function(u){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;r&&(r=0,i[0]&&(c=0)),c;)try{if(t=1,a&&(o=2&i[0]?a.return:i[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,i[1])).done)return o;switch(a=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,a=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=n.call(e,c)}catch(e){i=[6,e],a=0}finally{t=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var c=function(){return o(void 0,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},i=function(){return o(void 0,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/languagesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},u=function(e){return o(void 0,void 0,void 0,(function(){var n,t;return r(this,(function(a){switch(a.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/statesminified.json").then((function(e){return e.json()}))];case 1:return n=a.sent(),t=n.find((function(n){return n.id===e})),[2,t&&t.states?t.states:[]]}}))}))},l=function(e,n){return o(void 0,void 0,void 0,(function(){var t,a,o,c;return r(this,(function(r){switch(r.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/citiesminified.json").then((function(e){return e.json()}))];case 1:return t=r.sent(),(a=t.find((function(n){return n.id===e})))?(o=a&&a.states?a.states:[],[2,(c=o.find((function(e){return e.id===n})))&&c.cities?c.cities:[]]):[2,[]]}}))}))},s=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(o){var r=o.placeHolder,c=o.options,i=o.onChange,u=o.inputClassName,l=o.onTextChange,d=o.defaultValue,f=o.showFlag,m=void 0===f||f,h=n(!1),p=h[0],v=h[1],w=n(),g=w[0],C=w[1],E=n(""),N=E[0],y=E[1],b=t(null),x=t(null);a((function(){d&&C(d)}),[d]),a((function(){y(""),p&&b.current&&b.current.focus()}),[p]),a((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 j=function(e){return!!g&&g.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",{className:u,onChange:function(e){y(e.target.value),C(void 0),l&&l(e)},value:g?"".concat(m&&"emoji"in g?g.emoji:""," ").concat(g.name):N||"",placeholder:r,ref:b}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(s,null)))),p&&e.createElement("div",{className:"stdropdown-menu"},(N?c.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0})):c).map((function(n){return e.createElement("div",{onClick:function(){return function(e){C(e),i(e)}(n)},key:n.id,className:"".concat("stdropdown-item"," ").concat(j(n)&&"selected")},m&&e.createElement("span",null,"emoji"in n?n.emoji:"")," ",n.name)}))))},f=function(t){var o=t.containerClassName,r=t.inputClassName,i=t.onTextChange,u=t.defaultValue,l=t.onChange,s=t.placeHolder,f=t.showFlag,m=n([]),h=m[0],p=m[1];return a((function(){c().then((function(e){p(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,{placeHolder:s,options:h,onChange:function(e){l&&l(e)},showFlag:f,onTextChange:i,defaultValue:u,inputClassName:r})))},m=function(t){var o=t.containerClassName,r=t.inputClassName,c=t.onTextChange,i=t.defaultValue,l=t.onChange,s=t.countryid,f=t.placeHolder,m=n([]),h=m[0],p=m[1];return a((function(){s&&u(s).then((function(e){p(e)}))}),[s]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,{placeHolder:f,options:h,onChange:function(e){l&&l(e)},onTextChange:c,defaultValue:i,inputClassName:r})))},h=function(t){var o=t.containerClassName,r=t.inputClassName,c=t.onTextChange,i=t.defaultValue,u=t.onChange,s=t.countryid,f=t.stateid,m=t.placeHolder,h=n([]),p=h[0],v=h[1];return a((function(){s&&l(s,f).then((function(e){v(e)}))}),[s,f]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,{placeHolder:m,options:p,onChange:function(e){u&&u(e)},onTextChange:c,defaultValue:i,inputClassName:r})))},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(o){var r=o.placeHolder,c=o.options,i=o.onChange,u=o.inputClassName,l=o.onTextChange,s=o.defaultValue,d=o.displayNative,f=n(!1),m=f[0],h=f[1],v=n(),w=v[0],g=v[1],C=n(""),E=C[0],N=C[1],y=t(null),b=t(null);a((function(){s&&g(s)}),[s]),a((function(){N(""),m&&y.current&&y.current.focus()}),[m]),a((function(){var e=function(e){b.current&&!b.current.contains(e.target)&&h(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var x=function(e){return!!w&&w.code===e.code};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:b,onClick:function(){h(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",{className:u,onChange:function(e){N(e.target.value),g(void 0),l&&l(e)},value:w?"".concat(d?w.native:w.name):E||"",placeholder:r,ref:y}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(p,null)))),m&&e.createElement("div",{className:"stdropdown-menu"},(E?c.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0})):c).map((function(n){return e.createElement("div",{onClick:function(){return function(e){g(e),i(e)}(n)},key:n.code,className:"".concat("stdropdown-item"," ").concat(x(n)&&"selected")},d?n.native:n.name)}))))},w=function(t){var o=t.containerClassName,r=t.inputClassName,c=t.onTextChange,u=t.defaultValue,l=t.onChange,s=t.placeHolder,d=t.displayNative,f=n([]),m=f[0],h=f[1];return a((function(){i().then((function(e){h(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(v,{placeHolder:s,options:m,onChange:function(e){l&&l(e)},displayNative:d,onTextChange:c,defaultValue:u,inputClassName:r})))};export{h as CitySelect,f as CountrySelect,l as GetCity,c as GetCountries,i as GetLanguages,u as GetState,w as LanguageSelect,m as StateSelect};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactCountryStateCity={},e.React)}(this,(function(e,t){"use strict";function n(e,t,n,a){return new(n||(n=Promise))((function(o,r){function c(e){try{u(a.next(e))}catch(e){r(e)}}function i(e){try{u(a.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,i)}u((a=a.apply(e,t||[])).next())}))}function a(e,t){var n,a,o,r,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,i[0]&&(c=0)),c;)try{if(n=1,a&&(o=2&i[0]?a.return:i[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,i[1])).done)return o;switch(a=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,a=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],a=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var o=function(){return n(void 0,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},r=function(e){return n(void 0,void 0,void 0,(function(){var t,n;return a(this,(function(a){switch(a.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/statesminified.json").then((function(e){return e.json()}))];case 1:return t=a.sent(),n=t.find((function(t){return t.id===e})),[2,n&&n.states?n.states:[]]}}))}))},c=function(e,t){return n(void 0,void 0,void 0,(function(){var n,o,r,c;return a(this,(function(a){switch(a.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/citiesminified.json").then((function(e){return e.json()}))];case 1:return n=a.sent(),(o=n.find((function(t){return t.id===e})))?(r=o&&o.states?o.states:[],[2,(c=r.find((function(e){return e.id===t})))&&c.cities?c.cities:[]]):[2,[]]}}))}))},i=function(){return t.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},t.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"}))},u=function(e){var n=e.placeHolder,a=e.options,o=e.onChange,r=e.inputClassName,c=e.onTextChange,u=e.defaultValue,s=e.showFlag,l=void 0===s||s,f=t.useState(!1),d=f[0],m=f[1],p=t.useState(),h=p[0],v=p[1],g=t.useState(""),C=g[0],w=g[1],E=t.useRef(null),y=t.useRef(null);t.useEffect((function(){u&&v(u)}),[u]),t.useEffect((function(){w(""),d&&E.current&&E.current.focus()}),[d]),t.useEffect((function(){var e=function(e){y.current&&!y.current.contains(e.target)&&m(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var N=function(e){return!!h&&h.id===e.id};return t.createElement("div",{className:"stdropdown-container"},t.createElement("div",{ref:y,onClick:function(){m(!0)},className:"stdropdown-input stsearch-box"},t.createElement("input",{className:r,onChange:function(e){w(e.target.value),v(void 0),c&&c(e)},value:h?"".concat(l&&"emoji"in h?h.emoji:""," ").concat(h.name):C||"",placeholder:n,ref:E}),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(i,null)))),d&&t.createElement("div",{className:"stdropdown-menu"},(C?a.filter((function(e){return e.name.toLowerCase().indexOf(C.toLowerCase())>=0})):a).map((function(e){return t.createElement("div",{onClick:function(){return function(e){v(e),o(e)}(e)},key:e.id,className:"".concat("stdropdown-item"," ").concat(N(e)&&"selected")},l&&t.createElement("span",null,"emoji"in e?e.emoji:"")," ",e.name)}))))},s=function(){return t.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},t.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"}))},l=function(e){var n=e.placeHolder,a=e.options,o=e.onChange,r=e.inputClassName,c=e.onTextChange,i=e.defaultValue,u=e.displayNative,l=t.useState(!1),f=l[0],d=l[1],m=t.useState(),p=m[0],h=m[1],v=t.useState(""),g=v[0],C=v[1],w=t.useRef(null),E=t.useRef(null);t.useEffect((function(){i&&h(i)}),[i]),t.useEffect((function(){C(""),f&&w.current&&w.current.focus()}),[f]),t.useEffect((function(){var e=function(e){E.current&&!E.current.contains(e.target)&&d(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var y=function(e){return!!p&&p.code===e.code};return t.createElement("div",{className:"stdropdown-container"},t.createElement("div",{ref:E,onClick:function(){d(!0)},className:"stdropdown-input stsearch-box"},t.createElement("input",{className:r,onChange:function(e){C(e.target.value),h(void 0),c&&c(e)},value:p?"".concat(u?p.native:p.name):g||"",placeholder:n,ref:w}),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(s,null)))),f&&t.createElement("div",{className:"stdropdown-menu"},(g?a.filter((function(e){return e.name.toLowerCase().indexOf(g.toLowerCase())>=0})):a).map((function(e){return t.createElement("div",{onClick:function(){return function(e){h(e),o(e)}(e)},key:e.code,className:"".concat("stdropdown-item"," ").concat(y(e)&&"selected")},u?e.native:e.name)}))))};e.CitySelect=function(e){var n=e.containerClassName,a=e.inputClassName,o=e.onTextChange,r=e.defaultValue,i=e.onChange,s=e.countryid,l=e.stateid,f=e.placeHolder,d=t.useState([]),m=d[0],p=d[1];return t.useEffect((function(){s&&c(s,l).then((function(e){p(e)}))}),[s,l]),t.createElement(t.Fragment,null,t.createElement("div",{className:n,style:{position:"relative"}},t.createElement(u,{placeHolder:f,options:m,onChange:function(e){i&&i(e)},onTextChange:o,defaultValue:r,inputClassName:a})))},e.CountrySelect=function(e){var n=e.containerClassName,a=e.inputClassName,r=e.onTextChange,c=e.defaultValue,i=e.onChange,s=e.placeHolder,l=e.showFlag,f=t.useState([]),d=f[0],m=f[1];return t.useEffect((function(){o().then((function(e){m(e)}))}),[]),t.createElement(t.Fragment,null,t.createElement("div",{className:n,style:{position:"relative"}},t.createElement(u,{placeHolder:s,options:d,onChange:function(e){i&&i(e)},showFlag:l,onTextChange:r,defaultValue:c,inputClassName:a})))},e.GetCity=c,e.GetCountries=o,e.GetState=r,e.LanguageSelect=function(e){var o=e.containerClassName,r=e.inputClassName,c=e.onTextChange,i=e.defaultValue,u=e.onChange,s=e.placeHolder,f=e.displayNative,d=t.useState([]),m=d[0],p=d[1];return t.useEffect((function(){n(void 0,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/languagesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))})).then((function(e){p(e)}))}),[]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(l,{placeHolder:s,options:m,onChange:function(e){u&&u(e)},displayNative:f,onTextChange:c,defaultValue:i,inputClassName:r})))},e.StateSelect=function(e){var n=e.containerClassName,a=e.inputClassName,o=e.onTextChange,c=e.defaultValue,i=e.onChange,s=e.countryid,l=e.placeHolder,f=t.useState([]),d=f[0],m=f[1];return t.useEffect((function(){s&&r(s).then((function(e){m(e)}))}),[s]),t.createElement(t.Fragment,null,t.createElement("div",{className:n,style:{position:"relative"}},t.createElement(u,{placeHolder:l,options:d,onChange:function(e){i&&i(e)},onTextChange:o,defaultValue:c,inputClassName:a})))}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactCountryStateCity={},e.React)}(this,(function(e,t){"use strict";function n(e,t,n,a){return new(n||(n=Promise))((function(o,r){function c(e){try{u(a.next(e))}catch(e){r(e)}}function i(e){try{u(a.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,i)}u((a=a.apply(e,t||[])).next())}))}function a(e,t){var n,a,o,r,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function i(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,i[0]&&(c=0)),c;)try{if(n=1,a&&(o=2&i[0]?a.return:i[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,i[1])).done)return o;switch(a=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,a=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],a=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var o=function(){return n(void 0,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},r=function(){return n(void 0,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/languagesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},c=function(e){return n(void 0,void 0,void 0,(function(){var t,n;return a(this,(function(a){switch(a.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/statesminified.json").then((function(e){return e.json()}))];case 1:return t=a.sent(),n=t.find((function(t){return t.id===e})),[2,n&&n.states?n.states:[]]}}))}))},i=function(e,t){return n(void 0,void 0,void 0,(function(){var n,o,r,c;return a(this,(function(a){switch(a.label){case 0:return[4,fetch("https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/data/citiesminified.json").then((function(e){return e.json()}))];case 1:return n=a.sent(),(o=n.find((function(t){return t.id===e})))?(r=o&&o.states?o.states:[],[2,(c=r.find((function(e){return e.id===t})))&&c.cities?c.cities:[]]):[2,[]]}}))}))},u=function(){return t.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},t.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"}))},s=function(e){var n=e.placeHolder,a=e.options,o=e.onChange,r=e.inputClassName,c=e.onTextChange,i=e.defaultValue,s=e.showFlag,l=void 0===s||s,f=t.useState(!1),d=f[0],m=f[1],p=t.useState(),h=p[0],v=p[1],g=t.useState(""),C=g[0],w=g[1],E=t.useRef(null),y=t.useRef(null);t.useEffect((function(){i&&v(i)}),[i]),t.useEffect((function(){w(""),d&&E.current&&E.current.focus()}),[d]),t.useEffect((function(){var e=function(e){y.current&&!y.current.contains(e.target)&&m(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var N=function(e){return!!h&&h.id===e.id};return t.createElement("div",{className:"stdropdown-container"},t.createElement("div",{ref:y,onClick:function(){m(!0)},className:"stdropdown-input stsearch-box"},t.createElement("input",{className:r,onChange:function(e){w(e.target.value),v(void 0),c&&c(e)},value:h?"".concat(l&&"emoji"in h?h.emoji:""," ").concat(h.name):C||"",placeholder:n,ref:E}),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(u,null)))),d&&t.createElement("div",{className:"stdropdown-menu"},(C?a.filter((function(e){return e.name.toLowerCase().indexOf(C.toLowerCase())>=0})):a).map((function(e){return t.createElement("div",{onClick:function(){return function(e){v(e),o(e)}(e)},key:e.id,className:"".concat("stdropdown-item"," ").concat(N(e)&&"selected")},l&&t.createElement("span",null,"emoji"in e?e.emoji:"")," ",e.name)}))))},l=function(){return t.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},t.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"}))},f=function(e){var n=e.placeHolder,a=e.options,o=e.onChange,r=e.inputClassName,c=e.onTextChange,i=e.defaultValue,u=e.displayNative,s=t.useState(!1),f=s[0],d=s[1],m=t.useState(),p=m[0],h=m[1],v=t.useState(""),g=v[0],C=v[1],w=t.useRef(null),E=t.useRef(null);t.useEffect((function(){i&&h(i)}),[i]),t.useEffect((function(){C(""),f&&w.current&&w.current.focus()}),[f]),t.useEffect((function(){var e=function(e){E.current&&!E.current.contains(e.target)&&d(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var y=function(e){return!!p&&p.code===e.code};return t.createElement("div",{className:"stdropdown-container"},t.createElement("div",{ref:E,onClick:function(){d(!0)},className:"stdropdown-input stsearch-box"},t.createElement("input",{className:r,onChange:function(e){C(e.target.value),h(void 0),c&&c(e)},value:p?"".concat(u?p.native:p.name):g||"",placeholder:n,ref:w}),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(l,null)))),f&&t.createElement("div",{className:"stdropdown-menu"},(g?a.filter((function(e){return e.name.toLowerCase().indexOf(g.toLowerCase())>=0})):a).map((function(e){return t.createElement("div",{onClick:function(){return function(e){h(e),o(e)}(e)},key:e.code,className:"".concat("stdropdown-item"," ").concat(y(e)&&"selected")},u?e.native:e.name)}))))};e.CitySelect=function(e){var n=e.containerClassName,a=e.inputClassName,o=e.onTextChange,r=e.defaultValue,c=e.onChange,u=e.countryid,l=e.stateid,f=e.placeHolder,d=t.useState([]),m=d[0],p=d[1];return t.useEffect((function(){u&&i(u,l).then((function(e){p(e)}))}),[u,l]),t.createElement(t.Fragment,null,t.createElement("div",{className:n,style:{position:"relative"}},t.createElement(s,{placeHolder:f,options:m,onChange:function(e){c&&c(e)},onTextChange:o,defaultValue:r,inputClassName:a})))},e.CountrySelect=function(e){var n=e.containerClassName,a=e.inputClassName,r=e.onTextChange,c=e.defaultValue,i=e.onChange,u=e.placeHolder,l=e.showFlag,f=t.useState([]),d=f[0],m=f[1];return t.useEffect((function(){o().then((function(e){m(e)}))}),[]),t.createElement(t.Fragment,null,t.createElement("div",{className:n,style:{position:"relative"}},t.createElement(s,{placeHolder:u,options:d,onChange:function(e){i&&i(e)},showFlag:l,onTextChange:r,defaultValue:c,inputClassName:a})))},e.GetCity=i,e.GetCountries=o,e.GetLanguages=r,e.GetState=c,e.LanguageSelect=function(e){var n=e.containerClassName,a=e.inputClassName,o=e.onTextChange,c=e.defaultValue,i=e.onChange,u=e.placeHolder,s=e.displayNative,l=t.useState([]),d=l[0],m=l[1];return t.useEffect((function(){r().then((function(e){m(e)}))}),[]),t.createElement(t.Fragment,null,t.createElement("div",{className:n,style:{position:"relative"}},t.createElement(f,{placeHolder:u,options:d,onChange:function(e){i&&i(e)},displayNative:s,onTextChange:o,defaultValue:c,inputClassName:a})))},e.StateSelect=function(e){var n=e.containerClassName,a=e.inputClassName,o=e.onTextChange,r=e.defaultValue,i=e.onChange,u=e.countryid,l=e.placeHolder,f=t.useState([]),d=f[0],m=f[1];return t.useEffect((function(){u&&c(u).then((function(e){m(e)}))}),[u]),t.createElement(t.Fragment,null,t.createElement("div",{className:n,style:{position:"relative"}},t.createElement(s,{placeHolder:l,options:d,onChange:function(e){i&&i(e)},onTextChange:o,defaultValue:r,inputClassName:a})))}}));
//# sourceMappingURL=index.js.map
{
"name": "react-country-state-city",
"version": "1.0.7",
"version": "1.0.8",
"description": "React-country-state-city allows you to create a Select dropdown for countries, states, cities with search options.And also provide the option to create a language select dropdown to list all Languages.",

@@ -25,19 +25,24 @@ "main": "dist/cjs/index.js",

"react",
"react-select",
"react-dropdown",
"country",
"country-list",
"state",
"state-list",
"city",
"city-list",
"dropdown",
"search",
"select",
"country dropdown",
"state dropdown",
"city dropdown",
"component",
"country select",
"state select",
"city select",
"country-dropdown",
"state-dropdown",
"city-dropdown",
"country-select",
"state-select",
"city-select",
"language",
"language select",
"language-list",
"language-select",
"multilingual",
"multi language"
"multi-language"
],

@@ -44,0 +49,0 @@ "author": "Venkatesh",

@@ -10,2 +10,11 @@ # React-country-state-city

$ yarn add react-country-state-city
$ import {
CitySelect,
CountrySelect,
StateSelect,
LanguageSelect,
} from "react-country-state-city";
$ import "react-country-state-city/dist/react-country-state-city.css";
```

@@ -17,2 +26,3 @@

- Super easy to customize
- Can also use it in your own custom UI.
- Autosuggest: a list of matching countries is displayed when the input text changes.

@@ -27,2 +37,4 @@ - Country data is provided, State data is provided based on given country id, City data is provided based on given country id and state id.

### Default
```jsx

@@ -78,2 +90,97 @@ import {

### Custom
```jsx
import {
GetCountries,
GetState,
GetCity,
GetLanguages, //async functions
} from "react-country-state-city";
function App() {
const [countryid, setCountryid] = useState(0);
const [stateid, setStateid] = useState(0);
const [cityid, setCityid] = useState(0);
const [language, setLanguage] = useState(0);
const [countriesList, setCountriesList] = useState([]);
const [stateList, setStateList] = useState([]);
const [cityList, setCityList] = useState([]);
const [languageList, setLanguageList] = useState([]);
useEffect(() => {
GetCountries().then((result) => {
setCountries(result);
});
GetLanguages().then((result) => {
setLanguageList(result);
});
}, []);
return (
<div>
<h6>Country</h6>
<select
onChange={(e) => {
setCountryid(e.id);
GetState(e.id).then((result) => {
setStateList(result);
});
}}
value={countryid}
>
{countryList.map((item, index) => (
<option key={index} value={item.id}>
{item.name}
</option>
))}
</select>
<h6>State</h6>
<select
onChange={(e) => {
setStateid(e.id);
GetCity(countryid, e.id).then((result) => {
setCityList(result);
});
}}
value={stateid}
>
{stateList.map((item, index) => (
<option key={index} value={item.id}>
{item.name}
</option>
))}
</select>
<h6>City</h6>
<select
onChange={(e) => {
setCityid(e.id);
}}
value={cityid}
>
{cityList.map((item, index) => (
<option key={index} value={item.id}>
{item.name}
</option>
))}
</select>
<h6>Language</h6>
<select
onChange={(e) => {
setLanguage(e);
}}
value={language}
>
{languageList.map((item, index) => (
<option key={index} value={item.id}>
{item.name}
</option>
))}
</select>
</div>
);
}
```
### City Example

@@ -83,2 +190,14 @@

### GetCity - Result
[
{
id: number;
name: string;
latitude: string;
longitude: string;
},
...
]
### State Example

@@ -88,2 +207,15 @@

### GetState - Result
[
{
id: number;
name: string;
state_code: string;
latitude: string;
longitude: string;
},
...
]
### Country Example

@@ -93,2 +225,39 @@

### GetCountries - Result
[
{
id: number;
name: string;
iso3: string;
iso2: string;
numeric_code: string;
phone_code: number;
capital: string;
currency: string;
currency_name: string;
currency_symbol: string;
native: string;
region: string;
subregion: string;
emoji: string;
emojiU: string;
tld: string;
latitude: string;
longitude: string;
},
...
]
### GetLanguages - Result
[
{
code: string;
name: string;
native: string;
},
...
]
## The Country Select Properties

@@ -95,0 +264,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc