@blueking/bk-user-selector 0.0.39-beta.2 → 0.1.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 +314 -88
- package/package.json +2 -2
- package/typings/api/user.d.ts +42 -21
- package/typings/components/me-tag.vue.d.ts +14 -35
- package/typings/components/selection-popover.vue.d.ts +42 -197
- package/typings/components/user-selector.vue.d.ts +21 -29
- package/typings/constants/index.d.ts +25 -0
- package/typings/hooks/use-current-user.d.ts +30 -0
- package/typings/hooks/use-focus-state.d.ts +48 -0
- package/typings/hooks/use-input-handler.d.ts +44 -0
- package/typings/hooks/use-resize-observer.d.ts +17 -0
- package/typings/hooks/use-selected-users.d.ts +78 -0
- package/typings/hooks/use-sortable.d.ts +41 -0
- package/typings/hooks/use-tenant-data.d.ts +17 -0
- package/typings/hooks/use-user-search.d.ts +38 -0
- package/typings/hooks/use-user-selection.d.ts +32 -0
- package/typings/hooks/use-visible-tags.d.ts +51 -0
- package/typings/types/index.d.ts +117 -98
- package/typings/utils/logger.d.ts +47 -0
- package/vue2/index.es.min.js +2918 -4553
- package/vue2/index.iife.min.js +2864 -4442
- package/vue2/index.umd.min.js +2910 -4545
- package/vue2/vue2.css +30 -77
- package/vue3/index.es.min.js +1325 -1595
- package/vue3/index.iife.min.js +2908 -4543
- package/vue3/index.umd.min.js +1324 -1594
- package/vue3/vue3.css +30 -63
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用户选择公共逻辑 Hook
|
|
3
|
+
* @module hooks/useUserSelection
|
|
4
|
+
*/
|
|
5
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
6
|
+
import type { FormattedUser, UserGroupConfig } from '../types';
|
|
7
|
+
export interface UseUserSelectionOptions {
|
|
8
|
+
/** 排除的用户ID列表 */
|
|
9
|
+
excludeUserIds?: Ref<string[]>;
|
|
10
|
+
/** 搜索关键词 */
|
|
11
|
+
searchQuery: Ref<string>;
|
|
12
|
+
/** 已选用户ID列表(用于过滤) */
|
|
13
|
+
selectedUserIds: Ref<string[]>;
|
|
14
|
+
/** 用户群组配置 */
|
|
15
|
+
userGroup?: Ref<UserGroupConfig[]>;
|
|
16
|
+
}
|
|
17
|
+
export interface UseUserSelectionReturn {
|
|
18
|
+
/** 过滤后的用户群组(带搜索过滤) */
|
|
19
|
+
filteredUserGroup: ComputedRef<UserGroupConfig[]>;
|
|
20
|
+
/** 创建自定义用户 */
|
|
21
|
+
createCustomUser: (loginName: string) => FormattedUser;
|
|
22
|
+
/** 过滤选项(排除已选和排除列表) */
|
|
23
|
+
filterOptions: (options: FormattedUser[]) => FormattedUser[];
|
|
24
|
+
/** 检查用户是否已选中 */
|
|
25
|
+
isUserSelected: (userId: string) => boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 用户选择公共逻辑 Hook
|
|
29
|
+
* @param options - 配置选项
|
|
30
|
+
* @returns 用户选择相关方法
|
|
31
|
+
*/
|
|
32
|
+
export declare const useUserSelection: (options: UseUserSelectionOptions) => UseUserSelectionReturn;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { FormattedUser } from '../types';
|
|
3
|
+
export interface UseVisibleTagsOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 折叠容器引用
|
|
6
|
+
*/
|
|
7
|
+
collapsedContainerRef: Ref<HTMLDivElement | null>;
|
|
8
|
+
/**
|
|
9
|
+
* 是否聚焦状态
|
|
10
|
+
*/
|
|
11
|
+
isFocused: Ref<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* 已选用户列表
|
|
14
|
+
*/
|
|
15
|
+
selectedUsers: Ref<FormattedUser[]>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 可见标签计算 hook
|
|
19
|
+
*/
|
|
20
|
+
export declare function useVisibleTags(options: UseVisibleTagsOptions): {
|
|
21
|
+
visibleUsers: Ref<{
|
|
22
|
+
bk_username?: string | undefined;
|
|
23
|
+
data_source_type?: string | undefined;
|
|
24
|
+
display_name?: string | undefined;
|
|
25
|
+
full_name?: string | undefined;
|
|
26
|
+
hidden?: boolean | undefined;
|
|
27
|
+
id: string;
|
|
28
|
+
login_name?: string | undefined;
|
|
29
|
+
name: string;
|
|
30
|
+
owner_tenant_id?: string | undefined;
|
|
31
|
+
tenantId: string;
|
|
32
|
+
type?: import("../types").UserType | undefined;
|
|
33
|
+
username?: string | undefined;
|
|
34
|
+
}[], FormattedUser[] | {
|
|
35
|
+
bk_username?: string | undefined;
|
|
36
|
+
data_source_type?: string | undefined;
|
|
37
|
+
display_name?: string | undefined;
|
|
38
|
+
full_name?: string | undefined;
|
|
39
|
+
hidden?: boolean | undefined;
|
|
40
|
+
id: string;
|
|
41
|
+
login_name?: string | undefined;
|
|
42
|
+
name: string;
|
|
43
|
+
owner_tenant_id?: string | undefined;
|
|
44
|
+
tenantId: string;
|
|
45
|
+
type?: import("../types").UserType | undefined;
|
|
46
|
+
username?: string | undefined;
|
|
47
|
+
}[]>;
|
|
48
|
+
hiddenCount: Ref<number, number>;
|
|
49
|
+
calculateVisibleUsers: () => void;
|
|
50
|
+
scheduleVisibleUsersCalculation: () => void;
|
|
51
|
+
};
|
package/typings/types/index.d.ts
CHANGED
|
@@ -1,68 +1,128 @@
|
|
|
1
1
|
import type { createVNode } from 'vue';
|
|
2
2
|
import type { VNode } from 'vue';
|
|
3
|
+
import type { USER_TYPE } from '../constants';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* 基础选择器属性
|
|
5
6
|
*/
|
|
6
|
-
export interface
|
|
7
|
+
export interface BaseSelectorProps {
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* 是否允许创建用户
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
allowCreate?: boolean;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* 接口基础URL
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
apiBaseUrl: string;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* 本人ID
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
currentUserId?: string;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* 是否禁用
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
disabled?: boolean;
|
|
23
24
|
/**
|
|
24
|
-
*
|
|
25
|
+
* 无匹配人员时的提示文本
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 多选模式属性
|
|
30
|
-
*/
|
|
31
|
-
export interface MultipleSelectorProps extends BaseSelectorProps {
|
|
27
|
+
emptyText?: string;
|
|
32
28
|
/**
|
|
33
|
-
*
|
|
29
|
+
* 是否启用多租户模式
|
|
34
30
|
*/
|
|
35
|
-
|
|
31
|
+
enableMultiTenantMode?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 精确查找key
|
|
34
|
+
*/
|
|
35
|
+
exactSearchKey?: string;
|
|
36
|
+
/**
|
|
37
|
+
* 排除的用户ID列表
|
|
38
|
+
*/
|
|
39
|
+
excludeUserIds?: string[];
|
|
36
40
|
/**
|
|
37
41
|
* 是否允许粘贴任意文本
|
|
38
42
|
*/
|
|
39
43
|
freePaste?: boolean;
|
|
40
44
|
/**
|
|
41
|
-
*
|
|
45
|
+
* 占位文字
|
|
42
46
|
*/
|
|
43
|
-
|
|
47
|
+
placeholder?: string;
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
49
|
+
* 渲染列表项
|
|
46
50
|
*/
|
|
47
|
-
|
|
51
|
+
renderListItem?: RenderFunction;
|
|
48
52
|
/**
|
|
49
|
-
*
|
|
53
|
+
* 渲染标签
|
|
50
54
|
*/
|
|
51
|
-
|
|
55
|
+
renderTag?: RenderFunction;
|
|
56
|
+
/**
|
|
57
|
+
* 租户ID
|
|
58
|
+
*/
|
|
59
|
+
tenantId: string;
|
|
60
|
+
/**
|
|
61
|
+
* 用户组配置
|
|
62
|
+
*/
|
|
63
|
+
userGroup?: UserGroupConfig[];
|
|
64
|
+
/**
|
|
65
|
+
* 用户组名称
|
|
66
|
+
*/
|
|
67
|
+
userGroupName?: string;
|
|
52
68
|
}
|
|
53
69
|
/**
|
|
54
|
-
*
|
|
70
|
+
* 格式化后的用户信息
|
|
55
71
|
*/
|
|
56
|
-
export interface
|
|
72
|
+
export interface FormattedUser {
|
|
73
|
+
/**
|
|
74
|
+
* 用户名
|
|
75
|
+
*/
|
|
76
|
+
bk_username?: string;
|
|
77
|
+
/**
|
|
78
|
+
* 数据源类型
|
|
79
|
+
*/
|
|
80
|
+
data_source_type?: string;
|
|
81
|
+
/**
|
|
82
|
+
* 显示名称
|
|
83
|
+
*/
|
|
84
|
+
display_name?: string;
|
|
85
|
+
/**
|
|
86
|
+
* 全名
|
|
87
|
+
*/
|
|
88
|
+
full_name?: string;
|
|
89
|
+
/**
|
|
90
|
+
* 是否隐藏
|
|
91
|
+
*/
|
|
92
|
+
hidden?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* 用户ID
|
|
95
|
+
*/
|
|
96
|
+
id: string;
|
|
97
|
+
/**
|
|
98
|
+
* 登录名
|
|
99
|
+
*/
|
|
100
|
+
login_name?: string;
|
|
101
|
+
/**
|
|
102
|
+
* 用户名称
|
|
103
|
+
*/
|
|
104
|
+
name: string;
|
|
105
|
+
/**
|
|
106
|
+
* 所属租户ID
|
|
107
|
+
*/
|
|
108
|
+
owner_tenant_id?: string;
|
|
109
|
+
/**
|
|
110
|
+
* 租户ID
|
|
111
|
+
*/
|
|
112
|
+
tenantId: string;
|
|
57
113
|
/**
|
|
58
|
-
*
|
|
114
|
+
* 用户类型
|
|
59
115
|
*/
|
|
60
|
-
|
|
116
|
+
type?: UserType;
|
|
61
117
|
/**
|
|
62
|
-
*
|
|
118
|
+
* 旧版用户名
|
|
63
119
|
*/
|
|
64
|
-
|
|
120
|
+
username?: string;
|
|
65
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* 自定义渲染函数类型
|
|
124
|
+
*/
|
|
125
|
+
export type RenderFunction = (h: typeof createVNode, userInfo: FormattedUser) => VNode;
|
|
66
126
|
/**
|
|
67
127
|
* 租户信息
|
|
68
128
|
*/
|
|
@@ -76,6 +136,10 @@ export interface Tenant {
|
|
|
76
136
|
*/
|
|
77
137
|
name: string;
|
|
78
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* 租户信息映射
|
|
141
|
+
*/
|
|
142
|
+
export type TenantMap = Record<string, string>;
|
|
79
143
|
/**
|
|
80
144
|
* 用户对象接口
|
|
81
145
|
*/
|
|
@@ -110,89 +174,44 @@ export interface User {
|
|
|
110
174
|
username: string;
|
|
111
175
|
}
|
|
112
176
|
/**
|
|
113
|
-
*
|
|
177
|
+
* 用户群组配置
|
|
114
178
|
*/
|
|
115
|
-
export interface
|
|
179
|
+
export interface UserGroupConfig {
|
|
116
180
|
/**
|
|
117
|
-
*
|
|
181
|
+
* 是否隐藏
|
|
118
182
|
*/
|
|
119
|
-
|
|
183
|
+
hidden?: boolean;
|
|
120
184
|
/**
|
|
121
|
-
*
|
|
185
|
+
* 群组ID
|
|
122
186
|
*/
|
|
123
|
-
|
|
187
|
+
id: string;
|
|
124
188
|
/**
|
|
125
|
-
*
|
|
189
|
+
* 群组名称
|
|
126
190
|
*/
|
|
127
|
-
|
|
191
|
+
name: string;
|
|
128
192
|
}
|
|
129
193
|
/**
|
|
130
|
-
*
|
|
194
|
+
* 用户选择器属性
|
|
131
195
|
*/
|
|
132
|
-
interface BaseSelectorProps {
|
|
133
|
-
/**
|
|
134
|
-
* 是否允许创建用户
|
|
135
|
-
*/
|
|
136
|
-
allowCreate?: boolean;
|
|
137
|
-
/**
|
|
138
|
-
* 接口基础URL
|
|
139
|
-
*/
|
|
140
|
-
apiBaseUrl: string;
|
|
141
|
-
/**
|
|
142
|
-
* 本人ID
|
|
143
|
-
*/
|
|
144
|
-
currentUserId?: string;
|
|
145
|
-
/**
|
|
146
|
-
* 是否禁用
|
|
147
|
-
*/
|
|
148
|
-
disabled?: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* 无匹配人员时的提示文本
|
|
151
|
-
*/
|
|
152
|
-
emptyText?: string;
|
|
153
|
-
/**
|
|
154
|
-
* 是否启用多租户模式
|
|
155
|
-
*/
|
|
156
|
-
enableMultiTenantMode?: boolean;
|
|
157
|
-
/**
|
|
158
|
-
* 精确查找key
|
|
159
|
-
*/
|
|
160
|
-
exactSearchKey?: string;
|
|
161
|
-
/**
|
|
162
|
-
* 排除的用户ID列表
|
|
163
|
-
*/
|
|
164
|
-
excludeUserIds?: string[];
|
|
165
|
-
/**
|
|
166
|
-
* 是否允许粘贴任意文本
|
|
167
|
-
*/
|
|
168
|
-
freePaste?: boolean;
|
|
169
|
-
/**
|
|
170
|
-
* 占位文字
|
|
171
|
-
*/
|
|
172
|
-
placeholder?: string;
|
|
173
|
-
/**
|
|
174
|
-
* 租户ID
|
|
175
|
-
*/
|
|
176
|
-
tenantId: string;
|
|
196
|
+
export interface UserSelectorProps extends BaseSelectorProps {
|
|
177
197
|
/**
|
|
178
|
-
*
|
|
198
|
+
* 是否支持拖拽排序
|
|
179
199
|
*/
|
|
180
|
-
|
|
200
|
+
draggable?: boolean;
|
|
181
201
|
/**
|
|
182
|
-
*
|
|
202
|
+
* 最大可选数量(0 表示不限制)
|
|
183
203
|
*/
|
|
184
|
-
|
|
204
|
+
maxCount?: number;
|
|
185
205
|
/**
|
|
186
|
-
*
|
|
206
|
+
* 默认选中的用户(单选时为字符串,多选时为数组)
|
|
187
207
|
*/
|
|
188
|
-
|
|
208
|
+
modelValue?: string | string[];
|
|
189
209
|
/**
|
|
190
|
-
*
|
|
210
|
+
* 是否多选
|
|
191
211
|
*/
|
|
192
|
-
|
|
193
|
-
hidden?: boolean;
|
|
194
|
-
id: string;
|
|
195
|
-
name: string;
|
|
196
|
-
}[];
|
|
212
|
+
multiple?: boolean;
|
|
197
213
|
}
|
|
198
|
-
|
|
214
|
+
/**
|
|
215
|
+
* 用户类型
|
|
216
|
+
*/
|
|
217
|
+
export type UserType = (typeof USER_TYPE)[keyof typeof USER_TYPE];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 日志级别
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = 'debug' | 'error' | 'info' | 'warn';
|
|
5
|
+
/**
|
|
6
|
+
* 日志配置
|
|
7
|
+
*/
|
|
8
|
+
interface LoggerConfig {
|
|
9
|
+
/** 是否启用日志 */
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
/** 最小日志级别 */
|
|
12
|
+
level: LogLevel;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 配置日志
|
|
16
|
+
*/
|
|
17
|
+
export declare const configureLogger: (options: Partial<LoggerConfig>) => void;
|
|
18
|
+
/**
|
|
19
|
+
* 日志工具
|
|
20
|
+
*/
|
|
21
|
+
export declare const logger: {
|
|
22
|
+
/**
|
|
23
|
+
* 调试日志
|
|
24
|
+
*/
|
|
25
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* 信息日志
|
|
28
|
+
*/
|
|
29
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
30
|
+
/**
|
|
31
|
+
* 警告日志
|
|
32
|
+
*/
|
|
33
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
34
|
+
/**
|
|
35
|
+
* 错误日志
|
|
36
|
+
*/
|
|
37
|
+
error: (message: string, error?: unknown) => void;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* API 错误处理
|
|
41
|
+
*/
|
|
42
|
+
export declare const handleApiError: (operation: string, error: unknown) => void;
|
|
43
|
+
/**
|
|
44
|
+
* 参数校验警告
|
|
45
|
+
*/
|
|
46
|
+
export declare const warnMissingParams: (operation: string, params: string[]) => void;
|
|
47
|
+
export {};
|