@aws/mynah-ui 4.11.2 → 4.13.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.
Files changed (140) hide show
  1. package/dist/components/button.d.ts +8 -6
  2. package/dist/components/card/card-body.d.ts +2 -5
  3. package/dist/components/card/card.d.ts +2 -1
  4. package/dist/components/chat-item/chat-item-buttons.d.ts +1 -1
  5. package/dist/components/chat-item/chat-item-card-content.d.ts +35 -0
  6. package/dist/components/chat-item/chat-item-card.d.ts +13 -18
  7. package/dist/components/chat-item/chat-item-form-items.d.ts +1 -0
  8. package/dist/components/chat-item/chat-item-relevance-vote.d.ts +1 -0
  9. package/dist/components/chat-item/chat-item-tree-view-wrapper.d.ts +1 -0
  10. package/dist/components/chat-item/chat-prompt-input.d.ts +10 -6
  11. package/dist/components/chat-item/chat-wrapper.d.ts +1 -0
  12. package/dist/components/chat-item/prompt-input/prompt-text-input.d.ts +10 -2
  13. package/dist/components/chat-item/prompt-input/send-button.d.ts +4 -5
  14. package/dist/components/collapsible-content.d.ts +1 -0
  15. package/dist/components/feedback-form/feedback-form.d.ts +1 -0
  16. package/dist/components/form-items/radio-group.d.ts +15 -1
  17. package/dist/components/form-items/select.d.ts +16 -1
  18. package/dist/components/form-items/stars.d.ts +1 -0
  19. package/dist/components/form-items/text-area.d.ts +15 -1
  20. package/dist/components/form-items/text-input.d.ts +16 -2
  21. package/dist/components/icon.d.ts +1 -0
  22. package/dist/components/navigation-tabs.d.ts +1 -0
  23. package/dist/components/no-tabs.d.ts +1 -0
  24. package/dist/components/notification.d.ts +1 -0
  25. package/dist/components/overlay.d.ts +1 -0
  26. package/dist/components/syntax-highlighter.d.ts +2 -0
  27. package/dist/components/toggle.d.ts +1 -0
  28. package/dist/helper/config.d.ts +2 -1
  29. package/dist/helper/dom.d.ts +2 -0
  30. package/dist/main.d.ts +9 -1
  31. package/dist/main.js +1 -1
  32. package/dist/main.js.map +1 -1
  33. package/dist/static.d.ts +21 -1
  34. package/docs/CONFIG.md +311 -0
  35. package/docs/DATAMODEL.md +2078 -0
  36. package/docs/DEVELOPER.md +499 -0
  37. package/docs/PROPERTIES.md +863 -0
  38. package/docs/STARTUP.md +51 -0
  39. package/docs/STYLING.md +195 -0
  40. package/docs/USAGE.md +502 -0
  41. package/docs/img/code-attachment.png +0 -0
  42. package/docs/img/customForm.png +0 -0
  43. package/docs/img/data-model/chatItems/actions.png +0 -0
  44. package/docs/img/data-model/chatItems/answer.png +0 -0
  45. package/docs/img/data-model/chatItems/answerStream.png +0 -0
  46. package/docs/img/data-model/chatItems/body.png +0 -0
  47. package/docs/img/data-model/chatItems/canBeVoted.png +0 -0
  48. package/docs/img/data-model/chatItems/codeInsertAndCopyButtons.png +0 -0
  49. package/docs/img/data-model/chatItems/codeReference-1.png +0 -0
  50. package/docs/img/data-model/chatItems/codeReference-2.png +0 -0
  51. package/docs/img/data-model/chatItems/codeResult.png +0 -0
  52. package/docs/img/data-model/chatItems/customRenderer_html.png +0 -0
  53. package/docs/img/data-model/chatItems/customRenderer_json.png +0 -0
  54. package/docs/img/data-model/chatItems/followUp-1.png +0 -0
  55. package/docs/img/data-model/chatItems/followUp-2.png +0 -0
  56. package/docs/img/data-model/chatItems/icon.png +0 -0
  57. package/docs/img/data-model/chatItems/notification-1.png +0 -0
  58. package/docs/img/data-model/chatItems/notification-2.png +0 -0
  59. package/docs/img/data-model/chatItems/notification-3.png +0 -0
  60. package/docs/img/data-model/chatItems/notification-4.png +0 -0
  61. package/docs/img/data-model/chatItems/options-all-filled.png +0 -0
  62. package/docs/img/data-model/chatItems/options-mandatory-filled.png +0 -0
  63. package/docs/img/data-model/chatItems/options-submitted.png +0 -0
  64. package/docs/img/data-model/chatItems/options.png +0 -0
  65. package/docs/img/data-model/chatItems/prompt.png +0 -0
  66. package/docs/img/data-model/chatItems/relatedContent-1.png +0 -0
  67. package/docs/img/data-model/chatItems/relatedContent-2.png +0 -0
  68. package/docs/img/data-model/chatItems/relatedContent-3.png +0 -0
  69. package/docs/img/data-model/chatItems/status.png +0 -0
  70. package/docs/img/data-model/chatItems/systemPrompt.png +0 -0
  71. package/docs/img/data-model/tabStore/contextCommands.png +0 -0
  72. package/docs/img/data-model/tabStore/loadingChat-1.png +0 -0
  73. package/docs/img/data-model/tabStore/loadingChat-2.png +0 -0
  74. package/docs/img/data-model/tabStore/promptInputDisabledState.png +0 -0
  75. package/docs/img/data-model/tabStore/promptInputPlaceholder.png +0 -0
  76. package/docs/img/data-model/tabStore/promptInputStickyCard.png +0 -0
  77. package/docs/img/data-model/tabStore/quickActionCommands.png +0 -0
  78. package/docs/img/data-model/tabStore/selectedCodeSnippet.png +0 -0
  79. package/docs/img/data-model/tabStore/stopChatResponse.png +0 -0
  80. package/docs/img/data-model/tabStore/tabBarButtons1.png +0 -0
  81. package/docs/img/data-model/tabStore/tabBarButtons2.png +0 -0
  82. package/docs/img/data-model/tabStore/tabTitle.png +0 -0
  83. package/docs/img/developer/comp0.png +0 -0
  84. package/docs/img/developer/comp1.png +0 -0
  85. package/docs/img/developer/comp2.png +0 -0
  86. package/docs/img/feedbackOptions.png +0 -0
  87. package/docs/img/maxTabs1.png +0 -0
  88. package/docs/img/noPrompt.png +0 -0
  89. package/docs/img/notification.png +0 -0
  90. package/docs/img/onBeforeTabRemove.png +0 -0
  91. package/docs/img/onBodyActionClicked.png +0 -0
  92. package/docs/img/onChatItemEngagement.png +0 -0
  93. package/docs/img/onChatPrompt.png +0 -0
  94. package/docs/img/onCodeInsertToCursorPosition.png +0 -0
  95. package/docs/img/onCopyCodeToClipboard.png +0 -0
  96. package/docs/img/onCustomFormAction.png +0 -0
  97. package/docs/img/onFileActionClick.png +0 -0
  98. package/docs/img/onFollowupClicked.png +0 -0
  99. package/docs/img/onInfoLinkClick.png +0 -0
  100. package/docs/img/onLinkClick.png +0 -0
  101. package/docs/img/onOpenDiff.png +0 -0
  102. package/docs/img/onSendFeedback-1.png +0 -0
  103. package/docs/img/onSendFeedback-2.png +0 -0
  104. package/docs/img/onSendFeedback-3.png +0 -0
  105. package/docs/img/onShowMoreClick.png +0 -0
  106. package/docs/img/onSourceLinkClick.png +0 -0
  107. package/docs/img/onStopChatResponse.png +0 -0
  108. package/docs/img/onTabAdd.png +0 -0
  109. package/docs/img/onTabChange.png +0 -0
  110. package/docs/img/onTabRemove.png +0 -0
  111. package/docs/img/onVote.png +0 -0
  112. package/docs/img/prompt-with-code-attached.png +0 -0
  113. package/docs/img/splash.gif +0 -0
  114. package/docs/img/texts/codeFileSuggestions.png +0 -0
  115. package/docs/img/texts/copyInsertToCursor.png +0 -0
  116. package/docs/img/texts/feedbackForm.png +0 -0
  117. package/docs/img/texts/fileTreeTitle.png +0 -0
  118. package/docs/img/texts/mainTitle.png +0 -0
  119. package/docs/img/texts/noMoreTabs.png +0 -0
  120. package/docs/img/texts/noTabsOpen.png +0 -0
  121. package/docs/img/texts/pleaseSelect.png +0 -0
  122. package/docs/img/texts/spinnerText.png +0 -0
  123. package/docs/img/texts/stopGenerating.png +0 -0
  124. package/docs/img/texts/tabCloseConfirmation.png +0 -0
  125. package/docs/img/texts/voteAndSourceActions.png +0 -0
  126. package/docs/img/theming-1.png +0 -0
  127. package/docs/img/theming-2.png +0 -0
  128. package/package.json +2 -2
  129. package/dist/__test__/main.spec.d.ts +0 -1
  130. package/dist/components/__test__/button.spec.d.ts +0 -1
  131. package/dist/components/__test__/chat-item/chat-item-followup.spec.d.ts +0 -1
  132. package/dist/components/__test__/chat-item/chat-prompt-input.spec.d.ts +0 -1
  133. package/dist/components/__test__/feedback-form/feedback-form.spec.d.ts +0 -1
  134. package/dist/components/__test__/notification.spec.d.ts +0 -1
  135. package/dist/components/__test__/syntax-highlighter.spec.d.ts +0 -1
  136. package/dist/components/__test__/toggle.spec.d.ts +0 -1
  137. package/dist/helper/__test__/date-time.spec.d.ts +0 -1
  138. package/dist/helper/__test__/dom.spec.d.ts +0 -1
  139. package/dist/helper/__test__/events.spec.d.ts +0 -1
  140. package/dist/helper/__test__/file-tree.spec.d.ts +0 -1
