@blueking/bk-user-selector 0.0.6 → 0.0.7

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
@@ -9,6 +9,7 @@
9
9
  - 支持跨租户显示
10
10
  - 支持拖拽排序(多选模式)
11
11
  - 支持快速选择当前用户
12
+ - 支持用户组显示
12
13
 
13
14
  ## 安装
14
15
 
@@ -118,6 +119,8 @@ import '@blueking/bk-user-selector/vue2/vue2.css';
118
119
  | tenantId | 租户 ID | String | '' |
119
120
  | exactSearchKey | 精确查找key,可选值为 bk_username、login_name、full_name, 多个以逗号分隔 | String | 'bk_username' |
120
121
  | currentUserId | 当前用户ID(用于快速选择"我") | String | '' |
122
+ | userGroup | 用户组列表,用于在下拉列表中显示用户组 | Array | [] |
123
+ | userGroupName | 用户组名称,用于在下拉列表中显示用户组名称 | String | '用户群组' |
121
124
 
122
125
  ### 事件
123
126
 
@@ -136,6 +139,27 @@ import '@blueking/bk-user-selector/vue2/vue2.css';
136
139
  - 在多选模式下,点击"我"会将当前用户添加到已选列表中(如果尚未选择)
137
140
  - 当当前用户已被选中时,"我"标签会显示为灰色且不可点击
138
141
 
142
+ ### 用户组显示
143
+
144
+ 当设置了`userGroup`属性后,组件会在下拉列表中显示用户组信息。用户组数据格式如下:
145
+
146
+ ```javascript
147
+ const userGroup = [
148
+ {
149
+ id: '1',
150
+ name: '运维人员',
151
+ },
152
+ {
153
+ id: '2',
154
+ name: '产品人员',
155
+ },
156
+ ];
157
+ ```
158
+
159
+ - 用户组会显示在下拉列表的"用户群组"分组中
160
+ - 用户组数据会展示在最前面
161
+ - 有用户组信息,focus 时就会展示下拉框
162
+
139
163
  ## 开发
140
164
 
141
165
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/bk-user-selector",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "蓝鲸用户选择器",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",
@@ -0,0 +1,39 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ /**
3
+ * 当前用户ID
4
+ */
5
+ currentUserId: {
6
+ type: StringConstructor;
7
+ default: string;
8
+ };
9
+ /**
10
+ * 是否禁用
11
+ */
12
+ isDisabled: {
13
+ type: BooleanConstructor;
14
+ default: boolean;
15
+ };
16
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
+ click: (...args: any[]) => void;
18
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ /**
20
+ * 当前用户ID
21
+ */
22
+ currentUserId: {
23
+ type: StringConstructor;
24
+ default: string;
25
+ };
26
+ /**
27
+ * 是否禁用
28
+ */
29
+ isDisabled: {
30
+ type: BooleanConstructor;
31
+ default: boolean;
32
+ };
33
+ }>> & {
34
+ onClick?: ((...args: any[]) => any) | undefined;
35
+ }, {
36
+ currentUserId: string;
37
+ isDisabled: boolean;
38
+ }, {}>;
39
+ export default _default;
@@ -63,6 +63,23 @@ declare const _default: import("vue").DefineComponent<{
63
63
  type: StringConstructor;
64
64
  default: string;
65
65
  };
66
+ /**
67
+ * 用户组
68
+ */
69
+ userGroup: {
70
+ type: () => {
71
+ id: string;
72
+ name: string;
73
+ }[];
74
+ default: () => never[];
75
+ };
76
+ /**
77
+ * 用户组名称
78
+ */
79
+ userGroupName: {
80
+ type: StringConstructor;
81
+ default: string;
82
+ };
66
83
  }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
67
84
  "update:selectedUsers": (...args: any[]) => void;
68
85
  "add-user": (...args: any[]) => void;
@@ -131,19 +148,41 @@ declare const _default: import("vue").DefineComponent<{
131
148
  type: StringConstructor;
132
149
  default: string;
133
150
  };
151
+ /**
152
+ * 用户组
153
+ */
154
+ userGroup: {
155
+ type: () => {
156
+ id: string;
157
+ name: string;
158
+ }[];
159
+ default: () => never[];
160
+ };
161
+ /**
162
+ * 用户组名称
163
+ */
164
+ userGroupName: {
165
+ type: StringConstructor;
166
+ default: string;
167
+ };
134
168
  }>> & {
135
169
  "onUpdate:selectedUsers"?: ((...args: any[]) => any) | undefined;
136
170
  "onAdd-user"?: ((...args: any[]) => any) | undefined;
137
171
  "onRemove-user"?: ((...args: any[]) => any) | undefined;
138
172
  }, {
139
173
  tenantId: string;
174
+ currentUserId: string;
140
175
  tenants: Record<string, string>;
176
+ userGroup: {
177
+ id: string;
178
+ name: string;
179
+ }[];
180
+ userGroupName: string;
141
181
  draggable: boolean;
142
182
  modelValue: unknown[];
143
183
  placeholder: string;
144
184
  apiBaseUrl: string;
145
185
  selectedUsers: FormattedUser[];
146
- currentUserId: string;
147
186
  exactSearchKey: string;
148
187
  }, {}>;
