react-country-state-city
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -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"),t=function(){return t=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}function a(e,t,n,a){return new(n||(n=Promise))((function(o,r){function 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 o(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 r=function(){return a(void 0,void 0,void 0,(function(){return o(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 a(void 0,void 0,void 0,(function(){return o(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()]}}))}))},i=function(e){return a(void 0,void 0,void 0,(function(){var t,n;return o(this,(function(a){switch(a.label){case 0:return[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:[]]}}))}))},u=function(e,t){return a(void 0,void 0,void 0,(function(){var n,a,r,c;return o(this,(function(o){switch(o.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=o.sent(),(a=n.find((function(t){return t.id===e})))?(r=a&&a.states?a.states:[],[2,(c=r.find((function(e){return e.id===t})))&&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(a){var o=a.placeHolder,r=a.options,c=a.onChange,i=a.inputClassName,u=a.onTextChange,s=a.defaultValue,f=a.showFlag,d=void 0===f||f,p=n(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),m=e.useState(!1),h=m[0],v=m[1],C=e.useState(),g=C[0],y=C[1],w=e.useState(""),E=w[0],N=w[1],x=e.useRef(null),b=e.useRef(null);e.useEffect((function(){s&&y(s)}),[s]),e.useEffect((function(){N(""),h&&x.current&&x.current.focus()}),[h]),e.useEffect((function(){var e=function(e){b.current&&!b.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:b,onClick:function(){v(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",t({},p,{className:i,onChange:function(e){N(e.target.value),y(void 0),u&&u(e)},value:g?"".concat(d&&"emoji"in g?g.emoji:""," ").concat(g.name):E||"",placeholder:o,ref:x})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(l,null)))),h&&e.createElement("div",{className:"stdropdown-menu"},(E?r.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0})):r).map((function(t){return e.createElement("div",{onClick:function(){return function(e){y(e),c(e)}(t)},key:t.id,className:"".concat("stdropdown-item"," ").concat(j(t)&&"selected")},d&&e.createElement("span",null,"emoji"in t?t.emoji:""),t.name)}))))},f=function(){return e.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},e.createElement("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},d=function(a){var o=a.placeHolder,r=a.options,c=a.onChange,i=a.inputClassName,u=a.onTextChange,l=a.defaultValue,s=a.displayNative,d=n(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","displayNative"]),p=e.useState(!1),m=p[0],h=p[1],v=e.useState(),C=v[0],g=v[1],y=e.useState(""),w=y[0],E=y[1],N=e.useRef(null),x=e.useRef(null);e.useEffect((function(){l&&g(l)}),[l]),e.useEffect((function(){E(""),m&&N.current&&N.current.focus()}),[m]),e.useEffect((function(){var e=function(e){x.current&&!x.current.contains(e.target)&&h(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var b=function(e){return!!C&&C.code===e.code};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:x,onClick:function(){h(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",t({},d,{className:i,onChange:function(e){E(e.target.value),g(void 0),u&&u(e)},value:C?"".concat(s?C.native:C.name):w||"",placeholder:o,ref:N})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(f,null)))),m&&e.createElement("div",{className:"stdropdown-menu"},(w?r.filter((function(e){return e.name.toLowerCase().indexOf(w.toLowerCase())>=0})):r).map((function(t){return e.createElement("div",{onClick:function(){return function(e){g(e),c(e)}(t)},key:t.code,className:"".concat("stdropdown-item"," ").concat(b(t)&&"selected")},s?t.native:t.name)}))))};exports.CitySelect=function(a){var o=a.containerClassName,r=a.inputClassName,c=a.onTextChange,i=a.defaultValue,l=a.onChange,f=a.countryid,d=a.stateid,p=a.placeHolder,m=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder"]),h=e.useState([]),v=h[0],C=h[1];return e.useEffect((function(){f&&u(f,d).then((function(e){C(e)}))}),[f,d]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(s,t({},m,{placeHolder:p,options:v,onChange:function(e){l&&l(e)},onTextChange:c,defaultValue:i,inputClassName:r}))))},exports.CountrySelect=function(a){var o=a.containerClassName,c=a.inputClassName,i=a.onTextChange,u=a.defaultValue,l=a.onChange,f=a.placeHolder,d=a.showFlag,p=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag"]),m=e.useState([]),h=m[0],v=m[1];return e.useEffect((function(){r().then((function(e){v(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(s,t({},p,{placeHolder:f,options:h,onChange:function(e){l&&l(e)},showFlag:d,onTextChange:i,defaultValue:u,inputClassName:c}))))},exports.GetCity=u,exports.GetCountries=r,exports.GetLanguages=c,exports.GetState=i,exports.LanguageSelect=function(a){var o=a.containerClassName,r=a.inputClassName,i=a.onTextChange,u=a.defaultValue,l=a.onChange,s=a.placeHolder,f=a.displayNative,p=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","displayNative"]),m=e.useState([]),h=m[0],v=m[1];return e.useEffect((function(){c().then((function(e){v(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,t({},p,{placeHolder:s,options:h,onChange:function(e){l&&l(e)},displayNative:f,onTextChange:i,defaultValue:u,inputClassName:r}))))},exports.StateSelect=function(a){var o=a.containerClassName,r=a.inputClassName,c=a.onTextChange,u=a.defaultValue,l=a.onChange,f=a.countryid,d=a.placeHolder,p=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder"]),m=e.useState([]),h=m[0],v=m[1];return e.useEffect((function(){f&&i(f).then((function(e){v(e)}))}),[f]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(s,t({},p,{placeHolder:d,options:h,onChange:function(e){l&&l(e)},onTextChange:c,defaultValue:u,inputClassName:r}))))}; | ||
//# 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";var o=function(){return o=Object.assign||function(e){for(var n,t=1,a=arguments.length;t<a;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},o.apply(this,arguments)};function r(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)n.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(t[a[o]]=e[a[o]])}return t}function i(e,n,t,a){return new(t||(t=Promise))((function(o,r){function i(e){try{l(a.next(e))}catch(e){r(e)}}function c(e){try{l(a.throw(e))}catch(e){r(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,c)}l((a=a.apply(e,n||[])).next())}))}function c(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(l){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,l])}}}var l=function(){return i(void 0,void 0,void 0,(function(){return c(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()]}}))}))},u=function(){return i(void 0,void 0,void 0,(function(){return c(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()]}}))}))},s=function(e){return i(void 0,void 0,void 0,(function(){var n,t;return c(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:[]]}}))}))},d=function(e,n){return i(void 0,void 0,void 0,(function(){var t,a,o,r;return c(this,(function(i){switch(i.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=i.sent(),(a=t.find((function(n){return n.id===e})))?(o=a&&a.states?a.states:[],[2,(r=o.find((function(e){return e.id===n})))&&r.cities?r.cities:[]]):[2,[]]}}))}))},f=function(){return e.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},e.createElement("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},m=function(i){var c=i.placeHolder,l=i.options,u=i.onChange,s=i.inputClassName,d=i.onTextChange,m=i.defaultValue,p=i.showFlag,h=void 0===p||p,v=r(i,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),C=n(!1),g=C[0],w=C[1],y=n(),N=y[0],E=y[1],b=n(""),x=b[0],j=b[1],k=t(null),T=t(null);a((function(){m&&E(m)}),[m]),a((function(){j(""),g&&k.current&&k.current.focus()}),[g]),a((function(){var e=function(e){T.current&&!T.current.contains(e.target)&&w(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var H=function(e){return!!N&&N.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:T,onClick:function(){w(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",o({},v,{className:s,onChange:function(e){j(e.target.value),E(void 0),d&&d(e)},value:N?"".concat(h&&"emoji"in N?N.emoji:""," ").concat(N.name):x||"",placeholder:c,ref:k})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(f,null)))),g&&e.createElement("div",{className:"stdropdown-menu"},(x?l.filter((function(e){return e.name.toLowerCase().indexOf(x.toLowerCase())>=0})):l).map((function(n){return e.createElement("div",{onClick:function(){return function(e){E(e),u(e)}(n)},key:n.id,className:"".concat("stdropdown-item"," ").concat(H(n)&&"selected")},h&&e.createElement("span",null,"emoji"in n?n.emoji:""),n.name)}))))},p=function(t){var i=t.containerClassName,c=t.inputClassName,u=t.onTextChange,s=t.defaultValue,d=t.onChange,f=t.placeHolder,p=t.showFlag,h=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag"]),v=n([]),C=v[0],g=v[1];return a((function(){l().then((function(e){g(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(m,o({},h,{placeHolder:f,options:C,onChange:function(e){d&&d(e)},showFlag:p,onTextChange:u,defaultValue:s,inputClassName:c}))))},h=function(t){var i=t.containerClassName,c=t.inputClassName,l=t.onTextChange,u=t.defaultValue,d=t.onChange,f=t.countryid,p=t.placeHolder,h=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder"]),v=n([]),C=v[0],g=v[1];return a((function(){f&&s(f).then((function(e){g(e)}))}),[f]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(m,o({},h,{placeHolder:p,options:C,onChange:function(e){d&&d(e)},onTextChange:l,defaultValue:u,inputClassName:c}))))},v=function(t){var i=t.containerClassName,c=t.inputClassName,l=t.onTextChange,u=t.defaultValue,s=t.onChange,f=t.countryid,p=t.stateid,h=t.placeHolder,v=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder"]),C=n([]),g=C[0],w=C[1];return a((function(){f&&d(f,p).then((function(e){w(e)}))}),[f,p]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(m,o({},v,{placeHolder:h,options:g,onChange:function(e){s&&s(e)},onTextChange:l,defaultValue:u,inputClassName:c}))))},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"}))},g=function(i){var c=i.placeHolder,l=i.options,u=i.onChange,s=i.inputClassName,d=i.onTextChange,f=i.defaultValue,m=i.displayNative,p=r(i,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","displayNative"]),h=n(!1),v=h[0],g=h[1],w=n(),y=w[0],N=w[1],E=n(""),b=E[0],x=E[1],j=t(null),k=t(null);a((function(){f&&N(f)}),[f]),a((function(){x(""),v&&j.current&&j.current.focus()}),[v]),a((function(){var e=function(e){k.current&&!k.current.contains(e.target)&&g(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var T=function(e){return!!y&&y.code===e.code};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:k,onClick:function(){g(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",o({},p,{className:s,onChange:function(e){x(e.target.value),N(void 0),d&&d(e)},value:y?"".concat(m?y.native:y.name):b||"",placeholder:c,ref:j})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(C,null)))),v&&e.createElement("div",{className:"stdropdown-menu"},(b?l.filter((function(e){return e.name.toLowerCase().indexOf(b.toLowerCase())>=0})):l).map((function(n){return e.createElement("div",{onClick:function(){return function(e){N(e),u(e)}(n)},key:n.code,className:"".concat("stdropdown-item"," ").concat(T(n)&&"selected")},m?n.native:n.name)}))))},w=function(t){var i=t.containerClassName,c=t.inputClassName,l=t.onTextChange,s=t.defaultValue,d=t.onChange,f=t.placeHolder,m=t.displayNative,p=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","displayNative"]),h=n([]),v=h[0],C=h[1];return a((function(){u().then((function(e){C(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(g,o({},p,{placeHolder:f,options:v,onChange:function(e){d&&d(e)},displayNative:m,onTextChange:l,defaultValue:s,inputClassName:c}))))};export{v as CitySelect,p as CountrySelect,d as GetCity,l as GetCountries,u as GetLanguages,s as GetState,w as LanguageSelect,h 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";var n=function(){return n=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function a(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}function o(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 r(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 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 t,n;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 t=a.sent(),n=t.find((function(t){return t.id===e})),[2,n&&n.states?n.states:[]]}}))}))},l=function(e,t){return o(void 0,void 0,void 0,(function(){var n,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 n=r.sent(),(a=n.find((function(t){return t.id===e})))?(o=a&&a.states?a.states:[],[2,(i=o.find((function(e){return e.id===t})))&&i.cities?i.cities:[]]):[2,[]]}}))}))},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"}))},f=function(e){var o=e.placeHolder,r=e.options,i=e.onChange,c=e.inputClassName,u=e.onTextChange,l=e.defaultValue,f=e.showFlag,d=void 0===f||f,p=a(e,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),m=t.useState(!1),h=m[0],v=m[1],C=t.useState(),g=C[0],y=C[1],w=t.useState(""),E=w[0],N=w[1],b=t.useRef(null),x=t.useRef(null);t.useEffect((function(){l&&y(l)}),[l]),t.useEffect((function(){N(""),h&&b.current&&b.current.focus()}),[h]),t.useEffect((function(){var e=function(e){x.current&&!x.current.contains(e.target)&&v(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var j=function(e){return!!g&&g.id===e.id};return t.createElement("div",{className:"stdropdown-container"},t.createElement("div",{ref:x,onClick:function(){v(!0)},className:"stdropdown-input stsearch-box"},t.createElement("input",n({},p,{className:c,onChange:function(e){N(e.target.value),y(void 0),u&&u(e)},value:g?"".concat(d&&"emoji"in g?g.emoji:""," ").concat(g.name):E||"",placeholder:o,ref:b})),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(s,null)))),h&&t.createElement("div",{className:"stdropdown-menu"},(E?r.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0})):r).map((function(e){return t.createElement("div",{onClick:function(){return function(e){y(e),i(e)}(e)},key:e.id,className:"".concat("stdropdown-item"," ").concat(j(e)&&"selected")},d&&t.createElement("span",null,"emoji"in e?e.emoji:""),e.name)}))))},d=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"}))},p=function(e){var o=e.placeHolder,r=e.options,i=e.onChange,c=e.inputClassName,u=e.onTextChange,l=e.defaultValue,s=e.displayNative,f=a(e,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","displayNative"]),p=t.useState(!1),m=p[0],h=p[1],v=t.useState(),C=v[0],g=v[1],y=t.useState(""),w=y[0],E=y[1],N=t.useRef(null),b=t.useRef(null);t.useEffect((function(){l&&g(l)}),[l]),t.useEffect((function(){E(""),m&&N.current&&N.current.focus()}),[m]),t.useEffect((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!!C&&C.code===e.code};return t.createElement("div",{className:"stdropdown-container"},t.createElement("div",{ref:b,onClick:function(){h(!0)},className:"stdropdown-input stsearch-box"},t.createElement("input",n({},f,{className:c,onChange:function(e){E(e.target.value),g(void 0),u&&u(e)},value:C?"".concat(s?C.native:C.name):w||"",placeholder:o,ref:N})),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(d,null)))),m&&t.createElement("div",{className:"stdropdown-menu"},(w?r.filter((function(e){return e.name.toLowerCase().indexOf(w.toLowerCase())>=0})):r).map((function(e){return t.createElement("div",{onClick:function(){return function(e){g(e),i(e)}(e)},key:e.code,className:"".concat("stdropdown-item"," ").concat(x(e)&&"selected")},s?e.native:e.name)}))))};e.CitySelect=function(e){var o=e.containerClassName,r=e.inputClassName,i=e.onTextChange,c=e.defaultValue,u=e.onChange,s=e.countryid,d=e.stateid,p=e.placeHolder,m=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder"]),h=t.useState([]),v=h[0],C=h[1];return t.useEffect((function(){s&&l(s,d).then((function(e){C(e)}))}),[s,d]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(f,n({},m,{placeHolder:p,options:v,onChange:function(e){u&&u(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))},e.CountrySelect=function(e){var o=e.containerClassName,r=e.inputClassName,c=e.onTextChange,u=e.defaultValue,l=e.onChange,s=e.placeHolder,d=e.showFlag,p=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag"]),m=t.useState([]),h=m[0],v=m[1];return t.useEffect((function(){i().then((function(e){v(e)}))}),[]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(f,n({},p,{placeHolder:s,options:h,onChange:function(e){l&&l(e)},showFlag:d,onTextChange:c,defaultValue:u,inputClassName:r}))))},e.GetCity=l,e.GetCountries=i,e.GetLanguages=c,e.GetState=u,e.LanguageSelect=function(e){var o=e.containerClassName,r=e.inputClassName,i=e.onTextChange,u=e.defaultValue,l=e.onChange,s=e.placeHolder,f=e.displayNative,d=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","displayNative"]),m=t.useState([]),h=m[0],v=m[1];return t.useEffect((function(){c().then((function(e){v(e)}))}),[]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(p,n({},d,{placeHolder:s,options:h,onChange:function(e){l&&l(e)},displayNative:f,onTextChange:i,defaultValue:u,inputClassName:r}))))},e.StateSelect=function(e){var o=e.containerClassName,r=e.inputClassName,i=e.onTextChange,c=e.defaultValue,l=e.onChange,s=e.countryid,d=e.placeHolder,p=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder"]),m=t.useState([]),h=m[0],v=m[1];return t.useEffect((function(){s&&u(s).then((function(e){v(e)}))}),[s]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(f,n({},p,{placeHolder:d,options:h,onChange:function(e){l&&l(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))}})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-country-state-city", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"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.", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
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
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
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
1592275
197