@jetlinks-web/components 3.1.7 → 3.1.8

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.
@@ -31,12 +31,10 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
31
31
  "props": "setup-reactive-const",
32
32
  "emit": "setup-const",
33
33
  "displayText": "setup-ref",
34
- "selectedValue": "setup-ref",
35
34
  "keyword": "setup-ref",
36
35
  "filteredOptions": "setup-ref",
37
36
  "onSearch": "setup-const",
38
- "onSelect": "setup-const",
39
- "onChange": "setup-const"
37
+ "onSelect": "setup-const"
40
38
  } */
41
39
  import { defineComponent as _defineComponent } from 'vue';
42
40
  import { unref as _unref, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, mergeProps as _mergeProps, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from "vue";
@@ -60,13 +58,19 @@ const __sfc_main__ = _defineComponent({
60
58
  const props = __props;
61
59
  const emit = __emit;
62
60
  const displayText = ref();
63
- const selectedValue = ref();
64
61
  const keyword = ref('');
65
62
  const filteredOptions = computed(() => {
66
63
  if (!keyword.value)
67
64
  return props.options;
68
- return props.options.filter(opt => String(_nullishCoalesce(opt[props.searchKey], () => ('')))
65
+ const filterArr = props.options.filter(opt => String(_nullishCoalesce(opt[props.searchKey], () => ('')))
69
66
  .includes(keyword.value));
67
+ if (filterArr.length === 0) {
68
+ return [{
69
+ label: keyword.value,
70
+ value: keyword.value
71
+ }];
72
+ }
73
+ return filterArr;
70
74
  });
71
75
  /**
72
76
  * 根据关键词提示
@@ -74,23 +78,13 @@ const __sfc_main__ = _defineComponent({
74
78
  */
75
79
  const onSearch = (searchText) => {
76
80
  keyword.value = searchText;
77
- // _options.value = props.options?.filter(
78
- // (item) => !!item[props.searchKey]?.includes(searchText),
79
- // ) || [];
80
- // if (!_options.value.length) {
81
- // _options.value.unshift({ label: searchText, value: searchText });
82
- // }
83
81
  };
84
82
  const onSelect = (val, option) => {
85
83
  displayText.value = option.label;
84
+ keyword.value = undefined;
86
85
  emit('update:value', val);
87
86
  emit('select', val, option);
88
87
  };
89
- const onChange = (val) => {
90
- displayText.value = val;
91
- keyword.value = val;
92
- emit('update:value', '');
93
- };
94
88
  watch(() => props.value, (val) => {
95
89
  if (!val) {
96
90
  displayText.value = '';
@@ -107,7 +101,6 @@ const __sfc_main__ = _defineComponent({
107
101
  "onUpdate:value": _cache[0] || (_cache[0] = ($event) => ((displayText).value = $event)),
108
102
  options: filteredOptions.value,
109
103
  onSearch: onSearch,
110
- onChange: onChange,
111
104
  onSelect: onSelect
112
105
  }), {
113
106
  option: _withCtx(({ value, label }) => [
package/es/Search/Item.js CHANGED
@@ -188,11 +188,11 @@ const __sfc_main__ = _defineComponent({
188
188
  };
189
189
  const onTermTypeChange = () => {
190
190
  const isBtw = btwKeys.includes(termsModel.termType);
191
- if (!isBtw && Array.isArray(termsModel.value)) {
191
+ if (!isBtw && termsModel.value && Array.isArray(termsModel.value)) {
192
192
  termsModel.value = termsModel.value[0];
193
193
  onValueChange();
194
194
  }
195
- else if (isBtw && !Array.isArray(termsModel.value)) {
195
+ else if (isBtw && termsModel.value && !Array.isArray(termsModel.value)) {
196
196
  termsModel.value = [termsModel.value];
197
197
  onValueChange();
198
198
  }
@@ -11,7 +11,7 @@ var _flattenTree = function flattenTree(tree) {
11
11
  return _objectSpread({}, omit(i, 'children'));
12
12
  });
13
13
  var flatNode = _objectSpread(_objectSpread({}, omit(item, 'children')), {}, {
14
- children: _children,
14
+ _children: _children,
15
15
  level: level,
16
16
  parentId: parentId,
17
17
  expanded: false,
@@ -31,12 +31,10 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
31
31
  "props": "setup-reactive-const",
32
32
  "emit": "setup-const",
33
33
  "displayText": "setup-ref",
34
- "selectedValue": "setup-ref",
35
34
  "keyword": "setup-ref",
36
35
  "filteredOptions": "setup-ref",
37
36
  "onSearch": "setup-const",
38
- "onSelect": "setup-const",
39
- "onChange": "setup-const"
37
+ "onSelect": "setup-const"
40
38
  } */
41
39
  import { defineComponent as _defineComponent } from 'vue';
42
40
  import { unref as _unref, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, mergeProps as _mergeProps, withCtx as _withCtx, openBlock as _openBlock, createBlock as _createBlock } from "vue";
@@ -60,13 +58,19 @@ const __sfc_main__ = _defineComponent({
60
58
  const props = __props;
61
59
  const emit = __emit;
62
60
  const displayText = ref();
63
- const selectedValue = ref();
64
61
  const keyword = ref('');
65
62
  const filteredOptions = computed(() => {
66
63
  if (!keyword.value)
67
64
  return props.options;
68
- return props.options.filter(opt => String(_nullishCoalesce(opt[props.searchKey], () => ('')))
65
+ const filterArr = props.options.filter(opt => String(_nullishCoalesce(opt[props.searchKey], () => ('')))
69
66
  .includes(keyword.value));
67
+ if (filterArr.length === 0) {
68
+ return [{
69
+ label: keyword.value,
70
+ value: keyword.value
71
+ }];
72
+ }
73
+ return filterArr;
70
74
  });
71
75
  /**
72
76
  * 根据关键词提示
@@ -74,23 +78,13 @@ const __sfc_main__ = _defineComponent({
74
78
  */
75
79
  const onSearch = (searchText) => {
76
80
  keyword.value = searchText;
77
- // _options.value = props.options?.filter(
78
- // (item) => !!item[props.searchKey]?.includes(searchText),
79
- // ) || [];
80
- // if (!_options.value.length) {
81
- // _options.value.unshift({ label: searchText, value: searchText });
82
- // }
83
81
  };
84
82
  const onSelect = (val, option) => {
85
83
  displayText.value = option.label;
84
+ keyword.value = undefined;
86
85
  emit('update:value', val);
87
86
  emit('select', val, option);
88
87
  };
89
- const onChange = (val) => {
90
- displayText.value = val;
91
- keyword.value = val;
92
- emit('update:value', '');
93
- };
94
88
  watch(() => props.value, (val) => {
95
89
  if (!val) {
96
90
  displayText.value = '';
@@ -107,7 +101,6 @@ const __sfc_main__ = _defineComponent({
107
101
  "onUpdate:value": _cache[0] || (_cache[0] = ($event) => ((displayText).value = $event)),
108
102
  options: filteredOptions.value,
109
103
  onSearch: onSearch,
110
- onChange: onChange,
111
104
  onSelect: onSelect
112
105
  }), {
113
106
  option: _withCtx(({ value, label }) => [
@@ -188,11 +188,11 @@ const __sfc_main__ = _defineComponent({
188
188
  };
189
189
  const onTermTypeChange = () => {
190
190
  const isBtw = btwKeys.includes(termsModel.termType);
191
- if (!isBtw && Array.isArray(termsModel.value)) {
191
+ if (!isBtw && termsModel.value && Array.isArray(termsModel.value)) {
192
192
  termsModel.value = termsModel.value[0];
193
193
  onValueChange();
194
194
  }
195
- else if (isBtw && !Array.isArray(termsModel.value)) {
195
+ else if (isBtw && termsModel.value && !Array.isArray(termsModel.value)) {
196
196
  termsModel.value = [termsModel.value];
197
197
  onValueChange();
198
198
  }
@@ -19,7 +19,7 @@ var _flattenTree = exports.flattenTree = function flattenTree(tree) {
19
19
  return (0, _objectSpread2.default)({}, (0, _lodashEs.omit)(i, 'children'));
20
20
  });
21
21
  var flatNode = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodashEs.omit)(item, 'children')), {}, {
22
- children: _children,
22
+ _children: _children,
23
23
  level: level,
24
24
  parentId: parentId,
25
25
  expanded: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetlinks-web/components",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -155,8 +155,8 @@
155
155
  "webpack-merge": "^5.0.0",
156
156
  "webpackbar": "^5.0.2",
157
157
  "@jetlinks-web/constants": "^1.0.9",
158
- "@jetlinks-web/utils": "^1.2.12",
159
- "@jetlinks-web/hooks": "^1.1.1"
158
+ "@jetlinks-web/hooks": "^1.1.1",
159
+ "@jetlinks-web/utils": "^1.2.12"
160
160
  },
161
161
  "publishConfig": {
162
162
  "registry": "https://registry.npmjs.org/",