@carefrees/form-utils-vue 0.0.11 → 0.0.13
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 +104 -2
- package/assets/index.css +23 -12
- package/esm/component.js +3 -0
- package/esm/form/form.js +161 -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 +157 -0
- package/esm/formItem/form.Item.base.vue.d.ts +7 -8
- package/esm/formItem/form.hide.item.js +122 -0
- package/esm/formItem/form.hide.item.vue.d.ts +7 -8
- package/esm/formItem/formItem.js +151 -0
- package/esm/formItem/formItem.vue.d.ts +6 -9
- package/esm/formItem/index.d.ts +26 -37
- package/esm/formItem/index.js +8 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.js +13 -0
- package/esm/interface/index.d.ts +6 -11
- package/esm/interface/index.js +0 -0
- package/esm/interface/layout.d.ts +1 -1
- package/esm/interface/layout.formItem.d.ts +1 -1
- 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 +7 -8
- package/src/form/form.vue +21 -7
- package/src/formItem/form.Item.base.vue +5 -5
- package/src/formItem/form.hide.item.vue +3 -1
- package/src/formItem/formItem.vue +2 -1
- package/src/index.ts +1 -1
- package/src/interface/index.ts +6 -13
- package/src/interface/layout.formItem.ts +1 -2
- package/src/interface/layout.ts +2 -1
- package/src/layout/layout.formItem.vue +2 -1
- package/src/layout/layout.vue +2 -1
- 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.d.ts +0 -97
- package/esm/hooks/attr/attr.FormItem.mjs +0 -120
- package/esm/hooks/index.d.ts +0 -13
- package/esm/hooks/register/register.FormHideItem.d.ts +0 -9
- package/esm/hooks/register/register.FormHideItem.mjs +0 -38
- package/esm/hooks/register/register.FormItem.d.ts +0 -23
- package/esm/hooks/register/register.FormItem.mjs +0 -55
- package/esm/hooks/register/register.FormList.d.ts +0 -9
- package/esm/hooks/register/register.FormList.mjs +0 -43
- package/esm/hooks/register/register.form.d.ts +0 -3
- package/esm/hooks/register/register.form.mjs +0 -12
- package/esm/hooks/useAttrs.d.ts +0 -24
- package/esm/hooks/useAttrs.mjs +0 -43
- package/esm/hooks/useEffect.d.ts +0 -2
- package/esm/hooks/useEffect.mjs +0 -14
- package/esm/hooks/useForm.d.ts +0 -8
- package/esm/hooks/useForm.mjs +0 -26
- package/esm/hooks/useFormItem.d.ts +0 -7
- package/esm/hooks/useFormItem.mjs +0 -26
- package/esm/hooks/useFormItemParentName.d.ts +0 -18
- package/esm/hooks/useFormItemParentName.mjs +0 -37
- package/esm/hooks/useFormList.d.ts +0 -7
- package/esm/hooks/useFormList.mjs +0 -26
- package/esm/hooks/useHtmlFor.d.ts +0 -2
- package/esm/hooks/useHtmlFor.mjs +0 -11
- package/esm/hooks/useMultipleForm.d.ts +0 -7
- package/esm/hooks/useMultipleForm.mjs +0 -27
- package/esm/index.mjs +0 -59
- package/esm/instance/ruleIntsnace.d.ts +0 -49
- 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/hooks/attr/attr.FormItem.tsx +0 -174
- package/src/hooks/index.ts +0 -13
- package/src/hooks/register/register.FormHideItem.ts +0 -45
- package/src/hooks/register/register.FormItem.ts +0 -80
- package/src/hooks/register/register.FormList.ts +0 -49
- package/src/hooks/register/register.form.ts +0 -12
- package/src/hooks/useAttrs.ts +0 -64
- package/src/hooks/useEffect.ts +0 -13
- package/src/hooks/useForm.ts +0 -28
- package/src/hooks/useFormItem.ts +0 -28
- package/src/hooks/useFormItemParentName.ts +0 -49
- package/src/hooks/useFormList.ts +0 -28
- package/src/hooks/useHtmlFor.ts +0 -9
- package/src/hooks/useMultipleForm.ts +0 -29
- package/src/instance/ruleIntsnace.ts +0 -105
- package/src/vite-env.d.ts +0 -1
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const vue = require("vue");
|
|
4
|
-
const clx = require("classnames");
|
|
5
|
-
const useAttrs = require("../hooks/useAttrs.js");
|
|
6
|
-
const _hoisted_1 = ["for"];
|
|
7
|
-
const __default__ = vue.defineComponent({
|
|
8
|
-
name: "LayoutFormItem",
|
|
9
|
-
inheritAttrs: false
|
|
10
|
-
// 可选,防止属性自动应用到根元素
|
|
11
|
-
});
|
|
12
|
-
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
13
|
-
...__default__,
|
|
14
|
-
props: {
|
|
15
|
-
errorLayout: {},
|
|
16
|
-
required: { type: Boolean },
|
|
17
|
-
labelMode: {},
|
|
18
|
-
onlyRuleStyle: { type: Boolean },
|
|
19
|
-
label: { type: [Object, String, Number, Boolean, null, Array] },
|
|
20
|
-
helpText: { type: [Object, String, Number, Boolean, null, Array] },
|
|
21
|
-
extra: { type: [Object, String, Number, Boolean, null, Array] },
|
|
22
|
-
showColon: { type: Boolean },
|
|
23
|
-
colSpan: {},
|
|
24
|
-
rowSpan: {},
|
|
25
|
-
htmlFor: {},
|
|
26
|
-
validateResult: {},
|
|
27
|
-
style: { type: [Boolean, null, String, Object, Array] },
|
|
28
|
-
class: {},
|
|
29
|
-
labelStyle: { type: [Boolean, null, String, Object, Array] },
|
|
30
|
-
labelClass: {}
|
|
31
|
-
},
|
|
32
|
-
setup(__props) {
|
|
33
|
-
const preCls = "carefrees-form-item";
|
|
34
|
-
const attrs = useAttrs.useAttrsInject();
|
|
35
|
-
const props = __props;
|
|
36
|
-
const solts = vue.useSlots();
|
|
37
|
-
const labelMode = vue.computed(() => props.labelMode ?? vue.toValue(attrs.value.labelMode) ?? "top");
|
|
38
|
-
const showColon = vue.computed(() => props.showColon ?? vue.toValue(attrs.value.showColon));
|
|
39
|
-
const errorLayout = vue.computed(() => props.errorLayout ?? vue.toValue(attrs.value.errorLayout) ?? "left-bottom");
|
|
40
|
-
const tips = vue.computed(() => {
|
|
41
|
-
var _a;
|
|
42
|
-
const v = (_a = vue.toValue(props.validateResult)) == null ? void 0 : _a.tip;
|
|
43
|
-
if (Array.isArray(v)) {
|
|
44
|
-
return v.join(",");
|
|
45
|
-
}
|
|
46
|
-
return v;
|
|
47
|
-
});
|
|
48
|
-
const cls = vue.computed(() => {
|
|
49
|
-
var _a;
|
|
50
|
-
return clx(preCls, props.class, vue.toValue(attrs.value.formItemClass), { "dx-invalid": !!((_a = vue.toValue(props.validateResult)) == null ? void 0 : _a.isInvalid) });
|
|
51
|
-
});
|
|
52
|
-
const containerCls = vue.computed(() => clx(`${preCls}-container`, { [`${labelMode.value}`]: !!labelMode.value }));
|
|
53
|
-
const labelCls = vue.computed(() => clx(`${preCls}-label`, { required: !!props.required, "show-colon": showColon && (labelMode.value === "left" || labelMode.value === "between") }));
|
|
54
|
-
const labelWarpCls = vue.computed(() => clx(`${preCls}-label-warp`, vue.toValue(props.labelClass), vue.toValue(attrs.value.formItemLabelClass)));
|
|
55
|
-
const inputCls = vue.computed(() => clx(`${preCls}-body-input`));
|
|
56
|
-
const errorCls = vue.computed(() => clx(`${preCls}-body-error`, { [errorLayout.value]: !!errorLayout.value }));
|
|
57
|
-
const _isLabel = vue.computed(() => (props.label || solts.label) && labelMode.value !== "hide");
|
|
58
|
-
const style = vue.computed(() => {
|
|
59
|
-
const css = {};
|
|
60
|
-
if (props.onlyRuleStyle) {
|
|
61
|
-
css.padding = "0px";
|
|
62
|
-
}
|
|
63
|
-
if (props.colSpan) {
|
|
64
|
-
const colCount = vue.toValue(attrs.value.colCount) || 4;
|
|
65
|
-
const end = colCount > props.colSpan ? props.colSpan : colCount;
|
|
66
|
-
css.gridColumnEnd = `span ${end}`;
|
|
67
|
-
}
|
|
68
|
-
if (props.rowSpan) {
|
|
69
|
-
css.gridRowEnd = `span ${props.rowSpan}`;
|
|
70
|
-
}
|
|
71
|
-
return [vue.toValue(attrs.value.formItemStyle), props.style, css];
|
|
72
|
-
});
|
|
73
|
-
const labelStyle = vue.computed(() => {
|
|
74
|
-
return [vue.toValue(attrs.value.formItemLabelStyle), props.labelStyle];
|
|
75
|
-
});
|
|
76
|
-
const isHelpText = vue.computed(() => {
|
|
77
|
-
return !!props.helpText || solts.helpText;
|
|
78
|
-
});
|
|
79
|
-
const isExtra = vue.computed(() => {
|
|
80
|
-
return !!props.extra || solts.extra;
|
|
81
|
-
});
|
|
82
|
-
return (_ctx, _cache) => {
|
|
83
|
-
return vue.openBlock(), vue.createElementBlock(
|
|
84
|
-
"div",
|
|
85
|
-
{
|
|
86
|
-
class: vue.normalizeClass(cls.value),
|
|
87
|
-
style: vue.normalizeStyle(style.value)
|
|
88
|
-
},
|
|
89
|
-
[
|
|
90
|
-
vue.createElementVNode(
|
|
91
|
-
"div",
|
|
92
|
-
{
|
|
93
|
-
class: vue.normalizeClass(containerCls.value)
|
|
94
|
-
},
|
|
95
|
-
[
|
|
96
|
-
_isLabel.value ? (vue.openBlock(), vue.createElementBlock(
|
|
97
|
-
"div",
|
|
98
|
-
{
|
|
99
|
-
key: 0,
|
|
100
|
-
class: vue.normalizeClass(labelWarpCls.value)
|
|
101
|
-
},
|
|
102
|
-
[
|
|
103
|
-
vue.createElementVNode("label", {
|
|
104
|
-
style: vue.normalizeStyle(labelStyle.value),
|
|
105
|
-
class: vue.normalizeClass(labelCls.value),
|
|
106
|
-
for: vue.toValue(props.htmlFor)
|
|
107
|
-
}, [
|
|
108
|
-
props.label ? (vue.openBlock(), vue.createElementBlock(
|
|
109
|
-
vue.Fragment,
|
|
110
|
-
{ key: 0 },
|
|
111
|
-
[
|
|
112
|
-
vue.createTextVNode(
|
|
113
|
-
vue.toDisplayString(props.label),
|
|
114
|
-
1
|
|
115
|
-
/* TEXT */
|
|
116
|
-
)
|
|
117
|
-
],
|
|
118
|
-
64
|
|
119
|
-
/* STABLE_FRAGMENT */
|
|
120
|
-
)) : vue.renderSlot(_ctx.$slots, "label", { key: 1 })
|
|
121
|
-
], 14, _hoisted_1)
|
|
122
|
-
],
|
|
123
|
-
2
|
|
124
|
-
/* CLASS */
|
|
125
|
-
)) : vue.createCommentVNode("v-if", true),
|
|
126
|
-
vue.createElementVNode(
|
|
127
|
-
"div",
|
|
128
|
-
{
|
|
129
|
-
class: vue.normalizeClass(preCls + "-body")
|
|
130
|
-
},
|
|
131
|
-
[
|
|
132
|
-
vue.createElementVNode(
|
|
133
|
-
"div",
|
|
134
|
-
{
|
|
135
|
-
class: vue.normalizeClass(inputCls.value)
|
|
136
|
-
},
|
|
137
|
-
[
|
|
138
|
-
vue.renderSlot(_ctx.$slots, "default")
|
|
139
|
-
],
|
|
140
|
-
2
|
|
141
|
-
/* CLASS */
|
|
142
|
-
),
|
|
143
|
-
isHelpText.value ? (vue.openBlock(), vue.createElementBlock(
|
|
144
|
-
"div",
|
|
145
|
-
{
|
|
146
|
-
key: 0,
|
|
147
|
-
class: vue.normalizeClass(preCls + "-body-help")
|
|
148
|
-
},
|
|
149
|
-
[
|
|
150
|
-
props.helpText ? (vue.openBlock(), vue.createElementBlock(
|
|
151
|
-
vue.Fragment,
|
|
152
|
-
{ key: 0 },
|
|
153
|
-
[
|
|
154
|
-
vue.createTextVNode(
|
|
155
|
-
vue.toDisplayString(props.helpText),
|
|
156
|
-
1
|
|
157
|
-
/* TEXT */
|
|
158
|
-
)
|
|
159
|
-
],
|
|
160
|
-
64
|
|
161
|
-
/* STABLE_FRAGMENT */
|
|
162
|
-
)) : vue.renderSlot(_ctx.$slots, "helpText", { key: 1 })
|
|
163
|
-
],
|
|
164
|
-
2
|
|
165
|
-
/* CLASS */
|
|
166
|
-
)) : vue.createCommentVNode("v-if", true),
|
|
167
|
-
!!tips.value ? (vue.openBlock(), vue.createElementBlock(
|
|
168
|
-
"div",
|
|
169
|
-
{
|
|
170
|
-
key: 1,
|
|
171
|
-
class: vue.normalizeClass(errorCls.value)
|
|
172
|
-
},
|
|
173
|
-
vue.toDisplayString(tips.value),
|
|
174
|
-
3
|
|
175
|
-
/* TEXT, CLASS */
|
|
176
|
-
)) : vue.createCommentVNode("v-if", true)
|
|
177
|
-
],
|
|
178
|
-
2
|
|
179
|
-
/* CLASS */
|
|
180
|
-
)
|
|
181
|
-
],
|
|
182
|
-
2
|
|
183
|
-
/* CLASS */
|
|
184
|
-
),
|
|
185
|
-
isExtra.value ? (vue.openBlock(), vue.createElementBlock(
|
|
186
|
-
"div",
|
|
187
|
-
{
|
|
188
|
-
key: 0,
|
|
189
|
-
class: vue.normalizeClass(preCls + "-extra")
|
|
190
|
-
},
|
|
191
|
-
[
|
|
192
|
-
props.extra ? (vue.openBlock(), vue.createElementBlock(
|
|
193
|
-
vue.Fragment,
|
|
194
|
-
{ key: 0 },
|
|
195
|
-
[
|
|
196
|
-
vue.createTextVNode(
|
|
197
|
-
vue.toDisplayString(props.extra),
|
|
198
|
-
1
|
|
199
|
-
/* TEXT */
|
|
200
|
-
)
|
|
201
|
-
],
|
|
202
|
-
64
|
|
203
|
-
/* STABLE_FRAGMENT */
|
|
204
|
-
)) : vue.renderSlot(_ctx.$slots, "extra", { key: 1 })
|
|
205
|
-
],
|
|
206
|
-
2
|
|
207
|
-
/* CLASS */
|
|
208
|
-
)) : vue.createCommentVNode("v-if", true)
|
|
209
|
-
],
|
|
210
|
-
6
|
|
211
|
-
/* CLASS, STYLE */
|
|
212
|
-
);
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
exports.default = _sfc_main;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const layout_formItem_vue_vue_type_script_setup_true_lang = require("./layout.formItem.vue.js");
|
|
4
|
-
exports.default = layout_formItem_vue_vue_type_script_setup_true_lang.default;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FormLayoutProps } from '../interface/layout';
|
|
2
|
-
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<FormLayoutProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FormLayoutProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, Readonly<{
|
|
3
|
-
default: any;
|
|
4
|
-
title: any;
|
|
5
|
-
extra: any;
|
|
6
|
-
}> & {
|
|
7
|
-
default: any;
|
|
8
|
-
title: any;
|
|
9
|
-
extra: any;
|
|
10
|
-
}>;
|
|
11
|
-
export default _default;
|
|
12
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
13
|
-
new (): {
|
|
14
|
-
$slots: S;
|
|
15
|
-
};
|
|
16
|
-
};
|
package/lib/layout/layout.vue.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const vue = require("vue");
|
|
4
|
-
const clx = require("classnames");
|
|
5
|
-
const useAttrs = require("../hooks/useAttrs.js");
|
|
6
|
-
const __default__ = vue.defineComponent({
|
|
7
|
-
name: "Layout",
|
|
8
|
-
inheritAttrs: false
|
|
9
|
-
// 可选,防止属性自动应用到根元素
|
|
10
|
-
});
|
|
11
|
-
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
12
|
-
...__default__,
|
|
13
|
-
props: {
|
|
14
|
-
title: { type: [Object, String, Number, Boolean, null, Array] },
|
|
15
|
-
extra: { type: [Object, String, Number, Boolean, null, Array] },
|
|
16
|
-
isAllColSpan: { type: Boolean },
|
|
17
|
-
class: {},
|
|
18
|
-
headerClass: {},
|
|
19
|
-
bodyClass: {},
|
|
20
|
-
style: { type: [Boolean, null, String, Object, Array] },
|
|
21
|
-
headerStyle: { type: [Boolean, null, String, Object, Array] },
|
|
22
|
-
bodyStyle: { type: [Boolean, null, String, Object, Array] },
|
|
23
|
-
bordered: { type: Boolean },
|
|
24
|
-
colCount: {},
|
|
25
|
-
gap: {},
|
|
26
|
-
errorLayout: {},
|
|
27
|
-
labelMode: {},
|
|
28
|
-
showColon: {},
|
|
29
|
-
formItemClass: {},
|
|
30
|
-
formItemStyle: {},
|
|
31
|
-
formItemLabelClass: {},
|
|
32
|
-
formItemLabelStyle: {}
|
|
33
|
-
},
|
|
34
|
-
setup(__props) {
|
|
35
|
-
const preCls = "carefrees-form-layout";
|
|
36
|
-
const attrs = useAttrs.useAttrsInject();
|
|
37
|
-
const props = __props;
|
|
38
|
-
const solts = vue.useSlots();
|
|
39
|
-
const colCount = vue.computed(() => vue.toValue(props.colCount) ?? vue.toValue(attrs.value.colCount));
|
|
40
|
-
const errorLayout = vue.computed(() => vue.toValue(props.errorLayout) ?? vue.toValue(attrs.value.errorLayout));
|
|
41
|
-
const labelMode = vue.computed(() => vue.toValue(props.labelMode) ?? vue.toValue(attrs.value.labelMode));
|
|
42
|
-
const showColon = vue.computed(() => vue.toValue(props.showColon) ?? vue.toValue(attrs.value.showColon));
|
|
43
|
-
const formItemClass = vue.computed(() => vue.toValue(props.formItemClass) ?? vue.toValue(attrs.value.formItemClass));
|
|
44
|
-
const formItemStyle = vue.computed(() => vue.toValue(props.formItemStyle) ?? vue.toValue(attrs.value.formItemStyle));
|
|
45
|
-
const formItemLabelClass = vue.computed(() => vue.toValue(props.formItemLabelClass) ?? vue.toValue(attrs.value.formItemLabelClass));
|
|
46
|
-
const formItemLabelStyle = vue.computed(() => vue.toValue(props.formItemLabelStyle) ?? vue.toValue(attrs.value.formItemLabelStyle));
|
|
47
|
-
useAttrs.useAttrsProvide({
|
|
48
|
-
colCount,
|
|
49
|
-
errorLayout,
|
|
50
|
-
labelMode,
|
|
51
|
-
showColon,
|
|
52
|
-
formItemClass,
|
|
53
|
-
formItemStyle,
|
|
54
|
-
formItemLabelClass,
|
|
55
|
-
formItemLabelStyle
|
|
56
|
-
});
|
|
57
|
-
const cls = vue.computed(() => clx(preCls, props.class, { "all-colspan": props.isAllColSpan, bordered: props.bordered }));
|
|
58
|
-
const bodyCls = vue.computed(() => clx(`${preCls}-body`, props.bodyClass));
|
|
59
|
-
const headerCls = vue.computed(() => clx(`${preCls}-header`, props.headerClass));
|
|
60
|
-
const headerTitleCls = vue.computed(() => clx(`${preCls}-header-title`));
|
|
61
|
-
const headerExtraCls = vue.computed(() => clx(`${preCls}-header-extra`));
|
|
62
|
-
const bodyStyle = vue.computed(() => {
|
|
63
|
-
const css = {};
|
|
64
|
-
if (typeof props.gap === "string") {
|
|
65
|
-
css.gap = props.gap;
|
|
66
|
-
}
|
|
67
|
-
if (typeof props.gap === "number") {
|
|
68
|
-
css.gap = `${props.gap}px`;
|
|
69
|
-
}
|
|
70
|
-
if (colCount.value) {
|
|
71
|
-
css.gridTemplateColumns = `repeat(${colCount.value}, auto)`;
|
|
72
|
-
}
|
|
73
|
-
return [css, props.bodyStyle];
|
|
74
|
-
});
|
|
75
|
-
const isTitle = vue.computed(() => {
|
|
76
|
-
return !!props.title || solts.title;
|
|
77
|
-
});
|
|
78
|
-
const isExtra = vue.computed(() => {
|
|
79
|
-
return !!props.extra || solts.extra;
|
|
80
|
-
});
|
|
81
|
-
return (_ctx, _cache) => {
|
|
82
|
-
return vue.openBlock(), vue.createElementBlock(
|
|
83
|
-
"div",
|
|
84
|
-
{
|
|
85
|
-
style: vue.normalizeStyle(props.style),
|
|
86
|
-
class: vue.normalizeClass(cls.value)
|
|
87
|
-
},
|
|
88
|
-
[
|
|
89
|
-
isExtra.value || isTitle.value ? (vue.openBlock(), vue.createElementBlock(
|
|
90
|
-
"div",
|
|
91
|
-
{
|
|
92
|
-
key: 0,
|
|
93
|
-
style: vue.normalizeStyle(_ctx.headerStyle),
|
|
94
|
-
class: vue.normalizeClass(headerCls.value)
|
|
95
|
-
},
|
|
96
|
-
[
|
|
97
|
-
vue.createElementVNode(
|
|
98
|
-
"div",
|
|
99
|
-
{
|
|
100
|
-
class: vue.normalizeClass(headerTitleCls.value)
|
|
101
|
-
},
|
|
102
|
-
[
|
|
103
|
-
props.title ? (vue.openBlock(), vue.createElementBlock(
|
|
104
|
-
vue.Fragment,
|
|
105
|
-
{ key: 0 },
|
|
106
|
-
[
|
|
107
|
-
vue.createTextVNode(
|
|
108
|
-
vue.toDisplayString(props.title),
|
|
109
|
-
1
|
|
110
|
-
/* TEXT */
|
|
111
|
-
)
|
|
112
|
-
],
|
|
113
|
-
64
|
|
114
|
-
/* STABLE_FRAGMENT */
|
|
115
|
-
)) : vue.renderSlot(_ctx.$slots, "title", { key: 1 })
|
|
116
|
-
],
|
|
117
|
-
2
|
|
118
|
-
/* CLASS */
|
|
119
|
-
),
|
|
120
|
-
vue.createElementVNode(
|
|
121
|
-
"div",
|
|
122
|
-
{
|
|
123
|
-
class: vue.normalizeClass(headerExtraCls.value)
|
|
124
|
-
},
|
|
125
|
-
[
|
|
126
|
-
props.extra ? (vue.openBlock(), vue.createElementBlock(
|
|
127
|
-
vue.Fragment,
|
|
128
|
-
{ key: 0 },
|
|
129
|
-
[
|
|
130
|
-
vue.createTextVNode(
|
|
131
|
-
vue.toDisplayString(props.extra),
|
|
132
|
-
1
|
|
133
|
-
/* TEXT */
|
|
134
|
-
)
|
|
135
|
-
],
|
|
136
|
-
64
|
|
137
|
-
/* STABLE_FRAGMENT */
|
|
138
|
-
)) : vue.renderSlot(_ctx.$slots, "extra", { key: 1 })
|
|
139
|
-
],
|
|
140
|
-
2
|
|
141
|
-
/* CLASS */
|
|
142
|
-
)
|
|
143
|
-
],
|
|
144
|
-
6
|
|
145
|
-
/* CLASS, STYLE */
|
|
146
|
-
)) : vue.createCommentVNode("v-if", true),
|
|
147
|
-
vue.createElementVNode(
|
|
148
|
-
"div",
|
|
149
|
-
{
|
|
150
|
-
style: vue.normalizeStyle(bodyStyle.value),
|
|
151
|
-
class: vue.normalizeClass(bodyCls.value)
|
|
152
|
-
},
|
|
153
|
-
[
|
|
154
|
-
vue.renderSlot(_ctx.$slots, "default")
|
|
155
|
-
],
|
|
156
|
-
6
|
|
157
|
-
/* CLASS, STYLE */
|
|
158
|
-
)
|
|
159
|
-
],
|
|
160
|
-
6
|
|
161
|
-
/* CLASS, STYLE */
|
|
162
|
-
);
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
exports.default = _sfc_main;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const layout_vue_vue_type_script_setup_true_lang = require("./layout.vue.js");
|
|
4
|
-
exports.default = layout_vue_vue_type_script_setup_true_lang.default;
|
package/lib/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './withInstall';
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'vue';
|
|
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 | undefined, childComponents?: K | undefined) => SFCWithInstall<T> & E & K;
|
package/lib/utils/withInstall.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const withInstall = (main, extra, childComponents) => {
|
|
4
|
-
main.install = (app) => {
|
|
5
|
-
for (const comp of [main, ...Object.values(childComponents ?? {})]) {
|
|
6
|
-
const name = comp.name || comp.__name;
|
|
7
|
-
app.component(name, comp);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
if (childComponents) {
|
|
11
|
-
for (const [key, comp] of Object.entries(childComponents)) {
|
|
12
|
-
main[key] = comp;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
if (extra) {
|
|
16
|
-
for (const [key, comp] of Object.entries(extra)) {
|
|
17
|
-
main[key] = comp;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return main;
|
|
21
|
-
};
|
|
22
|
-
exports.withInstall = withInstall;
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { FormInstanceBase, FormItemInstanceBase, get } from '@carefrees/form-utils';
|
|
2
|
-
import { useHtmlFor } from './../useHtmlFor';
|
|
3
|
-
import { useRegisterFormItem, RegisterFormItemOptions } from './../register/register.FormItem';
|
|
4
|
-
import { computed, Ref, ref, toValue, watch } from 'vue';
|
|
5
|
-
import type { RuleInstanceBase2 } from '../../instance/ruleIntsnace';
|
|
6
|
-
|
|
7
|
-
export interface FormItemAttrOptions extends RegisterFormItemOptions {
|
|
8
|
-
/**依赖更新项*/
|
|
9
|
-
dependencies?: string[];
|
|
10
|
-
/**通知 只用于校验规则提示 字段 */
|
|
11
|
-
noticeOnlyRuleDataField?: string[];
|
|
12
|
-
/**通知父级字段监听方法更新*/
|
|
13
|
-
isNoticeParentField?: boolean;
|
|
14
|
-
/**通知watch监听方法更新*/
|
|
15
|
-
noticeWatchField?: string[];
|
|
16
|
-
/**是否保护值(不进行表单项组件卸载重置初始值)*/
|
|
17
|
-
preserve?: boolean;
|
|
18
|
-
/**重写规则*/
|
|
19
|
-
useRules?: (
|
|
20
|
-
ruleInstance: Ref<RuleInstanceBase2>,
|
|
21
|
-
form: FormInstanceBase,
|
|
22
|
-
formItemInstance: FormItemInstanceBase,
|
|
23
|
-
) => void;
|
|
24
|
-
/**输入框属性重写*/
|
|
25
|
-
useAttrs?: (attrs: any, form: FormInstanceBase, formItemInstance: FormItemInstanceBase) => any;
|
|
26
|
-
/**输入框属性*/
|
|
27
|
-
inputAttrs?: Object;
|
|
28
|
-
/**传递组件字段*/
|
|
29
|
-
valuePropName?: string;
|
|
30
|
-
/**取值字段(默认和valuePropName值相同)*/
|
|
31
|
-
getValuePath?: string;
|
|
32
|
-
/**自定义获取值*/
|
|
33
|
-
getValueFromEvent?: (event: any, form: FormInstanceBase, formItemInstance: FormItemInstanceBase) => any;
|
|
34
|
-
/**值格式化*/
|
|
35
|
-
formatValue?: (value: any, form: FormInstanceBase, formItemInstance: FormItemInstanceBase, event: any) => any;
|
|
36
|
-
/**触发数据更新之后触发(用于数据联动之类的)*/
|
|
37
|
-
onAfterUpdate?: (value: any, form: FormInstanceBase, formItemInstance: FormItemInstanceBase, event: any) => void;
|
|
38
|
-
/**事件名称*/
|
|
39
|
-
trigger?: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**表单项参数*/
|
|
43
|
-
export const useFormItemAttr = (options: FormItemAttrOptions) => {
|
|
44
|
-
const {
|
|
45
|
-
trigger = 'onChange',
|
|
46
|
-
dependencies,
|
|
47
|
-
noticeOnlyRuleDataField,
|
|
48
|
-
isNoticeParentField,
|
|
49
|
-
noticeWatchField,
|
|
50
|
-
preserve,
|
|
51
|
-
valuePropName = 'value',
|
|
52
|
-
getValuePath = valuePropName,
|
|
53
|
-
getValueFromEvent,
|
|
54
|
-
formatValue,
|
|
55
|
-
onAfterUpdate,
|
|
56
|
-
useAttrs,
|
|
57
|
-
useRules,
|
|
58
|
-
inputAttrs,
|
|
59
|
-
...rest
|
|
60
|
-
} = options;
|
|
61
|
-
const { formItemInstance, form, ruleInstance, newName, newSort, deepRefData } = useRegisterFormItem({ ...rest });
|
|
62
|
-
formItemInstance.dependencies = dependencies;
|
|
63
|
-
formItemInstance.noticeOnlyRuleDataField = noticeOnlyRuleDataField;
|
|
64
|
-
formItemInstance.isNoticeParentField = isNoticeParentField;
|
|
65
|
-
formItemInstance.onAfterUpdate = onAfterUpdate;
|
|
66
|
-
formItemInstance.noticeWatchField = noticeWatchField;
|
|
67
|
-
formItemInstance.preserve = preserve;
|
|
68
|
-
/**获取值*/
|
|
69
|
-
const oldValue = ref(get(form.formData, toValue(newName)));
|
|
70
|
-
|
|
71
|
-
watch(
|
|
72
|
-
() => [get(form.formData, toValue(newName)), toValue(newName)],
|
|
73
|
-
() => {
|
|
74
|
-
oldValue.value = form.getFieldValue(toValue(newName));
|
|
75
|
-
},
|
|
76
|
-
{ immediate: true },
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const onValueChange = (event: any) => {
|
|
80
|
-
try {
|
|
81
|
-
let value = event;
|
|
82
|
-
if (typeof getValueFromEvent === 'function') {
|
|
83
|
-
value = getValueFromEvent(event, form, formItemInstance);
|
|
84
|
-
} else if (event && event.target && typeof event.target === 'object' && getValuePath in event.target) {
|
|
85
|
-
value = get(event.target, getValuePath);
|
|
86
|
-
}
|
|
87
|
-
if (typeof formatValue === 'function') {
|
|
88
|
-
value = formatValue(value, form, formItemInstance, event);
|
|
89
|
-
}
|
|
90
|
-
if (oldValue.value !== value) {
|
|
91
|
-
form.updatedFieldValue(toValue(newName), value, 'validate');
|
|
92
|
-
formItemInstance.onAfterUpdate?.(value, form, formItemInstance, event);
|
|
93
|
-
if (Array.isArray(formItemInstance.noticeWatchField) && formItemInstance.noticeWatchField.length) {
|
|
94
|
-
form.noticeWatch(formItemInstance.noticeWatchField);
|
|
95
|
-
}
|
|
96
|
-
if (
|
|
97
|
-
Array.isArray(formItemInstance.noticeOnlyRuleDataField) &&
|
|
98
|
-
formItemInstance.noticeOnlyRuleDataField.length
|
|
99
|
-
) {
|
|
100
|
-
form.onlyValidate(formItemInstance.noticeOnlyRuleDataField);
|
|
101
|
-
}
|
|
102
|
-
if (formItemInstance.isNoticeParentField && formItemInstance.parentDataField) {
|
|
103
|
-
form.notice(formItemInstance.parentDataField);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
} catch (error) {
|
|
107
|
-
console.log(error);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
formItemInstance.onChange = onValueChange;
|
|
112
|
-
const htmlFor = useHtmlFor(newName);
|
|
113
|
-
|
|
114
|
-
watch(
|
|
115
|
-
() => htmlFor,
|
|
116
|
-
() => {
|
|
117
|
-
formItemInstance.htmlFor = htmlFor.value;
|
|
118
|
-
},
|
|
119
|
-
{ immediate: true },
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
/**属性处理*/
|
|
123
|
-
const newAttrs = computed(() => {
|
|
124
|
-
const _attr = inputAttrs || {};
|
|
125
|
-
return {
|
|
126
|
-
..._attr,
|
|
127
|
-
[trigger]: onValueChange,
|
|
128
|
-
name: toValue(newName),
|
|
129
|
-
id: toValue(htmlFor),
|
|
130
|
-
[valuePropName]: toValue(oldValue),
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const attrsLastData = ref(toValue(newAttrs));
|
|
135
|
-
|
|
136
|
-
watch(
|
|
137
|
-
() => [toValue(newAttrs), toValue(deepRefData), toValue(oldValue)],
|
|
138
|
-
() => {
|
|
139
|
-
attrsLastData.value = useAttrs?.(toValue(newAttrs), form, formItemInstance) || toValue(newAttrs);
|
|
140
|
-
},
|
|
141
|
-
{ immediate: true },
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
/**规则处理**/
|
|
145
|
-
const validateResult = ref(toValue(ruleInstance).getValidateResult());
|
|
146
|
-
|
|
147
|
-
watch(
|
|
148
|
-
() => [toValue(deepRefData), toValue(oldValue)],
|
|
149
|
-
() => {
|
|
150
|
-
useRules?.(ruleInstance as any, form, formItemInstance);
|
|
151
|
-
},
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
watch(
|
|
155
|
-
() => [toValue(ruleInstance).messages, toValue(ruleInstance).rules, toValue(oldValue)],
|
|
156
|
-
() => {
|
|
157
|
-
validateResult.value = toValue(ruleInstance).getValidateResult();
|
|
158
|
-
},
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
return {
|
|
162
|
-
valuePropName,
|
|
163
|
-
htmlFor,
|
|
164
|
-
onChange: onValueChange,
|
|
165
|
-
formItemInstance,
|
|
166
|
-
form,
|
|
167
|
-
ruleInstance,
|
|
168
|
-
newAttrs,
|
|
169
|
-
attrsLastData,
|
|
170
|
-
validateResult,
|
|
171
|
-
newSort,
|
|
172
|
-
newName,
|
|
173
|
-
};
|
|
174
|
-
};
|
package/src/hooks/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from './useAttrs';
|
|
2
|
-
export * from './useForm';
|
|
3
|
-
export * from './useFormItem';
|
|
4
|
-
export * from './useFormList';
|
|
5
|
-
export * from './useHtmlFor';
|
|
6
|
-
export * from './useMultipleForm';
|
|
7
|
-
export * from './useFormItemParentName';
|
|
8
|
-
export * from './useEffect';
|
|
9
|
-
export * from './register/register.FormHideItem';
|
|
10
|
-
export * from './register/register.FormItem';
|
|
11
|
-
export * from './register/register.FormList';
|
|
12
|
-
export * from './register/register.form';
|
|
13
|
-
export * from './attr/attr.FormItem';
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ref, toValue, watch } from 'vue';
|
|
2
|
-
import { RegisterFormItemOptions } from './register.FormItem';
|
|
3
|
-
import { FormHideItemInstanceBase } from '@carefrees/form-utils';
|
|
4
|
-
import { useFormItemParentNameInject } from '../useFormItemParentName';
|
|
5
|
-
import { useFormInject } from '../useForm';
|
|
6
|
-
import { useEffect } from '../useEffect';
|
|
7
|
-
|
|
8
|
-
interface RegisterFormHideItemOptions extends Omit<RegisterFormItemOptions, 'rules'> {}
|
|
9
|
-
|
|
10
|
-
/**注册表单隐藏表单项到表单实例中*/
|
|
11
|
-
export const useRegisterFormHideItem = (options: RegisterFormHideItemOptions) => {
|
|
12
|
-
const { name, sort, isJoinParentField = true } = options;
|
|
13
|
-
const form = useFormInject();
|
|
14
|
-
const { newName, newSort } = useFormItemParentNameInject({ name, sort, isJoinParentField });
|
|
15
|
-
const hideItemInstance = ref<FormHideItemInstanceBase>(new FormHideItemInstanceBase().ctor(newName.value));
|
|
16
|
-
const isHide = ref(form.getFieldHideValue(newName.value));
|
|
17
|
-
watch(
|
|
18
|
-
() => [toValue(isHide)],
|
|
19
|
-
() => {
|
|
20
|
-
hideItemInstance.value.preHideValue = isHide.value;
|
|
21
|
-
},
|
|
22
|
-
{ immediate: true },
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const setValue = () => {
|
|
26
|
-
isHide.value = form.getFieldHideValue(newName.value);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
hideItemInstance.value.updatedItem = setValue;
|
|
30
|
-
|
|
31
|
-
watch(
|
|
32
|
-
() => [form, toValue(newSort)],
|
|
33
|
-
() => {
|
|
34
|
-
hideItemInstance.value.instance = form;
|
|
35
|
-
hideItemInstance.value.sort = toValue(newSort);
|
|
36
|
-
},
|
|
37
|
-
{ immediate: true },
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
return form.registerFormHideItem(toValue(hideItemInstance) as FormHideItemInstanceBase);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return { form, isHide };
|
|
45
|
-
};
|