@blueking/bk-user-selector 0.0.16 → 0.0.18
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 +1 -1
- package/typings/components/render-tag.d.ts +8 -0
- package/typings/components/selection-popover.vue.d.ts +3 -0
- package/typings/types/index.d.ts +15 -1
- package/vue2/index.es.min.js +57 -41
- package/vue2/index.iife.min.js +58 -42
- package/vue2/index.umd.min.js +58 -42
- package/vue2/vue2.css +16 -16
- package/vue3/index.es.min.js +57 -41
- package/vue3/index.iife.min.js +58 -42
- package/vue3/index.umd.min.js +58 -42
- package/vue3/vue3.css +16 -16
package/package.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
renderTag: FunctionConstructor;
|
|
3
|
+
userInfo: ObjectConstructor;
|
|
4
|
+
}, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
5
|
+
renderTag: FunctionConstructor;
|
|
6
|
+
userInfo: ObjectConstructor;
|
|
7
|
+
}>>, {}, {}>;
|
|
8
|
+
export default _default;
|
|
@@ -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
|
@@ -16787,9 +16787,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16787
16787
|
const groupedUsers = computed(() => {
|
|
16788
16788
|
const groups = {};
|
|
16789
16789
|
if (Array.isArray(props2.userGroup) && props2.userGroup.length > 0) {
|
|
16790
|
-
groups[props2.userGroupName] = props2.userGroup.map((group) => ({
|
|
16791
|
-
|
|
16792
|
-
name: group.name,
|
|
16790
|
+
groups[props2.userGroupName] = props2.userGroup.filter((group) => !group.hidden).map((group) => ({
|
|
16791
|
+
...group,
|
|
16793
16792
|
tenantId: "",
|
|
16794
16793
|
type: "userGroup"
|
|
16795
16794
|
}));
|
|
@@ -16876,26 +16875,28 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16876
16875
|
key: user.id,
|
|
16877
16876
|
onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
|
|
16878
16877
|
}, [
|
|
16879
|
-
|
|
16880
|
-
|
|
16881
|
-
|
|
16882
|
-
|
|
16883
|
-
|
|
16884
|
-
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16890
|
-
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16878
|
+
createElementVNode("div", null, [
|
|
16879
|
+
user.login_name ? (openBlock(), createElementBlock(
|
|
16880
|
+
"span",
|
|
16881
|
+
_hoisted_5,
|
|
16882
|
+
toDisplayString(user.login_name) + "(" + toDisplayString(user.name) + ")",
|
|
16883
|
+
1
|
|
16884
|
+
/* TEXT */
|
|
16885
|
+
)) : (openBlock(), createElementBlock(
|
|
16886
|
+
"span",
|
|
16887
|
+
_hoisted_6,
|
|
16888
|
+
toDisplayString(user.name),
|
|
16889
|
+
1
|
|
16890
|
+
/* TEXT */
|
|
16891
|
+
)),
|
|
16892
|
+
user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
16893
|
+
"span",
|
|
16894
|
+
_hoisted_7,
|
|
16895
|
+
"@" + toDisplayString(__props.tenants[user.tenantId]),
|
|
16896
|
+
1
|
|
16897
|
+
/* TEXT */
|
|
16898
|
+
)) : createCommentVNode("v-if", true)
|
|
16899
|
+
])
|
|
16899
16900
|
], 40, _hoisted_4$1);
|
|
16900
16901
|
}),
|
|
16901
16902
|
128
|
|
@@ -16917,7 +16918,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16917
16918
|
};
|
|
16918
16919
|
}
|
|
16919
16920
|
});
|
|
16920
|
-
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
16921
|
+
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-7bcec2be"]]);
|
|
16921
16922
|
const _hoisted_1$3 = { class: "tag-content" };
|
|
16922
16923
|
const _hoisted_2$2 = { class: "user-name" };
|
|
16923
16924
|
const _hoisted_3$2 = {
|
|
@@ -16998,7 +16999,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
16998
16999
|
exactSearchKey: { default: "bk_username" },
|
|
16999
17000
|
userGroup: { default: () => [] },
|
|
17000
17001
|
userGroupName: { default: "用户群组" },
|
|
17001
|
-
emptyText: { default: "无匹配人员" }
|
|
17002
|
+
emptyText: { default: "无匹配人员" },
|
|
17003
|
+
renderListItem: {},
|
|
17004
|
+
renderTag: {}
|
|
17002
17005
|
},
|
|
17003
17006
|
emits: ["update:selectedUsers", "add-user", "remove-user"],
|
|
17004
17007
|
setup(__props, { emit: __emit }) {
|
|
@@ -17443,7 +17446,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
17443
17446
|
}
|
|
17444
17447
|
});
|
|
17445
17448
|
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-1b988eae"]]);
|
|
17446
|
-
const _withScopeId = (n2) => (pushScopeId("data-v-
|
|
17449
|
+
const _withScopeId = (n2) => (pushScopeId("data-v-5040d42f"), n2 = n2(), popScopeId(), n2);
|
|
17447
17450
|
const _hoisted_1$1 = { class: "input-container" };
|
|
17448
17451
|
const _hoisted_2 = {
|
|
17449
17452
|
key: 0,
|
|
@@ -17472,7 +17475,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17472
17475
|
exactSearchKey: { default: "bk_username" },
|
|
17473
17476
|
userGroup: { default: () => [] },
|
|
17474
17477
|
userGroupName: { default: "用户群组" },
|
|
17475
|
-
emptyText: { default: "无匹配人员" }
|
|
17478
|
+
emptyText: { default: "无匹配人员" },
|
|
17479
|
+
renderListItem: {},
|
|
17480
|
+
renderTag: {}
|
|
17476
17481
|
},
|
|
17477
17482
|
emits: ["update:modelValue", "change"],
|
|
17478
17483
|
setup(__props, { emit: __emit }) {
|
|
@@ -17487,9 +17492,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17487
17492
|
const showDropdown = ref(false);
|
|
17488
17493
|
const selectedUserInfo = computed(() => {
|
|
17489
17494
|
const userGroup = (props2.userGroup || []).map((group) => ({
|
|
17490
|
-
|
|
17491
|
-
|
|
17492
|
-
|
|
17495
|
+
...group,
|
|
17496
|
+
tenantId: "",
|
|
17497
|
+
type: "userGroup"
|
|
17493
17498
|
}));
|
|
17494
17499
|
const list = [...options.value, ...userGroup];
|
|
17495
17500
|
const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
|
|
@@ -17507,8 +17512,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17507
17512
|
if (props2.userGroup.length > 0) {
|
|
17508
17513
|
const groupResult = props2.userGroup.filter((group) => group.id == props2.modelValue);
|
|
17509
17514
|
options.value = groupResult.map((group) => ({
|
|
17510
|
-
|
|
17511
|
-
name: group.name,
|
|
17515
|
+
...group,
|
|
17512
17516
|
tenantId: "",
|
|
17513
17517
|
type: "userGroup"
|
|
17514
17518
|
}));
|
|
@@ -17641,7 +17645,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17641
17645
|
};
|
|
17642
17646
|
}
|
|
17643
17647
|
});
|
|
17644
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
17648
|
+
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-5040d42f"]]);
|
|
17645
17649
|
const _hoisted_1 = {
|
|
17646
17650
|
ref: "containerRef",
|
|
17647
17651
|
class: "bk-user-selector"
|
|
@@ -17662,7 +17666,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17662
17666
|
exactSearchKey: { default: "bk_username" },
|
|
17663
17667
|
userGroup: { default: () => [] },
|
|
17664
17668
|
userGroupName: { default: "用户群组" },
|
|
17665
|
-
emptyText: { default: "无匹配人员" }
|
|
17669
|
+
emptyText: { default: "无匹配人员" },
|
|
17670
|
+
renderListItem: {},
|
|
17671
|
+
renderTag: {}
|
|
17666
17672
|
},
|
|
17667
17673
|
emits: ["update:modelValue", "change"],
|
|
17668
17674
|
setup(__props, { emit: __emit }) {
|
|
@@ -17677,11 +17683,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17677
17683
|
const initSelectedUsers = async () => {
|
|
17678
17684
|
if (props2.multiple) {
|
|
17679
17685
|
const ids = Array.isArray(props2.modelValue) ? props2.modelValue : [];
|
|
17686
|
+
let selected = [];
|
|
17680
17687
|
if (props2.userGroup.length > 0) {
|
|
17681
17688
|
const result = props2.userGroup.filter((group) => ids.includes(group.id));
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
name: group.name,
|
|
17689
|
+
selected = result.map((group) => ({
|
|
17690
|
+
...group,
|
|
17685
17691
|
tenantId: "",
|
|
17686
17692
|
type: "userGroup"
|
|
17687
17693
|
}));
|
|
@@ -17689,7 +17695,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17689
17695
|
if (ids.length > 0) {
|
|
17690
17696
|
try {
|
|
17691
17697
|
const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactSearchKey, ids);
|
|
17692
|
-
selectedUsers.value = [...
|
|
17698
|
+
selectedUsers.value = [...selected, ...formatUsers(result)];
|
|
17693
17699
|
} catch (error3) {
|
|
17694
17700
|
console.error("获取选中用户信息失败:", error3);
|
|
17695
17701
|
}
|
|
@@ -17714,6 +17720,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17714
17720
|
emit("update:modelValue", newVal);
|
|
17715
17721
|
}
|
|
17716
17722
|
});
|
|
17723
|
+
watch(
|
|
17724
|
+
() => props2.userGroup,
|
|
17725
|
+
() => {
|
|
17726
|
+
initSelectedUsers();
|
|
17727
|
+
}
|
|
17728
|
+
);
|
|
17717
17729
|
onBeforeMount(() => {
|
|
17718
17730
|
initSelectedUsers();
|
|
17719
17731
|
});
|
|
@@ -17732,12 +17744,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17732
17744
|
"empty-text": _ctx.emptyText,
|
|
17733
17745
|
"exact-search-key": _ctx.exactSearchKey,
|
|
17734
17746
|
placeholder: _ctx.placeholder,
|
|
17747
|
+
"render-list-item": _ctx.renderListItem,
|
|
17748
|
+
"render-tag": _ctx.renderTag,
|
|
17735
17749
|
"tenant-id": _ctx.tenantId,
|
|
17736
17750
|
tenants: unref(tenants),
|
|
17737
17751
|
"user-group": _ctx.userGroup,
|
|
17738
17752
|
"user-group-name": _ctx.userGroupName,
|
|
17739
17753
|
onChange: handleUpdateUser
|
|
17740
|
-
}, 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(
|
|
17754
|
+
}, 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(
|
|
17741
17755
|
Fragment,
|
|
17742
17756
|
{ key: 1 },
|
|
17743
17757
|
[
|
|
@@ -17751,13 +17765,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17751
17765
|
"empty-text": _ctx.emptyText,
|
|
17752
17766
|
"exact-search-key": _ctx.exactSearchKey,
|
|
17753
17767
|
placeholder: _ctx.placeholder,
|
|
17768
|
+
"render-list-item": _ctx.renderListItem,
|
|
17769
|
+
"render-tag": _ctx.renderTag,
|
|
17754
17770
|
"selected-users": selectedUsers.value,
|
|
17755
17771
|
"tenant-id": _ctx.tenantId,
|
|
17756
17772
|
tenants: unref(tenants),
|
|
17757
17773
|
"user-group": _ctx.userGroup,
|
|
17758
17774
|
"user-group-name": _ctx.userGroupName,
|
|
17759
17775
|
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
17760
|
-
}, 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"])
|
|
17776
|
+
}, 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"])
|
|
17761
17777
|
],
|
|
17762
17778
|
2112
|
|
17763
17779
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
@@ -17769,7 +17785,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17769
17785
|
};
|
|
17770
17786
|
}
|
|
17771
17787
|
});
|
|
17772
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
17788
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c23f5bc9"]]);
|
|
17773
17789
|
const vue2 = {
|
|
17774
17790
|
model: {
|
|
17775
17791
|
prop: "modelValue",
|