@blueking/bk-user-selector 0.0.21 → 0.0.22

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/bk-user-selector",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "蓝鲸用户选择器",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",
@@ -18,6 +18,13 @@ declare const _default: import("vue").DefineComponent<{
18
18
  type: (StringConstructor | NumberConstructor)[];
19
19
  default: string;
20
20
  };
21
+ /**
22
+ * popover crossAxis 偏移量
23
+ */
24
+ crossAxisOffset: {
25
+ type: NumberConstructor;
26
+ default: number;
27
+ };
21
28
  /**
22
29
  * 是否加载中
23
30
  */
@@ -86,6 +93,7 @@ declare const _default: import("vue").DefineComponent<{
86
93
  };
87
94
  }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
88
95
  "select-user": (...args: any[]) => void;
96
+ "click-outside": (...args: any[]) => void;
89
97
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
90
98
  /**
91
99
  * 是否显示下拉菜单
@@ -101,6 +109,13 @@ declare const _default: import("vue").DefineComponent<{
101
109
  type: (StringConstructor | NumberConstructor)[];
102
110
  default: string;
103
111
  };
112
+ /**
113
+ * popover crossAxis 偏移量
114
+ */
115
+ crossAxisOffset: {
116
+ type: NumberConstructor;
117
+ default: number;
118
+ };
104
119
  /**
105
120
  * 是否加载中
106
121
  */
@@ -169,14 +184,16 @@ declare const _default: import("vue").DefineComponent<{
169
184
  };
170
185
  }>> & {
171
186
  "onSelect-user"?: ((...args: any[]) => any) | undefined;
187
+ "onClick-outside"?: ((...args: any[]) => any) | undefined;
172
188
  }, {
173
189
  tenantId: string;
190
+ tenants: Record<string, string>;
174
191
  isShow: boolean;
175
192
  containerWidth: string | number;
193
+ crossAxisOffset: number;
176
194
  loading: boolean;
177
195
  options: FormattedUser[];
178
196
  searchQuery: string;
179
- tenants: Record<string, string>;
180
197
  userGroup: {
181
198
  id: string;
182
199
  name: string;
@@ -1,21 +1,37 @@
1
1
  import type { FormattedUser } from '../types';
2
2
  declare const _default: import("vue").DefineComponent<{
3
- render: {
4
- type: FunctionConstructor;
5
- required: true;
6
- };
7
3
  user: {
8
4
  type: () => FormattedUser;
9
5
  required: true;
10
6
  };
11
- }, () => any, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
7
+ tenantId: {
8
+ type: StringConstructor;
9
+ required: true;
10
+ };
11
+ tenants: {
12
+ type: () => Record<string, string>;
13
+ required: true;
14
+ };
12
15
  render: {
13
16
  type: FunctionConstructor;
14
- required: true;
17
+ required: false;
15
18
  };
19
+ }, () => any, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
20
  user: {
17
21
  type: () => FormattedUser;
18
22
  required: true;
19
23
  };
24
+ tenantId: {
25
+ type: StringConstructor;
26
+ required: true;
27
+ };
28
+ tenants: {
29
+ type: () => Record<string, string>;
30
+ required: true;
31
+ };
32
+ render: {
33
+ type: FunctionConstructor;
34
+ required: false;
35
+ };
20
36
  }>>, {}, {}>;
21
37
  export default _default;
@@ -12,7 +12,7 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
12
12
  /**
13
13
  * 当前租户ID
14
14
  */
15
- currentTenantId?: string;
15
+ currentTenantId: string;
16
16
  /**
17
17
  * 是否可拖拽
18
18
  */
@@ -44,7 +44,7 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
44
44
  /**
45
45
  * 当前租户ID
46
46
  */
47
- currentTenantId?: string;
47
+ currentTenantId: string;
48
48
  /**
49
49
  * 是否可拖拽
50
50
  */
@@ -13639,7 +13639,7 @@ var __webpack_exports__$1 = {};
13639
13639
  })();
