@blueking/bk-user-selector 0.0.38 → 0.0.39-beta.1

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 CHANGED
@@ -144,15 +144,16 @@ export default {
144
144
  | excludeUserIds | 排除的用户ID列表 | Array | [] |
145
145
  | enableMultiTenantMode | 是否启用多租户模式,关闭后则使用原有用户管理接口查询 | Boolean | true |
146
146
  | allowCreate | 是否允许自定义用户输入,按 Enter 确认 | Boolean | false |
147
+ | freePaste | 是否允许粘贴任意文本 | Boolean | false |
147
148
 
148
149
  ### 事件
149
150
 
150
- | 事件名称 | 说明 | 回调参数 |
151
- | ----------------- | ---------------- | ---------------- |
152
- | update:modelValue | 绑定值变化时触发 | 变化后的值 |
153
- | change | 选中值变化时触发 | 变化后的用户信息 |
154
- | focus | 输入框获得焦点时触发 | - |
155
- | blur | 输入框失去焦点时触发 | - |
151
+ | 事件名称 | 说明 | 回调参数 |
152
+ | ----------------- | -------------------- | ---------------- |
153
+ | update:modelValue | 绑定值变化时触发 | 变化后的值 |
154
+ | change | 选中值变化时触发 | 变化后的用户信息 |
155
+ | focus | 输入框获得焦点时触发 | - |
156
+ | blur | 输入框失去焦点时触发 | - |
156
157
 
157
158
  ## 功能说明
158
159
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/bk-user-selector",
3
- "version": "0.0.38",
3
+ "version": "0.0.39-beta.1",
4
4
  "description": "蓝鲸用户选择器",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",
@@ -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[]>;
@@ -22,21 +22,22 @@ declare const _default: import("vue").DefineComponent<MultipleSelectorProps, {},
22
22
  currentUserId: string;
23
23
  tenants: Record<string, string>;
24
24
  userGroup: {
25
- id: string;
26
- name: string;
27
25
  hidden
28
26
  /**
29
27
  * 多选模式用户选择器组件
30
28
  */
31
29
  ?: boolean;
30
+ id: string;
31
+ name: string;
32
32
  }[];
33
33
  userGroupName: string;
34
34
  emptyText: string;
35
35
  draggable: boolean;
36
+ freePaste: boolean;
36
37
  modelValue: string[];
37
38
  selectedUsers: FormattedUser[];
38
- placeholder: string;
39
- excludeUserIds: string[];
40
39
  allowCreate: boolean;
40
+ excludeUserIds: string[];
41
+ placeholder: string;
41
42
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
42
43
  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;
@@ -21,22 +21,23 @@ declare const _default: import("vue").DefineComponent<UserSelectorProps, {}, {},
21
21
  currentUserId: string;
22
22
  disabled: boolean;
23
23
  userGroup: {
24
- id: string;
25
- name: string;
26
24
  hidden
27
25
  /**
28
26
  * 蓝鲸用户选择器组件
29
27
  * @module components/UserSelector
30
28
  */
31
29
  ?: boolean;
30
+ id: string;
31
+ name: string;
32
32
  }[];
33
33
  userGroupName: string;
34
34
  emptyText: string;
35
35
  draggable: boolean;
36
+ freePaste: boolean;
36
37
  modelValue: string | string[];
37
- placeholder: string;
38
- excludeUserIds: string[];
39
38
  allowCreate: boolean;
39
+ excludeUserIds: string[];
40
+ placeholder: string;
40
41
  multiple: boolean;
41
42
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
42
43
  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,67 @@
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 {
6
+ export interface FormattedUser {
7
7
  /**
8
- * 用户名
8
+ * 其他属性
9
9
  */
10
- bk_username: string;
10
+ [key: string]: boolean | string | undefined;
11
11
  /**
12
- * 显示名称
12
+ * 是否隐藏
13
13
  */
14
- display_name: string;
14
+ hidden?: boolean;
15
15
  /**
16
- * 所属租户ID
16
+ * 用户ID
17
17
  */
18
- owner_tenant_id: string;
18
+ id: string;
19
19
  /**
20
- * 数据源类型
20
+ * 用户名称
21
21
  */
22
- data_source_type: string;
22
+ name: string;
23
23
  /**
24
- * 全名
24
+ * 租户ID
25
25
  */
26
- full_name: string;
26
+ tenantId: string;
27
+ }
28
+ /**
29
+ * 多选模式属性
30
+ */
31
+ export interface MultipleSelectorProps extends BaseSelectorProps {
27
32
  /**
28
- * 登录名, 对应内网企微英文名
33
+ * 是否允许粘贴任意文本
29
34
  */
30
- login_name: string;
35
+ freePaste?: boolean;
31
36
  /**
32
- * 用户名 旧版
37
+ * 是否支持拖拽排序
33
38
  */
34
- username: string;
35
- }
36
- /**
37
- * 格式化后的用户信息
38
- */
39
- export interface FormattedUser {
39
+ draggable?: boolean;
40
40
  /**
41
- * 用户ID
41
+ * 选中的用户ID列表
42
42
  */
43
- id: string;
43
+ modelValue: string[];
44
44
  /**
45
- * 用户名称
45
+ * 已选用户列表
46
46
  */
47
- name: string;
47
+ selectedUsers: FormattedUser[];
48
48
  /**
49
- * 租户ID
49
+ * 租户信息映射
50
50
  */
51
- tenantId: string;
51
+ tenants: Record<string, string>;
52
+ }
53
+ /**
54
+ * 单选模式属性
55
+ */
56
+ export interface SingleSelectorProps extends BaseSelectorProps {
52
57
  /**
53
- * 是否隐藏
58
+ * 选中的用户ID
54
59
  */
55
- hidden?: boolean;
60
+ modelValue?: string;
56
61
  /**
57
- * 其他属性
62
+ * 租户信息映射
58
63
  */
59
- [key: string]: boolean | string | undefined;
64
+ tenants: Record<string, string>;
60
65
  }
61
66
  /**
62
67
  * 租户信息
@@ -72,119 +77,122 @@ export interface Tenant {
72
77
  name: string;
73
78
  }
74
79
  /**
75
- * 基础选择器属性
80
+ * 用户对象接口
76
81
  */
77
- interface BaseSelectorProps {
82
+ export interface User {
78
83
  /**
79
- * 接口基础URL
84
+ * 用户名
80
85
  */
81
- apiBaseUrl: string;
86
+ bk_username: string;
82
87
  /**
83
- * 租户ID
88
+ * 数据源类型
84
89
  */
85
- tenantId: string;
90
+ data_source_type: string;
86
91
  /**
87
- * 占位文字
92
+ * 显示名称
88
93
  */
89
- placeholder?: string;
94
+ display_name: string;
90
95
  /**
91
- * 本人ID
96
+ * 全名
92
97
  */
93
- currentUserId?: string;
98
+ full_name: string;
94
99
  /**
95
- * 精确查找key
100
+ * 登录名, 对应内网企微英文名
96
101
  */
97
- exactSearchKey?: string;
102
+ login_name: string;
98
103
  /**
99
- * 用户组配置
104
+ * 所属租户ID
100
105
  */
101
- userGroup?: {
102
- id: string;
103
- name: string;
104
- hidden?: boolean;
105
- }[];
106
+ owner_tenant_id: string;
106
107
  /**
107
- * 用户组名称
108
+ * 用户名 旧版
108
109
  */
109
- userGroupName?: string;
110
+ username: string;
111
+ }
112
+ /**
113
+ * 用户选择器属性
114
+ */
115
+ export interface UserSelectorProps extends BaseSelectorProps {
110
116
  /**
111
- * 无匹配人员时的提示文本
117
+ * 是否支持拖拽排序
112
118
  */
113
- emptyText?: string;
119
+ draggable?: boolean;
114
120
  /**
115
- * 是否禁用
121
+ * 默认选中的用户(单选时为字符串,多选时为数组)
116
122
  */
117
- disabled?: boolean;
123
+ modelValue?: string | string[];
118
124
  /**
119
- * 渲染列表项
125
+ * 是否多选
120
126
  */
121
- renderListItem?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
127
+ multiple?: boolean;
128
+ }
129
+ /**
130
+ * 基础选择器属性
131
+ */
132
+ interface BaseSelectorProps {
122
133
  /**
123
- * 渲染标签
134
+ * 是否允许创建用户
124
135
  */
125
- renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
136
+ allowCreate?: boolean;
126
137
  /**
127
- * 排除的用户ID列表
138
+ * 是否允许粘贴任意文本
128
139
  */
129
- excludeUserIds?: string[];
140
+ freePaste?: boolean;
130
141
  /**
131
- * 是否启用多租户模式
142
+ * 接口基础URL
132
143
  */
133
- enableMultiTenantMode?: boolean;
144
+ apiBaseUrl: string;
134
145
  /**
135
- * 是否允许创建用户
146
+ * 本人ID
136
147
  */
137
- allowCreate?: boolean;
138
- }
139
- /**
140
- * 用户选择器属性
141
- */
142
- export interface UserSelectorProps extends BaseSelectorProps {
148
+ currentUserId?: string;
143
149
  /**
144
- * 默认选中的用户(单选时为字符串,多选时为数组)
150
+ * 是否禁用
145
151
  */
146
- modelValue?: string | string[];
152
+ disabled?: boolean;
147
153
  /**
148
- * 是否支持拖拽排序
154
+ * 无匹配人员时的提示文本
149
155
  */
150
- draggable?: boolean;
156
+ emptyText?: string;
151
157
  /**
152
- * 是否多选
158
+ * 是否启用多租户模式
153
159
  */
154
- multiple?: boolean;
155
- }
156
- /**
157
- * 单选模式属性
158
- */
159
- export interface SingleSelectorProps extends BaseSelectorProps {
160
+ enableMultiTenantMode?: boolean;
160
161
  /**
161
- * 选中的用户ID
162
+ * 精确查找key
162
163
  */
163
- modelValue?: string;
164
+ exactSearchKey?: string;
164
165
  /**
165
- * 租户信息映射
166
+ * 排除的用户ID列表
166
167
  */
167
- tenants: Record<string, string>;
168
- }
169
- /**
170
- * 多选模式属性
171
- */
172
- export interface MultipleSelectorProps extends BaseSelectorProps {
168
+ excludeUserIds?: string[];
173
169
  /**
174
- * 选中的用户ID列表
170
+ * 占位文字
175
171
  */
176
- modelValue: string[];
172
+ placeholder?: string;
177
173
  /**
178
- * 是否支持拖拽排序
174
+ * 租户ID
179
175
  */
180
- draggable?: boolean;
176
+ tenantId: string;
181
177
  /**
182
- * 已选用户列表
178
+ * 用户组名称
183
179
  */
184
- selectedUsers: FormattedUser[];
180
+ userGroupName?: string;
185
181
  /**
186
- * 租户信息映射
182
+ * 渲染列表项
187
183
  */
188
- tenants: Record<string, string>;
184
+ renderListItem?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
185
+ /**
186
+ * 渲染标签
187
+ */
188
+ renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
189
+ /**
190
+ * 用户组配置
191
+ */
192
+ userGroup?: {
193
+ hidden?: boolean;
194
+ id: string;
195
+ name: string;
196
+ }[];
189
197
  }
190
198
  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 - 需要防抖的函数