From 6f8ca80377216a8691b2630cd2b119f06da1b8b3 Mon Sep 17 00:00:00 2001 From: Humberto Rocha Date: Tue, 16 May 2017 15:06:31 -0300 Subject: [PATCH] adding country-select-js typings --- .../country-select-js-tests.ts | 1 + types/country-select-js/index.d.ts | 55 +++++++++++++++++++ types/country-select-js/tsconfig.json | 23 ++++++++ types/country-select-js/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/country-select-js/country-select-js-tests.ts create mode 100644 types/country-select-js/index.d.ts create mode 100644 types/country-select-js/tsconfig.json create mode 100644 types/country-select-js/tslint.json 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..145dda23b2 --- /dev/null +++ b/types/country-select-js/country-select-js-tests.ts @@ -0,0 +1 @@ +$('#country').countrySelect(); diff --git a/types/country-select-js/index.d.ts b/types/country-select-js/index.d.ts new file mode 100644 index 0000000000..6aea963e0d --- /dev/null +++ b/types/country-select-js/index.d.ts @@ -0,0 +1,55 @@ +// 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..807376d634 --- /dev/null +++ b/types/country-select-js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "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" }