13640
13640
  __webpack_exports__$1.bkEllipsis;
13641
13641
  __webpack_exports__$1.bkEllipsisInstance;
13642
- var __webpack_exports__bkTooltips = __webpack_exports__$1.bkTooltips;
13642
+ __webpack_exports__$1.bkTooltips;
13643
13643
  var __webpack_exports__clickoutside = __webpack_exports__$1.clickoutside;
13644
13644
  __webpack_exports__$1.mousewheel;
13645
13645
  __webpack_exports__$1.overflowTitle;
@@ -16693,39 +16693,56 @@ const MeTag = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-88
16693
16693
  const UserRender = defineComponent({
16694
16694
  name: "UserRender",
16695
16695
  props: {
16696
- render: {
16697
- type: Function,
16696
+ user: {
16697
+ type: Object,
16698
16698
  required: true
16699
16699
  },
16700
- user: {
16700
+ tenantId: {
16701
+ type: String,
16702
+ required: true
16703
+ },
16704
+ tenants: {
16701
16705
  type: Object,
16702
16706
  required: true
16707
+ },
16708
+ render: {
16709
+ type: Function,
16710
+ required: false
16703
16711
  }
16704
16712
  },
16705
16713
  setup(props2) {
16714
+ const defaultRender = (h2, props22) => {
16715
+ return h2("div", [
16716
+ h2("span", props22.user.name),
16717
+ props22.user.tenantId !== props22.tenantId && props22.user.tenantId ? h2(
16718
+ "span",
16719
+ {
16720
+ style: {
16721
+ color: "#f59500",
16722
+ marginLeft: "4px"
16723
+ }
16724
+ },
16725
+ `@${props22.tenants[props22.user.tenantId] || props22.user.tenantId}`
16726
+ ) : null
16727
+ ]);
16728
+ };
16706
16729
  return () => {
16707
16730
  try {
16708
- return props2.render(h$1, props2.user);
16731
+ return props2.render ? props2.render(h$1, props2.user) : defaultRender(h$1, props2);
16709
16732
  } catch (error3) {
16710
16733
  console.error("Error rendering tag:", error3);
16711
- return h$1("div", props2.user.name);
16734
+ return defaultRender(h$1, props2);
16712
16735
  }
16713
16736
  };
16714
16737
  }
16715
16738
  });
16716
- const _hoisted_1$4 = {
16739
+ const _hoisted_1$3 = {
16717
16740
  key: 0,
16718
16741
  class: "no-data"
16719
16742
  };
16720
- const _hoisted_2$3 = { class: "group-name" };
16721
- const _hoisted_3$2 = { class: "group-count" };
16722
- const _hoisted_4$1 = ["onMousedown"];
16723
- const _hoisted_5 = { key: 0 };
16724
- const _hoisted_6 = { key: 1 };
16725
- const _hoisted_7 = {
16726
- key: 0,
16727
- class: "tenant-name"
16728
- };
16743
+ const _hoisted_2$2 = { class: "group-name" };
16744
+ const _hoisted_3$1 = { class: "group-count" };
16745
+ const _hoisted_4 = ["onMousedown"];
16729
16746
  const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16730
16747
  ...{
16731
16748
  name: "SelectionPopover"
@@ -16746,6 +16763,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16746
16763
  type: [Number, String],
16747
16764
  default: "auto"
16748
16765
  },
16766
+ /**
16767
+ * popover crossAxis 偏移量
16768
+ */
16769
+ crossAxisOffset: {
16770
+ type: Number,
16771
+ default: 0
16772
+ },
16749
16773
  /**
16750
16774
  * 是否加载中
16751
16775
  */
@@ -16809,7 +16833,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16809
16833
  type: Function
16810
16834
  }
16811
16835
  },
16812
- emits: ["select-user"],
16836
+ emits: ["select-user", "click-outside"],
16813
16837
  setup(__props, { emit: __emit }) {
16814
16838
  const props2 = __props;
16815
16839
  const emit = __emit;
@@ -16834,15 +16858,20 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16834
16858
  const selectUser = (user) => {
16835
16859
  emit("select-user", user);
16836
16860
  };
16861
+ const handleClickOutside = ({ event }) => {
16862
+ emit("click-outside", event);
16863
+ };
16837
16864
  return (_ctx, _cache) => {
16838
16865
  return openBlock(), createBlock(unref(__webpack_exports__default$1), {
16839
16866
  "ext-cls": "bk-user-selector-popover",
16840
16867
  arrow: false,
16841
16868
  "is-show": __props.isShow,
16869
+ offset: { mainAxis: 4, crossAxis: __props.crossAxisOffset },
16842
16870
  width: __props.containerWidth,
16843
16871
  placement: "bottom-start",
16844
16872
  theme: "light",
16845
- trigger: "manual"
16873
+ trigger: "manual",
16874
+ onClickoutside: handleClickOutside
16846
16875
  }, {
16847
16876
  content: withCtx(() => [
16848
16877
  createVNode(unref(__webpack_exports__default$3), {
@@ -16852,7 +16881,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16852
16881
  mode: "spin"
16853
16882
  }, {
16854
16883
  default: withCtx(() => [
16855
- __props.options.length === 0 && __props.userGroup.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
16884
+ __props.options.length === 0 && __props.userGroup.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
16856
16885
  createElementVNode(
16857
16886
  "span",
16858
16887
  null,
@@ -16879,14 +16908,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16879
16908
  [
16880
16909
  createElementVNode(
16881
16910
  "span",
16882
- _hoisted_2$3,
16911
+ _hoisted_2$2,
16883
16912
  toDisplayString(groupName),
16884
16913
  1
16885
16914
  /* TEXT */
16886
16915
  ),
16887
16916
  createElementVNode(
16888
16917
  "span",
16889
- _hoisted_3$2,
16918
+ _hoisted_3$1,
16890
16919
  "(" + toDisplayString(group.length) + ")",
16891
16920
  1
16892
16921
  /* TEXT */
@@ -16904,28 +16933,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16904
16933
  key: user.id,
16905
16934
  onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
16906
16935
  }, [
16907
- __props.renderListItem ? (openBlock(), createElementBlock("div", _hoisted_5, [
16908
- createVNode(unref(UserRender), {
16909
- render: __props.renderListItem,
16910
- user
16911
- }, null, 8, ["render", "user"])
16912
- ])) : (openBlock(), createElementBlock("div", _hoisted_6, [
16913
- createElementVNode(
16914
- "span",
16915
- null,
16916
- toDisplayString(user.name),
16917
- 1
16918
- /* TEXT */
16919
- ),
16920
- user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
16921
- "span",
16922
- _hoisted_7,
16923
- "@" + toDisplayString(__props.tenants[user.tenantId]),
16924
- 1
16925
- /* TEXT */
16926
- )) : createCommentVNode("v-if", true)
16927
- ]))
16928
- ], 40, _hoisted_4$1);
16936
+ createVNode(unref(UserRender), {
16937
+ render: __props.renderListItem,
16938
+ "tenant-id": __props.tenantId,
16939
+ tenants: __props.tenants,
16940
+ user
16941
+ }, null, 8, ["render", "tenant-id", "tenants", "user"])
16942
+ ], 40, _hoisted_4);
16929
16943
  }),
16930
16944
  128
16931
16945
  /* KEYED_FRAGMENT */
@@ -16942,21 +16956,11 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16942
16956
  ]),
16943
16957
  _: 1
16944
16958
  /* STABLE */
16945
- }, 8, ["is-show", "width"]);
16959
+ }, 8, ["is-show", "offset", "width"]);
16946
16960
  };
