@guokit-dev/im-react 0.27.0 → 0.28.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/README.md +21 -10
- package/dist/index.cjs +2467 -283
- package/dist/index.mjs +2448 -264
- package/dist/style.css +291 -0
- package/dist/types/core/groupAvatarCache.d.ts +37 -0
- package/dist/types/core/imStore.d.ts +6 -1
- package/dist/types/core/index.d.ts +3 -1
- package/dist/types/core/pinyinIndex.d.ts +15 -0
- package/dist/types/core/strings.d.ts +6 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/ui/contacts/AddFriendDialog.d.ts +2 -0
- package/dist/types/ui/contacts/ContactsPage.d.ts +9 -0
- package/dist/types/ui/contacts/FriendGroups.d.ts +6 -0
- package/dist/types/ui/contacts/FriendSettings.d.ts +4 -0
- package/dist/types/ui/contacts/NewFriendsPage.d.ts +2 -0
- package/dist/types/ui/contacts/UserCard.d.ts +8 -0
- package/dist/types/ui/contacts/index.d.ts +5 -0
- package/dist/types/ui/contacts/routes.d.ts +4 -0
- package/dist/types/ui/contacts/shared.d.ts +33 -0
- package/dist/types/ui/group/GroupChats.d.ts +2 -0
- package/dist/types/ui/group/GroupInfo.d.ts +9 -0
- package/dist/types/ui/group/GroupMembers.d.ts +11 -0
- package/dist/types/ui/group/GroupNotice.d.ts +8 -0
- package/dist/types/ui/group/SelectFriends.d.ts +8 -0
- package/dist/types/ui/group/routes.d.ts +4 -0
- package/dist/types/ui/group/shared.d.ts +47 -0
- package/dist/types/ui/hooks.d.ts +3 -1
- package/dist/types/ui/navigator.d.ts +38 -0
- package/dist/types/ui/privacy/PrivacyPage.d.ts +7 -0
- package/dist/types/ui/privacy/routes.d.ts +4 -0
- package/dist/types/ui/widgets/GroupAvatar.d.ts +21 -0
- package/dist/types/ui/widgets/Icon.d.ts +11 -0
- package/dist/types/ui/widgets/IndexedList.d.ts +14 -0
- package/package.json +2 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ImConversation, type ImGroup, type ImGroupMember } from '@guokit-dev/im';
|
|
3
|
+
import { MemberCache } from '../../core/memberCache';
|
|
4
|
+
import { type ImUiStrings } from '../../core/strings';
|
|
5
|
+
export declare function sameId(a: string, b: string): boolean;
|
|
6
|
+
export declare function errorText(e: unknown, s: ImUiStrings): string;
|
|
7
|
+
/** 成员显示名:昵称为空时用 userId。 */
|
|
8
|
+
export declare function memberName(m: ImGroupMember): string;
|
|
9
|
+
/** 角色标签:2 群主、1 管理员、0 成员。 */
|
|
10
|
+
export declare function roleName(role: number, s: ImUiStrings): string;
|
|
11
|
+
/** 剩余时长:不足 1 小时按分钟、不足 1 天按小时、再长按天,都向上取整(同 Flutter `remainingText`)。 */
|
|
12
|
+
export declare function remainingText(ms: number, s: ImUiStrings): string;
|
|
13
|
+
/** 本地日期「年/月/日」,可选带「时:分」。 */
|
|
14
|
+
export declare function ymd(ms: number, withTime?: boolean): string;
|
|
15
|
+
/**
|
|
16
|
+
* 群资料:进来拉一次,收到本群的 `groupChanged` 再拉(SDK 不缓存群资料)。
|
|
17
|
+
* 拉失败且还没有数据时给 error。
|
|
18
|
+
*/
|
|
19
|
+
export declare function useGroup(groupId: string): {
|
|
20
|
+
group: ImGroup | null;
|
|
21
|
+
error: unknown;
|
|
22
|
+
reload: () => Promise<void>;
|
|
23
|
+
setGroup: import("react").Dispatch<import("react").SetStateAction<ImGroup | null>>;
|
|
24
|
+
};
|
|
25
|
+
/** 本页自己的群成员缓存(按进群先后,500 人封顶),群变动时自动重拉。groupId 为 null 时不拉。 */
|
|
26
|
+
export declare function useMembers(groupId: string | null): {
|
|
27
|
+
cache: MemberCache | null;
|
|
28
|
+
map: ReadonlyMap<string, ImGroupMember>;
|
|
29
|
+
members: ImGroupMember[];
|
|
30
|
+
};
|
|
31
|
+
/** 本地会话里的这个群(免打扰、置顶、清空记录用);还没有会话时为 null。 */
|
|
32
|
+
export declare function useGroupConversation(groupId: string): ImConversation | null;
|
|
33
|
+
/** 开关(role=switch)。 */
|
|
34
|
+
export declare function Switch({ label, checked, onChange, disabled }: {
|
|
35
|
+
label: string;
|
|
36
|
+
checked: boolean;
|
|
37
|
+
onChange: (v: boolean) => void;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
}): import("react").JSX.Element;
|
|
40
|
+
/** 设置行:标题 + 右侧值或开关;传了 onClick 就是可点的行。 */
|
|
41
|
+
export declare function SettingRow({ title, value, sub, trailing, onClick }: {
|
|
42
|
+
title: string;
|
|
43
|
+
value?: ReactNode;
|
|
44
|
+
sub?: ReactNode;
|
|
45
|
+
trailing?: ReactNode;
|
|
46
|
+
onClick?: () => void;
|
|
47
|
+
}): import("react").JSX.Element;
|
package/dist/types/ui/hooks.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ImConnectionState, ImConversation } from '@guokit-dev/im';
|
|
1
|
+
import type { ImConnectionState, ImConversation, ImFriend } from '@guokit-dev/im';
|
|
2
2
|
/** 会话列表快照,置顶在前;未登录时是空数组。 */
|
|
3
3
|
export declare function useConversations(): readonly ImConversation[];
|
|
4
4
|
/** 总未读(免打扰不计)。 */
|
|
5
5
|
export declare function useTotalUnread(): number;
|
|
6
6
|
/** 实时连接状态。 */
|
|
7
7
|
export declare function useConnection(): ImConnectionState;
|
|
8
|
+
/** 好友快照(按 userId 升序);第一次订阅时触发对账,冷启动先是空的。 */
|
|
9
|
+
export declare function useFriends(): readonly ImFriend[];
|
|
@@ -23,6 +23,43 @@ export type ImRoute = {
|
|
|
23
23
|
} | {
|
|
24
24
|
name: 'videoPlayer';
|
|
25
25
|
message: ImMessage;
|
|
26
|
+
} | {
|
|
27
|
+
name: 'contacts';
|
|
28
|
+
} | {
|
|
29
|
+
name: 'contactProfile';
|
|
30
|
+
userId: string;
|
|
31
|
+
} | {
|
|
32
|
+
name: 'newFriends';
|
|
33
|
+
} | {
|
|
34
|
+
name: 'groupChats';
|
|
35
|
+
} | {
|
|
36
|
+
name: 'privacy';
|
|
37
|
+
} | {
|
|
38
|
+
name: 'blocklist';
|
|
39
|
+
} | {
|
|
40
|
+
name: 'userCard';
|
|
41
|
+
userId: string;
|
|
42
|
+
} | {
|
|
43
|
+
name: 'friendSettings';
|
|
44
|
+
userId: string;
|
|
45
|
+
} | {
|
|
46
|
+
name: 'friendGroups';
|
|
47
|
+
} | {
|
|
48
|
+
name: 'groupInfo';
|
|
49
|
+
groupId: string;
|
|
50
|
+
} | {
|
|
51
|
+
name: 'groupMembers';
|
|
52
|
+
groupId: string;
|
|
53
|
+
} | {
|
|
54
|
+
name: 'groupNotice';
|
|
55
|
+
groupId: string;
|
|
56
|
+
} | {
|
|
57
|
+
name: 'addFriend';
|
|
58
|
+
}
|
|
59
|
+
/** 不传 groupId 是发起群聊,传了是邀请进群。 */
|
|
60
|
+
| {
|
|
61
|
+
name: 'selectFriends';
|
|
62
|
+
groupId?: string;
|
|
26
63
|
};
|
|
27
64
|
export type ImRouteName = ImRoute['name'];
|
|
28
65
|
/**
|
|
@@ -42,6 +79,7 @@ export declare const initialNav: NavState;
|
|
|
42
79
|
type Action = {
|
|
43
80
|
type: 'open';
|
|
44
81
|
route: ImRoute;
|
|
82
|
+
as?: ImPlacement;
|
|
45
83
|
} | {
|
|
46
84
|
type: 'back';
|
|
47
85
|
} | {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 隐私:加好友方式三选一(进来读 `features().addPolicy`,点了即 `setFriendAddPolicy`,失败回滚)。
|
|
3
|
+
* 宽屏主区里黑名单作为第二段直接列出(设计稿 12);窄屏、抽屉里是一行入口,点进黑名单页。同 Flutter `ImPrivacyPage`。
|
|
4
|
+
*/
|
|
5
|
+
export declare function ImPrivacy(): import("react").JSX.Element;
|
|
6
|
+
/** 黑名单页(窄屏从隐私页进入)。 */
|
|
7
|
+
export declare function BlocklistPage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ImGroupMember } from '@guokit-dev/im';
|
|
2
|
+
export interface ImGroupAvatarProps {
|
|
3
|
+
groupId: string;
|
|
4
|
+
/** 群名,单色块兜底时取首字。 */
|
|
5
|
+
name?: string;
|
|
6
|
+
/** 群头像;非空时直接用,不拉成员。 */
|
|
7
|
+
url?: string;
|
|
8
|
+
/** 边长 px;不传时用 `--gkim-avatar-size`(会话列表里是放大后的尺寸)。 */
|
|
9
|
+
size?: number;
|
|
10
|
+
}
|
|
11
|
+
/** 九宫格本体:最多前 9 人,1–4 人两列、5–9 人三列,内边距与格间距 2px。 */
|
|
12
|
+
export declare function GroupGrid({ members, label, size }: {
|
|
13
|
+
members: ImGroupMember[];
|
|
14
|
+
label: string;
|
|
15
|
+
size?: number;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* 九宫格群头像:群设了头像直接用;没设时取前 9 名成员拼格子。滚进视口才拉(同一个 im 共用缓存,
|
|
19
|
+
* 同时最多 3 个请求),进退群或改群头像时重拉;拉不到时退回单色块。同 Flutter `ImGroupAvatar`。
|
|
20
|
+
*/
|
|
21
|
+
export declare function ImGroupAvatar({ groupId, name, url, size }: ImGroupAvatarProps): import("react").JSX.Element;
|
|
@@ -23,6 +23,17 @@ declare const PATHS: {
|
|
|
23
23
|
readonly check: import("react").JSX.Element;
|
|
24
24
|
readonly checkAll: import("react").JSX.Element;
|
|
25
25
|
readonly mute: import("react").JSX.Element;
|
|
26
|
+
readonly add: import("react").JSX.Element;
|
|
27
|
+
readonly userPlus: import("react").JSX.Element;
|
|
28
|
+
readonly chatPlus: import("react").JSX.Element;
|
|
29
|
+
readonly contacts: import("react").JSX.Element;
|
|
30
|
+
readonly shield: import("react").JSX.Element;
|
|
31
|
+
readonly search: import("react").JSX.Element;
|
|
32
|
+
readonly edit: import("react").JSX.Element;
|
|
33
|
+
readonly grip: import("react").JSX.Element;
|
|
34
|
+
readonly minus: import("react").JSX.Element;
|
|
35
|
+
readonly chevron: import("react").JSX.Element;
|
|
36
|
+
readonly minusLine: import("react").JSX.Element;
|
|
26
37
|
};
|
|
27
38
|
export type IconName = keyof typeof PATHS;
|
|
28
39
|
export declare function Icon({ name, size }: {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type IndexSection } from '../../core/pinyinIndex';
|
|
3
|
+
export interface IndexedListProps<T> {
|
|
4
|
+
sections: IndexSection<T>[];
|
|
5
|
+
renderItem: (item: T) => ReactNode;
|
|
6
|
+
keyOf: (item: T) => string;
|
|
7
|
+
/** 跟着列表一起滚的头部(搜索框、入口、分组)。 */
|
|
8
|
+
header?: ReactNode;
|
|
9
|
+
/** 列表末尾(空态、人数)。 */
|
|
10
|
+
footer?: ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/** 首字母分节列表 + 右侧 ↑ A–Z # 索引条(可点可拖)。通讯录与选择好友共用,同 Flutter `ImIndexedList`。 */
|
|
14
|
+
export declare function IndexedList<T>({ sections, renderItem, keyOf, header, footer, className }: IndexedListProps<T>): import("react").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guokit-dev/im-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "guokit IM 的 React UI 组件:开箱即用的整页会话、聊天,可换皮",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"type-check": "tsc --noEmit -p tsconfig.test.json"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@guokit-dev/im": ">=0.
|
|
40
|
+
"@guokit-dev/im": ">=0.28.0 <1",
|
|
41
41
|
"react": ">=18.2 <20",
|
|
42
42
|
"react-dom": ">=18.2 <20"
|
|
43
43
|
},
|