@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.
Files changed (72) hide show
  1. package/README.md +144 -0
  2. package/dist/index.cjs +5087 -11279
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.css +632 -152
  5. package/dist/index.css.map +1 -1
  6. package/dist/index.d.mts +273 -9
  7. package/dist/index.d.ts +273 -9
  8. package/dist/index.mjs +5085 -11295
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +2 -2
  11. package/src/components/Channel.tsx +0 -3
  12. package/src/components/ChannelActions.tsx +6 -1
  13. package/src/components/ChannelHeader.tsx +8 -32
  14. package/src/components/ChannelInfo/AddMemberModal.tsx +7 -1
  15. package/src/components/ChannelInfo/ChannelInfo.tsx +82 -2
  16. package/src/components/ChannelInfo/EditChannelModal.tsx +2 -2
  17. package/src/components/ChannelInfo/MediaGridItem.tsx +215 -78
  18. package/src/components/ChannelInfo/useChannelInfoTabs.tsx +170 -129
  19. package/src/components/ChannelList.tsx +72 -13
  20. package/src/components/CreateChannelModal.tsx +131 -12
  21. package/src/components/FilesPreview.tsx +8 -12
  22. package/src/components/FlatTopicGroupItem.tsx +27 -16
  23. package/src/components/ForwardMessageModal.tsx +11 -3
  24. package/src/components/MediaLightbox.tsx +444 -304
  25. package/src/components/MessageActionsBox.tsx +2 -0
  26. package/src/components/MessageInput.tsx +41 -12
  27. package/src/components/MessageItem.tsx +70 -25
  28. package/src/components/MessageQuickReactions.tsx +131 -128
  29. package/src/components/MessageReactions.tsx +47 -2
  30. package/src/components/MessageRenderers.tsx +1030 -433
  31. package/src/components/PinnedMessages.tsx +40 -12
  32. package/src/components/QuotedMessagePreview.tsx +99 -8
  33. package/src/components/RecoveryPin/RecoveryPin.tsx +279 -0
  34. package/src/components/RecoveryPin/index.ts +19 -0
  35. package/src/components/TopicList.tsx +20 -5
  36. package/src/components/TypingIndicator.tsx +3 -3
  37. package/src/components/UserPicker.tsx +26 -25
  38. package/src/components/VirtualMessageList.tsx +345 -125
  39. package/src/context/ChatProvider.tsx +27 -1
  40. package/src/hooks/useChannelListUpdates.ts +22 -1
  41. package/src/hooks/useChannelMessages.ts +338 -51
  42. package/src/hooks/useChannelRowUpdates.ts +18 -6
  43. package/src/hooks/useChatUser.ts +9 -1
  44. package/src/hooks/useE2eeAttachmentRenderer.ts +204 -0
  45. package/src/hooks/useE2eeFileUpload.ts +38 -0
  46. package/src/hooks/useFileUpload.ts +25 -5
  47. package/src/hooks/useForwardMessage.ts +210 -13
  48. package/src/hooks/useLoadMessages.ts +16 -4
  49. package/src/hooks/useMentions.ts +60 -6
  50. package/src/hooks/useMessageActions.ts +14 -8
  51. package/src/hooks/useMessageSend.ts +64 -12
  52. package/src/hooks/usePendingE2eeSends.ts +29 -0
  53. package/src/hooks/useRecoveryPin.ts +287 -0
  54. package/src/hooks/useScrollToMessage.ts +29 -4
  55. package/src/hooks/useTopicGroupUpdates.ts +49 -11
  56. package/src/index.ts +23 -0
  57. package/src/messageTypeUtils.ts +14 -0
  58. package/src/styles/_channel-info.css +9 -0
  59. package/src/styles/_channel-list.css +37 -14
  60. package/src/styles/_media-lightbox.css +36 -3
  61. package/src/styles/_message-bubble.css +381 -41
  62. package/src/styles/_message-input.css +8 -0
  63. package/src/styles/_message-list.css +67 -10
  64. package/src/styles/_message-quick-reactions.css +101 -59
  65. package/src/styles/_message-reactions.css +18 -32
  66. package/src/styles/_recovery-pin.css +97 -0
  67. package/src/styles/_tokens.css +5 -5
  68. package/src/styles/_typing-indicator.css +23 -13
  69. package/src/styles/index.css +1 -0
  70. package/src/types.ts +115 -1
  71. package/src/utils/avatarColors.ts +1 -1
  72. 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
- data-tooltip={tooltip}
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
  });