@connectycube/react-ui-kit 0.0.20 → 0.1.0

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.
Files changed (69) hide show
  1. package/README.md +31 -4
  2. package/configs/dependencies.json +19 -4
  3. package/configs/imports.json +7 -2
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/types/components/attachment.d.ts +5 -6
  9. package/dist/types/components/attachment.d.ts.map +1 -1
  10. package/dist/types/components/chat-bubble.d.ts +32 -0
  11. package/dist/types/components/chat-bubble.d.ts.map +1 -0
  12. package/dist/types/components/chat-input.d.ts +27 -0
  13. package/dist/types/components/chat-input.d.ts.map +1 -0
  14. package/dist/types/components/chat-list.d.ts +30 -0
  15. package/dist/types/components/chat-list.d.ts.map +1 -0
  16. package/dist/types/components/checkbox.d.ts +11 -0
  17. package/dist/types/components/checkbox.d.ts.map +1 -0
  18. package/dist/types/components/dialogs-list.d.ts +14 -0
  19. package/dist/types/components/dialogs-list.d.ts.map +1 -0
  20. package/dist/types/components/file-picker.d.ts +1 -1
  21. package/dist/types/components/file-picker.d.ts.map +1 -1
  22. package/dist/types/components/placeholder-text.d.ts.map +1 -1
  23. package/dist/types/components/quick-actions.d.ts +14 -0
  24. package/dist/types/components/quick-actions.d.ts.map +1 -0
  25. package/dist/types/components/status-call.d.ts +8 -0
  26. package/dist/types/components/status-call.d.ts.map +1 -0
  27. package/dist/types/index.d.ts +7 -2
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/gen/components/attachment.jsx +6 -6
  30. package/gen/components/button.jsx +1 -1
  31. package/gen/components/{chat-message.jsx → chat-bubble.jsx} +69 -48
  32. package/gen/components/chat-input.jsx +152 -0
  33. package/gen/components/chat-list.jsx +151 -0
  34. package/gen/components/checkbox.jsx +30 -0
  35. package/gen/components/dialog-item.jsx +1 -1
  36. package/gen/components/dialogs-list.jsx +73 -0
  37. package/gen/components/dismiss-layer.jsx +1 -1
  38. package/gen/components/file-picker.jsx +2 -2
  39. package/gen/components/placeholder-text.jsx +5 -1
  40. package/gen/components/quick-actions.jsx +62 -0
  41. package/gen/components/search.jsx +1 -1
  42. package/gen/components/status-call.jsx +18 -0
  43. package/gen/components/stream-view.jsx +8 -8
  44. package/gen/index.js +14 -2
  45. package/package.json +11 -8
  46. package/src/components/attachment.tsx +16 -14
  47. package/src/components/button.tsx +1 -1
  48. package/src/components/chat-bubble.tsx +176 -0
  49. package/src/components/chat-input.tsx +172 -0
  50. package/src/components/chat-list.tsx +164 -0
  51. package/src/components/checkbox.tsx +40 -0
  52. package/src/components/connectycube-ui/chat-input.tsx +174 -0
  53. package/src/components/dialog-item.tsx +1 -1
  54. package/src/components/dialogs-list.tsx +84 -0
  55. package/src/components/dismiss-layer.tsx +1 -1
  56. package/src/components/file-picker.tsx +3 -3
  57. package/src/components/placeholder-text.tsx +5 -1
  58. package/src/components/quick-actions.tsx +74 -0
  59. package/src/components/search.tsx +1 -1
  60. package/src/components/status-call.tsx +23 -0
  61. package/src/components/stream-view.tsx +8 -8
  62. package/src/index.ts +17 -2
  63. package/dist/types/components/call-message.d.ts +0 -17
  64. package/dist/types/components/call-message.d.ts.map +0 -1
  65. package/dist/types/components/chat-message.d.ts +0 -30
  66. package/dist/types/components/chat-message.d.ts.map +0 -1
  67. package/gen/components/call-message.jsx +0 -62
  68. package/src/components/call-message.tsx +0 -75
  69. 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 };