@aws/mynah-ui 1.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.
- package/CODE_OF_CONDUCT.md +4 -0
- package/CONTRIBUTING.md +59 -0
- package/LICENSE +175 -0
- package/NOTICE +1 -0
- package/README.md +187 -0
- package/THIRD-PARTY-LICENSES +27 -0
- package/dist/components/button.d.ts +20 -0
- package/dist/components/context-item.d.ts +16 -0
- package/dist/components/feedback-form/feedback-form-comment.d.ts +15 -0
- package/dist/components/feedback-form/feedback-form-stars.d.ts +15 -0
- package/dist/components/feedback-form/feedback-form.d.ts +22 -0
- package/dist/components/icon.d.ts +51 -0
- package/dist/components/main-container.d.ts +29 -0
- package/dist/components/notification/notification.d.ts +48 -0
- package/dist/components/overlay/overlay.d.ts +82 -0
- package/dist/components/prioritization-menu.d.ts +18 -0
- package/dist/components/search-block/autocomplete-card.d.ts +20 -0
- package/dist/components/search-block/autocomplete-content.d.ts +33 -0
- package/dist/components/search-block/search-api-help.d.ts +38 -0
- package/dist/components/search-block/search-card-header.d.ts +14 -0
- package/dist/components/search-block/search-card.d.ts +74 -0
- package/dist/components/search-block/search-context.d.ts +31 -0
- package/dist/components/search-block/search-history-card.d.ts +16 -0
- package/dist/components/search-block/search-history-content.d.ts +20 -0
- package/dist/components/search-block/search-input.d.ts +36 -0
- package/dist/components/search-block/search-live-toggle.d.ts +18 -0
- package/dist/components/suggestion-card/suggestion-card-body.d.ts +15 -0
- package/dist/components/suggestion-card/suggestion-card-context-wrapper.d.ts +12 -0
- package/dist/components/suggestion-card/suggestion-card-header.d.ts +19 -0
- package/dist/components/suggestion-card/suggestion-card-relevance-vote.d.ts +16 -0
- package/dist/components/suggestion-card/suggestion-card.d.ts +27 -0
- package/dist/components/syntax-highlighter.d.ts +38 -0
- package/dist/components/toggle.d.ts +27 -0
- package/dist/helper/config.d.ts +15 -0
- package/dist/helper/context-manager.d.ts +34 -0
- package/dist/helper/date-time.d.ts +12 -0
- package/dist/helper/dom.d.ts +52 -0
- package/dist/helper/find-language.d.ts +17 -0
- package/dist/helper/guid.d.ts +5 -0
- package/dist/main.d.ts +26 -0
- package/dist/main.js +3 -0
- package/dist/main.js.LICENSE.txt +13 -0
- package/dist/main.js.map +1 -0
- package/dist/static.d.ts +276 -0
- package/dist/translations/en.d.ts +9 -0
- package/dist/translations/i18n.d.ts +13 -0
- package/package.json +62 -0
|
@@ -0,0 +1,34 @@
|
|
|
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 './dom';
|
|
6
|
+
import { ContextSource, ContextTypes, ContextType, SearchPayloadMatchPolicy } from '../static';
|
|
7
|
+
export interface ContextCheckboxProps {
|
|
8
|
+
context: ContextType;
|
|
9
|
+
}
|
|
10
|
+
export declare class ContextCheckbox {
|
|
11
|
+
render: ExtendedHTMLElement[];
|
|
12
|
+
constructor(props: ContextCheckboxProps);
|
|
13
|
+
}
|
|
14
|
+
export declare const ContextTypePriorityMap: string[];
|
|
15
|
+
export declare const EmptyContextObject: {
|
|
16
|
+
context: string;
|
|
17
|
+
visible: boolean;
|
|
18
|
+
availableInSuggestion: boolean;
|
|
19
|
+
type: ContextTypes;
|
|
20
|
+
source: ContextSource;
|
|
21
|
+
};
|
|
22
|
+
export declare class ContextManager {
|
|
23
|
+
private static instance;
|
|
24
|
+
contextMap: Record<string, ContextType>;
|
|
25
|
+
private contextCheckboxes;
|
|
26
|
+
static getInstance(): ContextManager;
|
|
27
|
+
removeAll: () => void;
|
|
28
|
+
clear: () => void;
|
|
29
|
+
areContextItemsIdentical: (context: ContextType, contextToCompare: ContextType) => boolean;
|
|
30
|
+
addOrUpdateContext: (context: ContextType, dispatchEvent?: boolean) => ContextType;
|
|
31
|
+
removeContext: (contextKey: string) => void;
|
|
32
|
+
getContextObjectFromKey: (contextKey: string) => ContextType;
|
|
33
|
+
getContextMatchPolicy: () => SearchPayloadMatchPolicy;
|
|
34
|
+
}
|
|
@@ -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
|
+
export declare const getTimeDiff: (differenceInMs: number, show?: 1 | 2 | 3 | 4 | 5 | 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;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export declare const DS: typeof document.querySelectorAll;
|
|
6
|
+
export interface DomBuilderObject {
|
|
7
|
+
type: string;
|
|
8
|
+
attributes?: Record<string, string> | undefined;
|
|
9
|
+
classNames?: string[] | undefined;
|
|
10
|
+
events?: Record<string, (event?: any) => any> | undefined;
|
|
11
|
+
children?: Array<string | DomBuilderObject | HTMLElement | ExtendedHTMLElement> | undefined;
|
|
12
|
+
innerHTML?: string | undefined;
|
|
13
|
+
persistent?: boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface DomBuilderObjectFilled {
|
|
16
|
+
attributes?: Record<string, string | undefined>;
|
|
17
|
+
classNames?: string[];
|
|
18
|
+
events?: Record<string, (event?: any) => any>;
|
|
19
|
+
children?: Array<string | DomBuilderObject | HTMLElement | ExtendedHTMLElement>;
|
|
20
|
+
innerHTML?: string | undefined;
|
|
21
|
+
persistent?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ExtendedHTMLElement extends HTMLInputElement {
|
|
24
|
+
addClass(className: string): ExtendedHTMLElement;
|
|
25
|
+
removeClass(className: string): ExtendedHTMLElement;
|
|
26
|
+
toggleClass(className: string): ExtendedHTMLElement;
|
|
27
|
+
hasClass(className: string): boolean;
|
|
28
|
+
insertChild(position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', child: string | DomBuilderObject | HTMLElement | ExtendedHTMLElement | Array<string | DomBuilderObject | HTMLElement | ExtendedHTMLElement>): ExtendedHTMLElement;
|
|
29
|
+
clear(removePersistent?: boolean): ExtendedHTMLElement;
|
|
30
|
+
builderObject: DomBuilderObject;
|
|
31
|
+
update(builderObject: DomBuilderObjectFilled): ExtendedHTMLElement;
|
|
32
|
+
}
|
|
33
|
+
export declare class DomBuilder {
|
|
34
|
+
private static instance;
|
|
35
|
+
root: ExtendedHTMLElement;
|
|
36
|
+
private portals;
|
|
37
|
+
private constructor();
|
|
38
|
+
static getInstance(rootSelector?: string): DomBuilder;
|
|
39
|
+
addClass: (this: ExtendedHTMLElement, className: string) => ExtendedHTMLElement;
|
|
40
|
+
removeClass: (this: ExtendedHTMLElement, className: string) => ExtendedHTMLElement;
|
|
41
|
+
toggleClass: (this: ExtendedHTMLElement, className: string) => ExtendedHTMLElement;
|
|
42
|
+
hasClass: (this: ExtendedHTMLElement, className: string) => boolean;
|
|
43
|
+
insertChild: (this: ExtendedHTMLElement, position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend', child: string | HTMLElement | ExtendedHTMLElement | Array<string | HTMLElement | ExtendedHTMLElement>) => ExtendedHTMLElement;
|
|
44
|
+
clearChildren: (this: ExtendedHTMLElement, removePersistent: boolean) => ExtendedHTMLElement;
|
|
45
|
+
extendDomFunctionality: (this: DomBuilder, domElement: HTMLElement) => ExtendedHTMLElement;
|
|
46
|
+
build: (domBuilderObject: DomBuilderObject) => ExtendedHTMLElement;
|
|
47
|
+
update: (domToUpdate: ExtendedHTMLElement, domBuilderObject: DomBuilderObjectFilled) => ExtendedHTMLElement;
|
|
48
|
+
createPortal: (portalName: string, builderObject: DomBuilderObject, position: 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend') => ExtendedHTMLElement;
|
|
49
|
+
getPortal: (portalName: string) => ExtendedHTMLElement;
|
|
50
|
+
removePortal: (portalName: string) => void;
|
|
51
|
+
}
|
|
52
|
+
export declare const cancelEvent: (event: Event) => boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { Suggestion } from '../static';
|
|
6
|
+
/**
|
|
7
|
+
* Finds the coding language if there is a match witnin the supported languages from context or body or from the title
|
|
8
|
+
* @param suggestion SuggestionType
|
|
9
|
+
* @returns string | undefined
|
|
10
|
+
*/
|
|
11
|
+
export declare const findLanguageFromSuggestion: (suggestion: Suggestion) => string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Finds the coding language if there is a match within the supported languages from the given file name
|
|
14
|
+
* @param fileName string
|
|
15
|
+
* @returns string | undefined
|
|
16
|
+
*/
|
|
17
|
+
export declare const getLanguageFromFileName: (fileName: string) => string | undefined;
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { SearchPayload, ServiceConnector, StateManager } from './static';
|
|
6
|
+
import './styles/styles.scss';
|
|
7
|
+
export { AutocompleteItem, SearchPayloadCodeSelection, FeedbackPayload, RelevancyVoteType, LiveSearchState, SearchPayload, Suggestion, ContextType, SearchHistoryItem, EngagementType, SuggestionEngagement, } from './static';
|
|
8
|
+
export interface MynahUIProps {
|
|
9
|
+
serviceConnector: ServiceConnector;
|
|
10
|
+
stateManager: StateManager;
|
|
11
|
+
}
|
|
12
|
+
export declare class MynahUI {
|
|
13
|
+
private readonly wrapper;
|
|
14
|
+
private readonly searchCard;
|
|
15
|
+
private readonly mainContainer;
|
|
16
|
+
private readonly config;
|
|
17
|
+
private readonly connector;
|
|
18
|
+
constructor(props: MynahUIProps);
|
|
19
|
+
updateSearchPayload: (searchPayload: SearchPayload) => void;
|
|
20
|
+
private readonly handleLiveSearchExternalCommand;
|
|
21
|
+
private readonly handlePayloadChange;
|
|
22
|
+
private readonly handleLiveSearch;
|
|
23
|
+
private readonly handleContentUpdate;
|
|
24
|
+
handleSearch: (payload: SearchPayload, isFromAutocomplete: boolean, currAutocompleteSuggestionSelected?: number | undefined, autocompleteSuggestionsCount?: number | undefined) => void;
|
|
25
|
+
private readonly recordContextChange;
|
|
26
|
+
}
|