bkui-vue 0.0.2-beta.122 → 0.0.2-beta.123

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.
@@ -574,16 +574,20 @@ function usePopover(config, triggerRef) {
574
574
  };
575
575
  }
576
576
  function useRemoteSearch(method, callBack) {
577
- var searchKey = useDebouncedRef('');
577
+ var customOptionName = useDebouncedRef(''); // 自定义创建选项(自定义创建也会触发搜索)
578
+ var searchValue = useDebouncedRef('');
579
+ var curSearchValue = computed(function () {
580
+ return searchValue.value || customOptionName.value;
581
+ });
578
582
  var searchLoading = ref(false);
579
- watch(searchKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
583
+ watch(curSearchValue, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
580
584
  return _regeneratorRuntime.wrap(function _callee$(_context) {
581
585
  while (1) switch (_context.prev = _context.next) {
582
586
  case 0:
583
587
  _context.prev = 0;
584
588
  searchLoading.value = true;
585
589
  _context.next = 4;
586
- return method(searchKey.value);
590
+ return method(curSearchValue.value);
587
591
  case 4:
588
592
  searchLoading.value = false;
589
593
  _context.next = 10;
@@ -603,7 +607,9 @@ function useRemoteSearch(method, callBack) {
603
607
  }, _callee, null, [[0, 7, 10, 13]]);
604
608
  })));
605
609
  return {
606
- searchKey: searchKey,
610
+ customOptionName: customOptionName,
611
+ searchValue: searchValue,
612
+ curSearchValue: curSearchValue,
607
613
  searchLoading: searchLoading
608
614
  };
609
615
  }
@@ -20,7 +20,9 @@ export declare function usePopover(config: IPopoverConfig, triggerRef: Ref<HTMLE
20
20
  showPopover: () => void;
21
21
  };
22
22
  export declare function useRemoteSearch(method: Function, callBack?: Function): {
23
- searchKey: Ref<string>;
23
+ customOptionName: Ref<string>;
24
+ searchValue: Ref<string>;
25
+ curSearchValue: import("vue").ComputedRef<string>;
24
26
  searchLoading: Ref<boolean>;
25
27
  };
26
28
  export declare function toLowerCase(value?: string): string;
