Skip to content

Commit

Permalink
fix: fix index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
lleohao committed Jul 20, 2017
1 parent 31d5e5e commit 32a1be3
Showing 1 changed file with 89 additions and 70 deletions.
159 changes: 89 additions & 70 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
*/
interface BotUIOptions {
/**
* set this to true if you want to debug the underlaying Vue instance
* Set this to true if you want to debug the underlaying Vue instance
*
* @type {boolean}
* @memberof BotUIOptions
*/
debug?: boolean = false;
debug?: boolean;
/**
* set this to false if you already have FontAwesome in your project and don't want it to be loaded again by BotUI.
* Set this to false if you already have FontAwesome in your project and don't want it to be loaded again by BotUI.
*
* @type {boolean}
* @memberof BotUIOptions
*/
fontawesome?: boolean = true;
fontawesome?: boolean;
/**
* Set this to vue constructor when you use module loaded system e.g CMD or AMD.
*/
vue?: any;
}

/**
Expand All @@ -27,164 +31,179 @@ interface BotUIOptions {
*/
interface MessageOption {
/**
* set to true if you want to show a loading state '3 animated dots'. available in version >= 0.3.1
* Set to true if you want to show a loading state '3 animated dots'.
* Available in version >= 0.3.1
*
* @type {boolean}
* @memberof MessageOption
*/
loading?: boolean = false;
loading?: boolean;
/**
* wait before showing the message. in milliseconds.
* Wait before showing the message. in milliseconds.
*
* @type {number}
* @memberof MessageOption
*/
delay?: number = 0;
delay?: number;
/**
* either 'text' or 'embed'
* Either 'text' or 'embed'.
* If you set this to 'embed', BotUI will create an `iframe` element and set `content` as its `src`.
*
* @type {('text' | 'embed')}
* @memberof MessageOption
*/
type: 'text' | 'embed' = 'text';
type: 'text' | 'embed';
/**
* Should be a URL if type is 'embed', text otherwise.
*
* @type {string}
* @memberof MessageOption
*/
content: string = '';
content: string;
/**
* should be shown aligned to right side?
* Should be shown aligned to right side.
*
* @type {false}
* @memberof MessageOption
*/
human?: false;
/**
* a string or array of custom CSS classes you want to be added.
* A string or array of custom CSS classes you want to be added.
*
* @type {string|string[]}
* @memberof MessageOption
*/
cssClass?: string | string[] = '';
cssClass?: string | string[];
}

