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

react-country-state-city

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.1.4 to 1.1.5

dist/cjs/components/RegionSelect.d.ts

3

dist/cjs/components/CountrySelect.d.ts

@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react";

showFlag?: boolean;
region?: string;
};
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, ...props }: PageProps) => React.JSX.Element;
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, ...props }: PageProps) => React.JSX.Element;
export default CountrySelect;
import React, { ChangeEvent, InputHTMLAttributes } from "react";
import { City, Country, State } from "../types";
import { City, Country, Region, State } from "../types";
type ComponentProps = InputHTMLAttributes<HTMLInputElement> & {
placeHolder?: string;
options: Array<Country | State | City>;
options: Array<Region | Country | State | City>;
inputClassName?: string;
onTextChange?: (e: ChangeEvent<HTMLInputElement>) => void;
defaultValue?: Country | State | City;
onChange: (e: Country | State | City) => void;
defaultValue?: Region | Country | State | City;
onChange: (e: Region | Country | State | City) => void;
showFlag?: boolean;

@@ -11,0 +11,0 @@ };

@@ -5,4 +5,5 @@ import CountrySelect from "./components/CountrySelect";

import LanguageSelect from "./components/LanguageSelect";
import { GetCountries, GetState, GetCity, GetLanguages } from "./utils";
import RegionSelect from "./components/RegionSelect";
import { GetCountries, GetState, GetCity, GetLanguages, GetRegions } from "./utils";
import "./styles/style.scss";
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, GetCountries, GetState, GetCity, GetLanguages, };
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, GetCountries, GetState, GetCity, GetLanguages, GetRegions, };

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

