@constructor-io/constructorio-ui-pia 2.2.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constructorio-ui-pia-bundled.js +78 -22
- package/lib/cjs/components/Answer/Answer.js +2 -1
- package/lib/cjs/components/CioPia/CioPia.js +4 -10
- package/lib/cjs/components/CioPia/PiaCustomCarousel.js +15 -1
- package/lib/cjs/components/ConversationHistory/ConversationHistory.js +4 -2
- package/lib/cjs/components/ConversationHistory/ConversationHistoryStyles.css +1 -0
- package/lib/cjs/components/PiaConversation/PiaConversation.js +2 -2
- package/lib/cjs/components/PiaConversation/PiaModal.js +3 -2
- package/lib/cjs/components/PiaInlineAnswer/PiaInlineAnswer.js +18 -0
- package/lib/cjs/constants.js +0 -1
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/utils/contentTransformers.js +22 -0
- package/lib/cjs/utils/index.js +4 -0
- package/lib/cjs/utils/styleHelpers.js +0 -1
- package/lib/cjs/utils/translate.js +0 -1
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/Answer/Answer.js +2 -1
- package/lib/mjs/components/CioPia/CioPia.js +4 -10
- package/lib/mjs/components/CioPia/PiaCustomCarousel.js +27 -2
- package/lib/mjs/components/ConversationHistory/ConversationHistory.js +4 -2
- package/lib/mjs/components/ConversationHistory/ConversationHistoryStyles.css +1 -0
- package/lib/mjs/components/PiaConversation/PiaConversation.js +2 -2
- package/lib/mjs/components/PiaConversation/PiaModal.js +3 -2
- package/lib/mjs/components/PiaInlineAnswer/PiaInlineAnswer.js +14 -0
- package/lib/mjs/constants.js +0 -1
- package/lib/mjs/index.js +2 -0
- package/lib/mjs/utils/contentTransformers.js +16 -0
- package/lib/mjs/utils/index.js +1 -0
- package/lib/mjs/utils/styleHelpers.js +0 -1
- package/lib/mjs/utils/translate.js +0 -1
- package/lib/mjs/version.js +1 -1
- package/lib/types/components/CioPia/CioPia.d.ts +12 -14
- package/lib/types/components/ConversationHistory/ConversationHistory.d.ts +3 -2
- package/lib/types/components/PiaConversation/PiaConversation.d.ts +1 -1
- package/lib/types/components/PiaInlineAnswer/PiaInlineAnswer.d.ts +14 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/types.d.ts +11 -2
- package/lib/types/utils/contentTransformers.d.ts +2 -0
- package/lib/types/utils/index.d.ts +1 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +20 -16
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
5
|
const constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
|
|
6
|
+
const contentTransformers_1 = require("../../utils/contentTransformers");
|
|
6
7
|
function Answer({ text, componentOverride }) {
|
|
7
8
|
if (!text) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
11
|
return (react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { props: { text }, override: componentOverride === null || componentOverride === void 0 ? void 0 : componentOverride.reactNode },
|
|
11
|
-
react_1.default.createElement("div", { className: 'cio-pia-answer', "data-testid": 'answer-text'
|
|
12
|
+
react_1.default.createElement("div", { className: 'cio-pia-answer', "data-testid": 'answer-text', dangerouslySetInnerHTML: { __html: (0, contentTransformers_1.renderMarkdown)(text) } })));
|
|
12
13
|
}
|
|
13
14
|
exports.default = Answer;
|
|
@@ -3,22 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
5
|
const constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
|
|
6
|
-
const Disclaimer_1 = tslib_1.__importDefault(require("./Disclaimer"));
|
|
7
6
|
const Input_1 = tslib_1.__importDefault(require("../Input/Input"));
|
|
8
7
|
const SuggestedQuestionsContainer_1 = tslib_1.__importDefault(require("../SuggestedQuestionsContainer/SuggestedQuestionsContainer"));
|
|
9
|
-
const Answer_1 = tslib_1.__importDefault(require("../Answer/Answer"));
|
|
10
|
-
const Feedback_1 = tslib_1.__importDefault(require("../Feedback/Feedback"));
|
|
11
8
|
const useCioPia_1 = tslib_1.__importDefault(require("../../hooks/useCioPia"));
|
|
12
9
|
const useConversation_1 = tslib_1.__importDefault(require("../../hooks/useConversation"));
|
|
13
10
|
const ErrorBlock_1 = tslib_1.__importDefault(require("../Error/ErrorBlock"));
|
|
14
11
|
const LoadingSkeleton_1 = tslib_1.__importDefault(require("../LoadingSkeleton/LoadingSkeleton"));
|
|
15
12
|
const translate_1 = require("../../utils/translate");
|
|
16
|
-
const
|
|
13
|
+
const PiaInlineAnswer_1 = tslib_1.__importDefault(require("../PiaInlineAnswer/PiaInlineAnswer"));
|
|
17
14
|
const PiaModal_1 = tslib_1.__importDefault(require("../PiaConversation/PiaModal"));
|
|
18
15
|
const PiaConversation_1 = tslib_1.__importDefault(require("../PiaConversation/PiaConversation"));
|
|
19
16
|
function CioPia(props) {
|
|
20
17
|
const { apiKey, itemId, threadId, variationId, cioClient, displayConfigs, componentOverrides, callbacks, formatters, children, translations, suggestedQuestionsParameters, } = props;
|
|
21
|
-
const { learnMoreUrl, showFeedback, mode = 'default', type = 'inline', showPreviousItems, } = displayConfigs || {};
|
|
18
|
+
const { learnMoreUrl, showFeedback, mode = 'default', type = 'inline', showPreviousItems, disclaimerPosition = 'bottom', } = displayConfigs || {};
|
|
22
19
|
const isConversation = mode === 'conversation' || type === 'modal';
|
|
23
20
|
const pia = (0, useCioPia_1.default)({
|
|
24
21
|
apiKey,
|
|
@@ -48,6 +45,7 @@ function CioPia(props) {
|
|
|
48
45
|
showFeedback,
|
|
49
46
|
showPreviousItems,
|
|
50
47
|
learnMoreUrl,
|
|
48
|
+
disclaimerPosition,
|
|
51
49
|
translations,
|
|
52
50
|
callbacks,
|
|
53
51
|
componentOverrides,
|
|
@@ -68,11 +66,7 @@ function CioPia(props) {
|
|
|
68
66
|
isLoading && react_1.default.createElement(LoadingSkeleton_1.default, null),
|
|
69
67
|
!isLoading && error && react_1.default.createElement(ErrorBlock_1.default, { message: (error === null || error === void 0 ? void 0 : error.message) || 'Unexpected error' }),
|
|
70
68
|
!isLoading && !error && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
71
|
-
currentAnswer && (react_1.default.createElement(
|
|
72
|
-
react_1.default.createElement(Answer_1.default, { text: currentAnswer, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.answer }),
|
|
73
|
-
currentItems && (react_1.default.createElement(PiaCustomCarousel_1.default, { items: currentItems, componentOverrides: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.carousel, callbacks: callbacks })),
|
|
74
|
-
showFeedback && (react_1.default.createElement(Feedback_1.default, { translations: translations, onFeedback: callbacks === null || callbacks === void 0 ? void 0 : callbacks.onFeedback, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.feedback })),
|
|
75
|
-
react_1.default.createElement(Disclaimer_1.default, { learnMoreUrl: learnMoreUrl, translations: translations, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.disclaimer }))),
|
|
69
|
+
currentAnswer && (react_1.default.createElement(PiaInlineAnswer_1.default, { currentAnswer: currentAnswer, currentItems: currentItems, showFeedback: showFeedback, learnMoreUrl: learnMoreUrl, disclaimerPosition: disclaimerPosition, translations: translations, callbacks: callbacks, componentOverrides: componentOverrides })),
|
|
76
70
|
react_1.default.createElement(SuggestedQuestionsContainer_1.default, { questions: displayedQuestions, onQuestionClick: handleSubmitQuestion, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.suggestedQuestions }))))));
|
|
77
71
|
}
|
|
78
72
|
exports.default = CioPia;
|
|
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
|
|
6
|
+
const contentTransformers_1 = require("../../utils/contentTransformers");
|
|
7
|
+
function HtmlDescription({ product }) {
|
|
8
|
+
const { description } = product;
|
|
9
|
+
if (!description)
|
|
10
|
+
return null;
|
|
11
|
+
return (react_1.default.createElement("p", { className: 'cio-product-card-description', dangerouslySetInnerHTML: { __html: (0, contentTransformers_1.sanitizeHtml)(description) } }));
|
|
12
|
+
}
|
|
6
13
|
function PiaCustomCarousel({ items, componentOverrides, callbacks, }) {
|
|
7
14
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
8
15
|
// Determine to use user-defined click handler or default behavior
|
|
@@ -31,11 +38,18 @@ function PiaCustomCarousel({ items, componentOverrides, callbacks, }) {
|
|
|
31
38
|
el.removeEventListener(constructorio_ui_components_1.CIO_EVENTS.productCard.click, handleClick);
|
|
32
39
|
};
|
|
33
40
|
}, [productClickHandler]);
|
|
41
|
+
const mergedOverrides = (0, react_1.useMemo)(() => {
|
|
42
|
+
var _a, _b, _c, _d, _e, _f;
|
|
43
|
+
if ((_c = (_b = (_a = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.item) === null || _a === void 0 ? void 0 : _a.productCard) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.description) {
|
|
44
|
+
return componentOverrides;
|
|
45
|
+
}
|
|
46
|
+
return Object.assign(Object.assign({}, componentOverrides), { item: Object.assign(Object.assign({}, componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.item), { productCard: Object.assign(Object.assign({}, (_d = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.item) === null || _d === void 0 ? void 0 : _d.productCard), { content: Object.assign(Object.assign({}, (_f = (_e = componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.item) === null || _e === void 0 ? void 0 : _e.productCard) === null || _f === void 0 ? void 0 : _f.content), { description: { reactNode: HtmlDescription } }) }) }) });
|
|
47
|
+
}, [componentOverrides]);
|
|
34
48
|
// If there are no items, do not render the carousel
|
|
35
49
|
if (items.length === 0) {
|
|
36
50
|
return null;
|
|
37
51
|
}
|
|
38
52
|
return (react_1.default.createElement("div", { ref: wrapperRef },
|
|
39
|
-
react_1.default.createElement(constructorio_ui_components_1.Carousel, { items: items, componentOverrides:
|
|
53
|
+
react_1.default.createElement(constructorio_ui_components_1.Carousel, { items: items, componentOverrides: mergedOverrides })));
|
|
40
54
|
}
|
|
41
55
|
exports.default = PiaCustomCarousel;
|
|
@@ -8,7 +8,7 @@ const Disclaimer_1 = tslib_1.__importDefault(require("../CioPia/Disclaimer"));
|
|
|
8
8
|
const ErrorBlock_1 = tslib_1.__importDefault(require("../Error/ErrorBlock"));
|
|
9
9
|
const LoadingSkeleton_1 = tslib_1.__importDefault(require("../LoadingSkeleton/LoadingSkeleton"));
|
|
10
10
|
const PiaCustomCarousel_1 = tslib_1.__importDefault(require("../CioPia/PiaCustomCarousel"));
|
|
11
|
-
function ConversationHistory({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems = true, learnMoreUrl, translations, callbacks, componentOverrides, }) {
|
|
11
|
+
function ConversationHistory({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems = true, learnMoreUrl, disclaimerPosition = 'bottom', translations, callbacks, componentOverrides, }) {
|
|
12
12
|
const scrollContainerRef = (0, react_1.useRef)(null);
|
|
13
13
|
(0, react_1.useEffect)(() => {
|
|
14
14
|
const container = scrollContainerRef.current;
|
|
@@ -19,7 +19,9 @@ function ConversationHistory({ conversationHistory, isLoading, error, currentIte
|
|
|
19
19
|
});
|
|
20
20
|
return () => cancelAnimationFrame(frameId);
|
|
21
21
|
}, [conversationHistory, isLoading]);
|
|
22
|
+
const disclaimer = (react_1.default.createElement(Disclaimer_1.default, { learnMoreUrl: learnMoreUrl, translations: translations, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.disclaimer }));
|
|
22
23
|
return (react_1.default.createElement("div", { className: 'cio-pia-conversation-history' },
|
|
24
|
+
disclaimerPosition === 'top' && disclaimer,
|
|
23
25
|
react_1.default.createElement("div", { ref: scrollContainerRef, className: 'cio-pia-conversation-entries', role: 'log', "aria-label": 'Conversation history' }, conversationHistory.map((entry, index) => {
|
|
24
26
|
const isLast = index === conversationHistory.length - 1;
|
|
25
27
|
const previousEntryItems = showPreviousItems ? entry.items : null;
|
|
@@ -35,6 +37,6 @@ function ConversationHistory({ conversationHistory, isLoading, error, currentIte
|
|
|
35
37
|
carouselItems && (react_1.default.createElement(PiaCustomCarousel_1.default, { items: carouselItems, componentOverrides: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.carousel, callbacks: callbacks })),
|
|
36
38
|
isLast && showFeedback && (react_1.default.createElement(Feedback_1.default, { translations: translations, onFeedback: callbacks === null || callbacks === void 0 ? void 0 : callbacks.onFeedback, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.feedback }))))));
|
|
37
39
|
})),
|
|
38
|
-
|
|
40
|
+
disclaimerPosition === 'bottom' && disclaimer));
|
|
39
41
|
}
|
|
40
42
|
exports.default = ConversationHistory;
|
|
@@ -7,11 +7,11 @@ const SuggestedQuestionsContainer_1 = tslib_1.__importDefault(require("../Sugges
|
|
|
7
7
|
const SuggestedQuestionsSkeleton_1 = tslib_1.__importDefault(require("../SuggestedQuestionsContainer/SuggestedQuestionsSkeleton"));
|
|
8
8
|
const translate_1 = require("../../utils/translate");
|
|
9
9
|
const ConversationHistory_1 = tslib_1.__importDefault(require("../ConversationHistory/ConversationHistory"));
|
|
10
|
-
function PiaConversation({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems, learnMoreUrl, translations, callbacks, componentOverrides, displayedQuestions, handleSubmitQuestion, }) {
|
|
10
|
+
function PiaConversation({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems, learnMoreUrl, disclaimerPosition, translations, callbacks, componentOverrides, displayedQuestions, handleSubmitQuestion, }) {
|
|
11
11
|
const hasHistory = conversationHistory.length > 0;
|
|
12
12
|
return (react_1.default.createElement("div", { className: 'cio-pia-container cio-pia-conversation', "data-testid": 'cio-pia-container' },
|
|
13
13
|
!hasHistory && (react_1.default.createElement("p", { className: 'cio-pia-title', "data-testid": 'cio-pia-title' }, (0, translate_1.translate)('Any questions about this product?', translations))),
|
|
14
|
-
react_1.default.createElement(ConversationHistory_1.default, { conversationHistory: conversationHistory, isLoading: isLoading, error: error, currentItems: currentItems, showFeedback: showFeedback, showPreviousItems: showPreviousItems, learnMoreUrl: learnMoreUrl, translations: translations, callbacks: callbacks, componentOverrides: componentOverrides }),
|
|
14
|
+
react_1.default.createElement(ConversationHistory_1.default, { conversationHistory: conversationHistory, isLoading: isLoading, error: error, currentItems: currentItems, showFeedback: showFeedback, showPreviousItems: showPreviousItems, learnMoreUrl: learnMoreUrl, disclaimerPosition: disclaimerPosition, translations: translations, callbacks: callbacks, componentOverrides: componentOverrides }),
|
|
15
15
|
react_1.default.createElement("div", { className: 'cio-pia-conversation-footer' },
|
|
16
16
|
isLoading && !error && react_1.default.createElement(SuggestedQuestionsSkeleton_1.default, null),
|
|
17
17
|
!isLoading && !error && (react_1.default.createElement(SuggestedQuestionsContainer_1.default, { questions: displayedQuestions, onQuestionClick: handleSubmitQuestion, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.suggestedQuestions })),
|
|
@@ -61,8 +61,9 @@ function PiaModal({ initialQuestions, handleSubmitQuestion, isLoading, component
|
|
|
61
61
|
}, [handleSubmitQuestion, openModal]);
|
|
62
62
|
return (react_1.default.createElement("div", { className: 'cio-pia-container', "data-testid": 'cio-pia-container' },
|
|
63
63
|
react_1.default.createElement("p", { className: 'cio-pia-title', "data-testid": 'cio-pia-title' }, (0, translate_1.translate)('Any questions about this product?', translations)),
|
|
64
|
-
react_1.default.createElement(
|
|
65
|
-
|
|
64
|
+
react_1.default.createElement("div", { className: 'cio-pia-conversation-footer' },
|
|
65
|
+
initialQuestions.length > 0 && (react_1.default.createElement(SuggestedQuestionsContainer_1.default, { questions: initialQuestions, onQuestionClick: handleQuestion, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.suggestedQuestions })),
|
|
66
|
+
react_1.default.createElement(Input_1.default, { onSubmit: handleQuestion, disabled: isLoading || isOpen, translations: translations })),
|
|
66
67
|
react_1.default.createElement("dialog", { ref: dialogRef, className: 'cio-pia-modal', "aria-labelledby": 'cio-pia-modal-title' },
|
|
67
68
|
react_1.default.createElement("div", { className: 'cio-pia-modal-content' },
|
|
68
69
|
react_1.default.createElement("div", { className: 'cio-pia-modal-header' },
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const Answer_1 = tslib_1.__importDefault(require("../Answer/Answer"));
|
|
6
|
+
const Feedback_1 = tslib_1.__importDefault(require("../Feedback/Feedback"));
|
|
7
|
+
const Disclaimer_1 = tslib_1.__importDefault(require("../CioPia/Disclaimer"));
|
|
8
|
+
const PiaCustomCarousel_1 = tslib_1.__importDefault(require("../CioPia/PiaCustomCarousel"));
|
|
9
|
+
function PiaInlineAnswer({ currentAnswer, currentItems, showFeedback, learnMoreUrl, disclaimerPosition = 'bottom', translations, callbacks, componentOverrides, }) {
|
|
10
|
+
const disclaimer = (react_1.default.createElement(Disclaimer_1.default, { learnMoreUrl: learnMoreUrl, translations: translations, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.disclaimer }));
|
|
11
|
+
return (react_1.default.createElement("div", { className: 'cio-pia-answer-container' },
|
|
12
|
+
disclaimerPosition === 'top' && disclaimer,
|
|
13
|
+
react_1.default.createElement(Answer_1.default, { text: currentAnswer, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.answer }),
|
|
14
|
+
currentItems && (react_1.default.createElement(PiaCustomCarousel_1.default, { items: currentItems, componentOverrides: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.carousel, callbacks: callbacks })),
|
|
15
|
+
showFeedback && (react_1.default.createElement(Feedback_1.default, { translations: translations, onFeedback: callbacks === null || callbacks === void 0 ? void 0 : callbacks.onFeedback, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.feedback })),
|
|
16
|
+
disclaimerPosition === 'bottom' && disclaimer));
|
|
17
|
+
}
|
|
18
|
+
exports.default = PiaInlineAnswer;
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DISCLAIMER_TEXT = exports.MOCK_QUESTIONS = exports.DEMO_QUESTION_ALTERNATIVE_PRODUCTS = exports.DEMO_QUESTION = exports.DEMO_ITEM_ID = exports.DEMO_API_KEY = void 0;
|
|
4
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
5
4
|
exports.DEMO_API_KEY = 'key_13TO6qN9H3BP3Wrn';
|
|
6
5
|
exports.DEMO_ITEM_ID = '149100215';
|
|
7
6
|
exports.DEMO_QUESTION = 'What is the nutritional content of this shake?';
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CioPia = void 0;
|
|
3
|
+
exports.renderMarkdown = exports.sanitizeHtml = exports.CioPia = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const CioPia_1 = tslib_1.__importDefault(require("./components/CioPia"));
|
|
6
6
|
// Components
|
|
7
7
|
var CioPia_2 = require("./components/CioPia");
|
|
8
8
|
Object.defineProperty(exports, "CioPia", { enumerable: true, get: function () { return tslib_1.__importDefault(CioPia_2).default; } });
|
|
9
|
+
// Utilities
|
|
10
|
+
var contentTransformers_1 = require("./utils/contentTransformers");
|
|
11
|
+
Object.defineProperty(exports, "sanitizeHtml", { enumerable: true, get: function () { return contentTransformers_1.sanitizeHtml; } });
|
|
12
|
+
Object.defineProperty(exports, "renderMarkdown", { enumerable: true, get: function () { return contentTransformers_1.renderMarkdown; } });
|
|
9
13
|
// Default
|
|
10
14
|
tslib_1.__exportStar(require("./types"), exports);
|
|
11
15
|
exports.default = CioPia_1.default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderMarkdown = exports.sanitizeHtml = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const dompurify_1 = tslib_1.__importDefault(require("dompurify"));
|
|
6
|
+
const marked_1 = require("marked");
|
|
7
|
+
const purifyConfig = {
|
|
8
|
+
FORBID_TAGS: ['script', 'style', 'iframe', 'object', 'embed', 'form'],
|
|
9
|
+
};
|
|
10
|
+
function sanitizeHtml(html) {
|
|
11
|
+
if (!html)
|
|
12
|
+
return '';
|
|
13
|
+
return dompurify_1.default.sanitize(html, purifyConfig);
|
|
14
|
+
}
|
|
15
|
+
exports.sanitizeHtml = sanitizeHtml;
|
|
16
|
+
function renderMarkdown(content) {
|
|
17
|
+
if (!content)
|
|
18
|
+
return '';
|
|
19
|
+
const html = marked_1.marked.parse(content, { async: false });
|
|
20
|
+
return dompurify_1.default.sanitize(html, purifyConfig);
|
|
21
|
+
}
|
|
22
|
+
exports.renderMarkdown = renderMarkdown;
|
package/lib/cjs/utils/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderMarkdown = exports.sanitizeHtml = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
tslib_1.__exportStar(require("./styleHelpers"), exports);
|
|
6
|
+
var contentTransformers_1 = require("./contentTransformers");
|
|
7
|
+
Object.defineProperty(exports, "sanitizeHtml", { enumerable: true, get: function () { return contentTransformers_1.sanitizeHtml; } });
|
|
8
|
+
Object.defineProperty(exports, "renderMarkdown", { enumerable: true, get: function () { return contentTransformers_1.renderMarkdown; } });
|
|
@@ -19,7 +19,6 @@ const defaultTranslations = {
|
|
|
19
19
|
* @param translations - Optional user-provided translations object
|
|
20
20
|
* @returns The translated string or the original word if no translation exists
|
|
21
21
|
*/
|
|
22
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
23
22
|
const translate = (word, translations) => {
|
|
24
23
|
if (translations && translations[word] !== undefined) {
|
|
25
24
|
return translations[word];
|
package/lib/cjs/version.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RenderPropsWrapper, } from '@constructor-io/constructorio-ui-components';
|
|
3
|
+
import { renderMarkdown } from '../../utils/contentTransformers';
|
|
3
4
|
function Answer({ text, componentOverride }) {
|
|
4
5
|
if (!text) {
|
|
5
6
|
return null;
|
|
6
7
|
}
|
|
7
8
|
return (React.createElement(RenderPropsWrapper, { props: { text }, override: componentOverride?.reactNode },
|
|
8
|
-
React.createElement("div", { className: 'cio-pia-answer', "data-testid": 'answer-text'
|
|
9
|
+
React.createElement("div", { className: 'cio-pia-answer', "data-testid": 'answer-text', dangerouslySetInnerHTML: { __html: renderMarkdown(text) } })));
|
|
9
10
|
}
|
|
10
11
|
export default Answer;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RenderPropsWrapper, } from '@constructor-io/constructorio-ui-components';
|
|
3
|
-
import Disclaimer from './Disclaimer';
|
|
4
3
|
import Input from '../Input/Input';
|
|
5
4
|
import SuggestedQuestionsContainer from '../SuggestedQuestionsContainer/SuggestedQuestionsContainer';
|
|
6
|
-
import Answer from '../Answer/Answer';
|
|
7
|
-
import Feedback from '../Feedback/Feedback';
|
|
8
5
|
import useCioPia from '../../hooks/useCioPia';
|
|
9
6
|
import useConversation from '../../hooks/useConversation';
|
|
10
7
|
import ErrorBlock from '../Error/ErrorBlock';
|
|
11
8
|
import LoadingSkeleton from '../LoadingSkeleton/LoadingSkeleton';
|
|
12
9
|
import { translate } from '../../utils/translate';
|
|
13
|
-
import
|
|
10
|
+
import PiaInlineAnswer from '../PiaInlineAnswer/PiaInlineAnswer';
|
|
14
11
|
import PiaModal from '../PiaConversation/PiaModal';
|
|
15
12
|
import PiaConversation from '../PiaConversation/PiaConversation';
|
|
16
13
|
export default function CioPia(props) {
|
|
17
14
|
const { apiKey, itemId, threadId, variationId, cioClient, displayConfigs, componentOverrides, callbacks, formatters, children, translations, suggestedQuestionsParameters, } = props;
|
|
18
|
-
const { learnMoreUrl, showFeedback, mode = 'default', type = 'inline', showPreviousItems, } = displayConfigs || {};
|
|
15
|
+
const { learnMoreUrl, showFeedback, mode = 'default', type = 'inline', showPreviousItems, disclaimerPosition = 'bottom', } = displayConfigs || {};
|
|
19
16
|
const isConversation = mode === 'conversation' || type === 'modal';
|
|
20
17
|
const pia = useCioPia({
|
|
21
18
|
apiKey,
|
|
@@ -45,6 +42,7 @@ export default function CioPia(props) {
|
|
|
45
42
|
showFeedback,
|
|
46
43
|
showPreviousItems,
|
|
47
44
|
learnMoreUrl,
|
|
45
|
+
disclaimerPosition,
|
|
48
46
|
translations,
|
|
49
47
|
callbacks,
|
|
50
48
|
componentOverrides,
|
|
@@ -65,10 +63,6 @@ export default function CioPia(props) {
|
|
|
65
63
|
isLoading && React.createElement(LoadingSkeleton, null),
|
|
66
64
|
!isLoading && error && React.createElement(ErrorBlock, { message: error?.message || 'Unexpected error' }),
|
|
67
65
|
!isLoading && !error && (React.createElement(React.Fragment, null,
|
|
68
|
-
currentAnswer && (React.createElement(
|
|
69
|
-
React.createElement(Answer, { text: currentAnswer, componentOverride: componentOverrides?.answer }),
|
|
70
|
-
currentItems && (React.createElement(PiaCustomCarousel, { items: currentItems, componentOverrides: componentOverrides?.carousel, callbacks: callbacks })),
|
|
71
|
-
showFeedback && (React.createElement(Feedback, { translations: translations, onFeedback: callbacks?.onFeedback, componentOverride: componentOverrides?.feedback })),
|
|
72
|
-
React.createElement(Disclaimer, { learnMoreUrl: learnMoreUrl, translations: translations, componentOverride: componentOverrides?.disclaimer }))),
|
|
66
|
+
currentAnswer && (React.createElement(PiaInlineAnswer, { currentAnswer: currentAnswer, currentItems: currentItems, showFeedback: showFeedback, learnMoreUrl: learnMoreUrl, disclaimerPosition: disclaimerPosition, translations: translations, callbacks: callbacks, componentOverrides: componentOverrides })),
|
|
73
67
|
React.createElement(SuggestedQuestionsContainer, { questions: displayedQuestions, onQuestionClick: handleSubmitQuestion, componentOverride: componentOverrides?.suggestedQuestions }))))));
|
|
74
68
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import React, { useCallback, useRef, useEffect } from 'react';
|
|
1
|
+
import React, { useCallback, useRef, useEffect, useMemo } from 'react';
|
|
2
2
|
import { Carousel, CIO_EVENTS, } from '@constructor-io/constructorio-ui-components';
|
|
3
|
+
import { sanitizeHtml } from '../../utils/contentTransformers';
|
|
4
|
+
function HtmlDescription({ product }) {
|
|
5
|
+
const { description } = product;
|
|
6
|
+
if (!description)
|
|
7
|
+
return null;
|
|
8
|
+
return (React.createElement("p", { className: 'cio-product-card-description', dangerouslySetInnerHTML: { __html: sanitizeHtml(description) } }));
|
|
9
|
+
}
|
|
3
10
|
export default function PiaCustomCarousel({ items, componentOverrides, callbacks, }) {
|
|
4
11
|
const wrapperRef = useRef(null);
|
|
5
12
|
// Determine to use user-defined click handler or default behavior
|
|
@@ -28,10 +35,28 @@ export default function PiaCustomCarousel({ items, componentOverrides, callbacks
|
|
|
28
35
|
el.removeEventListener(CIO_EVENTS.productCard.click, handleClick);
|
|
29
36
|
};
|
|
30
37
|
}, [productClickHandler]);
|
|
38
|
+
const mergedOverrides = useMemo(() => {
|
|
39
|
+
if (componentOverrides?.item?.productCard?.content?.description) {
|
|
40
|
+
return componentOverrides;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
...componentOverrides,
|
|
44
|
+
item: {
|
|
45
|
+
...componentOverrides?.item,
|
|
46
|
+
productCard: {
|
|
47
|
+
...componentOverrides?.item?.productCard,
|
|
48
|
+
content: {
|
|
49
|
+
...componentOverrides?.item?.productCard?.content,
|
|
50
|
+
description: { reactNode: HtmlDescription },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}, [componentOverrides]);
|
|
31
56
|
// If there are no items, do not render the carousel
|
|
32
57
|
if (items.length === 0) {
|
|
33
58
|
return null;
|
|
34
59
|
}
|
|
35
60
|
return (React.createElement("div", { ref: wrapperRef },
|
|
36
|
-
React.createElement(Carousel, { items: items, componentOverrides:
|
|
61
|
+
React.createElement(Carousel, { items: items, componentOverrides: mergedOverrides })));
|
|
37
62
|
}
|
|
@@ -5,7 +5,7 @@ import Disclaimer from '../CioPia/Disclaimer';
|
|
|
5
5
|
import ErrorBlock from '../Error/ErrorBlock';
|
|
6
6
|
import LoadingSkeleton from '../LoadingSkeleton/LoadingSkeleton';
|
|
7
7
|
import PiaCustomCarousel from '../CioPia/PiaCustomCarousel';
|
|
8
|
-
export default function ConversationHistory({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems = true, learnMoreUrl, translations, callbacks, componentOverrides, }) {
|
|
8
|
+
export default function ConversationHistory({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems = true, learnMoreUrl, disclaimerPosition = 'bottom', translations, callbacks, componentOverrides, }) {
|
|
9
9
|
const scrollContainerRef = useRef(null);
|
|
10
10
|
useEffect(() => {
|
|
11
11
|
const container = scrollContainerRef.current;
|
|
@@ -16,7 +16,9 @@ export default function ConversationHistory({ conversationHistory, isLoading, er
|
|
|
16
16
|
});
|
|
17
17
|
return () => cancelAnimationFrame(frameId);
|
|
18
18
|
}, [conversationHistory, isLoading]);
|
|
19
|
+
const disclaimer = (React.createElement(Disclaimer, { learnMoreUrl: learnMoreUrl, translations: translations, componentOverride: componentOverrides?.disclaimer }));
|
|
19
20
|
return (React.createElement("div", { className: 'cio-pia-conversation-history' },
|
|
21
|
+
disclaimerPosition === 'top' && disclaimer,
|
|
20
22
|
React.createElement("div", { ref: scrollContainerRef, className: 'cio-pia-conversation-entries', role: 'log', "aria-label": 'Conversation history' }, conversationHistory.map((entry, index) => {
|
|
21
23
|
const isLast = index === conversationHistory.length - 1;
|
|
22
24
|
const previousEntryItems = showPreviousItems ? entry.items : null;
|
|
@@ -32,5 +34,5 @@ export default function ConversationHistory({ conversationHistory, isLoading, er
|
|
|
32
34
|
carouselItems && (React.createElement(PiaCustomCarousel, { items: carouselItems, componentOverrides: componentOverrides?.carousel, callbacks: callbacks })),
|
|
33
35
|
isLast && showFeedback && (React.createElement(Feedback, { translations: translations, onFeedback: callbacks?.onFeedback, componentOverride: componentOverrides?.feedback }))))));
|
|
34
36
|
})),
|
|
35
|
-
|
|
37
|
+
disclaimerPosition === 'bottom' && disclaimer));
|
|
36
38
|
}
|
|
@@ -4,11 +4,11 @@ import SuggestedQuestionsContainer from '../SuggestedQuestionsContainer/Suggeste
|
|
|
4
4
|
import SuggestedQuestionsSkeleton from '../SuggestedQuestionsContainer/SuggestedQuestionsSkeleton';
|
|
5
5
|
import { translate } from '../../utils/translate';
|
|
6
6
|
import ConversationHistory from '../ConversationHistory/ConversationHistory';
|
|
7
|
-
export default function PiaConversation({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems, learnMoreUrl, translations, callbacks, componentOverrides, displayedQuestions, handleSubmitQuestion, }) {
|
|
7
|
+
export default function PiaConversation({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems, learnMoreUrl, disclaimerPosition, translations, callbacks, componentOverrides, displayedQuestions, handleSubmitQuestion, }) {
|
|
8
8
|
const hasHistory = conversationHistory.length > 0;
|
|
9
9
|
return (React.createElement("div", { className: 'cio-pia-container cio-pia-conversation', "data-testid": 'cio-pia-container' },
|
|
10
10
|
!hasHistory && (React.createElement("p", { className: 'cio-pia-title', "data-testid": 'cio-pia-title' }, translate('Any questions about this product?', translations))),
|
|
11
|
-
React.createElement(ConversationHistory, { conversationHistory: conversationHistory, isLoading: isLoading, error: error, currentItems: currentItems, showFeedback: showFeedback, showPreviousItems: showPreviousItems, learnMoreUrl: learnMoreUrl, translations: translations, callbacks: callbacks, componentOverrides: componentOverrides }),
|
|
11
|
+
React.createElement(ConversationHistory, { conversationHistory: conversationHistory, isLoading: isLoading, error: error, currentItems: currentItems, showFeedback: showFeedback, showPreviousItems: showPreviousItems, learnMoreUrl: learnMoreUrl, disclaimerPosition: disclaimerPosition, translations: translations, callbacks: callbacks, componentOverrides: componentOverrides }),
|
|
12
12
|
React.createElement("div", { className: 'cio-pia-conversation-footer' },
|
|
13
13
|
isLoading && !error && React.createElement(SuggestedQuestionsSkeleton, null),
|
|
14
14
|
!isLoading && !error && (React.createElement(SuggestedQuestionsContainer, { questions: displayedQuestions, onQuestionClick: handleSubmitQuestion, componentOverride: componentOverrides?.suggestedQuestions })),
|
|
@@ -58,8 +58,9 @@ export default function PiaModal({ initialQuestions, handleSubmitQuestion, isLoa
|
|
|
58
58
|
}, [handleSubmitQuestion, openModal]);
|
|
59
59
|
return (React.createElement("div", { className: 'cio-pia-container', "data-testid": 'cio-pia-container' },
|
|
60
60
|
React.createElement("p", { className: 'cio-pia-title', "data-testid": 'cio-pia-title' }, translate('Any questions about this product?', translations)),
|
|
61
|
-
React.createElement(
|
|
62
|
-
|
|
61
|
+
React.createElement("div", { className: 'cio-pia-conversation-footer' },
|
|
62
|
+
initialQuestions.length > 0 && (React.createElement(SuggestedQuestionsContainer, { questions: initialQuestions, onQuestionClick: handleQuestion, componentOverride: componentOverrides?.suggestedQuestions })),
|
|
63
|
+
React.createElement(Input, { onSubmit: handleQuestion, disabled: isLoading || isOpen, translations: translations })),
|
|
63
64
|
React.createElement("dialog", { ref: dialogRef, className: 'cio-pia-modal', "aria-labelledby": 'cio-pia-modal-title' },
|
|
64
65
|
React.createElement("div", { className: 'cio-pia-modal-content' },
|
|
65
66
|
React.createElement("div", { className: 'cio-pia-modal-header' },
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Answer from '../Answer/Answer';
|
|
3
|
+
import Feedback from '../Feedback/Feedback';
|
|
4
|
+
import Disclaimer from '../CioPia/Disclaimer';
|
|
5
|
+
import PiaCustomCarousel from '../CioPia/PiaCustomCarousel';
|
|
6
|
+
export default function PiaInlineAnswer({ currentAnswer, currentItems, showFeedback, learnMoreUrl, disclaimerPosition = 'bottom', translations, callbacks, componentOverrides, }) {
|
|
7
|
+
const disclaimer = (React.createElement(Disclaimer, { learnMoreUrl: learnMoreUrl, translations: translations, componentOverride: componentOverrides?.disclaimer }));
|
|
8
|
+
return (React.createElement("div", { className: 'cio-pia-answer-container' },
|
|
9
|
+
disclaimerPosition === 'top' && disclaimer,
|
|
10
|
+
React.createElement(Answer, { text: currentAnswer, componentOverride: componentOverrides?.answer }),
|
|
11
|
+
currentItems && (React.createElement(PiaCustomCarousel, { items: currentItems, componentOverrides: componentOverrides?.carousel, callbacks: callbacks })),
|
|
12
|
+
showFeedback && (React.createElement(Feedback, { translations: translations, onFeedback: callbacks?.onFeedback, componentOverride: componentOverrides?.feedback })),
|
|
13
|
+
disclaimerPosition === 'bottom' && disclaimer));
|
|
14
|
+
}
|
package/lib/mjs/constants.js
CHANGED
package/lib/mjs/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import CioPia from './components/CioPia';
|
|
2
2
|
// Components
|
|
3
3
|
export { default as CioPia } from './components/CioPia';
|
|
4
|
+
// Utilities
|
|
5
|
+
export { sanitizeHtml, renderMarkdown } from './utils/contentTransformers';
|
|
4
6
|
// Default
|
|
5
7
|
export * from './types';
|
|
6
8
|
export default CioPia;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import DOMPurify from 'dompurify';
|
|
2
|
+
import { marked } from 'marked';
|
|
3
|
+
const purifyConfig = {
|
|
4
|
+
FORBID_TAGS: ['script', 'style', 'iframe', 'object', 'embed', 'form'],
|
|
5
|
+
};
|
|
6
|
+
export function sanitizeHtml(html) {
|
|
7
|
+
if (!html)
|
|
8
|
+
return '';
|
|
9
|
+
return DOMPurify.sanitize(html, purifyConfig);
|
|
10
|
+
}
|
|
11
|
+
export function renderMarkdown(content) {
|
|
12
|
+
if (!content)
|
|
13
|
+
return '';
|
|
14
|
+
const html = marked.parse(content, { async: false });
|
|
15
|
+
return DOMPurify.sanitize(html, purifyConfig);
|
|
16
|
+
}
|
package/lib/mjs/utils/index.js
CHANGED
|
@@ -16,7 +16,6 @@ const defaultTranslations = {
|
|
|
16
16
|
* @param translations - Optional user-provided translations object
|
|
17
17
|
* @returns The translated string or the original word if no translation exists
|
|
18
18
|
*/
|
|
19
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
20
19
|
export const translate = (word, translations) => {
|
|
21
20
|
if (translations && translations[word] !== undefined) {
|
|
22
21
|
return translations[word];
|
package/lib/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '2.
|
|
1
|
+
export default '2.4.0';
|
|
@@ -3,29 +3,27 @@ import { IncludeComponentOverrides, IncludeRenderProps } from '@constructor-io/c
|
|
|
3
3
|
import MockConstructorIOClient from '../../hooks/mocks/MockConstructorIOClient';
|
|
4
4
|
import { CioPiaRenderProps, CioPiaComponentOverrides, Callbacks, CioPiaDisplayConfigs, Translations, SuggestedQuestionsParameters, Formatters } from '../../types';
|
|
5
5
|
export interface CioPiaProps extends IncludeRenderProps<CioPiaRenderProps>, IncludeComponentOverrides<CioPiaComponentOverrides> {
|
|
6
|
+
/** Your Constructor.io API key. */
|
|
6
7
|
apiKey: string;
|
|
8
|
+
/** The product item ID to fetch insights for. */
|
|
7
9
|
itemId: string;
|
|
8
|
-
/** Thread ID for conversation context. Must be a valid UUID (e.g., "550e8400-e29b-41d4-a716-446655440000") */
|
|
10
|
+
/** Thread ID for conversation context. Must be a valid UUID (e.g., "550e8400-e29b-41d4-a716-446655440000"). */
|
|
9
11
|
threadId?: string;
|
|
12
|
+
/** Optional variation ID for the product. */
|
|
10
13
|
variationId?: string;
|
|
14
|
+
/** Optional Constructor.io client instance. If not provided, one will be created internally. */
|
|
11
15
|
cioClient?: MockConstructorIOClient;
|
|
16
|
+
/** Display configuration options (mode, type, showFeedback, etc.). */
|
|
12
17
|
displayConfigs?: CioPiaDisplayConfigs;
|
|
13
|
-
/**
|
|
14
|
-
* Callback handlers for user interactions:
|
|
15
|
-
*
|
|
16
|
-
* `onQuestionSubmit: (question: string) => void`
|
|
17
|
-
* Called when a question is submitted (via Enter key, Send button, or suggested question click).
|
|
18
|
-
*
|
|
19
|
-
* `onProductCardClick: (item: Item) => void`
|
|
20
|
-
* Called when a product card in the carousel is clicked.
|
|
21
|
-
*
|
|
22
|
-
* `onFeedback: (type: 'up' | 'down') => void`
|
|
23
|
-
* Called when the user submits positive or negative feedback on an answer.
|
|
24
|
-
*/
|
|
18
|
+
/** Callback handlers for user interactions (onQuestionSubmit, onProductCardClick, onFeedback). */
|
|
25
19
|
callbacks?: Callbacks;
|
|
26
|
-
/**
|
|
20
|
+
/** Custom component overrides via reactNode or render props functions. */
|
|
21
|
+
componentOverrides?: CioPiaComponentOverrides;
|
|
22
|
+
/** Formatter functions for transforming data before display. */
|
|
27
23
|
formatters?: Formatters;
|
|
24
|
+
/** UI string translations for internationalization. */
|
|
28
25
|
translations?: Translations;
|
|
26
|
+
/** Parameters for the suggested questions request. */
|
|
29
27
|
suggestedQuestionsParameters?: SuggestedQuestionsParameters;
|
|
30
28
|
}
|
|
31
29
|
export default function CioPia(props: CioPiaProps): React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ConversationEntry, Translations, Item, Callbacks, CioPiaComponentOverrides } from '../../types';
|
|
2
|
+
import { ConversationEntry, Translations, Item, Callbacks, CioPiaComponentOverrides, DisclaimerPosition } from '../../types';
|
|
3
3
|
export interface ConversationHistoryProps {
|
|
4
4
|
conversationHistory: ConversationEntry[];
|
|
5
5
|
isLoading: boolean;
|
|
@@ -18,8 +18,9 @@ export interface ConversationHistoryProps {
|
|
|
18
18
|
*/
|
|
19
19
|
showPreviousItems?: boolean;
|
|
20
20
|
learnMoreUrl?: string;
|
|
21
|
+
disclaimerPosition?: DisclaimerPosition;
|
|
21
22
|
translations?: Translations;
|
|
22
23
|
callbacks?: Callbacks;
|
|
23
24
|
componentOverrides?: CioPiaComponentOverrides;
|
|
24
25
|
}
|
|
25
|
-
export default function ConversationHistory({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems, learnMoreUrl, translations, callbacks, componentOverrides, }: ConversationHistoryProps): React.JSX.Element;
|
|
26
|
+
export default function ConversationHistory({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems, learnMoreUrl, disclaimerPosition, translations, callbacks, componentOverrides, }: ConversationHistoryProps): React.JSX.Element;
|
|
@@ -5,4 +5,4 @@ export interface PiaConversationProps extends ConversationHistoryProps {
|
|
|
5
5
|
displayedQuestions: Question[];
|
|
6
6
|
handleSubmitQuestion: (question: string) => void;
|
|
7
7
|
}
|
|
8
|
-
export default function PiaConversation({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems, learnMoreUrl, translations, callbacks, componentOverrides, displayedQuestions, handleSubmitQuestion, }: PiaConversationProps): React.JSX.Element;
|
|
8
|
+
export default function PiaConversation({ conversationHistory, isLoading, error, currentItems, showFeedback, showPreviousItems, learnMoreUrl, disclaimerPosition, translations, callbacks, componentOverrides, displayedQuestions, handleSubmitQuestion, }: PiaConversationProps): React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Callbacks, CioPiaComponentOverrides, DisclaimerPosition, Translations, Item } from '../../types';
|
|
3
|
+
interface PiaInlineAnswerProps {
|
|
4
|
+
currentAnswer: string;
|
|
5
|
+
currentItems: Item[] | null;
|
|
6
|
+
showFeedback?: boolean;
|
|
7
|
+
learnMoreUrl?: string;
|
|
8
|
+
disclaimerPosition?: DisclaimerPosition;
|
|
9
|
+
translations?: Translations;
|
|
10
|
+
callbacks?: Callbacks;
|
|
11
|
+
componentOverrides?: CioPiaComponentOverrides;
|
|
12
|
+
}
|
|
13
|
+
export default function PiaInlineAnswer({ currentAnswer, currentItems, showFeedback, learnMoreUrl, disclaimerPosition, translations, callbacks, componentOverrides, }: PiaInlineAnswerProps): React.JSX.Element;
|
|
14
|
+
export {};
|