@constructor-io/constructorio-ui-asa 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/LICENSE +21 -0
- package/README.md +253 -0
- package/dist/constructorio-ui-asa-bundled.js +33 -0
- package/lib/cjs/components/Button/Button.css +61 -0
- package/lib/cjs/components/Button/Button.js +12 -0
- package/lib/cjs/components/Chat/AiMessage.css +35 -0
- package/lib/cjs/components/Chat/AiMessage.js +34 -0
- package/lib/cjs/components/Chat/Chat.css +103 -0
- package/lib/cjs/components/Chat/Chat.js +34 -0
- package/lib/cjs/components/Chat/ChatHeader.css +41 -0
- package/lib/cjs/components/Chat/ChatHeader.js +18 -0
- package/lib/cjs/components/Chat/ChatInput.css +83 -0
- package/lib/cjs/components/Chat/ChatInput.js +30 -0
- package/lib/cjs/components/Chat/ChatMessageList.css +23 -0
- package/lib/cjs/components/Chat/ChatMessageList.js +46 -0
- package/lib/cjs/components/Chat/TypingIndicator.css +51 -0
- package/lib/cjs/components/Chat/TypingIndicator.js +14 -0
- package/lib/cjs/components/Chat/UserMessage.css +25 -0
- package/lib/cjs/components/Chat/UserMessage.js +14 -0
- package/lib/cjs/components/Chat/WelcomeScreen.css +205 -0
- package/lib/cjs/components/Chat/WelcomeScreen.js +43 -0
- package/lib/cjs/components/CioAsaProvider/CioAsaProvider.js +23 -0
- package/lib/cjs/components/ResultsBlock/ResultsBlock.css +217 -0
- package/lib/cjs/components/ResultsBlock/ResultsBlock.js +73 -0
- package/lib/cjs/components/ResultsBlock/constants.js +11 -0
- package/lib/cjs/components/ResultsBlock/renderProductCard.js +21 -0
- package/lib/cjs/components/icons/ArrowRightIcon.js +9 -0
- package/lib/cjs/components/icons/ChatBubbleDarkIcon.js +9 -0
- package/lib/cjs/components/icons/ChatBubbleLightIcon.js +9 -0
- package/lib/cjs/components/icons/SendArrowIcon.js +9 -0
- package/lib/cjs/components/icons/SendPlaneIcon.js +9 -0
- package/lib/cjs/components/icons/index.js +16 -0
- package/lib/cjs/constants.js +6 -0
- package/lib/cjs/hooks/asaStreamHandlers.js +34 -0
- package/lib/cjs/hooks/useAsaResults.js +120 -0
- package/lib/cjs/hooks/useCioAsaContext.js +15 -0
- package/lib/cjs/hooks/useCioClient.js +21 -0
- package/lib/cjs/hooks/useFocusTrap.js +38 -0
- package/lib/cjs/hooks/useMessageInput.js +22 -0
- package/lib/cjs/hooks/useRequestConfigs.js +27 -0
- package/lib/cjs/index.js +24 -0
- package/lib/cjs/styles.css +34 -0
- package/lib/cjs/types.js +6 -0
- package/lib/cjs/utils/formatters.js +11 -0
- package/lib/cjs/utils/productNormalizer.js +20 -0
- package/lib/cjs/utils/translate.js +30 -0
- package/lib/cjs/utils/typeHelpers.js +2 -0
- package/lib/cjs/utils/urlHelpers.js +102 -0
- package/lib/cjs/version.js +3 -0
- package/lib/mjs/components/Button/Button.css +61 -0
- package/lib/mjs/components/Button/Button.js +8 -0
- package/lib/mjs/components/Chat/AiMessage.css +35 -0
- package/lib/mjs/components/Chat/AiMessage.js +29 -0
- package/lib/mjs/components/Chat/Chat.css +103 -0
- package/lib/mjs/components/Chat/Chat.js +31 -0
- package/lib/mjs/components/Chat/ChatHeader.css +41 -0
- package/lib/mjs/components/Chat/ChatHeader.js +14 -0
- package/lib/mjs/components/Chat/ChatInput.css +83 -0
- package/lib/mjs/components/Chat/ChatInput.js +26 -0
- package/lib/mjs/components/Chat/ChatMessageList.css +23 -0
- package/lib/mjs/components/Chat/ChatMessageList.js +41 -0
- package/lib/mjs/components/Chat/TypingIndicator.css +51 -0
- package/lib/mjs/components/Chat/TypingIndicator.js +10 -0
- package/lib/mjs/components/Chat/UserMessage.css +25 -0
- package/lib/mjs/components/Chat/UserMessage.js +10 -0
- package/lib/mjs/components/Chat/WelcomeScreen.css +205 -0
- package/lib/mjs/components/Chat/WelcomeScreen.js +38 -0
- package/lib/mjs/components/CioAsaProvider/CioAsaProvider.js +19 -0
- package/lib/mjs/components/ResultsBlock/ResultsBlock.css +217 -0
- package/lib/mjs/components/ResultsBlock/ResultsBlock.js +76 -0
- package/lib/mjs/components/ResultsBlock/constants.js +8 -0
- package/lib/mjs/components/ResultsBlock/renderProductCard.js +17 -0
- package/lib/mjs/components/icons/ArrowRightIcon.js +5 -0
- package/lib/mjs/components/icons/ChatBubbleDarkIcon.js +5 -0
- package/lib/mjs/components/icons/ChatBubbleLightIcon.js +5 -0
- package/lib/mjs/components/icons/SendArrowIcon.js +5 -0
- package/lib/mjs/components/icons/SendPlaneIcon.js +5 -0
- package/lib/mjs/components/icons/index.js +5 -0
- package/lib/mjs/constants.js +3 -0
- package/lib/mjs/hooks/asaStreamHandlers.js +39 -0
- package/lib/mjs/hooks/useAsaResults.js +118 -0
- package/lib/mjs/hooks/useCioAsaContext.js +11 -0
- package/lib/mjs/hooks/useCioClient.js +23 -0
- package/lib/mjs/hooks/useFocusTrap.js +35 -0
- package/lib/mjs/hooks/useMessageInput.js +19 -0
- package/lib/mjs/hooks/useRequestConfigs.js +24 -0
- package/lib/mjs/index.js +11 -0
- package/lib/mjs/styles.css +34 -0
- package/lib/mjs/types.js +2 -0
- package/lib/mjs/utils/formatters.js +7 -0
- package/lib/mjs/utils/productNormalizer.js +15 -0
- package/lib/mjs/utils/translate.js +26 -0
- package/lib/mjs/utils/typeHelpers.js +1 -0
- package/lib/mjs/utils/urlHelpers.js +90 -0
- package/lib/mjs/version.js +1 -0
- package/lib/types/components/Button/Button.d.ts +12 -0
- package/lib/types/components/Chat/AiMessage.d.ts +12 -0
- package/lib/types/components/Chat/Chat.d.ts +38 -0
- package/lib/types/components/Chat/ChatHeader.d.ts +12 -0
- package/lib/types/components/Chat/ChatInput.d.ts +13 -0
- package/lib/types/components/Chat/ChatMessageList.d.ts +24 -0
- package/lib/types/components/Chat/TypingIndicator.d.ts +10 -0
- package/lib/types/components/Chat/UserMessage.d.ts +12 -0
- package/lib/types/components/Chat/WelcomeScreen.d.ts +16 -0
- package/lib/types/components/CioAsaProvider/CioAsaProvider.d.ts +3 -0
- package/lib/types/components/ResultsBlock/ResultsBlock.d.ts +32 -0
- package/lib/types/components/ResultsBlock/constants.d.ts +3 -0
- package/lib/types/components/ResultsBlock/renderProductCard.d.ts +12 -0
- package/lib/types/components/icons/ArrowRightIcon.d.ts +2 -0
- package/lib/types/components/icons/ChatBubbleDarkIcon.d.ts +2 -0
- package/lib/types/components/icons/ChatBubbleLightIcon.d.ts +2 -0
- package/lib/types/components/icons/SendArrowIcon.d.ts +2 -0
- package/lib/types/components/icons/SendPlaneIcon.d.ts +2 -0
- package/lib/types/components/icons/index.d.ts +5 -0
- package/lib/types/constants.d.ts +2 -0
- package/lib/types/hooks/asaStreamHandlers.d.ts +8 -0
- package/lib/types/hooks/useAsaResults.d.ts +2 -0
- package/lib/types/hooks/useCioAsaContext.d.ts +9 -0
- package/lib/types/hooks/useCioClient.d.ts +6 -0
- package/lib/types/hooks/useFocusTrap.d.ts +11 -0
- package/lib/types/hooks/useMessageInput.d.ts +15 -0
- package/lib/types/hooks/useRequestConfigs.d.ts +7 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/types.d.ts +178 -0
- package/lib/types/utils/formatters.d.ts +1 -0
- package/lib/types/utils/productNormalizer.d.ts +14 -0
- package/lib/types/utils/translate.d.ts +2 -0
- package/lib/types/utils/typeHelpers.d.ts +4 -0
- package/lib/types/utils/urlHelpers.d.ts +8 -0
- package/lib/types/version.d.ts +2 -0
- package/package.json +150 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as ChatBubbleDarkIcon } from './ChatBubbleDarkIcon';
|
|
2
|
+
export { default as ChatBubbleLightIcon } from './ChatBubbleLightIcon';
|
|
3
|
+
export { default as SendArrowIcon } from './SendArrowIcon';
|
|
4
|
+
export { default as SendPlaneIcon } from './SendPlaneIcon';
|
|
5
|
+
export { default as ArrowRightIcon } from './ArrowRightIcon';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const DEMO_API_KEY = "key_fygjntHGW7usvxC8";
|
|
2
|
+
export declare const PLACEHOLDER_IMAGE = "data:image/svg+xml,%3Csvg width='200' height='200' viewBox='0 0 200 200' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='200' height='200' rx='12' fill='%23F3F4F6'/%3E%3Crect x='0.5' y='0.5' width='199' height='199' rx='11.5' stroke='%23E5E7EB'/%3E%3C/svg%3E";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { ResultGroupMeta, ChatMessage } from '../types';
|
|
3
|
+
export type MessageUpdater = Dispatch<SetStateAction<ChatMessage[]>>;
|
|
4
|
+
export declare function handleSearchResult(data: any, pendingGroup: ResultGroupMeta | null, assistantId: string, setMessages: MessageUpdater): ResultGroupMeta | null;
|
|
5
|
+
export declare function handleMessage(data: any, assistantId: string, setMessages: MessageUpdater): void;
|
|
6
|
+
export declare function handleServerError(assistantId: string, setMessages: MessageUpdater): void;
|
|
7
|
+
export declare function handleStreamEnd(assistantId: string, setMessages: MessageUpdater): void;
|
|
8
|
+
export declare function handleStreamError(assistantId: string, setMessages: MessageUpdater): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AsaContextValue } from '../types';
|
|
3
|
+
export declare const AsaContext: import("react").Context<AsaContextValue | null>;
|
|
4
|
+
/**
|
|
5
|
+
* React Hook to access state provided by CioAsa provider.
|
|
6
|
+
* Note: Should only be used by components nested under a CioAsa provider
|
|
7
|
+
*/
|
|
8
|
+
export declare function useCioAsaContext(): AsaContextValue;
|
|
9
|
+
export default useCioAsaContext;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
2
|
+
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
3
|
+
import type { UseCioClientProps } from '../types';
|
|
4
|
+
type UseCioClient = (props: UseCioClientProps) => Nullable<ConstructorIOClient> | never;
|
|
5
|
+
declare const useCioClient: UseCioClient;
|
|
6
|
+
export default useCioClient;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
interface UseFocusTrapOptions {
|
|
3
|
+
/** Called when the Escape key is pressed while focus is inside the container. */
|
|
4
|
+
onEscape?: () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Traps Tab/Shift+Tab focus within the referenced container and invokes
|
|
8
|
+
* onEscape when Escape is pressed.
|
|
9
|
+
*/
|
|
10
|
+
export default function useFocusTrap(containerRef: RefObject<HTMLElement>, { onEscape }?: UseFocusTrapOptions): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface UseMessageInputOptions {
|
|
3
|
+
onSend: (text: string) => void;
|
|
4
|
+
isDisabled?: boolean;
|
|
5
|
+
/** When true, Shift+Enter will not submit (allowing a newline in multiline inputs). */
|
|
6
|
+
submitOnEnterOnly?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface UseMessageInput {
|
|
9
|
+
value: string;
|
|
10
|
+
setValue: (value: string) => void;
|
|
11
|
+
handleSubmit: () => void;
|
|
12
|
+
handleKeyDown: (e: React.KeyboardEvent) => void;
|
|
13
|
+
}
|
|
14
|
+
export default function useMessageInput({ onSend, isDisabled, submitOnEnterOnly, }: UseMessageInputOptions): UseMessageInput;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestConfigs } from '../types';
|
|
2
|
+
interface UseRequestConfigsReturn {
|
|
3
|
+
requestConfigs: RequestConfigs;
|
|
4
|
+
setRequestConfigs: (configsToUpdate: Partial<RequestConfigs>) => void;
|
|
5
|
+
}
|
|
6
|
+
export default function useRequestConfigs(): UseRequestConfigsReturn;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as CioAsaProvider } from './components/CioAsaProvider/CioAsaProvider';
|
|
2
|
+
export { default as Chat } from './components/Chat/Chat';
|
|
3
|
+
export type { ChatHandle } from './components/Chat/Chat';
|
|
4
|
+
export { default as ResultsBlock } from './components/ResultsBlock/ResultsBlock';
|
|
5
|
+
export type { AspectRatio } from './components/ResultsBlock/ResultsBlock';
|
|
6
|
+
export { default as Button } from './components/Button/Button';
|
|
7
|
+
export type { ButtonProps } from './components/Button/Button';
|
|
8
|
+
export { default as useAsaResults } from './hooks/useAsaResults';
|
|
9
|
+
export { normalizeItemToProduct } from './utils/productNormalizer';
|
|
10
|
+
export type { Product, NormalizeOptions } from './utils/productNormalizer';
|
|
11
|
+
export { ConstructorIOClient } from './types';
|
|
12
|
+
export type { Nullable, CioAsaProviderProps, AsaContextValue, CioClientOptions, RequestConfigs, Formatters, UrlHelpers, QueryParamEncodingOptions, DefaultQueryStringMap, Translations, ChatMessage, ChatMessageStatus, ResultGroup, ResultGroupMeta, UseChatReturn, ChatComponentOverrides, WelcomeScreenOverrides, ChatInputOverrides, AiMessageOverrides, ResultsBlockOverrides, ComponentOverrideProps, IncludeComponentOverrides, ChatHeaderRenderProps, ChatInputRenderProps, WelcomeScreenTitleRenderProps, WelcomeScreenInputRenderProps, SuggestedQuestionsRenderProps, UserMessageRenderProps, AiMessageLoaderRenderProps, AiMessageTextRenderProps, ResultsGroupTitleRenderProps, ResultsViewMoreRenderProps, } from './types';
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
4
|
+
import { ConstructorClientOptions, Nullable } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
5
|
+
import { IAgentParameters } from '@constructor-io/constructorio-client-javascript/lib/types/agent';
|
|
6
|
+
import { ComponentOverrideProps, CarouselOverrides, IncludeComponentOverrides } from '@constructor-io/constructorio-ui-components';
|
|
7
|
+
import type { Product } from './utils/productNormalizer';
|
|
8
|
+
export { Nullable, ConstructorIOClient };
|
|
9
|
+
export type CioClientOptions = Omit<ConstructorClientOptions, 'apiKey' | 'sendTrackingEvents'>;
|
|
10
|
+
export interface PrimaryColorStyles {
|
|
11
|
+
'--primary-color-h': string;
|
|
12
|
+
'--primary-color-s': string;
|
|
13
|
+
'--primary-color-l': string;
|
|
14
|
+
}
|
|
15
|
+
export interface AsaContextValue {
|
|
16
|
+
cioClient: Nullable<ConstructorIOClient>;
|
|
17
|
+
cioClientOptions: CioClientOptions;
|
|
18
|
+
setCioClientOptions: React.Dispatch<CioClientOptions>;
|
|
19
|
+
staticRequestConfigs: RequestConfigs;
|
|
20
|
+
formatters: Formatters;
|
|
21
|
+
urlHelpers: UrlHelpers;
|
|
22
|
+
}
|
|
23
|
+
export interface RequestConfigs extends IAgentParameters {
|
|
24
|
+
intent?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface Formatters {
|
|
27
|
+
formatPrice: (price?: number) => string;
|
|
28
|
+
}
|
|
29
|
+
export interface UrlHelpers {
|
|
30
|
+
getUrl: () => string | undefined;
|
|
31
|
+
setUrl: (newUrlWithEncodedState: string) => void;
|
|
32
|
+
getStateFromUrl: (urlString: string) => RequestConfigs;
|
|
33
|
+
getUrlFromState: (state: RequestConfigs, options: QueryParamEncodingOptions) => string;
|
|
34
|
+
defaultQueryStringMap: Readonly<DefaultQueryStringMap>;
|
|
35
|
+
}
|
|
36
|
+
export interface CioAsaProviderProps extends Omit<Partial<AsaContextValue>, 'setCioClientOptions' | 'cioClientOptions'> {
|
|
37
|
+
apiKey?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface UseCioClientProps {
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
cioClient?: Nullable<ConstructorIOClient>;
|
|
42
|
+
cioClientOptions?: CioClientOptions;
|
|
43
|
+
}
|
|
44
|
+
export type DefaultQueryStringMap = {
|
|
45
|
+
intent: 'q';
|
|
46
|
+
numResultsPerPage: 'resultsPerPod';
|
|
47
|
+
filters: 'filters';
|
|
48
|
+
};
|
|
49
|
+
export interface QueryParamEncodingOptions {
|
|
50
|
+
baseUrl?: string;
|
|
51
|
+
origin?: string;
|
|
52
|
+
pathname?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Composes a type for a Component that accepts
|
|
56
|
+
* - Props P,
|
|
57
|
+
* - A children function, that takes RenderProps as its argument
|
|
58
|
+
*/
|
|
59
|
+
export type IncludeRenderProps<ComponentProps, ChildrenFunctionProps> = ComponentProps & {
|
|
60
|
+
children?: ((props: ChildrenFunctionProps) => ReactNode) | React.ReactNode;
|
|
61
|
+
};
|
|
62
|
+
export interface ChatMessage {
|
|
63
|
+
id: string;
|
|
64
|
+
role: 'user' | 'assistant';
|
|
65
|
+
text: string;
|
|
66
|
+
groups?: ResultGroup[];
|
|
67
|
+
status: ChatMessageStatus;
|
|
68
|
+
}
|
|
69
|
+
export type ChatMessageStatus = 'idle' | 'loading' | 'streaming' | 'done' | 'error';
|
|
70
|
+
export interface ResultGroupMeta {
|
|
71
|
+
display_name: string;
|
|
72
|
+
value?: string;
|
|
73
|
+
data?: {
|
|
74
|
+
display_name?: string;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export interface ResultGroup {
|
|
79
|
+
group: ResultGroupMeta;
|
|
80
|
+
searchResults: Record<string, unknown>[];
|
|
81
|
+
}
|
|
82
|
+
export interface UseChatReturn {
|
|
83
|
+
messages: ChatMessage[];
|
|
84
|
+
sendMessage: (text: string) => void;
|
|
85
|
+
isStreaming: boolean;
|
|
86
|
+
clearHistory: () => void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Translations type for internationalizing UI strings.
|
|
90
|
+
* All keys are optional — any non-provided translation will fall back to the English default.
|
|
91
|
+
*/
|
|
92
|
+
export type Translations = {
|
|
93
|
+
'CioAsa.header.title'?: string;
|
|
94
|
+
'CioAsa.header.close'?: string;
|
|
95
|
+
'CioAsa.input.placeholder'?: string;
|
|
96
|
+
'CioAsa.input.ariaLabel'?: string;
|
|
97
|
+
'CioAsa.input.sendAriaLabel'?: string;
|
|
98
|
+
'CioAsa.welcome.title'?: string;
|
|
99
|
+
'CioAsa.welcome.placeholder'?: string;
|
|
100
|
+
'CioAsa.welcome.sendButton'?: string;
|
|
101
|
+
'CioAsa.welcome.inputAriaLabel'?: string;
|
|
102
|
+
'CioAsa.welcome.sendAriaLabel'?: string;
|
|
103
|
+
'CioAsa.welcome.suggestionsAriaLabel'?: string;
|
|
104
|
+
'CioAsa.messageList.ariaLabel'?: string;
|
|
105
|
+
'CioAsa.typingIndicator.ariaLabel'?: string;
|
|
106
|
+
'CioAsa.userMessage.ariaLabel'?: string;
|
|
107
|
+
'CioAsa.results.viewMore'?: string;
|
|
108
|
+
'CioAsa.results.addToCart'?: string;
|
|
109
|
+
'CioAsa.results.saleBadge'?: string;
|
|
110
|
+
'CioAsa.error.message'?: string;
|
|
111
|
+
};
|
|
112
|
+
export interface ChatHeaderRenderProps {
|
|
113
|
+
title: string;
|
|
114
|
+
onClose?: () => void;
|
|
115
|
+
}
|
|
116
|
+
export interface ChatInputRenderProps {
|
|
117
|
+
value: string;
|
|
118
|
+
onChange: (value: string) => void;
|
|
119
|
+
onSubmit: () => void;
|
|
120
|
+
placeholder: string;
|
|
121
|
+
isDisabled: boolean;
|
|
122
|
+
}
|
|
123
|
+
export interface WelcomeScreenTitleRenderProps {
|
|
124
|
+
text: string;
|
|
125
|
+
}
|
|
126
|
+
export interface WelcomeScreenInputRenderProps {
|
|
127
|
+
value: string;
|
|
128
|
+
onChange: (value: string) => void;
|
|
129
|
+
onSubmit: () => void;
|
|
130
|
+
placeholder: string;
|
|
131
|
+
isDisabled: boolean;
|
|
132
|
+
}
|
|
133
|
+
export interface SuggestedQuestionsRenderProps {
|
|
134
|
+
suggestions: string[];
|
|
135
|
+
onSuggestionClick: (suggestion: string) => void;
|
|
136
|
+
}
|
|
137
|
+
export interface UserMessageRenderProps {
|
|
138
|
+
text: string;
|
|
139
|
+
}
|
|
140
|
+
export interface AiMessageLoaderRenderProps {
|
|
141
|
+
translations?: Translations;
|
|
142
|
+
}
|
|
143
|
+
export interface AiMessageTextRenderProps {
|
|
144
|
+
text: string;
|
|
145
|
+
}
|
|
146
|
+
export interface ResultsGroupTitleRenderProps {
|
|
147
|
+
label: string;
|
|
148
|
+
}
|
|
149
|
+
export interface ResultsViewMoreRenderProps {
|
|
150
|
+
group: ResultGroupMeta;
|
|
151
|
+
onClick: () => void;
|
|
152
|
+
}
|
|
153
|
+
export interface WelcomeScreenOverrides {
|
|
154
|
+
title?: ComponentOverrideProps<WelcomeScreenTitleRenderProps>;
|
|
155
|
+
input?: ComponentOverrideProps<WelcomeScreenInputRenderProps>;
|
|
156
|
+
suggestedQuestions?: ComponentOverrideProps<SuggestedQuestionsRenderProps>;
|
|
157
|
+
}
|
|
158
|
+
export interface ChatInputOverrides {
|
|
159
|
+
reactNode?: ComponentOverrideProps<ChatInputRenderProps>['reactNode'];
|
|
160
|
+
}
|
|
161
|
+
export interface AiMessageOverrides {
|
|
162
|
+
loader?: ComponentOverrideProps<AiMessageLoaderRenderProps>;
|
|
163
|
+
text?: ComponentOverrideProps<AiMessageTextRenderProps>;
|
|
164
|
+
}
|
|
165
|
+
export interface ResultsBlockOverrides {
|
|
166
|
+
groupTitle?: ComponentOverrideProps<ResultsGroupTitleRenderProps>;
|
|
167
|
+
viewMore?: ComponentOverrideProps<ResultsViewMoreRenderProps>;
|
|
168
|
+
carousel?: CarouselOverrides<Product>;
|
|
169
|
+
}
|
|
170
|
+
export interface ChatComponentOverrides {
|
|
171
|
+
header?: ComponentOverrideProps<ChatHeaderRenderProps>;
|
|
172
|
+
welcomeScreen?: WelcomeScreenOverrides;
|
|
173
|
+
input?: ComponentOverrideProps<ChatInputRenderProps>;
|
|
174
|
+
userMessage?: ComponentOverrideProps<UserMessageRenderProps>;
|
|
175
|
+
aiMessage?: AiMessageOverrides;
|
|
176
|
+
resultsBlock?: ResultsBlockOverrides;
|
|
177
|
+
}
|
|
178
|
+
export type { ComponentOverrideProps, IncludeComponentOverrides };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatPrice(price?: number): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Product {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
imageUrl?: string;
|
|
6
|
+
price?: string | number;
|
|
7
|
+
salePrice?: string | number;
|
|
8
|
+
description?: string;
|
|
9
|
+
badge?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface NormalizeOptions {
|
|
12
|
+
saleBadgeText?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function normalizeItemToProduct(item: any, options?: NormalizeOptions): Product;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RequestConfigs, QueryParamEncodingOptions, DefaultQueryStringMap } from '../types';
|
|
2
|
+
export declare const defaultQueryStringMap: Readonly<DefaultQueryStringMap>;
|
|
3
|
+
export declare function getUrl(): string | undefined;
|
|
4
|
+
export declare function setUrl(newUrlWithEncodedState: string): void;
|
|
5
|
+
export declare function extractFiltersFromUrl(urlParams: URLSearchParams): {} | undefined;
|
|
6
|
+
export declare function getFilterParamsFromState(urlParams: URLSearchParams, filters: RequestConfigs['filters']): void;
|
|
7
|
+
export declare function getStateFromUrl(url: string): RequestConfigs;
|
|
8
|
+
export declare function getUrlFromState(state: RequestConfigs, options?: QueryParamEncodingOptions): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@constructor-io/constructorio-ui-asa",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Constructor.io AI Shopping Agent UI library for web applications",
|
|
5
|
+
"author": "constructor.io",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/Constructor-io/constructorio-ui-asa#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Constructor-io/constructorio-ui-asa.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Constructor-io/constructorio-ui-asa/issues"
|
|
14
|
+
},
|
|
15
|
+
"main": "lib/cjs/index.js",
|
|
16
|
+
"module": "lib/mjs/index.js",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./lib/mjs/index.js",
|
|
20
|
+
"require": "./lib/cjs/index.js",
|
|
21
|
+
"types": "./lib/types/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./styles.css": {
|
|
24
|
+
"import": "./lib/mjs/styles.css",
|
|
25
|
+
"require": "./lib/cjs/styles.css"
|
|
26
|
+
},
|
|
27
|
+
"./components/Chat/styles.css": {
|
|
28
|
+
"import": "./lib/mjs/components/Chat/Chat.css",
|
|
29
|
+
"require": "./lib/cjs/components/Chat/Chat.css"
|
|
30
|
+
},
|
|
31
|
+
"./components/ResultsBlock/styles.css": {
|
|
32
|
+
"import": "./lib/mjs/components/ResultsBlock/ResultsBlock.css",
|
|
33
|
+
"require": "./lib/cjs/components/ResultsBlock/ResultsBlock.css"
|
|
34
|
+
},
|
|
35
|
+
"./constructorio-ui-asa-bundled": {
|
|
36
|
+
"import": "./dist/constructorio-ui-asa-bundled.js",
|
|
37
|
+
"require": "./dist/constructorio-ui-asa-bundled.js"
|
|
38
|
+
},
|
|
39
|
+
"./cjs": {
|
|
40
|
+
"import": "./lib/cjs/index.js",
|
|
41
|
+
"require": "./lib/cjs/index.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"lib/**/*",
|
|
46
|
+
"dist/constructorio-ui-asa-bundled.js"
|
|
47
|
+
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20"
|
|
50
|
+
},
|
|
51
|
+
"types": "lib/types/index.d.ts",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"lint": "eslint src spec --ext js,ts,jsx,tsx",
|
|
54
|
+
"check-types": "npx tsc --noEmit -p tsconfig.check.json",
|
|
55
|
+
"copy-styles": "rsync -am --include='*/' --include='*.css' --exclude='*' src/ lib/mjs/ && rsync -am --include='*/' --include='*.css' --exclude='*' src/ lib/cjs/",
|
|
56
|
+
"dev": "storybook dev -p 6006",
|
|
57
|
+
"test": "jest",
|
|
58
|
+
"test:coverage": "jest --coverage",
|
|
59
|
+
"storybook:ci": "storybook dev --ci --quiet -p 6006",
|
|
60
|
+
"test-storybook": "test-storybook",
|
|
61
|
+
"test-storybook:watch": "test-storybook --watch",
|
|
62
|
+
"test-storybook:ci": "start-server-and-test storybook:ci http://localhost:6006 test-storybook",
|
|
63
|
+
"build-storybook": "storybook build --docs -o 'docs'",
|
|
64
|
+
"storybook-docs-dev": "storybook dev --docs -p 6007",
|
|
65
|
+
"serve-built-storybook": "npx http-server docs",
|
|
66
|
+
"version": "npm run build-storybook && git add -u ./docs && git add ./docs/* && npm run compile",
|
|
67
|
+
"compile": "node ./src/generateVersion.js && rm -rf lib && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && npm run copy-styles && vite build",
|
|
68
|
+
"check-license": "license-checker --production --onlyAllow 'Apache-2.0;BSD-3-Clause;MIT;0BSD;BSD-2-Clause;ISC' --excludePackages 'picocolors@1.0.0;lightningcss@1.32.0;lightningcss-darwin-arm64@1.32.0;lightningcss-linux-x64-gnu@1.32.0;lightningcss-linux-x64-musl@1.32.0'",
|
|
69
|
+
"prepare": "husky install"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@constructor-io/constructorio-client-javascript": "^2.88.0",
|
|
73
|
+
"@constructor-io/constructorio-ui-components": "^1.6.0",
|
|
74
|
+
"react": ">=16.12.0",
|
|
75
|
+
"react-dom": ">=16.12.0",
|
|
76
|
+
"tslib": "^2.4.0"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@axe-core/react": "^4.7.0",
|
|
80
|
+
"@constructor-io/constructorio-client-javascript": "^2.88.0",
|
|
81
|
+
"@constructor-io/constructorio-ui-components": "^1.6.0",
|
|
82
|
+
"@babel/preset-env": "^7.28.3",
|
|
83
|
+
"@babel/preset-react": "^7.27.1",
|
|
84
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
85
|
+
"@cspell/eslint-plugin": "^6.18.1",
|
|
86
|
+
"@storybook/addon-a11y": "^8.6.14",
|
|
87
|
+
"@storybook/addon-actions": "^8.6.14",
|
|
88
|
+
"@storybook/addon-essentials": "^8.6.14",
|
|
89
|
+
"@storybook/addon-interactions": "^8.6.14",
|
|
90
|
+
"@storybook/addon-links": "^8.6.14",
|
|
91
|
+
"@storybook/addon-mdx-gfm": "^8.6.14",
|
|
92
|
+
"@storybook/blocks": "^8.6.14",
|
|
93
|
+
"@storybook/react": "^8.6.14",
|
|
94
|
+
"@storybook/react-vite": "^8.6.14",
|
|
95
|
+
"@storybook/react-webpack5": "^8.6.14",
|
|
96
|
+
"@storybook/test-runner": "^0.22.1",
|
|
97
|
+
"@storybook/testing-library": "^0.2.0",
|
|
98
|
+
"@testing-library/jest-dom": "^6.1.5",
|
|
99
|
+
"@testing-library/react": "^14.0.0",
|
|
100
|
+
"@testing-library/user-event": "^14.6.1",
|
|
101
|
+
"@types/jest": "^29.5.8",
|
|
102
|
+
"@types/jest-axe": "^3.5.9",
|
|
103
|
+
"@types/react": "^18.0.26",
|
|
104
|
+
"@types/react-dom": "^18.0.9",
|
|
105
|
+
"@typescript-eslint/eslint-plugin": "^5.47.0",
|
|
106
|
+
"@typescript-eslint/parser": "^5.47.0",
|
|
107
|
+
"chromatic": "^10.0.0",
|
|
108
|
+
"eslint": "^8.30.0",
|
|
109
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
110
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
111
|
+
"eslint-config-prettier": "^8.5.0",
|
|
112
|
+
"eslint-plugin-import": "^2.26.0",
|
|
113
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
114
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
115
|
+
"eslint-plugin-react": "^7.31.11",
|
|
116
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
117
|
+
"eslint-plugin-storybook": "^0.6.13",
|
|
118
|
+
"husky": "^8.0.0",
|
|
119
|
+
"jest": "^28.1.3",
|
|
120
|
+
"jest-axe": "^8.0.0",
|
|
121
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
122
|
+
"license-checker": "^25.0.1",
|
|
123
|
+
"prop-types": "^15.8.1",
|
|
124
|
+
"react": "^18.2.0",
|
|
125
|
+
"react-dom": "^18.2.0",
|
|
126
|
+
"start-server-and-test": "^2.0.3",
|
|
127
|
+
"storybook": "^8.6.17",
|
|
128
|
+
"typescript": "^4.9.4",
|
|
129
|
+
"vite": "^6.4.1",
|
|
130
|
+
"vite-plugin-css-injected-by-js": "^3.1.0",
|
|
131
|
+
"webpack": "^5.105.4"
|
|
132
|
+
},
|
|
133
|
+
"dependencies": {},
|
|
134
|
+
"overrides": {
|
|
135
|
+
"brace-expansion@1": "1.1.16",
|
|
136
|
+
"brace-expansion@2": "2.1.2",
|
|
137
|
+
"minimatch@9": "9.0.9",
|
|
138
|
+
"form-data": "4.0.6",
|
|
139
|
+
"joi": "17.13.4",
|
|
140
|
+
"js-yaml@3": "3.15.0",
|
|
141
|
+
"js-yaml@4": "4.3.0",
|
|
142
|
+
"postcss": "8.5.24",
|
|
143
|
+
"uuid": "11.1.1",
|
|
144
|
+
"yaml": "1.10.3"
|
|
145
|
+
},
|
|
146
|
+
"volta": {
|
|
147
|
+
"node": "22.18.0",
|
|
148
|
+
"npm": "10.9.3"
|
|
149
|
+
}
|
|
150
|
+
}
|