@aws/mynah-ui 4.23.0-beta.5 → 4.23.0-beta.7

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
@@ -158,11 +158,13 @@ export declare enum MynahEventNames {
158
158
  FILE_ACTION_CLICK = "fileActionClick",
159
159
  TAB_FOCUS = "tabFocus",
160
160
  CUSTOM_FORM_ACTION_CLICK = "customFormActionClick",
161
+ FORM_MODIFIER_ENTER_PRESS = "formModifierEnterPress",
161
162
  ADD_ATTACHMENT = "addAttachment",
162
163
  REMOVE_ATTACHMENT = "removeAttachment",
163
164
  TAB_BAR_BUTTON_CLICK = "tabBarButtonClick",
164
165
  PROMPT_PROGRESS_ACTION_CLICK = "promptProgressActionClick",
165
- ROOT_RESIZE = "rootResize"
166
+ ROOT_RESIZE = "rootResize",
167
+ CONTEXT_SELECTED = "contextSelected"
166
168
  }
167
169
  export declare enum MynahPortalNames {
168
170
  WRAPPER = "wrapper",
@@ -228,6 +230,7 @@ export interface TreeNodeDetails {
228
230
  clickable?: boolean;
229
231
  }
230
232
  export interface ChatItemContent {
233
+ header?: ChatItemContent | null;
231
234
  body?: string | null;
232
235
  customRenderer?: string | ChatItemBodyRenderer | ChatItemBodyRenderer[] | null;
233
236
  followUp?: {
@@ -244,6 +247,8 @@ export interface ChatItemContent {
244
247
  rootFolderTitle?: string;
245
248
  filePaths?: string[];
246
249
  deletedFiles?: string[];
250
+ collapsedByDefault?: boolean;
251
+ hideFileCount?: boolean;
247
252
  actions?: Record<string, FileNodeAction[]>;
248
253
  details?: Record<string, TreeNodeDetails>;
249
254
  } | null;
@@ -288,9 +293,11 @@ interface BaseFormItem {
288
293
  title?: string;
289
294
  placeholder?: string;
290
295
  value?: string;
296
+ description?: string;
291
297
  }
292
298
  export type TextBasedFormItem = BaseFormItem & {
293
299
  type: 'textarea' | 'textinput' | 'numericinput' | 'email';
300
+ checkModifierEnterKeyPress?: boolean;
294
301
  validationPatterns?: {
295
302
  operator?: 'and' | 'or';
296
303
  genericValidationErrorMessage?: string;
package/docs/DATAMODEL.md CHANGED
@@ -868,6 +868,7 @@ type CodeBlockActions = Record<'copy' | 'insert-to-cursor' | string, CodeBlockAc
868
868
 
869
869
  // #################################
870
870
  interface ChatItemContent {
871
+ header?: ChatItemContent | null;
871
872
  body?: string | null;
872
873
  customRenderer?: string | ChatItemBodyRenderer | ChatItemBodyRenderer[] | null;
873
874
  followUp?: {
@@ -884,6 +885,8 @@ interface ChatItemContent {
884
885
  rootFolderTitle?: string;
885
886
  filePaths?: string[];
886
887
  deletedFiles?: string[];
888
+ collapsedByDefault?: boolean;
889
+ hideFileCount?: boolean;
887
890
  actions?: Record<string, FileNodeAction[]>;
888
891
  details?: Record<string, TreeNodeDetails>;
889
892
  } | null;
@@ -1075,6 +1078,43 @@ mynahUI.addChatItem('tab-1', {
1075
1078
 
1076
1079
  ---
1077
1080
 
1081
+ ## `header`
1082
+ With this parameter, you can add a `ChatItem` at the top of a ChatItem, before the body, but still within the card itself.
1083
+
1084
+ ```typescript
1085
+ const mynahUI = new MynahUI({
1086
+ tabs: {
1087
+ 'tab-1': {
1088
+ ...
1089
+ }
1090
+ }
1091
+ });
1092
+
1093
+ mynahUI.addChatItem(tabId, {
1094
+ type: ChatItemType.ANSWER,
1095
+ body: `SOME CONTENT`,
1096
+ header: {
1097
+ fileList: { // For example, want to show which file is used to generate that answer
1098
+ rootFolderTitle: undefined,
1099
+ fileTreeTitle: '',
1100
+ filePaths: ['./src/index.ts'],
1101
+ details: {
1102
+ './src/index.ts': {
1103
+ icon: MynahIcons.FILE,
1104
+ description: `SOME DESCRIPTION.`
1105
+ }
1106
+ }
1107
+ }
1108
+ }
1109
+ });
1110
+ ```
1111
+
1112
+ <p align="center">
1113
+ <img src="./img/data-model/chatItems/header.png" alt="header" style="max-width:600px; width:100%;border: 1px solid #e0e0e0;">
1114
+ </p>
1115
+
1116
+ ---
1117
+
1078
1118
  ## `body`
1079
1119
  Basically the body of the card. Which you can send a full markdown string. Allows code blocks, links etc.
1080
1120
 
@@ -1732,6 +1772,8 @@ mynahUI.addChatItem(tabId, {
1732
1772
  deletedFiles: ['src/devfile.yaml'],
1733
1773
  // fileTreeTitle: "Custom file tree card title";
1734
1774
  // rootFolderTitle: "Custom root folder title";
1775
+ // collapsedByDefault: true // Collapse the root folder by default
1776
+ // hideFileCount: true // Hide the file counter next to folders
1735
1777
  actions: {
1736
1778
  'src/App.tsx': [
1737
1779
  {
@@ -2034,8 +2076,10 @@ interface ChatItemFormItem {
2034
2076
  type: 'select' | 'textarea' | 'textinput' | 'numericinput' | 'stars' | 'radiogroup'; // type (see below for each of them)
2035
2077
  mandatory?: boolean; // If it is set to true, buttons in the same card with waitMandatoryFormItems set to true will wait them to be filled
2036
2078
  title?: string; // Label of the input
2079
+ description?: string; // The description, showing under the input field itself
2037
2080
  placeholder?: string; // Placeholder for input, but only applicable to textarea, textinput and numericinput
2038
2081
  value?: string; // Initial value of the item. All types of form items will get and return string values, conversion of the value type is up to you
2082
+ checkModifierEnterKeyPress?: boolean; // Only applicable to textual inputs: whether the onFormModifierEnterPress event can be triggered from this input field
2039
2083
  options?: Array<{ // Only applicable to select and radiogroup types
2040
2084
  value: string;
2041
2085
  label: string;
@@ -2122,6 +2166,7 @@ mynahUI.addChatItem(tabId, {
2122
2166
  mandatory: true,
2123
2167
  title: `Email`,
2124
2168
  placeholder: 'email',
2169
+ checkModifierEnterKeyPress: true
2125
2170
  },
2126
2171
  {
2127
2172
  id: 'name',
@@ -45,6 +45,9 @@ export interface MynahUIProps {
45
45
  onTabAdd?: (
46
46
  tabId: string,
47
47
  eventId?: string) => void;
48
+ onContextSelected?: (
49
+ contextItem: QuickActionCommand,
50
+ ) => boolean;
48
51
  onTabRemove?: (
49
52
  tabId: string,
50
53
  eventId?: string) => void;
@@ -115,6 +118,10 @@ export interface MynahUIProps {
115
118
  tabId: string,
116
119
  feedbackPayload: FeedbackPayload,
117
120
  eventId?: string) => void;
121
+ onFormModifierEnterPress?: (
122
+ formData: Record<string, string>,
123
+ tabId: string,
124
+ eventId?: string) => void;
118
125
  onCustomFormAction?: (
119
126
  tabId: string,
120
127
  action: {
@@ -512,6 +519,26 @@ onTabAdd?: (tabId: string):void => {
512
519
 
513
520
  ---
514
521
 
522
+ ### `onContextSelected`
523
+
524
+ This event will be fired whenever a user selects an item from the context (`@`) list either using mouse click or keyboard actions. It is only triggered for items without children, i.e. only leaves in the tree. The data of the selected context item can be accessed through the `contextItem`. This event handler expects a boolean return:
525
+ - Returning `true` indicates that the context item should be added to the prompt input text.
526
+ - Returning `false` indicates that nothing should be added to the prompt input, and the triggering string should be cleared. E.g. if a user types `@wor` and presses tab on the `@workspace` action, the `@wor` would be removed from the prompt input and no context item will be added.
527
+
528
+ ```typescript
529
+ ...
530
+ onContextSelected(contextItem: QuickActionCommand) {
531
+ if (contextItem.command === 'add_prompt') {
532
+ Log('Custom context action triggered for adding a prompt!')
533
+ return false;
534
+ }
535
+ return true;
536
+ },
537
+ ...
538
+ ```
539
+
540
+ ---
541
+
515
542
  ### `onBeforeTabRemove`
516
543
 
517
544
  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.
@@ -826,6 +853,26 @@ onSendFeedback?: (
826
853
  };
827
854
  ...
828
855
  ```
856
+
857
+ ---
858
+
859
+ ### `onFormModifierEnterPress`
860
+
861
+ This event will be fired when the user presses the modifier key (`cmd` on macOS, and `ctrl` on Windows / Linux) and the `enter` key at the same time, while focused on a textual form input field. The event will only be triggered for input fields that have set `checkModifierEnterKeyPress: true`, and it will only be triggered if the form is valid and can be submitted. An example use case for this would be submitting the form through a keyboard hotkey action.
862
+
863
+ ```typescript
864
+ ...
865
+ onFormModifierEnterPress?: (
866
+ formData: Record<string, string>,
867
+ tabId: string,
868
+ eventId?: string): void => {
869
+ console.log(`Form modifier enter pressed on tab <b>${tabId}</b>:<br/>
870
+ Form data: <b>${JSON.stringify(formData)}</b><br/>
871
+ `);
872
+ },
873
+ ...
874
+ ```
875
+
829
876
  ---
830
877
 
831
878
  ### `onCustomFormAction`
package/docs/STARTUP.md CHANGED
@@ -28,6 +28,7 @@ const mynahUI = new MynahUI({
28
28
  onBodyActionClicked: ...,
29
29
  onTabChange: ...,
30
30
  onTabAdd: ...,
31
+ onContextSelected: ...,
31
32
  onTabRemove: ...,
32
33
  onChatItemEngagement: ...,
33
34
  onCopyCodeToClipboard: ...,
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.5",
4
+ "version": "4.23.0-beta.7",
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",