@envive-ai/react-widgets-v3 0.3.14 → 0.3.15-alpha.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/debug/chatEmbed.cjs +1 -1
- package/dist/debug/chatEmbed.js +1 -1
- package/dist/debug/reportIssue.cjs +1 -1
- package/dist/debug/reportIssue.js +1 -1
- package/dist/hocs/withBaseWidget/types.d.cts +7 -8
- package/dist/hocs/withBaseWidget/types.d.ts +8 -8
- package/dist/hocs/withBaseWidget/withBaseWidget.cjs +37 -43
- package/dist/hocs/withBaseWidget/withBaseWidget.d.cts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.d.ts +2 -2
- package/dist/hocs/withBaseWidget/withBaseWidget.js +39 -45
- package/dist/hooks/dist/application/models/api/widgetText.d.cts +8 -0
- package/dist/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.cts +12 -0
- package/dist/hooks/dist/contexts/types.d.cts +38 -0
- package/dist/hooks/dist/contexts/typesV3.d.cts +230 -0
- package/dist/hooks/dist/types/customerService.d.cts +21 -0
- package/dist/node_modules/@spiffy-ai/commerce-api-client/dist/models/WidgetType.cjs +1 -0
- package/dist/packages/hooks/dist/application/models/api/orgConfigResults.d.ts +2 -0
- package/dist/packages/hooks/dist/application/models/api/userEvent.d.ts +1 -0
- package/dist/packages/hooks/dist/application/models/api/widgetText.d.ts +8 -0
- package/dist/packages/hooks/dist/application/models/frontendConfig.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +15 -0
- package/dist/packages/hooks/dist/contexts/hardcopyContext/index.d.ts +1 -0
- package/dist/packages/hooks/dist/contexts/types.d.ts +44 -0
- package/dist/packages/hooks/dist/contexts/typesV3.d.ts +230 -0
- package/dist/packages/hooks/dist/types/customerService.d.ts +21 -0
- package/dist/packages/hooks/dist/types/custservice-types.d.ts +1 -0
- package/dist/packages/icons/dist/IconCloseVariant.cjs +5 -6
- package/dist/packages/icons/dist/IconCloseVariant.js +4 -6
- package/dist/packages/widgets/dist/SearchResults/SearchResults.d.ts +4 -3
- package/dist/packages/widgets/dist/SearchResults/SearchResultsWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.ts +2 -2
- package/dist/packages/widgets/dist/SearchZeroState/index.d.ts +2 -1
- package/dist/packages/widgets/dist/SearchZeroState/types.d.ts +2 -2
- package/dist/packages/widgets/dist/SuggestionBar/SuggestionBar.d.ts +3 -3
- package/dist/packages/widgets/dist/SuggestionButtonContainer/index.d.ts +2 -0
- package/dist/packages/widgets/dist/SuggestionButtonContainer/types.d.ts +3 -2
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/api/response.d.ts +14 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/api/search.d.ts +15 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCase.d.ts +73 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/camelCasedPropertiesDeep.d.ts +61 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/internal.d.ts +25 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/splitWords.d.ts +35 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/trim.d.ts +32 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/utilityTypes/unknownArray.d.ts +32 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/variantInfo/pageVisitInfo.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/application/models/variantInfo/variantInfo.d.ts +2 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.ts +15 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/contexts/types.d.ts +64 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.ts +60 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/hooks/utils.d.ts +13 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/OrgInfo.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/index.d.ts +1 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/search-filter-types.d.ts +28 -0
- package/dist/packages/widgets/dist/packages/hooks/dist/types/test-types.d.ts +10 -0
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.cjs +35 -4
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.js +35 -4
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewLoadingWidget/ChatPreviewLoadingWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.cjs +33 -12
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.cts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.d.ts +3 -3
- package/dist/widgets/ChatPreviewWidget/ChatPreviewWidget.js +35 -14
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.cjs +44 -23
- package/dist/widgets/FloatingChatWidget/FloatingChatOverlay.js +44 -23
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.cjs +62 -38
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.cts +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.d.ts +5 -3
- package/dist/widgets/FloatingChatWidget/FloatingChatWidget.js +63 -39
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.cts +2 -2
- package/dist/widgets/FullPageSalesAgentWidget/FullPageSalesAgentWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.cjs +24 -12
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.cts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.d.ts +2 -2
- package/dist/widgets/ProductCardWidget/ProductCardWidget.js +26 -14
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.cjs +22 -12
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.cts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.d.ts +3 -3
- package/dist/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.js +24 -14
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.cjs +14 -11
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/PromptCarouselWidget/PromptCarouselWidget.js +18 -15
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.cjs +1 -1
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.d.ts +2 -2
- package/dist/widgets/SocialProofFlowWidget/SocialProofFlowWidget.js +1 -1
- package/dist/widgets/SocialProofWidget/SocialProofWidget.cjs +53 -15
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.cts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.d.ts +3 -3
- package/dist/widgets/SocialProofWidget/SocialProofWidget.js +56 -18
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.cjs +10 -10
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.cts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.d.ts +2 -2
- package/dist/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.js +13 -13
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.cjs +1 -1
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.cts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.d.ts +2 -2
- package/dist/widgets/TypingAnimationFlowWidget/TypingAnimationFlowWidget.js +1 -1
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.cjs +23 -11
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.cts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.d.ts +3 -3
- package/dist/widgets/TypingAnimationWidget/TypingAnimationWidget.js +26 -14
- package/dist/widgets/dist/SearchResults/SearchResults.d.cts +4 -3
- package/dist/widgets/dist/SearchResults/SearchResultsWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/SearchZeroStateWidget.d.cts +2 -2
- package/dist/widgets/dist/SearchZeroState/types.d.cts +2 -2
- package/dist/widgets/dist/SuggestionBar/SuggestionBar.d.cts +3 -3
- package/dist/widgets/dist/SuggestionButtonContainer/types.d.cts +3 -2
- 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/search.d.cts +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/camelCasedPropertiesDeep.d.cts +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/splitWords.d.cts +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/unknownArray.d.cts +32 -0
- package/dist/widgets/dist/packages/hooks/dist/atoms/search/searchAPI.d.cts +14 -0
- package/dist/widgets/dist/packages/hooks/dist/contexts/types.d.cts +61 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/Search/useSearch.d.cts +60 -0
- package/dist/widgets/dist/packages/hooks/dist/hooks/utils.d.cts +12 -0
- package/dist/widgets/dist/packages/hooks/dist/types/search-filter-types.d.cts +28 -0
- package/dist/widgets/dist/packages/hooks/dist/types/test-types.d.cts +10 -0
- package/dist/widgets/hooks/useGetWidgetStatus.cjs +1 -1
- package/dist/widgets/hooks/useGetWidgetStatus.js +1 -1
- package/dist/widgets/utils/functions.cjs +0 -14
- package/dist/widgets/utils/functions.js +1 -14
- package/dist/widgets-v2/SearchZeroState/index.d.cts +2 -1
- package/dist/widgets-v2/SearchZeroState/index.d.ts +2 -1
- package/dist/widgets-v2/SuggestionButtonContainer/index.d.ts +1 -0
- package/package.json +4 -4
- package/src/hocs/withBaseWidget/__tests__/withBaseWidget.test.tsx +68 -302
- package/src/hocs/withBaseWidget/types.ts +6 -6
- package/src/hocs/withBaseWidget/withBaseWidget.tsx +46 -61
- package/src/widgets/ChatPreviewComparisonWidget/ChatPreviewComparisonWidget.tsx +59 -8
- package/src/widgets/ChatPreviewWidget/ChatPreviewWidget.tsx +54 -18
- package/src/widgets/ChatPreviewWidget/__tests__/ChatPreviewWidget.test.tsx +11 -5
- package/src/widgets/FloatingChatWidget/FloatingChatOverlay.tsx +48 -19
- package/src/widgets/FloatingChatWidget/FloatingChatWidget.tsx +100 -52
- package/src/widgets/FloatingChatWidget/__tests__/FloatingChatWidget.test.tsx +11 -5
- package/src/widgets/ProductCardWidget/ProductCardWidget.tsx +37 -16
- package/src/widgets/ProductCardWidget/__tests__/ProductCardWidget.test.tsx +12 -8
- package/src/widgets/PromptButtonCarouselWithImageWidget/PromptButtonCarouselWithImageWidget.tsx +38 -19
- package/src/widgets/PromptButtonCarouselWithImageWidget/__tests__/PromptButtonCarouselWithImageWidget.test.tsx +19 -8
- package/src/widgets/PromptCarouselWidget/PromptCarouselWidget.tsx +32 -19
- package/src/widgets/PromptCarouselWidget/__tests__/PromptCarouselWidget.test.tsx +21 -8
- package/src/widgets/SocialProofWidget/SocialProofWidget.tsx +77 -18
- package/src/widgets/SocialProofWidget/__tests__/SocialProofWidget.test.tsx +19 -8
- package/src/widgets/TitledPromptCarouselWidget/TitledPromptCarouselWidget.tsx +23 -19
- package/src/widgets/TitledPromptCarouselWidget/__tests__/TitledPromptCarouselWidget.test.tsx +19 -8
- package/src/widgets/TypingAnimationWidget/TypingAnimationWidget.tsx +45 -21
- package/src/widgets/TypingAnimationWidget/__tests__/TypingAnimationWidget.test.tsx +19 -8
- package/src/widgets/__tests__/trackEventCanary.test.ts +1 -1
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.cjs +0 -27
- package/dist/packages/icons/dist/_virtual/rolldown_runtime.js +0 -25
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.cjs +0 -696
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.development.js +0 -696
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.cjs +0 -43
- package/dist/packages/icons/dist/node_modules/react/cjs/react-jsx-runtime.production.min.js +0 -43
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.cjs +0 -1528
- package/dist/packages/icons/dist/node_modules/react/cjs/react.development.js +0 -1528
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.cjs +0 -329
- package/dist/packages/icons/dist/node_modules/react/cjs/react.production.min.js +0 -329
- package/dist/packages/icons/dist/node_modules/react/index.cjs +0 -13
- package/dist/packages/icons/dist/node_modules/react/index.js +0 -13
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.cjs +0 -13
- package/dist/packages/icons/dist/node_modules/react/jsx-runtime.js +0 -13
package/dist/debug/chatEmbed.cjs
CHANGED
|
@@ -3,8 +3,8 @@ const require_MessageContent = require('./MessageContent.cjs');
|
|
|
3
3
|
let react = require("react");
|
|
4
4
|
react = require_rolldown_runtime.__toESM(react);
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
-
let jotai = require("jotai");
|
|
7
6
|
let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
|
|
7
|
+
let jotai = require("jotai");
|
|
8
8
|
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
9
9
|
let __envive_ai_react_toolkit_v3_PromptCarousel = require("@envive-ai/react-toolkit-v3/PromptCarousel");
|
|
10
10
|
let classnames = require("classnames");
|
package/dist/debug/chatEmbed.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MessageContent } from "./MessageContent.js";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { useAtomValue } from "jotai";
|
|
5
4
|
import { chatAtom } from "@envive-ai/react-hooks/atoms/chat";
|
|
5
|
+
import { useAtomValue } from "jotai";
|
|
6
6
|
import { MessageType } from "@envive-ai/react-hooks/application/models";
|
|
7
7
|
import { PromptCarousel, PromptCarouselRows } from "@envive-ai/react-toolkit-v3/PromptCarousel";
|
|
8
8
|
import classNames from "classnames";
|
|
@@ -5,8 +5,8 @@ const require_GenericSelect = require('./GenericSelect.cjs');
|
|
|
5
5
|
const require_chatEmbed = require('./chatEmbed.cjs');
|
|
6
6
|
let react = require("react");
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
-
let jotai = require("jotai");
|
|
9
8
|
let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
|
|
9
|
+
let jotai = require("jotai");
|
|
10
10
|
let __envive_ai_react_hooks_application_models = require("@envive-ai/react-hooks/application/models");
|
|
11
11
|
let __envive_ai_react_hooks_atoms_app = require("@envive-ai/react-hooks/atoms/app");
|
|
12
12
|
let classnames = require("classnames");
|
|
@@ -3,8 +3,8 @@ import { GenericSelect } from "./GenericSelect.js";
|
|
|
3
3
|
import chatEmbed_default from "./chatEmbed.js";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { useAtomValue } from "jotai";
|
|
7
6
|
import { chatAtom, lastAssistantMessageAtom } from "@envive-ai/react-hooks/atoms/chat";
|
|
7
|
+
import { useAtomValue } from "jotai";
|
|
8
8
|
import { MessageType } from "@envive-ai/react-hooks/application/models";
|
|
9
9
|
import { userIdAtom } from "@envive-ai/react-hooks/atoms/app";
|
|
10
10
|
import { ReportSessionRequestReportPriorityEnum, ReportSessionRequestReportTypeEnum } from "@spiffy-ai/commerce-api-client";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { OrgUIConfigV3, WidgetConfigV3, WidgetTypeV3 } from "../../hooks/dist/contexts/typesV3.cjs";
|
|
2
|
+
import { HardcopyResponse } from "../../hooks/dist/contexts/hardcopyContext/hardcopyContext.cjs";
|
|
1
3
|
import { RefObject } from "react";
|
|
2
|
-
import { SpiffyMetricsEventName } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
3
|
-
import { HardcopyResponse } from "@envive-ai/react-hooks/contexts/hardcopyContext";
|
|
4
|
-
import { OrgUIConfigV3, WidgetConfigV3, WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
5
4
|
|
|
6
5
|
//#region src/hocs/withBaseWidget/types.d.ts
|
|
7
6
|
interface BaseWidgetProps {
|
|
@@ -18,11 +17,6 @@ interface BaseWidgetProps {
|
|
|
18
17
|
isUiConfigLoading?: boolean;
|
|
19
18
|
}
|
|
20
19
|
interface WithBaseWidgetOptions {
|
|
21
|
-
/**
|
|
22
|
-
* The Amplitude event name to track when the widget becomes visible.
|
|
23
|
-
* Defaults to a generic component visible event if not provided.
|
|
24
|
-
*/
|
|
25
|
-
visibilityEventName?: SpiffyMetricsEventName;
|
|
26
20
|
/**
|
|
27
21
|
* Additional properties to include with the visibility event.
|
|
28
22
|
*/
|
|
@@ -32,6 +26,11 @@ interface WithBaseWidgetOptions {
|
|
|
32
26
|
* Defaults to '0px'.
|
|
33
27
|
*/
|
|
34
28
|
rootMargin?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to defer loading of the widget until it is visible.
|
|
31
|
+
* Defaults to true
|
|
32
|
+
*/
|
|
33
|
+
deferLoading?: boolean;
|
|
35
34
|
}
|
|
36
35
|
//#endregion
|
|
37
36
|
export { BaseWidgetProps, WithBaseWidgetOptions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { OrgUIConfigV3, WidgetConfigV3, WidgetTypeV3 } from "../../packages/hooks/dist/contexts/typesV3.js";
|
|
2
|
+
import { HardcopyResponse } from "../../packages/hooks/dist/contexts/hardcopyContext/hardcopyContext.js";
|
|
3
|
+
import "../../packages/hooks/dist/contexts/hardcopyContext/index.js";
|
|
1
4
|
import { RefObject } from "react";
|
|
2
|
-
import { SpiffyMetricsEventName } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
3
|
-
import { HardcopyResponse } from "@envive-ai/react-hooks/contexts/hardcopyContext";
|
|
4
|
-
import { OrgUIConfigV3, WidgetConfigV3, WidgetTypeV3 } from "@envive-ai/react-hooks/contexts/typesV3";
|
|
5
5
|
|
|
6
6
|
//#region src/hocs/withBaseWidget/types.d.ts
|
|
7
7
|
interface BaseWidgetProps {
|
|
@@ -18,11 +18,6 @@ interface BaseWidgetProps {
|
|
|
18
18
|
isUiConfigLoading?: boolean;
|
|
19
19
|
}
|
|
20
20
|
interface WithBaseWidgetOptions {
|
|
21
|
-
/**
|
|
22
|
-
* The Amplitude event name to track when the widget becomes visible.
|
|
23
|
-
* Defaults to a generic component visible event if not provided.
|
|
24
|
-
*/
|
|
25
|
-
visibilityEventName?: SpiffyMetricsEventName;
|
|
26
21
|
/**
|
|
27
22
|
* Additional properties to include with the visibility event.
|
|
28
23
|
*/
|
|
@@ -32,6 +27,11 @@ interface WithBaseWidgetOptions {
|
|
|
32
27
|
* Defaults to '0px'.
|
|
33
28
|
*/
|
|
34
29
|
rootMargin?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to defer loading of the widget until it is visible.
|
|
32
|
+
* Defaults to true
|
|
33
|
+
*/
|
|
34
|
+
deferLoading?: boolean;
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
export { BaseWidgetProps, WithBaseWidgetOptions };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let react = require("react");
|
|
3
3
|
let __envive_ai_react_hooks_contexts_amplitudeContext = require("@envive-ai/react-hooks/contexts/amplitudeContext");
|
|
4
|
+
let __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent = require("@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent");
|
|
4
5
|
let __envive_ai_react_hooks_contexts_hardcopyContext = require("@envive-ai/react-hooks/contexts/hardcopyContext");
|
|
5
6
|
let __envive_ai_react_hooks_contexts_pageContext = require("@envive-ai/react-hooks/contexts/pageContext");
|
|
6
7
|
let __envive_ai_react_hooks_contexts_widgetConfigContext = require("@envive-ai/react-hooks/contexts/widgetConfigContext");
|
|
@@ -12,9 +13,9 @@ function withBaseWidget(Widget, options) {
|
|
|
12
13
|
const WrappedWidget = (props) => {
|
|
13
14
|
const { widgetConfigId, widgetType } = props;
|
|
14
15
|
const widgetRef = (0, react.useRef)(null);
|
|
15
|
-
const
|
|
16
|
-
const { trackEvent, isReady } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
|
|
16
|
+
const { isReady } = (0, __envive_ai_react_hooks_contexts_amplitudeContext.useAmplitude)();
|
|
17
17
|
const [hardcopyContent, setHardcopyContent] = (0, react.useState)(void 0);
|
|
18
|
+
const hardcopyFetchedRef = (0, react.useRef)(false);
|
|
18
19
|
const { getHardcopy, isLoading: isHardcopyLoading } = (0, __envive_ai_react_hooks_contexts_hardcopyContext.useHardcopy)();
|
|
19
20
|
const { userEvent, isLoading: isPageLoading } = (0, __envive_ai_react_hooks_contexts_pageContext.usePage)();
|
|
20
21
|
const [widgetConfig, setWidgetConfig] = (0, react.useState)(void 0);
|
|
@@ -22,75 +23,68 @@ function withBaseWidget(Widget, options) {
|
|
|
22
23
|
const [uiConfig, setUiConfig] = (0, react.useState)(void 0);
|
|
23
24
|
const { getUiConfig, isLoading: isUiConfigLoading } = (0, __envive_ai_react_hooks_contexts_uiConfigContext.useUiConfig)();
|
|
24
25
|
const isLoading = isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading;
|
|
25
|
-
(0,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
widget_type: widgetType,
|
|
34
|
-
...options?.visibilityEventProps
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
hasTrackedEvent.current = true;
|
|
38
|
-
observer.disconnect();
|
|
39
|
-
}
|
|
40
|
-
}, { rootMargin: options?.rootMargin || "0px" });
|
|
41
|
-
observer.observe(widgetRef.current);
|
|
42
|
-
return () => {
|
|
43
|
-
observer.disconnect();
|
|
44
|
-
};
|
|
26
|
+
const { isVisible } = (0, __envive_ai_react_hooks_hooks_TrackComponentVisibleEvent.useTrackComponentVisibleEvent)(widgetRef, {
|
|
27
|
+
widget_config_id: widgetConfigId,
|
|
28
|
+
widget_type: widgetType,
|
|
29
|
+
...options?.visibilityEventProps
|
|
30
|
+
}, options?.rootMargin || "0px", isReady);
|
|
31
|
+
const startLoading = (0, react.useMemo)(() => {
|
|
32
|
+
if (options?.deferLoading === false) return true;
|
|
33
|
+
return isVisible && !!widgetConfigId && !!widgetType;
|
|
45
34
|
}, [
|
|
46
|
-
|
|
35
|
+
isVisible,
|
|
47
36
|
widgetConfigId,
|
|
48
|
-
widgetType
|
|
49
|
-
trackEvent
|
|
37
|
+
widgetType
|
|
50
38
|
]);
|
|
51
39
|
(0, react.useEffect)(() => {
|
|
52
|
-
if (!
|
|
40
|
+
if (!startLoading || hardcopyFetchedRef.current) return;
|
|
41
|
+
hardcopyFetchedRef.current = true;
|
|
53
42
|
getHardcopy({
|
|
54
43
|
widgetType,
|
|
55
44
|
userEvent
|
|
56
45
|
}).then(setHardcopyContent).catch(() => {});
|
|
57
46
|
}, [
|
|
58
|
-
|
|
47
|
+
startLoading,
|
|
59
48
|
widgetType,
|
|
60
49
|
getHardcopy,
|
|
61
|
-
userEvent
|
|
50
|
+
userEvent,
|
|
51
|
+
widgetConfigId
|
|
62
52
|
]);
|
|
63
53
|
(0, react.useEffect)(() => {
|
|
54
|
+
if (!startLoading) return;
|
|
64
55
|
getUiConfig().then(setUiConfig).catch(() => {});
|
|
65
56
|
}, [
|
|
57
|
+
startLoading,
|
|
66
58
|
getUiConfig,
|
|
67
59
|
widgetConfigId,
|
|
68
60
|
widgetType
|
|
69
61
|
]);
|
|
70
62
|
(0, react.useEffect)(() => {
|
|
71
|
-
if (!
|
|
63
|
+
if (!startLoading) return;
|
|
72
64
|
getWidgetConfig({
|
|
73
65
|
widgetConfigId,
|
|
74
66
|
widgetType
|
|
75
|
-
}).then(setWidgetConfig).catch((
|
|
76
|
-
console.error("Error getting widget config", widgetConfigId, widgetType, e);
|
|
77
|
-
});
|
|
67
|
+
}).then(setWidgetConfig).catch(() => {});
|
|
78
68
|
}, [
|
|
69
|
+
startLoading,
|
|
79
70
|
widgetConfigId,
|
|
80
71
|
widgetType,
|
|
81
72
|
getWidgetConfig
|
|
82
73
|
]);
|
|
83
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
74
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
75
|
+
ref: widgetRef,
|
|
76
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Widget, {
|
|
77
|
+
...props,
|
|
78
|
+
isLoading,
|
|
79
|
+
isHardcopyLoading,
|
|
80
|
+
isPageLoading,
|
|
81
|
+
isWidgetConfigLoading,
|
|
82
|
+
isUiConfigLoading,
|
|
83
|
+
uiConfig,
|
|
84
|
+
widgetConfig,
|
|
85
|
+
hardcopyContent,
|
|
86
|
+
observedWidget: widgetRef
|
|
87
|
+
})
|
|
94
88
|
});
|
|
95
89
|
};
|
|
96
90
|
WrappedWidget.displayName = `withBaseWidget(${Widget.displayName || Widget.name || "Component"})`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps, WithBaseWidgetOptions } from "./types.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime11 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/hocs/withBaseWidget/withBaseWidget.d.ts
|
|
5
5
|
declare function withBaseWidget<P extends BaseWidgetProps>(Widget: React.ComponentType<P>, options?: WithBaseWidgetOptions): {
|
|
6
|
-
(props: P):
|
|
6
|
+
(props: P): react_jsx_runtime11.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseWidgetProps, WithBaseWidgetOptions } from "./types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime13 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/hocs/withBaseWidget/withBaseWidget.d.ts
|
|
5
5
|
declare function withBaseWidget<P extends BaseWidgetProps>(Widget: React.ComponentType<P>, options?: WithBaseWidgetOptions): {
|
|
6
|
-
(props: P):
|
|
6
|
+
(props: P): react_jsx_runtime13.JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useAmplitude } from "@envive-ai/react-hooks/contexts/amplitudeContext";
|
|
3
|
+
import { useTrackComponentVisibleEvent } from "@envive-ai/react-hooks/hooks/TrackComponentVisibleEvent";
|
|
3
4
|
import { useHardcopy } from "@envive-ai/react-hooks/contexts/hardcopyContext";
|
|
4
5
|
import { usePage } from "@envive-ai/react-hooks/contexts/pageContext";
|
|
5
6
|
import { useWidgetConfig } from "@envive-ai/react-hooks/contexts/widgetConfigContext";
|
|
@@ -11,9 +12,9 @@ function withBaseWidget(Widget, options) {
|
|
|
11
12
|
const WrappedWidget = (props) => {
|
|
12
13
|
const { widgetConfigId, widgetType } = props;
|
|
13
14
|
const widgetRef = useRef(null);
|
|
14
|
-
const
|
|
15
|
-
const { trackEvent, isReady } = useAmplitude();
|
|
15
|
+
const { isReady } = useAmplitude();
|
|
16
16
|
const [hardcopyContent, setHardcopyContent] = useState(void 0);
|
|
17
|
+
const hardcopyFetchedRef = useRef(false);
|
|
17
18
|
const { getHardcopy, isLoading: isHardcopyLoading } = useHardcopy();
|
|
18
19
|
const { userEvent, isLoading: isPageLoading } = usePage();
|
|
19
20
|
const [widgetConfig, setWidgetConfig] = useState(void 0);
|
|
@@ -21,75 +22,68 @@ function withBaseWidget(Widget, options) {
|
|
|
21
22
|
const [uiConfig, setUiConfig] = useState(void 0);
|
|
22
23
|
const { getUiConfig, isLoading: isUiConfigLoading } = useUiConfig();
|
|
23
24
|
const isLoading = isHardcopyLoading || isPageLoading || isWidgetConfigLoading || isUiConfigLoading;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
widget_type: widgetType,
|
|
33
|
-
...options?.visibilityEventProps
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
hasTrackedEvent.current = true;
|
|
37
|
-
observer.disconnect();
|
|
38
|
-
}
|
|
39
|
-
}, { rootMargin: options?.rootMargin || "0px" });
|
|
40
|
-
observer.observe(widgetRef.current);
|
|
41
|
-
return () => {
|
|
42
|
-
observer.disconnect();
|
|
43
|
-
};
|
|
25
|
+
const { isVisible } = useTrackComponentVisibleEvent(widgetRef, {
|
|
26
|
+
widget_config_id: widgetConfigId,
|
|
27
|
+
widget_type: widgetType,
|
|
28
|
+
...options?.visibilityEventProps
|
|
29
|
+
}, options?.rootMargin || "0px", isReady);
|
|
30
|
+
const startLoading = useMemo(() => {
|
|
31
|
+
if (options?.deferLoading === false) return true;
|
|
32
|
+
return isVisible && !!widgetConfigId && !!widgetType;
|
|
44
33
|
}, [
|
|
45
|
-
|
|
34
|
+
isVisible,
|
|
46
35
|
widgetConfigId,
|
|
47
|
-
widgetType
|
|
48
|
-
trackEvent
|
|
36
|
+
widgetType
|
|
49
37
|
]);
|
|
50
38
|
useEffect(() => {
|
|
51
|
-
if (!
|
|
39
|
+
if (!startLoading || hardcopyFetchedRef.current) return;
|
|
40
|
+
hardcopyFetchedRef.current = true;
|
|
52
41
|
getHardcopy({
|
|
53
42
|
widgetType,
|
|
54
43
|
userEvent
|
|
55
44
|
}).then(setHardcopyContent).catch(() => {});
|
|
56
45
|
}, [
|
|
57
|
-
|
|
46
|
+
startLoading,
|
|
58
47
|
widgetType,
|
|
59
48
|
getHardcopy,
|
|
60
|
-
userEvent
|
|
49
|
+
userEvent,
|
|
50
|
+
widgetConfigId
|
|
61
51
|
]);
|
|
62
52
|
useEffect(() => {
|
|
53
|
+
if (!startLoading) return;
|
|
63
54
|
getUiConfig().then(setUiConfig).catch(() => {});
|
|
64
55
|
}, [
|
|
56
|
+
startLoading,
|
|
65
57
|
getUiConfig,
|
|
66
58
|
widgetConfigId,
|
|
67
59
|
widgetType
|
|
68
60
|
]);
|
|
69
61
|
useEffect(() => {
|
|
70
|
-
if (!
|
|
62
|
+
if (!startLoading) return;
|
|
71
63
|
getWidgetConfig({
|
|
72
64
|
widgetConfigId,
|
|
73
65
|
widgetType
|
|
74
|
-
}).then(setWidgetConfig).catch((
|
|
75
|
-
console.error("Error getting widget config", widgetConfigId, widgetType, e);
|
|
76
|
-
});
|
|
66
|
+
}).then(setWidgetConfig).catch(() => {});
|
|
77
67
|
}, [
|
|
68
|
+
startLoading,
|
|
78
69
|
widgetConfigId,
|
|
79
70
|
widgetType,
|
|
80
71
|
getWidgetConfig
|
|
81
72
|
]);
|
|
82
|
-
return /* @__PURE__ */ jsx(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
return /* @__PURE__ */ jsx("span", {
|
|
74
|
+
ref: widgetRef,
|
|
75
|
+
children: /* @__PURE__ */ jsx(Widget, {
|
|
76
|
+
...props,
|
|
77
|
+
isLoading,
|
|
78
|
+
isHardcopyLoading,
|
|
79
|
+
isPageLoading,
|
|
80
|
+
isWidgetConfigLoading,
|
|
81
|
+
isUiConfigLoading,
|
|
82
|
+
uiConfig,
|
|
83
|
+
widgetConfig,
|
|
84
|
+
hardcopyContent,
|
|
85
|
+
observedWidget: widgetRef
|
|
86
|
+
})
|
|
93
87
|
});
|
|
94
88
|
};
|
|
95
89
|
WrappedWidget.displayName = `withBaseWidget(${Widget.displayName || Widget.name || "Component"})`;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WidgetString } from "../../application/models/api/widgetText.cjs";
|
|
2
|
+
|
|
3
|
+
//#region ../hooks/dist/contexts/hardcopyContext/hardcopyContext.d.ts
|
|
4
|
+
|
|
5
|
+
type HardcopyResponse = {
|
|
6
|
+
responseId: string;
|
|
7
|
+
language: string;
|
|
8
|
+
rawValues?: Record<string, WidgetString | WidgetString[]>;
|
|
9
|
+
values: Record<string, string | string[]>;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { HardcopyResponse };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region ../hooks/dist/contexts/types.d.ts
|
|
2
|
+
|
|
3
|
+
interface AlphabeticFilterSorting {
|
|
4
|
+
type: 'alphabetic';
|
|
5
|
+
}
|
|
6
|
+
interface ProductCountFilterSorting {
|
|
7
|
+
type: 'productCount';
|
|
8
|
+
}
|
|
9
|
+
interface CustomFilterSorting {
|
|
10
|
+
type: 'custom';
|
|
11
|
+
map: Record<string, number>;
|
|
12
|
+
}
|
|
13
|
+
type FilterSorting = AlphabeticFilterSorting | ProductCountFilterSorting | CustomFilterSorting;
|
|
14
|
+
interface BaseFilterConfig {
|
|
15
|
+
filterId: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
}
|
|
18
|
+
interface DynamicFilterConfig extends BaseFilterConfig {
|
|
19
|
+
type: 'dynamic';
|
|
20
|
+
attribute: string;
|
|
21
|
+
sorting: FilterSorting;
|
|
22
|
+
}
|
|
23
|
+
interface PriceFilterConfig extends BaseFilterConfig {
|
|
24
|
+
type: 'price';
|
|
25
|
+
bucketSize: number;
|
|
26
|
+
}
|
|
27
|
+
type FilterAttribute = DynamicFilterConfig | PriceFilterConfig;
|
|
28
|
+
interface SearchConfig {
|
|
29
|
+
enableGlobalSearch: boolean;
|
|
30
|
+
searchFilterConfig: FilterAttribute[];
|
|
31
|
+
searchOverlayHeading?: string;
|
|
32
|
+
redirectSearchResultsUrl?: string;
|
|
33
|
+
additiveDynamicFilters?: boolean;
|
|
34
|
+
recommendedProducts?: string[];
|
|
35
|
+
recommendedProductsHeading?: string;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { type SearchConfig };
|