@blueking/bk-user-selector 0.0.1-beta.1 → 0.0.2-9.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 +199 -1
- package/package.json +3 -5
- package/typings/api/user.d.ts +55 -0
- package/typings/components/me-tag.vue.d.ts +39 -0
- package/typings/components/multiple-selector.vue.d.ts +33 -0
- package/typings/components/selection-popover.vue.d.ts +205 -0
- package/typings/components/single-selector.vue.d.ts +28 -0
- package/typings/components/user-render.d.ts +37 -0
- package/typings/components/user-selector.vue.d.ts +33 -0
- package/typings/components/user-tag.vue.d.ts +68 -0
- package/typings/hooks/use-jsonp.d.ts +29 -0
- package/typings/hooks/useTenantData.d.ts +16 -0
- package/typings/hooks/useUserSearch.d.ts +20 -0
- package/typings/types/index.d.ts +186 -0
- package/typings/utils/common.d.ts +33 -0
- package/typings/vue2.d.ts +19 -1
- package/typings/vue3.d.ts +1 -1
- package/vue2/index.es.min.js +14532 -39859
- package/vue2/index.iife.min.js +16626 -44806
- package/vue2/index.umd.min.js +14538 -39865
- package/vue2/vue2.css +276 -2483
- package/vue3/index.es.min.js +4033 -7125
- package/vue3/index.iife.min.js +14527 -39856
- package/vue3/index.umd.min.js +4048 -7140
- package/vue3/vue3.css +119 -176
- package/typings/index.vue.d.ts +0 -22
- package/typings/single.vue.d.ts +0 -12
- package/typings/utils/index.d.ts +0 -59
- package/typings/utils/jsonp.d.ts +0 -4
- package/typings/utils/lang.d.ts +0 -3
- package/typings/utils/service.d.ts +0 -36
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createVNode, VNode } from 'vue';
|
|
2
|
+
import { FormattedUser } from '../types';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<{
|
|
4
|
+
/**
|
|
5
|
+
* 用户信息
|
|
6
|
+
*/
|
|
7
|
+
user: FormattedUser;
|
|
8
|
+
/**
|
|
9
|
+
* 租户数据映射
|
|
10
|
+
*/
|
|
11
|
+
tenants: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* 当前租户ID
|
|
14
|
+
*/
|
|
15
|
+
currentTenantId: string;
|
|
16
|
+
/**
|
|
17
|
+
* 是否可拖拽
|
|
18
|
+
*/
|
|
19
|
+
draggable?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 是否激活状态
|
|
22
|
+
*/
|
|
23
|
+
active?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 是否显示租户信息
|
|
26
|
+
*/
|
|
27
|
+
showTenant?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 渲染标签
|
|
30
|
+
*/
|
|
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<{
|
|
36
|
+
/**
|
|
37
|
+
* 用户信息
|
|
38
|
+
*/
|
|
39
|
+
user: FormattedUser;
|
|
40
|
+
/**
|
|
41
|
+
* 租户数据映射
|
|
42
|
+
*/
|
|
43
|
+
tenants: Record<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* 当前租户ID
|
|
46
|
+
*/
|
|
47
|
+
currentTenantId: string;
|
|
48
|
+
/**
|
|
49
|
+
* 是否可拖拽
|
|
50
|
+
*/
|
|
51
|
+
draggable?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* 是否激活状态
|
|
54
|
+
*/
|
|
55
|
+
active?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 是否显示租户信息
|
|
58
|
+
*/
|
|
59
|
+
showTenant?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* 渲染标签
|
|
62
|
+
*/
|
|
63
|
+
renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
|
|
64
|
+
}> & Readonly<{
|
|
65
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
66
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
67
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
68
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type MaybeRef, type ShallowRef } from 'vue';
|
|
2
|
+
export interface JSONPOptions {
|
|
3
|
+
/** 超时时间(毫秒),默认为 2 * 60 * 1000 */
|
|
4
|
+
timeout?: number;
|
|
5
|
+
/** 请求参数 */
|
|
6
|
+
params?: Record<string, string | undefined>;
|
|
7
|
+
}
|
|
8
|
+
export interface JSONPResult<T> {
|
|
9
|
+
/** 响应数据 */
|
|
10
|
+
data: ShallowRef<T | null>;
|
|
11
|
+
/** 加载状态 */
|
|
12
|
+
loading: ShallowRef<boolean>;
|
|
13
|
+
/** 错误信息 */
|
|
14
|
+
error: ShallowRef<Error | null>;
|
|
15
|
+
/** 手动触发请求的函数 */
|
|
16
|
+
refetch: () => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* JSONP 请求函数
|
|
20
|
+
*/
|
|
21
|
+
export declare const jsonpRequest: <T>(requestUrl: MaybeRef<string>, options?: JSONPOptions) => Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* useJSONP
|
|
24
|
+
* @param url 请求的 URL,可以是字符串或 ref
|
|
25
|
+
* @param options JSONP 选项配置
|
|
26
|
+
* @returns JSONPResult 包含数据、加载状态、错误信息和重新请求函数
|
|
27
|
+
*/
|
|
28
|
+
export declare const useJSONP: <T = unknown>(url: MaybeRef<string>, options?: JSONPOptions) => JSONPResult<T>;
|
|
29
|
+
export default useJSONP;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 租户数据处理 Hook
|
|
3
|
+
* @module hooks/useTenantData
|
|
4
|
+
*/
|
|
5
|
+
import { type Ref } from 'vue';
|
|
6
|
+
/**
|
|
7
|
+
* 使用租户数据的Hook
|
|
8
|
+
* @param apiBaseUrl - API基础URL
|
|
9
|
+
* @param tenantId - 租户ID
|
|
10
|
+
* @returns 租户数据和加载状态
|
|
11
|
+
*/
|
|
12
|
+
export declare const useTenantData: (apiBaseUrl: string, tenantId: string) => {
|
|
13
|
+
tenants: Ref<Record<string, string>, Record<string, string>>;
|
|
14
|
+
loading: Ref<boolean, boolean>;
|
|
15
|
+
fetchTenants: () => Promise<void>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用户搜索 Hook
|
|
3
|
+
* @module hooks/useUserSearch
|
|
4
|
+
*/
|
|
5
|
+
import { type Ref } from 'vue';
|
|
6
|
+
import { type FormattedUser } from '../types';
|
|
7
|
+
/**
|
|
8
|
+
* 使用用户搜索的Hook
|
|
9
|
+
* @param apiBaseUrl - API基础URL
|
|
10
|
+
* @param tenantId - 租户ID
|
|
11
|
+
* @returns 用户搜索相关状态和方法
|
|
12
|
+
*/
|
|
13
|
+
export declare const useUserSearch: (apiBaseUrl: string, tenantId: string) => {
|
|
14
|
+
searchResults: Ref<FormattedUser[], FormattedUser[]>;
|
|
15
|
+
loading: Ref<boolean, boolean>;
|
|
16
|
+
searchQuery: Ref<string, string>;
|
|
17
|
+
performSearch: (keyword: string) => Promise<void>;
|
|
18
|
+
handleSearchInput: (value: string) => void;
|
|
19
|
+
clearSearch: () => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { type createVNode } from 'vue';
|
|
2
|
+
import type { VNode } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* 用户对象接口
|
|
5
|
+
*/
|
|
6
|
+
export interface User {
|
|
7
|
+
/**
|
|
8
|
+
* 用户名
|
|
9
|
+
*/
|
|
10
|
+
bk_username: string;
|
|
11
|
+
/**
|
|
12
|
+
* 显示名称
|
|
13
|
+
*/
|
|
14
|
+
display_name: string;
|
|
15
|
+
/**
|
|
16
|
+
* 所属租户ID
|
|
17
|
+
*/
|
|
18
|
+
owner_tenant_id: string;
|
|
19
|
+
/**
|
|
20
|
+
* 数据源类型
|
|
21
|
+
*/
|
|
22
|
+
data_source_type: string;
|
|
23
|
+
/**
|
|
24
|
+
* 全名
|
|
25
|
+
*/
|
|
26
|
+
full_name: string;
|
|
27
|
+
/**
|
|
28
|
+
* 登录名, 对应内网企微英文名
|
|
29
|
+
*/
|
|
30
|
+
login_name: string;
|
|
31
|
+
/**
|
|
32
|
+
* 用户名 旧版
|
|
33
|
+
*/
|
|
34
|
+
username: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 格式化后的用户信息
|
|
38
|
+
*/
|
|
39
|
+
export interface FormattedUser {
|
|
40
|
+
/**
|
|
41
|
+
* 用户ID
|
|
42
|
+
*/
|
|
43
|
+
id: string;
|
|
44
|
+
/**
|
|
45
|
+
* 用户名称
|
|
46
|
+
*/
|
|
47
|
+
name: string;
|
|
48
|
+
/**
|
|
49
|
+
* 租户ID
|
|
50
|
+
*/
|
|
51
|
+
tenantId: string;
|
|
52
|
+
/**
|
|
53
|
+
* 是否隐藏
|
|
54
|
+
*/
|
|
55
|
+
hidden?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 其他属性
|
|
58
|
+
*/
|
|
59
|
+
[key: string]: boolean | string | undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 租户信息
|
|
63
|
+
*/
|
|
64
|
+
export interface Tenant {
|
|
65
|
+
/**
|
|
66
|
+
* 租户ID
|
|
67
|
+
*/
|
|
68
|
+
id: string;
|
|
69
|
+
/**
|
|
70
|
+
* 租户名称
|
|
71
|
+
*/
|
|
72
|
+
name: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 基础选择器属性
|
|
76
|
+
*/
|
|
77
|
+
interface BaseSelectorProps {
|
|
78
|
+
/**
|
|
79
|
+
* 接口基础URL
|
|
80
|
+
*/
|
|
81
|
+
apiBaseUrl: string;
|
|
82
|
+
/**
|
|
83
|
+
* 租户ID
|
|
84
|
+
*/
|
|
85
|
+
tenantId: string;
|
|
86
|
+
/**
|
|
87
|
+
* 占位文字
|
|
88
|
+
*/
|
|
89
|
+
placeholder?: string;
|
|
90
|
+
/**
|
|
91
|
+
* 本人ID
|
|
92
|
+
*/
|
|
93
|
+
currentUserId?: string;
|
|
94
|
+
/**
|
|
95
|
+
* 精确查找key
|
|
96
|
+
*/
|
|
97
|
+
exactSearchKey?: string;
|
|
98
|
+
/**
|
|
99
|
+
* 用户组配置
|
|
100
|
+
*/
|
|
101
|
+
userGroup?: {
|
|
102
|
+
id: string;
|
|
103
|
+
name: string;
|
|
104
|
+
hidden?: boolean;
|
|
105
|
+
}[];
|
|
106
|
+
/**
|
|
107
|
+
* 用户组名称
|
|
108
|
+
*/
|
|
109
|
+
userGroupName?: string;
|
|
110
|
+
/**
|
|
111
|
+
* 无匹配人员时的提示文本
|
|
112
|
+
*/
|
|
113
|
+
emptyText?: string;
|
|
114
|
+
/**
|
|
115
|
+
* 是否禁用
|
|
116
|
+
*/
|
|
117
|
+
disabled?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* 渲染列表项
|
|
120
|
+
*/
|
|
121
|
+
renderListItem?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
|
|
122
|
+
/**
|
|
123
|
+
* 渲染标签
|
|
124
|
+
*/
|
|
125
|
+
renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
|
|
126
|
+
/**
|
|
127
|
+
* 排除的用户ID列表
|
|
128
|
+
*/
|
|
129
|
+
excludeUserIds?: string[];
|
|
130
|
+
/**
|
|
131
|
+
* 是否启用多租户模式
|
|
132
|
+
*/
|
|
133
|
+
enableMultiTenantMode?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 用户选择器属性
|
|
137
|
+
*/
|
|
138
|
+
export interface UserSelectorProps extends BaseSelectorProps {
|
|
139
|
+
/**
|
|
140
|
+
* 默认选中的用户(单选时为字符串,多选时为数组)
|
|
141
|
+
*/
|
|
142
|
+
modelValue?: string | string[];
|
|
143
|
+
/**
|
|
144
|
+
* 是否支持拖拽排序
|
|
145
|
+
*/
|
|
146
|
+
draggable?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* 是否多选
|
|
149
|
+
*/
|
|
150
|
+
multiple?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* 单选模式属性
|
|
154
|
+
*/
|
|
155
|
+
export interface SingleSelectorProps extends BaseSelectorProps {
|
|
156
|
+
/**
|
|
157
|
+
* 选中的用户ID
|
|
158
|
+
*/
|
|
159
|
+
modelValue?: string;
|
|
160
|
+
/**
|
|
161
|
+
* 租户信息映射
|
|
162
|
+
*/
|
|
163
|
+
tenants: Record<string, string>;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 多选模式属性
|
|
167
|
+
*/
|
|
168
|
+
export interface MultipleSelectorProps extends BaseSelectorProps {
|
|
169
|
+
/**
|
|
170
|
+
* 选中的用户ID列表
|
|
171
|
+
*/
|
|
172
|
+
modelValue: string[];
|
|
173
|
+
/**
|
|
174
|
+
* 是否支持拖拽排序
|
|
175
|
+
*/
|
|
176
|
+
draggable?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* 已选用户列表
|
|
179
|
+
*/
|
|
180
|
+
selectedUsers: FormattedUser[];
|
|
181
|
+
/**
|
|
182
|
+
* 租户信息映射
|
|
183
|
+
*/
|
|
184
|
+
tenants: Record<string, string>;
|
|
185
|
+
}
|
|
186
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通用工具函数
|
|
3
|
+
* @module utils/common
|
|
4
|
+
*/
|
|
5
|
+
import { type FormattedUser } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* 防抖函数
|
|
8
|
+
* @param fn - 需要防抖的函数
|
|
9
|
+
* @param delay - 延迟时间(毫秒)
|
|
10
|
+
* @returns 防抖后的函数
|
|
11
|
+
*/
|
|
12
|
+
export declare const debounce: <T extends (...args: any[]) => any>(fn: T, delay: number) => (...args: Parameters<T>) => void;
|
|
13
|
+
/**
|
|
14
|
+
* 计算标签容器可见数量
|
|
15
|
+
* @param container - 容器元素
|
|
16
|
+
* @param items - 项目元素列表
|
|
17
|
+
* @param containerWidth - 容器宽度
|
|
18
|
+
* @returns 可见项目数量
|
|
19
|
+
*/
|
|
20
|
+
export declare const calculateVisibleTags: (container: HTMLElement, items: HTMLElement[] | NodeListOf<Element>, containerWidth: number) => number;
|
|
21
|
+
/**
|
|
22
|
+
* 转换用户数组为Map结构,方便快速查找
|
|
23
|
+
* @param users - 用户列表
|
|
24
|
+
* @returns 用户Map对象
|
|
25
|
+
*/
|
|
26
|
+
export declare const userArrayToMap: (users: FormattedUser[]) => Map<string, FormattedUser>;
|
|
27
|
+
/**
|
|
28
|
+
* 判断两个数组是否有值的变化
|
|
29
|
+
* @param arr1 - 数组1
|
|
30
|
+
* @param arr2 - 数组2
|
|
31
|
+
* @returns 是否有变化
|
|
32
|
+
*/
|
|
33
|
+
export declare const hasArrayChanged: (arr1?: any[], arr2?: any[]) => boolean;
|
package/typings/vue2.d.ts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import BkUserSelector from './components/user-selector.vue';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
model: {
|
|
4
|
+
prop: string;
|
|
5
|
+
event: string;
|
|
6
|
+
};
|
|
7
|
+
beforeDestroy(): void;
|
|
8
|
+
created(): void;
|
|
9
|
+
data(): {
|
|
10
|
+
app: null;
|
|
11
|
+
unWatchStack: never[];
|
|
12
|
+
};
|
|
13
|
+
mounted(): void;
|
|
14
|
+
name: string;
|
|
15
|
+
props: any;
|
|
16
|
+
render(createElement: any): any;
|
|
17
|
+
};
|
|
2
18
|
export default _default;
|
|
19
|
+
export { BkUserSelector };
|
|
20
|
+
export * from './types';
|
package/typings/vue3.d.ts
CHANGED