@blueking/bk-user-selector 0.0.37 → 0.0.38-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/bk-user-selector",
3
- "version": "0.0.37",
3
+ "version": "0.0.38-beta.2",
4
4
  "description": "蓝鲸用户选择器",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",
@@ -66,4 +66,4 @@
66
66
  "engines": {
67
67
  "node": ">=18.16.0"
68
68
  }
69
- }
69
+ }
@@ -1,4 +1,4 @@
1
- import { type User, type Tenant, type FormattedUser } from '../types';
1
+ import type { FormattedUser, Tenant, User } from '../types';
2
2
  /**
3
3
  * 获取本租户所有数据来源的租户信息
4
4
  * @param apiBaseUrl - API基础URL
@@ -15,9 +15,9 @@ export declare const getTenants: (apiBaseUrl: string, tenantId: string) => Promi
15
15
  */
16
16
  export declare const searchUsers: (params: {
17
17
  apiBaseUrl: string;
18
- tenantId: string;
19
- keyword: string;
20
18
  enableMultiTenantMode?: boolean;
19
+ keyword: string;
20
+ tenantId: string;
21
21
  }) => Promise<User[]>;
22
22
  /**
23
23
  * 批量精准查找用户
@@ -29,10 +29,10 @@ export declare const searchUsers: (params: {
29
29
  */
30
30
  export declare const lookupUsers: (params: {
31
31
  apiBaseUrl: string;
32
- tenantId: string;
32
+ enableMultiTenantMode?: boolean;
33
33
  exactSearchKey: string;
34
+ tenantId: string;
34
35
  usersList: string[];
35
- enableMultiTenantMode?: boolean;
36
36
  }) => Promise<User[]>;
37
37
  /**
38
38
  * 将API返回的用户数据格式化为组件所需格式
@@ -47,9 +47,9 @@ export declare const formatUsers: (users: User[], enableMultiTenantMode?: boolea
47
47
  * @returns 用户列表
48
48
  */
49
49
  export declare const getUserList: (url: string, params: {
50
- userIds?: string[];
50
+ appCode?: string;
51
51
  keyword?: string;
52
- pageSize?: number;
53
52
  page?: number;
54
- appCode?: string;
53
+ pageSize?: number;
54
+ userIds?: string[];
55
55
  }) => Promise<User[]>;
@@ -5,12 +5,16 @@ declare const _default: import("vue").DefineComponent<MultipleSelectorProps, {},
5
5
  "update:selectedUsers": (...args: any[]) => void;
6
6
  "add-user": (...args: any[]) => void;
7
7
  "remove-user": (...args: any[]) => void;
