react-country-state-city
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -12,4 +12,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const CitySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, stateid, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const CitySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, stateid, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default CitySelect; |
@@ -12,4 +12,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
region?: string; | ||
src?: string; | ||
}; | ||
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, ...props }: PageProps) => React.JSX.Element; | ||
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, src, ...props }: PageProps) => React.JSX.Element; | ||
export default CountrySelect; |
@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
displayNative?: boolean; | ||
src?: string; | ||
}; | ||
declare const LanguageSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, displayNative, ...props }: PageProps) => React.JSX.Element; | ||
declare const LanguageSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, displayNative, src, ...props }: PageProps) => React.JSX.Element; | ||
export default LanguageSelect; |
@@ -10,4 +10,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const RegionSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const RegionSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default RegionSelect; |
@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const StateSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const StateSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default StateSelect; |
@@ -6,4 +6,5 @@ import CountrySelect from "./components/CountrySelect"; | ||
import RegionSelect from "./components/RegionSelect"; | ||
import { GetCountries, GetState, GetCity, GetLanguages, GetRegions } from "./utils"; | ||
import PhonecodeSelect from "./components/PhonecodeSelect"; | ||
import { GetCountries, GetPhonecodesByRegion, GetState, GetCity, GetLanguages, GetRegions, GetPhonecodes, GetCountriesByRegion } from "./utils"; | ||
import "./styles/style.scss"; | ||
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, GetCountries, GetState, GetCity, GetLanguages, GetRegions, }; | ||
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, PhonecodeSelect, GetCountries, GetCountriesByRegion, GetState, GetCity, GetLanguages, GetRegions, GetPhonecodes, GetPhonecodesByRegion, }; |
@@ -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 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}))))}; | ||
"use strict";var e=require("react"),n=function(){return n=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},n.apply(this,arguments)};function t(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 a(e,n,t,a){return new(t||(t=Promise))((function(o,r){function i(e){try{s(a.next(e))}catch(e){r(e)}}function c(e){try{s(a.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,c)}s((a=a.apply(e,n||[])).next())}))}function o(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(s){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,s])}}}var r=function(e){return a(void 0,void 0,void 0,(function(){var n;return o(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/regionsminified.json",e&&(n=e+"/regionsminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},i=function(e,n){return a(void 0,void 0,void 0,(function(){var t,a,r;return o(this,(function(o){switch(o.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",n&&(t=n+"/countriesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=o.sent(),r=a,e&&(r=r.filter((function(n){return n.region===e}))),[2,r]}}))}))},c=function(e){return a(void 0,void 0,void 0,(function(){var n;return o(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",e&&(n=e+"/countriesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},s=function(e){return a(void 0,void 0,void 0,(function(){var n;return o(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/languagesminified.json",e&&(n=e+"/languagesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},u=function(e,n){return a(void 0,void 0,void 0,(function(){var t,a,r;return o(this,(function(o){switch(o.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/statesminified.json",n&&(t=n+"/languagesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=o.sent(),r=a.find((function(n){return n.id===e})),[2,r&&r.states?r.states:[]]}}))}))},l=function(e,n,t){return a(void 0,void 0,void 0,(function(){var a,r,i,c,s;return o(this,(function(o){switch(o.label){case 0:return a="https://venkatmcajj.github.io/react-country-state-city/data/citiesminified.json",t&&(a=t+"/citiesminified.json"),[4,fetch(a).then((function(e){return e.json()}))];case 1:return r=o.sent(),(i=r.find((function(n){return n.id===e})))?(c=i&&i.states?i.states:[],[2,(s=c.find((function(e){return e.id===n})))&&s.cities?s.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"}))},d=function(a){var o=a.placeHolder,r=a.options,i=a.onChange,c=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.showFlag,d=void 0===l||l,m=t(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),p=e.useState(!1),h=p[0],v=p[1],g=e.useState(),C=g[0],w=g[1],E=e.useState(""),N=E[0],y=E[1],x=e.useRef(null),j=e.useRef(null);e.useEffect((function(){u&&w(u)}),[u]),e.useEffect((function(){y(""),h&&x.current&&x.current.focus()}),[h]),e.useEffect((function(){var e=function(e){j.current&&!j.current.contains(e.target)&&v(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var b=function(e){return!!C&&C.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:j,onClick:function(){v(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",n({},m,{className:c,onChange:function(e){y(e.target.value),w(void 0),s&&s(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(f,null)))),h&&e.createElement("div",{className:"stdropdown-menu"},(N?r.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0})):r).map((function(n){return e.createElement("div",{onClick:function(){return function(e){w(e),i(e)}(n)},key:n.id,className:"".concat("stdropdown-item"," ").concat(b(n)&&"selected")},d&&e.createElement("span",{className:"stdropdown-flag"},"emoji"in n?n.emoji:""," "),n.name)}))))},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(a){var o=a.placeHolder,r=a.options,i=a.onChange,c=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.displayNative,f=t(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","displayNative"]),d=e.useState(!1),p=d[0],h=d[1],v=e.useState(),g=v[0],C=v[1],w=e.useState(""),E=w[0],N=w[1],y=e.useRef(null),x=e.useRef(null);e.useEffect((function(){u&&C(u)}),[u]),e.useEffect((function(){N(""),p&&y.current&&y.current.focus()}),[p]),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 j=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",n({},f,{className:c,onChange:function(e){N(e.target.value),C(void 0),s&&s(e)},value:g?"".concat(l?g.native:g.name):E||"",placeholder:o,ref:y})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(m,null)))),p&&e.createElement("div",{className:"stdropdown-menu"},(E?r.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0||e.native.toLowerCase().indexOf(E.toLowerCase())>=0})):r).map((function(n){return e.createElement("div",{onClick:function(){return function(e){C(e),i(e)}(n)},key:n.code,className:"".concat("stdropdown-item"," ").concat(j(n)&&"selected")},l?n.native:n.name)}))))},h=function(){return e.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},e.createElement("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},v=function(a){var o=a.placeHolder,r=a.options,i=a.onChange,c=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.showFlag,f=void 0===l||l,d=t(a,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),m=e.useState(!1),p=m[0],v=m[1],g=e.useState(),C=g[0],w=g[1],E=e.useState(""),N=E[0],y=E[1],x=e.useRef(null),j=e.useRef(null);e.useEffect((function(){u&&w(u)}),[u]),e.useEffect((function(){y(""),p&&x.current&&x.current.focus()}),[p]),e.useEffect((function(){var e=function(e){j.current&&!j.current.contains(e.target)&&v(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var b=function(e){return!!C&&C.id===e.id};return e.createElement("div",{className:"stdropdown-container"},e.createElement("div",{ref:j,onClick:function(){v(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",n({},d,{className:c,onChange:function(e){y(e.target.value),w(void 0),s&&s(e)},value:C?"".concat(f&&"emoji"in C?C.emoji:""," +").concat(C.phone_code):N||"",placeholder:o,ref:x})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(h,null)))),p&&e.createElement("div",{className:"stdropdown-menu"},(N?r.filter((function(e){return e.name.toLowerCase().indexOf(N.toLowerCase())>=0||e.phone_code.indexOf(N)>=0||("+"+e.phone_code).indexOf(N)>=0})):r).map((function(n){return e.createElement("div",{onClick:function(){return function(e){w(e),i(e)}(n)},key:n.id,className:"".concat("stdropdown-item"," ").concat(b(n)&&"selected")},f&&e.createElement("span",{className:"stdropdown-flag"},"emoji"in n?n.emoji:""," "),"+",n.phone_code)}))))};exports.CitySelect=function(a){var o=a.containerClassName,r=a.inputClassName,i=a.onTextChange,c=a.defaultValue,s=a.onChange,u=a.countryid,f=a.stateid,m=a.placeHolder,p=a.src,h=t(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder","src"]),v=e.useState([]),g=v[0],C=v[1];return e.useEffect((function(){u&&l(u,f,p).then((function(e){C(e)}))}),[u,f,p]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,n({},h,{placeHolder:m,options:g,onChange:function(e){s&&s(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))},exports.CountrySelect=function(a){var o=a.containerClassName,r=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.onChange,f=a.placeHolder,m=a.showFlag,p=a.region,h=a.src,v=t(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region","src"]),g=e.useState([]),C=g[0],w=g[1];return e.useEffect((function(){p?i(p,h).then((function(e){w(e)})):c(h).then((function(e){w(e)}))}),[p,h]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,n({},v,{placeHolder:f,options:C,onChange:function(e){l&&l(e)},showFlag:m,onTextChange:s,defaultValue:u,inputClassName:r}))))},exports.GetCity=l,exports.GetCountries=c,exports.GetCountriesByRegion=i,exports.GetLanguages=s,exports.GetPhonecodes=function(e){return a(void 0,void 0,void 0,(function(){var n,t;return o(this,(function(a){switch(a.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",e&&(n=e+"/countriesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return t=a.sent(),[2,t.map((function(e){return{id:e.id,name:e.name,phone_code:e.phone_code,region:e.region}}))]}}))}))},exports.GetPhonecodesByRegion=function(e,n){return a(void 0,void 0,void 0,(function(){var t,a,r;return o(this,(function(o){switch(o.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",n&&(t=n+"/countriesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=o.sent(),r=a,e&&(r=r.filter((function(n){return n.region===e}))),[2,r.map((function(e){return{id:e.id,name:e.name,phone_code:e.phone_code,region:e.region}}))]}}))}))},exports.GetRegions=r,exports.GetState=u,exports.LanguageSelect=function(a){var o=a.containerClassName,r=a.inputClassName,i=a.onTextChange,c=a.defaultValue,u=a.onChange,l=a.placeHolder,f=a.displayNative,d=a.src,m=t(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","displayNative","src"]),h=e.useState([]),v=h[0],g=h[1];return e.useEffect((function(){s(d).then((function(e){g(e)}))}),[d]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(p,n({},m,{placeHolder:l,options:v,onChange:function(e){u&&u(e)},displayNative:f,onTextChange:i,defaultValue:c,inputClassName:r}))))},exports.PhonecodeSelect=function(a){var o=a.containerClassName,r=a.inputClassName,s=a.onTextChange,u=a.defaultValue,l=a.onChange,f=a.placeHolder,d=a.showFlag,m=a.region,p=a.src,h=t(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region","src"]),g=e.useState([]),C=g[0],w=g[1];return e.useEffect((function(){m?i(m,p).then((function(e){w(e)})):c(p).then((function(e){w(e)}))}),[m,p]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(v,n({},h,{placeHolder:f,options:C,onChange:function(e){l&&l(e)},showFlag:d,onTextChange:s,defaultValue:u,inputClassName:r}))))},exports.RegionSelect=function(a){var o=a.containerClassName,i=a.inputClassName,c=a.onTextChange,s=a.defaultValue,u=a.onChange,l=a.placeHolder,f=a.src,m=t(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","src"]),p=e.useState([]),h=p[0],v=p[1];return e.useEffect((function(){r(f).then((function(e){v(e)}))}),[f]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,n({},m,{placeHolder:l,options:h,onChange:function(e){u&&u(e)},onTextChange:c,defaultValue:s,inputClassName:i}))))},exports.StateSelect=function(a){var o=a.containerClassName,r=a.inputClassName,i=a.onTextChange,c=a.defaultValue,s=a.onChange,l=a.countryid,f=a.placeHolder,m=a.src,p=t(a,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder","src"]),h=e.useState([]),v=h[0],g=h[1];return e.useEffect((function(){l&&u(l,m).then((function(e){g(e)}))}),[l,m]),e.createElement(e.Fragment,null,e.createElement("div",{className:o,style:{position:"relative"}},e.createElement(d,n({},p,{placeHolder:f,options:v,onChange:function(e){s&&s(e)},onTextChange:i,defaultValue:c,inputClassName:r}))))}; | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ export interface Country { | ||
numeric_code: string; | ||
phone_code: number; | ||
phone_code: string; | ||
capital: string; | ||
@@ -22,2 +22,8 @@ currency: string; | ||
} | ||
export interface Phonecodes { | ||
id: number; | ||
name: string; | ||
phone_code: string; | ||
region: string; | ||
} | ||
export interface Region { | ||
@@ -24,0 +30,0 @@ id: number; |
@@ -1,6 +0,9 @@ | ||
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> | []>; | ||
import { City, Country, Language, Phonecodes, Region, State } from "../types"; | ||
export declare const GetRegions: (src?: string) => Promise<Region[] | []>; | ||
export declare const GetPhonecodesByRegion: (_region: string, src?: string) => Promise<Phonecodes[] | []>; | ||
export declare const GetPhonecodes: (src?: string) => Promise<Phonecodes[] | []>; | ||
export declare const GetCountriesByRegion: (_region: string, src?: string) => Promise<Country[] | []>; | ||
export declare const GetCountries: (src?: string) => Promise<Country[] | []>; | ||
export declare const GetLanguages: (src?: string) => Promise<Language[] | []>; | ||
export declare const GetState: (id: number, src?: string) => Promise<Array<State> | []>; | ||
export declare const GetCity: (countryid: number, stateid: number, src?: string) => Promise<Array<City> | []>; |
@@ -12,4 +12,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const CitySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, stateid, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const CitySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, stateid, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default CitySelect; |
@@ -12,4 +12,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
region?: string; | ||
src?: string; | ||
}; | ||
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, ...props }: PageProps) => React.JSX.Element; | ||
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, src, ...props }: PageProps) => React.JSX.Element; | ||
export default CountrySelect; |
@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
displayNative?: boolean; | ||
src?: string; | ||
}; | ||
declare const LanguageSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, displayNative, ...props }: PageProps) => React.JSX.Element; | ||
declare const LanguageSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, displayNative, src, ...props }: PageProps) => React.JSX.Element; | ||
export default LanguageSelect; |
@@ -10,4 +10,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const RegionSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const RegionSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default RegionSelect; |
@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const StateSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const StateSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default StateSelect; |
@@ -6,4 +6,5 @@ import CountrySelect from "./components/CountrySelect"; | ||
import RegionSelect from "./components/RegionSelect"; | ||
import { GetCountries, GetState, GetCity, GetLanguages, GetRegions } from "./utils"; | ||
import PhonecodeSelect from "./components/PhonecodeSelect"; | ||
import { GetCountries, GetPhonecodesByRegion, GetState, GetCity, GetLanguages, GetRegions, GetPhonecodes, GetCountriesByRegion } from "./utils"; | ||
import "./styles/style.scss"; | ||
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, GetCountries, GetState, GetCity, GetLanguages, GetRegions, }; | ||
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, PhonecodeSelect, GetCountries, GetCountriesByRegion, GetState, GetCity, GetLanguages, GetRegions, GetPhonecodes, GetPhonecodesByRegion, }; |
@@ -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/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}; | ||
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{s(a.next(e))}catch(e){r(e)}}function c(e){try{s(a.throw(e))}catch(e){r(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(i,c)}s((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(s){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,s])}}}var s=function(e){return i(void 0,void 0,void 0,(function(){var n;return c(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/regionsminified.json",e&&(n=e+"/regionsminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},l=function(e,n){return i(void 0,void 0,void 0,(function(){var t,a,o;return c(this,(function(r){switch(r.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",n&&(t=n+"/countriesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=r.sent(),o=a,e&&(o=o.filter((function(n){return n.region===e}))),[2,o.map((function(e){return{id:e.id,name:e.name,phone_code:e.phone_code,region:e.region}}))]}}))}))},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 n="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",e&&(n=e+"/countriesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return t=a.sent(),[2,t.map((function(e){return{id:e.id,name:e.name,phone_code:e.phone_code,region:e.region}}))]}}))}))},d=function(e,n){return i(void 0,void 0,void 0,(function(){var t,a,o;return c(this,(function(r){switch(r.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",n&&(t=n+"/countriesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=r.sent(),o=a,e&&(o=o.filter((function(n){return n.region===e}))),[2,o]}}))}))},f=function(e){return i(void 0,void 0,void 0,(function(){var n;return c(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",e&&(n=e+"/countriesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},m=function(e){return i(void 0,void 0,void 0,(function(){var n;return c(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/languagesminified.json",e&&(n=e+"/languagesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},h=function(e,n){return i(void 0,void 0,void 0,(function(){var t,a,o;return c(this,(function(r){switch(r.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/statesminified.json",n&&(t=n+"/languagesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=r.sent(),o=a.find((function(n){return n.id===e})),[2,o&&o.states?o.states:[]]}}))}))},p=function(e,n,t){return i(void 0,void 0,void 0,(function(){var a,o,r,i,s;return c(this,(function(c){switch(c.label){case 0:return a="https://venkatmcajj.github.io/react-country-state-city/data/citiesminified.json",t&&(a=t+"/citiesminified.json"),[4,fetch(a).then((function(e){return e.json()}))];case 1:return o=c.sent(),(r=o.find((function(n){return n.id===e})))?(i=r&&r.states?r.states:[],[2,(s=i.find((function(e){return e.id===n})))&&s.cities?s.cities:[]]):[2,[]]}}))}))},v=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,s=i.options,l=i.onChange,u=i.inputClassName,d=i.onTextChange,f=i.defaultValue,m=i.showFlag,h=void 0===m||m,p=r(i,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),g=n(!1),C=g[0],w=g[1],N=n(),y=N[0],E=N[1],j=n(""),x=j[0],b=j[1],k=t(null),T=t(null);a((function(){f&&E(f)}),[f]),a((function(){b(""),C&&k.current&&k.current.focus()}),[C]),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!!y&&y.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({},p,{className:u,onChange:function(e){b(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:k})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(v,null)))),C&&e.createElement("div",{className:"stdropdown-menu"},(x?s.filter((function(e){return e.name.toLowerCase().indexOf(x.toLowerCase())>=0})):s).map((function(n){return e.createElement("div",{onClick:function(){return function(e){E(e),l(e)}(n)},key:n.id,className:"".concat("stdropdown-item"," ").concat(H(n)&&"selected")},h&&e.createElement("span",{className:"stdropdown-flag"},"emoji"in n?n.emoji:""," "),n.name)}))))},C=function(t){var i=t.containerClassName,c=t.inputClassName,s=t.onTextChange,l=t.defaultValue,u=t.onChange,m=t.placeHolder,h=t.showFlag,p=t.region,v=t.src,C=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region","src"]),w=n([]),N=w[0],y=w[1];return a((function(){p?d(p,v).then((function(e){y(e)})):f(v).then((function(e){y(e)}))}),[p,v]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(g,o({},C,{placeHolder:m,options:N,onChange:function(e){u&&u(e)},showFlag:h,onTextChange:s,defaultValue:l,inputClassName:c}))))},w=function(t){var i=t.containerClassName,c=t.inputClassName,s=t.onTextChange,l=t.defaultValue,u=t.onChange,d=t.countryid,f=t.placeHolder,m=t.src,p=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder","src"]),v=n([]),C=v[0],w=v[1];return a((function(){d&&h(d,m).then((function(e){w(e)}))}),[d,m]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(g,o({},p,{placeHolder:f,options:C,onChange:function(e){u&&u(e)},onTextChange:s,defaultValue:l,inputClassName:c}))))},N=function(t){var i=t.containerClassName,c=t.inputClassName,s=t.onTextChange,l=t.defaultValue,u=t.onChange,d=t.countryid,f=t.stateid,m=t.placeHolder,h=t.src,v=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder","src"]),C=n([]),w=C[0],N=C[1];return a((function(){d&&p(d,f,h).then((function(e){N(e)}))}),[d,f,h]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(g,o({},v,{placeHolder:m,options:w,onChange:function(e){u&&u(e)},onTextChange:s,defaultValue:l,inputClassName:c}))))},y=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"}))},E=function(i){var c=i.placeHolder,s=i.options,l=i.onChange,u=i.inputClassName,d=i.onTextChange,f=i.defaultValue,m=i.displayNative,h=r(i,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","displayNative"]),p=n(!1),v=p[0],g=p[1],C=n(),w=C[0],N=C[1],E=n(""),j=E[0],x=E[1],b=t(null),k=t(null);a((function(){f&&N(f)}),[f]),a((function(){x(""),v&&b.current&&b.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!!w&&w.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({},h,{className:u,onChange:function(e){x(e.target.value),N(void 0),d&&d(e)},value:w?"".concat(m?w.native:w.name):j||"",placeholder:c,ref:b})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(y,null)))),v&&e.createElement("div",{className:"stdropdown-menu"},(j?s.filter((function(e){return e.name.toLowerCase().indexOf(j.toLowerCase())>=0||e.native.toLowerCase().indexOf(j.toLowerCase())>=0})):s).map((function(n){return e.createElement("div",{onClick:function(){return function(e){N(e),l(e)}(n)},key:n.code,className:"".concat("stdropdown-item"," ").concat(T(n)&&"selected")},m?n.native:n.name)}))))},j=function(t){var i=t.containerClassName,c=t.inputClassName,s=t.onTextChange,l=t.defaultValue,u=t.onChange,d=t.placeHolder,f=t.displayNative,h=t.src,p=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","displayNative","src"]),v=n([]),g=v[0],C=v[1];return a((function(){m(h).then((function(e){C(e)}))}),[h]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(E,o({},p,{placeHolder:d,options:g,onChange:function(e){u&&u(e)},displayNative:f,onTextChange:s,defaultValue:l,inputClassName:c}))))},x=function(t){var i=t.containerClassName,c=t.inputClassName,l=t.onTextChange,u=t.defaultValue,d=t.onChange,f=t.placeHolder,m=t.src,h=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","src"]),p=n([]),v=p[0],C=p[1];return a((function(){s(m).then((function(e){C(e)}))}),[m]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(g,o({},h,{placeHolder:f,options:v,onChange:function(e){d&&d(e)},onTextChange:l,defaultValue:u,inputClassName:c}))))},b=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"}))},k=function(i){var c=i.placeHolder,s=i.options,l=i.onChange,u=i.inputClassName,d=i.onTextChange,f=i.defaultValue,m=i.showFlag,h=void 0===m||m,p=r(i,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),v=n(!1),g=v[0],C=v[1],w=n(),N=w[0],y=w[1],E=n(""),j=E[0],x=E[1],k=t(null),T=t(null);a((function(){f&&y(f)}),[f]),a((function(){x(""),g&&k.current&&k.current.focus()}),[g]),a((function(){var e=function(e){T.current&&!T.current.contains(e.target)&&C(!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(){C(!0)},className:"stdropdown-input stsearch-box"},e.createElement("input",o({},p,{className:u,onChange:function(e){x(e.target.value),y(void 0),d&&d(e)},value:N?"".concat(h&&"emoji"in N?N.emoji:""," +").concat(N.phone_code):j||"",placeholder:c,ref:k})),e.createElement("div",{className:"stdropdown-tools"},e.createElement("div",{className:"stdropdown-tool"},e.createElement(b,null)))),g&&e.createElement("div",{className:"stdropdown-menu"},(j?s.filter((function(e){return e.name.toLowerCase().indexOf(j.toLowerCase())>=0||e.phone_code.indexOf(j)>=0||("+"+e.phone_code).indexOf(j)>=0})):s).map((function(n){return e.createElement("div",{onClick:function(){return function(e){y(e),l(e)}(n)},key:n.id,className:"".concat("stdropdown-item"," ").concat(H(n)&&"selected")},h&&e.createElement("span",{className:"stdropdown-flag"},"emoji"in n?n.emoji:""," "),"+",n.phone_code)}))))},T=function(t){var i=t.containerClassName,c=t.inputClassName,s=t.onTextChange,l=t.defaultValue,u=t.onChange,m=t.placeHolder,h=t.showFlag,p=t.region,v=t.src,g=r(t,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region","src"]),C=n([]),w=C[0],N=C[1];return a((function(){p?d(p,v).then((function(e){N(e)})):f(v).then((function(e){N(e)}))}),[p,v]),e.createElement(e.Fragment,null,e.createElement("div",{className:i,style:{position:"relative"}},e.createElement(k,o({},g,{placeHolder:m,options:w,onChange:function(e){u&&u(e)},showFlag:h,onTextChange:s,defaultValue:l,inputClassName:c}))))};export{N as CitySelect,C as CountrySelect,p as GetCity,f as GetCountries,d as GetCountriesByRegion,m as GetLanguages,u as GetPhonecodes,l as GetPhonecodesByRegion,s as GetRegions,h as GetState,j as LanguageSelect,T as PhonecodeSelect,x as RegionSelect,w as StateSelect}; | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ export interface Country { | ||
numeric_code: string; | ||
phone_code: number; | ||
phone_code: string; | ||
capital: string; | ||
@@ -22,2 +22,8 @@ currency: string; | ||
} | ||
export interface Phonecodes { | ||
id: number; | ||
name: string; | ||
phone_code: string; | ||
region: string; | ||
} | ||
export interface Region { | ||
@@ -24,0 +30,0 @@ id: number; |
@@ -1,6 +0,9 @@ | ||
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> | []>; | ||
import { City, Country, Language, Phonecodes, Region, State } from "../types"; | ||
export declare const GetRegions: (src?: string) => Promise<Region[] | []>; | ||
export declare const GetPhonecodesByRegion: (_region: string, src?: string) => Promise<Phonecodes[] | []>; | ||
export declare const GetPhonecodes: (src?: string) => Promise<Phonecodes[] | []>; | ||
export declare const GetCountriesByRegion: (_region: string, src?: string) => Promise<Country[] | []>; | ||
export declare const GetCountries: (src?: string) => Promise<Country[] | []>; | ||
export declare const GetLanguages: (src?: string) => Promise<Language[] | []>; | ||
export declare const GetState: (id: number, src?: string) => Promise<Array<State> | []>; | ||
export declare const GetCity: (countryid: number, stateid: number, src?: string) => Promise<Array<City> | []>; |
@@ -12,4 +12,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const CitySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, stateid, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const CitySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, stateid, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default CitySelect; |
@@ -12,4 +12,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
region?: string; | ||
src?: string; | ||
}; | ||
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, ...props }: PageProps) => React.JSX.Element; | ||
declare const CountrySelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, showFlag, region, src, ...props }: PageProps) => React.JSX.Element; | ||
export default CountrySelect; |
@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
displayNative?: boolean; | ||
src?: string; | ||
}; | ||
declare const LanguageSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, displayNative, ...props }: PageProps) => React.JSX.Element; | ||
declare const LanguageSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, displayNative, src, ...props }: PageProps) => React.JSX.Element; | ||
export default LanguageSelect; |
@@ -10,4 +10,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const RegionSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const RegionSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default RegionSelect; |
@@ -11,4 +11,5 @@ import React, { ChangeEvent, InputHTMLAttributes } from "react"; | ||
placeHolder?: string; | ||
src?: string; | ||
}; | ||
declare const StateSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, placeHolder, ...props }: PageProps) => React.JSX.Element; | ||
declare const StateSelect: ({ containerClassName, inputClassName, onTextChange, defaultValue, onChange, countryid, placeHolder, src, ...props }: PageProps) => React.JSX.Element; | ||
export default StateSelect; |
@@ -6,4 +6,5 @@ import CountrySelect from "./components/CountrySelect"; | ||
import RegionSelect from "./components/RegionSelect"; | ||
import { GetCountries, GetState, GetCity, GetLanguages, GetRegions } from "./utils"; | ||
import PhonecodeSelect from "./components/PhonecodeSelect"; | ||
import { GetCountries, GetPhonecodesByRegion, GetState, GetCity, GetLanguages, GetRegions, GetPhonecodes, GetCountriesByRegion } from "./utils"; | ||
import "./styles/style.scss"; | ||
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, GetCountries, GetState, GetCity, GetLanguages, GetRegions, }; | ||
export { CountrySelect, StateSelect, CitySelect, LanguageSelect, RegionSelect, PhonecodeSelect, GetCountries, GetCountriesByRegion, GetState, GetCity, GetLanguages, GetRegions, GetPhonecodes, GetPhonecodesByRegion, }; |
@@ -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/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}))))}})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ReactCountryStateCity={},e.React)}(this,(function(e,n){"use strict";var t=function(){return t=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},t.apply(this,arguments)};function a(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 o(e,n,t,a){return new(t||(t=Promise))((function(o,i){function r(e){try{s(a.next(e))}catch(e){i(e)}}function c(e){try{s(a.throw(e))}catch(e){i(e)}}function s(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,c)}s((a=a.apply(e,n||[])).next())}))}function i(e,n){var t,a,o,i,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(r=0)),r;)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 r.label++,{value:c[1],done:!1};case 5:r.label++,a=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(!(o=r.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){r=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(6===c[0]&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=n.call(e,r)}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,s])}}}var r=function(e){return o(void 0,void 0,void 0,(function(){var n;return i(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/regionsminified.json",e&&(n=e+"/regionsminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},c=function(e,n){return o(void 0,void 0,void 0,(function(){var t,a,o;return i(this,(function(i){switch(i.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",n&&(t=n+"/countriesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=i.sent(),o=a,e&&(o=o.filter((function(n){return n.region===e}))),[2,o]}}))}))},s=function(e){return o(void 0,void 0,void 0,(function(){var n;return i(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",e&&(n=e+"/countriesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},u=function(e){return o(void 0,void 0,void 0,(function(){var n;return i(this,(function(t){switch(t.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/languagesminified.json",e&&(n=e+"/languagesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},l=function(e,n){return o(void 0,void 0,void 0,(function(){var t,a,o;return i(this,(function(i){switch(i.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/statesminified.json",n&&(t=n+"/languagesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=i.sent(),o=a.find((function(n){return n.id===e})),[2,o&&o.states?o.states:[]]}}))}))},f=function(e,n,t){return o(void 0,void 0,void 0,(function(){var a,o,r,c,s;return i(this,(function(i){switch(i.label){case 0:return a="https://venkatmcajj.github.io/react-country-state-city/data/citiesminified.json",t&&(a=t+"/citiesminified.json"),[4,fetch(a).then((function(e){return e.json()}))];case 1:return o=i.sent(),(r=o.find((function(n){return n.id===e})))?(c=r&&r.states?r.states:[],[2,(s=c.find((function(e){return e.id===n})))&&s.cities?s.cities:[]]):[2,[]]}}))}))},d=function(){return n.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},n.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(e){var o=e.placeHolder,i=e.options,r=e.onChange,c=e.inputClassName,s=e.onTextChange,u=e.defaultValue,l=e.showFlag,f=void 0===l||l,m=a(e,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),h=n.useState(!1),p=h[0],v=h[1],g=n.useState(),C=g[0],w=g[1],E=n.useState(""),y=E[0],N=E[1],j=n.useRef(null),x=n.useRef(null);n.useEffect((function(){u&&w(u)}),[u]),n.useEffect((function(){N(""),p&&j.current&&j.current.focus()}),[p]),n.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 b=function(e){return!!C&&C.id===e.id};return n.createElement("div",{className:"stdropdown-container"},n.createElement("div",{ref:x,onClick:function(){v(!0)},className:"stdropdown-input stsearch-box"},n.createElement("input",t({},m,{className:c,onChange:function(e){N(e.target.value),w(void 0),s&&s(e)},value:C?"".concat(f&&"emoji"in C?C.emoji:""," ").concat(C.name):y||"",placeholder:o,ref:j})),n.createElement("div",{className:"stdropdown-tools"},n.createElement("div",{className:"stdropdown-tool"},n.createElement(d,null)))),p&&n.createElement("div",{className:"stdropdown-menu"},(y?i.filter((function(e){return e.name.toLowerCase().indexOf(y.toLowerCase())>=0})):i).map((function(e){return n.createElement("div",{onClick:function(){return function(e){w(e),r(e)}(e)},key:e.id,className:"".concat("stdropdown-item"," ").concat(b(e)&&"selected")},f&&n.createElement("span",{className:"stdropdown-flag"},"emoji"in e?e.emoji:""," "),e.name)}))))},h=function(){return n.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},n.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,i=e.options,r=e.onChange,c=e.inputClassName,s=e.onTextChange,u=e.defaultValue,l=e.displayNative,f=a(e,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","displayNative"]),d=n.useState(!1),m=d[0],p=d[1],v=n.useState(),g=v[0],C=v[1],w=n.useState(""),E=w[0],y=w[1],N=n.useRef(null),j=n.useRef(null);n.useEffect((function(){u&&C(u)}),[u]),n.useEffect((function(){y(""),m&&N.current&&N.current.focus()}),[m]),n.useEffect((function(){var e=function(e){j.current&&!j.current.contains(e.target)&&p(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var x=function(e){return!!g&&g.code===e.code};return n.createElement("div",{className:"stdropdown-container"},n.createElement("div",{ref:j,onClick:function(){p(!0)},className:"stdropdown-input stsearch-box"},n.createElement("input",t({},f,{className:c,onChange:function(e){y(e.target.value),C(void 0),s&&s(e)},value:g?"".concat(l?g.native:g.name):E||"",placeholder:o,ref:N})),n.createElement("div",{className:"stdropdown-tools"},n.createElement("div",{className:"stdropdown-tool"},n.createElement(h,null)))),m&&n.createElement("div",{className:"stdropdown-menu"},(E?i.filter((function(e){return e.name.toLowerCase().indexOf(E.toLowerCase())>=0||e.native.toLowerCase().indexOf(E.toLowerCase())>=0})):i).map((function(e){return n.createElement("div",{onClick:function(){return function(e){C(e),r(e)}(e)},key:e.code,className:"".concat("stdropdown-item"," ").concat(x(e)&&"selected")},l?e.native:e.name)}))))},v=function(){return n.createElement("svg",{height:"20",width:"20",viewBox:"0 0 20 20"},n.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(e){var o=e.placeHolder,i=e.options,r=e.onChange,c=e.inputClassName,s=e.onTextChange,u=e.defaultValue,l=e.showFlag,f=void 0===l||l,d=a(e,["placeHolder","options","onChange","inputClassName","onTextChange","defaultValue","showFlag"]),m=n.useState(!1),h=m[0],p=m[1],g=n.useState(),C=g[0],w=g[1],E=n.useState(""),y=E[0],N=E[1],j=n.useRef(null),x=n.useRef(null);n.useEffect((function(){u&&w(u)}),[u]),n.useEffect((function(){N(""),h&&j.current&&j.current.focus()}),[h]),n.useEffect((function(){var e=function(e){x.current&&!x.current.contains(e.target)&&p(!1)};return window.addEventListener("click",e),function(){window.removeEventListener("click",e)}}));var b=function(e){return!!C&&C.id===e.id};return n.createElement("div",{className:"stdropdown-container"},n.createElement("div",{ref:x,onClick:function(){p(!0)},className:"stdropdown-input stsearch-box"},n.createElement("input",t({},d,{className:c,onChange:function(e){N(e.target.value),w(void 0),s&&s(e)},value:C?"".concat(f&&"emoji"in C?C.emoji:""," +").concat(C.phone_code):y||"",placeholder:o,ref:j})),n.createElement("div",{className:"stdropdown-tools"},n.createElement("div",{className:"stdropdown-tool"},n.createElement(v,null)))),h&&n.createElement("div",{className:"stdropdown-menu"},(y?i.filter((function(e){return e.name.toLowerCase().indexOf(y.toLowerCase())>=0||e.phone_code.indexOf(y)>=0||("+"+e.phone_code).indexOf(y)>=0})):i).map((function(e){return n.createElement("div",{onClick:function(){return function(e){w(e),r(e)}(e)},key:e.id,className:"".concat("stdropdown-item"," ").concat(b(e)&&"selected")},f&&n.createElement("span",{className:"stdropdown-flag"},"emoji"in e?e.emoji:""," "),"+",e.phone_code)}))))};e.CitySelect=function(e){var o=e.containerClassName,i=e.inputClassName,r=e.onTextChange,c=e.defaultValue,s=e.onChange,u=e.countryid,l=e.stateid,d=e.placeHolder,h=e.src,p=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","stateid","placeHolder","src"]),v=n.useState([]),g=v[0],C=v[1];return n.useEffect((function(){u&&f(u,l,h).then((function(e){C(e)}))}),[u,l,h]),n.createElement(n.Fragment,null,n.createElement("div",{className:o,style:{position:"relative"}},n.createElement(m,t({},p,{placeHolder:d,options:g,onChange:function(e){s&&s(e)},onTextChange:r,defaultValue:c,inputClassName:i}))))},e.CountrySelect=function(e){var o=e.containerClassName,i=e.inputClassName,r=e.onTextChange,u=e.defaultValue,l=e.onChange,f=e.placeHolder,d=e.showFlag,h=e.region,p=e.src,v=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region","src"]),g=n.useState([]),C=g[0],w=g[1];return n.useEffect((function(){h?c(h,p).then((function(e){w(e)})):s(p).then((function(e){w(e)}))}),[h,p]),n.createElement(n.Fragment,null,n.createElement("div",{className:o,style:{position:"relative"}},n.createElement(m,t({},v,{placeHolder:f,options:C,onChange:function(e){l&&l(e)},showFlag:d,onTextChange:r,defaultValue:u,inputClassName:i}))))},e.GetCity=f,e.GetCountries=s,e.GetCountriesByRegion=c,e.GetLanguages=u,e.GetPhonecodes=function(e){return o(void 0,void 0,void 0,(function(){var n,t;return i(this,(function(a){switch(a.label){case 0:return n="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",e&&(n=e+"/countriesminified.json"),[4,fetch(n).then((function(e){return e.json()}))];case 1:return t=a.sent(),[2,t.map((function(e){return{id:e.id,name:e.name,phone_code:e.phone_code,region:e.region}}))]}}))}))},e.GetPhonecodesByRegion=function(e,n){return o(void 0,void 0,void 0,(function(){var t,a,o;return i(this,(function(i){switch(i.label){case 0:return t="https://venkatmcajj.github.io/react-country-state-city/data/countriesminified.json",n&&(t=n+"/countriesminified.json"),[4,fetch(t).then((function(e){return e.json()}))];case 1:return a=i.sent(),o=a,e&&(o=o.filter((function(n){return n.region===e}))),[2,o.map((function(e){return{id:e.id,name:e.name,phone_code:e.phone_code,region:e.region}}))]}}))}))},e.GetRegions=r,e.GetState=l,e.LanguageSelect=function(e){var o=e.containerClassName,i=e.inputClassName,r=e.onTextChange,c=e.defaultValue,s=e.onChange,l=e.placeHolder,f=e.displayNative,d=e.src,m=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","displayNative","src"]),h=n.useState([]),v=h[0],g=h[1];return n.useEffect((function(){u(d).then((function(e){g(e)}))}),[d]),n.createElement(n.Fragment,null,n.createElement("div",{className:o,style:{position:"relative"}},n.createElement(p,t({},m,{placeHolder:l,options:v,onChange:function(e){s&&s(e)},displayNative:f,onTextChange:r,defaultValue:c,inputClassName:i}))))},e.PhonecodeSelect=function(e){var o=e.containerClassName,i=e.inputClassName,r=e.onTextChange,u=e.defaultValue,l=e.onChange,f=e.placeHolder,d=e.showFlag,m=e.region,h=e.src,p=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","showFlag","region","src"]),v=n.useState([]),C=v[0],w=v[1];return n.useEffect((function(){m?c(m,h).then((function(e){w(e)})):s(h).then((function(e){w(e)}))}),[m,h]),n.createElement(n.Fragment,null,n.createElement("div",{className:o,style:{position:"relative"}},n.createElement(g,t({},p,{placeHolder:f,options:C,onChange:function(e){l&&l(e)},showFlag:d,onTextChange:r,defaultValue:u,inputClassName:i}))))},e.RegionSelect=function(e){var o=e.containerClassName,i=e.inputClassName,c=e.onTextChange,s=e.defaultValue,u=e.onChange,l=e.placeHolder,f=e.src,d=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","placeHolder","src"]),h=n.useState([]),p=h[0],v=h[1];return n.useEffect((function(){r(f).then((function(e){v(e)}))}),[f]),n.createElement(n.Fragment,null,n.createElement("div",{className:o,style:{position:"relative"}},n.createElement(m,t({},d,{placeHolder:l,options:p,onChange:function(e){u&&u(e)},onTextChange:c,defaultValue:s,inputClassName:i}))))},e.StateSelect=function(e){var o=e.containerClassName,i=e.inputClassName,r=e.onTextChange,c=e.defaultValue,s=e.onChange,u=e.countryid,f=e.placeHolder,d=e.src,h=a(e,["containerClassName","inputClassName","onTextChange","defaultValue","onChange","countryid","placeHolder","src"]),p=n.useState([]),v=p[0],g=p[1];return n.useEffect((function(){u&&l(u,d).then((function(e){g(e)}))}),[u,d]),n.createElement(n.Fragment,null,n.createElement("div",{className:o,style:{position:"relative"}},n.createElement(m,t({},h,{placeHolder:f,options:v,onChange:function(e){s&&s(e)},onTextChange:r,defaultValue:c,inputClassName:i}))))}})); | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ export interface Country { | ||
numeric_code: string; | ||
phone_code: number; | ||
phone_code: string; | ||
capital: string; | ||
@@ -22,2 +22,8 @@ currency: string; | ||
} | ||
export interface Phonecodes { | ||
id: number; | ||
name: string; | ||
phone_code: string; | ||
region: string; | ||
} | ||
export interface Region { | ||
@@ -24,0 +30,0 @@ id: number; |
@@ -1,6 +0,9 @@ | ||
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> | []>; | ||
import { City, Country, Language, Phonecodes, Region, State } from "../types"; | ||
export declare const GetRegions: (src?: string) => Promise<Region[] | []>; | ||
export declare const GetPhonecodesByRegion: (_region: string, src?: string) => Promise<Phonecodes[] | []>; | ||
export declare const GetPhonecodes: (src?: string) => Promise<Phonecodes[] | []>; | ||
export declare const GetCountriesByRegion: (_region: string, src?: string) => Promise<Country[] | []>; | ||
export declare const GetCountries: (src?: string) => Promise<Country[] | []>; | ||
export declare const GetLanguages: (src?: string) => Promise<Language[] | []>; | ||
export declare const GetState: (id: number, src?: string) => Promise<Array<State> | []>; | ||
export declare const GetCity: (countryid: number, stateid: number, src?: string) => Promise<Array<City> | []>; |
{ | ||
"name": "react-country-state-city", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"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.", | ||
@@ -52,3 +52,7 @@ "main": "dist/cjs/index.js", | ||
"continent-list", | ||
"continent-select" | ||
"continent-select", | ||
"phone_code", | ||
"phone_code-list", | ||
"phone_code-select", | ||
"mobile_code" | ||
], | ||
@@ -55,0 +59,0 @@ "author": "Venkatesh", |
@@ -16,3 +16,4 @@ # React-country-state-city | ||
LanguageSelect, | ||
RegionSelect | ||
RegionSelect, | ||
PhonecodeSelect | ||
} from "react-country-state-city"; | ||
@@ -35,3 +36,9 @@ | ||
- Regions or Continents dropdown to list and search all the regions from the world. | ||
- Phonecode dropdown to list and search all the codes based on country name or phone codes. | ||
## Data | ||
By default, the control will load the github hosted data files. Alternatively, you can [download the data](https://github.com/venkatmcajj/react-country-state-city/tree/master/data) json file and host it yourself. Simply download the JSON files, and supply the src property to each control to tell it where to download from. | ||
## The gist | ||
@@ -47,3 +54,4 @@ | ||
LanguageSelect, | ||
RegionSelect | ||
RegionSelect, | ||
PhonecodeSelect | ||
} from "react-country-state-city"; | ||
@@ -54,2 +62,3 @@ import "react-country-state-city/dist/react-country-state-city.css"; | ||
const [region, setRegion] = useState(""); | ||
const [phonecode, setPhoneCode] = useState(""); | ||
const [countryid, setCountryid] = useState(0); | ||
@@ -66,2 +75,3 @@ const [stateid, setstateid] = useState(0); | ||
/> | ||
<h6>Country</h6> | ||
@@ -82,2 +92,9 @@ <CountrySelect | ||
/> | ||
<h6>Phone Code</h6> | ||
<RegionSelect | ||
onChange={(e) => { | ||
setPhoneCode(e.phone_code); | ||
}} | ||
placeHolder="Select Phone Code" | ||
/> | ||
<h6>State</h6> | ||
@@ -120,3 +137,4 @@ <StateSelect | ||
GetLanguages, | ||
GetRegions //async functions | ||
GetRegions, | ||
GetPhonecodes //async functions | ||
} from "react-country-state-city"; | ||
@@ -130,3 +148,5 @@ | ||
const [language, setLanguage] = useState(0); | ||
const [phoneCode, setPhoneCode] = useState(""); | ||
const [phonecodeList, setPhonecodeList] = useState([]); | ||
const [regionsList, setRegionsList] = useState([]); | ||
@@ -139,2 +159,5 @@ const [countriesList, setCountriesList] = useState([]); | ||
useEffect(() => { | ||
GetPhonecodes().then((result) => { | ||
setPhonecodeList(result); | ||
}); | ||
GetRegions().then((result) => { | ||
@@ -157,3 +180,3 @@ setRegionsList(result); | ||
const _region = regionsList[e.target.value]; | ||
setRegion(country.name); | ||
setRegion(_region.name); | ||
}} | ||
@@ -185,2 +208,15 @@ value={region} | ||
</select> | ||
<h6>Phone Code</h6> | ||
<select | ||
onChange={(e) => { | ||
setRegion(e.target.value); | ||
}} | ||
value={phoneCode} | ||
> | ||
{regionsList.map((item, index) => ( | ||
<option key={index} value={item.phone_code}> | ||
+{item.phone_code} - {item.name} | ||
</option> | ||
))} | ||
</select> | ||
<h6>State</h6> | ||
@@ -251,2 +287,3 @@ <select | ||
### State Example | ||
@@ -269,2 +306,3 @@ | ||
### Country Example | ||
@@ -333,2 +371,19 @@ | ||
### Phonecode Example | ||
<img src="https://raw.githubusercontent.com/venkatmcajj/react-country-state-city/master/example/src/example7.png" alt="React country state city example screenshot"/> | ||
### GetPhonecodes - Result | ||
[ | ||
{ | ||
id: string; | ||
name: string; | ||
region:string; | ||
phone_code:string; | ||
}, | ||
... | ||
] | ||
## The Country Select Properties | ||
@@ -340,2 +395,3 @@ | ||
| ------------------ | -------- | --------------------------------------------------------------------------------------- | | ||
| src | string | `optional` The relative or absolute URL where the data files are hosted. Default is to serve from hosted CDN. e.g., https://venkatmcajj.github.io/react-country-state-city/data | | ||
| defaultValue | Country | `optional` The current value: a country object | | ||
@@ -355,2 +411,3 @@ | containerClassName | string | `optional` styles for a container | | ||
| --------- | ------ | ------------------------------------------------ | | ||
| src | string | `optional` The relative or absolute URL where the data files are hosted. Default is to serve from hosted CDN. e.g., https://venkatmcajj.github.io/react-country-state-city/data | | ||
| countryid | number | `required` The id of the selected country object | | ||
@@ -364,2 +421,3 @@ | ||
| --------- | ------ | ------------------------------------------------ | | ||
| src | string | `optional` The relative or absolute URL where the data files are hosted. Default is to serve from hosted CDN. e.g., https://venkatmcajj.github.io/react-country-state-city/data | | ||
| countryid | number | `required` The id of the selected country object | | ||
@@ -374,2 +432,3 @@ | stateid | number | `required` The id of the selected state object | | ||
| ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| src | string | `optional` The relative or absolute URL where the data files are hosted. Default is to serve from hosted CDN. e.g., https://venkatmcajj.github.io/react-country-state-city/data | | ||
| defaultValue | Country | `optional` The current value: a country object | | ||
@@ -387,2 +446,6 @@ | containerClassName | string | `optional` styles for a container | | ||
## Phonecode Select Properties | ||
The same country select properties | ||
## Demo | ||
@@ -389,0 +452,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1685509
47
873
449
25