@axos-web-dev/shared-components 1.0.100-dev.7 → 1.0.100-dev.8

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.
@@ -15,3 +15,4 @@ export declare const endChatButtonStyle: string;
15
15
  export declare const chatbotMenu: string;
16
16
  export declare const chatbotMenuItem: string;
17
17
  export declare const chatNetworkStatus: string;
18
+ export declare const chatFinishDialog: string;
@@ -16,9 +16,11 @@ var endChatButtonStyle = "_13n1jqkd";
16
16
  var chatbotMenu = "_13n1jqke";
17
17
  var chatbotMenuItem = "_13n1jqkf";
18
18
  var chatNetworkStatus = "_13n1jqkg";
19
+ var chatFinishDialog = "_13n1jqkh";
19
20
  export {
20
21
  arrowFill,
21
22
  button_reset,
23
+ chatFinishDialog,
22
24
  chatNetworkStatus,
23
25
  chat_title,
24
26
  chatbotMenu,
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import { jsxs, jsx, Fragment as Fragment$1 } from "react/jsx-runtime";
2
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
- import React, { useRef, useEffect, Fragment } from "react";
4
+ import React, { useRef, useEffect, Fragment as Fragment$1 } from "react";
5
5
  import ReactMarkdown from "react-markdown";
6
6
  import { useNetworkState, useMount } from "react-use";
7
7
  import remarkGfm from "remark-gfm";
8
- import { windowBarStyle, chat_title, chatbotMenuItem, chatbotMenu, button_reset, arrowFill, chatNetworkStatus, notificationStyle, messageStyle, inline_button_wrapper, inline_button, endChatButtonStyle, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
8
+ import { windowBarStyle, chat_title, chatbotMenuItem, chatbotMenu, chatFinishDialog, endChatButtonStyle, button_reset, arrowFill, chatNetworkStatus, notificationStyle, messageStyle, inline_button_wrapper, inline_button, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
9
9
  import { EllipsisIcon } from "./EllipsisIcon.js";
10
10
  import { useOpenChat } from "./store/chat.js";
11
11
  const ChatWindow = ({
@@ -88,46 +88,75 @@ const ChatWindow = ({
88
88
  children: "Finish chat"
89
89
  }
90
90
  ) }) }),
91
- showEndChatDialog && /* @__PURE__ */ jsx(
92
- "dialog",
93
- {
94
- open: showEndChatDialog,
95
- style: {
96
- padding: "1rem",
97
- borderRadius: 8,
98
- background: "#fff",
99
- color: "#000",
100
- border: "none",
101
- outline: "none",
102
- maxWidth: "90%",
103
- top: "25%"
104
- },
105
- children: /* @__PURE__ */ jsxs("form", { method: "dialog", children: [
106
- /* @__PURE__ */ jsx("p", { children: "are you sure you want to end this chat?" }),
107
- /* @__PURE__ */ jsx(
108
- "button",
109
- {
110
- type: "submit",
111
- onClick: () => {
112
- endChat();
113
- setShowEndChatDialog(false);
114
- },
115
- children: "Yes"
116
- }
117
- ),
118
- /* @__PURE__ */ jsx(
119
- "button",
120
- {
121
- type: "button",
122
- onClick: () => {
123
- setShowEndChatDialog(false);
124
- },
125
- children: "No"
126
- }
127
- )
128
- ] })
129
- }
130
- ),
91
+ showEndChatDialog && /* @__PURE__ */ jsxs(Fragment, { children: [
92
+ /* @__PURE__ */ jsx(
93
+ "div",
94
+ {
95
+ style: {
96
+ background: "#00000080",
97
+ position: "fixed",
98
+ top: 0,
99
+ left: 0,
100
+ right: 0,
101
+ bottom: 0,
102
+ zIndex: 999,
103
+ opacity: 0.75
104
+ }
105
+ }
106
+ ),
107
+ /* @__PURE__ */ jsx(
108
+ "dialog",
109
+ {
110
+ open: showEndChatDialog,
111
+ style: {
112
+ padding: "1rem",
113
+ borderRadius: 8,
114
+ background: "#fff",
115
+ color: "#000",
116
+ border: `1px solid ${endUserBg}`,
117
+ outline: "none",
118
+ maxWidth: "90%",
119
+ top: "25%",
120
+ marginInline: "auto",
121
+ zIndex: 1e3
122
+ },
123
+ children: /* @__PURE__ */ jsxs("form", { method: "dialog", className: chatFinishDialog, children: [
124
+ /* @__PURE__ */ jsx("p", { children: "Are you sure you want to end this chat?" }),
125
+ /* @__PURE__ */ jsxs(
126
+ "div",
127
+ {
128
+ style: { display: "flex", gap: "1rem", marginTop: "1rem" },
129
+ children: [
130
+ /* @__PURE__ */ jsx(
131
+ "button",
132
+ {
133
+ className: endChatButtonStyle,
134
+ type: "submit",
135
+ onClick: () => {
136
+ endChat();
137
+ setShowEndChatDialog(false);
138
+ },
139
+ children: "Yes"
140
+ }
141
+ ),
142
+ /* @__PURE__ */ jsx(
143
+ "button",
144
+ {
145
+ className: endChatButtonStyle,
146
+ type: "button",
147
+ onClick: () => {
148
+ setShowEndChatDialog(false);
149
+ },
150
+ children: "No"
151
+ }
152
+ )
153
+ ]
154
+ }
155
+ )
156
+ ] })
157
+ }
158
+ )
159
+ ] }),
131
160
  onClose && /* @__PURE__ */ jsx(
132
161
  "button",
133
162
  {
@@ -156,7 +185,7 @@ const ChatWindow = ({
156
185
  }
157
186
  )
158
187
  ] }),
