5
5
*/
6
6
interface BotUIOptions {
7
7
/**
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
9
9
*
10
10
* @type {boolean }
11
11
* @memberof BotUIOptions
12
12
*/
13
- debug ?: boolean = false ;
13
+ debug ?: boolean ;
14
14
/**
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.
16
16
*
17
17
* @type {boolean }
18
18
* @memberof BotUIOptions
19
19
*/
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 ;
21
25
}
22
26
23
27
/**
@@ -27,164 +31,179 @@ interface BotUIOptions {
27
31
*/
28
32
interface MessageOption {
29
33
/**
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
31
36
*
32
37
* @type {boolean }
33
38
* @memberof MessageOption
34
39
*/
35
- loading ?: boolean = false ;
40
+ loading ?: boolean ;
36
41
/**
37
- * wait before showing the message. in milliseconds.
42
+ * Wait before showing the message. in milliseconds.
38
43
*
39
44
* @type {number }
40
45
* @memberof MessageOption
41
46
*/
42
- delay ?: number = 0 ;
47
+ delay ?: number ;
43
48
/**
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`.
45
51
*
46
52
* @type {('text' | 'embed') }
47
53
* @memberof MessageOption
48
54
*/
49
- type : 'text' | 'embed' = ' text ' ;
55
+ type : 'text' | 'embed' ;
50
56
/**
51
57
* Should be a URL if type is 'embed', text otherwise.
52
58
*
53
59
* @type {string }
54
60
* @memberof MessageOption
55
61
*/
56
- content : string = '' ;
62
+ content : string ;
57
63
/**
58
- * should be shown aligned to right side?
64
+ * Should be shown aligned to right side.
59
65
*
60
66
* @type {false }
61
67
* @memberof MessageOption
62
68
*/
63
69
human ?: false ;
64
70
/**
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.
66
72
*
67
73
* @type {string|string[] }
68
74
* @memberof MessageOption
69
75
*/
70
- cssClass ?: string | string [ ] = '' ;
76
+ cssClass ?: string | string [ ] ;
71
77
}
72
78
73
79
/**
74
80
* Actions method option
75
81
*
76
82
* @interface ActionsOption
77
83
*/
78
- interface ActionsOption {
84
+ interface BaseActionsOption {
79
85
/**
80
- * either 'text' or 'button',
86
+ * Either 'text' or 'button'.
81
87
*
82
88
* @type {('text' | 'button') }
83
89
* @memberof ActionsOption
84
90
*/
85
- type : 'text' | 'button' = 'text' ;
91
+ type : 'text' | 'button' ;
86
92
/**
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.
88
94
*
89
- * @type {ButtonObject[]|TextObject[] }
95
+ * @type {ButtonObject[]|TextObject }
90
96
* @memberof ActionsOption
91
97
*/
92
- action : ButtonObject [ ] | TextObject [ ] ;
98
+ action : ButtonObject [ ] | TextObject ;
93
99
/**
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.
95
101
*
96
102
* @type {string|string[] }
97
103
* @memberof ActionsOption
98
104
*/
99
- cssClass ?: string | string [ ] = '' ;
105
+ cssClass ?: string | string [ ] ;
100
106
/**
101
- * should the actions sections be hidden when submitted.
107
+ * Should the actions sections be hidden when submitted.
102
108
*
103
109
* @type {boolean }
104
110
* @memberof ActionsOption
105
111
*/
106
- autoHide ?: boolean = true ;
112
+ autoHide ?: boolean ;
107
113
/**
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.
109
115
*
110
116
* @type {boolean }
111
117
* @memberof ActionsOption
112
118
*/
113
- autoMessage ?: boolean = true ;
119
+ addMessage ?: boolean ;
114
120
}
115
121
116
122
/**
117
- * Button object
123
+ * Text action option.
118
124
*
119
- * @interface ButtonObject
125
+ * @interface TextObject
120
126
*/
121
- interface ButtonObject {
127
+ interface TextObject {
122
128
/**
123
- * icon to show in button .
129
+ * Size of the input to show. Relies on HTML size attribute for input elements .
124
130
*
125
- * @type {string }
126
- * @memberof ButtonObject
131
+ * @type {number }
132
+ * @memberof TextObject
127
133
*/
128
- icon ?: string = '' ;
134
+ size ?: number ;
129
135
/**
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.
131
137
*
132
138
* @type {string }
133
- * @memberof ButtonObject
139
+ * @memberof TextObject
134
140
*/
135
- text : string = '' ;
141
+ sub_type ? : string ;
136
142
/**
137
- * this is how you will identify the button when result is returned .
143
+ * Pre-populates the text field. Only for 'text' type .
138
144
*
139
145
* @type {string }
140
- * @memberof ButtonObject
146
+ * @memberof TextObject
141
147
*/
142
- value : string = '' ;
148
+ value : string ;
143
149
/**
144
- * a string or array of custom CSS classes you want to be added .
150
+ * Sets the placeholder text for the input element .
145
151
*
146
- * @type {string|string[] }
147
- * @memberof ButtonObject
152
+ * @type {string }
153
+ * @memberof TextObject
148
154
*/
149
- cssClass ?: string | string [ ] = '' ;
155
+ placeholder ?: string ;
150
156
}
151
157
152
158
/**
153
- * Text action option.
159
+ * Button object
154
160
*
155
- * @interface TextObject
161
+ * @interface ButtonObject
156
162
*/
157
- interface TextObject {
163
+ interface ButtonObject {
158
164
/**
159
- * size of the input to show. Relies on HTML size attribute for input elements .
165
+ * Icon to show in button .
160
166
*
161
- * @type {number }
162
- * @memberof TextObject
167
+ * @type {string }
168
+ * @memberof ButtonObject
163
169
*/
164
- size ?: number = 30 ;
170
+ icon ?: string ;
165
171
/**
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!
167
173
*
168
174
* @type {string }
169
- * @memberof TextObject
175
+ * @memberof ButtonObject
170
176
*/
171
- sub_type ? : string = '' ;
177
+ text : string ;
172
178
/**
173
- * pre-populates the text field. Only for 'text' type .
179
+ * This is how you will identify the button when result is returned .
174
180
*
175
181
* @type {string }
176
- * @memberof TextObject
182
+ * @memberof ButtonObject
177
183
*/
178
- value : string = '' ;
184
+ value : string ;
179
185
/**
180
- * Sets the placeholder text for the input element .
186
+ * A string or array of custom CSS classes you want to be added .
181
187
*
182
- * @type {string }
183
- * @memberof TextObject
188
+ * @type {string|string[] }
189
+ * @memberof ButtonObject
184
190
*/
185
- placeholder ?: string = '' ;
191
+ cssClass ?: string | string [ ] ;
186
192
}
187
193
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
+ */
188
207
interface ResultObject {
189
208
/**
190
209
* 'Text' or 'Button' Type of the action it was returned from.
@@ -199,20 +218,20 @@ interface ResultObject {
199
218
* @type {string }
200
219
* @memberof ResultObject
201
220
*/
202
- value : string = '' ;
221
+ value : string ;
203
222
/**
204
223
* Only present if type of message is 'button'. same as the 'text' in button object.
205
224
*
206
225
* @type {string }
207
226
* @memberof ResultObject
208
227
*/
209
- text : string = '' ;
228
+ text : string ;
210
229
}
211
230
212
231
declare class BotUI {
213
232
214
233
215
- constructor ( id : string , opts ?: BotUIOptions ) { }
234
+ constructor ( id : string , opts ?: BotUIOptions ) ;
216
235
217
236
message : {
218
237
/**
@@ -272,9 +291,9 @@ declare class BotUI {
272
291
/**
273
292
* Shows the action section.
274
293
*
275
- * @returns {Promise<void > }
294
+ * @returns {Promise<ResultObject > }
276
295
*/
277
- show ( action : ActionsOption ) : Promise < void > ;
296
+ show ( action : BaseActionsOption ) : Promise < ResultObject > ;
278
297
/**
279
298
* Hides the action section.
280
299
*
@@ -285,15 +304,15 @@ declare class BotUI {
285
304
* Shows the action section and sets the action type to text. Its a shorthand to show.
286
305
*
287
306
* @param {ActionsOption } action
288
- * @returns {Promist <ResultObject> }
307
+ * @returns {Promise <ResultObject> }
289
308
*/
290
- text ( action : ActionsOption ) : Promist < ResultObject > ;
309
+ text ( action : TextActionOption ) : Promise < ResultObject > ;
291
310
/**
292
311
* Shows the action section and sets the action type to button. Its a shorthand to show.
293
312
*
294
313
* @param {ActionsOption } action
295
- * @returns {Promist <ResultObject> }
314
+ * @returns {Promise <ResultObject> }
296
315
*/
297
- button ( action : ActionsOption ) : Promist < ResultObject > ;
316
+ button ( action : ButtonActionOption ) : Promise < ResultObject > ;
298
317
}
299
- }
318
+ }
0 commit comments