mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-14 22:10:30 +00:00
Merge pull request #31569 from leonard-thieu/intl-tel-input/umd
[intl-tel-input] Enable importing as a module.
This commit is contained in:
Vendored
+59
-11
@@ -1,9 +1,21 @@
|
||||
// Type definitions for intl-tel-input 14.0
|
||||
// Project: https://github.com/jackocnr/intl-tel-input
|
||||
// Definitions by: Fidan Hakaj <https://github.com/fdnhkj>, Leonard Thieu <https://github.com/leonard-thieu>, Márton Molnár <https://github.com/molnarm>
|
||||
// Definitions by: Fidan Hakaj <https://github.com/fdnhkj>
|
||||
// Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Márton Molnár <https://github.com/molnarm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export as namespace intlTelInput;
|
||||
|
||||
export = IntlTelInput;
|
||||
|
||||
/**
|
||||
* initialise the plugin with optional options.
|
||||
* @param options options that can be provided during initialization.
|
||||
*/
|
||||
declare function IntlTelInput(node: Element, options?: IntlTelInput.Options): IntlTelInput.Plugin;
|
||||
|
||||
declare namespace IntlTelInput {
|
||||
interface Static {
|
||||
/**
|
||||
@@ -25,6 +37,8 @@ declare namespace IntlTelInput {
|
||||
}
|
||||
|
||||
interface Plugin {
|
||||
promise: Promise<void>;
|
||||
|
||||
/**
|
||||
* Remove the plugin from the input, and unbind any event listeners.
|
||||
*/
|
||||
@@ -386,16 +400,50 @@ declare namespace intlTelInputUtils {
|
||||
| "VOIP";
|
||||
}
|
||||
|
||||
interface Window {
|
||||
intlTelInputGlobals: IntlTelInput.Static;
|
||||
declare global {
|
||||
namespace intlTelInputUtils {
|
||||
enum numberFormat {
|
||||
E164 = 0,
|
||||
INTERNATIONAL = 1,
|
||||
NATIONAL = 2,
|
||||
RFC3966 = 3
|
||||
}
|
||||
|
||||
/**
|
||||
* initialise the plugin with optional options.
|
||||
* @param options options that can be provided during initialization.
|
||||
*/
|
||||
intlTelInput(node: Element, options?: IntlTelInput.Options): IntlTelInput.Plugin;
|
||||
}
|
||||
enum numberType {
|
||||
FIXED_LINE = 0,
|
||||
MOBILE = 1,
|
||||
FIXED_LINE_OR_MOBILE = 2,
|
||||
TOLL_FREE = 3,
|
||||
PREMIUM_RATE = 4,
|
||||
SHARED_COST = 5,
|
||||
VOIP = 6,
|
||||
PERSONAL_NUMBER = 7,
|
||||
PAGER = 8,
|
||||
UAN = 9,
|
||||
VOICEMAIL = 10,
|
||||
UNKNOWN = -1
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
intlTelInput: IntlTelInput.JQueryPlugin;
|
||||
enum validationError {
|
||||
IS_POSSIBLE = 0,
|
||||
INVALID_COUNTRY_CODE = 1,
|
||||
TOO_SHORT = 2,
|
||||
TOO_LONG = 3,
|
||||
NOT_A_NUMBER = 4
|
||||
}
|
||||
}
|
||||
|
||||
interface Window {
|
||||
intlTelInputGlobals: IntlTelInput.Static;
|
||||
|
||||
/**
|
||||
* initialise the plugin with optional options.
|
||||
* @param options options that can be provided during initialization.
|
||||
*/
|
||||
intlTelInput(node: Element, options?: IntlTelInput.Options): IntlTelInput.Plugin;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
intlTelInput: IntlTelInput.JQueryPlugin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/// <reference types="jquery" />
|
||||
|
||||
// Global
|
||||
|
||||
// $ExpectType (node: Element, options?: Options) => Plugin
|
||||
intlTelInput;
|
||||
|
||||
// Normal version
|
||||
|
||||
const input = document.querySelector("#phone");
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import intlTelInput = require('intl-tel-input');
|
||||
|
||||
function test_import() {
|
||||
// $ExpectType (node: Element, options?: Options) => Plugin
|
||||
intlTelInput;
|
||||
}
|
||||
|
||||
function test_IntlTelInput_not_visible() {
|
||||
// $ExpectError
|
||||
const options: IntlTelInput.Options = {
|
||||
allowDropdown: true
|
||||
};
|
||||
}
|
||||
|
||||
function test_intlTelInputUtils_global() {
|
||||
const input = document.querySelector('#phone');
|
||||
const iti = intlTelInput(input, {
|
||||
utilsScript: 'node_modules/intl-tel-input/build/js/utils.js'
|
||||
});
|
||||
|
||||
iti.promise.then(() => {
|
||||
console.log(intlTelInputUtils.numberFormat.E164);
|
||||
});
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"intl-tel-input-tests.ts"
|
||||
"intl-tel-input-tests.ts",
|
||||
"test/module-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user