@connectycube/react-ui-kit 0.0.20 → 0.0.22
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/configs/dependencies.json +19 -4
- package/configs/imports.json +7 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/components/attachment.d.ts +5 -6
- package/dist/types/components/attachment.d.ts.map +1 -1
- package/dist/types/components/chat-bubble.d.ts +32 -0
- package/dist/types/components/chat-bubble.d.ts.map +1 -0
- package/dist/types/components/chat-input.d.ts +27 -0
- package/dist/types/components/chat-input.d.ts.map +1 -0
- package/dist/types/components/chat-list.d.ts +30 -0
- package/dist/types/components/chat-list.d.ts.map +1 -0
- package/dist/types/components/checkbox.d.ts +11 -0
- package/dist/types/components/checkbox.d.ts.map +1 -0
- package/dist/types/components/dialogs-list.d.ts +14 -0
- package/dist/types/components/dialogs-list.d.ts.map +1 -0
- package/dist/types/components/file-picker.d.ts +1 -1
- package/dist/types/components/file-picker.d.ts.map +1 -1
- package/dist/types/components/placeholder-text.d.ts.map +1 -1
- package/dist/types/components/quick-actions.d.ts +14 -0
- package/dist/types/components/quick-actions.d.ts.map +1 -0
- package/dist/types/components/status-call.d.ts +8 -0
- package/dist/types/components/status-call.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -2
- package/dist/types/index.d.ts.map +1 -1
- package/gen/components/attachment.jsx +6 -6
- package/gen/components/button.jsx +1 -1
- package/gen/components/{chat-message.jsx → chat-bubble.jsx} +69 -48
- package/gen/components/chat-input.jsx +152 -0
- package/gen/components/chat-list.jsx +151 -0
- package/gen/components/checkbox.jsx +30 -0
- package/gen/components/dialog-item.jsx +1 -1
- package/gen/components/dialogs-list.jsx +73 -0
- package/gen/components/dismiss-layer.jsx +1 -1
- package/gen/components/file-picker.jsx +2 -2
- package/gen/components/placeholder-text.jsx +5 -1
- package/gen/components/quick-actions.jsx +62 -0
- package/gen/components/search.jsx +1 -1
- package/gen/components/status-call.jsx +18 -0
- package/gen/components/stream-view.jsx +8 -8
- package/gen/index.js +14 -2
- package/package.json +11 -8
- package/src/components/attachment.tsx +16 -14
- package/src/components/button.tsx +1 -1
- package/src/components/chat-bubble.tsx +176 -0
- package/src/components/chat-input.tsx +172 -0
- package/src/components/chat-list.tsx +164 -0
- package/src/components/checkbox.tsx +40 -0
- package/src/components/connectycube-ui/chat-input.tsx +174 -0
- package/src/components/dialog-item.tsx +1 -1
- package/src/components/dialogs-list.tsx +84 -0
- package/src/components/dismiss-layer.tsx +1 -1
- package/src/components/file-picker.tsx +3 -3
- package/src/components/placeholder-text.tsx +5 -1
- package/src/components/quick-actions.tsx +74 -0
- package/src/components/search.tsx +1 -1
- package/src/components/status-call.tsx +23 -0
- package/src/components/stream-view.tsx +8 -8
- package/src/index.ts +17 -2
- package/dist/types/components/call-message.d.ts +0 -17
- package/dist/types/components/call-message.d.ts.map +0 -1
- package/dist/types/components/chat-message.d.ts +0 -30
- package/dist/types/components/chat-message.d.ts.map +0 -1
- package/gen/components/call-message.jsx +0 -62
- package/src/components/call-message.tsx +0 -75
- package/src/components/chat-message.tsx +0 -138
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { forwardRef, memo } from 'react';
|
|
3
|
-
import { Phone, PhoneIncoming, PhoneMissed, PhoneOutgoing, type LucideProps } from 'lucide-react';
|
|
4
|
-
import { FormattedDate, type FormattedDateProps } from './formatted-date';
|
|
5
|
-
import { cn } from './utils';
|
|
6
|
-
|
|
7
|
-
interface CallMessageProps extends React.ComponentProps<'div'> {
|
|
8
|
-
signal?: 'reject' | 'notAnswer' | 'hungUp' | 'cancel' | undefined;
|
|
9
|
-
info?: string | undefined;
|
|
10
|
-
duration?: number | undefined;
|
|
11
|
-
fromMe: boolean;
|
|
12
|
-
isLast: boolean;
|
|
13
|
-
iconElement?: React.ReactNode;
|
|
14
|
-
iconProps?: LucideProps;
|
|
15
|
-
infoProps?: React.ComponentProps<'span'>;
|
|
16
|
-
formattedDateProps?: FormattedDateProps;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function formatDuration(seconds: number): string {
|
|
20
|
-
const h = Math.floor(seconds / 3600);
|
|
21
|
-
const m = Math.floor((seconds % 3600) / 60);
|
|
22
|
-
const s = seconds % 60;
|
|
23
|
-
const pad = (num: number) => String(num).padStart(2, '0');
|
|
24
|
-
|
|
25
|
-
return h > 0 ? `${h}:${pad(m)}:${pad(s)}` : `${pad(m)}:${pad(s)}`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function CallMessageBase(
|
|
29
|
-
{
|
|
30
|
-
signal,
|
|
31
|
-
info,
|
|
32
|
-
duration = 0,
|
|
33
|
-
fromMe = false,
|
|
34
|
-
isLast = false,
|
|
35
|
-
iconElement,
|
|
36
|
-
iconProps,
|
|
37
|
-
infoProps,
|
|
38
|
-
formattedDateProps,
|
|
39
|
-
...props
|
|
40
|
-
}: CallMessageProps,
|
|
41
|
-
ref: React.ForwardedRef<HTMLDivElement>
|
|
42
|
-
) {
|
|
43
|
-
const CallIcon =
|
|
44
|
-
signal === 'hungUp' ? Phone : fromMe ? (signal === 'reject' ? PhoneIncoming : PhoneOutgoing) : PhoneMissed;
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div
|
|
48
|
-
ref={ref}
|
|
49
|
-
{...props}
|
|
50
|
-
className={cn(
|
|
51
|
-
'flex items-center justify-center gap-2 rounded-full w-fit bg-ring/20 mx-auto px-3 py-1.5',
|
|
52
|
-
isLast ? 'my-2' : 'mt-2',
|
|
53
|
-
props?.className
|
|
54
|
-
)}
|
|
55
|
-
>
|
|
56
|
-
{iconElement || (
|
|
57
|
-
<CallIcon
|
|
58
|
-
{...iconProps}
|
|
59
|
-
className={cn('size-4', signal === 'hungUp' ? 'text-green-500' : 'text-red-500', iconProps?.className)}
|
|
60
|
-
/>
|
|
61
|
-
)}
|
|
62
|
-
<span
|
|
63
|
-
{...infoProps}
|
|
64
|
-
className={cn('text-sm mb-px', infoProps?.className)}
|
|
65
|
-
>{`${info}${duration ? ` - ${formatDuration(duration)}` : ''}`}</span>
|
|
66
|
-
<FormattedDate distanceToNow {...formattedDateProps} />
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const CallMessage = memo(forwardRef<HTMLDivElement, CallMessageProps>(CallMessageBase));
|
|
72
|
-
|
|
73
|
-
CallMessage.displayName = 'CallMessage';
|
|
74
|
-
|
|
75
|
-
export { CallMessage, type CallMessageProps };
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
-
import { useInView } from 'react-intersection-observer';
|
|
4
|
-
import { Attachment, type AttachmentProps } from './attachment';
|
|
5
|
-
import { Avatar, type AvatarProps } from './avatar';
|
|
6
|
-
import { FormattedDate, type FormattedDateProps } from './formatted-date';
|
|
7
|
-
import { LinkifyText, type LinkifyTextProps } from './linkify-text';
|
|
8
|
-
import { LinkPreview, type LinkPreviewProps } from './link-preview';
|
|
9
|
-
import { StatusSent, type StatusSentProps } from './status-sent';
|
|
10
|
-
import { cn } from './utils';
|
|
11
|
-
|
|
12
|
-
interface ChatMessageProps extends React.ComponentProps<'div'> {
|
|
13
|
-
isLast: boolean;
|
|
14
|
-
fromMe: boolean;
|
|
15
|
-
sameSenderAbove: boolean;
|
|
16
|
-
title?: string;
|
|
17
|
-
senderName?: string;
|
|
18
|
-
senderAvatar?: string;
|
|
19
|
-
attachmentElement?: React.ReactNode;
|
|
20
|
-
linkifyTextElement?: React.ReactNode;
|
|
21
|
-
linkPreviewElement?: React.ReactNode;
|
|
22
|
-
onView?: () => void;
|
|
23
|
-
avatarProps?: AvatarProps;
|
|
24
|
-
bubbleProps?: React.ComponentProps<'div'>;
|
|
25
|
-
titleProps?: React.ComponentProps<'span'>;
|
|
26
|
-
formattedDateProps?: FormattedDateProps;
|
|
27
|
-
statusSentProps?: StatusSentProps;
|
|
28
|
-
attachmentProps?: AttachmentProps;
|
|
29
|
-
linkifyTextProps?: LinkifyTextProps;
|
|
30
|
-
linkPreviewProps?: LinkPreviewProps;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function ChatMessageBase(
|
|
34
|
-
{
|
|
35
|
-
isLast,
|
|
36
|
-
fromMe,
|
|
37
|
-
sameSenderAbove,
|
|
38
|
-
title,
|
|
39
|
-
senderName,
|
|
40
|
-
senderAvatar,
|
|
41
|
-
attachmentElement,
|
|
42
|
-
linkifyTextElement,
|
|
43
|
-
linkPreviewElement,
|
|
44
|
-
onView = () => {},
|
|
45
|
-
avatarProps,
|
|
46
|
-
bubbleProps,
|
|
47
|
-
titleProps,
|
|
48
|
-
formattedDateProps,
|
|
49
|
-
statusSentProps,
|
|
50
|
-
attachmentProps,
|
|
51
|
-
linkifyTextProps,
|
|
52
|
-
linkPreviewProps,
|
|
53
|
-
children,
|
|
54
|
-
...props
|
|
55
|
-
}: ChatMessageProps,
|
|
56
|
-
ref: React.ForwardedRef<HTMLDivElement>
|
|
57
|
-
) {
|
|
58
|
-
const [setRef, inView] = useInView();
|
|
59
|
-
const messageRef = useRef<HTMLDivElement>(null);
|
|
60
|
-
const setRefs = useCallback(
|
|
61
|
-
(node: HTMLDivElement) => {
|
|
62
|
-
messageRef.current = node;
|
|
63
|
-
setRef(node);
|
|
64
|
-
},
|
|
65
|
-
[setRef]
|
|
66
|
-
);
|
|
67
|
-
const hasAvatar = Boolean((avatarProps || senderAvatar) && !sameSenderAbove);
|
|
68
|
-
const hasAvatarMargin = Boolean((avatarProps || senderAvatar) && sameSenderAbove);
|
|
69
|
-
const hasThinMarginTop = hasAvatarMargin || Boolean(fromMe && sameSenderAbove);
|
|
70
|
-
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (inView) {
|
|
73
|
-
onView();
|
|
74
|
-
}
|
|
75
|
-
}, [inView, onView]);
|
|
76
|
-
|
|
77
|
-
useImperativeHandle(ref, () => messageRef.current!, []);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<div
|
|
81
|
-
ref={setRefs}
|
|
82
|
-
{...props}
|
|
83
|
-
className={cn(
|
|
84
|
-
`flex relative text-left whitespace-pre-wrap`,
|
|
85
|
-
fromMe ? 'self-end flex-row-reverse ml-12' : `self-start mr-12`,
|
|
86
|
-
isLast && 'mb-2',
|
|
87
|
-
hasThinMarginTop ? 'mt-1' : 'mt-2',
|
|
88
|
-
inView && 'view',
|
|
89
|
-
props?.className
|
|
90
|
-
)}
|
|
91
|
-
>
|
|
92
|
-
{hasAvatar && (
|
|
93
|
-
<Avatar
|
|
94
|
-
name={senderName}
|
|
95
|
-
src={senderAvatar}
|
|
96
|
-
imageProps={{ className: 'bg-ring/30' }}
|
|
97
|
-
fallbackProps={{ className: 'bg-ring/30' }}
|
|
98
|
-
{...avatarProps}
|
|
99
|
-
className={cn('mt-1 mr-1', avatarProps?.className)}
|
|
100
|
-
/>
|
|
101
|
-
)}
|
|
102
|
-
|
|
103
|
-
<div
|
|
104
|
-
className={cn(
|
|
105
|
-
'relative flex flex-col min-w-42 max-w-120 rounded-xl px-2 pt-2 pb-6',
|
|
106
|
-
fromMe ? 'bg-blue-200' : 'bg-gray-200',
|
|
107
|
-
hasAvatarMargin && 'ml-9',
|
|
108
|
-
bubbleProps?.className
|
|
109
|
-
)}
|
|
110
|
-
>
|
|
111
|
-
{(title || senderName) && (
|
|
112
|
-
<span
|
|
113
|
-
{...titleProps}
|
|
114
|
-
className={cn(
|
|
115
|
-
'font-semibold',
|
|
116
|
-
title && 'mb-1 py-1.5 text-xs text-muted-foreground italic border-b',
|
|
117
|
-
titleProps?.className
|
|
118
|
-
)}
|
|
119
|
-
>
|
|
120
|
-
{title || senderName}
|
|
121
|
-
</span>
|
|
122
|
-
)}
|
|
123
|
-
{children}
|
|
124
|
-
{attachmentElement || (attachmentProps ? <Attachment {...attachmentProps} /> : null)}
|
|
125
|
-
{linkifyTextElement || (linkifyTextProps ? <LinkifyText {...linkifyTextProps} /> : null)}
|
|
126
|
-
{linkPreviewElement || (linkPreviewProps ? <LinkPreview {...linkPreviewProps} /> : null)}
|
|
127
|
-
<div className="absolute bottom-1 right-2 flex items-center gap-1 italic">
|
|
128
|
-
<FormattedDate distanceToNow {...formattedDateProps} />
|
|
129
|
-
<StatusSent {...statusSentProps} />
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const ChatMessage = memo(forwardRef<HTMLDivElement, ChatMessageProps>(ChatMessageBase));
|
|
137
|
-
|
|
138
|
-
export { ChatMessage, type ChatMessageProps };
|