"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}))))};
"use strict";var e=require("react"),t=function(){return t=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}function a(e,t,n,a){return new(n||(n=Promise))((function(o,r){function i(e){try{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 o(e,t){var n,a,o,r,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function c(c){return function(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 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/regionsminified.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/countriesminified.json").then((function(e){return e.json()}))];case 1:return t=a.sent(),n=t,e&&(n=n.filter((function(t){return t.region===e}))),[2,n]}}))}))},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()]}}))}))},u=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:[]]}}))}))},l=function(e,t){return a(void 0,void 0,void 0,(function(){var n,a,r,i;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,(i=r.find((function(e){return e.id===t})))&&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"}))},f=function(a){var o=a.placeHolder,r=a.options,i=a.onChange,c=a.inputClassName,u=a.onTextChange,l=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],g=e.useState(),C=g[0],y=g[1],E=e.useState(""),N=E[0],w=E[1],x=e.useRef(null),b=e.useRef(null);e.useEffect((function(){l&&y(l)}),[l]),e.useEffect((function(){w(""),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!!C&&C.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:c,onChange:function(e){w(e.target.value),y(void 0),u&&u(e)},value:C?"".concat(d&&"emoji"in C?C.emoji:""," ").concat(C.name):N||"",placeholder:o,ref:x})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(s,null)))),h&&e.createElement("div",{className:"stdropdown-menu"},(N?r.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0})):r).map((function(t){return e.createElement("div",{onClick:function(){return function(e){y(e),i(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)}))))},d=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(a){var o=a.placeHolder,r=a.options,i=a.onChange,c=a.inputClassName,u=a.onTextChange,l=a.defaultValue,s=a.displayNative,f=n(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","displayNative"]),p=e.useState(!1),m=p[0],h=p[1],v=e.useState(),g=v[0],C=v[1],y=e.useState(""),E=y[0],N=y[1],w=e.useRef(null),x=e.useRef(null);e.useEffect((function(){l&&C(l)}),[l]),e.useEffect((function(){N(""),m&&w.current&&w.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!!g&&g.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({},f,{className:c,onChange:function(e){N(e.target.value),C(void 0),u&&u(e)},value:g?"".concat(s?g.native:g.name):E||"",placeholder:o,ref:w})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(d,null)))),m&&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){C(e),i(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,i=a.onTextChange,c=a.defaultValue,u=a.onChange,s=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],g=h[1];return e.useEffect((function(){s&&l(s,d).then((function(e){g(e)}))}),[s,d]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(f,t({},m,{placeHolder:p,options:v,onChange:function(e){u&&u(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))},exports.CountrySelect=function(a){var o=a.containerClassName,r=a.inputClassName,c=a.onTextChange,u=a.defaultValue,l=a.onChange,s=a.placeHolder,d=a.showFlag,p=a.region,m=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region"]),h=e.useState([]),v=h[0],g=h[1];return e.useEffect((function(){i(p).then((function(e){g(e)}))}),[p]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(f,t({},m,{placeHolder:s,options:v,onChange:function(e){l&&l(e)},showFlag:d,onTextChange:c,defaultValue:u,inputClassName:r}))))},exports.GetCity=l,exports.GetCountries=i,exports.GetLanguages=c,exports.GetRegions=r,exports.GetState=u,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,d=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(p,t({},d,{placeHolder:s,options:h,onChange:function(e){l&&l(e)},displayNative:f,onTextChange:i,defaultValue:u,inputClassName:r}))))},exports.RegionSelect=function(a){var o=a.containerClassName,i=a.inputClassName,c=a.onTextChange,u=a.defaultValue,l=a.onChange,s=a.placeHolder,d=n(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder"]),p=e.useState([]),m=p[0],h=p[1];return e.useEffect((function(){r().then((function(e){h(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(f,t({},d,{placeHolder:s,options:m,onChange:function(e){l&&l(e)},onTextChange:c,defaultValue:u,inputClassName:i}))))},exports.StateSelect=function(a){var o=a.containerClassName,r=a.inputClassName,i=a.onTextChange,c=a.defaultValue,l=a.onChange,s=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(){s&&u(s).then((function(e){v(e)}))}),[s]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(f,t({},p,{placeHolder:d,options:h,onChange:function(e){l&&l(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))};
//# sourceMappingURL=index.js.map

@@ -21,2 +21,6 @@ export interface Country {

}
export interface Region {
id: number;
name: string;
}
export interface State {

@@ -23,0 +27,0 @@ id: number;

@@ -1,5 +0,6 @@

import { City, Country, Language, State } from "../types";
export declare const GetCountries: () => Promise<Country[] | []>;
import { City, Country, Language, Region, State } from "../types";
export declare const GetRegions: () => Promise<Region[] | []>;
export declare const GetCountries: (_region?: string) => Promise<Country[] | []>;
export declare const GetLanguages: () => Promise<Language[] | []>;
export declare const GetState: (id: number) => Promise<Array<State> | []>;
export declare const GetCity: (countryid: number, stateid: number) => Promise<Array<City> | []>;

@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react";

showFlag?: boolean;
region?: string;
};
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, ...props }: PageProps) => React.JSX.Element;
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, ...props }: PageProps) => React.JSX.Element;
export default CountrySelect;
import React, { ChangeEvent, InputHTMLAttributes } from "react";
import { City, Country, State } from "../types";
import { City, Country, Region, State } from "../types";
type ComponentProps = InputHTMLAttributes<HTMLInputElement> & {
placeHolder?: string;
options: Array<Country | State | City>;
options: Array<Region | Country | State | City>;
inputClassName?: string;
onTextChange?: (e: ChangeEvent<HTMLInputElement>) => void;
defaultValue?: Country | State | City;
onChange: (e: Country | State | City) => void;
defaultValue?: Region | Country | State | City;
onChange: (e: Region | Country | State | City) => void;
showFlag?: boolean;

@@ -11,0 +11,0 @@ };

@@ -5,4 +5,5 @@ import CountrySelect from "./components/CountrySelect";

