@webinex/chatify 2.0.0-alpha13 → 2.0.0-alpha14

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 (143) hide show
  1. package/dist/{Chatify-CwAfN1wu.js → Chatify-CP2jgo8d.js} +191 -118
  2. package/dist/Chatify-CP2jgo8d.js.map +1 -0
  3. package/dist/Chatify.css +28 -0
  4. package/dist/audit.js +3 -2
  5. package/dist/audit.js.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/types/audit/index.d.ts +17 -15
  8. package/dist/types/ui/Chat/ChatContext.d.ts +2 -0
  9. package/dist/types/ui/Chat/ChatPanel.d.ts +7 -0
  10. package/dist/types/ui/Chat/ChatView.d.ts +4 -2
  11. package/dist/types/ui/ChatGroup/ChatGroupContext.d.ts +4 -1
  12. package/dist/types/ui/ChatGroup/ChatGroupPanel.d.ts +21 -2
  13. package/dist/types/ui/Conversation/Conversation.d.ts +1 -0
  14. package/dist/types/ui/Conversation/ConversationContext.d.ts +1 -0
  15. package/dist/types/ui/Conversation/ConversationHeader.d.ts +4 -1
  16. package/dist/types/ui/localizer.d.ts +4 -1
  17. package/dist/types/ui/useCompact.d.ts +4 -0
  18. package/package.json +81 -81
  19. package/src/audit/AuditChatList.tsx +25 -25
  20. package/src/audit/AuditConversationPanel.tsx +49 -48
  21. package/src/audit/AuditPanel.tsx +76 -76
  22. package/src/audit/AuditPanelCustomizeValue.ts +11 -11
  23. package/src/audit/AuditSearch.tsx +89 -89
  24. package/src/audit/AuditSearchValue.tsx +42 -42
  25. package/src/audit/auditApi.tsx +113 -113
  26. package/src/audit/index.d.ts +18 -18
  27. package/src/audit/index.tsx +28 -28
  28. package/src/audit/styles.scss +72 -72
  29. package/src/core/api/api.ts +675 -675
  30. package/src/core/api/baseApi.ts +38 -38
  31. package/src/core/api/index.ts +1 -1
  32. package/src/core/client.ts +298 -298
  33. package/src/core/constants.ts +1 -1
  34. package/src/core/debounce.ts +90 -90
  35. package/src/core/index.ts +4 -4
  36. package/src/core/types.tsx +182 -182
  37. package/src/index.ts +2 -2
  38. package/src/styles/aside.scss +34 -26
  39. package/src/styles/chat-list.scss +138 -138
  40. package/src/styles/chat.scss +11 -11
  41. package/src/styles/conversation.scss +199 -200
  42. package/src/styles/index.scss +227 -220
  43. package/src/styles/input.scss +148 -148
  44. package/src/styles/keyframes.scss +14 -14
  45. package/src/styles/members.scss +30 -13
  46. package/src/styles/mixins.scss +38 -25
  47. package/src/styles/variables.scss +13 -13
  48. package/src/ui/Chat/ChatContext.tsx +32 -30
  49. package/src/ui/Chat/ChatEditableHeaderName.tsx +63 -63
  50. package/src/ui/Chat/ChatHeaderActions.tsx +19 -19
  51. package/src/ui/Chat/ChatPanel.tsx +46 -30
  52. package/src/ui/Chat/ChatView.tsx +122 -115
  53. package/src/ui/Chat/Members/ChatMembersButton.tsx +9 -9
  54. package/src/ui/Chat/Members/ChatMembersPanel.tsx +128 -112
  55. package/src/ui/Chat/Members/ChatMembersPreview.tsx +25 -25
  56. package/src/ui/Chat/Members/index.ts +13 -13
  57. package/src/ui/Chat/index.ts +6 -6
  58. package/src/ui/ChatGroup/AutoReply/AutoReplyButton.tsx +21 -21
  59. package/src/ui/ChatGroup/AutoReply/AutoReplyForm.tsx +50 -50
  60. package/src/ui/ChatGroup/AutoReply/AutoReplyPanel.tsx +94 -94
  61. package/src/ui/ChatGroup/AutoReply/AutoReplyPeriodInput.tsx +22 -22
  62. package/src/ui/ChatGroup/AutoReply/AutoReplyTextInput.tsx +22 -22
  63. package/src/ui/ChatGroup/AutoReply/index.ts +19 -19
  64. package/src/ui/ChatGroup/ChatGroupContext.tsx +63 -61
  65. package/src/ui/ChatGroup/ChatGroupPanel.tsx +110 -75
  66. package/src/ui/ChatGroup/Create/CreateChatButton.tsx +15 -15
  67. package/src/ui/ChatGroup/Create/CreateChatForm.tsx +36 -36
  68. package/src/ui/ChatGroup/Create/CreateChatMemberInput.tsx +65 -65
  69. package/src/ui/ChatGroup/Create/CreateChatNameInput.tsx +25 -25
  70. package/src/ui/ChatGroup/Create/CreateChatPanel.tsx +45 -45
  71. package/src/ui/ChatGroup/Create/index.ts +19 -19
  72. package/src/ui/ChatGroup/Layout/ChatGroupActions.tsx +15 -15
  73. package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +12 -12
  74. package/src/ui/ChatGroup/Layout/ChatGroupBody.tsx +17 -10
  75. package/src/ui/ChatGroup/Layout/ChatGroupFooter.tsx +3 -3
  76. package/src/ui/ChatGroup/Layout/ChatGroupHeader.tsx +5 -5
  77. package/src/ui/ChatGroup/Layout/ChatGroupMain.tsx +21 -19
  78. package/src/ui/ChatGroup/Layout/index.ts +22 -22
  79. package/src/ui/ChatGroup/List/ChatListPanel.tsx +28 -28
  80. package/src/ui/ChatGroup/List/index.ts +8 -8
  81. package/src/ui/ChatGroup/index.ts +6 -6
  82. package/src/ui/Chatify.tsx +15 -15
  83. package/src/ui/Conversation/Conversation.tsx +96 -92
  84. package/src/ui/Conversation/ConversationActions.tsx +12 -12
  85. package/src/ui/Conversation/ConversationBody.tsx +28 -28
  86. package/src/ui/Conversation/ConversationContext.ts +31 -30
  87. package/src/ui/Conversation/ConversationHeader.tsx +35 -19
  88. package/src/ui/Conversation/ConversationName.tsx +7 -7
  89. package/src/ui/Conversation/InputBox/InputBox.tsx +126 -126
  90. package/src/ui/Conversation/InputBox/InputBoxFile.tsx +38 -38
  91. package/src/ui/Conversation/InputBox/InputBoxFileList.tsx +21 -21
  92. package/src/ui/Conversation/InputBox/InputFilesBox.tsx +78 -78
  93. package/src/ui/Conversation/InputBox/InputSubmitButtonBox.tsx +26 -26
  94. package/src/ui/Conversation/InputBox/InputTextBox.tsx +63 -61
  95. package/src/ui/Conversation/InputBox/index.ts +23 -23
  96. package/src/ui/Conversation/Message/MessageAuthor.tsx +13 -13
  97. package/src/ui/Conversation/Message/MessageBox.tsx +20 -20
  98. package/src/ui/Conversation/Message/MessageContent.tsx +15 -15
  99. package/src/ui/Conversation/Message/MessageFile.tsx +54 -54
  100. package/src/ui/Conversation/Message/MessageFileList.tsx +14 -14
  101. package/src/ui/Conversation/Message/MessageInfoBox.tsx +28 -28
  102. package/src/ui/Conversation/Message/MessageRow.tsx +28 -28
  103. package/src/ui/Conversation/Message/MessageText.tsx +7 -7
  104. package/src/ui/Conversation/Message/index.ts +28 -28
  105. package/src/ui/Conversation/NextObserver/NextMessagesObserver.tsx +47 -47
  106. package/src/ui/Conversation/NextObserver/index.ts +1 -1
  107. package/src/ui/Conversation/ReadObserver/MessageReadObserver.tsx +49 -49
  108. package/src/ui/Conversation/ReadObserver/index.ts +1 -1
  109. package/src/ui/Conversation/SendingMessage/SendingMessageBox.tsx +16 -16
  110. package/src/ui/Conversation/SendingMessage/SendingMessageContent.tsx +13 -13
  111. package/src/ui/Conversation/SendingMessage/SendingMessageInfoBox.tsx +13 -13
  112. package/src/ui/Conversation/SendingMessage/SendingMessageText.tsx +7 -7
  113. package/src/ui/Conversation/SendingMessage/index.ts +16 -16
  114. package/src/ui/Conversation/SystemMessage/SystemMessageBox.tsx +20 -20
  115. package/src/ui/Conversation/SystemMessage/SystemMessageRow.tsx +28 -28
  116. package/src/ui/Conversation/SystemMessage/index.ts +10 -10
  117. package/src/ui/Conversation/index.ts +13 -13
  118. package/src/ui/Thread/ThreadActions.tsx +22 -22
  119. package/src/ui/Thread/ThreadContext.ts +13 -13
  120. package/src/ui/Thread/ThreadPanel.tsx +128 -127
  121. package/src/ui/Thread/index.tsx +3 -3
  122. package/src/ui/color.ts +20 -20
  123. package/src/ui/common/Avatar.tsx +20 -20
  124. package/src/ui/common/ChatList/ChatList.tsx +83 -84
  125. package/src/ui/common/ChatList/ChatListItemAvatar.tsx +22 -22
  126. package/src/ui/common/ChatList/ChatListItemBox.tsx +32 -32
  127. package/src/ui/common/ChatList/ChatListItemLastMessage.tsx +15 -15
  128. package/src/ui/common/ChatList/ChatListItemLastMessageAuthor.tsx +15 -15
  129. package/src/ui/common/ChatList/ChatListItemLastMessageContent.tsx +21 -21
  130. package/src/ui/common/ChatList/ChatListItemLastMessageSentAt.tsx +22 -22
  131. package/src/ui/common/ChatList/ChatListItemName.tsx +8 -8
  132. package/src/ui/common/ChatList/ChatListItemUnreadCount.tsx +12 -12
  133. package/src/ui/common/ChatList/ChatListValue.ts +9 -9
  134. package/src/ui/common/ChatList/index.ts +32 -32
  135. package/src/ui/common/Icon.tsx +48 -48
  136. package/src/ui/common/MessageSkeleton.tsx +20 -20
  137. package/src/ui/common/index.ts +14 -14
  138. package/src/ui/customize.tsx +51 -51
  139. package/src/ui/index.ts +11 -11
  140. package/src/ui/localizer.tsx +148 -137
  141. package/src/ui/useCompact.tsx +32 -0
  142. package/src/ui/useFormatter.tsx +17 -17
  143. package/dist/Chatify-CwAfN1wu.js.map +0 -1
