@vunk/form 1.1.85 → 1.2.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/composables/index.cjs +89 -0
- package/package.json +29 -18
- package/shared/const/index.cjs +59 -0
- package/shared/element-plus/index.cjs +317 -0
- package/shared/form/index.cjs +33 -0
- package/shared/helper/index.cjs +11 -0
- package/shared/index.cjs +8 -0
- package/shared/infer-prop/index.cjs +36 -0
- package/shared/progress-it/index.cjs +40 -0
- package/shared/rules/index.cjs +56 -0
- package/shared/types/form/index.cjs +2 -0
- package/shared/types/index.cjs +2 -0
- package/shared/types/source/index.cjs +2 -0
- package/shared/types/source-manager/index.cjs +2 -0
- package/shared/upload/index.cjs +774 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
|
|
5
|
+
const useSourceManager = (source, opts = {}) => {
|
|
6
|
+
if (!vue.isRef(source)) {
|
|
7
|
+
source = vue.ref(source);
|
|
8
|
+
}
|
|
9
|
+
const op = {
|
|
10
|
+
...opts,
|
|
11
|
+
slotsChildren: ["default"]
|
|
12
|
+
};
|
|
13
|
+
opts.slotsChildren && op.slotsChildren.push(...opts.slotsChildren);
|
|
14
|
+
const manager = vue.computed(() => {
|
|
15
|
+
const keyRecord = {};
|
|
16
|
+
const propRecord = {};
|
|
17
|
+
const idRecord = {};
|
|
18
|
+
function intoData(list, k = []) {
|
|
19
|
+
list.forEach((item, index) => {
|
|
20
|
+
const currentK = [...k, index];
|
|
21
|
+
const managerInfo = {
|
|
22
|
+
source: item,
|
|
23
|
+
key: currentK,
|
|
24
|
+
nextKey: [...k, index + 1],
|
|
25
|
+
prop: item.prop,
|
|
26
|
+
id: item.id
|
|
27
|
+
};
|
|
28
|
+
keyRecord[currentK.join()] = managerInfo;
|
|
29
|
+
if (item.prop) {
|
|
30
|
+
propRecord[item.prop] = managerInfo;
|
|
31
|
+
}
|
|
32
|
+
if (item.id) {
|
|
33
|
+
idRecord[item.id] = managerInfo;
|
|
34
|
+
}
|
|
35
|
+
if (item.templateSlots) {
|
|
36
|
+
if (Array.isArray(item.templateSlots)) {
|
|
37
|
+
currentK.push("templateSlots");
|
|
38
|
+
intoData(item.templateSlots, currentK);
|
|
39
|
+
}
|
|
40
|
+
op.slotsChildren.forEach((filed) => {
|
|
41
|
+
if (Array.isArray(item.templateSlots[filed])) {
|
|
42
|
+
currentK.push("templateSlots", filed);
|
|
43
|
+
intoData(item.templateSlots[filed], currentK);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
intoData(vue.unref(source));
|
|
50
|
+
return {
|
|
51
|
+
keyRecord,
|
|
52
|
+
propRecord,
|
|
53
|
+
idRecord
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
const getManagerInfoByProp = (prop) => {
|
|
57
|
+
return manager.value.propRecord[prop];
|
|
58
|
+
};
|
|
59
|
+
const getManagerInfoByKey = (key) => {
|
|
60
|
+
return manager.value.keyRecord[key.join()];
|
|
61
|
+
};
|
|
62
|
+
const getManagerInfoById = (id) => {
|
|
63
|
+
return manager.value.idRecord[id];
|
|
64
|
+
};
|
|
65
|
+
return [
|
|
66
|
+
source,
|
|
67
|
+
{
|
|
68
|
+
manager,
|
|
69
|
+
getManagerInfoByProp,
|
|
70
|
+
getManagerInfoByKey,
|
|
71
|
+
getManagerInfoById
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const useForm = () => {
|
|
77
|
+
return vue.inject("vkfFormVm", null);
|
|
78
|
+
};
|
|
79
|
+
const useComputedReadonly = (props) => {
|
|
80
|
+
const form = useForm();
|
|
81
|
+
const readonly = vue.computed(() => {
|
|
82
|
+
return props.readonly ?? form?.props.readonly ?? false;
|
|
83
|
+
});
|
|
84
|
+
return readonly;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
exports.useComputedReadonly = useComputedReadonly;
|
|
88
|
+
exports.useForm = useForm;
|
|
89
|
+
exports.useSourceManager = useSourceManager;
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vunk/form",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.esm.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "gulp -f gulpfile.ts"
|
|
8
8
|
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@vunk/core": "npm:@vunk/core@alpha"
|
|
11
|
-
},
|
|
12
9
|
"keywords": [],
|
|
13
10
|
"author": "",
|
|
14
11
|
"license": "ISC",
|
|
@@ -20,59 +17,73 @@
|
|
|
20
17
|
},
|
|
21
18
|
"./shared": {
|
|
22
19
|
"import": "./shared/index.mjs",
|
|
23
|
-
"types": "./shared/index.d.ts"
|
|
20
|
+
"types": "./shared/index.d.ts",
|
|
21
|
+
"require": "./shared/index.cjs"
|
|
24
22
|
},
|
|
25
23
|
"./shared/upload": {
|
|
26
24
|
"import": "./shared/upload/index.mjs",
|
|
27
|
-
"types": "./shared/upload/index.d.ts"
|
|
25
|
+
"types": "./shared/upload/index.d.ts",
|
|
26
|
+
"require": "./shared/upload/index.cjs"
|
|
28
27
|
},
|
|
29
28
|
"./shared/types": {
|
|
30
29
|
"import": "./shared/types/index.mjs",
|
|
31
|
-
"types": "./shared/types/index.d.ts"
|
|
30
|
+
"types": "./shared/types/index.d.ts",
|
|
31
|
+
"require": "./shared/types/index.cjs"
|
|
32
32
|
},
|
|
33
33
|
"./shared/types/source-manager": {
|
|
34
34
|
"import": "./shared/types/source-manager/index.mjs",
|
|
35
|
-
"types": "./shared/types/source-manager/index.d.ts"
|
|
35
|
+
"types": "./shared/types/source-manager/index.d.ts",
|
|
36
|
+
"require": "./shared/types/source-manager/index.cjs"
|
|
36
37
|
},
|
|
37
38
|
"./shared/types/source": {
|
|
38
39
|
"import": "./shared/types/source/index.mjs",
|
|
39
|
-
"types": "./shared/types/source/index.d.ts"
|
|
40
|
+
"types": "./shared/types/source/index.d.ts",
|
|
41
|
+
"require": "./shared/types/source/index.cjs"
|
|
40
42
|
},
|
|
41
43
|
"./shared/types/form": {
|
|
42
44
|
"import": "./shared/types/form/index.mjs",
|
|
43
|
-
"types": "./shared/types/form/index.d.ts"
|
|
45
|
+
"types": "./shared/types/form/index.d.ts",
|
|
46
|
+
"require": "./shared/types/form/index.cjs"
|
|
44
47
|
},
|
|
45
48
|
"./shared/rules": {
|
|
46
49
|
"import": "./shared/rules/index.mjs",
|
|
47
|
-
"types": "./shared/rules/index.d.ts"
|
|
50
|
+
"types": "./shared/rules/index.d.ts",
|
|
51
|
+
"require": "./shared/rules/index.cjs"
|
|
48
52
|
},
|
|
49
53
|
"./shared/progress-it": {
|
|
50
54
|
"import": "./shared/progress-it/index.mjs",
|
|
51
|
-
"types": "./shared/progress-it/index.d.ts"
|
|
55
|
+
"types": "./shared/progress-it/index.d.ts",
|
|
56
|
+
"require": "./shared/progress-it/index.cjs"
|
|
52
57
|
},
|
|
53
58
|
"./shared/infer-prop": {
|
|
54
59
|
"import": "./shared/infer-prop/index.mjs",
|
|
55
|
-
"types": "./shared/infer-prop/index.d.ts"
|
|
60
|
+
"types": "./shared/infer-prop/index.d.ts",
|
|
61
|
+
"require": "./shared/infer-prop/index.cjs"
|
|
56
62
|
},
|
|
57
63
|
"./shared/helper": {
|
|
58
64
|
"import": "./shared/helper/index.mjs",
|
|
59
|
-
"types": "./shared/helper/index.d.ts"
|
|
65
|
+
"types": "./shared/helper/index.d.ts",
|
|
66
|
+
"require": "./shared/helper/index.cjs"
|
|
60
67
|
},
|
|
61
68
|
"./shared/form": {
|
|
62
69
|
"import": "./shared/form/index.mjs",
|
|
63
|
-
"types": "./shared/form/index.d.ts"
|
|
70
|
+
"types": "./shared/form/index.d.ts",
|
|
71
|
+
"require": "./shared/form/index.cjs"
|
|
64
72
|
},
|
|
65
73
|
"./shared/element-plus": {
|
|
66
74
|
"import": "./shared/element-plus/index.mjs",
|
|
67
|
-
"types": "./shared/element-plus/index.d.ts"
|
|
75
|
+
"types": "./shared/element-plus/index.d.ts",
|
|
76
|
+
"require": "./shared/element-plus/index.cjs"
|
|
68
77
|
},
|
|
69
78
|
"./shared/const": {
|
|
70
79
|
"import": "./shared/const/index.mjs",
|
|
71
|
-
"types": "./shared/const/index.d.ts"
|
|
80
|
+
"types": "./shared/const/index.d.ts",
|
|
81
|
+
"require": "./shared/const/index.cjs"
|
|
72
82
|
},
|
|
73
83
|
"./composables": {
|
|
74
84
|
"import": "./composables/index.mjs",
|
|
75
|
-
"types": "./composables/index.d.ts"
|
|
85
|
+
"types": "./composables/index.d.ts",
|
|
86
|
+
"require": "./composables/index.cjs"
|
|
76
87
|
},
|
|
77
88
|
"./components": {
|
|
78
89
|
"import": "./components/index.mjs",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CORE_FORM_TEMPLATE_OPTIONS = [
|
|
4
|
+
{
|
|
5
|
+
value: "VkfInput",
|
|
6
|
+
label: "\u8F93\u5165\u6846"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
value: "VkfSelect",
|
|
10
|
+
label: "\u4E0B\u62C9\u6846"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
value: "VkfCheckbox",
|
|
14
|
+
label: "\u591A\u9009\u6846"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: "VkfRadio",
|
|
18
|
+
label: "\u5355\u9009\u6846"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: "VkfDatePicker",
|
|
22
|
+
label: "\u65E5\u671F\u9009\u62E9\u5668"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: "VkfInputNumber",
|
|
26
|
+
label: "\u6570\u5B57\u8F93\u5165\u6846"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: "VkfSwitch",
|
|
30
|
+
label: "\u5F00\u5173"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: "VkfSlider",
|
|
34
|
+
label: "\u6ED1\u5757"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: "VkfInputLink",
|
|
38
|
+
label: "\u94FE\u63A5\u8F93\u5165\u6846"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
value: "VkfEsriInputGeojson",
|
|
42
|
+
label: "\u5730\u4FE1\u8F93\u5165\u6846"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
value: "VkfCascader",
|
|
46
|
+
label: "\u7EA7\u8054\u9009\u62E9\u5668"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
value: "VkfUpload",
|
|
50
|
+
label: "\u4E0A\u4F20"
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
const CORE_FORM_TEMPLATE_REFLECT = CORE_FORM_TEMPLATE_OPTIONS.reduce((acc, cur) => {
|
|
54
|
+
acc[cur.value] = cur;
|
|
55
|
+
return acc;
|
|
56
|
+
}, {});
|
|
57
|
+
|
|
58
|
+
exports.CORE_FORM_TEMPLATE_OPTIONS = CORE_FORM_TEMPLATE_OPTIONS;
|
|
59
|
+
exports.CORE_FORM_TEMPLATE_REFLECT = CORE_FORM_TEMPLATE_REFLECT;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var elementPlus = require('element-plus');
|
|
4
|
+
var utilsVue = require('@vunk/core/shared/utils-vue');
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
|
|
7
|
+
/*! Element Plus Icons Vue v2.3.1 */
|
|
8
|
+
|
|
9
|
+
var arrow_down_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({
|
|
10
|
+
name: "ArrowDown",
|
|
11
|
+
__name: "arrow-down",
|
|
12
|
+
setup(__props) {
|
|
13
|
+
return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", {
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
viewBox: "0 0 1024 1024"
|
|
16
|
+
}, [
|
|
17
|
+
vue.createElementVNode("path", {
|
|
18
|
+
fill: "currentColor",
|
|
19
|
+
d: "M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"
|
|
20
|
+
})
|
|
21
|
+
]));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// src/components/arrow-down.vue
|
|
26
|
+
var arrow_down_default = arrow_down_vue_vue_type_script_setup_true_lang_default;
|
|
27
|
+
var circle_close_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ vue.defineComponent({
|
|
28
|
+
name: "CircleClose",
|
|
29
|
+
__name: "circle-close",
|
|
30
|
+
setup(__props) {
|
|
31
|
+
return (_ctx, _cache) => (vue.openBlock(), vue.createElementBlock("svg", {
|
|
32
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
+
viewBox: "0 0 1024 1024"
|
|
34
|
+
}, [
|
|
35
|
+
vue.createElementVNode("path", {
|
|
36
|
+
fill: "currentColor",
|
|
37
|
+
d: "m466.752 512-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248z"
|
|
38
|
+
}),
|
|
39
|
+
vue.createElementVNode("path", {
|
|
40
|
+
fill: "currentColor",
|
|
41
|
+
d: "M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"
|
|
42
|
+
})
|
|
43
|
+
]));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// src/components/circle-close.vue
|
|
48
|
+
var circle_close_default = circle_close_vue_vue_type_script_setup_true_lang_default;
|
|
49
|
+
|
|
50
|
+
const datePickerProps = {
|
|
51
|
+
...elementPlus.timePickerDefaultProps,
|
|
52
|
+
type: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "date"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const datePickerEmits = {
|
|
58
|
+
"update:modelValue": null,
|
|
59
|
+
"change": null,
|
|
60
|
+
"focus": null,
|
|
61
|
+
"blur": null,
|
|
62
|
+
"calendar-change": null,
|
|
63
|
+
"panel-change": null,
|
|
64
|
+
"visible-change": null,
|
|
65
|
+
"keydown": null
|
|
66
|
+
};
|
|
67
|
+
const selectProps = {
|
|
68
|
+
name: String,
|
|
69
|
+
id: String,
|
|
70
|
+
modelValue: {
|
|
71
|
+
type: [Array, String, Number, Boolean, Object],
|
|
72
|
+
default: void 0
|
|
73
|
+
},
|
|
74
|
+
autocomplete: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: "off"
|
|
77
|
+
},
|
|
78
|
+
automaticDropdown: Boolean,
|
|
79
|
+
size: {
|
|
80
|
+
type: String
|
|
81
|
+
},
|
|
82
|
+
effect: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: "light"
|
|
85
|
+
},
|
|
86
|
+
disabled: Boolean,
|
|
87
|
+
clearable: Boolean,
|
|
88
|
+
filterable: Boolean,
|
|
89
|
+
allowCreate: Boolean,
|
|
90
|
+
loading: Boolean,
|
|
91
|
+
popperClass: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: ""
|
|
94
|
+
},
|
|
95
|
+
remote: Boolean,
|
|
96
|
+
loadingText: String,
|
|
97
|
+
noMatchText: String,
|
|
98
|
+
noDataText: String,
|
|
99
|
+
remoteMethod: Function,
|
|
100
|
+
filterMethod: Function,
|
|
101
|
+
multiple: Boolean,
|
|
102
|
+
multipleLimit: {
|
|
103
|
+
type: Number,
|
|
104
|
+
default: 0
|
|
105
|
+
},
|
|
106
|
+
placeholder: {
|
|
107
|
+
type: String
|
|
108
|
+
},
|
|
109
|
+
defaultFirstOption: Boolean,
|
|
110
|
+
reserveKeyword: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
default: true
|
|
113
|
+
},
|
|
114
|
+
valueKey: {
|
|
115
|
+
type: String,
|
|
116
|
+
default: "value"
|
|
117
|
+
},
|
|
118
|
+
collapseTags: Boolean,
|
|
119
|
+
collapseTagsTooltip: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: false
|
|
122
|
+
},
|
|
123
|
+
teleported: elementPlus.useTooltipContentProps.teleported,
|
|
124
|
+
persistent: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: true
|
|
127
|
+
},
|
|
128
|
+
clearIcon: {
|
|
129
|
+
type: [String, Object],
|
|
130
|
+
default: circle_close_default
|
|
131
|
+
},
|
|
132
|
+
fitInputWidth: {
|
|
133
|
+
type: Boolean,
|
|
134
|
+
default: false
|
|
135
|
+
},
|
|
136
|
+
suffixIcon: {
|
|
137
|
+
type: [String, Object],
|
|
138
|
+
default: arrow_down_default
|
|
139
|
+
},
|
|
140
|
+
// eslint-disable-next-line vue/require-prop-types
|
|
141
|
+
tagType: { ...elementPlus.tagProps.type, default: "info" }
|
|
142
|
+
};
|
|
143
|
+
const selectEmits = {
|
|
144
|
+
"update:modelValue": null,
|
|
145
|
+
"change": null,
|
|
146
|
+
"remove-tag": null,
|
|
147
|
+
"clear": null,
|
|
148
|
+
"visible-change": null,
|
|
149
|
+
"focus": null,
|
|
150
|
+
"blur": null
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const createInputBindProps = utilsVue.bindPropsFactory(elementPlus.inputProps);
|
|
154
|
+
const createInputOnEmits = utilsVue.onEmitsFactory(elementPlus.inputEmits);
|
|
155
|
+
const createFormBindProps = utilsVue.bindPropsFactory(elementPlus.formProps);
|
|
156
|
+
const createFormOnEmits = utilsVue.onEmitsFactory(elementPlus.formEmits);
|
|
157
|
+
const createFormItemBindProps = utilsVue.bindPropsFactory(elementPlus.formItemProps);
|
|
158
|
+
const createSwitchBindProps = utilsVue.bindPropsFactory(elementPlus.switchProps);
|
|
159
|
+
const createSwitchOnEmits = utilsVue.onEmitsFactory(elementPlus.switchEmits);
|
|
160
|
+
const createSelectBindProps = utilsVue.bindPropsFactory(selectProps);
|
|
161
|
+
const createSelectOnEmits = utilsVue.onEmitsFactory(selectEmits);
|
|
162
|
+
const createDatePickerBindProps = utilsVue.bindPropsFactory(datePickerProps);
|
|
163
|
+
const createDatePickerOnEmits = utilsVue.onEmitsFactory(datePickerEmits);
|
|
164
|
+
const createInputNumberBindProps = utilsVue.bindPropsFactory(elementPlus.inputNumberProps);
|
|
165
|
+
const createInputNumberOnEmits = utilsVue.onEmitsFactory(elementPlus.inputNumberEmits);
|
|
166
|
+
const createRadioGroupBindProps = utilsVue.bindPropsFactory(elementPlus.radioGroupProps);
|
|
167
|
+
const createRadioGroupOnEmits = utilsVue.onEmitsFactory(elementPlus.radioGroupEmits);
|
|
168
|
+
const createCheckboxGroupBindProps = utilsVue.bindPropsFactory(elementPlus.checkboxGroupProps);
|
|
169
|
+
const createCheckboxGroupOnEmits = utilsVue.onEmitsFactory(elementPlus.checkboxGroupEmits);
|
|
170
|
+
const createUploadBindProps = utilsVue.bindPropsFactory(elementPlus.uploadProps);
|
|
171
|
+
const createColorPickerBindProps = utilsVue.bindPropsFactory(elementPlus.colorPickerProps);
|
|
172
|
+
const createColorPickerOnEmits = utilsVue.onEmitsFactory(elementPlus.colorPickerEmits);
|
|
173
|
+
const createButtonBindProps = utilsVue.bindPropsFactory(elementPlus.buttonProps);
|
|
174
|
+
const createButtonOnEmits = utilsVue.onEmitsFactory(elementPlus.buttonEmits);
|
|
175
|
+
const createCascaderBindProps = utilsVue.bindPropsFactory(elementPlus.cascaderProps);
|
|
176
|
+
const createCascaderOnEmits = utilsVue.onEmitsFactory(elementPlus.cascaderEmits);
|
|
177
|
+
const createSliderBindProps = utilsVue.bindPropsFactory(elementPlus.sliderProps);
|
|
178
|
+
const createSliderOnEmits = utilsVue.onEmitsFactory(elementPlus.sliderEmits);
|
|
179
|
+
|
|
180
|
+
const semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
|
|
181
|
+
const validateAndParse = (version) => {
|
|
182
|
+
if (typeof version !== 'string') {
|
|
183
|
+
throw new TypeError('Invalid argument expected string');
|
|
184
|
+
}
|
|
185
|
+
const match = version.match(semver);
|
|
186
|
+
if (!match) {
|
|
187
|
+
throw new Error(`Invalid argument not valid semver ('${version}' received)`);
|
|
188
|
+
}
|
|
189
|
+
match.shift();
|
|
190
|
+
return match;
|
|
191
|
+
};
|
|
192
|
+
const isWildcard = (s) => s === '*' || s === 'x' || s === 'X';
|
|
193
|
+
const tryParse = (v) => {
|
|
194
|
+
const n = parseInt(v, 10);
|
|
195
|
+
return isNaN(n) ? v : n;
|
|
196
|
+
};
|
|
197
|
+
const forceType = (a, b) => typeof a !== typeof b ? [String(a), String(b)] : [a, b];
|
|
198
|
+
const compareStrings = (a, b) => {
|
|
199
|
+
if (isWildcard(a) || isWildcard(b))
|
|
200
|
+
return 0;
|
|
201
|
+
const [ap, bp] = forceType(tryParse(a), tryParse(b));
|
|
202
|
+
if (ap > bp)
|
|
203
|
+
return 1;
|
|
204
|
+
if (ap < bp)
|
|
205
|
+
return -1;
|
|
206
|
+
return 0;
|
|
207
|
+
};
|
|
208
|
+
const compareSegments = (a, b) => {
|
|
209
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
210
|
+
const r = compareStrings(a[i] || '0', b[i] || '0');
|
|
211
|
+
if (r !== 0)
|
|
212
|
+
return r;
|
|
213
|
+
}
|
|
214
|
+
return 0;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
|
|
219
|
+
* This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
|
|
220
|
+
* @param v1 - First version to compare
|
|
221
|
+
* @param v2 - Second version to compare
|
|
222
|
+
* @returns Numeric value compatible with the [Array.sort(fn) interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters).
|
|
223
|
+
*/
|
|
224
|
+
const compareVersions = (v1, v2) => {
|
|
225
|
+
// validate input and split into segments
|
|
226
|
+
const n1 = validateAndParse(v1);
|
|
227
|
+
const n2 = validateAndParse(v2);
|
|
228
|
+
// pop off the patch
|
|
229
|
+
const p1 = n1.pop();
|
|
230
|
+
const p2 = n2.pop();
|
|
231
|
+
// validate numbers
|
|
232
|
+
const r = compareSegments(n1, n2);
|
|
233
|
+
if (r !== 0)
|
|
234
|
+
return r;
|
|
235
|
+
// validate pre-release
|
|
236
|
+
if (p1 && p2) {
|
|
237
|
+
return compareSegments(p1.split('.'), p2.split('.'));
|
|
238
|
+
}
|
|
239
|
+
else if (p1 || p2) {
|
|
240
|
+
return p1 ? -1 : 1;
|
|
241
|
+
}
|
|
242
|
+
return 0;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Compare [semver](https://semver.org/) version strings using the specified operator.
|
|
247
|
+
*
|
|
248
|
+
* @param v1 First version to compare
|
|
249
|
+
* @param v2 Second version to compare
|
|
250
|
+
* @param operator Allowed arithmetic operator to use
|
|
251
|
+
* @returns `true` if the comparison between the firstVersion and the secondVersion satisfies the operator, `false` otherwise.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```
|
|
255
|
+
* compare('10.1.8', '10.0.4', '>'); // return true
|
|
256
|
+
* compare('10.0.1', '10.0.1', '='); // return true
|
|
257
|
+
* compare('10.1.1', '10.2.2', '<'); // return true
|
|
258
|
+
* compare('10.1.1', '10.2.2', '<='); // return true
|
|
259
|
+
* compare('10.1.1', '10.2.2', '>='); // return false
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
const compare = (v1, v2, operator) => {
|
|
263
|
+
// validate input operator
|
|
264
|
+
assertValidOperator(operator);
|
|
265
|
+
// since result of compareVersions can only be -1 or 0 or 1
|
|
266
|
+
// a simple map can be used to replace switch
|
|
267
|
+
const res = compareVersions(v1, v2);
|
|
268
|
+
return operatorResMap[operator].includes(res);
|
|
269
|
+
};
|
|
270
|
+
const operatorResMap = {
|
|
271
|
+
'>': [1],
|
|
272
|
+
'>=': [0, 1],
|
|
273
|
+
'=': [0],
|
|
274
|
+
'<=': [-1, 0],
|
|
275
|
+
'<': [-1],
|
|
276
|
+
'!=': [-1, 1],
|
|
277
|
+
};
|
|
278
|
+
const allowedOperators = Object.keys(operatorResMap);
|
|
279
|
+
const assertValidOperator = (op) => {
|
|
280
|
+
if (allowedOperators.indexOf(op) === -1) {
|
|
281
|
+
throw new Error(`Invalid operator, expected one of ${allowedOperators.join('|')}`);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const isGte2_6_0 = compare(elementPlus.version, "2.6.0", ">=");
|
|
286
|
+
|
|
287
|
+
exports.createButtonBindProps = createButtonBindProps;
|
|
288
|
+
exports.createButtonOnEmits = createButtonOnEmits;
|
|
289
|
+
exports.createCascaderBindProps = createCascaderBindProps;
|
|
290
|
+
exports.createCascaderOnEmits = createCascaderOnEmits;
|
|
291
|
+
exports.createCheckboxGroupBindProps = createCheckboxGroupBindProps;
|
|
292
|
+
exports.createCheckboxGroupOnEmits = createCheckboxGroupOnEmits;
|
|
293
|
+
exports.createColorPickerBindProps = createColorPickerBindProps;
|
|
294
|
+
exports.createColorPickerOnEmits = createColorPickerOnEmits;
|
|
295
|
+
exports.createDatePickerBindProps = createDatePickerBindProps;
|
|
296
|
+
exports.createDatePickerOnEmits = createDatePickerOnEmits;
|
|
297
|
+
exports.createFormBindProps = createFormBindProps;
|
|
298
|
+
exports.createFormItemBindProps = createFormItemBindProps;
|
|
299
|
+
exports.createFormOnEmits = createFormOnEmits;
|
|
300
|
+
exports.createInputBindProps = createInputBindProps;
|
|
301
|
+
exports.createInputNumberBindProps = createInputNumberBindProps;
|
|
302
|
+
exports.createInputNumberOnEmits = createInputNumberOnEmits;
|
|
303
|
+
exports.createInputOnEmits = createInputOnEmits;
|
|
304
|
+
exports.createRadioGroupBindProps = createRadioGroupBindProps;
|
|
305
|
+
exports.createRadioGroupOnEmits = createRadioGroupOnEmits;
|
|
306
|
+
exports.createSelectBindProps = createSelectBindProps;
|
|
307
|
+
exports.createSelectOnEmits = createSelectOnEmits;
|
|
308
|
+
exports.createSliderBindProps = createSliderBindProps;
|
|
309
|
+
exports.createSliderOnEmits = createSliderOnEmits;
|
|
310
|
+
exports.createSwitchBindProps = createSwitchBindProps;
|
|
311
|
+
exports.createSwitchOnEmits = createSwitchOnEmits;
|
|
312
|
+
exports.createUploadBindProps = createUploadBindProps;
|
|
313
|
+
exports.datePickerEmits = datePickerEmits;
|
|
314
|
+
exports.datePickerProps = datePickerProps;
|
|
315
|
+
exports.isGte2_6_0 = isGte2_6_0;
|
|
316
|
+
exports.selectEmits = selectEmits;
|
|
317
|
+
exports.selectProps = selectProps;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var elementPlus = require('element-plus');
|
|
4
|
+
|
|
5
|
+
const validateCatch = (err, init = {}) => {
|
|
6
|
+
let msg = "";
|
|
7
|
+
msg += init.prefix || "";
|
|
8
|
+
for (const key in err) {
|
|
9
|
+
err[key].forEach((v) => {
|
|
10
|
+
msg += v.message + ";";
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
msg += init.suffix || "";
|
|
14
|
+
elementPlus.ElMessage({
|
|
15
|
+
type: "warning",
|
|
16
|
+
message: msg
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const genTemplateIfFunc = (templateIfRaw) => {
|
|
20
|
+
if (typeof templateIfRaw === "boolean") {
|
|
21
|
+
const flag = templateIfRaw;
|
|
22
|
+
return () => flag;
|
|
23
|
+
} else if (typeof templateIfRaw === "string") {
|
|
24
|
+
const templateIf = new Function("data", templateIfRaw);
|
|
25
|
+
return templateIf;
|
|
26
|
+
} else if (typeof templateIfRaw === "function") {
|
|
27
|
+
return templateIfRaw;
|
|
28
|
+
}
|
|
29
|
+
return () => true;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.genTemplateIfFunc = genTemplateIfFunc;
|
|
33
|
+
exports.validateCatch = validateCatch;
|
package/shared/index.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const inferString = (item) => ({
|
|
4
|
+
prop: item.prop,
|
|
5
|
+
type: "String"
|
|
6
|
+
});
|
|
7
|
+
const inferBoolean = (item) => ({
|
|
8
|
+
prop: item.prop,
|
|
9
|
+
type: "Boolean"
|
|
10
|
+
});
|
|
11
|
+
const inferNumber = (item) => {
|
|
12
|
+
const info = {
|
|
13
|
+
prop: item.prop,
|
|
14
|
+
type: "Number"
|
|
15
|
+
};
|
|
16
|
+
if (item.precision) {
|
|
17
|
+
info.precision = item.precision;
|
|
18
|
+
}
|
|
19
|
+
return info;
|
|
20
|
+
};
|
|
21
|
+
const inferDate = (item) => ({
|
|
22
|
+
prop: item.prop,
|
|
23
|
+
type: "Date"
|
|
24
|
+
});
|
|
25
|
+
const propInfoAction = {
|
|
26
|
+
VkfSelect: inferString,
|
|
27
|
+
VkfRadio: inferString,
|
|
28
|
+
VkfCheckbox: inferString,
|
|
29
|
+
VkfColorPicker: inferString,
|
|
30
|
+
VkfInputNumber: inferNumber,
|
|
31
|
+
VkfSwitch: inferBoolean,
|
|
32
|
+
VkfUpload: inferString,
|
|
33
|
+
VkfDatePicker: inferDate
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.propInfoAction = propInfoAction;
|