@constructor-io/constructorio-ui-pia 2.1.0 → 2.1.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/LICENSE +1 -1
- package/README.md +219 -15
- package/dist/constructorio-ui-pia-bundled.js +12 -12
- package/lib/cjs/components/Answer/Answer.js +13 -0
- package/lib/cjs/components/Answer/AnswerStyles.css +8 -0
- package/lib/cjs/components/CioPia/CioPia.js +76 -0
- package/lib/cjs/components/CioPia/CioPiaStyles.css +32 -0
- package/lib/cjs/components/CioPia/Disclaimer.js +16 -0
- package/lib/cjs/components/CioPia/PiaCustomCarousel.js +41 -0
- package/lib/cjs/components/CioPia/index.js +6 -0
- package/lib/cjs/components/ConversationHistory/ConversationHistory.js +36 -0
- package/lib/cjs/components/ConversationHistory/ConversationHistoryStyles.css +51 -0
- package/lib/cjs/components/Error/ErrorBlock.js +23 -0
- package/lib/cjs/components/Error/ErrorStyles.css +46 -0
- package/lib/cjs/components/Feedback/Feedback.js +28 -0
- package/lib/cjs/components/Feedback/FeedbackStyles.css +31 -0
- package/lib/cjs/components/Input/Input.js +40 -0
- package/lib/cjs/components/Input/InputStyles.css +102 -0
- package/lib/cjs/components/LoadingSkeleton/LoadingSkeleton.js +11 -0
- package/lib/cjs/components/LoadingSkeleton/LoadingSkeletonStyles.css +32 -0
- package/lib/cjs/components/PiaConversation/PiaConversation.js +20 -0
- package/lib/cjs/components/PiaConversation/PiaConversationStyles.css +91 -0
- package/lib/cjs/components/PiaConversation/PiaModal.js +74 -0
- package/lib/cjs/components/SuggestedQuestion/SuggestedQuestion.js +16 -0
- package/lib/cjs/components/SuggestedQuestion/SuggestedQuestionStyles.css +33 -0
- package/lib/cjs/components/SuggestedQuestionsContainer/SuggestedQuestionsContainer.js +14 -0
- package/lib/cjs/components/SuggestedQuestionsContainer/SuggestedQuestionsContainerStyles.css +37 -0
- package/lib/cjs/components/SuggestedQuestionsContainer/SuggestedQuestionsSkeleton.js +11 -0
- package/lib/cjs/constants.js +17 -0
- package/lib/cjs/hooks/mocks/MockConstructorIOClient.js +20 -0
- package/lib/cjs/hooks/mocks/agent.js +146 -0
- package/lib/cjs/hooks/mocks/types.js +2 -0
- package/lib/cjs/hooks/useAnswerResults.js +62 -0
- package/lib/cjs/hooks/useCioClient.js +21 -0
- package/lib/cjs/hooks/useCioPia.js +29 -0
- package/lib/cjs/hooks/useConversation.js +74 -0
- package/lib/cjs/hooks/useSuggestedQuestions.js +52 -0
- package/lib/cjs/stories/assets/storybook-styles.css +112 -0
- package/lib/cjs/styles.css +26 -0
- package/lib/cjs/types.js +10 -0
- package/lib/cjs/utils/index.js +4 -0
- package/lib/cjs/utils/styleHelpers.js +14 -0
- package/lib/cjs/utils/transformers.js +29 -0
- package/lib/cjs/utils/translate.js +29 -0
- package/lib/cjs/version.js +3 -0
- package/lib/mjs/components/Answer/Answer.js +10 -0
- package/lib/mjs/components/Answer/AnswerStyles.css +8 -0
- package/lib/mjs/components/CioPia/CioPia.js +72 -0
- package/lib/mjs/components/CioPia/CioPiaStyles.css +32 -0
- package/lib/mjs/components/CioPia/Disclaimer.js +12 -0
- package/lib/mjs/components/CioPia/PiaCustomCarousel.js +37 -0
- package/lib/mjs/components/CioPia/index.js +3 -0
- package/lib/mjs/components/ConversationHistory/ConversationHistory.js +32 -0
- package/lib/mjs/components/ConversationHistory/ConversationHistoryStyles.css +51 -0
- package/lib/mjs/components/Error/ErrorBlock.js +20 -0
- package/lib/mjs/components/Error/ErrorStyles.css +46 -0
- package/lib/mjs/components/Feedback/Feedback.js +24 -0
- package/lib/mjs/components/Feedback/FeedbackStyles.css +31 -0
- package/lib/mjs/components/Input/Input.js +37 -0
- package/lib/mjs/components/Input/InputStyles.css +102 -0
- package/lib/mjs/components/LoadingSkeleton/LoadingSkeleton.js +7 -0
- package/lib/mjs/components/LoadingSkeleton/LoadingSkeletonStyles.css +32 -0
- package/lib/mjs/components/PiaConversation/PiaConversation.js +16 -0
- package/lib/mjs/components/PiaConversation/PiaConversationStyles.css +91 -0
- package/lib/mjs/components/PiaConversation/PiaModal.js +70 -0
- package/lib/mjs/components/SuggestedQuestion/SuggestedQuestion.js +13 -0
- package/lib/mjs/components/SuggestedQuestion/SuggestedQuestionStyles.css +33 -0
- package/lib/mjs/components/SuggestedQuestionsContainer/SuggestedQuestionsContainer.js +10 -0
- package/lib/mjs/components/SuggestedQuestionsContainer/SuggestedQuestionsContainerStyles.css +37 -0
- package/lib/mjs/components/SuggestedQuestionsContainer/SuggestedQuestionsSkeleton.js +7 -0
- package/lib/mjs/constants.js +14 -0
- package/lib/mjs/hooks/mocks/MockConstructorIOClient.js +35 -0
- package/lib/mjs/hooks/mocks/agent.js +138 -0
- package/lib/mjs/hooks/mocks/types.js +1 -0
- package/lib/mjs/hooks/useAnswerResults.js +57 -0
- package/lib/mjs/hooks/useCioClient.js +23 -0
- package/lib/mjs/hooks/useCioPia.js +25 -0
- package/lib/mjs/hooks/useConversation.js +71 -0
- package/lib/mjs/hooks/useSuggestedQuestions.js +48 -0
- package/lib/mjs/index.js +6 -0
- package/lib/mjs/stories/assets/storybook-styles.css +112 -0
- package/lib/mjs/styles.css +26 -0
- package/lib/mjs/types.js +6 -0
- package/lib/mjs/utils/index.js +1 -0
- package/lib/mjs/utils/styleHelpers.js +9 -0
- package/lib/mjs/utils/transformers.js +30 -0
- package/lib/mjs/utils/translate.js +25 -0
- package/lib/mjs/version.js +1 -0
- package/lib/types/components/Answer/Answer.d.ts +9 -0
- package/lib/types/components/CioPia/CioPia.d.ts +17 -0
- package/lib/types/components/CioPia/Disclaimer.d.ts +8 -0
- package/lib/types/components/CioPia/PiaCustomCarousel.d.ts +10 -0
- package/lib/types/components/CioPia/index.d.ts +3 -0
- package/lib/types/components/ConversationHistory/ConversationHistory.d.ts +14 -0
- package/lib/types/components/Error/ErrorBlock.d.ts +7 -0
- package/lib/types/components/Feedback/Feedback.d.ts +10 -0
- package/lib/types/components/Input/Input.d.ts +12 -0
- package/lib/types/components/LoadingSkeleton/LoadingSkeleton.d.ts +2 -0
- package/lib/types/components/PiaConversation/PiaConversation.d.ts +8 -0
- package/lib/types/components/PiaConversation/PiaModal.d.ts +12 -0
- package/lib/types/components/SuggestedQuestion/SuggestedQuestion.d.ts +7 -0
- package/lib/types/components/SuggestedQuestionsContainer/SuggestedQuestionsContainer.d.ts +10 -0
- package/lib/types/components/SuggestedQuestionsContainer/SuggestedQuestionsSkeleton.d.ts +2 -0
- package/lib/types/constants.d.ts +8 -0
- package/lib/types/hooks/mocks/MockConstructorIOClient.d.ts +14 -0
- package/lib/types/hooks/mocks/agent.d.ts +10 -0
- package/lib/types/hooks/mocks/types.d.ts +75 -0
- package/lib/types/hooks/useAnswerResults.d.ts +18 -0
- package/lib/types/hooks/useCioClient.d.ts +13 -0
- package/lib/types/hooks/useCioPia.d.ts +17 -0
- package/lib/types/hooks/useConversation.d.ts +19 -0
- package/lib/types/hooks/useSuggestedQuestions.d.ts +16 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/types.d.ts +102 -0
- package/lib/types/utils/index.d.ts +1 -0
- package/lib/types/utils/styleHelpers.d.ts +1 -0
- package/lib/types/utils/transformers.d.ts +7 -0
- package/lib/types/utils/translate.d.ts +10 -0
- package/lib/types/version.d.ts +2 -0
- package/package.json +15 -4
|
@@ -0,0 +1,13 @@
|
|
|
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 constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
|
|
6
|
+
function Answer({ text, componentOverride }) {
|
|
7
|
+
if (!text) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
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' }, text)));
|
|
12
|
+
}
|
|
13
|
+
exports.default = Answer;
|
|
@@ -0,0 +1,76 @@
|
|
|
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 constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
|
|
6
|
+
const Disclaimer_1 = tslib_1.__importDefault(require("./Disclaimer"));
|
|
7
|
+
const Input_1 = tslib_1.__importDefault(require("../Input/Input"));
|
|
8
|
+
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
|
+
const useCioPia_1 = tslib_1.__importDefault(require("../../hooks/useCioPia"));
|
|
12
|
+
const useConversation_1 = tslib_1.__importDefault(require("../../hooks/useConversation"));
|
|
13
|
+
const ErrorBlock_1 = tslib_1.__importDefault(require("../Error/ErrorBlock"));
|
|
14
|
+
const LoadingSkeleton_1 = tslib_1.__importDefault(require("../LoadingSkeleton/LoadingSkeleton"));
|
|
15
|
+
const translate_1 = require("../../utils/translate");
|
|
16
|
+
const PiaCustomCarousel_1 = tslib_1.__importDefault(require("./PiaCustomCarousel"));
|
|
17
|
+
const PiaModal_1 = tslib_1.__importDefault(require("../PiaConversation/PiaModal"));
|
|
18
|
+
const PiaConversation_1 = tslib_1.__importDefault(require("../PiaConversation/PiaConversation"));
|
|
19
|
+
function CioPia(props) {
|
|
20
|
+
const { apiKey, itemId, threadId, variationId, cioClient, displayConfigs, componentOverrides, callbacks, children, translations, suggestedQuestionsParameters, } = props;
|
|
21
|
+
const { learnMoreUrl, showFeedback, mode = 'default', type = 'inline' } = displayConfigs || {};
|
|
22
|
+
const isConversation = mode === 'conversation' || type === 'modal';
|
|
23
|
+
const pia = (0, useCioPia_1.default)({
|
|
24
|
+
apiKey,
|
|
25
|
+
itemId,
|
|
26
|
+
threadId,
|
|
27
|
+
variationId,
|
|
28
|
+
cioClient,
|
|
29
|
+
suggestedQuestionsParameters,
|
|
30
|
+
});
|
|
31
|
+
const { currentQuestion, displayedQuestions, conversationHistory, currentAnswer, currentItems, isLoading, error, handleSubmitQuestion, resetState, } = (0, useConversation_1.default)({ pia, itemId, isConversation });
|
|
32
|
+
const renderProps = {
|
|
33
|
+
items: currentItems,
|
|
34
|
+
isLoading,
|
|
35
|
+
error,
|
|
36
|
+
currentAnswer,
|
|
37
|
+
currentQuestion,
|
|
38
|
+
displayedQuestions,
|
|
39
|
+
handleSubmitQuestion,
|
|
40
|
+
conversationHistory,
|
|
41
|
+
};
|
|
42
|
+
const conversationHistoryProps = {
|
|
43
|
+
conversationHistory,
|
|
44
|
+
isLoading,
|
|
45
|
+
error,
|
|
46
|
+
currentItems,
|
|
47
|
+
showFeedback,
|
|
48
|
+
learnMoreUrl,
|
|
49
|
+
translations,
|
|
50
|
+
callbacks,
|
|
51
|
+
componentOverrides,
|
|
52
|
+
displayedQuestions,
|
|
53
|
+
handleSubmitQuestion,
|
|
54
|
+
};
|
|
55
|
+
if (type === 'modal') {
|
|
56
|
+
return (react_1.default.createElement(PiaModal_1.default, { initialQuestions: pia.suggestedQuestions.data, handleSubmitQuestion: handleSubmitQuestion, isLoading: isLoading, componentOverrides: componentOverrides, translations: translations, onClose: resetState },
|
|
57
|
+
react_1.default.createElement(PiaConversation_1.default, Object.assign({}, conversationHistoryProps))));
|
|
58
|
+
}
|
|
59
|
+
if (isConversation)
|
|
60
|
+
return react_1.default.createElement(PiaConversation_1.default, Object.assign({}, conversationHistoryProps));
|
|
61
|
+
// Default inline mode
|
|
62
|
+
return (react_1.default.createElement("div", { className: 'cio-pia-container', "data-testid": 'cio-pia-container' },
|
|
63
|
+
react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { props: renderProps, override: children || (componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.reactNode) },
|
|
64
|
+
react_1.default.createElement("p", { className: 'cio-pia-title', "data-testid": 'cio-pia-title' }, (0, translate_1.translate)('Any questions about this product?', translations)),
|
|
65
|
+
react_1.default.createElement(Input_1.default, { onSubmit: handleSubmitQuestion, value: currentQuestion, translations: translations }),
|
|
66
|
+
isLoading && react_1.default.createElement(LoadingSkeleton_1.default, null),
|
|
67
|
+
!isLoading && error && react_1.default.createElement(ErrorBlock_1.default, { message: (error === null || error === void 0 ? void 0 : error.message) || 'Unexpected error' }),
|
|
68
|
+
!isLoading && !error && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
69
|
+
currentAnswer && (react_1.default.createElement("div", { className: 'cio-pia-answer-container' },
|
|
70
|
+
react_1.default.createElement(Answer_1.default, { text: currentAnswer, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.answer }),
|
|
71
|
+
currentItems && (react_1.default.createElement(PiaCustomCarousel_1.default, { items: currentItems, componentOverrides: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.carousel, callbacks: callbacks })),
|
|
72
|
+
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 })),
|
|
73
|
+
react_1.default.createElement(Disclaimer_1.default, { learnMoreUrl: learnMoreUrl, translations: translations, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.disclaimer }))),
|
|
74
|
+
react_1.default.createElement(SuggestedQuestionsContainer_1.default, { questions: displayedQuestions, onQuestionClick: handleSubmitQuestion, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.suggestedQuestions }))))));
|
|
75
|
+
}
|
|
76
|
+
exports.default = CioPia;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.cio-pia-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: 24px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.cio-pia-title {
|
|
9
|
+
color: #14151a;
|
|
10
|
+
font-size: 18px;
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
text-align: start;
|
|
13
|
+
margin-top: 0;
|
|
14
|
+
margin-bottom: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cio-pia-answer-container {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.cio-pia-disclaimer {
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
font-weight: 400;
|
|
26
|
+
text-align: start;
|
|
27
|
+
color: rgba(15, 19, 36, 0.7);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.cio-pia-learn-more {
|
|
31
|
+
color: inherit;
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
|
|
6
|
+
const translate_1 = require("../../utils/translate");
|
|
7
|
+
const constants_1 = require("../../constants");
|
|
8
|
+
function Disclaimer({ learnMoreUrl, translations, componentOverride, }) {
|
|
9
|
+
return (react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { props: { learnMoreUrl, translations }, override: componentOverride === null || componentOverride === void 0 ? void 0 : componentOverride.reactNode },
|
|
10
|
+
react_1.default.createElement("span", { className: 'cio-pia-disclaimer' },
|
|
11
|
+
(0, translate_1.translate)(constants_1.DISCLAIMER_TEXT, translations),
|
|
12
|
+
' ',
|
|
13
|
+
learnMoreUrl && (react_1.default.createElement("a", { href: learnMoreUrl, target: '_blank', rel: 'noopener noreferrer', className: 'cio-pia-learn-more' },
|
|
14
|
+
react_1.default.createElement("u", null, (0, translate_1.translate)('Learn More.', translations)))))));
|
|
15
|
+
}
|
|
16
|
+
exports.default = Disclaimer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
|
|
6
|
+
function PiaCustomCarousel({ items, componentOverrides, callbacks, }) {
|
|
7
|
+
const wrapperRef = (0, react_1.useRef)(null);
|
|
8
|
+
// Determine to use user-defined click handler or default behavior
|
|
9
|
+
const productClickHandler = (0, react_1.useCallback)((item) => {
|
|
10
|
+
const { onProductCardClick } = callbacks || {};
|
|
11
|
+
if (onProductCardClick) {
|
|
12
|
+
onProductCardClick(item);
|
|
13
|
+
}
|
|
14
|
+
else if (item === null || item === void 0 ? void 0 : item.url) {
|
|
15
|
+
window.open(item.url, '_blank', 'noopener,noreferrer');
|
|
16
|
+
}
|
|
17
|
+
}, [callbacks]);
|
|
18
|
+
// Set up event listener for product card clicks
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
const el = wrapperRef.current;
|
|
21
|
+
if (!el)
|
|
22
|
+
return undefined;
|
|
23
|
+
const handleClick = (e) => {
|
|
24
|
+
const { product } = e.detail;
|
|
25
|
+
if (product) {
|
|
26
|
+
productClickHandler(product);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
el.addEventListener(constructorio_ui_components_1.CIO_EVENTS.productCard.click, handleClick);
|
|
30
|
+
return () => {
|
|
31
|
+
el.removeEventListener(constructorio_ui_components_1.CIO_EVENTS.productCard.click, handleClick);
|
|
32
|
+
};
|
|
33
|
+
}, [productClickHandler]);
|
|
34
|
+
// If there are no items, do not render the carousel
|
|
35
|
+
if (items.length === 0) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return (react_1.default.createElement("div", { ref: wrapperRef },
|
|
39
|
+
react_1.default.createElement(constructorio_ui_components_1.Carousel, { items: items, componentOverrides: componentOverrides })));
|
|
40
|
+
}
|
|
41
|
+
exports.default = PiaCustomCarousel;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const CioPia_1 = tslib_1.__importDefault(require("./CioPia"));
|
|
5
|
+
tslib_1.__exportStar(require("./CioPia"), exports);
|
|
6
|
+
exports.default = CioPia_1.default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(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 ErrorBlock_1 = tslib_1.__importDefault(require("../Error/ErrorBlock"));
|
|
9
|
+
const LoadingSkeleton_1 = tslib_1.__importDefault(require("../LoadingSkeleton/LoadingSkeleton"));
|
|
10
|
+
const PiaCustomCarousel_1 = tslib_1.__importDefault(require("../CioPia/PiaCustomCarousel"));
|
|
11
|
+
function ConversationHistory({ conversationHistory, isLoading, error, currentItems, showFeedback, learnMoreUrl, translations, callbacks, componentOverrides, }) {
|
|
12
|
+
const scrollContainerRef = (0, react_1.useRef)(null);
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
const container = scrollContainerRef.current;
|
|
15
|
+
if (!container)
|
|
16
|
+
return undefined;
|
|
17
|
+
const frameId = requestAnimationFrame(() => {
|
|
18
|
+
container.scrollTo({ top: container.scrollHeight, behavior: 'smooth' });
|
|
19
|
+
});
|
|
20
|
+
return () => cancelAnimationFrame(frameId);
|
|
21
|
+
}, [conversationHistory, isLoading]);
|
|
22
|
+
return (react_1.default.createElement("div", { ref: scrollContainerRef, className: 'cio-pia-conversation-history', role: 'log', "aria-label": 'Conversation history' }, conversationHistory.map((entry, index) => {
|
|
23
|
+
const isLast = index === conversationHistory.length - 1;
|
|
24
|
+
return (react_1.default.createElement("div", { key: entry.id, className: 'cio-pia-conversation-entry' },
|
|
25
|
+
react_1.default.createElement("div", { className: 'cio-pia-chat-question' }, entry.question),
|
|
26
|
+
isLast && isLoading && (react_1.default.createElement("div", { className: 'cio-pia-conversation-loading', "aria-live": 'polite' },
|
|
27
|
+
react_1.default.createElement(LoadingSkeleton_1.default, null))),
|
|
28
|
+
isLast && !isLoading && error && (react_1.default.createElement(ErrorBlock_1.default, { message: error.message || 'Unexpected error' })),
|
|
29
|
+
entry.answer && (react_1.default.createElement("div", { className: 'cio-pia-answer-container' },
|
|
30
|
+
react_1.default.createElement(Answer_1.default, { text: entry.answer, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.answer }),
|
|
31
|
+
isLast && currentItems && (react_1.default.createElement(PiaCustomCarousel_1.default, { items: currentItems, componentOverrides: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.carousel, callbacks: callbacks })),
|
|
32
|
+
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 })))),
|
|
33
|
+
isLast && entry.answer && (react_1.default.createElement(Disclaimer_1.default, { learnMoreUrl: learnMoreUrl, translations: translations, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.disclaimer }))));
|
|
34
|
+
})));
|
|
35
|
+
}
|
|
36
|
+
exports.default = ConversationHistory;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.cio-pia-conversation-history {
|
|
2
|
+
--conversation-gap: 16px;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--conversation-gap);
|
|
6
|
+
overflow-y: auto;
|
|
7
|
+
flex: 1;
|
|
8
|
+
min-height: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.cio-pia-conversation-entry {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: var(--conversation-gap);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cio-pia-chat-question {
|
|
18
|
+
align-self: flex-end;
|
|
19
|
+
background: var(--cio-pia-chat-question-bg);
|
|
20
|
+
border-radius: 12px 12px 12px 12px;
|
|
21
|
+
padding: 8px 12px;
|
|
22
|
+
font-size: 14px;
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
color: #14151a;
|
|
25
|
+
max-width: 80%;
|
|
26
|
+
text-align: start;
|
|
27
|
+
word-break: break-word;
|
|
28
|
+
transition: border-radius 0.3s ease;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cio-pia-conversation-entry .cio-pia-answer-container {
|
|
32
|
+
align-self: flex-start;
|
|
33
|
+
background: var(--cio-pia-chat-answer-bg);
|
|
34
|
+
border-radius: 12px 12px 12px 12px;
|
|
35
|
+
padding: 8px 12px;
|
|
36
|
+
max-width: 80%;
|
|
37
|
+
transition: border-radius 0.3s ease;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.cio-pia-conversation-entry:last-child .cio-pia-chat-question {
|
|
41
|
+
border-bottom-right-radius: 2px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.cio-pia-conversation-entry:last-child .cio-pia-answer-container {
|
|
45
|
+
border-bottom-left-radius: 2px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.cio-pia-conversation-loading {
|
|
49
|
+
align-self: flex-start;
|
|
50
|
+
max-width: 80%;
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
function WarningIcon() {
|
|
6
|
+
return (react_1.default.createElement("svg", { width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
|
|
7
|
+
react_1.default.createElement("path", { d: 'M12.0004 2C6.4804 2 2.0004 6.48 2.0004 12C2.0004 17.52 6.4804 22 12.0004 22C17.5204 22 22.0004 17.52 22.0004 12C22.0004 6.48 17.5204 2 12.0004 2ZM13.0004 17H11.0004V15H13.0004V17ZM13.0004 13H11.0004V7H13.0004V13Z', fill: '#F1923A' })));
|
|
8
|
+
}
|
|
9
|
+
function RetryIcon() {
|
|
10
|
+
return (react_1.default.createElement("svg", { width: '16', height: '16', viewBox: '0 0 16 16', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
|
|
11
|
+
react_1.default.createElement("path", { d: 'M11.7633 4.23329C10.7966 3.26663 9.46992 2.66663 7.99659 2.66663C5.04992 2.66663 2.66992 5.05329 2.66992 7.99996C2.66992 10.9466 5.04992 13.3333 7.99659 13.3333C10.4833 13.3333 12.5566 11.6333 13.1499 9.33329H11.7633C11.2166 10.8866 9.73659 12 7.99659 12C5.78992 12 3.99659 10.2066 3.99659 7.99996C3.99659 5.79329 5.78992 3.99996 7.99659 3.99996C9.10326 3.99996 10.0899 4.45996 10.8099 5.18663L8.66326 7.33329H13.3299V2.66663L11.7633 4.23329Z', fill: 'white' })));
|
|
12
|
+
}
|
|
13
|
+
function ErrorBlock({ message, onRetry = undefined }) {
|
|
14
|
+
return (react_1.default.createElement("div", { className: 'cio-pia-error-block-container', "data-testid": 'error-block' },
|
|
15
|
+
react_1.default.createElement("div", { className: 'cio-pia-error-block-warning-icon-container', "data-testid": 'error-block-warning-icon' },
|
|
16
|
+
react_1.default.createElement(WarningIcon, null)),
|
|
17
|
+
react_1.default.createElement("div", { className: 'cio-pia-error-block-text-container' },
|
|
18
|
+
react_1.default.createElement("p", { className: 'cio-pia-error-block-text' }, message),
|
|
19
|
+
onRetry && (react_1.default.createElement("button", { type: 'button', onClick: onRetry, className: 'cio-pia-error-block-retry-button' },
|
|
20
|
+
react_1.default.createElement(RetryIcon, null),
|
|
21
|
+
"Retry")))));
|
|
22
|
+
}
|
|
23
|
+
exports.default = ErrorBlock;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.cio-pia-error-block-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
max-width: 320px;
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: 12px;
|
|
7
|
+
background-color: #fef8f4;
|
|
8
|
+
border-radius: 6px;
|
|
9
|
+
padding: 12px;
|
|
10
|
+
border: 1px solid #f4e3db;
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
font-size: 14px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.cio-pia-error-block-warning-icon-container {
|
|
16
|
+
flex: 0 0 24px;
|
|
17
|
+
width: 24px;
|
|
18
|
+
height: 24px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.cio-pia-error-block-text-container {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
margin: 4px 0px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.cio-pia-error-block-text {
|
|
28
|
+
margin: 0.5rem 0rem;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
text-overflow: ellipsis;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.cio-pia-error-block-retry-button {
|
|
34
|
+
width: 76px;
|
|
35
|
+
display: inline-flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
background-color: #121212;
|
|
38
|
+
color: #fff;
|
|
39
|
+
border: none;
|
|
40
|
+
padding: 6px 10px;
|
|
41
|
+
border-radius: 4px;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
gap: 4px;
|
|
44
|
+
font-size: 14px;
|
|
45
|
+
font-weight: 500;
|
|
46
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const constructorio_ui_components_1 = require("@constructor-io/constructorio-ui-components");
|
|
6
|
+
const types_1 = require("../../types");
|
|
7
|
+
const translate_1 = require("../../utils/translate");
|
|
8
|
+
function ThumbsUpIcon({ isSelected }) {
|
|
9
|
+
return (react_1.default.createElement("svg", { width: '16', height: '16', viewBox: '0 0 16 16', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, isSelected ? (react_1.default.createElement("path", { d: 'M3.33317 6.66667H0.666504V14.6667H3.33317V6.66667ZM5.99984 14.6667C5.2665 14.6667 4.6665 14.0667 4.6665 13.3333V6.66667C4.6665 6.3 4.81317 5.96667 5.05317 5.72667L9.4465 1.33333L10.1532 2.03333C10.3332 2.21333 10.4465 2.46667 10.4465 2.74L10.4265 2.95333L9.79317 6.00001H13.9998C14.7332 6.00001 15.3332 6.60001 15.3332 7.33334V8.66668C15.3332 8.84001 15.2998 9.00001 15.2398 9.15334L13.2265 13.8533C13.0265 14.3333 12.5532 14.6667 11.9998 14.6667H5.99984Z', fill: '#4CAF50', fillOpacity: '1' })) : (react_1.default.createElement("path", { d: 'M5.99984 14.6667H11.9998C12.5532 14.6667 13.0265 14.3333 13.2265 13.8533L15.2398 9.15334C15.2998 9.00001 15.3332 8.84001 15.3332 8.66668V7.33334C15.3332 6.60001 14.7332 6.00001 13.9998 6.00001H9.79317L10.4265 2.95334L10.4465 2.74001C10.4465 2.46668 10.3332 2.21334 10.1532 2.03334L9.4465 1.33334L5.05317 5.72668C4.81317 5.96668 4.6665 6.30001 4.6665 6.66668V13.3333C4.6665 14.0667 5.2665 14.6667 5.99984 14.6667ZM5.99984 6.66668L8.89317 3.77334L7.99984 7.33334H13.9998V8.66668L11.9998 13.3333H5.99984V6.66668ZM0.666504 6.66668H3.33317V14.6667H0.666504V6.66668Z', fill: '#0F1324', fillOpacity: '0.6' }))));
|
|
10
|
+
}
|
|
11
|
+
function ThumbsDownIcon({ isSelected }) {
|
|
12
|
+
return (react_1.default.createElement("svg", { width: '16', height: '16', viewBox: '0 0 16 16', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, isSelected ? (react_1.default.createElement("path", { d: 'M12.6665 9.33334H15.3332V1.33334H12.6665V9.33334ZM9.99984 1.33334C10.7332 1.33334 11.3332 1.93334 11.3332 2.66668V9.33334C11.3332 9.70001 11.1865 10.0333 10.9465 10.2733L6.55317 14.6667L5.8465 13.9667C5.6665 13.7867 5.55317 13.5333 5.55317 13.26L5.57317 13.0467L6.2065 10H1.99984C1.2665 10 0.666504 9.40001 0.666504 8.66668V7.33334C0.666504 7.16001 0.699837 7.00001 0.759837 6.84668L2.77317 2.14668C2.97317 1.66668 3.4465 1.33334 3.99984 1.33334H9.99984Z', fill: '#F44336', fillOpacity: '1' })) : (react_1.default.createElement("path", { d: 'M9.99984 1.33334H3.99984C3.4465 1.33334 2.97317 1.66668 2.77317 2.14668L0.759837 6.84668C0.699837 7.00001 0.666504 7.16001 0.666504 7.33334V8.66668C0.666504 9.40001 1.2665 10 1.99984 10H6.2065L5.57317 13.0467L5.55317 13.26C5.55317 13.5333 5.6665 13.7867 5.8465 13.9667L6.55317 14.6667L10.9465 10.2733C11.1865 10.0333 11.3332 9.70001 11.3332 9.33334V2.66668C11.3332 1.93334 10.7332 1.33334 9.99984 1.33334ZM9.99984 9.33334L7.1065 12.2267L7.99984 8.66668H1.99984V7.33334L3.99984 2.66668H9.99984V9.33334ZM12.6665 1.33334H15.3332V9.33334H12.6665V1.33334Z', fill: '#0F1324', fillOpacity: '0.6' }))));
|
|
13
|
+
}
|
|
14
|
+
function Feedback({ translations, onFeedback, componentOverride }) {
|
|
15
|
+
const [feedback, setFeedback] = (0, react_1.useState)(null);
|
|
16
|
+
const handleFeedback = (type) => {
|
|
17
|
+
setFeedback(type);
|
|
18
|
+
onFeedback === null || onFeedback === void 0 ? void 0 : onFeedback(type);
|
|
19
|
+
};
|
|
20
|
+
return (react_1.default.createElement(constructorio_ui_components_1.RenderPropsWrapper, { props: { translations, onFeedback }, override: componentOverride === null || componentOverride === void 0 ? void 0 : componentOverride.reactNode },
|
|
21
|
+
react_1.default.createElement("div", { className: 'cio-pia-feedback-container' },
|
|
22
|
+
react_1.default.createElement("p", { className: 'cio-pia-feedback-text' }, (0, translate_1.translate)('Is this answer useful?', translations)),
|
|
23
|
+
react_1.default.createElement("button", { type: 'button', className: 'cio-pia-feedback-button', "aria-label": 'thumbs up', onClick: () => handleFeedback(types_1.FeedbackType.UP) },
|
|
24
|
+
react_1.default.createElement(ThumbsUpIcon, { isSelected: feedback === types_1.FeedbackType.UP })),
|
|
25
|
+
react_1.default.createElement("button", { type: 'button', className: 'cio-pia-feedback-button', "aria-label": 'thumbs down', onClick: () => handleFeedback(types_1.FeedbackType.DOWN) },
|
|
26
|
+
react_1.default.createElement(ThumbsDownIcon, { isSelected: feedback === types_1.FeedbackType.DOWN })))));
|
|
27
|
+
}
|
|
28
|
+
exports.default = Feedback;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.cio-pia-feedback-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: start;
|
|
5
|
+
height: 20px;
|
|
6
|
+
gap: 8px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.cio-pia-feedback-text {
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
letter-spacing: -0.5%;
|
|
13
|
+
color: rgba(15, 19, 36, 0.7);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.cio-pia-feedback-button {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
width: fit-content;
|
|
21
|
+
background: none;
|
|
22
|
+
border: 0px;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
padding: 0;
|
|
25
|
+
transition: transform 0.2s ease;
|
|
26
|
+
position: relative;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.cio-pia-feedback-button:hover {
|
|
30
|
+
opacity: 0.8;
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const translate_1 = require("../../utils/translate");
|
|
6
|
+
function SendIcon() {
|
|
7
|
+
return (react_1.default.createElement("svg", { width: '16', height: '16', viewBox: '0 0 16 16', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
|
|
8
|
+
react_1.default.createElement("g", { id: '.icon-send' },
|
|
9
|
+
react_1.default.createElement("path", { id: 'Vector', d: 'M14.8934 7.09533L14.8884 7.09314L1.54219 1.55752C1.42993 1.51053 1.30778 1.49211 1.18666 1.50388C1.06554 1.51566 0.949225 1.55728 0.848125 1.62502C0.741311 1.69501 0.653573 1.79045 0.592805 1.90277C0.532037 2.01509 0.500145 2.14075 0.5 2.26845V5.80877C0.50006 5.98335 0.561019 6.15243 0.67237 6.28689C0.783722 6.42134 0.938491 6.51274 1.11 6.54533L8.38906 7.89127C8.41767 7.89669 8.44348 7.91193 8.46205 7.93435C8.48062 7.95677 8.49078 7.98497 8.49078 8.01408C8.49078 8.04319 8.48062 8.07139 8.46205 8.09381C8.44348 8.11623 8.41767 8.13147 8.38906 8.13689L1.11031 9.48283C0.938851 9.51533 0.784092 9.60661 0.67269 9.74094C0.561288 9.87528 0.500219 10.0443 0.5 10.2188V13.7597C0.499917 13.8816 0.530111 14.0017 0.587871 14.1091C0.645632 14.2165 0.729152 14.3079 0.830938 14.375C0.953375 14.4564 1.09706 14.4998 1.24406 14.5C1.34626 14.4999 1.4474 14.4794 1.54156 14.4397L14.8875 8.93564L14.8934 8.93283C15.0731 8.85563 15.2262 8.72745 15.3337 8.56415C15.4413 8.40086 15.4986 8.20961 15.4986 8.01408C15.4986 7.81855 15.4413 7.6273 15.3337 7.46401C15.2262 7.30071 15.0731 7.17253 14.8934 7.09533Z', fill: 'white' }))));
|
|
10
|
+
}
|
|
11
|
+
function Input({ value: providedValue, placeholder, disabled = false, onSubmit, translations, }) {
|
|
12
|
+
const [value, setValue] = (0, react_1.useState)(providedValue || '');
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
if (providedValue) {
|
|
15
|
+
setValue(providedValue);
|
|
16
|
+
}
|
|
17
|
+
}, [providedValue]);
|
|
18
|
+
const handleSubmit = () => {
|
|
19
|
+
if (value.trim()) {
|
|
20
|
+
onSubmit(value.trim());
|
|
21
|
+
setValue('');
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const handleSubmitOnEnter = (e) => {
|
|
25
|
+
if (e.key === 'Enter') {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
handleSubmit();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// Priority: translations > placeholder prop > default
|
|
31
|
+
const resolvedPlaceholder = (translations === null || translations === void 0 ? void 0 : translations['Ask anything']) !== undefined
|
|
32
|
+
? (0, translate_1.translate)('Ask anything', translations)
|
|
33
|
+
: (placeholder !== null && placeholder !== void 0 ? placeholder : (0, translate_1.translate)('Ask anything'));
|
|
34
|
+
return (react_1.default.createElement("div", { className: 'cio-pia-input-container' },
|
|
35
|
+
react_1.default.createElement("input", { type: 'text', value: value, onChange: (e) => setValue(e.target.value), onKeyDown: handleSubmitOnEnter, placeholder: resolvedPlaceholder, disabled: disabled, className: 'cio-pia-input' }),
|
|
36
|
+
react_1.default.createElement("button", { type: 'button', onClick: handleSubmit, className: 'cio-pia-send-button', disabled: disabled },
|
|
37
|
+
(0, translate_1.translate)('Send', translations),
|
|
38
|
+
react_1.default.createElement(SendIcon, null))));
|
|
39
|
+
}
|
|
40
|
+
exports.default = Input;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/* Input Container */
|
|
2
|
+
.cio-pia-input-container {
|
|
3
|
+
display: flex;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 40px;
|
|
6
|
+
position: relative;
|
|
7
|
+
gap: 8px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Input */
|
|
11
|
+
.cio-pia-input {
|
|
12
|
+
width: 100%;
|
|
13
|
+
padding: 8px 80px 8px 12px;
|
|
14
|
+
border: 1px solid #dee0e3;
|
|
15
|
+
border-radius: 4px;
|
|
16
|
+
font-size: 14px;
|
|
17
|
+
background: #ffffff;
|
|
18
|
+
box-shadow:
|
|
19
|
+
1px 1px 2px 0px rgba(18, 18, 105, 0.1) inset,
|
|
20
|
+
0px 1px 4px 0px rgba(18, 18, 105, 0.05) inset,
|
|
21
|
+
1px 1px 1px 0px rgba(18, 18, 105, 0.05) inset;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* Input Hover */
|
|
25
|
+
.cio-pia-input:hover {
|
|
26
|
+
border: 1px solid #c8cad0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Input Focus */
|
|
30
|
+
.cio-pia-input:focus {
|
|
31
|
+
outline: none;
|
|
32
|
+
border: 1px solid #a980ff;
|
|
33
|
+
box-shadow: 0px 0px 0px 2px rgba(201, 176, 254, 0.7);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Input Active */
|
|
37
|
+
.cio-pia-input:focus:active {
|
|
38
|
+
outline: none;
|
|
39
|
+
border: 1px solid #000000;
|
|
40
|
+
box-shadow:
|
|
41
|
+
0px 1px 4px 0px rgba(18, 18, 105, 0.14) inset,
|
|
42
|
+
2.1px 2px 2px 0px rgba(18, 18, 105, 0.1) inset,
|
|
43
|
+
0px 1.5px 3px 0px rgba(18, 18, 105, 0.05) inset;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Input Placeholder */
|
|
47
|
+
.cio-pia-input::placeholder {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Input Disabled */
|
|
52
|
+
.cio-pia-input:disabled {
|
|
53
|
+
border: 1px solid #e9eaec;
|
|
54
|
+
cursor: not-allowed;
|
|
55
|
+
box-shadow: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Input Disabled Placeholder */
|
|
59
|
+
.cio-pia-input:disabled::placeholder {
|
|
60
|
+
color: #ffffff;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Send Button */
|
|
64
|
+
.cio-pia-send-button {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: 6px;
|
|
68
|
+
background: #14151a;
|
|
69
|
+
color: #ffffff;
|
|
70
|
+
border: none;
|
|
71
|
+
border-radius: 4px;
|
|
72
|
+
padding: 4px 8px;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
font-size: 13px;
|
|
75
|
+
font-weight: 500;
|
|
76
|
+
position: absolute;
|
|
77
|
+
right: 8px;
|
|
78
|
+
top: 50%;
|
|
79
|
+
transform: translateY(-50%);
|
|
80
|
+
box-shadow:
|
|
81
|
+
0px 0.4px 1px 0px rgba(18, 18, 105, 0.13),
|
|
82
|
+
0px 0.9px 6px 0px rgba(18, 18, 105, 0.05),
|
|
83
|
+
0px 1px 3px 0px rgba(18, 18, 105, 0.05);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Send Button */
|
|
87
|
+
.cio-pia-send-button:hover {
|
|
88
|
+
background: #2b2d36;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Send Button Disabled */
|
|
92
|
+
.cio-pia-send-button:disabled {
|
|
93
|
+
background: #e9eaec;
|
|
94
|
+
color: #0a0f2940;
|
|
95
|
+
border: none;
|
|
96
|
+
box-shadow: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Send Button Disabled SVG */
|
|
100
|
+
.cio-pia-send-button:disabled svg path {
|
|
101
|
+
fill: #0a0f2940;
|
|
102
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
function LoadingSkeleton() {
|
|
6
|
+
return (react_1.default.createElement("div", { className: 'cio-pia-loading-skeleton', "data-testid": 'loading-skeleton' },
|
|
7
|
+
react_1.default.createElement("div", { className: 'skeleton-bar' }),
|
|
8
|
+
react_1.default.createElement("div", { className: 'skeleton-bar' }),
|
|
9
|
+
react_1.default.createElement("div", { className: 'skeleton-bar skeleton-short' })));
|
|
10
|
+
}
|
|
11
|
+
exports.default = LoadingSkeleton;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.cio-pia-loading-skeleton {
|
|
2
|
+
min-width: 430px;
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: 8px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.skeleton-bar {
|
|
10
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
11
|
+
height: 16px;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
animation: loading-animation 2s infinite ease-in-out;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.skeleton-short {
|
|
18
|
+
width: 80%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Animation for the loader */
|
|
22
|
+
@keyframes loading-animation {
|
|
23
|
+
0% {
|
|
24
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
25
|
+
}
|
|
26
|
+
50% {
|
|
27
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
28
|
+
}
|
|
29
|
+
100% {
|
|
30
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 Input_1 = tslib_1.__importDefault(require("../Input/Input"));
|
|
6
|
+
const SuggestedQuestionsContainer_1 = tslib_1.__importDefault(require("../SuggestedQuestionsContainer/SuggestedQuestionsContainer"));
|
|
7
|
+
const SuggestedQuestionsSkeleton_1 = tslib_1.__importDefault(require("../SuggestedQuestionsContainer/SuggestedQuestionsSkeleton"));
|
|
8
|
+
const translate_1 = require("../../utils/translate");
|
|
9
|
+
const ConversationHistory_1 = tslib_1.__importDefault(require("../ConversationHistory/ConversationHistory"));
|
|
10
|
+
function PiaConversation({ conversationHistory, isLoading, error, currentItems, showFeedback, learnMoreUrl, translations, callbacks, componentOverrides, displayedQuestions, handleSubmitQuestion, }) {
|
|
11
|
+
const hasHistory = conversationHistory.length > 0;
|
|
12
|
+
return (react_1.default.createElement("div", { className: 'cio-pia-container cio-pia-conversation', "data-testid": 'cio-pia-container' },
|
|
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, learnMoreUrl: learnMoreUrl, translations: translations, callbacks: callbacks, componentOverrides: componentOverrides }),
|
|
15
|
+
react_1.default.createElement("div", { className: 'cio-pia-conversation-footer' },
|
|
16
|
+
isLoading && !error && react_1.default.createElement(SuggestedQuestionsSkeleton_1.default, null),
|
|
17
|
+
!isLoading && !error && (react_1.default.createElement(SuggestedQuestionsContainer_1.default, { questions: displayedQuestions, onQuestionClick: handleSubmitQuestion, componentOverride: componentOverrides === null || componentOverrides === void 0 ? void 0 : componentOverrides.suggestedQuestions })),
|
|
18
|
+
react_1.default.createElement(Input_1.default, { onSubmit: handleSubmitQuestion, disabled: isLoading, translations: translations }))));
|
|
19
|
+
}
|
|
20
|
+
exports.default = PiaConversation;
|