@@ -0,0 +1,863 @@
1
+ # Mynah UI Constructor Properties
2
+ You can configure your Chat UI's initial render and defaults through these properties as well as connecting the events which will trigger after user interactions. Since all of the props are optional, feel free to assign only the ones you need.
3
+ ```typescript
4
+ export interface MynahUIProps {
5
+ rootSelector?: string;
6
+ defaults?: MynahUITabStoreTab;
7
+ tabs?: MynahUITabStoreModel;
8
+ config?: Partial<ConfigModel>;
9
+ onShowMoreWebResultsClick?: (
10
+ tabId: string,
11
+ messageId: string,
12
+ eventId?: string) => void;
13
+ onReady?: () => void;
14
+ onVote?: (
15
+ tabId: string,
16
+ messageId: string,
17
+ vote: RelevancyVoteType,
18
+ eventId?: string) => void;
19
+ onStopChatResponse?: (
20
+ tabId: string,
21
+ eventId?: string) => void;
22
+ onResetStore?: (tabId: string) => void;
23
+ onChatPrompt?: (
24
+ tabId: string,
25
+ prompt: ChatPrompt,
26
+ eventId?: string) => void;
27
+ onFollowUpClicked?: (
28
+ tabId: string,
29
+ messageId: string,
30
+ followUp: ChatItemAction,
31
+ eventId?: string) => void;
32
+ onInBodyButtonClicked?: (
33
+ tabId: string,
34
+ messageId: string,
35
+ action: {
36
+ id: string;
37
+ text?: string;
38
+ formItemValues?: Record<string, string>;
39
+ },
40
+ eventId?: string) => void;
41
+ onTabChange?: (
42
+ tabId: string,
43
+ eventId?: string) => void;
44
+ onTabAdd?: (
45
+ tabId: string,
46
+ eventId?: string) => void;
47
+ onTabRemove?: (
48
+ tabId: string,
49
+ eventId?: string) => void;
50
+ /**
51
+ * @param tabId tabId which the close button triggered
52
+ * @returns boolean -> If you want to close the tab immediately send true
53
+ */
54
+ onBeforeTabRemove?: (
55
+ tabId: string,
56
+ eventId?: string) => boolean;
57
+ onChatItemEngagement?: (
58
+ tabId: string,
59
+ messageId: string,
60
+ engagement: Engagement) => void;
61
+ onCopyCodeToClipboard?: (
62
+ tabId: string,
63
+ messageId: string,
64
+ code?: string,
65
+ type?: CodeSelectionType,
66
+ referenceTrackerInformation?: ReferenceTrackerInformation[],
67
+ eventId?: string,
68
+ codeBlockIndex?: number,
69
+ totalCodeBlocks?: number) => void;
70
+ onCodeInsertToCursorPosition?: (
71
+ tabId: string,
72
+ messageId: string,
73
+ code?: string,
74
+ type?: CodeSelectionType,
75
+ referenceTrackerInformation?: ReferenceTrackerInformation[],
76
+ eventId?: string,
77
+ codeBlockIndex?: number,
78
+ totalCodeBlocks?: number) => void;
79
+ onSourceLinkClick?: (
80
+ tabId: string,
81
+ messageId: string,
82
+ link: string,
83
+ mouseEvent?: MouseEvent,
84
+ eventId?: string) => void;
85
+ onLinkClick?: (
86
+ tabId: string,
87
+ messageId: string,
88
+ link: string,
89
+ mouseEvent?: MouseEvent,
90
+ eventId?: string) => void;
91
+ onInfoLinkClick?: (
92
+ tabId: string,
93
+ link: string,
94
+ mouseEvent?: MouseEvent,
95
+ eventId?: string) => void;
96
+ onSendFeedback?: (
97
+ tabId: string,
98
+ feedbackPayload: FeedbackPayload,
99
+ eventId?: string) => void;
100
+ onCustomFormAction?: (
101
+ tabId: string,
102
+ action: {
103
+ id: string;
104
+ text?: string;
105
+ formItemValues?: Record<string, string>;
106
+ },
107
+ eventId?: string) => void;
108
+ /**
109
+ * @deprecated since version 4.6.3. Will be dropped after version 5.x.x. Use {@link onFileClick} instead
110
+ */
111
+ onOpenDiff?: (
112
+ tabId: string,
113
+ filePath: string,
114
+ deleted: boolean,
115
+ messageId?: string,
116
+ eventId?: string) => void;
117
+ onFileClick?: (
118
+ tabId: string,
119
+ filePath: string,
120
+ deleted: boolean,
121
+ messageId?: string,
122
+ eventId?: string) => void;
123
+ onFileActionClick?: (
124
+ tabId: string,
125
+ messageId: string,
126
+ filePath: string,
127
+ actionName: string,
128
+ eventId?: string) => void;
129
+ onTabBarButtonClick?: (
130
+ tabId: string,
131
+ buttonId: string,
132
+ eventId?: string) => void;
133
+ }
134
+ ```
135
+ _Let's deep dive into each property you can set._
136
+
137
+ ### But before that, what is `eventId`?
138
+ You may notice that a wast majority of the event functions have `eventId` property. We're sending a unique `eventId` **for all real intended user actions** like clicks, prompts or tab related actions.
139
+ It is mandatory to send it as an argument for some functions like `mynahUI.selectTab`.You need to send the incoming `eventId` from the connected event function to change a tab programmatically. Because without a user intent, you cannot change a tab.
140
+
141
+ And those kind of functions **will only work** with the last `eventId`. So you cannot store an id and send it after several different user actions.
142
+
143
+ ---------
144
+ ### `rootSelector`
145
+ _(default: `"body"`)_
146
+
147
+ rootSelector simply allows you to set which dom element you want to render the whole chat interface including the tabs and the chat prompt block and also the chat items. It will also create temporary or portal elements inside the same element such as notifications, custom dropdown blocks and also tooltips with rich content. However, they'll exceed the views boundaries.
148
+
149
+ ```typescript
150
+ ...
151
+ rootSelector: "#chat-wrapper", // default: "body"
152
+ ...
153
+ ```
154
+ ---------
155
+
156
+ ### `defaults`
157
+ _(default: `undefined`)_
158
+
159
+ defaults is here for you to set the default content and parameters for every new tab will be opened by the end user or created on the runtime without giving a specific data. You can set the prompt related fields, initial chat bubbles, or any parameter on a tab's [data model](./DATAMODEL.md).
160
+
161
+ ```typescript
162
+ ...
163
+ defaults: {
164
+ store:{
165
+ // ...
166
+ }
167
+ }, // default: undefined
168
+ ...
169
+ ```
170
+ **For more information about what is the data model for the store attribute please refer to [Data Model Documentation](./DATAMODEL.md)**
171
+
172
+ ---
173
+
174
+ ### `tabs`
175
+ _(default: `undefined`)_
176
+
177
+ tabs is here for you to set the initial tabs with their initial content while initializing and rendering the UI for the first time. You can set anything related with the tab and or any parameter on a tab's [data model](./DATAMODEL.md).
178
+
179
+ It is pretty handy to keep the state of the whole UI and send it back while reinitializing after a refresh for example.
180
+
181
+ _Note: You cannot set it on the runtime, it is just for initialization._
182
+
183
+ ```typescript
184
+ ...
185
+ tabs: {
186
+ "Unique_Tab_Id": {
187
+ isSelected: true | false, // default: false
188
+ store:{
189
+ // ...
190
+ }
191
+ },
192
+ ...
193
+ }, // default: undefined
194
+ ...
195
+ ```
196
+ **For more information about what is the data model for the store attribute please refer to [Data Model Documentation](./DATAMODEL.md)**
197
+
198
+ ---
199
+
200
+ ### `config`
201
+ _(default: `undefined`)_
202
+
203
+ You can set the config here.
204
+
205
+ _Note: You cannot set it on the runtime, it is just for initialization._
206
+
207
+ ```typescript
208
+ ...
209
+ config: {
210
+ // Do not forget that you have to provide all of them
211
+ // Config doesn't allow partial set of texts
212
+ texts: {
213
+ mainTitle: string;
214
+ feedbackFormTitle: string;
215
+ feedbackFormOptionsLabel: string;
216
+ feedbackFormCommentLabel: string;
217
+ feedbackThanks: string;
218
+ feedbackReportButtonLabel: string;
219
+ codeSuggestions: string;
220
+ files: string;
221
+ insertAtCursorLabel: string;
222
+ copy: string;
223
+ showMore: string;
224
+ save: string;
225
+ cancel: string;
226
+ submit: string;
227
+ stopGenerating: string;
228
+ copyToClipboard: string;
229
+ noMoreTabsTooltip: string;
230
+ codeSuggestionWithReferenceTitle: string;
231
+ spinnerText: string;
232
+ };
233
+ // Options to show up on the overlay feedback form
234
+ // after user clicks to downvote on a chat item
235
+ // and clicks 'Report' again
236
+ feedbackOptions: Array<{
237
+ label: string;
238
+ value: string;
239
+ }>;
240
+ maxTabs: number;
241
+ }, // default: undefined
242
+ ...
243
+ ```
244
+ **Refer to the [configuration](./CONFIG.md) for more details**
245
+
246
+ ---
247
+ <p><br/></p>
248
+
249
+ # Events
250
+ _Now let's dive deep into the events you can catch from the UI_
251
+
252
+ ---
253
+
254
+ ### `onShowMoreWebResultsClick`
255
+
256
+ This event will be fired when end user clicks to show all resources down arrow button and pass the arguments `tabId` and `messageId`.
257
+
258
+ <p align="center">
259
+ <img src="./img/onShowMoreClick.png" alt="onShowMoreWebResultsClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
260
+ </p>
261
+
262
+ ```typescript
263
+ ...
264
+ onShowMoreWebResultsClick: (
265
+ tabId: string,
266
+ messageId: string) => {
267
+ console.log(`Sent from tab: ${tabId}`);
268
+ console.log(`From message card: ${messageId}`);
269
+ };
270
+ ...
271
+ ```
272
+
273
+ ---
274
+
275
+ ### `onReady`
276
+
277
+ This event will be fired when the UI is initialized and rendered without any arguments.
278
+
279
+ ```typescript
280
+ ...
281
+ onReady: () => {
282
+ console.log('UI is ready');
283
+ };
284
+ ...
285
+ ```
286
+
287
+ ---
288
+
289
+ ### `onVote`
290
+
291
+ This event will be fired when end user clicks one of the thumbs up or down buttons to vote the answer. It will pass the arguments `tabId`, `messageId` and the `vote`.
292
+
293
+ _Please refer to the [data model](./DATAMODEL.md) to learn how to enable vote buttons for chat answers_
294
+
295
+ <p align="center">
296
+ <img src="./img/onVote.png" alt="onVote" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
297
+ </p>
298
+
299
+ ```typescript
300
+ ...
301
+ onVote: (
302
+ tabId: string,
303
+ messageId: string,
304
+ vote: RelevancyVoteType) => {
305
+ console.log(`Sent from tab: ${tabId}`);
306
+ console.log(`Vote for message: ${messageId}`);
307
+ console.log(`Vote: ${vote}`); // 'upvote' | 'downvote'
308
+ };
309
+ ...
310
+ ```
311
+
312
+ ---
313
+
314
+ ### `onStopChatResponse`
315
+
316
+ This event will be fired when end user clicks to `Stop generating` button. It will pass only the `tabId` argument. To enable this feature globally, you need to set this function
317
+
318
+ _Please refer to the [data model](./DATAMODEL.md) to learn how to enable/disable onStopChatResponse for individual tabs_
319
+
320
+ <p align="center">
321
+ <img src="./img/onStopChatResponse.png" alt="onStopChatResponse" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
322
+ </p>
323
+
324
+ ```typescript
325
+ ...
326
+ onStopChatResponse: (tabId: string):void => {
327
+ console.log(`Sent from tab: ${tabId}`);
328
+ };
329
+ ...
330
+ ```
331
+
332
+ ---
333
+
334
+ ### `onResetStore`
335
+
336
+ This event will be fired when the store is reset for that specific tab. It will pass only the `tabId` argument.
337
+
338
+ ```typescript
339
+ ...
340
+ onResetStore: (tabId: string):void => {
341
+ console.log(`Store reset for tab: ${tabId}`);
342
+ };
343
+ ...
344
+ ```
345
+
346
+ ---
347
+
348
+ ### `onChatPrompt`
349
+
350
+ This event will be fired when user hits enter or clicks to send button on the prompt input field. It will pass `tabId` and the `prompt` object as arguments.
351
+
352
+ _Please refer to the [data model](./DATAMODEL.md) to learn more about the `ChatPrompt` object type._
353
+
354
+ <p align="center">
355
+ <img src="./img/onChatPrompt.png" alt="onChatPrompt" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
356
+ </p>
357
+
358
+ ```typescript
359
+ ...
360
+ onChatPrompt?: (
361
+ tabId: string,
362
+ prompt: ChatPrompt):void => {
363
+ console.log(`Sent from tab: ${tabId}`);
364
+ console.log(`Prompt text (as written): ${prompt.prompt}`);
365
+ console.log(`Prompt text (HTML escaped): ${prompt.escapedPrompt}`);
366
+ console.log(`Command (if selected from quick actions): ${prompt.command}`);
367
+ console.log(`Context (if selected from context selector): ${(prompt.context??[]).join(', ')}`);
368
+ console.log(`Attachment (feature not available yet): ${prompt.attachment}`);
369
+ };
370
+ ...
371
+ ```
372
+
373
+ ### Very important note
374
+ You have to manually add the chat item for the prompt with the given ways on the **[How to use](./USAGE.md)** document.
375
+
376
+ ---
377
+
378
+ ### `onFollowUpClicked`
379
+
380
+ This event will be fired when user selects one of the available followups. It will pass `tabId`, `messageId` and the clicked `followUp` object as arguments.
381
+
382
+ **Important note:** If the clicked followup item contains `prompt` attribute, MynahUI will automatically add the `ChatItem` to the chat stack and will render it as a user prompt chat bubble with the `prompt` attributes text (on the right side). If you want to avoid this and manually control what will be added as a chat item or not adding anything at all after the selection of the followup, leave the `prompt` attribute undefined.
383
+
384
+ **Important note:** Followup texts show up at most 40 chars in the followup pill. If the length is more than 40 chars it will pop up a tooltip to show the rest of the text. However, it will not break the `description` to show up as a tooltip, instead if there is also the `description` attribute, it will append that to a new line in the tooltip.
385
+
386
+ _Please refer to the [data model](./DATAMODEL.md) to learn more about the `ChatItemAction` object type._
387
+
388
+ <p align="center">
389
+ <img src="./img/onFollowupClicked.png" alt="onFollowUpClicked" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
390
+ </p>
391
+
392
+ ```typescript
393
+ ...
394
+ onFollowUpClicked?: (
395
+ tabId: string,
396
+ messageId: string,
397
+ followUp: ChatItemAction):void => {
398
+ console.log(`Sent from tab: ${tabId}`);
399
+ console.log(`For the message: ${messageId}`);
400
+ console.log(`Followup type (free text): ${followUp.type}`);
401
+ console.log(`Followup text (visible on screen): ${followUp.pillText}`);
402
+ };
403
+ ...
404
+ ```
405
+
406
+ ---
407
+
408
+ ### `onInBodyButtonClicked`
409
+
410
+ This event will be fired when user clicks one of the available followups.
411
+
412
+ It will pass you the `tabId`, `messageId` and information about the clicked `action`.
413
+
414
+ And the last argument `action` will contain:
415
+ ```
416
+ id: string; // Id of the action clicked
417
+ text?: string; // Label text of the action
418
+ formItemValues?: Record<string, string>; // Form item values if you add any using the formItems
419
+ ```
420
+ Please refer to [formItems](./DATAMODEL.md#formItems) for combining actions and form items in a card.
421
+
422
+ **Important note:** If you clicked an action item which doesn't have the value `true` for `keepCardAfterClick` attribute, that click will remove the whole card. Otherwise it will disable all the actions and the form items inside that card.
423
+
424
+ _Please refer to the [data model](./DATAMODEL.md) to learn more about the `ChatItemButton` object type._
425
+
426
+ <p align="center">
427
+ <img src="./img/onBodyActionClicked.png" alt="onBodyActionClicked" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
428
+ </p>
429
+
430
+ ```typescript
431
+ ...
432
+ onInBodyButtonClicked?: (
433
+ tabId: string,
434
+ messageId: string,
435
+ action):void => {
436
+ console.log(`Sent from tab: ${tabId}`);
437
+ console.log(`For the message: ${messageId}`);
438
+ console.log(`Action id: ${action.id}`);
439
+ console.log(`Action text: ${action.text ?? ''}`);
440
+ console.log(`Form item values: ${JSON.stringify(action.formItemValues ?? {})}`);
441
+ };
442
+ ...
443
+ ```
444
+
445
+ ---
446
+
447
+ ### `onTabChange`
448
+
449
+ This event will be fired when user changes the tab. It will only pass `tabId` for the new selected tab as argument.
450
+
451
+ <p align="center">
452
+ <img src="./img/onTabChange.png" alt="onTabChange" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
453
+ </p>
454
+
455
+ ```typescript
456
+ ...
457
+ onTabChange?: (tabId: string):void => {
458
+ console.log(`New selected tabId: ${tabId}`);
459
+ };
460
+ ...
461
+ ```
462
+
463
+ ---
464
+
465
+ ### `onTabAdd`
466
+
467
+ This event will be fired when user clicks the add tab button or double clicks to an empty space on the tab bar to open a new tab. It will only pass `tabId` for the new tab as argument.
468
+
469
+ <p align="center">
470
+ <img src="./img/onTabAdd.png" alt="onTabAdd" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
471
+ </p>
472
+
473
+ ```typescript
474
+ ...
475
+ onTabAdd?: (tabId: string):void => {
476
+ console.log(`New tabId: ${tabId}`);
477
+ };
478
+ ...
479
+ ```
480
+
481
+ ---
482
+
483
+ ### `onBeforeTabRemove`
484
+
485
+ This event will be fired when user clicks the close button but before actually closing the tab. You have **partial control over the tab close**. If you return false to this function, it will not immediately close the tab and will ask an approval from the user. Otherwise it will close the tab. You can set the texts which will be appeared on the confirmation overlay on **[Config/TEXTS](./CONFIG.md#texts)**. It will only pass `tabId` for the closed tab as argument.
486
+
487
+ <p align="center">
488
+ <img src="./img/onTabRemove.png" alt="onTabRemove" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
489
+ </p>
490
+
491
+ ```typescript
492
+ ...
493
+ onBeforeTabRemove: (tabId: string):boolean => {
494
+ // For example you can check if the tab is in loading state or not.
495
+ const isTabLoading = mynahUI.getAllTabs()[tabId].store?.loadingChat;
496
+ return !isTabLoading;
497
+ }
498
+ ...
499
+ ```
500
+
501
+ <p align="center">
502
+ <img src="./img/onBeforeTabRemove.png" alt="onTabRemoveConfirmation" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
503
+ </p>
504
+
505
+ ---
506
+
507
+ ### `onTabRemove`
508
+
509
+ This event will be fired when user clicks the close button on a tab or middle clicks to the tab to close it but if `onBeforeTabRemove` is not attached or attached but returned `true`. It will only pass `tabId` for the closed tab as argument.
510
+
511
+ <p align="center">
512
+ <img src="./img/onTabRemove.png" alt="onTabRemove" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
513
+ </p>
514
+
515
+ ```typescript
516
+ ...
517
+ onTabRemove?: (tabId: string):void => {
518
+ console.log(`Closed tabId: ${tabId}`);
519
+ };
520
+ ...
521
+ ```
522
+ ---
523
+
524
+ ### `onChatItemEngagement`
525
+
526
+ This event will be fired when user engages with a system generated chat bubble in various ways like moving/holding the mouse over it more than 3 seconds or selects some text inside the chat message bubble or clicks anywhere inside it. It will pass `tabId`, `messageId` for the engaged chat message bubble and also the `engagement` for the engagement details as arguments.
527
+
528
+ _Please refer to the [data model](./DATAMODEL.md) to learn more about the `Engagement` object type._
529
+
530
+ **Note:** This event will be only activated if you bind a function to it. It means that if you leave it undefined it will not listen/track any mouse movement at all for the chat message bubbles.
531
+
532
+ <p align="center">
533
+ <img src="./img/onChatItemEngagement.png" alt="onChatItemEngagement" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
534
+ </p>
535
+
536
+ ```typescript
537
+ ...
538
+ onChatItemEngagement?: (
539
+ tabId: string,
540
+ messageId: string,
541
+ engagement: Engagement):void => {
542
+ console.log(`Sent from tab: ${tabId}`);
543
+ console.log(`Engaged message: ${messageId}`);
544
+ console.log(`Engagement type: ${engagement.engagementType}`); // interaction | timespend
545
+ console.log(`Engagement duration: ${engagement.engagementDurationTillTrigger}`);
546
+ console.log(`Engagement total mouse distance travelled: ${engagement.totalMouseDistanceTraveled}`);
547
+ console.log(`Engagement selection:
548
+ x movement: ${engagement.selectionDistanceTraveled?.x}
549
+ y movement: ${engagement.selectionDistanceTraveled?.y}
550
+ selected text: ${engagement.selectionDistanceTraveled?.selectedText}
551
+ `);
552
+ };
553
+ ...
554
+ ```
555
+ ---
556
+
557
+ ### `onCopyCodeToClipboard`
558
+
559
+ This event will be fired when user clicks the copy button on the footer of a code block or selects some text inside a code block and triggers keyboard shortcuts for copying. It will pass `tabId`, `messageId`, `code` for the copied code to theclipboard as a text, `type` for the type of the code copied (block or selection) and the `referenceTrackerInformation` if the copied code block contains some code reference as the arguments. Finally after the `eventId` attribute, you can get the index of the code block inside that message with `codeBlockIndex` together with total number of code blocks again inside that message with `totalCodeBlocks`.
560
+
561
+ **Note:** even though the `referenceTrackerInformation` comes to the message with `codeReference` attribute with the index position depending on the whole content of the body of the message, the return of it as an attribute from this event gives the indexes according to position inside that code block.
562
+
563
+ _Please refer to the [data model](./DATAMODEL.md) to learn more about the `ReferenceTrackerInformation` object type._
564
+
565
+
566
+ <p align="center">
567
+ <img src="./img/onCopyCodeToClipboard.png" alt="onCopyCodeToClipboard" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
568
+ </p>
569
+
570
+ ```typescript
571
+ ...
572
+ onCopyCodeToClipboard?: (
573
+ tabId: string,
574
+ messageId: string,
575
+ code?: string,
576
+ type?: CodeSelectionType,
577
+ referenceTrackerInformation?: ReferenceTrackerInformation[],
578
+ eventId:string,
579
+ codeBlockIndex?: number,
580
+ totalCodeBlocks?: number):void => {
581
+ console.log(`Sent from tab: ${tabId}`);
582
+ console.log(`Code inside message: ${messageId}`);
583
+ console.log(`Copied code: ${code}`);
584
+ console.log(`Copy type: ${type}`); // selection | block
585
+ console.log(`Reference tracker info: ${referenceTrackerInformation?.map(rti=>`${rti.licenseName} ${rti.repository}`).join(', ')}`);
586
+ console.log(`Code block index: ${codeBlockIndex + 1} of ${totalCodeBlocks}`);
587
+ };
588
+ ...
589
+ ```
590
+ ---
591
+
592
+ ### `onCodeInsertToCursorPosition`
593
+
594
+ This event will be fired when user clicks the copy button on the footer of a code block or selects some text inside a code block and triggers keyboard shortcuts for copying. It will pass `tabId`, `messageId`, `code` for the copied code to theclipboard as a text, `type` for the type of the code copied (block or selection) and the `referenceTrackerInformation` if the copied code block contains some code reference as the arguments. Finally after the `eventId` attribute, you can get the index of the code block inside that message with `codeBlockIndex` together with total number of code blocks again inside that message with `totalCodeBlocks`
595
+
596
+ **Note:** even though the `referenceTrackerInformation` comes to the message with `codeReference` attribute with the index position depending on the whole content of the body of the message, the return of it as an attribute from this event gives the indexes according to position inside that code block.
597
+
598
+ _Please refer to the [data model](./DATAMODEL.md) to learn more about the `ReferenceTrackerInformation` object type._
599
+
600
+
601
+ <p align="center">
602
+ <img src="./img/onCodeInsertToCursorPosition.png" alt="onCodeInsertToCursorPosition" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
603
+ </p>
604
+
605
+ ```typescript
606
+ ...
607
+ onCodeInsertToCursorPosition?: (
608
+ tabId: string,
609
+ messageId: string,
610
+ code?: string,
611
+ type?: CodeSelectionType,
612
+ referenceTrackerInformation?: ReferenceTrackerInformation[],
613
+ eventId:string,
614
+ codeBlockIndex?: number,
615
+ totalCodeBlocks?: number):void => {
616
+ console.log(`Sent from tab: ${tabId}`);
617
+ console.log(`Code inside message: ${messageId}`);
618
+ console.log(`Code to insert: ${code}`);
619
+ console.log(`Copy type: ${type}`); // selection | block
620
+ console.log(`Reference tracker info: ${referenceTrackerInformation?.map(rti=>`${rti.licenseName} ${rti.repository}`).join(', ')}`);
621
+ console.log(`Code block index: ${codeBlockIndex + 1} of ${totalCodeBlocks}`);
622
+ };
623
+ ...
624
+ ```
625
+ ---
626
+
627
+ ### `onSourceLinkClick`
628
+
629
+ This event will be fired when user clicks one the the sources links after the body of a chat message body. It will pass `tabId`, `messageId`, `link` for the clicked link and the `mouseEvent` for the event object in case if it needs to be prevented as the arguments.
630
+
631
+ **Note:** For example, JetBrains JCEF WebView opens the links in a new browser view of its own. However to prevent this action and navigate to user's own preferred browser to open the links, you may want to cancel the default behaviour and run your own function to open the OS default browser.
632
+
633
+
634
+ <p align="center">
635
+ <img src="./img/onSourceLinkClick.png" alt="onSourceLinkClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
636
+ </p>
637
+
638
+ ```typescript
639
+ ...
640
+ onSourceLinkClick?: (
641
+ tabId: string,
642
+ messageId: string,
643
+ link: string,
644
+ mouseEvent?: MouseEvent):void => {
645
+ console.log(`Sent from tab: ${tabId}`);
646
+ console.log(`Source link of message: ${messageId}`);
647
+ console.log(`link: ${link}`);
648
+ // mouseEvent.preventDefault();
649
+ };
650
+ ...
651
+ ```
652
+ ---
653
+
654
+ ### `onLinkClick`
655
+
656
+ This event will be fired when user clicks a link inside the body of a chat message. It will pass `tabId`, `messageId`, `link` for the clicked link and the `mouseEvent` for the event object in case if it needs to be prevented as the arguments.
657
+
658
+ **Note:** For example, JetBrains JCEF WebView opens the links in a new browser view of its own. However to prevent this action and navigate to user's own preferred browser to open the links, you may want to cancel the default behaviour and run your own function to open the OS default browser.
659
+
660
+
661
+ <p align="center">
662
+ <img src="./img/onLinkClick.png" alt="onLinkClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
663
+ </p>
664
+
665
+ ```typescript
666
+ ...
667
+ onLinkClick?: (
668
+ tabId: string,
669
+ messageId: string,
670
+ link: string,
671
+ mouseEvent?: MouseEvent):void => {
672
+ console.log(`Sent from tab: ${tabId}`);
673
+ console.log(`Source link of message: ${messageId}`);
674
+ console.log(`link: ${link}`);
675
+ // mouseEvent.preventDefault();
676
+ };
677
+ ...
678
+ ```
679
+ ---
680
+
681
+ ### `onInfoLinkClick`
682
+
683
+ This event will be fired when user clicks a link inside the footer information message below the prompt input field for that tab. It will pass `tabId`, `link` for the clicked link and the `mouseEvent` for the event object in case if it needs to be prevented as the arguments.
684
+
685
+ **Note:** For example, JetBrains JCEF WebView opens the links in a new browser view of its own. However to prevent this action and navigate to user's own preferred browser to open the links, you may want to cancel the default behaviour and run your own function to open the OS default browser.
686
+
687
+
688
+ <p align="center">
689
+ <img src="./img/onInfoLinkClick.png" alt="onInfoLinkClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
690
+ </p>
691
+
692
+ ```typescript
693
+ ...
694
+ onInfoLinkClick?: (
695
+ tabId: string,
696
+ link: string,
697
+ mouseEvent?: MouseEvent):void => {
698
+ console.log(`Sent from tab: ${tabId}`);
699
+ console.log(`link: ${link}`);
700
+ // mouseEvent.preventDefault();
701
+ };
702
+ ...
703
+ ```
704
+ ---
705
+
706
+ ### `onSendFeedback`
707
+
708
+ This event will be fired when user sends a feedback from the feedback panel which opens after giving a negative vote to a message and follow it with a send feedback button click. It will pass `tabId` and `feedbackPayload` for the feedback details as the arguments.
709
+
710
+ **Note:** The options for the feedback type are coming from the configuration.
711
+
712
+ _Please refer to the [configuration](./CONFIG.md) to learn more about the feedback type options._
713
+
714
+
715
+ <p align="center">
716
+ <img src="./img/onSendFeedback-1.png" alt="onSendFeedbackStep1" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
717
+ <img src="./img/onSendFeedback-2.png" alt="onSendFeedbackStep2" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
718
+ <img src="./img/onSendFeedback-3.png" alt="onSendFeedbackStep3" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
719
+ </p>
720
+
721
+ ```typescript
722
+ ...
723
+ onSendFeedback?: (
724
+ tabId: string,
725
+ feedbackPayload: FeedbackPayload):void => {
726
+ console.log(`Sent from tab: ${tabId}`);
727
+ console.log(`Feedback for message: ${feedbackPayload.messageId}`);
728
+ console.log(`Feedback type: ${feedbackPayload.selectedOption}`);
729
+ console.log(`Feedback comment: ${feedbackPayload.comment}`);
730
+ // mouseEvent.preventDefault();
731
+ };
732
+ ...
733
+ ```
734
+ ---
735
+
736
+ ### `onCustomFormAction`
737
+
738
+ This event will be fired when user clicks one of the buttons inside a custom popup form. It will pass `tabId` and `action`. But `action` argument contains the `id` and `text` of the action clicked and the values for each form item with string values.
739
+
740
+
741
+ <p align="center">
742
+ <img src="./img/onCustomFormAction.png" alt="onCustomFormAction" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
743
+ </p>
744
+
745
+ ```typescript
746
+ ...
747
+ onCustomFormAction?: (
748
+ tabId: string,
749
+ action):void => {
750
+ console.log(`Sent from tab: ${tabId}`);
751
+ console.log(`Action id: ${action.id}`);
752
+ console.log(`Action text: ${action.text ?? ''}`);
753
+ console.log(`Form item values: ${JSON.stringify(action.formItemValues ?? {})}`);
754
+ };
755
+ ...
756
+ ```
757
+ ---
758
+
759
+
760
+ ### `onOpenDiff` [DEPRECATED: will be dropped after version 5.x.x]
761
+
762
+ This event will be fired when user clicks to a file name on the file list inside a chat message body. It will pass `tabId`, `filePath` for the clicked file, `deleted` to identify if the file is deleted and `messageId` as the arguments.
763
+
764
+
765
+ <p align="center">
766
+ <img src="./img/onOpenDiff.png" alt="onOpenDiff" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
767
+ </p>
768
+
769
+ ```typescript
770
+ ...
771
+ onOpenDiff?: (
772
+ tabId: string,
773
+ filePath: string,
774
+ deleted: boolean,
775
+ messageId?: string):void => {
776
+ console.log(`Sent from tab: ${tabId}`);
777
+ console.log(`For message: ${messageId}`);
778
+ console.log(`File to open diff view: ${filePath}`);
779
+ console.log(`Is file deleted: ${deleted}`);
780
+ };
781
+ ...
782
+ ```
783
+
784
+ ---
785
+
786
+
787
+ ### `onFileClick`
788
+
789
+ This event will be fired when user clicks to a file name on the file list inside a chat message body. It will pass `tabId`, `filePath` for the clicked file, `deleted` to identify if the file is deleted and `messageId` as the arguments.
790
+
791
+
792
+ <p align="center">
793
+ <img src="./img/onOpenDiff.png" alt="onFileClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
794
+ </p>
795
+
796
+ ```typescript
797
+ ...
798
+ onFileClick?: (
799
+ tabId: string,
800
+ filePath: string,
801
+ deleted: boolean,
802
+ messageId?: string):void => {
803
+ console.log(`Sent from tab: ${tabId}`);
804
+ console.log(`For message: ${messageId}`);
805
+ console.log(`File to open diff view: ${filePath}`);
806
+ console.log(`Is file deleted: ${deleted}`);
807
+ };
808
+ ...
809
+ ```
810
+
811
+ ---
812
+
813
+ ### `onFileActionClick`
814
+
815
+ This event will be fired when user clicks to an action button for a specific file in a file node tree. It will pass `tabId`, `messageId`, `filePath` and the `actionName`.
816
+
817
+ **TIP:** To do further updates on the file tree card, hold the `messageId` then you can use the [updateChatAnswerWithMessageId](./USAGE.md#updateChatAnswerWithMessageId) function to update that specific card.
818
+
819
+
820
+ <p align="center">
821
+ <img src="./img/onFileActionClick.png" alt="onOpenDiff" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
822
+ </p>
823
+
824
+ ```typescript
825
+ ...
826
+ onFileActionClick?: (
827
+ tabId: string,
828
+ messageId?: string,
829
+ filePath: string,
830
+ actionName: string):void => {
831
+ console.log(`Sent from tab: ${tabId}`);
832
+ console.log(`For message: ${messageId}`);
833
+ console.log(`File name which the action clicked: ${filePath}`);
834
+ console.log(`The action id/name clicked: ${actionName}`);
835
+ };
836
+ ...
837
+ ```
838
+
839
+ ---
840
+
841
+ ### `onTabBarButtonClick`
842
+
843
+ This event will be fired when user clicks to a button inside the tab tab or a button under a menu item inside the tab bar.
844
+
845
+ **TIP:** To configure tab buttons according to a tab please see [DATAMODEL Documentation](./DATAMODEL.md#tabbarbuttons). Or for global tab bar button settings please see [Config Documentation](./CONFIG.md#tabbarbuttons).
846
+
847
+
848
+ <p align="center">
849
+ <img src="./img/data-model/tabStore/tabBarButtons1.png" alt="tabBarButtons" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
850
+ <img src="./img/data-model/tabStore/tabBarButtons2.png" alt="tabBarButtons" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
851
+ </p>
852
+
853
+ ```typescript
854
+ ...
855
+ onTabBarButtonClick?: (
856
+ tabId: string,
857
+ buttonId: string,
858
+ eventId?: string):void => {
859
+ console.log(`Sent from tab: ${tabId}`);
860
+ console.log(`Button ID: ${buttonId}`);
861
+ };
862
+ ...
863
+ ```