@banbox/chat 1.0.4 → 1.0.5
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.cjs +252 -412
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2273 -0
- package/dist/index.d.cts +19 -13
- package/dist/index.d.ts +19 -13
- package/dist/index.js +252 -412
- package/dist/index.js.map +1 -1
- package/package.json +9 -3
- package/src/chat/ChatRoot.tsx +15 -10
- package/src/chat/InboxPopup.tsx +105 -176
- package/src/chat/SinglePopup.tsx +39 -43
- package/src/index.ts +3 -0
- package/src/styles/index.css +231 -0
- package/src/ui/chat/ChatHeader.tsx +3 -14
- package/src/ui/chat/ChatListHeader.tsx +74 -103
- package/src/ui/chat/ChatScroll.tsx +5 -24
- package/src/ui/chat/TypingIndicator.tsx +8 -38
|
@@ -6,15 +6,14 @@ type Props = {
|
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
className?: string;
|
|
8
8
|
style?: React.CSSProperties;
|
|
9
|
-
/** set true if you want short threads anchored at the bottom */
|
|
10
9
|
bottomAlignWhenShort?: boolean;
|
|
11
|
-
/** when this value changes, we auto-scroll to the bottom */
|
|
12
10
|
scrollKey?: string | number;
|
|
13
11
|
};
|
|
14
12
|
|
|
15
13
|
const ChatScroll: React.FC<Props> = ({
|
|
16
14
|
top,
|
|
17
15
|
children,
|
|
16
|
+
className,
|
|
18
17
|
style,
|
|
19
18
|
bottomAlignWhenShort = false,
|
|
20
19
|
scrollKey,
|
|
@@ -23,13 +22,10 @@ const ChatScroll: React.FC<Props> = ({
|
|
|
23
22
|
|
|
24
23
|
const scrollToBottom = React.useCallback(() => {
|
|
25
24
|
const el = ref.current;
|
|
26
|
-
if (!el)
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
25
|
+
if (!el) return;
|
|
29
26
|
el.scrollTop = el.scrollHeight;
|
|
30
27
|
}, []);
|
|
31
28
|
|
|
32
|
-
// On mount & when scrollKey changes
|
|
33
29
|
React.useEffect(() => {
|
|
34
30
|
scrollToBottom();
|
|
35
31
|
const id = window.setTimeout(scrollToBottom, 0);
|
|
@@ -40,26 +36,11 @@ const ChatScroll: React.FC<Props> = ({
|
|
|
40
36
|
<div
|
|
41
37
|
ref={ref}
|
|
42
38
|
data-chat-scroll
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
minHeight: 0,
|
|
46
|
-
overflowY: "auto",
|
|
47
|
-
backgroundColor: "#fff",
|
|
48
|
-
padding: 16,
|
|
49
|
-
// custom scrollbar — hide track for clean look
|
|
50
|
-
scrollbarWidth: "thin",
|
|
51
|
-
scrollbarColor: "#d1d5db transparent",
|
|
52
|
-
...style,
|
|
53
|
-
}}
|
|
39
|
+
className={`h-full min-h-0 overflow-y-auto bg-white p-4 custom-scroll-hidden${className ? ` ${className}` : ""}`}
|
|
40
|
+
style={style}
|
|
54
41
|
>
|
|
55
|
-
{/* Ensures content is at least as tall as the scroll area */}
|
|
56
42
|
<div
|
|
57
|
-
|
|
58
|
-
minHeight: "100%",
|
|
59
|
-
display: "flex",
|
|
60
|
-
flexDirection: "column",
|
|
61
|
-
justifyContent: bottomAlignWhenShort ? "flex-end" : "flex-start",
|
|
62
|
-
}}
|
|
43
|
+
className={`min-h-full flex flex-col${bottomAlignWhenShort ? " justify-end" : " justify-start"}`}
|
|
63
44
|
>
|
|
64
45
|
{top}
|
|
65
46
|
{children}
|
|
@@ -8,10 +8,6 @@ const Lottie = ((_Lottie as any).default ?? _Lottie) as typeof _Lottie;
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
import dots from "../../lottie/typingdotanimation2.json";
|
|
10
10
|
|
|
11
|
-
/* =======================
|
|
12
|
-
Types
|
|
13
|
-
======================= */
|
|
14
|
-
|
|
15
11
|
type Props = {
|
|
16
12
|
size?: number;
|
|
17
13
|
loop?: boolean;
|
|
@@ -22,13 +18,10 @@ type Props = {
|
|
|
22
18
|
avatarSize?: number;
|
|
23
19
|
};
|
|
24
20
|
|
|
25
|
-
/* =======================
|
|
26
|
-
Component
|
|
27
|
-
======================= */
|
|
28
|
-
|
|
29
21
|
const TypingIndicator: React.FC<Props> = ({
|
|
30
22
|
loop = true,
|
|
31
23
|
autoplay = true,
|
|
24
|
+
className,
|
|
32
25
|
ariaLabel = "Typing…",
|
|
33
26
|
avatarSize = 40,
|
|
34
27
|
style,
|
|
@@ -39,49 +32,26 @@ const TypingIndicator: React.FC<Props> = ({
|
|
|
39
32
|
<div
|
|
40
33
|
role="status"
|
|
41
34
|
aria-label={ariaLabel}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
display: "flex",
|
|
45
|
-
alignItems: "flex-end",
|
|
46
|
-
gap: 6,
|
|
47
|
-
...style,
|
|
48
|
-
}}
|
|
35
|
+
className={`relative flex items-end gap-[6px]${className ? ` ${className}` : ""}`}
|
|
36
|
+
style={style}
|
|
49
37
|
>
|
|
50
38
|
{/* Avatar */}
|
|
51
39
|
<div
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
flexShrink: 0,
|
|
55
|
-
borderRadius: "50%",
|
|
56
|
-
border: "1px solid #F1F1F1",
|
|
57
|
-
width: avatarSize,
|
|
58
|
-
height: avatarSize,
|
|
59
|
-
}}
|
|
40
|
+
className="relative shrink-0 rounded-full border border-[#F1F1F1]"
|
|
41
|
+
style={{ width: avatarSize, height: avatarSize }}
|
|
60
42
|
>
|
|
61
43
|
<img
|
|
62
44
|
src="/chat/img/girl_support.png"
|
|
63
45
|
alt="avatar image"
|
|
64
|
-
|
|
46
|
+
className="h-full w-full rounded-full object-cover"
|
|
65
47
|
/>
|
|
66
|
-
|
|
67
48
|
{isOnline && (
|
|
68
|
-
<span
|
|
69
|
-
style={{
|
|
70
|
-
position: "absolute",
|
|
71
|
-
bottom: 0,
|
|
72
|
-
right: 0,
|
|
73
|
-
height: 11.25,
|
|
74
|
-
width: 11.25,
|
|
75
|
-
borderRadius: "50%",
|
|
76
|
-
backgroundColor: "#328545",
|
|
77
|
-
outline: "2px solid #fff",
|
|
78
|
-
}}
|
|
79
|
-
/>
|
|
49
|
+
<span className="absolute bottom-0 right-0 h-[11.25px] w-[11.25px] rounded-full bg-[#328545] ring-1 ring-white" />
|
|
80
50
|
)}
|
|
81
51
|
</div>
|
|
82
52
|
|
|
83
53
|
{/* Lottie typing dots */}
|
|
84
|
-
<span
|
|
54
|
+
<span className="absolute bottom-[-13px] left-[30px]">
|
|
85
55
|
<Lottie
|
|
86
56
|
animationData={dots}
|
|
87
57
|
loop={loop}
|