16947
16961
  }
16948
16962
  });
16949
- const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-a1278ff6"]]);
16950
- const _hoisted_1$3 = { key: 0 };
16951
- const _hoisted_2$2 = {
16952
- key: 1,
16953
- class: "tag-content"
16954
- };
16955
- const _hoisted_3$1 = { class: "user-name" };
16956
- const _hoisted_4 = {
16957
- key: 0,
16958
- class: "tenant-name"
16959
- };
16963
+ const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-54b68f9a"]]);
16960
16964
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16961
16965
  ...{
16962
16966
  name: "UserTag"
@@ -16988,27 +16992,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16988
16992
  onClose: handleClose
16989
16993
  }, {
16990
16994
  default: withCtx(() => [
16991
- _ctx.renderTag ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
16992
- createVNode(unref(UserRender), {
16993
- render: _ctx.renderTag,
16994
- user: _ctx.user
16995
- }, null, 8, ["render", "user"])
16996
- ])) : (openBlock(), createElementBlock("div", _hoisted_2$2, [
16997
- createElementVNode(
16998
- "span",
16999
- _hoisted_3$1,
17000
- toDisplayString(_ctx.user.name),
17001
- 1
17002
- /* TEXT */
17003
- ),
17004
- _ctx.user.tenantId !== _ctx.currentTenantId && _ctx.user.tenantId ? (openBlock(), createElementBlock(
17005
- "span",
17006
- _hoisted_4,
17007
- " @" + toDisplayString(_ctx.tenants[_ctx.user.tenantId]),
17008
- 1
17009
- /* TEXT */
17010
- )) : createCommentVNode("v-if", true)
17011
- ]))
16995
+ createVNode(unref(UserRender), {
16996
+ render: _ctx.renderTag,
16997
+ "tenant-id": _ctx.currentTenantId,
16998
+ tenants: _ctx.tenants,
16999
+ user: _ctx.user
17000
+ }, null, 8, ["render", "tenant-id", "tenants", "user"])
17012
17001
  ]),