import LanguageSelect from "./components/LanguageSelect";
import { GetCountries, GetState, GetCity, GetLanguages } from "./utils";
import RegionSelect from "./components/RegionSelect";
import { GetCountries, GetState, GetCity, GetLanguages, GetRegions } from "./utils";
import "./styles/style.scss";
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, GetCountries, GetState, GetCity, GetLanguages, };
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, GetCountries, GetState, GetCity, GetLanguages, GetRegions, };

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

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};
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/regionsminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},u=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/countriesminified.json").then((function(e){return e.json()}))];case 1:return n=a.sent(),t=n,e&&(t=t.filter((function(n){return n.region===e}))),[2,t]}}))}))},s=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()]}}))}))},d=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:[]]}}))}))},f=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,[]]}}))}))},m=function(){return e.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},e.createElement("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},p=function(i){var c=i.placeHolder,l=i.options,u=i.onChange,s=i.inputClassName,d=i.onTextChange,f=i.defaultValue,p=i.showFlag,h=void 0===p||p,v=r(i,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),g=n(!1),C=g[0],N=g[1],w=n(),y=w[0],E=w[1],b=n(""),x=b[0],j=b[1],T=t(null),k=t(null);a((function(){f&&E(f)}),[f]),a((function(){j(""),C&&T.current&&T.current.focus()}),[C]),a((function(){var e=function(e){k.current&&!k.current.contains(e.target)&&N(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var H=function(e){return!!y&&y.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:k,onClick:function(){N(!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:y?"".concat(h&&"emoji"in y?y.emoji:""," ").concat(y.name):x||"",placeholder:c,ref:T})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(m,null)))),C&&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)}))))},h=function(t){var i=t.containerClassName,c=t.inputClassName,l=t.onTextChange,s=t.defaultValue,d=t.onChange,f=t.placeHolder,m=t.showFlag,h=t.region,v=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region"]),g=n([]),C=g[0],N=g[1];return a((function(){u(h).then((function(e){N(e)}))}),[h]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(p,o({},v,{placeHolder:f,options:C,onChange:function(e){d&&d(e)},showFlag:m,onTextChange:l,defaultValue:s,inputClassName:c}))))},v=function(t){var i=t.containerClassName,c=t.inputClassName,l=t.onTextChange,u=t.defaultValue,s=t.onChange,f=t.countryid,m=t.placeHolder,h=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder"]),v=n([]),g=v[0],C=v[1];return a((function(){f&&d(f).then((function(e){C(e)}))}),[f]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(p,o({},h,{placeHolder:m,options:g,onChange:function(e){s&&s(e)},onTextChange:l,defaultValue:u,inputClassName:c}))))},g=function(t){var i=t.containerClassName,c=t.inputClassName,l=t.onTextChange,u=t.defaultValue,s=t.onChange,d=t.countryid,m=t.stateid,h=t.placeHolder,v=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder"]),g=n([]),C=g[0],N=g[1];return a((function(){d&&f(d,m).then((function(e){N(e)}))}),[d,m]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(p,o({},v,{placeHolder:h,options:C,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"}))},N=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],N=n(),w=N[0],y=N[1],E=n(""),b=E[0],x=E[1],j=t(null),T=t(null);a((function(){f&&y(f)}),[f]),a((function(){x(""),v&&j.current&&j.current.focus()}),[v]),a((function(){var e=function(e){T.current&&!T.current.contains(e.target)&&g(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var k=function(e){return!!w&&w.code===e.code};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:T,onClick:function(){g(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",o({},p,{className:s,onChange:function(e){x(e.target.value),y(void 0),d&&d(e)},value:w?"".concat(m?w.native:w.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){y(e),u(e)}(n)},key:n.code,className:"".concat("stdropdown-item"," ").concat(k(n)&&"selected")},m?n.native:n.name)}))))},w=function(t){var i=t.containerClassName,c=t.inputClassName,l=t.onTextChange,u=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],g=h[1];return a((function(){s().then((function(e){g(e)}))}),[]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(N,o({},p,{placeHolder:f,options:v,onChange:function(e){d&&d(e)},displayNative:m,onTextChange:l,defaultValue:u,inputClassName:c}))))},y=function(t){var i=t.containerClassName,c=t.inputClassName,u=t.onTextChange,s=t.defaultValue,d=t.onChange,f=t.placeHolder,m=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder"]),h=n([]),v=h[0],g=h[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(p,o({},m,{placeHolder:f,options:v,onChange:function(e){d&&d(e)},onTextChange:u,defaultValue:s,inputClassName:c}))))};export{g as CitySelect,h as CountrySelect,f as GetCity,u as GetCountries,s as GetLanguages,l as GetRegions,d as GetState,w as LanguageSelect,y as RegionSelect,v as StateSelect};
//# sourceMappingURL=index.js.map

@@ -21,2 +21,6 @@ export interface Country {

}
export interface Region {
id: number;
name: string;
}
export interface State {

@@ -23,0 +27,0 @@ id: number;

@@ -1,5 +0,6 @@

import { City, Country, Language, State } from "../types";
export declare const GetCountries: () => Promise<Country[] | []>;
import { City, Country, Language, Region, State } from "../types";
export declare const GetRegions: () => Promise<Region[] | []>;
export declare const GetCountries: (_region?: string) => Promise<Country[] | []>;
export declare const GetLanguages: () => Promise<Language[] | []>;
export declare const GetState: (id: number) => Promise<Array<State> | []>;
export declare const GetCity: (countryid: number, stateid: number) => Promise<Array<City> | []>;

@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react";

showFlag?: boolean;
region?: string;
};
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, ...props }: PageProps) => React.JSX.Element;
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, ...props }: PageProps) => React.JSX.Element;
export default CountrySelect;
import React, { ChangeEvent, InputHTMLAttributes } from "react";
import { City, Country, State } from "../types";
import { City, Country, Region, State } from "../types";
type ComponentProps = InputHTMLAttributes<HTMLInputElement> & {
placeHolder?: string;
options: Array<Country | State | City>;
options: Array<Region | Country | State | City>;
inputClassName?: string;
onTextChange?: (e: ChangeEvent<HTMLInputElement>) => void;
defaultValue?: Country | State | City;
onChange: (e: Country | State | City) => void;
defaultValue?: Region | Country | State | City;
onChange: (e: Region | Country | State | City) => void;
showFlag?: boolean;

@@ -11,0 +11,0 @@ };

