bkui-vue 0.0.1-beta.157 → 0.0.1-beta.158

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/dist/index.esm.js CHANGED
@@ -7906,6 +7906,34 @@ const formKey = Symbol("form");
7906
7906
  const formItemKey = Symbol("formItem");
7907
7907
  const useForm = () => inject(formKey);
7908
7908
  const useFormItem = () => inject(formItemKey, EMPTY_OBJ);
7909
+ const on$2 = (() => {
7910
+ if (document.addEventListener) {
7911
+ return (element, event, handler) => {
7912
+ if (element && event && handler) {
7913
+ element.addEventListener(event, handler, true);
7914
+ }
7915
+ };
7916
+ }
7917
+ return (element, event, handler) => {
7918
+ if (element && event && handler) {
7919
+ element.attachEvent(`on${event}`, handler);
7920
+ }
7921
+ };
7922
+ })();
7923
+ const off$2 = (() => {
7924
+ if (document.removeEventListener) {
7925
+ return (element, event, handler) => {
7926
+ if (element && event) {
7927
+ element.removeEventListener(event, handler, true);
7928
+ }
7929
+ };
7930
+ }
7931
+ return (element, event, handler) => {
7932
+ if (element && event) {
7933
+ element.detachEvent(`on${event}`, handler);
7934
+ }
7935
+ };
7936
+ })();
7909
7937
  function classes(dynamicCls, constCls = "") {
7910
7938
  return Object.entries(dynamicCls).filter((entry) => entry[1]).map((entry) => entry[0]).join(" ").concat(constCls ? ` ${constCls}` : "");
7911
7939
  }
@@ -14232,7 +14260,7 @@ var SelectTagInput = defineComponent({
14232
14260
  allowCreate: PropTypes.bool.def(false),
14233
14261
  modelValue: PropTypes.any
14234
14262
  },
14235
- emits: ["update:modelValue", "remove", "focus", "enter"],
14263
+ emits: ["update:modelValue", "remove", "enter"],
14236
14264
  setup(props2, {
14237
14265
  emit
14238
14266
  }) {
@@ -14248,9 +14276,6 @@ var SelectTagInput = defineComponent({
14248
14276
  const handleRemoveTag = (val) => {
14249
14277
  emit("remove", val);
14250
14278
  };
14251
- const handleFocus = () => {
14252
- emit("focus");
14253
- };
14254
14279
  const focus = () => {
14255
14280
  var _a;
14256
14281
  (_a = inputRef.value) == null ? void 0 : _a.focus();
@@ -14271,7 +14296,6 @@ var SelectTagInput = defineComponent({
14271
14296
  value,
14272
14297
  inputRef,
14273
14298
  handleRemoveTag,
14274
- handleFocus,
14275
14299
  focus,
14276
14300
  handleInput,
14277
14301
  handleKeydown,
@@ -14291,17 +14315,16 @@ var SelectTagInput = defineComponent({
14291
14315
  }, _isSlot$5(_slot = this.handleGetLabelByValue(item)) ? _slot : {
14292
14316
  default: () => [_slot]
14293
14317
  });
14294
- }), withDirectives(createVNode("input", {
14318
+ }), createVNode("input", {
14295
14319
  "class": "bk-select-tag-input",
14296
14320
  "ref": "inputRef",
14297
14321
  "type": "text",
14298
14322
  "placeholder": !this.selected.length ? this.placeholder : "",
14299
14323
  "readonly": !this.filterable,
14300
- "onUpdate:modelValue": ($event) => this.value = $event,
14301
- "onFocus": this.handleFocus,
14324
+ "value": !this.filterable ? "" : this.value,
14302
14325
  "onInput": this.handleInput,
14303
14326
  "onKeydown": this.handleKeydown
14304
- }, null), [[vModelText, this.value]]), (_d = (_c = this.$slots) == null ? void 0 : _c.suffix) == null ? void 0 : _d.call(_c)]);
14327
+ }, null), (_d = (_c = this.$slots) == null ? void 0 : _c.suffix) == null ? void 0 : _d.call(_c)]);
14305
14328
  }
14306
14329
  });