17013
17002
  _: 1
17014
17003
  /* STABLE */
@@ -17016,7 +17005,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
17016
17005
  };
17017
17006
  }
17018
17007
  });
17019
- const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-7099192b"]]);
17008
+ const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-655f7a5a"]]);
17020
17009
  const _hoisted_1$2 = ["onClick"];
17021
17010
  const _hoisted_2$1 = ["placeholder"];
17022
17011
  const _hoisted_3 = ["placeholder"];
@@ -17120,7 +17109,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17120
17109
  }
17121
17110
  });
17122
17111
  };
17123
- const handleClickOutside = ({ event }) => {
17112
+ const handleClickOutside = (event) => {
17124
17113
  event.stopPropagation();
17125
17114
  const target = event.target;
17126
17115
  const container = containerRef.value;
@@ -17255,6 +17244,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17255
17244
  });
17256
17245
  }
17257
17246
  };
17247
+ const crossAxisOffset = ref(0);
17258
17248
  watch(
17259
17249
  () => props2.selectedUsers,
17260
17250
  () => {
@@ -17422,25 +17412,42 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17422
17412
  /* KEYED_FRAGMENT */
17423
17413
  )),
17424
17414
  createCommentVNode(" 显示折叠标签数量 "),
17425
- hiddenCount.value > 0 ? withDirectives((openBlock(), createBlock(unref(__webpack_exports__default), {
17415
+ hiddenCount.value > 0 ? (openBlock(), createBlock(unref(__webpack_exports__default$1), {
17426
17416
  key: 0,
17427
- onClick: withModifiers(handleFocus, ["stop"])
17417
+ placement: "top"
17428
17418
  }, {
17419
+ content: withCtx(() => [
17420
+ (openBlock(true), createElementBlock(
17421
+ Fragment,
17422
+ null,
17423
+ renderList(_ctx.selectedUsers.slice(visibleUsers.value.length), (user) => {
17424
+ return openBlock(), createBlock(unref(UserRender), {
17425
+ key: user.id,
17426
+ "tenant-id": _ctx.tenantId,
17427
+ tenants: _ctx.tenants,
17428
+ user
17429
+ }, null, 8, ["tenant-id", "tenants", "user"]);
17430
+ }),
17431
+ 128
17432
+ /* KEYED_FRAGMENT */
17433
+ ))
17434
+ ]),
17429
17435
  default: withCtx(() => [
17430
- createTextVNode(
17431
- " +" + toDisplayString(hiddenCount.value),
17432
- 1
17433
- /* TEXT */
17434
- )
17436
+ createVNode(unref(__webpack_exports__default), null, {
17437
+ default: withCtx(() => [
17438
+ createTextVNode(
17439
+ " +" + toDisplayString(hiddenCount.value),
17440
+ 1
17441
+ /* TEXT */
17442
+ )
17443
+ ]),
17444
+ _: 1
17445
+ /* STABLE */
17446
+ })
17435
17447
  ]),
17436
17448
  _: 1
17437
17449
  /* STABLE */
17438
- })), [
17439
- [unref(__webpack_exports__bkTooltips), {
17440
- content: _ctx.selectedUsers.slice(visibleUsers.value.length).map((user) => user.display_name).join(","),
17441
- placement: "top"
17442
- }]
17443
- ]) : createCommentVNode("v-if", true),
17450
+ })) : createCommentVNode("v-if", true),
17444
17451
  createCommentVNode(" 搜索输入框 "),
