Skip to content

Commit 32a1be3

Browse files
committed
fix: fix index.d.ts
1 parent 31d5e5e commit 32a1be3

File tree

1 file changed

+89
-70
lines changed

1 file changed

+89
-70
lines changed

typings/index.d.ts

Lines changed: 89 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55
*/
66
interface BotUIOptions {
77
/**
8-
* set this to true if you want to debug the underlaying Vue instance
8+
* Set this to true if you want to debug the underlaying Vue instance
99
*
1010
* @type {boolean}
1111
* @memberof BotUIOptions
1212
*/
13-
debug?: boolean = false;
13+
debug?: boolean;
1414
/**
15-
* set this to false if you already have FontAwesome in your project and don't want it to be loaded again by BotUI.
15+
* Set this to false if you already have FontAwesome in your project and don't want it to be loaded again by BotUI.
1616
*
1717
* @type {boolean}
1818
* @memberof BotUIOptions
1919
*/
20-
fontawesome?: boolean = true;
20+
fontawesome?: boolean;
21+
/**
22+
* Set this to vue constructor when you use module loaded system e.g CMD or AMD.
23+
*/
24+
vue?: any;
2125
}
2226

2327
/**
@@ -27,164 +31,179 @@ interface BotUIOptions {
2731
*/
2832
interface MessageOption {
2933
/**
30-
* set to true if you want to show a loading state '3 animated dots'. available in version >= 0.3.1
34+
* Set to true if you want to show a loading state '3 animated dots'.
35+
* Available in version >= 0.3.1
3136
*
3237
* @type {boolean}
3338
* @memberof MessageOption
3439
*/
35-
loading?: boolean = false;
40+
loading?: boolean;
3641
/**
37-
* wait before showing the message. in milliseconds.
42+
* Wait before showing the message. in milliseconds.
3843
*
3944
* @type {number}
4045
* @memberof MessageOption
4146
*/
42-
delay?: number = 0;
47+
delay?: number;
4348
/**
44-
* either 'text' or 'embed'
49+
* Either 'text' or 'embed'.
50+
* If you set this to 'embed', BotUI will create an `iframe` element and set `content` as its `src`.
4551
*
4652
* @type {('text' | 'embed')}
4753
* @memberof MessageOption
4854
*/
49-
type: 'text' | 'embed' = 'text';
55+
type: 'text' | 'embed';
5056
/**
5157
* Should be a URL if type is 'embed', text otherwise.
5258
*
5359
* @type {string}
5460
* @memberof MessageOption
5561
*/
56-
content: string = '';
62+
content: string;
5763
/**
58-
* should be shown aligned to right side?
64+
* Should be shown aligned to right side.
5965
*
6066
* @type {false}
6167
* @memberof MessageOption
6268
*/
6369
human?: false;
6470
/**
65-
* a string or array of custom CSS classes you want to be added.
71+
* A string or array of custom CSS classes you want to be added.
6672
*
6773
* @type {string|string[]}
6874
* @memberof MessageOption
6975
*/
70-
cssClass?: string | string[] = '';
76+
cssClass?: string | string[];
7177
}
7278

