@opentiny/vue-search-box 0.1.1-alpha.3 → 0.1.2
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/es/components/first-level-panel.vue.es.js +4 -0
- package/dist/es/components/first-level-panel.vue.es2.js +177 -0
- package/dist/es/components/second-level-panel.vue.es.js +4 -0
- package/dist/es/components/second-level-panel.vue.es2.js +466 -0
- package/dist/es/composables/use-checkbox.es.js +5 -18
- package/dist/es/composables/use-custom.es.js +1 -0
- package/dist/es/composables/use-datepicker.es.js +1 -1
- package/dist/es/composables/use-dropdown.es.js +27 -18
- package/dist/es/composables/use-edit.es.js +3 -1
- package/dist/es/composables/use-init.es.js +24 -10
- package/dist/es/composables/use-match.es.js +42 -42
- package/dist/es/composables/use-num-range.es.js +1 -1
- package/dist/es/composables/use-placeholder.es.js +2 -2
- package/dist/es/composables/use-tag.es.js +6 -1
- package/dist/es/{index-VrLZbD8H.css → index-BYxS8gdW.css} +56 -14
- package/dist/es/index.es.js +6 -0
- package/dist/es/index.vue.es2.js +150 -623
- package/dist/es/utils/dropdown.es.js +9 -5
- package/dist/es/utils/tag.es.js +2 -4
- package/dist/index.css +56 -14
- package/dist/lib/components/first-level-panel.vue.cjs.js +4 -0
- package/dist/lib/components/first-level-panel.vue.cjs2.js +177 -0
- package/dist/lib/components/second-level-panel.vue.cjs.js +4 -0
- package/dist/lib/components/second-level-panel.vue.cjs2.js +466 -0
- package/dist/lib/composables/use-checkbox.cjs.js +5 -18
- package/dist/lib/composables/use-custom.cjs.js +1 -0
- package/dist/lib/composables/use-datepicker.cjs.js +1 -1
- package/dist/lib/composables/use-dropdown.cjs.js +27 -18
- package/dist/lib/composables/use-edit.cjs.js +3 -1
- package/dist/lib/composables/use-init.cjs.js +24 -10
- package/dist/lib/composables/use-match.cjs.js +41 -41
- package/dist/lib/composables/use-num-range.cjs.js +1 -1
- package/dist/lib/composables/use-placeholder.cjs.js +2 -2
- package/dist/lib/composables/use-tag.cjs.js +6 -1
- package/dist/lib/{index-VrLZbD8H.css → index-BYxS8gdW.css} +56 -14
- package/dist/lib/index.cjs.js +6 -0
- package/dist/lib/index.vue.cjs2.js +156 -629
- package/dist/lib/utils/dropdown.cjs.js +9 -5
- package/dist/lib/utils/tag.cjs.js +1 -3
- package/dist/types/composables/use-checkbox.d.ts +0 -2
- package/dist/types/composables/use-dropdown.d.ts +1 -0
- package/package.json +1 -2
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { getTagId, hasTagItem, createNewTag, emitChangeModelEvent } from "../utils/tag.es.js";
|
|
3
3
|
import { omitObj, deepClone } from "../utils/clone.es.js";
|
|
4
|
+
import { showDropdown } from "../utils/dropdown.es.js";
|
|
4
5
|
function useCheckbox({ props, state, emits }) {
|
|
5
6
|
const selectCheckbox = (confirm) => {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
showDropdown(state, false);
|
|
6
9
|
const { checkboxGroup, prevItem, propItem } = state;
|
|
7
10
|
const rest = omitObj(prevItem);
|
|
8
|
-
state.hiden = true;
|
|
9
11
|
if (confirm) {
|
|
10
12
|
const tagList = [];
|
|
11
13
|
const oldValue = deepClone(state.innerModelValue);
|
|
@@ -16,7 +18,7 @@ function useCheckbox({ props, state, emits }) {
|
|
|
16
18
|
const { indexMap } = state;
|
|
17
19
|
const hasTagIndex = indexMap.get(prevLabel);
|
|
18
20
|
hasTagIndex !== void 0 && state.innerModelValue.splice(hasTagIndex, 1);
|
|
19
|
-
state.backupList.forEach((item) => {
|
|
21
|
+
(_a = state.backupList) == null ? void 0 : _a.forEach((item) => {
|
|
20
22
|
const { label } = item;
|
|
21
23
|
const checkboxLabel = `${prevLabel}${label}`;
|
|
22
24
|
const hasItem = checkboxGroup.includes(checkboxLabel);
|
|
@@ -35,7 +37,7 @@ function useCheckbox({ props, state, emits }) {
|
|
|
35
37
|
} else {
|
|
36
38
|
const { valueMap } = state;
|
|
37
39
|
const indexList = [];
|
|
38
|
-
state.backupList.forEach((item) => {
|
|
40
|
+
(_b = state.backupList) == null ? void 0 : _b.forEach((item) => {
|
|
39
41
|
const { label } = item;
|
|
40
42
|
const value = `${prevLabel}${label}`;
|
|
41
43
|
const hasItem = checkboxGroup.includes(value);
|
|
@@ -61,24 +63,9 @@ function useCheckbox({ props, state, emits }) {
|
|
|
61
63
|
state.inputValue = "";
|
|
62
64
|
}
|
|
63
65
|
};
|
|
64
|
-
const isIndeterminate = computed(
|
|
65
|
-
() => state.checkboxGroup.length > 0 && state.checkboxGroup.length !== state.filterList.length
|
|
66
|
-
);
|
|
67
|
-
const checkAll = computed({
|
|
68
|
-
get: () => state.checkboxGroup.length && state.checkboxGroup.length === state.filterList.length,
|
|
69
|
-
set: (val) => {
|
|
70
|
-
if (val) {
|
|
71
|
-
state.checkboxGroup = state.filterList.flatMap((item) => `${state.prevItem.label}${item.label}`);
|
|
72
|
-
} else {
|
|
73
|
-
state.checkboxGroup = [];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
66
|
const isShowClose = computed(() => props.modelValue.length || state.propItem.label || state.inputValue);
|
|
78
67
|
return {
|
|
79
68
|
selectCheckbox,
|
|
80
|
-
isIndeterminate,
|
|
81
|
-
checkAll,
|
|
82
69
|
isShowClose
|
|
83
70
|
};
|
|
84
71
|
}
|
|
@@ -2,6 +2,7 @@ import { emitChangeModelEvent, hasTagItem, resetInput } from "../utils/tag.es.js
|
|
|
2
2
|
import { showDropdown, showPopover } from "../utils/dropdown.es.js";
|
|
3
3
|
function useCustom({ state, emits }) {
|
|
4
4
|
const updateCustomValue = (customTag) => {
|
|
5
|
+
showDropdown(state, false);
|
|
5
6
|
const { prevItem, indexMap } = state;
|
|
6
7
|
const { replace, label } = prevItem;
|
|
7
8
|
const tagList = [];
|
|
@@ -10,10 +10,10 @@ function useDatePicker({ props, state, emits }) {
|
|
|
10
10
|
}
|
|
11
11
|
const newTag = await getVerifyDateTag(instance, state, props, isDateTimeType);
|
|
12
12
|
if (newTag) {
|
|
13
|
+
showDropdown(state, false);
|
|
13
14
|
const newValue = props.modelValue.filter((prev) => prev.type !== newTag.type || prev.field !== newTag.field);
|
|
14
15
|
newValue.push(newTag);
|
|
15
16
|
emitChangeModelEvent({ emits, state, newValue });
|
|
16
|
-
showDropdown(state, false);
|
|
17
17
|
} else {
|
|
18
18
|
showDropdown(state);
|
|
19
19
|
}
|
|
@@ -5,12 +5,11 @@ import { omitObj, deepClone } from "../utils/clone.es.js";
|
|
|
5
5
|
function useDropdown({ props, emits, state, t, format }) {
|
|
6
6
|
const { instance } = state;
|
|
7
7
|
const showValueItem = (item) => {
|
|
8
|
-
var _a;
|
|
8
|
+
var _a, _b, _c;
|
|
9
9
|
const { start, end, type } = item;
|
|
10
|
-
state.backupList =
|
|
10
|
+
state.backupList = item.options;
|
|
11
11
|
if (type === "numRange") {
|
|
12
12
|
setStateNumRange(state, item, t);
|
|
13
|
-
state.hiden = false;
|
|
14
13
|
} else if (type === "dateRange") {
|
|
15
14
|
const { dateRangeFormat } = state;
|
|
16
15
|
if (!state.startDate && start) {
|
|
@@ -21,7 +20,6 @@ function useDropdown({ props, emits, state, t, format }) {
|
|
|
21
20
|
const newEnd = format(end, dateRangeFormat);
|
|
22
21
|
state.endDate = newEnd < state.startDate ? null : newEnd;
|
|
23
22
|
}
|
|
24
|
-
state.hiden = false;
|
|
25
23
|
} else if (type === "datetimeRange") {
|
|
26
24
|
const { datetimeRangeFormat } = state;
|
|
27
25
|
if (!state.startDateTime && start) {
|
|
@@ -32,28 +30,26 @@ function useDropdown({ props, emits, state, t, format }) {
|
|
|
32
30
|
const newEnd = format(end, datetimeRangeFormat);
|
|
33
31
|
state.endDateTime = newEnd < state.startDateTime ? null : newEnd;
|
|
34
32
|
}
|
|
35
|
-
state.hiden = false;
|
|
36
33
|
} else if (state.backupList && type === "checkbox") {
|
|
37
34
|
state.filterList = state.backupList;
|
|
38
35
|
state.checkboxGroup = [];
|
|
39
|
-
state.backupList.forEach((subItem) => {
|
|
36
|
+
(_a = state.backupList) == null ? void 0 : _a.forEach((subItem) => {
|
|
40
37
|
if (hasTagItem(state, subItem.label)) {
|
|
41
38
|
state.checkboxGroup.push(`${item.label}${subItem.label}`);
|
|
42
39
|
}
|
|
43
40
|
subItem.isFilter = false;
|
|
44
41
|
});
|
|
45
|
-
state.hiden = false;
|
|
46
|
-
} else if (type === "custom") {
|
|
47
|
-
state.hiden = false;
|
|
48
42
|
}
|
|
49
|
-
if (
|
|
50
|
-
state.backupList.forEach((option) => {
|
|
43
|
+
if (type !== "checkbox" && ((_b = state.backupList) == null ? void 0 : _b.length)) {
|
|
44
|
+
(_c = state.backupList) == null ? void 0 : _c.forEach((option) => {
|
|
51
45
|
option.isFilter = false;
|
|
52
46
|
option.isChecked = hasTagItem(state, option.label);
|
|
53
47
|
});
|
|
54
48
|
}
|
|
55
49
|
state.currentOperators = null;
|
|
56
|
-
if (!
|
|
50
|
+
if (!state.backupList && !["dateRange", "datetimeRange", "numRange", "custom"].includes(type)) {
|
|
51
|
+
showDropdown(state, false);
|
|
52
|
+
} else {
|
|
57
53
|
showDropdown(state);
|
|
58
54
|
}
|
|
59
55
|
};
|
|
@@ -68,7 +64,6 @@ function useDropdown({ props, emits, state, t, format }) {
|
|
|
68
64
|
if (operators == null ? void 0 : operators.length) {
|
|
69
65
|
state.operatorValue = "";
|
|
70
66
|
state.currentOperators = operators;
|
|
71
|
-
state.isResetFlag = true;
|
|
72
67
|
showDropdown(state);
|
|
73
68
|
} else {
|
|
74
69
|
state.operatorValue = ":";
|
|
@@ -105,6 +100,7 @@ function useDropdown({ props, emits, state, t, format }) {
|
|
|
105
100
|
resetInput(state);
|
|
106
101
|
return;
|
|
107
102
|
}
|
|
103
|
+
showDropdown(state, false);
|
|
108
104
|
const oldValue = deepClone(state.innerModelValue);
|
|
109
105
|
if ((replace || mergeTag) && index >= 0) {
|
|
110
106
|
state.innerModelValue.splice(index, 1);
|
|
@@ -113,7 +109,16 @@ function useDropdown({ props, emits, state, t, format }) {
|
|
|
113
109
|
const newValue = state.innerModelValue;
|
|
114
110
|
emitChangeModelEvent({ emits, state, newValue, oldValue });
|
|
115
111
|
};
|
|
112
|
+
const selectInputValue = (val) => {
|
|
113
|
+
var _a;
|
|
114
|
+
if ((_a = state.propItem) == null ? void 0 : _a.label) {
|
|
115
|
+
selectRadioItem({ label: val });
|
|
116
|
+
} else {
|
|
117
|
+
createTag();
|
|
118
|
+
}
|
|
119
|
+
};
|
|
116
120
|
const selectRadioItem = (item, isPotential = false) => {
|
|
121
|
+
showDropdown(state, false);
|
|
117
122
|
if (isPotential) {
|
|
118
123
|
state.prevItem = item;
|
|
119
124
|
state.backupPrevItem = item;
|
|
@@ -144,11 +149,12 @@ function useDropdown({ props, emits, state, t, format }) {
|
|
|
144
149
|
}
|
|
145
150
|
};
|
|
146
151
|
const newTagUpdateModelValue = (prevItem, propItem, tag) => {
|
|
147
|
-
|
|
152
|
+
var _a;
|
|
153
|
+
const item = (_a = state.backupList) == null ? void 0 : _a.find((subItem) => subItem.label === tag);
|
|
148
154
|
updateModelValue(prevItem, item, propItem.label, tag);
|
|
149
155
|
};
|
|
150
156
|
const hasInputValueCreateTag = (inputValue, propItem, prevItem) => {
|
|
151
|
-
var _a;
|
|
157
|
+
var _a, _b;
|
|
152
158
|
if (propItem.label) {
|
|
153
159
|
const { regexp, replace, type, mergeTag } = prevItem;
|
|
154
160
|
const tagList = type !== "checkbox" && replace || type === "checkbox" && mergeTag ? [inputValue] : inputValue.split(props.splitInputValue);
|
|
@@ -165,12 +171,15 @@ function useDropdown({ props, emits, state, t, format }) {
|
|
|
165
171
|
}
|
|
166
172
|
} else {
|
|
167
173
|
const { items, defaultField } = props;
|
|
168
|
-
const currentItem =
|
|
174
|
+
const currentItem = items.find((item) => {
|
|
175
|
+
const { regexp } = item;
|
|
176
|
+
return regexp && regexp.test(state.inputValue);
|
|
177
|
+
}) || (defaultField ? items.find((item) => item.field === defaultField) : state.allTypeAttri);
|
|
169
178
|
const { replace, type, mergeTag } = currentItem;
|
|
170
179
|
const tagList = type !== "checkbox" && replace || type === "checkbox" && mergeTag ? [inputValue] : inputValue.split(props.splitInputValue);
|
|
171
180
|
if ((_a = currentItem == null ? void 0 : currentItem.options) == null ? void 0 : _a.length) {
|
|
172
181
|
state.backupList = [...currentItem.options];
|
|
173
|
-
state.backupList.forEach((item) => {
|
|
182
|
+
(_b = state.backupList) == null ? void 0 : _b.forEach((item) => {
|
|
174
183
|
const label2 = item.value || item.label;
|
|
175
184
|
if (tagList.includes(label2)) {
|
|
176
185
|
item.isChecked = true;
|
|
@@ -200,7 +209,7 @@ function useDropdown({ props, emits, state, t, format }) {
|
|
|
200
209
|
const helpClick = () => {
|
|
201
210
|
emits("help");
|
|
202
211
|
};
|
|
203
|
-
return { selectPropItem, selectRadioItem, createTag, helpClick, setOperator };
|
|
212
|
+
return { selectPropItem, selectRadioItem, selectInputValue, createTag, helpClick, setOperator };
|
|
204
213
|
}
|
|
205
214
|
export {
|
|
206
215
|
useDropdown
|
|
@@ -49,6 +49,7 @@ function useEdit({ props, state, t, nextTick, format, emits }) {
|
|
|
49
49
|
!state.prevItem && (state.prevItem = tag);
|
|
50
50
|
state.selectValue = tag.label;
|
|
51
51
|
state.currentModelValueIndex = index;
|
|
52
|
+
emits("tagClick", tag);
|
|
52
53
|
setDropdownProps(tag);
|
|
53
54
|
};
|
|
54
55
|
const selectPropChange = (item, disabled) => {
|
|
@@ -73,8 +74,9 @@ function useEdit({ props, state, t, nextTick, format, emits }) {
|
|
|
73
74
|
newTag = await getVerifyTag(instance, state, props);
|
|
74
75
|
}
|
|
75
76
|
if (newTag) {
|
|
76
|
-
|
|
77
|
+
showDropdown(state, false);
|
|
77
78
|
state.popoverVisible = false;
|
|
79
|
+
emitChangeModelEvent({ emits, state, index, newTag, isEdit: true });
|
|
78
80
|
} else {
|
|
79
81
|
state.popoverVisible = true;
|
|
80
82
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { showDropdown, showPopover } from "../utils/dropdown.es.js";
|
|
2
|
+
import { hasTagItem } from "../utils/tag.es.js";
|
|
2
3
|
function useInit({ props, state }) {
|
|
3
|
-
const { instance } = state;
|
|
4
4
|
const initItems = () => {
|
|
5
5
|
state.groupItems = {};
|
|
6
6
|
state.recordItems.forEach((item) => {
|
|
7
|
+
var _a;
|
|
7
8
|
const { groupKey = "0" } = item;
|
|
8
9
|
if (state.groupItems[groupKey]) {
|
|
9
10
|
state.groupItems[groupKey].push({ ...item });
|
|
@@ -11,12 +12,31 @@ function useInit({ props, state }) {
|
|
|
11
12
|
state.groupItems[groupKey] = [{ ...item }];
|
|
12
13
|
state.matchItems[groupKey] = { attr: [], attrValue: [] };
|
|
13
14
|
}
|
|
15
|
+
if (state.prevItem && item.field === state.prevItem.field && item !== state.prevItem) {
|
|
16
|
+
const { options, type } = item;
|
|
17
|
+
state.prevItem = item;
|
|
18
|
+
if (options == null ? void 0 : options.length) {
|
|
19
|
+
state.backupList = options;
|
|
20
|
+
}
|
|
21
|
+
if (type === "checkbox") {
|
|
22
|
+
state.filterList = state.backupList;
|
|
23
|
+
state.checkboxGroup = [];
|
|
24
|
+
(_a = state.backupList) == null ? void 0 : _a.forEach((subItem) => {
|
|
25
|
+
const { label } = subItem;
|
|
26
|
+
if (hasTagItem(state, label)) {
|
|
27
|
+
state.checkboxGroup.push(`${item.label}${label}`);
|
|
28
|
+
}
|
|
29
|
+
subItem.isFilter = false;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
showDropdown(state, item.field === state.prevItem.field && item !== state.prevItem);
|
|
33
|
+
}
|
|
14
34
|
});
|
|
15
35
|
};
|
|
16
36
|
const handleClick = (e) => {
|
|
37
|
+
var _a;
|
|
17
38
|
const { backupPrevItem, prevItem } = state;
|
|
18
39
|
e.stopPropagation();
|
|
19
|
-
state.isResetFlag = true;
|
|
20
40
|
if (props.editable) {
|
|
21
41
|
state.popoverVisible = false;
|
|
22
42
|
state.currentEditValue = [];
|
|
@@ -24,24 +44,18 @@ function useInit({ props, state }) {
|
|
|
24
44
|
state.prevItem = backupPrevItem;
|
|
25
45
|
}
|
|
26
46
|
}
|
|
27
|
-
if (!state.
|
|
47
|
+
if (state.hasBackupList && (((_a = state.backupList) == null ? void 0 : _a.length) === 0 || !state.backupList) && !state.inputValue || props.items.length === 0) {
|
|
28
48
|
showDropdown(state, false);
|
|
29
49
|
} else {
|
|
30
50
|
showDropdown(state);
|
|
31
51
|
}
|
|
32
52
|
};
|
|
33
53
|
const watchOutsideClick = () => {
|
|
34
|
-
var _a, _b, _c;
|
|
35
|
-
if (!state.isMouseDown) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
54
|
if (props.editable) {
|
|
39
55
|
showPopover(state, false);
|
|
40
56
|
}
|
|
41
57
|
state.isMouseDown = false;
|
|
42
|
-
|
|
43
|
-
showDropdown(state, false);
|
|
44
|
-
}
|
|
58
|
+
showDropdown(state, false);
|
|
45
59
|
};
|
|
46
60
|
const watchMouseDown = () => {
|
|
47
61
|
state.isMouseDown = true;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { ref
|
|
1
|
+
import { ref } from "vue";
|
|
2
2
|
import Loading from "@opentiny/vue-loading";
|
|
3
3
|
import { debounce } from "../utils/index.es.js";
|
|
4
4
|
import { hasTagItem, getTagId, createNewTag, emitChangeModelEvent } from "../utils/tag.es.js";
|
|
5
5
|
import { showDropdown } from "../utils/dropdown.es.js";
|
|
6
6
|
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7
|
-
const getHighlightMatch = (labelRegex, label
|
|
7
|
+
const getHighlightMatch = (labelRegex, label) => {
|
|
8
8
|
const match = [];
|
|
9
|
-
let lastIndex;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const startIndex =
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
let lastIndex = 0;
|
|
10
|
+
let result;
|
|
11
|
+
while ((result = labelRegex.exec(label)) !== null) {
|
|
12
|
+
const startIndex = result.index;
|
|
13
|
+
const endIndex = labelRegex.lastIndex;
|
|
14
|
+
if (startIndex > lastIndex) {
|
|
15
|
+
match.push(label.slice(lastIndex, startIndex));
|
|
16
|
+
}
|
|
17
|
+
match.push(label.slice(startIndex, endIndex));
|
|
18
|
+
lastIndex = endIndex;
|
|
17
19
|
}
|
|
18
20
|
if (lastIndex < label.length) {
|
|
19
21
|
match.push(label.slice(lastIndex));
|
|
@@ -22,29 +24,18 @@ const getHighlightMatch = (labelRegex, label, valueLength) => {
|
|
|
22
24
|
};
|
|
23
25
|
function useMatch({ props, state, emits }) {
|
|
24
26
|
const loadingInstance = ref(null);
|
|
25
|
-
watch(
|
|
26
|
-
() => state.inputValue,
|
|
27
|
-
(newInput) => {
|
|
28
|
-
if (!newInput.trim()) {
|
|
29
|
-
state.isShowDropdown = true;
|
|
30
|
-
} else {
|
|
31
|
-
state.isShowDropdown = false;
|
|
32
|
-
}
|
|
33
|
-
showDropdown(state, false);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
27
|
const getMatchList = async (keyword) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
if (typeof document !== "undefined") {
|
|
29
|
+
!loadingInstance.value && (loadingInstance.value = Loading.service({
|
|
30
|
+
target: document.getElementById("potential-loading")
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
40
33
|
state.potentialOptions = await props.potentialOptions.getMatchList(keyword);
|
|
41
34
|
loadingInstance.value && loadingInstance.value.close();
|
|
42
|
-
|
|
43
|
-
state.isShowDropdown = true;
|
|
44
|
-
}
|
|
45
|
-
showDropdown(state, state.isShowDropdown);
|
|
35
|
+
showDropdown(state, true);
|
|
46
36
|
};
|
|
47
37
|
const handleSearch = (e) => {
|
|
38
|
+
var _a, _b, _c;
|
|
48
39
|
const { recordItems, propItem } = state;
|
|
49
40
|
const inputValue = e.target.value.trim();
|
|
50
41
|
const { maxlength } = props;
|
|
@@ -53,13 +44,13 @@ function useMatch({ props, state, emits }) {
|
|
|
53
44
|
return;
|
|
54
45
|
}
|
|
55
46
|
if (inputValue.length === 0) {
|
|
47
|
+
showDropdown(state);
|
|
56
48
|
return;
|
|
57
49
|
}
|
|
58
50
|
Object.keys(state.matchItems).forEach((key) => {
|
|
59
51
|
state.matchItems[key].attr = [];
|
|
60
52
|
state.matchItems[key].attrValue = [];
|
|
61
53
|
});
|
|
62
|
-
state.isShowDropdown = false;
|
|
63
54
|
const value = escapeRegExp(inputValue);
|
|
64
55
|
const patt = new RegExp(value, "i");
|
|
65
56
|
const hasItem = propItem.label || !value ? null : recordItems.find((item) => item.type === "map" && patt.test(item.label));
|
|
@@ -71,7 +62,7 @@ function useMatch({ props, state, emits }) {
|
|
|
71
62
|
state.backupList = hasItem.options || [];
|
|
72
63
|
return;
|
|
73
64
|
}
|
|
74
|
-
state.filterList = state.backupList.filter((item) => {
|
|
65
|
+
state.filterList = (_a = state.backupList) == null ? void 0 : _a.filter((item) => {
|
|
75
66
|
if (patt.test(item.label)) {
|
|
76
67
|
delete item.isFilter;
|
|
77
68
|
if (hasTagItem(state, item.label)) {
|
|
@@ -84,62 +75,70 @@ function useMatch({ props, state, emits }) {
|
|
|
84
75
|
}
|
|
85
76
|
});
|
|
86
77
|
const labelRegex = new RegExp(value, "ig");
|
|
87
|
-
const
|
|
78
|
+
const hightlighStr = inputValue.toLowerCase();
|
|
88
79
|
if (state.propItem.label) {
|
|
89
|
-
state.backupList.forEach((item) => {
|
|
80
|
+
(_b = state.backupList) == null ? void 0 : _b.forEach((item) => {
|
|
81
|
+
item.hightlighStr = hightlighStr;
|
|
90
82
|
const itemLabel = item.label;
|
|
91
83
|
if (patt.test(itemLabel)) {
|
|
92
|
-
item.match = getHighlightMatch(labelRegex, itemLabel
|
|
84
|
+
item.match = getHighlightMatch(labelRegex, itemLabel);
|
|
93
85
|
item.isFilter = false;
|
|
94
|
-
state.isShowDropdown = true;
|
|
95
86
|
} else {
|
|
96
87
|
item.isFilter = true;
|
|
97
88
|
}
|
|
98
89
|
});
|
|
90
|
+
if (((_c = state.backupList) == null ? void 0 : _c.length) || inputValue) {
|
|
91
|
+
showDropdown(state);
|
|
92
|
+
} else {
|
|
93
|
+
showDropdown(state, false);
|
|
94
|
+
}
|
|
99
95
|
return;
|
|
100
96
|
}
|
|
101
97
|
for (const item of recordItems) {
|
|
102
98
|
const { options = [], groupKey = "0", ...rest } = item;
|
|
103
99
|
const itemLabel = rest.label;
|
|
104
100
|
if (patt.test(itemLabel)) {
|
|
105
|
-
const match = getHighlightMatch(labelRegex, itemLabel
|
|
106
|
-
state.matchItems[groupKey].attr.push({ ...item, match });
|
|
107
|
-
state.isShowDropdown = true;
|
|
101
|
+
const match = getHighlightMatch(labelRegex, itemLabel);
|
|
102
|
+
state.matchItems[groupKey].attr.push({ ...item, match, hightlighStr });
|
|
108
103
|
}
|
|
109
104
|
for (const option of options) {
|
|
110
105
|
const optionLabel = state.propItem.label ? itemLabel : `${itemLabel}:${option.label}`;
|
|
111
106
|
if (patt.test(optionLabel)) {
|
|
112
|
-
const match = getHighlightMatch(labelRegex, optionLabel
|
|
107
|
+
const match = getHighlightMatch(labelRegex, optionLabel);
|
|
113
108
|
state.matchItems[groupKey].attrValue.push({
|
|
114
109
|
...option,
|
|
115
110
|
...rest,
|
|
111
|
+
options,
|
|
112
|
+
hightlighStr,
|
|
116
113
|
value: option.label,
|
|
117
114
|
match
|
|
118
115
|
});
|
|
119
|
-
state.isShowDropdown = true;
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
118
|
}
|
|
123
119
|
if (value && props.potentialOptions && props.potentialOptions.getMatchList) {
|
|
124
120
|
getMatchList(value);
|
|
125
121
|
} else {
|
|
126
|
-
showDropdown(state
|
|
122
|
+
showDropdown(state);
|
|
127
123
|
}
|
|
128
124
|
};
|
|
129
125
|
const handleInput = debounce(handleSearch, 500);
|
|
130
126
|
const resetBackupList = () => {
|
|
131
|
-
|
|
127
|
+
var _a;
|
|
128
|
+
(_a = state.backupList) == null ? void 0 : _a.forEach((item) => item.isFilter && delete item.isFilter);
|
|
132
129
|
};
|
|
133
130
|
const selectFirstMap = (item, isFirst) => {
|
|
131
|
+
var _a;
|
|
134
132
|
const { options } = item;
|
|
135
133
|
const { prevItem, propItem } = state;
|
|
136
134
|
if (options) {
|
|
135
|
+
showDropdown(state, false);
|
|
137
136
|
state.propItem.value = `${item.label}=`;
|
|
138
137
|
state.isShowTagKey = false;
|
|
139
138
|
state.inputValue = "";
|
|
140
139
|
state.backupList = item.options || [];
|
|
141
140
|
resetBackupList();
|
|
142
|
-
state.backupList.forEach((subItem) => {
|
|
141
|
+
(_a = state.backupList) == null ? void 0 : _a.forEach((subItem) => {
|
|
143
142
|
const value = propItem.value + subItem.label;
|
|
144
143
|
subItem.isChecked = hasTagItem(state, value);
|
|
145
144
|
});
|
|
@@ -147,6 +146,7 @@ function useMatch({ props, state, emits }) {
|
|
|
147
146
|
if (item.isChecked) {
|
|
148
147
|
return;
|
|
149
148
|
}
|
|
149
|
+
showDropdown(state, false);
|
|
150
150
|
state.isShowTagKey = true;
|
|
151
151
|
resetBackupList();
|
|
152
152
|
const { field, type } = prevItem;
|
|
@@ -10,10 +10,10 @@ function useNumRange({ props, state, t, emits }) {
|
|
|
10
10
|
}
|
|
11
11
|
const newTag = await getVerifyNumTag(instance, state, props);
|
|
12
12
|
if (newTag) {
|
|
13
|
+
showDropdown(state, false);
|
|
13
14
|
const newValue = props.modelValue.filter((prev) => prev.type !== newTag.type || prev.field !== newTag.field);
|
|
14
15
|
newValue.push(newTag);
|
|
15
16
|
emitChangeModelEvent({ emits, state, newValue });
|
|
16
|
-
showDropdown(state, false);
|
|
17
17
|
} else {
|
|
18
18
|
showDropdown(state);
|
|
19
19
|
}
|
|
@@ -10,13 +10,14 @@ function usePlaceholder({ props, state, t }) {
|
|
|
10
10
|
watch(
|
|
11
11
|
() => state.propItem.label,
|
|
12
12
|
(newValue) => {
|
|
13
|
+
var _a;
|
|
13
14
|
if (newValue) {
|
|
14
15
|
const { placeholder: placeholder2, type } = state.prevItem;
|
|
15
16
|
if (placeholder2) {
|
|
16
17
|
setPlaceholder(placeholder2);
|
|
17
18
|
} else if (type === "map") {
|
|
18
19
|
setPlaceholder(t("tvp.tvpSearchbox.tagPlaceholder"));
|
|
19
|
-
} else if (state.backupList.length) {
|
|
20
|
+
} else if ((_a = state.backupList) == null ? void 0 : _a.length) {
|
|
20
21
|
setPlaceholder(t("tvp.tvpSearchbox.dynamicPlaceholder", { newValue }));
|
|
21
22
|
} else {
|
|
22
23
|
setPlaceholder(t("tvp.tvpSearchbox.addPlaceholder"));
|
|
@@ -27,7 +28,6 @@ function usePlaceholder({ props, state, t }) {
|
|
|
27
28
|
} else {
|
|
28
29
|
setPlaceholder(props.emptyPlaceholder);
|
|
29
30
|
}
|
|
30
|
-
!state.hiden && (state.hiden = true);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
);
|
|
@@ -13,18 +13,21 @@ function useTag({ props, state, emits }) {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
const deleteTag = (tag) => {
|
|
16
|
+
showDropdown(state, false);
|
|
16
17
|
changeIsChecked(tag);
|
|
17
18
|
const newValue = props.modelValue.filter((item) => item !== tag);
|
|
18
19
|
emitChangeModelEvent({ emits, state, newValue });
|
|
19
20
|
};
|
|
20
21
|
const clearTag = () => {
|
|
22
|
+
showDropdown(state, false);
|
|
21
23
|
props.modelValue.forEach((item) => changeIsChecked(item));
|
|
22
24
|
state.propItem = {};
|
|
23
25
|
state.inputValue = "";
|
|
24
26
|
emitChangeModelEvent({ emits, state, newValue: [] });
|
|
25
|
-
|
|
27
|
+
emits("clear");
|
|
26
28
|
};
|
|
27
29
|
const backspaceDeleteTag = () => {
|
|
30
|
+
var _a, _b;
|
|
28
31
|
if (state.inputValue) {
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
@@ -33,12 +36,14 @@ function useTag({ props, state, emits }) {
|
|
|
33
36
|
return;
|
|
34
37
|
}
|
|
35
38
|
if (lastInputValue.value === "" && state.inputValue === "") {
|
|
39
|
+
showDropdown(state, false);
|
|
36
40
|
const lastIndex = props.modelValue.length - 1;
|
|
37
41
|
changeIsChecked(props.modelValue[lastIndex]);
|
|
38
42
|
const newValue = state.innerModelValue.slice(0, props.modelValue.length - 1);
|
|
39
43
|
emitChangeModelEvent({ emits, state, newValue });
|
|
40
44
|
}
|
|
41
45
|
lastInputValue.value = state.inputValue;
|
|
46
|
+
(_b = (_a = state == null ? void 0 : state.instance) == null ? void 0 : _a.refs) == null ? void 0 : _b.inputRef.$el.click();
|
|
42
47
|
};
|
|
43
48
|
return {
|
|
44
49
|
deleteTag,
|