mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for muibox (#36183)
* Added typings for muibox * Removed patch version
This commit is contained in:
parent
f11abd2433
commit
ba5e0a2a2b
29
types/muibox/index.d.ts
vendored
Normal file
29
types/muibox/index.d.ts
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// Type definitions for muibox 1.0
|
||||
// Project: https://github.com/chunkai1312/muibox
|
||||
// Definitions by: Diego Mijelshon <https://github.com/diegose>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function DialogProvider(_: any): any;
|
||||
export function useDialog(): Dialog;
|
||||
export function withDialog(): (WrappedComponent: any) => (props: any) => any;
|
||||
|
||||
export interface Dialog {
|
||||
alert(options: AlertOptions | string): Promise<void>;
|
||||
confirm(options: ConfirmOptions | string): Promise<void>;
|
||||
prompt(options: PromptOptions | string): Promise<string>;
|
||||
}
|
||||
|
||||
export interface AlertOptions {
|
||||
title?: string;
|
||||
message?: string;
|
||||
ok?: string;
|
||||
}
|
||||
|
||||
export interface ConfirmOptions extends AlertOptions {
|
||||
cancel?: string;
|
||||
}
|
||||
|
||||
export interface PromptOptions extends ConfirmOptions {
|
||||
required?: boolean;
|
||||
defaultValue?: string | number;
|
||||
}
|
||||
40
types/muibox/muibox-tests.ts
Normal file
40
types/muibox/muibox-tests.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import * as muibox from "muibox";
|
||||
|
||||
const dialog = muibox.useDialog();
|
||||
|
||||
dialog.alert("Hello world").then(() => "bye");
|
||||
dialog
|
||||
.alert({ message: "Hello world", ok: "Close", title: "Salutation" })
|
||||
.then(() => "bye");
|
||||
|
||||
dialog
|
||||
.confirm("Are you sure?")
|
||||
.then(() => "do it")
|
||||
.catch(() => "don't do it");
|
||||
|
||||
dialog
|
||||
.confirm({
|
||||
message: "Are you sure?",
|
||||
title: "Confirmation",
|
||||
ok: "Sure",
|
||||
cancel: "No"
|
||||
})
|
||||
.then(() => "do it")
|
||||
.catch(() => "don't do it");
|
||||
|
||||
dialog
|
||||
.prompt("What is your name?")
|
||||
.then(name => `Hello ${name}`)
|
||||
.catch(() => "canceled");
|
||||
|
||||
dialog
|
||||
.prompt({
|
||||
message: "What is your name?",
|
||||
title: "Salutation",
|
||||
ok: "Proceed",
|
||||
cancel: "Quit",
|
||||
defaultValue: "Joe",
|
||||
required: true
|
||||
})
|
||||
.then(name => `Hello ${name}`)
|
||||
.catch(() => "canceled");
|
||||
23
types/muibox/tsconfig.json
Normal file
23
types/muibox/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"muibox-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/muibox/tslint.json
Normal file
1
types/muibox/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user