7379
/**
7480
* Actions method option
7581
*
7682
* @interface ActionsOption
7783
*/
78-
interface ActionsOption {
84+
interface BaseActionsOption {
7985
/**
80-
* either 'text' or 'button',
86+
* Either 'text' or 'button'.
8187
*
8288
* @type {('text' | 'button')}
8389
* @memberof ActionsOption
8490
*/
85-
type: 'text' | 'button' = 'text';
91+
type: 'text' | 'button';
8692
/**
87-
* array of 'button' objects if type is 'button'. object of 'text' otherwise.
93+
* Array of 'ButtonObject' if type is 'button'. Object of 'TextObject' otherwise.
8894
*
89-
* @type {ButtonObject[]|TextObject[]}
95+
* @type {ButtonObject[]|TextObject}
9096
* @memberof ActionsOption
9197
*/
92-
action: ButtonObject[] | TextObject[];
98+
action: ButtonObject[] | TextObject;
9399
/**
94-
* a string or array of custom CSS classes you want to be added.
100+
* A string or array of custom CSS classes you want to be added.
95101
*
96102
* @type {string|string[]}
97103
* @memberof ActionsOption
98104
*/
99-
cssClass?: string | string[] = '';
105+
cssClass?: string | string[];
100106
/**
101-
* should the actions sections be hidden when submitted.
107+
* Should the actions sections be hidden when submitted.
102108
*
103109
* @type {boolean}
104110
* @memberof ActionsOption
105111
*/
106-
autoHide?: boolean = true;
112+
autoHide?: boolean;
107113
/**
108-
* text from action is added as a message in UI from human side.
114+
* Text from action is added as a message in UI from human side.
109115
*
110116
* @type {boolean}
111117
* @memberof ActionsOption
112118
*/
113-
autoMessage?: boolean = true;
119+
addMessage?: boolean;
114120
}
115121

116122
/**
117-
* Button object
123+
* Text action option.
118124
*
119-
* @interface ButtonObject
125+
* @interface TextObject
120126
*/
121-
interface ButtonObject {
127+
interface TextObject {
122128
/**
123-
* icon to show in button.
129+
* Size of the input to show. Relies on HTML size attribute for input elements.
124130
*
125-
* @type {string}
126-
* @memberof ButtonObject
131+
* @type {number}
132+
* @memberof TextObject
127133
*/
128-
icon?: string = '';
134+
size?: number;
129135
/**
130-
* Text to show in the button. be creative!
136+
* Could be any of the valid types for HTML input elements. e.g.: number, tel, time, date, email, etc.
131137
*
132138
* @type {string}
133-
* @memberof ButtonObject
139+
* @memberof TextObject
134140
*/
135-
text: string = '';
141+
sub_type?: string;
136142
/**
137-
* this is how you will identify the button when result is returned.
143+
* Pre-populates the text field. Only for 'text' type.
138144
*
139145
* @type {string}
140-
* @memberof ButtonObject
146+
* @memberof TextObject
141147
*/
142-
value: string = '';
148+
value: string;
143149
/**
144-
* a string or array of custom CSS classes you want to be added.
150+
* Sets the placeholder text for the input element.
145151
*
146-
* @type {string|string[]}
147-
* @memberof ButtonObject
152+
* @type {string}
153+
* @memberof TextObject
148154
*/
149-
cssClass?: string | string[] = '';
155+
placeholder?: string;
150156
}
151157

152158
/**
153-
* Text action option.
159+
* Button object
154160
*
155-
* @interface TextObject
161+
* @interface ButtonObject
156162
*/
157-
interface TextObject {
163+
interface ButtonObject {
158164
/**
159-
* size of the input to show. Relies on HTML size attribute for input elements.
165+
* Icon to show in button.
160166
*
161-
* @type {number}
162-
* @memberof TextObject
167+
* @type {string}
168+
* @memberof ButtonObject
163169
*/
164-
size?: number = 30;
170+
icon?: string;
165171
/**
166-
* Could be any of the valid types for HTML input elements. e.g.: number, tel, time, date, email, etc.
172+
* Text to show in the button. be creative!
167173
*
168174
* @type {string}
169-
* @memberof TextObject
175+
* @memberof ButtonObject
170176
*/
171-
sub_type?: string = '';
177+
text: string;
172178
/**
173-
* pre-populates the text field. Only for 'text' type.
179+
* This is how you will identify the button when result is returned.
174180
*
175181
* @type {string}
176-
* @memberof TextObject
182+
* @memberof ButtonObject
177183
*/
178-
value: string = '';
184+
value: string;
179185
/**
180-
* Sets the placeholder text for the input element.
186+
* A string or array of custom CSS classes you want to be added.
181187
*
182-
* @type {string}
183-
* @memberof TextObject
188+
* @type {string|string[]}
189+
* @memberof ButtonObject
184190
*/
185-
placeholder?: string = '';
191+
cssClass?: string | string[];
186192
}
187193

194+
interface TextActionOption extends BaseActionsOption {
195+
action: TextObject;
196+
}
197+
198+
interface ButtonActionOption extends BaseActionsOption {
199+
action: ButtonObject[];
200+
}
201+
202+
/**
203+
* Result object.
204+
*
205+
* @interface ResultObject
206+
*/
188207
interface ResultObject {
189208
/**
190209
* 'Text' or 'Button' Type of the action it was returned from.
@@ -199,20 +218,20 @@ interface ResultObject {
199218
* @type {string}
200219
* @memberof ResultObject
201220
*/
202-
value: string = '';
221+
value: string;
203222
/**
204223
* Only present if type of message is 'button'. same as the 'text' in button object.
205224
*
206225
* @type {string}
207226
* @memberof ResultObject
208227
*/
209-
text: string = '';
228+
text: string;
210229
}
211230

212231
declare class BotUI {
213232

214233

215-
constructor(id: string, opts?: BotUIOptions) { }
234+
constructor(id: string, opts?: BotUIOptions);
216235

217236
message: {
218237
/**
@@ -272,9 +291,9 @@ declare class BotUI {
272291
/**
273292
* Shows the action section.
274293
*
275-
* @returns {Promise<void>}
294+
* @returns {Promise<ResultObject>}
276295
*/
277-
show(action: ActionsOption): Promise<void>;
296+
show(action: BaseActionsOption): Promise<ResultObject>;
278297
/**
279298
* Hides the action section.
280299
*
@@ -285,15 +304,15 @@ declare class BotUI {
285304
* Shows the action section and sets the action type to text. Its a shorthand to show.
286305
*
287306
* @param {ActionsOption} action
288-
* @returns {Promist<ResultObject>}
307+
* @returns {Promise<ResultObject>}
289308
*/
290-
text(action: ActionsOption): Promist<ResultObject>;
309+
text(action: TextActionOption): Promise<ResultObject>;
291310
/**
292311
* Shows the action section and sets the action type to button. Its a shorthand to show.
293312
*
294313
* @param {ActionsOption} action
295-
* @returns {Promist<ResultObject>}
314+
* @returns {Promise<ResultObject>}
296315
*/
297-
button(action: ActionsOption): Promist<ResultObject>;
316+
button(action: ButtonActionOption): Promise<ResultObject>;
298317
}
299-
}
318+
}

0 commit comments

Comments
 (0)