@@ -667,7 +667,8 @@ declare const BkSelect: {
667
667
  isShowSelectContent: import("vue").ComputedRef<boolean>;
668
668
  curContentText: import("vue").ComputedRef<string>;
669
669
  isGroup: import("vue").ComputedRef<boolean>;
670
- searchKey: import("vue").Ref<string>;
670
+ searchValue: import("vue").Ref<string>;
671
+ customOptionName: import("vue").Ref<string>;
671
672
  isShowAll: import("vue").ComputedRef<boolean>;
672
673
  isShowSelectAll: import("vue").ComputedRef<boolean>;
673
674
  virtualHeight: import("vue").ComputedRef<number>;
@@ -826,7 +827,7 @@ declare const BkSelect: {
826
827
  localSearchPlaceholder: import("vue").ComputedRef<string>;
827
828
  localSelectAllText: import("vue").ComputedRef<string>;
828
829
  resolveClassName: (cls: string) => string;
829
- handleCreateCustomOption: (val: string | number) => void;
830
+ handleCreateCustomOption: (val: string | number, e: KeyboardEvent) => void;
830
831
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "change" | "focus" | "select" | "toggle" | "clear" | "update:modelValue" | "scroll-end" | "tag-remove" | "deselect")[], string, {
831
832
  prefix: string;
832
833
  disabled: boolean;
@@ -1438,7 +1439,8 @@ declare const BkSelect: {
1438
1439
  isShowSelectContent: import("vue").ComputedRef<boolean>;
1439
1440
  curContentText: import("vue").ComputedRef<string>;
1440
1441
  isGroup: import("vue").ComputedRef<boolean>;
1441
- searchKey: import("vue").Ref<string>;
1442
+ searchValue: import("vue").Ref<string>;
1443
+ customOptionName: import("vue").Ref<string>;
1442
1444
  isShowAll: import("vue").ComputedRef<boolean>;
1443
1445
  isShowSelectAll: import("vue").ComputedRef<boolean>;
1444
1446
  virtualHeight: import("vue").ComputedRef<number>;
@@ -1597,7 +1599,7 @@ declare const BkSelect: {
1597
1599
  localSearchPlaceholder: import("vue").ComputedRef<string>;
1598
1600
  localSelectAllText: import("vue").ComputedRef<string>;
1599
1601
  resolveClassName: (cls: string) => string;
1600
- handleCreateCustomOption: (val: string | number) => void;
1602
+ handleCreateCustomOption: (val: string | number, e: KeyboardEvent) => void;
1601
1603
  }> & {} & import("vue").ComponentCustomProperties & {};
1602
1604
  __isFragment?: never;
1603
1605
  __isTeleport?: never;
@@ -2154,7 +2156,8 @@ declare const BkSelect: {
2154
2156
  isShowSelectContent: import("vue").ComputedRef<boolean>;
2155
2157
  curContentText: import("vue").ComputedRef<string>;
2156
2158
  isGroup: import("vue").ComputedRef<boolean>;
2157
- searchKey: import("vue").Ref<string>;
2159
+ searchValue: import("vue").Ref<string>;
2160
+ customOptionName: import("vue").Ref<string>;
2158
2161
  isShowAll: import("vue").ComputedRef<boolean>;
2159
2162
  isShowSelectAll: import("vue").ComputedRef<boolean>;
2160
2163
  virtualHeight: import("vue").ComputedRef<number>;
@@ -2313,7 +2316,7 @@ declare const BkSelect: {
2313
2316
  localSearchPlaceholder: import("vue").ComputedRef<string>;
2314
2317
  localSelectAllText: import("vue").ComputedRef<string>;
2315
2318
  resolveClassName: (cls: string) => string;
2316
- handleCreateCustomOption: (val: string | number) => void;
2319
+ handleCreateCustomOption: (val: string | number, e: KeyboardEvent) => void;
2317
2320
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "change" | "focus" | "select" | "toggle" | "clear" | "update:modelValue" | "scroll-end" | "tag-remove" | "deselect")[], "blur" | "change" | "focus" | "select" | "toggle" | "clear" | "update:modelValue" | "scroll-end" | "tag-remove" | "deselect", {
2318
2321
  prefix: string;
2319
2322
  disabled: boolean;
@@ -661,16 +661,20 @@ function usePopover(config, triggerRef) {
661
661
  };
662
662
  }
663
663
  function useRemoteSearch(method, callBack) {
664
- var searchKey = useDebouncedRef('');
664
+ var customOptionName = useDebouncedRef(''); // 自定义创建选项(自定义创建也会触发搜索)
665
+ var searchValue = useDebouncedRef('');
666
+ var curSearchValue = (0,external_vue_namespaceObject.computed)(function () {
667
+ return searchValue.value || customOptionName.value;
668
+ });
665
669
  var searchLoading = (0,external_vue_namespaceObject.ref)(false);
666
- (0,external_vue_namespaceObject.watch)(searchKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee() {
670
+ (0,external_vue_namespaceObject.watch)(curSearchValue, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee() {
667
671
  return regenerator_default().wrap(function _callee$(_context) {
668
672
  while (1) switch (_context.prev = _context.next) {
669
673
  case 0:
670
674
  _context.prev = 0;
671
675
  searchLoading.value = true;
672
676
  _context.next = 4;
673
- return method(searchKey.value);
677
+ return method(curSearchValue.value);
674
678
  case 4:
675
679
  searchLoading.value = false;
676
680
  _context.next = 10;
@@ -690,7 +694,9 @@ function useRemoteSearch(method, callBack) {
690
694
  }, _callee, null, [[0, 7, 10, 13]]);
691
695
  })));
692
696
  return {
693
- searchKey: searchKey,
697
+ customOptionName: customOptionName,
698
+ searchValue: searchValue,
699
+ curSearchValue: curSearchValue,
694
700
  searchLoading: searchLoading
695
701
  };
696
702
  }
@@ -1514,9 +1520,9 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
1514
1520
  return isRemoteSearch.value ? list.value : list.value.filter(function (item) {
1515
1521
  var _toLowerCase;
1516
1522
  if (hasFilterOptionFunc.value) {
1517
- return !!filterOption.value(searchKey.value, item);
1523
+ return !!filterOption.value(curSearchValue.value, item);
1518
1524
  }
1519
- return (_toLowerCase = toLowerCase(String(item[displayKey.value]))) === null || _toLowerCase === void 0 ? void 0 : _toLowerCase.includes(toLowerCase(searchKey.value));
1525
+ return (_toLowerCase = toLowerCase(String(item[displayKey.value]))) === null || _toLowerCase === void 0 ? void 0 : _toLowerCase.includes(toLowerCase(curSearchValue.value));
1520
1526
  });
1521
1527
  });
1522
1528
  // select组件是否禁用
@@ -1573,7 +1579,7 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
1573
1579
  });
1574
1580
  // 是否显示全选
1575
1581
  var isShowSelectAll = (0,external_vue_namespaceObject.computed)(function () {
1576
- return multiple.value && showSelectAll.value && (!searchKey.value || !filterable.value);
1582
+ return multiple.value && showSelectAll.value && (!curSearchValue.value || !filterable.value);
1577
1583
  });
1578
1584
  var isShowAll = (0,external_vue_namespaceObject.computed)(function () {
1579
1585
  return multiple.value && showAll.value;
@@ -1651,7 +1657,7 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
1651
1657
  emit('toggle', isPopoverShow.value);
1652
1658
  if (!isShow) {
1653
1659
  if (!keepSearchValue.value) {
1654
- searchKey.value = '';
1660
+ searchValue.value = '';
1655
1661
  }
1656
1662
  document.removeEventListener('keydown', handleDocumentKeydown);
1657
1663
  } else {
@@ -1704,7 +1710,9 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
1704
1710
  }
1705
1711
  };
1706
1712
  var _useRemoteSearch = useRemoteSearch(isRemoteSearch.value ? remoteMethod.value : defaultSearchMethod, initActiveOptionValue),
1707
- searchKey = _useRemoteSearch.searchKey,
1713
+ searchValue = _useRemoteSearch.searchValue,
1714
+ customOptionName = _useRemoteSearch.customOptionName,
1715
+ curSearchValue = _useRemoteSearch.curSearchValue,
1708
1716
  searchLoading = _useRemoteSearch.searchLoading;
1709
1717
  // 派发change事件
1710
1718
  var emitChange = function emitChange(val) {
@@ -1718,22 +1726,25 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
1718
1726
  handleFocus();
1719
1727
  togglePopover();
1720
1728
  };
1721
- // 搜索
1729
+ // 自定义创建
1722
1730
  var handleInputChange = function handleInputChange(value) {
1723
1731
  if (!filterable.value) return;
1724
- searchKey.value = value;
1732
+ customOptionName.value = value;
1725
1733
  };
1726
1734
  // allow create(创建自定义选项)
1727
- var handleCreateCustomOption = function handleCreateCustomOption(val) {
1735
+ var handleCreateCustomOption = function handleCreateCustomOption(val, e) {
1728
1736
  var value = String(val);
1729
1737
  if (!allowCreate.value || !value) return;
1738
+ // 阻止触发鼠标事件
1739
+ e.stopPropagation();
1740
+ e.preventDefault();
1730
1741
  var matchedOption = options.value.find(function (data) {
1731
1742
  return toLowerCase(String(data.optionName)) === toLowerCase(value);
1732
1743
  });
1733
1744
  if (filterable.value && matchedOption) {
1734
1745
  // 开启搜索后,正好匹配到自定义选项,则不进行创建操作
1735
1746
  handleOptionSelected(matchedOption);
1736
- searchKey.value = '';
1747
+ customOptionName.value = '';
1737
1748
  return;
1738
1749
  }
1739
1750
  var data = optionsMap.value.get(value);
@@ -1754,7 +1765,7 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
1754
1765
  emitChange(value);
1755
1766
  hidePopover();
1756
1767
  }
1757
- searchKey.value = '';
1768
+ customOptionName.value = '';
1758
1769
  };
1759
1770
  // Option点击事件
1760
1771
  var handleOptionSelected = function handleOptionSelected(option) {
@@ -1980,7 +1991,7 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
1980
1991
  // 删除选项
1981
1992
  case 'Backspace':
1982
1993
  {
1983
- if (!multiple.value || !selected.value.length || searchKey.value.length || e.target === searchRef.value) return; // 单选和下拉搜索不支持回退键删除
1994
+ if (!multiple.value || !selected.value.length || customOptionName.value.length || e.target === searchRef.value) return; // 单选和下拉搜索不支持回退键删除
1984
1995
  selected.value.pop();
1985
1996
  emitChange(selected.value.map(function (item) {
1986
1997
  return item.value;
@@ -2060,7 +2071,8 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
2060
2071
  isShowSelectContent: isShowSelectContent,
2061
2072
  curContentText: curContentText,
2062
2073
  isGroup: isGroup,
2063
- searchKey: searchKey,
2074
+ searchValue: searchValue,
2075
+ customOptionName: customOptionName,
2064
2076
  isShowAll: isShowAll,
2065
2077
  isShowSelectAll: isShowSelectAll,
2066
2078
  virtualHeight: virtualHeight,
@@ -2156,9 +2168,9 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
2156
2168
  if (_this.multipleMode === 'tag') {
2157
2169
  return (0,external_vue_namespaceObject.createVNode)(selectTagInput, {
2158
2170
  "ref": "selectTagInputRef",
2159
- "modelValue": _this.searchKey,
2171
+ "modelValue": _this.customOptionName,
2160
2172
  "onUpdate:modelValue": function onUpdateModelValue($event) {
2161
- return _this.searchKey = $event;
2173
+ return _this.customOptionName = $event;
2162
2174
  },
2163
2175
  "selected": _this.selected,
2164
2176
  "tagTheme": _this.tagTheme,
@@ -2183,7 +2195,7 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
2183
2195
  return (0,external_vue_namespaceObject.createVNode)(external_input_namespaceObject["default"], (0,external_vue_namespaceObject.mergeProps)({
2184
2196
  "ref": "inputRef",
2185
2197
  "type": "text",
2186
- "modelValue": _this.isInput ? _this.searchKey : _this.selectedLabel.join(','),
2198
+ "modelValue": _this.isInput ? _this.customOptionName : _this.selectedLabel.join(','),
2187
2199
  "placeholder": _this.isInput ? _this.selectedLabel.join(',') || _this.localPlaceholder : _this.localPlaceholder,
2188
2200
  "readonly": !_this.isInput,
2189
2201
  "selectReadonly": true,
@@ -2238,9 +2250,9 @@ function select_objectSpread(target) { for (var i = 1; i < arguments.length; i++
2238
2250
  "class": _this.resolveClassName('select-search-input'),
2239
2251
  "placeholder": _this.localSearchPlaceholder,
2240
2252
  "onUpdate:modelValue": function onUpdateModelValue($event) {
2241
- return _this.searchKey = $event;
2253
+ return _this.searchValue = $event;
2242
2254
  }
2243
- }, null), [[external_vue_namespaceObject.vModelText, _this.searchKey]])]), !_this.isShowSelectContent && (0,external_vue_namespaceObject.createVNode)("div", {
2255
+ }, null), [[external_vue_namespaceObject.vModelText, _this.searchValue]])]), !_this.isShowSelectContent && (0,external_vue_namespaceObject.createVNode)("div", {
2244
2256
  "class": _this.resolveClassName('select-empty')
2245
2257
  }, [_this.searchLoading && (0,external_vue_namespaceObject.createVNode)(external_loading_namespaceObject["default"], {
2246
2258
  "class": "mr5",
@@ -541,7 +541,8 @@ declare const _default: import("vue").DefineComponent<{
541
541
  isShowSelectContent: import("vue").ComputedRef<boolean>;
542
542
  curContentText: import("vue").ComputedRef<string>;
543
543
  isGroup: import("vue").ComputedRef<boolean>;
544
- searchKey: import("vue").Ref<string>;
544
+ searchValue: import("vue").Ref<string>;
545
+ customOptionName: import("vue").Ref<string>;
545
546
  isShowAll: import("vue").ComputedRef<boolean>;
546
547
  isShowSelectAll: import("vue").ComputedRef<boolean>;
547
548
  virtualHeight: import("vue").ComputedRef<number>;
@@ -700,7 +701,7 @@ declare const _default: import("vue").DefineComponent<{
700
701
  localSearchPlaceholder: import("vue").ComputedRef<string>;
701
702
  localSelectAllText: import("vue").ComputedRef<string>;
702
703
  resolveClassName: (cls: string) => string;
703
- handleCreateCustomOption: (val: string | number) => void;
704
+ handleCreateCustomOption: (val: string | number, e: KeyboardEvent) => void;
704
705
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("blur" | "change" | "focus" | "select" | "toggle" | "clear" | "update:modelValue" | "scroll-end" | "tag-remove" | "deselect")[], "blur" | "change" | "focus" | "select" | "toggle" | "clear" | "update:modelValue" | "scroll-end" | "tag-remove" | "deselect", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
705
706
  modelValue: import("vue-types").VueTypeValidableDef<any>;
706
707
  multiple: import("vue-types").VueTypeValidableDef<boolean> & {
@@ -1066,16 +1066,17 @@ function tag_input_objectSpread(target) { for (var i = 1; i < arguments.length;
1066
1066
  // 通知表单组件,可用于实时验证
1067
1067
  // this.dispatch('bk-form-item', 'form-blur')
1068
1068
  state.isEdit = false;
1069
- if (isSingleSelect.value) {
1070
- var _listState$tagListCac = _slicedToArray(listState.tagListCache, 1),
1071
- oldValue = _listState$tagListCac[0];
1072
- // 如果是单选,且input不为空,即保留了上次的结果则恢复
1073
- if (inputValue && inputValue === oldValue && listState.selectedTagListCache.length) {
1074
- addTag(listState.selectedTagListCache[0], 'select');
1075
- } else {
1076
- handleChange('remove');
1069
+ if (props.allowAutoMatch && inputValue) {
1070
+ if (isSingleSelect.value) {
1071
+ var _listState$tagListCac = _slicedToArray(listState.tagListCache, 1),
1072
+ oldValue = _listState$tagListCac[0];
1073
+ // 如果是单选,且input不为空,即保留了上次的结果则恢复
1074
+ if (inputValue === oldValue && listState.selectedTagListCache.length) {
1075
+ addTag(listState.selectedTagListCache[0], 'select');
1076
+ } else {
1077
+ handleChange('remove');
1078
+ }
1077
1079
  }
1078
- } else if (props.allowAutoMatch && inputValue) {
1079
1080
  // 如果匹配,则自动选则
1080
1081
  var matchItem = pageState.curPageList.find(function (item) {
1081
1082
  if (Array.isArray(props.searchKey)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkui-vue",
3
- "version": "0.0.2-beta.122",
3
+ "version": "0.0.2-beta.123",
4
4
  "workspaces": {
5
5
  "packages": [
6
6
  "packages/!(**.bak)*",