@vunk/form 1.1.13 → 1.1.15
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/components/button/index.js +3 -13
- package/components/cascader/index.css +10 -0
- package/components/cascader/index.js +6 -2
- package/components/form/src/ctx.d.ts +2 -2
- package/components/form-item/index.js +49 -8
- package/components/form-item/src/index.vue.d.ts +5 -3
- package/components/upload/index.css +3 -0
- package/index.css +14 -0
- package/package.json +1 -1
- package/shared/form/index.d.ts +6 -0
- package/shared/form/index.js +16 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { _VkfFormItemCtx, VkfFormItem } from '@vunk/form/components/form-item';
|
|
2
|
-
import { buttonProps, buttonEmits, ElButton
|
|
2
|
+
import { buttonProps, buttonEmits, ElButton } from 'element-plus';
|
|
3
3
|
import { defineComponent, inject, resolveComponent, openBlock, createBlock, normalizeProps, guardReactiveProps, withCtx, createVNode, mergeProps, toHandlers, createSlots, renderSlot, createTextVNode, toDisplayString, renderList, resolveDynamicComponent } from 'vue';
|
|
4
4
|
import { createButtonBindProps, createButtonOnEmits } from '@vunk/form/shared/element-plus';
|
|
5
|
+
import { validateCatch } from '@vunk/form/shared/form';
|
|
5
6
|
|
|
6
7
|
var __defProp = Object.defineProperty;
|
|
7
8
|
var __defProps = Object.defineProperties;
|
|
@@ -66,18 +67,7 @@ const _sfc_main = defineComponent({
|
|
|
66
67
|
if (flag) {
|
|
67
68
|
emit("click", e);
|
|
68
69
|
}
|
|
69
|
-
}).catch(
|
|
70
|
-
let msg = "";
|
|
71
|
-
for (const key in err) {
|
|
72
|
-
err[key].forEach((v) => {
|
|
73
|
-
msg += v.message + ";";
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
ElMessage({
|
|
77
|
-
type: "warning",
|
|
78
|
-
message: msg
|
|
79
|
-
});
|
|
80
|
-
});
|
|
70
|
+
}).catch(validateCatch);
|
|
81
71
|
};
|
|
82
72
|
return {
|
|
83
73
|
formBindProps,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
.el-cascader.is-readonly{
|
|
3
|
+
--el-readonly-cursor: text;
|
|
4
|
+
--el-disabled-bg-color: initial;
|
|
5
|
+
--el-disabled-text-color: var(--el-input-text-color);
|
|
6
|
+
}
|
|
7
|
+
.el-cascader.is-readonly .el-input.is-disabled .el-input__inner,
|
|
8
|
+
.el-cascader.is-readonly .el-input.is-disabled{
|
|
9
|
+
cursor: var(--el-readonly-cursor);
|
|
10
|
+
}
|
|
@@ -114,8 +114,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
114
114
|
default: withCtx(() => [
|
|
115
115
|
createVNode(_component_ElCascader, mergeProps(_ctx.coreBindProps, toHandlers(_ctx.coreOnEmits), {
|
|
116
116
|
readonly: _ctx.readonly,
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
disabled: _ctx.readonly || _ctx.disabled,
|
|
118
|
+
options: _ctx.options,
|
|
119
|
+
class: {
|
|
120
|
+
"is-readonly": _ctx.readonly
|
|
121
|
+
}
|
|
122
|
+
}), null, 16, ["readonly", "disabled", "options", "class"])
|
|
119
123
|
]),
|
|
120
124
|
_: 1
|
|
121
125
|
}, 16);
|
|
@@ -334,7 +334,7 @@ export declare const props: {
|
|
|
334
334
|
default: boolean;
|
|
335
335
|
};
|
|
336
336
|
/**
|
|
337
|
-
*
|
|
337
|
+
* layout 为 true 时,
|
|
338
338
|
* 该值生效
|
|
339
339
|
* el-row 添加额外属性
|
|
340
340
|
*/
|
|
@@ -343,7 +343,7 @@ export declare const props: {
|
|
|
343
343
|
default: () => {};
|
|
344
344
|
};
|
|
345
345
|
/**
|
|
346
|
-
*
|
|
346
|
+
* layout 为 true 时,
|
|
347
347
|
* 该值生效
|
|
348
348
|
* el-col 添加额外属性
|
|
349
349
|
*/
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { formItemProps, ElFormItem } from 'element-plus';
|
|
1
|
+
import { formItemProps, ElFormItem, useGlobalConfig } from 'element-plus';
|
|
2
2
|
import { bindPropsFactory } from '@vunk/core/shared/utils-vue';
|
|
3
3
|
import { defineComponent, computed, resolveComponent, openBlock, createBlock, mergeProps, createSlots, withCtx, renderSlot, renderList, resolveDynamicComponent } from 'vue';
|
|
4
4
|
import { createFormItemBindProps } from '@vunk/form/shared/element-plus';
|
|
5
5
|
import { useComputedReadonly } from '@vunk/form/composables';
|
|
6
|
-
import { isNotEmptyObject } from '@vunk/core/shared/utils-object';
|
|
6
|
+
import { isPlainObject, isNotEmptyObject } from '@vunk/core/shared/utils-object';
|
|
7
|
+
import { PATTERN_OPTIONS } from '@vunk/form/shared/rules';
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __defProps = Object.defineProperties;
|
|
@@ -73,19 +74,59 @@ const _sfc_main = defineComponent({
|
|
|
73
74
|
setup(props2) {
|
|
74
75
|
const formItemBindProps = createFormItemBindProps(props2, ["rules"]);
|
|
75
76
|
const readonly = useComputedReadonly(props2);
|
|
77
|
+
const globalConfig = useGlobalConfig();
|
|
78
|
+
const localeName = computed(() => {
|
|
79
|
+
return globalConfig.value?.locale?.name;
|
|
80
|
+
});
|
|
81
|
+
const requiredMessage = `${props2.label || "\u8BE5\u5B57\u6BB5"}\u4E0D\u80FD\u4E3A\u7A7A`;
|
|
82
|
+
const setDefaultMessage = (rule) => {
|
|
83
|
+
if (localeName.value === "zh-cn") {
|
|
84
|
+
if (rule.message)
|
|
85
|
+
return;
|
|
86
|
+
if (rule.required) {
|
|
87
|
+
rule.message = requiredMessage;
|
|
88
|
+
}
|
|
89
|
+
const ruleInfo = PATTERN_OPTIONS.find((i) => i.value === rule.pattern);
|
|
90
|
+
if (ruleInfo) {
|
|
91
|
+
rule.message = `\u8F93\u5165 ${props2.label || "\u8BE5\u5B57\u6BB5"} ${ruleInfo.title}`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
76
95
|
const rules = computed(() => {
|
|
77
|
-
let data =
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
let data = [];
|
|
97
|
+
if (!props2.rules) {
|
|
98
|
+
if (props2.required) {
|
|
99
|
+
data.push({
|
|
100
|
+
required: true
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (isPlainObject(props2.rules)) {
|
|
105
|
+
data = [props2.rules];
|
|
106
|
+
}
|
|
107
|
+
if (Array.isArray(props2.rules)) {
|
|
108
|
+
data = props2.rules;
|
|
109
|
+
if (props2.required) {
|
|
110
|
+
if (!props2.rules.find((item) => item.required)) {
|
|
111
|
+
data.push({
|
|
112
|
+
required: true
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
82
116
|
}
|
|
117
|
+
data = data.filter((rule) => {
|
|
118
|
+
return isNotEmptyObject(rule);
|
|
119
|
+
});
|
|
120
|
+
data.forEach((rule) => {
|
|
121
|
+
setDefaultMessage(rule);
|
|
122
|
+
});
|
|
83
123
|
return data;
|
|
84
124
|
});
|
|
85
125
|
return {
|
|
86
126
|
formItemBindProps,
|
|
87
127
|
readonly,
|
|
88
|
-
rules
|
|
128
|
+
rules,
|
|
129
|
+
localeName
|
|
89
130
|
};
|
|
90
131
|
}
|
|
91
132
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FormItemRule } from 'element-plus';
|
|
1
2
|
declare const _default: import("vue").DefineComponent<Omit<{
|
|
2
3
|
formItemSize: {
|
|
3
4
|
type: import("vue").PropType<"default" | "small" | "large">;
|
|
@@ -29,7 +30,7 @@ declare const _default: import("vue").DefineComponent<Omit<{
|
|
|
29
30
|
};
|
|
30
31
|
required: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
|
|
31
32
|
rules: {
|
|
32
|
-
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) =>
|
|
33
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => FormItemRule | FormItemRule[]) | (() => import("element-plus/es/utils").Arrayable<FormItemRule>) | ((new (...args: any[]) => FormItemRule | FormItemRule[]) | (() => import("element-plus/es/utils").Arrayable<FormItemRule>))[], unknown, unknown>>;
|
|
33
34
|
readonly required: false;
|
|
34
35
|
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
35
36
|
__epPropKey: true;
|
|
@@ -63,7 +64,8 @@ declare const _default: import("vue").DefineComponent<Omit<{
|
|
|
63
64
|
showMessage: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
|
|
64
65
|
}>;
|
|
65
66
|
readonly: import("vue").ComputedRef<boolean>;
|
|
66
|
-
rules: import("vue").ComputedRef<
|
|
67
|
+
rules: import("vue").ComputedRef<FormItemRule[]>;
|
|
68
|
+
localeName: import("vue").ComputedRef<string | undefined>;
|
|
67
69
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<Omit<{
|
|
68
70
|
formItemSize: {
|
|
69
71
|
type: import("vue").PropType<"default" | "small" | "large">;
|
|
@@ -95,7 +97,7 @@ declare const _default: import("vue").DefineComponent<Omit<{
|
|
|
95
97
|
};
|
|
96
98
|
required: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, undefined, boolean>;
|
|
97
99
|
rules: {
|
|
98
|
-
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) =>
|
|
100
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => FormItemRule | FormItemRule[]) | (() => import("element-plus/es/utils").Arrayable<FormItemRule>) | ((new (...args: any[]) => FormItemRule | FormItemRule[]) | (() => import("element-plus/es/utils").Arrayable<FormItemRule>))[], unknown, unknown>>;
|
|
99
101
|
readonly required: false;
|
|
100
102
|
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
101
103
|
__epPropKey: true;
|
package/index.css
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
|
|
2
|
+
.el-cascader.is-readonly{
|
|
3
|
+
--el-readonly-cursor: text;
|
|
4
|
+
--el-disabled-bg-color: initial;
|
|
5
|
+
--el-disabled-text-color: var(--el-input-text-color);
|
|
6
|
+
}
|
|
7
|
+
.el-cascader.is-readonly .el-input.is-disabled .el-input__inner,
|
|
8
|
+
.el-cascader.is-readonly .el-input.is-disabled{
|
|
9
|
+
cursor: var(--el-readonly-cursor);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
2
13
|
.el-checkbox-group.is-readonly .el-checkbox,
|
|
3
14
|
.el-checkbox-group.is-readonly{
|
|
4
15
|
--el-readonly-cursor: auto;
|
|
@@ -182,6 +193,9 @@
|
|
|
182
193
|
|
|
183
194
|
|
|
184
195
|
|
|
196
|
+
.vkf-upload {
|
|
197
|
+
width: 100%;
|
|
198
|
+
}
|
|
185
199
|
.vkf-upload-empty-tip{
|
|
186
200
|
display: none;
|
|
187
201
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ElMessage } from 'element-plus';
|
|
2
|
+
|
|
3
|
+
const validateCatch = (err) => {
|
|
4
|
+
let msg = "";
|
|
5
|
+
for (const key in err) {
|
|
6
|
+
err[key].forEach((v) => {
|
|
7
|
+
msg += v.message + ";";
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
ElMessage({
|
|
11
|
+
type: "warning",
|
|
12
|
+
message: msg
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { validateCatch };
|