@aws/mynah-ui 2.0.0-beta.9.1 → 3.0.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 (43) hide show
  1. package/.eslintrc.js +48 -0
  2. package/README.md +53 -114
  3. package/dist/components/card/card-body.d.ts +36 -0
  4. package/dist/components/card/card.d.ts +32 -0
  5. package/dist/components/chat-item/chat-item-card.d.ts +8 -12
  6. package/dist/components/chat-item/chat-item-followup.d.ts +4 -0
  7. package/dist/components/chat-item/chat-item-source-links.d.ts +19 -0
  8. package/dist/components/chat-item/chat-item-tree-view-wrapper.d.ts +1 -0
  9. package/dist/components/chat-item/chat-prompt-input-command.d.ts +16 -0
  10. package/dist/components/chat-item/chat-prompt-input-info.d.ts +12 -0
  11. package/dist/components/chat-item/chat-prompt-input.d.ts +9 -5
  12. package/dist/components/chat-item/chat-wrapper.d.ts +5 -6
  13. package/dist/components/chat-item/prompt-input/code-snippet-widget.d.ts +14 -0
  14. package/dist/components/chat-item/prompt-input/code-snippet.d.ts +16 -0
  15. package/dist/components/chat-item/prompt-input/prompt-text-input.d.ts +21 -0
  16. package/dist/components/chat-item/prompt-input/send-button.d.ts +11 -0
  17. package/dist/components/navigation-tabs.d.ts +7 -1
  18. package/dist/components/{notification/notification.d.ts → notification.d.ts} +3 -3
  19. package/dist/components/{overlay/overlay.d.ts → overlay.d.ts} +1 -1
  20. package/dist/components/source-link/source-link-body.d.ts +16 -0
  21. package/dist/components/source-link/source-link-header.d.ts +20 -0
  22. package/dist/components/source-link/source-link.d.ts +15 -0
  23. package/dist/components/syntax-highlighter.d.ts +25 -22
  24. package/dist/components/toggle.d.ts +1 -0
  25. package/dist/helper/__test__/date-time.spec.d.ts +1 -0
  26. package/dist/helper/__test__/dom.spec.d.ts +1 -0
  27. package/dist/helper/__test__/events.spec.d.ts +1 -0
  28. package/dist/helper/__test__/file-tree.spec.d.ts +1 -0
  29. package/dist/helper/date-time.d.ts +8 -8
  30. package/dist/helper/file-tree.d.ts +3 -2
  31. package/dist/helper/store.d.ts +2 -2
  32. package/dist/helper/tabs-store.d.ts +8 -6
  33. package/dist/main.d.ts +14 -16
  34. package/dist/main.js +1 -1
  35. package/dist/main.js.LICENSE.txt +8 -0
  36. package/dist/main.js.map +1 -1
  37. package/dist/static.d.ts +44 -33
  38. package/jest.config.js +6 -0
  39. package/package.json +16 -10
  40. package/dist/components/suggestion-card/suggestion-card-body.d.ts +0 -23
  41. package/dist/components/suggestion-card/suggestion-card-header.d.ts +0 -18
  42. package/dist/components/suggestion-card/suggestion-card.d.ts +0 -22
  43. package/dist/components/suggestion-card/suggestion-skeleton.d.ts +0 -5
