@opentiny/vue-search-box 0.1.1-alpha.1 → 0.1.1-alpha.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 -106
- package/dist/es/index.es.js +11 -3
- package/dist/es/index.vue.es2.js +11 -42
- package/dist/es/utils/en_US.es.js +37 -37
- package/dist/es/utils/zh_CN.es.js +1 -1
- package/dist/lib/index.cjs.js +10 -2
- package/dist/lib/index.vue.cjs2.js +83 -114
- package/dist/lib/utils/en_US.cjs.js +38 -38
- package/dist/lib/utils/zh_CN.cjs.js +2 -2
- package/dist/types/utils/en_US.d.ts +2 -1
- package/dist/types/utils/zh_CN.d.ts +2 -1
- package/package.json +72 -67
- package/src/index.ts +21 -10
- package/README.zh-CN.md +0 -107
- package/__tests__/search-box.spec.ts +0 -0
- package/scripts/pre-release.cjs +0 -8
- package/src/composables/use-checkbox.ts +0 -90
- package/src/composables/use-custom.ts +0 -53
- package/src/composables/use-datepicker.ts +0 -90
- package/src/composables/use-dropdown.ts +0 -251
- package/src/composables/use-edit.ts +0 -119
- package/src/composables/use-init.ts +0 -69
- package/src/composables/use-match.ts +0 -193
- package/src/composables/use-num-range.ts +0 -86
- package/src/composables/use-placeholder.ts +0 -43
- package/src/composables/use-tag.ts +0 -54
- package/src/index.less +0 -376
- package/src/index.type.ts +0 -192
- package/src/index.vue +0 -1138
- package/src/smb-theme.ts +0 -15
- package/src/theme.json +0 -135
- package/src/utils/clone.ts +0 -37
- package/src/utils/date.ts +0 -724
- package/src/utils/dropdown.ts +0 -27
- package/src/utils/en_US.ts +0 -41
- package/src/utils/index.ts +0 -11
- package/src/utils/tag.ts +0 -80
- package/src/utils/type.ts +0 -6
- package/src/utils/validate.ts +0 -234
- package/src/utils/zh_CN.ts +0 -41
- package/src/vars.less +0 -56
- package/vite.config.theme.ts +0 -20
- package/vite.config.ts +0 -60
package/README.md
CHANGED
|
@@ -1,106 +1 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
TinySearchBox is a comprehensive search component based on Vue3. It uses the TinyVue component library and follows the OpenTiny design specifications. It is easy to use and powerful. It supports single selection, multiple selection, time, time range and so on.
|
|
4
|
-
|
|
5
|
-
English | [简体中文](README.zh-CN.md)
|
|
6
|
-
|
|
7
|
-
## Advantages
|
|
8
|
-
|
|
9
|
-
TinySearchBox has the following advantages:
|
|
10
|
-
|
|
11
|
-
- Gather the filtering criteria into one input box for higher filtering efficiency and a better user experience
|
|
12
|
-
- Supports multiple types of conditional filtering such as single selection, multiple selection, time, time interval, number size, and number interval
|
|
13
|
-
- Powerful search functions, supporting fuzzy search, custom search, etc.
|
|
14
|
-
|
|
15
|
-