14307
14330
  var Component$j = defineComponent({
@@ -14330,6 +14353,7 @@ var Component$j = defineComponent({
14330
14353
  noMatchText: PropTypes.string.def("\u65E0\u5339\u914D\u6570\u636E"),
14331
14354
  loadingText: PropTypes.string.def("\u52A0\u8F7D\u4E2D..."),
14332
14355
  placeholder: PropTypes.string.def("\u8BF7\u9009\u62E9"),
14356
+ searchPlaceholder: PropTypes.string.def("\u8BF7\u8F93\u5165\u5173\u952E\u5B57"),
14333
14357
  selectAllText: PropTypes.string.def("\u5168\u90E8"),
14334
14358
  scrollLoading: PropTypes.bool.def(false),
14335
14359
  allowCreate: PropTypes.bool.def(false),
@@ -14339,7 +14363,8 @@ var Component$j = defineComponent({
14339
14363
  idKey: PropTypes.string.def("value"),
14340
14364
  displayKey: PropTypes.string.def("label"),
14341
14365
  withValidate: PropTypes.bool.def(true),
14342
- showSelectedIcon: PropTypes.bool.def(true)
14366
+ showSelectedIcon: PropTypes.bool.def(true),
14367
+ inputSearch: PropTypes.bool.def(true)
14343
14368
  },
14344
14369
  emits: ["update:modelValue", "change", "toggle", "clear", "scroll-end", "focus", "blur"],
14345
14370
  setup(props2, {
@@ -14360,11 +14385,14 @@ var Component$j = defineComponent({
14360
14385
  multipleMode,
14361
14386
  allowCreate,
14362
14387
  customContent,
14363
- showSelectedIcon
14388
+ showSelectedIcon,
14389
+ inputSearch
14364
14390
  } = toRefs(props2);
14365
14391
  const formItem = useFormItem();
14366
14392
  const inputRef = ref();
14367
14393
  const triggerRef = ref();
14394
+ const contentRef = ref();
14395
+ const searchRef = ref();
14368
14396
  const selectTagInputRef = ref();
14369
14397
  const optionsMap = ref(/* @__PURE__ */ new Map());
14370
14398
  const options = computed(() => [...optionsMap.value.values()]);
@@ -14422,13 +14450,17 @@ var Component$j = defineComponent({
14422
14450
  cancelHover
14423
14451
  } = useHover();
14424
14452
  const isFocus = ref(false);
14425
- const handleFocus = (e) => {
14453
+ const handleFocus = () => {
14454
+ if (isFocus.value)
14455
+ return;
14426
14456
  isFocus.value = true;
14427
- emit("focus", e);
14457
+ emit("focus");
14428
14458
  };
14429
14459
  const handleBlur = () => {
14430
- isFocus.value && emit("blur");
14460
+ if (!isFocus.value)
14461
+ return;
14431
14462
  isFocus.value = false;
14463
+ emit("blur");
14432
14464
  };
14433
14465
  const {
14434
14466
  popperWidth,
@@ -14439,12 +14471,12 @@ var Component$j = defineComponent({
14439
14471
  } = usePopover({
14440
14472
  popoverMinWidth: popoverMinWidth.value
14441
14473
  }, triggerRef);
14442
- const isInput = computed(() => (filterable.value || allowCreate.value) && isPopoverShow.value);
14474
+ const isInput = computed(() => (filterable.value && inputSearch.value || allowCreate.value) && isPopoverShow.value);
14443
14475
  watch(isPopoverShow, (isShow) => {
14444
14476
  if (!isShow) {
14445
14477
  searchKey.value = "";
14446
14478
  } else {
14447
- focus();
14479
+ focusInput();
14448
14480
  initActiveOptionValue();
14449
14481
  }
14450
14482
  });
@@ -14479,6 +14511,7 @@ var Component$j = defineComponent({
14479
14511
  const handleTogglePopover = () => {
14480
14512
  if (isDisabled.value)
14481
14513
  return;
14514
+ handleFocus();
14482
14515
  togglePopover();
14483
14516
  emit("toggle", isPopoverShow.value);
14484
14517
  };
@@ -14533,15 +14566,21 @@ var Component$j = defineComponent({
14533
14566
  emitChange(option.value);
14534
14567
  hidePopover();
14535
14568
  }
14536
- focus();
14569
+ focusInput();
14537
14570
  };
14538
- const focus = () => {
14539
- var _a, _b;
14540
- if (multipleMode.value === "tag") {
14541
- (_a = selectTagInputRef.value) == null ? void 0 : _a.focus();
14542
- } else {
14543
- (_b = inputRef.value) == null ? void 0 : _b.focus();
14544
- }
14571
+ const focusInput = () => {
14572
+ setTimeout(() => {
14573
+ var _a, _b, _c;
14574
+ if (!inputSearch.value && !allowCreate.value) {
14575
+ (_a = searchRef.value) == null ? void 0 : _a.focus();
14576
+ } else {
14577
+ if (multipleMode.value === "tag") {
14578
+ (_b = selectTagInputRef.value) == null ? void 0 : _b.focus();
14579
+ } else {
14580
+ (_c = inputRef.value) == null ? void 0 : _c.focus();
14581
+ }
14582
+ }
14583
+ }, 0);
14545
14584
  };
14546
14585
  const handleClear = (e) => {
14547
14586
  e.stopPropagation();
@@ -14567,7 +14606,7 @@ var Component$j = defineComponent({
14567
14606
  });
14568
14607
  }
14569
14608
  emitChange(selected.value.map((item) => item.value));
14570
- focus();
14609
+ focusInput();
14571
14610
  };
14572
14611
  const handleScroll = (e) => {
14573
14612
  const {
@@ -14605,6 +14644,8 @@ var Component$j = defineComponent({
14605
14644
  };
14606
14645
  const handleKeydown = (e) => {
14607
14646
  var _a, _b;
14647
+ if (!triggerRef.value.contains(e.target) && !contentRef.value.contains(e.target))
14648
+ return;
14608
14649
  const availableOptions = options.value.filter((option) => !option.disabled && option.visible);
14609
14650
  const index = availableOptions.findIndex((option) => option.value === activeOptionValue.value);
14610
14651
  if (!availableOptions.length || index === -1)
@@ -14623,7 +14664,7 @@ var Component$j = defineComponent({
14623
14664
  break;
14624
14665
  }
14625
14666
  case "Backspace": {
14626
- if (!multiple.value || !selected.value.length || searchKey.value.length)
14667
+ if (!multiple.value || !selected.value.length || searchKey.value.length || e.target === searchRef.value)
14627
14668
  return;
14628
14669
  selected.value.pop();
14629
14670
  emitChange(selected.value.map((item) => item.value));
@@ -14669,6 +14710,10 @@ var Component$j = defineComponent({
14669
14710
  setTimeout(() => {
14670
14711
  showOnInit.value && showPopover();
14671
14712
  });
14713
+ on$2(document, "keydown", handleKeydown);
14714
+ });
14715
+ onBeforeMount(() => {
14716
+ off$2(document, "keydown", handleKeydown);
14672
14717
  });
14673
14718
  return {
14674
14719
  selected,
@@ -14681,6 +14726,8 @@ var Component$j = defineComponent({
14681
14726
  popperWidth,
14682
14727
  inputRef,
14683
14728
  triggerRef,
14729
+ contentRef,
14730
+ searchRef,
14684
14731
  selectTagInputRef,
14685
14732
  searchLoading,
14686
14733
  isOptionsEmpty,
@@ -14693,6 +14740,7 @@ var Component$j = defineComponent({
14693
14740
  setHover,
14694
14741
  cancelHover,
14695
14742
  handleFocus,
14743
+ handleBlur,
14696
14744
  handleTogglePopover,
14697
14745
  handleClear,
14698
14746
  hidePopover,
@@ -14757,7 +14805,6 @@ var Component$j = defineComponent({
14757
14805
  "tagTheme": this.tagTheme,
14758
14806
  "placeholder": this.placeholder,
14759
14807
  "filterable": this.isInput,
14760
- "onFocus": this.handleFocus,
14761
14808
  "onRemove": this.handleDeleteTag,
14762
14809
  "onEnter": this.handleInputEnter
14763
14810
  }, {
@@ -14778,10 +14825,8 @@ var Component$j = defineComponent({
14778
14825
  "disabled": this.isDisabled,
14779
14826
  "behavior": this.behavior,
14780
14827
  "size": this.size,
14781
- "onFocus": this.handleFocus,
14782
14828
  "onInput": this.handleInputChange,
14783
- "onEnter": this.handleInputEnter,
14784
- "onKeydown": (_2, e) => this.handleKeydown(e)
14829
+ "onEnter": this.handleInputEnter
14785
14830
  }, {
14786
14831
  prefix: () => {
14787
14832
  var _a, _b;
@@ -14795,14 +14840,25 @@ var Component$j = defineComponent({
14795
14840
  "ref": "triggerRef",
14796
14841
  "onClick": this.handleTogglePopover,
14797
14842
  "onMouseenter": this.setHover,
14798
- "onMouseleave": this.cancelHover,
14799
- "onKeydown": this.handleKeydown
14843
+ "onMouseleave": this.cancelHover
14800
14844
  }, [renderTriggerInput()]);
14801
14845
  const renderSelectContent = () => {
14802
14846
  var _a, _b;
14803
14847
  return createVNode("div", {
14804
- "class": "bk-select-content"
14805
- }, [!this.isShowSelectContent && createVNode("div", {
14848
+ "class": "bk-select-content",
14849
+ "ref": "contentRef"
14850
+ }, [this.filterable && !this.inputSearch && createVNode("div", {
14851
+ "class": "bk-select-search-wrapper"
14852
+ }, [createVNode(search, {
14853
+ "class": "icon-search",
14854
+ "width": 16,
14855
+ "height": 16
14856
+ }, null), withDirectives(createVNode("input", {
14857
+ "ref": "searchRef",
14858
+ "class": "bk-select-search-input",
14859
+ "placeholder": this.searchPlaceholder,
14860
+ "onUpdate:modelValue": ($event) => this.searchKey = $event
14861
+ }, null), [[vModelText, this.searchKey]])]), !this.isShowSelectContent && createVNode("div", {
14806
14862
  "class": "bk-select-empty"
14807
14863
  }, [this.searchLoading && createVNode(BkLoading, {
14808
14864
  "class": "mr5",