@@ -0,0 +1,20 @@
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
+ import { SourceLink } from '../../static';
7
+ export interface SourceLinkHeaderProps {
8
+ sourceLink: SourceLink;
9
+ showCardOnHover?: boolean;
10
+ onClick?: (e?: MouseEvent) => void;
11
+ }
12
+ export declare class SourceLinkHeader {
13
+ private sourceLinkPreview;
14
+ private sourceLinkPreviewTimeout;
15
+ render: ExtendedHTMLElement;
16
+ constructor(props: SourceLinkHeaderProps);
17
+ private readonly getSourceMetaBlock;
18
+ private readonly showLinkPreview;
19
+ private readonly hideLinkPreview;
20
+ }
@@ -0,0 +1,15 @@
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
+ import { SourceLink } from '../../static';
7
+ export interface SourceLinkCardProps {
8
+ sourceLink: SourceLink;
9
+ compact?: 'flat' | true;
10
+ }
11
+ export declare class SourceLinkCard {
12
+ private readonly sourceLink;
13
+ render: ExtendedHTMLElement;
14
+ constructor(props: SourceLinkCardProps);
15
+ }
@@ -3,13 +3,31 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { ExtendedHTMLElement } from '../helper/dom';
6
- import 'prismjs/components/prism-typescript';
7
- import 'prismjs/components/prism-python';
8
- import 'prismjs/components/prism-java';
9
- import 'prismjs/components/prism-javascript';
10
- import 'prismjs/components/prism-json';
6
+ import 'prismjs/components/prism-markup.min';
7
+ import 'prismjs/components/prism-xml-doc.min';
8
+ import 'prismjs/components/prism-css.min';
9
+ import 'prismjs/components/prism-clike.min';
10
+ import 'prismjs/components/prism-javascript.min';
11
+ import 'prismjs/components/prism-typescript.min';
12
+ import 'prismjs/components/prism-jsx.min';
13
+ import 'prismjs/components/prism-tsx.min';
14
+ import 'prismjs/components/prism-lua.min';
15
+ import 'prismjs/components/prism-java.min';
16
+ import 'prismjs/components/prism-json.min';
17
+ import 'prismjs/components/prism-markdown.min';
18
+ import 'prismjs/components/prism-mongodb.min';
19
+ import 'prismjs/components/prism-c.min';
20
+ import 'prismjs/components/prism-bash.min';
21
+ import 'prismjs/components/prism-csharp.min';
22
+ import 'prismjs/components/prism-objectivec.min';
23
+ import 'prismjs/components/prism-python.min';
24
+ import 'prismjs/components/prism-regex.min';
25
+ import 'prismjs/components/prism-scala.min';
26
+ import 'prismjs/components/prism-scss.min';
27
+ import 'prismjs/components/prism-less.min';
11
28
  import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