@@ -1,148 +1,148 @@
1
- @use './variables.scss' as vars;
2
- @use './mixins.scss' as mixins;
3
-
4
- @keyframes wxchtf-add-files-animate {
5
- 15% {
6
- transform: scale(70%);
7
- }
8
-
9
- 50% {
10
- transform: scale(120%);
11
- }
12
- }
13
-
14
- @mixin iconBtn {
15
- flex: none;
16
- display: flex;
17
- padding: 0 1rem;
18
- align-items: flex-end;
19
-
20
- .ant-btn.ant-btn-icon-only .anticon {
21
- font-size: 1.5rem;
22
- }
23
- }
24
-
25
- .wxchtf-input-form {
26
- flex: none;
27
- max-height: 300px;
28
- display: flex;
29
- flex-flow: column nowrap;
30
- margin: 12px 20px 20px 20px;
31
-
32
- .wxchtf-input-box {
33
- flex: none;
34
- padding: 8px;
35
- max-width: vars.$messageBoxWidth;
36
- width: 100%;
37
- margin: auto;
38
- background: rgb(245, 245, 245);
39
- border-radius: 25px;
40
-
41
- .wxchtf-input-box-row {
42
- display: flex;
43
- flex-flow: row nowrap;
44
- }
45
-
46
- .wxchtf-add-files-box,
47
- .wxchtf-submit-btn-box {
48
- align-items: center;
49
-
50
- button {
51
- width: unset;
52
- }
53
-
54
- svg {
55
- font-size: 18px;
56
- color: rgba(14, 15, 23, 0.25);
57
- }
58
- }
59
-
60
- .wxchtf-text-input-box {
61
- flex: auto;
62
- margin-left: 16px;
63
- margin-right: 16px;
64
-
65
- textarea {
66
- resize: none;
67
- border: none;
68
- outline: none;
69
- box-shadow: none;
70
- background: transparent;
71
- padding-inline: 0;
72
- font-size: 13px;
73
- line-height: 26px;
74
-
75
- @include mixins.scrollbar();
76
- }
77
- }
78
-
79
- .wxchtf-submit-btn-box {
80
- @include iconBtn();
81
- margin-left: 1rem;
82
- }
83
- }
84
- }
85
-
86
- .wxchtf-add-files-box {
87
- @include iconBtn();
88
- flex: none;
89
-
90
- .wxchtf-add-files-added-btn {
91
- margin-left: 0.5rem;
92
- width: 1rem;
93
-
94
- .ant-btn-icon {
95
- font-size: 1.1rem;
96
- font-weight: 600;
97
- color: vars.$strokeColor;
98
- }
99
-
100
- &.active {
101
- animation: wxchtf-add-files-animate 2s ease-out infinite;
102
- }
103
- }
104
- }
105
-
106
- .wxchtf-file-list-box {
107
- margin-bottom: 1rem;
108
-
109
- .wxchtf-file-list {
110
- @include mixins.scrollbar($hide: true);
111
-
112
- display: flex;
113
- flex-flow: row wrap;
114
- gap: 1rem;
115
- padding: 0.5rem;
116
- max-height: 100px;
117
- overflow-y: auto;
118
- overflow-x: visible;
119
- }
120
-
121
- .wxchtf-file {
122
- display: inline-flex;
123
- flex-flow: row nowrap;
124
- background-color: white;
125
- padding: 1rem;
126
- border-radius: 20px;
127
- box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
128
- align-items: center;
129
-
130
- .wxchtf-file-info {
131
- margin-right: 2rem;
132
- min-width: 0;
133
- max-width: 200px;
134
- }
135
-
136
- .wxchtf-file-name {
137
- font-size: 0.9rem;
138
- overflow: hidden;
139
- white-space: nowrap;
140
- text-overflow: ellipsis;
141
- }
142
-
143
- .wxchtf-file-size {
144
- color: vars.$strokeColor;
145
- font-size: 0.8rem;
146
- }
147
- }
148
- }
1
+ @use './variables.scss' as vars;
2
+ @use './mixins.scss' as mixins;
3
+
4
+ @keyframes wxchtf-add-files-animate {
5
+ 15% {
6
+ transform: scale(70%);
7
+ }
8
+
9
+ 50% {
10
+ transform: scale(120%);
11
+ }
12
+ }
13
+
14
+ @mixin iconBtn {
15
+ flex: none;
16
+ display: flex;
17
+ padding: 0 1rem;
18
+ align-items: flex-end;
19
+
20
+ .ant-btn.ant-btn-icon-only .anticon {
21
+ font-size: 1.5rem;
22
+ }
23
+ }
24
+
25
+ .wxchtf-input-form {
26
+ flex: none;
27
+ max-height: 300px;
28
+ display: flex;
29
+ flex-flow: column nowrap;
30
+ margin: 12px 20px 20px 20px;
31
+
32
+ .wxchtf-input-box {
33
+ flex: none;
34
+ padding: 8px;
35
+ max-width: vars.$messageBoxWidth;
36
+ width: 100%;
37
+ margin: auto;
38
+ background: rgb(245, 245, 245);
39
+ border-radius: 25px;
40
+
41
+ .wxchtf-input-box-row {
42
+ display: flex;
43
+ flex-flow: row nowrap;
44
+ }
45
+
46
+ .wxchtf-add-files-box,
47
+ .wxchtf-submit-btn-box {
48
+ align-items: center;
49
+
50
+ button {
51
+ width: unset;
52
+ }
53
+
54
+ svg {
55
+ font-size: 18px;
56
+ color: rgba(14, 15, 23, 0.25);
57
+ }
58
+ }
59
+
60
+ .wxchtf-text-input-box {
61
+ flex: auto;
62
+ margin-left: 16px;
63
+ margin-right: 16px;
64
+
65
+ textarea {
66
+ resize: none;
67
+ border: none;
68
+ outline: none;
69
+ box-shadow: none;
70
+ background: transparent;
71
+ padding-inline: 0;
72
+ font-size: 13px;
73
+ line-height: 26px;
74
+
75
+ @include mixins.scrollbar();
76
+ }
77
+ }
78
+
79
+ .wxchtf-submit-btn-box {
80
+ @include iconBtn();
81
+ margin-left: 1rem;
82
+ }
83
+ }
84
+ }
85
+
86
+ .wxchtf-add-files-box {
87
+ @include iconBtn();
88
+ flex: none;
89
+
90
+ .wxchtf-add-files-added-btn {
91
+ margin-left: 0.5rem;
92
+ width: 1rem;
93
+
94
+ .ant-btn-icon {
95
+ font-size: 1.1rem;
96
+ font-weight: 600;
97
+ color: vars.$strokeColor;
98
+ }
99
+
100
+ &.active {
101
+ animation: wxchtf-add-files-animate 2s ease-out infinite;
102
+ }
103
+ }
104
+ }
105
+
106
+ .wxchtf-file-list-box {
107
+ margin-bottom: 1rem;
108
+
109
+ .wxchtf-file-list {
110
+ @include mixins.scrollbar($hide: true);
111
+
112
+ display: flex;
113
+ flex-flow: row wrap;
114
+ gap: 1rem;
115
+ padding: 0.5rem;
116
+ max-height: 100px;
117
+ overflow-y: auto;
118
+ overflow-x: visible;
119
+ }
120
+
121
+ .wxchtf-file {
122
+ display: inline-flex;
123
+ flex-flow: row nowrap;
124
+ background-color: white;
125
+ padding: 1rem;
126
+ border-radius: 20px;
127
+ box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
128
+ align-items: center;
129
+
130
+ .wxchtf-file-info {
131
+ margin-right: 2rem;
132
+ min-width: 0;
133
+ max-width: 200px;
134
+ }
135
+
136
+ .wxchtf-file-name {
137
+ font-size: 0.9rem;
138
+ overflow: hidden;
139
+ white-space: nowrap;
140
+ text-overflow: ellipsis;
141
+ }
142
+
143
+ .wxchtf-file-size {
144
+ color: vars.$strokeColor;
145
+ font-size: 0.8rem;
146
+ }
147
+ }
148
+ }
@@ -1,14 +1,14 @@
1
- @keyframes fadeInFromNone {
2
- 0% {
3
- display: none;
4
- opacity: 0;
5
- }
6
-
7
- 1% {
8
- opacity: 0;
9
- }
10
-
11
- 100% {
12
- opacity: 1;
13
- }
14
- }
1
+ @keyframes fadeInFromNone {
2
+ 0% {
3
+ display: none;
4
+ opacity: 0;
5
+ }
6
+
7
+ 1% {
8
+ opacity: 0;
9
+ }
10
+
11
+ 100% {
12
+ opacity: 1;
13
+ }
14
+ }
@@ -1,13 +1,30 @@
1
- .wxchtf-chatify {
2
- .wxchtf-chat-members-panel {
3
- min-width: 300px;
4
- box-shadow: -4px 0px 20px -5px #0cd9e214, -2px 1px 12px #006e720f;
5
-
6
- .wxchtf-chat-members-list {
7
- .wxchtf-chat-members-list-item {
8
- padding-inline: 1rem;
9
- border-block-end: none;
10
- }
11
- }
12
- }
13
- }
1
+ @use './mixins.scss' as mixins;
2
+
3
+ .wxchtf-chatify.--compact {
4
+ .wxchtf-chat-members-panel {
5
+ width: 100%;
6
+ box-shadow: none;
7
+ }
8
+ }
9
+
10
+ .wxchtf-chatify {
11
+ .wxchtf-chat-members-panel {
12
+ min-width: 300px;
13
+ box-shadow: -4px 0px 20px -5px #0cd9e214, -2px 1px 12px #006e720f;
14
+
15
+ .wxchtf-chat-members-list {
16
+ .wxchtf-chat-members-list-item {
17
+ padding-inline: 1rem;
18
+ border-block-end: none;
19
+ }
20
+ }
21
+
22
+ .wxchtf-chat-members-panel-header {
23
+ @include mixins.header();
24
+
25
+ .wxchtf-chat-members-panel-title {
26
+ @include mixins.title();
27
+ }
28
+ }
29
+ }
30
+ }
@@ -1,25 +1,38 @@
1
- @mixin scrollbar($hide: false) {
2
- @if ($hide) {
3
- scrollbar-width: none;
4
- -ms-overflow-style: none;
5
- } @else {
6
- &::-webkit-scrollbar {
7
- width: 8px;
8
- height: 8px;
9
- }
10
-
11
- &::-webkit-scrollbar-track {
12
- background-color: #f1f1f1;
13
- }
14
-
15
- &::-webkit-scrollbar-thumb {
16
- background-color: #dfdfdf;
17
- }
18
- }
19
- }
20
-
21
- @mixin avatarSize($size) {
22
- width: $size;
23
- height: $size;
24
- line-height: $size - 2px;
25
- }
1
+ @mixin scrollbar($hide: false) {
2
+ @if ($hide) {
3
+ scrollbar-width: none;
4
+ -ms-overflow-style: none;
5
+ } @else {
6
+ &::-webkit-scrollbar {
7
+ width: 8px;
8
+ height: 8px;
9
+ }
10
+
11
+ &::-webkit-scrollbar-track {
12
+ background-color: #f1f1f1;
13
+ }
14
+
15
+ &::-webkit-scrollbar-thumb {
16
+ background-color: #dfdfdf;
17
+ }
18
+ }
19
+ }
20
+
21
+ @mixin avatarSize($size) {
22
+ width: $size;
23
+ height: $size;
24
+ line-height: $size - 2px;
25
+ }
26
+
27
+ @mixin header() {
28
+ padding: 15px 20px;
29
+ line-height: 24px;
30
+ z-index: 2;
31
+ box-shadow: 0px 2px 4px 0px rgba(88, 99, 107, 0.04), 0px 1px 9px -1px rgba(88, 99, 107, 0.04),
32
+ 0px 1px 2px 0px rgba(88, 99, 107, 0.06);
33
+ }
34
+
35
+ @mixin title() {
36
+ font-weight: 600;
37
+ font-size: 16px;
38
+ }
@@ -1,13 +1,13 @@
1
- $borderColor: #ddd;
2
- $border: 1px solid #ddd;
3
- $background: white;
4
- $strokeColor: #0e0f1740;
5
- $radius: 24px;
6
- $messageBackground: #f5f5f5;
7
- $myMessageBackground: #e4f7f7;
8
- $unreadCountBackground: #ffa726;
9
- $primaryColor: #0cd9e2;
10
- $avatarSize: 40px;
11
- $messageBorderRadius: 10px;
12
- $messageBoxWidth: 1110px;
13
- $linkColor: #1677ff;
1
+ $borderColor: #ddd;
2
+ $border: 1px solid #ddd;
3
+ $background: white;
4
+ $strokeColor: #0e0f1740;
5
+ $radius: 24px;
6
+ $messageBackground: #f5f5f5;
7
+ $myMessageBackground: #e4f7f7;
8
+ $unreadCountBackground: #ffa726;
9
+ $primaryColor: #0cd9e2;
10
+ $avatarSize: 40px;
11
+ $messageBorderRadius: 10px;
12
+ $messageBoxWidth: 1110px;
13
+ $linkColor: #1677ff;
@@ -1,30 +1,32 @@
1
- import React, { PropsWithChildren, useContext, useMemo, useState } from 'react';
2
-
3
- export interface ChatContext {
4
- id: string;
5
- showMembers: boolean;
6
- onShowMembers: (value: boolean) => void;
7
- }
8
-
9
- const ChatReactContext = React.createContext<ChatContext>(null!);
10
-
11
- export function useChatContext() {
12
- return useContext(ChatReactContext);
13
- }
14
-
15
- // eslint-disable-next-line @typescript-eslint/no-redeclare
16
- export function ChatContext(props: PropsWithChildren<{ id: string }>) {
17
- const { id, children } = props;
18
- const [showMembers, onShowMembers] = useState(false);
19
-
20
- const value = useMemo<ChatContext>(
21
- () => ({
22
- id,
23
- showMembers,
24
- onShowMembers,
25
- }),
26
- [id, showMembers],
27
- );
28
-
29
- return <ChatReactContext.Provider value={value}>{children}</ChatReactContext.Provider>;
30
- }
1
+ import React, { PropsWithChildren, useContext, useMemo, useState } from 'react';
2
+
3
+ export interface ChatContext {
4
+ id: string;
5
+ compact: boolean;
6
+ showMembers: boolean;
7
+ onShowMembers: (value: boolean) => void;
8
+ }
9
+
10
+ const ChatReactContext = React.createContext<ChatContext>(null!);
11
+
12
+ export function useChatContext() {
13
+ return useContext(ChatReactContext);
14
+ }
15
+
16
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
17
+ export function ChatContext(props: PropsWithChildren<{ id: string; compact: boolean }>) {
18
+ const { id, children, compact } = props;
19
+ const [showMembers, onShowMembers] = useState(false);
20
+
21
+ const value = useMemo<ChatContext>(
22
+ () => ({
23
+ id,
24
+ showMembers,
25
+ onShowMembers,
26
+ compact,
27
+ }),
28
+ [id, showMembers, compact],
29
+ );
30
+
31
+ return <ChatReactContext.Provider value={value}>{children}</ChatReactContext.Provider>;
32
+ }
@@ -1,63 +1,63 @@
1
- import { Input, Tooltip } from 'antd';
2
- import { chatifyApi } from '../../core';
3
- import { customize } from '../customize';
4
- import { useEffect, useState } from 'react';
5
- import { isHotkey } from 'is-hotkey';
6
- import { useConversation } from '../Conversation';
7
-
8
- const isEscape = isHotkey('escape');
9
- const isEnter = isHotkey('enter');
10
-
11
- function useUpdateChatName(id: string, value: string) {
12
- const [updateChatName] = chatifyApi.useUpdateChatNameMutation();
13
- return () => updateChatName({ id, name: value });
14
- }
15
-
16
- export const ChatEditableHeaderName = customize('ChatEditableHeaderName', () => {
17
- const { id, name, active } = useConversation();
18
- const [editNameValue, setEditNameValue] = useState('');
19
- const [edit, setEdit] = useState(false);
20
- const updateChatName = useUpdateChatName(id, editNameValue);
21
-
22
- useEffect(() => {
23
- if (edit) {
24
- setEditNameValue(name ?? '');
25
- }
26
- }, [edit, name]);
27
-
28
- if (!active) {
29
- return <span className="wxchtf-conversation-name">{name}</span>;
30
- }
31
-
32
- if (edit) {
33
- return (
34
- <Tooltip defaultOpen title="Press Enter to save new chat name or Escape to cancel editing">
35
- <Input
36
- value={editNameValue}
37
- onChange={(e) => setEditNameValue(e.target.value)}
38
- onBlur={() => setEdit(false)}
39
- onKeyDown={(e) => {
40
- if (isEscape(e)) {
41
- setEdit(false);
42
- } else if (isEnter(e)) {
43
- setEdit(false);
44
-
45
- if (editNameValue !== name && editNameValue.trim() !== '') {
46
- updateChatName();
47
- }
48
- }
49
- }}
50
- autoFocus
51
- />
52
- </Tooltip>
53
- );
54
- }
55
-
56
- return (
57
- <Tooltip title="Click to edit name...">
58
- <span className="wxchtf-conversation-name --editable" onClick={() => setEdit(true)}>
59
- {name}
60
- </span>
61
- </Tooltip>
62
- );
63
- });
1
+ import { Input, Tooltip } from 'antd';
2
+ import { chatifyApi } from '../../core';
3
+ import { customize } from '../customize';
4
+ import { useEffect, useState } from 'react';
5
+ import { isHotkey } from 'is-hotkey';
6
+ import { useConversation } from '../Conversation';
7
+
8
+ const isEscape = isHotkey('escape');
9
+ const isEnter = isHotkey('enter');
10
+
11
+ function useUpdateChatName(id: string, value: string) {
12
+ const [updateChatName] = chatifyApi.useUpdateChatNameMutation();
13
+ return () => updateChatName({ id, name: value });
14
+ }
15
+
16
+ export const ChatEditableHeaderName = customize('ChatEditableHeaderName', () => {
17
+ const { id, name, active } = useConversation();
18
+ const [editNameValue, setEditNameValue] = useState('');
19
+ const [edit, setEdit] = useState(false);
20
+ const updateChatName = useUpdateChatName(id, editNameValue);
21
+
22
+ useEffect(() => {
23
+ if (edit) {
24
+ setEditNameValue(name ?? '');
25
+ }
26
+ }, [edit, name]);
27
+
28
+ if (!active) {
29
+ return <span className="wxchtf-conversation-name">{name}</span>;
30
+ }
31
+
32
+ if (edit) {
33
+ return (
34
+ <Tooltip defaultOpen title="Press Enter to save new chat name or Escape to cancel editing">
35
+ <Input
36
+ value={editNameValue}
37
+ onChange={(e) => setEditNameValue(e.target.value)}
38
+ onBlur={() => setEdit(false)}
39
+ onKeyDown={(e) => {
40
+ if (isEscape(e)) {
41
+ setEdit(false);
42
+ } else if (isEnter(e)) {
43
+ setEdit(false);
44
+
45
+ if (editNameValue !== name && editNameValue.trim() !== '') {
46
+ updateChatName();
47
+ }
48
+ }
49
+ }}
50
+ autoFocus
51
+ />
52
+ </Tooltip>
53
+ );
54
+ }
55
+
56
+ return (
57
+ <Tooltip title="Click to edit name...">
58
+ <span className="wxchtf-conversation-name --editable" onClick={() => setEdit(true)}>
59
+ {name}
60
+ </span>
61
+ </Tooltip>
62
+ );
63
+ });