@aws/mynah-ui 4.17.1 → 4.18.0
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/dist/components/background.d.ts +10 -0
- package/dist/components/button.d.ts +4 -3
- package/dist/components/card/card-body.d.ts +1 -1
- package/dist/components/chat-item/chat-item-buttons.d.ts +1 -1
- package/dist/components/chat-item/chat-item-card-content.d.ts +2 -2
- package/dist/components/chat-item/chat-item-card.d.ts +4 -1
- package/dist/components/chat-item/chat-item-information-card.d.ts +3 -1
- package/dist/components/chat-item/chat-item-tabbed-card.d.ts +17 -0
- package/dist/components/chat-item/chat-item-tree-file.d.ts +1 -0
- package/dist/components/chat-item/chat-prompt-input.d.ts +3 -1
- package/dist/components/chat-item/chat-wrapper.d.ts +4 -0
- package/dist/components/icon.d.ts +1 -0
- package/dist/components/syntax-highlighter.d.ts +0 -21
- package/dist/components/title-description-with-icon.d.ts +20 -0
- package/dist/helper/chat-item.d.ts +2 -1
- package/dist/helper/dom.d.ts +1 -1
- package/dist/helper/test-ids.d.ts +5 -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 +51 -13
- package/docs/CONFIG.md +3 -0
- package/docs/DATAMODEL.md +354 -32
- package/docs/img/data-model/chatItems/actions.png +0 -0
- package/docs/img/data-model/chatItems/buttonFlash.png +0 -0
- package/docs/img/data-model/chatItems/confirmationButtons.png +0 -0
- package/docs/img/data-model/chatItems/hoverEffect.png +0 -0
- package/docs/img/data-model/chatItems/tabbed-card.png +0 -0
- package/docs/img/data-model/tabStore/compactMode.png +0 -0
- package/docs/img/data-model/tabStore/promptInputLabel.png +0 -0
- package/docs/img/data-model/tabStore/promptInputText.png +0 -0
- package/docs/img/data-model/tabStore/promptInputVisible.png +0 -0
- package/docs/img/data-model/tabStore/tabBackground.png +0 -0
- package/docs/img/data-model/tabStore/tabHeaderDetails.png +0 -0
- package/docs/img/data-model/tabStore/tabHeaderDetails2.png +0 -0
- package/package.json +1 -1
- package/ui-tests/dist/main.js +1 -1
- package/ui-tests/dist/main.js.map +1 -1
package/dist/static.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { MynahIcons } from './components/icon';
|
|
6
6
|
import { ChatItemBodyRenderer } from './helper/dom';
|
|
7
|
-
import { SelectAbstract, SelectProps, RadioGroupAbstract, RadioGroupProps, ButtonAbstract, ButtonProps, TextInputProps, TextInputAbstract, TextAreaProps, TextAreaAbstract } from './main';
|
|
7
|
+
import { SelectAbstract, SelectProps, RadioGroupAbstract, RadioGroupProps, ButtonAbstract, ButtonProps, TextInputProps, TextInputAbstract, TextAreaProps, TextAreaAbstract, ToggleOption } from './main';
|
|
8
8
|
export interface QuickActionCommand {
|
|
9
9
|
command: string;
|
|
10
10
|
disabled?: boolean;
|
|
@@ -24,6 +24,10 @@ export interface MynahUIDataModel {
|
|
|
24
24
|
* Tab title
|
|
25
25
|
* */
|
|
26
26
|
tabTitle?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Tab title
|
|
29
|
+
* */
|
|
30
|
+
tabBackground?: boolean;
|
|
27
31
|
/**
|
|
28
32
|
* If tab is running an action (loadingChat = true) this markdown will be shown before close in a popup
|
|
29
33
|
*/
|
|
@@ -61,6 +65,18 @@ export interface MynahUIDataModel {
|
|
|
61
65
|
*/
|
|
62
66
|
promptInputPlaceholder?: string;
|
|
63
67
|
/**
|
|
68
|
+
* Prompt input text
|
|
69
|
+
*/
|
|
70
|
+
promptInputText?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Label to be shown on top of the prompt input
|
|
73
|
+
*/
|
|
74
|
+
promptInputLabel?: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Label to be shown on top of the prompt input
|
|
77
|
+
*/
|
|
78
|
+
promptInputVisible?: boolean;
|
|
79
|
+
/**
|
|
64
80
|
* Info block to be shown under prompt input
|
|
65
81
|
*/
|
|
66
82
|
promptInputInfo?: string;
|
|
@@ -88,6 +104,14 @@ export interface MynahUIDataModel {
|
|
|
88
104
|
* Tab bar buttons next to the tab items
|
|
89
105
|
*/
|
|
90
106
|
tabBarButtons?: TabBarMainAction[];
|
|
107
|
+
/**
|
|
108
|
+
* Tab content compact mode which keeps everything in the middle
|
|
109
|
+
*/
|
|
110
|
+
compactMode?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Tab content header details, only visibile when showTabHeaderDetails is set to 'true'
|
|
113
|
+
*/
|
|
114
|
+
tabHeaderDetails?: TabHeaderDetails | null;
|
|
91
115
|
}
|
|
92
116
|
export interface MynahUITabStoreTab {
|
|
93
117
|
/**
|
|
@@ -120,6 +144,7 @@ export declare enum MynahEventNames {
|
|
|
120
144
|
CHAT_ITEM_ADD = "chatItemAdd",
|
|
121
145
|
FOLLOW_UP_CLICKED = "followUpClicked",
|
|
122
146
|
BODY_ACTION_CLICKED = "bodyActionClicked",
|
|
147
|
+
TABBED_CONTENT_SWITCH = "tabbedContentSwitch",
|
|
123
148
|
SHOW_MORE_WEB_RESULTS_CLICK = "showMoreWebResultsClick",
|
|
124
149
|
SHOW_FEEDBACK_FORM = "showFeedbackForm",
|
|
125
150
|
FILE_CLICK = "fileClick",
|
|
@@ -192,19 +217,20 @@ export interface TreeNodeDetails {
|
|
|
192
217
|
icon?: MynahIcons;
|
|
193
218
|
label?: string;
|
|
194
219
|
description?: string;
|
|
220
|
+
clickable?: boolean;
|
|
195
221
|
}
|
|
196
222
|
export interface ChatItemContent {
|
|
197
|
-
body?: string;
|
|
198
|
-
customRenderer?: string | ChatItemBodyRenderer | ChatItemBodyRenderer[];
|
|
223
|
+
body?: string | null;
|
|
224
|
+
customRenderer?: string | ChatItemBodyRenderer | ChatItemBodyRenderer[] | null;
|
|
199
225
|
followUp?: {
|
|
200
226
|
text?: string;
|
|
201
227
|
options?: ChatItemAction[];
|
|
202
|
-
};
|
|
228
|
+
} | null;
|
|
203
229
|
relatedContent?: {
|
|
204
230
|
title?: string;
|
|
205
231
|
content: SourceLink[];
|
|
206
|
-
};
|
|
207
|
-
codeReference?: ReferenceTrackerInformation[];
|
|
232
|
+
} | null;
|
|
233
|
+
codeReference?: ReferenceTrackerInformation[] | null;
|
|
208
234
|
fileList?: {
|
|
209
235
|
fileTreeTitle?: string;
|
|
210
236
|
rootFolderTitle?: string;
|
|
@@ -212,10 +238,10 @@ export interface ChatItemContent {
|
|
|
212
238
|
deletedFiles?: string[];
|
|
213
239
|
actions?: Record<string, FileNodeAction[]>;
|
|
214
240
|
details?: Record<string, TreeNodeDetails>;
|
|
215
|
-
};
|
|
216
|
-
buttons?: ChatItemButton[];
|
|
217
|
-
formItems?: ChatItemFormItem[];
|
|
218
|
-
footer?: ChatItemContent;
|
|
241
|
+
} | null;
|
|
242
|
+
buttons?: ChatItemButton[] | null;
|
|
243
|
+
formItems?: ChatItemFormItem[] | null;
|
|
244
|
+
footer?: ChatItemContent | null;
|
|
219
245
|
informationCard?: {
|
|
220
246
|
title?: string;
|
|
221
247
|
status?: {
|
|
@@ -226,8 +252,11 @@ export interface ChatItemContent {
|
|
|
226
252
|
description?: string;
|
|
227
253
|
icon?: MynahIcons;
|
|
228
254
|
content: ChatItemContent;
|
|
229
|
-
};
|
|
230
|
-
|
|
255
|
+
} | null;
|
|
256
|
+
tabbedContent?: Array<ToggleOption & {
|
|
257
|
+
content: ChatItemContent;
|
|
258
|
+
}> | null;
|
|
259
|
+
codeBlockActions?: CodeBlockActions | null;
|
|
231
260
|
}
|
|
232
261
|
export interface ChatItem extends ChatItemContent {
|
|
233
262
|
type: ChatItemType;
|
|
@@ -235,6 +264,7 @@ export interface ChatItem extends ChatItemContent {
|
|
|
235
264
|
snapToTop?: boolean;
|
|
236
265
|
canBeVoted?: boolean;
|
|
237
266
|
icon?: MynahIcons;
|
|
267
|
+
hoverEffect?: boolean;
|
|
238
268
|
status?: Status;
|
|
239
269
|
}
|
|
240
270
|
export interface ChatItemFormItem {
|
|
@@ -270,8 +300,10 @@ export interface ChatItemButton {
|
|
|
270
300
|
id: string;
|
|
271
301
|
disabled?: boolean;
|
|
272
302
|
description?: string;
|
|
273
|
-
status?: 'primary' | Status;
|
|
303
|
+
status?: 'main' | 'primary' | 'clear' | Status;
|
|
304
|
+
flash?: 'infinite' | 'once';
|
|
274
305
|
icon?: MynahIcons;
|
|
306
|
+
position?: 'inside' | 'outside';
|
|
275
307
|
}
|
|
276
308
|
export interface TabBarAction {
|
|
277
309
|
text?: string;
|
|
@@ -382,12 +414,18 @@ export declare enum NotificationType {
|
|
|
382
414
|
WARNING = "warning",
|
|
383
415
|
ERROR = "error"
|
|
384
416
|
}
|
|
417
|
+
export interface TabHeaderDetails {
|
|
418
|
+
icon?: MynahIcons;
|
|
419
|
+
title?: string;
|
|
420
|
+
description?: string;
|
|
421
|
+
}
|
|
385
422
|
export interface CodeBlockAction {
|
|
386
423
|
id: 'copy' | 'insert-to-cursor' | string;
|
|
387
424
|
label: string;
|
|
388
425
|
description?: string;
|
|
389
426
|
icon?: MynahIcons;
|
|
390
427
|
data?: any;
|
|
428
|
+
flash?: 'infinite' | 'once';
|
|
391
429
|
acceptedLanguages?: string[];
|
|
392
430
|
}
|
|
393
431
|
export type CodeBlockActions = Record<'copy' | 'insert-to-cursor' | string, CodeBlockAction | undefined | null>;
|
package/docs/CONFIG.md
CHANGED
|
@@ -321,6 +321,9 @@ With this parameter, you can add global code block actions to the code blocks. B
|
|
|
321
321
|
### Note
|
|
322
322
|
If you want to show that action only for certain coding languages, you can set the array for `acceptedLanguages` parameter. Keep in mind that it will check an exact mathc. If the incoming language is same with one of the acceptedLanguages list, it will show the action.
|
|
323
323
|
|
|
324
|
+
#### flash
|
|
325
|
+
You can also make the code block actions flash once or foverer when user hovers the the containing card. Until user hovers to the action itself, whenever they hover to the card it will flash the code block action. It you set it to `once` it will only flash once for every hover to the container card, if you set it to `infinite` it will keep flashing forever every 3 seconds until user hovers to the action itself. Whe user hovers to the action, it will not flash again.
|
|
326
|
+
|
|
324
327
|
#### By default, we add `copy` and `insert to cursor position` ones:
|
|
325
328
|
|
|
326
329
|
```typescript
|
package/docs/DATAMODEL.md
CHANGED
|
@@ -12,6 +12,10 @@ interface MynahUIDataModel {
|
|
|
12
12
|
* Tab title
|
|
13
13
|
* */
|
|
14
14
|
tabTitle?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Tab title
|
|
17
|
+
* */
|
|
18
|
+
tabBackground?: boolean;
|
|
15
19
|
/**
|
|
16
20
|
* If tab is running an action (loadingChat = true) this markdown will be shown before close in a popup
|
|
17
21
|
*/
|
|
@@ -49,6 +53,18 @@ interface MynahUIDataModel {
|
|
|
49
53
|
*/
|
|
50
54
|
promptInputPlaceholder?: string;
|
|
51
55
|
/**
|
|
56
|
+
* Prompt input text
|
|
57
|
+
*/
|
|
58
|
+
promptInputText?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Label to be shown on top of the prompt input
|
|
61
|
+
*/
|
|
62
|
+
promptInputLabel?: string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Label to be shown on top of the prompt input
|
|
65
|
+
*/
|
|
66
|
+
promptInputVisible?: boolean;
|
|
67
|
+
/**
|
|
52
68
|
* Info block to be shown under prompt input
|
|
53
69
|
*/
|
|
54
70
|
promptInputInfo?: string;
|
|
@@ -57,7 +73,7 @@ interface MynahUIDataModel {
|
|
|
57
73
|
*/
|
|
58
74
|
promptInputStickyCard?: Partial<ChatItem> | null;
|
|
59
75
|
/**
|
|
60
|
-
* Prompt input field disabled state, set to
|
|
76
|
+
* Prompt input field disabled state, set to tru to disable it
|
|
61
77
|
*/
|
|
62
78
|
promptInputDisabledState?: boolean;
|
|
63
79
|
/**
|
|
@@ -76,6 +92,14 @@ interface MynahUIDataModel {
|
|
|
76
92
|
* Tab bar buttons next to the tab items
|
|
77
93
|
*/
|
|
78
94
|
tabBarButtons?: TabBarMainAction[];
|
|
95
|
+
/**
|
|
96
|
+
* Tab content compact mode which keeps everything in the middle
|
|
97
|
+
*/
|
|
98
|
+
compactMode?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Tab content header details, only visibile when showTabHeaderDetails is set to 'true'
|
|
101
|
+
*/
|
|
102
|
+
tabHeaderDetails?: TabHeaderDetails | null;
|
|
79
103
|
}
|
|
80
104
|
```
|
|
81
105
|
|
|
@@ -100,11 +124,28 @@ mynahUI.updateStore('tab-1', {
|
|
|
100
124
|
})
|
|
101
125
|
```
|
|
102
126
|
|
|
127
|
+
### `tabBackground` (default: `false`)
|
|
128
|
+
Shows or hides the gradient background on the tab.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const mynahUI = new MynahUI({
|
|
132
|
+
tabs: {
|
|
133
|
+
'tab-1': {
|
|
134
|
+
...
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
mynahUI.updateStore('tab-1', {
|
|
140
|
+
tabBackground: true
|
|
141
|
+
})
|
|
142
|
+
```
|
|
143
|
+
|
|
103
144
|
|
|
104
145
|
###
|
|
105
146
|
|
|
106
147
|
<p align="center">
|
|
107
|
-
<img src="./img/data-model/tabStore/
|
|
148
|
+
<img src="./img/data-model/tabStore/tabBackground.png" alt="tabBackground" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
108
149
|
</p>
|
|
109
150
|
|
|
110
151
|
---
|
|
@@ -347,6 +388,79 @@ mynahUI.updateStore('tab-1', {
|
|
|
347
388
|
|
|
348
389
|
---
|
|
349
390
|
|
|
391
|
+
### `promptInputText` (default: `''`)
|
|
392
|
+
|
|
393
|
+
This is the text inside the prompt input. You can set it anytime, but be careful, it will override what is already written in the text input.
|
|
394
|
+
A nice trick to use it is to open the quick actions command picker too. If you send `"/"` or `"/some-matching-text"` it will open the quick actions command selector automatically and also filter the list with the following text if given.
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
const mynahUI = new MynahUI({
|
|
398
|
+
tabs: {
|
|
399
|
+
'tab-1': {
|
|
400
|
+
...
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
mynahUI.updateStore('tab-1', {
|
|
406
|
+
promptInputText: '/dev'
|
|
407
|
+
})
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
<p align="center">
|
|
411
|
+
<img src="./img/data-model/tabStore/promptInputText.png" alt="Prompt input text" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
412
|
+
</p>
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
### `promptInputLabel` (default: `''`)
|
|
417
|
+
|
|
418
|
+
This is label for the prompt input text.
|
|
419
|
+
|
|
420
|
+
```typescript
|
|
421
|
+
const mynahUI = new MynahUI({
|
|
422
|
+
tabs: {
|
|
423
|
+
'tab-1': {
|
|
424
|
+
...
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
mynahUI.updateStore('tab-1', {
|
|
430
|
+
promptInputLabel: 'Prompt input text label'
|
|
431
|
+
})
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
<p align="center">
|
|
435
|
+
<img src="./img/data-model/tabStore/promptInputLabel.png" alt="prompt input label" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
436
|
+
</p>
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
### `promptInputVisible` (default: `true`)
|
|
441
|
+
|
|
442
|
+
This is a control point for the visibility of the prompt input field. Unlike the `showPromptField` in [global CONFIG](./CONFIG.md#showpromptfield) it allows you to change the visibility of the prompt input field for each individual tab on runtime.
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
const mynahUI = new MynahUI({
|
|
446
|
+
tabs: {
|
|
447
|
+
'tab-1': {
|
|
448
|
+
...
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
mynahUI.updateStore('tab-1', {
|
|
454
|
+
promptInputVisible: false,
|
|
455
|
+
})
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
<p align="center">
|
|
459
|
+
<img src="./img/data-model/tabStore/promptInputVisible.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
460
|
+
</p>
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
350
464
|
### `promptInputInfo` (default: `''`)
|
|
351
465
|
|
|
352
466
|
This is a info field under the bottom of the prompt input field, like a footer text
|
|
@@ -564,6 +678,64 @@ mynahUI.updateStore('tab-1', {
|
|
|
564
678
|
|
|
565
679
|
---
|
|
566
680
|
|
|
681
|
+
### `compactMode`
|
|
682
|
+
|
|
683
|
+
You can enable/disable compact mode. In compact mode, there will be more paddings from every edge. In addition to the paddings, the chat content will be middle placed (15% more pushed from the bottom) instead of being stretched to the available height. However, it will not exceed the available height for its own space.
|
|
684
|
+
While doing the transition for the compact mode switch, there is also a nice and smooth animation.
|
|
685
|
+
|
|
686
|
+
```typescript
|
|
687
|
+
const mynahUI = new MynahUI({
|
|
688
|
+
tabs: {
|
|
689
|
+
'tab-1': {
|
|
690
|
+
...
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
mynahUI.updateStore('tab-1', {
|
|
696
|
+
compactMode: true,
|
|
697
|
+
})
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
<p align="center">
|
|
701
|
+
<img src="./img/data-model/tabStore/compactMode.png" alt="compactMode" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
702
|
+
</p>
|
|
703
|
+
|
|
704
|
+
---
|
|
705
|
+
|
|
706
|
+
### `tabHeaderDetails` (default: `null`)
|
|
707
|
+
|
|
708
|
+
There is a chance to add a detailed header on top of the tab content. Which can have an icon, title and the description.
|
|
709
|
+
**NOTE:** When you give `tabHeaderDetails` it will also adjust the alignment of the chat items to top. So until the content section reaches the max height available, they'll start to be ordered from top to bottom. Which means that it will also take space as their available content height. This will make the prompt field also moves up under the content. If the content height is more than available space, prompt input will still fit under the bottom of the screen.
|
|
710
|
+
|
|
711
|
+
**NOTE:** When you provide `tabHeaderDetails` it will also make the chat cards width stretch to full available width of the screen. So they'll not get their width depending on their content and up to 90%. Instead, it will always be 100%.
|
|
712
|
+
|
|
713
|
+
```typescript
|
|
714
|
+
const mynahUI = new MynahUI({
|
|
715
|
+
tabs: {
|
|
716
|
+
'tab-1': {
|
|
717
|
+
...
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
mynahUI.updateStore('tab-1', {
|
|
723
|
+
tabHeaderDetails: {
|
|
724
|
+
icon: MynahIcons.Q,
|
|
725
|
+
title: "Welcome to Q Developer",
|
|
726
|
+
description: "What kind of questions you have?"
|
|
727
|
+
},
|
|
728
|
+
})
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
<p align="center">
|
|
732
|
+
<img src="./img/data-model/tabStore/tabHeaderDetails.png" alt="tabHeaderDetails" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
733
|
+
<br />
|
|
734
|
+
<img src="./img/data-model/tabStore/tabHeaderDetails2.png" alt="tabHeaderDetails 2" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
735
|
+
</p>
|
|
736
|
+
|
|
737
|
+
---
|
|
738
|
+
|
|
567
739
|
### `chatItems` (default: `[]`)
|
|
568
740
|
|
|
569
741
|
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.
|
|
@@ -654,6 +826,7 @@ interface TreeNodeDetails {
|
|
|
654
826
|
icon?: MynahIcons;
|
|
655
827
|
label?: string;
|
|
656
828
|
description?: string; // Markdown tooltip
|
|
829
|
+
clickable?: boolean; // can it be clicked? (Default: true)
|
|
657
830
|
}
|
|
658
831
|
|
|
659
832
|
interface SourceLink {
|
|
@@ -688,23 +861,24 @@ interface CodeBlockAction {
|
|
|
688
861
|
description?: string;
|
|
689
862
|
icon?: MynahIcons;
|
|
690
863
|
data?: any;
|
|
864
|
+
flash?: 'infinite' | 'once';
|
|
691
865
|
acceptedLanguages?: string[];
|
|
692
866
|
}
|
|
693
867
|
type CodeBlockActions = Record<'copy' | 'insert-to-cursor' | string, CodeBlockAction | undefined | null>;
|
|
694
868
|
|
|
695
869
|
// #################################
|
|
696
870
|
interface ChatItemContent {
|
|
697
|
-
body?: string;
|
|
698
|
-
customRenderer?: string | ChatItemBodyRenderer | ChatItemBodyRenderer[];
|
|
871
|
+
body?: string | null;
|
|
872
|
+
customRenderer?: string | ChatItemBodyRenderer | ChatItemBodyRenderer[] | null;
|
|
699
873
|
followUp?: {
|
|
700
874
|
text?: string;
|
|
701
875
|
options?: ChatItemAction[];
|
|
702
|
-
};
|
|
876
|
+
} | null;
|
|
703
877
|
relatedContent?: {
|
|
704
878
|
title?: string;
|
|
705
879
|
content: SourceLink[];
|
|
706
|
-
};
|
|
707
|
-
codeReference?: ReferenceTrackerInformation[];
|
|
880
|
+
} | null;
|
|
881
|
+
codeReference?: ReferenceTrackerInformation[] | null;
|
|
708
882
|
fileList?: {
|
|
709
883
|
fileTreeTitle?: string;
|
|
710
884
|
rootFolderTitle?: string;
|
|
@@ -712,10 +886,10 @@ interface ChatItemContent {
|
|
|
712
886
|
deletedFiles?: string[];
|
|
713
887
|
actions?: Record<string, FileNodeAction[]>;
|
|
714
888
|
details?: Record<string, TreeNodeDetails>;
|
|
715
|
-
};
|
|
716
|
-
buttons?: ChatItemButton[];
|
|
717
|
-
formItems?: ChatItemFormItem[];
|
|
718
|
-
footer?: ChatItemContent;
|
|
889
|
+
} | null;
|
|
890
|
+
buttons?: ChatItemButton[] | null;
|
|
891
|
+
formItems?: ChatItemFormItem[] | null;
|
|
892
|
+
footer?: ChatItemContent | null;
|
|
719
893
|
informationCard?: {
|
|
720
894
|
title?: string;
|
|
721
895
|
status?: {
|
|
@@ -726,8 +900,11 @@ interface ChatItemContent {
|
|
|
726
900
|
description?: string;
|
|
727
901
|
icon?: MynahIcons;
|
|
728
902
|
content: ChatItemContent;
|
|
729
|
-
};
|
|
730
|
-
|
|
903
|
+
} | null;
|
|
904
|
+
tabbedContent?: Array<ToggleOption & {
|
|
905
|
+
content: ChatItemContent;
|
|
906
|
+
}> | null;
|
|
907
|
+
codeBlockActions?: CodeBlockActions | null;
|
|
731
908
|
}
|
|
732
909
|
|
|
733
910
|
interface ChatItem extends ChatItemContent{
|
|
@@ -736,6 +913,7 @@ interface ChatItem extends ChatItemContent{
|
|
|
736
913
|
snapToTop?: boolean;
|
|
737
914
|
canBeVoted?: boolean;
|
|
738
915
|
icon?: MynahIcons;
|
|
916
|
+
hoverEffect?: boolean;
|
|
739
917
|
status?: 'info' | 'success' | 'warning' | 'error';
|
|
740
918
|
}
|
|
741
919
|
// #################################
|
|
@@ -1335,6 +1513,31 @@ mynahUI.addChatItem('tab-1', {
|
|
|
1335
1513
|
});
|
|
1336
1514
|
```
|
|
1337
1515
|
|
|
1516
|
+
|
|
1517
|
+
## `hoverEffect`
|
|
1518
|
+
It gives you the option to put a hover effect on the card when it is hovered. It will also show the cursor as a pointer. It will make the card pop more than the others when user hovers to that card by adding a shadow and slight upwards movement.
|
|
1519
|
+
|
|
1520
|
+
```typescript
|
|
1521
|
+
const mynahUI = new MynahUI({
|
|
1522
|
+
tabs: {
|
|
1523
|
+
'tab-1': {
|
|
1524
|
+
...
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
|
|
1529
|
+
mynahUI.addChatItem('tab-1', {
|
|
1530
|
+
type: ChatItemType.ANSWER,
|
|
1531
|
+
...
|
|
1532
|
+
hoverEffect: true,
|
|
1533
|
+
...
|
|
1534
|
+
});
|
|
1535
|
+
```
|
|
1536
|
+
|
|
1537
|
+
<p align="center">
|
|
1538
|
+
<img src="./img/data-model/chatItems/hoverEffect.png" alt="hoverEffect" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
1539
|
+
</p>
|
|
1540
|
+
|
|
1338
1541
|
---
|
|
1339
1542
|
|
|
1340
1543
|
## `canBeVoted`
|
|
@@ -1376,6 +1579,9 @@ With this parameter, you can add per chatitem code block actions to the code blo
|
|
|
1376
1579
|
### Note
|
|
1377
1580
|
If you want to show that action only for certain coding languages, you can set the array for `acceptedLanguages` parameter. Keep in mind that it will check an exact mathc. If the incoming language is same with one of the acceptedLanguages list, it will show the action.
|
|
1378
1581
|
|
|
1582
|
+
#### flash
|
|
1583
|
+
You can also make the code block actions flash once or foverer when user hovers the the containing card. Until user hovers to the action itself, whenever they hover to the card it will flash the code block action. It you set it to `once` it will only flash once for every hover to the container card, if you set it to `infinite` it will keep flashing forever every 3 seconds until user hovers to the action itself. Whe user hovers to the action, it will not flash again.
|
|
1584
|
+
|
|
1379
1585
|
```typescript
|
|
1380
1586
|
const mynahUI = new MynahUI({
|
|
1381
1587
|
tabs: {
|
|
@@ -1546,7 +1752,8 @@ mynahUI.addChatItem(tabId, {
|
|
|
1546
1752
|
status: 'error',
|
|
1547
1753
|
label: "Change rejected",
|
|
1548
1754
|
icon: MynahIcons.REVERT,
|
|
1549
|
-
description: 'Markdown tooltip to show'
|
|
1755
|
+
description: 'Markdown tooltip to show',
|
|
1756
|
+
clickable: true; // or false if you want to make the file not clickabke
|
|
1550
1757
|
}
|
|
1551
1758
|
}
|
|
1552
1759
|
},
|
|
@@ -1567,6 +1774,8 @@ mynahUI.addChatItem(tabId, {
|
|
|
1567
1774
|
|
|
1568
1775
|
**NOTE 2:** You can add actions and details for each file (**but not for folders**). Beware that you need to add those actions for each specific file as a map which **the key needs to be the path of the file**.
|
|
1569
1776
|
|
|
1777
|
+
**NOTE 3:** In case you want to show one single file (or folder by giving it a folder icon) and not make it clickable, use the `details` section with the file name and set the `clickable` to `false`.
|
|
1778
|
+
|
|
1570
1779
|
<p align="center">
|
|
1571
1780
|
<img src="./img/data-model/chatItems/codeResult.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
1572
1781
|
</p>
|
|
@@ -1611,6 +1820,45 @@ A status can also be added to emphasize a particular state. The `status.status`
|
|
|
1611
1820
|
|
|
1612
1821
|
---
|
|
1613
1822
|
|
|
1823
|
+
### `tabbedContent`
|
|
1824
|
+
|
|
1825
|
+
Show a card with switchable content based on navigation tabs.
|
|
1826
|
+
|
|
1827
|
+
```typescript
|
|
1828
|
+
mynahUI.addChatItem(selectedTabId, {
|
|
1829
|
+
messageId: generateUID(),
|
|
1830
|
+
type: ChatItemType.ANSWER,
|
|
1831
|
+
tabbedContent: [
|
|
1832
|
+
{
|
|
1833
|
+
value: 'overview',
|
|
1834
|
+
label: 'Overview',
|
|
1835
|
+
icon: MynahIcons.COMMENT,
|
|
1836
|
+
selected: true,
|
|
1837
|
+
content: {
|
|
1838
|
+
body: 'Overview content'
|
|
1839
|
+
}
|
|
1840
|
+
},
|
|
1841
|
+
{
|
|
1842
|
+
value: 'examples',
|
|
1843
|
+
label: 'Examples',
|
|
1844
|
+
icon: MynahIcons.PLAY,
|
|
1845
|
+
selected: false,
|
|
1846
|
+
content: {
|
|
1847
|
+
body: 'Examples content'
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
]
|
|
1851
|
+
});
|
|
1852
|
+
```
|
|
1853
|
+
|
|
1854
|
+
Define a unique identifier for each tab in the `value` prop, and add a label and icon. Determine which tab is selected by default by using the `selected` boolean. The content is a `ChatItemContent`, which is the content shown when the tab is selected.
|
|
1855
|
+
|
|
1856
|
+
<p align="center">
|
|
1857
|
+
<img src="./img/data-model/chatItems/tabbed-card.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
1858
|
+
</p>
|
|
1859
|
+
|
|
1860
|
+
---
|
|
1861
|
+
|
|
1614
1862
|
## `buttons`
|
|
1615
1863
|
It allows you to add actions inside a chat item card. **BUT, beware that when those actions are clicked if you set the `keepCardAfterClick` to false, they will remove the card they are in.**.
|
|
1616
1864
|
|
|
@@ -1626,8 +1874,10 @@ interface ChatItemButton {
|
|
|
1626
1874
|
id: string; // id of the button, since when they are clicked they all call the same property onInBodyButtonClicked
|
|
1627
1875
|
disabled?: boolean; // in any case if you want to make the button disabled (mandatory check will discard this)
|
|
1628
1876
|
description?: string; // A text to be shown inside a tooltip and it can be markdown
|
|
1629
|
-
status?: '
|
|
1877
|
+
status?: 'main' | 'primary' | 'clear' | Status;
|
|
1878
|
+
flash?: 'infinite' | 'once'; // Flashes the card
|
|
1630
1879
|
icon?: MynahIcons; // in case if you want to put an icon to the button.
|
|
1880
|
+
position?: 'inside' | 'outside'; // Whether the button shows up inside or oustide a card, default is 'inside'
|
|
1631
1881
|
}
|
|
1632
1882
|
```
|
|
1633
1883
|
|
|
@@ -1646,31 +1896,103 @@ mynahUI.addChatItem(tabId, {
|
|
|
1646
1896
|
type: ChatItemType.ANSWER,
|
|
1647
1897
|
messageId: new Date().getTime().toString(),
|
|
1648
1898
|
body: `This is a card with actions inside!`,
|
|
1899
|
+
buttons: [
|
|
1900
|
+
{
|
|
1901
|
+
text: 'Action 1',
|
|
1902
|
+
id: 'action-1',
|
|
1903
|
+
status: 'info',
|
|
1904
|
+
icon: MynahIcons.CHAT
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
text: 'Action 2',
|
|
1908
|
+
description: 'This action will not remove the card!',
|
|
1909
|
+
id: 'action-2',
|
|
1910
|
+
keepCardAfterClick: false, // So when this button is clicked, it will remove the whole card.
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
text: 'Action 3',
|
|
1914
|
+
description: 'This is disabled for some reason!',
|
|
1915
|
+
id: 'action-3',
|
|
1916
|
+
disabled: true,
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
text: 'Primary',
|
|
1920
|
+
description: 'This is colored!',
|
|
1921
|
+
id: 'action-3',
|
|
1922
|
+
status: 'primary',
|
|
1923
|
+
},
|
|
1924
|
+
{
|
|
1925
|
+
text: 'Main',
|
|
1926
|
+
description: 'This is more colored!',
|
|
1927
|
+
id: 'action-3',
|
|
1928
|
+
status: 'main',
|
|
1929
|
+
},
|
|
1930
|
+
{
|
|
1931
|
+
text: 'Clear',
|
|
1932
|
+
description: 'This is clear!',
|
|
1933
|
+
id: 'action-3',
|
|
1934
|
+
status: 'clear',
|
|
1935
|
+
},
|
|
1936
|
+
],
|
|
1937
|
+
});
|
|
1938
|
+
```
|
|
1939
|
+
|
|
1940
|
+
<p align="center">
|
|
1941
|
+
<img src="./img/data-model/chatItems/actions.png" alt="buttons" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
1942
|
+
</p>
|
|
1943
|
+
|
|
1944
|
+
#### Outside buttons
|
|
1945
|
+
You can make buttons appear after the container chat card. A common usage for this use case is to add confirmation and rejection buttons to a particular card.
|
|
1946
|
+
|
|
1947
|
+
```typescript
|
|
1948
|
+
mynahUI.addChatItem(tabId, {
|
|
1949
|
+
type: ChatItemType.ANSWER,
|
|
1950
|
+
messageId: new Date().getTime().toString(),
|
|
1951
|
+
body: 'Do you wish to continue?',
|
|
1952
|
+
buttons: [
|
|
1953
|
+
{
|
|
1954
|
+
id: 'confirmation-buttons-cancel',
|
|
1955
|
+
text: 'Cancel',
|
|
1956
|
+
status: 'error',
|
|
1957
|
+
icon: MynahIcons.CANCEL_CIRCLE,
|
|
1958
|
+
position: 'outside'
|
|
1959
|
+
},
|
|
1960
|
+
{
|
|
1961
|
+
id: 'confirmation-buttons-confirm',
|
|
1962
|
+
text: 'Confirm',
|
|
1963
|
+
status: 'success',
|
|
1964
|
+
icon: MynahIcons.OK_CIRCLED,
|
|
1965
|
+
position: 'outside'
|
|
1966
|
+
},
|
|
1967
|
+
]
|
|
1968
|
+
});
|
|
1969
|
+
```
|
|
1970
|
+
|
|
1971
|
+
<p align="center">
|
|
1972
|
+
<img src="./img/data-model/chatItems/confirmationButtons.png" alt="confirmation buttons" style="max-width:250px; width:100%;border: 1px solid #e0e0e0;">
|
|
1973
|
+
</p>
|
|
1974
|
+
|
|
1975
|
+
#### Button flash
|
|
1976
|
+
|
|
1977
|
+
You can also make the button flash once or foverer when user hovers the the containing card. Until user hovers to the button itself, whenever they hover to the card it will flash the button. It you set it to `once` it will only flash once for every hover to the container card, if you set it to `infinite` it will keep flashing forever every 3 seconds until user hovers to the button itself. Whe user hovers to the button, it will not flash again.
|
|
1978
|
+
|
|
1979
|
+
```typescript
|
|
1980
|
+
mynahUI.addChatItem(tabId, {
|
|
1981
|
+
type: ChatItemType.ANSWER,
|
|
1982
|
+
...
|
|
1649
1983
|
buttons: [
|
|
1650
1984
|
{
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
icon: MynahIcons.CHAT
|
|
1655
|
-
},
|
|
1656
|
-
{
|
|
1657
|
-
text: 'Action 2',
|
|
1658
|
-
description: 'This action will not remove the card!',
|
|
1659
|
-
id: 'action-2',
|
|
1660
|
-
keepCardAfterClick: false, // So when this button is clicked, it will remove the whole card.
|
|
1661
|
-
},
|
|
1662
|
-
{
|
|
1663
|
-
text: 'Action 3',
|
|
1664
|
-
description: 'This is disabled for some reason!',
|
|
1665
|
-
id: 'action-3',
|
|
1666
|
-
disabled: true,
|
|
1985
|
+
...
|
|
1986
|
+
flash: 'infinite',
|
|
1987
|
+
...
|
|
1667
1988
|
},
|
|
1989
|
+
...,
|
|
1668
1990
|
],
|
|
1669
1991
|
});
|
|
1670
1992
|
```
|
|
1671
1993
|
|
|
1672
1994
|
<p align="center">
|
|
1673
|
-
<img src="./img/data-model/chatItems/
|
|
1995
|
+
<img src="./img/data-model/chatItems/buttonFlash.png" alt="button flash" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
1674
1996
|
</p>
|
|
1675
1997
|
|
|
1676
1998
|
---
|
|
Binary file
|