@aws/mynah-ui 4.23.0-beta.1 → 4.23.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/static.d.ts CHANGED
@@ -2,14 +2,14 @@
2
2
  * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import { MynahIcons } from './components/icon';
5
+ import { MynahIcons, MynahIconsType } from './components/icon';
6
6
  import { ChatItemBodyRenderer } from './helper/dom';
7
7
  import { SelectAbstract, SelectProps, RadioGroupAbstract, RadioGroupProps, ButtonAbstract, ButtonProps, TextInputProps, TextInputAbstract, TextAreaProps, TextAreaAbstract, ToggleOption } from './main';
8
8
  export interface QuickActionCommand {
9
9
  command: string;
10
10
  label?: string;
11
11
  disabled?: boolean;
12
- icon?: MynahIcons;
12
+ icon?: MynahIcons | MynahIconsType;
13
13
  description?: string;
14
14
  placeholder?: string;
15
15
  children?: QuickActionCommandGroup[];
@@ -20,6 +20,7 @@ export interface QuickActionCommandInternal extends QuickActionCommand {
20
20
  }
21
21
  export interface QuickActionCommandGroup {
22
22
  groupName?: string;
23
+ actions?: Action[];
23
24
  commands: QuickActionCommand[];
24
25
  }
25
26
  export interface QuickActionCommandGroupInternal extends QuickActionCommandGroup {
@@ -154,6 +155,7 @@ export declare enum MynahEventNames {
154
155
  CHAT_ITEM_ADD = "chatItemAdd",
155
156
  FOLLOW_UP_CLICKED = "followUpClicked",
156
157
  BODY_ACTION_CLICKED = "bodyActionClicked",
158
+ QUICK_COMMAND_GROUP_ACTION_CLICK = "quickCommandGroupActionClicked",
157
159
  TABBED_CONTENT_SWITCH = "tabbedContentSwitch",
158
160
  SHOW_MORE_WEB_RESULTS_CLICK = "showMoreWebResultsClick",
159
161
  SHOW_FEEDBACK_FORM = "showFeedbackForm",
@@ -225,7 +227,7 @@ export interface ProgressField {
225
227
  }
226
228
  export interface TreeNodeDetails {
227
229
  status?: Status;
228
- icon?: MynahIcons;
230
+ icon?: MynahIcons | MynahIconsType;
229
231
  label?: string;
230
232
  description?: string;
231
233
  clickable?: boolean;
@@ -260,11 +262,11 @@ export interface ChatItemContent {
260
262
  title?: string;
261
263
  status?: {
262
264
  status?: Status;
263
- icon?: MynahIcons;
265
+ icon?: MynahIcons | MynahIconsType;
264
266
  body?: string;
265
267
  };
266
268
  description?: string;
267
- icon?: MynahIcons;
269
+ icon?: MynahIcons | MynahIconsType;
268
270
  content: ChatItemContent;
269
271
  } | null;
270
272
  tabbedContent?: Array<ToggleOption & {
@@ -277,7 +279,7 @@ export interface ChatItem extends ChatItemContent {
277
279
  messageId?: string;
278
280
  snapToTop?: boolean;
279
281
  canBeVoted?: boolean;
280
- icon?: MynahIcons;
282
+ icon?: MynahIcons | MynahIconsType;
281
283
  hoverEffect?: boolean;
282
284
  status?: Status;
283
285
  }
@@ -305,28 +307,25 @@ export interface ChatItemAction extends ChatPrompt {
305
307
  disabled?: boolean;
306
308
  description?: string;
307
309
  status?: 'primary' | Status;
308
- icon?: MynahIcons;
310
+ icon?: MynahIcons | MynahIconsType;
309
311
  }
310
- export interface ChatItemButton {
312
+ export interface ChatItemButton extends Omit<Action, 'status'> {
311
313
  keepCardAfterClick?: boolean;
312
314
  waitMandatoryFormItems?: boolean;
313
- text: string;
314
- id: string;
315
- disabled?: boolean;
316
- description?: string;
317
315
  status?: 'main' | 'primary' | 'clear' | Status;
318
316
  flash?: 'infinite' | 'once';
319
317
  fillState?: 'hover' | 'always';
320
- icon?: MynahIcons;
321
318
  position?: 'inside' | 'outside';
322
319
  }
323
- export interface TabBarAction {
320
+ export interface Action {
324
321
  text?: string;
325
322
  id: string;
326
323
  disabled?: boolean;
327
324
  description?: string;
328
325
  status?: Status;
329
- icon?: MynahIcons;
326
+ icon?: MynahIcons | MynahIconsType;
327
+ }
328
+ export interface TabBarAction extends Action {
330
329
  }
331
330
  export interface TabBarMainAction extends TabBarAction {
332
331
  items?: TabBarAction[];
@@ -337,7 +336,7 @@ export interface FileNodeAction {
337
336
  disabled?: boolean;
338
337
  description?: string;
339
338
  status?: Status;
340
- icon: MynahIcons;
339
+ icon: MynahIcons | MynahIconsType;
341
340
  }
342
341
  export declare enum KeyMap {
343
342
  ESCAPE = "Escape",
@@ -430,7 +429,7 @@ export declare enum NotificationType {
430
429
  ERROR = "error"
431
430
  }
432
431
  export interface TabHeaderDetails {
433
- icon?: MynahIcons;
432
+ icon?: MynahIcons | MynahIconsType;
434
433
  title?: string;
435
434
  description?: string;
436
435
  }
@@ -438,7 +437,7 @@ export interface CodeBlockAction {
438
437
  id: 'copy' | 'insert-to-cursor' | string;
439
438
  label: string;
440
439
  description?: string;
441
- icon?: MynahIcons;
440
+ icon?: MynahIcons | MynahIconsType;
442
441
  data?: any;
443
442
  flash?: 'infinite' | 'once';
444
443
  acceptedLanguages?: string[];
package/docs/USAGE.md CHANGED
@@ -18,6 +18,7 @@ mynahUI.addToUserPrompt(...);
18
18
  mynahUI.updateLastChatAnswer(...);
19
19
  mynahUI.updateChatAnswerWithMessageId(...);
20
20
  mynahUI.endMessageStream(...);
21
+ mynahUI.serializeChat(...);
21
22
  mynahUI.updateStore(...);
22
23
  mynahUI.selectTab(...);
23
24
  mynahUI.removeTab(...);
@@ -390,6 +391,25 @@ Can you end stream for a card you already ended the stream? Basically yes becaus
390
391
 
391
392
  ---
392
393
 
394
+ ## Serializing a chat (`serializeChat`)
395
+
396
+ You can serialize an entire chat from a specific tab using this function. Only the card bodies will be included, meaning that buttons and other interactable components are left out. There are two output options for the serialization:
397
+ - **Markdown:** get all the bodies from chat items in markdown format so that it serves as the contents of a valid `.md` file. Each card body is separated by `\n\n---\n\n`.
398
+ - **HTML:** get a string which serves as the contents of a valid `.html` file. It consists of a centered chat container, containing all the chat item bodies in cards. All the relevant stylesheets from MynahUI are included in the `<style>` section of the string.
399
+
400
+ The following example shows how serialization could be used to download an export of a tab's chat:
401
+ ```typescript
402
+ const serializedChat = mynahUI.serializeChat(tabId, 'markdown')
403
+ const blob = new Blob([serializedChat], { type: 'text/plain' });
404
+ const url = URL.createObjectURL(blob);
405
+ const link = document.createElement('a');
406
+ link.download = 'exported-chat.md';
407
+ link.href = url;
408
+ link.click();
409
+ ```
410
+
411
+ ---
412
+
393
413
  ## Adding code attachments to prompt field (`addToUserPrompt`)
394
414
 
395
415
  You can add code attachments under the prompt field of the desired tab. When user fills the prompt field and sends it, the attached code block will be appended at the end of the prompt text. It accepts max chars set through **[CONFIG](./CONFIG.md#maxUserInput)** however you don't need to worry about it. MynahUI will automatically crop it depending on the available chars left from the prompt field itself by using a `96` chars of threshold. **So beware that for example if you want 4000 chars exact, you need to give 4096 to the config.**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aws/mynah-ui",
3
3
  "displayName": "AWS Mynah UI",
4
- "version": "4.23.0-beta.1",
4
+ "version": "4.23.0-beta.3",
5
5
  "description": "AWS Toolkit VSCode and Intellij IDE Extension Mynah UI",
6
6
  "publisher": "Amazon Web Services",
7
7
  "license": "Apache License 2.0",