@envive-ai/react-toolkit-v3 0.3.17 → 0.3.19
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/CSSVariablesEditor/CssVariablesEditorComponent.d.cts +2 -2
- package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.ts +2 -2
- package/dist/Carousel/Carousel.cjs +7 -6
- package/dist/Carousel/Carousel.d.cts +3 -2
- package/dist/Carousel/Carousel.d.ts +3 -2
- package/dist/Carousel/Carousel.js +7 -6
- package/dist/Carousel/components/Container.cjs +2 -2
- package/dist/Carousel/components/Container.js +2 -2
- package/dist/Carousel/types/types.d.cts +5 -0
- package/dist/Carousel/types/types.d.ts +5 -0
- package/dist/ChatFooter/ChatFooter.cjs +1 -1
- package/dist/ChatFooter/ChatFooter.d.cts +2 -2
- package/dist/ChatFooter/ChatFooter.d.ts +2 -2
- package/dist/ChatFooter/ChatFooter.js +1 -1
- package/dist/ChatFooter/components/Layout.cjs +2 -2
- package/dist/ChatFooter/components/Layout.js +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/ChatHeader/components/Handle.cjs +2 -2
- package/dist/ChatHeader/components/Handle.js +2 -2
- package/dist/ChatHeader/components/Toggle.cjs +3 -3
- package/dist/ChatHeader/components/Toggle.js +3 -3
- package/dist/ChatPreview/ChatPreview.cjs +1 -1
- package/dist/ChatPreview/ChatPreview.d.cts +2 -2
- package/dist/ChatPreview/ChatPreview.d.ts +2 -2
- package/dist/ChatPreview/ChatPreview.js +1 -1
- package/dist/ChatPreviewComparison/ChatPreviewComparison.cjs +1 -1
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.cts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.ts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.js +1 -1
- package/dist/ChatPreviewComparison/components/Headline.cjs +2 -2
- package/dist/ChatPreviewComparison/components/Headline.js +2 -2
- package/dist/ChatPreviewComparison/components/Layout.cjs +4 -4
- package/dist/ChatPreviewComparison/components/Layout.js +4 -4
- package/dist/ChatPreviewComparison/components/Message.cjs +2 -2
- package/dist/ChatPreviewComparison/components/Message.js +2 -2
- package/dist/ChatPreviewLoading/ChatPreviewLoading.d.cts +2 -2
- package/dist/ChatPreviewLoading/ChatPreviewLoading.d.ts +2 -2
- package/dist/Container/Container.d.cts +14 -14
- package/dist/Container/Container.d.ts +177 -177
- package/dist/DesignTokens/DesignTokensComponent.d.cts +2 -2
- package/dist/DesignTokens/DesignTokensComponent.d.ts +2 -2
- package/dist/Disclaimer/components/Container.cjs +2 -2
- package/dist/Disclaimer/components/Container.js +2 -2
- package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.cts +2 -2
- package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.ts +2 -2
- package/dist/DocumentRetrievalCard/components/Layout.cjs +2 -2
- package/dist/DocumentRetrievalCard/components/Layout.js +2 -2
- package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Icon.cjs +1 -1
- package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Icon.js +1 -1
- package/dist/FloatingButton/FloatingButton.d.cts +2 -2
- package/dist/FloatingButton/FloatingButton.d.ts +2 -2
- package/dist/FloatingChat/FloatingChat.cjs +61 -16
- package/dist/FloatingChat/FloatingChat.d.cts +2 -2
- package/dist/FloatingChat/FloatingChat.d.ts +2 -2
- package/dist/FloatingChat/FloatingChat.js +63 -18
- package/dist/FloatingChat/components/AgentMessage.cjs +8 -3
- package/dist/FloatingChat/components/AgentMessage.js +8 -3
- package/dist/FloatingChat/components/ChatMessages.cjs +5 -4
- package/dist/FloatingChat/components/ChatMessages.js +5 -4
- package/dist/FloatingChat/components/Layout.cjs +5 -4
- package/dist/FloatingChat/components/Layout.js +5 -4
- package/dist/FloatingChat/components/ResultsGridView.cjs +72 -0
- package/dist/FloatingChat/components/ResultsGridView.js +71 -0
- package/dist/FloatingChat/components/SalesAgentBadgeContent.cjs +59 -0
- package/dist/FloatingChat/components/SalesAgentBadgeContent.js +56 -0
- package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.cjs +14 -5
- package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.js +14 -5
- package/dist/FloatingChat/components/SlideChatContent.cjs +46 -0
- package/dist/FloatingChat/components/SlideChatContent.js +45 -0
- package/dist/FloatingChat/components/index.cjs +4 -0
- package/dist/FloatingChat/components/index.js +4 -0
- package/dist/FloatingChat/hooks/useProductResultsView.cjs +36 -0
- package/dist/FloatingChat/hooks/useProductResultsView.js +35 -0
- package/dist/FloatingChat/utils/functions.cjs +28 -1
- package/dist/FloatingChat/utils/functions.js +25 -1
- package/dist/FullPageSalesAgent/FullPageSalesAgent.cjs +12 -7
- package/dist/FullPageSalesAgent/FullPageSalesAgent.d.cts +2 -2
- package/dist/FullPageSalesAgent/FullPageSalesAgent.d.ts +2 -2
- package/dist/FullPageSalesAgent/FullPageSalesAgent.js +12 -7
- package/dist/FullPageSalesAgent/components/Layout.cjs +1 -2
- package/dist/FullPageSalesAgent/components/Layout.js +1 -2
- package/dist/FullPageSalesAgent/hooks/useContainerResizerObserver.cjs +4 -1
- package/dist/FullPageSalesAgent/hooks/useContainerResizerObserver.js +4 -1
- 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/ImageGallery/components/Layout.cjs +1 -1
- package/dist/ImageGallery/components/Layout.js +1 -1
- package/dist/MarkdownProcessor/MarkdownProcessor.d.cts +2 -2
- package/dist/MarkdownProcessor/MarkdownProcessor.d.ts +2 -2
- package/dist/Message/components/LinkButton.cjs +1 -1
- package/dist/Message/components/LinkButton.js +1 -1
- package/dist/OrderLookupCard/OrderLookupCard.cjs +1 -1
- package/dist/OrderLookupCard/OrderLookupCard.js +1 -1
- package/dist/ProductCard/ProductCard.cjs +2 -2
- package/dist/ProductCard/ProductCard.d.cts +2 -2
- package/dist/ProductCard/ProductCard.d.ts +2 -2
- package/dist/ProductCard/ProductCard.js +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/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.cjs +1 -1
- package/dist/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.js +1 -1
- package/dist/PromptCarousel/PromptCarousel.cjs +3 -3
- package/dist/PromptCarousel/PromptCarousel.d.cts +2 -2
- package/dist/PromptCarousel/PromptCarousel.d.ts +2 -2
- package/dist/PromptCarousel/PromptCarousel.js +3 -3
- package/dist/ReviewCard/ReviewCard.d.cts +2 -2
- package/dist/ReviewCard/ReviewCard.d.ts +2 -2
- package/dist/ReviewCard/components/Container.cjs +2 -2
- package/dist/ReviewCard/components/Container.js +2 -2
- package/dist/ReviewCard/components/ReadMoreButton.cjs +1 -1
- package/dist/ReviewCard/components/ReadMoreButton.js +1 -1
- package/dist/ReviewCard/components/index.d.cts +6 -6
- package/dist/ReviewCard/components/index.d.ts +6 -6
- package/dist/SalesAgentProductCard/SalesAgentProductCard.d.cts +2 -2
- package/dist/SalesAgentProductCard/SalesAgentProductCard.d.ts +2 -2
- package/dist/SalesAgentProductCard/components/Container.cjs +2 -2
- package/dist/SalesAgentProductCard/components/Container.js +2 -2
- package/dist/SalesAgentProductCard/components/index.d.cts +8 -8
- package/dist/SalesAgentProductCard/components/index.d.ts +8 -8
- package/dist/SocialProof/SocialProof.cjs +1 -1
- package/dist/SocialProof/SocialProof.d.ts +2 -2
- package/dist/SocialProof/SocialProof.js +1 -1
- package/dist/SocialProof/components/Headline.cjs +3 -3
- package/dist/SocialProof/components/Headline.js +3 -3
- package/dist/SocialProof/components/LayoutFourHorizontal.cjs +1 -1
- package/dist/SocialProof/components/LayoutFourHorizontal.js +1 -1
- package/dist/SocialProof/components/Subheadline.cjs +1 -1
- package/dist/SocialProof/components/Subheadline.js +1 -1
- package/dist/SparkleAnimation/SparkleAnimation.d.cts +2 -2
- package/dist/SparkleAnimation/SparkleAnimation.d.ts +2 -2
- package/dist/Stack/Stack.d.cts +2 -2
- package/dist/Stack/Stack.d.ts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.cjs +1 -1
- package/dist/TitledPromptCarousel/TitledPromptCarousel.d.cts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.d.ts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.js +1 -1
- package/dist/Tokens/index.cjs +1 -1
- package/dist/Tokens/index.js +1 -1
- package/dist/TypingAnimation/TypingAnimation.cjs +1 -1
- package/dist/TypingAnimation/TypingAnimation.d.cts +2 -2
- package/dist/TypingAnimation/TypingAnimation.d.ts +2 -2
- package/dist/TypingAnimation/TypingAnimation.js +1 -1
- package/dist/TypingAnimation/hooks/useGetTypographyVariant.cjs +1 -1
- package/dist/TypingAnimation/hooks/useGetTypographyVariant.js +1 -1
- package/dist/Typography/Typography.d.cts +4 -4
- package/dist/Typography/Typography.d.ts +4 -4
- package/dist/WelcomeMessage/components/Container.cjs +2 -2
- package/dist/WelcomeMessage/components/Container.js +2 -2
- package/dist/WidgetTextField/WidgetTextField.cjs +1 -1
- package/dist/WidgetTextField/WidgetTextField.d.cts +2 -2
- package/dist/WidgetTextField/WidgetTextField.js +1 -1
- package/dist/WidgetTextField/components/Container.cjs +2 -2
- package/dist/WidgetTextField/components/Container.js +2 -2
- package/dist/WidgetTextField/components/Icon.cjs +1 -1
- package/dist/WidgetTextField/components/Icon.js +1 -1
- 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 +1 -1
- package/src/components/Carousel/Carousel.tsx +11 -8
- package/src/components/Carousel/types/types.ts +5 -0
- package/src/components/FloatingChat/FloatingChat.tsx +91 -19
- package/src/components/FloatingChat/components/AgentMessage.tsx +8 -0
- package/src/components/FloatingChat/components/ChatMessages.tsx +3 -0
- package/src/components/FloatingChat/components/Layout.tsx +7 -1
- package/src/components/FloatingChat/components/ModalSheet.tsx +1 -1
- package/src/components/FloatingChat/components/ResultsGridView.tsx +93 -0
- package/src/components/FloatingChat/components/SalesAgentBadgeContent.tsx +86 -0
- package/src/components/FloatingChat/components/SalesAgentProductCardsCarousel.tsx +18 -7
- package/src/components/FloatingChat/components/SlideChatContent.tsx +72 -0
- package/src/components/FloatingChat/components/index.ts +4 -1
- package/src/components/FloatingChat/hooks/useFilteredChatMessages.ts +1 -1
- package/src/components/FloatingChat/hooks/useProductResultsView.ts +49 -0
- package/src/components/FloatingChat/utils/functions.ts +41 -0
- package/src/components/FullPageSalesAgent/FullPageSalesAgent.tsx +10 -6
- package/src/components/FullPageSalesAgent/components/Layout.tsx +1 -2
- package/src/components/FullPageSalesAgent/hooks/useContainerResizerObserver.ts +1 -0
- package/src/logging/logger.ts +33 -8
- package/src/mocks/productCardMocks.ts +955 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_resolveTheme = require('../../utils/resolveTheme.cjs');
|
|
3
|
+
const require_Stack = require('../../Stack/Stack.cjs');
|
|
4
|
+
require('../../Stack/index.cjs');
|
|
5
|
+
const require_index = require('../../Typography/types/index.cjs');
|
|
6
|
+
const require_Typography = require('../../Typography/Typography.cjs');
|
|
7
|
+
require('../../Typography/index.cjs');
|
|
8
|
+
const require_types = require('../../SalesAgentProductCard/types/types.cjs');
|
|
9
|
+
const require_SalesAgentProductCard = require('../../SalesAgentProductCard/SalesAgentProductCard.cjs');
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
|
|
12
|
+
//#region src/components/FloatingChat/components/ResultsGridView.tsx
|
|
13
|
+
const ResultsGridView = ({ theme, searchQuery, products, onBackToChat, onProductCardClick }) => {
|
|
14
|
+
const finalTheme = require_resolveTheme.resolveTheme(theme);
|
|
15
|
+
const forceShowCurrentPriceSpace = products.some((product) => product.currentPrice && product.previousPrice !== product.currentPrice);
|
|
16
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Stack.Stack, {
|
|
17
|
+
direction: "column",
|
|
18
|
+
gap: "4",
|
|
19
|
+
className: "envive-tw-pb-4 envive-tw-pl-4 envive-tw-pr-4",
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
22
|
+
className: "envive-tw-top-0 envive-tw-sticky envive-tw-z-10 envive-tw-mb-2 envive-tw-bg-background-light envive-tw-pb-2 envive-tw-pt-2",
|
|
23
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
24
|
+
type: "button",
|
|
25
|
+
onClick: onBackToChat,
|
|
26
|
+
className: "envive-tw-flex envive-tw-items-center envive-tw-gap-1 envive-tw-rounded-global-custom envive-tw-border envive-tw-border-border-medium envive-tw-bg-background-light envive-tw-p-2 envive-tw-shadow-sm hover:envive-tw-border-border-dark",
|
|
27
|
+
"aria-label": "Back to Chat",
|
|
28
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
29
|
+
className: "envive-tw-text-[--envive-colors-text-primary]",
|
|
30
|
+
"aria-hidden": true,
|
|
31
|
+
children: "←"
|
|
32
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Typography.Typography, {
|
|
33
|
+
variant: require_index.TypographyVariant.B3_MD,
|
|
34
|
+
color: require_index.TypographyColor.TEXT_PRIMARY,
|
|
35
|
+
children: "Back to Chat"
|
|
36
|
+
})]
|
|
37
|
+
})
|
|
38
|
+
}),
|
|
39
|
+
searchQuery && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Typography.Typography, {
|
|
40
|
+
variant: require_index.TypographyVariant.B3_MD,
|
|
41
|
+
color: require_index.TypographyColor.TEXT_PRIMARY,
|
|
42
|
+
className: "envive-tw-mb-2",
|
|
43
|
+
children: [
|
|
44
|
+
"Results for \"",
|
|
45
|
+
searchQuery,
|
|
46
|
+
"\""
|
|
47
|
+
]
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
50
|
+
className: "envive-tw-grid envive-tw-grid-cols-2 envive-tw-gap-4",
|
|
51
|
+
children: products.map((product, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SalesAgentProductCard.SalesAgentProductCard, {
|
|
52
|
+
variant: require_types.SalesAgentProductCardVariant.LARGE,
|
|
53
|
+
productName: product.productName,
|
|
54
|
+
currentPrice: product.currentPrice,
|
|
55
|
+
previousPrice: product.previousPrice,
|
|
56
|
+
pricePrefix: product.pricePrefix ?? "$",
|
|
57
|
+
forceShowCurrentPriceSpace,
|
|
58
|
+
rate: product.rate,
|
|
59
|
+
numberOfReviews: product.numberOfReviews,
|
|
60
|
+
image: product.image,
|
|
61
|
+
url: product.url,
|
|
62
|
+
target: "_blank",
|
|
63
|
+
theme: finalTheme,
|
|
64
|
+
onClick: () => onProductCardClick?.(product)
|
|
65
|
+
}, product.id ?? `product-${index}`))
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
exports.ResultsGridView = ResultsGridView;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { resolveTheme } from "../../utils/resolveTheme.js";
|
|
2
|
+
import { Stack } from "../../Stack/Stack.js";
|
|
3
|
+
import "../../Stack/index.js";
|
|
4
|
+
import { TypographyColor, TypographyVariant } from "../../Typography/types/index.js";
|
|
5
|
+
import { Typography } from "../../Typography/Typography.js";
|
|
6
|
+
import "../../Typography/index.js";
|
|
7
|
+
import { SalesAgentProductCardVariant } from "../../SalesAgentProductCard/types/types.js";
|
|
8
|
+
import { SalesAgentProductCard } from "../../SalesAgentProductCard/SalesAgentProductCard.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
//#region src/components/FloatingChat/components/ResultsGridView.tsx
|
|
12
|
+
const ResultsGridView = ({ theme, searchQuery, products, onBackToChat, onProductCardClick }) => {
|
|
13
|
+
const finalTheme = resolveTheme(theme);
|
|
14
|
+
const forceShowCurrentPriceSpace = products.some((product) => product.currentPrice && product.previousPrice !== product.currentPrice);
|
|
15
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
16
|
+
direction: "column",
|
|
17
|
+
gap: "4",
|
|
18
|
+
className: "envive-tw-pb-4 envive-tw-pl-4 envive-tw-pr-4",
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ jsx("div", {
|
|
21
|
+
className: "envive-tw-top-0 envive-tw-sticky envive-tw-z-10 envive-tw-mb-2 envive-tw-bg-background-light envive-tw-pb-2 envive-tw-pt-2",
|
|
22
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
23
|
+
type: "button",
|
|
24
|
+
onClick: onBackToChat,
|
|
25
|
+
className: "envive-tw-flex envive-tw-items-center envive-tw-gap-1 envive-tw-rounded-global-custom envive-tw-border envive-tw-border-border-medium envive-tw-bg-background-light envive-tw-p-2 envive-tw-shadow-sm hover:envive-tw-border-border-dark",
|
|
26
|
+
"aria-label": "Back to Chat",
|
|
27
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: "envive-tw-text-[--envive-colors-text-primary]",
|
|
29
|
+
"aria-hidden": true,
|
|
30
|
+
children: "←"
|
|
31
|
+
}), /* @__PURE__ */ jsx(Typography, {
|
|
32
|
+
variant: TypographyVariant.B3_MD,
|
|
33
|
+
color: TypographyColor.TEXT_PRIMARY,
|
|
34
|
+
children: "Back to Chat"
|
|
35
|
+
})]
|
|
36
|
+
})
|
|
37
|
+
}),
|
|
38
|
+
searchQuery && /* @__PURE__ */ jsxs(Typography, {
|
|
39
|
+
variant: TypographyVariant.B3_MD,
|
|
40
|
+
color: TypographyColor.TEXT_PRIMARY,
|
|
41
|
+
className: "envive-tw-mb-2",
|
|
42
|
+
children: [
|
|
43
|
+
"Results for \"",
|
|
44
|
+
searchQuery,
|
|
45
|
+
"\""
|
|
46
|
+
]
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: "envive-tw-grid envive-tw-grid-cols-2 envive-tw-gap-4",
|
|
50
|
+
children: products.map((product, index) => /* @__PURE__ */ jsx(SalesAgentProductCard, {
|
|
51
|
+
variant: SalesAgentProductCardVariant.LARGE,
|
|
52
|
+
productName: product.productName,
|
|
53
|
+
currentPrice: product.currentPrice,
|
|
54
|
+
previousPrice: product.previousPrice,
|
|
55
|
+
pricePrefix: product.pricePrefix ?? "$",
|
|
56
|
+
forceShowCurrentPriceSpace,
|
|
57
|
+
rate: product.rate,
|
|
58
|
+
numberOfReviews: product.numberOfReviews,
|
|
59
|
+
image: product.image,
|
|
60
|
+
url: product.url,
|
|
61
|
+
target: "_blank",
|
|
62
|
+
theme: finalTheme,
|
|
63
|
+
onClick: () => onProductCardClick?.(product)
|
|
64
|
+
}, product.id ?? `product-${index}`))
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { ResultsGridView };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_Stack = require('../../Stack/Stack.cjs');
|
|
3
|
+
const require_index = require('../../Typography/types/index.cjs');
|
|
4
|
+
const require_Typography = require('../../Typography/Typography.cjs');
|
|
5
|
+
require('../../Typography/index.cjs');
|
|
6
|
+
const require_ArrowIcon = require('../../Carousel/components/ArrowIcon.cjs');
|
|
7
|
+
const require_functions = require('../utils/functions.cjs');
|
|
8
|
+
let react = require("react");
|
|
9
|
+
react = require_rolldown_runtime.__toESM(react);
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
let classnames = require("classnames");
|
|
12
|
+
classnames = require_rolldown_runtime.__toESM(classnames);
|
|
13
|
+
|
|
14
|
+
//#region src/components/FloatingChat/components/SalesAgentBadgeContent.tsx
|
|
15
|
+
const SalesAgentBadgeContent = ({ totalProducts, displayLimit = require_functions.MOST_RELEVANT_DISPLAY_LIMIT, onExploreAllResults }) => {
|
|
16
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Stack.Stack, {
|
|
17
|
+
direction: "row",
|
|
18
|
+
justify: "between",
|
|
19
|
+
align: "center",
|
|
20
|
+
gap: "1",
|
|
21
|
+
className: "envive-tw-w-full envive-tw-rounded-global-custom envive-tw-p-2",
|
|
22
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Typography.Typography, {
|
|
23
|
+
variant: require_index.TypographyVariant.B3_MD,
|
|
24
|
+
color: require_index.TypographyColor.TEXT_PRIMARY,
|
|
25
|
+
children: [
|
|
26
|
+
"Most Relevant (",
|
|
27
|
+
displayLimit,
|
|
28
|
+
")"
|
|
29
|
+
]
|
|
30
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
31
|
+
type: "button",
|
|
32
|
+
onClick: onExploreAllResults,
|
|
33
|
+
className: (0, classnames.default)("envive-tw-flex envive-tw-items-center envive-tw-gap-1", "envive-tw-bg-background-secondary envive-tw-p-2", "envive-tw-rounded-global-custom envive-tw-border envive-tw-border-border-medium", "hover:envive-tw-border-border-dark"),
|
|
34
|
+
"aria-label": `Explore all ${totalProducts} results`,
|
|
35
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Typography.Typography, {
|
|
36
|
+
variant: require_index.TypographyVariant.B3_MD,
|
|
37
|
+
color: require_index.TypographyColor.TEXT_LINK,
|
|
38
|
+
children: [
|
|
39
|
+
"Explore All Results (",
|
|
40
|
+
totalProducts,
|
|
41
|
+
")"
|
|
42
|
+
]
|
|
43
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ArrowIcon.ArrowIcon, { direction: "right" })]
|
|
44
|
+
})]
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const getBadgeContentAndLabel = ({ totalProducts, areProductsMoreThanDisplayLimit, onExploreAllResults, displayLimit = require_functions.MOST_RELEVANT_DISPLAY_LIMIT }) => {
|
|
48
|
+
return {
|
|
49
|
+
badgeContent: areProductsMoreThanDisplayLimit ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SalesAgentBadgeContent, {
|
|
50
|
+
totalProducts,
|
|
51
|
+
displayLimit,
|
|
52
|
+
onExploreAllResults
|
|
53
|
+
}) : null,
|
|
54
|
+
badgeLabel: !areProductsMoreThanDisplayLimit && totalProducts > 1 ? `${totalProducts} Products` : null
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
exports.getBadgeContentAndLabel = getBadgeContentAndLabel;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Stack } from "../../Stack/Stack.js";
|
|
2
|
+
import { TypographyColor, TypographyVariant } from "../../Typography/types/index.js";
|
|
3
|
+
import { Typography } from "../../Typography/Typography.js";
|
|
4
|
+
import "../../Typography/index.js";
|
|
5
|
+
import { ArrowIcon } from "../../Carousel/components/ArrowIcon.js";
|
|
6
|
+
import { MOST_RELEVANT_DISPLAY_LIMIT } from "../utils/functions.js";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import classNames from "classnames";
|
|
10
|
+
|
|
11
|
+
//#region src/components/FloatingChat/components/SalesAgentBadgeContent.tsx
|
|
12
|
+
const SalesAgentBadgeContent = ({ totalProducts, displayLimit = MOST_RELEVANT_DISPLAY_LIMIT, onExploreAllResults }) => {
|
|
13
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
14
|
+
direction: "row",
|
|
15
|
+
justify: "between",
|
|
16
|
+
align: "center",
|
|
17
|
+
gap: "1",
|
|
18
|
+
className: "envive-tw-w-full envive-tw-rounded-global-custom envive-tw-p-2",
|
|
19
|
+
children: [/* @__PURE__ */ jsxs(Typography, {
|
|
20
|
+
variant: TypographyVariant.B3_MD,
|
|
21
|
+
color: TypographyColor.TEXT_PRIMARY,
|
|
22
|
+
children: [
|
|
23
|
+
"Most Relevant (",
|
|
24
|
+
displayLimit,
|
|
25
|
+
")"
|
|
26
|
+
]
|
|
27
|
+
}), /* @__PURE__ */ jsxs("button", {
|
|
28
|
+
type: "button",
|
|
29
|
+
onClick: onExploreAllResults,
|
|
30
|
+
className: classNames("envive-tw-flex envive-tw-items-center envive-tw-gap-1", "envive-tw-bg-background-secondary envive-tw-p-2", "envive-tw-rounded-global-custom envive-tw-border envive-tw-border-border-medium", "hover:envive-tw-border-border-dark"),
|
|
31
|
+
"aria-label": `Explore all ${totalProducts} results`,
|
|
32
|
+
children: [/* @__PURE__ */ jsxs(Typography, {
|
|
33
|
+
variant: TypographyVariant.B3_MD,
|
|
34
|
+
color: TypographyColor.TEXT_LINK,
|
|
35
|
+
children: [
|
|
36
|
+
"Explore All Results (",
|
|
37
|
+
totalProducts,
|
|
38
|
+
")"
|
|
39
|
+
]
|
|
40
|
+
}), /* @__PURE__ */ jsx(ArrowIcon, { direction: "right" })]
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const getBadgeContentAndLabel = ({ totalProducts, areProductsMoreThanDisplayLimit, onExploreAllResults, displayLimit = MOST_RELEVANT_DISPLAY_LIMIT }) => {
|
|
45
|
+
return {
|
|
46
|
+
badgeContent: areProductsMoreThanDisplayLimit ? /* @__PURE__ */ jsx(SalesAgentBadgeContent, {
|
|
47
|
+
totalProducts,
|
|
48
|
+
displayLimit,
|
|
49
|
+
onExploreAllResults
|
|
50
|
+
}) : null,
|
|
51
|
+
badgeLabel: !areProductsMoreThanDisplayLimit && totalProducts > 1 ? `${totalProducts} Products` : null
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { getBadgeContentAndLabel };
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_resolveTheme = require('../../utils/resolveTheme.cjs');
|
|
3
3
|
const require_Carousel = require('../../Carousel/Carousel.cjs');
|
|
4
|
+
const require_functions = require('../utils/functions.cjs');
|
|
4
5
|
const require_types = require('../../SalesAgentProductCard/types/types.cjs');
|
|
5
6
|
const require_SalesAgentProductCard = require('../../SalesAgentProductCard/SalesAgentProductCard.cjs');
|
|
7
|
+
const require_SalesAgentBadgeContent = require('./SalesAgentBadgeContent.cjs');
|
|
6
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
9
|
|
|
8
10
|
//#region src/components/FloatingChat/components/SalesAgentProductCardsCarousel.tsx
|
|
9
|
-
const SalesAgentProductCardsCarousel = ({ products, theme, hideNavigation = false, numberOfProducts, variant = require_types.SalesAgentProductCardVariant.LARGE, onProductCardClick }) => {
|
|
11
|
+
const SalesAgentProductCardsCarousel = ({ products, theme, hideNavigation = false, numberOfProducts, variant = require_types.SalesAgentProductCardVariant.LARGE, onProductCardClick, onExploreAllResults }) => {
|
|
10
12
|
const finalTheme = require_resolveTheme.resolveTheme(theme);
|
|
11
|
-
const
|
|
13
|
+
const { totalProducts, areProductsMoreThanDisplayLimit, displayedProducts } = require_functions.getProductCarouselDisplayInfo(products, numberOfProducts);
|
|
14
|
+
const forceShowCurrentPriceSpace = displayedProducts.some((product) => product.currentPrice && product.previousPrice !== product.currentPrice);
|
|
15
|
+
const { badgeContent, badgeLabel } = require_SalesAgentBadgeContent.getBadgeContentAndLabel({
|
|
16
|
+
totalProducts,
|
|
17
|
+
areProductsMoreThanDisplayLimit,
|
|
18
|
+
onExploreAllResults
|
|
19
|
+
});
|
|
12
20
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Carousel.Carousel, {
|
|
13
21
|
hideNavigation,
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
badgeContent,
|
|
23
|
+
badgeLabel,
|
|
24
|
+
elements: displayedProducts.map((product, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SalesAgentProductCard.SalesAgentProductCard, {
|
|
16
25
|
variant,
|
|
17
26
|
productName: product.productName,
|
|
18
27
|
currentPrice: product.currentPrice,
|
|
@@ -26,7 +35,7 @@ const SalesAgentProductCardsCarousel = ({ products, theme, hideNavigation = fals
|
|
|
26
35
|
target: "_blank",
|
|
27
36
|
theme: finalTheme,
|
|
28
37
|
onClick: () => onProductCardClick(product)
|
|
29
|
-
}, product.id)),
|
|
38
|
+
}, product.id ?? `product-${index}`)),
|
|
30
39
|
theme: finalTheme
|
|
31
40
|
});
|
|
32
41
|
};
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { resolveTheme } from "../../utils/resolveTheme.js";
|
|
2
2
|
import { Carousel } from "../../Carousel/Carousel.js";
|
|
3
|
+
import { getProductCarouselDisplayInfo } from "../utils/functions.js";
|
|
3
4
|
import { SalesAgentProductCardVariant } from "../../SalesAgentProductCard/types/types.js";
|
|
4
5
|
import { SalesAgentProductCard } from "../../SalesAgentProductCard/SalesAgentProductCard.js";
|
|
6
|
+
import { getBadgeContentAndLabel } from "./SalesAgentBadgeContent.js";
|
|
5
7
|
import { jsx } from "react/jsx-runtime";
|
|
6
8
|
|
|
7
9
|
//#region src/components/FloatingChat/components/SalesAgentProductCardsCarousel.tsx
|
|
8
|
-
const SalesAgentProductCardsCarousel = ({ products, theme, hideNavigation = false, numberOfProducts, variant = SalesAgentProductCardVariant.LARGE, onProductCardClick }) => {
|
|
10
|
+
const SalesAgentProductCardsCarousel = ({ products, theme, hideNavigation = false, numberOfProducts, variant = SalesAgentProductCardVariant.LARGE, onProductCardClick, onExploreAllResults }) => {
|
|
9
11
|
const finalTheme = resolveTheme(theme);
|
|
10
|
-
const
|
|
12
|
+
const { totalProducts, areProductsMoreThanDisplayLimit, displayedProducts } = getProductCarouselDisplayInfo(products, numberOfProducts);
|
|
13
|
+
const forceShowCurrentPriceSpace = displayedProducts.some((product) => product.currentPrice && product.previousPrice !== product.currentPrice);
|
|
14
|
+
const { badgeContent, badgeLabel } = getBadgeContentAndLabel({
|
|
15
|
+
totalProducts,
|
|
16
|
+
areProductsMoreThanDisplayLimit,
|
|
17
|
+
onExploreAllResults
|
|
18
|
+
});
|
|
11
19
|
return /* @__PURE__ */ jsx(Carousel, {
|
|
12
20
|
hideNavigation,
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
badgeContent,
|
|
22
|
+
badgeLabel,
|
|
23
|
+
elements: displayedProducts.map((product, index) => /* @__PURE__ */ jsx(SalesAgentProductCard, {
|
|
15
24
|
variant,
|
|
16
25
|
productName: product.productName,
|
|
17
26
|
currentPrice: product.currentPrice,
|
|
@@ -25,7 +34,7 @@ const SalesAgentProductCardsCarousel = ({ products, theme, hideNavigation = fals
|
|
|
25
34
|
target: "_blank",
|
|
26
35
|
theme: finalTheme,
|
|
27
36
|
onClick: () => onProductCardClick(product)
|
|
28
|
-
}, product.id)),
|
|
37
|
+
}, product.id ?? `product-${index}`)),
|
|
29
38
|
theme: finalTheme
|
|
30
39
|
});
|
|
31
40
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_ResultsGridView = require('./ResultsGridView.cjs');
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
let framer_motion = require("framer-motion");
|
|
5
|
+
|
|
6
|
+
//#region src/components/FloatingChat/components/SlideChatContent.tsx
|
|
7
|
+
const slideVariants = {
|
|
8
|
+
enter: (isResults) => ({ x: isResults ? "100%" : "-100%" }),
|
|
9
|
+
center: { x: 0 },
|
|
10
|
+
exit: (isResults) => ({ x: isResults ? "100%" : "-100%" })
|
|
11
|
+
};
|
|
12
|
+
const SlideChatContent = ({ isResultsView, isResultsViewRef, resultsViewData, onBackToChat, onProductCardClick, theme, chatMessages, scrollToBottom }) => {
|
|
13
|
+
const resultsViewContent = resultsViewData && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ResultsGridView.ResultsGridView, {
|
|
14
|
+
theme,
|
|
15
|
+
searchQuery: resultsViewData.searchQuery,
|
|
16
|
+
products: resultsViewData.products,
|
|
17
|
+
onBackToChat,
|
|
18
|
+
onProductCardClick
|
|
19
|
+
});
|
|
20
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
21
|
+
className: "envive-tw-relative envive-tw-min-h-[200px] envive-tw-w-full envive-tw-overflow-hidden",
|
|
22
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.AnimatePresence, {
|
|
23
|
+
initial: false,
|
|
24
|
+
mode: "wait",
|
|
25
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.div, {
|
|
26
|
+
custom: isResultsView,
|
|
27
|
+
variants: slideVariants,
|
|
28
|
+
initial: "enter",
|
|
29
|
+
animate: "center",
|
|
30
|
+
exit: "exit",
|
|
31
|
+
transition: {
|
|
32
|
+
duration: .3,
|
|
33
|
+
ease: "easeInOut"
|
|
34
|
+
},
|
|
35
|
+
onAnimationComplete: () => {
|
|
36
|
+
if (!isResultsViewRef.current) scrollToBottom();
|
|
37
|
+
},
|
|
38
|
+
className: "envive-tw-w-full",
|
|
39
|
+
children: isResultsView ? resultsViewContent : chatMessages
|
|
40
|
+
}, isResultsView ? "results" : "chat")
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.SlideChatContent = SlideChatContent;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ResultsGridView } from "./ResultsGridView.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
4
|
+
|
|
5
|
+
//#region src/components/FloatingChat/components/SlideChatContent.tsx
|
|
6
|
+
const slideVariants = {
|
|
7
|
+
enter: (isResults) => ({ x: isResults ? "100%" : "-100%" }),
|
|
8
|
+
center: { x: 0 },
|
|
9
|
+
exit: (isResults) => ({ x: isResults ? "100%" : "-100%" })
|
|
10
|
+
};
|
|
11
|
+
const SlideChatContent = ({ isResultsView, isResultsViewRef, resultsViewData, onBackToChat, onProductCardClick, theme, chatMessages, scrollToBottom }) => {
|
|
12
|
+
const resultsViewContent = resultsViewData && /* @__PURE__ */ jsx(ResultsGridView, {
|
|
13
|
+
theme,
|
|
14
|
+
searchQuery: resultsViewData.searchQuery,
|
|
15
|
+
products: resultsViewData.products,
|
|
16
|
+
onBackToChat,
|
|
17
|
+
onProductCardClick
|
|
18
|
+
});
|
|
19
|
+
return /* @__PURE__ */ jsx("div", {
|
|
20
|
+
className: "envive-tw-relative envive-tw-min-h-[200px] envive-tw-w-full envive-tw-overflow-hidden",
|
|
21
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
22
|
+
initial: false,
|
|
23
|
+
mode: "wait",
|
|
24
|
+
children: /* @__PURE__ */ jsx(motion.div, {
|
|
25
|
+
custom: isResultsView,
|
|
26
|
+
variants: slideVariants,
|
|
27
|
+
initial: "enter",
|
|
28
|
+
animate: "center",
|
|
29
|
+
exit: "exit",
|
|
30
|
+
transition: {
|
|
31
|
+
duration: .3,
|
|
32
|
+
ease: "easeInOut"
|
|
33
|
+
},
|
|
34
|
+
onAnimationComplete: () => {
|
|
35
|
+
if (!isResultsViewRef.current) scrollToBottom();
|
|
36
|
+
},
|
|
37
|
+
className: "envive-tw-w-full",
|
|
38
|
+
children: isResultsView ? resultsViewContent : chatMessages
|
|
39
|
+
}, isResultsView ? "results" : "chat")
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { SlideChatContent };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const require_Layout = require('./Layout.cjs');
|
|
2
|
+
const require_ResultsGridView = require('./ResultsGridView.cjs');
|
|
3
|
+
const require_SlideChatContent = require('./SlideChatContent.cjs');
|
|
2
4
|
const require_UserMessage = require('./UserMessage.cjs');
|
|
3
5
|
const require_DocumentRetrievalCardsCarousel = require('./DocumentRetrievalCardsCarousel.cjs');
|
|
4
6
|
const require_OrderLookupCardCarousel = require('./OrderLookupCardCarousel.cjs');
|
|
@@ -13,6 +15,8 @@ const require_ModalSheet = require('./ModalSheet.cjs');
|
|
|
13
15
|
//#region src/components/FloatingChat/components/index.ts
|
|
14
16
|
const FloatingChatComponents = {
|
|
15
17
|
Layout: require_Layout.Layout,
|
|
18
|
+
ResultsGridView: require_ResultsGridView.ResultsGridView,
|
|
19
|
+
SlideChatContent: require_SlideChatContent.SlideChatContent,
|
|
16
20
|
UserMessage: require_UserMessage.UserMessage,
|
|
17
21
|
AgentMessage: require_AgentMessage.AgentMessage,
|
|
18
22
|
ChatMessages: require_ChatMessages.ChatMessages,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Layout } from "./Layout.js";
|
|
2
|
+
import { ResultsGridView } from "./ResultsGridView.js";
|
|
3
|
+
import { SlideChatContent } from "./SlideChatContent.js";
|
|
2
4
|
import { UserMessage } from "./UserMessage.js";
|
|
3
5
|
import { DocumentRetrievalCardsCarousel } from "./DocumentRetrievalCardsCarousel.js";
|
|
4
6
|
import { OrderLookupCardCarousel } from "./OrderLookupCardCarousel.js";
|
|
@@ -13,6 +15,8 @@ import { ModalSheet } from "./ModalSheet.js";
|
|
|
13
15
|
//#region src/components/FloatingChat/components/index.ts
|
|
14
16
|
const FloatingChatComponents = {
|
|
15
17
|
Layout,
|
|
18
|
+
ResultsGridView,
|
|
19
|
+
SlideChatContent,
|
|
16
20
|
UserMessage,
|
|
17
21
|
AgentMessage,
|
|
18
22
|
ChatMessages,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
|
|
4
|
+
//#region src/components/FloatingChat/hooks/useProductResultsView.ts
|
|
5
|
+
const useProductResultsView = ({ scrollToBottom }) => {
|
|
6
|
+
const [resultsViewData, setResultsViewData] = (0, react.useState)(null);
|
|
7
|
+
const isResultsView = resultsViewData !== null;
|
|
8
|
+
const scrollContainerRef = (0, react.useRef)(null);
|
|
9
|
+
const isResultsViewRef = (0, react.useRef)(isResultsView);
|
|
10
|
+
isResultsViewRef.current = isResultsView;
|
|
11
|
+
const handleBackToChat = () => {
|
|
12
|
+
setResultsViewData(null);
|
|
13
|
+
};
|
|
14
|
+
(0, react.useEffect)(() => {
|
|
15
|
+
if (isResultsView && scrollContainerRef.current) scrollContainerRef.current.scrollTo({
|
|
16
|
+
top: 0,
|
|
17
|
+
behavior: "smooth"
|
|
18
|
+
});
|
|
19
|
+
}, [isResultsView]);
|
|
20
|
+
const prevIsResultsViewRef = (0, react.useRef)(isResultsView);
|
|
21
|
+
(0, react.useEffect)(() => {
|
|
22
|
+
if (prevIsResultsViewRef.current && !isResultsView) scrollToBottom();
|
|
23
|
+
prevIsResultsViewRef.current = isResultsView;
|
|
24
|
+
}, [isResultsView, scrollToBottom]);
|
|
25
|
+
return {
|
|
26
|
+
resultsViewData,
|
|
27
|
+
setResultsViewData,
|
|
28
|
+
isResultsView,
|
|
29
|
+
scrollContainerRef,
|
|
30
|
+
isResultsViewRef,
|
|
31
|
+
handleBackToChat
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.useProductResultsView = useProductResultsView;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/FloatingChat/hooks/useProductResultsView.ts
|
|
4
|
+
const useProductResultsView = ({ scrollToBottom }) => {
|
|
5
|
+
const [resultsViewData, setResultsViewData] = useState(null);
|
|
6
|
+
const isResultsView = resultsViewData !== null;
|
|
7
|
+
const scrollContainerRef = useRef(null);
|
|
8
|
+
const isResultsViewRef = useRef(isResultsView);
|
|
9
|
+
isResultsViewRef.current = isResultsView;
|
|
10
|
+
const handleBackToChat = () => {
|
|
11
|
+
setResultsViewData(null);
|
|
12
|
+
};
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (isResultsView && scrollContainerRef.current) scrollContainerRef.current.scrollTo({
|
|
15
|
+
top: 0,
|
|
16
|
+
behavior: "smooth"
|
|
17
|
+
});
|
|
18
|
+
}, [isResultsView]);
|
|
19
|
+
const prevIsResultsViewRef = useRef(isResultsView);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (prevIsResultsViewRef.current && !isResultsView) scrollToBottom();
|
|
22
|
+
prevIsResultsViewRef.current = isResultsView;
|
|
23
|
+
}, [isResultsView, scrollToBottom]);
|
|
24
|
+
return {
|
|
25
|
+
resultsViewData,
|
|
26
|
+
setResultsViewData,
|
|
27
|
+
isResultsView,
|
|
28
|
+
scrollContainerRef,
|
|
29
|
+
isResultsViewRef,
|
|
30
|
+
handleBackToChat
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { useProductResultsView };
|
|
@@ -76,11 +76,38 @@ const getCleanOrders = (messages) => {
|
|
|
76
76
|
return null;
|
|
77
77
|
}).filter((o) => o !== null);
|
|
78
78
|
};
|
|
79
|
+
const MOST_RELEVANT_DISPLAY_LIMIT = 8;
|
|
80
|
+
/**
|
|
81
|
+
* Extracts the search query from a message block (or previous blocks) that led to product results.
|
|
82
|
+
* Looks for QueryTyped (metadata.content) or SuggestionClicked (metadata.suggestionContent).
|
|
83
|
+
*/
|
|
84
|
+
const getSearchQueryFromMessageBlock = (messages, productBlockIndex) => {
|
|
85
|
+
for (let i = productBlockIndex; i >= 0; i -= 1) {
|
|
86
|
+
const block = messages[i];
|
|
87
|
+
const queryTyped = block.find((msg) => msg.type === __envive_ai_react_hooks_application_models.MessageType.QueryTyped);
|
|
88
|
+
if (queryTyped && "content" in queryTyped.metadata) return queryTyped.metadata.content ?? "";
|
|
89
|
+
const suggestionClicked = block.find((msg) => msg.type === __envive_ai_react_hooks_application_models.MessageType.SuggestionClicked);
|
|
90
|
+
if (suggestionClicked && "suggestionContent" in suggestionClicked.metadata) return suggestionClicked.metadata.suggestionContent ?? "";
|
|
91
|
+
}
|
|
92
|
+
return "";
|
|
93
|
+
};
|
|
94
|
+
const getProductCarouselDisplayInfo = (products, numberOfProducts, displayLimit = MOST_RELEVANT_DISPLAY_LIMIT) => {
|
|
95
|
+
const totalProducts = numberOfProducts ?? products.length;
|
|
96
|
+
const areProductsMoreThanDisplayLimit = totalProducts > displayLimit;
|
|
97
|
+
return {
|
|
98
|
+
totalProducts,
|
|
99
|
+
areProductsMoreThanDisplayLimit,
|
|
100
|
+
displayedProducts: areProductsMoreThanDisplayLimit ? products.slice(0, displayLimit) : products
|
|
101
|
+
};
|
|
102
|
+
};
|
|
79
103
|
|
|
80
104
|
//#endregion
|
|
105
|
+
exports.MOST_RELEVANT_DISPLAY_LIMIT = MOST_RELEVANT_DISPLAY_LIMIT;
|
|
81
106
|
exports.checkIfHideAgentName = checkIfHideAgentName;
|
|
82
107
|
exports.getCleanDocuments = getCleanDocuments;
|
|
83
108
|
exports.getCleanOrders = getCleanOrders;
|
|
84
109
|
exports.getCleanProducts = getCleanProducts;
|
|
85
110
|
exports.getCleanReviews = getCleanReviews;
|
|
86
|
-
exports.getGroupableMessages = getGroupableMessages;
|
|
111
|
+
exports.getGroupableMessages = getGroupableMessages;
|
|
112
|
+
exports.getProductCarouselDisplayInfo = getProductCarouselDisplayInfo;
|
|
113
|
+
exports.getSearchQueryFromMessageBlock = getSearchQueryFromMessageBlock;
|
|
@@ -75,6 +75,30 @@ const getCleanOrders = (messages) => {
|
|
|
75
75
|
return null;
|
|
76
76
|
}).filter((o) => o !== null);
|
|
77
77
|
};
|
|
78
|
+
const MOST_RELEVANT_DISPLAY_LIMIT = 8;
|
|
79
|
+
/**
|
|
80
|
+
* Extracts the search query from a message block (or previous blocks) that led to product results.
|
|
81
|
+
* Looks for QueryTyped (metadata.content) or SuggestionClicked (metadata.suggestionContent).
|
|
82
|
+
*/
|
|
83
|
+
const getSearchQueryFromMessageBlock = (messages, productBlockIndex) => {
|
|
84
|
+
for (let i = productBlockIndex; i >= 0; i -= 1) {
|
|
85
|
+
const block = messages[i];
|
|
86
|
+
const queryTyped = block.find((msg) => msg.type === MessageType.QueryTyped);
|
|
87
|
+
if (queryTyped && "content" in queryTyped.metadata) return queryTyped.metadata.content ?? "";
|
|
88
|
+
const suggestionClicked = block.find((msg) => msg.type === MessageType.SuggestionClicked);
|
|
89
|
+
if (suggestionClicked && "suggestionContent" in suggestionClicked.metadata) return suggestionClicked.metadata.suggestionContent ?? "";
|
|
90
|
+
}
|
|
91
|
+
return "";
|
|
92
|
+
};
|
|
93
|
+
const getProductCarouselDisplayInfo = (products, numberOfProducts, displayLimit = MOST_RELEVANT_DISPLAY_LIMIT) => {
|
|
94
|
+
const totalProducts = numberOfProducts ?? products.length;
|
|
95
|
+
const areProductsMoreThanDisplayLimit = totalProducts > displayLimit;
|
|
96
|
+
return {
|
|
97
|
+
totalProducts,
|
|
98
|
+
areProductsMoreThanDisplayLimit,
|
|
99
|
+
displayedProducts: areProductsMoreThanDisplayLimit ? products.slice(0, displayLimit) : products
|
|
100
|
+
};
|
|
101
|
+
};
|
|
78
102
|
|
|
79
103
|
//#endregion
|
|
80
|
-
export { checkIfHideAgentName, getCleanDocuments, getCleanOrders, getCleanProducts, getCleanReviews, getGroupableMessages };
|
|
104
|
+
export { MOST_RELEVANT_DISPLAY_LIMIT, checkIfHideAgentName, getCleanDocuments, getCleanOrders, getCleanProducts, getCleanReviews, getGroupableMessages, getProductCarouselDisplayInfo, getSearchQueryFromMessageBlock };
|