@axos-web-dev/shared-components 1.0.100-dev.54 → 1.0.100-dev.55

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.
@@ -3,10 +3,10 @@ export declare const windowOpenStyle: string;
3
3
  export declare const windowBarStyle: string;
4
4
  export declare const left_bar_section: string;
5
5
  export declare const chat_title: string;
6
+ export declare const buttonss_section: string;
6
7
  export declare const button_bar: string;
7
8
  export declare const button_reset: string;
8
9
  export declare const arrowFill: string;
9
- export declare const buttonss_section: string;
10
10
  export declare const inputStyle: string;
11
11
  /**
12
12
  * Style for automatically resizing a textarea or input element.
@@ -9,10 +9,10 @@ var windowOpenStyle = "_13n1jqk1";
9
9
  var windowBarStyle = "_13n1jqk2";
10
10
  var left_bar_section = "_13n1jqk3";
11
11
  var chat_title = "_13n1jqk4";
12
- var button_bar = "_13n1jqk5";
13
- var button_reset = "_13n1jqk6";
14
- var arrowFill = "_13n1jqk7";
15
- var buttonss_section = "_13n1jqk8";
12
+ var buttonss_section = "_13n1jqk5";
13
+ var button_bar = "_13n1jqk6";
14
+ var button_reset = "_13n1jqk7";
15
+ var arrowFill = "_13n1jqk8";
16
16
  var inputStyle = "_13n1jqk9";
17
17
  var autoResize = "_13n1jqka";
18
18
  var sendButtonStyle = "_13n1jqkb";
@@ -141,11 +141,12 @@ const ChatWindow = ({
141
141
  },
142
142
  className: clsx(button_bar),
143
143
  style: {
144
- border: "none",
144
+ border: menuOpen ? `1px solid ${vars.chatbot.window.headerText}` : "none",
145
145
  cursor: "pointer",
146
146
  padding: 0,
147
147
  display: "flex",
148
- alignContent: "center"
148
+ alignContent: "center",
149
+ background: menuOpen ? "#0000000f" : void 0
149
150
  },
150
151
  children: /* @__PURE__ */ jsx(EllipsisIcon, {})
151
152
  }