@@ -5,4 +5,5 @@ import CountrySelect from "./components/CountrySelect";

import LanguageSelect from "./components/LanguageSelect";
import { GetCountries, GetState, GetCity, GetLanguages } from "./utils";
import RegionSelect from "./components/RegionSelect";
import { GetCountries, GetState, GetCity, GetLanguages, GetRegions } from "./utils";
import "./styles/style.scss";
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, GetCountries, GetState, GetCity, GetLanguages, };
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, GetCountries, GetState, GetCity, GetLanguages, GetRegions, };

@@ -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";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}))))}}));
!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/regionsminified.json").then((function(e){return e.json()}))];case 1:return[2,e.sent()]}}))}))},c=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/countriesminified.json").then((function(e){return e.json()}))];case 1:return t=a.sent(),n=t,e&&(n=n.filter((function(t){return t.region===e}))),[2,n]}}))}))},u=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()]}}))}))},l=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:[]]}}))}))},s=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,[]]}}))}))},f=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"}))},d=function(e){var o=e.placeHolder,r=e.options,i=e.onChange,c=e.inputClassName,u=e.onTextChange,l=e.defaultValue,s=e.showFlag,d=void 0===s||s,m=a(e,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),p=t.useState(!1),h=p[0],v=p[1],g=t.useState(),C=g[0],y=g[1],E=t.useState(""),N=E[0],w=E[1],b=t.useRef(null),x=t.useRef(null);t.useEffect((function(){l&&y(l)}),[l]),t.useEffect((function(){w(""),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!!C&&C.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({},m,{className:c,onChange:function(e){w(e.target.value),y(void 0),u&&u(e)},value:C?"".concat(d&&"emoji"in C?C.emoji:""," ").concat(C.name):N||"",placeholder:o,ref:b})),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(f,null)))),h&&t.createElement("div",{className:"stdropdown-menu"},(N?r.filter((function(e){return e.name.toLowerCase().indexOf(N.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)}))))},m=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"]),d=t.useState(!1),p=d[0],h=d[1],v=t.useState(),g=v[0],C=v[1],y=t.useState(""),E=y[0],N=y[1],w=t.useRef(null),b=t.useRef(null);t.useEffect((function(){l&&C(l)}),[l]),t.useEffect((function(){N(""),p&&w.current&&w.current.focus()}),[p]),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!!g&&g.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){N(e.target.value),C(void 0),u&&u(e)},value:g?"".concat(s?g.native:g.name):E||"",placeholder:o,ref:w})),t.createElement("div",{className:"stdropdown-tools"},t.createElement("div",{className:"stdropdown-tool"},t.createElement(m,null)))),p&&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){C(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,l=e.countryid,f=e.stateid,m=e.placeHolder,p=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder"]),h=t.useState([]),v=h[0],g=h[1];return t.useEffect((function(){l&&s(l,f).then((function(e){g(e)}))}),[l,f]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(d,n({},p,{placeHolder:m,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,i=e.onTextChange,u=e.defaultValue,l=e.onChange,s=e.placeHolder,f=e.showFlag,m=e.region,p=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region"]),h=t.useState([]),v=h[0],g=h[1];return t.useEffect((function(){c(m).then((function(e){g(e)}))}),[m]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(d,n({},p,{placeHolder:s,options:v,onChange:function(e){l&&l(e)},showFlag:f,onTextChange:i,defaultValue:u,inputClassName:r}))))},e.GetCity=s,e.GetCountries=c,e.GetLanguages=u,e.GetRegions=i,e.GetState=l,e.LanguageSelect=function(e){var o=e.containerClassName,r=e.inputClassName,i=e.onTextChange,c=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(){u().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:c,inputClassName:r}))))},e.RegionSelect=function(e){var o=e.containerClassName,r=e.inputClassName,c=e.onTextChange,u=e.defaultValue,l=e.onChange,s=e.placeHolder,f=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder"]),m=t.useState([]),p=m[0],h=m[1];return t.useEffect((function(){i().then((function(e){h(e)}))}),[]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(d,n({},f,{placeHolder:s,options:p,onChange:function(e){l&&l(e)},onTextChange:c,defaultValue:u,inputClassName:r}))))},e.StateSelect=function(e){var o=e.containerClassName,r=e.inputClassName,i=e.onTextChange,c=e.defaultValue,u=e.onChange,s=e.countryid,f=e.placeHolder,m=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder"]),p=t.useState([]),h=p[0],v=p[1];return t.useEffect((function(){s&&l(s).then((function(e){v(e)}))}),[s]),t.createElement(t.Fragment,null,t.createElement("div",{className:o,style:{position:"relative"}},t.createElement(d,n({},m,{placeHolder:f,options:h,onChange:function(e){u&&u(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))}}));
//# sourceMappingURL=index.js.map

@@ -21,2 +21,6 @@ export interface Country {

}
export interface Region {
id: number;
name: string;
}
export interface State {

@@ -23,0 +27,0 @@ id: number;

@@ -1,5 +0,6 @@

import { City, Country, Language, State } from "../types";
export declare const GetCountries: () => Promise<Country[] | []>;
import { City, Country, Language, Region, State } from "../types";
export declare const GetRegions: () => Promise<Region[] | []>;
export declare const GetCountries: (_region?: string) => Promise<Country[] | []>;
export declare const GetLanguages: () => Promise<Language[] | []>;
export declare const GetState: (id: number) => Promise<Array<State> | []>;
export declare const GetCity: (countryid: number, stateid: number) => Promise<Array<City> | []>;
{
"name": "react-country-state-city",
"version": "1.1.4",
"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.",
"version": "1.1.5",
"description": "A lightweight and easy-to-use React library that provides a comprehensive list of regions or continents, countries, states, cities and languages for creating dynamic and searchable dropdowns. Ideal for building forms and input fields that require accurate and up-to-date geographical selections, with seamless integration for improved user experience.",
"main": "dist/cjs/index.js",

@@ -46,3 +46,9 @@ "module": "dist/esm/index.js",

"multilingual",
"multi-language"
"multi-language",
"region",
"region-list",
"region-select",
"continent",
"continent-list",
"continent-select"
],

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

@@ -16,2 +16,3 @@ # React-country-state-city

LanguageSelect,
RegionSelect
} from "react-country-state-city";

@@ -33,2 +34,3 @@

- Language dropdown to list and search all languages in English and native too.
- Regions or Continents dropdown to list and search all the regions from the world.

@@ -45,2 +47,3 @@ ## The gist

LanguageSelect,
RegionSelect
} from "react-country-state-city";

