improved typing for bootbox options

This commit is contained in:
Troy McKinnon
2016-03-17 09:48:18 -05:00
parent 41f8573534
commit e147c2463e
2 changed files with 53 additions and 34 deletions
+47 -29
View File
@@ -1,25 +1,56 @@
// Type definitions for Bootbox 4.4.0
// Project: https://github.com/makeusabrew/bootbox
// Definitions by: Vincent Bortone <https://github.com/vbortone/>, Kon Pik <https://github.com/konpikwastaken/>, Anup Kattel <https://github.com/kanup/>, Dominik Schroeter <https://github.com/icereed/>
// Definitions by: Vincent Bortone <https://github.com/vbortone/>, Kon Pik <https://github.com/konpikwastaken/>, Anup Kattel <https://github.com/kanup/>, Dominik Schroeter <https://github.com/icereed/>, Troy McKinnon <https://github.com/trodi/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
interface BootboxAlertOptions {
/** Bootbox options shared by all modal types */
interface BootboxBaseOptions {
title?: string | Element;
callback?: (result: boolean | string) => any;
onEscape?: () => any | boolean;
show?: boolean;
backdrop?: boolean;
closeButton?: boolean;
animate?: boolean;
className?: string;
size?: string;
message: string;
buttons?: BootboxButtonMap; // complex object where each key is of type BootboxButton
}
/** Bootbox options available for custom modals */
interface BootboxDialogOptions extends BootboxBaseOptions {
message: string | Element;
}
/** Bootbox options available for alert modals */
interface BootboxAlertOptions extends BootboxDialogOptions {
callback?: () => any;
buttons?: BootboxAlertButtonMap;
}
interface BootboxConfirmOptions {
size?: string;
message: string;
/** Bootbox options available for confirm modals */
interface BootboxConfirmOptions extends BootboxDialogOptions {
callback: (result: boolean) => any;
buttons?: BootboxConfirmPromptButtonMap;
}
interface BootboxPromptOptions {
size?: string;
message?: string;
/** Bootbox options available for prompt modals */
interface BootboxPromptOptions extends BootboxBaseOptions {
title: string;
callback: (result: string) => any;
buttons?: BootboxConfirmPromptButtonMap;
}
/** Bootbox options available when setting defaults for modals */
interface BootboxDefaultOptions {
locale?: string;
show?: boolean;
backdrop?: boolean;
closeButton?: boolean;
animate?: boolean;
className?: string;
}
interface BootboxButton {
@@ -32,28 +63,15 @@ interface BootboxButtonMap {
[key: string]: BootboxButton | Function;
}
interface BootboxDialogOptions {
message: string | Element;
title?: string | Element;
locale?: string;
callback?: (result: boolean) => any;
onEscape?: () => any | boolean;
show?: boolean;
backdrop?: boolean;
closeButton?: boolean;
animate?: boolean;
className?: string;
size?: string;
buttons?: BootboxButtonMap; // complex object where each key is of type BootboxButton
/** ButtonMap options for alerts modals */
interface BootboxAlertButtonMap extends BootboxButtonMap {
ok: BootboxButton | Function;
}
interface BootboxDefaultOptions {
locale?: string;
show?: boolean;
backdrop?: boolean;
closeButton?: boolean;
animate?: boolean;
className?: string;
/** ButtonMap options for confirm and prompt modals */
interface BootboxConfirmPromptButtonMap extends BootboxButtonMap {
confirm: BootboxButton | Function;
cancel: BootboxButton | Function;
}
interface BootboxLocaleValues {