@blueking/bk-user-selector 0.0.8 → 0.0.10

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.
@@ -16776,7 +16776,6 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16776
16776
  const emit = __emit;
16777
16777
  const groupedUsers = computed(() => {
16778
16778
  const groups = {};
16779
- console.log("props.options", props2.options);
16780
16779
  if (Array.isArray(props2.userGroup) && props2.userGroup.length > 0) {
16781
16780
  groups[props2.userGroupName] = props2.userGroup.map((group) => ({
16782
16781
  id: group.id,
@@ -16830,9 +16829,10 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16830
16829
  class: "user-group",
16831
16830
  key: groupName
16832
16831
  }, [
16833
- createElementVNode(
16832
+ Object.keys(groupedUsers.value).length > 1 ? (openBlock(), createElementBlock(
16834
16833
  "div",
16835
16834
  {
16835
+ key: 0,
16836
16836
  class: "group-header",
16837
16837
  onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
16838
16838
  }, ["prevent"]))
@@ -16855,7 +16855,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16855
16855
  ],
16856
16856
  32
16857
16857
  /* NEED_HYDRATION */
16858
- ),
16858
+ )) : createCommentVNode("v-if", true),
16859
16859
  (openBlock(true), createElementBlock(
16860
16860
  Fragment,
16861
16861
  null,
@@ -16900,7 +16900,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16900
16900
  };
16901
16901
  }
16902
16902
  });
16903
- const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-c68dfcac"]]);
16903
+ const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-01b75e6e"]]);
16904
16904
  const _hoisted_1$3 = { class: "tag-content" };
16905
16905
  const _hoisted_2$2 = { class: "user-name" };
16906
16906
  const _hoisted_3$2 = {
@@ -16970,83 +16970,17 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16970
16970
  },
16971
16971
  __name: "multiple-selector",
16972
16972
  props: {
16973
- /**
16974
- * 绑定值
16975
- */
16976
- modelValue: {
16977
- type: Array,
16978
- default: () => []
16979
- },
16980
- /**
16981
- * 占位文本
16982
- */
16983
- placeholder: {
16984
- type: String,
16985
- default: "请输入人员名称搜索"
16986
- },
16987
- /**
16988
- * 是否可拖拽
16989
- */
16990
- draggable: {
16991
- type: Boolean,
16992
- default: false
16993
- },
16994
- /**
16995
- * API 基础 URL
16996
- */
16997
- apiBaseUrl: {
16998
- type: String,
16999
- default: ""
17000
- },
17001
- /**
17002
- * 租户 ID
17003
- */
17004
- tenantId: {
17005
- type: String,
17006
- default: ""
17007
- },
17008
- /**
17009
- * 已选用户
17010
- */
17011
- selectedUsers: {
17012
- type: Array,
17013
- default: () => []
17014
- },
17015
- /**
17016
- * 租户信息映射
17017
- */
17018
- tenants: {
17019
- type: Object,
17020
- default: () => ({})
17021
- },
17022
- /**
17023
- * 当前用户ID
17024
- */
17025
- currentUserId: {
17026
- type: String,
17027
- default: ""
17028
- },
17029
- /**
17030
- * 精确查找key
17031
- */
17032
- exactSearchKey: {
17033
- type: String,
17034
- default: "bk_username"
17035
- },
17036
- /**
17037
- * 用户组
17038
- */
17039
- userGroup: {
17040
- type: Array,
17041
- default: () => []
17042
- },
17043
- /**
17044
- * 用户组名称
17045
- */
17046
- userGroupName: {
17047
- type: String,
17048
- default: "用户群组"
17049
- }
16973
+ modelValue: { default: () => [] },
16974
+ draggable: { type: Boolean, default: false },
16975
+ selectedUsers: { default: () => [] },
16976
+ tenants: { default: () => ({}) },
16977
+ apiBaseUrl: { default: "" },
16978
+ tenantId: { default: "" },
16979
+ placeholder: { default: "请输入人员名称搜索" },
16980
+ currentUserId: { default: "" },
16981
+ exactSearchKey: { default: "bk_username" },
16982
+ userGroup: { default: () => [] },
16983
+ userGroupName: { default: "用户群组" }
17050
16984
  },
17051
16985
  emits: ["update:selectedUsers", "add-user", "remove-user"],
17052
16986
  setup(__props, { emit: __emit }) {
@@ -17309,7 +17243,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17309
17243
  (openBlock(true), createElementBlock(
17310
17244
  Fragment,
17311
17245
  null,
17312
- renderList(__props.selectedUsers, (user, index) => {
17246
+ renderList(_ctx.selectedUsers, (user, index) => {
17313
17247
  return openBlock(), createElementBlock("div", {
17314
17248
  class: "tag-wrapper",
17315
17249
  key: user.id,
@@ -17317,15 +17251,15 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17317
17251
  }, [
17318
17252
  createVNode(UserTag, {
17319
17253
  active: index === activeTagIndex.value,
17320
- "current-tenant-id": __props.tenantId,
17321
- draggable: __props.draggable,
17322
- tenants: __props.tenants,
17254
+ "current-tenant-id": _ctx.tenantId,
17255
+ draggable: _ctx.draggable,
17256
+ tenants: _ctx.tenants,
17323
17257
  user,
17324
17258
  onClick: ($event) => handleTagClick(index),
17325
17259
  onClose: ($event) => removeUser(user)
17326
17260
  }, null, 8, ["active", "current-tenant-id", "draggable", "tenants", "user", "onClick", "onClose"]),
17327
17261
  createCommentVNode(" 在当前激活标签后插入输入框 "),
17328
- index === activeTagIndex.value && activeTagIndex.value !== __props.selectedUsers.length - 1 ? withDirectives((openBlock(), createElementBlock(
17262
+ index === activeTagIndex.value && activeTagIndex.value !== _ctx.selectedUsers.length - 1 ? withDirectives((openBlock(), createElementBlock(
17329
17263
  "input",
17330
17264
  {
17331
17265
  key: 0,
@@ -17351,13 +17285,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17351
17285
  /* KEYED_FRAGMENT */
17352
17286
  )),
17353
17287
  createCommentVNode(" 最后一个输入框 "),
17354
- activeTagIndex.value === -1 || activeTagIndex.value === __props.selectedUsers.length - 1 ? withDirectives((openBlock(), createElementBlock("input", {
17288
+ activeTagIndex.value === -1 || activeTagIndex.value === _ctx.selectedUsers.length - 1 ? withDirectives((openBlock(), createElementBlock("input", {
17355
17289
  key: 0,
17356
17290
  ref_key: "lastInputRef",
17357
17291
  ref: lastInputRef,
17358
17292
  class: "search-input last",
17359
17293
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
17360
- placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
17294
+ placeholder: !_ctx.selectedUsers.length ? _ctx.placeholder : "",
17361
17295
  onFocus: handleInputFocus,
17362
17296
  onInput: handleInput,
17363
17297
  onKeydown: handleKeyDown,
@@ -17367,8 +17301,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17367
17301
  ]) : createCommentVNode("v-if", true),
17368
17302
  createCommentVNode(' "我"标签 '),
17369
17303
  createVNode(MeTag, {
17370
- "current-user-id": __props.currentUserId,
17371
- "is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user.id === __props.currentUserId),
17304
+ "current-user-id": _ctx.currentUserId,
17305
+ "is-disabled": !!_ctx.currentUserId && _ctx.selectedUsers.some((user) => user.id === _ctx.currentUserId),
17372
17306
  onClick: addCurrentUser
17373
17307
  }, null, 8, ["current-user-id", "is-disabled"])
17374
17308
  ],
@@ -17397,10 +17331,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17397
17331
  null,
17398
17332
  renderList(visibleUsers.value, (user) => {
17399
17333
  return openBlock(), createBlock(UserTag, {
17400
- "current-tenant-id": __props.tenantId,
17334
+ "current-tenant-id": _ctx.tenantId,
17401
17335
  key: user.id,
17402
17336
  "show-tenant": true,
17403
- tenants: __props.tenants,
17337
+ tenants: _ctx.tenants,
17404
17338
  user,
17405
17339
  onClick: handleFocus,
17406
17340
  onClose: ($event) => removeUser(user)
@@ -17425,7 +17359,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17425
17359
  /* STABLE */
17426
17360
  })), [
17427
17361
  [unref(__webpack_exports__bkTooltips), {
17428
- content: __props.selectedUsers.slice(visibleUsers.value.length).map((user) => user.display_name).join(","),
17362
+ content: _ctx.selectedUsers.slice(visibleUsers.value.length).map((user) => user.display_name).join(","),
17429
17363
  placement: "top"
17430
17364
  }]
17431
17365
  ]) : createCommentVNode("v-if", true),
@@ -17435,15 +17369,15 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17435
17369
  ref: collapsedInputRef,
17436
17370
  class: "search-input collapsed",
17437
17371
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
17438
- placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
17372
+ placeholder: !_ctx.selectedUsers.length ? _ctx.placeholder : "",
17439
17373
  onFocus: handleFocus
17440
17374
  }, null, 40, _hoisted_3$1), [
17441
17375
  [vModelText, unref(searchQuery)]
17442
17376
  ]),
17443
17377
  createCommentVNode(' 未聚焦状态下的"我"标签 '),
17444
17378
  createVNode(MeTag, {
17445
- "current-user-id": __props.currentUserId,
17446
- "is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user[props2.exactSearchKey] === __props.currentUserId),
17379
+ "current-user-id": _ctx.currentUserId,
17380
+ "is-disabled": !!_ctx.currentUserId && _ctx.selectedUsers.some((user) => user[props2.exactSearchKey] === _ctx.currentUserId),
17447
17381
  onClick: addCurrentUser
17448
17382
  }, null, 8, ["current-user-id", "is-disabled"])
17449
17383
  ],
@@ -17461,10 +17395,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17461
17395
  loading: unref(searchLoading),
17462
17396
  options: options.value,
17463
17397
  "search-query": unref(searchQuery),
17464
- "tenant-id": __props.tenantId,
17465
- tenants: __props.tenants,
17466
- "user-group": __props.userGroup,
17467
- "user-group-name": __props.userGroupName,
17398
+ "tenant-id": _ctx.tenantId,
17399
+ tenants: _ctx.tenants,
17400
+ "user-group": _ctx.userGroup,
17401
+ "user-group-name": _ctx.userGroupName,
17468
17402
  onSelectUser: addUser
17469
17403
  }, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
17470
17404
  ])), [
@@ -17473,8 +17407,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17473
17407
  };
17474
17408
  }
17475
17409
  });
17476
- const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a09f11c3"]]);
17477
- const _withScopeId = (n2) => (pushScopeId("data-v-8b8dd0fd"), n2 = n2(), popScopeId(), n2);
17410
+ const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-1a376d26"]]);
17411
+ const _withScopeId = (n2) => (pushScopeId("data-v-22d9b76f"), n2 = n2(), popScopeId(), n2);
17478
17412
  const _hoisted_1$1 = { class: "input-container" };
17479
17413
  const _hoisted_2 = {
17480
17414
  key: 0,
@@ -17494,15 +17428,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17494
17428
  },
17495
17429
  __name: "single-selector",
17496
17430
  props: {
17497
- modelValue: {},
17431
+ modelValue: { default: "" },
17498
17432
  tenants: {},
17499
- apiBaseUrl: {},
17500
- tenantId: {},
17501
- placeholder: {},
17502
- currentUserId: {},
17503
- exactSearchKey: {},
17504
- userGroup: {},
17505
- userGroupName: {}
17433
+ apiBaseUrl: { default: "" },
17434
+ tenantId: { default: "" },
17435
+ placeholder: { default: "请输入人员名称搜索" },
17436
+ currentUserId: { default: "" },
17437
+ exactSearchKey: { default: "bk_username" },
17438
+ userGroup: { default: () => [] },
17439
+ userGroupName: { default: "用户群组" }
17506
17440
  },
17507
17441
  emits: ["update:modelValue", "change"],
17508
17442
  setup(__props, { emit: __emit }) {
@@ -17563,7 +17497,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17563
17497
  try {
17564
17498
  const result = await searchUsers(props2.apiBaseUrl, props2.tenantId, keyword);
17565
17499
  options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
17566
- console.log("options.value", options.value);
17567
17500
  } catch (error3) {
17568
17501
  console.error("获取用户列表失败:", error3);
17569
17502
  options.value = [];
@@ -17572,7 +17505,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17572
17505
  }
17573
17506
  };
17574
17507
  const addUser = (user) => {
17575
- console.log("addUser", user);
17576
17508
  selectedUser.value = user.id;
17577
17509
  searchQuery.value = "";
17578
17510
  showDropdown.value = false;
@@ -17587,7 +17519,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17587
17519
  }
17588
17520
  };
17589
17521
  const handleInput = () => {
17590
- console.log("handleInput", searchQuery.value);
17591
17522
  fetchUsers(searchQuery.value);
17592
17523
  showDropdown.value = searchQuery.value.length >= 2;
17593
17524
  };
@@ -17595,7 +17526,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17595
17526
  showDropdown.value = false;
17596
17527
  };
17597
17528
  watch(selectedUser, (newVal) => {
17598
- console.log("selectedUser", newVal);
17599
17529
  emit("update:modelValue", newVal);
17600
17530
  });
17601
17531
  return (_ctx, _cache) => {
@@ -17641,10 +17571,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17641
17571
  ]),
17642
17572
  createCommentVNode(' "我"标签 '),
17643
17573
  createVNode(MeTag, {
17644
- "is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey || "bk_username"] === _ctx.currentUserId,
17645
17574
  "current-user-id": _ctx.currentUserId,
17575
+ "is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey] === _ctx.currentUserId,
17646
17576
  onClick: addCurrentUser
17647
- }, null, 8, ["is-disabled", "current-user-id"])
17577
+ }, null, 8, ["current-user-id", "is-disabled"])
17648
17578
  ]),
17649
17579
  createCommentVNode(" 使用新的公共下拉选项组件 "),
17650
17580
  createVNode(SelectionPopover, {
@@ -17665,8 +17595,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17665
17595
  };
17666
17596
  }
17667
17597
  });
