@blueking/bk-user-selector 0.1.5 → 0.1.6

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
@@ -22,6 +22,7 @@
22
22
  | 🎭 **自定义渲染** | 支持自定义标签和列表项渲染 |
23
23
  | 📝 **多行输入** | 支持 textarea 模式,完整展示所有标签 |
24
24
  | ⌨️ **键盘导航** | 支持上下键切换选项、Enter 快速选中 |
25
+ | 🎯 **焦点控制** | 支持自动聚焦和手动 focus/blur 方法 |
25
26
 
26
27
  ## 📦 安装
27
28
 
@@ -294,33 +295,34 @@ export default {
294
295
 
295
296
  ### Props 属性
296
297
 
297
- | 参数 | 说明 | 类型 | 默认值 | 必填 |
298
- | --------------------- | --------------------------------- | ------------------------------------------------ | ---------------------- | ---- |
299
- | modelValue / v-model | 绑定值,单选为字符串,多选为数组 | `string` / `string[]` | `''` / `[]` | 是 |
300
- | apiBaseUrl | API 基础 URL | `string` | `''` | 是 |
301
- | tenantId | 租户 ID | `string` | `'default'` | 否 |
302
- | hasAvatar | 是否显示头像 | `boolean` | `false` | 否 |
303
- | avatarBaseUrl | 头像基础 URL | `string` | `` | 否 |
304
- | label | 文本标签 | `string` | `'人员选择'` | 否 |
305
- | placeholder | 占位文本 | `string` | `'请输入人员名称搜索'` | 否 |
306
- | multiple | 是否多选 | `boolean` | `false` | 否 |
307
- | draggable | 是否可拖拽排序(仅多选模式有效) | `boolean` | `false` | 否 |
308
- | exactSearchKey | 精确查找 key | `'bk_username'` / `'login_name'` / `'full_name'` | `'bk_username'` | 否 |
309
- | currentUserId | 当前用户 ID(用于快速选择"我") | `string` | `''` | 否 |
310
- | userGroup | 用户组列表 | `UserGroupItem[]` | `[]` | 否 |
311
- | userGroupName | 用户组分类名称 | `string` | `'用户群组'` | 否 |
312
- | emptyText | 无匹配人员时的提示文本 | `string` | `'无匹配人员'` | 否 |
313
- | disabled | 是否禁用 | `boolean` | `false` | 否 |
314
- | renderTag | 自定义标签渲染函数 | `(h, userInfo) => VNode` | - | 否 |
315
- | renderListItem | 自定义列表项渲染函数 | `(h, userInfo) => VNode` | - | 否 |
316
- | excludeUserIds | 排除的用户 ID 列表 | `string[]` | `[]` | 否 |
317
- | enableMultiTenantMode | 是否启用多租户模式 | `boolean` | `true` | 否 |
318
- | allowCreate | 是否允许自定义输入,按 Enter 确认 | `boolean` | `false` | 否 |
319
- | freePaste | 是否允许粘贴任意文本 | `boolean` | `false` | 否 |
320
- | maxCount | 最大可选数量(0 表示不限制) | `number` | `0` | 否 |
321
- | type | 输入框类型 | `'input'` / `'textarea'` | `'input'` | 否 |
322
- | rows | 默认行数(仅 textarea 模式生效) | `number` | `4` | 否 |
323
- | resize | 是否允许拖拽调整高度(仅 textarea 模式生效) | `boolean` | `true` | 否 |
298
+ | 参数 | 说明 | 类型 | 默认值 | 必填 |
299
+ | --------------------- | -------------------------------------------- | ------------------------------------------------ | ---------------------- | ---- |
300
+ | modelValue / v-model | 绑定值,单选为字符串,多选为数组 | `string` / `string[]` | `''` / `[]` | 是 |
301
+ | apiBaseUrl | API 基础 URL | `string` | `''` | 是 |
302
+ | tenantId | 租户 ID | `string` | `'default'` | 否 |
303
+ | hasAvatar | 是否显示头像 | `boolean` | `false` | 否 |
304
+ | avatarBaseUrl | 头像基础 URL | `string` | `` | 否 |
305
+ | label | 文本标签 | `string` | `'人员选择'` | 否 |
306
+ | placeholder | 占位文本 | `string` | `'请输入人员名称搜索'` | 否 |
307
+ | multiple | 是否多选 | `boolean` | `false` | 否 |
308
+ | draggable | 是否可拖拽排序(仅多选模式有效) | `boolean` | `false` | 否 |
309
+ | exactSearchKey | 精确查找 key | `'bk_username'` / `'login_name'` / `'full_name'` | `'bk_username'` | 否 |
310
+ | currentUserId | 当前用户 ID(用于快速选择"我") | `string` | `''` | 否 |
311
+ | userGroup | 用户组列表 | `UserGroupItem[]` | `[]` | 否 |
312
+ | userGroupName | 用户组分类名称 | `string` | `'用户群组'` | 否 |
313
+ | emptyText | 无匹配人员时的提示文本 | `string` | `'无匹配人员'` | 否 |
314
+ | disabled | 是否禁用 | `boolean` | `false` | 否 |
315
+ | renderTag | 自定义标签渲染函数 | `(h, userInfo) => VNode` | - | 否 |
316
+ | renderListItem | 自定义列表项渲染函数 | `(h, userInfo) => VNode` | - | 否 |
317
+ | excludeUserIds | 排除的用户 ID 列表 | `string[]` | `[]` | 否 |
318
+ | enableMultiTenantMode | 是否启用多租户模式 | `boolean` | `true` | 否 |
319
+ | allowCreate | 是否允许自定义输入,按 Enter 确认 | `boolean` | `false` | 否 |
320
+ | freePaste | 是否允许粘贴任意文本 | `boolean` | `false` | 否 |
321
+ | maxCount | 最大可选数量(0 表示不限制) | `number` | `0` | 否 |
322
+ | type | 输入框类型 | `'input'` / `'textarea'` | `'input'` | 否 |
323
+ | rows | 默认行数(仅 textarea 模式生效) | `number` | `4` | 否 |
324
+ | resize | 是否允许拖拽调整高度(仅 textarea 模式生效) | `boolean` | `true` | 否 |
325
+ | autoFocus | 是否自动聚焦 | `boolean` | `false` | 否 |
324
326
 
325
327
  #### exactSearchKey 说明
326
328
 
@@ -339,8 +341,36 @@ export default {
339
341
  | ----------------- | -------------------- | ------------------------------------ |
340
342
  | update:modelValue | 绑定值变化时触发 | `(value: string \| string[])` |
341
343
  | change | 选中值变化时触发 | `(userInfo: UserInfo \| UserInfo[])` |
342
- | focus | 输入框获得焦点时触发 | `(event: FocusEvent)` |
343
- | blur | 输入框失去焦点时触发 | `(event: FocusEvent)` |
344
+ | focus | 输入框获得焦点时触发 | - |
345
+ | blur | 输入框失去焦点时触发 | - |
346
+
347
+ ### Methods 方法
348
+
349
+ 通过模板 ref 调用组件方法:
350
+
351
+ | 方法名 | 说明 | 参数 |
352
+ | ------ | ---------- | ---- |
353
+ | focus | 使组件聚焦 | - |
354
+ | blur | 使组件失焦 | - |
355
+
356
+ ```vue
357
+ <template>
358
+ <BkUserSelector
359
+ ref="selectorRef"
360
+ v-model="value"
361
+ :api-base-url="apiBaseUrl"
362
+ />
363
+ <button @click="selectorRef?.focus()">聚焦</button>
364
+ <button @click="selectorRef?.blur()">失焦</button>
365
+ </template>
366
+
367
+ <script setup>
368
+ import { ref } from 'vue';
369
+ const selectorRef = ref(null);
370
+ const value = ref('');
371
+ const apiBaseUrl = 'https://api.example.com';
372
+ </script>
373
+ ```
344
374
 
345
375
  ### 类型定义
346
376
 
@@ -462,7 +492,7 @@ A: 通过 `change` 事件获取,它会返回完整的用户信息对象,而
462
492
 
463
493
  ### Q: 多选模式下如何限制选择数量?
464
494
 
465
- A: 目前组件暂不支持直接限制,可以通过 `change` 事件监听并在超出数量时给出提示。
495
+ A: 使用 `maxCount` 属性设置最大可选数量,`0` 表示不限制。
466
496
 
467
497
  ### Q: 搜索没有结果怎么办?
468
498
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/bk-user-selector",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "蓝鲸用户选择器",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",
@@ -1,5 +1,8 @@
1
1
  import { FormattedUser, UserSelectorProps } from '../types';
2
- declare const __VLS_export: import("vue").DefineComponent<UserSelectorProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
2
+ declare const __VLS_export: import("vue").DefineComponent<UserSelectorProps, {
3
+ focus: () => void;
4
+ blur: () => void;
5
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
3
6
  blur: () => any;
4
7
  change: (user: FormattedUser | FormattedUser[] | null) => any;
5
8
  focus: () => any;
@@ -32,6 +35,7 @@ declare const __VLS_export: import("vue").DefineComponent<UserSelectorProps, {},
32
35
  userGroupName: string;
33
36
  disabled: boolean;
34
37
  draggable: boolean;
38
+ autoFocus: boolean;
35
39
  modelValue: string | string[];
36
40
  multiple: boolean;
37
41
  rows: number;
@@ -204,6 +204,11 @@ export interface UserGroupConfig {
204
204
  * 用户选择器属性
205
205
  */
206
206
  export interface UserSelectorProps extends BaseSelectorProps {
207
+ /**
208
+ * 是否自动聚焦
209
+ * @default false
210
+ */
211
+ autoFocus?: boolean;
207
212
  /**
208
213
  * 是否支持拖拽排序
209
214
  */
@@ -11317,6 +11317,11 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
11317
11317
  name: "BkUserSelector",
11318
11318
  __name: "user-selector",
11319
11319
  props: {
11320
+ autoFocus: {
11321
+ type: Boolean,
11322
+ required: false,
11323
+ default: false
11324
+ },
11320
11325
  draggable: {
11321
11326
  type: Boolean,
11322
11327
  required: false,
@@ -11445,12 +11450,11 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
11445
11450
  "update:modelValue"
11446
11451
  ],
11447
11452
  setup(__props, { expose: __expose, emit: __emit }) {
11448
- __expose();
11449
11453
  const { t: t$1 } = use_i18n_default();
11450
11454
  __webpack_exports__provideGlobalConfig({ prefix: "bk-user-selector" });
11451
11455
  const props = __props;
11452
11456
  const emit = __emit;
11453
- const { tenants = {} } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11457
+ const { tenants } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11454
11458
  const { searchResults, loading: searchLoading, searchQuery, clearSearch, handleSearchInput } = useUserSearch(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11455
11459
  const { fetchCurrentUser } = useCurrentUser({
11456
11460
  apiBaseUrl: props.apiBaseUrl,
@@ -11506,7 +11510,7 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
11506
11510
  currentTenantId: props.tenantId,
11507
11511
  hasAvatar: props.hasAvatar,
11508
11512
  renderTag: props.renderTag,
11509
- tenants
11513
+ tenants: tenants.value
11510
11514
  }));
11511
11515
  const { filteredUserGroup, filterOptions, createCustomUser } = useUserSelection({
11512
11516
  selectedUserIds,
@@ -11644,10 +11648,7 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
11644
11648
  const scheduleVisibleUsersCalculation = () => {
11645
11649
  if (!isFocused.value) nextTick(calculateVisibleUsers);
11646
11650
  };
11647
- const handleClickOutside = (event) => {
11648
- const target = event.target;
11649
- const container = containerRef.value;
11650
- if (container?.contains(target) || container === target) return;
11651
+ const blur = () => {
11651
11652
  if (isFocused.value) emit("blur");
11652
11653
  isFocused.value = false;
11653
11654
  activeTagIndex.value = selectedUsers.value.length - 1;
@@ -11655,6 +11656,12 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
11655
11656
  highlightedIndex.value = -1;
11656
11657
  scheduleVisibleUsersCalculation();
11657
11658
  };
11659
+ const handleClickOutside = (event) => {
11660
+ const target = event.target;
11661
+ const container = containerRef.value;
11662
+ if (container?.contains(target) || container === target) return;
11663
+ blur();
11664
+ };
11658
11665
  const handleContainerClick = () => {
11659
11666
  activeTagIndex.value = selectedUsers.value.length - 1;
11660
11667
  nextTick(() => focusCurrentInput());
@@ -11804,16 +11811,26 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
11804
11811
  useResizeObserver(containerRef, () => {
11805
11812
  scheduleVisibleUsersCalculation();
11806
11813
  });
11814
+ let initPromise;
11807
11815
  onBeforeMount(() => {
11808
- initSelectedUsers();
11816
+ initPromise = initSelectedUsers();
11809
11817
  });
11810
- onMounted(() => {
11818
+ onMounted(async () => {
11811
11819
  initSortable();
11812
11820
  nextTick(calculateVisibleUsers);
11821
+ if (props.autoFocus && !props.disabled) {
11822
+ await initPromise;
11823
+ await nextTick();
11824
+ handleFocus();
11825
+ }
11813
11826
  });
11814
11827
  onUnmounted(() => {
11815
11828
  sortableInstance.value?.destroy();
11816
11829
  });
11830
+ __expose({
11831
+ focus: handleFocus,
11832
+ blur
11833
+ });
11817
11834
  const __returned__ = {
11818
11835
  t: t$1,
11819
11836
  props,
@@ -11864,6 +11881,7 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
11864
11881
  calculateVisibleUsers,
11865
11882
  handleFocus,
11866
11883
  scheduleVisibleUsersCalculation,
11884
+ blur,
11867
11885
  handleClickOutside,
11868
11886
  handleContainerClick,
11869
11887
  focusCurrentInput,
@@ -11875,6 +11893,12 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
11875
11893
  handleKeyDown,
11876
11894
  addUser,
11877
11895
  removeUser,
11896
+ get initPromise() {
11897
+ return initPromise;
11898
+ },
11899
+ set initPromise(v$1) {
11900
+ initPromise = v$1;
11901
+ },
11878
11902
  get Popover() {
11879
11903
  return __webpack_exports__default;
11880
11904
  },
@@ -17000,6 +17000,11 @@ Expected function or array of functions, received type ${typeof value}.`);
17000
17000
  name: "BkUserSelector",
17001
17001
  __name: "user-selector",
17002
17002
  props: {
17003
+ autoFocus: {
17004
+ type: Boolean,
17005
+ required: false,
17006
+ default: false
17007
+ },
17003
17008
  draggable: {
17004
17009
  type: Boolean,
17005
17010
  required: false,
@@ -17128,12 +17133,11 @@ Expected function or array of functions, received type ${typeof value}.`);
17128
17133
  "update:modelValue"
17129
17134
  ],
17130
17135
  setup(__props, { expose: __expose, emit: __emit }) {
17131
- __expose();
17132
17136
  const { t: t$1 } = use_i18n_default();
17133
17137
  __webpack_exports__provideGlobalConfig({ prefix: "bk-user-selector" });
17134
17138
  const props = __props;
17135
17139
  const emit$2 = __emit;
17136
- const { tenants = {} } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
17140
+ const { tenants } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
17137
17141
  const { searchResults, loading: searchLoading, searchQuery, clearSearch, handleSearchInput } = useUserSearch(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
17138
17142
  const { fetchCurrentUser } = useCurrentUser({
17139
17143
  apiBaseUrl: props.apiBaseUrl,
@@ -17189,7 +17193,7 @@ Expected function or array of functions, received type ${typeof value}.`);
17189
17193
  currentTenantId: props.tenantId,
17190
17194
  hasAvatar: props.hasAvatar,
17191
17195
  renderTag: props.renderTag,
17192
- tenants
17196
+ tenants: tenants.value
17193
17197
  }));
17194
17198
  const { filteredUserGroup, filterOptions, createCustomUser } = useUserSelection({
17195
17199
  selectedUserIds,
@@ -17327,10 +17331,7 @@ Expected function or array of functions, received type ${typeof value}.`);
17327
17331
  const scheduleVisibleUsersCalculation = () => {
17328
17332
  if (!isFocused.value) nextTick(calculateVisibleUsers);
17329
17333
  };
17330
- const handleClickOutside = (event) => {
17331
- const target = event.target;
17332
- const container = containerRef.value;
17333
- if (container?.contains(target) || container === target) return;
17334
+ const blur = () => {
17334
17335
  if (isFocused.value) emit$2("blur");
17335
17336
  isFocused.value = false;
17336
17337
  activeTagIndex.value = selectedUsers.value.length - 1;
@@ -17338,6 +17339,12 @@ Expected function or array of functions, received type ${typeof value}.`);
17338
17339
  highlightedIndex.value = -1;
17339
17340
  scheduleVisibleUsersCalculation();
17340
17341
  };
17342
+ const handleClickOutside = (event) => {
17343
+ const target = event.target;
17344
+ const container = containerRef.value;
17345
+ if (container?.contains(target) || container === target) return;
17346
+ blur();
17347
+ };
17341
17348
  const handleContainerClick = () => {
17342
17349
  activeTagIndex.value = selectedUsers.value.length - 1;
17343
17350
  nextTick(() => focusCurrentInput());
@@ -17487,16 +17494,26 @@ Expected function or array of functions, received type ${typeof value}.`);
17487
17494
  useResizeObserver(containerRef, () => {
17488
17495
  scheduleVisibleUsersCalculation();
17489
17496
  });
17497
+ let initPromise;
17490
17498
  onBeforeMount(() => {
17491
- initSelectedUsers();
17499
+ initPromise = initSelectedUsers();
17492
17500
  });
17493
- onMounted(() => {
17501
+ onMounted(async () => {
17494
17502
  initSortable();
17495
17503
  nextTick(calculateVisibleUsers);
17504
+ if (props.autoFocus && !props.disabled) {
17505
+ await initPromise;
17506
+ await nextTick();
17507
+ handleFocus();
17508
+ }
17496
17509
  });
17497
17510
  onUnmounted(() => {
17498
17511
  sortableInstance.value?.destroy();
17499
17512
  });
17513
+ __expose({
17514
+ focus: handleFocus,
17515
+ blur
17516
+ });
17500
17517
  const __returned__ = {
17501
17518
  t: t$1,
17502
17519
  props,
@@ -17547,6 +17564,7 @@ Expected function or array of functions, received type ${typeof value}.`);
17547
17564
  calculateVisibleUsers,
17548
17565
  handleFocus,
17549
17566
  scheduleVisibleUsersCalculation,
17567
+ blur,
17550
17568
  handleClickOutside,
17551
17569
  handleContainerClick,
17552
17570
  focusCurrentInput,
@@ -17558,6 +17576,12 @@ Expected function or array of functions, received type ${typeof value}.`);
17558
17576
  handleKeyDown,
17559
17577
  addUser,
17560
17578
  removeUser,
17579
+ get initPromise() {
17580
+ return initPromise;
17581
+ },
17582
+ set initPromise(v$1) {
17583
+ initPromise = v$1;
17584
+ },
17561
17585
  get Popover() {
17562
17586
  return __webpack_exports__default;
17563
17587
  },
@@ -11326,6 +11326,11 @@
11326
11326
  name: "BkUserSelector",
11327
11327
  __name: "user-selector",
11328
11328
  props: {
11329
+ autoFocus: {
11330
+ type: Boolean,
11331
+ required: false,
11332
+ default: false
11333
+ },
11329
11334
  draggable: {
11330
11335
  type: Boolean,
11331
11336
  required: false,
@@ -11454,12 +11459,11 @@
11454
11459
  "update:modelValue"
11455
11460
  ],
11456
11461
  setup(__props, { expose: __expose, emit: __emit }) {
11457
- __expose();
11458
11462
  const { t: t$1 } = use_i18n_default();
11459
11463
  __webpack_exports__provideGlobalConfig({ prefix: "bk-user-selector" });
11460
11464
  const props = __props;
11461
11465
  const emit = __emit;
11462
- const { tenants = {} } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11466
+ const { tenants } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11463
11467
  const { searchResults, loading: searchLoading, searchQuery, clearSearch, handleSearchInput } = useUserSearch(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11464
11468
  const { fetchCurrentUser } = useCurrentUser({
11465
11469
  apiBaseUrl: props.apiBaseUrl,
@@ -11515,7 +11519,7 @@
11515
11519
  currentTenantId: props.tenantId,
11516
11520
  hasAvatar: props.hasAvatar,
11517
11521
  renderTag: props.renderTag,
11518
- tenants
11522
+ tenants: tenants.value
11519
11523
  }));
11520
11524
  const { filteredUserGroup, filterOptions, createCustomUser } = useUserSelection({
11521
11525
  selectedUserIds,
@@ -11653,10 +11657,7 @@
11653
11657
  const scheduleVisibleUsersCalculation = () => {
11654
11658
  if (!isFocused.value) (0, __blueking_bkui_library.nextTick)(calculateVisibleUsers);
11655
11659
  };
11656
- const handleClickOutside = (event) => {
11657
- const target = event.target;
11658
- const container = containerRef.value;
11659
- if (container?.contains(target) || container === target) return;
11660
+ const blur = () => {
11660
11661
  if (isFocused.value) emit("blur");
11661
11662
  isFocused.value = false;
11662
11663
  activeTagIndex.value = selectedUsers.value.length - 1;
@@ -11664,6 +11665,12 @@
11664
11665
  highlightedIndex.value = -1;
11665
11666
  scheduleVisibleUsersCalculation();
11666
11667
  };
11668
+ const handleClickOutside = (event) => {
11669
+ const target = event.target;
11670
+ const container = containerRef.value;
11671
+ if (container?.contains(target) || container === target) return;
11672
+ blur();
11673
+ };
11667
11674
  const handleContainerClick = () => {
11668
11675
  activeTagIndex.value = selectedUsers.value.length - 1;
11669
11676
  (0, __blueking_bkui_library.nextTick)(() => focusCurrentInput());
@@ -11813,16 +11820,26 @@
11813
11820
  useResizeObserver(containerRef, () => {
11814
11821
  scheduleVisibleUsersCalculation();
11815
11822
  });
11823
+ let initPromise;
11816
11824
  (0, __blueking_bkui_library.onBeforeMount)(() => {
11817
- initSelectedUsers();
11825
+ initPromise = initSelectedUsers();
11818
11826
  });
11819
- (0, __blueking_bkui_library.onMounted)(() => {
11827
+ (0, __blueking_bkui_library.onMounted)(async () => {
11820
11828
  initSortable();
11821
11829
  (0, __blueking_bkui_library.nextTick)(calculateVisibleUsers);
11830
+ if (props.autoFocus && !props.disabled) {
11831
+ await initPromise;
11832
+ await (0, __blueking_bkui_library.nextTick)();
11833
+ handleFocus();
11834
+ }
11822
11835
  });
11823
11836
  (0, __blueking_bkui_library.onUnmounted)(() => {
11824
11837
  sortableInstance.value?.destroy();
11825
11838
  });
11839
+ __expose({
11840
+ focus: handleFocus,
11841
+ blur
11842
+ });
11826
11843
  const __returned__ = {
11827
11844
  t: t$1,
11828
11845
  props,
@@ -11873,6 +11890,7 @@
11873
11890
  calculateVisibleUsers,
11874
11891
  handleFocus,
11875
11892
  scheduleVisibleUsersCalculation,
11893
+ blur,
11876
11894
  handleClickOutside,
11877
11895
  handleContainerClick,
11878
11896
  focusCurrentInput,
@@ -11884,6 +11902,12 @@
11884
11902
  handleKeyDown,
11885
11903
  addUser,
11886
11904
  removeUser,
11905
+ get initPromise() {
11906
+ return initPromise;
11907
+ },
11908
+ set initPromise(v$1) {
11909
+ initPromise = v$1;
11910
+ },
11887
11911
  get Popover() {
11888
11912
  return __webpack_exports__default;
11889
11913
  },
@@ -3328,6 +3328,11 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
3328
3328
  name: "BkUserSelector",
3329
3329
  __name: "user-selector",
3330
3330
  props: {
3331
+ autoFocus: {
3332
+ type: Boolean,
3333
+ required: false,
3334
+ default: false
3335
+ },
3331
3336
  draggable: {
3332
3337
  type: Boolean,
3333
3338
  required: false,
@@ -3456,12 +3461,11 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
3456
3461
  "update:modelValue"
3457
3462
  ],
3458
3463
  setup(__props, { expose: __expose, emit: __emit }) {
3459
- __expose();
3460
3464
  const { t } = use_i18n_default();
3461
3465
  provideGlobalConfig({ prefix: "bk" });
3462
3466
  const props = __props;
3463
3467
  const emit = __emit;
3464
- const { tenants = {} } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
3468
+ const { tenants } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
3465
3469
  const { searchResults, loading: searchLoading, searchQuery, clearSearch, handleSearchInput } = useUserSearch(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
3466
3470
  const { fetchCurrentUser } = useCurrentUser({
3467
3471
  apiBaseUrl: props.apiBaseUrl,
@@ -3517,7 +3521,7 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
3517
3521
  currentTenantId: props.tenantId,
3518
3522
  hasAvatar: props.hasAvatar,
3519
3523
  renderTag: props.renderTag,
3520
- tenants
3524
+ tenants: tenants.value
3521
3525
  }));
3522
3526
  const { filteredUserGroup, filterOptions, createCustomUser } = useUserSelection({
3523
3527
  selectedUserIds,
@@ -3655,10 +3659,7 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
3655
3659
  const scheduleVisibleUsersCalculation = () => {
3656
3660
  if (!isFocused.value) nextTick(calculateVisibleUsers);
3657
3661
  };
3658
- const handleClickOutside = (event) => {
3659
- const target = event.target;
3660
- const container = containerRef.value;
3661
- if (container?.contains(target) || container === target) return;
3662
+ const blur = () => {
3662
3663
  if (isFocused.value) emit("blur");
3663
3664
  isFocused.value = false;
3664
3665
  activeTagIndex.value = selectedUsers.value.length - 1;
@@ -3666,6 +3667,12 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
3666
3667
  highlightedIndex.value = -1;
3667
3668
  scheduleVisibleUsersCalculation();
3668
3669
  };
3670
+ const handleClickOutside = (event) => {
3671
+ const target = event.target;
3672
+ const container = containerRef.value;
3673
+ if (container?.contains(target) || container === target) return;
3674
+ blur();
3675
+ };
3669
3676
  const handleContainerClick = () => {
3670
3677
  activeTagIndex.value = selectedUsers.value.length - 1;
3671
3678
  nextTick(() => focusCurrentInput());
@@ -3815,16 +3822,26 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
3815
3822
  useResizeObserver(containerRef, () => {
3816
3823
  scheduleVisibleUsersCalculation();
3817
3824
  });
3825
+ let initPromise;
3818
3826
  onBeforeMount(() => {
3819
- initSelectedUsers();
3827
+ initPromise = initSelectedUsers();
3820
3828
  });
3821
- onMounted(() => {
3829
+ onMounted(async () => {
3822
3830
  initSortable();
3823
3831
  nextTick(calculateVisibleUsers);
3832
+ if (props.autoFocus && !props.disabled) {
3833
+ await initPromise;
3834
+ await nextTick();
3835
+ handleFocus();
3836
+ }
3824
3837
  });
3825
3838
  onUnmounted(() => {
3826
3839
  sortableInstance.value?.destroy();
3827
3840
  });
3841
+ __expose({
3842
+ focus: handleFocus,
3843
+ blur
3844
+ });
3828
3845
  const __returned__ = {
3829
3846
  t,
3830
3847
  props,
@@ -3875,6 +3892,7 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
3875
3892
  calculateVisibleUsers,
3876
3893
  handleFocus,
3877
3894
  scheduleVisibleUsersCalculation,
3895
+ blur,
3878
3896
  handleClickOutside,
3879
3897
  handleContainerClick,
3880
3898
  focusCurrentInput,
@@ -3886,6 +3904,12 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
3886
3904
  handleKeyDown,
3887
3905
  addUser,
3888
3906
  removeUser,
3907
+ get initPromise() {
3908
+ return initPromise;
3909
+ },
3910
+ set initPromise(v) {
3911
+ initPromise = v;
3912
+ },
3889
3913
  get Popover() {
3890
3914
  return Popover;
3891
3915
  },
@@ -11332,6 +11332,11 @@ var lesscodeCustomComponentLibrary = (function(exports, vue) {
11332
11332
  name: "BkUserSelector",
11333
11333
  __name: "user-selector",
11334
11334
  props: {
11335
+ autoFocus: {
11336
+ type: Boolean,
11337
+ required: false,
11338
+ default: false
11339
+ },
11335
11340
  draggable: {
11336
11341
  type: Boolean,
11337
11342
  required: false,
@@ -11460,12 +11465,11 @@ var lesscodeCustomComponentLibrary = (function(exports, vue) {
11460
11465
  "update:modelValue"
11461
11466
  ],
11462
11467
  setup(__props, { expose: __expose, emit: __emit }) {
11463
- __expose();
11464
11468
  const { t: t$1 } = use_i18n_default();
11465
11469
  __webpack_exports__provideGlobalConfig({ prefix: "bk-user-selector" });
11466
11470
  const props = __props;
11467
11471
  const emit = __emit;
11468
- const { tenants = {} } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11472
+ const { tenants } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11469
11473
  const { searchResults, loading: searchLoading, searchQuery, clearSearch, handleSearchInput } = useUserSearch(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
11470
11474
  const { fetchCurrentUser } = useCurrentUser({
11471
11475
  apiBaseUrl: props.apiBaseUrl,
@@ -11521,7 +11525,7 @@ var lesscodeCustomComponentLibrary = (function(exports, vue) {
11521
11525
  currentTenantId: props.tenantId,
11522
11526
  hasAvatar: props.hasAvatar,
11523
11527
  renderTag: props.renderTag,
11524
- tenants
11528
+ tenants: tenants.value
11525
11529
  }));
11526
11530
  const { filteredUserGroup, filterOptions, createCustomUser } = useUserSelection({
11527
11531
  selectedUserIds,
@@ -11659,10 +11663,7 @@ var lesscodeCustomComponentLibrary = (function(exports, vue) {
11659
11663
  const scheduleVisibleUsersCalculation = () => {
11660
11664
  if (!isFocused.value) (0, vue.nextTick)(calculateVisibleUsers);
11661
11665
  };
11662
- const handleClickOutside = (event) => {
11663
- const target = event.target;
11664
- const container = containerRef.value;
11665
- if (container?.contains(target) || container === target) return;
11666
+ const blur = () => {
11666
11667
  if (isFocused.value) emit("blur");
11667
11668
  isFocused.value = false;
11668
11669
  activeTagIndex.value = selectedUsers.value.length - 1;
@@ -11670,6 +11671,12 @@ var lesscodeCustomComponentLibrary = (function(exports, vue) {
11670
11671
  highlightedIndex.value = -1;
11671
11672
  scheduleVisibleUsersCalculation();
11672
11673
  };
11674
+ const handleClickOutside = (event) => {
11675
+ const target = event.target;
11676
+ const container = containerRef.value;
11677
+ if (container?.contains(target) || container === target) return;
11678
+ blur();
11679
+ };
11673
11680
  const handleContainerClick = () => {
11674
11681
  activeTagIndex.value = selectedUsers.value.length - 1;
11675
11682
  (0, vue.nextTick)(() => focusCurrentInput());
@@ -11819,16 +11826,26 @@ var lesscodeCustomComponentLibrary = (function(exports, vue) {
11819
11826
  useResizeObserver(containerRef, () => {
11820
11827
  scheduleVisibleUsersCalculation();
11821
11828
  });
11829
+ let initPromise;
11822
11830
  (0, vue.onBeforeMount)(() => {
11823
- initSelectedUsers();
11831
+ initPromise = initSelectedUsers();
11824
11832
  });
11825
- (0, vue.onMounted)(() => {
11833
+ (0, vue.onMounted)(async () => {
11826
11834
  initSortable();
11827
11835
  (0, vue.nextTick)(calculateVisibleUsers);
11836
+ if (props.autoFocus && !props.disabled) {
11837
+ await initPromise;
11838
+ await (0, vue.nextTick)();
11839
+ handleFocus();
11840
+ }
11828
11841
  });
11829
11842
  (0, vue.onUnmounted)(() => {
11830
11843
  sortableInstance.value?.destroy();
11831
11844
  });
11845
+ __expose({
11846
+ focus: handleFocus,
11847
+ blur
11848
+ });
11832
11849
  const __returned__ = {
11833
11850
  t: t$1,
11834
11851
  props,
@@ -11879,6 +11896,7 @@ var lesscodeCustomComponentLibrary = (function(exports, vue) {
11879
11896
  calculateVisibleUsers,
11880
11897
  handleFocus,
11881
11898
  scheduleVisibleUsersCalculation,
11899
+ blur,
11882
11900
  handleClickOutside,
11883
11901
  handleContainerClick,
11884
11902
  focusCurrentInput,
@@ -11890,6 +11908,12 @@ var lesscodeCustomComponentLibrary = (function(exports, vue) {
11890
11908
  handleKeyDown,
11891
11909
  addUser,
11892
11910
  removeUser,
11911
+ get initPromise() {
11912
+ return initPromise;
11913
+ },
11914
+ set initPromise(v$1) {
11915
+ initPromise = v$1;
11916
+ },
11893
11917
  get Popover() {
11894
11918
  return __webpack_exports__default;
11895
11919
  },
@@ -3340,6 +3340,11 @@
3340
3340
  name: "BkUserSelector",
3341
3341
  __name: "user-selector",
3342
3342
  props: {
3343
+ autoFocus: {
3344
+ type: Boolean,
3345
+ required: false,
3346
+ default: false
3347
+ },
3343
3348
  draggable: {
3344
3349
  type: Boolean,
3345
3350
  required: false,
@@ -3468,12 +3473,11 @@
3468
3473
  "update:modelValue"
3469
3474
  ],
3470
3475
  setup(__props, { expose: __expose, emit: __emit }) {
3471
- __expose();
3472
3476
  const { t } = use_i18n_default();
3473
3477
  (0, bkui_vue.provideGlobalConfig)({ prefix: "bk" });
3474
3478
  const props = __props;
3475
3479
  const emit = __emit;
3476
- const { tenants = {} } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
3480
+ const { tenants } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
3477
3481
  const { searchResults, loading: searchLoading, searchQuery, clearSearch, handleSearchInput } = useUserSearch(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
3478
3482
  const { fetchCurrentUser } = useCurrentUser({
3479
3483
  apiBaseUrl: props.apiBaseUrl,
@@ -3529,7 +3533,7 @@
3529
3533
  currentTenantId: props.tenantId,
3530
3534
  hasAvatar: props.hasAvatar,
3531
3535
  renderTag: props.renderTag,
3532
- tenants
3536
+ tenants: tenants.value
3533
3537
  }));
3534
3538
  const { filteredUserGroup, filterOptions, createCustomUser } = useUserSelection({
3535
3539
  selectedUserIds,
@@ -3667,10 +3671,7 @@
3667
3671
  const scheduleVisibleUsersCalculation = () => {
3668
3672
  if (!isFocused.value) (0, vue.nextTick)(calculateVisibleUsers);
3669
3673
  };
3670
- const handleClickOutside = (event) => {
3671
- const target = event.target;
3672
- const container = containerRef.value;
3673
- if (container?.contains(target) || container === target) return;
3674
+ const blur = () => {
3674
3675
  if (isFocused.value) emit("blur");
3675
3676
  isFocused.value = false;
3676
3677
  activeTagIndex.value = selectedUsers.value.length - 1;
@@ -3678,6 +3679,12 @@
3678
3679
  highlightedIndex.value = -1;
3679
3680
  scheduleVisibleUsersCalculation();
3680
3681
  };
3682
+ const handleClickOutside = (event) => {
3683
+ const target = event.target;
3684
+ const container = containerRef.value;
3685
+ if (container?.contains(target) || container === target) return;
3686
+ blur();
3687
+ };
3681
3688
  const handleContainerClick = () => {
3682
3689
  activeTagIndex.value = selectedUsers.value.length - 1;
3683
3690
  (0, vue.nextTick)(() => focusCurrentInput());
@@ -3827,16 +3834,26 @@
3827
3834
  useResizeObserver(containerRef, () => {
3828
3835
  scheduleVisibleUsersCalculation();
3829
3836
  });
3837
+ let initPromise;
3830
3838
  (0, vue.onBeforeMount)(() => {
3831
- initSelectedUsers();
3839
+ initPromise = initSelectedUsers();
3832
3840
  });
3833
- (0, vue.onMounted)(() => {
3841
+ (0, vue.onMounted)(async () => {
3834
3842
  initSortable();
3835
3843
  (0, vue.nextTick)(calculateVisibleUsers);
3844
+ if (props.autoFocus && !props.disabled) {
3845
+ await initPromise;
3846
+ await (0, vue.nextTick)();
3847
+ handleFocus();
3848
+ }
3836
3849
  });
3837
3850
  (0, vue.onUnmounted)(() => {
3838
3851
  sortableInstance.value?.destroy();
3839
3852
  });
3853
+ __expose({
3854
+ focus: handleFocus,
3855
+ blur
3856
+ });
3840
3857
  const __returned__ = {
3841
3858
  t,
3842
3859
  props,
@@ -3887,6 +3904,7 @@
3887
3904
  calculateVisibleUsers,
3888
3905
  handleFocus,
3889
3906
  scheduleVisibleUsersCalculation,
3907
+ blur,
3890
3908
  handleClickOutside,
3891
3909
  handleContainerClick,
3892
3910
  focusCurrentInput,
@@ -3898,6 +3916,12 @@
3898
3916
  handleKeyDown,
3899
3917
  addUser,
3900
3918
  removeUser,
3919
+ get initPromise() {
3920
+ return initPromise;
3921
+ },
3922
+ set initPromise(v) {
3923
+ initPromise = v;
3924
+ },
3901
3925
  get Popover() {
3902
3926
  return bkui_vue.Popover;
3903
3927
  },