@ermis-network/ermis-chat-react 2.0.0 → 2.0.1
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/README.md +144 -0
- package/dist/index.cjs +5087 -11279
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +632 -152
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +273 -9
- package/dist/index.d.ts +273 -9
- package/dist/index.mjs +5085 -11295
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/Channel.tsx +0 -3
- package/src/components/ChannelActions.tsx +6 -1
- package/src/components/ChannelHeader.tsx +8 -32
- package/src/components/ChannelInfo/AddMemberModal.tsx +7 -1
- package/src/components/ChannelInfo/ChannelInfo.tsx +82 -2
- package/src/components/ChannelInfo/EditChannelModal.tsx +2 -2
- package/src/components/ChannelInfo/MediaGridItem.tsx +215 -78
- package/src/components/ChannelInfo/useChannelInfoTabs.tsx +170 -129
- package/src/components/ChannelList.tsx +72 -13
- package/src/components/CreateChannelModal.tsx +131 -12
- package/src/components/FilesPreview.tsx +8 -12
- package/src/components/FlatTopicGroupItem.tsx +27 -16
- package/src/components/ForwardMessageModal.tsx +11 -3
- package/src/components/MediaLightbox.tsx +444 -304
- package/src/components/MessageActionsBox.tsx +2 -0
- package/src/components/MessageInput.tsx +41 -12
- package/src/components/MessageItem.tsx +70 -25
- package/src/components/MessageQuickReactions.tsx +131 -128
- package/src/components/MessageReactions.tsx +47 -2
- package/src/components/MessageRenderers.tsx +1030 -433
- package/src/components/PinnedMessages.tsx +40 -12
- package/src/components/QuotedMessagePreview.tsx +99 -8
- package/src/components/RecoveryPin/RecoveryPin.tsx +279 -0
- package/src/components/RecoveryPin/index.ts +19 -0
- package/src/components/TopicList.tsx +20 -5
- package/src/components/TypingIndicator.tsx +3 -3
- package/src/components/UserPicker.tsx +26 -25
- package/src/components/VirtualMessageList.tsx +345 -125
- package/src/context/ChatProvider.tsx +27 -1
- package/src/hooks/useChannelListUpdates.ts +22 -1
- package/src/hooks/useChannelMessages.ts +338 -51
- package/src/hooks/useChannelRowUpdates.ts +18 -6
- package/src/hooks/useChatUser.ts +9 -1
- package/src/hooks/useE2eeAttachmentRenderer.ts +204 -0
- package/src/hooks/useE2eeFileUpload.ts +38 -0
- package/src/hooks/useFileUpload.ts +25 -5
- package/src/hooks/useForwardMessage.ts +210 -13
- package/src/hooks/useLoadMessages.ts +16 -4
- package/src/hooks/useMentions.ts +60 -6
- package/src/hooks/useMessageActions.ts +14 -8
- package/src/hooks/useMessageSend.ts +64 -12
- package/src/hooks/usePendingE2eeSends.ts +29 -0
- package/src/hooks/useRecoveryPin.ts +287 -0
- package/src/hooks/useScrollToMessage.ts +29 -4
- package/src/hooks/useTopicGroupUpdates.ts +49 -11
- package/src/index.ts +23 -0
- package/src/messageTypeUtils.ts +14 -0
- package/src/styles/_channel-info.css +9 -0
- package/src/styles/_channel-list.css +37 -14
- package/src/styles/_media-lightbox.css +36 -3
- package/src/styles/_message-bubble.css +381 -41
- package/src/styles/_message-input.css +8 -0
- package/src/styles/_message-list.css +67 -10
- package/src/styles/_message-quick-reactions.css +101 -59
- package/src/styles/_message-reactions.css +18 -32
- package/src/styles/_recovery-pin.css +97 -0
- package/src/styles/_tokens.css +5 -5
- package/src/styles/_typing-indicator.css +23 -13
- package/src/styles/index.css +1 -0
- package/src/types.ts +115 -1
- package/src/utils/avatarColors.ts +1 -1
- package/src/utils.ts +38 -18
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { MessageReactionsProps } from '../types';
|
|
3
3
|
|
|
4
4
|
import { useChatClient } from '../hooks/useChatClient';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
5
6
|
|
|
6
7
|
const defaultReactionEmojiMap: Record<string, string> = {
|
|
7
8
|
like: '👍',
|
|
@@ -11,6 +12,33 @@ const defaultReactionEmojiMap: Record<string, string> = {
|
|
|
11
12
|
fire: '🔥',
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
const ReactionTooltip = ({ text, rect }: { text: string; rect: DOMRect }) => {
|
|
16
|
+
if (!text || !rect) return null;
|
|
17
|
+
return createPortal(
|
|
18
|
+
<div style={{
|
|
19
|
+
position: 'fixed',
|
|
20
|
+
top: rect.top - 6,
|
|
21
|
+
left: rect.left + rect.width / 2,
|
|
22
|
+
transform: 'translate(-50%, -100%)',
|
|
23
|
+
backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
|
24
|
+
color: '#fff',
|
|
25
|
+
padding: '4px 8px',
|
|
26
|
+
borderRadius: '6px',
|
|
27
|
+
fontSize: '11px',
|
|
28
|
+
whiteSpace: 'pre-wrap',
|
|
29
|
+
wordBreak: 'break-word',
|
|
30
|
+
width: 'max-content',
|
|
31
|
+
maxWidth: '200px',
|
|
32
|
+
textAlign: 'center',
|
|
33
|
+
zIndex: 999999,
|
|
34
|
+
pointerEvents: 'none'
|
|
35
|
+
}}>
|
|
36
|
+
{text}
|
|
37
|
+
</div>,
|
|
38
|
+
document.body
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
14
42
|
export const MessageReactions: React.FC<MessageReactionsProps> = React.memo(({
|
|
15
43
|
reactionCounts,
|
|
16
44
|
ownReactions,
|
|
@@ -21,6 +49,19 @@ export const MessageReactions: React.FC<MessageReactionsProps> = React.memo(({
|
|
|
21
49
|
}) => {
|
|
22
50
|
const { client } = useChatClient();
|
|
23
51
|
const currentUserId = client?.userID;
|
|
52
|
+
const [hoveredTooltip, setHoveredTooltip] = React.useState<{text: string, rect: DOMRect} | null>(null);
|
|
53
|
+
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
if (hoveredTooltip) {
|
|
56
|
+
const handleHide = () => setHoveredTooltip(null);
|
|
57
|
+
window.addEventListener('scroll', handleHide, true);
|
|
58
|
+
window.addEventListener('resize', handleHide);
|
|
59
|
+
return () => {
|
|
60
|
+
window.removeEventListener('scroll', handleHide, true);
|
|
61
|
+
window.removeEventListener('resize', handleHide);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}, [hoveredTooltip]);
|
|
24
65
|
|
|
25
66
|
if (!reactionCounts || Object.keys(reactionCounts).length === 0) return null;
|
|
26
67
|
|
|
@@ -49,15 +90,19 @@ export const MessageReactions: React.FC<MessageReactionsProps> = React.memo(({
|
|
|
49
90
|
className={`ermis-message-reactions__item ${
|
|
50
91
|
isOwn ? 'ermis-message-reactions__item--active' : ''
|
|
51
92
|
}`}
|
|
52
|
-
|
|
93
|
+
onMouseEnter={(e) => {
|
|
94
|
+
setHoveredTooltip({ text: tooltip, rect: e.currentTarget.getBoundingClientRect() });
|
|
95
|
+
}}
|
|
96
|
+
onMouseLeave={() => setHoveredTooltip(null)}
|
|
53
97
|
onClick={() => onClickReaction?.(type)}
|
|
54
98
|
type="button"
|
|
55
99
|
>
|
|
56
100
|
<span className="ermis-message-reactions__emoji">{emoji}</span>
|
|
57
|
-
<span className="ermis-message-reactions__count">{count}</span>
|
|
101
|
+
{count > 1 && <span className="ermis-message-reactions__count">{count}</span>}
|
|
58
102
|
</button>
|
|
59
103
|
);
|
|
60
104
|
})}
|
|
105
|
+
{hoveredTooltip && <ReactionTooltip text={hoveredTooltip.text} rect={hoveredTooltip.rect} />}
|
|
61
106
|
</div>
|
|
62
107
|
);
|
|
63
108
|
});
|