diff --git a/types/country-select-js/country-select-js-tests.ts b/types/country-select-js/country-select-js-tests.ts new file mode 100644 index 0000000000..a3bf640b69 --- /dev/null +++ b/types/country-select-js/country-select-js-tests.ts @@ -0,0 +1,7 @@ +$('#country').countrySelect(); + +$('#country').countrySelect({ + defaultCountry: 'gb' +}); + +$('#country').countrySelect('destroy'); diff --git a/types/country-select-js/index.d.ts b/types/country-select-js/index.d.ts new file mode 100644 index 0000000000..72c33489c2 --- /dev/null +++ b/types/country-select-js/index.d.ts @@ -0,0 +1,57 @@ +// Type definitions for country-select-js 1.0 +// Project: https://github.com/mrmarkfrench/country-select-js +// Definitions by: Humberto Rocha +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace CountrySelectJs { + interface Options { + /** + * Set the default country by it's country code. Otherwise it will just be + * the first country in the list. + */ + defaultCountry?: string; + + /** + * Display only the countries you specify. Takes an array of country codes. + */ + onlyCountries?: string[]; + + /** + * Specify the countries to appear at the top of the list. Defaults to + * ["us", "gb"] + */ + preferredCountries?: string[]; + + /** + * Set the dropdown's width to be the same as the input. This is + * automatically enabled for small screens. + */ + responsiveDropdown?: boolean; + } + + interface CountryData { + name: string; + iso2: string; + } +} + +interface JQuery { + /** + * Remove the plugin from the input, and unbind any event listeners. + */ + countrySelect(method: 'destroy'): void; + + /** + * Get the country data for the currently selected flag. + */ + countrySelect(method: 'getSelectedCountryData'): CountrySelectJs.CountryData; + + countrySelect(method: string, value: string): void; + + /** + * initialize the plugin with optional options. + */ + countrySelect(options?: CountrySelectJs.Options): JQueryDeferred; +} diff --git a/types/country-select-js/tsconfig.json b/types/country-select-js/tsconfig.json new file mode 100644 index 0000000000..749b1b3af1 --- /dev/null +++ b/types/country-select-js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "country-select-js-tests.ts" + ] +} diff --git a/types/country-select-js/tslint.json b/types/country-select-js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/country-select-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }