pager-widget 1.0.3 → 1.0.4
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/index.css +1 -1
- package/dist/index.js +4 -4
- package/dist/react-parcel.9f367d21.css +2 -18
- package/dist/react-parcel.9f367d21.css.map +1 -1
- package/dist/react-parcel.js +119 -214
- package/dist/react-parcel.js.map +1 -1
- package/out/AgentFeedbackButtonWrapper.js +15 -0
- package/out/App.js +28 -0
- package/out/BotMain.js +91 -0
- package/out/ButtonsWrapper.js +29 -0
- package/out/ChatPage.js +9 -0
- package/out/ChatPageContent.js +131 -0
- package/out/ChatPageHeader.js +267 -0
- package/out/ChatPageInput.js +29 -0
- package/out/ChatWidget.js +17 -0
- package/out/Consent.js +66 -0
- package/out/CountryDropdown.js +31 -0
- package/out/Form.js +238 -0
- package/out/HomePage.js +11 -0
- package/out/HomePageContent.js +32 -0
- package/out/HomePageFooter.js +87 -0
- package/out/HomePageHeader.js +66 -0
- package/out/InputField.js +80 -0
- package/out/Markdown.js +126 -0
- package/out/Message.js +197 -0
- package/out/MessagesT.js +2 -0
- package/out/NewRecentMessagePage.js +525 -0
- package/out/NewRecentMessageTab.js +23 -0
- package/out/ReceivedMessage.js +211 -0
- package/out/RecentMessageDetail.js +178 -0
- package/out/RecentMessageList.js +112 -0
- package/out/RecentMessageListCard.js +20 -0
- package/out/RecentMessageListHeader.js +156 -0
- package/out/RecentMessagePage.js +183 -0
- package/out/RecentMessageTab.js +35 -0
- package/out/WidgetMessage.js +14 -0
- package/out/WidgetToggleButton.js +191 -0
- package/out/WidgetType.js +2 -0
- package/out/assets/icons/pikaicons-react.js +17475 -0
- package/out/components/ConsentForm.js +7 -0
- package/out/components/CustomTooltip.js +34 -0
- package/out/hooks/useChatHistoryExists.js +32 -0
- package/out/hooks/useChatHistoryListExist.js +81 -0
- package/out/hooks/useChatScroll.js +14 -0
- package/out/hooks/useCurrentConversationExists.js +88 -0
- package/out/hooks/useInitialMessage.js +33 -0
- package/out/hooks/useMessage.js +230 -0
- package/out/hooks/useMessageReceiver.js +183 -0
- package/out/hooks/usePopupAnimation.js +20 -0
- package/out/hooks/useSocket.js +19 -0
- package/out/hooks/useSocketContext.js +81 -0
- package/out/hooks/useWidgetDimension.js +41 -0
- package/out/hooks/useWidgetToggle.js +22 -0
- package/out/index.js +31 -0
- package/out/markdown/CodeCopy.js +22 -0
- package/out/markdown/CodeHighlight.js +58 -0
- package/out/markdown/PagerMarkdown.js +36 -0
- package/out/markdown/pager_md.js +152 -0
- package/out/onscreenNotificationPopup.js +23 -0
- package/out/socket.js +11 -0
- package/out/utils/checkConversationExit.js +24 -0
- package/out/utils/convertTime.js +43 -0
- package/out/utils/sendInitialMessage.js +82 -0
- package/out/widget.js +21 -0
- package/out/widgetConfigStore.js +205 -0
- package/out/widgetConfigStore2.js +569 -0
- package/out/widgetControlstore.js +23 -0
- package/out/widgetStateHandler.js +106 -0
- package/out/widgetStore.js +171 -0
- package/out/widgetUserStore.js +47 -0
- package/package.json +1 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReceivedMessage = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const ButtonsWrapper_1 = require("./ButtonsWrapper");
|
|
11
|
+
const pikaicons_react_1 = require("./assets/icons/pikaicons-react");
|
|
12
|
+
const pager_md_1 = __importDefault(require("./markdown/pager_md"));
|
|
13
|
+
const widgetConfigStore2_1 = require("./widgetConfigStore2");
|
|
14
|
+
const convertTime_1 = require("./utils/convertTime");
|
|
15
|
+
const PagerMarkdown_1 = __importDefault(require("./markdown/PagerMarkdown"));
|
|
16
|
+
const AgentFeedbackButtonWrapper_1 = require("./AgentFeedbackButtonWrapper");
|
|
17
|
+
const ReceivedMessage = ({ message, sendFeedback, sendMessage, time, }) => {
|
|
18
|
+
const widget = (0, widgetConfigStore2_1.useWidgetData)();
|
|
19
|
+
const [, setTick] = react_1.default.useState(0);
|
|
20
|
+
react_1.default.useEffect(() => {
|
|
21
|
+
const interval = setInterval(() => {
|
|
22
|
+
setTick((tick) => tick + 1);
|
|
23
|
+
}, 30000);
|
|
24
|
+
return () => clearInterval(interval);
|
|
25
|
+
}, []);
|
|
26
|
+
const formatMessageTime = (timestamp) => {
|
|
27
|
+
const now = new Date();
|
|
28
|
+
const messageTime = new Date(timestamp);
|
|
29
|
+
const diffMs = now - messageTime;
|
|
30
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
31
|
+
if (diffMins < 1) {
|
|
32
|
+
return 'Just now';
|
|
33
|
+
}
|
|
34
|
+
else if (diffMins <= 10) {
|
|
35
|
+
return diffMins == 1
|
|
36
|
+
? `${diffMins} min ago`
|
|
37
|
+
: `${diffMins} mins ago`;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
let hours = messageTime.getHours();
|
|
41
|
+
const minutes = messageTime.getMinutes().toString().padStart(2, '0');
|
|
42
|
+
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
43
|
+
hours = hours % 12 || 12;
|
|
44
|
+
return `${hours}:${minutes}${ampm}`;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
if (message.output[0].response_type === 'ai_response') {
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-2.5 px-5 py-0 relative self-stretch w-full animate-slide-in-left", children: (0, jsx_runtime_1.jsxs)("div", { className: "items-start gap-1.5 self-stretch w-full flex flex-col relative", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2.5 px-[26px] py-0 relative self-stretch w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "relative w-fit mt-[-1.00px] font-medium text-xs text-[#020618]", children: widget?.data?.name }) }), (0, jsx_runtime_1.jsxs)("div", { className: "inline-flex items-start gap-1 relative", children: [(0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center justify-center w-[22px] h-[22px] bg-[#4b2fff] rounded-full", children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiBotStroke, { className: "relative w-3.5 h-3.5 bg-[100%_100%] text-white" }) }), (0, jsx_runtime_1.jsx)("div", { className: "inline-flex flex-col bg-zinc-100 items-start gap-2.5 px-3.5 py-2.5 relative rounded-lg max-w-[80%]", children: (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsx)(PagerMarkdown_1.default, { message: message.output[0].text }) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-[86%] items-start gap-1 relative", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2.5 pl-[26px] pr-0 py-0 relative flex-1 grow", children: (0, jsx_runtime_1.jsx)("div", { className: "relative w-fit mt-[-1.00px] text-xs text-[#45556c]", children: (0, convertTime_1.formatTimeAMPM)(time) }) }), (0, jsx_runtime_1.jsx)(ButtonsWrapper_1.AiFeedbackButtonsWrapper, { event_id: message.event_id, buttons: message.output[0].buttons, sendFeedback: sendFeedback, sendMessage: sendMessage })] })] }) }));
|
|
49
|
+
}
|
|
50
|
+
// if(message.output[0].response_type === 'agent_response'){
|
|
51
|
+
// return(
|
|
52
|
+
// <p>{message.output[0].type}</p>
|
|
53
|
+
// )
|
|
54
|
+
// }
|
|
55
|
+
else if (message.output[0].response_type === 'live_agent_prompt' &&
|
|
56
|
+
message.output[0].text) {
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "inline-flex items-start gap-1 relative w-full animate-slide-in-left", children: [(0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center justify-center w-[22px] h-[22px] bg-[#4b2fff] rounded-full", children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiBotStroke, { className: "relative w-3.5 h-3.5 bg-[100%_100%] text-white" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "inline-flex flex-col bg-zinc-100 items-start gap-2.5 px-3.5 py-2.5 relative rounded-lg max-w-[80%]", children: [(0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message.output[0].text }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-2.5 relative self-stretch w-full", children: message.output[0].buttons.map((button, i) => ((0, jsx_runtime_1.jsx)("button", { className: "flex cursor-pointer items-center justify-center gap-2 px-3.5 py-1.5 relative self-stretch w-full bg-white rounded-lg border border-gray-200 hover:border-[#4b2fff]", onClick: () => sendMessage(button.action.send_rly), children: (0, jsx_runtime_1.jsx)("span", { className: "relative w-fit mt-[-1.00px] font-medium text-sm text-[#314158]", children: button.label }) }, i))) })] })] }));
|
|
58
|
+
}
|
|
59
|
+
else if (message.output[0].response_type === 'live_agent_prompt' &&
|
|
60
|
+
message.output[0].value) {
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-1.5 w-full px-5 animate-slide-in-left", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-start w-full rounded-lg overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-[5px]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex w-auto h-[24px] items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("img", { src: widget?.data?.logo_url, className: "w-auto h-6 text-white" }) }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-[90%]", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-baseline pt-0.5", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium text-[#020618]", children: widget?.data?.name }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs text-[#62748E]", children: (0, convertTime_1.formatTimeAMPM)(time) })] }), (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message.output[0].value }) })] })] }) }) }));
|
|
62
|
+
}
|
|
63
|
+
else if (message.output[0].response_type === 'fallback') {
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-1.5 w-full px-5 animate-slide-in-left", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-start w-full rounded-lg overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-[5px]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex w-auto h-[24px] items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("img", { src: widget?.data?.logo_url, className: "w-auto h-6 text-white" }) }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-[90%]", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-baseline pt-0.5", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium text-[#020618]", children: widget?.data?.name }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs text-[#62748E]", children: (0, convertTime_1.formatTimeAMPM)(time) })] }), (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message.output[0].value }) })] })] }) }) }));
|
|
65
|
+
}
|
|
66
|
+
else if (message.output[0].response_type === 'agent') {
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-1.5 w-full px-5 animate-slide-in-left", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-start w-full rounded-lg overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-[5px]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex w-auto h-[24px] items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("img", { src: widget?.data?.logo_url, className: "w-auto h-6 text-white" }) }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-[90%]", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-baseline pt-0.5", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium text-[#020618]", children: widget?.data?.name }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs text-[#62748E]", children: (0, convertTime_1.formatTimeAMPM)(time) })] }), (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message.output[0].value }) })] })] }) }) }));
|
|
68
|
+
}
|
|
69
|
+
else if (message.output[0].response_type === 'agent_feedback') {
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-1.5 w-full px-5 animate-slide-in-left", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start w-full flex-col gap-2.5", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-start w-full rounded-lg overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-[5px]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex w-auto h-[24px] items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("img", { src: widget?.data?.logo_url, className: "w-auto h-6 text-white" }) }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-[90%]", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-baseline pt-0.5", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium text-[#020618]", children: widget?.data?.name }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs text-[#62748E]", children: (0, convertTime_1.formatTimeAMPM)(time) })] }), (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message.output[0].text }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-wrap items-start gap-2 relative self-stretch pt-1", children: (0, jsx_runtime_1.jsx)(AgentFeedbackButtonWrapper_1.AgentFeedbackButtonWrapper, { sendMessage: sendMessage, buttons: message.output[0].buttons }) })] })] }) }) })
|
|
71
|
+
// <div className="flex flex-col items-start gap-2.5 px-5 py-0 relative self-stretch w-full animate-slide-in-left">
|
|
72
|
+
// <div className="items-start gap-1.5 self-stretch w-full flex flex-col relative">
|
|
73
|
+
// {/* <div className="flex items-center gap-2.5 px-[26px] py-0 relative self-stretch w-full">
|
|
74
|
+
// <div className="relative w-fit mt-[-1.00px] font-medium text-xs text-[#020618]">
|
|
75
|
+
// {widget?.data?.name}
|
|
76
|
+
// </div>
|
|
77
|
+
// </div> */}
|
|
78
|
+
// {/* <div className="inline-flex items-start gap-1 relative">
|
|
79
|
+
// <div className="inline-flex items-center justify-center w-[22px] h-[22px] bg-[#4b2fff] rounded-full">
|
|
80
|
+
// <PiBotStroke className="relative w-3.5 h-3.5 bg-[100%_100%] text-white" />
|
|
81
|
+
// </div>
|
|
82
|
+
// <div className="inline-flex flex-col bg-zinc-100 items-start gap-2.5 px-3.5 py-2.5 relative rounded-lg max-w-[80%]">
|
|
83
|
+
// <div className="relative mt-[-1.00px] text-sm text-[#020618] w-full">
|
|
84
|
+
// <PagerMd mdText={message.output[0].text} />
|
|
85
|
+
// </div>
|
|
86
|
+
// </div>
|
|
87
|
+
// </div> */}
|
|
88
|
+
// <div className="flex items-center gap-2">
|
|
89
|
+
// <div className="flex items-start gap-[5px]">
|
|
90
|
+
// <div className="flex w-auto h-[24px] items-center justify-center rounded-full">
|
|
91
|
+
// <img
|
|
92
|
+
// src={widget?.data?.logo_url}
|
|
93
|
+
// className="w-[18px] h-[18px] text-white"
|
|
94
|
+
// />
|
|
95
|
+
// </div>
|
|
96
|
+
// </div>
|
|
97
|
+
// </div>
|
|
98
|
+
// <div className="flex flex-col items-start gap-2 w-full">
|
|
99
|
+
// <div className="flex gap-2 items-baseline pt-0.5">
|
|
100
|
+
// <div className="text-sm font-medium text-[#020618]">
|
|
101
|
+
// {widget?.data?.name}
|
|
102
|
+
// </div>
|
|
103
|
+
// </div>
|
|
104
|
+
// <div className="relative mt-[-1.00px] text-sm text-[#020618] w-full">
|
|
105
|
+
// <PagerMd
|
|
106
|
+
// mdText={
|
|
107
|
+
// message.output[0].text
|
|
108
|
+
// }
|
|
109
|
+
// />
|
|
110
|
+
// </div>
|
|
111
|
+
// </div>
|
|
112
|
+
// <div className="flex w-[86%] items-start gap-1 relative">
|
|
113
|
+
// {/* <div className="flex items-center gap-2.5 pl-[26px] pr-0 py-0 relative flex-1 grow">
|
|
114
|
+
// <div className="relative w-fit mt-[-1.00px] text-xs text-[#45556c]">
|
|
115
|
+
// {formatTimeAMPM(time)}
|
|
116
|
+
// </div>
|
|
117
|
+
// </div> */}
|
|
118
|
+
// <AgentFeedbackButtonWrapper sendMessage = {sendMessage} buttons={message.output[0].buttons}/>
|
|
119
|
+
// {/*
|
|
120
|
+
// <AiFeedbackButtonsWrapper
|
|
121
|
+
// event_id={message.event_id}
|
|
122
|
+
// buttons={message.output[0].buttons}
|
|
123
|
+
// sendFeedback={sendFeedback}
|
|
124
|
+
// sendMessage={sendMessage}
|
|
125
|
+
// /> */}
|
|
126
|
+
// </div>
|
|
127
|
+
// </div>
|
|
128
|
+
// </div>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
else if (message.output[0].type === 'text') {
|
|
132
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-1.5 w-full px-5 animate-slide-in-left", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-start w-full rounded-lg overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-[5px]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex w-auto h-[24px] items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("img", { src: widget?.data?.logo_url, className: "w-auto h-6 text-white" }) }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-[90%]", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-baseline pt-0.5", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium text-[#020618]", children: widget?.data?.name }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs text-[#62748E]", children: formatMessageTime(time) })] }), (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsx)(PagerMarkdown_1.default, { message: message.output[0].value.value }) })] })] }) }) }) }));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-1.5 w-full px-5 animate-slide-in-left", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-start w-full rounded-lg overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-[5px]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex w-auto h-[24px] items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("img", { src: widget?.data?.logo_url, className: "w-auto h-6 text-white" }) }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-[90%]", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-baseline pt-0.5", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium text-[#020618]", children: widget?.data?.name }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs text-[#62748E]", children: formatMessageTime(time) })] }), (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message.output[0].value }) })] })] }) }) })
|
|
136
|
+
// <div className="flex flex-col items-start gap-2.5 px-5 py-0 relative self-stretch w-full">
|
|
137
|
+
// <div className="items-start gap-1.5 self-stretch w-full flex flex-col relative">
|
|
138
|
+
// <div className="flex items-center gap-2.5 px-[26px] py-0 relative self-stretch w-full">
|
|
139
|
+
// <div className="relative w-fit mt-[-1.00px] font-medium text-xs text-[#020618]">
|
|
140
|
+
// {widget?.data?.name}
|
|
141
|
+
// </div>
|
|
142
|
+
// <div>{formatTimeAMPM(time)}</div>
|
|
143
|
+
// </div>
|
|
144
|
+
// <div className="inline-flex items-start gap-1 relative">
|
|
145
|
+
// <div className="inline-flex items-center justify-center w-[22px] h-[22px] bg-[#4b2fff] rounded-full">
|
|
146
|
+
// <img src={widget?.data?.logo_url} />
|
|
147
|
+
// </div>
|
|
148
|
+
// <div className="inline-flex flex-col bg-zinc-100 items-start gap-2.5 px-3.5 py-2.5 relative rounded-lg max-w-[80%]">
|
|
149
|
+
// <div className="relative mt-[-1.00px] text-sm text-[#020618] w-full">
|
|
150
|
+
// <PagerMd mdText={message.output[0].value} />
|
|
151
|
+
// </div>
|
|
152
|
+
// </div>
|
|
153
|
+
// </div>
|
|
154
|
+
// </div>
|
|
155
|
+
// </div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
// return(
|
|
159
|
+
// <>
|
|
160
|
+
// {message.output[0].response_type === "ai_response"? (
|
|
161
|
+
// <div className="flex flex-col items-start gap-2.5 px-5 py-0 relative self-stretch w-full">
|
|
162
|
+
// <div className="items-start gap-1.5 self-stretch w-full flex flex-col relative">
|
|
163
|
+
// <div className="flex items-center gap-2.5 px-[26px] py-0 relative self-stretch w-full">
|
|
164
|
+
// <div className="relative w-fit mt-[-1.00px] font-medium text-xs text-[#020618]">
|
|
165
|
+
// Bot
|
|
166
|
+
// </div>
|
|
167
|
+
// </div>
|
|
168
|
+
// <div className="inline-flex items-start gap-1 relative">
|
|
169
|
+
// <div className="inline-flex items-center justify-center w-[22px] h-[22px] bg-[#4b2fff] rounded-full">
|
|
170
|
+
// <PiBotStroke className="relative w-3.5 h-3.5 bg-[100%_100%] text-white" />
|
|
171
|
+
// </div>
|
|
172
|
+
// <div className="inline-flex flex-col bg-zinc-100 items-start gap-2.5 px-3.5 py-2.5 relative rounded-lg">
|
|
173
|
+
// <div className="relative mt-[-1.00px] text-sm text-[#020618] w-full">
|
|
174
|
+
// <PagerMd mdText={message.output[0].text} />
|
|
175
|
+
// </div>
|
|
176
|
+
// </div>
|
|
177
|
+
// </div>
|
|
178
|
+
// <div className="flex w-[289px] items-start gap-1 relative">
|
|
179
|
+
// <div className="flex items-center gap-2.5 pl-[26px] pr-0 py-0 relative flex-1 grow">
|
|
180
|
+
// <div className="relative w-fit mt-[-1.00px] text-xs text-[#45556c]">
|
|
181
|
+
// 4:09
|
|
182
|
+
// </div>
|
|
183
|
+
// </div>
|
|
184
|
+
// <AiFeedbackButtonsWrapper event_id={message.event_id} buttons={message.output[0].buttons} sendFeedback={sendFeedback} sendMessage={sendMessage}/>
|
|
185
|
+
// </div>
|
|
186
|
+
// </div>
|
|
187
|
+
// </div>
|
|
188
|
+
// ):
|
|
189
|
+
// <div className="flex flex-col items-start gap-2.5 px-5 py-0 relative self-stretch w-full">
|
|
190
|
+
// <div className="items-start gap-1.5 self-stretch w-full flex flex-col relative">
|
|
191
|
+
// <div className="flex items-center gap-2.5 px-[26px] py-0 relative self-stretch w-full">
|
|
192
|
+
// <div className="relative w-fit mt-[-1.00px] font-medium text-xs text-[#020618]">
|
|
193
|
+
// Bot
|
|
194
|
+
// </div>
|
|
195
|
+
// </div>
|
|
196
|
+
// <div className="inline-flex items-start gap-1 relative">
|
|
197
|
+
// <div className="inline-flex items-center justify-center w-[22px] h-[22px] bg-[#4b2fff] rounded-full">
|
|
198
|
+
// <PiBotStroke className="relative w-3.5 h-3.5 bg-[100%_100%] text-white" />
|
|
199
|
+
// </div>
|
|
200
|
+
// <div className="inline-flex flex-col bg-zinc-100 items-start gap-2.5 px-3.5 py-2.5 relative rounded-lg">
|
|
201
|
+
// <div className="relative mt-[-1.00px] text-sm text-[#020618] w-full">
|
|
202
|
+
// <PagerMd mdText={message.output[0].value} />
|
|
203
|
+
// </div>
|
|
204
|
+
// </div>
|
|
205
|
+
// </div>
|
|
206
|
+
// </div>
|
|
207
|
+
// </div>}
|
|
208
|
+
// </>
|
|
209
|
+
// )
|
|
210
|
+
};
|
|
211
|
+
exports.ReceivedMessage = ReceivedMessage;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.RecentMessageDetail = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const BotMain_1 = require("./BotMain");
|
|
43
|
+
const ReceivedMessage_1 = require("./ReceivedMessage");
|
|
44
|
+
const pikaicons_react_1 = require("./assets/icons/pikaicons-react");
|
|
45
|
+
const useChatHistoryListExist_1 = require("./hooks/useChatHistoryListExist");
|
|
46
|
+
const pager_md_1 = __importDefault(require("./markdown/pager_md"));
|
|
47
|
+
const widgetConfigStore2_1 = require("./widgetConfigStore2");
|
|
48
|
+
const widgetStore_1 = require("./widgetStore");
|
|
49
|
+
const RecentMessageDetail = ({ isExpanded }) => {
|
|
50
|
+
const widget = (0, widgetConfigStore2_1.useWidgetData)();
|
|
51
|
+
const { status } = widget;
|
|
52
|
+
const conversation_id = (0, widgetStore_1.useSelectedConversationData)();
|
|
53
|
+
const { chatDetail } = (0, useChatHistoryListExist_1.useGetSingleConversation)(conversation_id);
|
|
54
|
+
console.log('chatDetail', chatDetail);
|
|
55
|
+
const expandRef = react_1.default.useRef(null);
|
|
56
|
+
const [expandPopupOpen, setExpandPopupOpen] = react_1.default.useState(false);
|
|
57
|
+
const [showExpandPopUp, setShowExpandPopUp] = react_1.default.useState(false);
|
|
58
|
+
const expandMenuItems = [
|
|
59
|
+
{
|
|
60
|
+
id: 1,
|
|
61
|
+
icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiPhoneStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
|
|
62
|
+
label: 'Default mode',
|
|
63
|
+
selected: isExpanded === widgetStore_1.WidgetExpandType.DEFAULT,
|
|
64
|
+
onClick: () => {
|
|
65
|
+
widgetStore_1.widgetStore.trigger.expandWidget({
|
|
66
|
+
expanded_size: widgetStore_1.WidgetExpandType.DEFAULT,
|
|
67
|
+
});
|
|
68
|
+
setExpandPopupOpen(false);
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: 2,
|
|
73
|
+
icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiTabletStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
|
|
74
|
+
label: 'Expanded mode',
|
|
75
|
+
selected: isExpanded === widgetStore_1.WidgetExpandType.EXPANDED,
|
|
76
|
+
onClick: () => {
|
|
77
|
+
widgetStore_1.widgetStore.trigger.expandWidget({
|
|
78
|
+
expanded_size: widgetStore_1.WidgetExpandType.EXPANDED,
|
|
79
|
+
});
|
|
80
|
+
setExpandPopupOpen(false);
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 3,
|
|
85
|
+
icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiSpatialCurvedScreenStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
|
|
86
|
+
label: 'Full screen mode',
|
|
87
|
+
selected: isExpanded === widgetStore_1.WidgetExpandType.FULLSCREEN,
|
|
88
|
+
onClick: () => {
|
|
89
|
+
widgetStore_1.widgetStore.trigger.expandWidget({
|
|
90
|
+
expanded_size: widgetStore_1.WidgetExpandType.FULLSCREEN,
|
|
91
|
+
});
|
|
92
|
+
setExpandPopupOpen(false);
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
const selectedExpandItem = expandMenuItems.find((item) => {
|
|
97
|
+
return item.selected ? item.icon : null;
|
|
98
|
+
});
|
|
99
|
+
(0, react_1.useEffect)(() => {
|
|
100
|
+
function handleClick(event) {
|
|
101
|
+
if (expandRef.current &&
|
|
102
|
+
!expandRef.current.contains(event.target)) {
|
|
103
|
+
setExpandPopupOpen(false);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (expandPopupOpen) {
|
|
107
|
+
document.addEventListener('mousedown', handleClick);
|
|
108
|
+
}
|
|
109
|
+
return () => {
|
|
110
|
+
document.removeEventListener('mousedown', handleClick);
|
|
111
|
+
};
|
|
112
|
+
}, [expandPopupOpen]);
|
|
113
|
+
react_1.default.useEffect(() => {
|
|
114
|
+
if (expandPopupOpen) {
|
|
115
|
+
setShowExpandPopUp(true);
|
|
116
|
+
}
|
|
117
|
+
else if (showExpandPopUp) {
|
|
118
|
+
const timeout = setTimeout(() => setShowExpandPopUp(false), 140);
|
|
119
|
+
return () => clearTimeout(timeout);
|
|
120
|
+
}
|
|
121
|
+
}, [expandPopupOpen, showExpandPopUp]);
|
|
122
|
+
const handleBackButtonClick = () => {
|
|
123
|
+
if (isExpanded) {
|
|
124
|
+
widgetStore_1.widgetStore.trigger.selectTab({
|
|
125
|
+
tab: BotMain_1.TabType.RECENT_MESSAGE_LIST,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
widgetStore_1.widgetStore.trigger.selectTab({ tab: BotMain_1.TabType.RECENT_MESSAGE_LIST });
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
if (!(status !== 'NOT_STARTED' &&
|
|
133
|
+
status !== 'WIDGET_LOADING' &&
|
|
134
|
+
status !== 'INVALID_STATE')) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("header", { className: "flex items-center px-0 py-[15px] border-b border-zinc-300 w-full justify-between h-[60px] bg-white rounded-t-[22px] cursor-pointer", "data-model-id": "10445:55564", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 px-5 py-0 w-full", children: [(0, jsx_runtime_1.jsx)("button", { className: "inline-flex items-center justify-center gap-2.5 p-0 cursor-pointer hover:bg-slate-100 rounded-xl overflow-hidden", onClick: handleBackButtonClick, children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiChevronLeftStroke, { className: "w-6 h-6 cursor-pointer" }) }), (0, jsx_runtime_1.jsx)("img", { className: "w-auto h-[30px]", src: widget?.data?.logo_url }), (0, jsx_runtime_1.jsx)("span", { className: "flex flex-col items-start flex-1 grow", children: (0, jsx_runtime_1.jsx)("span", { className: "flex flex-col items-start gap-[18px] flex-[0_0_auto]", children: (0, jsx_runtime_1.jsx)("h1", { className: "w-fit mt-[-1.00px] font-text-md-medium font-[number:var(--text-md-medium-font-weight)] text-[#020618] text-[length:var(--text-md-medium-font-size)] tracking-[var(--text-md-medium-letter-spacing)] leading-[var(--text-md-medium-line-height)] whitespace-nowrap [font-style:var(--text-md-medium-font-style)]", children: widget?.data?.name }) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 px-5 py-0 w-max justify-end", children: [(0, jsx_runtime_1.jsx)("div", { className: "relative" }), (0, jsx_runtime_1.jsxs)("div", { className: "relative", ref: expandRef, children: [(0, jsx_runtime_1.jsx)("button", { className: "inline-flex items-center gap-2.5 p-1 cursor-pointer hover:bg-slate-100 rounded-lg overflow-hidden", onClick: () => setExpandPopupOpen(!expandPopupOpen), children: (0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center gap-2.5", children: selectedExpandItem
|
|
138
|
+
? selectedExpandItem.icon
|
|
139
|
+
: null }) }), showExpandPopUp && ((0, jsx_runtime_1.jsxs)("nav", { className: `flex flex-col w-[148px] h-max absolute items-start gap-1 p-1 right-0 bg-white rounded-lg overflow-hidden border border-solid border-slate-200 z-50`, style: {
|
|
140
|
+
animation: expandPopupOpen
|
|
141
|
+
? 'popin 0.18s cubic-bezier(0.4,0,0.2,1)'
|
|
142
|
+
: 'popout 0.14s cubic-bezier(0.4,0,0.2,1)',
|
|
143
|
+
}, children: [(0, jsx_runtime_1.jsx)("style", { children: `
|
|
144
|
+
@keyframes popin {
|
|
145
|
+
0% {
|
|
146
|
+
opacity: 0;
|
|
147
|
+
transform: scale(0.95) translateY(-8px);
|
|
148
|
+
}
|
|
149
|
+
100% {
|
|
150
|
+
opacity: 1;
|
|
151
|
+
transform: scale(1) translateY(0);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
@keyframes popout {
|
|
155
|
+
0% {
|
|
156
|
+
opacity: 1;
|
|
157
|
+
transform: scale(1) translateY(0);
|
|
158
|
+
}
|
|
159
|
+
100% {
|
|
160
|
+
opacity: 0;
|
|
161
|
+
transform: scale(0.95) translateY(-8px);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
` }), expandMenuItems.map((item) => ((0, jsx_runtime_1.jsxs)("button", { className: `flex items-center gap-1.5 pl-2 pr-3 py-1.5 relative self-stretch w-full cursor-pointer
|
|
165
|
+
hover:bg-slate-100 rounded-md overflow-hidden`, style: {
|
|
166
|
+
backgroundColor: item.selected
|
|
167
|
+
? '#f0f0f0'
|
|
168
|
+
: '',
|
|
169
|
+
}, onClick: item.onClick, children: [(0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center gap-2.5 flex-[0_0_auto]", children: item.icon }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start justify-center gap-2 flex-1 self-stretch grow", children: (0, jsx_runtime_1.jsx)("div", { className: "inline-flex flex-col items-start gap-1 flex-[0_0_auto]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-1 flex-[0_0_auto]", children: (0, jsx_runtime_1.jsx)("div", { className: "w-fit whitespace-nowrap text-xs font-medium text-[#020618]", children: item.label }) }) }) })] }, item.id)))] }))] }), (0, jsx_runtime_1.jsx)("button", { className: "inline-flex items-center gap-2.5 p-1 cursor-pointer hover:bg-slate-50 rounded-lg overflow-hidden", children: (0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center gap-2.5", children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiMultipleCrossCancelDefaultStroke, { className: "w-[18px] h-[18px]" }) }) })] })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col h-[94%] pb-8 justify-between", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-4 relative h-full overflow-y-scroll w-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center gap-2.5 px-5 py-0 relative self-stretch w-full" }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-5 w-full pb-3", children: chatDetail?.map((message) => ((0, jsx_runtime_1.jsx)("div", { children: message.type === 'received' ? ((0, jsx_runtime_1.jsx)(ReceivedMessage_1.ReceivedMessage, { sendFeedback: () => { }, sendMessage: () => { }, message: message.message, time: message.time })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-end gap-2.5 px-5 py-0 relative self-stretch w-full animate-slide-in-right", children: (0, jsx_runtime_1.jsx)("div", { className: "w-[300px] items-end gap-1 flex flex-col relative", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end items-end w-fit gap-1 relative", children: (0, jsx_runtime_1.jsx)("div", { className: `flex flex-1 grow text-[${widget?.data?.user_message_text_color}] items-start gap-2.5 px-3.5 py-2.5 relative rounded-lg`, style: {
|
|
170
|
+
backgroundColor: widget?.data
|
|
171
|
+
?.secondary_color,
|
|
172
|
+
color: widget?.data
|
|
173
|
+
?.user_message_text_color,
|
|
174
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm", children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message
|
|
175
|
+
.message
|
|
176
|
+
.input }) }) }) }) }) }) })) }, message.type))) })] }) })] }));
|
|
177
|
+
};
|
|
178
|
+
exports.RecentMessageDetail = RecentMessageDetail;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RecentMessageList = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const HomePageFooter_1 = require("./HomePageFooter");
|
|
10
|
+
const BotMain_1 = require("./BotMain");
|
|
11
|
+
const RecentMessageListHeader_1 = __importDefault(require("./RecentMessageListHeader"));
|
|
12
|
+
const RecentMessageListCard_1 = __importDefault(require("./RecentMessageListCard"));
|
|
13
|
+
const pikaicons_react_1 = require("./assets/icons/pikaicons-react");
|
|
14
|
+
const useChatHistoryListExist_1 = require("./hooks/useChatHistoryListExist");
|
|
15
|
+
const widgetStore_1 = require("./widgetStore");
|
|
16
|
+
const convertTime_1 = require("./utils/convertTime");
|
|
17
|
+
const widgetConfigStore2_1 = require("./widgetConfigStore2");
|
|
18
|
+
const HomePageHeader_1 = require("./HomePageHeader");
|
|
19
|
+
const RecentMessageList = ({ toggleWidget, isExpanded, switchTab, }) => {
|
|
20
|
+
const [visibleCount, setVisibleCount] = (0, react_1.useState)(0);
|
|
21
|
+
const widget = (0, widgetConfigStore2_1.useWidgetData)();
|
|
22
|
+
const { recentChatList } = (0, useChatHistoryListExist_1.useChatHistoryListExists)();
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
if (visibleCount <= (recentChatList || []).length) {
|
|
25
|
+
const timeout = setTimeout(() => {
|
|
26
|
+
setVisibleCount((c) => c + 1);
|
|
27
|
+
}, 120); // adjust delay as needed
|
|
28
|
+
return () => clearTimeout(timeout);
|
|
29
|
+
}
|
|
30
|
+
}, [visibleCount]);
|
|
31
|
+
console.log(recentChatList, 'Inga recent list');
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(RecentMessageListHeader_1.default, { isExpanded: isExpanded, toggleWidget: toggleWidget }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-1 flex-col justify-between h-[90%] relative", children: [(0, jsx_runtime_1.jsx)("div", { className: "pt-4 px-5 pb-[70px] overflow-y-scroll h-full flex flex-col items-start gap-3", children: (recentChatList || [])
|
|
33
|
+
.map((item, index) => ({
|
|
34
|
+
...item,
|
|
35
|
+
originalIndex: index,
|
|
36
|
+
}))
|
|
37
|
+
.sort((a, b) => {
|
|
38
|
+
const aTime = new Date(a.events?.[a.events.length - 1]?.time || 0).getTime();
|
|
39
|
+
const bTime = new Date(b.events?.[b.events.length - 1]?.time || 0).getTime();
|
|
40
|
+
return bTime - aTime;
|
|
41
|
+
})
|
|
42
|
+
.map((chat, index) => {
|
|
43
|
+
const events = chat.events;
|
|
44
|
+
const lastMessage = events[events.length - 1];
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(RecentMessageListCard_1.default, { lastActive: (0, convertTime_1.formatTimeAMPM)(lastMessage?.time), message: lastMessage?.message?.output?.[0]?.value
|
|
46
|
+
?.value ?? 'No message', brandColor: widget?.data?.brand_color, animate: index < visibleCount, delay: index * 2, onClick: () => {
|
|
47
|
+
localStorage.setItem('SELECTED_INDEX', `${chat.originalIndex}`);
|
|
48
|
+
widgetStore_1.widgetStore.trigger.selectTab({
|
|
49
|
+
tab: BotMain_1.TabType.NEW_RECENT_MESSAGE,
|
|
50
|
+
});
|
|
51
|
+
} }, index));
|
|
52
|
+
}) }), (0, jsx_runtime_1.jsx)("div", { className: "w-full absolute flex justify-center bottom-20", children: (0, jsx_runtime_1.jsxs)("button", { className: `${(0, HomePageHeader_1.isDarkColor)(widget?.data?.brand_color) == 'light' ? 'text-black' : 'text-white'} flex p-2 text-sm z-50 font-medium leading-5 cursor-pointer pl-3.5 pr-3 justify-center items-center gap-1.5 rounded-[10px]`, style: {
|
|
53
|
+
backgroundColor: widget?.data?.brand_color
|
|
54
|
+
? widget?.data?.brand_color
|
|
55
|
+
: '#4B2FFF',
|
|
56
|
+
color: (0, HomePageHeader_1.isDarkColor)(widget?.data?.brand_color) ==
|
|
57
|
+
'light'
|
|
58
|
+
? '#000'
|
|
59
|
+
: '#fff',
|
|
60
|
+
}, onClick: () => {
|
|
61
|
+
localStorage.setItem('Tab', 'Chat');
|
|
62
|
+
widgetStore_1.widgetStore.trigger.selectTab({ tab: BotMain_1.TabType.CHAT });
|
|
63
|
+
}, children: [widget?.data?.send_message_description
|
|
64
|
+
? widget?.data?.send_message_description
|
|
65
|
+
: 'Send us a message', (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiSendPlaneSlantStroke, { className: "w-4 h-4" })] }) }), (0, jsx_runtime_1.jsx)("div", { className: "w-full absolute flex justify-center bottom-gradient-recent-list", children: '' }), (0, jsx_runtime_1.jsx)(HomePageFooter_1.HomePageFooter, { switchTab: switchTab, isExpanded: isExpanded })] })] }));
|
|
66
|
+
};
|
|
67
|
+
exports.RecentMessageList = RecentMessageList;
|
|
68
|
+
{
|
|
69
|
+
/* <>
|
|
70
|
+
<RecentMessageListHeader
|
|
71
|
+
isExpanded={isExpanded}
|
|
72
|
+
setIsExpanded={setIsExpanded}
|
|
73
|
+
setIsHomeScreen={setIsHomeScreen}
|
|
74
|
+
setSwitchTab={setSwitchTab}
|
|
75
|
+
toggleWidget={toggleWidget}
|
|
76
|
+
/>
|
|
77
|
+
<div className="flex flex-1 flex-col justify-between h-[90%] relative">
|
|
78
|
+
<div className="pt-4 px-5 pb-[70px] overflow-y-scroll h-full flex flex-col items-start gap-3">
|
|
79
|
+
{messages.map((msg, index) => (
|
|
80
|
+
<RecentMessageListCard
|
|
81
|
+
key={index}
|
|
82
|
+
message={msg}
|
|
83
|
+
lastActive="2 hours ago"
|
|
84
|
+
onClick={() => {}}
|
|
85
|
+
animate={index < visibleCount}
|
|
86
|
+
delay={index * 2}
|
|
87
|
+
/>
|
|
88
|
+
))}
|
|
89
|
+
<div className="w-[calc(100%-40px)] absolute flex justify-center bottom-20">
|
|
90
|
+
<button
|
|
91
|
+
className="flex p-2 text-sm z-50 font-medium leading-5 cursor-pointer pl-3.5 pr-3 justify-center items-center gap-1.5 rounded-[10px] text-white bg-[#4B2FFF] hover:bg-[#3f25e8]"
|
|
92
|
+
onClick={() => {
|
|
93
|
+
localStorage.setItem('Tab', 'Chat')
|
|
94
|
+
setSwitchTab(TabType.CHAT)
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
Send us message{' '}
|
|
98
|
+
<PiSendPlaneSlantStroke className="w-4 h-4" />
|
|
99
|
+
</button>
|
|
100
|
+
</div>
|
|
101
|
+
<div className="w-full absolute flex justify-center bottom-gradient-recent-list">
|
|
102
|
+
{''}
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
<HomePageFooter
|
|
106
|
+
switchTab={switchTab}
|
|
107
|
+
setIsHomeScreen={setIsHomeScreen}
|
|
108
|
+
setSwitchTab={setSwitchTab}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
</> */
|
|
112
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const pikaicons_react_1 = require("./assets/icons/pikaicons-react");
|
|
6
|
+
const RecentMessageListCard = ({ message, lastActive, onClick, animate, delay = 0, brandColor, }) => {
|
|
7
|
+
const [isHovered, setIsHovered] = (0, react_1.useState)(false);
|
|
8
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `flex py-3 pl-5 !pr-4 items-center gap-2.5 rounded-xl w-full justify-between cursor-pointer text-slate-950 hover:text-[#4B2FFF] transition-all duration-800 ease-in-out
|
|
9
|
+
${animate ? 'opacity-100 translate-x-0' : 'opacity-0 -translate-x-1'}
|
|
10
|
+
`, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), style: {
|
|
11
|
+
willChange: 'transform, opacity',
|
|
12
|
+
transitionDelay: `${delay}ms`,
|
|
13
|
+
border: `1px solid ${isHovered ? brandColor : '#e4e4e7'}`,
|
|
14
|
+
}, onClick: onClick, children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-1 w-[93%]", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-slate-950 text-sm font-normal leading-5 overflow-hidden text-ellipsis whitespace-nowrap w-full", children: message }), (0, jsx_runtime_1.jsx)("span", { className: "text-slate-600 text-xs font-normal leading-[18px] overflow-hidden text-ellipsis whitespace-nowrap w-full", children: lastActive ? lastActive : '-' })] }), (0, jsx_runtime_1.jsx)("span", { className: `w-3 h-5 transition-all duration-800 ease-in-out ${animate ? 'opacity-100 translate-x-0' : 'opacity-0 -translate-x-1'}`, style: {
|
|
15
|
+
color: isHovered ? brandColor : '#e4e4e7',
|
|
16
|
+
willChange: 'transform, opacity',
|
|
17
|
+
transitionDelay: `${delay}ms`,
|
|
18
|
+
}, children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiChevronBigRightStroke, { className: "w-[18px] h-[18px]" }) })] }));
|
|
19
|
+
};
|
|
20
|
+
exports.default = RecentMessageListCard;
|