8
+ dragStart: (...args: any[]) => void;
9
+ dragEnd: (...args: any[]) => void;
8
10
  }, string, import("vue").PublicProps, Readonly<MultipleSelectorProps> & Readonly<{
9
11
  onBlur?: ((...args: any[]) => any) | undefined;
10
12
  onFocus?: ((...args: any[]) => any) | undefined;
11
13
  "onUpdate:selectedUsers"?: ((...args: any[]) => any) | undefined;
12
14
  "onAdd-user"?: ((...args: any[]) => any) | undefined;
13
15
  "onRemove-user"?: ((...args: any[]) => any) | undefined;
16
+ onDragStart?: ((...args: any[]) => any) | undefined;
17
+ onDragEnd?: ((...args: any[]) => any) | undefined;
14
18
  }>, {
15
19
  tenantId: string;
16
20
  apiBaseUrl: string;
@@ -18,21 +22,21 @@ declare const _default: import("vue").DefineComponent<MultipleSelectorProps, {},
18
22
  currentUserId: string;
19
23
  tenants: Record<string, string>;
20
24
  userGroup: {
21
- id: string;
22
- name: string;
23
25
  hidden
24
26
  /**
25
27
  * 多选模式用户选择器组件
26
28
  */
27
29
  ?: boolean;
30
+ id: string;
31
+ name: string;
28
32
  }[];
29
33
  userGroupName: string;
30
34
  emptyText: string;
31
35
  draggable: boolean;
32
36
  modelValue: string[];
33
37
  selectedUsers: FormattedUser[];
34
- placeholder: string;
35
- excludeUserIds: string[];
36
38
  allowCreate: boolean;
39
+ excludeUserIds: string[];
40
+ placeholder: string;
37
41
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
42
  export default _default;
@@ -76,9 +76,9 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
76
76
  */
77
77
  userGroup: {
78
78
  type: () => {
79
+ hidden?: boolean;
79
80
  id: string;
80
81
  name: string;
81
- hidden?: boolean;
82
82
  }[];
83
83
  default: () => never[];
84
84
  };
@@ -167,9 +167,9 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
167
167
  */
168
168
  userGroup: {
169
169
  type: () => {
170
+ hidden?: boolean;
170
171
  id: string;
171
172
  name: string;
172
- hidden?: boolean;
173
173
  }[];
174
174
  default: () => never[];
175
175
  };
@@ -206,9 +206,9 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
206
206
  options: FormattedUser[];
207
207
  searchQuery: string;
208
208
  userGroup: {
209
+ hidden?: boolean;
209
210
  id: string;
210
211
  name: string;
211
- hidden?: boolean;
212
212
  }[];
213
213
  userGroupName: string;
214
214
  emptyText: string;
@@ -15,18 +15,18 @@ declare const _default: import("vue").DefineComponent<SingleSelectorProps, {}, {
15
15
  exactSearchKey: string;
16
16
  currentUserId: string;
17
17
  userGroup: {
18
- id: string;
19
- name: string;
20
18
  hidden
21
19
  /**
22
20
  * 单选模式用户选择器组件
23
21
  */
24
22
  ?: boolean;
23
+ id: string;
24
+ name: string;
25
25
  }[];
26
26
  userGroupName: string;
27
27
  emptyText: string;
28
28
  modelValue: string;
29
- placeholder: string;
30
29
  excludeUserIds: string[];
30
+ placeholder: string;
31
31
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
32
32
  export default _default;
@@ -3,11 +3,15 @@ declare const _default: import("vue").DefineComponent<UserSelectorProps, {}, {},
3
3
  blur: (...args: any[]) => void;
4
4
  change: (...args: any[]) => void;
5
5
  focus: (...args: any[]) => void;
6
+ dragStart: (...args: any[]) => void;
7
+ dragEnd: (...args: any[]) => void;
6
8
  "update:modelValue": (...args: any[]) => void;
7
9
  }, string, import("vue").PublicProps, Readonly<UserSelectorProps> & Readonly<{
8
10
  onBlur?: ((...args: any[]) => any) | undefined;
9
11
  onChange?: ((...args: any[]) => any) | undefined;
10
12
  onFocus?: ((...args: any[]) => any) | undefined;
13
+ onDragStart?: ((...args: any[]) => any) | undefined;
14
+ onDragEnd?: ((...args: any[]) => any) | undefined;
11
15
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
12
16
  }>, {
13
17
  tenantId: string;
@@ -17,22 +21,22 @@ declare const _default: import("vue").DefineComponent<UserSelectorProps, {}, {},
17
21
  currentUserId: string;
18
22
  disabled: boolean;
19
23
  userGroup: {
20
- id: string;
21
- name: string;
22
24
  hidden
23
25
  /**
24
26
  * 蓝鲸用户选择器组件
25
27
  * @module components/UserSelector
26
28
  */
27
29
  ?: boolean;
30
+ id: string;
31
+ name: string;
28
32
  }[];
29
33
  userGroupName: string;
30
34
  emptyText: string;
31
35
  draggable: boolean;
32
36
  modelValue: string | string[];
33
- placeholder: string;
34
- excludeUserIds: string[];
35
37
  allowCreate: boolean;
38
+ excludeUserIds: string[];
39
+ placeholder: string;
36
40
  multiple: boolean;
37
41
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
42
  export default _default;
@@ -2,13 +2,9 @@ import { createVNode, VNode } from 'vue';
2
2
  import { FormattedUser } from '../types';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  /**
5
- * 用户信息
6
- */
7
- user: FormattedUser;
8
- /**
9
- * 租户数据映射
5
+ * 是否激活状态
10
6
  */
11
- tenants: Record<string, string>;
7
+ active?: boolean;
12
8
  /**
13
9
  * 当前租户ID
14
10
  */
@@ -18,29 +14,29 @@ declare const _default: import("vue").DefineComponent<{
18
14
  */
19
15
  draggable?: boolean;
20
16
  /**
21
- * 是否激活状态
17
+ * 渲染标签
22
18
  */
23
- active?: boolean;
19
+ renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
24
20
  /**
25
21
  * 是否显示租户信息
26
22
  */
27
23
  showTenant?: boolean;
28
24
  /**
29
- * 渲染标签
25
+ * 租户数据映射
30
26
  */
31
- renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
32
- }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
- click: (...args: any[]) => void;
34
- close: (...args: any[]) => void;
35
- }, string, import("vue").PublicProps, Readonly<{
27
+ tenants: Record<string, string>;
36
28
  /**
37
29
  * 用户信息
38
30
  */
39
31
  user: FormattedUser;
32
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
+ click: (...args: any[]) => void;
34
+ close: (...args: any[]) => void;
35
+ }, string, import("vue").PublicProps, Readonly<{
40
36
  /**
41
- * 租户数据映射
37
+ * 是否激活状态
42
38
  */
43
- tenants: Record<string, string>;
39
+ active?: boolean;
44
40
  /**
45
41
  * 当前租户ID
46
42
  */
@@ -50,17 +46,21 @@ declare const _default: import("vue").DefineComponent<{
50
46
  */
51
47
  draggable?: boolean;
52
48
  /**
53
- * 是否激活状态
49
+ * 渲染标签
54
50
  */
55
- active?: boolean;
51
+ renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
56
52
  /**
57
53
  * 是否显示租户信息
58
54
  */
59
55
  showTenant?: boolean;
60
56
  /**
61
- * 渲染标签
57
+ * 租户数据映射
62
58
  */
63
- renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
59
+ tenants: Record<string, string>;
60
+ /**
61
+ * 用户信息
62
+ */
63
+ user: FormattedUser;
64
64
  }> & Readonly<{
65
65
  onClick?: ((...args: any[]) => any) | undefined;
66
66
  onClose?: ((...args: any[]) => any) | undefined;
@@ -1,19 +1,19 @@
1
1
  import { type MaybeRef, type ShallowRef } from 'vue';
2
2
  export interface JSONPOptions {
3
- /** 超时时间(毫秒),默认为 2 * 60 * 1000 */
4
- timeout?: number;
5
3
  /** 请求参数 */
6
4
  params?: Record<string, string | undefined>;
5
+ /** 超时时间(毫秒),默认为 2 * 60 * 1000 */
6
+ timeout?: number;
7
7
  /** 是否携带凭证(cookie),默认为 true */
8
8
  withCredentials?: boolean;
9
9
  }
10
10
  export interface JSONPResult<T> {
11
11
  /** 响应数据 */
12
- data: ShallowRef<T | null>;
13
- /** 加载状态 */
14
- loading: ShallowRef<boolean>;
12
+ data: ShallowRef<null | T>;
15
13
  /** 错误信息 */
16
14
  error: ShallowRef<Error | null>;
15
+ /** 加载状态 */
16
+ loading: ShallowRef<boolean>;
17
17
  /** 手动触发请求的函数 */
18
18
  refetch: () => void;
19
19
  }
@@ -3,7 +3,7 @@
3
3
  * @module hooks/useUserSearch
4
4
  */
5
5
  import { type Ref } from 'vue';
6
- import { type FormattedUser } from '../types';
6
+ import type { FormattedUser } from '../types';
7
7
  /**
8
8
  * 使用用户搜索的Hook
9
9
  * @param apiBaseUrl - API基础URL
@@ -1,62 +1,63 @@
1
- import { type createVNode } from 'vue';
1
+ import type { createVNode } from 'vue';
2
2
  import type { VNode } from 'vue';
3
3
  /**
4
- * 用户对象接口
4
+ * 格式化后的用户信息
5
5
  */
6
- export interface User {
7
- /**
8
- * 用户名
9
- */
10
- bk_username: string;
11
- /**
12
- * 显示名称
13
- */
14
- display_name: string;
6
+ export interface FormattedUser {
15
7
  /**
16
- * 所属租户ID
8
+ * 其他属性
17
9
  */
18
- owner_tenant_id: string;
10
+ [key: string]: boolean | string | undefined;
19
11
  /**
20
- * 数据源类型
12
+ * 是否隐藏
21
13
  */
22
- data_source_type: string;
14
+ hidden?: boolean;
23
15
  /**
24
- * 全名
16
+ * 用户ID
25
17
  */
26
- full_name: string;
18
+ id: string;
27
19
  /**
28
- * 登录名, 对应内网企微英文名
20
+ * 用户名称
29
21
  */
30
- login_name: string;
22
+ name: string;
31
23
  /**
32
- * 用户名 旧版
24
+ * 租户ID
33
25
  */
34
- username: string;
26
+ tenantId: string;
35
27
  }
36
28
  /**
37
- * 格式化后的用户信息
29
+ * 多选模式属性
38
30
  */
39
- export interface FormattedUser {
31
+ export interface MultipleSelectorProps extends BaseSelectorProps {
40
32
  /**
41
- * 用户ID
33
+ * 是否支持拖拽排序
42
34
  */
43
- id: string;
35
+ draggable?: boolean;
44
36
  /**
45
- * 用户名称
37
+ * 选中的用户ID列表
46
38
  */
47
- name: string;
39
+ modelValue: string[];
48
40
  /**
49
- * 租户ID
41
+ * 已选用户列表
50
42
  */
51
- tenantId: string;
43
+ selectedUsers: FormattedUser[];
52
44
  /**
53
- * 是否隐藏
45
+ * 租户信息映射
54
46
  */
55
- hidden?: boolean;
47
+ tenants: Record<string, string>;
48
+ }
49
+ /**
50
+ * 单选模式属性
51
+ */
52
+ export interface SingleSelectorProps extends BaseSelectorProps {
56
53
  /**
57
- * 其他属性
54
+ * 选中的用户ID
58
55
  */
59
- [key: string]: boolean | string | undefined;
56
+ modelValue?: string;
57
+ /**
58
+ * 租户信息映射
59
+ */
60
+ tenants: Record<string, string>;
60
61
  }
61
62
  /**
62
63
  * 租户信息
@@ -72,119 +73,118 @@ export interface Tenant {
72
73
  name: string;
73
74
  }
74
75
  /**
75
- * 基础选择器属性
76
+ * 用户对象接口
76
77
  */
77
- interface BaseSelectorProps {
78
+ export interface User {
78
79
  /**
79
- * 接口基础URL
80
+ * 用户名
80
81
  */
81
- apiBaseUrl: string;
82
+ bk_username: string;
82
83
  /**
83
- * 租户ID
84
+ * 数据源类型
84
85
  */
85
- tenantId: string;
86
+ data_source_type: string;
86
87
  /**
87
- * 占位文字
88
+ * 显示名称
88
89
  */
89
- placeholder?: string;
90
+ display_name: string;
90
91
  /**
91
- * 本人ID
92
+ * 全名
92
93
  */
93
- currentUserId?: string;
94
+ full_name: string;
94
95
  /**
95
- * 精确查找key
96
+ * 登录名, 对应内网企微英文名
96
97
  */
97
- exactSearchKey?: string;
98
+ login_name: string;
98
99
  /**
99
- * 用户组配置
100
+ * 所属租户ID
100
101
  */
101
- userGroup?: {
102
- id: string;
103
- name: string;
104
- hidden?: boolean;
105
- }[];
102
+ owner_tenant_id: string;
106
103
  /**
107
- * 用户组名称
104
+ * 用户名 旧版
108
105
  */
109
- userGroupName?: string;
106
+ username: string;
107
+ }
108
+ /**
109
+ * 用户选择器属性
110
+ */
111
+ export interface UserSelectorProps extends BaseSelectorProps {
110
112
  /**
111
- * 无匹配人员时的提示文本
113
+ * 是否支持拖拽排序
112
114
  */
113
- emptyText?: string;
115
+ draggable?: boolean;
114
116
  /**
115
- * 是否禁用
117
+ * 默认选中的用户(单选时为字符串,多选时为数组)
116
118
  */
117
- disabled?: boolean;
119
+ modelValue?: string | string[];
118
120
  /**
119
- * 渲染列表项
121
+ * 是否多选
120
122
  */
121
- renderListItem?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
123
+ multiple?: boolean;
124
+ }
125
+ /**
126
+ * 基础选择器属性
127
+ */
128
+ interface BaseSelectorProps {
122
129
  /**
123
- * 渲染标签
130
+ * 是否允许创建用户
124
131
  */
125
- renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
132
+ allowCreate?: boolean;
126
133
  /**
127
- * 排除的用户ID列表
134
+ * 接口基础URL
128
135
  */
129
- excludeUserIds?: string[];
136
+ apiBaseUrl: string;
130
137
  /**
131
- * 是否启用多租户模式
138
+ * 本人ID
132
139
  */
133
- enableMultiTenantMode?: boolean;
140
+ currentUserId?: string;
134
141
  /**
135
- * 是否允许创建用户
142
+ * 是否禁用
136
143
  */
137
- allowCreate?: boolean;
138
- }
139
- /**
140
- * 用户选择器属性
141
- */
142
- export interface UserSelectorProps extends BaseSelectorProps {
144
+ disabled?: boolean;
143
145
  /**
144
- * 默认选中的用户(单选时为字符串,多选时为数组)
146
+ * 无匹配人员时的提示文本
145
147
  */
146
- modelValue?: string | string[];
148
+ emptyText?: string;
147
149
  /**
148
- * 是否支持拖拽排序
150
+ * 是否启用多租户模式
149
151
  */
150
- draggable?: boolean;
152
+ enableMultiTenantMode?: boolean;
151
153
  /**
152
- * 是否多选
154
+ * 精确查找key
153
155
  */
154
- multiple?: boolean;
155
- }
156
- /**
157
- * 单选模式属性
158
- */
159
- export interface SingleSelectorProps extends BaseSelectorProps {
156
+ exactSearchKey?: string;
160
157
  /**
161
- * 选中的用户ID
158
+ * 排除的用户ID列表
162
159
  */
163
- modelValue?: string;
160
+ excludeUserIds?: string[];
164
161
  /**
165
- * 租户信息映射
162
+ * 占位文字
166
163
  */
167
- tenants: Record<string, string>;
168
- }
169
- /**
170
- * 多选模式属性
171
- */
172
- export interface MultipleSelectorProps extends BaseSelectorProps {
164
+ placeholder?: string;
173
165
  /**
174
- * 选中的用户ID列表
166
+ * 租户ID
175
167
  */
176
- modelValue: string[];
168
+ tenantId: string;
177
169
  /**
178
- * 是否支持拖拽排序
170
+ * 用户组名称
179
171
  */
180
- draggable?: boolean;
172
+ userGroupName?: string;
181
173
  /**
182
- * 已选用户列表
174
+ * 渲染列表项
183
175
  */
184
- selectedUsers: FormattedUser[];
176
+ renderListItem?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
185
177
  /**
186
- * 租户信息映射
178
+ * 渲染标签
187
179
  */
188
- tenants: Record<string, string>;
180
+ renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
181
+ /**
182
+ * 用户组配置
183
+ */
184
+ userGroup?: {
185
+ hidden?: boolean;
186
+ id: string;
187
+ name: string;
188
+ }[];
189
189
  }
190
190
  export {};
@@ -2,7 +2,7 @@
2
2
  * 通用工具函数
3
3
  * @module utils/common
4
4
  */
5
- import { type FormattedUser } from '../types';
5
+ import type { FormattedUser } from '../types';
6
6
  /**
7
7
  * 防抖函数
8
8
  * @param fn - 需要防抖的函数