17668
- const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b8dd0fd"]]);
17669
- const _hoisted_1 = { class: "bk-user-selector" };
17598
+ const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-22d9b76f"]]);
17599
+ const _hoisted_1 = {
17600
+ ref: "containerRef",
17601
+ class: "bk-user-selector"
17602
+ };
17670
17603
  const _sfc_main = /* @__PURE__ */ defineComponent({
17671
17604
  ...{
17672
17605
  name: "BkUserSelector"
@@ -17699,7 +17632,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17699
17632
  const ids = Array.isArray(props2.modelValue) ? props2.modelValue : [];
17700
17633
  if (ids.length > 0) {
17701
17634
  try {
17702
- console.log(props2.exactSearchKey);
17703
17635
  const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactSearchKey, ids);
17704
17636
  selectedUsers.value = formatUsers(result);
17705
17637
  } catch (error3) {
@@ -17730,51 +17662,61 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17730
17662
  initSelectedUsers();
17731
17663
  });
17732
17664
  return (_ctx, _cache) => {
17733
- return openBlock(), createElementBlock("section", _hoisted_1, [
17734
- createCommentVNode(" 单选模式 "),
17735
- !_ctx.multiple ? (openBlock(), createBlock(SingleSelector, {
17736
- key: 0,
17737
- modelValue: selectedUser.value,
17738
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedUser.value = $event),
17739
- "api-base-url": _ctx.apiBaseUrl,
17740
- "current-user-id": _ctx.currentUserId,
17741
- "exact-search-key": _ctx.exactSearchKey,
17742
- placeholder: _ctx.placeholder,
17743
- "tenant-id": _ctx.tenantId,
17744
- tenants: unref(tenants),
17745
- "user-group": _ctx.userGroup,
17746
- "user-group-name": _ctx.userGroupName,
17747
- onChange: handleUpdateUser
17748
- }, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
17749
- Fragment,
17750
- { key: 1 },
17751
- [
17752
- createCommentVNode(" 多选模式 "),
17753
- createVNode(MultipleSelector, {
17754
- modelValue: selectedUserIds.value,
17755
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => selectedUserIds.value = $event),
17756
- "api-base-url": _ctx.apiBaseUrl,
17757
- "current-user-id": _ctx.currentUserId,
17758
- draggable: _ctx.draggable,
17759
- "exact-search-key": _ctx.exactSearchKey,
17760
- placeholder: _ctx.placeholder,
17761
- "selected-users": selectedUsers.value,
17762
- "tenant-id": _ctx.tenantId,
17763
- tenants: unref(tenants),
17764
- "user-group": _ctx.userGroup,
17765
- "user-group-name": _ctx.userGroupName,
17766
- "onUpdate:selectedUsers": handleUpdateSelectedUsers
17767
- }, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name"])
17768
- ],
17769
- 2112
17770
- /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
17771
- ))
17772
- ]);
17665
+ return openBlock(), createElementBlock(
17666
+ "section",
17667
+ _hoisted_1,
17668
+ [
17669
+ createCommentVNode(" 单选模式 "),
17670
+ !_ctx.multiple ? (openBlock(), createBlock(SingleSelector, {
17671
+ key: 0,
17672
+ modelValue: selectedUser.value,
17673
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedUser.value = $event),
17674
+ "api-base-url": _ctx.apiBaseUrl,
17675
+ "current-user-id": _ctx.currentUserId,
17676
+ "exact-search-key": _ctx.exactSearchKey,
17677
+ placeholder: _ctx.placeholder,
17678
+ "tenant-id": _ctx.tenantId,
17679
+ tenants: unref(tenants),
17680
+ "user-group": _ctx.userGroup,
17681
+ "user-group-name": _ctx.userGroupName,
17682
+ onChange: handleUpdateUser
17683
+ }, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
17684
+ Fragment,
17685
+ { key: 1 },
17686
+ [
17687
+ createCommentVNode(" 多选模式 "),
17688
+ createVNode(MultipleSelector, {
17689
+ modelValue: selectedUserIds.value,
17690
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => selectedUserIds.value = $event),
17691
+ "api-base-url": _ctx.apiBaseUrl,
17692
+ "current-user-id": _ctx.currentUserId,
17693
+ draggable: _ctx.draggable,
17694
+ "exact-search-key": _ctx.exactSearchKey,
17695
+ placeholder: _ctx.placeholder,
17696
+ "selected-users": selectedUsers.value,
17697
+ "tenant-id": _ctx.tenantId,
17698
+ tenants: unref(tenants),
17699
+ "user-group": _ctx.userGroup,
17700
+ "user-group-name": _ctx.userGroupName,
17701
+ "onUpdate:selectedUsers": handleUpdateSelectedUsers
17702
+ }, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name"])
17703
+ ],
17704
+ 2112
17705
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
17706
+ ))
17707
+ ],
17708
+ 512
17709
+ /* NEED_PATCH */
17710
+ );
17773
17711
  };
17774
17712
  }
17775
17713
  });
17776
- const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc7b4ccd"]]);
17714
+ const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-84252deb"]]);
17777
17715
  const vue2 = {
17716
+ model: {
17717
+ prop: "modelValue",
17718
+ event: "change"
17719
+ },
17778
17720
  beforeDestroy() {
17779
17721
  var _a;
17780
17722
  this.unWatchStack.forEach((unWatch) => unWatch == null ? void 0 : unWatch());