@blueking/bk-user-selector 0.0.4 → 0.0.5

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 CHANGED
@@ -57,7 +57,7 @@ import '@blueking/bk-user-selector/vue2/vue2.css';
57
57
  :api-base-url="apiBaseUrl"
58
58
  :tenant-id="tenantId"
59
59
  :current-user-id="currentUserId"
60
- :exact-key="exactKey"
60
+ :exact-search-key="exactSearchKey"
61
61
  @change="handleUserChange"
62
62
  />
63
63
 
@@ -67,7 +67,7 @@ import '@blueking/bk-user-selector/vue2/vue2.css';
67
67
  :api-base-url="apiBaseUrl"
68
68
  :tenant-id="tenantId"
69
69
  :current-user-id="currentUserId"
70
- :exact-key="exactKey"
70
+ :exact-search-key="exactSearchKey"
71
71
  :multiple="true"
72
72
  :draggable="true"
73
73
  @change="handleUsersChange"
@@ -84,7 +84,7 @@ import '@blueking/bk-user-selector/vue2/vue2.css';
84
84
  // 当前用户ID
85
85
  const currentUserId = ref('admin');
86
86
  // 精确查找key
87
- const exactKey = ref('bk_username');
87
+ const exactSearchKey = ref('bk_username');
88
88
  // 单选选中值
89
89
  const selectedUser = ref('');
90
90
  // 多选选中值
@@ -116,7 +116,7 @@ import '@blueking/bk-user-selector/vue2/vue2.css';
116
116
  | draggable | 是否可拖拽(仅多选模式有效) | Boolean | false |
117
117
  | apiBaseUrl | API 基础 URL | String | '' |
118
118
  | tenantId | 租户 ID | String | '' |
119
- | exactKey | 精确查找key,可选值为 bk_username、login_name、full_name, 多个以逗号分隔 | String | 'bk_username' |
119
+ | exactSearchKey | 精确查找key,可选值为 bk_username、login_name、full_name, 多个以逗号分隔 | String | 'bk_username' |
120
120
  | currentUserId | 当前用户ID(用于快速选择"我") | String | '' |
121
121
 
122
122
  ### 事件
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/bk-user-selector",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "蓝鲸用户选择器",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",
@@ -23,10 +23,10 @@ export declare const searchUsers: (apiBaseUrl?: string, tenantId?: string, keywo
23
23
  * @param apiBaseUrl - API基础URL
24
24
  * @param tenantId - 租户ID
25
25
  * @param users - 用户名列表
26
- * @param exactKey - 精确查找key
26
+ * @param exactSearchKey - 精确查找key
27
27
  * @returns 查找到的用户列表Promise
28
28
  */
29
- export declare const lookupUsers: (apiBaseUrl?: string, tenantId?: string, exactKey?: string, users?: string[]) => Promise<User[]>;
29
+ export declare const lookupUsers: (apiBaseUrl?: string, tenantId?: string, exactSearchKey?: string, users?: string[]) => Promise<User[]>;
30
30
  /**
31
31
  * 将API返回的用户数据格式化为组件所需格式
32
32
  * @param users - API返回的用户列表
@@ -59,7 +59,7 @@ declare const _default: import("vue").DefineComponent<{
59
59
  /**
60
60
  * 精确查找key
61
61
  */
62
- exactKey: {
62
+ exactSearchKey: {
63
63
  type: StringConstructor;
64
64
  default: string;
65
65
  };
@@ -127,7 +127,7 @@ declare const _default: import("vue").DefineComponent<{
127
127
  /**
128
128
  * 精确查找key
129
129
  */
130
- exactKey: {
130
+ exactSearchKey: {
131
131
  type: StringConstructor;
132
132
  default: string;
133
133
  };
@@ -144,6 +144,6 @@ declare const _default: import("vue").DefineComponent<{
144
144
  tenantId: string;
145
145
  selectedUsers: FormattedUser[];
146
146
  currentUserId: string;
147
- exactKey: string;
147
+ exactSearchKey: string;
148
148
  }, {}>;
149
149
  export default _default;
@@ -7,7 +7,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
7
7
  draggable: boolean;
8
8
  multiple: boolean;
9
9
  currentUserId: string;
10
- exactKey: string;
10
+ exactSearchKey: string;
11
11
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  change: (...args: any[]) => void;
13
13
  "update:modelValue": (...args: any[]) => void;
@@ -19,7 +19,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
19
19
  draggable: boolean;
20
20
  multiple: boolean;
21
21
  currentUserId: string;
22
- exactKey: string;
22
+ exactSearchKey: string;
23
23
  }>>> & {
24
24
  onChange?: ((...args: any[]) => any) | undefined;
25
25
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
@@ -30,7 +30,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
30
30
  apiBaseUrl: string;
31
31
  tenantId: string;
32
32
  currentUserId: string;
33
- exactKey: string;
33
+ exactSearchKey: string;
34
34
  multiple: boolean;
35
35
  }, {}>;
36
36
  export default _default;
@@ -92,7 +92,7 @@ export interface UserSelectorProps {
92
92
  /**
93
93
  * 精确查找key, 默认是 bk_username, 可选值为 bk_username、login_name、full_name, 多个以逗号分隔
94
94
  */
95
- exactKey?: string;
95
+ exactSearchKey?: string;
96
96
  }
97
97
  /**
98
98
  * 单选模式属性
@@ -125,5 +125,5 @@ export interface SingleSelectorProps {
125
125
  /**
126
126
  * 精确查找key
127
127
  */
128
- exactKey?: string;
128
+ exactSearchKey?: string;
129
129
  }
@@ -48,13 +48,13 @@ const searchUsers = async (apiBaseUrl = "", tenantId = "", keyword = "") => {
48
48
  return [];
49
49
  }
50
50
  };
51
- const lookupUsers = async (apiBaseUrl = "", tenantId = "", exactKey = "bk_username", users = []) => {
51
+ const lookupUsers = async (apiBaseUrl = "", tenantId = "", exactSearchKey = "bk_username", users = []) => {
52
52
  if (users.length === 0 || !apiBaseUrl || !tenantId) {
53
53
  console.warn("批量查找用户需要提供有效的apiBaseUrl、租户ID和至少一个用户名");
54
54
  return [];
55
55
  }
56
56
  try {
57
- const url = `${apiBaseUrl}/api/v3/open-web/tenant/users/-/lookup/?lookups=${users.join(",")}&lookup_fields=${exactKey}`;
57
+ const url = `${apiBaseUrl}/api/v3/open-web/tenant/users/-/lookup/?lookups=${users.join(",")}&lookup_fields=${exactSearchKey}`;
58
58
  const response = await fetch(url, {
59
59
  method: "GET",
60
60
  headers: {
@@ -16780,7 +16780,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16780
16780
  /**
16781
16781
  * 精确查找key
16782
16782
  */
16783
- exactKey: {
16783
+ exactSearchKey: {
16784
16784
  type: String,
16785
16785
  default: "bk_username"
16786
16786
  }
@@ -16898,7 +16898,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16898
16898
  const addCurrentUser = async () => {
16899
16899
  if (!props2.currentUserId || props2.selectedUsers.some((user) => user.id === props2.currentUserId)) return;
16900
16900
  try {
16901
- const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactKey, [props2.currentUserId]);
16901
+ const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactSearchKey, [props2.currentUserId]);
16902
16902
  const formattedUsers = formatUsers(result);
16903
16903
  if (formattedUsers.length > 0) {
16904
16904
  if (!props2.selectedUsers.some((item) => item.id === formattedUsers[0].id)) {
@@ -16919,7 +16919,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16919
16919
  if (pastedText.trim()) {
16920
16920
  try {
16921
16921
  const users = pastedText.trim().split(/[,,;\n\s]+/).filter(Boolean);
16922
- const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactKey, users);
16922
+ const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactSearchKey, users);
16923
16923
  const formattedUsers = formatUsers(result);
16924
16924
  if (formattedUsers.length > 0) {
16925
16925
  const updatedUsers = [...props2.selectedUsers, ...formattedUsers];
@@ -17257,8 +17257,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17257
17257
  };
17258
17258
  }
17259
17259
  });
17260
- const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-55945956"]]);
17261
- const _withScopeId = (n2) => (pushScopeId("data-v-d17d0282"), n2 = n2(), popScopeId(), n2);
17260
+ const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-9ddcc982"]]);
17261
+ const _withScopeId = (n2) => (pushScopeId("data-v-1b38f31d"), n2 = n2(), popScopeId(), n2);
17262
17262
  const _hoisted_1$1 = { class: "input-container" };
17263
17263
  const _hoisted_2 = {
17264
17264
  key: 0,
@@ -17293,7 +17293,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17293
17293
  tenantId: {},
17294
17294
  tenants: {},
17295
17295
  currentUserId: {},
17296
- exactKey: {}
17296
+ exactSearchKey: {}
17297
17297
  },
17298
17298
  emits: ["update:modelValue", "change"],
17299
17299
  setup(__props, { emit: __emit }) {
@@ -17313,7 +17313,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17313
17313
  if (typeof props2.modelValue === "string" && props2.modelValue) {
17314
17314
  try {
17315
17315
  isLoading.value = true;
17316
- const result = await lookupUsers(props2.apiBaseUrl || "", props2.tenantId || "", props2.exactKey, [
17316
+ const result = await lookupUsers(props2.apiBaseUrl || "", props2.tenantId || "", props2.exactSearchKey, [
17317
17317
  props2.modelValue
17318
17318
  ]);
17319
17319
  options.value = formatUsers(result);
@@ -17327,7 +17327,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17327
17327
  const addCurrentUser = async () => {
17328
17328
  if (!props2.currentUserId || selectedUser.value === props2.currentUserId) return;
17329
17329
  try {
17330
- const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactKey, [props2.currentUserId]);
17330
+ const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactSearchKey, [props2.currentUserId]);
17331
17331
  const formattedResults = formatUsers(result);
17332
17332
  if (formattedResults.length > 0) {
17333
17333
  options.value = formattedResults;
@@ -17503,7 +17503,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17503
17503
  };
17504
17504
  }
17505
17505
  });
17506
- const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-d17d0282"]]);
17506
+ const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-1b38f31d"]]);
17507
17507
  const _hoisted_1 = { class: "bk-user-selector" };
17508
17508
  const _sfc_main = /* @__PURE__ */ defineComponent({
17509
17509
  ...{
@@ -17518,7 +17518,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17518
17518
  draggable: { type: Boolean, default: false },
17519
17519
  multiple: { type: Boolean, default: false },
17520
17520
  currentUserId: { default: "" },
17521
- exactKey: { default: "" }
17521
+ exactSearchKey: { default: "" }
17522
17522
  },
17523
17523
  emits: ["update:modelValue", "change"],
17524
17524
  setup(__props, { emit: __emit }) {
@@ -17535,8 +17535,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17535
17535
  const ids = Array.isArray(props2.modelValue) ? props2.modelValue : [];
17536
17536
  if (ids.length > 0) {
17537
17537
  try {
17538
- console.log(props2.exactKey);
17539
- const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactKey, ids);
17538
+ console.log(props2.exactSearchKey);
17539
+ const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactSearchKey, ids);
17540
17540
  selectedUsers.value = formatUsers(result);
17541
17541
  } catch (error3) {
17542
17542
  console.error("获取选中用户信息失败:", error3);
@@ -17574,12 +17574,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17574
17574
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedUser.value = $event),
17575
17575
  "api-base-url": _ctx.apiBaseUrl,
17576
17576
  "current-user-id": _ctx.currentUserId,
17577
- "exact-key": _ctx.exactKey,
17577
+ "exact-search-key": _ctx.exactSearchKey,
17578
17578
  placeholder: _ctx.placeholder,
17579
17579
  "tenant-id": _ctx.tenantId,
17580
17580
  tenants: unref(tenants),
17581
17581
  onChange: handleUpdateUser
17582
- }, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-key", "placeholder", "tenant-id", "tenants"])) : (openBlock(), createElementBlock(
17582
+ }, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants"])) : (openBlock(), createElementBlock(
17583
17583
  Fragment,
17584
17584
  { key: 1 },
17585
17585
  [
@@ -17590,13 +17590,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17590
17590
  "api-base-url": _ctx.apiBaseUrl,
17591
17591
  "current-user-id": _ctx.currentUserId,
17592
17592
  draggable: _ctx.draggable,
17593
- "exact-key": _ctx.exactKey,
17593
+ "exact-search-key": _ctx.exactSearchKey,
17594
17594
  placeholder: _ctx.placeholder,
17595
17595
  "selected-users": selectedUsers.value,
17596
17596
  "tenant-id": _ctx.tenantId,
17597
17597
  tenants: unref(tenants),
17598
17598
  "onUpdate:selectedUsers": handleUpdateSelectedUsers
17599
- }, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-key", "placeholder", "selected-users", "tenant-id", "tenants"])
17599
+ }, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants"])
17600
17600
  ],
17601
17601
  2112
17602
17602
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
@@ -17605,7 +17605,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17605
17605
  };
17606
17606
  }
17607
17607
  });
17608
- const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ee509d86"]]);
17608
+ const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fe084750"]]);
17609
17609
  const vue2 = {
17610
17610
  beforeDestroy() {
17611
17611
  var _a;