@carefrees/form-utils-vue 0.0.10 → 0.0.12
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 +56 -2
- package/assets/index.css +23 -12
- package/esm/component.js +3 -0
- package/esm/form/form.js +156 -0
- package/esm/form/form.vue.d.ts +10 -7
- package/esm/form/index.d.ts +12 -12
- package/esm/form/index.js +4 -0
- package/esm/formItem/form.Item.base.js +162 -0
- package/esm/formItem/form.Item.base.vue.d.ts +6 -8
- package/esm/formItem/form.hide.item.js +126 -0
- package/esm/formItem/form.hide.item.vue.d.ts +6 -8
- package/esm/formItem/formItem.js +155 -0
- package/esm/formItem/formItem.vue.d.ts +6 -9
- package/esm/formItem/index.d.ts +24 -37
- package/esm/formItem/index.js +8 -0
- package/esm/hooks/attr/attr.FormItem.d.ts +5 -5
- package/esm/hooks/attr/attr.FormItem.js +97 -0
- package/esm/hooks/index.js +13 -0
- package/esm/hooks/register/register.FormHideItem.d.ts +2 -2
- package/esm/hooks/register/register.FormHideItem.js +42 -0
- package/esm/hooks/register/register.FormItem.d.ts +9 -6
- package/esm/hooks/register/register.FormItem.js +67 -0
- package/esm/hooks/register/register.FormList.d.ts +3 -3
- package/esm/hooks/register/register.FormList.js +42 -0
- package/esm/hooks/register/register.form.d.ts +1 -1
- package/esm/hooks/register/register.form.js +10 -0
- package/esm/hooks/useAttrs.d.ts +1 -0
- package/esm/hooks/useAttrs.js +26 -0
- package/esm/hooks/useEffect.js +12 -0
- package/esm/hooks/useForm.d.ts +1 -1
- package/esm/hooks/useForm.js +17 -0
- package/esm/hooks/useFormItem.js +17 -0
- package/esm/hooks/useFormItemParentName.js +47 -0
- package/esm/hooks/useFormList.js +17 -0
- package/esm/hooks/useHtmlFor.d.ts +1 -1
- package/esm/hooks/useHtmlFor.js +7 -0
- package/esm/hooks/useMultipleForm.d.ts +1 -1
- package/esm/hooks/useMultipleForm.js +18 -0
- package/esm/index.d.ts +1 -1
- package/esm/index.js +13 -0
- package/esm/instance/ruleIntsnace.d.ts +1 -1
- package/esm/instance/ruleIntsnace.js +65 -0
- package/esm/interface/index.d.ts +2 -0
- package/esm/interface/index.js +0 -0
- package/esm/interface/layout.formItem.js +0 -0
- package/esm/interface/layout.js +0 -0
- package/esm/layout/index.d.ts +24 -33
- package/esm/layout/index.js +8 -0
- package/esm/layout/layout.form.rows.js +21 -0
- package/esm/layout/layout.form.rows.vue.d.ts +8 -5
- package/esm/layout/layout.formItem.js +195 -0
- package/esm/layout/layout.formItem.vue.d.ts +6 -9
- package/esm/layout/layout.js +160 -0
- package/esm/layout/layout.vue.d.ts +6 -8
- package/esm/utils/index.js +1 -0
- package/esm/utils/withInstall.d.ts +2 -2
- package/esm/utils/withInstall.js +15 -0
- package/package.json +6 -8
- package/src/form/form.vue +8 -1
- package/src/interface/index.ts +2 -0
- package/esm/component.mjs +0 -12
- package/esm/form/form.vue.mjs +0 -110
- package/esm/form/form.vue2.mjs +0 -4
- package/esm/form/index.mjs +0 -6
- package/esm/formItem/form.Item.base.vue.mjs +0 -114
- package/esm/formItem/form.Item.base.vue2.mjs +0 -4
- package/esm/formItem/form.hide.item.vue.mjs +0 -78
- package/esm/formItem/form.hide.item.vue2.mjs +0 -4
- package/esm/formItem/formItem.vue.mjs +0 -102
- package/esm/formItem/formItem.vue2.mjs +0 -4
- package/esm/formItem/index.mjs +0 -12
- package/esm/hooks/attr/attr.FormItem.mjs +0 -120
- package/esm/hooks/register/register.FormHideItem.mjs +0 -38
- package/esm/hooks/register/register.FormItem.mjs +0 -55
- package/esm/hooks/register/register.FormList.mjs +0 -43
- package/esm/hooks/register/register.form.mjs +0 -12
- package/esm/hooks/useAttrs.mjs +0 -43
- package/esm/hooks/useEffect.mjs +0 -14
- package/esm/hooks/useForm.mjs +0 -26
- package/esm/hooks/useFormItem.mjs +0 -26
- package/esm/hooks/useFormItemParentName.mjs +0 -37
- package/esm/hooks/useFormList.mjs +0 -26
- package/esm/hooks/useHtmlFor.mjs +0 -11
- package/esm/hooks/useMultipleForm.mjs +0 -27
- package/esm/index.mjs +0 -59
- package/esm/instance/ruleIntsnace.mjs +0 -73
- package/esm/layout/index.mjs +0 -12
- package/esm/layout/layout.form.rows.vue.mjs +0 -31
- package/esm/layout/layout.form.rows.vue2.mjs +0 -4
- package/esm/layout/layout.formItem.vue.mjs +0 -216
- package/esm/layout/layout.formItem.vue2.mjs +0 -4
- package/esm/layout/layout.vue.mjs +0 -166
- package/esm/layout/layout.vue2.mjs +0 -4
- package/esm/utils/withInstall.mjs +0 -22
- package/lib/component.d.ts +0 -3
- package/lib/component.js +0 -12
- package/lib/form/form.vue.d.ts +0 -19
- package/lib/form/form.vue.js +0 -110
- package/lib/form/form.vue2.js +0 -4
- package/lib/form/index.d.ts +0 -37
- package/lib/form/index.js +0 -6
- package/lib/formItem/form.Item.base.vue.d.ts +0 -16
- package/lib/formItem/form.Item.base.vue.js +0 -114
- package/lib/formItem/form.Item.base.vue2.js +0 -4
- package/lib/formItem/form.hide.item.vue.d.ts +0 -16
- package/lib/formItem/form.hide.item.vue.js +0 -78
- package/lib/formItem/form.hide.item.vue2.js +0 -4
- package/lib/formItem/formItem.vue.d.ts +0 -18
- package/lib/formItem/formItem.vue.js +0 -102
- package/lib/formItem/formItem.vue2.js +0 -4
- package/lib/formItem/index.d.ts +0 -71
- package/lib/formItem/index.js +0 -12
- package/lib/hooks/attr/attr.FormItem.d.ts +0 -97
- package/lib/hooks/attr/attr.FormItem.js +0 -120
- package/lib/hooks/index.d.ts +0 -13
- package/lib/hooks/register/register.FormHideItem.d.ts +0 -9
- package/lib/hooks/register/register.FormHideItem.js +0 -38
- package/lib/hooks/register/register.FormItem.d.ts +0 -23
- package/lib/hooks/register/register.FormItem.js +0 -55
- package/lib/hooks/register/register.FormList.d.ts +0 -9
- package/lib/hooks/register/register.FormList.js +0 -43
- package/lib/hooks/register/register.form.d.ts +0 -3
- package/lib/hooks/register/register.form.js +0 -12
- package/lib/hooks/useAttrs.d.ts +0 -24
- package/lib/hooks/useAttrs.js +0 -43
- package/lib/hooks/useEffect.d.ts +0 -2
- package/lib/hooks/useEffect.js +0 -14
- package/lib/hooks/useForm.d.ts +0 -8
- package/lib/hooks/useForm.js +0 -26
- package/lib/hooks/useFormItem.d.ts +0 -7
- package/lib/hooks/useFormItem.js +0 -26
- package/lib/hooks/useFormItemParentName.d.ts +0 -18
- package/lib/hooks/useFormItemParentName.js +0 -37
- package/lib/hooks/useFormList.d.ts +0 -7
- package/lib/hooks/useFormList.js +0 -26
- package/lib/hooks/useHtmlFor.d.ts +0 -2
- package/lib/hooks/useHtmlFor.js +0 -11
- package/lib/hooks/useMultipleForm.d.ts +0 -7
- package/lib/hooks/useMultipleForm.js +0 -27
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -59
- package/lib/instance/ruleIntsnace.d.ts +0 -49
- package/lib/instance/ruleIntsnace.js +0 -73
- package/lib/interface/index.d.ts +0 -36
- package/lib/interface/layout.d.ts +0 -28
- package/lib/interface/layout.formItem.d.ts +0 -39
- package/lib/layout/index.d.ts +0 -65
- package/lib/layout/index.js +0 -12
- package/lib/layout/layout.form.rows.vue.d.ts +0 -10
- package/lib/layout/layout.form.rows.vue.js +0 -31
- package/lib/layout/layout.form.rows.vue2.js +0 -4
- package/lib/layout/layout.formItem.vue.d.ts +0 -18
- package/lib/layout/layout.formItem.vue.js +0 -216
- package/lib/layout/layout.formItem.vue2.js +0 -4
- package/lib/layout/layout.vue.d.ts +0 -16
- package/lib/layout/layout.vue.js +0 -166
- package/lib/layout/layout.vue2.js +0 -4
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/withInstall.d.ts +0 -3
- package/lib/utils/withInstall.js +0 -22
- package/src/vite-env.d.ts +0 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderSlot, toDisplayString, toValue, useSlots } from "vue";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import { useAttrsInject } from "../hooks/useAttrs.js";
|
|
4
|
+
const _hoisted_1 = [
|
|
5
|
+
"for"
|
|
6
|
+
];
|
|
7
|
+
const preCls = "carefrees-form-item";
|
|
8
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
9
|
+
name: "LayoutFormItem",
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
__name: "layout.formItem",
|
|
12
|
+
props: {
|
|
13
|
+
errorLayout: {},
|
|
14
|
+
required: {
|
|
15
|
+
type: Boolean
|
|
16
|
+
},
|
|
17
|
+
labelMode: {},
|
|
18
|
+
onlyRuleStyle: {
|
|
19
|
+
type: Boolean
|
|
20
|
+
},
|
|
21
|
+
label: {
|
|
22
|
+
type: [
|
|
23
|
+
Object,
|
|
24
|
+
String,
|
|
25
|
+
Number,
|
|
26
|
+
Boolean,
|
|
27
|
+
null,
|
|
28
|
+
Array
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
helpText: {
|
|
32
|
+
type: [
|
|
33
|
+
Object,
|
|
34
|
+
String,
|
|
35
|
+
Number,
|
|
36
|
+
Boolean,
|
|
37
|
+
null,
|
|
38
|
+
Array
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
extra: {
|
|
42
|
+
type: [
|
|
43
|
+
Object,
|
|
44
|
+
String,
|
|
45
|
+
Number,
|
|
46
|
+
Boolean,
|
|
47
|
+
null,
|
|
48
|
+
Array
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
showColon: {
|
|
52
|
+
type: Boolean
|
|
53
|
+
},
|
|
54
|
+
colSpan: {},
|
|
55
|
+
rowSpan: {},
|
|
56
|
+
htmlFor: {},
|
|
57
|
+
validateResult: {},
|
|
58
|
+
style: {
|
|
59
|
+
type: [
|
|
60
|
+
Boolean,
|
|
61
|
+
null,
|
|
62
|
+
String,
|
|
63
|
+
Object,
|
|
64
|
+
Array
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
class: {},
|
|
68
|
+
labelStyle: {
|
|
69
|
+
type: [
|
|
70
|
+
Boolean,
|
|
71
|
+
null,
|
|
72
|
+
String,
|
|
73
|
+
Object,
|
|
74
|
+
Array
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
labelClass: {}
|
|
78
|
+
},
|
|
79
|
+
setup (__props) {
|
|
80
|
+
const attrs = useAttrsInject();
|
|
81
|
+
const props = __props;
|
|
82
|
+
const solts = useSlots();
|
|
83
|
+
const labelMode = computed(()=>props.labelMode ?? toValue(attrs.value.labelMode) ?? "top");
|
|
84
|
+
const showColon = computed(()=>props.showColon ?? toValue(attrs.value.showColon));
|
|
85
|
+
const errorLayout = computed(()=>props.errorLayout ?? toValue(attrs.value.errorLayout) ?? "left-bottom");
|
|
86
|
+
const tips = computed(()=>{
|
|
87
|
+
const v = toValue(props.validateResult)?.tip;
|
|
88
|
+
if (Array.isArray(v)) return v.join(",");
|
|
89
|
+
return v;
|
|
90
|
+
});
|
|
91
|
+
const cls = computed(()=>classnames(preCls, props.class, toValue(attrs.value.formItemClass), {
|
|
92
|
+
"dx-invalid": !!toValue(props.validateResult)?.isInvalid
|
|
93
|
+
}));
|
|
94
|
+
const containerCls = computed(()=>classnames(`${preCls}-container`, {
|
|
95
|
+
[`${labelMode.value}`]: !!labelMode.value
|
|
96
|
+
}));
|
|
97
|
+
const labelCls = computed(()=>classnames(`${preCls}-label`, {
|
|
98
|
+
required: !!props.required,
|
|
99
|
+
"show-colon": showColon && ("left" === labelMode.value || "between" === labelMode.value)
|
|
100
|
+
}));
|
|
101
|
+
const labelWarpCls = computed(()=>classnames(`${preCls}-label-warp`, toValue(props.labelClass), toValue(attrs.value.formItemLabelClass)));
|
|
102
|
+
const inputCls = computed(()=>classnames(`${preCls}-body-input`));
|
|
103
|
+
const errorCls = computed(()=>classnames(`${preCls}-body-error`, {
|
|
104
|
+
[errorLayout.value]: !!errorLayout.value
|
|
105
|
+
}));
|
|
106
|
+
const _isLabel = computed(()=>(props.label || solts.label) && "hide" !== labelMode.value);
|
|
107
|
+
const style = computed(()=>{
|
|
108
|
+
const css = {};
|
|
109
|
+
if (props.onlyRuleStyle) css.padding = "0px";
|
|
110
|
+
if (props.colSpan) {
|
|
111
|
+
const colCount = toValue(attrs.value.colCount) || 4;
|
|
112
|
+
const end = colCount > props.colSpan ? props.colSpan : colCount;
|
|
113
|
+
css.gridColumnEnd = `span ${end}`;
|
|
114
|
+
}
|
|
115
|
+
if (props.rowSpan) css.gridRowEnd = `span ${props.rowSpan}`;
|
|
116
|
+
return [
|
|
117
|
+
toValue(attrs.value.formItemStyle),
|
|
118
|
+
props.style,
|
|
119
|
+
css
|
|
120
|
+
];
|
|
121
|
+
});
|
|
122
|
+
const labelStyle = computed(()=>[
|
|
123
|
+
toValue(attrs.value.formItemLabelStyle),
|
|
124
|
+
props.labelStyle
|
|
125
|
+
]);
|
|
126
|
+
const isHelpText = computed(()=>!!props.helpText || solts.helpText);
|
|
127
|
+
const isExtra = computed(()=>!!props.extra || solts.extra);
|
|
128
|
+
return (_ctx, _cache)=>(openBlock(), createElementBlock("div", {
|
|
129
|
+
class: normalizeClass(cls.value),
|
|
130
|
+
style: normalizeStyle(style.value)
|
|
131
|
+
}, [
|
|
132
|
+
createElementVNode("div", {
|
|
133
|
+
class: normalizeClass(containerCls.value)
|
|
134
|
+
}, [
|
|
135
|
+
_isLabel.value ? (openBlock(), createElementBlock("div", {
|
|
136
|
+
key: 0,
|
|
137
|
+
class: normalizeClass(labelWarpCls.value)
|
|
138
|
+
}, [
|
|
139
|
+
createElementVNode("label", {
|
|
140
|
+
style: normalizeStyle(labelStyle.value),
|
|
141
|
+
class: normalizeClass(labelCls.value),
|
|
142
|
+
for: toValue(props.htmlFor)
|
|
143
|
+
}, [
|
|
144
|
+
props.label ? (openBlock(), createElementBlock(Fragment, {
|
|
145
|
+
key: 0
|
|
146
|
+
}, [
|
|
147
|
+
createTextVNode(toDisplayString(props.label), 1)
|
|
148
|
+
], 64)) : renderSlot(_ctx.$slots, "label", {
|
|
149
|
+
key: 1
|
|
150
|
+
})
|
|
151
|
+
], 14, _hoisted_1)
|
|
152
|
+
], 2)) : createCommentVNode("", true),
|
|
153
|
+
createElementVNode("div", {
|
|
154
|
+
class: normalizeClass(preCls + "-body")
|
|
155
|
+
}, [
|
|
156
|
+
createElementVNode("div", {
|
|
157
|
+
class: normalizeClass(inputCls.value)
|
|
158
|
+
}, [
|
|
159
|
+
renderSlot(_ctx.$slots, "default")
|
|
160
|
+
], 2),
|
|
161
|
+
isHelpText.value ? (openBlock(), createElementBlock("div", {
|
|
162
|
+
key: 0,
|
|
163
|
+
class: normalizeClass(preCls + "-body-help")
|
|
164
|
+
}, [
|
|
165
|
+
props.helpText ? (openBlock(), createElementBlock(Fragment, {
|
|
166
|
+
key: 0
|
|
167
|
+
}, [
|
|
168
|
+
createTextVNode(toDisplayString(props.helpText), 1)
|
|
169
|
+
], 64)) : renderSlot(_ctx.$slots, "helpText", {
|
|
170
|
+
key: 1
|
|
171
|
+
})
|
|
172
|
+
], 2)) : createCommentVNode("", true),
|
|
173
|
+
tips.value ? (openBlock(), createElementBlock("div", {
|
|
174
|
+
key: 1,
|
|
175
|
+
class: normalizeClass(errorCls.value)
|
|
176
|
+
}, toDisplayString(tips.value), 3)) : createCommentVNode("", true)
|
|
177
|
+
], 2)
|
|
178
|
+
], 2),
|
|
179
|
+
isExtra.value ? (openBlock(), createElementBlock("div", {
|
|
180
|
+
key: 0,
|
|
181
|
+
class: normalizeClass(preCls + "-extra")
|
|
182
|
+
}, [
|
|
183
|
+
props.extra ? (openBlock(), createElementBlock(Fragment, {
|
|
184
|
+
key: 0
|
|
185
|
+
}, [
|
|
186
|
+
createTextVNode(toDisplayString(props.extra), 1)
|
|
187
|
+
], 64)) : renderSlot(_ctx.$slots, "extra", {
|
|
188
|
+
key: 1
|
|
189
|
+
})
|
|
190
|
+
], 2)) : createCommentVNode("", true)
|
|
191
|
+
], 6));
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const layout_formItem = _sfc_main;
|
|
195
|
+
export { layout_formItem as default };
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { LayoutFormItemProps } from
|
|
2
|
-
|
|
1
|
+
import type { LayoutFormItemProps } from "../interface/layout.formItem";
|
|
2
|
+
type __VLS_Slots = {
|
|
3
3
|
default: any;
|
|
4
4
|
label: any;
|
|
5
5
|
helpText: any;
|
|
6
6
|
extra: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
helpText: any;
|
|
11
|
-
extra: any;
|
|
12
|
-
}>;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_component: import("vue").DefineComponent<LayoutFormItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<LayoutFormItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
13
10
|
export default _default;
|
|
14
|
-
type
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
15
12
|
new (): {
|
|
16
13
|
$slots: S;
|
|
17
14
|
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderSlot, toDisplayString, toValue, useSlots } from "vue";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import { useAttrsInject, useAttrsProvide } from "../hooks/useAttrs.js";
|
|
4
|
+
const preCls = "carefrees-form-layout";
|
|
5
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "Layout",
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
__name: "layout",
|
|
9
|
+
props: {
|
|
10
|
+
title: {
|
|
11
|
+
type: [
|
|
12
|
+
Object,
|
|
13
|
+
String,
|
|
14
|
+
Number,
|
|
15
|
+
Boolean,
|
|
16
|
+
null,
|
|
17
|
+
Array
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
extra: {
|
|
21
|
+
type: [
|
|
22
|
+
Object,
|
|
23
|
+
String,
|
|
24
|
+
Number,
|
|
25
|
+
Boolean,
|
|
26
|
+
null,
|
|
27
|
+
Array
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
isAllColSpan: {
|
|
31
|
+
type: Boolean
|
|
32
|
+
},
|
|
33
|
+
class: {},
|
|
34
|
+
headerClass: {},
|
|
35
|
+
bodyClass: {},
|
|
36
|
+
style: {
|
|
37
|
+
type: [
|
|
38
|
+
Boolean,
|
|
39
|
+
null,
|
|
40
|
+
String,
|
|
41
|
+
Object,
|
|
42
|
+
Array
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
headerStyle: {
|
|
46
|
+
type: [
|
|
47
|
+
Boolean,
|
|
48
|
+
null,
|
|
49
|
+
String,
|
|
50
|
+
Object,
|
|
51
|
+
Array
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
bodyStyle: {
|
|
55
|
+
type: [
|
|
56
|
+
Boolean,
|
|
57
|
+
null,
|
|
58
|
+
String,
|
|
59
|
+
Object,
|
|
60
|
+
Array
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
bordered: {
|
|
64
|
+
type: Boolean
|
|
65
|
+
},
|
|
66
|
+
colCount: {},
|
|
67
|
+
gap: {},
|
|
68
|
+
errorLayout: {},
|
|
69
|
+
labelMode: {},
|
|
70
|
+
showColon: {},
|
|
71
|
+
formItemClass: {},
|
|
72
|
+
formItemStyle: {},
|
|
73
|
+
formItemLabelClass: {},
|
|
74
|
+
formItemLabelStyle: {}
|
|
75
|
+
},
|
|
76
|
+
setup (__props) {
|
|
77
|
+
const attrs = useAttrsInject();
|
|
78
|
+
const props = __props;
|
|
79
|
+
const solts = useSlots();
|
|
80
|
+
const colCount = computed(()=>toValue(props.colCount) ?? toValue(attrs.value.colCount));
|
|
81
|
+
const errorLayout = computed(()=>toValue(props.errorLayout) ?? toValue(attrs.value.errorLayout));
|
|
82
|
+
const labelMode = computed(()=>toValue(props.labelMode) ?? toValue(attrs.value.labelMode));
|
|
83
|
+
const showColon = computed(()=>toValue(props.showColon) ?? toValue(attrs.value.showColon));
|
|
84
|
+
const formItemClass = computed(()=>toValue(props.formItemClass) ?? toValue(attrs.value.formItemClass));
|
|
85
|
+
const formItemStyle = computed(()=>toValue(props.formItemStyle) ?? toValue(attrs.value.formItemStyle));
|
|
86
|
+
const formItemLabelClass = computed(()=>toValue(props.formItemLabelClass) ?? toValue(attrs.value.formItemLabelClass));
|
|
87
|
+
const formItemLabelStyle = computed(()=>toValue(props.formItemLabelStyle) ?? toValue(attrs.value.formItemLabelStyle));
|
|
88
|
+
useAttrsProvide({
|
|
89
|
+
colCount,
|
|
90
|
+
errorLayout,
|
|
91
|
+
labelMode,
|
|
92
|
+
showColon,
|
|
93
|
+
formItemClass,
|
|
94
|
+
formItemStyle,
|
|
95
|
+
formItemLabelClass,
|
|
96
|
+
formItemLabelStyle
|
|
97
|
+
});
|
|
98
|
+
const cls = computed(()=>classnames(preCls, props.class, {
|
|
99
|
+
"all-colspan": props.isAllColSpan,
|
|
100
|
+
bordered: props.bordered
|
|
101
|
+
}));
|
|
102
|
+
const bodyCls = computed(()=>classnames(`${preCls}-body`, props.bodyClass));
|
|
103
|
+
const headerCls = computed(()=>classnames(`${preCls}-header`, props.headerClass));
|
|
104
|
+
const headerTitleCls = computed(()=>classnames(`${preCls}-header-title`));
|
|
105
|
+
const headerExtraCls = computed(()=>classnames(`${preCls}-header-extra`));
|
|
106
|
+
const bodyStyle = computed(()=>{
|
|
107
|
+
const css = {};
|
|
108
|
+
if ("string" == typeof props.gap) css.gap = props.gap;
|
|
109
|
+
if ("number" == typeof props.gap) css.gap = `${props.gap}px`;
|
|
110
|
+
if (colCount.value) css.gridTemplateColumns = `repeat(${colCount.value}, auto)`;
|
|
111
|
+
return [
|
|
112
|
+
css,
|
|
113
|
+
props.bodyStyle
|
|
114
|
+
];
|
|
115
|
+
});
|
|
116
|
+
const isTitle = computed(()=>!!props.title || solts.title);
|
|
117
|
+
const isExtra = computed(()=>!!props.extra || solts.extra);
|
|
118
|
+
return (_ctx, _cache)=>(openBlock(), createElementBlock("div", {
|
|
119
|
+
style: normalizeStyle(props.style),
|
|
120
|
+
class: normalizeClass(cls.value)
|
|
121
|
+
}, [
|
|
122
|
+
isExtra.value || isTitle.value ? (openBlock(), createElementBlock("div", {
|
|
123
|
+
key: 0,
|
|
124
|
+
style: normalizeStyle(_ctx.headerStyle),
|
|
125
|
+
class: normalizeClass(headerCls.value)
|
|
126
|
+
}, [
|
|
127
|
+
createElementVNode("div", {
|
|
128
|
+
class: normalizeClass(headerTitleCls.value)
|
|
129
|
+
}, [
|
|
130
|
+
props.title ? (openBlock(), createElementBlock(Fragment, {
|
|
131
|
+
key: 0
|
|
132
|
+
}, [
|
|
133
|
+
createTextVNode(toDisplayString(props.title), 1)
|
|
134
|
+
], 64)) : renderSlot(_ctx.$slots, "title", {
|
|
135
|
+
key: 1
|
|
136
|
+
})
|
|
137
|
+
], 2),
|
|
138
|
+
createElementVNode("div", {
|
|
139
|
+
class: normalizeClass(headerExtraCls.value)
|
|
140
|
+
}, [
|
|
141
|
+
props.extra ? (openBlock(), createElementBlock(Fragment, {
|
|
142
|
+
key: 0
|
|
143
|
+
}, [
|
|
144
|
+
createTextVNode(toDisplayString(props.extra), 1)
|
|
145
|
+
], 64)) : renderSlot(_ctx.$slots, "extra", {
|
|
146
|
+
key: 1
|
|
147
|
+
})
|
|
148
|
+
], 2)
|
|
149
|
+
], 6)) : createCommentVNode("", true),
|
|
150
|
+
createElementVNode("div", {
|
|
151
|
+
style: normalizeStyle(bodyStyle.value),
|
|
152
|
+
class: normalizeClass(bodyCls.value)
|
|
153
|
+
}, [
|
|
154
|
+
renderSlot(_ctx.$slots, "default")
|
|
155
|
+
], 6)
|
|
156
|
+
], 6));
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
const layout = _sfc_main;
|
|
160
|
+
export { layout as default };
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { FormLayoutProps } from
|
|
2
|
-
|
|
1
|
+
import type { FormLayoutProps } from "../interface/layout";
|
|
2
|
+
type __VLS_Slots = {
|
|
3
3
|
default: any;
|
|
4
4
|
title: any;
|
|
5
5
|
extra: any;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
extra: any;
|
|
10
|
-
}>;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_component: import("vue").DefineComponent<FormLayoutProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormLayoutProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
11
9
|
export default _default;
|
|
12
|
-
type
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
13
11
|
new (): {
|
|
14
12
|
$slots: S;
|
|
15
13
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./withInstall.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Plugin } from 'vue';
|
|
1
|
+
import type { Plugin } from 'vue';
|
|
2
2
|
export type SFCWithInstall<T> = T & Plugin;
|
|
3
|
-
export declare const withInstall: <T, E extends Record<string, any> = Record<string, any>, K extends Record<string, any> = Record<string, any>>(main: T, extra?: E
|
|
3
|
+
export declare const withInstall: <T, E extends Record<string, any> = Record<string, any>, K extends Record<string, any> = Record<string, any>>(main: T, extra?: E, childComponents?: K) => SFCWithInstall<T> & E & K;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const withInstall = (main, extra, childComponents)=>{
|
|
2
|
+
main.install = (app)=>{
|
|
3
|
+
for (const comp of [
|
|
4
|
+
main,
|
|
5
|
+
...Object.values(childComponents ?? {})
|
|
6
|
+
]){
|
|
7
|
+
const name = comp.name || comp.__name;
|
|
8
|
+
app.component(name, comp);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
if (childComponents) for (const [key, comp] of Object.entries(childComponents))main[key] = comp;
|
|
12
|
+
if (extra) for (const [key, comp] of Object.entries(extra))main[key] = comp;
|
|
13
|
+
return main;
|
|
14
|
+
};
|
|
15
|
+
export { withInstall };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carefrees/form-utils-vue",
|
|
3
3
|
"author": "SunLxy <1011771396@qq.com>",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.12",
|
|
5
5
|
"description": "",
|
|
6
|
-
"main": "
|
|
7
|
-
"module": "esm/index.
|
|
6
|
+
"main": "esm/index.js",
|
|
7
|
+
"module": "esm/index.js",
|
|
8
8
|
"types": "esm/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "
|
|
11
|
-
"watch": "
|
|
10
|
+
"build": "carefrees-rslib build --vue --esm",
|
|
11
|
+
"watch": "carefrees-rslib build --watch --vue --esm"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -16,17 +16,15 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"assets",
|
|
18
18
|
"src",
|
|
19
|
-
"lib",
|
|
20
19
|
"esm"
|
|
21
20
|
],
|
|
22
21
|
"keywords": [],
|
|
23
22
|
"license": "ISC",
|
|
24
23
|
"devDependencies": {
|
|
25
|
-
"@saqu-vue/core": "^1.0.1",
|
|
26
24
|
"vue": "^3.5.13"
|
|
27
25
|
},
|
|
28
26
|
"dependencies": {
|
|
29
|
-
"@carefrees/form-utils": "^0.0.
|
|
27
|
+
"@carefrees/form-utils": "^0.0.12",
|
|
30
28
|
"async-validator": "~4.2.5",
|
|
31
29
|
"classnames": "2.5.1"
|
|
32
30
|
}
|
package/src/form/form.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<form :class='cls' :style='
|
|
2
|
+
<form :class='cls' :style='formStyle' @submit='onSubmit'>
|
|
3
3
|
<FormLayout v-bind='rest' :class='layoutClass' :style='layoutStyle'>
|
|
4
4
|
<slot />
|
|
5
5
|
</FormLayout>
|
|
@@ -34,11 +34,18 @@ const {
|
|
|
34
34
|
onValuesChange,
|
|
35
35
|
layoutStyle,
|
|
36
36
|
layoutClass,
|
|
37
|
+
bgcolor,
|
|
37
38
|
...rest
|
|
38
39
|
} = props
|
|
39
40
|
|
|
40
41
|
const cls = computed(() => clx('carefrees-form', props.class));
|
|
41
42
|
|
|
43
|
+
const formStyle = computed(() => {
|
|
44
|
+
if (bgcolor)
|
|
45
|
+
return [{ backgroundColor: bgcolor }, props.style];
|
|
46
|
+
return [props.style]
|
|
47
|
+
});
|
|
48
|
+
|
|
42
49
|
const formInstance = useForm(props.form);
|
|
43
50
|
formInstance.value.ctor(reactive(props.formData || {}), reactive(props.hideData || {}), reactive(props.hideRuleData || {}));
|
|
44
51
|
|
package/src/interface/index.ts
CHANGED
package/esm/component.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Form } from "./form/index.mjs";
|
|
2
|
-
import { FormHideItem, FormItem, FormItemBase } from "./formItem/index.mjs";
|
|
3
|
-
import { FormLayoutRows, Layout, LayoutFormItem } from "./layout/index.mjs";
|
|
4
|
-
export {
|
|
5
|
-
Form,
|
|
6
|
-
FormHideItem,
|
|
7
|
-
FormItem,
|
|
8
|
-
FormItemBase,
|
|
9
|
-
FormLayoutRows,
|
|
10
|
-
Layout,
|
|
11
|
-
LayoutFormItem
|
|
12
|
-
};
|
package/esm/form/form.vue.mjs
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { defineComponent, computed, reactive, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createVNode, mergeProps, withCtx, renderSlot } from "vue";
|
|
2
|
-
import { useRegisterForm } from "../hooks/register/register.form.mjs";
|
|
3
|
-
import { useForm, useFormProvide } from "../hooks/useForm.mjs";
|
|
4
|
-
import _sfc_main$1 from "../layout/layout.vue.mjs";
|
|
5
|
-
import clx from "classnames";
|
|
6
|
-
const __default__ = defineComponent({
|
|
7
|
-
name: "Form",
|
|
8
|
-
inheritAttrs: false
|
|
9
|
-
// 可选,防止属性自动应用到根元素
|
|
10
|
-
});
|
|
11
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
12
|
-
...__default__,
|
|
13
|
-
props: {
|
|
14
|
-
form: {},
|
|
15
|
-
style: { type: [Boolean, null, String, Object, Array] },
|
|
16
|
-
class: {},
|
|
17
|
-
layoutClass: {},
|
|
18
|
-
layoutStyle: { type: [Boolean, null, String, Object, Array] },
|
|
19
|
-
formData: {},
|
|
20
|
-
onValuesChange: {},
|
|
21
|
-
onFinish: {},
|
|
22
|
-
onFinishFailed: {},
|
|
23
|
-
hideData: {},
|
|
24
|
-
name: {},
|
|
25
|
-
hideRuleData: {},
|
|
26
|
-
title: { type: [Object, String, Number, Boolean, null, Array] },
|
|
27
|
-
extra: { type: [Object, String, Number, Boolean, null, Array] },
|
|
28
|
-
isAllColSpan: { type: Boolean },
|
|
29
|
-
headerClass: {},
|
|
30
|
-
bodyClass: {},
|
|
31
|
-
headerStyle: { type: [Boolean, null, String, Object, Array] },
|
|
32
|
-
bodyStyle: { type: [Boolean, null, String, Object, Array] },
|
|
33
|
-
bordered: { type: Boolean },
|
|
34
|
-
colCount: {},
|
|
35
|
-
gap: {},
|
|
36
|
-
errorLayout: {},
|
|
37
|
-
labelMode: {},
|
|
38
|
-
showColon: {},
|
|
39
|
-
formItemClass: {},
|
|
40
|
-
formItemStyle: {},
|
|
41
|
-
formItemLabelClass: {},
|
|
42
|
-
formItemLabelStyle: {}
|
|
43
|
-
},
|
|
44
|
-
emits: ["finish", "valuesChange", "finishFailed"],
|
|
45
|
-
setup(__props, { emit: __emit }) {
|
|
46
|
-
const props = __props;
|
|
47
|
-
const {
|
|
48
|
-
form,
|
|
49
|
-
style,
|
|
50
|
-
formData,
|
|
51
|
-
hideData,
|
|
52
|
-
hideRuleData,
|
|
53
|
-
name,
|
|
54
|
-
onFinish,
|
|
55
|
-
onFinishFailed,
|
|
56
|
-
onValuesChange,
|
|
57
|
-
layoutStyle,
|
|
58
|
-
layoutClass,
|
|
59
|
-
...rest
|
|
60
|
-
} = props;
|
|
61
|
-
const cls = computed(() => clx("carefrees-form", props.class));
|
|
62
|
-
const formInstance = useForm(props.form);
|
|
63
|
-
formInstance.value.ctor(reactive(props.formData || {}), reactive(props.hideData || {}), reactive(props.hideRuleData || {}));
|
|
64
|
-
const emits = __emit;
|
|
65
|
-
formInstance.value.onFinish = (...rest2) => {
|
|
66
|
-
emits("finish", ...rest2);
|
|
67
|
-
};
|
|
68
|
-
formInstance.value.onValuesChange = (...rest2) => {
|
|
69
|
-
emits("valuesChange", ...rest2);
|
|
70
|
-
};
|
|
71
|
-
formInstance.value.onFinishFailed = (...rest2) => {
|
|
72
|
-
emits("finishFailed", ...rest2);
|
|
73
|
-
};
|
|
74
|
-
useRegisterForm(formInstance.value, props.name);
|
|
75
|
-
const onSubmit = (event) => {
|
|
76
|
-
var _a, _b, _c, _d;
|
|
77
|
-
(_a = event == null ? void 0 : event.preventDefault) == null ? void 0 : _a.call(event);
|
|
78
|
-
(_b = event == null ? void 0 : event.stopPropagation) == null ? void 0 : _b.call(event);
|
|
79
|
-
(_d = (_c = formInstance.value).submit) == null ? void 0 : _d.call(_c);
|
|
80
|
-
};
|
|
81
|
-
useFormProvide(formInstance.value);
|
|
82
|
-
return (_ctx, _cache) => {
|
|
83
|
-
return openBlock(), createElementBlock(
|
|
84
|
-
"form",
|
|
85
|
-
{
|
|
86
|
-
class: normalizeClass(cls.value),
|
|
87
|
-
style: normalizeStyle(unref(style)),
|
|
88
|
-
onSubmit
|
|
89
|
-
},
|
|
90
|
-
[
|
|
91
|
-
createVNode(_sfc_main$1, mergeProps(rest, {
|
|
92
|
-
class: unref(layoutClass),
|
|
93
|
-
style: unref(layoutStyle)
|
|
94
|
-
}), {
|
|
95
|
-
default: withCtx(() => [
|
|
96
|
-
renderSlot(_ctx.$slots, "default")
|
|
97
|
-
]),
|
|
98
|
-
_: 3
|
|
99
|
-
/* FORWARDED */
|
|
100
|
-
}, 16, ["class", "style"])
|
|
101
|
-
],
|
|
102
|
-
38
|
|
103
|
-
/* CLASS, STYLE, NEED_HYDRATION */
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
export {
|
|
109
|
-
_sfc_main as default
|
|
110
|
-
};
|
package/esm/form/form.vue2.mjs
DELETED