@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.
@@ -3110,9 +3110,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3110
3110
  const groupedUsers = computed(() => {
3111
3111
  const groups = {};
3112
3112
  if (Array.isArray(props.userGroup) && props.userGroup.length > 0) {
3113
- groups[props.userGroupName] = props.userGroup.map((group) => ({
3114
- id: group.id,
3115
- name: group.name,
3113
+ groups[props.userGroupName] = props.userGroup.filter((group) => !group.hidden).map((group) => ({
3114
+ ...group,
3116
3115
  tenantId: "",
3117
3116
  type: "userGroup"
3118
3117
  }));
@@ -3199,26 +3198,28 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3199
3198
  key: user.id,
3200
3199
  onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
3201
3200
  }, [
3202
- user.login_name ? (openBlock(), createElementBlock(
3203
- "span",
3204
- _hoisted_5,
3205
- toDisplayString(user.login_name) + "(" + toDisplayString(user.name) + ")",
3206
- 1
3207
- /* TEXT */
3208
- )) : (openBlock(), createElementBlock(
3209
- "span",
3210
- _hoisted_6,
3211
- toDisplayString(user.name),
3212
- 1
3213
- /* TEXT */
3214
- )),
3215
- user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
3216
- "span",
3217
- _hoisted_7,
3218
- "@" + toDisplayString(__props.tenants[user.tenantId]),
3219
- 1
3220
- /* TEXT */
3221
- )) : createCommentVNode("v-if", true)
3201
+ createElementVNode("div", null, [
3202
+ user.login_name ? (openBlock(), createElementBlock(
3203
+ "span",
3204
+ _hoisted_5,
3205
+ toDisplayString(user.login_name) + "(" + toDisplayString(user.name) + ")",
3206
+ 1
3207
+ /* TEXT */
3208
+ )) : (openBlock(), createElementBlock(
3209
+ "span",
3210
+ _hoisted_6,
3211
+ toDisplayString(user.name),
3212
+ 1
3213
+ /* TEXT */
3214
+ )),
3215
+ user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
3216
+ "span",
3217
+ _hoisted_7,
3218
+ "@" + toDisplayString(__props.tenants[user.tenantId]),
3219
+ 1
3220
+ /* TEXT */
3221
+ )) : createCommentVNode("v-if", true)
3222
+ ])
3222
3223
  ], 40, _hoisted_4$1);
3223
3224
  }),
3224
3225
  128
@@ -3240,7 +3241,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
3240
3241
  };
3241
3242
  }
3242
3243
  });
3243
- const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-8489ef3d"]]);
3244
+ const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-7bcec2be"]]);
3244
3245
  const _hoisted_1$3 = { class: "tag-content" };
3245
3246
  const _hoisted_2$2 = { class: "user-name" };
3246
3247
  const _hoisted_3$2 = {
@@ -3321,7 +3322,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3321
3322
  exactSearchKey: { default: "bk_username" },
3322
3323
  userGroup: { default: () => [] },
3323
3324
  userGroupName: { default: "用户群组" },
3324
- emptyText: { default: "无匹配人员" }
3325
+ emptyText: { default: "无匹配人员" },
3326
+ renderListItem: {},
3327
+ renderTag: {}
3325
3328
  },
3326
3329
  emits: ["update:selectedUsers", "add-user", "remove-user"],
3327
3330
  setup(__props, { emit: __emit }) {
@@ -3766,7 +3769,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
3766
3769
  }
3767
3770
  });
3768
3771
  const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-1b988eae"]]);
3769
- const _withScopeId = (n) => (pushScopeId("data-v-b9296528"), n = n(), popScopeId(), n);
3772
+ const _withScopeId = (n) => (pushScopeId("data-v-5040d42f"), n = n(), popScopeId(), n);
3770
3773
  const _hoisted_1$1 = { class: "input-container" };
3771
3774
  const _hoisted_2 = {
3772
3775
  key: 0,
@@ -3795,7 +3798,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3795
3798
  exactSearchKey: { default: "bk_username" },
3796
3799
  userGroup: { default: () => [] },
3797
3800
  userGroupName: { default: "用户群组" },
3798
- emptyText: { default: "无匹配人员" }
3801
+ emptyText: { default: "无匹配人员" },
3802
+ renderListItem: {},
3803
+ renderTag: {}
3799
3804
  },
3800
3805
  emits: ["update:modelValue", "change"],