159
- /* @__PURE__ */ jsx("div", { className: clsx(chatNetworkStatus), children: mounted && !state.online ? /* @__PURE__ */ jsxs(
188
+ mounted && !state.online ? /* @__PURE__ */ jsx("div", { className: clsx(chatNetworkStatus), children: /* @__PURE__ */ jsxs(
160
189
  "div",
161
190
  {
162
191
  style: {
@@ -178,9 +207,9 @@ const ChatWindow = ({
178
207
  "You are currently disconnected. Please check your connection."
179
208
  ]
180
209
  }
181
- ) : null }),
210
+ ) }) : null,
182
211
  /* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
183
- messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment, { children: [
212
+ messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
184
213
  msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationStarted" && /* @__PURE__ */ jsx("div", { className: notificationStyle, children: "We are connecting you with a human agent..." }, msg.$index),
185
214
  msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
186
215
  /* @__PURE__ */ jsx("strong", { children: "Virtual Agent" }),
@@ -282,7 +311,7 @@ const ChatWindow = ({
282
311
  index
283
312
  );
284
313
  }) }),
285
- msg.event == "chatEnded" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
314
+ msg.event == "chatEnded" && /* @__PURE__ */ jsxs(Fragment, { children: [
286
315
  /* @__PURE__ */ jsxs(
287
316
  "div",
288
317
  {
@@ -332,6 +361,7 @@ const ChatWindow = ({
332
361
  onChange: (e) => setInput(e.target.value),
333
362
  placeholder: "Ask something...",
334
363
  className: inputStyle,
364
+ autoFocus: true,
335
365
  disabled: inputDisabled || status !== "connected"
336
366
  }
337
367
  ),
@@ -4,7 +4,7 @@ import { bubbleWrapper, svgFill } from "./Bubble.css.js";
4
4
  import { Chatbot } from "./Chatbot.js";
5
5
  import { chatbotAXB, chatbotUFB } from "./Chatbot.css.js";
6
6
  import { ChatWindow } from "./ChatWindow.js";
7
- import { arrowFill, button_reset, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
7
+ import { arrowFill, button_reset, chatFinishDialog, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
8
8
  import { useOpenChat } from "./store/chat.js";
9
9
  import { useMessages } from "./store/messages.js";
10
10
  import { useHeadlessChat } from "./useHeadlessChat.js";
@@ -15,6 +15,7 @@ export {
15
15
  arrowFill,
16
16
  bubbleWrapper,
17
17
  button_reset,
18
+ chatFinishDialog,
18
19
  chatNetworkStatus,
19
20
  chat_title,
20
21
  chatbotAXB,
@@ -68,9 +68,11 @@ function useHeadlessChat({
68
68
  if (debug) console.log("channelId:", menuRef.current);
69
69
  if (debug) console.log("channelId:", menuRef.current?.menus[5].id);
70
70
  try {
71
- const chatId = localStorage.getItem("ujet:chat");
72
- if (chatId) {
73
- chatRef.current = await clientRef.current?.resumeChat(chatId);
71
+ chatRef.current = await clientRef.current?.loadOngoingChat();
72
+ if (chatRef.current != null) {
73
+ chatRef.current = await clientRef.current?.resumeChat(
74
+ chatRef.current?.state?.id
75
+ );
74
76
  if (debug) console.log("Resumed chatRef:", chatRef.current);
75
77
  } else {
76
78
  const custom_data = {
@@ -203,4 +203,11 @@
203
203
  }
204
204
  ._1hpv6vm1 ._13n1jqkg {
205
205
  color: #323339;
206
+ }
207
+ ._13n1jqkh {
208
+ display: flex;
209
+ flex-direction: column;
210
+ align-items: center;
211
+ justify-content: center;
212
+ padding: 0 1rem;
206
213
  }
package/dist/main.js CHANGED
@@ -42,7 +42,7 @@ import { bubbleWrapper, svgFill } from "./Chatbot/Bubble.css.js";
42
42
  import { Chatbot } from "./Chatbot/Chatbot.js";
43
43
  import { chatbotAXB, chatbotUFB } from "./Chatbot/Chatbot.css.js";
44
44
  import { ChatWindow } from "./Chatbot/ChatWindow.js";
45
- import { arrowFill, button_reset, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./Chatbot/ChatWindow.css.js";
45
+ import { arrowFill, button_reset, chatFinishDialog, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./Chatbot/ChatWindow.css.js";
46
46
  import { useOpenChat } from "./Chatbot/store/chat.js";
47
47
  import { useMessages } from "./Chatbot/store/messages.js";
48
48
  import { useHeadlessChat } from "./Chatbot/useHeadlessChat.js";
@@ -457,6 +457,7 @@ export {
457
457
  center_center,
458
458
  center_left,
459
459
  center_right,
460
+ chatFinishDialog,
460
461
  chatNetworkStatus,
461
462
  chat_title,
462
463
  chatbotAXB,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@axos-web-dev/shared-components",
3
3
  "description": "Axos shared components library for web.",
4
- "version": "1.0.100-dev.7",
4
+ "version": "1.0.100-dev.8",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",