@aws/mynah-ui 1.1.12 → 1.2.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ export const createMynahUI = () => {
19
19
  // initial UI state data
20
20
  // It doesn't have to be matched with backend data
21
21
  // but to update the UI and rerender its desired parts,
22
- // it expects the data in this model.
22
+ // it expects the data in type of MynahUIDataModel.
23
23
  storeData?: MynahUIDataModel;
24
24
 
25
25
  // All below items trigger when;
@@ -51,6 +51,9 @@ export const createMynahUI = () => {
51
51
  // Matching policy is changed (context items)
52
52
  onChangeContext?: (changeType: ContextChangeType, queryContext: ContextType) => void;
53
53
 
54
+ // When navigation tab is changed
55
+ onNavigationTabChange?: (selectedTab: string) => void;
56
+
54
57
  // User engages with a suggestion
55
58
  onSuggestionEngagement?: (engagement: SuggestionEngagement) => void;
56
59
 
@@ -108,6 +111,18 @@ export const createMynahUI = () => {
108
111
  ...,
109
112
  onSearch: getSuggestions
110
113
  });
114
+
115
+ // to update the store fully or partially
116
+ mynahUI.updateStore(...);
117
+
118
+ // set default values for the UI data store fully or partially
119
+ mynahUI.setStoreDefaults(...);
120
+
121
+ // get current search payload
122
+ mynahUI.getSearchPayload();
123
+
124
+ // Show a notification balloon
125
+ mynahUI.notify(...);
111
126
  }
112
127
  ```
113
128
 
@@ -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
+ export interface NavivationTabsProps {
7
+ onChange?: (selectedValue: string) => void;
8
+ }
9
+ export declare class NavivationTabs {
10
+ render: ExtendedHTMLElement;
11
+ private readonly props;
12
+ constructor(props: NavivationTabsProps);
13
+ private readonly setLoading;
14
+ private readonly getTabsRender;
15
+ }
@@ -6,11 +6,13 @@ import { ExtendedHTMLElement } from '../helper/dom';
6
6
  export interface ToggleOption {
7
7
  label?: ExtendedHTMLElement | string | HTMLElement;
8
8
  color?: string;
9
+ disabled?: boolean;
9
10
  value: string;
10
11
  }
11
12
  export interface ToggleProps {
12
13
  options: ToggleOption[];
13
- value?: string;
14
+ type?: 'switch' | 'tabs';
15
+ value?: string | null;
14
16
  name: string;
15
17
  disabled?: boolean;
16
18
  onChange?: (selectedValue: string) => void;
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { SearchPayload } from '../static';
6
+ export interface PayloadTransformRule {
7
+ targetRoute: string[];
8
+ method: 'add' | 'remove' | 'set';
9
+ value?: any;
10
+ values?: any[];
11
+ }
12
+ export declare const transformPayloadData: (rules: PayloadTransformRule[], payloadData: SearchPayload) => SearchPayload;
13
+ export declare const validateRulesOnPayloadData: (rules: PayloadTransformRule[], payloadData: SearchPayload) => boolean;
@@ -19,6 +19,10 @@ export declare class MynahUIDataStore {
19
19
  * @param defaults partial set of MynahUIDataModel for defaults
20
20
  */
21
21
  setDefaults: (defaults: MynahUIDataModel | null) => void;
22
+ /**
23
+ * Get the defaults to use while generating an empty store data
24
+ */
25
+ getDefaults: () => MynahUIDataModel | null;
22
26
  /**
23
27
  * Subscribe to value changes of a specific item in data store
24
28
  * @param storeKey One of the keys in MynahUIDataModel
@@ -48,7 +52,7 @@ export declare class MynahUIDataStore {
48
52
  * Updates the store and informs the subscribers.
49
53
  * @param data A full or partial set of store data model with values.
50
54
  */
51
- updateStore: (data: MynahUIDataModel) => void;
55
+ updateStore: (data: MynahUIDataModel, skipSubscribers?: boolean | undefined) => void;
52
56
  /**
53
57
  * Clears store data and informs all the subscribers
54
58
  */
package/dist/main.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  import { SuggestionEngagement, Suggestion, SearchPayload, LiveSearchState, SuggestionEventName, RelevancyVoteType, FeedbackPayload, MynahUIDataModel, ContextChangeType, ContextType, SearchHistoryFilters, NotificationType } from './static';
6
6
  import './styles/styles.scss';
7
7
  export { AutocompleteItem, SearchPayloadCodeSelection, FeedbackPayload, RelevancyVoteType, LiveSearchState, SearchPayload, Suggestion, ContextType, SearchHistoryItem, EngagementType, SuggestionEngagement, SuggestionEventName, SearchHistoryFilters, MynahUIDataModel, ContextChangeType, ContextSource, ContextTypes, NotificationType, } from './static';
8
+ export { transformPayloadData, validateRulesOnPayloadData, PayloadTransformRule, } from './helper/payload-transformer';
8
9
  export interface MynahUIProps {
9
10
  rootSelector?: string;
10
11
  storeData?: MynahUIDataModel;
@@ -23,12 +24,13 @@ export interface MynahUIProps {
23
24
  }) => void;
24
25
  onResetStore?: () => void;
25
26
  onChangeContext?: (changeType: ContextChangeType, queryContext: ContextType) => void;
27
+ onNavigationTabChange?: (selectedTab: string) => void;
26
28
  onSuggestionEngagement?: (engagement: SuggestionEngagement) => void;
27
29
  onSuggestionClipboardInteraction?: (suggestionId: string, type?: string, text?: string) => void;
28
30
  onSuggestionInteraction?: (eventName: SuggestionEventName, suggestion: Suggestion, mouseEvent?: MouseEvent) => void;
29
31
  onSendFeedback?: (feedbackPayload: FeedbackPayload) => void;
30
32
  onRequestHistoryRecords?: (filterPayload: SearchHistoryFilters) => void;
31
- onRequestAutocompleteList?: (input: string) => void;
33
+ onInputQueryChange?: (input: string) => void;
32
34
  onChangeLiveSearchState?: (liveSearchState: LiveSearchState) => void;
33
35
  onClickAutocompleteItem?: (text: string, currSelected?: number, suggestionCount?: number) => void;
34
36
  }
@@ -36,6 +38,7 @@ export declare class MynahUI {
36
38
  private readonly props;
37
39
  private readonly wrapper;
38
40
  private readonly searchCard;
41
+ private readonly navTabs;
39
42
  private readonly mainContainer;
40
43
  private readonly config;
41
44
  constructor(props: MynahUIProps);
@@ -51,6 +54,10 @@ export declare class MynahUI {
51
54
  * @param defaults partial set of MynahUIDataModel for defaults
52
55
  */
53
56
  setStoreDefaults: (defaults: MynahUIDataModel | null) => void;
57
+ /**
58
+ * Returns the current search payload
59
+ */
60
+ getSearchPayload: () => SearchPayload;
54
61
  /**
55
62
  * Simply creates and shows a notification
56
63
  * @param props NotificationProps