@@ -50,2 +53,3 @@ import "react-country-state-city/dist/react-country-state-city.css";

function App() {
const [region, setRegion] = useState("");
const [countryid, setCountryid] = useState(0);

@@ -55,2 +59,9 @@ const [stateid, setstateid] = useState(0);

<div>
<h6>Region / Continent</h6>
<RegionSelect
onChange={(e) => {
setRegion(e.name);
}}
placeHolder="Select Region"
/>
<h6>Country</h6>

@@ -62,3 +73,11 @@ <CountrySelect

placeHolder="Select Country"
region={region}
/>
<h6>All Country</h6>
<CountrySelect
onChange={(e) => {
setCountryid(e.id);
}}
placeHolder="Select Country"
/>
<h6>State</h6>

@@ -100,6 +119,8 @@ <StateSelect

GetCity,
GetLanguages, //async functions
GetLanguages,
GetRegions //async functions
} from "react-country-state-city";
function App() {
const [region, setRegion] = useState("");
const [countryid, setCountryid] = useState(0);

@@ -110,2 +131,3 @@ const [stateid, setStateid] = useState(0);

const [regionsList, setRegionsList] = useState([]);
const [countriesList, setCountriesList] = useState([]);

@@ -117,4 +139,7 @@ const [stateList, setStateList] = useState([]);

useEffect(() => {
GetRegions().then((result) => {
setRegionsList(result);
});
GetCountries().then((result) => {
setCountries(result);
setCountriesList(result);
});

@@ -128,2 +153,16 @@

<div>
<h6>Region</h6>
<select
onChange={(e) => {
const _region = regionsList[e.target.value];
setRegion(country.name);
}}
value={region}
>
{regionsList.map((item, index) => (
<option key={index} value={index}>
{item.name}
</option>
))}
</select>
<h6>Country</h6>

@@ -258,2 +297,9 @@ <select

### Languages Example
<img src="https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/example/src/example4.png" alt="React country state city example screenshot"/>
<img src="https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/example/src/example5.png" alt="React country state city example screenshot"/>
### GetLanguages - Result

@@ -270,2 +316,17 @@

### Regions Example
<img src="https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/example/src/example6.png" alt="React country state city example screenshot"/>
### GetRegions - Result
[
{
id: string;
name: string;
},
...
]
## The Country Select Properties

@@ -316,2 +377,6 @@

## Region Select Properties
The same country select properties
## Demo

@@ -327,6 +392,8 @@

Become a financial contributor and help us sustain our community. [Contribute](https://opencollective.com/react-country-state-city)
Buy me a cup of coffee,
Binance Smart Chain or Ethereum - 0x7C6Bfb7f240f6028Fd2a0039924826eD8B879635
## 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc