@aws/mynah-ui 4.9.2 → 4.10.0-beta.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.
Files changed (124) hide show
  1. package/cloudscape-wrapper/main.ts +3 -0
  2. package/cloudscape-wrapper/package.json +72 -0
  3. package/cloudscape-wrapper/test-config/__mocks__/empty.mock.js +1 -0
  4. package/cloudscape-wrapper/test-config/test-utils.ts +11 -0
  5. package/dist/components/button.d.ts +7 -6
  6. package/dist/components/card/card-body.d.ts +1 -0
  7. package/dist/components/card/card.d.ts +1 -1
  8. package/dist/components/chat-item/chat-item-buttons.d.ts +1 -0
  9. package/dist/components/chat-item/chat-item-card-content.d.ts +35 -0
  10. package/dist/components/chat-item/chat-item-card.d.ts +13 -18
  11. package/dist/components/chat-item/chat-item-form-items.d.ts +1 -0
  12. package/dist/components/chat-item/chat-item-relevance-vote.d.ts +1 -0
  13. package/dist/components/chat-item/chat-item-tree-view-wrapper.d.ts +1 -0
  14. package/dist/components/chat-item/chat-prompt-input.d.ts +3 -3
  15. package/dist/components/chat-item/chat-wrapper.d.ts +2 -2
  16. package/dist/components/chat-item/prompt-input/prompt-attachment.d.ts +14 -0
  17. package/dist/components/chat-item/prompt-input/{code-snippet-widget.d.ts → prompt-text-attachment.d.ts} +7 -6
  18. package/dist/components/chat-item/prompt-input/send-button.d.ts +4 -5
  19. package/dist/components/form-items/radio-group.d.ts +14 -1
  20. package/dist/components/form-items/select.d.ts +15 -1
  21. package/dist/components/form-items/text-area.d.ts +14 -1
  22. package/dist/components/form-items/text-input.d.ts +15 -2
  23. package/dist/components/syntax-highlighter.d.ts +1 -0
  24. package/dist/helper/config.d.ts +2 -1
  25. package/dist/helper/dom.d.ts +2 -0
  26. package/dist/main.d.ts +16 -8
  27. package/dist/main.js +1 -1
  28. package/dist/main.js.map +1 -1
  29. package/dist/static.d.ts +18 -3
  30. package/docs/CONFIG.md +311 -0
  31. package/docs/DATAMODEL.md +1988 -0
  32. package/docs/DEVELOPER.md +499 -0
  33. package/docs/PROPERTIES.md +862 -0
  34. package/docs/STARTUP.md +51 -0
  35. package/docs/STYLING.md +195 -0
  36. package/docs/USAGE.md +502 -0
  37. package/docs/img/code-attachment.png +0 -0
  38. package/docs/img/customForm.png +0 -0
  39. package/docs/img/data-model/chatItems/actions.png +0 -0
  40. package/docs/img/data-model/chatItems/answer.png +0 -0
  41. package/docs/img/data-model/chatItems/answerStream.png +0 -0
  42. package/docs/img/data-model/chatItems/body.png +0 -0
  43. package/docs/img/data-model/chatItems/canBeVoted.png +0 -0
  44. package/docs/img/data-model/chatItems/codeInsertAndCopyButtons.png +0 -0
  45. package/docs/img/data-model/chatItems/codeReference-1.png +0 -0
  46. package/docs/img/data-model/chatItems/codeReference-2.png +0 -0
  47. package/docs/img/data-model/chatItems/codeResult.png +0 -0
  48. package/docs/img/data-model/chatItems/customRenderer_html.png +0 -0
  49. package/docs/img/data-model/chatItems/customRenderer_json.png +0 -0
  50. package/docs/img/data-model/chatItems/followUp-1.png +0 -0
  51. package/docs/img/data-model/chatItems/followUp-2.png +0 -0
  52. package/docs/img/data-model/chatItems/icon.png +0 -0
  53. package/docs/img/data-model/chatItems/notification-1.png +0 -0
  54. package/docs/img/data-model/chatItems/notification-2.png +0 -0
  55. package/docs/img/data-model/chatItems/notification-3.png +0 -0
  56. package/docs/img/data-model/chatItems/notification-4.png +0 -0
  57. package/docs/img/data-model/chatItems/options-all-filled.png +0 -0
  58. package/docs/img/data-model/chatItems/options-mandatory-filled.png +0 -0
  59. package/docs/img/data-model/chatItems/options-submitted.png +0 -0
  60. package/docs/img/data-model/chatItems/options.png +0 -0
  61. package/docs/img/data-model/chatItems/prompt.png +0 -0
  62. package/docs/img/data-model/chatItems/relatedContent-1.png +0 -0
  63. package/docs/img/data-model/chatItems/relatedContent-2.png +0 -0
  64. package/docs/img/data-model/chatItems/relatedContent-3.png +0 -0
  65. package/docs/img/data-model/chatItems/status.png +0 -0
  66. package/docs/img/data-model/chatItems/systemPrompt.png +0 -0
  67. package/docs/img/data-model/tabStore/loadingChat-1.png +0 -0
  68. package/docs/img/data-model/tabStore/loadingChat-2.png +0 -0
  69. package/docs/img/data-model/tabStore/promptInputDisabledState.png +0 -0
  70. package/docs/img/data-model/tabStore/promptInputPlaceholder.png +0 -0
  71. package/docs/img/data-model/tabStore/promptInputStickyCard.png +0 -0
  72. package/docs/img/data-model/tabStore/quickActionCommands.png +0 -0
  73. package/docs/img/data-model/tabStore/selectedCodeSnippet.png +0 -0
  74. package/docs/img/data-model/tabStore/stopChatResponse.png +0 -0
  75. package/docs/img/data-model/tabStore/tabBarButtons1.png +0 -0
  76. package/docs/img/data-model/tabStore/tabBarButtons2.png +0 -0
  77. package/docs/img/data-model/tabStore/tabTitle.png +0 -0
  78. package/docs/img/developer/comp0.png +0 -0
  79. package/docs/img/developer/comp1.png +0 -0
  80. package/docs/img/developer/comp2.png +0 -0
  81. package/docs/img/feedbackOptions.png +0 -0
  82. package/docs/img/maxTabs1.png +0 -0
  83. package/docs/img/noPrompt.png +0 -0
  84. package/docs/img/notification.png +0 -0
  85. package/docs/img/onBeforeTabRemove.png +0 -0
  86. package/docs/img/onBodyActionClicked.png +0 -0
  87. package/docs/img/onChatItemEngagement.png +0 -0
  88. package/docs/img/onChatPrompt.png +0 -0
  89. package/docs/img/onCodeInsertToCursorPosition.png +0 -0
  90. package/docs/img/onCopyCodeToClipboard.png +0 -0
  91. package/docs/img/onCustomFormAction.png +0 -0
  92. package/docs/img/onFileActionClick.png +0 -0
  93. package/docs/img/onFollowupClicked.png +0 -0
  94. package/docs/img/onInfoLinkClick.png +0 -0
  95. package/docs/img/onLinkClick.png +0 -0
  96. package/docs/img/onOpenDiff.png +0 -0
  97. package/docs/img/onSendFeedback-1.png +0 -0
  98. package/docs/img/onSendFeedback-2.png +0 -0
  99. package/docs/img/onSendFeedback-3.png +0 -0
  100. package/docs/img/onShowMoreClick.png +0 -0
  101. package/docs/img/onSourceLinkClick.png +0 -0
  102. package/docs/img/onStopChatResponse.png +0 -0
  103. package/docs/img/onTabAdd.png +0 -0
  104. package/docs/img/onTabChange.png +0 -0
  105. package/docs/img/onTabRemove.png +0 -0
  106. package/docs/img/onVote.png +0 -0
  107. package/docs/img/prompt-with-code-attached.png +0 -0
  108. package/docs/img/splash.gif +0 -0
  109. package/docs/img/texts/codeFileSuggestions.png +0 -0
  110. package/docs/img/texts/copyInsertToCursor.png +0 -0
  111. package/docs/img/texts/feedbackForm.png +0 -0
  112. package/docs/img/texts/fileTreeTitle.png +0 -0
  113. package/docs/img/texts/mainTitle.png +0 -0
  114. package/docs/img/texts/noMoreTabs.png +0 -0
  115. package/docs/img/texts/noTabsOpen.png +0 -0
  116. package/docs/img/texts/pleaseSelect.png +0 -0
  117. package/docs/img/texts/spinnerText.png +0 -0
  118. package/docs/img/texts/stopGenerating.png +0 -0
  119. package/docs/img/texts/tabCloseConfirmation.png +0 -0
  120. package/docs/img/texts/voteAndSourceActions.png +0 -0
  121. package/docs/img/theming-1.png +0 -0
  122. package/docs/img/theming-2.png +0 -0
  123. package/package.json +11 -2
  124. package/dist/components/chat-item/prompt-input/code-snippet.d.ts +0 -18
package/dist/static.d.ts CHANGED
@@ -4,6 +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
8
  export interface QuickActionCommand {
8
9
  command: string;
9
10
  disabled?: boolean;
@@ -115,8 +116,8 @@ export declare enum MynahEventNames {
115
116
  FILE_ACTION_CLICK = "fileActionClick",
116
117
  TAB_FOCUS = "tabFocus",
117
118
  CUSTOM_FORM_ACTION_CLICK = "customFormActionClick",
118
- ADD_CODE_SNIPPET = "addCodeSnippet",
119
- REMOVE_CODE_SNIPPET = "removeCodeSnippet",
119
+ ADD_ATTACHMENT = "addAttachment",
120
+ REMOVE_ATTACHMENT = "removeAttachment",
120
121
  TAB_BAR_BUTTON_CLICK = "tabBarButtonClick"
121
122
  }
122
123
  export declare enum MynahPortalNames {
@@ -125,6 +126,7 @@ export declare enum MynahPortalNames {
125
126
  OVERLAY = "overlay",
126
127
  FEEDBACK_FORM = "feedbackForm"
127
128
  }
129
+ export type PromptAttachmentType = 'code' | 'markdown';
128
130
  export interface SourceLinkMetaData {
129
131
  stars?: number;
130
132
  forks?: number;
@@ -189,7 +191,7 @@ export interface ChatItem {
189
191
  }
190
192
  export interface ChatItemFormItem {
191
193
  id: string;
192
- type: 'select' | 'textarea' | 'textinput' | 'numericinput' | 'stars' | 'radiogroup';
194
+ type: 'select' | 'textarea' | 'textinput' | 'numericinput' | 'stars' | 'radiogroup' | 'email';
193
195
  mandatory?: boolean;
194
196
  title?: string;
195
197
  placeholder?: string;
@@ -359,6 +361,17 @@ export interface ConfigTexts {
359
361
  noTabsOpen: string;
360
362
  openNewTab: string;
361
363
  }
364
+ type PickMatching<T, V> = {
365
+ [K in keyof T as T[K] extends V ? K : never]: T[K];
366
+ };
367
+ type ExtractMethods<T> = PickMatching<T, any>;
368
+ export interface ComponentOverrides {
369
+ Button?: new (props: ButtonProps) => ExtractMethods<ButtonAbstract>;
370
+ RadioGroup?: new (props: RadioGroupProps) => ExtractMethods<RadioGroupAbstract>;
371
+ Select?: new (props: SelectProps) => ExtractMethods<SelectAbstract>;
372
+ TextInput?: new (props: TextInputProps) => ExtractMethods<TextInputAbstract>;
373
+ TextArea?: new (props: TextAreaProps) => ExtractMethods<TextAreaAbstract>;
374
+ }
362
375
  export interface ConfigOptions {
363
376
  feedbackOptions: Array<{
364
377
  label: string;
@@ -374,7 +387,9 @@ export interface ConfigOptions {
374
387
  }
375
388
  export interface ConfigModel extends ConfigOptions {
376
389
  texts: Partial<ConfigTexts>;
390
+ componentOverrides: Partial<ComponentOverrides>;
377
391
  }
378
392
  export interface CardRenderDetails {
379
393
  totalNumberOfCodeBlocks?: number;
380
394
  }
395
+ export {};
package/docs/CONFIG.md ADDED
@@ -0,0 +1,311 @@
1
+ # MynahUI Config
2
+
3
+ You can set the config from the constructor parameters while creating a new instance of `mynah-ui`.
4
+
5
+ _**Note:** You cannot set it on runtime. It is getting used just once during the initialization._
6
+
7
+ ```typescript
8
+ ...
9
+ interface ConfigModel {
10
+ // Do not forget that you have to provide all of them
11
+ // Config allows partial set of texts
12
+ texts: {
13
+ mainTitle?: string;
14
+ feedbackFormTitle?: string;
15
+ feedbackFormOptionsLabel?: string;
16
+ feedbackFormCommentLabel?: string;
17
+ feedbackThanks?: string;
18
+ feedbackReportButtonLabel?: string;
19
+ codeSuggestions?: string;
20
+ files?: string;
21
+ insertAtCursorLabel?: string;
22
+ copy?: string;
23
+ showMore?: string;
24
+ save?: string;
25
+ cancel?: string;
26
+ submit?: string;
27
+ pleaseSelect?: string;
28
+ stopGenerating?: string;
29
+ copyToClipboard?: string;
30
+ noMoreTabsTooltip?: string;
31
+ codeSuggestionWithReferenceTitle?: string;
32
+ spinnerText?: string;
33
+ tabCloseConfirmationMessage?: string;
34
+ tabCloseConfirmationKeepButton?: string;
35
+ tabCloseConfirmationCloseButton?: string;
36
+ noTabsOpen: string; // Supports markdown
37
+ openNewTab: string;
38
+ };
39
+ // Options to show up on the overlay feedback form
40
+ // after user clicks to downvote on a chat item
41
+ // and clicks 'Report' again
42
+ feedbackOptions: Array<{
43
+ label: string;
44
+ value: string;
45
+ }>;
46
+ tabBarButtons?: TabBarMainAction[]; // Tab bar buttons will be shown on the right of the tab
47
+ maxUserInput: number; // max number of chars for the input field
48
+ codeInsertToCursorEnabled?: boolean; // show or hide copy buttons on code blocks system wide
49
+ codeCopyToClipboardEnabled?: boolean; // show or hide insert to cursor buttons on code blocks system wide
50
+ autoFocus: boolean; // auto focuses to input panel after every action
51
+ maxTabs: number; // set 1 to hide tabs panel
52
+ showPromptField: boolean; // shows prompt field (default: true)
53
+ }
54
+ ...
55
+ ```
56
+ ---
57
+
58
+ <p><br/></p>
59
+
60
+
61
+ # `tabBarButtons`
62
+
63
+ You can put buttons on the right of the tab bar also with some inner buttons inside a menu. You can do it in two different ways. If you want the buttons globally available for every tab you can use the `tabBarButtons` in the config. If you want them set individually for different tabs check the **[DATAMODEL Documentation](./DATAMODEL.md#tabbarbuttons)**.
64
+
65
+ ```typescript
66
+ const mynahUI = new MynahUI({
67
+ ...
68
+ config: {
69
+ ...
70
+ tabBarButtons: [
71
+ {
72
+ id: 'clear',
73
+ description: 'Clear messages in this tab',
74
+ icon: MynahIcons.REFRESH,
75
+ },
76
+ {
77
+ id: 'multi',
78
+ icon: MynahIcons.ELLIPSIS,
79
+ items: [
80
+ {
81
+ id: 'menu-action-1',
82
+ text: 'Menu action 1!',
83
+ icon: MynahIcons.CHAT,
84
+ },
85
+ {
86
+ id: 'menu-action-2',
87
+ text: 'Menu action 2!',
88
+ icon: MynahIcons.CODE_BLOCK,
89
+ },
90
+ {
91
+ id: 'menu-action-3',
92
+ text: 'Menu action 3!'
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ }
98
+ ...
99
+ });
100
+ ```
101
+
102
+ <p align="center">
103
+ <img src="./img/data-model/tabStore/tabBarButtons1.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
104
+ <br/>
105
+ <img src="./img/data-model/tabStore/tabBarButtons2.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
106
+ </p>
107
+
108
+ ---
109
+
110
+
111
+
112
+ # `texts`
113
+ All static texts will be shown on UI.
114
+ Please take a look at each image to identify which text blongs to which item on UI.
115
+
116
+ ## mainTitle
117
+ Default tab title text if it is not set through store data for that tab.
118
+
119
+ <p align="center">
120
+ <img src="./img/texts/mainTitle.png" alt="mainTitle" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
121
+ </p>
122
+
123
+ ---
124
+
125
+ ## feedbackFormTitle, feedbackFormOptionsLabel, feedbackFormCommentLabel, submit, cancel
126
+ <p align="center">
127
+ <img src="./img/texts/feedbackForm.png" alt="feedbackForm" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
128
+ </p>
129
+
130
+
131
+ ---
132
+
133
+ ## fileTreeTitle, rootFolderTitle, feedbackFormCommentLabel, submit, cancel
134
+ <p align="center">
135
+ <img src="./img/texts/fileTreeTitle.png" alt="fileTree" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
136
+ </p>
137
+
138
+
139
+ ---
140
+
141
+ ## pleaseSelect
142
+ <p align="center">
143
+ <img src="./img/texts/pleaseSelect.png" alt="feedbackForm" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
144
+ </p>
145
+
146
+ ---
147
+
148
+ ## feedbackThanks, feedbackReportButtonLabel, showMore
149
+ <p align="center">
150
+ <img src="./img/texts/voteAndSourceActions.png" alt="voteAndSourceActions" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
151
+ </p>
152
+
153
+ ---
154
+
155
+ ## stopGenerating
156
+ <p align="center">
157
+ <img src="./img/texts/stopGenerating.png" alt="stopGenerating" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
158
+ </p>
159
+
160
+ ---
161
+
162
+ ## insertAtCursorLabel, copy
163
+ <p align="center">
164
+ <img src="./img/texts/copyInsertToCursor.png" alt="copyInsertToCursor" style="border-radius: 10px; max-width:500px; width:100%;border: 1px solid #e0e0e0;">
165
+ </p>
166
+
167
+ ---
168
+
169
+ ## codeSuggestions, files, codeSuggestionWithReferenceTitle
170
+ <p align="center">
171
+ <img src="./img/texts/codeFileSuggestions.png" alt="codeFileSuggestions" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
172
+ </p>
173
+
174
+ ---
175
+
176
+ ## spinnerText
177
+ <p align="center">
178
+ <img src="./img/texts/spinnerText.png" alt="spinnerText" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
179
+ </p>
180
+
181
+ ---
182
+
183
+ ## tabCloseConfirmationMessage, tabCloseConfirmationKeepButton, tabCloseConfirmationCloseButton
184
+ <p align="center">
185
+ <img src="./img/texts/tabCloseConfirmation.png" alt="tabCloseConfirmation" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
186
+ </p>
187
+
188
+ ---
189
+
190
+ ## noMoreTabsTooltip
191
+ <p align="center">
192
+ <img src="./img/texts/noMoreTabs.png" alt="noMoreTabsTooltip" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
193
+ </p>
194
+
195
+ ---
196
+
197
+ ## noTabsOpen, openNewTab
198
+ <p align="center">
199
+ <img src="./img/texts/noTabsOpen.png" alt="noTabsOpen" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
200
+ </p>
201
+
202
+ ---
203
+
204
+ <p><br/></p>
205
+
206
+ # `feedbackOptions`
207
+
208
+ Feedback type options to be shown on feedback form.
209
+ defaults:
210
+ ```typescript
211
+ ...
212
+ feedbackOptions: [
213
+ {
214
+ value: 'inaccurate-response',
215
+ label: 'Inaccurate response',
216
+ },
217
+ {
218
+ value: 'harmful-content',
219
+ label: 'Harmful content'
220
+ },
221
+ {
222
+ value: 'overlap',
223
+ label: 'Overlaps with existing content'
224
+ },
225
+ {
226
+ value: 'incorrect-syntax',
227
+ label: 'Incorrect syntax'
228
+ },
229
+ {
230
+ value: 'buggy-code',
231
+ label: 'Buggy code'
232
+ },
233
+ {
234
+ value: 'low-quality',
235
+ label: 'Low quality'
236
+ },
237
+ {
238
+ value: 'other',
239
+ label: 'Other'
240
+ }
241
+ ],
242
+ ...
243
+ ```
244
+
245
+ <p align="center">
246
+ <img src="./img/feedbackOptions.png" alt="feedbackOptions" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
247
+ </p>
248
+
249
+ ---
250
+
251
+ <p><br/></p>
252
+
253
+ # `maxTabs`
254
+ Maximum number of tabs user/system can open in a single instance of `mynah-ui`.
255
+
256
+ default: `1000`
257
+
258
+ An important note here is that if you provide **`1`** to maxTabs, it will not show the tab bar at all. However you still need to add a tab then initially to show a content.
259
+
260
+ And finally, if you try to add tabs more than given `maxTabs` amount while initializing the MynahUI with [Constructor Properties](./PROPERTIES.md), it will only generate the tabs till it reaches the `maxTabs` limit.
261
+
262
+ _Assume that you've provided `1` for `maxTabs`._
263
+
264
+
265
+ <p align="center">
266
+ <img src="./img/maxTabs1.png" alt="maxTabs1" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
267
+ </p>
268
+
269
+ ---
270
+
271
+ <p><br/></p>
272
+
273
+ # `autoFocus`
274
+ Just auto focus to prompt input field after every response arrival or initialization.
275
+
276
+ default: `true`
277
+
278
+ ---
279
+
280
+ <p><br/></p>
281
+
282
+ # `maxUserInput`
283
+ Max number of chars user can insert into the prompt field. But, as might know you can also add code attachments under the prompt field. A treshold of `96` chars will be automatically reduced from the `maxUserInput`.
284
+
285
+ **So beware that if you want 4000 chars exact, you need to give 4096 to the config.**
286
+
287
+ default: `4096`
288
+
289
+ ---
290
+
291
+ ## `codeInsertToCursorEnabled` and `codeCopyToClipboardEnabled` (default: true)
292
+ These two parameters allow you to make copy and insert buttons disabled system wide. If you want to disable it specifically for a message you can do it through `ChatItem` object. Please see [DATAMODEL Documentation](./DATAMODEL.md#codeinserttocursorenabled-and-codecopytoclipboardenabled-default-true).
293
+
294
+ <p align="center">
295
+ <img src="./img/data-model/chatItems/codeInsertAndCopyButtons.png" alt="codeInsertAndCopy" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
296
+ </p>
297
+
298
+ ---
299
+
300
+ <p><br/></p>
301
+
302
+ # `showPromptField`
303
+ Show or hide the prompt input field completely. You may want to hide the prompt field by setting `showPromptField` to `false` to make the chat work one way only. Just to provide answers or information.
304
+
305
+ default: `true`
306
+
307
+ _If you set `showPromptField` to `false`_
308
+
309
+ <p align="center">
310
+ <img src="./img/noPrompt.png" alt="noPrompt" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
311
+ </p>