@jetlinks-web/components 3.2.6 → 3.2.7
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.
|
@@ -37,11 +37,13 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
|
|
|
37
37
|
"isEmpty": "setup-const",
|
|
38
38
|
"normalizeText": "setup-const",
|
|
39
39
|
"isOptionMatched": "setup-const",
|
|
40
|
+
"isOptionContainsKeyword": "setup-const",
|
|
40
41
|
"componentProps": "setup-ref",
|
|
41
42
|
"mergedOptions": "setup-ref",
|
|
42
43
|
"displayOptions": "setup-ref",
|
|
43
44
|
"appendCustomOption": "setup-const",
|
|
44
45
|
"handleSearch": "setup-const",
|
|
46
|
+
"resetSearchValue": "setup-const",
|
|
45
47
|
"handleMultipleChange": "setup-const",
|
|
46
48
|
"handleSingleChange": "setup-const",
|
|
47
49
|
"handleSingleBlur": "setup-const",
|
|
@@ -90,6 +92,11 @@ const __sfc_main__ = _defineComponent({
|
|
|
90
92
|
const optionLabel = normalizeText(_nullishCoalesce(_optionalChain([option, 'optionalAccess', _2 => _2[props.searchKey]]), () => (_optionalChain([option, 'optionalAccess', _3 => _3.label]))));
|
|
91
93
|
return optionValue === keyword || optionLabel === keyword;
|
|
92
94
|
};
|
|
95
|
+
const isOptionContainsKeyword = (option, keyword) => {
|
|
96
|
+
const optionValue = normalizeText(_optionalChain([option, 'optionalAccess', _4 => _4.value]));
|
|
97
|
+
const optionLabel = normalizeText(_nullishCoalesce(_optionalChain([option, 'optionalAccess', _5 => _5[props.searchKey]]), () => (_optionalChain([option, 'optionalAccess', _6 => _6.label]))));
|
|
98
|
+
return optionValue.includes(keyword) || optionLabel.includes(keyword);
|
|
99
|
+
};
|
|
93
100
|
const componentProps = computed(() => {
|
|
94
101
|
const { multiple, searchKey, options, value, mode, ...rest } = props;
|
|
95
102
|
return rest;
|
|
@@ -101,7 +108,7 @@ const __sfc_main__ = _defineComponent({
|
|
|
101
108
|
const result = [];
|
|
102
109
|
const keys = new Set();
|
|
103
110
|
[...customOptions.value, ...baseOptions].forEach((option) => {
|
|
104
|
-
const key = normalizeText(_optionalChain([option, 'optionalAccess',
|
|
111
|
+
const key = normalizeText(_optionalChain([option, 'optionalAccess', _7 => _7.value]) || _optionalChain([option, 'optionalAccess', _8 => _8[props.searchKey]]) || _optionalChain([option, 'optionalAccess', _9 => _9.label]));
|
|
105
112
|
if (!key || keys.has(key)) {
|
|
106
113
|
return;
|
|
107
114
|
}
|
|
@@ -115,11 +122,12 @@ const __sfc_main__ = _defineComponent({
|
|
|
115
122
|
if (!keyword) {
|
|
116
123
|
return mergedOptions.value;
|
|
117
124
|
}
|
|
125
|
+
const matchedOptions = mergedOptions.value.filter((option) => isOptionContainsKeyword(option, keyword));
|
|
118
126
|
const exists = mergedOptions.value.some((option) => isOptionMatched(option, keyword));
|
|
119
127
|
if (exists) {
|
|
120
|
-
return
|
|
128
|
+
return matchedOptions;
|
|
121
129
|
}
|
|
122
|
-
return [{ label: keyword, value: keyword }, ...
|
|
130
|
+
return [{ label: keyword, value: keyword }, ...matchedOptions];
|
|
123
131
|
});
|
|
124
132
|
const appendCustomOption = (val) => {
|
|
125
133
|
const keyword = normalizeText(val);
|
|
@@ -135,6 +143,9 @@ const __sfc_main__ = _defineComponent({
|
|
|
135
143
|
const handleSearch = (val) => {
|
|
136
144
|
searchValue.value = normalizeText(val);
|
|
137
145
|
};
|
|
146
|
+
const resetSearchValue = () => {
|
|
147
|
+
searchValue.value = '';
|
|
148
|
+
};
|
|
138
149
|
const handleMultipleChange = (val) => {
|
|
139
150
|
const nextValue = Array.isArray(val)
|
|
140
151
|
? val
|
|
@@ -143,6 +154,7 @@ const __sfc_main__ = _defineComponent({
|
|
|
143
154
|
: [val];
|
|
144
155
|
nextValue.forEach((item) => appendCustomOption(item));
|
|
145
156
|
myValue.value = nextValue;
|
|
157
|
+
resetSearchValue();
|
|
146
158
|
emit('update:value', nextValue);
|
|
147
159
|
emit('change', nextValue);
|
|
148
160
|
};
|
|
@@ -154,9 +166,11 @@ const __sfc_main__ = _defineComponent({
|
|
|
154
166
|
};
|
|
155
167
|
const handleSingleBlur = () => {
|
|
156
168
|
appendCustomOption(myValue.value);
|
|
169
|
+
resetSearchValue();
|
|
157
170
|
};
|
|
158
171
|
const onSelect = (val, option) => {
|
|
159
172
|
appendCustomOption(val);
|
|
173
|
+
resetSearchValue();
|
|
160
174
|
emit('select', val, option);
|
|
161
175
|
};
|
|
162
176
|
const normalizeValueByMode = (val) => {
|
|
@@ -175,6 +189,10 @@ const __sfc_main__ = _defineComponent({
|
|
|
175
189
|
nextValue.forEach((item) => appendCustomOption(item));
|
|
176
190
|
}
|
|
177
191
|
else {
|
|
192
|
+
if (!props.multiple &&
|
|
193
|
+
normalizeText(nextValue) === normalizeText(searchValue.value)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
178
196
|
appendCustomOption(nextValue);
|
|
179
197
|
}
|
|
180
198
|
}, { immediate: true });
|
|
@@ -37,11 +37,13 @@ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]
|
|
|
37
37
|
"isEmpty": "setup-const",
|
|
38
38
|
"normalizeText": "setup-const",
|
|
39
39
|
"isOptionMatched": "setup-const",
|
|
40
|
+
"isOptionContainsKeyword": "setup-const",
|
|
40
41
|
"componentProps": "setup-ref",
|
|
41
42
|
"mergedOptions": "setup-ref",
|
|
42
43
|
"displayOptions": "setup-ref",
|
|
43
44
|
"appendCustomOption": "setup-const",
|
|
44
45
|
"handleSearch": "setup-const",
|
|
46
|
+
"resetSearchValue": "setup-const",
|
|
45
47
|
"handleMultipleChange": "setup-const",
|
|
46
48
|
"handleSingleChange": "setup-const",
|
|
47
49
|
"handleSingleBlur": "setup-const",
|
|
@@ -90,6 +92,11 @@ const __sfc_main__ = _defineComponent({
|
|
|
90
92
|
const optionLabel = normalizeText(_nullishCoalesce(_optionalChain([option, 'optionalAccess', _2 => _2[props.searchKey]]), () => (_optionalChain([option, 'optionalAccess', _3 => _3.label]))));
|
|
91
93
|
return optionValue === keyword || optionLabel === keyword;
|
|
92
94
|
};
|
|
95
|
+
const isOptionContainsKeyword = (option, keyword) => {
|
|
96
|
+
const optionValue = normalizeText(_optionalChain([option, 'optionalAccess', _4 => _4.value]));
|
|
97
|
+
const optionLabel = normalizeText(_nullishCoalesce(_optionalChain([option, 'optionalAccess', _5 => _5[props.searchKey]]), () => (_optionalChain([option, 'optionalAccess', _6 => _6.label]))));
|
|
98
|
+
return optionValue.includes(keyword) || optionLabel.includes(keyword);
|
|
99
|
+
};
|
|
93
100
|
const componentProps = computed(() => {
|
|
94
101
|
const { multiple, searchKey, options, value, mode, ...rest } = props;
|
|
95
102
|
return rest;
|
|
@@ -101,7 +108,7 @@ const __sfc_main__ = _defineComponent({
|
|
|
101
108
|
const result = [];
|
|
102
109
|
const keys = new Set();
|
|
103
110
|
[...customOptions.value, ...baseOptions].forEach((option) => {
|
|
104
|
-
const key = normalizeText(_optionalChain([option, 'optionalAccess',
|
|
111
|
+
const key = normalizeText(_optionalChain([option, 'optionalAccess', _7 => _7.value]) || _optionalChain([option, 'optionalAccess', _8 => _8[props.searchKey]]) || _optionalChain([option, 'optionalAccess', _9 => _9.label]));
|
|
105
112
|
if (!key || keys.has(key)) {
|
|
106
113
|
return;
|
|
107
114
|
}
|
|
@@ -115,11 +122,12 @@ const __sfc_main__ = _defineComponent({
|
|
|
115
122
|
if (!keyword) {
|
|
116
123
|
return mergedOptions.value;
|
|
117
124
|
}
|
|
125
|
+
const matchedOptions = mergedOptions.value.filter((option) => isOptionContainsKeyword(option, keyword));
|
|
118
126
|
const exists = mergedOptions.value.some((option) => isOptionMatched(option, keyword));
|
|
119
127
|
if (exists) {
|
|
120
|
-
return
|
|
128
|
+
return matchedOptions;
|
|
121
129
|
}
|
|
122
|
-
return [{ label: keyword, value: keyword }, ...
|
|
130
|
+
return [{ label: keyword, value: keyword }, ...matchedOptions];
|
|
123
131
|
});
|
|
124
132
|
const appendCustomOption = (val) => {
|
|
125
133
|
const keyword = normalizeText(val);
|
|
@@ -135,6 +143,9 @@ const __sfc_main__ = _defineComponent({
|
|
|
135
143
|
const handleSearch = (val) => {
|
|
136
144
|
searchValue.value = normalizeText(val);
|
|
137
145
|
};
|
|
146
|
+
const resetSearchValue = () => {
|
|
147
|
+
searchValue.value = '';
|
|
148
|
+
};
|
|
138
149
|
const handleMultipleChange = (val) => {
|
|
139
150
|
const nextValue = Array.isArray(val)
|
|
140
151
|
? val
|
|
@@ -143,6 +154,7 @@ const __sfc_main__ = _defineComponent({
|
|
|
143
154
|
: [val];
|
|
144
155
|
nextValue.forEach((item) => appendCustomOption(item));
|
|
145
156
|
myValue.value = nextValue;
|
|
157
|
+
resetSearchValue();
|
|
146
158
|
emit('update:value', nextValue);
|
|
147
159
|
emit('change', nextValue);
|
|
148
160
|
};
|
|
@@ -154,9 +166,11 @@ const __sfc_main__ = _defineComponent({
|
|
|
154
166
|
};
|
|
155
167
|
const handleSingleBlur = () => {
|
|
156
168
|
appendCustomOption(myValue.value);
|
|
169
|
+
resetSearchValue();
|
|
157
170
|
};
|
|
158
171
|
const onSelect = (val, option) => {
|
|
159
172
|
appendCustomOption(val);
|
|
173
|
+
resetSearchValue();
|
|
160
174
|
emit('select', val, option);
|
|
161
175
|
};
|
|
162
176
|
const normalizeValueByMode = (val) => {
|
|
@@ -175,6 +189,10 @@ const __sfc_main__ = _defineComponent({
|
|
|
175
189
|
nextValue.forEach((item) => appendCustomOption(item));
|
|
176
190
|
}
|
|
177
191
|
else {
|
|
192
|
+
if (!props.multiple &&
|
|
193
|
+
normalizeText(nextValue) === normalizeText(searchValue.value)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
178
196
|
appendCustomOption(nextValue);
|
|
179
197
|
}
|
|
180
198
|
}, { immediate: true });
|