@aws/mynah-ui 1.1.0 → 1.1.2
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/README.md +103 -23
- 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 +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mynah UI
|
|
2
2
|
|
|
3
|
-
This package is the whole UI of AWS Tookit Mynah extension UI for VSCode and Intellij IDEs written in typescript without
|
|
3
|
+
This package is the whole UI of AWS Tookit Mynah extension UI for VSCode and Intellij IDEs written in typescript without any framework or third-party UI library dependency. Purpose of the separated UI is to handle the interactions and look & feel of the UI from one single source.
|
|
4
4
|
|
|
5
5
|
## How to install
|
|
6
6
|
|
|
@@ -9,39 +9,112 @@ npm install @aws/mynah-ui
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## How to use
|
|
12
|
-
When you import `@aws/mynah-ui` it provides you the `MynahUI` class to generate a new all-in-one object to create the UI.
|
|
12
|
+
When you import `@aws/mynah-ui` it provides you the `MynahUI` class to generate a new all-in-one object to create the UI. You can connect to user interaction events through the initial properties have provide to the UI.
|
|
13
13
|
|
|
14
14
|
``` typescript
|
|
15
15
|
import { MynahUI } from '@aws/mynah-ui';
|
|
16
16
|
|
|
17
17
|
export const createMynahUI = () => {
|
|
18
|
-
new MynahUI({
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const mynahUI = new MynahUI({
|
|
19
|
+
// initial UI state data
|
|
20
|
+
// It doesn't have to be matched with backend data
|
|
21
|
+
// but to update the UI and rerender its desired parts,
|
|
22
|
+
// it expects the data in this model.
|
|
23
|
+
storeData?: MynahUIDataModel;
|
|
24
|
+
|
|
25
|
+
// All below items trigger when;
|
|
26
|
+
// User hits search button or enter inside query input
|
|
27
|
+
onSearch?: (
|
|
28
|
+
searchPayload: SearchPayload,
|
|
29
|
+
isFromHistory?: boolean,
|
|
30
|
+
isFromAutocomplete?: boolean
|
|
31
|
+
) => void;
|
|
32
|
+
|
|
33
|
+
// UI is ready
|
|
34
|
+
onReady?: () => void;
|
|
35
|
+
|
|
36
|
+
// User votes a suggestion
|
|
37
|
+
onClickSuggestionVote?: (suggestion: Suggestion, vote: RelevancyVoteType) => void;
|
|
38
|
+
// User opens the detail view of selected code block
|
|
39
|
+
onClickCodeDetails?: (
|
|
40
|
+
code: string,
|
|
41
|
+
fileName?: string,
|
|
42
|
+
range?: {
|
|
43
|
+
start: { row: string; column?: string };
|
|
44
|
+
end?: { row: string; column?: string };
|
|
24
45
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
) => void;
|
|
47
|
+
|
|
48
|
+
// Data store is reset
|
|
49
|
+
onResetStore?: () => void;
|
|
50
|
+
|
|
51
|
+
// Matching policy is changed (context items)
|
|
52
|
+
onChangeContext?: (changeType: ContextChangeType, queryContext: ContextType) => void;
|
|
53
|
+
|
|
54
|
+
// User engages with a suggestion
|
|
55
|
+
onSuggestionEngagement?: (engagement: SuggestionEngagement) => void;
|
|
56
|
+
|
|
57
|
+
// User copies text from suggestion
|
|
58
|
+
onSuggestionClipboardInteraction?: (suggestionId: string, type?: string, text?: string) => void;
|
|
59
|
+
|
|
60
|
+
// User clicks to the title, clicks or copies the link of the suggestion
|
|
61
|
+
onSuggestionInteraction?: (eventName: SuggestionEventName, suggestion: Suggestion) => void;
|
|
62
|
+
|
|
63
|
+
// User sends feedback
|
|
64
|
+
onSendFeedback?: (feedbackPayload: FeedbackPayload) => void;
|
|
65
|
+
|
|
66
|
+
// Search history panel view opens
|
|
67
|
+
onRequestHistoryRecords?: (filterPayload: SearchHistoryFilters) => void;
|
|
68
|
+
|
|
69
|
+
// Autocomplete items list block opens
|
|
70
|
+
onRequestAutocompleteList?: (input: string) => void;
|
|
71
|
+
|
|
72
|
+
// User changes live search state
|
|
73
|
+
onChangeLiveSearchState?: (liveSearchState: LiveSearchState) => void;
|
|
74
|
+
|
|
75
|
+
// User selects and autocomplete item
|
|
76
|
+
onClickAutocompleteItem?: (
|
|
77
|
+
text: string,
|
|
78
|
+
currSelected?: number,
|
|
79
|
+
suggestionCount?: number
|
|
80
|
+
) => void;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
MynahUI also provides some accessible functions to help developer show a notification or more importantly update the UI state data store. When you update the data store, it will automatically rerender the parts that is subscribed to that particular data part.
|
|
86
|
+
|
|
87
|
+
``` typescript
|
|
88
|
+
import { MynahUI } from '@aws/mynah-ui';
|
|
89
|
+
|
|
90
|
+
export const createMynahUI = () => {
|
|
91
|
+
let mynahUI:MynahUI;
|
|
92
|
+
const getSuggestions = (searchPayload) => {
|
|
93
|
+
mynahUI.updateStore({loading: true});
|
|
94
|
+
// get suggestions list
|
|
95
|
+
const suggestions = await getSuggestions(searchPayload);
|
|
96
|
+
if(suggestions){
|
|
97
|
+
mynahUI.updateStore({suggestions, loading: false});
|
|
98
|
+
} else {
|
|
99
|
+
mynahUI.updateStore({loading: false});
|
|
100
|
+
mynahUI.notify({
|
|
101
|
+
content: "Couldn't get suggestions!",
|
|
102
|
+
type: NotificationType.ERROR,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
const mynahUI = new MynahUI({
|
|
108
|
+
...,
|
|
109
|
+
onSearch: getSuggestions
|
|
37
110
|
});
|
|
38
111
|
}
|
|
39
112
|
```
|
|
40
113
|
|
|
41
|
-
In addition to MynahUI class, there are also some exported type definitions that
|
|
114
|
+
In addition to MynahUI class, there are also some exported type definitions that can be handy for function returns or proper usage of arguments.
|
|
42
115
|
|
|
43
116
|
``` typescript
|
|
44
|
-
|
|
117
|
+
import {
|
|
45
118
|
AutocompleteItem,
|
|
46
119
|
SearchPayloadCodeSelection,
|
|
47
120
|
FeedbackPayload,
|
|
@@ -53,7 +126,14 @@ export {
|
|
|
53
126
|
SearchHistoryItem,
|
|
54
127
|
EngagementType,
|
|
55
128
|
SuggestionEngagement,
|
|
56
|
-
|
|
129
|
+
SuggestionEventName,
|
|
130
|
+
SearchHistoryFilters,
|
|
131
|
+
MynahUIDataModel,
|
|
132
|
+
ContextChangeType,
|
|
133
|
+
ContextSource,
|
|
134
|
+
ContextTypes,
|
|
135
|
+
NotificationType,
|
|
136
|
+
} from '@aws/mynah-ui';
|
|
57
137
|
```
|
|
58
138
|
|
|
59
139
|
## Styles
|
package/dist/main.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface MynahUIProps {
|
|
|
20
20
|
column?: string;
|
|
21
21
|
};
|
|
22
22
|
}) => void;
|
|
23
|
+
onResetStore?: () => void;
|
|
23
24
|
onChangeContext?: (changeType: ContextChangeType, queryContext: ContextType) => void;
|
|
24
25
|
onSuggestionEngagement?: (engagement: SuggestionEngagement) => void;
|
|
25
26
|
onSuggestionClipboardInteraction?: (suggestionId: string, type?: string, text?: string) => void;
|