@@ -309,9 +310,12 @@ const ChatWindow = ({
309
310
  onClose && /* @__PURE__ */ jsxs(
310
311
  "button",
311
312
  {
312
- onClick: onClose,
313
+ onClick: () => {
314
+ onClose();
315
+ setMenuOpen(false);
316
+ },
313
317
  className: clsx(button_reset, button_bar),
314
- "aria-label": "Close chat",
318
+ "aria-label": "Close chat window",
315
319
  title: "Close",
316
320
  children: [
317
321
  /* @__PURE__ */ jsx(
@@ -30,6 +30,17 @@ const Chatbot = ({
30
30
  ["axos", 1],
31
31
  ["ufb", 3]
32
32
  ]);
33
+ const typingMessage = {
34
+ $sid: "typing-1",
35
+ type: "system",
36
+ // or a custom type like "typing"
37
+ text: "AI is typing...",
38
+ sender: { id: "system", type: "system" },
39
+ $timestamp: /* @__PURE__ */ new Date(),
40
+ $userType: "system",
41
+ $index: -10,
42
+ $userId: 0
43
+ };
33
44
  const custom_data = {
34
45
  unsigned: {
35
46
  facingBrandId: {
@@ -67,6 +78,9 @@ const Chatbot = ({
67
78
  const onChatMessageHandler = async (message) => {
68
79
  console.log("Received message:", message);
69
80
  addMessage(message);
81
+ if (message.$userType != "virtual_agent") {
82
+ addMessage(typingMessage);
83
+ }
70
84
  };
71
85
  const onChatTypingStartedHandler = async (identity) => {
72
86
  console.log("Typing started by:", identity);
@@ -9,7 +9,7 @@ import '../assets/themes/victorie.css';import '../assets/themes/ufb.css';import
9
9
  /* empty css */
10
10
  /* empty css */
11
11
  import clsx from "clsx";
12
- import { notificationStyle, endChatButtonStyle, messageStyle, user_msg, agent_msg, inline_button_wrapper, inline_button } from "./ChatWindow.css.js";
12
+ import { shimmerText, notificationStyle, endChatButtonStyle, messageStyle, user_msg, agent_msg, inline_button_wrapper, inline_button } from "./ChatWindow.css.js";
13
13
  function timeAgo(date) {
14
14
  const seconds = Math.floor(((/* @__PURE__ */ new Date()).getTime() - date.getTime()) / 1e3);
15
15
  if (seconds < 60) return "Just now";
@@ -34,7 +34,33 @@ const ChatbotMessage = ({
34
34
  return () => clearInterval(interval);
35
35
  }, [msg.$timestamp]);
36
36
  if (msg.$sid === "typing-1") {
37
- return /* @__PURE__ */ jsx("div", { children: "IA is thinking..." });
37
+ return /* @__PURE__ */ jsx(
38
+ "div",
39
+ {
40
+ className: clsx(),
41
+ style: {
42
+ textAlign: "left",
43
+ alignSelf: "flex-start",
44
+ color: "#1e3860",
45
+ borderRadius: 16,
46
+ padding: "8px 8px",
47
+ maxWidth: "80%",
48
+ marginBottom: 2
49
+ },
50
+ children: /* @__PURE__ */ jsx(
51
+ "div",
52
+ {
53
+ style: {
54
+ fontSize: 14,
55
+ display: "flex",
56
+ flexDirection: "column",
57
+ gap: 4
58
+ },
59
+ children: /* @__PURE__ */ jsx("p", { className: shimmerText, children: "AI thinking..." })
60
+ }
61
+ )
62
+ }
63
+ );
38
64
  }
39
65
  return /* @__PURE__ */ jsxs(Fragment, { children: [
40
66
  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),
@@ -1,19 +1,15 @@
1
1
  import { create } from "zustand";
2
2
  const useMessages = create((set) => ({
3
3
  messages: [],
4
- addMessage: (message) => set((state) => ({ messages: [...state.messages, message] })),
5
- removeMessage: (id) => (
6
- // set((state) => ({
7
- // messages: state.messages.filter(
8
- // (msg) => "$sid" in msg && msg.$sid !== id
9
- // ),
10
- // })
11
- setTimeout(() => {
12
- set((state) => ({
13
- messages: state.messages.filter((msg) => msg.$sid !== id)
14
- }));
15
- }, 800)
16
- ),
4
+ addMessage: (message) => set((state) => {
5
+ const cleaned = state.messages.filter((m) => m.$sid !== "typing-1");
6
+ return { messages: [...cleaned, message] };
7
+ }),
8
+ removeMessage: (id) => set((state) => ({
9
+ messages: state.messages.filter(
10
+ (msg) => "$sid" in msg && msg.$sid !== id
11
+ )
12
+ })),
17
13
  addMessages: (newMessages) => set((state) => ({ messages: [...state.messages, ...newMessages] })),
18
14
  clearMessages: () => set({ messages: [] })
19
15
  }));
@@ -47,6 +47,11 @@
47
47
  line-height: 1.5;
48
48
  }
49
49
  ._13n1jqk5 {
50
+ display: flex;
51
+ align-items: center;
52
+ gap: 8px;
53
+ }
54
+ ._13n1jqk6 {
50
55
  width: 32px;
51
56
  height: 32px;
52
57
  border-radius: 50%;
@@ -56,28 +61,31 @@
56
61
  justify-content: center;
57
62
  align-items: center;
58
63
  }
59
- ._13n1jqk6 {
64
+ ._13n1jqk6:hover {
65
+ background: #0000000f;
66
+ cursor: pointer;
67
+ }
68
+ button:has(span:hover) ._13n1jqk6 {
69
+ background: #0000000f;
70
+ cursor: pointer;
71
+ }
72
+ ._13n1jqk7 {
60
73
  border: none;
61
74
  cursor: pointer;
62
75
  line-height: 1;
63
76
  margin-left: 8px;
64
77
  padding: 0;
65
78
  }
66
- ._13n1jqk6 >:first-child {
79
+ ._13n1jqk7 >:first-child {
67
80
  display: block;
68
81
  }
69
- ._13n1jqk6 > :last-child {
82
+ ._13n1jqk7 > :last-child {
70
83
  display: none;
71
84
  }
72
- ._13n1jqk7 {
85
+ ._13n1jqk8 {
73
86
  fill: var(--_1073cm819);
74
87
  color: var(--_1073cm819);
75
88
  }
76
- ._13n1jqk8 {
77
- display: flex;
78
- align-items: center;
79
- gap: 8px;
80
- }
81
89
  ._13n1jqk9 {
82
90
  border: none;
83
91
  color: #1F1F1F;
@@ -327,10 +335,10 @@
327
335
  }
328
336
  }
329
337
  @media screen and (max-width:768px) {
330
- ._13n1jqk6 >:first-child {
338
+ ._13n1jqk7 >:first-child {
331
339
  display: none;
332
340
  }
333
- ._13n1jqk6 > :last-child {
341
+ ._13n1jqk7 > :last-child {
334
342
  display: block;
335
343
  }
336
344
  }
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.54",
4
+ "version": "1.0.100-dev.55",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",