@aws/mynah-ui 2.0.0-beta.5 → 2.0.0-beta.6.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.
@@ -6,11 +6,11 @@ import { ExtendedHTMLElement } from '../../helper/dom';
6
6
  import { ChatItem } from '../../static';
7
7
  import { SuggestionCardBody } from '../suggestion-card/suggestion-card-body';
8
8
  export interface ChatItemCardProps {
9
+ tabId: string;
9
10
  chatItem: ChatItem;
10
- onShowAllWebResultsClick?: () => void;
11
11
  }
12
12
  export declare class ChatItemCard {
13
- private readonly chatItem;
13
+ private readonly props;
14
14
  private readonly relatedContentWrapper;
15
15
  private readonly referencesWrapper;
16
16
  private readonly showMoreButtonBlock;
@@ -5,10 +5,11 @@
5
5
  import { ExtendedHTMLElement } from '../../helper/dom';
6
6
  import { ChatItem } from '../../static';
7
7
  export interface ChatItemFollowUpProps {
8
+ tabId: string;
8
9
  chatItem: ChatItem;
9
10
  }
10
11
  export declare class ChatItemFollowUpContainer {
11
- private readonly chatItem;
12
+ private readonly props;
12
13
  render: ExtendedHTMLElement;
13
14
  constructor(props: ChatItemFollowUpProps);
14
15
  }
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { ExtendedHTMLElement } from '../../helper/dom';
6
+ export interface ChatItemTreeViewWrapperProps {
7
+ files: string[];
8
+ }
9
+ export declare class ChatItemTreeViewWrapper {
10
+ render: ExtendedHTMLElement;
11
+ constructor(props: ChatItemTreeViewWrapperProps);
12
+ }
@@ -0,0 +1,18 @@
1
+ import { ExtendedHTMLElement } from '../../helper/dom';
2
+ import { TreeNode } from '../../helper/file-tree';
3
+ export interface ChatItemTreeViewProps {
4
+ node: TreeNode;
5
+ depth?: number;
6
+ }
7
+ export declare class ChatItemTreeView {
8
+ private readonly node;
9
+ private isOpen;
10
+ private readonly depth;
11
+ render: ExtendedHTMLElement;
12
+ constructor(props: ChatItemTreeViewProps);
13
+ getClassNames(): string[];
14
+ updateTree(): void;
15
+ buildFolderChildren(): ExtendedHTMLElement[];
16
+ buildFolderNode(): ExtendedHTMLElement[];
17
+ buildFileNode(): ExtendedHTMLElement[];
18
+ }
@@ -3,8 +3,12 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { ExtendedHTMLElement } from '../../helper/dom';
6
+ export interface ChatPromptInputProps {
7
+ tabId: string;
8
+ }
6
9
  export declare class ChatPromptInput {
7
10
  render: ExtendedHTMLElement;
11
+ private readonly props;
8
12
  private readonly attachmentWrapper;
9
13
  private readonly promptTextInputWrapper;
10
14
  private readonly promptTextInput;
@@ -16,7 +20,7 @@ export declare class ChatPromptInput {
16
20
  private inputDisabled;
17
21
  private attachment?;
18
22
  private filteredCommandsList;
19
- constructor();
23
+ constructor(props: ChatPromptInputProps);
20
24
  private readonly handleInputKeydown;
21
25
  private readonly getQuickCommandActions;
22
26
  private readonly calculateTextAreaHeight;
@@ -3,18 +3,23 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { ExtendedHTMLElement } from '../../helper/dom';
6
+ import { Suggestion } from '../../static';
6
7
  export interface ChatWrapperProps {
7
- onStopChatResponse?: () => void;
8
- onShowAllWebResultsClick?: () => void;
8
+ onStopChatResponse?: (tabId: string) => void;
9
+ tabId: string;
9
10
  }
10
11
  export declare class ChatWrapper {
11
- private readonly props?;
12
+ private readonly props;
12
13
  private readonly chatItemsContainer;
13
14
  private readonly intermediateBlockContainer;
14
15
  private readonly promptInput;
15
16
  private lastChatItemCard;
16
17
  render: ExtendedHTMLElement;
17
- constructor(props?: ChatWrapperProps);
18
+ constructor(props: ChatWrapperProps);
18
19
  private readonly insertChatItem;
19
20
  removeAllExceptAnswersAndPrompts: () => void;
21
+ updateLastCharAnswerStream: (updateWith: string | {
22
+ title: string | boolean;
23
+ suggestions: Suggestion[];
24
+ }) => void;
20
25
  }
@@ -3,14 +3,14 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { ExtendedHTMLElement } from '../helper/dom';
6
- export declare const getSelectedTabValueFromStore: () => string;
7
- export interface NavivationTabsProps {
8
- onChange?: (selectedValue: string) => void;
6
+ export interface TabsProps {
7
+ onChange?: (selectedTabId: string) => void;
9
8
  }
10
- export declare class NavivationTabs {
9
+ export declare class Tabs {
11
10
  render: ExtendedHTMLElement;
11
+ private toggleGroup;
12
12
  private readonly props;
13
- constructor(props: NavivationTabsProps);
14
- private readonly setLoading;
13
+ constructor(props: TabsProps);
14
+ private readonly getTabOptionsFromTabStoreData;
15
15
  private readonly getTabsRender;
16
16
  }
@@ -6,7 +6,6 @@ import { ExtendedHTMLElement } from '../helper/dom';
6
6
  import { MynahIcons } from './icon';
7
7
  export interface ToggleOption {
8
8
  label?: ExtendedHTMLElement | string | HTMLElement;
9
- color?: string;
10
9
  icon?: MynahIcons;
11
10
  disabled?: boolean;
12
11
  selected?: boolean;
@@ -15,21 +14,20 @@ export interface ToggleOption {
15
14
  }
16
15
  export interface ToggleProps {
17
16
  options: ToggleOption[];
18
- type?: 'switch' | 'tabs';
19
17
  direction?: 'horizontal' | 'vertical';
20
18
  value?: string | null;
21
19
  name: string;
22
20
  disabled?: boolean;
23
21
  onChange?: (selectedValue: string) => void;
22
+ onRemove?: (selectedValue: string) => void;
24
23
  }
25
24
  export declare class Toggle {
26
25
  render: ExtendedHTMLElement;
27
26
  private readonly props;
28
- private currentValue?;
29
- private readonly relocateTransitioner;
27
+ private readonly currentValue?;
30
28
  constructor(props: ToggleProps);
29
+ private readonly transformScroll;
31
30
  private readonly getChildren;
32
- private readonly setRelocatePosition;
33
31
  private readonly updateSelectionRender;
34
32
  setValue: (value: string) => void;
35
33
  getValue: () => string | undefined;
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ export declare type TreeNode = FolderNode | FileNode;
6
+ export interface FileNode {
7
+ name: string;
8
+ type: 'file';
9
+ filePath: string;
10
+ }
11
+ export interface FolderNode {
12
+ name: string;
13
+ type: 'folder';
14
+ children: Array<FolderNode | FileNode>;
15
+ }
16
+ export declare const fileListToTree: (filePaths: string[]) => TreeNode;
@@ -8,12 +8,10 @@ export declare class EmptyMynahUIDataModel {
8
8
  constructor(defaults?: MynahUIDataModel | null);
9
9
  }
10
10
  export declare class MynahUIDataStore {
11
- private static instance;
12
11
  private readonly subsciptions;
13
12
  private store;
14
13
  private defaults;
15
- private constructor();
16
- static getInstance: (initialData?: MynahUIDataModel | undefined) => MynahUIDataStore;
14
+ constructor(initialData?: MynahUIDataModel);
17
15
  setDefaults: (defaults: MynahUIDataModel | null) => void;
18
16
  getDefaults: () => MynahUIDataModel | null;
19
17
  subscribe: (storeKey: keyof MynahUIDataModel, handler: (newValue: any, oldValue?: any) => void) => string;
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { MynahUITabStoreModel, MynahUITabStoreTab } from '../static';
6
+ interface TabStoreSubscription {
7
+ 'add': Record<string, (tabId: string, tabData?: MynahUITabStoreTab) => void>;
8
+ 'remove': Record<string, (tabId: string) => void>;
9
+ 'update': Record<string, (tabId: string, tabData?: MynahUITabStoreTab) => void>;
10
+ 'selectedTabChange': Record<string, (tabId: string) => void>;
11
+ }
12
+ export declare class EmptyMynahUITabsStoreModel {
13
+ data: Required<MynahUITabStoreModel>;
14
+ constructor();
15
+ }
16
+ export declare class MynahUITabsStore {
17
+ private static instance;
18
+ private readonly subsciptions;
19
+ private readonly tabDefaults;
20
+ private readonly tabsStore;
21
+ private readonly tabsDataStore;
22
+ private constructor();
23
+ readonly addTab: (tabData?: MynahUITabStoreTab | undefined) => string;
24
+ readonly removeTab: (tabId: string) => string;
25
+ readonly selectTab: (tabId: string) => void;
26
+ updateTab: (tabId: string, tabData?: Partial<MynahUITabStoreTab> | undefined, skipSubscribers?: boolean | undefined) => void;
27
+ static getInstance: (initialData?: MynahUITabStoreModel | undefined, defaults?: MynahUITabStoreTab | undefined) => MynahUITabsStore;
28
+ addListener: (eventName: keyof TabStoreSubscription, handler: (tabId: string, tabData?: MynahUITabStoreTab | undefined) => void) => string;
29
+ removeListener: (eventName: keyof TabStoreSubscription, subscriptionId: string) => void;
30
+ private readonly informSubscribers;
31
+ getTab: (tabId: string) => any;
32
+ getAllTabs: () => MynahUITabStoreModel;
33
+ getTabDataStore: (tabId: string) => any;
34
+ getSelectedTabId: () => string;
35
+ removeAllTabs: () => void;
36
+ }
37
+ export {};
package/dist/main.d.ts CHANGED
@@ -2,54 +2,49 @@
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 { SuggestionEngagement, Suggestion, SearchPayload, SuggestionEventName, RelevancyVoteType, FeedbackPayload, MynahUIDataModel, NotificationType, ChatItem, ChatItemFollowUp, ChatPrompt, MynahMode } from './static';
5
+ import { SuggestionEngagement, Suggestion, SuggestionEventName, RelevancyVoteType, FeedbackPayload, MynahUIDataModel, NotificationType, ChatItem, ChatItemFollowUp, ChatPrompt, MynahUITabStoreModel, MynahUITabStoreTab } from './static';
6
6
  import './styles/styles.scss';
7
- export { SearchPayloadCodeSelection, FeedbackPayload, RelevancyVoteType, SearchPayload, Suggestion, EngagementType, SuggestionEngagement, SuggestionEventName, MynahUIDataModel, NotificationType, MynahMode, ChatItem, ChatItemFollowUp, ChatItemType, ChatPrompt } from './static';
7
+ export { FeedbackPayload, RelevancyVoteType, Suggestion, EngagementType, SuggestionEngagement, SuggestionEventName, MynahUIDataModel, NotificationType, ChatItem, ChatItemFollowUp, ChatItemType, ChatPrompt } from './static';
8
8
  export { ToggleOption } from './components/toggle';
9
9
  export { MynahIcons } from './components/icon';
10
- export { transformPayloadData, validateRulesOnPayloadData, PayloadTransformRule, } from './helper/payload-transformer';
11
10
  export interface MynahUIProps {
12
11
  rootSelector?: string;
13
- storeData?: MynahUIDataModel;
14
- onSearch?: ((searchPayload: SearchPayload) => void) | ((searchPayload: SearchPayload) => MynahUIDataModel);
12
+ defaults?: MynahUITabStoreTab;
13
+ tabs?: MynahUITabStoreModel;
15
14
  onShowMoreWebResultsClick?: () => void;
16
15
  onReady?: () => void;
17
- onVote?: (votedItemID: string, vote: RelevancyVoteType) => void;
18
- onStopChatResponse?: () => void;
16
+ onVote?: (tabId: string, votedItemID: string, vote: RelevancyVoteType) => void;
17
+ onStopChatResponse?: (tabId: string) => void;
19
18
  onResetStore?: () => void;
20
- onChatPrompt?: (prompt: ChatPrompt) => void;
21
- onFollowUpClicked?: (followUp: ChatItemFollowUp) => void;
22
- onSuggestionAttachedToChatPrompt?: (attachment: Suggestion) => void;
23
- onNavigationTabChange?: (selectedTab: string) => void;
24
- onSideNavigationTabChange?: (selectedTab: string) => void;
19
+ onChatPrompt?: (tabId: string, prompt: ChatPrompt) => void;
20
+ onFollowUpClicked?: (tabId: string, followUp: ChatItemFollowUp) => void;
21
+ onTabChange?: (selectedTabId: string) => void;
22
+ onTabAdd?: (tabId: string) => void;
23
+ onTabRemove?: (tabId: string) => void;
25
24
  onSuggestionEngagement?: (engagement: SuggestionEngagement) => void;
26
25
  onCopyCodeToClipboard?: (code?: string, type?: 'selection' | 'block') => void;
27
26
  onCodeInsertToCursorPosition?: (code?: string, type?: 'selection' | 'block') => void;
28
27
  onSuggestionInteraction?: (eventName: SuggestionEventName, suggestion: Suggestion, mouseEvent?: MouseEvent) => void;
29
- onSendFeedback?: (feedbackPayload: FeedbackPayload) => void;
30
- onOpenDiff?: (leftPath: string, rightPath: string) => void;
28
+ onSendFeedback?: (tabId: string, feedbackPayload: FeedbackPayload) => void;
29
+ onOpenDiff?: (tabId: string, leftPath: string, rightPath: string) => void;
31
30
  }
32
31
  export declare class MynahUI {
33
32
  private readonly props;
34
33
  private readonly wrapper;
35
- private readonly sideNav;
34
+ private readonly tabsWrapper;
35
+ private readonly tabContentsWrapper;
36
36
  private readonly feedbackForm?;
37
- private readonly mainContainer;
38
- private readonly chatWrapper;
37
+ private readonly chatWrappers;
39
38
  private readonly config;
40
39
  constructor(props: MynahUIProps);
41
- private readonly sideNavigationTabChanged;
42
40
  private readonly addGlobalListeners;
43
- addChatAnswer: (answer: ChatItem) => void;
44
- getLastChatAnswer: () => ChatItem | undefined;
45
- updateLastChatAnswerStream: (updateWith: string | {
46
- title?: string;
41
+ addChatAnswer: (tabId: string, answer: ChatItem) => void;
42
+ getLastChatAnswer: (tabId: string) => ChatItem | undefined;
43
+ updateLastChatAnswerStream: (tabId: string, updateWith: string | {
44
+ title: string | boolean;
47
45
  suggestions: Suggestion[];
48
46
  }) => void;
49
- updateStore: (data: MynahUIDataModel) => void;
50
- getMode: () => MynahMode | undefined;
51
- setStoreDefaults: (defaults: MynahUIDataModel | null) => void;
52
- getSearchPayload: () => SearchPayload;
47
+ updateStore: (tabId: string | '', data: MynahUIDataModel) => string;
53
48
  showFeedbackForm: () => void;
54
49
  notify: (props: {
55
50
  duration?: number;