@envive-ai/react-widgets-v3 0.3.2
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/CXIntegration/hooks/useUnifiedCXButton.cjs +23 -0
- package/dist/CXIntegration/hooks/useUnifiedCXButton.js +22 -0
- package/dist/CXIntegration/implementations/useDefaultUnifiedCXButton.cjs +11 -0
- package/dist/CXIntegration/implementations/useDefaultUnifiedCXButton.js +10 -0
- package/dist/CXIntegration/implementations/useGladlyUnifiedCXButton.cjs +20 -0
- package/dist/CXIntegration/implementations/useGladlyUnifiedCXButton.js +19 -0
- package/dist/CXIntegration/implementations/useGorgiasUnifiedCXButton.cjs +53 -0
- package/dist/CXIntegration/implementations/useGorgiasUnifiedCXButton.js +52 -0
- package/dist/CXIntegration/implementations/useGrooveUnifiedCXButton.cjs +45 -0
- package/dist/CXIntegration/implementations/useGrooveUnifiedCXButton.js +44 -0
- package/dist/CXIntegration/implementations/useKustomerUnifiedCXButton.cjs +70 -0
- package/dist/CXIntegration/implementations/useKustomerUnifiedCXButton.js +69 -0
- package/dist/CXIntegration/implementations/useReDoUnifiedCXButton.cjs +59 -0
- package/dist/CXIntegration/implementations/useReDoUnifiedCXButton.js +58 -0
- package/dist/CXIntegration/implementations/useRichpanelUnifiedCXButton.cjs +65 -0
- package/dist/CXIntegration/implementations/useRichpanelUnifiedCXButton.js +64 -0
- package/dist/CXIntegration/implementations/useShopifyChatUnifiedCXButton.cjs +53 -0
- package/dist/CXIntegration/implementations/useShopifyChatUnifiedCXButton.js +52 -0
- package/dist/CXIntegration/implementations/useTidioUnifiedCXButton.cjs +18 -0
- package/dist/CXIntegration/implementations/useTidioUnifiedCXButton.js +17 -0
- package/dist/CXIntegration/implementations/useZendeskUnifiedCXButton.cjs +54 -0
- package/dist/CXIntegration/implementations/useZendeskUnifiedCXButton.js +53 -0
- package/dist/CXIntegration/implementations/useZowieUnifiedCXButton.cjs +18 -0
- package/dist/CXIntegration/implementations/useZowieUnifiedCXButton.js +17 -0
- package/dist/CXIntegration/types.cjs +19 -0
- package/dist/CXIntegration/types.js +18 -0
- package/dist/CXIntegration/utils/functions.cjs +30 -0
- package/dist/CXIntegration/utils/functions.js +30 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/hocs/withBaseWidget/index.cjs +3 -0
- package/dist/hocs/withBaseWidget/index.d.cts +3 -0
- package/dist/hocs/withBaseWidget/index.d.ts +3 -0
- package/dist/hocs/withBaseWidget/index.js +3 -0
- package/dist/hocs/withBaseWidget/types.d.cts +37 -0
- package/dist/hocs/withBaseWidget/types.d.ts +39 -0
- package/dist/hocs/withBaseWidget/withBaseWidget.cjs +101 -0
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +10 -0
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +10 -0
- package/dist/hocs/withBaseWidget/withBaseWidget.js +100 -0
- package/dist/hooks/dist/application/models/api/orgConfigResults.d.ts +1 -0
- package/dist/hooks/dist/application/models/frontendConfig.d.ts +1 -0
- package/dist/hooks/dist/contexts/amplitudeContext/amplitudeContext.d.ts +2 -0
- package/dist/hooks/dist/contexts/amplitudeContext/index.d.ts +2 -0
- package/dist/hooks/dist/contexts/featureFlagServiceContext/featureFlagServiceContext.d.ts +2 -0
- package/dist/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.cts +8 -0
- package/dist/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +11 -0
- package/dist/hooks/dist/contexts/hardcopyContext/index.d.ts +1 -0
- package/dist/hooks/dist/contexts/types.d.cts +44 -0
- package/dist/hooks/dist/contexts/types.d.ts +47 -0
- package/dist/hooks/dist/contexts/typesV3.d.cts +201 -0
- package/dist/hooks/dist/contexts/typesV3.d.ts +201 -0
- package/dist/hooks/dist/services/amplitudeService/amplitudeService.d.cts +36 -0
- package/dist/hooks/dist/services/amplitudeService/amplitudeService.d.ts +37 -0
- package/dist/hooks/dist/types/customerService.d.cts +18 -0
- package/dist/hooks/dist/types/customerService.d.ts +18 -0
- package/dist/stories/SalesAgentTest/index.cjs +0 -0
- package/dist/stories/SalesAgentTest/index.d.cts +1 -0
- package/dist/stories/SalesAgentTest/index.d.ts +1 -0
- package/dist/stories/SalesAgentTest/index.js +0 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +98 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +19 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +19 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +96 -0
- package/dist/widgets/ChatPreviewComparisonWidget/index.cjs +4 -0
- package/dist/widgets/ChatPreviewComparisonWidget/index.d.cts +2 -0
- package/dist/widgets/ChatPreviewComparisonWidget/index.d.ts +2 -0
- package/dist/widgets/ChatPreviewComparisonWidget/index.js +3 -0
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.cjs +44 -0
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +16 -0
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +16 -0
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.js +42 -0
- package/dist/widgets/ChatPreviewLoadingWidget/index.cjs +4 -0
- package/dist/widgets/ChatPreviewLoadingWidget/index.d.cts +2 -0
- package/dist/widgets/ChatPreviewLoadingWidget/index.d.ts +2 -0
- package/dist/widgets/ChatPreviewLoadingWidget/index.js +3 -0
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +86 -0
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +19 -0
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +19 -0
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +84 -0
- package/dist/widgets/ChatPreviewWidget/index.cjs +4 -0
- package/dist/widgets/ChatPreviewWidget/index.d.cts +2 -0
- package/dist/widgets/ChatPreviewWidget/index.d.ts +2 -0
- package/dist/widgets/ChatPreviewWidget/index.js +3 -0
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +66 -0
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +64 -0
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +70 -0
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +10 -0
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +10 -0
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +69 -0
- package/dist/widgets/FloatingChatWidget/constants.cjs +6 -0
- package/dist/widgets/FloatingChatWidget/constants.d.cts +4 -0
- package/dist/widgets/FloatingChatWidget/constants.d.ts +4 -0
- package/dist/widgets/FloatingChatWidget/constants.js +5 -0
- package/dist/widgets/FloatingChatWidget/index.cjs +5 -0
- package/dist/widgets/FloatingChatWidget/index.d.cts +3 -0
- package/dist/widgets/FloatingChatWidget/index.d.ts +3 -0
- package/dist/widgets/FloatingChatWidget/index.js +4 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +60 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +19 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +19 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +58 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/index.cjs +4 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/index.d.cts +2 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/index.d.ts +2 -0
- package/dist/widgets/PromptButtonCarouselWithImageWidget/index.js +3 -0
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +64 -0
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +14 -0
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +14 -0
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +63 -0
- package/dist/widgets/PromptCarouselWidget/index.cjs +3 -0
- package/dist/widgets/PromptCarouselWidget/index.d.cts +2 -0
- package/dist/widgets/PromptCarouselWidget/index.d.ts +2 -0
- package/dist/widgets/PromptCarouselWidget/index.js +3 -0
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +35 -0
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.cts +14 -0
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +14 -0
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +34 -0
- package/dist/widgets/SocialProofFlowWidget/index.cjs +3 -0
- package/dist/widgets/SocialProofFlowWidget/index.d.cts +2 -0
- package/dist/widgets/SocialProofFlowWidget/index.d.ts +2 -0
- package/dist/widgets/SocialProofFlowWidget/index.js +3 -0
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +118 -0
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +19 -0
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +19 -0
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +116 -0
- package/dist/widgets/SocialProofWidget/index.cjs +4 -0
- package/dist/widgets/SocialProofWidget/index.d.cts +2 -0
- package/dist/widgets/SocialProofWidget/index.d.ts +2 -0
- package/dist/widgets/SocialProofWidget/index.js +3 -0
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +67 -0
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +14 -0
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +14 -0
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +66 -0
- package/dist/widgets/TitledPromptCarouselWidget/index.cjs +3 -0
- package/dist/widgets/TitledPromptCarouselWidget/index.d.cts +2 -0
- package/dist/widgets/TitledPromptCarouselWidget/index.d.ts +2 -0
- package/dist/widgets/TitledPromptCarouselWidget/index.js +3 -0
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.cjs +35 -0
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +14 -0
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +14 -0
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +34 -0
- package/dist/widgets/TypingAnimationFlowWidget/index.cjs +3 -0
- package/dist/widgets/TypingAnimationFlowWidget/index.d.cts +2 -0
- package/dist/widgets/TypingAnimationFlowWidget/index.d.ts +2 -0
- package/dist/widgets/TypingAnimationFlowWidget/index.js +3 -0
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +90 -0
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +19 -0
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +19 -0
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +88 -0
- package/dist/widgets/TypingAnimationWidget/index.cjs +4 -0
- package/dist/widgets/TypingAnimationWidget/index.d.cts +2 -0
- package/dist/widgets/TypingAnimationWidget/index.d.ts +2 -0
- package/dist/widgets/TypingAnimationWidget/index.js +3 -0
- package/dist/widgets/dist/SearchResults/SearchResults.d.cts +15 -0
- package/dist/widgets/dist/SearchResults/SearchResults.d.ts +15 -0
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +9 -0
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.ts +9 -0
- package/dist/widgets/dist/SearchResults/index.d.ts +2 -0
- package/dist/widgets/dist/SearchResults/types.d.cts +20 -0
- package/dist/widgets/dist/SearchResults/types.d.ts +20 -0
- package/dist/widgets/dist/SearchZeroState/SearchZeroState.d.cts +10 -0
- package/dist/widgets/dist/SearchZeroState/SearchZeroState.d.ts +10 -0
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +18 -0
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +18 -0
- package/dist/widgets/dist/SearchZeroState/index.d.ts +4 -0
- package/dist/widgets/dist/SearchZeroState/types.d.cts +13 -0
- package/dist/widgets/dist/SearchZeroState/types.d.ts +13 -0
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +36 -0
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.ts +36 -0
- package/dist/widgets/dist/SuggestionBar/index.d.ts +2 -0
- package/dist/widgets/dist/SuggestionBar/types.d.cts +9 -0
- package/dist/widgets/dist/SuggestionBar/types.d.ts +9 -0
- package/dist/widgets/dist/SuggestionButtonContainer/SuggestionButtonContainer.d.cts +9 -0
- package/dist/widgets/dist/SuggestionButtonContainer/SuggestionButtonContainer.d.ts +9 -0
- package/dist/widgets/dist/SuggestionButtonContainer/types.d.cts +20 -0
- package/dist/widgets/dist/SuggestionButtonContainer/types.d.ts +20 -0
- package/dist/widgets/dist/config/BaseWidgetConfig.d.cts +13 -0
- package/dist/widgets/dist/config/BaseWidgetConfig.d.ts +13 -0
- package/dist/widgets/dist/config/WidgetType.d.cts +23 -0
- package/dist/widgets/dist/config/WidgetType.d.ts +23 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/response.d.cts +14 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/response.d.ts +14 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/search.d.cts +15 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/api/search.d.ts +15 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.cts +73 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.ts +73 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.cts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.ts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.cts +25 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.ts +25 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.cts +35 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.ts +35 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.cts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.ts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.cts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.ts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.cts +14 -0
- package/dist/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.ts +15 -0
- package/dist/widgets/dist/packages/hooks/dist/contexts/types.d.cts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/contexts/types.d.ts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.cts +60 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.ts +60 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/utils.d.cts +11 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/utils.d.ts +11 -0
- package/dist/widgets/dist/packages/hooks/dist/types/search-filter-types.d.cts +28 -0
- package/dist/widgets/dist/packages/hooks/dist/types/search-filter-types.d.ts +28 -0
- package/dist/widgets/dist/packages/hooks/dist/types/test-types.d.cts +10 -0
- package/dist/widgets/dist/packages/hooks/dist/types/test-types.d.ts +10 -0
- package/dist/widgets/hooks/useGetWidgetStatus.cjs +27 -0
- package/dist/widgets/hooks/useGetWidgetStatus.js +26 -0
- package/dist/widgets/utils/functions.cjs +55 -0
- package/dist/widgets/utils/functions.js +48 -0
- package/dist/widgets-v2/SearchResults/index.cjs +5 -0
- package/dist/widgets-v2/SearchResults/index.d.cts +3 -0
- package/dist/widgets-v2/SearchResults/index.d.ts +4 -0
- package/dist/widgets-v2/SearchResults/index.js +3 -0
- package/dist/widgets-v2/SearchZeroState/index.cjs +8 -0
- package/dist/widgets-v2/SearchZeroState/index.d.cts +5 -0
- package/dist/widgets-v2/SearchZeroState/index.d.ts +6 -0
- package/dist/widgets-v2/SearchZeroState/index.js +3 -0
- package/dist/widgets-v2/SuggestionBar/index.cjs +5 -0
- package/dist/widgets-v2/SuggestionBar/index.d.cts +3 -0
- package/dist/widgets-v2/SuggestionBar/index.d.ts +4 -0
- package/dist/widgets-v2/SuggestionBar/index.js +3 -0
- package/dist/widgets-v2/SuggestionButtonContainer/index.cjs +5 -0
- package/dist/widgets-v2/SuggestionButtonContainer/index.d.cts +3 -0
- package/dist/widgets-v2/SuggestionButtonContainer/index.d.ts +3 -0
- package/dist/widgets-v2/SuggestionButtonContainer/index.js +3 -0
- package/package.json +158 -0
- package/src/CXIntegration/hooks/useUnifiedCXButton.ts +38 -0
- package/src/CXIntegration/implementations/useDefaultUnifiedCXButton.ts +8 -0
- package/src/CXIntegration/implementations/useGladlyUnifiedCXButton.ts +28 -0
- package/src/CXIntegration/implementations/useGorgiasUnifiedCXButton.ts +67 -0
- package/src/CXIntegration/implementations/useGrooveUnifiedCXButton.ts +83 -0
- package/src/CXIntegration/implementations/useKustomerUnifiedCXButton.ts +120 -0
- package/src/CXIntegration/implementations/useReDoUnifiedCXButton.ts +80 -0
- package/src/CXIntegration/implementations/useRichpanelUnifiedCXButton.ts +83 -0
- package/src/CXIntegration/implementations/useShopifyChatUnifiedCXButton.ts +78 -0
- package/src/CXIntegration/implementations/useTidioUnifiedCXButton.ts +34 -0
- package/src/CXIntegration/implementations/useZendeskUnifiedCXButton.ts +69 -0
- package/src/CXIntegration/implementations/useZowieUnifiedCXButton.ts +34 -0
- package/src/CXIntegration/types.ts +24 -0
- package/src/CXIntegration/utils/functions.ts +50 -0
- package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +689 -0
- package/src/hocs/withBaseWidget/index.ts +2 -0
- package/src/hocs/withBaseWidget/types.ts +39 -0
- package/src/hocs/withBaseWidget/withBaseWidget.tsx +126 -0
- package/src/stories/FloatingChatWidget.stories.tsx +56 -0
- package/src/stories/PromptButtonCarouselWithImageWidget.stories.tsx +54 -0
- package/src/stories/PromptCarouselWidget.stories.tsx +54 -0
- package/src/stories/SalesAgentTest/SalesAgentTest.stories.tsx +18 -0
- package/src/stories/SalesAgentTest/SalesAgentTest.tsx +111 -0
- package/src/stories/SalesAgentTest/index.ts +0 -0
- package/src/stories/SearchResults.stories.tsx +29 -0
- package/src/stories/SearchZeroState.stories.tsx +52 -0
- package/src/stories/SocialProofFlowWidget.stories.tsx +77 -0
- package/src/stories/SuggestionBar.stories.tsx +45 -0
- package/src/stories/TitledPromptCarouselWidget.stories.tsx +71 -0
- package/src/stories/TypingAnimationFlowWidget.stories.tsx +67 -0
- package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +152 -0
- package/src/widgets/ChatPreviewComparisonWidget/index.ts +7 -0
- package/src/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.tsx +82 -0
- package/src/widgets/ChatPreviewLoadingWidget/index.ts +7 -0
- package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +119 -0
- package/src/widgets/ChatPreviewWidget/index.ts +4 -0
- package/src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx +115 -0
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +110 -0
- package/src/widgets/FloatingChatWidget/constants.ts +1 -0
- package/src/widgets/FloatingChatWidget/index.ts +5 -0
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +87 -0
- package/src/widgets/PromptButtonCarouselWithImageWidget/index.ts +6 -0
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +83 -0
- package/src/widgets/PromptCarouselWidget/index.ts +2 -0
- package/src/widgets/SocialProofFlowWidget/SocialProofFlowWidget.tsx +61 -0
- package/src/widgets/SocialProofFlowWidget/index.ts +4 -0
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +160 -0
- package/src/widgets/SocialProofWidget/index.ts +2 -0
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +93 -0
- package/src/widgets/TitledPromptCarouselWidget/index.ts +2 -0
- package/src/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.tsx +61 -0
- package/src/widgets/TypingAnimationFlowWidget/index.ts +4 -0
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +115 -0
- package/src/widgets/TypingAnimationWidget/index.ts +2 -0
- package/src/widgets/hooks/useGetWidgetStatus.tsx +29 -0
- package/src/widgets/utils/functions.ts +104 -0
- package/src/widgets-v2/SearchResults/index.ts +3 -0
- package/src/widgets-v2/SearchZeroState/index.ts +15 -0
- package/src/widgets-v2/SuggestionBar/index.ts +6 -0
- package/src/widgets-v2/SuggestionButtonContainer/index.ts +6 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { TitledPromptCarouselWidget } from '../widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Widgets V3/TitledPromptCarouselWidget',
|
|
6
|
+
component: TitledPromptCarouselWidget,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
args: {
|
|
9
|
+
widgetConfigId: 'titled-prompt-carousel-test-light-widget',
|
|
10
|
+
},
|
|
11
|
+
argTypes: {
|
|
12
|
+
widgetConfigId: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description:
|
|
15
|
+
'Unique identifier for the widget configuration. The widget will fetch the widget config and hardcopy content based on this ID.',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
docs: {
|
|
20
|
+
description: {
|
|
21
|
+
component:
|
|
22
|
+
'TitledPromptCarouselWidget is a widget wrapper that combines a Title component with a PromptCarousel component. It includes base widget functionality such as visibility tracking, widget config fetching and hardcopy content fetching. The widget automatically fetches title label, title logo, and prompt button texts from hardcopy and widget config based on the widgetConfigId.',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
decorators: [
|
|
27
|
+
Story => (
|
|
28
|
+
<div
|
|
29
|
+
style={{
|
|
30
|
+
padding: '1rem',
|
|
31
|
+
maxWidth: '100%',
|
|
32
|
+
overflow: 'hidden',
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<Story />
|
|
36
|
+
</div>
|
|
37
|
+
),
|
|
38
|
+
],
|
|
39
|
+
} satisfies Meta<typeof TitledPromptCarouselWidget>;
|
|
40
|
+
|
|
41
|
+
export default meta;
|
|
42
|
+
|
|
43
|
+
type Story = StoryObj<typeof meta>;
|
|
44
|
+
|
|
45
|
+
export const Light: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
widgetConfigId: 'titled-prompt-carousel-test-light-widget',
|
|
48
|
+
},
|
|
49
|
+
parameters: {
|
|
50
|
+
docs: {
|
|
51
|
+
description: {
|
|
52
|
+
story:
|
|
53
|
+
'TitledPromptCarouselWidget in light mode. The widget displays with light prompt buttons.',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const Dark: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
widgetConfigId: 'titled-prompt-carousel-test-dark-widget',
|
|
62
|
+
},
|
|
63
|
+
parameters: {
|
|
64
|
+
docs: {
|
|
65
|
+
description: {
|
|
66
|
+
story:
|
|
67
|
+
'TitledPromptCarouselWidget in dark mode. The widget displays with dark prompt buttons.',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { TypingAnimationFlowWidget } from '../widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Widgets V3/TypingAnimationFlowWidget',
|
|
6
|
+
component: TypingAnimationFlowWidget,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
args: {
|
|
9
|
+
widgetConfigId: 'typing-animation-test-light-widget',
|
|
10
|
+
},
|
|
11
|
+
argTypes: {
|
|
12
|
+
widgetConfigId: {
|
|
13
|
+
control: 'select',
|
|
14
|
+
options: ['typing-animation-test-light-widget', 'typing-animation-test-dark-widget'],
|
|
15
|
+
description:
|
|
16
|
+
'Unique identifier for the widget configuration. The widget will fetch the widget config based on this ID.',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
parameters: {
|
|
20
|
+
docs: {
|
|
21
|
+
description: {
|
|
22
|
+
component:
|
|
23
|
+
'TypingAnimationFlowWidget is a widget wrapper around TypingAnimation, ChatPreviewLoading and ChatPreview that includes base widget functionality such as visibility tracking, widget config fetching and hardcopy content fetching. The widget automatically fetches typing animation content (title, headline, animated text sequence, prompt buttons) from hardcopy and widget config based on the widgetConfigId. It handles post-interaction actions by transitioning to ChatPreview widget when the user interacts.',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
decorators: [
|
|
28
|
+
Story => (
|
|
29
|
+
<div
|
|
30
|
+
style={{
|
|
31
|
+
padding: '1rem',
|
|
32
|
+
maxWidth: '100%',
|
|
33
|
+
overflow: 'hidden',
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<Story />
|
|
37
|
+
</div>
|
|
38
|
+
),
|
|
39
|
+
],
|
|
40
|
+
} satisfies Meta<typeof TypingAnimationFlowWidget>;
|
|
41
|
+
|
|
42
|
+
export default meta;
|
|
43
|
+
|
|
44
|
+
type Story = StoryObj<typeof meta>;
|
|
45
|
+
|
|
46
|
+
export const Playground: Story = {
|
|
47
|
+
parameters: {
|
|
48
|
+
docs: {
|
|
49
|
+
description: {
|
|
50
|
+
story:
|
|
51
|
+
'Experiment with different widgetConfigId values. The widget will fetch typing animation content (title, headline, animated text sequence, prompt buttons) from hardcopy content and widget config based on the widgetConfigId. After user interaction, it will transition to ChatPreview widget.',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const LightButtons: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
widgetConfigId: 'typing-animation-test-light-widget',
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const DarkButtons: Story = {
|
|
64
|
+
args: {
|
|
65
|
+
widgetConfigId: 'typing-animation-test-dark-widget',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChatPreviewComparisonWidgetV3Config,
|
|
3
|
+
WidgetTypeV3,
|
|
4
|
+
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
+
import { useAtomValue } from 'jotai';
|
|
6
|
+
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
7
|
+
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
8
|
+
import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
9
|
+
|
|
10
|
+
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
11
|
+
import { useCallback, useMemo } from 'react';
|
|
12
|
+
import {
|
|
13
|
+
ChatElementDisplayLocationV3,
|
|
14
|
+
VariantTypeEnum,
|
|
15
|
+
} from '@envive-ai/react-hooks/application/models';
|
|
16
|
+
import { ChatPreviewComparison } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison';
|
|
17
|
+
import { ChatPreviewComparisonProps } from '@envive-ai/react-toolkit-v3/ChatPreviewComparison/types/types';
|
|
18
|
+
import { variantInfoAtom } from '@envive-ai/react-hooks/atoms/app';
|
|
19
|
+
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
20
|
+
import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
|
|
21
|
+
import { getMessageText, getRecentProductImageUrls } from '../utils/functions';
|
|
22
|
+
import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
|
|
23
|
+
|
|
24
|
+
const ChatPreviewComparisonWidgetHandler = (props: BaseWidgetProps) => {
|
|
25
|
+
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
26
|
+
const { openChat } = useChatToggle();
|
|
27
|
+
|
|
28
|
+
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
29
|
+
|
|
30
|
+
const variantInfo = useAtomValue(variantInfoAtom);
|
|
31
|
+
const productId = variantInfo.variant === VariantTypeEnum.Pdp ? variantInfo.productId : undefined;
|
|
32
|
+
|
|
33
|
+
const { suggestions } = useAtomValue(chatAtom);
|
|
34
|
+
|
|
35
|
+
const promptButtonTexts = useMemo(() => {
|
|
36
|
+
return suggestions.map(suggestion => suggestion.content);
|
|
37
|
+
}, [suggestions]);
|
|
38
|
+
|
|
39
|
+
const messageText = useMemo(() => getMessageText(lastAssistantMessage), [lastAssistantMessage]);
|
|
40
|
+
|
|
41
|
+
const productImageUrls = useMemo(
|
|
42
|
+
() => (lastAssistantMessage ? getRecentProductImageUrls(lastAssistantMessage, productId) : []),
|
|
43
|
+
[lastAssistantMessage, productId],
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const images = useMemo(
|
|
47
|
+
() =>
|
|
48
|
+
productImageUrls
|
|
49
|
+
? productImageUrls.map((url, index) => ({ src: url, alt: `Product Image ${index + 1}` }))
|
|
50
|
+
: [],
|
|
51
|
+
[productImageUrls],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const { hardcopyContent, widgetConfig, uiConfig, isLoading, widgetConfigId } = props;
|
|
55
|
+
|
|
56
|
+
const chatPreviewComparisonWidgetConfig = widgetConfig as ChatPreviewComparisonWidgetV3Config;
|
|
57
|
+
|
|
58
|
+
const id = widgetConfig?.contentId;
|
|
59
|
+
|
|
60
|
+
const hardCopyContent = {
|
|
61
|
+
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
62
|
+
headlineText: hardcopyContent?.values?.headlineText,
|
|
63
|
+
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
64
|
+
messageText,
|
|
65
|
+
promptButtonTexts,
|
|
66
|
+
} as Pick<
|
|
67
|
+
ChatPreviewComparisonProps['widgetContentProps'],
|
|
68
|
+
'headlineText' | 'messageText' | 'promptButtonTexts' | 'textFieldPlaceholderText' | 'titleLabel'
|
|
69
|
+
>;
|
|
70
|
+
|
|
71
|
+
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
72
|
+
|
|
73
|
+
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
74
|
+
|
|
75
|
+
const handlePromptButtonClick = useCallback(
|
|
76
|
+
(text: string) => {
|
|
77
|
+
onTypedMessageSubmitted({ query: text, userTyped: false });
|
|
78
|
+
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_PROMPT_BUTTON);
|
|
79
|
+
},
|
|
80
|
+
[onTypedMessageSubmitted, openChat],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const handleTextFieldClick = useCallback(() => {
|
|
84
|
+
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_COMPARISON_TEXT_FIELD);
|
|
85
|
+
}, [openChat]);
|
|
86
|
+
|
|
87
|
+
if (isLoading) {
|
|
88
|
+
return (
|
|
89
|
+
<ChatPreviewLoadingWidgetWithBaseWidget
|
|
90
|
+
widgetConfigId={widgetConfigId}
|
|
91
|
+
widgetType={WidgetTypeV3.ChatPreviewLoadingV3}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const widgetStyleProps: ChatPreviewComparisonProps['widgetStyleProps'] = {
|
|
97
|
+
theme: Theme.GLOBAL_CUSTOM,
|
|
98
|
+
variant: chatPreviewComparisonWidgetConfig?.variant,
|
|
99
|
+
hideImage:
|
|
100
|
+
images?.length === 0 || images === undefined
|
|
101
|
+
? true
|
|
102
|
+
: chatPreviewComparisonWidgetConfig?.hideImage,
|
|
103
|
+
hideTextField: chatPreviewComparisonWidgetConfig?.hideTextField,
|
|
104
|
+
hideLogo,
|
|
105
|
+
hexCardColor: chatPreviewComparisonWidgetConfig?.hexCardColor,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const widgetContentProps: ChatPreviewComparisonProps['widgetContentProps'] = {
|
|
109
|
+
titleLabel: hardCopyContent?.titleLabel,
|
|
110
|
+
headlineText: hardCopyContent?.headlineText,
|
|
111
|
+
messageText: hardCopyContent?.messageText,
|
|
112
|
+
promptButtonTexts: hardCopyContent?.promptButtonTexts,
|
|
113
|
+
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
114
|
+
images: images ?? [],
|
|
115
|
+
logoSrc: logoSrc ?? undefined,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const widgetEventProps: ChatPreviewComparisonProps['widgetEventProps'] = {
|
|
119
|
+
handlePromptButtonClick,
|
|
120
|
+
handleTextFieldClick,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<ChatPreviewComparison
|
|
125
|
+
baseProps={{ id }}
|
|
126
|
+
widgetStyleProps={widgetStyleProps}
|
|
127
|
+
widgetContentProps={widgetContentProps}
|
|
128
|
+
widgetEventProps={widgetEventProps}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export const ChatPreviewComparisonWidgetWithBaseWidget = withBaseWidget<BaseWidgetProps>(
|
|
134
|
+
ChatPreviewComparisonWidgetHandler,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
export interface ChatPreviewComparisonWidgetProps {
|
|
138
|
+
widgetConfigId: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export const ChatPreviewComparisonWidget = ({
|
|
142
|
+
widgetConfigId,
|
|
143
|
+
}: ChatPreviewComparisonWidgetProps) => {
|
|
144
|
+
return (
|
|
145
|
+
<ChatPreviewComparisonWidgetWithBaseWidget
|
|
146
|
+
widgetConfigId={widgetConfigId}
|
|
147
|
+
widgetType={WidgetTypeV3.ChatPreviewComparisonV3}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
ChatPreviewComparisonWidget.displayName = 'ChatPreviewComparisonWidget';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChatPreviewComparisonWidget,
|
|
3
|
+
ChatPreviewComparisonWidgetWithBaseWidget,
|
|
4
|
+
} from './ChatPreviewComparisonWidget';
|
|
5
|
+
|
|
6
|
+
export { ChatPreviewComparisonWidget, ChatPreviewComparisonWidgetWithBaseWidget };
|
|
7
|
+
export type { ChatPreviewComparisonWidgetProps } from './ChatPreviewComparisonWidget';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChatPreviewLoadingWidgetV3Config,
|
|
3
|
+
WidgetTypeV3,
|
|
4
|
+
} from '@envive-ai/react-hooks/contexts/typesV3';
|
|
5
|
+
import { useAtomValue } from 'jotai';
|
|
6
|
+
|
|
7
|
+
import { ChatPreviewLoading } from '@envive-ai/react-toolkit-v3/ChatPreviewLoading';
|
|
8
|
+
import { chatPreviewLoadingDataAtom } from '@envive-ai/react-hooks/atoms/widget';
|
|
9
|
+
import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
|
|
10
|
+
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
11
|
+
import { PromptCarouselWidget } from '../PromptCarouselWidget/PromptCarouselWidget';
|
|
12
|
+
|
|
13
|
+
const ChatPreviewLoadingWidgetHandler = (props: BaseWidgetProps) => {
|
|
14
|
+
const { widgetConfig, isLoading, widgetConfigId, hardcopyContent, uiConfig } = props;
|
|
15
|
+
|
|
16
|
+
const chatPreviewLoadingWidgetConfig = widgetConfig as ChatPreviewLoadingWidgetV3Config;
|
|
17
|
+
|
|
18
|
+
const id = widgetConfig?.contentId;
|
|
19
|
+
|
|
20
|
+
const chatPreviewLoadingDataMap = useAtomValue(chatPreviewLoadingDataAtom);
|
|
21
|
+
const chatPreviewLoadingData = chatPreviewLoadingDataMap[widgetConfigId] ?? undefined;
|
|
22
|
+
|
|
23
|
+
const isCacheEmpty =
|
|
24
|
+
!chatPreviewLoadingData ||
|
|
25
|
+
Object.values(chatPreviewLoadingData).every(value => value === undefined) ||
|
|
26
|
+
Object.keys(chatPreviewLoadingData).length === 0;
|
|
27
|
+
|
|
28
|
+
if (isLoading && isCacheEmpty) {
|
|
29
|
+
return <ChatPreviewLoading fullIsLoading />;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const titleLabel =
|
|
33
|
+
(hardcopyContent?.values?.titleLabel as string) ?? chatPreviewLoadingData?.titleLabel;
|
|
34
|
+
|
|
35
|
+
const textFieldPlaceholder =
|
|
36
|
+
(hardcopyContent?.values?.textFieldPlaceholderText as string) ??
|
|
37
|
+
chatPreviewLoadingData?.textFieldPlaceholder;
|
|
38
|
+
|
|
39
|
+
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo ?? chatPreviewLoadingData?.hideLogo;
|
|
40
|
+
|
|
41
|
+
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc ?? chatPreviewLoadingData?.logoSrc;
|
|
42
|
+
|
|
43
|
+
const variant = chatPreviewLoadingWidgetConfig?.variant ?? chatPreviewLoadingData?.variant;
|
|
44
|
+
|
|
45
|
+
const hexCardColor =
|
|
46
|
+
chatPreviewLoadingWidgetConfig?.hexCardColor ?? chatPreviewLoadingData?.hexCardColor;
|
|
47
|
+
|
|
48
|
+
const hideTextField =
|
|
49
|
+
chatPreviewLoadingWidgetConfig?.hideTextField ?? chatPreviewLoadingData?.hideTextField;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ChatPreviewLoading
|
|
53
|
+
id={id}
|
|
54
|
+
variant={variant}
|
|
55
|
+
hexCardColor={hexCardColor}
|
|
56
|
+
hideTextField={hideTextField}
|
|
57
|
+
textFieldPlaceholder={textFieldPlaceholder}
|
|
58
|
+
hideLogo={hideLogo}
|
|
59
|
+
logoSrc={logoSrc}
|
|
60
|
+
titleLabel={titleLabel}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const ChatPreviewLoadingWidgetWithBaseWidget = withBaseWidget<BaseWidgetProps>(
|
|
66
|
+
ChatPreviewLoadingWidgetHandler,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export interface ChatPreviewLoadingWidgetProps {
|
|
70
|
+
widgetConfigId: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const ChatPreviewLoadingWidget = ({ widgetConfigId }: ChatPreviewLoadingWidgetProps) => {
|
|
74
|
+
return (
|
|
75
|
+
<ChatPreviewLoadingWidgetWithBaseWidget
|
|
76
|
+
widgetConfigId={widgetConfigId}
|
|
77
|
+
widgetType={WidgetTypeV3.ChatPreviewLoadingV3}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
PromptCarouselWidget.displayName = 'PromptCarouselWidget';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChatPreviewLoadingWidget,
|
|
3
|
+
ChatPreviewLoadingWidgetWithBaseWidget,
|
|
4
|
+
} from './ChatPreviewLoadingWidget';
|
|
5
|
+
|
|
6
|
+
export { ChatPreviewLoadingWidget, ChatPreviewLoadingWidgetWithBaseWidget };
|
|
7
|
+
export type { ChatPreviewLoadingWidgetProps } from './ChatPreviewLoadingWidget';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ChatPreviewWidgetV3Config, WidgetTypeV3 } from '@envive-ai/react-hooks/contexts/typesV3';
|
|
2
|
+
import { useAtomValue } from 'jotai';
|
|
3
|
+
import { useSalesAgent } from '@envive-ai/react-hooks/contexts/salesAgentContext';
|
|
4
|
+
import { useChatToggle } from '@envive-ai/react-hooks/hooks/ChatToggle';
|
|
5
|
+
import { chatAtom, lastAssistantMessageAtom } from '@envive-ai/react-hooks/atoms/chat';
|
|
6
|
+
|
|
7
|
+
import { Theme } from '@envive-ai/react-toolkit-v3/Tokens';
|
|
8
|
+
import { useCallback, useMemo } from 'react';
|
|
9
|
+
import { ChatElementDisplayLocationV3 } from '@envive-ai/react-hooks/application/models';
|
|
10
|
+
import { ChatPreviewProps } from '@envive-ai/react-toolkit-v3/ChatPreview/types/types';
|
|
11
|
+
import { ChatPreview } from '@envive-ai/react-toolkit-v3/ChatPreview';
|
|
12
|
+
import { withBaseWidget } from '../../hocs/withBaseWidget/withBaseWidget';
|
|
13
|
+
import { BaseWidgetProps } from '../../hocs/withBaseWidget/types';
|
|
14
|
+
import { getMessageText } from '../utils/functions';
|
|
15
|
+
import { ChatPreviewLoadingWidgetWithBaseWidget } from '../ChatPreviewLoadingWidget/ChatPreviewLoadingWidget';
|
|
16
|
+
|
|
17
|
+
const ChatPreviewWidgetHandler = (props: BaseWidgetProps) => {
|
|
18
|
+
const { onTypedMessageSubmitted } = useSalesAgent();
|
|
19
|
+
const { openChat } = useChatToggle();
|
|
20
|
+
|
|
21
|
+
const lastAssistantMessage = useAtomValue(lastAssistantMessageAtom);
|
|
22
|
+
|
|
23
|
+
const { suggestions } = useAtomValue(chatAtom);
|
|
24
|
+
|
|
25
|
+
const promptButtonTexts = useMemo(() => {
|
|
26
|
+
return suggestions.map(suggestion => suggestion.content);
|
|
27
|
+
}, [suggestions]);
|
|
28
|
+
|
|
29
|
+
const messageText = useMemo(() => getMessageText(lastAssistantMessage), [lastAssistantMessage]);
|
|
30
|
+
|
|
31
|
+
const { hardcopyContent, widgetConfig, uiConfig, isLoading, widgetConfigId } = props;
|
|
32
|
+
|
|
33
|
+
const chatPreviewWidgetConfig = widgetConfig as ChatPreviewWidgetV3Config;
|
|
34
|
+
|
|
35
|
+
const id = widgetConfig?.contentId;
|
|
36
|
+
|
|
37
|
+
const hardCopyContent = {
|
|
38
|
+
titleLabel: hardcopyContent?.values?.titleLabel,
|
|
39
|
+
textFieldPlaceholderText: hardcopyContent?.values?.textFieldPlaceholderText,
|
|
40
|
+
messageText,
|
|
41
|
+
promptButtonTexts,
|
|
42
|
+
} as Pick<
|
|
43
|
+
ChatPreviewProps['widgetContentProps'],
|
|
44
|
+
'messageText' | 'promptButtonTexts' | 'textFieldPlaceholderText' | 'titleLabel'
|
|
45
|
+
>;
|
|
46
|
+
|
|
47
|
+
const logoSrc = uiConfig?.lookAndFeel?.widgetLogoSrc;
|
|
48
|
+
|
|
49
|
+
const hideLogo = uiConfig?.lookAndFeel?.hideWidgetLogo;
|
|
50
|
+
|
|
51
|
+
const handlePromptButtonClick = useCallback(
|
|
52
|
+
(text: string) => {
|
|
53
|
+
onTypedMessageSubmitted({ query: text, userTyped: false });
|
|
54
|
+
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_PROMPT_BUTTON);
|
|
55
|
+
},
|
|
56
|
+
[onTypedMessageSubmitted, openChat],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const handleTextFieldClick = useCallback(() => {
|
|
60
|
+
openChat(ChatElementDisplayLocationV3.CHAT_PREVIEW_TEXT_FIELD);
|
|
61
|
+
}, [openChat]);
|
|
62
|
+
|
|
63
|
+
if (isLoading) {
|
|
64
|
+
return (
|
|
65
|
+
<ChatPreviewLoadingWidgetWithBaseWidget
|
|
66
|
+
widgetConfigId={widgetConfigId}
|
|
67
|
+
widgetType={WidgetTypeV3.ChatPreviewLoadingV3}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const widgetStyleProps: ChatPreviewProps['widgetStyleProps'] = {
|
|
73
|
+
theme: Theme.GLOBAL_CUSTOM,
|
|
74
|
+
variant: chatPreviewWidgetConfig?.variant,
|
|
75
|
+
hideTextField: chatPreviewWidgetConfig?.hideTextField,
|
|
76
|
+
hideLogo,
|
|
77
|
+
hexCardColor: chatPreviewWidgetConfig?.hexCardColor,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const widgetContentProps: ChatPreviewProps['widgetContentProps'] = {
|
|
81
|
+
titleLabel: hardCopyContent?.titleLabel,
|
|
82
|
+
messageText: hardCopyContent?.messageText,
|
|
83
|
+
promptButtonTexts: hardCopyContent?.promptButtonTexts,
|
|
84
|
+
textFieldPlaceholderText: hardCopyContent?.textFieldPlaceholderText,
|
|
85
|
+
logoSrc: logoSrc ?? undefined,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const widgetEventProps: ChatPreviewProps['widgetEventProps'] = {
|
|
89
|
+
handlePromptButtonClick,
|
|
90
|
+
handleTextFieldClick,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<ChatPreview
|
|
95
|
+
baseProps={{ id }}
|
|
96
|
+
widgetStyleProps={widgetStyleProps}
|
|
97
|
+
widgetContentProps={widgetContentProps}
|
|
98
|
+
widgetEventProps={widgetEventProps}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const ChatPreviewWidgetWithBaseWidget =
|
|
104
|
+
withBaseWidget<BaseWidgetProps>(ChatPreviewWidgetHandler);
|
|
105
|
+
|
|
106
|
+
export interface ChatPreviewWidgetProps {
|
|
107
|
+
widgetConfigId: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const ChatPreviewWidget = ({ widgetConfigId }: ChatPreviewWidgetProps) => {
|
|
111
|
+
return (
|
|
112
|
+
<ChatPreviewWidgetWithBaseWidget
|
|
113
|
+
widgetConfigId={widgetConfigId}
|
|
114
|
+
widgetType={WidgetTypeV3.ChatPreviewV3}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
ChatPreviewWidget.displayName = 'ChatPreviewWidget';
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
|
|
6
|
+
export interface FloatingChatOverlayProps {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
isOpened: boolean;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
dataTestId?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const FloatingChatOverlay = ({
|
|
15
|
+
children,
|
|
16
|
+
isOpened,
|
|
17
|
+
onClose,
|
|
18
|
+
className,
|
|
19
|
+
dataTestId,
|
|
20
|
+
}: FloatingChatOverlayProps) => {
|
|
21
|
+
const overlayClasses = classNames(
|
|
22
|
+
'envive-floating-chat-overlay',
|
|
23
|
+
'envive-tw-fixed',
|
|
24
|
+
'envive-tw-top-0',
|
|
25
|
+
'envive-tw-left-0',
|
|
26
|
+
'envive-tw-h-screen',
|
|
27
|
+
'envive-tw-w-full',
|
|
28
|
+
'envive-tw-z-[2147483647]',
|
|
29
|
+
className,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const backdropClasses = classNames(
|
|
33
|
+
'envive-floating-chat-backdrop',
|
|
34
|
+
'envive-tw-absolute',
|
|
35
|
+
'envive-tw-top-0',
|
|
36
|
+
'envive-tw-left-0',
|
|
37
|
+
'envive-tw-h-full',
|
|
38
|
+
'envive-tw-w-full',
|
|
39
|
+
'envive-tw-bg-black',
|
|
40
|
+
'envive-tw-opacity-50',
|
|
41
|
+
'envive-tw-pointer-events-none',
|
|
42
|
+
'envive-tw-z-0',
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const overlayContentClasses = classNames(
|
|
46
|
+
'envive-floating-chat-overlay-content',
|
|
47
|
+
'envive-tw-relative',
|
|
48
|
+
'envive-tw-flex',
|
|
49
|
+
'envive-tw-justify-end',
|
|
50
|
+
'envive-tw-items-stretch',
|
|
51
|
+
'envive-tw-h-full',
|
|
52
|
+
'envive-tw-w-full',
|
|
53
|
+
'envive-tw-pointer-events-auto',
|
|
54
|
+
'envive-tw-cursor-pointer',
|
|
55
|
+
'envive-tw-z-10',
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const chatWrapper = (
|
|
59
|
+
<AnimatePresence>
|
|
60
|
+
{isOpened && (
|
|
61
|
+
<motion.div
|
|
62
|
+
key="floating-chat-overlay"
|
|
63
|
+
className={overlayClasses}
|
|
64
|
+
initial={{ opacity: 0 }}
|
|
65
|
+
animate={{ opacity: 1 }}
|
|
66
|
+
exit={{ opacity: 0 }}
|
|
67
|
+
transition={{ duration: 0.3 }}
|
|
68
|
+
data-testid={dataTestId}
|
|
69
|
+
>
|
|
70
|
+
<motion.div
|
|
71
|
+
className={backdropClasses}
|
|
72
|
+
initial={{ opacity: 0 }}
|
|
73
|
+
animate={{ opacity: 0.5 }}
|
|
74
|
+
exit={{ opacity: 0 }}
|
|
75
|
+
transition={{ duration: 0.3 }}
|
|
76
|
+
aria-label="Close chat"
|
|
77
|
+
/>
|
|
78
|
+
<div
|
|
79
|
+
className={overlayContentClasses}
|
|
80
|
+
onClick={onClose}
|
|
81
|
+
onKeyDown={e => {
|
|
82
|
+
if (e.key === 'Escape') {
|
|
83
|
+
onClose();
|
|
84
|
+
}
|
|
85
|
+
}}
|
|
86
|
+
role="button"
|
|
87
|
+
tabIndex={0}
|
|
88
|
+
aria-label="Close floating chat"
|
|
89
|
+
>
|
|
90
|
+
<motion.div
|
|
91
|
+
initial={{ opacity: 0, x: 512 }}
|
|
92
|
+
animate={{ opacity: 1, x: 0 }}
|
|
93
|
+
exit={{ opacity: 0, x: 512 }}
|
|
94
|
+
transition={{ duration: 0.3 }}
|
|
95
|
+
style={{ height: '100dvh', cursor: 'default' }}
|
|
96
|
+
className="envive-tw-shadow-md"
|
|
97
|
+
onClick={e => e.stopPropagation()}
|
|
98
|
+
>
|
|
99
|
+
{children}
|
|
100
|
+
</motion.div>
|
|
101
|
+
</div>
|
|
102
|
+
</motion.div>
|
|
103
|
+
)}
|
|
104
|
+
</AnimatePresence>
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// Render using portal to body to ensure it's on top of everything
|
|
108
|
+
if (typeof document !== 'undefined') {
|
|
109
|
+
return createPortal(chatWrapper, document.body);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return chatWrapper;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
FloatingChatOverlay.displayName = 'FloatingChatOverlay';
|