@guokit-dev/im-react 0.0.0-stage → 0.27.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.
- package/LICENSE +21 -0
- package/README.md +147 -2
- package/dist/index.cjs +3095 -0
- package/dist/index.mjs +3073 -0
- package/dist/style.css +280 -0
- package/dist/types/core/chatController.d.ts +121 -0
- package/dist/types/core/externalStore.d.ts +25 -0
- package/dist/types/core/features.d.ts +8 -0
- package/dist/types/core/format.d.ts +32 -0
- package/dist/types/core/imStore.d.ts +8 -0
- package/dist/types/core/index.d.ts +9 -0
- package/dist/types/core/media.d.ts +37 -0
- package/dist/types/core/memberCache.d.ts +31 -0
- package/dist/types/core/mention.d.ts +31 -0
- package/dist/types/core/strings.d.ts +309 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/ui/chat/ChatPage.d.ts +11 -0
- package/dist/types/ui/chat/Composer.d.ts +29 -0
- package/dist/types/ui/chat/MessageList.d.ts +17 -0
- package/dist/types/ui/chat/MessageRow.d.ts +24 -0
- package/dist/types/ui/chat/bubbles.d.ts +26 -0
- package/dist/types/ui/chat/emojis.d.ts +2 -0
- package/dist/types/ui/context.d.ts +44 -0
- package/dist/types/ui/conversation/ConversationList.d.ts +13 -0
- package/dist/types/ui/hooks.d.ts +7 -0
- package/dist/types/ui/layout/ImWorkspace.d.ts +8 -0
- package/dist/types/ui/layout/Layers.d.ts +19 -0
- package/dist/types/ui/layout/frame.d.ts +14 -0
- package/dist/types/ui/layout/useWide.d.ts +4 -0
- package/dist/types/ui/menu/Report.d.ts +7 -0
- package/dist/types/ui/navigator.d.ts +73 -0
- package/dist/types/ui/routes.d.ts +7 -0
- package/dist/types/ui/theme.d.ts +30 -0
- package/dist/types/ui/types.d.ts +44 -0
- package/dist/types/ui/viewer/ImageViewer.d.ts +6 -0
- package/dist/types/ui/viewer/VideoPlayer.d.ts +5 -0
- package/dist/types/ui/widgets/Avatar.d.ts +16 -0
- package/dist/types/ui/widgets/Icon.d.ts +32 -0
- package/dist/types/ui/widgets/Menu.d.ts +36 -0
- package/dist/types/ui/widgets/Page.d.ts +16 -0
- package/dist/types/ui/widgets/UnreadBadge.d.ts +11 -0
- package/dist/types/ui/widgets/feedback.d.ts +23 -0
- package/dist/types/ui/widgets/useFocusTrap.d.ts +2 -0
- package/package.json +54 -4
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
export interface ImUiStrings {
|
|
2
|
+
conversationsTitle: string;
|
|
3
|
+
markAllRead: string;
|
|
4
|
+
disconnected: string;
|
|
5
|
+
emptyConversations: string;
|
|
6
|
+
/** 群名为空时的兜底名称。 */
|
|
7
|
+
groupChat: string;
|
|
8
|
+
/** 会话摘要前缀:群里有人 @ 我。 */
|
|
9
|
+
atMe: string;
|
|
10
|
+
pin: string;
|
|
11
|
+
unpin: string;
|
|
12
|
+
mute: string;
|
|
13
|
+
unmute: string;
|
|
14
|
+
deleteConversation: string;
|
|
15
|
+
deleteConversationConfirm: string;
|
|
16
|
+
cancel: string;
|
|
17
|
+
confirm: string;
|
|
18
|
+
yesterday: string;
|
|
19
|
+
/** 周一到周日。 */
|
|
20
|
+
weekdays: readonly string[];
|
|
21
|
+
operationFailed: string;
|
|
22
|
+
/** 单聊标题栏副标题。 */
|
|
23
|
+
typing: string;
|
|
24
|
+
/** 已退群时替代输入框的提示。 */
|
|
25
|
+
notInGroup: string;
|
|
26
|
+
read: string;
|
|
27
|
+
unreadMark: string;
|
|
28
|
+
/** 客服机器人消息的标注。 */
|
|
29
|
+
aiGenerated: string;
|
|
30
|
+
send: string;
|
|
31
|
+
/** 被拒收(rejected)且服务端没给原因时的提示。 */
|
|
32
|
+
sendRejected: string;
|
|
33
|
+
/** 撤回、群提示里指代人:本人、单聊对方、管理员、系统。 */
|
|
34
|
+
you: string;
|
|
35
|
+
peer: string;
|
|
36
|
+
admin: string;
|
|
37
|
+
system: string;
|
|
38
|
+
/** 撤回提示,`{name}` 换成撤回人。 */
|
|
39
|
+
recalled: string;
|
|
40
|
+
/** 没有专门气泡时的兜底文字。 */
|
|
41
|
+
image: string;
|
|
42
|
+
voice: string;
|
|
43
|
+
video: string;
|
|
44
|
+
file: string;
|
|
45
|
+
location: string;
|
|
46
|
+
unsupported: string;
|
|
47
|
+
/** 群变动提示:`{op}` 操作人,`{targets}` 被操作的人(顿号连接),`{name}` 新群名。 */
|
|
48
|
+
tipCreate: string;
|
|
49
|
+
tipJoin: string;
|
|
50
|
+
tipQuit: string;
|
|
51
|
+
tipKick: string;
|
|
52
|
+
tipDismiss: string;
|
|
53
|
+
tipUpdate: string;
|
|
54
|
+
tipRename: string;
|
|
55
|
+
tipNotice: string;
|
|
56
|
+
tipAdminOn: string;
|
|
57
|
+
tipAdminOff: string;
|
|
58
|
+
tipTransfer: string;
|
|
59
|
+
tipMute: string;
|
|
60
|
+
tipUnmute: string;
|
|
61
|
+
tipOther: string;
|
|
62
|
+
/** @ 选成员面板。 */
|
|
63
|
+
mentionTitle: string;
|
|
64
|
+
search: string;
|
|
65
|
+
atAll: string;
|
|
66
|
+
/** 输入栏按钮的无障碍标签。 */
|
|
67
|
+
emoji: string;
|
|
68
|
+
keyboard: string;
|
|
69
|
+
more: string;
|
|
70
|
+
/** 业务卡片 `kind` 的显示名;不在表里的显示 [cardKindOther]。 */
|
|
71
|
+
cardKinds: Readonly<Record<string, string>>;
|
|
72
|
+
cardKindOther: string;
|
|
73
|
+
/** 「+」面板内置项。 */
|
|
74
|
+
album: string;
|
|
75
|
+
camera: string;
|
|
76
|
+
fileItem: string;
|
|
77
|
+
/** 按住说话。 */
|
|
78
|
+
holdToTalk: string;
|
|
79
|
+
releaseToSend: string;
|
|
80
|
+
slideUpToCancel: string;
|
|
81
|
+
releaseToCancel: string;
|
|
82
|
+
tooShort: string;
|
|
83
|
+
noMicPermission: string;
|
|
84
|
+
voiceInput: string;
|
|
85
|
+
/** 超过站点上限,`{mb}` 换成上限。 */
|
|
86
|
+
fileTooLarge: string;
|
|
87
|
+
videoUnreadable: string;
|
|
88
|
+
/** 长按消息菜单。 */
|
|
89
|
+
copy: string;
|
|
90
|
+
copied: string;
|
|
91
|
+
recall: string;
|
|
92
|
+
report: string;
|
|
93
|
+
/** 举报原因显示名,key 是 SDK `reportReasons`;举报弹窗按 SDK 列表顺序显示。 */
|
|
94
|
+
reportReasons: Readonly<Record<string, string>>;
|
|
95
|
+
alsoBlock: string;
|
|
96
|
+
submit: string;
|
|
97
|
+
reported: string;
|
|
98
|
+
reportDuplicated: string;
|
|
99
|
+
done: string;
|
|
100
|
+
/** 首字母索引条的无障碍标签。 */
|
|
101
|
+
indexBar: string;
|
|
102
|
+
/** 没有昵称时的显示名,`{id}` 换成 userId。 */
|
|
103
|
+
unknownUser: string;
|
|
104
|
+
rateLimited: string;
|
|
105
|
+
startGroupChat: string;
|
|
106
|
+
addFriend: string;
|
|
107
|
+
contactsTitle: string;
|
|
108
|
+
contactsSearchHint: string;
|
|
109
|
+
newFriends: string;
|
|
110
|
+
/** 通讯录入口与群聊列表页标题。 */
|
|
111
|
+
groupChats: string;
|
|
112
|
+
blocklist: string;
|
|
113
|
+
/** 分组 chips 的第一项。 */
|
|
114
|
+
allFriends: string;
|
|
115
|
+
emptyContacts: string;
|
|
116
|
+
emptyGroupChats: string;
|
|
117
|
+
requestsIn: string;
|
|
118
|
+
requestsOut: string;
|
|
119
|
+
accept: string;
|
|
120
|
+
reject: string;
|
|
121
|
+
/** 发出的申请还没处理。 */
|
|
122
|
+
requestPending: string;
|
|
123
|
+
requestAccepted: string;
|
|
124
|
+
requestRejected: string;
|
|
125
|
+
requestExpired: string;
|
|
126
|
+
requestsTip: string;
|
|
127
|
+
emptyRequests: string;
|
|
128
|
+
addFriendHint: string;
|
|
129
|
+
addFriendTip: string;
|
|
130
|
+
/** 搜到的卡片副标题,`{q}` 换成输入的内容。 */
|
|
131
|
+
matchedByUserId: string;
|
|
132
|
+
matchedBySearchKey: string;
|
|
133
|
+
view: string;
|
|
134
|
+
userNotFound: string;
|
|
135
|
+
userNotFoundTip: string;
|
|
136
|
+
searchSelf: string;
|
|
137
|
+
userCardTitle: string;
|
|
138
|
+
/** 有备注时显示的昵称行。 */
|
|
139
|
+
nicknameLabel: string;
|
|
140
|
+
accountLabel: string;
|
|
141
|
+
remarkAndGroups: string;
|
|
142
|
+
friendSince: string;
|
|
143
|
+
sendMessage: string;
|
|
144
|
+
blockUser: string;
|
|
145
|
+
blockConfirm: string;
|
|
146
|
+
deleteFriend: string;
|
|
147
|
+
deleteFriendConfirm: string;
|
|
148
|
+
addToContacts: string;
|
|
149
|
+
friendRequestTitle: string;
|
|
150
|
+
/** 申请附言默认值,`{name}` 换成本人昵称;本人昵称为空时附言留空。 */
|
|
151
|
+
friendRequestDefault: string;
|
|
152
|
+
sendRequest: string;
|
|
153
|
+
requestSent: string;
|
|
154
|
+
becameFriends: string;
|
|
155
|
+
addDenied: string;
|
|
156
|
+
/** 双方有拉黑关系时(`IM_BLOCKED`)。 */
|
|
157
|
+
addBlocked: string;
|
|
158
|
+
remark: string;
|
|
159
|
+
remarkTip: string;
|
|
160
|
+
clearRemark: string;
|
|
161
|
+
friendGroupsMulti: string;
|
|
162
|
+
manageFriendGroups: string;
|
|
163
|
+
newFriendGroup: string;
|
|
164
|
+
friendGroupName: string;
|
|
165
|
+
friendGroupsTitle: string;
|
|
166
|
+
friendGroupsTip: string;
|
|
167
|
+
rename: string;
|
|
168
|
+
deleteFriendGroup: string;
|
|
169
|
+
deleteFriendGroupConfirm: string;
|
|
170
|
+
dragToSort: string;
|
|
171
|
+
groupInfoTitle: string;
|
|
172
|
+
groupIdAndCount: string;
|
|
173
|
+
inviteMember: string;
|
|
174
|
+
removeMember: string;
|
|
175
|
+
viewAllMembers: string;
|
|
176
|
+
groupNameLabel: string;
|
|
177
|
+
groupNotice: string;
|
|
178
|
+
notSet: string;
|
|
179
|
+
pinChat: string;
|
|
180
|
+
groupManage: string;
|
|
181
|
+
muteAll: string;
|
|
182
|
+
muteAllTip: string;
|
|
183
|
+
inviteAdminOnly: string;
|
|
184
|
+
groupAdmins: string;
|
|
185
|
+
peopleCount: string;
|
|
186
|
+
transferOwner: string;
|
|
187
|
+
clearHistory: string;
|
|
188
|
+
clearHistoryConfirm: string;
|
|
189
|
+
quitGroup: string;
|
|
190
|
+
quitGroupConfirm: string;
|
|
191
|
+
ownerQuitTip: string;
|
|
192
|
+
dismissGroup: string;
|
|
193
|
+
dismissGroupConfirm: string;
|
|
194
|
+
/** 群角色标签。 */
|
|
195
|
+
roleOwner: string;
|
|
196
|
+
roleAdmin: string;
|
|
197
|
+
roleMember: string;
|
|
198
|
+
groupMembersTitle: string;
|
|
199
|
+
searchMembers: string;
|
|
200
|
+
mutedRemaining: string;
|
|
201
|
+
joinedAt: string;
|
|
202
|
+
viewProfile: string;
|
|
203
|
+
setAdmin: string;
|
|
204
|
+
unsetAdmin: string;
|
|
205
|
+
muteMember: string;
|
|
206
|
+
unmuteMember: string;
|
|
207
|
+
/** 禁言时长选项:秒数 → 显示名,按表里顺序列出。 */
|
|
208
|
+
muteDurations: Readonly<Record<string, string>>;
|
|
209
|
+
/** 剩余时长。 */
|
|
210
|
+
durationMinutes: string;
|
|
211
|
+
durationHours: string;
|
|
212
|
+
durationDays: string;
|
|
213
|
+
kickMember: string;
|
|
214
|
+
kickConfirm: string;
|
|
215
|
+
transferTo: string;
|
|
216
|
+
transferConfirm: string;
|
|
217
|
+
selectFriendsTitle: string;
|
|
218
|
+
doneWithCount: string;
|
|
219
|
+
searchFriends: string;
|
|
220
|
+
alreadyInGroup: string;
|
|
221
|
+
inviteToGroup: string;
|
|
222
|
+
skippedMembers: string;
|
|
223
|
+
/** 发起群聊的默认群名用它连接「我的昵称、前两位所选的昵称」。 */
|
|
224
|
+
groupNameSeparator: string;
|
|
225
|
+
editNotice: string;
|
|
226
|
+
publish: string;
|
|
227
|
+
noticePublishedAt: string;
|
|
228
|
+
noticeEditTip: string;
|
|
229
|
+
noticeHint: string;
|
|
230
|
+
noticePublishTip: string;
|
|
231
|
+
emptyNotice: string;
|
|
232
|
+
privacyTitle: string;
|
|
233
|
+
addMeWhen: string;
|
|
234
|
+
/** 加好友方式,下标即 `addPolicy`:0 需要验证、1 任何人直接加、2 不允许。 */
|
|
235
|
+
addPolicyTitles: readonly string[];
|
|
236
|
+
addPolicyTips: readonly string[];
|
|
237
|
+
blocklistTip: string;
|
|
238
|
+
unblock: string;
|
|
239
|
+
blockedAt: string;
|
|
240
|
+
emptyBlocklist: string;
|
|
241
|
+
searchContacts: string;
|
|
242
|
+
searchGroups: string;
|
|
243
|
+
searchMessagesTitle: string;
|
|
244
|
+
searchMore: string;
|
|
245
|
+
/** 一个会话里命中的条数;还有下一页时 `{n}` 是「已加载数+」,如「20+」。 */
|
|
246
|
+
searchRelated: string;
|
|
247
|
+
searchLoadMore: string;
|
|
248
|
+
searchNoResult: string;
|
|
249
|
+
searchFailed: string;
|
|
250
|
+
searchNoMore: string;
|
|
251
|
+
findChatHistory: string;
|
|
252
|
+
/** 搜索结果推不出会话对方(本机没有这个会话、命中的是自己发的)时的提示。 */
|
|
253
|
+
conversationGone: string;
|
|
254
|
+
backToLatest: string;
|
|
255
|
+
csTitle: string;
|
|
256
|
+
csBot: string;
|
|
257
|
+
csHandoff: string;
|
|
258
|
+
/** 排队中,`{n}` 是排在自己前面的人数。 */
|
|
259
|
+
csQueued: string;
|
|
260
|
+
csQueuedNext: string;
|
|
261
|
+
csOffline: string;
|
|
262
|
+
csOfflineWait: string;
|
|
263
|
+
csActive: string;
|
|
264
|
+
csLeave: string;
|
|
265
|
+
leaveTitle: string;
|
|
266
|
+
leaveTip: string;
|
|
267
|
+
leaveName: string;
|
|
268
|
+
leavePhone: string;
|
|
269
|
+
leaveEmail: string;
|
|
270
|
+
leaveOptional: string;
|
|
271
|
+
leaveContactTip: string;
|
|
272
|
+
leaveDone: string;
|
|
273
|
+
ratingTitle: string;
|
|
274
|
+
/** 1–5 星各自的说法,下标 0 是 1 星。 */
|
|
275
|
+
ratingLevels: readonly string[];
|
|
276
|
+
ratingScore: string;
|
|
277
|
+
ratingComment: string;
|
|
278
|
+
ratingCommentHint: string;
|
|
279
|
+
ratingSubmit: string;
|
|
280
|
+
ratingDone: string;
|
|
281
|
+
back: string;
|
|
282
|
+
close: string;
|
|
283
|
+
/** 输入框占位。 */
|
|
284
|
+
inputPlaceholder: string;
|
|
285
|
+
/** 发送按钮旁的按键提示。 */
|
|
286
|
+
enterToSend: string;
|
|
287
|
+
/** 拖文件进聊天区时的遮罩,`{name}` 是会话名。 */
|
|
288
|
+
dropToSend: string;
|
|
289
|
+
removeAttachment: string;
|
|
290
|
+
sendImageOrVideo: string;
|
|
291
|
+
sendFile: string;
|
|
292
|
+
zoomIn: string;
|
|
293
|
+
zoomOut: string;
|
|
294
|
+
prevImage: string;
|
|
295
|
+
nextImage: string;
|
|
296
|
+
openOriginal: string;
|
|
297
|
+
/** 导航条「消息」。 */
|
|
298
|
+
navMessages: string;
|
|
299
|
+
selectConversation: string;
|
|
300
|
+
/** 站点没开放这一类文件。 */
|
|
301
|
+
fileNotAllowed: string;
|
|
302
|
+
/** 图片预览的张数,`{n}` 当前第几张、`{total}` 共几张。 */
|
|
303
|
+
imageIndex: string;
|
|
304
|
+
}
|
|
305
|
+
export declare const defaultStrings: ImUiStrings;
|
|
306
|
+
/** 浅合并:传了的键整体覆盖(数组、对象也是整个替换)。 */
|
|
307
|
+
export declare function mergeStrings(over?: Partial<ImUiStrings>): ImUiStrings;
|
|
308
|
+
/** 替换占位符 `{key}`;没给的保持原样。 */
|
|
309
|
+
export declare function fill(template: string, vars: Record<string, string | number>): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { GuokitImUi, useIm, type GuokitImUiProps } from './ui/context';
|
|
2
|
+
export { ImWorkspace, type ImWorkspaceProps } from './ui/layout/ImWorkspace';
|
|
3
|
+
export { useImNavigator, type ImNavigator, type ImRoute, type ChatRouteTarget } from './ui/navigator';
|
|
4
|
+
export { useConversations, useTotalUnread, useConnection } from './ui/hooks';
|
|
5
|
+
export { ImUnreadBadge } from './ui/widgets/UnreadBadge';
|
|
6
|
+
export { ImConversationList, type ImConversationListProps } from './ui/conversation/ConversationList';
|
|
7
|
+
export { ImChat, type ImChatProps } from './ui/chat/ChatPage';
|
|
8
|
+
export { Avatar as ImAvatar, type AvatarProps as ImAvatarProps } from './ui/widgets/Avatar';
|
|
9
|
+
export type { ImUiTheme, ImAvatarShape } from './ui/theme';
|
|
10
|
+
export type { ImChatTarget, ImMoreItem, ImMenuItem, ImUiCallbacks, ImMessageRenderer, ImMe } from './ui/types';
|
|
11
|
+
export { defaultStrings, type ImUiStrings } from './core/strings';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ImConversation } from '@guokit-dev/im';
|
|
2
|
+
export interface ImChatProps {
|
|
3
|
+
/** 从会话列表进来。 */
|
|
4
|
+
conversation?: ImConversation;
|
|
5
|
+
/** 按对方 userId 打开,还没有会话时也能发。 */
|
|
6
|
+
peer?: string;
|
|
7
|
+
/** 按群号打开。 */
|
|
8
|
+
group?: string;
|
|
9
|
+
}
|
|
10
|
+
/** 聊天页:单聊、群聊共用(C 期再加客服与定位到消息)。同 Flutter `ImChatPage`。 */
|
|
11
|
+
export declare function ImChat(props: ImChatProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ImFeatures, ImGroupMember } from '@guokit-dev/im';
|
|
2
|
+
import { type MediaKind } from '../../core/media';
|
|
3
|
+
import type { ImChatTarget } from '../types';
|
|
4
|
+
export interface Attachment {
|
|
5
|
+
id: number;
|
|
6
|
+
file: File;
|
|
7
|
+
kind: MediaKind;
|
|
8
|
+
}
|
|
9
|
+
export interface ComposerHandle {
|
|
10
|
+
/** 拖进聊天区的文件:先进附件条。 */
|
|
11
|
+
addFiles(files: File[]): void;
|
|
12
|
+
}
|
|
13
|
+
export interface ComposerProps {
|
|
14
|
+
/** 发文字(at 是 userId 列表,`@all` 为所有人)。 */
|
|
15
|
+
onSend: (text: string, at: string[]) => Promise<void>;
|
|
16
|
+
/** 逐个发附件,按附件条顺序。 */
|
|
17
|
+
onSendFile: (a: Attachment) => Promise<void>;
|
|
18
|
+
onTyping?: () => void;
|
|
19
|
+
/** 非 null 时禁用输入区并显示提示(已退群)。 */
|
|
20
|
+
disabledHint?: string | null;
|
|
21
|
+
features: ImFeatures | null;
|
|
22
|
+
/** 群成员;非 null 时输入「@」弹出选成员。 */
|
|
23
|
+
members: readonly ImGroupMember[] | null;
|
|
24
|
+
/** 群主、管理员可以 @所有人。 */
|
|
25
|
+
canAtAll: boolean;
|
|
26
|
+
target: ImChatTarget | null;
|
|
27
|
+
}
|
|
28
|
+
/** 输入区:工具栏(表情、图片 / 视频、文件、「+」)、待发送附件条、@ 选成员、Enter 发送。设计稿 04。 */
|
|
29
|
+
export declare const Composer: import("react").ForwardRefExoticComponent<ComposerProps & import("react").RefAttributes<ComposerHandle>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { ImMessage } from '@guokit-dev/im';
|
|
3
|
+
import type { ChatController, ChatSnapshot } from '../../core/chatController';
|
|
4
|
+
export interface MessageListProps {
|
|
5
|
+
ctl: ChatController;
|
|
6
|
+
snap: ChatSnapshot;
|
|
7
|
+
isGroup: boolean;
|
|
8
|
+
nameOf: (userId: string) => string;
|
|
9
|
+
renderRow: (m: ImMessage) => ReactNode;
|
|
10
|
+
/** 由聊天页调:滚到最新(发送后、本人在别处发的、停在底部附近时来新消息)。 */
|
|
11
|
+
scrollRef: React.MutableRefObject<(() => void) | null>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 消息列表:`column-reverse` 的滚动容器,贴底与往前插入保持位置都由浏览器处理;
|
|
15
|
+
* 滚到离顶部 200px 内翻页。每行带 `content-visibility: auto`,代替虚拟滚动。
|
|
16
|
+
*/
|
|
17
|
+
export declare function MessageList({ ctl, snap, isGroup, nameOf, renderRow, scrollRef }: MessageListProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { ImMessage } from '@guokit-dev/im';
|
|
3
|
+
import { type BubbleProps } from './bubbles';
|
|
4
|
+
/** 居中灰色提示:撤回、群变动、时间分隔共用。 */
|
|
5
|
+
export declare function CenterTip({ text }: {
|
|
6
|
+
text: string;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export interface MessageRowProps extends Omit<BubbleProps, 'message'> {
|
|
9
|
+
message: ImMessage;
|
|
10
|
+
senderName: string;
|
|
11
|
+
senderAvatarUrl: string;
|
|
12
|
+
/** 群聊里对方的消息在气泡上方显示名字。 */
|
|
13
|
+
showName: boolean;
|
|
14
|
+
/** 本人已确认消息的已读状态;null 不显示。 */
|
|
15
|
+
read: boolean | null;
|
|
16
|
+
onResend?: (m: ImMessage) => void;
|
|
17
|
+
onAvatarClick?: (userId: string) => void;
|
|
18
|
+
/** 右键 / 触屏长按气泡。 */
|
|
19
|
+
onMenu?: (m: ImMessage, x: number, y: number) => void;
|
|
20
|
+
/** 悬停操作条(A4),由聊天页按消息生成。 */
|
|
21
|
+
hoverBar?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/** 聊天页的一条普通消息:头像、群里对方的名字、气泡、发送状态、已读 / 未读、「AI 生成」。同 Flutter `ImMessageRow`。 */
|
|
24
|
+
export declare const MessageRow: import("react").NamedExoticComponent<MessageRowProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ImMessage } from '@guokit-dev/im';
|
|
3
|
+
export interface BubbleProps {
|
|
4
|
+
message: ImMessage;
|
|
5
|
+
/** 本设备刚发的附件的 objectURL,上传完成前做占位。 */
|
|
6
|
+
localUrl?: string | null;
|
|
7
|
+
/** 上传进度 0–1;null 表示没在上传。 */
|
|
8
|
+
progress?: number | null;
|
|
9
|
+
/** 这条语音正在播放。 */
|
|
10
|
+
playing?: boolean;
|
|
11
|
+
onImageClick?: (m: ImMessage) => void;
|
|
12
|
+
onVideoClick?: (m: ImMessage) => void;
|
|
13
|
+
onVoiceClick?: (m: ImMessage) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function formatFileSize(bytes: number | null): string;
|
|
16
|
+
export declare function formatDuration(sec: number | null): string;
|
|
17
|
+
/** 新标签页打开;跨域时 `<a download>` 会被浏览器忽略,所以文件也走新标签页。 */
|
|
18
|
+
export declare function openExternal(url: string): void;
|
|
19
|
+
/** 带底色的文字气泡。群消息里 `@昵称` 高亮。 */
|
|
20
|
+
export declare function TextBubble({ message: m, text, children }: {
|
|
21
|
+
message: ImMessage;
|
|
22
|
+
text?: string;
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}): import("react").JSX.Element;
|
|
25
|
+
/** 气泡内容:宿主 messageRenderers 优先,返回 null 走默认。 */
|
|
26
|
+
export declare function MessageContent(props: BubbleProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
import type { GuokitIm, ImMessage } from '@guokit-dev/im';
|
|
3
|
+
import { type ImUiStrings } from '../core/strings';
|
|
4
|
+
import { type ChatRouteTarget } from './navigator';
|
|
5
|
+
import { type ImUiTheme } from './theme';
|
|
6
|
+
import type { ImChatTarget, ImMe, ImMenuItem, ImMessageRenderer, ImMoreItem, ImUiCallbacks } from './types';
|
|
7
|
+
export interface GuokitImUiProps {
|
|
8
|
+
/** SDK 实例,由宿主 new、login、销毁;组件只订阅。 */
|
|
9
|
+
im: GuokitIm;
|
|
10
|
+
me?: ImMe;
|
|
11
|
+
theme?: ImUiTheme;
|
|
12
|
+
/** 部分覆盖默认中文文案,浅合并。 */
|
|
13
|
+
strings?: Partial<ImUiStrings>;
|
|
14
|
+
callbacks?: ImUiCallbacks;
|
|
15
|
+
/** 按消息 type 覆盖气泡,返回 null 走默认。 */
|
|
16
|
+
messageRenderers?: Record<string, ImMessageRenderer>;
|
|
17
|
+
/** 「+」菜单的宿主扩展项;没有时「+」按钮隐藏。 */
|
|
18
|
+
moreItems?: ImMoreItem[];
|
|
19
|
+
/** 追加到消息「更多」与右键菜单末尾。 */
|
|
20
|
+
menuItems?: (message: ImMessage) => ImMenuItem[];
|
|
21
|
+
className?: string;
|
|
22
|
+
style?: CSSProperties;
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
export interface ImUiContextValue {
|
|
26
|
+
im: GuokitIm;
|
|
27
|
+
me: ImMe;
|
|
28
|
+
strings: ImUiStrings;
|
|
29
|
+
callbacks: ImUiCallbacks;
|
|
30
|
+
messageRenderers: Record<string, ImMessageRenderer>;
|
|
31
|
+
moreItems: ImMoreItem[];
|
|
32
|
+
menuItems?: (message: ImMessage) => ImMenuItem[];
|
|
33
|
+
}
|
|
34
|
+
/** 把打开聊天的路由目标换成交给宿主的 `ImChatTarget`。 */
|
|
35
|
+
export declare function chatTargetOf(t: ChatRouteTarget): ImChatTarget;
|
|
36
|
+
/**
|
|
37
|
+
* IM 组件的根,对应 Flutter 的 `GuokitImUi`。下面放 `ImWorkspace`(整页)或单页组件。
|
|
38
|
+
* 单页组件模式下,抽屉、对话框类页面由这里自带的浮层宿主渲染;主区、列表栏类走回调。
|
|
39
|
+
*/
|
|
40
|
+
export declare function GuokitImUi(props: GuokitImUiProps): import("react").JSX.Element;
|
|
41
|
+
/** 组件内部用:取 Provider 数据。 */
|
|
42
|
+
export declare function useImUi(): ImUiContextValue;
|
|
43
|
+
/** 当前的 SDK 实例。 */
|
|
44
|
+
export declare function useIm(): GuokitIm;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ImConversation } from '@guokit-dev/im';
|
|
2
|
+
export interface ImConversationListProps {
|
|
3
|
+
/** 点会话。不传时:在 ImWorkspace 里主区打开聊天,单页组件模式下走 `callbacks.onOpenConversation`。 */
|
|
4
|
+
onOpen?: (conversation: ImConversation) => void;
|
|
5
|
+
/** 标题栏「+」菜单:发起群聊、添加朋友(B 期)。 */
|
|
6
|
+
showAddMenu?: boolean;
|
|
7
|
+
/** 顶部搜索框(C 期接全局搜索)。 */
|
|
8
|
+
showSearch?: boolean;
|
|
9
|
+
/** 当前选中的会话 id(宽屏高亮);ImWorkspace 里自动取主区打开的会话。 */
|
|
10
|
+
selectedId?: number | null;
|
|
11
|
+
}
|
|
12
|
+
/** 会话列表:置顶、未读、免打扰、断线横条、右键(触屏长按)置顶 / 免打扰 / 删除、全部已读。同 Flutter `ImConversationListPage`。 */
|
|
13
|
+
export declare function ImConversationList({ onOpen, showAddMenu, showSearch, selectedId }: ImConversationListProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ImConnectionState, ImConversation } from '@guokit-dev/im';
|
|
2
|
+
/** 会话列表快照,置顶在前;未登录时是空数组。 */
|
|
3
|
+
export declare function useConversations(): readonly ImConversation[];
|
|
4
|
+
/** 总未读(免打扰不计)。 */
|
|
5
|
+
export declare function useTotalUnread(): number;
|
|
6
|
+
/** 实时连接状态。 */
|
|
7
|
+
export declare function useConnection(): ImConnectionState;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type NavState } from '../navigator';
|
|
2
|
+
/** 右侧抽屉:只显示栈顶,下面的保留挂载(返回时状态还在)。 */
|
|
3
|
+
export declare function DrawerLayer({ stack, back, close }: {
|
|
4
|
+
stack: NavState['drawer'];
|
|
5
|
+
back(): void;
|
|
6
|
+
close(): void;
|
|
7
|
+
}): import("react").JSX.Element | null;
|
|
8
|
+
/** 居中对话框,可以叠多层,每层一个遮罩。 */
|
|
9
|
+
export declare function DialogLayer({ stack, back }: {
|
|
10
|
+
stack: NavState['dialog'];
|
|
11
|
+
back(): void;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
13
|
+
/** 全屏遮罩(图片、视频预览),宽窄屏都是遮罩。 */
|
|
14
|
+
export declare function OverlayLayer({ stack, back }: {
|
|
15
|
+
stack: NavState['overlay'];
|
|
16
|
+
back(): void;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
/** 单页组件模式的浮层宿主:渲染 Provider 视图栈里的抽屉、对话框与遮罩。 */
|
|
19
|
+
export declare function LayerHost(): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 页面所在的框:宽屏 main / list / drawer / dialog,窄屏 page(整页,带返回)。
|
|
3
|
+
* 页面组件据此决定头部画返回、关闭还是什么都不画。
|
|
4
|
+
*/
|
|
5
|
+
export interface Frame {
|
|
6
|
+
kind: 'main' | 'list' | 'drawer' | 'dialog' | 'page' | 'standalone';
|
|
7
|
+
/** 头部要不要画返回(窄屏非底页、抽屉内堆栈非底层)。 */
|
|
8
|
+
canBack: boolean;
|
|
9
|
+
back(): void;
|
|
10
|
+
/** 关掉这一层(抽屉整体、对话框)。 */
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const FrameContext: import("react").Context<Frame>;
|
|
14
|
+
export declare function useFrame(): Frame;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ImTarget } from '@guokit-dev/im';
|
|
2
|
+
/** 举报:原因单选两列,可勾选同时加入黑名单(设计稿 06,口径同 Flutter `showReportSheet`)。 */
|
|
3
|
+
export declare function ReportDialog({ target, title, messageIds }: {
|
|
4
|
+
target: ImTarget;
|
|
5
|
+
title: string;
|
|
6
|
+
messageIds?: number[];
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ImConversation, ImMessage, ImTarget } from '@guokit-dev/im';
|
|
2
|
+
/** 打开聊天的目标:三选一(C 期再加 service / anchor)。 */
|
|
3
|
+
export interface ChatRouteTarget {
|
|
4
|
+
conversation?: ImConversation;
|
|
5
|
+
peer?: string;
|
|
6
|
+
group?: string;
|
|
7
|
+
}
|
|
8
|
+
/** 内置视图栈的路由。各期往这里加成员;宽屏放在哪由 `routePlacement` 决定(spec §4)。 */
|
|
9
|
+
export type ImRoute = {
|
|
10
|
+
name: 'conversations';
|
|
11
|
+
} | {
|
|
12
|
+
name: 'chat';
|
|
13
|
+
target: ChatRouteTarget;
|
|
14
|
+
} | {
|
|
15
|
+
name: 'report';
|
|
16
|
+
target: ImTarget;
|
|
17
|
+
title: string;
|
|
18
|
+
messageIds?: number[];
|
|
19
|
+
} | {
|
|
20
|
+
name: 'imageViewer';
|
|
21
|
+
images: ImMessage[];
|
|
22
|
+
index: number;
|
|
23
|
+
} | {
|
|
24
|
+
name: 'videoPlayer';
|
|
25
|
+
message: ImMessage;
|
|
26
|
+
};
|
|
27
|
+
export type ImRouteName = ImRoute['name'];
|
|
28
|
+
/**
|
|
29
|
+
* main 主区、list 列表栏、drawer 右侧抽屉(内部堆栈)、dialog 居中对话框、overlay 全屏遮罩(预览)。
|
|
30
|
+
* 窄屏下 main / drawer / dialog 都变成整页 push,overlay 仍是遮罩。
|
|
31
|
+
*/
|
|
32
|
+
export type ImPlacement = 'main' | 'list' | 'drawer' | 'dialog' | 'overlay';
|
|
33
|
+
export declare const routePlacement: Record<ImRouteName, ImPlacement>;
|
|
34
|
+
export interface NavState {
|
|
35
|
+
list: ImRoute;
|
|
36
|
+
main: ImRoute | null;
|
|
37
|
+
drawer: ImRoute[];
|
|
38
|
+
dialog: ImRoute[];
|
|
39
|
+
overlay: ImRoute[];
|
|
40
|
+
}
|
|
41
|
+
export declare const initialNav: NavState;
|
|
42
|
+
type Action = {
|
|
43
|
+
type: 'open';
|
|
44
|
+
route: ImRoute;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'back';
|
|
47
|
+
} | {
|
|
48
|
+
type: 'close';
|
|
49
|
+
};
|
|
50
|
+
export declare function navReducer(s: NavState, a: Action): NavState;
|
|
51
|
+
/** 最上层的路由(窄屏当前页、宽屏最上层浮层或主区)。 */
|
|
52
|
+
export declare function topRoute(s: NavState): ImRoute | null;
|
|
53
|
+
export interface ImNavigator {
|
|
54
|
+
/** 打开一个路由,按放置规则落到主区、列表栏、抽屉或对话框。 */
|
|
55
|
+
open(route: ImRoute): void;
|
|
56
|
+
/** 退一层:遮罩 → 对话框 → 抽屉 → 主区。 */
|
|
57
|
+
back(): void;
|
|
58
|
+
/** 关掉所有抽屉、对话框与遮罩。 */
|
|
59
|
+
close(): void;
|
|
60
|
+
}
|
|
61
|
+
export interface NavContextValue extends ImNavigator {
|
|
62
|
+
state: NavState;
|
|
63
|
+
/** true 时 main / list 路由由视图栈自己渲染(ImWorkspace);false 时交给 `onMainOrList`(单页组件)。 */
|
|
64
|
+
workspace: boolean;
|
|
65
|
+
}
|
|
66
|
+
export declare const NavContext: import("react").Context<NavContextValue | null>;
|
|
67
|
+
/** 建一个视图栈。`onMainOrList` 给单页组件模式用:主区、列表栏类路由不入栈,交给它处理。 */
|
|
68
|
+
export declare function useNavState(workspace: boolean, onMainOrList?: (r: ImRoute) => void): NavContextValue;
|
|
69
|
+
/** 组件内部用:带状态的视图栈。 */
|
|
70
|
+
export declare function useNavContext(): NavContextValue;
|
|
71
|
+
/** 当前视图栈:`open(route)`、`back()`、`close()`。要放在 `GuokitImUi` 下面。 */
|
|
72
|
+
export declare function useImNavigator(): ImNavigator;
|
|
73
|
+
export {};
|