@blueking/bk-user-selector 0.0.17 → 0.0.19
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 +2 -1
- package/package.json +1 -1
- package/typings/components/selection-popover.vue.d.ts +3 -0
- package/typings/types/index.d.ts +15 -1
- package/vue2/index.es.min.js +47 -45
- package/vue2/index.iife.min.js +48 -46
- package/vue2/index.umd.min.js +48 -46
- package/vue2/vue2.css +16 -16
- package/vue3/index.es.min.js +47 -45
- package/vue3/index.iife.min.js +48 -46
- package/vue3/index.umd.min.js +48 -46
- package/vue3/vue3.css +16 -16
package/README.md
CHANGED
|
@@ -92,11 +92,12 @@ import '@blueking/bk-user-selector/vue2/vue2.css';
|
|
|
92
92
|
const selectedUser = ref('');
|
|
93
93
|
// 多选选中值
|
|
94
94
|
const selectedUsers = ref([]);
|
|
95
|
-
//
|
|
95
|
+
// 用户组, hidden 为 true 时,不会展示在下拉列表里,但回显时会展示
|
|
96
96
|
const userGroup = ref([
|
|
97
97
|
{
|
|
98
98
|
id: '1',
|
|
99
99
|
name: '运维人员',
|
|
100
|
+
hidden: true,
|
|
100
101
|
},
|
|
101
102
|
{
|
|
102
103
|
id: '2',
|
package/package.json
CHANGED
|
@@ -56,6 +56,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
56
56
|
type: () => {
|
|
57
57
|
id: string;
|
|
58
58
|
name: string;
|
|
59
|
+
hidden?: boolean;
|
|
59
60
|
}[];
|
|
60
61
|
default: () => never[];
|
|
61
62
|
};
|
|
@@ -132,6 +133,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
132
133
|
type: () => {
|
|
133
134
|
id: string;
|
|
134
135
|
name: string;
|
|
136
|
+
hidden?: boolean;
|
|
135
137
|
}[];
|
|
136
138
|
default: () => never[];
|
|
137
139
|
};
|
|
@@ -162,6 +164,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
162
164
|
userGroup: {
|
|
163
165
|
id: string;
|
|
164
166
|
name: string;
|
|
167
|
+
hidden?: boolean;
|
|
165
168
|
}[];
|
|
166
169
|
userGroupName: string;
|
|
167
170
|
emptyText: string;
|
package/typings/types/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type createVNode } from 'vue';
|
|
2
|
+
import type { VNode } from 'vue';
|
|
1
3
|
/**
|
|
2
4
|
* 用户对象接口
|
|
3
5
|
*/
|
|
@@ -43,10 +45,14 @@ export interface FormattedUser {
|
|
|
43
45
|
* 租户ID
|
|
44
46
|
*/
|
|
45
47
|
tenantId: string;
|
|
48
|
+
/**
|
|
49
|
+
* 是否隐藏
|
|
50
|
+
*/
|
|
51
|
+
hidden?: boolean;
|
|
46
52
|
/**
|
|
47
53
|
* 其他属性
|
|
48
54
|
*/
|
|
49
|
-
[key: string]: string;
|
|
55
|
+
[key: string]: boolean | string | undefined;
|
|
50
56
|
}
|
|
51
57
|
/**
|
|
52
58
|
* 租户信息
|
|
@@ -100,6 +106,14 @@ interface BaseSelectorProps {
|
|
|
100
106
|
* 无匹配人员时的提示文本
|
|
101
107
|
*/
|
|
102
108
|
emptyText?: string;
|
|
109
|
+
/**
|
|
110
|
+
* 渲染列表项
|
|
111
|
+
*/
|
|
112
|
+
renderListItem?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
|
|
113
|
+
/**
|
|
114
|
+
* 渲染标签
|
|
115
|
+
*/
|
|
116
|
+
renderTag?: (h: typeof createVNode, userInfo: FormattedUser) => VNode;
|
|
103
117
|
}
|
|
104
118
|
/**
|
|
105
119
|
* 用户选择器属性
|
package/vue2/index.es.min.js
CHANGED
|
@@ -16697,10 +16697,8 @@ const _hoisted_1$4 = {
|
|
|
16697
16697
|
const _hoisted_2$3 = { class: "group-name" };
|
|
16698
16698
|
const _hoisted_3$3 = { class: "group-count" };
|
|
16699
16699
|
const _hoisted_4$1 = ["onMousedown"];
|
|
16700
|
-
const _hoisted_5 = {
|
|
16701
|
-
|
|
16702
|
-
const _hoisted_7 = {
|
|
16703
|
-
key: 2,
|
|
16700
|
+
const _hoisted_5 = {
|
|
16701
|
+
key: 0,
|
|
16704
16702
|
class: "tenant-name"
|
|
16705
16703
|
};
|
|
16706
16704
|
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
@@ -16787,9 +16785,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16787
16785
|
const groupedUsers = computed(() => {
|
|
16788
16786
|
const groups = {};
|
|
16789
16787
|
if (Array.isArray(props2.userGroup) && props2.userGroup.length > 0) {
|
|
16790
|
-
groups[props2.userGroupName] = props2.userGroup.map((group) => ({
|
|
16791
|
-
|
|
16792
|
-
name: group.name,
|
|
16788
|
+
groups[props2.userGroupName] = props2.userGroup.filter((group) => !group.hidden).map((group) => ({
|
|
16789
|
+
...group,
|
|
16793
16790
|
tenantId: "",
|
|
16794
16791
|
type: "userGroup"
|
|
16795
16792
|
}));
|
|
@@ -16876,26 +16873,22 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16876
16873
|
key: user.id,
|
|
16877
16874
|
onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
|
|
16878
16875
|
}, [
|
|
16879
|
-
|
|
16880
|
-
|
|
16881
|
-
|
|
16882
|
-
|
|
16883
|
-
|
|
16884
|
-
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16890
|
-
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
"
|
|
16894
|
-
|
|
16895
|
-
"@" + toDisplayString(__props.tenants[user.tenantId]),
|
|
16896
|
-
1
|
|
16897
|
-
/* TEXT */
|
|
16898
|
-
)) : createCommentVNode("v-if", true)
|
|
16876
|
+
createElementVNode("div", null, [
|
|
16877
|
+
createElementVNode(
|
|
16878
|
+
"span",
|
|
16879
|
+
null,
|
|
16880
|
+
toDisplayString(user.name),
|
|
16881
|
+
1
|
|
16882
|
+
/* TEXT */
|
|
16883
|
+
),
|
|
16884
|
+
user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
16885
|
+
"span",
|
|
16886
|
+
_hoisted_5,
|
|
16887
|
+
"@" + toDisplayString(__props.tenants[user.tenantId]),
|
|
16888
|
+
1
|
|
16889
|
+
/* TEXT */
|
|
16890
|
+
)) : createCommentVNode("v-if", true)
|
|
16891
|
+
])
|
|
16899
16892
|
], 40, _hoisted_4$1);
|
|
16900
16893
|
}),
|
|
16901
16894
|
128
|
|
@@ -16917,7 +16910,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16917
16910
|
};
|
|
16918
16911
|
}
|
|
16919
16912
|
});
|
|
16920
|
-
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
16913
|
+
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-f47cc878"]]);
|
|
16921
16914
|
const _hoisted_1$3 = { class: "tag-content" };
|
|
16922
16915
|
const _hoisted_2$2 = { class: "user-name" };
|
|
16923
16916
|
const _hoisted_3$2 = {
|
|
@@ -16998,7 +16991,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
16998
16991
|
exactSearchKey: { default: "bk_username" },
|
|
16999
16992
|
userGroup: { default: () => [] },
|
|
17000
16993
|
userGroupName: { default: "用户群组" },
|
|
17001
|
-
emptyText: { default: "无匹配人员" }
|
|
16994
|
+
emptyText: { default: "无匹配人员" },
|
|
16995
|
+
renderListItem: {},
|
|
16996
|
+
renderTag: {}
|
|
17002
16997
|
},
|
|
17003
16998
|
emits: ["update:selectedUsers", "add-user", "remove-user"],
|
|
17004
16999
|
setup(__props, { emit: __emit }) {
|
|
@@ -17443,7 +17438,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
17443
17438
|
}
|
|
17444
17439
|
});
|
|
17445
17440
|
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-1b988eae"]]);
|
|
17446
|
-
const _withScopeId = (n2) => (pushScopeId("data-v-
|
|
17441
|
+
const _withScopeId = (n2) => (pushScopeId("data-v-5040d42f"), n2 = n2(), popScopeId(), n2);
|
|
17447
17442
|
const _hoisted_1$1 = { class: "input-container" };
|
|
17448
17443
|
const _hoisted_2 = {
|
|
17449
17444
|
key: 0,
|
|
@@ -17472,7 +17467,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17472
17467
|
exactSearchKey: { default: "bk_username" },
|
|
17473
17468
|
userGroup: { default: () => [] },
|
|
17474
17469
|
userGroupName: { default: "用户群组" },
|
|
17475
|
-
emptyText: { default: "无匹配人员" }
|
|
17470
|
+
emptyText: { default: "无匹配人员" },
|
|
17471
|
+
renderListItem: {},
|
|
17472
|
+
renderTag: {}
|
|
17476
17473
|
},
|
|
17477
17474
|
emits: ["update:modelValue", "change"],
|
|
17478
17475
|
setup(__props, { emit: __emit }) {
|
|
@@ -17487,9 +17484,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17487
17484
|
const showDropdown = ref(false);
|
|
17488
17485
|
const selectedUserInfo = computed(() => {
|
|
17489
17486
|
const userGroup = (props2.userGroup || []).map((group) => ({
|
|
17490
|
-
|
|
17491
|
-
|
|
17492
|
-
|
|
17487
|
+
...group,
|
|
17488
|
+
tenantId: "",
|
|
17489
|
+
type: "userGroup"
|
|
17493
17490
|
}));
|
|
17494
17491
|
const list = [...options.value, ...userGroup];
|
|
17495
17492
|
const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
|
|
@@ -17507,8 +17504,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17507
17504
|
if (props2.userGroup.length > 0) {
|
|
17508
17505
|
const groupResult = props2.userGroup.filter((group) => group.id == props2.modelValue);
|
|
17509
17506
|
options.value = groupResult.map((group) => ({
|
|
17510
|
-
|
|
17511
|
-
name: group.name,
|
|
17507
|
+
...group,
|
|
17512
17508
|
tenantId: "",
|
|
17513
17509
|
type: "userGroup"
|
|
17514
17510
|
}));
|
|
@@ -17641,7 +17637,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17641
17637
|
};
|
|
17642
17638
|
}
|
|
17643
17639
|
});
|
|
17644
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
17640
|
+
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-5040d42f"]]);
|
|
17645
17641
|
const _hoisted_1 = {
|
|
17646
17642
|
ref: "containerRef",
|
|
17647
17643
|
class: "bk-user-selector"
|
|
@@ -17662,7 +17658,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17662
17658
|
exactSearchKey: { default: "bk_username" },
|
|
17663
17659
|
userGroup: { default: () => [] },
|
|
17664
17660
|
userGroupName: { default: "用户群组" },
|
|
17665
|
-
emptyText: { default: "无匹配人员" }
|
|
17661
|
+
emptyText: { default: "无匹配人员" },
|
|
17662
|
+
renderListItem: {},
|
|
17663
|
+
renderTag: {}
|
|
17666
17664
|
},
|
|
17667
17665
|
emits: ["update:modelValue", "change"],
|
|
17668
17666
|
setup(__props, { emit: __emit }) {
|
|
@@ -17677,11 +17675,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17677
17675
|
const initSelectedUsers = async () => {
|
|
17678
17676
|
if (props2.multiple) {
|
|
17679
17677
|
const ids = Array.isArray(props2.modelValue) ? props2.modelValue : [];
|
|
17678
|
+
let selected = [];
|
|
17680
17679
|
if (props2.userGroup.length > 0) {
|
|
17681
17680
|
const result = props2.userGroup.filter((group) => ids.includes(group.id));
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
name: group.name,
|
|
17681
|
+
selected = result.map((group) => ({
|
|
17682
|
+
...group,
|
|
17685
17683
|
tenantId: "",
|
|
17686
17684
|
type: "userGroup"
|
|
17687
17685
|
}));
|
|
@@ -17689,7 +17687,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17689
17687
|
if (ids.length > 0) {
|
|
17690
17688
|
try {
|
|
17691
17689
|
const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactSearchKey, ids);
|
|
17692
|
-
selectedUsers.value = [...
|
|
17690
|
+
selectedUsers.value = [...selected, ...formatUsers(result)];
|
|
17693
17691
|
} catch (error3) {
|
|
17694
17692
|
console.error("获取选中用户信息失败:", error3);
|
|
17695
17693
|
}
|
|
@@ -17738,12 +17736,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17738
17736
|
"empty-text": _ctx.emptyText,
|
|
17739
17737
|
"exact-search-key": _ctx.exactSearchKey,
|
|
17740
17738
|
placeholder: _ctx.placeholder,
|
|
17739
|
+
"render-list-item": _ctx.renderListItem,
|
|
17740
|
+
"render-tag": _ctx.renderTag,
|
|
17741
17741
|
"tenant-id": _ctx.tenantId,
|
|
17742
17742
|
tenants: unref(tenants),
|
|
17743
17743
|
"user-group": _ctx.userGroup,
|
|
17744
17744
|
"user-group-name": _ctx.userGroupName,
|
|
17745
17745
|
onChange: handleUpdateUser
|
|
17746
|
-
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "empty-text", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
|
|
17746
|
+
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "empty-text", "exact-search-key", "placeholder", "render-list-item", "render-tag", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
|
|
17747
17747
|
Fragment,
|
|
17748
17748
|
{ key: 1 },
|
|
17749
17749
|
[
|
|
@@ -17757,13 +17757,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17757
17757
|
"empty-text": _ctx.emptyText,
|
|
17758
17758
|
"exact-search-key": _ctx.exactSearchKey,
|
|
17759
17759
|
placeholder: _ctx.placeholder,
|
|
17760
|
+
"render-list-item": _ctx.renderListItem,
|
|
17761
|
+
"render-tag": _ctx.renderTag,
|
|
17760
17762
|
"selected-users": selectedUsers.value,
|
|
17761
17763
|
"tenant-id": _ctx.tenantId,
|
|
17762
17764
|
tenants: unref(tenants),
|
|
17763
17765
|
"user-group": _ctx.userGroup,
|
|
17764
17766
|
"user-group-name": _ctx.userGroupName,
|
|
17765
17767
|
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
17766
|
-
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "empty-text", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
17768
|
+
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "empty-text", "exact-search-key", "placeholder", "render-list-item", "render-tag", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
17767
17769
|
],
|
|
17768
17770
|
2112
|
|
17769
17771
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
@@ -17775,7 +17777,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17775
17777
|
};
|
|
17776
17778
|
}
|
|
17777
17779
|
});
|
|
17778
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
17780
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c23f5bc9"]]);
|
|
17779
17781
|
const vue2 = {
|
|
17780
17782
|
model: {
|
|
17781
17783
|
prop: "modelValue",
|