@opentiny/vue-search-box 0.0.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.
- package/README.md +111 -0
- package/es/composables/use-checkbox.es.js +87 -0
- package/es/composables/use-custom.es.js +48 -0
- package/es/composables/use-datepicker.es.js +86 -0
- package/es/composables/use-dropdown.es.js +207 -0
- package/es/composables/use-edit.es.js +106 -0
- package/es/composables/use-init.es.js +64 -0
- package/es/composables/use-match.es.js +170 -0
- package/es/composables/use-num-range.es.js +77 -0
- package/es/composables/use-placeholder.es.js +41 -0
- package/es/composables/use-tag.es.js +51 -0
- package/es/index-DCPOFFNd.css +337 -0
- package/es/index.es.js +10 -0
- package/es/index.type.es.js +1 -0
- package/es/index.vue.es.js +4 -0
- package/es/index.vue.es2.js +1287 -0
- package/es/smb-theme.es.js +18 -0
- package/es/utils/clone.es.js +29 -0
- package/es/utils/date.es.js +431 -0
- package/es/utils/dropdown.es.js +20 -0
- package/es/utils/en_US.es.js +44 -0
- package/es/utils/index.es.js +13 -0
- package/es/utils/tag.es.js +46 -0
- package/es/utils/type.es.js +4 -0
- package/es/utils/validate.es.js +179 -0
- package/es/utils/zh_CN.es.js +44 -0
- package/index.css +337 -0
- package/lib/composables/use-checkbox.cjs.js +87 -0
- package/lib/composables/use-custom.cjs.js +48 -0
- package/lib/composables/use-datepicker.cjs.js +86 -0
- package/lib/composables/use-dropdown.cjs.js +207 -0
- package/lib/composables/use-edit.cjs.js +106 -0
- package/lib/composables/use-init.cjs.js +64 -0
- package/lib/composables/use-match.cjs.js +170 -0
- package/lib/composables/use-num-range.cjs.js +77 -0
- package/lib/composables/use-placeholder.cjs.js +41 -0
- package/lib/composables/use-tag.cjs.js +51 -0
- package/lib/index-DCPOFFNd.css +337 -0
- package/lib/index.cjs.js +10 -0
- package/lib/index.type.cjs.js +1 -0
- package/lib/index.vue.cjs.js +4 -0
- package/lib/index.vue.cjs2.js +1287 -0
- package/lib/smb-theme.cjs.js +18 -0
- package/lib/utils/clone.cjs.js +29 -0
- package/lib/utils/date.cjs.js +431 -0
- package/lib/utils/dropdown.cjs.js +20 -0
- package/lib/utils/en_US.cjs.js +44 -0
- package/lib/utils/index.cjs.js +13 -0
- package/lib/utils/tag.cjs.js +46 -0
- package/lib/utils/type.cjs.js +4 -0
- package/lib/utils/validate.cjs.js +179 -0
- package/lib/utils/zh_CN.cjs.js +44 -0
- package/package.json +65 -0
- package/types/composables/use-checkbox.d.ts +10 -0
- package/types/composables/use-custom.d.ts +7 -0
- package/types/composables/use-datepicker.d.ts +11 -0
- package/types/composables/use-dropdown.d.ts +13 -0
- package/types/composables/use-edit.d.ts +13 -0
- package/types/composables/use-init.d.ts +10 -0
- package/types/composables/use-match.d.ts +8 -0
- package/types/composables/use-num-range.d.ts +9 -0
- package/types/composables/use-placeholder.d.ts +8 -0
- package/types/composables/use-tag.d.ts +9 -0
- package/types/index.type.d.ts +189 -0
- package/types/smb-theme.d.ts +15 -0
- package/types/utils/clone.d.ts +12 -0
- package/types/utils/date.d.ts +234 -0
- package/types/utils/dropdown.d.ts +12 -0
- package/types/utils/en_US.d.ts +41 -0
- package/types/utils/index.d.ts +1 -0
- package/types/utils/tag.d.ts +46 -0
- package/types/utils/type.d.ts +6 -0
- package/types/utils/validate.d.ts +31 -0
- package/types/utils/zh_CN.d.ts +41 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { getTagId, createNewTag } from "./tag.es.js";
|
|
2
|
+
import { isNumber } from "./type.es.js";
|
|
3
|
+
import { omitObj } from "./clone.es.js";
|
|
4
|
+
const getVerifyTag = async (instance, state, props) => {
|
|
5
|
+
const { prevItem, inputEditValue } = state;
|
|
6
|
+
const { operators } = prevItem;
|
|
7
|
+
const rest = omitObj(prevItem);
|
|
8
|
+
let newTag = null;
|
|
9
|
+
let isPass = true;
|
|
10
|
+
await instance.refs.formRef.validateField(["inputEditValue"], (errMsg) => {
|
|
11
|
+
if (errMsg) {
|
|
12
|
+
isPass = false;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (isPass) {
|
|
16
|
+
let id = null;
|
|
17
|
+
const operator = state.operatorValue && operators ? { operator: state.operatorValue } : null;
|
|
18
|
+
let value = inputEditValue;
|
|
19
|
+
const otherAttr = {};
|
|
20
|
+
if (Array.isArray(inputEditValue)) {
|
|
21
|
+
otherAttr.options = [];
|
|
22
|
+
value = "";
|
|
23
|
+
inputEditValue.forEach((editValue) => {
|
|
24
|
+
const item = state.currentEditValue.find((item2) => item2.label === editValue);
|
|
25
|
+
const label = (item == null ? void 0 : item.label) || editValue;
|
|
26
|
+
value = !value ? label : `${value} | ${label}`;
|
|
27
|
+
if (item) {
|
|
28
|
+
const itemId = getTagId(props, prevItem, item);
|
|
29
|
+
otherAttr.options.push({ label, ...itemId });
|
|
30
|
+
} else {
|
|
31
|
+
otherAttr.options.push({ label });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
} else if (Array.isArray(state.currentEditValue)) {
|
|
35
|
+
const item = state.currentEditValue.find((item2) => item2.label === value);
|
|
36
|
+
id = getTagId(props, prevItem, item);
|
|
37
|
+
}
|
|
38
|
+
newTag = createNewTag({ ...rest, label: state.selectValue, ...operator, value, ...id, ...otherAttr });
|
|
39
|
+
}
|
|
40
|
+
return newTag;
|
|
41
|
+
};
|
|
42
|
+
const getVerifyNumTag = async (instance, state, props) => {
|
|
43
|
+
const { prevItem } = state;
|
|
44
|
+
const minNum = `min${prevItem.field}`;
|
|
45
|
+
const maxNum = `max${prevItem.field}`;
|
|
46
|
+
const start = state[minNum];
|
|
47
|
+
const end = state[maxNum];
|
|
48
|
+
const verifyProps = [minNum, maxNum];
|
|
49
|
+
let isPass = true;
|
|
50
|
+
let newTag = null;
|
|
51
|
+
await instance.refs.formRef.validateField(verifyProps, (errMsg) => {
|
|
52
|
+
if (errMsg) {
|
|
53
|
+
isPass = false;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (isPass) {
|
|
57
|
+
const { field, label: prevLabel, unit, type, operators } = prevItem;
|
|
58
|
+
const label = unit ? `${prevLabel}(${unit})` : prevLabel;
|
|
59
|
+
let value = "";
|
|
60
|
+
if (start && end) {
|
|
61
|
+
value = `${start}-${end}`;
|
|
62
|
+
} else {
|
|
63
|
+
value = start ? `≥${start}` : `≤${end}`;
|
|
64
|
+
}
|
|
65
|
+
const id = getTagId(props, prevItem, prevItem);
|
|
66
|
+
const operator = state.operatorValue && operators ? { operator: state.operatorValue } : null;
|
|
67
|
+
newTag = createNewTag({ type, field, label, value, ...id, start, end, ...operator });
|
|
68
|
+
}
|
|
69
|
+
return newTag;
|
|
70
|
+
};
|
|
71
|
+
const getVerifyDateTag = async (instance, state, props, isDateTimeType) => {
|
|
72
|
+
const { prevItem, startDate, endDate, startDateTime, endDateTime } = state;
|
|
73
|
+
let start = null;
|
|
74
|
+
let end = null;
|
|
75
|
+
let isPass = true;
|
|
76
|
+
let newTag = null;
|
|
77
|
+
let verifyProps = null;
|
|
78
|
+
if (isDateTimeType) {
|
|
79
|
+
start = startDateTime;
|
|
80
|
+
end = endDateTime;
|
|
81
|
+
verifyProps = ["startDateTime", "endDateTime"];
|
|
82
|
+
} else {
|
|
83
|
+
start = startDate;
|
|
84
|
+
end = endDate;
|
|
85
|
+
verifyProps = ["startDate", "endDate"];
|
|
86
|
+
}
|
|
87
|
+
await instance.refs.formRef.validateField(verifyProps, (errMsg) => {
|
|
88
|
+
if (errMsg) {
|
|
89
|
+
isPass = false;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (isPass) {
|
|
93
|
+
const { field, label, type, operators } = prevItem;
|
|
94
|
+
let value = "";
|
|
95
|
+
if (start && end) {
|
|
96
|
+
if (start > end) {
|
|
97
|
+
return;
|
|
98
|
+
} else if (start === end) {
|
|
99
|
+
value = start;
|
|
100
|
+
} else {
|
|
101
|
+
value = `${start}-${end}`;
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
value = start ? `≥${start}` : `≤${end}`;
|
|
105
|
+
}
|
|
106
|
+
const id = getTagId(props, prevItem, prevItem);
|
|
107
|
+
const operator = state.operatorValue && operators ? { operator: state.operatorValue } : null;
|
|
108
|
+
newTag = createNewTag({ type, field, label, value, start, end, ...id, ...operator });
|
|
109
|
+
}
|
|
110
|
+
return newTag;
|
|
111
|
+
};
|
|
112
|
+
const setStateNumRange = (state, item, t) => {
|
|
113
|
+
const { prevItem } = state;
|
|
114
|
+
const { field, start, end, min = prevItem.min, max = prevItem.max } = item;
|
|
115
|
+
const nextMinNum = `min${field}`;
|
|
116
|
+
const nextMaxNum = `max${field}`;
|
|
117
|
+
if (state.curMinNumVar !== nextMinNum || state.curMaxNumVar !== nextMaxNum) {
|
|
118
|
+
delete state[state.curMinNumVar];
|
|
119
|
+
delete state[state.curMaxNumVar];
|
|
120
|
+
delete state.formRules[state.curMinNumVar];
|
|
121
|
+
delete state.formRules[state.curMaxNumVar];
|
|
122
|
+
state.curMinNumVar = nextMinNum;
|
|
123
|
+
state.curMaxNumVar = nextMaxNum;
|
|
124
|
+
}
|
|
125
|
+
state[state.curMinNumVar] = start;
|
|
126
|
+
state[state.curMaxNumVar] = end;
|
|
127
|
+
const { curMinNumVar, curMaxNumVar } = state;
|
|
128
|
+
const minIsNumber = isNumber(min);
|
|
129
|
+
const maxIsNumber = isNumber(max);
|
|
130
|
+
if (minIsNumber || maxIsNumber) {
|
|
131
|
+
state.formRules[curMinNumVar] = {
|
|
132
|
+
validator: (rule, value, cb) => {
|
|
133
|
+
const valueIsNumber = isNumber(value);
|
|
134
|
+
if (!valueIsNumber && isNumber(state[curMaxNumVar]) || valueIsNumber && (minIsNumber && !maxIsNumber && value >= min || !minIsNumber && maxIsNumber && value <= max || value >= min && value <= max)) {
|
|
135
|
+
cb();
|
|
136
|
+
} else {
|
|
137
|
+
state.numberShowMessage = Boolean(value || state[curMaxNumVar]);
|
|
138
|
+
cb(new Error(t("tvp.tvpSearchbox.rangeMinErr", [min, max])));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
state.formRules[curMaxNumVar] = {
|
|
143
|
+
validator: (rule, value, cb) => {
|
|
144
|
+
const MinValueIsNumber = isNumber(state[curMinNumVar]);
|
|
145
|
+
const curMin = MinValueIsNumber && min < state[curMinNumVar] ? Number(state[curMinNumVar]) : min;
|
|
146
|
+
const curMinIsNumber = isNumber(curMin);
|
|
147
|
+
const valueIsNumber = isNumber(value);
|
|
148
|
+
if (!valueIsNumber && MinValueIsNumber || valueIsNumber && (curMinIsNumber && !maxIsNumber && value >= curMin || !curMinIsNumber && maxIsNumber && value <= max || value >= curMin && value <= max)) {
|
|
149
|
+
cb();
|
|
150
|
+
} else if (!valueIsNumber && !MinValueIsNumber) {
|
|
151
|
+
cb(new Error(t("tvp.tvpSearchbox.rangeNumberTitle")));
|
|
152
|
+
} else {
|
|
153
|
+
cb(new Error(t("tvp.tvpSearchbox.rangeMaxErr")));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
} else {
|
|
158
|
+
state.formRules[curMaxNumVar] = {
|
|
159
|
+
validator: (rule, value, cb) => {
|
|
160
|
+
const curMin = state[curMinNumVar];
|
|
161
|
+
const valueIsNumber = isNumber(value);
|
|
162
|
+
const curMinIsNumber = isNumber(curMin);
|
|
163
|
+
if (valueIsNumber && !curMinIsNumber || !valueIsNumber && curMinIsNumber || valueIsNumber && curMinIsNumber && value >= Number(curMin)) {
|
|
164
|
+
cb();
|
|
165
|
+
} else if (!valueIsNumber && !curMinIsNumber) {
|
|
166
|
+
cb(new Error(t("tvp.tvpSearchbox.rangeNumberTitle")));
|
|
167
|
+
} else {
|
|
168
|
+
cb(new Error(t("tvp.tvpSearchbox.rangeMaxErr")));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
export {
|
|
175
|
+
getVerifyDateTag,
|
|
176
|
+
getVerifyNumTag,
|
|
177
|
+
getVerifyTag,
|
|
178
|
+
setStateNumRange
|
|
179
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const zhCN = {
|
|
2
|
+
tvp: {
|
|
3
|
+
tvpSearchbox: {
|
|
4
|
+
defaultPlaceholder: "请选择属性筛选,或输入关键字",
|
|
5
|
+
addPlaceholder: "添加筛选条件",
|
|
6
|
+
tagPlaceholder: "请选择标签键/值搜索,或输入“键=值”搜索",
|
|
7
|
+
dynamicPlaceholder: "请选择{newValue}搜索",
|
|
8
|
+
attributeType: "属性类型",
|
|
9
|
+
propertyValue: "{0}的值",
|
|
10
|
+
matched: "潜在匹配项",
|
|
11
|
+
allValues: "所有值",
|
|
12
|
+
allProperty: "全部属性",
|
|
13
|
+
operator: "运算符",
|
|
14
|
+
clearAll: "清空",
|
|
15
|
+
emptyValue: "空 值",
|
|
16
|
+
help: "点击查看帮助",
|
|
17
|
+
switchText: "切换到默认搜索项",
|
|
18
|
+
tagKey: "键",
|
|
19
|
+
tagValue: "值",
|
|
20
|
+
minValueText: "最小值",
|
|
21
|
+
maxValueText: "最大值",
|
|
22
|
+
rangeMinArr: "输入值必须在{0}~{1}之间",
|
|
23
|
+
rangeMaxArr: "最大值必须大于等于最小值,或者为空",
|
|
24
|
+
rangeNumberTitle: "请至少输入一个值",
|
|
25
|
+
rangeDateTitle: "请至少输入一个日期",
|
|
26
|
+
timeLengthTitle: "可选时间跨度为{value}天内",
|
|
27
|
+
rangeBeginLabel: "开始日期",
|
|
28
|
+
rangeEndLabel: "结束日期",
|
|
29
|
+
rulekeyword1: "关键字",
|
|
30
|
+
notBeNull: "值不能为空",
|
|
31
|
+
noData: "暂无匹配数据...",
|
|
32
|
+
selectAll: "全选",
|
|
33
|
+
confirm: "确定",
|
|
34
|
+
cancel: "取消",
|
|
35
|
+
equal: "等于",
|
|
36
|
+
notEqual: "不等于",
|
|
37
|
+
contain: "包含",
|
|
38
|
+
notContain: "不包含"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
zhCN
|
|
44
|
+
};
|
package/index.css
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
.tvp-search-box__dropdown-menu,
|
|
2
|
+
.tvp-search-box__popover {
|
|
3
|
+
--tvp-SearchBox-bg-color: var(--tv-color-bg-secondary, #ffffff);
|
|
4
|
+
--tvp-SearchBox-border-color: var(--tv-color-bg-control-unactive, #c2c2c2);
|
|
5
|
+
--tvp-SearchBox-focus-border-color: var(--tv-color-bg-active-primary, #191919);
|
|
6
|
+
--tvp-SearchBox-border-radius: var(--tv-border-radius-md, 6px);
|
|
7
|
+
--tvp-SearchBox-tag-hover-text-color: var(--tv-color-icon-hover, #191919);
|
|
8
|
+
--tvp-SearchBox-tag-hover-fill-color: var(--tvp-SearchBox-tag-hover-text-color);
|
|
9
|
+
--tvp-SearchBox-dropdown-header-text-color: var(--tv-color-text-weaken, #808080);
|
|
10
|
+
--tvp-SearchBox-search-filter-text-color: var(--tv-color-info-text-primary, #191919);
|
|
11
|
+
--tvp-SearchBox-close-icon-margin-right: var(--tv-space-sm, 4px);
|
|
12
|
+
--tvp-SearchBox-separator-icon-margin-right: var(--tv-space-sm, 4px);
|
|
13
|
+
--tvp-SearchBox-right-icon-color: var(--tv-color-icon, #808080);
|
|
14
|
+
--tvp-SearchBox-right-icon-color-hover: var(--tv-color-icon-hover, #191919);
|
|
15
|
+
--tvp-SearchBox-left-icon-font-size: var(--tv-font-size-heading-xs, 16px);
|
|
16
|
+
--tvp-SearchBox-min-height: var(--tv-size-height-md, 32px);
|
|
17
|
+
--tvp-SearchBox-padding-left: var(--tv-size-height-md, 32px);
|
|
18
|
+
--tvp-SearchBox-dropdown-keyword-text-color: var(--tv-color-act-info-text-active, #1476ff);
|
|
19
|
+
--tvp-SearchBox-dropdown-btn-group-border-color: var(--tv-color-bg-header, #f0f0f0);
|
|
20
|
+
--tvp-SearchBox-dropdown-btn-group-margin-top: var(--tv-space-md, 8px);
|
|
21
|
+
--tvp-SearchBox-dropdown-btn-group-padding-top: var(--tv-space-xl, 16px);
|
|
22
|
+
--tvp-SearchBox-dropdown-btn-group-padding-bottom: var(--tv-space-md, 8px);
|
|
23
|
+
--tvp-SearchBox-dropdown-num-title-text-color: var(--tv-color-text-weaken, #808080);
|
|
24
|
+
--tvp-SearchBox-tag-margin-right: var(--tv-space-sm, 4px);
|
|
25
|
+
--tvp-SearchBox-place-padding-right: var(--tv-space-sm, 4px);
|
|
26
|
+
--tvp-SearchBox-tag-bottom-border-color: var(--tv-color-act-primary-text-active, #191919);
|
|
27
|
+
--tvp-SearchBox-tag-font-size: var(--tv-font-size-md, 14px);
|
|
28
|
+
--tvp-SearchBox-dropdown-desc-font-size: var(--tv-font-size-md, 14px);
|
|
29
|
+
--tvp-SearchBox-dropdown-desc-text-color: var(--tv-color-info-text-primary, #191919);
|
|
30
|
+
width: 232px;
|
|
31
|
+
overflow: auto;
|
|
32
|
+
}
|
|
33
|
+
.tvp-search-box__dropdown-menu .tiny-form-item.is-error .tvp-search-box-select .tiny-select__tags-group,
|
|
34
|
+
.tvp-search-box__popover .tiny-form-item.is-error .tvp-search-box-select .tiny-select__tags-group {
|
|
35
|
+
border-color: #f23030;
|
|
36
|
+
}
|
|
37
|
+
.tvp-search-box__dropdown-menu .tvp-search-box-select .tiny-select .tiny-svg,
|
|
38
|
+
.tvp-search-box__popover .tvp-search-box-select .tiny-select .tiny-svg {
|
|
39
|
+
z-index: 1000;
|
|
40
|
+
}
|
|
41
|
+
.tvp-search-box__dropdown-menu .tvp-search-box-select .tiny-select__tags-group,
|
|
42
|
+
.tvp-search-box__popover .tvp-search-box-select .tiny-select__tags-group {
|
|
43
|
+
min-height: 32px;
|
|
44
|
+
max-height: 82px;
|
|
45
|
+
padding: 2px;
|
|
46
|
+
width: 100%;
|
|
47
|
+
border: 1px solid #c2c2c2;
|
|
48
|
+
border-radius: 6px;
|
|
49
|
+
}
|
|
50
|
+
.tvp-search-box__dropdown-menu .tvp-search-box-select .tiny-select__tags.is-show-tag,
|
|
51
|
+
.tvp-search-box__popover .tvp-search-box-select .tiny-select__tags.is-show-tag {
|
|
52
|
+
max-width: 276px !important;
|
|
53
|
+
width: calc(100% - 8px) !important;
|
|
54
|
+
min-height: 30px;
|
|
55
|
+
padding-right: 20px;
|
|
56
|
+
max-height: 76px;
|
|
57
|
+
overflow: auto;
|
|
58
|
+
}
|
|
59
|
+
.tvp-search-box__dropdown-menu .tvp-search-box-select .tiny-input__suffix,
|
|
60
|
+
.tvp-search-box__popover .tvp-search-box-select .tiny-input__suffix {
|
|
61
|
+
z-index: 1000;
|
|
62
|
+
}
|
|
63
|
+
.tvp-search-box__dropdown-menu .tvp-search-box-select .tiny-input__inner,
|
|
64
|
+
.tvp-search-box__popover .tvp-search-box-select .tiny-input__inner {
|
|
65
|
+
border: 0px;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
}
|
|
68
|
+
.tvp-search-box__dropdown-menu input[type='number'],
|
|
69
|
+
.tvp-search-box__popover input[type='number'] {
|
|
70
|
+
-moz-appearance: textfield;
|
|
71
|
+
/* Firefox */
|
|
72
|
+
appearance: textfield;
|
|
73
|
+
}
|
|
74
|
+
.tvp-search-box__dropdown-menu input[type='number']::-webkit-inner-spin-button,
|
|
75
|
+
.tvp-search-box__popover input[type='number']::-webkit-inner-spin-button,
|
|
76
|
+
.tvp-search-box__dropdown-menu input[type='number']::-webkit-outer-spin-button,
|
|
77
|
+
.tvp-search-box__popover input[type='number']::-webkit-outer-spin-button {
|
|
78
|
+
-webkit-appearance: none;
|
|
79
|
+
/* Safari */
|
|
80
|
+
margin: 0;
|
|
81
|
+
}
|
|
82
|
+
.tvp-search-box__popover.tiny-popover[x-placement^='bottom'] {
|
|
83
|
+
margin-top: 0;
|
|
84
|
+
}
|
|
85
|
+
.tvp-search-box {
|
|
86
|
+
--tvp-SearchBox-bg-color: var(--tv-color-bg-secondary, #ffffff);
|
|
87
|
+
--tvp-SearchBox-border-color: var(--tv-color-bg-control-unactive, #c2c2c2);
|
|
88
|
+
--tvp-SearchBox-focus-border-color: var(--tv-color-bg-active-primary, #191919);
|
|
89
|
+
--tvp-SearchBox-border-radius: var(--tv-border-radius-md, 6px);
|
|
90
|
+
--tvp-SearchBox-tag-hover-text-color: var(--tv-color-icon-hover, #191919);
|
|
91
|
+
--tvp-SearchBox-tag-hover-fill-color: var(--tvp-SearchBox-tag-hover-text-color);
|
|
92
|
+
--tvp-SearchBox-dropdown-header-text-color: var(--tv-color-text-weaken, #808080);
|
|
93
|
+
--tvp-SearchBox-search-filter-text-color: var(--tv-color-info-text-primary, #191919);
|
|
94
|
+
--tvp-SearchBox-close-icon-margin-right: var(--tv-space-sm, 4px);
|
|
95
|
+
--tvp-SearchBox-separator-icon-margin-right: var(--tv-space-sm, 4px);
|
|
96
|
+
--tvp-SearchBox-right-icon-color: var(--tv-color-icon, #808080);
|
|
97
|
+
--tvp-SearchBox-right-icon-color-hover: var(--tv-color-icon-hover, #191919);
|
|
98
|
+
--tvp-SearchBox-left-icon-font-size: var(--tv-font-size-heading-xs, 16px);
|
|
99
|
+
--tvp-SearchBox-min-height: var(--tv-size-height-md, 32px);
|
|
100
|
+
--tvp-SearchBox-padding-left: var(--tv-size-height-md, 32px);
|
|
101
|
+
--tvp-SearchBox-dropdown-keyword-text-color: var(--tv-color-act-info-text-active, #1476ff);
|
|
102
|
+
--tvp-SearchBox-dropdown-btn-group-border-color: var(--tv-color-bg-header, #f0f0f0);
|
|
103
|
+
--tvp-SearchBox-dropdown-btn-group-margin-top: var(--tv-space-md, 8px);
|
|
104
|
+
--tvp-SearchBox-dropdown-btn-group-padding-top: var(--tv-space-xl, 16px);
|
|
105
|
+
--tvp-SearchBox-dropdown-btn-group-padding-bottom: var(--tv-space-md, 8px);
|
|
106
|
+
--tvp-SearchBox-dropdown-num-title-text-color: var(--tv-color-text-weaken, #808080);
|
|
107
|
+
--tvp-SearchBox-tag-margin-right: var(--tv-space-sm, 4px);
|
|
108
|
+
--tvp-SearchBox-place-padding-right: var(--tv-space-sm, 4px);
|
|
109
|
+
--tvp-SearchBox-tag-bottom-border-color: var(--tv-color-act-primary-text-active, #191919);
|
|
110
|
+
--tvp-SearchBox-tag-font-size: var(--tv-font-size-md, 14px);
|
|
111
|
+
--tvp-SearchBox-dropdown-desc-font-size: var(--tv-font-size-md, 14px);
|
|
112
|
+
--tvp-SearchBox-dropdown-desc-text-color: var(--tv-color-info-text-primary, #191919);
|
|
113
|
+
display: flex;
|
|
114
|
+
position: relative;
|
|
115
|
+
flex-wrap: wrap;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: flex-start;
|
|
118
|
+
border: 1px solid var(--tvp-SearchBox-border-color);
|
|
119
|
+
border-radius: var(--tvp-SearchBox-border-radius);
|
|
120
|
+
min-height: var(--tvp-SearchBox-min-height);
|
|
121
|
+
padding-left: var(--tvp-SearchBox-padding-left);
|
|
122
|
+
background-color: var(--tvp-SearchBox-bg-color);
|
|
123
|
+
}
|
|
124
|
+
.tvp-search-box__form {
|
|
125
|
+
width: auto;
|
|
126
|
+
flex: 1;
|
|
127
|
+
min-width: 200px;
|
|
128
|
+
}
|
|
129
|
+
.tvp-search-box__form-popover {
|
|
130
|
+
position: absolute;
|
|
131
|
+
}
|
|
132
|
+
.tvp-search-box:focus-within {
|
|
133
|
+
border-color: var(--tvp-SearchBox-focus-border-color);
|
|
134
|
+
}
|
|
135
|
+
.tvp-search-box > .tvp-search-box__prefix {
|
|
136
|
+
position: absolute;
|
|
137
|
+
top: calc((var(--tvp-SearchBox-min-height) - var(--tvp-SearchBox-left-icon-font-size)) / 2 - 1px);
|
|
138
|
+
left: 12px;
|
|
139
|
+
display: inline;
|
|
140
|
+
font-size: var(--tvp-SearchBox-left-icon-font-size);
|
|
141
|
+
fill: #808080;
|
|
142
|
+
}
|
|
143
|
+
.tvp-search-box__text-highlight {
|
|
144
|
+
color: var(--tvp-SearchBox-dropdown-keyword-text-color);
|
|
145
|
+
}
|
|
146
|
+
.tvp-search-box__placeholder {
|
|
147
|
+
padding-right: var(--tvp-SearchBox-place-padding-right);
|
|
148
|
+
}
|
|
149
|
+
.tvp-search-box__tag {
|
|
150
|
+
margin: 1px var(--tvp-SearchBox-tag-margin-right) 1px 0;
|
|
151
|
+
max-width: 100%;
|
|
152
|
+
}
|
|
153
|
+
.tvp-search-box__tag > .tvp-search-box__tag-value {
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
text-overflow: ellipsis;
|
|
156
|
+
}
|
|
157
|
+
.tvp-search-box__tag:hover {
|
|
158
|
+
cursor: pointer;
|
|
159
|
+
color: var(--tvp-SearchBox-tag-hover-text-color);
|
|
160
|
+
fill: var(--tvp-SearchBox-tag-hover-fill-color);
|
|
161
|
+
}
|
|
162
|
+
.tvp-search-box__tag-editor span {
|
|
163
|
+
border-bottom: 1px dashed var(--tvp-SearchBox-tag-bottom-border-color);
|
|
164
|
+
line-height: 1;
|
|
165
|
+
}
|
|
166
|
+
.tvp-search-box__input .tiny-input-display-only {
|
|
167
|
+
width: calc(100% - var(--tv-Input-suffix-right) - 63px);
|
|
168
|
+
}
|
|
169
|
+
.tvp-search-box__input .tiny-svg {
|
|
170
|
+
margin-left: 0;
|
|
171
|
+
}
|
|
172
|
+
.tvp-search-box__input-close {
|
|
173
|
+
margin-right: var(--tvp-SearchBox-close-icon-margin-right);
|
|
174
|
+
}
|
|
175
|
+
.tvp-search-box__input-separator {
|
|
176
|
+
display: inline-block;
|
|
177
|
+
margin-right: var(--tvp-SearchBox-separator-icon-margin-right);
|
|
178
|
+
height: 14px;
|
|
179
|
+
width: 1px;
|
|
180
|
+
background-color: #dfe1e6;
|
|
181
|
+
}
|
|
182
|
+
.tvp-search-box__input-help {
|
|
183
|
+
margin-right: 0px;
|
|
184
|
+
}
|
|
185
|
+
.tvp-search-box__input .tvp-search-box__input-search {
|
|
186
|
+
display: none;
|
|
187
|
+
margin-right: 2px;
|
|
188
|
+
}
|
|
189
|
+
.tvp-search-box__input-wrapper {
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
192
|
+
width: 100%;
|
|
193
|
+
}
|
|
194
|
+
.tvp-search-box .tvp-search-box__dropdown:not(.is-disabled) .tvp-search-box__input:not(.is-disabled) .tiny-input__suffix .tiny-svg {
|
|
195
|
+
font-size: 16px;
|
|
196
|
+
margin-top: 0;
|
|
197
|
+
fill: var(--tvp-SearchBox-right-icon-color);
|
|
198
|
+
}
|
|
199
|
+
.tvp-search-box .tvp-search-box__dropdown:not(.is-disabled) .tvp-search-box__input:not(.is-disabled) .tiny-input__suffix .tiny-svg:hover {
|
|
200
|
+
fill: var(--tvp-SearchBox-right-icon-color-hover);
|
|
201
|
+
}
|
|
202
|
+
.tvp-search-box .tvp-search-box__dropdown:not(.is-disabled) .tvp-search-box__input:not(.is-disabled) .tiny-input__suffix-inner {
|
|
203
|
+
display: flex;
|
|
204
|
+
align-items: center;
|
|
205
|
+
}
|
|
206
|
+
.tvp-search-box__prop {
|
|
207
|
+
white-space: nowrap;
|
|
208
|
+
vertical-align: middle;
|
|
209
|
+
font-size: var(--tvp-SearchBox-tag-font-size);
|
|
210
|
+
}
|
|
211
|
+
.tvp-search-box__prop span {
|
|
212
|
+
padding-left: 8px;
|
|
213
|
+
}
|
|
214
|
+
.tvp-search-box .tiny-dropdown__trigger {
|
|
215
|
+
display: block;
|
|
216
|
+
}
|
|
217
|
+
.tvp-search-box .tiny-dropdown__trigger .tiny-dropdown__title {
|
|
218
|
+
width: 100%;
|
|
219
|
+
}
|
|
220
|
+
.tvp-search-box__dropdown {
|
|
221
|
+
display: block;
|
|
222
|
+
flex: 1;
|
|
223
|
+
}
|
|
224
|
+
.tvp-search-box__radio-wrap {
|
|
225
|
+
max-height: 240px;
|
|
226
|
+
overflow: auto;
|
|
227
|
+
}
|
|
228
|
+
.tvp-search-box__checkbox-wrap {
|
|
229
|
+
max-height: 186px;
|
|
230
|
+
overflow: auto;
|
|
231
|
+
}
|
|
232
|
+
.tvp-search-box__checkbox {
|
|
233
|
+
flex-direction: column;
|
|
234
|
+
}
|
|
235
|
+
.tvp-search-box__bottom-btn,
|
|
236
|
+
.tvp-search-box__checkbox-btn {
|
|
237
|
+
display: flex;
|
|
238
|
+
width: 100%;
|
|
239
|
+
border-top: 1px solid var(--tvp-SearchBox-dropdown-btn-group-border-color);
|
|
240
|
+
margin-top: var(--tvp-SearchBox-dropdown-btn-group-margin-top);
|
|
241
|
+
padding-top: var(--tvp-SearchBox-dropdown-btn-group-padding-top);
|
|
242
|
+
padding-right: 10px;
|
|
243
|
+
padding-bottom: var(--tvp-SearchBox-dropdown-btn-group-padding-bottom);
|
|
244
|
+
}
|
|
245
|
+
.tvp-search-box__bottom-btn .tiny-button,
|
|
246
|
+
.tvp-search-box__checkbox-btn .tiny-button {
|
|
247
|
+
min-width: 72px;
|
|
248
|
+
}
|
|
249
|
+
.tvp-search-box__checkbox-btn {
|
|
250
|
+
padding-left: 10px;
|
|
251
|
+
}
|
|
252
|
+
.tvp-search-box__filter-type {
|
|
253
|
+
display: inline-block;
|
|
254
|
+
padding: 0 16px;
|
|
255
|
+
margin-top: 12px;
|
|
256
|
+
height: 18px;
|
|
257
|
+
line-height: 18px;
|
|
258
|
+
font-weight: 500;
|
|
259
|
+
white-space: nowrap;
|
|
260
|
+
overflow: hidden;
|
|
261
|
+
text-overflow: ellipsis;
|
|
262
|
+
color: var(--tvp-SearchBox-dropdown-header-text-color);
|
|
263
|
+
}
|
|
264
|
+
.tvp-search-box__potential-box {
|
|
265
|
+
min-height: 30px;
|
|
266
|
+
}
|
|
267
|
+
.tvp-search-box__filter-item {
|
|
268
|
+
color: var(--tvp-SearchBox-search-filter-text-color);
|
|
269
|
+
border-bottom: 1px solid #fff;
|
|
270
|
+
}
|
|
271
|
+
.tvp-search-box__dropdown-item.tiny-dropdown-item {
|
|
272
|
+
width: 100%;
|
|
273
|
+
max-width: 100%;
|
|
274
|
+
}
|
|
275
|
+
.tvp-search-box__dropdown-item.tiny-dropdown-item > div {
|
|
276
|
+
white-space: nowrap;
|
|
277
|
+
overflow: hidden;
|
|
278
|
+
text-overflow: ellipsis;
|
|
279
|
+
}
|
|
280
|
+
.tvp-search-box__dropdown-item.tiny-dropdown-item.tvp-search-box__checkbox-item .tiny-checkbox__inner > .tiny-svg {
|
|
281
|
+
margin-right: 0;
|
|
282
|
+
}
|
|
283
|
+
.tvp-search-box__checkbox-item .tvp-search-box__checkbox-item-label,
|
|
284
|
+
.tvp-search-box__checkbox-item .tiny-checkbox,
|
|
285
|
+
.tvp-search-box__checkbox-item .tiny-dropdown-item__label {
|
|
286
|
+
width: 100%;
|
|
287
|
+
}
|
|
288
|
+
.tvp-search-box__checkbox-item-label .tiny-checkbox__label {
|
|
289
|
+
width: 100%;
|
|
290
|
+
overflow: hidden;
|
|
291
|
+
text-overflow: ellipsis;
|
|
292
|
+
}
|
|
293
|
+
.tvp-search-box__checkbox-item .tiny-dropdown-item__wrap {
|
|
294
|
+
padding: 0;
|
|
295
|
+
}
|
|
296
|
+
.tvp-search-box__checkbox-item .tiny-checkbox {
|
|
297
|
+
padding: 6px 10px;
|
|
298
|
+
}
|
|
299
|
+
.tvp-search-box__dropdown-title {
|
|
300
|
+
margin: 8px 0px;
|
|
301
|
+
line-height: 18px;
|
|
302
|
+
color: var(--tvp-SearchBox-dropdown-num-title-text-color);
|
|
303
|
+
font-size: 12px;
|
|
304
|
+
}
|
|
305
|
+
.tvp-search-box__dropdown-start,
|
|
306
|
+
.tvp-search-box__dropdown-end {
|
|
307
|
+
margin: 8px 0px;
|
|
308
|
+
font-size: var(--tvp-SearchBox-dropdown-desc-font-size);
|
|
309
|
+
color: var(--tvp-SearchBox-dropdown-desc-text-color);
|
|
310
|
+
letter-spacing: 0;
|
|
311
|
+
line-height: 1.5;
|
|
312
|
+
}
|
|
313
|
+
.tvp-search-box__panel-box {
|
|
314
|
+
width: 100%;
|
|
315
|
+
padding: 0px 10px;
|
|
316
|
+
}
|
|
317
|
+
.tvp-search-box__date-item.tiny-form-item,
|
|
318
|
+
.tvp-search-box__number-item.tiny-form-item {
|
|
319
|
+
padding-bottom: 8px;
|
|
320
|
+
margin-bottom: 0;
|
|
321
|
+
width: 200px;
|
|
322
|
+
}
|
|
323
|
+
.tvp-search-box__date-item.tiny-form-item > div,
|
|
324
|
+
.tvp-search-box__number-item.tiny-form-item > div {
|
|
325
|
+
width: 100%;
|
|
326
|
+
white-space: nowrap;
|
|
327
|
+
}
|
|
328
|
+
.tvp-search-box__date-item.tiny-form-item .tiny-form-item__error,
|
|
329
|
+
.tvp-search-box__number-item.tiny-form-item .tiny-form-item__error {
|
|
330
|
+
font-size: 12px;
|
|
331
|
+
}
|
|
332
|
+
.tvp-search-box__input input {
|
|
333
|
+
border: 0;
|
|
334
|
+
}
|
|
335
|
+
.tvp-search-box__input-wrapper .tvp-search-box__dropdown .tvp-search-box__input .tiny-input__inner {
|
|
336
|
+
padding-left: 0px;
|
|
337
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const vue = require("vue");
|
|
4
|
+
const tag = require("../utils/tag.cjs.js");
|
|
5
|
+
const clone = require("../utils/clone.cjs.js");
|
|
6
|
+
function useCheckbox({ props, state, emits }) {
|
|
7
|
+
const selectCheckbox = (confirm) => {
|
|
8
|
+
const { checkboxGroup, prevItem, propItem } = state;
|
|
9
|
+
const rest = clone.omitObj(prevItem);
|
|
10
|
+
state.hiden = true;
|
|
11
|
+
if (confirm) {
|
|
12
|
+
const tagList = [];
|
|
13
|
+
const oldValue = clone.deepClone(state.innerModelValue);
|
|
14
|
+
const { mergeTag, operators, label: prevLabel } = prevItem;
|
|
15
|
+
if (mergeTag) {
|
|
16
|
+
let value = "";
|
|
17
|
+
const options = [];
|
|
18
|
+
const { indexMap } = state;
|
|
19
|
+
const hasTagIndex = indexMap.get(prevLabel);
|
|
20
|
+
hasTagIndex !== void 0 && state.innerModelValue.splice(hasTagIndex, 1);
|
|
21
|
+
state.backupList.forEach((item) => {
|
|
22
|
+
const { label } = item;
|
|
23
|
+
const checkboxLabel = `${prevLabel}${label}`;
|
|
24
|
+
const hasItem = checkboxGroup.includes(checkboxLabel);
|
|
25
|
+
if (hasItem) {
|
|
26
|
+
delete item.isFilter;
|
|
27
|
+
const id = tag.getTagId(props, prevItem, item);
|
|
28
|
+
const newOptions = { label: item.label, ...id };
|
|
29
|
+
value += !value ? label : ` | ${label}`;
|
|
30
|
+
options.push(newOptions);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (options.length > 0) {
|
|
34
|
+
const newTag = { ...rest, value, options };
|
|
35
|
+
tagList.push(newTag);
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
const { valueMap } = state;
|
|
39
|
+
const indexList = [];
|
|
40
|
+
state.backupList.forEach((item) => {
|
|
41
|
+
const { label } = item;
|
|
42
|
+
const value = `${prevLabel}${label}`;
|
|
43
|
+
const hasItem = checkboxGroup.includes(value);
|
|
44
|
+
if (hasItem && !tag.hasTagItem(state, label)) {
|
|
45
|
+
const id = tag.getTagId(props, prevItem, item);
|
|
46
|
+
const operator = state.operatorValue && operators ? { operator: state.operatorValue } : null;
|
|
47
|
+
const newTag = tag.createNewTag({ ...rest, label: propItem.label, value: label, ...id, ...operator });
|
|
48
|
+
tagList.push(newTag);
|
|
49
|
+
item.isChecked = true;
|
|
50
|
+
} else if (!hasItem && tag.hasTagItem(state, label)) {
|
|
51
|
+
item.isChecked = false;
|
|
52
|
+
const index = valueMap.get(value);
|
|
53
|
+
indexList.push(index);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (indexList.length) {
|
|
57
|
+
state.innerModelValue = state.innerModelValue.filter((item, index) => item && !indexList.includes(index));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
tag.emitChangeModelEvent({ emits, state, tagList, oldValue });
|
|
61
|
+
} else {
|
|
62
|
+
propItem.label = "";
|
|
63
|
+
state.inputValue = "";
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const isIndeterminate = vue.computed(
|
|
67
|
+
() => state.checkboxGroup.length > 0 && state.checkboxGroup.length !== state.filterList.length
|
|
68
|
+
);
|
|
69
|
+
const checkAll = vue.computed({
|
|
70
|
+
get: () => state.checkboxGroup.length && state.checkboxGroup.length === state.filterList.length,
|
|
71
|
+
set: (val) => {
|
|
72
|
+
if (val) {
|
|
73
|
+
state.checkboxGroup = state.filterList.flatMap((item) => `${state.prevItem.label}${item.label}`);
|
|
74
|
+
} else {
|
|
75
|
+
state.checkboxGroup = [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const isShowClose = vue.computed(() => props.modelValue.length || state.propItem.label || state.inputValue);
|
|
80
|
+
return {
|
|
81
|
+
selectCheckbox,
|
|
82
|
+
isIndeterminate,
|
|
83
|
+
checkAll,
|
|
84
|
+
isShowClose
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
exports.useCheckbox = useCheckbox;
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
function useCustom({ state, emits }) {
|
|
6
|
+
const updateCustomValue = (customTag) => {
|
|
7
|
+
const { prevItem, indexMap } = state;
|
|
8
|
+
const { replace, label } = prevItem;
|
|
9
|
+
const tagList = [];
|
|
10
|
+
if (replace && indexMap.has(label)) {
|
|
11
|
+
const index = indexMap.get(label);
|
|
12
|
+
const newTag = { ...prevItem, ...customTag };
|
|
13
|
+
tag.emitChangeModelEvent({ emits, state, newTag, index });
|
|
14
|
+
return;
|
|
15
|
+
} else if (!replace && Array.isArray(customTag)) {
|
|
16
|
+
customTag.forEach((tag$1) => {
|
|
17
|
+
if (!tag.hasTagItem(state, tag$1.value)) {
|
|
18
|
+
tagList.push({ ...prevItem, ...tag$1 });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
if (!tag.hasTagItem(state, customTag.value)) {
|
|
23
|
+
tagList.push({ ...prevItem, ...customTag });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
tag.emitChangeModelEvent({ emits, state, tagList });
|
|
27
|
+
};
|
|
28
|
+
const handleConfirm = (customTag) => {
|
|
29
|
+
if (!customTag) {
|
|
30
|
+
tag.resetInput(state);
|
|
31
|
+
dropdown.showDropdown(state, false);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
updateCustomValue(customTag);
|
|
35
|
+
};
|
|
36
|
+
const handleEditConfirm = (customTag) => {
|
|
37
|
+
if (!customTag) {
|
|
38
|
+
dropdown.showPopover(state, false);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
updateCustomValue(customTag);
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
handleConfirm,
|
|
45
|
+
handleEditConfirm
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.useCustom = useCustom;
|