12
- import { OnCopiedToClipboardFunction, OnInsertToCursorPositionFunction, ReferenceTrackerInformation } from '../static';
29
+ import 'prismjs/plugins/keep-markup/prism-keep-markup.js';
30
+ import { OnCopiedToClipboardFunction, OnInsertToCursorPositionFunction } from '../static';
13
31
  export declare const highlighters: {
14
32
  start: {
15
33
  markup: string;
@@ -20,16 +38,6 @@ export declare const highlighters: {
20
38
  textReplacement: string;
21
39
  };
22
40
  };
23
- export declare const highlightersWithTooltip: {
24
- start: {
25
- markup: string;
26
- textReplacement: string;
27
- };
28
- end: {
29
- markup: string;
30
- textReplacement: string;
31
- };
32
- };
33
41
  export declare const ellipsis: {
34
42
  start: {
35
43
  markup: string;
@@ -48,20 +56,15 @@ export interface SyntaxHighlighterProps {
48
56
  block?: boolean;
49
57
  startingLineNumber?: number;
50
58
  showCopyOptions?: boolean;
51
- highlightRangeWithTooltip?: ReferenceTrackerInformation[];
52
59
  onCopiedToClipboard?: OnCopiedToClipboardFunction;
53
60
  onInsertToCursorPosition?: OnInsertToCursorPositionFunction;
54
61
  }
55
62
  export declare class SyntaxHighlighter {
56
63
  private readonly onCopiedToClipboard?;
57
64
  private readonly onInsertToCursorPosition?;
58
- private readonly highlightRangeWithTooltip;
59
- private highlightRangeTooltipTimeout;
60
- private highlightRangeTooltip;
61
65
  render: ExtendedHTMLElement;
62
66
  constructor(props: SyntaxHighlighterProps);
63
- private readonly showHighlightRangeTooltip;
64
- private readonly hideHighlightRangeTooltip;
67
+ private readonly getSelectedCodeContextMenu;
65
68
  private readonly getSelectedCode;
66
69
  private readonly copyToClipboard;
67
70
  }
@@ -33,6 +33,7 @@ export declare class Toggle {
33
33
  addOption: (option: ToggleOption) => void;
34
34
  removeOption: (value: string) => void;
35
35
  updateOptionTitle: (value: string, title: string) => void;
36
+ updateOptionIndicator: (value: string, indication: boolean) => void;
36
37
  snapToOption: (value: string) => void;
37
38
  getValue: () => string | undefined | null;
38
39
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -2,11 +2,11 @@
2
2
  * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- export declare const getTimeDiff: (differenceInMs: number, show?: 1 | 2 | 5 | 3 | 4 | 6 | {
6
- years?: boolean | undefined;
7
- months?: boolean | undefined;
8
- weeks?: boolean | undefined;
9
- days?: boolean | undefined;
10
- hours?: boolean | undefined;
11
- minutes?: boolean | undefined;
12
- } | undefined, separator?: string | undefined) => string;
5
+ export declare const getTimeDiff: (differenceInMs: number, show?: {
6
+ years?: boolean;
7
+ months?: boolean;
8
+ weeks?: boolean;
9
+ days?: boolean;
10
+ hours?: boolean;
11
+ minutes?: boolean;
12
+ } | 1 | 2 | 3 | 4 | 5 | 6, separator?: string) => string;
@@ -2,15 +2,16 @@
2
2
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- export declare type TreeNode = FolderNode | FileNode;
5
+ export type TreeNode = FolderNode | FileNode;
6
6
  export interface FileNode {
7
7
  name: string;
8
8
  type: 'file';
9
9
  filePath: string;
10
+ deleted: boolean;
10
11
  }
11
12
  export interface FolderNode {
12
13
  name: string;
13
14
  type: 'folder';
14
15
  children: Array<FolderNode | FileNode>;
15
16
  }
16
- export declare const fileListToTree: (filePaths: string[]) => TreeNode;
17
+ export declare const fileListToTree: (modifiedFilePaths: string[], deletedFilePaths?: string[]) => TreeNode;
@@ -8,7 +8,7 @@ export declare class EmptyMynahUIDataModel {
8
8
  constructor(defaults?: MynahUIDataModel | null);
9
9
  }
10
10
  export declare class MynahUIDataStore {
11
- private readonly subsciptions;
11
+ private readonly subscriptions;
12
12
  private readonly tabId;
13
13
  private store;
14
14
  private defaults;
@@ -19,6 +19,6 @@ export declare class MynahUIDataStore {
19
19
  unsubscribe: (storeKey: keyof MynahUIDataModel, subscriptionId: string) => void;
20
20
  getValue: (storeKey: keyof MynahUIDataModel) => any;
21
21
  getDefaultValue: (storeKey: keyof MynahUIDataModel) => any;
22
- updateStore: (data: MynahUIDataModel, skipSubscribers?: boolean | undefined) => void;
22
+ updateStore: (data: MynahUIDataModel, skipSubscribers?: boolean) => void;
23
23
  resetStore: () => void;
24
24
  }
@@ -3,6 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { MynahUIDataModel, MynahUITabStoreModel, MynahUITabStoreTab } from '../static';
6
+ import { MynahUIDataStore } from './store';
6
7
  interface TabStoreSubscription {
7
8
  'add': Record<string, (tabId: string, tabData?: MynahUITabStoreTab) => void>;
8
9
  'remove': Record<string, (tabId: string, newSelectedTab?: MynahUITabStoreTab) => void>;
@@ -15,26 +16,27 @@ export declare class EmptyMynahUITabsStoreModel {
15
16
  }
16
17
  export declare class MynahUITabsStore {
17
18
  private static instance;
18
- private readonly subsciptions;
19
+ private readonly subscriptions;
19
20
  private readonly tabDefaults;
20
21
  private readonly tabsStore;
21
22
  private readonly tabsDataStore;
22
23
  private constructor();
23
24
  private readonly deselectAllTabs;
24
- readonly addTab: (tabData?: MynahUITabStoreTab | undefined) => string;
25
+ readonly addTab: (tabData?: MynahUITabStoreTab) => string | undefined;
25
26
  readonly removeTab: (tabId: string) => string;
26
27
  readonly selectTab: (tabId: string) => void;
27
- updateTab: (tabId: string, tabData?: Partial<MynahUITabStoreTab> | undefined, skipSubscribers?: boolean | undefined) => void;
28
- static getInstance: (initialData?: MynahUITabStoreModel | undefined, defaults?: MynahUITabStoreTab | undefined) => MynahUITabsStore;
29
- addListener: (eventName: keyof TabStoreSubscription, handler: (tabId: string, tabData?: MynahUITabStoreTab | undefined) => void) => string;
28
+ updateTab: (tabId: string, tabData?: Partial<MynahUITabStoreTab>, skipSubscribers?: boolean) => void;
29
+ static getInstance: (initialData?: MynahUITabStoreModel, defaults?: MynahUITabStoreTab) => MynahUITabsStore;
30
+ addListener: (eventName: keyof TabStoreSubscription, handler: (tabId: string, tabData?: MynahUITabStoreTab) => void) => string;
30
31
  addListenerToDataStore: (tabId: string, storeKey: keyof MynahUIDataModel, handler: (newValue: any, oldValue?: any) => void) => string | null;
31
32
  removeListenerFromDataStore: (tabId: string, subscriptionId: string, storeKey: keyof MynahUIDataModel) => void;
32
33
  removeListener: (eventName: keyof TabStoreSubscription, subscriptionId: string) => void;
33
34
  private readonly informSubscribers;
34
35
  getTab: (tabId: string) => MynahUITabStoreTab | null;
35
36
  getAllTabs: () => MynahUITabStoreModel;
36
- getTabDataStore: (tabId: string) => any;
37
+ getTabDataStore: (tabId: string) => MynahUIDataStore;
37
38
  getSelectedTabId: () => string;
38
39
  removeAllTabs: () => void;
40
+ tabsLength: () => number;
39
41
  }
40
42
  export {};
package/dist/main.d.ts CHANGED
@@ -2,32 +2,33 @@
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, SuggestionEventName, RelevancyVoteType, FeedbackPayload, MynahUIDataModel, NotificationType, ChatItem, ChatItemFollowUp, ChatPrompt, MynahUITabStoreModel, MynahUITabStoreTab, ConfigModel, ReferenceTrackerInformation } from './static';
5
+ import { RelevancyVoteType, FeedbackPayload, MynahUIDataModel, NotificationType, ChatItem, ChatItemFollowUp, ChatPrompt, MynahUITabStoreModel, MynahUITabStoreTab, ConfigModel, ReferenceTrackerInformation, CodeSelectionType, Engagement } from './static';
6
6
  import './styles/styles.scss';
7
- export { FeedbackPayload, RelevancyVoteType, Suggestion, EngagementType, SuggestionEngagement, SuggestionEventName, MynahUIDataModel, NotificationType, ChatItem, ChatItemFollowUp, ChatItemType, ChatPrompt } from './static';
7
+ export { FeedbackPayload, RelevancyVoteType, EngagementType, Engagement, MynahUIDataModel, NotificationType, ChatItem, ChatItemFollowUp, ChatItemType, ChatPrompt, SourceLink } from './static';
8
8
  export { ToggleOption } from './components/toggle';
9
9
  export { MynahIcons } from './components/icon';
10
10
  export interface MynahUIProps {
11
11
  rootSelector?: string;
12
12
  defaults?: MynahUITabStoreTab;
13
13
  tabs?: MynahUITabStoreModel;
14
- config?: ConfigModel;
14
+ config?: Partial<ConfigModel>;
15
15
  onShowMoreWebResultsClick?: (tabId: string, messageId: string) => void;
16
16
  onReady?: () => void;
17
17
  onVote?: (tabId: string, messageId: string, vote: RelevancyVoteType) => void;
18
18
  onStopChatResponse?: (tabId: string) => void;
19
19
  onResetStore?: (tabId: string) => void;
20
20
  onChatPrompt?: (tabId: string, prompt: ChatPrompt) => void;
21
- onFollowUpClicked?: (tabId: string, followUp: ChatItemFollowUp) => void;
21
+ onFollowUpClicked?: (tabId: string, messageId: string, followUp: ChatItemFollowUp) => void;
22
22
  onTabChange?: (tabId: string) => void;
23
23
  onTabAdd?: (tabId: string) => void;
24
24
  onTabRemove?: (tabId: string) => void;
25
- onSuggestionEngagement?: (tabId: string, engagement: SuggestionEngagement) => void;
26
- onCopyCodeToClipboard?: (tabId: string, code?: string, type?: 'selection' | 'block', referenceTrackerInformation?: ReferenceTrackerInformation[]) => void;
27
- onCodeInsertToCursorPosition?: (tabId: string, code?: string, type?: 'selection' | 'block', referenceTrackerInformation?: ReferenceTrackerInformation[]) => void;
28
- onSuggestionInteraction?: (tabId: string, eventName: SuggestionEventName, suggestion: Suggestion, mouseEvent?: MouseEvent) => void;
25
+ onChatItemEngagement?: (tabId: string, messageId: string, engagement: Engagement) => void;
26
+ onCopyCodeToClipboard?: (tabId: string, messageId: string, code?: string, type?: CodeSelectionType, referenceTrackerInformation?: ReferenceTrackerInformation[]) => void;
27
+ onCodeInsertToCursorPosition?: (tabId: string, messageId: string, code?: string, type?: CodeSelectionType, referenceTrackerInformation?: ReferenceTrackerInformation[]) => void;
28
+ onSourceLinkClick?: (tabId: string, messageId: string, link: string, mouseEvent?: MouseEvent) => void;
29
+ onLinkClick?: (tabId: string, messageId: string, link: string, mouseEvent?: MouseEvent) => void;
29
30
  onSendFeedback?: (tabId: string, feedbackPayload: FeedbackPayload) => void;
30
- onOpenDiff?: (tabId: string, leftPath: string, rightPath: string, messageId?: string) => void;
31
+ onOpenDiff?: (tabId: string, filePath: string, deleted: boolean, messageId?: string) => void;
31
32
  }
32
33
  export declare class MynahUI {
33
34
  private readonly props;
@@ -38,13 +39,10 @@ export declare class MynahUI {
38
39
  private readonly chatWrappers;
39
40
  constructor(props: MynahUIProps);
40
41
  private readonly addGlobalListeners;
41
- addChatAnswer: (tabId: string, answer: ChatItem) => void;
42
- getLastChatAnswer: (tabId: string) => ChatItem | undefined;
43
- updateLastChatAnswerStream: (tabId: string, updateWith: string | {
44
- title: string | boolean;
45
- suggestions: Suggestion[];
46
- }) => void;
47
- updateStore: (tabId: string | '', data: MynahUIDataModel) => string;
42
+ addToUserPrompt: (tabId: string, prompt: string) => void;
43
+ addChatItem: (tabId: string, chatItem: ChatItem) => void;
44
+ updateLastChatAnswer: (tabId: string, updateWith: Partial<ChatItem>) => void;
45
+ updateStore: (tabId: string | '', data: MynahUIDataModel) => string | undefined;
48
46
  notify: (props: {
49
47
  duration?: number;
50
48
  type?: NotificationType;