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
17
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.1.0 to 1.1.2

dist/fonts/TwemojiMozilla.ttf

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(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 n(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 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://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},o=function(){return t(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,fetch("https://venkatmcajj.github.io/react-country-state-city/data/languagesminified.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://venkatmcajj.github.io/react-country-state-city/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,o,r,c;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("https://venkatmcajj.github.io/react-country-state-city/data/citiesminified.json").then((function(e){return e.json()}))];case 1:return t=n.sent(),(o=t.find((function(t){return t.id===e})))?(r=o&&o.states?o.states:[],[2,(c=r.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,o=t.onChange,r=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(""),C=g[0],E=g[1],w=e.useRef(null),y=e.useRef(null);e.useEffect((function(){u&&v(u)}),[u]),e.useEffect((function(){E(""),d&&w.current&&w.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:r,onChange:function(e){E(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:w}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(i,null)))),d&&e.createElement("div",{className:"stdropdown-menu"},(C?a.filter((function(e){return e.name.toLowerCase().indexOf(C.toLowerCase())>=0})):a).map((function(t){return e.createElement("div",{onClick:function(){return function(e){v(e),o(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,o=t.onChange,r=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],C=v[1],E=e.useRef(null),w=e.useRef(null);e.useEffect((function(){i&&h(i)}),[i]),e.useEffect((function(){C(""),f&&E.current&&E.current.focus()}),[f]),e.useEffect((function(){var e=function(e){w.current&&!w.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:w,onClick:function(){d(!0)},className:"stdropdown-input stsearch-box"},e.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:E}),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),o(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,o=t.onTextChange,r=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:o,defaultValue:r,inputClassName:a})))},exports.CountrySelect=function(t){var n=t.containerClassName,o=t.inputClassName,r=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:r,defaultValue:c,inputClassName:o})))},exports.GetCity=c,exports.GetCountries=a,exports.GetLanguages=o,exports.GetState=r,exports.LanguageSelect=function(t){var n=t.containerClassName,a=t.inputClassName,r=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(){o().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:r,defaultValue:c,inputClassName:a})))},exports.StateSelect=function(t){var n=t.containerClassName,a=t.inputClassName,o=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&&r(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:o,defaultValue:c,inputClassName:a})))};
"use strict";var e=require("react");function t(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 n(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 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://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},o=function(){return t(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,fetch("https://venkatmcajj.github.io/react-country-state-city/data/languagesminified.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://venkatmcajj.github.io/react-country-state-city/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,o,r,c;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("https://venkatmcajj.github.io/react-country-state-city/data/citiesminified.json").then((function(e){return e.json()}))];case 1:return t=n.sent(),(o=t.find((function(t){return t.id===e})))?(r=o&&o.states?o.states:[],[2,(c=r.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,o=t.onChange,r=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(""),C=g[0],E=g[1],w=e.useRef(null),y=e.useRef(null);e.useEffect((function(){u&&v(u)}),[u]),e.useEffect((function(){E(""),d&&w.current&&w.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:r,onChange:function(e){E(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:w}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(i,null)))),d&&e.createElement("div",{className:"stdropdown-menu"},(C?a.filter((function(e){return e.name.toLowerCase().indexOf(C.toLowerCase())>=0})):a).map((function(t){return e.createElement("div",{onClick:function(){return function(e){v(e),o(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,o=t.onChange,r=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],C=v[1],E=e.useRef(null),w=e.useRef(null);e.useEffect((function(){i&&h(i)}),[i]),e.useEffect((function(){C(""),f&&E.current&&E.current.focus()}),[f]),e.useEffect((function(){var e=function(e){w.current&&!w.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:w,onClick:function(){d(!0)},className:"stdropdown-input stsearch-box"},e.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:E}),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),o(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,o=t.onTextChange,r=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:o,defaultValue:r,inputClassName:a})))},exports.CountrySelect=function(t){var n=t.containerClassName,o=t.inputClassName,r=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:r,defaultValue:c,inputClassName:o})))},exports.GetCity=c,exports.GetCountries=a,exports.GetLanguages=o,exports.GetState=r,exports.LanguageSelect=function(t){var n=t.containerClassName,a=t.inputClassName,r=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(){o().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:r,defaultValue:c,inputClassName:a})))},exports.StateSelect=function(t){var n=t.containerClassName,a=t.inputClassName,o=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&&r(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:o,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 i(e){try{u(a.next(e))}catch(e){r(e)}}function c(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(i,c)}u((a=a.apply(e,n||[])).next())}))}function r(e,n){var t,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(u){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;r&&(r=0,c[0]&&(i=0)),i;)try{if(t=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=n.call(e,i)}catch(e){c=[6,e],a=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var 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://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},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://venkatmcajj.github.io/react-country-state-city/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://venkatmcajj.github.io/react-country-state-city/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,i;return r(this,(function(r){switch(r.label){case 0:return[4,fetch("https://venkatmcajj.github.io/react-country-state-city/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,(i=o.find((function(e){return e.id===n})))&&i.cities?i.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,i=o.options,c=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],g=n(),w=g[0],C=g[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!!w&&w.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:w?"".concat(m&&"emoji"in w?w.emoji:""," ").concat(w.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?i.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0})):i).map((function(n){return e.createElement("div",{onClick:function(){return function(e){C(e),c(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,c=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(){i().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:c,defaultValue:u,inputClassName:r})))},m=function(t){var o=t.containerClassName,r=t.inputClassName,i=t.onTextChange,c=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:i,defaultValue:c,inputClassName:r})))},h=function(t){var o=t.containerClassName,r=t.inputClassName,i=t.onTextChange,c=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:i,defaultValue:c,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,i=o.options,c=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(),g=v[0],w=v[1],C=n(""),E=C[0],N=C[1],y=t(null),b=t(null);a((function(){s&&w(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!!g&&g.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),w(void 0),l&&l(e)},value:g?"".concat(d?g.native:g.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?i.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0})):i).map((function(n){return e.createElement("div",{onClick:function(){return function(e){w(e),c(e)}(n)},key:n.code,className:"".concat("stdropdown-item"," ").concat(x(n)&&"selected")},d?n.native:n.name)}))))},g=function(t){var o=t.containerClassName,r=t.inputClassName,i=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(){c().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:i,defaultValue:u,inputClassName:r})))};export{h as CitySelect,f as CountrySelect,l as GetCity,i as GetCountries,c as GetLanguages,u as GetState,g as LanguageSelect,m 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 i(e){try{u(a.next(e))}catch(e){r(e)}}function c(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(i,c)}u((a=a.apply(e,n||[])).next())}))}function r(e,n){var t,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(u){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;r&&(r=0,c[0]&&(i=0)),i;)try{if(t=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=n.call(e,i)}catch(e){c=[6,e],a=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var 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://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},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://venkatmcajj.github.io/react-country-state-city/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://venkatmcajj.github.io/react-country-state-city/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,i;return r(this,(function(r){switch(r.label){case 0:return[4,fetch("https://venkatmcajj.github.io/react-country-state-city/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,(i=o.find((function(e){return e.id===n})))&&i.cities?i.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,i=o.options,c=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],g=n(),w=g[0],C=g[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!!w&&w.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:w?"".concat(m&&"emoji"in w?w.emoji:""," ").concat(w.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?i.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0})):i).map((function(n){return e.createElement("div",{onClick:function(){return function(e){C(e),c(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,c=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(){i().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:c,defaultValue:u,inputClassName:r})))},m=function(t){var o=t.containerClassName,r=t.inputClassName,i=t.onTextChange,c=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:i,defaultValue:c,inputClassName:r})))},h=function(t){var o=t.containerClassName,r=t.inputClassName,i=t.onTextChange,c=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:i,defaultValue:c,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,i=o.options,c=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(),g=v[0],w=v[1],C=n(""),E=C[0],N=C[1],y=t(null),b=t(null);a((function(){s&&w(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!!g&&g.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),w(void 0),l&&l(e)},value:g?"".concat(d?g.native:g.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?i.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0})):i).map((function(n){return e.createElement("div",{onClick:function(){return function(e){w(e),c(e)}(n)},key:n.code,className:"".concat("stdropdown-item"," ").concat(x(n)&&"selected")},d?n.native:n.name)}))))},g=function(t){var o=t.containerClassName,r=t.inputClassName,i=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(){c().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:i,defaultValue:u,inputClassName:r})))};export{h as CitySelect,f as CountrySelect,l as GetCity,i as GetCountries,c as GetLanguages,u as GetState,g 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://venkatmcajj.github.io/react-country-state-city/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://venkatmcajj.github.io/react-country-state-city/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://venkatmcajj.github.io/react-country-state-city/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://venkatmcajj.github.io/react-country-state-city/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],E=g[1],w=t.useRef(null),y=t.useRef(null);t.useEffect((function(){i&&v(i)}),[i]),t.useEffect((function(){E(""),d&&w.current&&w.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){E(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:w}),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],E=t.useRef(null),w=t.useRef(null);t.useEffect((function(){i&&h(i)}),[i]),t.useEffect((function(){C(""),f&&E.current&&E.current.focus()}),[f]),t.useEffect((function(){var e=function(e){w.current&&!w.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:w,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:E}),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})))}}));
!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://venkatmcajj.github.io/react-country-state-city/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://venkatmcajj.github.io/react-country-state-city/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://venkatmcajj.github.io/react-country-state-city/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://venkatmcajj.github.io/react-country-state-city/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],E=g[1],w=t.useRef(null),y=t.useRef(null);t.useEffect((function(){i&&v(i)}),[i]),t.useEffect((function(){E(""),d&&w.current&&w.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){E(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:w}),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],E=t.useRef(null),w=t.useRef(null);t.useEffect((function(){i&&h(i)}),[i]),t.useEffect((function(){C(""),f&&E.current&&E.current.focus()}),[f]),t.useEffect((function(){var e=function(e){w.current&&!w.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:w,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:E}),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.1.0",
"version": "1.1.2",
"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.",

@@ -56,5 +56,7 @@ "main": "dist/cjs/index.js",

"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-image": "^3.0.3",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-terser": "^0.4.1",
"@rollup/plugin-url": "^8.0.2",
"@testing-library/react": "^14.0.0",

@@ -83,2 +85,3 @@ "@types/jest": "^29.5.1",

"rollup": "^3.21.6",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-peer-deps-external": "^2.2.4",

@@ -85,0 +88,0 @@ "rollup-plugin-postcss": "^4.0.2",

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

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