@aws/mynah-ui 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -0
- package/README.md +3 -1
- package/dist/helper/store.d.ts +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/static.d.ts +1 -2
- package/package.json +1 -1
- package/docs/CONFIG.md +0 -190
- package/docs/DATAMODEL.md +0 -932
- package/docs/PROPERTIES.md +0 -615
- package/docs/STARTUP.md +0 -50
- package/docs/STYLING.md +0 -175
- package/docs/USAGE.md +0 -325
- package/docs/img/code-attachment.png +0 -0
- package/docs/img/data-model/chatItems/answer.png +0 -0
- package/docs/img/data-model/chatItems/answerStream.png +0 -0
- package/docs/img/data-model/chatItems/body.png +0 -0
- package/docs/img/data-model/chatItems/canBeVoted.png +0 -0
- package/docs/img/data-model/chatItems/codeReference-1.png +0 -0
- package/docs/img/data-model/chatItems/codeReference-2.png +0 -0
- package/docs/img/data-model/chatItems/codeResult.png +0 -0
- package/docs/img/data-model/chatItems/followUp-1.png +0 -0
- package/docs/img/data-model/chatItems/followUp-2.png +0 -0
- package/docs/img/data-model/chatItems/notification-1.png +0 -0
- package/docs/img/data-model/chatItems/notification-2.png +0 -0
- package/docs/img/data-model/chatItems/notification-3.png +0 -0
- package/docs/img/data-model/chatItems/notification-4.png +0 -0
- package/docs/img/data-model/chatItems/prompt.png +0 -0
- package/docs/img/data-model/chatItems/relatedContent-1.png +0 -0
- package/docs/img/data-model/chatItems/relatedContent-2.png +0 -0
- package/docs/img/data-model/chatItems/relatedContent-3.png +0 -0
- package/docs/img/data-model/chatItems/systemPrompt.png +0 -0
- package/docs/img/data-model/tabStore/loadingChat-1.png +0 -0
- package/docs/img/data-model/tabStore/loadingChat-2.png +0 -0
- package/docs/img/data-model/tabStore/promptInputDisabledState.png +0 -0
- package/docs/img/data-model/tabStore/promptInputPlaceholder.png +0 -0
- package/docs/img/data-model/tabStore/quickActionCommands.png +0 -0
- package/docs/img/data-model/tabStore/stopChatResponse.png +0 -0
- package/docs/img/data-model/tabStore/tabTitle.png +0 -0
- package/docs/img/feedbackOptions.png +0 -0
- package/docs/img/maxTabs1.png +0 -0
- package/docs/img/noPrompt.png +0 -0
- package/docs/img/notification.png +0 -0
- package/docs/img/onChatItemEngagement.png +0 -0
- package/docs/img/onChatPrompt.png +0 -0
- package/docs/img/onCodeInsertToCursorPosition.png +0 -0
- package/docs/img/onCopyCodeToClipboard.png +0 -0
- package/docs/img/onFollowupClicked.png +0 -0
- package/docs/img/onInfoLinkClick.png +0 -0
- package/docs/img/onLinkClick.png +0 -0
- package/docs/img/onOpenDiff.png +0 -0
- package/docs/img/onSendFeedback-1.png +0 -0
- package/docs/img/onSendFeedback-2.png +0 -0
- package/docs/img/onSendFeedback-3.png +0 -0
- package/docs/img/onShowMoreClick.png +0 -0
- package/docs/img/onSourceLinkClick.png +0 -0
- package/docs/img/onStopChatResponse.png +0 -0
- package/docs/img/onTabAdd.png +0 -0
- package/docs/img/onTabChange.png +0 -0
- package/docs/img/onTabRemove.png +0 -0
- package/docs/img/onVote.png +0 -0
- package/docs/img/prompt-with-code-attached.png +0 -0
- package/docs/img/texts/codeFileSuggestions.png +0 -0
- package/docs/img/texts/copyInsertToCursor.png +0 -0
- package/docs/img/texts/feedbackForm.png +0 -0
- package/docs/img/texts/mainTitle.png +0 -0
- package/docs/img/texts/noMoreTabs.png +0 -0
- package/docs/img/texts/spinnerText.png +0 -0
- package/docs/img/texts/stopGenerating.png +0 -0
- package/docs/img/texts/voteAndSourceActions.png +0 -0
- package/docs/img/theming-1.png +0 -0
- package/docs/img/theming-2.png +0 -0
package/docs/PROPERTIES.md
DELETED
|
@@ -1,615 +0,0 @@
|
|
|
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) => void;
|
|
12
|
-
onReady?: () => void;
|
|
13
|
-
onVote?: (
|
|
14
|
-
tabId: string,
|
|
15
|
-
messageId: string,
|
|
16
|
-
vote: RelevancyVoteType) => void;
|
|
17
|
-
onStopChatResponse?: (tabId: string) => void;
|
|
18
|
-
onResetStore?: (tabId: string) => void;
|
|
19
|
-
onChatPrompt?: (
|
|
20
|
-
tabId: string,
|
|
21
|
-
prompt: ChatPrompt) => void;
|
|
22
|
-
onFollowUpClicked?: (
|
|
23
|
-
tabId: string,
|
|
24
|
-
messageId: string,
|
|
25
|
-
followUp: ChatItemFollowUp) => void;
|
|
26
|
-
onTabChange?: (tabId: string) => void;
|
|
27
|
-
onTabAdd?: (tabId: string) => void;
|
|
28
|
-
onTabRemove?: (tabId: string) => void;
|
|
29
|
-
onChatItemEngagement?: (
|
|
30
|
-
tabId: string,
|
|
31
|
-
messageId: string,
|
|
32
|
-
engagement: Engagement) => void;
|
|
33
|
-
onCopyCodeToClipboard?: (
|
|
34
|
-
tabId: string,
|
|
35
|
-
messageId: string,
|
|
36
|
-
code?: string,
|
|
37
|
-
type?: CodeSelectionType,
|
|
38
|
-
referenceTrackerInformation?: ReferenceTrackerInformation[]) => void;
|
|
39
|
-
onCodeInsertToCursorPosition?: (
|
|
40
|
-
tabId: string,
|
|
41
|
-
messageId: string,
|
|
42
|
-
code?: string,
|
|
43
|
-
type?: CodeSelectionType,
|
|
44
|
-
referenceTrackerInformation?: ReferenceTrackerInformation[]) => void;
|
|
45
|
-
onSourceLinkClick?: (
|
|
46
|
-
tabId: string,
|
|
47
|
-
messageId: string,
|
|
48
|
-
link: string,
|
|
49
|
-
mouseEvent?: MouseEvent) => void;
|
|
50
|
-
onLinkClick?: (
|
|
51
|
-
tabId: string,
|
|
52
|
-
messageId: string,
|
|
53
|
-
link: string,
|
|
54
|
-
mouseEvent?: MouseEvent) => void;
|
|
55
|
-
onInfoLinkClick?: (
|
|
56
|
-
tabId: string,
|
|
57
|
-
link: string,
|
|
58
|
-
mouseEvent?: MouseEvent) => void;
|
|
59
|
-
onSendFeedback?: (
|
|
60
|
-
tabId: string,
|
|
61
|
-
feedbackPayload: FeedbackPayload) => void;
|
|
62
|
-
onOpenDiff?: (
|
|
63
|
-
tabId: string,
|
|
64
|
-
filePath: string,
|
|
65
|
-
deleted: boolean,
|
|
66
|
-
messageId?: string) => void;
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
_Let's deep dive into each property you can set._
|
|
70
|
-
|
|
71
|
-
---------
|
|
72
|
-
### `rootSelector`
|
|
73
|
-
_(default: `"body"`)_
|
|
74
|
-
|
|
75
|
-
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.
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
...
|
|
79
|
-
rootSelector: "#chat-wrapper", // default: "body"
|
|
80
|
-
...
|
|
81
|
-
```
|
|
82
|
-
---------
|
|
83
|
-
|
|
84
|
-
### `defaults`
|
|
85
|
-
_(default: `undefined`)_
|
|
86
|
-
|
|
87
|
-
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).
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
...
|
|
91
|
-
defaults: {
|
|
92
|
-
store:{
|
|
93
|
-
// ...
|
|
94
|
-
}
|
|
95
|
-
}, // default: undefined
|
|
96
|
-
...
|
|
97
|
-
```
|
|
98
|
-
**For more information about what is the data model for the store attribute please refer to [Data Model Documentation](./DATAMODEL.md)**
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
### `tabs`
|
|
103
|
-
_(default: `undefined`)_
|
|
104
|
-
|
|
105
|
-
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).
|
|
106
|
-
|
|
107
|
-
It is pretty handy to keep the state of the whole UI and send it back while reinitializing after a refresh for example.
|
|
108
|
-
|
|
109
|
-
_Note: You cannot set it on the runtime, it is just for initialization._
|
|
110
|
-
|
|
111
|
-
```typescript
|
|
112
|
-
...
|
|
113
|
-
tabs: {
|
|
114
|
-
"Unique_Tab_Id": {
|
|
115
|
-
isSelected: true | false, // default: false
|
|
116
|
-
store:{
|
|
117
|
-
// ...
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
...
|
|
121
|
-
}, // default: undefined
|
|
122
|
-
...
|
|
123
|
-
```
|
|
124
|
-
**For more information about what is the data model for the store attribute please refer to [Data Model Documentation](./DATAMODEL.md)**
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
### `config`
|
|
129
|
-
_(default: `undefined`)_
|
|
130
|
-
|
|
131
|
-
You can set the config here.
|
|
132
|
-
|
|
133
|
-
_Note: You cannot set it on the runtime, it is just for initialization._
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
...
|
|
137
|
-
config: {
|
|
138
|
-
// Do not forget that you have to provide all of them
|
|
139
|
-
// Config doesn't allow partial set of texts
|
|
140
|
-
texts: {
|
|
141
|
-
mainTitle: string;
|
|
142
|
-
feedbackFormTitle: string;
|
|
143
|
-
feedbackFormOptionsLabel: string;
|
|
144
|
-
feedbackFormCommentLabel: string;
|
|
145
|
-
feedbackThanks: string;
|
|
146
|
-
feedbackReportButtonLabel: string;
|
|
147
|
-
codeSuggestions: string;
|
|
148
|
-
clickFileToViewDiff: string;
|
|
149
|
-
files: string;
|
|
150
|
-
insertAtCursorLabel: string;
|
|
151
|
-
copy: string;
|
|
152
|
-
showMore: string;
|
|
153
|
-
save: string;
|
|
154
|
-
cancel: string;
|
|
155
|
-
submit: string;
|
|
156
|
-
stopGenerating: string;
|
|
157
|
-
copyToClipboard: string;
|
|
158
|
-
noMoreTabsTooltip: string;
|
|
159
|
-
codeSuggestionWithReferenceTitle: string;
|
|
160
|
-
spinnerText: string;
|
|
161
|
-
};
|
|
162
|
-
// Options to show up on the overlay feedback form
|
|
163
|
-
// after user clicks to downvote on a chat item
|
|
164
|
-
// and clicks 'Report' again
|
|
165
|
-
feedbackOptions: Array<{
|
|
166
|
-
label: string;
|
|
167
|
-
value: string;
|
|
168
|
-
}>;
|
|
169
|
-
maxTabs: number;
|
|
170
|
-
}, // default: undefined
|
|
171
|
-
...
|
|
172
|
-
```
|
|
173
|
-
**Refer to the [configuration](./CONFIG.md) for more details**
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
<p><br/></p>
|
|
177
|
-
|
|
178
|
-
# Events
|
|
179
|
-
_Now let's dive deep into the events you can catch from the UI_
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
### `onShowMoreWebResultsClick`
|
|
184
|
-
|
|
185
|
-
This event will be fired when end user clicks to show all resources down arrow button and pass the arguments `tabId` and `messageId`.
|
|
186
|
-
|
|
187
|
-
<p align="center">
|
|
188
|
-
<img src="./img/onShowMoreClick.png" alt="onShowMoreWebResultsClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
189
|
-
</p>
|
|
190
|
-
|
|
191
|
-
```typescript
|
|
192
|
-
...
|
|
193
|
-
onShowMoreWebResultsClick: (
|
|
194
|
-
tabId: string,
|
|
195
|
-
messageId: string) => {
|
|
196
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
197
|
-
console.log(`From message card: ${messageId}`);
|
|
198
|
-
};
|
|
199
|
-
...
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
### `onReady`
|
|
205
|
-
|
|
206
|
-
This event will be fired when the UI is initialized and rendered without any arguments.
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
...
|
|
210
|
-
onReady: () => {
|
|
211
|
-
console.log('UI is ready');
|
|
212
|
-
};
|
|
213
|
-
...
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
### `onVote`
|
|
219
|
-
|
|
220
|
-
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`.
|
|
221
|
-
|
|
222
|
-
_Please refer to the [data model](./DATAMODEL.md) to learn how to enable vote buttons for chat answers_
|
|
223
|
-
|
|
224
|
-
<p align="center">
|
|
225
|
-
<img src="./img/onVote.png" alt="onVote" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
226
|
-
</p>
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
...
|
|
230
|
-
onVote: (
|
|
231
|
-
tabId: string,
|
|
232
|
-
messageId: string,
|
|
233
|
-
vote: RelevancyVoteType) => {
|
|
234
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
235
|
-
console.log(`Vote for message: ${messageId}`);
|
|
236
|
-
console.log(`Vote: ${vote}`); // 'upvote' | 'downvote'
|
|
237
|
-
};
|
|
238
|
-
...
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
---
|
|
242
|
-
|
|
243
|
-
### `onStopChatResponse`
|
|
244
|
-
|
|
245
|
-
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
|
|
246
|
-
|
|
247
|
-
_Please refer to the [data model](./DATAMODEL.md) to learn how to enable/disable onStopChatResponse for individual tabs_
|
|
248
|
-
|
|
249
|
-
<p align="center">
|
|
250
|
-
<img src="./img/onStopChatResponse.png" alt="onStopChatResponse" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
251
|
-
</p>
|
|
252
|
-
|
|
253
|
-
```typescript
|
|
254
|
-
...
|
|
255
|
-
onStopChatResponse: (tabId: string):void => {
|
|
256
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
257
|
-
};
|
|
258
|
-
...
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
### `onResetStore`
|
|
264
|
-
|
|
265
|
-
This event will be fired when the store is reset for that specific tab. It will pass only the `tabId` argument.
|
|
266
|
-
|
|
267
|
-
```typescript
|
|
268
|
-
...
|
|
269
|
-
onResetStore: (tabId: string):void => {
|
|
270
|
-
console.log(`Store reset for tab: ${tabId}`);
|
|
271
|
-
};
|
|
272
|
-
...
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
### `onChatPrompt`
|
|
278
|
-
|
|
279
|
-
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.
|
|
280
|
-
|
|
281
|
-
_Please refer to the [data model](./DATAMODEL.md) to learn more about the `ChatPrompt` object type._
|
|
282
|
-
|
|
283
|
-
<p align="center">
|
|
284
|
-
<img src="./img/onChatPrompt.png" alt="onChatPrompt" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
285
|
-
</p>
|
|
286
|
-
|
|
287
|
-
```typescript
|
|
288
|
-
...
|
|
289
|
-
onChatPrompt?: (
|
|
290
|
-
tabId: string,
|
|
291
|
-
prompt: ChatPrompt):void => {
|
|
292
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
293
|
-
console.log(`Prompt text (as written): ${prompt.prompt}`);
|
|
294
|
-
console.log(`Prompt text (HTML escaped): ${prompt.escapedPrompt}`);
|
|
295
|
-
console.log(`Command (if selected from quick actions): ${prompt.command}`);
|
|
296
|
-
console.log(`Attachment (feature not available yet): ${prompt.attachment}`);
|
|
297
|
-
};
|
|
298
|
-
...
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
### Very important note
|
|
302
|
-
You have to manually add the chat item for the prompt with the given ways on the **[How to use](./USAGE.md)** document.
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
### `onFollowUpClicked`
|
|
307
|
-
|
|
308
|
-
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.
|
|
309
|
-
|
|
310
|
-
**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.
|
|
311
|
-
|
|
312
|
-
**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.
|
|
313
|
-
|
|
314
|
-
_Please refer to the [data model](./DATAMODEL.md) to learn more about the `ChatItemFollowUp` object type._
|
|
315
|
-
|
|
316
|
-
<p align="center">
|
|
317
|
-
<img src="./img/onFollowupClicked.png" alt="onFollowUpClicked" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
318
|
-
</p>
|
|
319
|
-
|
|
320
|
-
```typescript
|
|
321
|
-
...
|
|
322
|
-
onFollowUpClicked?: (
|
|
323
|
-
tabId: string,
|
|
324
|
-
messageId: string,
|
|
325
|
-
followUp: ChatItemFollowUp):void => {
|
|
326
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
327
|
-
console.log(`For the message: ${messageId}`);
|
|
328
|
-
console.log(`Followup type (free text): ${followUp.type}`);
|
|
329
|
-
console.log(`Followup text (visible on screen): ${followUp.pillText}`);
|
|
330
|
-
};
|
|
331
|
-
...
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
---
|
|
335
|
-
|
|
336
|
-
### `onTabChange`
|
|
337
|
-
|
|
338
|
-
This event will be fired when user changes the tab. It will only pass `tabId` for the new selected tab as argument.
|
|
339
|
-
|
|
340
|
-
<p align="center">
|
|
341
|
-
<img src="./img/onTabChange.png" alt="onTabChange" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
342
|
-
</p>
|
|
343
|
-
|
|
344
|
-
```typescript
|
|
345
|
-
...
|
|
346
|
-
onTabChange?: (tabId: string):void => {
|
|
347
|
-
console.log(`New selected tabId: ${tabId}`);
|
|
348
|
-
};
|
|
349
|
-
...
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
---
|
|
353
|
-
|
|
354
|
-
### `onTabAdd`
|
|
355
|
-
|
|
356
|
-
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.
|
|
357
|
-
|
|
358
|
-
<p align="center">
|
|
359
|
-
<img src="./img/onTabAdd.png" alt="onTabAdd" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
360
|
-
</p>
|
|
361
|
-
|
|
362
|
-
```typescript
|
|
363
|
-
...
|
|
364
|
-
onTabAdd?: (tabId: string):void => {
|
|
365
|
-
console.log(`New tabId: ${tabId}`);
|
|
366
|
-
};
|
|
367
|
-
...
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
---
|
|
371
|
-
|
|
372
|
-
### `onTabRemove`
|
|
373
|
-
|
|
374
|
-
This event will be fired when user clicks the close button on a tab or middle clicks to the tab to close it. It will only pass `tabId` for the closed tab as argument.
|
|
375
|
-
|
|
376
|
-
<p align="center">
|
|
377
|
-
<img src="./img/onTabRemove.png" alt="onTabAdd" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
378
|
-
</p>
|
|
379
|
-
|
|
380
|
-
```typescript
|
|
381
|
-
...
|
|
382
|
-
onTabRemove?: (tabId: string):void => {
|
|
383
|
-
console.log(`Closed tabId: ${tabId}`);
|
|
384
|
-
};
|
|
385
|
-
...
|
|
386
|
-
```
|
|
387
|
-
---
|
|
388
|
-
|
|
389
|
-
### `onChatItemEngagement`
|
|
390
|
-
|
|
391
|
-
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.
|
|
392
|
-
|
|
393
|
-
_Please refer to the [data model](./DATAMODEL.md) to learn more about the `Engagement` object type._
|
|
394
|
-
|
|
395
|
-
**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.
|
|
396
|
-
|
|
397
|
-
<p align="center">
|
|
398
|
-
<img src="./img/onChatItemEngagement.png" alt="onChatItemEngagement" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
399
|
-
</p>
|
|
400
|
-
|
|
401
|
-
```typescript
|
|
402
|
-
...
|
|
403
|
-
onChatItemEngagement?: (
|
|
404
|
-
tabId: string,
|
|
405
|
-
messageId: string,
|
|
406
|
-
engagement: Engagement):void => {
|
|
407
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
408
|
-
console.log(`Engaged message: ${messageId}`);
|
|
409
|
-
console.log(`Engagement type: ${engagement.engagementType}`); // interaction | timespend
|
|
410
|
-
console.log(`Engagement duration: ${engagement.engagementDurationTillTrigger}`);
|
|
411
|
-
console.log(`Engagement total mouse distance travelled: ${engagement.totalMouseDistanceTraveled}`);
|
|
412
|
-
console.log(`Engagement selection:
|
|
413
|
-
x movement: ${engagement.selectionDistanceTraveled?.x}
|
|
414
|
-
y movement: ${engagement.selectionDistanceTraveled?.y}
|
|
415
|
-
selected text: ${engagement.selectionDistanceTraveled?.selectedText}
|
|
416
|
-
`);
|
|
417
|
-
};
|
|
418
|
-
...
|
|
419
|
-
```
|
|
420
|
-
---
|
|
421
|
-
|
|
422
|
-
### `onCopyCodeToClipboard`
|
|
423
|
-
|
|
424
|
-
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.
|
|
425
|
-
|
|
426
|
-
**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.
|
|
427
|
-
|
|
428
|
-
_Please refer to the [data model](./DATAMODEL.md) to learn more about the `ReferenceTrackerInformation` object type._
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
<p align="center">
|
|
432
|
-
<img src="./img/onCopyCodeToClipboard.png" alt="onCopyCodeToClipboard" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
433
|
-
</p>
|
|
434
|
-
|
|
435
|
-
```typescript
|
|
436
|
-
...
|
|
437
|
-
onCopyCodeToClipboard?: (
|
|
438
|
-
tabId: string,
|
|
439
|
-
messageId: string,
|
|
440
|
-
code?: string,
|
|
441
|
-
type?: CodeSelectionType,
|
|
442
|
-
referenceTrackerInformation?: ReferenceTrackerInformation[]):void => {
|
|
443
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
444
|
-
console.log(`Code inside message: ${messageId}`);
|
|
445
|
-
console.log(`Copied code: ${code}`);
|
|
446
|
-
console.log(`Copy type: ${type}`); // selection | block
|
|
447
|
-
console.log(`Reference tracker info: ${referenceTrackerInformation?.map(rti=>`${rti.licenseName} ${rti.repository}`).join(', ')}`);
|
|
448
|
-
};
|
|
449
|
-
...
|
|
450
|
-
```
|
|
451
|
-
---
|
|
452
|
-
|
|
453
|
-
### `onCodeInsertToCursorPosition`
|
|
454
|
-
|
|
455
|
-
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.
|
|
456
|
-
|
|
457
|
-
**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.
|
|
458
|
-
|
|
459
|
-
_Please refer to the [data model](./DATAMODEL.md) to learn more about the `ReferenceTrackerInformation` object type._
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
<p align="center">
|
|
463
|
-
<img src="./img/onCodeInsertToCursorPosition.png" alt="onCodeInsertToCursorPosition" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
464
|
-
</p>
|
|
465
|
-
|
|
466
|
-
```typescript
|
|
467
|
-
...
|
|
468
|
-
onCodeInsertToCursorPosition?: (
|
|
469
|
-
tabId: string,
|
|
470
|
-
messageId: string,
|
|
471
|
-
code?: string,
|
|
472
|
-
type?: CodeSelectionType,
|
|
473
|
-
referenceTrackerInformation?: ReferenceTrackerInformation[]):void => {
|
|
474
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
475
|
-
console.log(`Code inside message: ${messageId}`);
|
|
476
|
-
console.log(`Copied code: ${code}`);
|
|
477
|
-
console.log(`Copy type: ${type}`); // selection | block
|
|
478
|
-
console.log(`Reference tracker info: ${referenceTrackerInformation?.map(rti=>`${rti.licenseName} ${rti.repository}`).join(', ')}`);
|
|
479
|
-
};
|
|
480
|
-
...
|
|
481
|
-
```
|
|
482
|
-
---
|
|
483
|
-
|
|
484
|
-
### `onSourceLinkClick`
|
|
485
|
-
|
|
486
|
-
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.
|
|
487
|
-
|
|
488
|
-
**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.
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
<p align="center">
|
|
492
|
-
<img src="./img/onSourceLinkClick.png" alt="onSourceLinkClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
493
|
-
</p>
|
|
494
|
-
|
|
495
|
-
```typescript
|
|
496
|
-
...
|
|
497
|
-
onSourceLinkClick?: (
|
|
498
|
-
tabId: string,
|
|
499
|
-
messageId: string,
|
|
500
|
-
link: string,
|
|
501
|
-
mouseEvent?: MouseEvent):void => {
|
|
502
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
503
|
-
console.log(`Source link of message: ${messageId}`);
|
|
504
|
-
console.log(`link: ${link}`);
|
|
505
|
-
// mouseEvent.preventDefault();
|
|
506
|
-
};
|
|
507
|
-
...
|
|
508
|
-
```
|
|
509
|
-
---
|
|
510
|
-
|
|
511
|
-
### `onLinkClick`
|
|
512
|
-
|
|
513
|
-
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.
|
|
514
|
-
|
|
515
|
-
**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.
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
<p align="center">
|
|
519
|
-
<img src="./img/onLinkClick.png" alt="onLinkClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
520
|
-
</p>
|
|
521
|
-
|
|
522
|
-
```typescript
|
|
523
|
-
...
|
|
524
|
-
onLinkClick?: (
|
|
525
|
-
tabId: string,
|
|
526
|
-
messageId: string,
|
|
527
|
-
link: string,
|
|
528
|
-
mouseEvent?: MouseEvent):void => {
|
|
529
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
530
|
-
console.log(`Source link of message: ${messageId}`);
|
|
531
|
-
console.log(`link: ${link}`);
|
|
532
|
-
// mouseEvent.preventDefault();
|
|
533
|
-
};
|
|
534
|
-
...
|
|
535
|
-
```
|
|
536
|
-
---
|
|
537
|
-
|
|
538
|
-
### `onInfoLinkClick`
|
|
539
|
-
|
|
540
|
-
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.
|
|
541
|
-
|
|
542
|
-
**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.
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
<p align="center">
|
|
546
|
-
<img src="./img/onInfoLinkClick.png" alt="onInfoLinkClick" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
547
|
-
</p>
|
|
548
|
-
|
|
549
|
-
```typescript
|
|
550
|
-
...
|
|
551
|
-
onInfoLinkClick?: (
|
|
552
|
-
tabId: string,
|
|
553
|
-
link: string,
|
|
554
|
-
mouseEvent?: MouseEvent):void => {
|
|
555
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
556
|
-
console.log(`link: ${link}`);
|
|
557
|
-
// mouseEvent.preventDefault();
|
|
558
|
-
};
|
|
559
|
-
...
|
|
560
|
-
```
|
|
561
|
-
---
|
|
562
|
-
|
|
563
|
-
### `onSendFeedback`
|
|
564
|
-
|
|
565
|
-
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.
|
|
566
|
-
|
|
567
|
-
**Note:** The options for the feedback type are coming from the configuration.
|
|
568
|
-
|
|
569
|
-
_Please refer to the [configuration](./CONFIG.md) to learn more about the feedback type options._
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
<p align="center">
|
|
573
|
-
<img src="./img/onSendFeedback-1.png" alt="onSendFeedbackStep1" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
574
|
-
<img src="./img/onSendFeedback-2.png" alt="onSendFeedbackStep2" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
575
|
-
<img src="./img/onSendFeedback-3.png" alt="onSendFeedbackStep3" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
576
|
-
</p>
|
|
577
|
-
|
|
578
|
-
```typescript
|
|
579
|
-
...
|
|
580
|
-
onSendFeedback?: (
|
|
581
|
-
tabId: string,
|
|
582
|
-
feedbackPayload: FeedbackPayload):void => {
|
|
583
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
584
|
-
console.log(`Feedback for message: ${feedbackPayload.messageId}`);
|
|
585
|
-
console.log(`Feedback type: ${feedbackPayload.selectedOption}`);
|
|
586
|
-
console.log(`Feedback comment: ${feedbackPayload.comment}`);
|
|
587
|
-
// mouseEvent.preventDefault();
|
|
588
|
-
};
|
|
589
|
-
...
|
|
590
|
-
```
|
|
591
|
-
---
|
|
592
|
-
|
|
593
|
-
### `onOpenDiff`
|
|
594
|
-
|
|
595
|
-
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.
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
<p align="center">
|
|
599
|
-
<img src="./img/onOpenDiff.png" alt="onOpenDiff" style="max-width:500px; width:100%;border: 1px solid #e0e0e0;">
|
|
600
|
-
</p>
|
|
601
|
-
|
|
602
|
-
```typescript
|
|
603
|
-
...
|
|
604
|
-
onOpenDiff?: (
|
|
605
|
-
tabId: string,
|
|
606
|
-
filePath: string,
|
|
607
|
-
deleted: boolean,
|
|
608
|
-
messageId?: string):void => {
|
|
609
|
-
console.log(`Sent from tab: ${tabId}`);
|
|
610
|
-
console.log(`For message: ${messageId}`);
|
|
611
|
-
console.log(`File to open diff view: ${filePath}`);
|
|
612
|
-
console.log(`Is file deleted: ${deleted}`);
|
|
613
|
-
};
|
|
614
|
-
...
|
|
615
|
-
```
|
package/docs/STARTUP.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# How to install and start using Mynah UI
|
|
2
|
-
Simply install it from npm with your favorite package manager.
|
|
3
|
-
```console
|
|
4
|
-
npm install @aws/mynah-ui
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
When you import `@aws/mynah-ui` it provides you the main `MynahUI` class to generate a new all-in-one object to create and render the UI inside a desired DOM element. While creating the UI, you can provide the initial and default datas to be shown. You can also connect to the user interaction events through the initial properties. Additionally you can also configure the texts depending on your language preferences.
|
|
8
|
-
|
|
9
|
-
``` typescript
|
|
10
|
-
import { MynahUI } from '@aws/mynah-ui';
|
|
11
|
-
|
|
12
|
-
// Assign it to a variable to be able call functions.
|
|
13
|
-
const mynahUI = new MynahUI({
|
|
14
|
-
// All props are optional
|
|
15
|
-
// so even without providing anything
|
|
16
|
-
// it will create the UI
|
|
17
|
-
rootSelector: ...,
|
|
18
|
-
defaults: ...,
|
|
19
|
-
tabs: ...,
|
|
20
|
-
config: ...,
|
|
21
|
-
onShowMoreWebResultsClick: ...,
|
|
22
|
-
onReady: ...,
|
|
23
|
-
onVote: ...,
|
|
24
|
-
onStopChatResponse: ...,
|
|
25
|
-
onResetStore: ...,
|
|
26
|
-
onChatPrompt: ...,
|
|
27
|
-
onFollowUpClicked: ...,
|
|
28
|
-
onTabChange: ...,
|
|
29
|
-
onTabAdd: ...,
|
|
30
|
-
onTabRemove: ...,
|
|
31
|
-
onChatItemEngagement: ...,
|
|
32
|
-
onCopyCodeToClipboard: ...,
|
|
33
|
-
onCodeInsertToCursorPosition: ...,
|
|
34
|
-
onSourceLinkClick: ...,
|
|
35
|
-
onLinkClick: ...,
|
|
36
|
-
onInfoLinkClick: ...,
|
|
37
|
-
onSendFeedback: ...,
|
|
38
|
-
onOpenDiff: ...,
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
You're ready to go, now you have a Chat UI generated and rendered into place you set.
|
|
43
|
-
|
|
44
|
-
# What's Next?
|
|
45
|
-
- Take a look to the **[Constructor Properties](./PROPERTIES.md)**
|
|
46
|
-
- Take a look to the **[Configuration](./CONFIG.md)**
|
|
47
|
-
- Take a look to the **[How to use MynahUI](./USAGE.md)**
|
|
48
|
-
- Take a look to the **[Data Model](./DATAMODEL.md)**
|
|
49
|
-
- Take a look to the **[Styling Configuration](./STYLING.md)**
|
|
50
|
-
|