react-country-state-city
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -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],h=e.useState(),p=h[0],v=h[1],w=e.useState(""),C=w[0],g=w[1],y=e.useRef(null),E=e.useRef(null);e.useEffect((function(){u&&v(u)}),[u]),e.useEffect((function(){g(""),d&&y.current&&y.current.focus()}),[d]),e.useEffect((function(){var e=function(e){E.current&&!E.current.contains(e.target)&&m(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var b=function(e){return!!p&&p.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:E,onClick:function(){m(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",{className:o,onChange:function(e){g(e.target.value),v(void 0),i&&i(e)},value:p?"".concat(l&&"emoji"in p?p.emoji:""," ").concat(p.name):C||"",placeholder:n,ref:y}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(c,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),r(e)}(t)},key:t.id,className:"".concat("stdropdown-item"," ").concat(b(t)&&"selected")},l&&e.createElement("span",null,"emoji"in t?t.emoji:"")," ",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],h=d[1];return e.useEffect((function(){s&&o(s,l).then((function(e){h(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.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(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})))}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{useState as n,useRef as t,useEffect as a}from"react";function r(e,n,t,a){return new(t||(t=Promise))((function(r,o){function i(e){try{u(a.next(e))}catch(e){o(e)}}function c(e){try{u(a.throw(e))}catch(e){o(e)}}function u(e){var n;e.done?r(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 o(e,n){var t,a,r,o,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(u){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(i=0)),i;)try{if(t=1,a&&(r=2&c[0]?a.return:c[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,c[1])).done)return r;switch(a=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=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(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(e,i)}catch(e){c=[6,e],a=0}finally{t=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}var i=function(){return r(void 0,void 0,void 0,(function(){return o(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()]}}))}))},c=function(e){return r(void 0,void 0,void 0,(function(){var n,t;return o(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 r(void 0,void 0,void 0,(function(){var t,a,r,i;return o(this,(function(o){switch(o.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=o.sent(),(a=t.find((function(n){return n.id===e})))?(r=a&&a.states?a.states:[],[2,(i=r.find((function(e){return e.id===n})))&&i.cities?i.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(r){var o=r.placeHolder,i=r.options,c=r.onChange,u=r.inputClassName,s=r.onTextChange,f=r.defaultValue,d=r.showFlag,m=void 0===d||d,h=n(!1),p=h[0],v=h[1],w=n(),g=w[0],C=w[1],y=n(""),E=y[0],b=y[1],N=t(null),j=t(null);a((function(){f&&C(f)}),[f]),a((function(){b(""),p&&N.current&&N.current.focus()}),[p]),a((function(){var e=function(e){j.current&&!j.current.contains(e.target)&&v(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var x=function(e){return!!g&&g.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:j,onClick:function(){v(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",{className:u,onChange:function(e){b(e.target.value),C(void 0),s&&s(e)},value:g?"".concat(m&&"emoji"in g?g.emoji:""," ").concat(g.name):E||"",placeholder:o,ref:N}),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(l,null)))),p&&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){C(e),c(e)}(n)},key:n.id,className:"".concat("stdropdown-item"," ").concat(x(n)&&"selected")},m&&e.createElement("span",null,"emoji"in n?n.emoji:"")," ",n.name)}))))},f=function(t){var r=t.containerClassName,o=t.inputClassName,c=t.onTextChange,u=t.defaultValue,l=t.onChange,f=t.placeHolder,d=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:r,style:{position:"relative"}},e.createElement(s,{placeHolder:f,options:h,onChange:function(e){l&&l(e)},showFlag:d,onTextChange:c,defaultValue:u,inputClassName:o})))},d=function(t){var r=t.containerClassName,o=t.inputClassName,i=t.onTextChange,u=t.defaultValue,l=t.onChange,f=t.countryid,d=t.placeHolder,m=n([]),h=m[0],p=m[1];return a((function(){f&&c(f).then((function(e){p(e)}))}),[f]),e.createElement(e.Fragment,null,e.createElement("div",{className:r,style:{position:"relative"}},e.createElement(s,{placeHolder:d,options:h,onChange:function(e){l&&l(e)},onTextChange:i,defaultValue:u,inputClassName:o})))},m=function(t){var r=t.containerClassName,o=t.inputClassName,i=t.onTextChange,c=t.defaultValue,l=t.onChange,f=t.countryid,d=t.stateid,m=t.placeHolder,h=n([]),p=h[0],v=h[1];return a((function(){f&&u(f,d).then((function(e){v(e)}))}),[f,d]),e.createElement(e.Fragment,null,e.createElement("div",{className:r,style:{position:"relative"}},e.createElement(s,{placeHolder:m,options:p,onChange:function(e){l&&l(e)},onTextChange:i,defaultValue:c,inputClassName:o})))};export{m as CitySelect,f as CountrySelect,u as GetCity,i as GetCountries,c as GetState,d 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(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}; | ||
//# 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 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 t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}u((a=a.apply(e,t||[])).next())}))}function a(e,t){var n,a,o,r,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,c[0]&&(i=0)),i;)try{if(n=1,a&&(o=2&c[0]?a.return:c[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,c[1])).done)return o;switch(a=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,a=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],a=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,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:[]]}}))}))},i=function(e,t){return n(void 0,void 0,void 0,(function(){var n,o,r,i;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,(i=r.find((function(e){return e.id===t})))&&i.cities?i.cities:[]]):[2,[]]}}))}))},c=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,i=e.onTextChange,u=e.defaultValue,s=e.showFlag,l=void 0===s||s,f=t.useState(!1),d=f[0],m=f[1],h=t.useState(),p=h[0],v=h[1],y=t.useState(""),C=y[0],g=y[1],w=t.useRef(null),E=t.useRef(null);t.useEffect((function(){u&&v(u)}),[u]),t.useEffect((function(){g(""),d&&w.current&&w.current.focus()}),[d]),t.useEffect((function(){var e=function(e){E.current&&!E.current.contains(e.target)&&m(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var b=function(e){return!!p&&p.id===e.id};return t.createElement("div",{className:"stdropdown-container"},t.createElement("div",{ref:E,onClick:function(){m(!0)},className:"stdropdown-input stsearch-box"},t.createElement("input",{className:r,onChange:function(e){g(e.target.value),v(void 0),i&&i(e)},value:p?"".concat(l&&"emoji"in p?p.emoji:""," ").concat(p.name):C||"",placeholder:n,ref:w}),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(c,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(b(e)&&"selected")},l&&t.createElement("span",null,"emoji"in e?e.emoji:"")," ",e.name)}))))};e.CitySelect=function(e){var n=e.containerClassName,a=e.inputClassName,o=e.onTextChange,r=e.defaultValue,c=e.onChange,s=e.countryid,l=e.stateid,f=e.placeHolder,d=t.useState([]),m=d[0],h=d[1];return t.useEffect((function(){s&&i(s,l).then((function(e){h(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){c&&c(e)},onTextChange:o,defaultValue:r,inputClassName:a})))},e.CountrySelect=function(e){var n=e.containerClassName,a=e.inputClassName,r=e.onTextChange,i=e.defaultValue,c=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){c&&c(e)},showFlag:l,onTextChange:r,defaultValue:i,inputClassName:a})))},e.GetCity=i,e.GetCountries=o,e.GetState=r,e.StateSelect=function(e){var n=e.containerClassName,a=e.inputClassName,o=e.onTextChange,i=e.defaultValue,c=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){c&&c(e)},onTextChange:o,defaultValue:i,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(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})))}})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-country-state-city", | ||
"version": "1.0.4", | ||
"description": "React-country-state-city allows you to create a Select dropdown for countries, states, cities with search options.", | ||
"version": "1.0.5", | ||
"description": "React-country-state-city allows you to create a Select dropdown for countries, states, cities with search options.And also provide the language select bar.", | ||
"main": "dist/cjs/index.js", | ||
@@ -37,3 +37,7 @@ "module": "dist/esm/index.js", | ||
"state select", | ||
"city select" | ||
"city select", | ||
"language", | ||
"language select", | ||
"multilingual", | ||
"multi language" | ||
], | ||
@@ -40,0 +44,0 @@ "author": "Venkatesh", |
@@ -109,2 +109,16 @@ # React-country-state-city | ||
## The Language Select Properties | ||
Properties used to customise the rendering: | ||
| Name | Type | Description | | ||
| ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| defaultValue | Country | `optional` The current value: a country object | | ||
| containerClassName | string | `optional` styles for a container | | ||
| inputClassName | string | `optional` styles for input box | | ||
| onChange | function | `optional` The current value: a country object.The argument is the country object | | ||
| onTextChange | function | `optional` A callback fired when the input text changes. | | ||
| placeHolder | string | `optional` Placeholder text displayed in empty input | | ||
| displayNative | boolean | `optional` value are used to display the languages in native language when is true and display in english when is false. default is false. | | ||
## Demo | ||
@@ -118,4 +132,8 @@ | ||
## Financial Contributors | ||
Become a financial contributor and help us sustain our community. [Contribute](https://opencollective.com/react-country-state-city) | ||
## License | ||
Licensed under MIT |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
106142
175
138
12