@envive-ai/react-toolkit-v3 0.3.10 → 0.3.11
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/dist/AnimatedText/AnimatedText.d.cts +3 -3
- package/dist/AnimatedText/AnimatedText.d.ts +3 -3
- package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.cts +2 -2
- package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.ts +2 -2
- package/dist/Carousel/Carousel.d.cts +2 -2
- package/dist/Carousel/Carousel.d.ts +2 -2
- package/dist/ChatFooter/ChatFooter.d.cts +2 -2
- package/dist/ChatFooter/ChatFooter.d.ts +2 -2
- package/dist/ChatFooter/components/index.d.cts +5 -5
- package/dist/ChatFooter/components/index.d.ts +5 -5
- package/dist/ChatHeader/ChatHeader.d.cts +2 -2
- package/dist/ChatHeader/ChatHeader.d.ts +2 -2
- package/dist/ChatPreview/ChatPreview.d.cts +2 -2
- package/dist/ChatPreview/ChatPreview.d.ts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.cts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.ts +2 -2
- package/dist/ChatPreviewLoading/ChatPreviewLoading.d.cts +2 -2
- package/dist/ChatPreviewLoading/ChatPreviewLoading.d.ts +2 -2
- package/dist/Container/Container.d.cts +175 -175
- package/dist/Container/Container.d.ts +4 -4
- package/dist/DesignTokens/DesignTokensComponent.d.cts +2 -2
- package/dist/DesignTokens/DesignTokensComponent.d.ts +2 -2
- package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.cts +2 -2
- package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.ts +2 -2
- package/dist/FloatingButton/FloatingButton.d.cts +2 -2
- package/dist/FloatingButton/FloatingButton.d.ts +2 -2
- package/dist/FloatingChat/FloatingChat.cjs +5 -3
- package/dist/FloatingChat/FloatingChat.d.cts +3 -2
- package/dist/FloatingChat/FloatingChat.d.ts +1 -0
- package/dist/FloatingChat/FloatingChat.js +5 -3
- package/dist/FloatingChat/components/Layout.cjs +5 -1
- package/dist/FloatingChat/components/Layout.js +5 -1
- package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.cjs +1 -0
- package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.js +1 -0
- package/dist/FloatingChat/types/types.d.cts +4 -0
- package/dist/FloatingChat/types/types.d.ts +4 -0
- package/dist/FullPageSalesAgent/FullPageSalesAgent.cjs +131 -0
- package/dist/FullPageSalesAgent/FullPageSalesAgent.d.cts +24 -0
- package/dist/FullPageSalesAgent/FullPageSalesAgent.d.ts +24 -0
- package/dist/FullPageSalesAgent/FullPageSalesAgent.js +130 -0
- package/dist/FullPageSalesAgent/components/Layout.cjs +53 -0
- package/dist/FullPageSalesAgent/components/Layout.js +51 -0
- package/dist/FullPageSalesAgent/components/index.cjs +7 -0
- package/dist/FullPageSalesAgent/components/index.js +7 -0
- package/dist/FullPageSalesAgent/hooks/useContainerResizerObserver.cjs +23 -0
- package/dist/FullPageSalesAgent/hooks/useContainerResizerObserver.js +22 -0
- package/dist/FullPageSalesAgent/hooks/useGetContainerStyles.cjs +16 -0
- package/dist/FullPageSalesAgent/hooks/useGetContainerStyles.js +16 -0
- package/dist/FullPageSalesAgent/hooks/useGetFooterStyles.cjs +16 -0
- package/dist/FullPageSalesAgent/hooks/useGetFooterStyles.js +16 -0
- package/dist/FullPageSalesAgent/hooks/useGetScrollContentStyles.cjs +19 -0
- package/dist/FullPageSalesAgent/hooks/useGetScrollContentStyles.js +17 -0
- package/dist/FullPageSalesAgent/hooks/useIsMobile.cjs +7 -0
- package/dist/FullPageSalesAgent/hooks/useIsMobile.js +7 -0
- package/dist/FullPageSalesAgent/index.cjs +3 -0
- package/dist/FullPageSalesAgent/index.d.cts +2 -0
- package/dist/FullPageSalesAgent/index.d.ts +2 -0
- package/dist/FullPageSalesAgent/index.js +3 -0
- package/dist/Image/Image.d.cts +2 -2
- package/dist/Image/Image.d.ts +2 -2
- package/dist/ImageGallery/ImageGallery.d.cts +2 -2
- package/dist/ImageGallery/ImageGallery.d.ts +2 -2
- package/dist/MarkdownProcessor/MarkdownProcessor.d.cts +2 -2
- package/dist/MarkdownProcessor/MarkdownProcessor.d.ts +2 -2
- package/dist/Message/hooks/useVariantStyleProperties.cjs +1 -1
- package/dist/Message/hooks/useVariantStyleProperties.js +1 -1
- package/dist/ProductCard/ProductCard.d.cts +2 -2
- package/dist/ProductCard/ProductCard.d.ts +2 -2
- package/dist/PromptButton/PromptButton.d.cts +2 -2
- package/dist/PromptButton/PromptButton.d.ts +2 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.cts +2 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.ts +2 -2
- package/dist/PromptCarousel/PromptCarousel.d.cts +2 -2
- package/dist/PromptCarousel/PromptCarousel.d.ts +2 -2
- package/dist/ReviewCard/ReviewCard.d.cts +2 -2
- package/dist/ReviewCard/ReviewCard.d.ts +2 -2
- package/dist/ReviewCard/components/index.d.cts +6 -6
- package/dist/ReviewCard/components/index.d.ts +4 -4
- package/dist/SalesAgentProductCard/SalesAgentProductCard.cjs +2 -1
- package/dist/SalesAgentProductCard/SalesAgentProductCard.d.cts +3 -2
- package/dist/SalesAgentProductCard/SalesAgentProductCard.d.ts +3 -2
- package/dist/SalesAgentProductCard/SalesAgentProductCard.js +2 -1
- package/dist/SalesAgentProductCard/components/Container.cjs +7 -5
- package/dist/SalesAgentProductCard/components/Container.d.cts +2 -1
- package/dist/SalesAgentProductCard/components/Container.d.ts +2 -1
- package/dist/SalesAgentProductCard/components/Container.js +7 -5
- package/dist/SalesAgentProductCard/components/index.d.cts +9 -8
- package/dist/SalesAgentProductCard/components/index.d.ts +9 -8
- package/dist/SalesAgentProductCard/types/types.d.cts +4 -0
- package/dist/SalesAgentProductCard/types/types.d.ts +4 -0
- package/dist/SocialProof/SocialProof.d.cts +2 -2
- package/dist/SocialProof/SocialProof.d.ts +2 -2
- package/dist/Stack/Stack.d.ts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.d.cts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.d.ts +2 -2
- package/dist/TypingAnimation/TypingAnimation.d.cts +2 -2
- package/dist/TypingAnimation/TypingAnimation.d.ts +2 -2
- package/dist/Typography/Typography.d.cts +4 -4
- package/dist/Typography/Typography.d.ts +4 -4
- package/dist/WidgetTextField/WidgetTextField.d.cts +2 -2
- package/dist/WidgetTextField/WidgetTextField.d.ts +2 -2
- package/dist/WidgetWrapper/WidgetWrapper.d.cts +2 -2
- package/dist/WidgetWrapper/WidgetWrapper.d.ts +2 -2
- package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.cts +2 -2
- package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.ts +2 -2
- package/dist/styles.css +1 -1
- package/package.json +5 -1
- package/src/components/FloatingChat/FloatingChat.tsx +7 -1
- package/src/components/FloatingChat/components/Layout.tsx +3 -0
- package/src/components/FloatingChat/components/SalesAgentProductCardsCarousel.tsx +4 -3
- package/src/components/FloatingChat/types/types.ts +4 -0
- package/src/components/FullPageSalesAgent/FullPageSalesAgent.tsx +199 -0
- package/src/components/FullPageSalesAgent/components/Layout.tsx +81 -0
- package/src/components/FullPageSalesAgent/components/index.ts +5 -0
- package/src/components/FullPageSalesAgent/hooks/useContainerResizerObserver.ts +33 -0
- package/src/components/FullPageSalesAgent/hooks/useGetContainerStyles.ts +24 -0
- package/src/components/FullPageSalesAgent/hooks/useGetFooterStyles.ts +17 -0
- package/src/components/FullPageSalesAgent/hooks/useGetScrollContentStyles.ts +17 -0
- package/src/components/FullPageSalesAgent/hooks/useIsMobile.ts +3 -0
- package/src/components/FullPageSalesAgent/index.ts +1 -0
- package/src/components/Message/hooks/useVariantStyleProperties.ts +1 -1
- package/src/components/SalesAgentProductCard/SalesAgentProductCard.tsx +2 -0
- package/src/components/SalesAgentProductCard/components/Container.tsx +16 -9
- package/src/components/SalesAgentProductCard/types/types.ts +4 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { Theme } from '../../../../tokens/theme/theme';
|
|
2
|
+
import { Carousel } from '../../Carousel/Carousel';
|
|
3
|
+
import { SalesAgentProductCard } from '../../SalesAgentProductCard/SalesAgentProductCard';
|
|
1
4
|
import {
|
|
2
5
|
SalesAgentProductCardProps,
|
|
3
6
|
SalesAgentProductCardVariant,
|
|
4
7
|
} from '../../SalesAgentProductCard/types/types';
|
|
5
8
|
import { resolveTheme } from '../../utils/resolveTheme';
|
|
6
|
-
import { Carousel } from '../../Carousel/Carousel';
|
|
7
|
-
import { SalesAgentProductCard } from '../../SalesAgentProductCard/SalesAgentProductCard';
|
|
8
|
-
import { Theme } from '../../../../tokens/theme/theme';
|
|
9
9
|
|
|
10
10
|
export interface SalesAgentProductCardsCarouselProps {
|
|
11
11
|
theme: Theme;
|
|
@@ -52,6 +52,7 @@ export const SalesAgentProductCardsCarousel = ({
|
|
|
52
52
|
numberOfReviews={product.numberOfReviews}
|
|
53
53
|
image={product.image}
|
|
54
54
|
url={product.url}
|
|
55
|
+
target="_blank"
|
|
55
56
|
theme={finalTheme}
|
|
56
57
|
/>
|
|
57
58
|
))}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
2
|
+
import { HardcopyResponse } from '@envive-ai/react-hooks/contexts/hardcopyContext';
|
|
3
|
+
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
4
|
+
import { FloatingChatConfig, LookAndFeelConfig } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
+
import { useRef, useState } from 'react';
|
|
6
|
+
import { ChatFooter } from '../ChatFooter';
|
|
7
|
+
import { Disclaimer } from '../Disclaimer';
|
|
8
|
+
import { FloatingChatComponents } from '../FloatingChat/components';
|
|
9
|
+
import { useChatSuggestions } from '../FloatingChat/hooks/useChatSuggestions';
|
|
10
|
+
import { useScrollToBottom } from '../FloatingChat/hooks/useScrollToBottom';
|
|
11
|
+
import { PromptButtonVariant } from '../PromptButton';
|
|
12
|
+
import { PromptCarousel, PromptCarouselRows } from '../PromptCarousel';
|
|
13
|
+
import { Theme } from '../Tokens';
|
|
14
|
+
import { resolveTheme } from '../utils/resolveTheme';
|
|
15
|
+
import { SparkleIconColor, WelcomeMessage } from '../WelcomeMessage';
|
|
16
|
+
import { FullPageSAComponents } from './components';
|
|
17
|
+
import { useGetFooterStyles } from './hooks/useGetFooterStyles';
|
|
18
|
+
import { useIsMobile } from './hooks/useIsMobile';
|
|
19
|
+
|
|
20
|
+
interface FullPageSalesAgentProps {
|
|
21
|
+
theme?: Theme;
|
|
22
|
+
floatingChatConfig: FloatingChatConfig;
|
|
23
|
+
lookAndFeelConfig: LookAndFeelConfig;
|
|
24
|
+
hardcopyContent: HardcopyResponse;
|
|
25
|
+
headerContainer?: string;
|
|
26
|
+
autoHeight?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const FullPageSalesAgent = ({
|
|
30
|
+
theme = Theme.GLOBAL_CUSTOM,
|
|
31
|
+
floatingChatConfig,
|
|
32
|
+
lookAndFeelConfig,
|
|
33
|
+
hardcopyContent,
|
|
34
|
+
headerContainer,
|
|
35
|
+
autoHeight,
|
|
36
|
+
}: FullPageSalesAgentProps) => {
|
|
37
|
+
const resolvedTheme = resolveTheme(theme);
|
|
38
|
+
const salesAgentData = useSalesAgent();
|
|
39
|
+
const [query, setQuery] = useState('');
|
|
40
|
+
const chatMessagesRef = useRef<HTMLDivElement>(null);
|
|
41
|
+
const { footerStyles } = useGetFooterStyles();
|
|
42
|
+
const { isMobile } = useIsMobile();
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
welcomeMessageIconColor,
|
|
46
|
+
ignoreFirstModelResponse,
|
|
47
|
+
neverShowSingleProductCards,
|
|
48
|
+
showVerifiedBuyer,
|
|
49
|
+
showEnviveLogo,
|
|
50
|
+
userQueryInputEnabled = true,
|
|
51
|
+
} = floatingChatConfig;
|
|
52
|
+
|
|
53
|
+
const { agentName } = lookAndFeelConfig;
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
welcomeMessageTitle,
|
|
57
|
+
welcomeMessageText,
|
|
58
|
+
chatFooterTextFieldPlaceholderText,
|
|
59
|
+
disclaimerText,
|
|
60
|
+
} = hardcopyContent?.values ?? {};
|
|
61
|
+
|
|
62
|
+
const {
|
|
63
|
+
messages,
|
|
64
|
+
isResponseStreaming,
|
|
65
|
+
isPendingResponse,
|
|
66
|
+
suggestions,
|
|
67
|
+
onSuggestionClicked,
|
|
68
|
+
onTypedMessageSubmitted,
|
|
69
|
+
onFormResponseSubmitted,
|
|
70
|
+
} = salesAgentData;
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
answerSuggestions,
|
|
74
|
+
generalSuggestions,
|
|
75
|
+
showAnswerSuggestions,
|
|
76
|
+
setAnswerSuggestions,
|
|
77
|
+
setGeneralSuggestions,
|
|
78
|
+
} = useChatSuggestions({
|
|
79
|
+
suggestions,
|
|
80
|
+
isPendingResponse,
|
|
81
|
+
isResponseStreaming,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const { showScrollButton, scrollToBottom, isFloatingLayout } = useScrollToBottom({
|
|
85
|
+
messagesRef: chatMessagesRef,
|
|
86
|
+
scrollThreshold: 100,
|
|
87
|
+
footerHeight: 160,
|
|
88
|
+
autoScrollDependencies: [
|
|
89
|
+
messages,
|
|
90
|
+
isPendingResponse,
|
|
91
|
+
suggestions,
|
|
92
|
+
answerSuggestions,
|
|
93
|
+
generalSuggestions,
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const welcomeMessage = (
|
|
98
|
+
<WelcomeMessage
|
|
99
|
+
sparkleIconColor={welcomeMessageIconColor as SparkleIconColor}
|
|
100
|
+
title={welcomeMessageTitle as string}
|
|
101
|
+
text={welcomeMessageText as string}
|
|
102
|
+
theme={resolvedTheme}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const footer = (
|
|
107
|
+
<ChatFooter
|
|
108
|
+
className="envive-tw-bg-background-light"
|
|
109
|
+
style={footerStyles}
|
|
110
|
+
theme={resolvedTheme}
|
|
111
|
+
isScrolled={isMobile ? isFloatingLayout : false}
|
|
112
|
+
disabled={isPendingResponse || isResponseStreaming}
|
|
113
|
+
disabledInput={!userQueryInputEnabled}
|
|
114
|
+
isLoadingPromptSuggestions={
|
|
115
|
+
isPendingResponse || isResponseStreaming || generalSuggestions.length === 0
|
|
116
|
+
}
|
|
117
|
+
hideEnviveWatermark={!showEnviveLogo}
|
|
118
|
+
textFieldPlaceholderText={chatFooterTextFieldPlaceholderText as string}
|
|
119
|
+
promptSuggestions={
|
|
120
|
+
isPendingResponse || isResponseStreaming || generalSuggestions.length === 0
|
|
121
|
+
? ['Loading suggestions 1...', 'Loading suggestions 2...']
|
|
122
|
+
: generalSuggestions
|
|
123
|
+
}
|
|
124
|
+
handleButtonClick={buttonText => {
|
|
125
|
+
const suggestion = suggestions.find(s => s.content === buttonText && !s.isAnswer);
|
|
126
|
+
if (suggestion) {
|
|
127
|
+
onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.FLOATING_CHAT_PROMPT_BUTTON);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setAnswerSuggestions([]);
|
|
131
|
+
setGeneralSuggestions([]);
|
|
132
|
+
}}
|
|
133
|
+
onChange={setQuery}
|
|
134
|
+
onSubmit={() => {
|
|
135
|
+
onTypedMessageSubmitted({ query, userTyped: true });
|
|
136
|
+
setAnswerSuggestions([]);
|
|
137
|
+
setGeneralSuggestions([]);
|
|
138
|
+
}}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const chatMessages = (
|
|
143
|
+
<FloatingChatComponents.ChatMessages
|
|
144
|
+
theme={resolvedTheme}
|
|
145
|
+
ref={chatMessagesRef}
|
|
146
|
+
isLoading={isPendingResponse && !isResponseStreaming}
|
|
147
|
+
agentName={agentName}
|
|
148
|
+
messages={messages}
|
|
149
|
+
hasFilteredMessages={false}
|
|
150
|
+
handlePreviousDiscussions={() => {}}
|
|
151
|
+
isResponseStreaming={isResponseStreaming}
|
|
152
|
+
ignoreFirstModelResponse={ignoreFirstModelResponse}
|
|
153
|
+
neverShowSingleProductCards={neverShowSingleProductCards}
|
|
154
|
+
showVerifiedBuyer={showVerifiedBuyer}
|
|
155
|
+
onFormResponseSubmitted={onFormResponseSubmitted}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const answerSuggestionsComponent = (
|
|
160
|
+
<PromptCarousel
|
|
161
|
+
className="envive-tw-flex envive-tw-justify-end envive-tw-p-4 [&>div>div]:envive-tw-items-end"
|
|
162
|
+
theme={resolvedTheme}
|
|
163
|
+
promptButtonType={PromptButtonVariant.SUGGESTED_RESPONSE}
|
|
164
|
+
promptCarouselRows={PromptCarouselRows.ALWAYS_TWO}
|
|
165
|
+
promptButtonTexts={answerSuggestions}
|
|
166
|
+
handleButtonClick={buttonText => {
|
|
167
|
+
const suggestion = suggestions.find(s => s.content === buttonText && s.isAnswer);
|
|
168
|
+
if (suggestion) {
|
|
169
|
+
onSuggestionClicked(suggestion, ChatElementDisplayLocationV3.FLOATING_CHAT_PROMPT_BUTTON);
|
|
170
|
+
}
|
|
171
|
+
setAnswerSuggestions([]);
|
|
172
|
+
setGeneralSuggestions([]);
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const disclaimer =
|
|
178
|
+
disclaimerText && typeof disclaimerText === 'string' ? (
|
|
179
|
+
<Disclaimer disclaimerMarkdown={disclaimerText} />
|
|
180
|
+
) : undefined;
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<FullPageSAComponents.Layout
|
|
184
|
+
theme={resolvedTheme}
|
|
185
|
+
welcomeMessage={welcomeMessage}
|
|
186
|
+
footer={footer}
|
|
187
|
+
chatMessages={chatMessages}
|
|
188
|
+
answerSuggestions={showAnswerSuggestions ? answerSuggestionsComponent : undefined}
|
|
189
|
+
scrollToBottomButton={
|
|
190
|
+
showScrollButton ? (
|
|
191
|
+
<FloatingChatComponents.ScrollToBottomButton onClick={scrollToBottom} />
|
|
192
|
+
) : undefined
|
|
193
|
+
}
|
|
194
|
+
disclaimer={disclaimer}
|
|
195
|
+
headerContainer={headerContainer}
|
|
196
|
+
autoHeight={autoHeight}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { isValidElement } from 'react';
|
|
3
|
+
import { Stack } from 'src/components/Stack';
|
|
4
|
+
import { Theme } from 'tokens/theme/theme';
|
|
5
|
+
import { useGetContainerStyles } from '../hooks/useGetContainerStyles';
|
|
6
|
+
import { useGetFooterStyles } from '../hooks/useGetFooterStyles';
|
|
7
|
+
import { useGetScrollContentStyles } from '../hooks/useGetScrollContentStyles';
|
|
8
|
+
|
|
9
|
+
export interface LayoutProps {
|
|
10
|
+
theme: Theme;
|
|
11
|
+
welcomeMessage: React.ReactNode;
|
|
12
|
+
footer?: React.ReactNode;
|
|
13
|
+
chatMessages?: React.ReactNode;
|
|
14
|
+
answerSuggestions?: React.ReactNode;
|
|
15
|
+
scrollToBottomButton?: React.ReactNode;
|
|
16
|
+
disclaimer?: React.ReactNode;
|
|
17
|
+
headerContainer?: string;
|
|
18
|
+
autoHeight?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Layout = ({
|
|
22
|
+
theme,
|
|
23
|
+
welcomeMessage,
|
|
24
|
+
footer,
|
|
25
|
+
chatMessages,
|
|
26
|
+
answerSuggestions,
|
|
27
|
+
scrollToBottomButton,
|
|
28
|
+
disclaimer,
|
|
29
|
+
headerContainer,
|
|
30
|
+
autoHeight,
|
|
31
|
+
}: LayoutProps) => {
|
|
32
|
+
const hasWelcomeMessage = isValidElement(welcomeMessage);
|
|
33
|
+
const hasAnswerSuggestions = isValidElement(answerSuggestions);
|
|
34
|
+
const { contentClasses, messageContainerClasses } = useGetScrollContentStyles();
|
|
35
|
+
const { footerContainerClasses } = useGetFooterStyles();
|
|
36
|
+
const { containerClasses, containerStyles } = useGetContainerStyles({
|
|
37
|
+
headerContainer,
|
|
38
|
+
autoHeight,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
className={containerClasses}
|
|
44
|
+
style={containerStyles}
|
|
45
|
+
>
|
|
46
|
+
<div className={contentClasses}>
|
|
47
|
+
<Stack
|
|
48
|
+
className={messageContainerClasses}
|
|
49
|
+
direction="column"
|
|
50
|
+
justify="between"
|
|
51
|
+
>
|
|
52
|
+
{welcomeMessage}
|
|
53
|
+
{disclaimer}
|
|
54
|
+
</Stack>
|
|
55
|
+
<Stack
|
|
56
|
+
direction="column"
|
|
57
|
+
gap="0"
|
|
58
|
+
className={classNames(
|
|
59
|
+
(!hasWelcomeMessage || (hasWelcomeMessage && theme === Theme.STANDARD)) &&
|
|
60
|
+
!hasAnswerSuggestions &&
|
|
61
|
+
'envive-tw-pb-4',
|
|
62
|
+
'envive-tw-pt-4',
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
{chatMessages}
|
|
66
|
+
{answerSuggestions}
|
|
67
|
+
</Stack>
|
|
68
|
+
</div>
|
|
69
|
+
<div className={footerContainerClasses}>
|
|
70
|
+
{scrollToBottomButton && (
|
|
71
|
+
<div className="envive-tw-h-[0px]">
|
|
72
|
+
<div className="envive-tw-ml-auto envive-tw-table envive-tw-translate-x-[-30px] envive-tw-translate-y-[-50px]">
|
|
73
|
+
{scrollToBottomButton}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
77
|
+
{footer}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useContainerResizerObserver = ({
|
|
4
|
+
headerContainer,
|
|
5
|
+
autoHeight,
|
|
6
|
+
}: {
|
|
7
|
+
headerContainer?: string;
|
|
8
|
+
autoHeight?: boolean;
|
|
9
|
+
}) => {
|
|
10
|
+
const [containerHeight, setContainerHeight] = useState<number | string>('100%');
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!autoHeight) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const watchResizing = () => {
|
|
18
|
+
const header = document.querySelector(headerContainer)?.getBoundingClientRect()?.height || 0;
|
|
19
|
+
setContainerHeight(window.innerHeight - header);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
window.addEventListener('resize', watchResizing);
|
|
23
|
+
watchResizing();
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
window.removeEventListener('resize', watchResizing);
|
|
27
|
+
};
|
|
28
|
+
}, [headerContainer, autoHeight]);
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
containerHeight,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useContainerResizerObserver } from './useContainerResizerObserver';
|
|
2
|
+
|
|
3
|
+
export const useGetContainerStyles = ({
|
|
4
|
+
headerContainer,
|
|
5
|
+
autoHeight,
|
|
6
|
+
}: {
|
|
7
|
+
headerContainer?: string;
|
|
8
|
+
autoHeight?: boolean;
|
|
9
|
+
}) => {
|
|
10
|
+
const { containerHeight } = useContainerResizerObserver({
|
|
11
|
+
headerContainer,
|
|
12
|
+
autoHeight,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const containerClasses =
|
|
16
|
+
'envive-tw-mx-auto envive-tw-flex envive-tw-h-full envive-tw-max-w-[768px] envive-tw-flex-col';
|
|
17
|
+
|
|
18
|
+
const containerStyles = { height: containerHeight };
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
containerClasses,
|
|
22
|
+
containerStyles,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useIsMobile } from './useIsMobile';
|
|
2
|
+
|
|
3
|
+
export const useGetFooterStyles = () => {
|
|
4
|
+
const { isMobile } = useIsMobile();
|
|
5
|
+
const footerStyles = !isMobile
|
|
6
|
+
? { boxShadow: '0px 2px 10px 0px rgba(0, 0, 0, 0.2)', borderWidth: '1px' }
|
|
7
|
+
: null;
|
|
8
|
+
|
|
9
|
+
const footerContainerClasses = isMobile
|
|
10
|
+
? 'envive-tw-absolute envive-tw-bottom-[0] envive-tw-left-[0] envive-tw-right-[0]'
|
|
11
|
+
: 'envive-tw-pb-5';
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
footerStyles,
|
|
15
|
+
footerContainerClasses,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { useIsMobile } from './useIsMobile';
|
|
3
|
+
|
|
4
|
+
export const useGetScrollContentStyles = () => {
|
|
5
|
+
const { isMobile } = useIsMobile();
|
|
6
|
+
const contentClasses = classNames({
|
|
7
|
+
'envive-tw-flex-1 envive-tw-overflow-y-auto envive-tw-overflow-x-hidden envive-tw-transition-all envive-tw-duration-300 envive-tw-ease-in-out': true,
|
|
8
|
+
'envive-tw-pb-[131px]': isMobile,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const messageContainerClasses = !isMobile ? 'envive-tw-pt-4' : null;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
contentClasses,
|
|
15
|
+
messageContainerClasses,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FullPageSalesAgent } from './FullPageSalesAgent';
|
|
@@ -20,7 +20,7 @@ export const useVariantStyleProperties = (
|
|
|
20
20
|
const variantStylesMap: Record<MessageVariant, VariantStylesProperties> = {
|
|
21
21
|
[MessageVariant.AGENT]: {
|
|
22
22
|
containerLayoutClasses: 'envive-tw-flex envive-tw-flex-col envive-tw-gap-2',
|
|
23
|
-
containerBackgroundClasses: '
|
|
23
|
+
containerBackgroundClasses: '',
|
|
24
24
|
containerBorderClasses: '',
|
|
25
25
|
containerRadiusClasses: 'envive-tw-rounded-md',
|
|
26
26
|
contentClasses: '',
|
|
@@ -29,6 +29,7 @@ export const SalesAgentProductCard = ({
|
|
|
29
29
|
rate,
|
|
30
30
|
image,
|
|
31
31
|
url,
|
|
32
|
+
target,
|
|
32
33
|
onClick,
|
|
33
34
|
}: SalesAgentProductCardProps) => {
|
|
34
35
|
const finalTheme = resolveTheme(theme);
|
|
@@ -42,6 +43,7 @@ export const SalesAgentProductCard = ({
|
|
|
42
43
|
theme={finalTheme}
|
|
43
44
|
variant={variant}
|
|
44
45
|
url={url}
|
|
46
|
+
target={target}
|
|
45
47
|
onClick={onClick}
|
|
46
48
|
productName={
|
|
47
49
|
<SalesAgentProductCardComponents.ProductName
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
+
import { Theme } from '../../../../tokens/theme/theme';
|
|
3
|
+
import { Container as ContainerComponent } from '../../Container';
|
|
2
4
|
import { Stack } from '../../Stack';
|
|
3
|
-
import { SalesAgentProductCardVariant } from '../types/types';
|
|
4
5
|
import { useGetContainerProperties } from '../hooks/useGetContainerProperties';
|
|
5
6
|
import { useGetProductDescriptionProperties } from '../hooks/useGetProductDescriptionProperties';
|
|
6
|
-
import {
|
|
7
|
-
import { Theme } from '../../../../tokens/theme/theme';
|
|
7
|
+
import { SalesAgentProductCardProps, SalesAgentProductCardVariant } from '../types/types';
|
|
8
8
|
|
|
9
9
|
export type ContainerProps = {
|
|
10
10
|
id?: string;
|
|
@@ -18,6 +18,7 @@ export type ContainerProps = {
|
|
|
18
18
|
rate: React.ReactNode;
|
|
19
19
|
image: React.ReactNode;
|
|
20
20
|
url: string;
|
|
21
|
+
target?: SalesAgentProductCardProps['target'];
|
|
21
22
|
onClick?: () => void | Promise<void>;
|
|
22
23
|
};
|
|
23
24
|
|
|
@@ -33,6 +34,7 @@ export const Container = ({
|
|
|
33
34
|
rate,
|
|
34
35
|
image,
|
|
35
36
|
url,
|
|
37
|
+
target = '_self',
|
|
36
38
|
onClick,
|
|
37
39
|
}: ContainerProps) => {
|
|
38
40
|
const { baseClassName, themeContainerClassNames, containerDirection, containerWidthClassName } =
|
|
@@ -48,12 +50,17 @@ export const Container = ({
|
|
|
48
50
|
variant,
|
|
49
51
|
});
|
|
50
52
|
|
|
51
|
-
const anchorProps: React.AnchorHTMLAttributes<HTMLAnchorElement> =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const anchorProps: React.AnchorHTMLAttributes<HTMLAnchorElement> =
|
|
54
|
+
target !== 'none'
|
|
55
|
+
? {
|
|
56
|
+
href: url,
|
|
57
|
+
onClick,
|
|
58
|
+
target,
|
|
59
|
+
draggable: false,
|
|
60
|
+
}
|
|
61
|
+
: {
|
|
62
|
+
onClick,
|
|
63
|
+
};
|
|
57
64
|
|
|
58
65
|
return (
|
|
59
66
|
<ContainerComponent
|
|
@@ -71,6 +71,10 @@ export type SalesAgentProductCardProps = {
|
|
|
71
71
|
* The URL to navigate to when the card is clicked.
|
|
72
72
|
*/
|
|
73
73
|
url?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The URL target to be applied.
|
|
76
|
+
*/
|
|
77
|
+
target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'] | 'none';
|
|
74
78
|
/**
|
|
75
79
|
* Callback function called when the card is clicked.
|
|
76
80
|
*/
|