@aws/mynah-ui 3.3.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -0
- package/README.md +3 -1
- package/dist/helper/store.d.ts +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/static.d.ts +1 -2
- package/package.json +1 -1
- package/docs/CONFIG.md +0 -190
- package/docs/DATAMODEL.md +0 -932
- package/docs/PROPERTIES.md +0 -615
- package/docs/STARTUP.md +0 -50
- package/docs/STYLING.md +0 -175
- package/docs/USAGE.md +0 -325
- package/docs/img/code-attachment.png +0 -0
- package/docs/img/data-model/chatItems/answer.png +0 -0
- package/docs/img/data-model/chatItems/answerStream.png +0 -0
- package/docs/img/data-model/chatItems/body.png +0 -0
- package/docs/img/data-model/chatItems/canBeVoted.png +0 -0
- package/docs/img/data-model/chatItems/codeReference-1.png +0 -0
- package/docs/img/data-model/chatItems/codeReference-2.png +0 -0
- package/docs/img/data-model/chatItems/codeResult.png +0 -0
- package/docs/img/data-model/chatItems/followUp-1.png +0 -0
- package/docs/img/data-model/chatItems/followUp-2.png +0 -0
- package/docs/img/data-model/chatItems/notification-1.png +0 -0
- package/docs/img/data-model/chatItems/notification-2.png +0 -0
- package/docs/img/data-model/chatItems/notification-3.png +0 -0
- package/docs/img/data-model/chatItems/notification-4.png +0 -0
- package/docs/img/data-model/chatItems/prompt.png +0 -0
- package/docs/img/data-model/chatItems/relatedContent-1.png +0 -0
- package/docs/img/data-model/chatItems/relatedContent-2.png +0 -0
- package/docs/img/data-model/chatItems/relatedContent-3.png +0 -0
- package/docs/img/data-model/chatItems/systemPrompt.png +0 -0
- package/docs/img/data-model/tabStore/loadingChat-1.png +0 -0
- package/docs/img/data-model/tabStore/loadingChat-2.png +0 -0
- package/docs/img/data-model/tabStore/promptInputDisabledState.png +0 -0
- package/docs/img/data-model/tabStore/promptInputPlaceholder.png +0 -0
- package/docs/img/data-model/tabStore/quickActionCommands.png +0 -0
- package/docs/img/data-model/tabStore/stopChatResponse.png +0 -0
- package/docs/img/data-model/tabStore/tabTitle.png +0 -0
- package/docs/img/feedbackOptions.png +0 -0
- package/docs/img/maxTabs1.png +0 -0
- package/docs/img/noPrompt.png +0 -0
- package/docs/img/notification.png +0 -0
- package/docs/img/onChatItemEngagement.png +0 -0
- package/docs/img/onChatPrompt.png +0 -0
- package/docs/img/onCodeInsertToCursorPosition.png +0 -0
- package/docs/img/onCopyCodeToClipboard.png +0 -0
- package/docs/img/onFollowupClicked.png +0 -0
- package/docs/img/onInfoLinkClick.png +0 -0
- package/docs/img/onLinkClick.png +0 -0
- package/docs/img/onOpenDiff.png +0 -0
- package/docs/img/onSendFeedback-1.png +0 -0
- package/docs/img/onSendFeedback-2.png +0 -0
- package/docs/img/onSendFeedback-3.png +0 -0
- package/docs/img/onShowMoreClick.png +0 -0
- package/docs/img/onSourceLinkClick.png +0 -0
- package/docs/img/onStopChatResponse.png +0 -0
- package/docs/img/onTabAdd.png +0 -0
- package/docs/img/onTabChange.png +0 -0
- package/docs/img/onTabRemove.png +0 -0
- package/docs/img/onVote.png +0 -0
- package/docs/img/prompt-with-code-attached.png +0 -0
- package/docs/img/texts/codeFileSuggestions.png +0 -0
- package/docs/img/texts/copyInsertToCursor.png +0 -0
- package/docs/img/texts/feedbackForm.png +0 -0
- package/docs/img/texts/mainTitle.png +0 -0
- package/docs/img/texts/noMoreTabs.png +0 -0
- package/docs/img/texts/spinnerText.png +0 -0
- package/docs/img/texts/stopGenerating.png +0 -0
- package/docs/img/texts/voteAndSourceActions.png +0 -0
- package/docs/img/theming-1.png +0 -0
- package/docs/img/theming-2.png +0 -0
package/docs/DATAMODEL.md
DELETED
|
@@ -1,932 +0,0 @@
|
|
|
1
|
-
# MynahUI Data Model (with how the things appear on screen)
|
|
2
|
-
|
|
3
|
-
There are few models for different items on the screen for mynah ui. Let's star from the top and go in detail one by one.
|
|
4
|
-
|
|
5
|
-
## Tab Data Store
|
|
6
|
-
|
|
7
|
-
All information you can set related with a tab.
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
interface MynahUIDataModel {
|
|
11
|
-
/**
|
|
12
|
-
* Tab title
|
|
13
|
-
* */
|
|
14
|
-
tabTitle?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Chat screen loading animation state (mainly use during the stream or getting the initial answer)
|
|
17
|
-
*/
|
|
18
|
-
loadingChat?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Show cancel button while loading the chat
|
|
21
|
-
* If you want to disable it globally, leave the onStopChatResponse on mynah ui constructor as undefined
|
|
22
|
-
* */
|
|
23
|
-
cancelButtonWhenLoading?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Quick Action commands to show when user hits / to the input initially
|
|
26
|
-
*/
|
|
27
|
-
quickActionCommands?: QuickActionCommandGroup[];
|
|
28
|
-
/**
|
|
29
|
-
* Placeholder to be shown on prompt input
|
|
30
|
-
*/
|
|
31
|
-
promptInputPlaceholder?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Info block to be shown under prompt input
|
|
34
|
-
*/
|
|
35
|
-
promptInputInfo?: string; // supports MARKDOWN string
|
|
36
|
-
/**
|
|
37
|
-
* Prompt input field disabled state, set to tru to disable it
|
|
38
|
-
*/
|
|
39
|
-
promptInputDisabledState?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* List of chat item objects to be shown on the web suggestions search screen
|
|
42
|
-
*/
|
|
43
|
-
chatItems?: ChatItem[];
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
You can set tab data with this model for `defaults`, initial `tabs` which can be set through [Constructor Properties](./PROPERTIES.md) or update a tab on runtime by using `mynahUI.updateStore(...)`.
|
|
48
|
-
|
|
49
|
-
Let's see which items is what.
|
|
50
|
-
|
|
51
|
-
### `tabTitle` (default: `"AWS Q"`)
|
|
52
|
-
Basically it is the tab title.
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
const mynahUI = new MynahUI({
|
|
56
|
-
tabs: {
|
|
57
|
-
'tab-1': {
|
|
58
|
-
...
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
mynahUI.updateStore('tab-1', {
|
|
64
|
-
tabTitle: 'Chat'
|
|
65
|
-
})
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
<p align="center">
|
|
69
|
-
<img src="./img/data-model/tabStore/tabTitle.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
70
|
-
</p>
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
### `loadingChat` (default: `false`)
|
|
75
|
-
Basically it is the tab title.
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
const mynahUI = new MynahUI({
|
|
79
|
-
tabs: {
|
|
80
|
-
'tab-1': {
|
|
81
|
-
...
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
mynahUI.updateStore('tab-1', {
|
|
87
|
-
loadingChat: true
|
|
88
|
-
})
|
|
89
|
-
```
|
|
90
|
-
When you set `loadingChat` to true, if there is a streaming card it will start to animate the spinner in two different way. If the card body is empty it will show the `spinnerText` from the texts inside the config right next to a spinning circle. If the card has a body (after it is updated for example) it will show a sliding colored bottom border animation.
|
|
91
|
-
|
|
92
|
-
In addition to the spinner, if `onStopChatResponse` is attached globally through MynahUI main class constructor properties _(see [Constructor properties](./PROPERTIES.md) for details)_ and `cancelButtonWhenLoading` is not set to false specifically for that tab it will show the stop generating button too.
|
|
93
|
-
|
|
94
|
-
<p align="center">
|
|
95
|
-
<img src="./img/data-model/tabStore/loadingChat-1.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
96
|
-
</p>
|
|
97
|
-
<p align="center">
|
|
98
|
-
<img src="./img/data-model/tabStore/loadingChat-2.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
99
|
-
</p>
|
|
100
|
-
|
|
101
|
-
---
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
### `cancelButtonWhenLoading` (default: `true`)
|
|
105
|
-
If `onStopChatResponse` is attached globally through `MynahUI` main class constructor properties _(see [Constructor properties](./PROPERTIES.md) for details)_ it will show a stop generating button to let the user cancel the ongoing action.
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
const mynahUI = new MynahUI({
|
|
109
|
-
tabs: {
|
|
110
|
-
'tab-1': {
|
|
111
|
-
...
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
mynahUI.updateStore('tab-1', {
|
|
117
|
-
loadingChat: true,
|
|
118
|
-
cancelButtonWhenLoading: true
|
|
119
|
-
})
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
<p align="center">
|
|
123
|
-
<img src="./img/data-model/tabStore/stopChatResponse.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
124
|
-
</p>
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
### `quickActionCommands` (default: `[]`)
|
|
130
|
-
Quick action commands are the predefined commands which user can pick between. When users hit `/` from their keyboard as the initial char in the input, if there is an available list it will show up as a overlay menu.
|
|
131
|
-
|
|
132
|
-
If you want a command immediately run after the selection and trigger `onChatPrompt` event (attached to the `MynahUI` main instance through the [Constructor properties](./PROPERTIES.md)) leave the `placeholder` attribute undefined. MynahUI will decide that it doesn't allow additional prompt text for that command and immediately run the trigger. _(See command-2 in the example)_
|
|
133
|
-
|
|
134
|
-
```typescript
|
|
135
|
-
const mynahUI = new MynahUI({
|
|
136
|
-
tabs: {
|
|
137
|
-
'tab-1': {
|
|
138
|
-
...
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
mynahUI.updateStore('tab-1', {
|
|
144
|
-
quickActionCommands: [
|
|
145
|
-
{
|
|
146
|
-
groupName: 'Command Group 1',
|
|
147
|
-
commands: [
|
|
148
|
-
{
|
|
149
|
-
command: '/command-1',
|
|
150
|
-
placeholder: 'Command which accepts a prompt after the command selection',
|
|
151
|
-
description: 'Command 1 description',
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
command: '/command-2',
|
|
155
|
-
description: 'Command 2 description',
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
groupName: 'Command Group 2',
|
|
161
|
-
commands: [
|
|
162
|
-
{
|
|
163
|
-
command: '/command-3',
|
|
164
|
-
placeholder: 'Command which accepts a prompt after the command selection',
|
|
165
|
-
description: 'Command 3 description',
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
// Command Group without title
|
|
171
|
-
commands: [
|
|
172
|
-
{
|
|
173
|
-
command: '/command-4',
|
|
174
|
-
placeholder: 'Command which accepts a prompt after the command selection',
|
|
175
|
-
description: 'Command 4 description',
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
]
|
|
180
|
-
})
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
<p align="center">
|
|
184
|
-
<img src="./img/data-model/tabStore/quickActionCommands.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
185
|
-
</p>
|
|
186
|
-
|
|
187
|
-
To handle the incoming command (if there is) check it with the prompt object in the `onChatPrompt` event.
|
|
188
|
-
|
|
189
|
-
```typescript
|
|
190
|
-
const mynahUI = new MynahUI({
|
|
191
|
-
...
|
|
192
|
-
onChatPrompt: (prompt)=>{
|
|
193
|
-
if(prompt.command !== undefined){
|
|
194
|
-
switch (prompt.command) {
|
|
195
|
-
case '/command-1':
|
|
196
|
-
console.log(`Command 1 selected with prompt: ${prompt.prompt}`);
|
|
197
|
-
break;
|
|
198
|
-
case '/command-2':
|
|
199
|
-
console.log('Command 2 selected');
|
|
200
|
-
break;
|
|
201
|
-
default:
|
|
202
|
-
...
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
### `promptInputPlaceholder` (default: `''`)
|
|
213
|
-
|
|
214
|
-
This is the placeholder text for the prompt input
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
const mynahUI = new MynahUI({
|
|
218
|
-
tabs: {
|
|
219
|
-
'tab-1': {
|
|
220
|
-
...
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
mynahUI.updateStore('tab-1', {
|
|
226
|
-
promptInputPlaceholder: 'Ask a question or “/” for capabilities'
|
|
227
|
-
})
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
<p align="center">
|
|
231
|
-
<img src="./img/data-model/tabStore/promptInputPlaceholder.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
232
|
-
</p>
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
### `promptInputInfo` (default: `''`)
|
|
237
|
-
|
|
238
|
-
This is a info field under the bottom of the prompt input field, like a footer text
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
const mynahUI = new MynahUI({
|
|
242
|
-
tabs: {
|
|
243
|
-
'tab-1': {
|
|
244
|
-
...
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
mynahUI.updateStore('tab-1', {
|
|
250
|
-
promptInputInfo: 'Use of Amazon Q is subject to the [AWS Responsible AI Policy](https://aws.com).',
|
|
251
|
-
})
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
<p align="center">
|
|
255
|
-
<img src="./img/data-model/tabStore/promptInputPlaceholder.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
256
|
-
</p>
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
### `promptInputDisabledState` (default: `false`)
|
|
261
|
-
|
|
262
|
-
This is the disabled state if the prompt input field. When set to true, user cannot focus to the input and cannot click to the send button.
|
|
263
|
-
|
|
264
|
-
```typescript
|
|
265
|
-
const mynahUI = new MynahUI({
|
|
266
|
-
tabs: {
|
|
267
|
-
'tab-1': {
|
|
268
|
-
...
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
mynahUI.updateStore('tab-1', {
|
|
274
|
-
promptInputDisabledState: true,
|
|
275
|
-
})
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
<p align="center">
|
|
279
|
-
<img src="./img/data-model/tabStore/promptInputDisabledState.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
280
|
-
</p>
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
### `chatItems` (default: `[]`)
|
|
285
|
-
|
|
286
|
-
This is holding the chat items. If you provide it through the `defaults` or inside a tab item in the initial `tabs` property in the [Constructor properties](./PROPERTIES.md) you can give the whole set.
|
|
287
|
-
|
|
288
|
-
**BUT** if you will set it through `updateStore` it will append the items in the list to the current chatItems list. In case if you need to update the list with a new one manually on runtime, you need to send an empty list first and than send the desired new list.
|
|
289
|
-
|
|
290
|
-
```typescript
|
|
291
|
-
const mynahUI = new MynahUI({
|
|
292
|
-
tabs: {
|
|
293
|
-
'tab-1': {
|
|
294
|
-
...
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
mynahUI.updateStore('tab-1', {
|
|
300
|
-
chatItems: [],
|
|
301
|
-
})
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
<p><br/></p>
|
|
305
|
-
|
|
306
|
-
---
|
|
307
|
-
|
|
308
|
-
<p><br/></p>
|
|
309
|
-
|
|
310
|
-
# `ChatItem` (and how they appear on screen)
|
|
311
|
-
|
|
312
|
-
There are basically 2 main types of chat items. One is to show a file list and the other one is for all other items with a body of markdown string content.
|
|
313
|
-
|
|
314
|
-
Let's start with the model definition:
|
|
315
|
-
|
|
316
|
-
```typescript
|
|
317
|
-
// There can be more types on the ChatItemType enum list
|
|
318
|
-
// However those are the only ones getting used by MynahUI
|
|
319
|
-
enum ChatItemType {
|
|
320
|
-
CODE_RESULT = 'code-result',
|
|
321
|
-
ANSWER_STREAM = 'answer-stream',
|
|
322
|
-
ANSWER = 'answer',
|
|
323
|
-
PROMPT = 'prompt',
|
|
324
|
-
SYSTEM_PROMPT = 'system-prompt'
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
interface ChatItem {
|
|
328
|
-
type: ChatItemType;
|
|
329
|
-
fileList?: {
|
|
330
|
-
filePaths?: string[];
|
|
331
|
-
deletedFiles?: string[];
|
|
332
|
-
};
|
|
333
|
-
body?: string; // supports MARKDOWN string
|
|
334
|
-
messageId?: string;
|
|
335
|
-
canBeVoted?: boolean; // requires messageId to be filled to show vote thumbs
|
|
336
|
-
relatedContent?: {
|
|
337
|
-
title?: string;
|
|
338
|
-
content: SourceLink[];
|
|
339
|
-
};
|
|
340
|
-
followUp?: {
|
|
341
|
-
text?: string;
|
|
342
|
-
options?: ChatItemFollowUp[];
|
|
343
|
-
};
|
|
344
|
-
codeReference?: ReferenceTrackerInformation[];
|
|
345
|
-
}
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
Let's see all kind of examples and what parameter reflects to what.
|
|
349
|
-
|
|
350
|
-
## `type`
|
|
351
|
-
|
|
352
|
-
### ChatItemType.`CODE_RESULT` and `fileList` _(position: left)_
|
|
353
|
-
|
|
354
|
-
Use for showing a file list. You have to provide the `fileList` if your chat item type is `CODE_RESULT`. See the example below.
|
|
355
|
-
|
|
356
|
-
```typescript
|
|
357
|
-
const mynahUI = new MynahUI({
|
|
358
|
-
tabs: {
|
|
359
|
-
'tab-1': {
|
|
360
|
-
...
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
mynahUI.addChatItem(tabId, {
|
|
366
|
-
type: ChatItemType.CODE_RESULT,
|
|
367
|
-
fileList: {
|
|
368
|
-
filePaths: [ 'src/App.tsx', 'devfile.yaml', 'src/App.test.tsx' ],
|
|
369
|
-
},
|
|
370
|
-
codeReference: [
|
|
371
|
-
{
|
|
372
|
-
information: 'Reference code *under the MIT license* from repository `amazon`.'
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
information: 'Reference code *under the MIT license* from repository `aws`.'
|
|
376
|
-
},
|
|
377
|
-
],
|
|
378
|
-
canBeVoted: true,
|
|
379
|
-
messageId: new Date().getTime().toString()
|
|
380
|
-
});
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
<p align="center">
|
|
384
|
-
<img src="./img/data-model/chatItems/codeResult.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
385
|
-
</p>
|
|
386
|
-
|
|
387
|
-
---
|
|
388
|
-
|
|
389
|
-
### ChatItemType.`ANSWER_STREAM` _(position: left)_
|
|
390
|
-
Use for streaming cards. It is better to start with an empty string to let the initial spinner rotate. As far as the `loadingState` is true for the tab which holds this chat item, it will show the spinner (rotating circle for empty state and bottom border for with a body).
|
|
391
|
-
|
|
392
|
-
When you add a new chat item with type `ANSWER_STREAM` MynahUI will set it as the streaming card and when you call `updateLastChatAnswer` it will update this.
|
|
393
|
-
|
|
394
|
-
```typescript
|
|
395
|
-
const mynahUI = new MynahUI({
|
|
396
|
-
tabs: {
|
|
397
|
-
'tab-1': {
|
|
398
|
-
...
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
mynahUI.addChatItem('tab-1', {
|
|
404
|
-
type: ChatItemType.ANSWER_STREAM,
|
|
405
|
-
body: ''
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
// After a moment
|
|
409
|
-
mynahUI.updateLastChatAnswer('tab-1', {
|
|
410
|
-
body: `### How to create a React stateless function component
|
|
411
|
-
|
|
412
|
-
*React .14* introduced a simpler way to define components called stateless functional components.
|
|
413
|
-
`
|
|
414
|
-
});
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
<p align="center">
|
|
418
|
-
<img src="./img/data-model/chatItems/answerStream.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
419
|
-
</p>
|
|
420
|
-
|
|
421
|
-
---
|
|
422
|
-
|
|
423
|
-
### ChatItemType.`ANSWER` _(position: left)_
|
|
424
|
-
Use for all kind of answers. Including the followups etc.
|
|
425
|
-
|
|
426
|
-
And yes, except the `fileList` you can combine followups and markdown string content chat items at once. Which means that a single chat item can also contain the `followUp` at the same time with `body`.
|
|
427
|
-
|
|
428
|
-
```typescript
|
|
429
|
-
const mynahUI = new MynahUI({
|
|
430
|
-
tabs: {
|
|
431
|
-
'tab-1': {
|
|
432
|
-
...
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
mynahUI.addChatItem('tab-1', {
|
|
438
|
-
type: ChatItemType.ANSWER,
|
|
439
|
-
body: 'Hi, I\'m Amazon Q. I can answer your software development questions. Ask me to explain, debug, or optimize your code. You can enter `/` to see a list of quick actions.'
|
|
440
|
-
followUp:{
|
|
441
|
-
text: 'Or you can select one of these',
|
|
442
|
-
options: [
|
|
443
|
-
{
|
|
444
|
-
pillText: 'Explain selected code',
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
pillText: 'How can Amazon Q help me?',
|
|
448
|
-
prompt: 'How can Amazon Q help me?',
|
|
449
|
-
}
|
|
450
|
-
],
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
<p align="center">
|
|
456
|
-
<img src="./img/data-model/chatItems/answer.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
457
|
-
</p>
|
|
458
|
-
|
|
459
|
-
---
|
|
460
|
-
|
|
461
|
-
### ChatItemType.`PROMPT` _(position: right)_
|
|
462
|
-
Use for user prompts. You can also send followups to let them appear on right.
|
|
463
|
-
|
|
464
|
-
```typescript
|
|
465
|
-
const mynahUI = new MynahUI({
|
|
466
|
-
tabs: {
|
|
467
|
-
'tab-1': {
|
|
468
|
-
...
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
mynahUI.addChatItem('tab-1', {
|
|
474
|
-
type: ChatItemType.PROMPT,
|
|
475
|
-
body: 'Who are you?'
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
mynahUI.addChatItem('tab-1', {
|
|
479
|
-
type: ChatItemType.PROMPT,
|
|
480
|
-
followUp:{
|
|
481
|
-
text: 'Or you can select one of these',
|
|
482
|
-
options: [
|
|
483
|
-
{
|
|
484
|
-
pillText: 'Explain selected code',
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
pillText: 'How can Amazon Q help me?',
|
|
488
|
-
prompt: 'How can Amazon Q help me?',
|
|
489
|
-
}
|
|
490
|
-
],
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
<p align="center">
|
|
496
|
-
<img src="./img/data-model/chatItems/prompt.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
497
|
-
</p>
|
|
498
|
-
|
|
499
|
-
---
|
|
500
|
-
|
|
501
|
-
### ChatItemType.`SYSTEM_PROMPT` _(position: right)_
|
|
502
|
-
Use for sysyem prompts. Only difference with `PROMPT` is the color of the chat card. (Depends on your **[Styling Configuration](STYLING.md)**) You can also send followups to let them appear on right.
|
|
503
|
-
|
|
504
|
-
```typescript
|
|
505
|
-
const mynahUI = new MynahUI({
|
|
506
|
-
tabs: {
|
|
507
|
-
'tab-1': {
|
|
508
|
-
...
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
mynahUI.addChatItem('tab-1', {
|
|
514
|
-
type: ChatItemType.SYSTEM_PROMPT,
|
|
515
|
-
body: 'This is a system prompt'
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
mynahUI.addChatItem('tab-1', {
|
|
519
|
-
type: ChatItemType.SYSTEM_PROMPT,
|
|
520
|
-
followUp: {
|
|
521
|
-
text: 'Or you can select one of these',
|
|
522
|
-
options: [
|
|
523
|
-
{
|
|
524
|
-
pillText: 'Explain selected code',
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
pillText: 'How can Amazon Q help me?',
|
|
528
|
-
prompt: 'How can Amazon Q help me?',
|
|
529
|
-
}
|
|
530
|
-
],
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
<p align="center">
|
|
536
|
-
<img src="./img/data-model/chatItems/systemPrompt.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
537
|
-
</p>
|
|
538
|
-
|
|
539
|
-
---
|
|
540
|
-
|
|
541
|
-
## `body`
|
|
542
|
-
Basically the body of the card. Which you can send a full markdown string. Allows code blocks, links etc.
|
|
543
|
-
|
|
544
|
-
```typescript
|
|
545
|
-
const mynahUI = new MynahUI({
|
|
546
|
-
tabs: {
|
|
547
|
-
'tab-1': {
|
|
548
|
-
...
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
mynahUI.addChatItem('tab-1', {
|
|
554
|
-
type: ChatItemType.ANSWER,
|
|
555
|
-
body: "## Here'a heading 2\nAnd also here are some code blocks which supports most common languages.\n```typescript\nconst a = 5;\n```\n You can also use some `inline code` items too.\n And also for example [a link](https://aws.com)"
|
|
556
|
-
});
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
<p align="center">
|
|
560
|
-
<img src="./img/data-model/chatItems/body.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
561
|
-
</p>
|
|
562
|
-
|
|
563
|
-
---
|
|
564
|
-
|
|
565
|
-
## `canBeVoted`
|
|
566
|
-
It enables the up and down vote buttons for that particular chat item. Important thing to remember here is that you have provide a `messageId` together with the `canBeVoted` to let the buttons appear and trigger the `onVote` event which can be binded through [Constructor properties](./PROPERTIES.md).
|
|
567
|
-
|
|
568
|
-
```typescript
|
|
569
|
-
const mynahUI = new MynahUI({
|
|
570
|
-
tabs: {
|
|
571
|
-
'tab-1': {
|
|
572
|
-
...
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
mynahUI.addChatItem('tab-1', {
|
|
578
|
-
type: ChatItemType.ANSWER,
|
|
579
|
-
messageId: '1', // Should be a unique one,
|
|
580
|
-
canBeVoted: true,
|
|
581
|
-
body: "Here's a message which **can** be voted."
|
|
582
|
-
});
|
|
583
|
-
|
|
584
|
-
mynahUI.addChatItem('tab-1', {
|
|
585
|
-
type: ChatItemType.ANSWER,
|
|
586
|
-
messageId: '2', // Should be a unique one,
|
|
587
|
-
canBeVoted: false,
|
|
588
|
-
body: "Here's another message which **cannot** be voted."
|
|
589
|
-
});
|
|
590
|
-
```
|
|
591
|
-
|
|
592
|
-
<p align="center">
|
|
593
|
-
<img src="./img/data-model/chatItems/canBeVoted.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
594
|
-
</p>
|
|
595
|
-
|
|
596
|
-
---
|
|
597
|
-
|
|
598
|
-
## `relatedContent`
|
|
599
|
-
It allow you to show some related links under the body of the chat item. It shows one item and if you provided more user can expand the list with the show more button.
|
|
600
|
-
|
|
601
|
-
If you also provide a markdown body for the source link, it will generate a tooltip to show more details for it.
|
|
602
|
-
|
|
603
|
-
See the example below.
|
|
604
|
-
|
|
605
|
-
```typescript
|
|
606
|
-
const mynahUI = new MynahUI({
|
|
607
|
-
tabs: {
|
|
608
|
-
'tab-1': {
|
|
609
|
-
...
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
mynahUI.addChatItem('tab-1', {
|
|
615
|
-
type: ChatItemType.ANSWER,
|
|
616
|
-
messageId: '1', // Should be a unique one,
|
|
617
|
-
body: "Here's a message with source links.",
|
|
618
|
-
relatedContent: {
|
|
619
|
-
title: 'Related Link',
|
|
620
|
-
content: [
|
|
621
|
-
{
|
|
622
|
-
url: 'https://aws.com/deep/url/1',
|
|
623
|
-
title: 'Related content 1',
|
|
624
|
-
body: '## This is the body of the related\nAnd yes it also supports markdown!\n```typescript\nconst a = 5;\n```\n',
|
|
625
|
-
},
|
|
626
|
-
{
|
|
627
|
-
url: 'https://aws.com/more/deeper/url/2',
|
|
628
|
-
title: 'Related content 2',
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
url: 'https://aws.com/deep/url/3',
|
|
632
|
-
title: 'Related content 3',
|
|
633
|
-
}
|
|
634
|
-
]
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
```
|
|
638
|
-
|
|
639
|
-
<p align="center">
|
|
640
|
-
<img src="./img/data-model/chatItems/relatedContent-1.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
641
|
-
</p>
|
|
642
|
-
<p align="center">
|
|
643
|
-
<img src="./img/data-model/chatItems/relatedContent-2.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
644
|
-
</p>
|
|
645
|
-
<p align="center">
|
|
646
|
-
<img src="./img/data-model/chatItems/relatedContent-3.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
647
|
-
</p>
|
|
648
|
-
|
|
649
|
-
---
|
|
650
|
-
|
|
651
|
-
## `followUp`
|
|
652
|
-
Followups allows you to add predefined direct triggers for the user for ease of use. Instead of typing a followup question, they can select from the provided ones. But you can also use them to get user input some from multiple choice options before going further for example.
|
|
653
|
-
|
|
654
|
-
Here's the model for the `options` attribute for the `followUp`.
|
|
655
|
-
|
|
656
|
-
```typescript
|
|
657
|
-
interface ChatItemFollowUp {
|
|
658
|
-
type?: string;
|
|
659
|
-
pillText: string;
|
|
660
|
-
prompt?: string;
|
|
661
|
-
disabled?: boolean;
|
|
662
|
-
description?: string;
|
|
663
|
-
status?: 'info' | 'success' | 'warning' | 'error';
|
|
664
|
-
icon?: MynahIcons;
|
|
665
|
-
}
|
|
666
|
-
```
|
|
667
|
-
|
|
668
|
-
Let's see all the possible options you can do with the followups.
|
|
669
|
-
|
|
670
|
-
```typescript
|
|
671
|
-
const mynahUI = new MynahUI({
|
|
672
|
-
tabs: {
|
|
673
|
-
'tab-1': {
|
|
674
|
-
...
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
mynahUI.addChatItem('tab-1', {
|
|
680
|
-
type: ChatItemType.ANSWER,
|
|
681
|
-
followUp: {
|
|
682
|
-
text: 'Followup All option types',
|
|
683
|
-
options: [
|
|
684
|
-
{
|
|
685
|
-
pillText: 'Trigger automatically',
|
|
686
|
-
prompt: 'This prompt will be triggered automatically',
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
pillText: 'Followup with tooltip',
|
|
690
|
-
description: 'This markdown will be shown **when you hover only**.'
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
pillText: 'Status Danger',
|
|
694
|
-
status: 'error',
|
|
695
|
-
icon: MynahIcons.BLOCK,
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
pillText: 'Status Warning',
|
|
699
|
-
status: 'warning',
|
|
700
|
-
icon: MynahIcons.WARNING,
|
|
701
|
-
},
|
|
702
|
-
{
|
|
703
|
-
pillText: 'Status Ok',
|
|
704
|
-
status: 'success',
|
|
705
|
-
icon: MynahIcons.OK,
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
pillText: 'Status Info',
|
|
709
|
-
status: 'info',
|
|
710
|
-
},
|
|
711
|
-
{
|
|
712
|
-
pillText: 'This is disabled',
|
|
713
|
-
disabled: true,
|
|
714
|
-
}
|
|
715
|
-
]
|
|
716
|
-
}
|
|
717
|
-
});
|
|
718
|
-
```
|
|
719
|
-
|
|
720
|
-
<p align="center">
|
|
721
|
-
<img src="./img/data-model/chatItems/followUp-1.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
722
|
-
</p>
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
You can also make them appear on the right by just changing the type of the chat item.
|
|
726
|
-
|
|
727
|
-
```typescript
|
|
728
|
-
mynahUI.addChatItem('tab-1', {
|
|
729
|
-
type: ChatItemType.SYSTEM_PROMPT,
|
|
730
|
-
followUp: {
|
|
731
|
-
... // Same with above
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
```
|
|
735
|
-
|
|
736
|
-
<p align="center">
|
|
737
|
-
<img src="./img/data-model/chatItems/followUp-2.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
738
|
-
</p>
|
|
739
|
-
|
|
740
|
-
---
|
|
741
|
-
|
|
742
|
-
## `codeReference`
|
|
743
|
-
This is one of the most complex and hard to tell features you can use on `MynahUI`. But it basically allows you to add some highlights and let them show some tooltips when user hovers to them.
|
|
744
|
-
|
|
745
|
-
They reflect their position according to the whole body
|
|
746
|
-
|
|
747
|
-
**BUT;** if they appear inside a code block, when user clicks one of the copy or the insert to cursor position buttons in the footer of the code block, that `codeReference` content span position will be recalculated according to the position inside the code block while sending it to the events `onCopyCodeToClipboard` or `onCodeInsertToCursorPosition` which can be binded through [Constructor properties](./PROPERTIES.md).
|
|
748
|
-
|
|
749
|
-
#### Note:
|
|
750
|
-
The position for the recommandation span has to be calculated considering all chars in the string. Even the back ticks etc.
|
|
751
|
-
|
|
752
|
-
```typescript
|
|
753
|
-
interface ReferenceTrackerInformation {
|
|
754
|
-
licenseName?: string; // optional, not used on UI
|
|
755
|
-
repository?: string; // optional, not used on UI
|
|
756
|
-
url?: string; // optional, not used on UI
|
|
757
|
-
recommendationContentSpan: {
|
|
758
|
-
start: number;
|
|
759
|
-
end: number;
|
|
760
|
-
};
|
|
761
|
-
information: string; // supports MARKDOWN, will be shown on tooltip
|
|
762
|
-
}
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
Let's see how it works and looks like.
|
|
766
|
-
|
|
767
|
-
To make it easy to read, let's assume that the below block is the body content for us and we've assigned it to a constant called **`bodyContent`**.
|
|
768
|
-
|
|
769
|
-
>\#\#\# How to create a React stateless function component\
|
|
770
|
-
\
|
|
771
|
-
*React .14* introduced a simpler way to define components called stateless functional components.\
|
|
772
|
-
\
|
|
773
|
-
First let's start generating a react \`functional\` component.
|
|
774
|
-
\
|
|
775
|
-
\
|
|
776
|
-
Functional components are just JavaScript functions. They take in an optional input which we call as \`props\`.
|
|
777
|
-
\
|
|
778
|
-
\
|
|
779
|
-
\`\`\`tsx\
|
|
780
|
-
import React from 'react';\
|
|
781
|
-
\
|
|
782
|
-
interface MyStatelessFunctionalComponentProps {\
|
|
783
|
-
value: string;\
|
|
784
|
-
onChange: (value: string) => void;\
|
|
785
|
-
}\
|
|
786
|
-
\
|
|
787
|
-
export const MyStatelessFunctionalComponent = (props: MyStatelessFunctionalComponentProps) => {\
|
|
788
|
-
return <>\
|
|
789
|
-
\<input\
|
|
790
|
-
type="text"\
|
|
791
|
-
placeholder="placeholder"\
|
|
792
|
-
value={props.value}\
|
|
793
|
-
onChange={props.onChange}/>\
|
|
794
|
-
</>\
|
|
795
|
-
}\
|
|
796
|
-
\`\`\`\
|
|
797
|
-
\[Link inside body!\]\(https://google.com\).\
|
|
798
|
-
\
|
|
799
|
-
In this case, our input component will only use the given value through props which will come from the parent and it will not have any state. When you type into the input element, even it will change the value visually, it will not change the actual holded value. We should inform parent when the value is changed. We will use \`onChange\` prop here.\
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
**And let's use that `bodyContent` now.**
|
|
803
|
-
```typescript
|
|
804
|
-
const mynahUI = new MynahUI({
|
|
805
|
-
tabs: {
|
|
806
|
-
'tab-1': {
|
|
807
|
-
...
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
const bodyContent = MARKDOWN; // above markdown text
|
|
812
|
-
|
|
813
|
-
mynahUI.addChatItem('tab-1', {
|
|
814
|
-
type: ChatItemType.ANSWER,
|
|
815
|
-
body: bodyContent,
|
|
816
|
-
codeReference: [
|
|
817
|
-
{
|
|
818
|
-
recommendationContentSpan: {
|
|
819
|
-
start: 362,
|
|
820
|
-
end: 470
|
|
821
|
-
},
|
|
822
|
-
information: 'Reference code *under the MIT license* from repository `amazon`.'
|
|
823
|
-
},
|
|
824
|
-
{
|
|
825
|
-
recommendationContentSpan: {
|
|
826
|
-
start: 484,
|
|
827
|
-
end: 514
|
|
828
|
-
},
|
|
829
|
-
information: '**Reference tracker information:**\n\rReference code *under the MIT license* from repository `aws`.'
|
|
830
|
-
}
|
|
831
|
-
]
|
|
832
|
-
});
|
|
833
|
-
```
|
|
834
|
-
|
|
835
|
-
<p align="center">
|
|
836
|
-
<img src="./img/data-model/chatItems/codeReference-1.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
837
|
-
</p>
|
|
838
|
-
|
|
839
|
-
Here's what you'll see when you hover to them.
|
|
840
|
-
|
|
841
|
-
<p align="center">
|
|
842
|
-
<img src="./img/data-model/chatItems/codeReference-2.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
843
|
-
</p>
|
|
844
|
-
|
|
845
|
-
<p>
|
|
846
|
-
<br />
|
|
847
|
-
</p>
|
|
848
|
-
|
|
849
|
-
---
|
|
850
|
-
|
|
851
|
-
<p>
|
|
852
|
-
<br />
|
|
853
|
-
</p>
|
|
854
|
-
|
|
855
|
-
## `NotificationProps`
|
|
856
|
-
|
|
857
|
-
To show a notification inside the `MynahUI` block, you can use the notify function, and here's how they look like.
|
|
858
|
-
|
|
859
|
-
```typescript
|
|
860
|
-
enum NotificationType {
|
|
861
|
-
INFO = ...,
|
|
862
|
-
SUCCESS = ...,
|
|
863
|
-
WARNING = ...,
|
|
864
|
-
ERROR = ...,
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
interface NotificationProps {
|
|
868
|
-
duration?: number;
|
|
869
|
-
type?: NotificationType;
|
|
870
|
-
title?: string;
|
|
871
|
-
content: NotificationContentType | NotificationContentType[]; // Can be a string or HTMLElement
|
|
872
|
-
onNotificationClick?: () => void;
|
|
873
|
-
onNotificationHide?: () => void;
|
|
874
|
-
}
|
|
875
|
-
```
|
|
876
|
-
|
|
877
|
-
Here are some examples:
|
|
878
|
-
|
|
879
|
-
```typescript
|
|
880
|
-
const mynahUI = new MynahUI(...);
|
|
881
|
-
mynahUI.notify({
|
|
882
|
-
content: 'Content block', // not optional
|
|
883
|
-
duration: -1, // will stay forever until user cliks,
|
|
884
|
-
type: NotificationType.INFO, // This is the default
|
|
885
|
-
title: 'Notification',
|
|
886
|
-
});
|
|
887
|
-
```
|
|
888
|
-
<p align="center">
|
|
889
|
-
<img src="./img/data-model/chatItems/notification-1.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
890
|
-
</p>
|
|
891
|
-
|
|
892
|
-
```typescript
|
|
893
|
-
const mynahUI = new MynahUI(...);
|
|
894
|
-
mynahUI.notify({
|
|
895
|
-
content: 'An error occured.',
|
|
896
|
-
duration: 5000, // will stay 5 seconds on the screen
|
|
897
|
-
type: NotificationType.ERROR,
|
|
898
|
-
title: 'Error',
|
|
899
|
-
});
|
|
900
|
-
```
|
|
901
|
-
|
|
902
|
-
<p align="center">
|
|
903
|
-
<img src="./img/data-model/chatItems/notification-2.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
904
|
-
</p>
|
|
905
|
-
|
|
906
|
-
```typescript
|
|
907
|
-
const mynahUI = new MynahUI(...);
|
|
908
|
-
mynahUI.notify({
|
|
909
|
-
content: 'This is the last warning!',
|
|
910
|
-
duration: 5000,
|
|
911
|
-
type: NotificationType.WARNING,
|
|
912
|
-
title: 'Warning!',
|
|
913
|
-
});
|
|
914
|
-
```
|
|
915
|
-
|
|
916
|
-
<p align="center">
|
|
917
|
-
<img src="./img/data-model/chatItems/notification-3.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
918
|
-
</p>
|
|
919
|
-
|
|
920
|
-
```typescript
|
|
921
|
-
const mynahUI = new MynahUI(...);
|
|
922
|
-
mynahUI.notify({
|
|
923
|
-
content: 'You\'ve succeeded!',
|
|
924
|
-
duration: 5000,
|
|
925
|
-
type: NotificationType.SUCCESS,
|
|
926
|
-
title: 'Congrats!',
|
|
927
|
-
});
|
|
928
|
-
```
|
|
929
|
-
|
|
930
|
-
<p align="center">
|
|
931
|
-
<img src="./img/data-model/chatItems/notification-4.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
932
|
-
</p>
|