149
188
  export default _default;
@@ -0,0 +1,154 @@
1
+ import { FormattedUser } from '../types';
2
+ declare const _default: import("vue").DefineComponent<{
3
+ /**
4
+ * 是否显示下拉菜单
5
+ */
6
+ isShow: {
7
+ type: BooleanConstructor;
8
+ default: boolean;
9
+ };
10
+ /**
11
+ * 容器宽度
12
+ */
13
+ containerWidth: {
14
+ type: (StringConstructor | NumberConstructor)[];
15
+ default: string;
16
+ };
17
+ /**
18
+ * 是否加载中
19
+ */
20
+ loading: {
21
+ type: BooleanConstructor;
22
+ default: boolean;
23
+ };
24
+ /**
25
+ * 搜索结果选项
26
+ */
27
+ options: {
28
+ type: () => FormattedUser[];
29
+ default: () => never[];
30
+ };
31
+ /**
32
+ * 搜索关键词
33
+ */
34
+ searchQuery: {
35
+ type: StringConstructor;
36
+ default: string;
37
+ };
38
+ /**
39
+ * 当前租户ID
40
+ */
41
+ tenantId: {
42
+ type: StringConstructor;
43
+ default: string;
44
+ };
45
+ /**
46
+ * 租户信息映射
47
+ */
48
+ tenants: {
49
+ type: () => Record<string, string>;
50
+ default: () => {};
51
+ };
52
+ /**
53
+ * 用户组
54
+ */
55
+ userGroup: {
56
+ type: () => {
57
+ id: string;
58
+ name: string;
59
+ }[];
60
+ default: () => never[];
61
+ };
62
+ /**
63
+ * 用户组名称
64
+ */
65
+ userGroupName: {
66
+ type: StringConstructor;
67
+ default: string;
68
+ };
69
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
70
+ "select-user": (...args: any[]) => void;
71
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
72
+ /**
73
+ * 是否显示下拉菜单
74
+ */
75
+ isShow: {
76
+ type: BooleanConstructor;
77
+ default: boolean;
78
+ };
79
+ /**
80
+ * 容器宽度
81
+ */
82
+ containerWidth: {
83
+ type: (StringConstructor | NumberConstructor)[];
84
+ default: string;
85
+ };
86
+ /**
87
+ * 是否加载中
88
+ */
89
+ loading: {
90
+ type: BooleanConstructor;
91
+ default: boolean;
92
+ };
93
+ /**
94
+ * 搜索结果选项
95
+ */
96
+ options: {
97
+ type: () => FormattedUser[];
98
+ default: () => never[];
99
+ };
100
+ /**
101
+ * 搜索关键词
102
+ */
103
+ searchQuery: {
104
+ type: StringConstructor;
105
+ default: string;
106
+ };
107
+ /**
108
+ * 当前租户ID
109
+ */
110
+ tenantId: {
111
+ type: StringConstructor;
112
+ default: string;
113
+ };
114
+ /**
115
+ * 租户信息映射
116
+ */
117
+ tenants: {
118
+ type: () => Record<string, string>;
119
+ default: () => {};
120
+ };
121
+ /**
122
+ * 用户组
123
+ */
124
+ userGroup: {
125
+ type: () => {
126
+ id: string;
127
+ name: string;
128
+ }[];
129
+ default: () => never[];
130
+ };
131
+ /**
132
+ * 用户组名称
133
+ */
134
+ userGroupName: {
135
+ type: StringConstructor;
136
+ default: string;
137
+ };
138
+ }>> & {
139
+ "onSelect-user"?: ((...args: any[]) => any) | undefined;
140
+ }, {
141
+ tenantId: string;
142
+ isShow: boolean;
143
+ containerWidth: string | number;
144
+ loading: boolean;
145
+ options: FormattedUser[];
146
+ searchQuery: string;
147
+ tenants: Record<string, string>;
148
+ userGroup: {
149
+ id: string;
150
+ name: string;
151
+ }[];
152
+ userGroupName: string;
153
+ }, {}>;
154
+ export default _default;
@@ -8,6 +8,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
8
8
  multiple: boolean;