|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
Install TinySearchBox:
|
|
20
|
-
|
|
21
|
-
```shell
|
|
22
|
-
npm i @opentiny/vue-search-box
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Import TinySearchBox:
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
import TinySearchBox from '@opentiny/vue-search-box';
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Import styles:
|
|
32
|
-
|
|
33
|
-
```css
|
|
34
|
-
@import '@opentiny/vue-search-box/index.css';
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
html:
|
|
38
|
-
|
|
39
|
-
```html
|
|
40
|
-
<script setup>
|
|
41
|
-
const tags = ref([]);
|
|
42
|
-
const items = ref([
|
|
43
|
-
{
|
|
44
|
-
label: '名称',
|
|
45
|
-
field: 'testName',
|
|
46
|
-
replace: true,
|
|
47
|
-
placeholder: '我是自定义名称的占位符',
|
|
48
|
-
options: [
|
|
49
|
-
{
|
|
50
|
-
label: 'test-1'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
label: 'test-2'
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
label: '可用地区',
|
|
59
|
-
field: 'testRegion',
|
|
60
|
-
type: 'checkbox',
|
|
61
|
-
mergeTag: true,
|
|
62
|
-
placeholder: '我是自定义可选地区的占位符',
|
|
63
|
-
editAttrDisabled: true, // 编辑状态此属性禁用,不可变更
|
|
64
|
-
options: [
|
|
65
|
-
{
|
|
66
|
-
label: '华南区',
|
|
67
|
-
id: '2-1'
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: '华北区',
|
|
71
|
-
id: '2-2'
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
label: '大小',
|
|
77
|
-
field: 'size',
|
|
78
|
-
type: 'numRange',
|
|
79
|
-
placeholder: '我是自定义大小的占位符',
|
|
80
|
-
unit: 'GB',
|
|
81
|
-
start: -1,
|
|
82
|
-
min: -1,
|
|
83
|
-
max: 20
|
|
84
|
-
}
|
|
85
|
-
]);
|
|
86
|
-
</script>
|
|
87
|
-
|
|
88
|
-
<template>
|
|
89
|
-
<TinySearchBox v-model="tags" :items="items"></TinySearchBox>
|
|
90
|
-
</template>
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Development
|
|
94
|
-
|
|
95
|
-
```shell
|
|
96
|
-
git clone git@github.com:opentiny/tiny-search-box.git
|
|
97
|
-
cd tiny-search-box
|
|
98
|
-
pnpm i
|
|
99
|
-
pnpm dev
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Open a browser to access:[http://localhost:5173/tiny-search-box/](http://localhost:5173/tiny-search-box/)
|
|
103
|
-
|
|
104
|
-
## License
|
|
105
|
-
|
|
106
|
-
[MIT](LICENSE)
|
|
1
|
+
# SearchBox 综合搜索组件
|
package/dist/es/index.es.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import "./index.vue.es.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import zhCN from "./utils/zh_CN.es.js";
|
|
3
|
+
import { default as default2 } from "./utils/en_US.es.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
import "./index.type.es.js";
|
|
6
6
|
import _sfc_main from "./index.vue.es2.js";
|
|
7
|
+
let apps;
|
|
7
8
|
_sfc_main.install = function(app) {
|
|
9
|
+
apps = app;
|
|
8
10
|
app.component(_sfc_main.name, _sfc_main);
|
|
9
11
|
};
|
|
12
|
+
const t = (key) => {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
14
|
+
const array = key.split(".");
|
|
15
|
+
return ((_b = (_a = apps == null ? void 0 : apps.config) == null ? void 0 : _a.globalProperties) == null ? void 0 : _b.$t) ? (_d = (_c = apps == null ? void 0 : apps.config) == null ? void 0 : _c.globalProperties) == null ? void 0 : _d.$t(key) : (_g = (_f = (_e = zhCN) == null ? void 0 : _e[array == null ? void 0 : array[0]]) == null ? void 0 : _f[array == null ? void 0 : array[1]]) == null ? void 0 : _g[array == null ? void 0 : array[2]];
|
|
16
|
+
};
|
|
10
17
|
export {
|
|
11
18
|
_sfc_main as default,
|
|
12
|
-
enUS,
|
|
19
|
+
default2 as enUS,
|
|
20
|
+
t,
|
|
13
21
|
zhCN
|
|
14
22
|
};
|
package/dist/es/index.vue.es2.js
CHANGED
|
@@ -15,7 +15,7 @@ import TinyPopover from "@opentiny/vue-popover";
|
|
|
15
15
|
import TinySelect from "@opentiny/vue-select";
|
|
16
16
|
import TinyOption from "@opentiny/vue-option";
|
|
17
17
|
import { iconSearch, iconClose, iconHelpQuery } from "@opentiny/vue-icon";
|
|
18
|
-
import { t } from "
|
|
18
|
+
import { t } from "./index.es.js";
|
|
19
19
|
import { useTag } from "./composables/use-tag.es.js";
|
|
20
20
|
import { useDropdown } from "./composables/use-dropdown.es.js";
|
|
21
21
|
import { useMatch } from "./composables/use-match.es.js";
|
|
@@ -166,7 +166,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
166
166
|
},
|
|
167
167
|
emptyPlaceholder: {
|
|
168
168
|
type: String,
|
|
169
|
-
default:
|
|
169
|
+
default: ""
|
|
170
170
|
},
|
|
171
171
|
potentialOptions: {
|
|
172
172
|
type: Object,
|
|
@@ -212,13 +212,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
212
212
|
default: true
|
|
213
213
|
}
|
|
214
214
|
},
|
|
215
|
-
emits: [
|
|
216
|
-
"update:modelValue",
|
|
217
|
-
"change",
|
|
218
|
-
"search",
|
|
219
|
-
"exceed",
|
|
220
|
-
"first-level-select"
|
|
221
|
-
],
|
|
215
|
+
emits: ["update:modelValue", "change", "search", "exceed", "first-level-select"],
|
|
222
216
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
223
217
|
const props = __props;
|
|
224
218
|
const emits = __emit;
|
|
@@ -329,13 +323,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
329
323
|
emits
|
|
330
324
|
});
|
|
331
325
|
const { handleConfirm, handleEditConfirm } = useCustom({ state, emits });
|
|
332
|
-
const {
|
|
333
|
-
initItems,
|
|
334
|
-
watchOutsideClick,
|
|
335
|
-
watchMouseDown,
|
|
336
|
-
watchMouseMove,
|
|
337
|
-
handleClick
|
|
338
|
-
} = useInit({
|
|
326
|
+
const { initItems, watchOutsideClick, watchMouseDown, watchMouseMove, handleClick } = useInit({
|
|
339
327
|
props,
|
|
340
328
|
state
|
|
341
329
|
});
|
|
@@ -382,7 +370,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
382
370
|
});
|
|
383
371
|
showPopover(state, false);
|
|
384
372
|
if (newVal.length === 0) {
|
|
385
|
-
setPlaceholder(props.emptyPlaceholder);
|
|
373
|
+
setPlaceholder(props.emptyPlaceholder || t("tvp.tvpSearchbox.defaultPlaceholder"));
|
|
386
374
|
}
|
|
387
375
|
if (props.editable && !state.inputEditValue.length && newVal[0]) {
|
|
388
376
|
state.inputEditValue = newVal[0].value;
|
|
@@ -418,10 +406,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
418
406
|
return openBlock(), createBlock(unref(TinyTag), {
|
|
419
407
|
key: tag.field + index,
|
|
420
408
|
closable: "",
|
|
421
|
-
class: normalizeClass([
|
|
422
|
-
"tvp-search-box__tag",
|
|
423
|
-
__props.editable && tag.type !== "map" ? "tvp-search-box__tag-editor" : ""
|
|
424
|
-
]),
|
|
409
|
+
class: normalizeClass(["tvp-search-box__tag", __props.editable && tag.type !== "map" ? "tvp-search-box__tag-editor" : ""]),
|
|
425
410
|
title: `${tag.label} ${tag.operator || ":"} ${tag.value}`,
|
|
426
411
|
onClose: ($event) => unref(deleteTag)(tag),
|
|
427
412
|
onClick: withModifiers(($event) => unref(editTag)(tag, index, $event), ["stop"])
|
|
@@ -498,9 +483,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
498
483
|
}), 128))
|
|
499
484
|
], 64)) : createCommentVNode("", true),
|
|
500
485
|
value["attrValue"].length ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
501
|
-
createElementVNode("span", _hoisted_8, toDisplayString(unref(t)("tvp.tvpSearchbox.propertyValue", [
|
|
502
|
-
key === "0" ? unref(t)("tvp.tvpSearchbox.attributeType") : key
|
|
503
|
-
])), 1),
|
|
486
|
+
createElementVNode("span", _hoisted_8, toDisplayString(unref(t)("tvp.tvpSearchbox.propertyValue", [key === "0" ? unref(t)("tvp.tvpSearchbox.attributeType") : key])), 1),
|
|
504
487
|
(openBlock(true), createElementBlock(Fragment, null, renderList(value["attrValue"], (item, index) => {
|
|
505
488
|
return openBlock(), createBlock(unref(TinyDropdownItem), {
|
|
506
489
|
key: item.label + index,
|
|
@@ -554,10 +537,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
554
537
|
[vShow, props.potentialOptions]
|
|
555
538
|
])
|
|
556
539
|
], 512), [
|
|
557
|
-
[
|
|
558
|
-
vShow,
|
|
559
|
-
state.isResetFlag && !state.propItem.label && state.inputValue.trim()
|
|
560
|
-
]
|
|
540
|
+
[vShow, state.isResetFlag && !state.propItem.label && state.inputValue.trim()]
|
|
561
541
|
]),
|
|
562
542
|
withDirectives(createElementVNode("div", _hoisted_14, [
|
|
563
543
|
(openBlock(true), createElementBlock(Fragment, null, renderList(state.groupItems, (group, key) => {
|
|
@@ -580,10 +560,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
580
560
|
], 64);
|
|
581
561
|
}), 128))
|
|
582
562
|
], 512), [
|
|
583
|
-
[
|
|
584
|
-
vShow,
|
|
585
|
-
state.isResetFlag && !state.propItem.label && !state.inputValue.trim()
|
|
586
|
-
]
|
|
563
|
+
[vShow, state.isResetFlag && !state.propItem.label && !state.inputValue.trim()]
|
|
587
564
|
]),
|
|
588
565
|
withDirectives(createElementVNode("div", null, [
|
|
589
566
|
((_a = state.currentOperators) == null ? void 0 : _a.length) ? (openBlock(), createElementBlock("div", _hoisted_17, [
|
|
@@ -1025,10 +1002,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1025
1002
|
label: unref(t)("tvp.tvpSearchbox.allProperty"),
|
|
1026
1003
|
value: state.allTypeAttri.label,
|
|
1027
1004
|
disabled: unref(selectItemIsDisable)(state.allTypeAttri),
|
|
1028
|
-
onClick: _cache[21] || (_cache[21] = ($event) => unref(selectPropChange)(
|
|
1029
|
-
state.allTypeAttri,
|
|
1030
|
-
unref(selectItemIsDisable)(state.allTypeAttri)
|
|
1031
|
-
))
|
|
1005
|
+
onClick: _cache[21] || (_cache[21] = ($event) => unref(selectPropChange)(state.allTypeAttri, unref(selectItemIsDisable)(state.allTypeAttri)))
|
|
1032
1006
|
}, null, 8, ["label", "value", "disabled"])),
|
|
1033
1007
|
(openBlock(true), createElementBlock(Fragment, null, renderList(state.recordItems, (item) => {
|
|
1034
1008
|
return openBlock(), createBlock(unref(TinyOption), {
|
|
@@ -1070,12 +1044,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1070
1044
|
_: 1
|
|
1071
1045
|
})) : createCommentVNode("", true),
|
|
1072
1046
|
state.prevItem.type !== "numRange" ? (openBlock(), createElementBlock("div", _hoisted_51, toDisplayString(unref(t)("tvp.tvpSearchbox.tagValue")), 1)) : createCommentVNode("", true),
|
|
1073
|
-
![
|
|
1074
|
-
"numRange",
|
|
1075
|
-
"dateRange",
|
|
1076
|
-
"datetimeRange",
|
|
1077
|
-
"custom"
|
|
1078
|
-
].includes(state.prevItem.type) ? (openBlock(), createBlock(unref(TinyFormItem), {
|
|
1047
|
+
!["numRange", "dateRange", "datetimeRange", "custom"].includes(state.prevItem.type) ? (openBlock(), createBlock(unref(TinyFormItem), {
|
|
1079
1048
|
key: 3,
|
|
1080
1049
|
prop: "inputEditValue",
|
|
1081
1050
|
class: "tvp-search-box__number-item"
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
const
|
|
1
|
+
const en_US = {
|
|
2
2
|
tvp: {
|
|
3
3
|
tvpSearchbox: {
|
|
4
|
-
defaultPlaceholder: "
|
|
5
|
-
addPlaceholder: "
|
|
6
|
-
tagPlaceholder: "
|
|
7
|
-
dynamicPlaceholder: "
|
|
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
|
-
rangeMinErr: "
|
|
23
|
-
rangeMaxErr: "
|
|
24
|
-
rangeNumberTitle: "
|
|
25
|
-
rangeDateTitle: "
|
|
26
|
-
timeLengthTitle: "
|
|
27
|
-
rangeBeginLabel: "
|
|
28
|
-
rangeEndLabel: "
|
|
29
|
-
rulekeyword1: "
|
|
30
|
-
notBeNull: "
|
|
31
|
-
noData: "
|
|
32
|
-
selectAll: "
|
|
33
|
-
confirm: "
|
|
34
|
-
cancel: "
|
|
35
|
-
equal: "
|
|
36
|
-
notEqual: "
|
|
37
|
-
contain: "
|
|
38
|
-
notContain: "
|
|
4
|
+
defaultPlaceholder: "Select attribute filtering or enter keywords",
|
|
5
|
+
addPlaceholder: "Add filtering criteria",
|
|
6
|
+
tagPlaceholder: 'Please select tag key/value search, or enter "key=value" to search',
|
|
7
|
+
dynamicPlaceholder: "Please select {newValue} to search",
|
|
8
|
+
attributeType: "Attribute Type",
|
|
9
|
+
propertyValue: "The value of {0}",
|
|
10
|
+
matched: "Potential matching items",
|
|
11
|
+
allValues: "All values",
|
|
12
|
+
allProperty: "All Properties",
|
|
13
|
+
operator: "Operator",
|
|
14
|
+
clearAll: "Clear",
|
|
15
|
+
emptyValue: "Empty value",
|
|
16
|
+
help: "Click to view help",
|
|
17
|
+
switchText: "Switch to default search terms",
|
|
18
|
+
tagKey: "Key",
|
|
19
|
+
tagValue: "Value",
|
|
20
|
+
minValueText: "Minimum value",
|
|
21
|
+
maxValueText: "Maximum value",
|
|
22
|
+
rangeMinErr: "The input value must be between {0} and {1}",
|
|
23
|
+
rangeMaxErr: "The maximum value must be greater than or equal to the minimum value, or empty",
|
|
24
|
+
rangeNumberTitle: "Please enter at least one value",
|
|
25
|
+
rangeDateTitle: "Please enter at least one date",
|
|
26
|
+
timeLengthTitle: "The optional time span is within {value} days",
|
|
27
|
+
rangeBeginLabel: "Start date",
|
|
28
|
+
rangeEndLabel: "End date",
|
|
29
|
+
rulekeyword1: "Keywords",
|
|
30
|
+
notBeNull: "The value cannot be empty",
|
|
31
|
+
noData: "There is currently no matching data available ..",
|
|
32
|
+
selectAll: "Select All",
|
|
33
|
+
confirm: "Confirm",
|
|
34
|
+
cancel: "Cancel",
|
|
35
|
+
equal: "Equal",
|
|
36
|
+
notEqual: "Not equal",
|
|
37
|
+
contain: "Contain",
|
|
38
|
+
notContain: "Does not contain"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
export {
|
|
43
|
-
|
|
43
|
+
en_US as default
|
|
44
44
|
};
|
package/dist/lib/index.cjs.js
CHANGED
|
@@ -6,9 +6,17 @@ const en_US = require("./utils/en_US.cjs.js");
|
|
|
6
6
|
;/* empty css */
|
|
7
7
|
require("./index.type.cjs.js");
|
|
8
8
|
const index_vue_vue_type_script_setup_true_lang = require("./index.vue.cjs2.js");
|
|
9
|
+
let apps;
|
|
9
10
|
index_vue_vue_type_script_setup_true_lang.default.install = function(app) {
|
|
11
|
+
apps = app;
|
|
10
12
|
app.component(index_vue_vue_type_script_setup_true_lang.default.name, index_vue_vue_type_script_setup_true_lang.default);
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
const t = (key) => {
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
16
|
+
const array = key.split(".");
|
|
17
|
+
return ((_b = (_a = apps == null ? void 0 : apps.config) == null ? void 0 : _a.globalProperties) == null ? void 0 : _b.$t) ? (_d = (_c = apps == null ? void 0 : apps.config) == null ? void 0 : _c.globalProperties) == null ? void 0 : _d.$t(key) : (_g = (_f = (_e = zh_CN.default) == null ? void 0 : _e[array == null ? void 0 : array[0]]) == null ? void 0 : _f[array == null ? void 0 : array[1]]) == null ? void 0 : _g[array == null ? void 0 : array[2]];
|
|
18
|
+
};
|
|
19
|
+
exports.zhCN = zh_CN.default;
|
|
20
|
+
exports.enUS = en_US.default;
|
|
14
21
|
exports.default = index_vue_vue_type_script_setup_true_lang.default;
|
|
22
|
+
exports.t = t;
|