/**
* Actions method option
*
* @interface ActionsOption
*/
interface ActionsOption {
interface BaseActionsOption {
/**
* either 'text' or 'button',
* Either 'text' or 'button'.
*
* @type {('text' | 'button')}
* @memberof ActionsOption
*/
type: 'text' | 'button' = 'text';
type: 'text' | 'button';
/**
* array of 'button' objects if type is 'button'. object of 'text' otherwise.
* Array of 'ButtonObject' if type is 'button'. Object of 'TextObject' otherwise.
*
* @type {ButtonObject[]|TextObject[]}
* @type {ButtonObject[]|TextObject}
* @memberof ActionsOption
*/
action: ButtonObject[] | TextObject[];
action: ButtonObject[] | TextObject;
/**
* a string or array of custom CSS classes you want to be added.
* A string or array of custom CSS classes you want to be added.
*
* @type {string|string[]}
* @memberof ActionsOption
*/
cssClass?: string | string[] = '';
cssClass?: string | string[];
/**
* should the actions sections be hidden when submitted.
* Should the actions sections be hidden when submitted.
*
* @type {boolean}
* @memberof ActionsOption
*/
autoHide?: boolean = true;
autoHide?: boolean;
/**
* text from action is added as a message in UI from human side.
* Text from action is added as a message in UI from human side.
*
* @type {boolean}
* @memberof ActionsOption
*/
autoMessage?: boolean = true;
addMessage?: boolean;
}

/**
* Button object
* Text action option.
*
* @interface ButtonObject
* @interface TextObject
*/
interface ButtonObject {
interface TextObject {
/**
* icon to show in button.
* Size of the input to show. Relies on HTML size attribute for input elements.
*
* @type {string}
* @memberof ButtonObject
* @type {number}
* @memberof TextObject
*/
icon?: string = '';
size?: number;
/**
* Text to show in the button. be creative!
* Could be any of the valid types for HTML input elements. e.g.: number, tel, time, date, email, etc.
*
* @type {string}
* @memberof ButtonObject
* @memberof TextObject
*/
text: string = '';
sub_type?: string;
/**
* this is how you will identify the button when result is returned.
* Pre-populates the text field. Only for 'text' type.
*
* @type {string}
* @memberof ButtonObject
* @memberof TextObject
*/
value: string = '';
value: string;
/**
* a string or array of custom CSS classes you want to be added.
* Sets the placeholder text for the input element.
*
* @type {string|string[]}
* @memberof ButtonObject
* @type {string}
* @memberof TextObject
*/
cssClass?: string | string[] = '';
placeholder?: string;
}

/**
* Text action option.
* Button object
*
* @interface TextObject
* @interface ButtonObject
*/
interface TextObject {
interface ButtonObject {
/**
* size of the input to show. Relies on HTML size attribute for input elements.
* Icon to show in button.
*
* @type {number}
* @memberof TextObject
* @type {string}
* @memberof ButtonObject
*/
size?: number = 30;
icon?: string;
/**
* Could be any of the valid types for HTML input elements. e.g.: number, tel, time, date, email, etc.
* Text to show in the button. be creative!
*
* @type {string}
* @memberof TextObject
* @memberof ButtonObject
*/
sub_type?: string = '';
text: string;
/**
* pre-populates the text field. Only for 'text' type.
* This is how you will identify the button when result is returned.
*
* @type {string}
* @memberof TextObject
* @memberof ButtonObject
*/
value: string = '';
value: string;
/**
* Sets the placeholder text for the input element.
* A string or array of custom CSS classes you want to be added.
*
* @type {string}
* @memberof TextObject
* @type {string|string[]}
* @memberof ButtonObject
*/
placeholder?: string = '';
cssClass?: string | string[];
}

interface TextActionOption extends BaseActionsOption {
action: TextObject;
}

interface ButtonActionOption extends BaseActionsOption {
action: ButtonObject[];
}

/**
* Result object.
*
* @interface ResultObject
*/
interface ResultObject {
/**
* 'Text' or 'Button' Type of the action it was returned from.
Expand All @@ -199,20 +218,20 @@ interface ResultObject {
* @type {string}
* @memberof ResultObject
*/
value: string = '';
value: string;
/**
* Only present if type of message is 'button'. same as the 'text' in button object.
*
* @type {string}
* @memberof ResultObject
*/
text: string = '';
text: string;
}

declare class BotUI {


constructor(id: string, opts?: BotUIOptions) { }
constructor(id: string, opts?: BotUIOptions);

message: {
/**
Expand Down Expand Up @@ -272,9 +291,9 @@ declare class BotUI {
/**
* Shows the action section.
*
* @returns {Promise<void>}
* @returns {Promise<ResultObject>}
*/
show(action: ActionsOption): Promise<void>;
show(action: BaseActionsOption): Promise<ResultObject>;
/**
* Hides the action section.
*
Expand All @@ -285,15 +304,15 @@ declare class BotUI {
* Shows the action section and sets the action type to text. Its a shorthand to show.
*
* @param {ActionsOption} action
* @returns {Promist<ResultObject>}
* @returns {Promise<ResultObject>}
*/
text(action: ActionsOption): Promist<ResultObject>;
text(action: TextActionOption): Promise<ResultObject>;
/**
* Shows the action section and sets the action type to button. Its a shorthand to show.
*
* @param {ActionsOption} action
* @returns {Promist<ResultObject>}
* @returns {Promise<ResultObject>}
*/
button(action: ActionsOption): Promist<ResultObject>;
button(action: ButtonActionOption): Promise<ResultObject>;
}
}
}

0 comments on commit 32a1be3

Please sign in to comment.