@vunk/form 1.1.14 → 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.
|
@@ -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);
|
|
@@ -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
|
}
|