3801
3806
  setup(__props, { emit: __emit }) {
@@ -3810,9 +3815,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3810
3815
  const showDropdown = ref(false);
3811
3816
  const selectedUserInfo = computed(() => {
3812
3817
  const userGroup = (props.userGroup || []).map((group) => ({
3813
- id: group.id,
3814
- name: group.name,
3815
- tenantId: ""
3818
+ ...group,
3819
+ tenantId: "",
3820
+ type: "userGroup"
3816
3821
  }));
3817
3822
  const list = [...options.value, ...userGroup];
3818
3823
  const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
@@ -3830,8 +3835,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3830
3835
  if (props.userGroup.length > 0) {
3831
3836
  const groupResult = props.userGroup.filter((group) => group.id == props.modelValue);
3832
3837
  options.value = groupResult.map((group) => ({
3833
- id: group.id,
3834
- name: group.name,
3838
+ ...group,
3835
3839
  tenantId: "",
3836
3840
  type: "userGroup"
3837
3841
  }));
@@ -3964,7 +3968,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
3964
3968
  };
3965
3969
  }
3966
3970
  });
3967
- const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-b9296528"]]);
3971
+ const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-5040d42f"]]);
3968
3972
  const _hoisted_1 = {
3969
3973
  ref: "containerRef",
3970
3974
  class: "bk-user-selector"
@@ -3985,7 +3989,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
3985
3989
  exactSearchKey: { default: "bk_username" },
3986
3990
  userGroup: { default: () => [] },
3987
3991
  userGroupName: { default: "用户群组" },
3988
- emptyText: { default: "无匹配人员" }
3992
+ emptyText: { default: "无匹配人员" },
3993
+ renderListItem: {},
3994
+ renderTag: {}
3989
3995
  },
3990
3996
  emits: ["update:modelValue", "change"],
3991
3997
  setup(__props, { emit: __emit }) {
@@ -4000,11 +4006,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4000
4006
  const initSelectedUsers = async () => {
4001
4007
  if (props.multiple) {
4002
4008
  const ids = Array.isArray(props.modelValue) ? props.modelValue : [];
4009
+ let selected = [];
4003
4010
  if (props.userGroup.length > 0) {
4004
4011
  const result = props.userGroup.filter((group) => ids.includes(group.id));
4005
- selectedUsers.value = result.map((group) => ({
4006
- id: group.id,
4007
- name: group.name,
4012
+ selected = result.map((group) => ({
4013
+ ...group,
4008
4014
  tenantId: "",
4009
4015
  type: "userGroup"
4010
4016
  }));
@@ -4012,7 +4018,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4012
4018
  if (ids.length > 0) {
4013
4019
  try {
4014
4020
  const result = await lookupUsers(props.apiBaseUrl, props.tenantId, props.exactSearchKey, ids);
4015
- selectedUsers.value = [...selectedUsers.value, ...formatUsers(result)];
4021
+ selectedUsers.value = [...selected, ...formatUsers(result)];
4016
4022
  } catch (error) {
4017
4023
  console.error("获取选中用户信息失败:", error);
4018
4024
  }
@@ -4037,6 +4043,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4037
4043
  emit("update:modelValue", newVal);
4038
4044
  }
4039
4045
  });
4046
+ watch(
4047
+ () => props.userGroup,
4048
+ () => {
4049
+ initSelectedUsers();
4050
+ }
4051
+ );
4040
4052
  onBeforeMount(() => {
4041
4053
  initSelectedUsers();
4042
4054
  });
@@ -4055,12 +4067,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4055
4067
  "empty-text": _ctx.emptyText,
4056
4068
  "exact-search-key": _ctx.exactSearchKey,
4057
4069
  placeholder: _ctx.placeholder,
4070
+ "render-list-item": _ctx.renderListItem,
4071
+ "render-tag": _ctx.renderTag,
4058
4072
  "tenant-id": _ctx.tenantId,
4059
4073
  tenants: unref(tenants),
4060
4074
  "user-group": _ctx.userGroup,
4061
4075
  "user-group-name": _ctx.userGroupName,
4062
4076
  onChange: handleUpdateUser
4063
- }, 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(
4077
+ }, 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(
4064
4078
  Fragment,
4065
4079
  { key: 1 },
4066
4080
  [
@@ -4074,13 +4088,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4074
4088
  "empty-text": _ctx.emptyText,
4075
4089
  "exact-search-key": _ctx.exactSearchKey,
4076
4090
  placeholder: _ctx.placeholder,
4091
+ "render-list-item": _ctx.renderListItem,
4092
+ "render-tag": _ctx.renderTag,
4077
4093
  "selected-users": selectedUsers.value,
4078
4094
  "tenant-id": _ctx.tenantId,
4079
4095
  tenants: unref(tenants),
4080
4096
  "user-group": _ctx.userGroup,
4081
4097
  "user-group-name": _ctx.userGroupName,
4082
4098
  "onUpdate:selectedUsers": handleUpdateSelectedUsers
4083
- }, 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"])
4099
+ }, 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"])
4084
4100
  ],
4085
4101
  2112
4086
4102
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
@@ -4092,7 +4108,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
4092
4108
  };
4093
4109
  }
4094
4110
  });
4095
- const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5dcf7617"]]);
4111
+ const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c23f5bc9"]]);
4096
4112
  export {
4097
4113
  BkUserSelector,
4098
4114
  BkUserSelector as default