@banbox/chat 1.0.3 → 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 +214 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2273 -0
- package/dist/index.d.cts +20 -14
- package/dist/index.d.ts +20 -14
- package/dist/index.js +212 -190
- package/dist/index.js.map +1 -1
- package/package.json +9 -3
- package/src/chat/ChatRoot.tsx +15 -10
- package/src/chat/InboxPopup.tsx +97 -75
- package/src/chat/SinglePopup.tsx +40 -29
- package/src/index.ts +3 -0
- package/src/styles/index.css +231 -0
- package/src/ui/chat/ChatHeader.tsx +21 -24
- package/src/ui/chat/ChatListHeader.tsx +128 -156
- package/src/ui/chat/ChatScroll.tsx +52 -64
- package/src/ui/chat/TypingIndicator.tsx +10 -21
|
@@ -1,64 +1,52 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"min-h-full flex flex-col",
|
|
54
|
-
bottomAlignWhenShort ? "justify-end" : "justify-start",
|
|
55
|
-
)}
|
|
56
|
-
>
|
|
57
|
-
{top}
|
|
58
|
-
{children}
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default ChatScroll;
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
top?: React.ReactNode;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
bottomAlignWhenShort?: boolean;
|
|
10
|
+
scrollKey?: string | number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const ChatScroll: React.FC<Props> = ({
|
|
14
|
+
top,
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
bottomAlignWhenShort = false,
|
|
19
|
+
scrollKey,
|
|
20
|
+
}) => {
|
|
21
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
22
|
+
|
|
23
|
+
const scrollToBottom = React.useCallback(() => {
|
|
24
|
+
const el = ref.current;
|
|
25
|
+
if (!el) return;
|
|
26
|
+
el.scrollTop = el.scrollHeight;
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
scrollToBottom();
|
|
31
|
+
const id = window.setTimeout(scrollToBottom, 0);
|
|
32
|
+
return () => window.clearTimeout(id);
|
|
33
|
+
}, [scrollKey, scrollToBottom]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div
|
|
37
|
+
ref={ref}
|
|
38
|
+
data-chat-scroll
|
|
39
|
+
className={`h-full min-h-0 overflow-y-auto bg-white p-4 custom-scroll-hidden${className ? ` ${className}` : ""}`}
|
|
40
|
+
style={style}
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
className={`min-h-full flex flex-col${bottomAlignWhenShort ? " justify-end" : " justify-start"}`}
|
|
44
|
+
>
|
|
45
|
+
{top}
|
|
46
|
+
{children}
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default ChatScroll;
|
|
@@ -6,44 +6,34 @@ import _Lottie from "lottie-react";
|
|
|
6
6
|
const Lottie = ((_Lottie as any).default ?? _Lottie) as typeof _Lottie;
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
|
-
import { cn } from "../../utils/cn";
|
|
10
9
|
import dots from "../../lottie/typingdotanimation2.json";
|
|
11
10
|
|
|
12
|
-
/* =======================
|
|
13
|
-
Types
|
|
14
|
-
======================= */
|
|
15
|
-
|
|
16
11
|
type Props = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
autoplay?: boolean; // default true
|
|
12
|
+
size?: number;
|
|
13
|
+
loop?: boolean;
|
|
14
|
+
autoplay?: boolean;
|
|
21
15
|
className?: string;
|
|
16
|
+
style?: React.CSSProperties;
|
|
22
17
|
ariaLabel?: string;
|
|
23
|
-
|
|
24
|
-
/** Avatar size in px */
|
|
25
|
-
avatarSize?: number; // default 40
|
|
18
|
+
avatarSize?: number;
|
|
26
19
|
};
|
|
27
20
|
|
|
28
|
-
/* =======================
|
|
29
|
-
Component
|
|
30
|
-
======================= */
|
|
31
|
-
|
|
32
21
|
const TypingIndicator: React.FC<Props> = ({
|
|
33
|
-
size = 18,
|
|
34
22
|
loop = true,
|
|
35
23
|
autoplay = true,
|
|
36
24
|
className,
|
|
37
25
|
ariaLabel = "Typing…",
|
|
38
26
|
avatarSize = 40,
|
|
27
|
+
style,
|
|
39
28
|
}) => {
|
|
40
29
|
const isOnline = true;
|
|
41
30
|
|
|
42
31
|
return (
|
|
43
32
|
<div
|
|
44
|
-
className={cn("relative flex items-end gap-[6px]", className)}
|
|
45
33
|
role="status"
|
|
46
34
|
aria-label={ariaLabel}
|
|
35
|
+
className={`relative flex items-end gap-[6px]${className ? ` ${className}` : ""}`}
|
|
36
|
+
style={style}
|
|
47
37
|
>
|
|
48
38
|
{/* Avatar */}
|
|
49
39
|
<div
|
|
@@ -55,13 +45,12 @@ const TypingIndicator: React.FC<Props> = ({
|
|
|
55
45
|
alt="avatar image"
|
|
56
46
|
className="h-full w-full rounded-full object-cover"
|
|
57
47
|
/>
|
|
58
|
-
|
|
59
48
|
{isOnline && (
|
|
60
|
-
<span className="absolute bottom-
|
|
49
|
+
<span className="absolute bottom-0 right-0 h-[11.25px] w-[11.25px] rounded-full bg-[#328545] ring-1 ring-white" />
|
|
61
50
|
)}
|
|
62
51
|
</div>
|
|
63
52
|
|
|
64
|
-
{/* typing
|
|
53
|
+
{/* Lottie typing dots */}
|
|
65
54
|
<span className="absolute bottom-[-13px] left-[30px]">
|
|
66
55
|
<Lottie
|
|
67
56
|
animationData={dots}
|