17445
17452
  withDirectives(createElementVNode("input", {
17446
17453
  ref_key: "collapsedInputRef",
@@ -17469,6 +17476,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17469
17476
  createCommentVNode(" 下拉选项列表 "),
17470
17477
  createVNode(SelectionPopover, {
17471
17478
  "container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
17479
+ "cross-axis-offset": crossAxisOffset.value,
17472
17480
  "empty-text": _ctx.emptyText,
17473
17481
  "is-show": showDropdown.value,
17474
17482
  loading: unref(searchLoading),
@@ -17479,9 +17487,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17479
17487
  tenants: _ctx.tenants,
17480
17488
  "user-group": userGroupFilter.value,
17481
17489
  "user-group-name": _ctx.userGroupName,
17482
- onClickoutside: handleClickOutside,
17490
+ onClickOutside: handleClickOutside,
17483
17491
  onSelectUser: addUser
17484
- }, null, 8, ["container-width", "empty-text", "is-show", "loading", "options", "render-list-item", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
17492
+ }, null, 8, ["container-width", "cross-axis-offset", "empty-text", "is-show", "loading", "options", "render-list-item", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
17485
17493
  ],
17486
17494
  512
17487
17495
  /* NEED_PATCH */
@@ -17489,7 +17497,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17489
17497
  };
17490
17498
  }
17491
17499
  });
17492
- const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-d4f489c3"]]);
17500
+ const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-d9743f6d"]]);
17493
17501
  const _hoisted_1$1 = { class: "input-container" };
17494
17502
  const _hoisted_2 = ["placeholder"];
17495
17503
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
@@ -17626,11 +17634,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17626
17634
  onClick: withModifiers(removeSelectedUser, ["stop"])
17627
17635
  }, [
17628
17636
  createVNode(UserTag, {
17637
+ "current-tenant-id": _ctx.tenantId,
17629
17638
  "render-tag": _ctx.renderTag,
17630
17639
  tenants: _ctx.tenants,
17631
17640
  user: selectedUserInfo.value,
17632
17641
  onClose: removeSelectedUser
17633
- }, null, 8, ["render-tag", "tenants", "user"])
17642
+ }, null, 8, ["current-tenant-id", "render-tag", "tenants", "user"])
17634
17643
  ])) : createCommentVNode("v-if", true),
17635
17644
  withDirectives(createElementVNode("input", {
17636
17645
  ref_key: "inputRef",
@@ -17671,7 +17680,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17671
17680
  };
17672
17681
  }
17673
17682
  });
17674
- const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-91a75bba"]]);
17683
+ const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-b20a7499"]]);
17675
17684
  const _hoisted_1 = {
17676
17685
  ref: "containerRef",
17677
17686
  class: "bk-user-selector"