Merge pull request #16561 from humrochagf/master

Add type definitions for country-select-js
This commit is contained in:
Arthur Ozga
2017-05-18 14:42:36 -07:00
committed by GitHub
4 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
$('#country').countrySelect();
$('#country').countrySelect({
defaultCountry: 'gb'
});
$('#country').countrySelect('destroy');

57
types/country-select-js/index.d.ts vendored Normal file
View File

@@ -0,0 +1,57 @@
// Type definitions for country-select-js 1.0
// Project: https://github.com/mrmarkfrench/country-select-js
// Definitions by: Humberto Rocha <https://github.com/humrochagf>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery" />
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<any>;
}

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }