@aws/mynah-ui 4.13.0 → 4.14.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/card/card-body.d.ts +3 -2
- package/dist/components/chat-item/chat-item-card-content.d.ts +4 -3
- package/dist/components/chat-item/chat-item-card.d.ts +7 -0
- package/dist/components/chat-item/chat-wrapper.d.ts +2 -0
- package/dist/components/chat-item/prompt-input/prompt-text-input.d.ts +2 -0
- package/dist/components/icon.d.ts +4 -1
- package/dist/components/syntax-highlighter.d.ts +4 -4
- package/dist/helper/chat-item.d.ts +1 -0
- package/dist/main.d.ts +10 -3
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/static.d.ts +23 -11
- package/docs/CONFIG.md +39 -0
- package/docs/DATAMODEL.md +103 -35
- package/docs/img/data-model/chatItems/codeBlockActions.png +0 -0
- package/docs/img/data-model/chatItems/codeInsertAndCopyButtonsThroughConfig.png +0 -0
- package/docs/img/data-model/chatItems/footer.png +0 -0
- package/docs/img/data-model/chatItems/footer2.png +0 -0
- package/package.json +1 -1
- package/postinstall.js +4 -2
package/dist/static.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ export declare enum MynahEventNames {
|
|
|
109
109
|
LINK_CLICK = "linkClick",
|
|
110
110
|
CHAT_ITEM_ENGAGEMENT = "chatItemEngagement",
|
|
111
111
|
COPY_CODE_TO_CLIPBOARD = "copyCodeToClipboard",
|
|
112
|
-
|
|
112
|
+
CODE_BLOCK_ACTION = "codeBlockAction",
|
|
113
113
|
CHAT_PROMPT = "chatPrompt",
|
|
114
114
|
CHAT_ITEM_ADD = "chatItemAdd",
|
|
115
115
|
FOLLOW_UP_CLICKED = "followUpClicked",
|
|
@@ -163,15 +163,9 @@ export interface TreeNodeDetails {
|
|
|
163
163
|
label?: string;
|
|
164
164
|
description?: string;
|
|
165
165
|
}
|
|
166
|
-
export interface
|
|
167
|
-
type: ChatItemType;
|
|
166
|
+
export interface ChatItemContent {
|
|
168
167
|
body?: string;
|
|
169
168
|
customRenderer?: string | ChatItemBodyRenderer | ChatItemBodyRenderer[];
|
|
170
|
-
messageId?: string;
|
|
171
|
-
snapToTop?: boolean;
|
|
172
|
-
canBeVoted?: boolean;
|
|
173
|
-
codeInsertToCursorEnabled?: boolean;
|
|
174
|
-
codeCopyToClipboardEnabled?: boolean;
|
|
175
169
|
followUp?: {
|
|
176
170
|
text?: string;
|
|
177
171
|
options?: ChatItemAction[];
|
|
@@ -189,10 +183,18 @@ export interface ChatItem {
|
|
|
189
183
|
actions?: Record<string, FileNodeAction[]>;
|
|
190
184
|
details?: Record<string, TreeNodeDetails>;
|
|
191
185
|
};
|
|
192
|
-
icon?: MynahIcons;
|
|
193
|
-
status?: 'info' | 'success' | 'warning' | 'error';
|
|
194
186
|
buttons?: ChatItemButton[];
|
|
195
187
|
formItems?: ChatItemFormItem[];
|
|
188
|
+
footer?: ChatItemContent;
|
|
189
|
+
codeBlockActions?: CodeBlockActions;
|
|
190
|
+
}
|
|
191
|
+
export interface ChatItem extends ChatItemContent {
|
|
192
|
+
type: ChatItemType;
|
|
193
|
+
messageId?: string;
|
|
194
|
+
snapToTop?: boolean;
|
|
195
|
+
canBeVoted?: boolean;
|
|
196
|
+
icon?: MynahIcons;
|
|
197
|
+
status?: 'info' | 'success' | 'warning' | 'error';
|
|
196
198
|
}
|
|
197
199
|
export interface ChatItemFormItem {
|
|
198
200
|
id: string;
|
|
@@ -284,7 +286,7 @@ export interface ReferenceTrackerInformation {
|
|
|
284
286
|
}
|
|
285
287
|
export type CodeSelectionType = 'selection' | 'block';
|
|
286
288
|
export type OnCopiedToClipboardFunction = (type?: CodeSelectionType, text?: string, referenceTrackerInformation?: ReferenceTrackerInformation[], codeBlockIndex?: number, totalCodeBlocks?: number) => void;
|
|
287
|
-
export type
|
|
289
|
+
export type OnCodeBlockActionFunction = (actionId: string, data?: any, type?: CodeSelectionType, text?: string, referenceTrackerInformation?: ReferenceTrackerInformation[], codeBlockIndex?: number, totalCodeBlocks?: number) => void;
|
|
288
290
|
export declare enum RelevancyVoteType {
|
|
289
291
|
UP = "upvote",
|
|
290
292
|
DOWN = "downvote"
|
|
@@ -339,6 +341,15 @@ export declare enum NotificationType {
|
|
|
339
341
|
WARNING = "warning",
|
|
340
342
|
ERROR = "error"
|
|
341
343
|
}
|
|
344
|
+
export interface CodeBlockAction {
|
|
345
|
+
id: 'copy' | 'insert-to-cursor' | string;
|
|
346
|
+
label: string;
|
|
347
|
+
description?: string;
|
|
348
|
+
icon?: MynahIcons;
|
|
349
|
+
data?: any;
|
|
350
|
+
acceptedLanguages?: string[];
|
|
351
|
+
}
|
|
352
|
+
export type CodeBlockActions = Record<'copy' | 'insert-to-cursor' | string, CodeBlockAction | undefined | null>;
|
|
342
353
|
export interface ConfigTexts {
|
|
343
354
|
mainTitle: string;
|
|
344
355
|
feedbackFormTitle: string;
|
|
@@ -389,6 +400,7 @@ export interface ConfigOptions {
|
|
|
389
400
|
showPromptField: boolean;
|
|
390
401
|
autoFocus: boolean;
|
|
391
402
|
maxUserInput: number;
|
|
403
|
+
codeBlockActions?: CodeBlockActions;
|
|
392
404
|
codeInsertToCursorEnabled?: boolean;
|
|
393
405
|
codeCopyToClipboardEnabled?: boolean;
|
|
394
406
|
}
|
package/docs/CONFIG.md
CHANGED
|
@@ -297,6 +297,45 @@ These two parameters allow you to make copy and insert buttons disabled system w
|
|
|
297
297
|
|
|
298
298
|
---
|
|
299
299
|
|
|
300
|
+
## `codeBlockActions`
|
|
301
|
+
With this parameter, you can add global code block actions to the code blocks. But, you can override them through [ChatItem Data Model](./DATAMODEL.md#codeBlockActions).
|
|
302
|
+
|
|
303
|
+
### Note
|
|
304
|
+
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.
|
|
305
|
+
|
|
306
|
+
#### By default, we add `copy` and `insert to cursor position` ones:
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
{
|
|
310
|
+
codeBlockActions: {
|
|
311
|
+
...(codeCopyToClipboardEnabled !== false
|
|
312
|
+
? {
|
|
313
|
+
copy: {
|
|
314
|
+
id: 'copy',
|
|
315
|
+
label: texts.copy,
|
|
316
|
+
icon: MynahIcons.COPY
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
: {}),
|
|
320
|
+
...(codeInsertToCursorEnabled !== false
|
|
321
|
+
? {
|
|
322
|
+
'insert-to-cursor': {
|
|
323
|
+
id: 'insert-to-cursor',
|
|
324
|
+
label: texts.insertAtCursorLabel,
|
|
325
|
+
icon: MynahIcons.CURSOR_INSERT
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
: {}),
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
<p align="center">
|
|
334
|
+
<img src="./img/data-model/chatItems/codeInsertAndCopyButtonsThroughConfig.png" alt="codeInsertAndCopy" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
335
|
+
</p>
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
300
339
|
<p><br/></p>
|
|
301
340
|
|
|
302
341
|
# `showPromptField`
|
package/docs/DATAMODEL.md
CHANGED
|
@@ -563,7 +563,7 @@ enum ChatItemType {
|
|
|
563
563
|
SYSTEM_PROMPT = 'system-prompt'
|
|
564
564
|
}
|
|
565
565
|
|
|
566
|
-
|
|
566
|
+
interface ChatItemAction extends ChatPrompt {
|
|
567
567
|
type?: string;
|
|
568
568
|
pillText: string;
|
|
569
569
|
disabled?: boolean;
|
|
@@ -572,7 +572,7 @@ export interface ChatItemAction extends ChatPrompt {
|
|
|
572
572
|
icon?: MynahIcons;
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
|
|
575
|
+
interface ChatItemButton {
|
|
576
576
|
keepCardAfterClick?: boolean;
|
|
577
577
|
waitMandatoryFormItems?: boolean;
|
|
578
578
|
text: string;
|
|
@@ -583,7 +583,7 @@ export interface ChatItemButton {
|
|
|
583
583
|
icon?: MynahIcons;
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
|
|
586
|
+
interface ChatItemFormItem {
|
|
587
587
|
id: string;
|
|
588
588
|
type: 'select' | 'textarea' | 'textinput' | 'numericinput' | 'stars' | 'radiogroup';
|
|
589
589
|
mandatory?: boolean;
|
|
@@ -596,7 +596,7 @@ export interface ChatItemFormItem {
|
|
|
596
596
|
}>;
|
|
597
597
|
}
|
|
598
598
|
|
|
599
|
-
|
|
599
|
+
interface FileNodeAction {
|
|
600
600
|
name: string;
|
|
601
601
|
label?: string;
|
|
602
602
|
disabled?: boolean;
|
|
@@ -605,14 +605,14 @@ export interface FileNodeAction {
|
|
|
605
605
|
icon: MynahIcons;
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
-
|
|
608
|
+
interface TreeNodeDetails {
|
|
609
609
|
status?: 'info' | 'success' | 'warning' | 'error';
|
|
610
610
|
icon?: MynahIcons;
|
|
611
611
|
label?: string;
|
|
612
612
|
description?: string; // Markdown tooltip
|
|
613
613
|
}
|
|
614
614
|
|
|
615
|
-
|
|
615
|
+
interface SourceLink {
|
|
616
616
|
title: string;
|
|
617
617
|
id?: string;
|
|
618
618
|
url: string;
|
|
@@ -621,7 +621,7 @@ export interface SourceLink {
|
|
|
621
621
|
metadata?: Record<string, SourceLinkMetaData>;
|
|
622
622
|
}
|
|
623
623
|
|
|
624
|
-
|
|
624
|
+
interface ReferenceTrackerInformation {
|
|
625
625
|
licenseName?: string;
|
|
626
626
|
repository?: string;
|
|
627
627
|
url?: string;
|
|
@@ -632,41 +632,56 @@ export interface ReferenceTrackerInformation {
|
|
|
632
632
|
information: string;
|
|
633
633
|
}
|
|
634
634
|
|
|
635
|
-
|
|
635
|
+
interface ChatItemBodyRenderer extends GenericDomBuilderAttributes {
|
|
636
636
|
type: AllowedTagsInCustomRenderer;
|
|
637
637
|
children?: Array<string | ChatItemBodyRenderer> | undefined;
|
|
638
638
|
attributes?: Partial<Record<AllowedAttributesInCustomRenderer, string>> | undefined;
|
|
639
639
|
}
|
|
640
640
|
|
|
641
|
+
interface CodeBlockAction {
|
|
642
|
+
id: 'copy' | 'insert-to-cursor' | string;
|
|
643
|
+
label: string;
|
|
644
|
+
description?: string;
|
|
645
|
+
icon?: MynahIcons;
|
|
646
|
+
data?: any;
|
|
647
|
+
acceptedLanguages?: string[];
|
|
648
|
+
}
|
|
649
|
+
type CodeBlockActions = Record<'copy' | 'insert-to-cursor' | string, CodeBlockAction | undefined | null>;
|
|
650
|
+
|
|
641
651
|
// #################################
|
|
642
|
-
interface
|
|
643
|
-
|
|
644
|
-
fileList?: {
|
|
645
|
-
filePaths?: string[];
|
|
646
|
-
deletedFiles?: string[];
|
|
647
|
-
actions?: Record<string, FileNodeAction[]>;
|
|
648
|
-
details?: Record<string, TreeNodeDetails>;
|
|
649
|
-
};
|
|
650
|
-
body?: string; // supports MARKDOWN string
|
|
652
|
+
interface ChatItemContent {
|
|
653
|
+
body?: string;
|
|
651
654
|
customRenderer?: string | ChatItemBodyRenderer | ChatItemBodyRenderer[];
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
codeCopyToClipboardEnabled?: boolean; // show or hide insert to cursor buttons on all code blocks for this message
|
|
655
|
+
followUp?: {
|
|
656
|
+
text?: string;
|
|
657
|
+
options?: ChatItemAction[];
|
|
658
|
+
};
|
|
657
659
|
relatedContent?: {
|
|
658
660
|
title?: string;
|
|
659
661
|
content: SourceLink[];
|
|
660
662
|
};
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
663
|
+
codeReference?: ReferenceTrackerInformation[];
|
|
664
|
+
fileList?: {
|
|
665
|
+
fileTreeTitle?: string;
|
|
666
|
+
rootFolderTitle?: string;
|
|
667
|
+
filePaths?: string[];
|
|
668
|
+
deletedFiles?: string[];
|
|
669
|
+
actions?: Record<string, FileNodeAction[]>;
|
|
670
|
+
details?: Record<string, TreeNodeDetails>;
|
|
664
671
|
};
|
|
665
672
|
buttons?: ChatItemButton[];
|
|
666
673
|
formItems?: ChatItemFormItem[];
|
|
667
|
-
|
|
674
|
+
footer?: ChatItemContent;
|
|
675
|
+
codeBlockActions?: CodeBlockActions;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
interface ChatItem extends ChatItemContent{
|
|
679
|
+
type: ChatItemType;
|
|
680
|
+
messageId?: string;
|
|
681
|
+
snapToTop?: boolean;
|
|
682
|
+
canBeVoted?: boolean;
|
|
668
683
|
icon?: MynahIcons;
|
|
669
|
-
|
|
684
|
+
status?: 'info' | 'success' | 'warning' | 'error';
|
|
670
685
|
}
|
|
671
686
|
// #################################
|
|
672
687
|
```
|
|
@@ -1300,8 +1315,11 @@ mynahUI.addChatItem('tab-1', {
|
|
|
1300
1315
|
|
|
1301
1316
|
---
|
|
1302
1317
|
|
|
1303
|
-
## `
|
|
1304
|
-
|
|
1318
|
+
## `codeBlockActions`
|
|
1319
|
+
With this parameter, you can add per chatitem code block actions to the code blocks inside that ChatItem. You can also override the actions added through [CONFIG](./CONFIG.md#codeblockactions).
|
|
1320
|
+
|
|
1321
|
+
### Note
|
|
1322
|
+
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.
|
|
1305
1323
|
|
|
1306
1324
|
```typescript
|
|
1307
1325
|
const mynahUI = new MynahUI({
|
|
@@ -1312,16 +1330,66 @@ const mynahUI = new MynahUI({
|
|
|
1312
1330
|
}
|
|
1313
1331
|
});
|
|
1314
1332
|
|
|
1315
|
-
mynahUI.addChatItem(
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1333
|
+
mynahUI.addChatItem(tabId, {
|
|
1334
|
+
type: ChatItemType.ANSWER,
|
|
1335
|
+
body: `SOME CODE DIFF`,
|
|
1336
|
+
codeBlockActions: {
|
|
1337
|
+
'copy': undefined, // To override the one comes from the config by default
|
|
1338
|
+
'accept-diff': {
|
|
1339
|
+
id: 'accept-diff',
|
|
1340
|
+
label: 'Accept Diff',
|
|
1341
|
+
icon: MynahIcons.OK_CIRCLED,
|
|
1342
|
+
data: { // Can be "any"thing
|
|
1343
|
+
updatedCode: `SOME CODE DIFF APPLIED`
|
|
1344
|
+
},
|
|
1345
|
+
acceptedLanguages: ['diff-typescript']
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1320
1348
|
});
|
|
1321
1349
|
```
|
|
1322
1350
|
|
|
1323
1351
|
<p align="center">
|
|
1324
|
-
<img src="./img/data-model/chatItems/
|
|
1352
|
+
<img src="./img/data-model/chatItems/codeBlockActions.png" alt="codeBlockActions" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
1353
|
+
</p>
|
|
1354
|
+
|
|
1355
|
+
---
|
|
1356
|
+
|
|
1357
|
+
## `footer`
|
|
1358
|
+
With this parameter, you can add another `ChatItem` only with contents to the footer of a ChatItem.
|
|
1359
|
+
|
|
1360
|
+
```typescript
|
|
1361
|
+
const mynahUI = new MynahUI({
|
|
1362
|
+
tabs: {
|
|
1363
|
+
'tab-1': {
|
|
1364
|
+
...
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
|
|
1369
|
+
mynahUI.addChatItem(tabId, {
|
|
1370
|
+
type: ChatItemType.ANSWER,
|
|
1371
|
+
body: `SOME CONTENT`,
|
|
1372
|
+
footer: {
|
|
1373
|
+
fileList: { // For example, want to show which file is used to generate that answer
|
|
1374
|
+
rootFolderTitle: undefined,
|
|
1375
|
+
fileTreeTitle: '',
|
|
1376
|
+
filePaths: ['./src/index.ts'],
|
|
1377
|
+
details: {
|
|
1378
|
+
'./src/index.ts': {
|
|
1379
|
+
icon: MynahIcons.FILE,
|
|
1380
|
+
description: `SOME DESCRIPTION.`
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
```
|
|
1387
|
+
|
|
1388
|
+
<p align="center">
|
|
1389
|
+
<img src="./img/data-model/chatItems/footer.png" alt="footer-1" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
1390
|
+
</p>
|
|
1391
|
+
<p align="center">
|
|
1392
|
+
<img src="./img/data-model/chatItems/footer2.png" alt="footer-2" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
1325
1393
|
</p>
|
|
1326
1394
|
|
|
1327
1395
|
---
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const deprecationList = [
|
|
2
|
-
'Config.texts.clickFileToViewDiff will be deprecated 5.x.x',
|
|
3
|
-
'MynahUIProps.onOpenDiff will be deprecated
|
|
2
|
+
'Config.texts.clickFileToViewDiff will be deprecated after 5.x.x',
|
|
3
|
+
'MynahUIProps.onOpenDiff will be deprecated after 5.x.x',
|
|
4
|
+
'MynahUIProps.onCodeInsertToCursorPosition will be deprecated after 5.x.x',
|
|
5
|
+
'MynahUIProps.onCopyCodeToClipboard will be changed to be used only on keyboard and context menu copy actions after 5.x.x',
|
|
4
6
|
];
|
|
5
7
|
|
|
6
8
|
deprecationList.forEach(deprecationItem => console.log(deprecationItem));
|