@carefrees/form-utils-vue 0.0.11 → 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
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FormItemInstanceBase } from "@carefrees/form-utils";
|
|
2
|
-
import { ref, provide, inject } from "vue";
|
|
3
|
-
const formItemProvideSymbol = Symbol("carefrees-form-item");
|
|
4
|
-
function useFormItemProvide(formItem) {
|
|
5
|
-
provide(formItemProvideSymbol, formItem);
|
|
6
|
-
}
|
|
7
|
-
function useFormItemInject() {
|
|
8
|
-
const formItem = inject(formItemProvideSymbol, new FormItemInstanceBase());
|
|
9
|
-
return formItem;
|
|
10
|
-
}
|
|
11
|
-
function useFormItem(formItem) {
|
|
12
|
-
const refForm = ref();
|
|
13
|
-
if (!refForm.value) {
|
|
14
|
-
if (formItem) {
|
|
15
|
-
refForm.value = formItem;
|
|
16
|
-
} else {
|
|
17
|
-
refForm.value = new FormItemInstanceBase();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return refForm.value;
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
useFormItem,
|
|
24
|
-
useFormItemInject,
|
|
25
|
-
useFormItemProvide
|
|
26
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { provide, computed, inject, ref, toValue } from "vue";
|
|
2
|
-
const parentNameProvideSymbol = Symbol("carefrees-parent-name");
|
|
3
|
-
const useFormItemParentNameProvide = (props) => {
|
|
4
|
-
const { name, sort } = props;
|
|
5
|
-
provide(
|
|
6
|
-
parentNameProvideSymbol,
|
|
7
|
-
computed(() => ({ name, sort }))
|
|
8
|
-
);
|
|
9
|
-
};
|
|
10
|
-
const useFormItemParentNameInject = (options) => {
|
|
11
|
-
const { isJoinParentField = true, sort, name } = options;
|
|
12
|
-
const parentItem = inject(
|
|
13
|
-
parentNameProvideSymbol,
|
|
14
|
-
computed(() => ({ name: ref(""), sort: ref("") }))
|
|
15
|
-
);
|
|
16
|
-
const newName = computed(() => {
|
|
17
|
-
const _name = toValue(parentItem.value.name);
|
|
18
|
-
if (_name && isJoinParentField) {
|
|
19
|
-
if (/^\./.test(`${name}`)) {
|
|
20
|
-
return [_name, name].filter(Boolean).join("");
|
|
21
|
-
} else if (name) {
|
|
22
|
-
return [_name, ".", name].filter(Boolean).join("");
|
|
23
|
-
}
|
|
24
|
-
return [_name, name].filter(Boolean).join("");
|
|
25
|
-
}
|
|
26
|
-
return [name].filter(Boolean).join("");
|
|
27
|
-
});
|
|
28
|
-
const newSort = computed(() => {
|
|
29
|
-
const _sort = toValue(parentItem.value.sort);
|
|
30
|
-
return [isJoinParentField ? _sort : "", sort].filter(Boolean).join("-");
|
|
31
|
-
});
|
|
32
|
-
return { newName, newSort, parentItem };
|
|
33
|
-
};
|
|
34
|
-
export {
|
|
35
|
-
useFormItemParentNameInject,
|
|
36
|
-
useFormItemParentNameProvide
|
|
37
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FormListInstanceBase } from "@carefrees/form-utils";
|
|
2
|
-
import { provide, inject, ref } from "vue";
|
|
3
|
-
const formListProvideSymbol = Symbol("carefrees-form-list");
|
|
4
|
-
function useFormListProvide(formList) {
|
|
5
|
-
provide(formListProvideSymbol, formList);
|
|
6
|
-
}
|
|
7
|
-
function useFormListInject() {
|
|
8
|
-
const formList = inject(formListProvideSymbol, new FormListInstanceBase());
|
|
9
|
-
return formList;
|
|
10
|
-
}
|
|
11
|
-
function useFormList(formList) {
|
|
12
|
-
const refForm = ref();
|
|
13
|
-
if (!refForm.value) {
|
|
14
|
-
if (formList) {
|
|
15
|
-
refForm.value = formList;
|
|
16
|
-
} else {
|
|
17
|
-
refForm.value = new FormListInstanceBase();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return refForm.value;
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
useFormList,
|
|
24
|
-
useFormListInject,
|
|
25
|
-
useFormListProvide
|
|
26
|
-
};
|
package/esm/hooks/useHtmlFor.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ref, computed } from "vue";
|
|
2
|
-
let localId = 0;
|
|
3
|
-
const useHtmlFor = (suffix) => {
|
|
4
|
-
const count = ref(localId++);
|
|
5
|
-
return computed(() => {
|
|
6
|
-
return `carefree-vue-form-item_${count.value.toString(32)}_${suffix.value}`;
|
|
7
|
-
});
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
useHtmlFor
|
|
11
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MultipleInstanceBase } from "@carefrees/form-utils";
|
|
2
|
-
import { inject, provide, ref } from "vue";
|
|
3
|
-
const multipleFormProvideSymbol = Symbol("carefrees-multiple-form");
|
|
4
|
-
function useMultipleFormProvide(multipleForm) {
|
|
5
|
-
const newMultipleForm = useMultipleForm(multipleForm);
|
|
6
|
-
provide(multipleFormProvideSymbol, newMultipleForm);
|
|
7
|
-
}
|
|
8
|
-
function useMultipleFormInject() {
|
|
9
|
-
const multipleForm = inject(multipleFormProvideSymbol, new MultipleInstanceBase());
|
|
10
|
-
return multipleForm;
|
|
11
|
-
}
|
|
12
|
-
function useMultipleForm(multipleForm) {
|
|
13
|
-
const refForm = ref();
|
|
14
|
-
if (!refForm.value) {
|
|
15
|
-
if (multipleForm) {
|
|
16
|
-
refForm.value = multipleForm;
|
|
17
|
-
} else {
|
|
18
|
-
refForm.value = new MultipleInstanceBase();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return refForm.value;
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
useMultipleForm,
|
|
25
|
-
useMultipleFormInject,
|
|
26
|
-
useMultipleFormProvide
|
|
27
|
-
};
|
package/esm/index.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as component from "./component.mjs";
|
|
2
|
-
import { useAttrsInject, useAttrsProvide } from "./hooks/useAttrs.mjs";
|
|
3
|
-
import { useForm, useFormInject, useFormProvide } from "./hooks/useForm.mjs";
|
|
4
|
-
import { useFormItem, useFormItemInject, useFormItemProvide } from "./hooks/useFormItem.mjs";
|
|
5
|
-
import { useFormList, useFormListInject, useFormListProvide } from "./hooks/useFormList.mjs";
|
|
6
|
-
import { useHtmlFor } from "./hooks/useHtmlFor.mjs";
|
|
7
|
-
import { useMultipleForm, useMultipleFormInject, useMultipleFormProvide } from "./hooks/useMultipleForm.mjs";
|
|
8
|
-
import { useFormItemParentNameInject, useFormItemParentNameProvide } from "./hooks/useFormItemParentName.mjs";
|
|
9
|
-
import { useEffect } from "./hooks/useEffect.mjs";
|
|
10
|
-
import { useRegisterFormHideItem } from "./hooks/register/register.FormHideItem.mjs";
|
|
11
|
-
import { useRegisterFormItem } from "./hooks/register/register.FormItem.mjs";
|
|
12
|
-
import { useRegisterFormList } from "./hooks/register/register.FormList.mjs";
|
|
13
|
-
import { useRegisterForm } from "./hooks/register/register.form.mjs";
|
|
14
|
-
import { useFormItemAttr } from "./hooks/attr/attr.FormItem.mjs";
|
|
15
|
-
import { withInstall } from "./utils/withInstall.mjs";
|
|
16
|
-
import { Form } from "./form/index.mjs";
|
|
17
|
-
import { FormHideItem, FormItem, FormItemBase } from "./formItem/index.mjs";
|
|
18
|
-
import { FormLayoutRows, Layout, LayoutFormItem } from "./layout/index.mjs";
|
|
19
|
-
const index = {
|
|
20
|
-
install: (app) => {
|
|
21
|
-
for (const c in component) {
|
|
22
|
-
app.use(component[c]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
export {
|
|
27
|
-
Form,
|
|
28
|
-
FormHideItem,
|
|
29
|
-
FormItem,
|
|
30
|
-
FormItemBase,
|
|
31
|
-
FormLayoutRows,
|
|
32
|
-
Layout,
|
|
33
|
-
LayoutFormItem,
|
|
34
|
-
index as default,
|
|
35
|
-
useAttrsInject,
|
|
36
|
-
useAttrsProvide,
|
|
37
|
-
useEffect,
|
|
38
|
-
useForm,
|
|
39
|
-
useFormInject,
|
|
40
|
-
useFormItem,
|
|
41
|
-
useFormItemAttr,
|
|
42
|
-
useFormItemInject,
|
|
43
|
-
useFormItemParentNameInject,
|
|
44
|
-
useFormItemParentNameProvide,
|
|
45
|
-
useFormItemProvide,
|
|
46
|
-
useFormList,
|
|
47
|
-
useFormListInject,
|
|
48
|
-
useFormListProvide,
|
|
49
|
-
useFormProvide,
|
|
50
|
-
useHtmlFor,
|
|
51
|
-
useMultipleForm,
|
|
52
|
-
useMultipleFormInject,
|
|
53
|
-
useMultipleFormProvide,
|
|
54
|
-
useRegisterForm,
|
|
55
|
-
useRegisterFormHideItem,
|
|
56
|
-
useRegisterFormItem,
|
|
57
|
-
useRegisterFormList,
|
|
58
|
-
withInstall
|
|
59
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import AsyncValidator from "async-validator";
|
|
2
|
-
import { ref, toValue } from "vue";
|
|
3
|
-
class RuleInstanceBase2 {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.name = "";
|
|
6
|
-
this.rules = ref([]);
|
|
7
|
-
this.messages = ref([]);
|
|
8
|
-
this.isRequired = () => {
|
|
9
|
-
var _a, _b;
|
|
10
|
-
if ((_b = (_a = this.instance) == null ? void 0 : _a.getFieldHideRulesValue) == null ? void 0 : _b.call(_a, this.name)) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
const findItem = (toValue(this.rules) || []).find((item) => item == null ? void 0 : item.required);
|
|
14
|
-
return !!findItem;
|
|
15
|
-
};
|
|
16
|
-
this.ctor = (name, rules) => {
|
|
17
|
-
this.name = name;
|
|
18
|
-
this.rules.value = rules || [];
|
|
19
|
-
return this;
|
|
20
|
-
};
|
|
21
|
-
this.isValidate = () => {
|
|
22
|
-
var _a, _b;
|
|
23
|
-
if ((_b = (_a = this.instance) == null ? void 0 : _a.getFieldHideRulesValue) == null ? void 0 : _b.call(_a, this.name)) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const _rules = toValue(this.rules);
|
|
27
|
-
return !!(Array.isArray(_rules) && _rules.length);
|
|
28
|
-
};
|
|
29
|
-
this.updatedMessages = (messages) => {
|
|
30
|
-
var _a;
|
|
31
|
-
this.messages.value = messages || [];
|
|
32
|
-
(_a = this.updated) == null ? void 0 : _a.call(this, {});
|
|
33
|
-
};
|
|
34
|
-
this.updatedRules = (rules) => {
|
|
35
|
-
var _a;
|
|
36
|
-
this.rules.value = rules;
|
|
37
|
-
(_a = this.updatedMessages) == null ? void 0 : _a.call(this, []);
|
|
38
|
-
};
|
|
39
|
-
this.validate = (isOnly = false) => {
|
|
40
|
-
return new Promise((resolve, reject) => {
|
|
41
|
-
var _a, _b, _c, _d;
|
|
42
|
-
const value = (_b = (_a = this.instance) == null ? void 0 : _a.getFieldValue) == null ? void 0 : _b.call(_a, this.name);
|
|
43
|
-
if ((_d = (_c = this.instance) == null ? void 0 : _c.getFieldHideRulesValue) == null ? void 0 : _d.call(_c, this.name)) {
|
|
44
|
-
this.updatedMessages([]);
|
|
45
|
-
resolve({ [this.name]: value });
|
|
46
|
-
}
|
|
47
|
-
new AsyncValidator({ [this.name]: toValue(this.rules) || [] }).validate({ [this.name]: value }).then((values) => {
|
|
48
|
-
if (!isOnly) this.updatedMessages([]);
|
|
49
|
-
resolve(values);
|
|
50
|
-
}).catch(({ errors }) => {
|
|
51
|
-
if (Array.isArray(errors)) {
|
|
52
|
-
if (!isOnly) this.updatedMessages(errors);
|
|
53
|
-
reject(errors);
|
|
54
|
-
} else {
|
|
55
|
-
reject();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
this.getValidateResult = () => {
|
|
61
|
-
const _messages = toValue(this.messages);
|
|
62
|
-
const tip = Array.isArray(_messages) ? _messages.map((it) => it.message) : "";
|
|
63
|
-
const isInvalid = Array.isArray(tip) ? !!tip.length : !!tip;
|
|
64
|
-
return {
|
|
65
|
-
tip,
|
|
66
|
-
isInvalid
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
export {
|
|
72
|
-
RuleInstanceBase2
|
|
73
|
-
};
|
package/esm/layout/index.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import _sfc_main from "./layout.vue.mjs";
|
|
2
|
-
import _sfc_main$1 from "./layout.formItem.vue.mjs";
|
|
3
|
-
import _sfc_main$2 from "./layout.form.rows.vue.mjs";
|
|
4
|
-
import { withInstall } from "../utils/withInstall.mjs";
|
|
5
|
-
const Layout = withInstall(_sfc_main);
|
|
6
|
-
const LayoutFormItem = withInstall(_sfc_main$1);
|
|
7
|
-
const FormLayoutRows = withInstall(_sfc_main$2);
|
|
8
|
-
export {
|
|
9
|
-
FormLayoutRows,
|
|
10
|
-
Layout,
|
|
11
|
-
LayoutFormItem
|
|
12
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { defineComponent, computed, createElementBlock, openBlock, mergeProps, renderSlot } from "vue";
|
|
2
|
-
import clx from "classnames";
|
|
3
|
-
const __default__ = defineComponent({
|
|
4
|
-
name: "FormLayoutRows",
|
|
5
|
-
inheritAttrs: false
|
|
6
|
-
// 可选,防止属性自动应用到根元素
|
|
7
|
-
});
|
|
8
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
9
|
-
...__default__,
|
|
10
|
-
setup(__props) {
|
|
11
|
-
const preCls = "carefrees-form-layout";
|
|
12
|
-
const props = __props;
|
|
13
|
-
const cls = computed(() => clx(preCls, props.class, {
|
|
14
|
-
"all-colspan": true
|
|
15
|
-
}));
|
|
16
|
-
return (_ctx, _cache) => {
|
|
17
|
-
return openBlock(), createElementBlock(
|
|
18
|
-
"div",
|
|
19
|
-
mergeProps(props, { class: cls.value }),
|
|
20
|
-
[
|
|
21
|
-
renderSlot(_ctx.$slots, "default")
|
|
22
|
-
],
|
|
23
|
-
16
|
|
24
|
-
/* FULL_PROPS */
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
export {
|
|
30
|
-
_sfc_main as default
|
|
31
|
-
};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { defineComponent, useSlots, computed, toValue, createElementBlock, openBlock, normalizeStyle, normalizeClass, createElementVNode, createCommentVNode, renderSlot, Fragment, createTextVNode, toDisplayString } from "vue";
|
|
2
|
-
import clx from "classnames";
|
|
3
|
-
import { useAttrsInject } from "../hooks/useAttrs.mjs";
|
|
4
|
-
const _hoisted_1 = ["for"];
|
|
5
|
-
const __default__ = defineComponent({
|
|
6
|
-
name: "LayoutFormItem",
|
|
7
|
-
inheritAttrs: false
|
|
8
|
-
// 可选,防止属性自动应用到根元素
|
|
9
|
-
});
|
|
10
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
11
|
-
...__default__,
|
|
12
|
-
props: {
|
|
13
|
-
errorLayout: {},
|
|
14
|
-
required: { type: Boolean },
|
|
15
|
-
labelMode: {},
|
|
16
|
-
onlyRuleStyle: { type: Boolean },
|
|
17
|
-
label: { type: [Object, String, Number, Boolean, null, Array] },
|
|
18
|
-
helpText: { type: [Object, String, Number, Boolean, null, Array] },
|
|
19
|
-
extra: { type: [Object, String, Number, Boolean, null, Array] },
|
|
20
|
-
showColon: { type: Boolean },
|
|
21
|
-
colSpan: {},
|
|
22
|
-
rowSpan: {},
|
|
23
|
-
htmlFor: {},
|
|
24
|
-
validateResult: {},
|
|
25
|
-
style: { type: [Boolean, null, String, Object, Array] },
|
|
26
|
-
class: {},
|
|
27
|
-
labelStyle: { type: [Boolean, null, String, Object, Array] },
|
|
28
|
-
labelClass: {}
|
|
29
|
-
},
|
|
30
|
-
setup(__props) {
|
|
31
|
-
const preCls = "carefrees-form-item";
|
|
32
|
-
const attrs = useAttrsInject();
|
|
33
|
-
const props = __props;
|
|
34
|
-
const solts = useSlots();
|
|
35
|
-
const labelMode = computed(() => props.labelMode ?? toValue(attrs.value.labelMode) ?? "top");
|
|
36
|
-
const showColon = computed(() => props.showColon ?? toValue(attrs.value.showColon));
|
|
37
|
-
const errorLayout = computed(() => props.errorLayout ?? toValue(attrs.value.errorLayout) ?? "left-bottom");
|
|
38
|
-
const tips = computed(() => {
|
|
39
|
-
var _a;
|
|
40
|
-
const v = (_a = toValue(props.validateResult)) == null ? void 0 : _a.tip;
|
|
41
|
-
if (Array.isArray(v)) {
|
|
42
|
-
return v.join(",");
|
|
43
|
-
}
|
|
44
|
-
return v;
|
|
45
|
-
});
|
|
46
|
-
const cls = computed(() => {
|
|
47
|
-
var _a;
|
|
48
|
-
return clx(preCls, props.class, toValue(attrs.value.formItemClass), { "dx-invalid": !!((_a = toValue(props.validateResult)) == null ? void 0 : _a.isInvalid) });
|
|
49
|
-
});
|
|
50
|
-
const containerCls = computed(() => clx(`${preCls}-container`, { [`${labelMode.value}`]: !!labelMode.value }));
|
|
51
|
-
const labelCls = computed(() => clx(`${preCls}-label`, { required: !!props.required, "show-colon": showColon && (labelMode.value === "left" || labelMode.value === "between") }));
|
|
52
|
-
const labelWarpCls = computed(() => clx(`${preCls}-label-warp`, toValue(props.labelClass), toValue(attrs.value.formItemLabelClass)));
|
|
53
|
-
const inputCls = computed(() => clx(`${preCls}-body-input`));
|
|
54
|
-
const errorCls = computed(() => clx(`${preCls}-body-error`, { [errorLayout.value]: !!errorLayout.value }));
|
|
55
|
-
const _isLabel = computed(() => (props.label || solts.label) && labelMode.value !== "hide");
|
|
56
|
-
const style = computed(() => {
|
|
57
|
-
const css = {};
|
|
58
|
-
if (props.onlyRuleStyle) {
|
|
59
|
-
css.padding = "0px";
|
|
60
|
-
}
|
|
61
|
-
if (props.colSpan) {
|
|
62
|
-
const colCount = toValue(attrs.value.colCount) || 4;
|
|
63
|
-
const end = colCount > props.colSpan ? props.colSpan : colCount;
|
|
64
|
-
css.gridColumnEnd = `span ${end}`;
|
|
65
|
-
}
|
|
66
|
-
if (props.rowSpan) {
|
|
67
|
-
css.gridRowEnd = `span ${props.rowSpan}`;
|
|
68
|
-
}
|
|
69
|
-
return [toValue(attrs.value.formItemStyle), props.style, css];
|
|
70
|
-
});
|
|
71
|
-
const labelStyle = computed(() => {
|
|
72
|
-
return [toValue(attrs.value.formItemLabelStyle), props.labelStyle];
|
|
73
|
-
});
|
|
74
|
-
const isHelpText = computed(() => {
|
|
75
|
-
return !!props.helpText || solts.helpText;
|
|
76
|
-
});
|
|
77
|
-
const isExtra = computed(() => {
|
|
78
|
-
return !!props.extra || solts.extra;
|
|
79
|
-
});
|
|
80
|
-
return (_ctx, _cache) => {
|
|
81
|
-
return openBlock(), createElementBlock(
|
|
82
|
-
"div",
|
|
83
|
-
{
|
|
84
|
-
class: normalizeClass(cls.value),
|
|
85
|
-
style: normalizeStyle(style.value)
|
|
86
|
-
},
|
|
87
|
-
[
|
|
88
|
-
createElementVNode(
|
|
89
|
-
"div",
|
|
90
|
-
{
|
|
91
|
-
class: normalizeClass(containerCls.value)
|
|
92
|
-
},
|
|
93
|
-
[
|
|
94
|
-
_isLabel.value ? (openBlock(), createElementBlock(
|
|
95
|
-
"div",
|
|
96
|
-
{
|
|
97
|
-
key: 0,
|
|
98
|
-
class: normalizeClass(labelWarpCls.value)
|
|
99
|
-
},
|
|
100
|
-
[
|
|
101
|
-
createElementVNode("label", {
|
|
102
|
-
style: normalizeStyle(labelStyle.value),
|
|
103
|
-
class: normalizeClass(labelCls.value),
|
|
104
|
-
for: toValue(props.htmlFor)
|
|
105
|
-
}, [
|
|
106
|
-
props.label ? (openBlock(), createElementBlock(
|
|
107
|
-
Fragment,
|
|
108
|
-
{ key: 0 },
|
|
109
|
-
[
|
|
110
|
-
createTextVNode(
|
|
111
|
-
toDisplayString(props.label),
|
|
112
|
-
1
|
|
113
|
-
/* TEXT */
|
|
114
|
-
)
|
|
115
|
-
],
|
|
116
|
-
64
|
|
117
|
-
/* STABLE_FRAGMENT */
|
|
118
|
-
)) : renderSlot(_ctx.$slots, "label", { key: 1 })
|
|
119
|
-
], 14, _hoisted_1)
|
|
120
|
-
],
|
|
121
|
-
2
|
|
122
|
-
/* CLASS */
|
|
123
|
-
)) : createCommentVNode("v-if", true),
|
|
124
|
-
createElementVNode(
|
|
125
|
-
"div",
|
|
126
|
-
{
|
|
127
|
-
class: normalizeClass(preCls + "-body")
|
|
128
|
-
},
|
|
129
|
-
[
|
|
130
|
-
createElementVNode(
|
|
131
|
-
"div",
|
|
132
|
-
{
|
|
133
|
-
class: normalizeClass(inputCls.value)
|
|
134
|
-
},
|
|
135
|
-
[
|
|
136
|
-
renderSlot(_ctx.$slots, "default")
|
|
137
|
-
],
|
|
138
|
-
2
|
|
139
|
-
/* CLASS */
|
|
140
|
-
),
|
|
141
|
-
isHelpText.value ? (openBlock(), createElementBlock(
|
|
142
|
-
"div",
|
|
143
|
-
{
|
|
144
|
-
key: 0,
|
|
145
|
-
class: normalizeClass(preCls + "-body-help")
|
|
146
|
-
},
|
|
147
|
-
[
|
|
148
|
-
props.helpText ? (openBlock(), createElementBlock(
|
|
149
|
-
Fragment,
|
|
150
|
-
{ key: 0 },
|
|
151
|
-
[
|
|
152
|
-
createTextVNode(
|
|
153
|
-
toDisplayString(props.helpText),
|
|
154
|
-
1
|
|
155
|
-
/* TEXT */
|
|
156
|
-
)
|
|
157
|
-
],
|
|
158
|
-
64
|
|
159
|
-
/* STABLE_FRAGMENT */
|
|
160
|
-
)) : renderSlot(_ctx.$slots, "helpText", { key: 1 })
|
|
161
|
-
],
|
|
162
|
-
2
|
|
163
|
-
/* CLASS */
|
|
164
|
-
)) : createCommentVNode("v-if", true),
|
|
165
|
-
!!tips.value ? (openBlock(), createElementBlock(
|
|
166
|
-
"div",
|
|
167
|
-
{
|
|
168
|
-
key: 1,
|
|
169
|
-
class: normalizeClass(errorCls.value)
|
|
170
|
-
},
|
|
171
|
-
toDisplayString(tips.value),
|
|
172
|
-
3
|
|
173
|
-
/* TEXT, CLASS */
|
|
174
|
-
)) : createCommentVNode("v-if", true)
|
|
175
|
-
],
|
|
176
|
-
2
|
|
177
|
-
/* CLASS */
|
|
178
|
-
)
|
|
179
|
-
],
|
|
180
|
-
2
|
|
181
|
-
/* CLASS */
|
|
182
|
-
),
|
|
183
|
-
isExtra.value ? (openBlock(), createElementBlock(
|
|
184
|
-
"div",
|
|
185
|
-
{
|
|
186
|
-
key: 0,
|
|
187
|
-
class: normalizeClass(preCls + "-extra")
|
|
188
|
-
},
|
|
189
|
-
[
|
|
190
|
-
props.extra ? (openBlock(), createElementBlock(
|
|
191
|
-
Fragment,
|
|
192
|
-
{ key: 0 },
|
|
193
|
-
[
|
|
194
|
-
createTextVNode(
|
|
195
|
-
toDisplayString(props.extra),
|
|
196
|
-
1
|
|
197
|
-
/* TEXT */
|
|
198
|
-
)
|
|
199
|
-
],
|
|
200
|
-
64
|
|
201
|
-
/* STABLE_FRAGMENT */
|
|
202
|
-
)) : renderSlot(_ctx.$slots, "extra", { key: 1 })
|
|
203
|
-
],
|
|
204
|
-
2
|
|
205
|
-
/* CLASS */
|
|
206
|
-
)) : createCommentVNode("v-if", true)
|
|
207
|
-
],
|
|
208
|
-
6
|
|
209
|
-
/* CLASS, STYLE */
|
|
210
|
-
);
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
export {
|
|
215
|
-
_sfc_main as default
|
|
216
|
-
};
|