@opentiny/vue-search-box 0.1.6 → 2.27.1

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.
Files changed (85) hide show
  1. package/{dist/index.css → index.css} +22 -19
  2. package/index.js +2804 -0
  3. package/index.js.map +1 -0
  4. package/package.json +38 -56
  5. package/README.md +0 -134
  6. package/README.zh-CN.md +0 -135
  7. package/dist/es/components/first-level-panel.vue.es.js +0 -4
  8. package/dist/es/components/first-level-panel.vue.es2.js +0 -177
  9. package/dist/es/components/second-level-panel.vue.es.js +0 -4
  10. package/dist/es/components/second-level-panel.vue.es2.js +0 -466
  11. package/dist/es/composables/use-checkbox.es.js +0 -74
  12. package/dist/es/composables/use-custom.es.js +0 -49
  13. package/dist/es/composables/use-datepicker.es.js +0 -86
  14. package/dist/es/composables/use-dropdown.es.js +0 -216
  15. package/dist/es/composables/use-edit.es.js +0 -108
  16. package/dist/es/composables/use-init.es.js +0 -78
  17. package/dist/es/composables/use-match.es.js +0 -170
  18. package/dist/es/composables/use-num-range.es.js +0 -77
  19. package/dist/es/composables/use-placeholder.es.js +0 -41
  20. package/dist/es/composables/use-tag.es.js +0 -56
  21. package/dist/es/index-Tlzvfwv-.css +0 -401
  22. package/dist/es/index.es.js +0 -45
  23. package/dist/es/index.type.es.js +0 -1
  24. package/dist/es/index.vue.es.js +0 -4
  25. package/dist/es/index.vue.es2.js +0 -780
  26. package/dist/es/smb-theme.es.js +0 -18
  27. package/dist/es/utils/clone.es.js +0 -29
  28. package/dist/es/utils/date.es.js +0 -431
  29. package/dist/es/utils/dropdown.es.js +0 -24
  30. package/dist/es/utils/en_US.es.js +0 -45
  31. package/dist/es/utils/index.es.js +0 -13
  32. package/dist/es/utils/tag.es.js +0 -44
  33. package/dist/es/utils/type.es.js +0 -4
  34. package/dist/es/utils/validate.es.js +0 -179
  35. package/dist/es/utils/zh_CN.es.js +0 -45
  36. package/dist/lib/components/first-level-panel.vue.cjs.js +0 -4
  37. package/dist/lib/components/first-level-panel.vue.cjs2.js +0 -177
  38. package/dist/lib/components/second-level-panel.vue.cjs.js +0 -4
  39. package/dist/lib/components/second-level-panel.vue.cjs2.js +0 -466
  40. package/dist/lib/composables/use-checkbox.cjs.js +0 -74
  41. package/dist/lib/composables/use-custom.cjs.js +0 -49
  42. package/dist/lib/composables/use-datepicker.cjs.js +0 -86
  43. package/dist/lib/composables/use-dropdown.cjs.js +0 -216
  44. package/dist/lib/composables/use-edit.cjs.js +0 -108
  45. package/dist/lib/composables/use-init.cjs.js +0 -78
  46. package/dist/lib/composables/use-match.cjs.js +0 -170
  47. package/dist/lib/composables/use-num-range.cjs.js +0 -77
  48. package/dist/lib/composables/use-placeholder.cjs.js +0 -41
  49. package/dist/lib/composables/use-tag.cjs.js +0 -56
  50. package/dist/lib/index-Tlzvfwv-.css +0 -401
  51. package/dist/lib/index.cjs.js +0 -45
  52. package/dist/lib/index.type.cjs.js +0 -1
  53. package/dist/lib/index.vue.cjs.js +0 -4
  54. package/dist/lib/index.vue.cjs2.js +0 -780
  55. package/dist/lib/smb-theme.cjs.js +0 -18
  56. package/dist/lib/utils/clone.cjs.js +0 -29
  57. package/dist/lib/utils/date.cjs.js +0 -431
  58. package/dist/lib/utils/dropdown.cjs.js +0 -24
  59. package/dist/lib/utils/en_US.cjs.js +0 -45
  60. package/dist/lib/utils/index.cjs.js +0 -13
  61. package/dist/lib/utils/tag.cjs.js +0 -44
  62. package/dist/lib/utils/type.cjs.js +0 -4
  63. package/dist/lib/utils/validate.cjs.js +0 -179
  64. package/dist/lib/utils/zh_CN.cjs.js +0 -45
  65. package/dist/types/composables/use-checkbox.d.ts +0 -8
  66. package/dist/types/composables/use-custom.d.ts +0 -7
  67. package/dist/types/composables/use-datepicker.d.ts +0 -11
  68. package/dist/types/composables/use-dropdown.d.ts +0 -14
  69. package/dist/types/composables/use-edit.d.ts +0 -13
  70. package/dist/types/composables/use-init.d.ts +0 -10
  71. package/dist/types/composables/use-match.d.ts +0 -8
  72. package/dist/types/composables/use-num-range.d.ts +0 -9
  73. package/dist/types/composables/use-placeholder.d.ts +0 -8
  74. package/dist/types/composables/use-tag.d.ts +0 -9
  75. package/dist/types/smb-theme.d.ts +0 -15
  76. package/dist/types/utils/clone.d.ts +0 -12
  77. package/dist/types/utils/date.d.ts +0 -234
  78. package/dist/types/utils/dropdown.d.ts +0 -12
  79. package/dist/types/utils/en_US.d.ts +0 -43
  80. package/dist/types/utils/index.d.ts +0 -1
  81. package/dist/types/utils/tag.d.ts +0 -46
  82. package/dist/types/utils/type.d.ts +0 -6
  83. package/dist/types/utils/validate.d.ts +0 -31
  84. package/dist/types/utils/zh_CN.d.ts +0 -43
  85. /package/{dist/types → types}/index.type.d.ts +0 -0