9
9
  currentUserId: string;
10
10
  exactSearchKey: string;
11
+ userGroup: () => never[];
12
+ userGroupName: string;
11
13
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
14
  change: (...args: any[]) => void;
13
15
  "update:modelValue": (...args: any[]) => void;
@@ -20,16 +22,23 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
20
22
  multiple: boolean;
21
23
  currentUserId: string;
22
24
  exactSearchKey: string;
25
+ userGroup: () => never[];
26
+ userGroupName: string;
23
27
  }>>> & {
24
28
  onChange?: ((...args: any[]) => any) | undefined;
25
29
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
26
30
  }, {
27
31
  tenantId: string;
32
+ currentUserId: string;
33
+ userGroup: {
34
+ id: string;
35
+ name: string;
36
+ }[];
37
+ userGroupName: string;
28
38
  draggable: boolean;
29
39
  modelValue: string | string[];
30
40
  placeholder: string;
31
41
  apiBaseUrl: string;
32
- currentUserId: string;
33
42
  exactSearchKey: string;
34
43
  multiple: boolean;
35
44
  }, {}>;
@@ -6,14 +6,18 @@ export interface User {
6
6
  * 用户名
7
7
  */
8
8
  bk_username: string;
9
- /**
10
- * 数据源类型
11
- */
12
- data_source_type: string;
13
9
  /**
14
10
  * 显示名称
15
11
  */
16
12
  display_name: string;
13
+ /**
14
+ * 所属租户ID
15
+ */
16
+ owner_tenant_id: string;
17
+ /**
18
+ * 数据源类型
19
+ */
20
+ data_source_type: string;
17
21
  /**
18
22
  * 全名
19
23
  */
@@ -22,10 +26,6 @@ export interface User {
22
26
  * 登录名, 对应内网企微英文名
23
27
  */
24
28
  login_name: string;
25
- /**
26
- * 所属租户ID
27
- */
28
- owner_tenant_id: string;
29
29
  }
30
30
  /**
31
31
  * 格式化后的用户信息
@@ -62,9 +62,9 @@ export interface Tenant {
62
62
  name: string;
63
63
  }
64
64
  /**
65
- * 用户选择器属性
65
+ * 基础选择器属性
66
66
  */
67
- export interface UserSelectorProps {
67
+ interface BaseSelectorProps {
68
68
  /**
69
69
  * 接口基础URL
70
70
  */
@@ -77,6 +77,30 @@ export interface UserSelectorProps {
77
77
  * 占位文字
78
78
  */
79
79
  placeholder?: string;
80
+ /**
81
+ * 本人ID
82
+ */
83
+ currentUserId?: string;
84
+ /**
85
+ * 精确查找key
86
+ */
87
+ exactSearchKey?: string;
88
+ /**
89
+ * 用户组配置
90
+ */
91
+ userGroup?: {
92
+ id: string;
93
+ name: string;
94
+ }[];
95
+ /**
96
+ * 用户组名称
97
+ */
98
+ userGroupName?: string;
99
+ }
100
+ /**
101
+ * 用户选择器属性
102
+ */
103
+ export interface UserSelectorProps extends BaseSelectorProps {
80
104
  /**
81
105
  * 默认选中的用户(单选时为字符串,多选时为数组)
82
106
  */
@@ -89,45 +113,18 @@ export interface UserSelectorProps {
89
113
  * 是否多选
90
114
  */
91
115
  multiple?: boolean;
92
- /**
93
- * 本人ID
94
- */
95
- currentUserId?: string;
96
- /**
97
- * 精确查找key, 默认是 bk_username, 可选值为 bk_username、login_name、full_name, 多个以逗号分隔
98
- */
99
- exactSearchKey?: string;
100
116
  }
101
117
  /**
102
118
  * 单选模式属性
103
119
  */
104
- export interface SingleSelectorProps {
120
+ export interface SingleSelectorProps extends BaseSelectorProps {
105
121
  /**
106
122
  * 选中的用户ID
107
123
  */
108
124
  modelValue?: string;
109
- /**
110
- * 占位文字
111
- */
112
- placeholder?: string;
113
- /**
114
- * 接口基础URL
115
- */
116
- apiBaseUrl?: string;
117
- /**
118
- * 租户ID
119
- */
120
- tenantId?: string;
121
125
  /**
122
126
  * 租户信息映射
123
127
  */
124
128
  tenants: Record<string, string>;
125
- /**
126
- * 本人ID
127
- */
128
- currentUserId?: string;
129
- /**
130
- * 精确查找key
131
- */
132
- exactSearchKey: string;
133
129
  }
130
+ export {};