@@ -1,216 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tag = require("../utils/tag.cjs.js");
4
- const dropdown = require("../utils/dropdown.cjs.js");
5
- const validate = require("../utils/validate.cjs.js");
6
- const clone = require("../utils/clone.cjs.js");
7
- function useDropdown({ props, emits, state, t, format }) {
8
- const { instance } = state;
9
- const showValueItem = (item) => {
10
- var _a, _b, _c;
11
- const { start, end, type } = item;
12
- state.backupList = item.options;
13
- if (type === "numRange") {
14
- validate.setStateNumRange(state, item, t);
15
- } else if (type === "dateRange") {
16
- const { dateRangeFormat } = state;
17
- if (!state.startDate && start) {
18
- const newStart = format(start, dateRangeFormat);
19
- state.startDate = state.endDate < newStart ? null : newStart;
20
- }
21
- if (!state.endDate && end) {
22
- const newEnd = format(end, dateRangeFormat);
23
- state.endDate = newEnd < state.startDate ? null : newEnd;
24
- }
25
- } else if (type === "datetimeRange") {
26
- const { datetimeRangeFormat } = state;
27
- if (!state.startDateTime && start) {
28
- const newStart = format(start, datetimeRangeFormat);
29
- state.startDateTime = state.endDateTime < newStart ? null : newStart;
30
- }
31
- if (!state.endDateTime && end) {
32
- const newEnd = format(end, datetimeRangeFormat);
33
- state.endDateTime = newEnd < state.startDateTime ? null : newEnd;
34
- }
35
- } else if (state.backupList && type === "checkbox") {
36
- state.filterList = state.backupList;
37
- state.checkboxGroup = [];
38
- (_a = state.backupList) == null ? void 0 : _a.forEach((subItem) => {
39
- if (tag.hasTagItem(state, subItem.label)) {
40
- state.checkboxGroup.push(`${item.label}${subItem.label}`);
41
- }
42
- subItem.isFilter = false;
43
- });
44
- }
45
- if (type !== "checkbox" && ((_b = state.backupList) == null ? void 0 : _b.length)) {
46
- (_c = state.backupList) == null ? void 0 : _c.forEach((option) => {
47
- option.isFilter = false;
48
- option.isChecked = tag.hasTagItem(state, option.label);
49
- });
50
- }
51
- state.currentOperators = null;
52
- if (!state.backupList && !["dateRange", "datetimeRange", "numRange", "custom"].includes(type)) {
53
- dropdown.showDropdown(state, false);
54
- } else {
55
- dropdown.showDropdown(state);
56
- }
57
- };
58
- const selectPropItem = (item) => {
59
- const { field, label } = item;
60
- state.propItem.label = label;
61
- emits("first-level-select", field);
62
- const inputRef = instance.refs.inputRef;
63
- state.prevItem = item;
64
- state.backupPrevItem = item;
65
- const { operators } = item;
66
- if (operators == null ? void 0 : operators.length) {
67
- state.operatorValue = "";
68
- state.currentOperators = operators;
69
- dropdown.showDropdown(state);
70
- } else {
71
- state.operatorValue = ":";
72
- showValueItem(item);
73
- }
74
- state.inputValue = "";
75
- inputRef.focus();
76
- };
77
- const setOperator = (operator) => {
78
- state.operatorValue = operator;
79
- showValueItem(state.prevItem);
80
- };
81
- const updateModelValue = (prevItem, item, label, value) => {
82
- const { replace, operators, mergeTag } = prevItem;
83
- const rest = clone.omitObj(prevItem);
84
- const { indexMap } = state;
85
- const index = indexMap.get(label);
86
- const id = tag.getTagId(props, prevItem, item);
87
- const operator = state.operatorValue && operators ? { operator: state.operatorValue } : null;
88
- let newTag = null;
89
- if (mergeTag) {
90
- const options = { label: value, ...id };
91
- if (index >= 0) {
92
- const newValue2 = `${state.innerModelValue[index].value} | ${value}`;
93
- const newOptions = [...state.innerModelValue[index].options, options];
94
- newTag = tag.createNewTag({ ...state.innerModelValue[index], value: newValue2, options: newOptions });
95
- } else {
96
- newTag = tag.createNewTag({ ...rest, label, value, options: [options] });
97
- }
98
- } else {
99
- newTag = tag.createNewTag({ ...rest, label, value, ...id, ...operator });
100
- }
101
- if (tag.hasTagItem(state, value, label)) {
102
- tag.resetInput(state);
103
- return;
104
- }
105
- dropdown.showDropdown(state, false);
106
- const oldValue = clone.deepClone(state.innerModelValue);
107
- if ((replace || mergeTag) && index >= 0) {
108
- state.innerModelValue.splice(index, 1);
109
- }
110
- state.innerModelValue.push(newTag);
111
- const newValue = state.innerModelValue;
112
- tag.emitChangeModelEvent({ emits, state, newValue, oldValue });
113
- };
114
- const selectInputValue = (val) => {
115
- var _a;
116
- if ((_a = state.propItem) == null ? void 0 : _a.label) {
117
- selectRadioItem({ label: val });
118
- } else {
119
- createTag();
120
- }
121
- };
122
- const selectRadioItem = (item, isPotential = false) => {
123
- dropdown.showDropdown(state, false);
124
- if (isPotential) {
125
- state.prevItem = item;
126
- state.backupPrevItem = item;
127
- }
128
- const { prevItem } = state;
129
- const value = item.value || item.label;
130
- const inputRef = instance.refs.inputRef;
131
- if (!tag.hasTagItem(state, value)) {
132
- const tagLabel = state.propItem.label || item.label;
133
- updateModelValue(prevItem, item, tagLabel, value);
134
- }
135
- inputRef.focus();
136
- };
137
- const hasNotInputValueCreateTag = (propItem, prevItem) => {
138
- if (propItem.label) {
139
- if (!prevItem.options) {
140
- return;
141
- }
142
- const hasTag = props.modelValue.find((item) => item.value === prevItem.options[0].label);
143
- if (!hasTag) {
144
- const label = prevItem.label;
145
- const value = prevItem.options && prevItem.options[0].label;
146
- updateModelValue(prevItem, prevItem.options[0], label, value);
147
- return;
148
- }
149
- } else {
150
- emits("search", state.innerModelValue);
151
- }
152
- };
153
- const newTagUpdateModelValue = (prevItem, propItem, tag2) => {
154
- var _a;
155
- const item = (_a = state.backupList) == null ? void 0 : _a.find((subItem) => subItem.label === tag2);
156
- updateModelValue(prevItem, item, propItem.label, tag2);
157
- };
158
- const hasInputValueCreateTag = (inputValue, propItem, prevItem) => {
159
- var _a, _b;
160
- if (propItem.label) {
161
- const { regexp, replace, type, mergeTag } = prevItem;
162
- const tagList = type !== "checkbox" && replace || type === "checkbox" && mergeTag ? [inputValue] : inputValue.split(props.splitInputValue);
163
- if (regexp) {
164
- for (const tag2 of tagList) {
165
- if (regexp.test(tag2)) {
166
- newTagUpdateModelValue(prevItem, propItem, tag2);
167
- }
168
- }
169
- } else {
170
- for (const tag2 of tagList) {
171
- newTagUpdateModelValue(prevItem, propItem, tag2);
172
- }
173
- }
174
- } else {
175
- const { items, defaultField } = props;
176
- const currentItem = items.find((item) => {
177
- const { regexp } = item;
178
- return regexp && regexp.test(state.inputValue);
179
- }) || (defaultField ? items.find((item) => item.field === defaultField) : state.allTypeAttri);
180
- const { replace, type, mergeTag } = currentItem;
181
- const tagList = type !== "checkbox" && replace || type === "checkbox" && mergeTag ? [inputValue] : inputValue.split(props.splitInputValue);
182
- if ((_a = currentItem == null ? void 0 : currentItem.options) == null ? void 0 : _a.length) {
183
- state.backupList = [...currentItem.options];
184
- (_b = state.backupList) == null ? void 0 : _b.forEach((item) => {
185
- const label2 = item.value || item.label;
186
- if (tagList.includes(label2)) {
187
- item.isChecked = true;
188
- }
189
- });
190
- }
191
- const label = currentItem.label;
192
- for (const tag2 of tagList) {
193
- updateModelValue(currentItem, {}, label, tag2);
194
- }
195
- }
196
- };
197
- const createTag = () => {
198
- const { inputValue, propItem, prevItem } = state;
199
- dropdown.showDropdown(state, false);
200
- if (!inputValue) {
201
- hasNotInputValueCreateTag(propItem, prevItem);
202
- } else {
203
- const { maxlength } = props;
204
- if (maxlength && maxlength < inputValue.length) {
205
- emits("exceed", maxlength);
206
- return;
207
- }
208
- hasInputValueCreateTag(inputValue, propItem, prevItem);
209
- }
210
- };
211
- const helpClick = () => {
212
- emits("help");
213
- };
214
- return { selectPropItem, selectRadioItem, selectInputValue, createTag, helpClick, setOperator };
215
- }
216
- exports.useDropdown = useDropdown;
@@ -1,108 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tag = require("../utils/tag.cjs.js");
4
- const validate = require("../utils/validate.cjs.js");
5
- const dropdown = require("../utils/dropdown.cjs.js");
6
- function useEdit({ props, state, t, nextTick, format, emits }) {
7
- const { instance } = state;
8
- const setDropdownProps = (curTag) => {
9
- var _a;
10
- const { operator, value, start, end } = curTag;
11
- const { options, operators, type, mergeTag } = state.prevItem;
12
- if (type === "custom") {
13
- return;
14
- } else if (type === "numRange") {
15
- validate.setStateNumRange(state, curTag, t);
16
- } else if (type === "dateRange") {
17
- const { dateRangeFormat } = state;
18
- state.startDate = format(start, dateRangeFormat);
19
- state.endDate = format(end, dateRangeFormat);
20
- } else if (type === "datetimeRange") {
21
- const { datetimeRangeFormat } = state;
22
- state.startDateTime = format(start, datetimeRangeFormat);
23
- state.endDateTime = format(end, datetimeRangeFormat);
24
- } else {
25
- if (mergeTag) {
26
- state.inputEditValue = (_a = curTag.options) == null ? void 0 : _a.flatMap((item) => item.label);
27
- state.currentEditSelectTags = state.inputEditValue;
28
- } else {
29
- state.inputEditValue = value;
30
- }
31
- state.currentEditValue = options;
32
- }
33
- state.operatorValue = operator;
34
- state.currentOperators = operators;
35
- };
36
- const editTag = (tag2, index, e) => {
37
- if (!props.editable || tag2.type && tag2.type === "map") {
38
- return;
39
- }
40
- dropdown.showDropdown(state, false);
41
- state.popoverVisible = false;
42
- const dom = e.target.classList.contains("tiny-tag") ? e.target : e.srcElement.parentElement;
43
- nextTick(() => {
44
- const { popoverRef } = instance.refs;
45
- popoverRef.state.referenceElm = dom;
46
- popoverRef.state.popperElm && (popoverRef.state.popperElm.style.display = "none");
47
- popoverRef.doDestroy();
48
- state.popoverVisible = true;
49
- });
50
- state.prevItem = state.recordItems.find((item) => item.field === tag2.field);
51
- !state.prevItem && (state.prevItem = tag2);
52
- state.selectValue = tag2.label;
53
- state.currentModelValueIndex = index;
54
- emits("tagClick", tag2);
55
- setDropdownProps(tag2);
56
- };
57
- const selectPropChange = (item, disabled) => {
58
- if (disabled) return;
59
- state.prevItem = item;
60
- setDropdownProps(item);
61
- };
62
- const confirmEditTag = async (isConfirm) => {
63
- if (!isConfirm) {
64
- state.popoverVisible = false;
65
- return;
66
- }
67
- const { prevItem, currentModelValueIndex: index } = state;
68
- let newTag = null;
69
- if (prevItem.type === "numRange") {
70
- newTag = await validate.getVerifyNumTag(instance, state, props);
71
- } else if (prevItem.type === "dateRange") {
72
- newTag = await validate.getVerifyDateTag(instance, state, props, false);
73
- } else if (prevItem.type === "datetimeRange") {
74
- newTag = await validate.getVerifyDateTag(instance, state, props, true);
75
- } else {
76
- newTag = await validate.getVerifyTag(instance, state, props);
77
- }
78
- if (newTag) {
79
- dropdown.showDropdown(state, false);
80
- state.popoverVisible = false;
81
- tag.emitChangeModelEvent({ emits, state, index, newTag, isEdit: true });
82
- } else {
83
- state.popoverVisible = true;
84
- }
85
- state.currentEditValue = [];
86
- };
87
- const selectItemIsDisable = (item) => {
88
- var _a, _b, _c, _d;
89
- if (item.type && item.type === "map") {
90
- return true;
91
- }
92
- if (((_a = state.prevItem) == null ? void 0 : _a.operators) || item.operators) {
93
- return ((_b = state.prevItem.operators) == null ? void 0 : _b.length) !== ((_c = item.operators) == null ? void 0 : _c.length);
94
- }
95
- const typeArr = ["radio", "checkbox"];
96
- if (state.prevItem.type && typeArr.includes(state.prevItem.type)) {
97
- return !item.type ? false : !typeArr.includes(item.type);
98
- }
99
- return ((_d = state.prevItem) == null ? void 0 : _d.type) !== item.type;
100
- };
101
- return {
102
- editTag,
103
- confirmEditTag,
104
- selectPropChange,
105
- selectItemIsDisable
106
- };
107
- }
108
- exports.useEdit = useEdit;
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const dropdown = require("../utils/dropdown.cjs.js");
4
- const tag = require("../utils/tag.cjs.js");
5
- function useInit({ props, state }) {
6
- const initItems = () => {
7
- state.groupItems = {};
8
- state.recordItems.forEach((item) => {
9
- var _a;
10
- const { groupKey = "0" } = item;
11
- if (state.groupItems[groupKey]) {
12
- state.groupItems[groupKey].push({ ...item });
13
- } else {
14
- state.groupItems[groupKey] = [{ ...item }];
15
- state.matchItems[groupKey] = { attr: [], attrValue: [] };
16
- }
17
- if (state.prevItem && item.field === state.prevItem.field && item !== state.prevItem) {
18
- const { options, type } = item;
19
- state.prevItem = item;
20
- if (options == null ? void 0 : options.length) {
21
- state.backupList = options;
22
- }
23
- if (type === "checkbox") {
24
- state.filterList = state.backupList;
25
- state.checkboxGroup = [];
26
- (_a = state.backupList) == null ? void 0 : _a.forEach((subItem) => {
27
- const { label } = subItem;
28
- if (tag.hasTagItem(state, label)) {
29
- state.checkboxGroup.push(`${item.label}${label}`);
30
- }
31
- subItem.isFilter = false;
32
- });
33
- }
34
- dropdown.showDropdown(state, item.field === state.prevItem.field && item !== state.prevItem);
35
- }
36
- });
37
- };
38
- const handleClick = (e) => {
39
- var _a;
40
- const { backupPrevItem, prevItem } = state;
41
- e.stopPropagation();
42
- if (props.editable) {
43
- state.popoverVisible = false;
44
- state.currentEditValue = [];
45
- if (state.propItem.label && backupPrevItem && backupPrevItem !== prevItem) {
46
- state.prevItem = backupPrevItem;
47
- }
48
- }
49
- if (state.hasBackupList && (((_a = state.backupList) == null ? void 0 : _a.length) === 0 || !state.backupList) && !state.inputValue || props.items.length === 0) {
50
- dropdown.showDropdown(state, false);
51
- } else {
52
- dropdown.showDropdown(state);
53
- }
54
- };
55
- const watchOutsideClick = () => {
56
- if (props.editable) {
57
- dropdown.showPopover(state, false);
58
- }
59
- state.isMouseDown = false;
60
- dropdown.showDropdown(state, false);
61
- };
62
- const watchMouseDown = () => {
63
- state.isMouseDown = true;
64
- };
65
- const watchMouseMove = () => {
66
- if (state.isMouseDown) {
67
- state.isMouseDown = false;
68
- }
69
- };
70
- return {
71
- initItems,
72
- watchOutsideClick,
73
- watchMouseDown,
74
- watchMouseMove,
75
- handleClick
76
- };
77
- }
78
- exports.useInit = useInit;
@@ -1,170 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const vue = require("vue");
4
- const Loading = require("@opentiny/vue-loading");
5
- const index = require("../utils/index.cjs.js");
6
- const tag = require("../utils/tag.cjs.js");
7
- const dropdown = require("../utils/dropdown.cjs.js");
8
- const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9
- const getHighlightMatch = (labelRegex, label) => {
10
- const match = [];
11
- let lastIndex = 0;
12
- let result;
13
- while ((result = labelRegex.exec(label)) !== null) {
14
- const startIndex = result.index;
15
- const endIndex = labelRegex.lastIndex;
16
- if (startIndex > lastIndex) {
17
- match.push(label.slice(lastIndex, startIndex));
18
- }
19
- match.push(label.slice(startIndex, endIndex));
20
- lastIndex = endIndex;
21
- }
22
- if (lastIndex < label.length) {
23
- match.push(label.slice(lastIndex));
24
- }
25
- return match;
26
- };
27
- function useMatch({ props, state, emits }) {
28
- const loadingInstance = vue.ref(null);
29
- const getMatchList = async (keyword) => {
30
- if (typeof document !== "undefined") {
31
- !loadingInstance.value && (loadingInstance.value = Loading.service({
32
- target: document.getElementById("potential-loading")
33
- }));
34
- }
35
- state.potentialOptions = await props.potentialOptions.getMatchList(keyword);
36
- loadingInstance.value && loadingInstance.value.close();
37
- dropdown.showDropdown(state, true);
38
- };
39
- const handleSearch = (e) => {
40
- var _a, _b, _c;
41
- const { recordItems, propItem } = state;
42
- const inputValue = e.target.value.trim();
43
- const { maxlength } = props;
44
- if (maxlength && maxlength < inputValue.length) {
45
- emits("exceed", maxlength);
46
- return;
47
- }
48
- if (inputValue.length === 0) {
49
- dropdown.showDropdown(state);
50
- return;
51
- }
52
- Object.keys(state.matchItems).forEach((key) => {
53
- state.matchItems[key].attr = [];
54
- state.matchItems[key].attrValue = [];
55
- });
56
- const value = escapeRegExp(inputValue);
57
- const patt = new RegExp(value, "i");
58
- const hasItem = propItem.label || !value ? null : recordItems.find((item) => item.type === "map" && patt.test(item.label));
59
- if (hasItem) {
60
- state.propItem.label = hasItem.label;
61
- state.inputValue = "";
62
- state.prevItem = hasItem;
63
- state.backupPrevItem = hasItem;
64
- state.backupList = hasItem.options || [];
65
- return;
66
- }
67
- state.filterList = (_a = state.backupList) == null ? void 0 : _a.filter((item) => {
68
- if (patt.test(item.label)) {
69
- delete item.isFilter;
70
- if (tag.hasTagItem(state, item.label)) {
71
- state.checkboxGroup.push(`${state.prevItem.label}${item.label}`);
72
- }
73
- return true;
74
- } else {
75
- item.isFilter = true;
76
- return false;
77
- }
78
- });
79
- const labelRegex = new RegExp(value, "ig");
80
- const hightlighStr = inputValue.toLowerCase();
81
- if (state.propItem.label) {
82
- (_b = state.backupList) == null ? void 0 : _b.forEach((item) => {
83
- item.hightlighStr = hightlighStr;
84
- const itemLabel = item.label;
85
- if (patt.test(itemLabel)) {
86
- item.match = getHighlightMatch(labelRegex, itemLabel);
87
- item.isFilter = false;
88
- } else {
89
- item.isFilter = true;
90
- }
91
- });
92
- if (((_c = state.backupList) == null ? void 0 : _c.length) || inputValue) {
93
- dropdown.showDropdown(state);
94
- } else {
95
- dropdown.showDropdown(state, false);
96
- }
97
- return;
98
- }
99
- for (const item of recordItems) {
100
- const { options = [], groupKey = "0", ...rest } = item;
101
- const itemLabel = rest.label;
102
- if (patt.test(itemLabel)) {
103
- const match = getHighlightMatch(labelRegex, itemLabel);
104
- state.matchItems[groupKey].attr.push({ ...item, match, hightlighStr });
105
- }
106
- for (const option of options) {
107
- const optionLabel = state.propItem.label ? itemLabel : `${itemLabel}:${option.label}`;
108
- if (patt.test(optionLabel)) {
109
- const match = getHighlightMatch(labelRegex, optionLabel);
110
- state.matchItems[groupKey].attrValue.push({
111
- ...option,
112
- ...rest,
113
- options,
114
- hightlighStr,
115
- value: option.label,
116
- match
117
- });
118
- }
119
- }
120
- }
121
- if (value && props.potentialOptions && props.potentialOptions.getMatchList) {
122
- getMatchList(value);
123
- } else {
124
- dropdown.showDropdown(state);
125
- }
126
- };
127
- const handleInput = index.debounce(handleSearch, 500);
128
- const resetBackupList = () => {
129
- var _a;
130
- (_a = state.backupList) == null ? void 0 : _a.forEach((item) => item.isFilter && delete item.isFilter);
131
- };
132
- const selectFirstMap = (item, isFirst) => {
133
- var _a;
134
- const { options } = item;
135
- const { prevItem, propItem } = state;
136
- if (options) {
137
- dropdown.showDropdown(state, false);
138
- state.propItem.value = `${item.label}=`;
139
- state.isShowTagKey = false;
140
- state.inputValue = "";
141
- state.backupList = item.options || [];
142
- resetBackupList();
143
- (_a = state.backupList) == null ? void 0 : _a.forEach((subItem) => {
144
- const value = propItem.value + subItem.label;
145
- subItem.isChecked = tag.hasTagItem(state, value);
146
- });
147
- } else {
148
- if (item.isChecked) {
149
- return;
150
- }
151
- dropdown.showDropdown(state, false);
152
- state.isShowTagKey = true;
153
- resetBackupList();
154
- const { field, type } = prevItem;
155
- const value = propItem.value + item.label;
156
- const id = tag.getTagId(props, prevItem, item);
157
- const newTag = tag.createNewTag({ type, field, label: propItem.label, value, ...id });
158
- const tagList = [newTag];
159
- tag.emitChangeModelEvent({ emits, state, tagList });
160
- }
161
- if (isFirst) {
162
- dropdown.showDropdown(state);
163
- }
164
- };
165
- return {
166
- handleInput,
167
- selectFirstMap
168
- };
169
- }
170
- exports.useMatch = useMatch;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const dropdown = require("../utils/dropdown.cjs.js");
4
- const validate = require("../utils/validate.cjs.js");
5
- const tag = require("../utils/tag.cjs.js");
6
- function useNumRange({ props, state, t, emits }) {
7
- const { instance } = state;
8
- const sizeChange = async (confirm) => {
9
- if (!confirm) {
10
- state.propItem.label = "";
11
- return;
12
- }
13
- const newTag = await validate.getVerifyNumTag(instance, state, props);
14
- if (newTag) {
15
- dropdown.showDropdown(state, false);
16
- const newValue = props.modelValue.filter((prev) => prev.type !== newTag.type || prev.field !== newTag.field);
17
- newValue.push(newTag);
18
- tag.emitChangeModelEvent({ emits, state, newValue });
19
- } else {
20
- dropdown.showDropdown(state);
21
- }
22
- };
23
- const createDateRules = (item, startKey, endKey) => {
24
- const { maxTimeLength = 0 } = item;
25
- return {
26
- [startKey]: {
27
- validator: (rule, value, cb) => {
28
- if (maxTimeLength > 0 && !value) {
29
- cb(new Error(t("tvp.tvpSearchbox.notBeNull")));
30
- } else if (!value && !state[endKey]) {
31
- cb(new Error(t("tvp.tvpSearchbox.rangeDateTitle")));
32
- } else {
33
- cb();
34
- }
35
- }
36
- },
37
- [endKey]: {
38
- validator: (rule, value, cb) => {
39
- if (maxTimeLength > 0 && !value) {
40
- cb(new Error(t("tvp.tvpSearchbox.notBeNull")));
41
- } else if (!value && !state[startKey]) {
42
- cb(new Error(t("tvp.tvpSearchbox.rangeDateTitle")));
43
- } else {
44
- cb();
45
- }
46
- }
47
- }
48
- };
49
- };
50
- const initFormRule = () => {
51
- let dateRules = {}, datetimeRules = {};
52
- props.items.forEach((item) => {
53
- if (item.type === "dateRange") {
54
- dateRules = createDateRules(item, "startDate", "endDate");
55
- }
56
- if (item.type === "datetimeRange") {
57
- datetimeRules = createDateRules(item, "startDateTime", "endDateTime");
58
- }
59
- });
60
- state.formRules = {
61
- ...dateRules,
62
- ...datetimeRules
63
- };
64
- if (props.editable) {
65
- state.formRules.inputEditValue = {
66
- required: true,
67
- message: t("tvp.tvpSearchbox.notBeNull"),
68
- trigger: ["change", "blur"]
69
- };
70
- }
71
- };
72
- return {
73
- initFormRule,
74
- sizeChange
75
- };
76
- }
77
- exports.useNumRange = useNumRange;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const vue = require("vue");
4
- function usePlaceholder({ props, state, t }) {
5
- const placeholder = vue.ref(props.emptyPlaceholder);
6
- const setPlaceholder = (placeholderValue) => {
7
- placeholder.value = placeholderValue;
8
- };
9
- if (props.modelValue.length > 0) {
10
- setPlaceholder(t("tvp.tvpSearchbox.addPlaceholder"));
11
- }
12
- vue.watch(
13
- () => state.propItem.label,
14
- (newValue) => {
15
- var _a;
16
- if (newValue) {
17
- const { placeholder: placeholder2, type } = state.prevItem;
18
- if (placeholder2) {
19
- setPlaceholder(placeholder2);
20
- } else if (type === "map") {
21
- setPlaceholder(t("tvp.tvpSearchbox.tagPlaceholder"));
22
- } else if ((_a = state.backupList) == null ? void 0 : _a.length) {
23
- setPlaceholder(t("tvp.tvpSearchbox.dynamicPlaceholder", { newValue }));
24
- } else {
25
- setPlaceholder(t("tvp.tvpSearchbox.addPlaceholder"));
26
- }
27
- } else {
28
- if (props.modelValue.length > 0) {
29
- setPlaceholder(t("tvp.tvpSearchbox.addPlaceholder"));
30
- } else {
31
- setPlaceholder(props.emptyPlaceholder);
32
- }
33
- }
34
- }
35
- );
36
- return {
37
- placeholder,
38
- setPlaceholder
39
- };
40
- }
41
- exports.usePlaceholder = usePlaceholder;