@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,120 +0,0 @@
|
|
|
1
|
-
import { get } from "@carefrees/form-utils";
|
|
2
|
-
import { useHtmlFor } from "../useHtmlFor.mjs";
|
|
3
|
-
import { useRegisterFormItem } from "../register/register.FormItem.mjs";
|
|
4
|
-
import { ref, toValue, watch, computed } from "vue";
|
|
5
|
-
const useFormItemAttr = (options) => {
|
|
6
|
-
const {
|
|
7
|
-
trigger = "onChange",
|
|
8
|
-
dependencies,
|
|
9
|
-
noticeOnlyRuleDataField,
|
|
10
|
-
isNoticeParentField,
|
|
11
|
-
noticeWatchField,
|
|
12
|
-
preserve,
|
|
13
|
-
valuePropName = "value",
|
|
14
|
-
getValuePath = valuePropName,
|
|
15
|
-
getValueFromEvent,
|
|
16
|
-
formatValue,
|
|
17
|
-
onAfterUpdate,
|
|
18
|
-
useAttrs,
|
|
19
|
-
useRules,
|
|
20
|
-
inputAttrs,
|
|
21
|
-
...rest
|
|
22
|
-
} = options;
|
|
23
|
-
const {
|
|
24
|
-
formItemInstance,
|
|
25
|
-
form,
|
|
26
|
-
ruleInstance,
|
|
27
|
-
newName,
|
|
28
|
-
newSort,
|
|
29
|
-
deepRefData
|
|
30
|
-
} = useRegisterFormItem({
|
|
31
|
-
...rest
|
|
32
|
-
});
|
|
33
|
-
formItemInstance.dependencies = dependencies;
|
|
34
|
-
formItemInstance.noticeOnlyRuleDataField = noticeOnlyRuleDataField;
|
|
35
|
-
formItemInstance.isNoticeParentField = isNoticeParentField;
|
|
36
|
-
formItemInstance.onAfterUpdate = onAfterUpdate;
|
|
37
|
-
formItemInstance.noticeWatchField = noticeWatchField;
|
|
38
|
-
formItemInstance.preserve = preserve;
|
|
39
|
-
const oldValue = ref(get(form.formData, toValue(newName)));
|
|
40
|
-
watch(() => [get(form.formData, toValue(newName)), toValue(newName)], () => {
|
|
41
|
-
oldValue.value = form.getFieldValue(toValue(newName));
|
|
42
|
-
}, {
|
|
43
|
-
immediate: true
|
|
44
|
-
});
|
|
45
|
-
const onValueChange = (event) => {
|
|
46
|
-
var _a;
|
|
47
|
-
try {
|
|
48
|
-
let value = event;
|
|
49
|
-
if (typeof getValueFromEvent === "function") {
|
|
50
|
-
value = getValueFromEvent(event, form, formItemInstance);
|
|
51
|
-
} else if (event && event.target && typeof event.target === "object" && getValuePath in event.target) {
|
|
52
|
-
value = get(event.target, getValuePath);
|
|
53
|
-
}
|
|
54
|
-
if (typeof formatValue === "function") {
|
|
55
|
-
value = formatValue(value, form, formItemInstance, event);
|
|
56
|
-
}
|
|
57
|
-
if (oldValue.value !== value) {
|
|
58
|
-
form.updatedFieldValue(toValue(newName), value, "validate");
|
|
59
|
-
(_a = formItemInstance.onAfterUpdate) == null ? void 0 : _a.call(formItemInstance, value, form, formItemInstance, event);
|
|
60
|
-
if (Array.isArray(formItemInstance.noticeWatchField) && formItemInstance.noticeWatchField.length) {
|
|
61
|
-
form.noticeWatch(formItemInstance.noticeWatchField);
|
|
62
|
-
}
|
|
63
|
-
if (Array.isArray(formItemInstance.noticeOnlyRuleDataField) && formItemInstance.noticeOnlyRuleDataField.length) {
|
|
64
|
-
form.onlyValidate(formItemInstance.noticeOnlyRuleDataField);
|
|
65
|
-
}
|
|
66
|
-
if (formItemInstance.isNoticeParentField && formItemInstance.parentDataField) {
|
|
67
|
-
form.notice(formItemInstance.parentDataField);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
console.log(error);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
formItemInstance.onChange = onValueChange;
|
|
75
|
-
const htmlFor = useHtmlFor(newName);
|
|
76
|
-
watch(() => htmlFor, () => {
|
|
77
|
-
formItemInstance.htmlFor = htmlFor.value;
|
|
78
|
-
}, {
|
|
79
|
-
immediate: true
|
|
80
|
-
});
|
|
81
|
-
const newAttrs = computed(() => {
|
|
82
|
-
const _attr = inputAttrs || {};
|
|
83
|
-
return {
|
|
84
|
-
..._attr,
|
|
85
|
-
[trigger]: onValueChange,
|
|
86
|
-
name: toValue(newName),
|
|
87
|
-
id: toValue(htmlFor),
|
|
88
|
-
[valuePropName]: toValue(oldValue)
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
const attrsLastData = ref(toValue(newAttrs));
|
|
92
|
-
watch(() => [toValue(newAttrs), toValue(deepRefData), toValue(oldValue)], () => {
|
|
93
|
-
attrsLastData.value = (useAttrs == null ? void 0 : useAttrs(toValue(newAttrs), form, formItemInstance)) || toValue(newAttrs);
|
|
94
|
-
}, {
|
|
95
|
-
immediate: true
|
|
96
|
-
});
|
|
97
|
-
const validateResult = ref(toValue(ruleInstance).getValidateResult());
|
|
98
|
-
watch(() => [toValue(deepRefData), toValue(oldValue)], () => {
|
|
99
|
-
useRules == null ? void 0 : useRules(ruleInstance, form, formItemInstance);
|
|
100
|
-
});
|
|
101
|
-
watch(() => [toValue(ruleInstance).messages, toValue(ruleInstance).rules, toValue(oldValue)], () => {
|
|
102
|
-
validateResult.value = toValue(ruleInstance).getValidateResult();
|
|
103
|
-
});
|
|
104
|
-
return {
|
|
105
|
-
valuePropName,
|
|
106
|
-
htmlFor,
|
|
107
|
-
onChange: onValueChange,
|
|
108
|
-
formItemInstance,
|
|
109
|
-
form,
|
|
110
|
-
ruleInstance,
|
|
111
|
-
newAttrs,
|
|
112
|
-
attrsLastData,
|
|
113
|
-
validateResult,
|
|
114
|
-
newSort,
|
|
115
|
-
newName
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
export {
|
|
119
|
-
useFormItemAttr
|
|
120
|
-
};
|
package/esm/hooks/index.d.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,9 +0,0 @@
|
|
|
1
|
-
import { RegisterFormItemOptions } from './register.FormItem';
|
|
2
|
-
interface RegisterFormHideItemOptions extends Omit<RegisterFormItemOptions, 'rules'> {
|
|
3
|
-
}
|
|
4
|
-
/**注册表单隐藏表单项到表单实例中*/
|
|
5
|
-
export declare const useRegisterFormHideItem: (options: RegisterFormHideItemOptions) => {
|
|
6
|
-
form: import('@carefrees/form-utils').FormInstanceBase<any>;
|
|
7
|
-
isHide: import('vue').Ref<any, any>;
|
|
8
|
-
};
|
|
9
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ref, watch, toValue } from "vue";
|
|
2
|
-
import { FormHideItemInstanceBase } from "@carefrees/form-utils";
|
|
3
|
-
import { useFormItemParentNameInject } from "../useFormItemParentName.mjs";
|
|
4
|
-
import { useFormInject } from "../useForm.mjs";
|
|
5
|
-
import { useEffect } from "../useEffect.mjs";
|
|
6
|
-
const useRegisterFormHideItem = (options) => {
|
|
7
|
-
const { name, sort, isJoinParentField = true } = options;
|
|
8
|
-
const form = useFormInject();
|
|
9
|
-
const { newName, newSort } = useFormItemParentNameInject({ name, sort, isJoinParentField });
|
|
10
|
-
const hideItemInstance = ref(new FormHideItemInstanceBase().ctor(newName.value));
|
|
11
|
-
const isHide = ref(form.getFieldHideValue(newName.value));
|
|
12
|
-
watch(
|
|
13
|
-
() => [toValue(isHide)],
|
|
14
|
-
() => {
|
|
15
|
-
hideItemInstance.value.preHideValue = isHide.value;
|
|
16
|
-
},
|
|
17
|
-
{ immediate: true }
|
|
18
|
-
);
|
|
19
|
-
const setValue = () => {
|
|
20
|
-
isHide.value = form.getFieldHideValue(newName.value);
|
|
21
|
-
};
|
|
22
|
-
hideItemInstance.value.updatedItem = setValue;
|
|
23
|
-
watch(
|
|
24
|
-
() => [form, toValue(newSort)],
|
|
25
|
-
() => {
|
|
26
|
-
hideItemInstance.value.instance = form;
|
|
27
|
-
hideItemInstance.value.sort = toValue(newSort);
|
|
28
|
-
},
|
|
29
|
-
{ immediate: true }
|
|
30
|
-
);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
return form.registerFormHideItem(toValue(hideItemInstance));
|
|
33
|
-
});
|
|
34
|
-
return { form, isHide };
|
|
35
|
-
};
|
|
36
|
-
export {
|
|
37
|
-
useRegisterFormHideItem
|
|
38
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
import { RuleItem } from 'async-validator';
|
|
3
|
-
import { RuleInstanceBase2 } from '../../instance/ruleIntsnace';
|
|
4
|
-
export interface RegisterFormItemOptions {
|
|
5
|
-
/**字段*/
|
|
6
|
-
name: string;
|
|
7
|
-
/**规则*/
|
|
8
|
-
rules?: RuleItem[];
|
|
9
|
-
/**排序值*/
|
|
10
|
-
sort?: string;
|
|
11
|
-
/**是否拼接父级字段*/
|
|
12
|
-
isJoinParentField?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**注册表单项到表单实例中*/
|
|
15
|
-
export declare const useRegisterFormItem: (options: RegisterFormItemOptions) => {
|
|
16
|
-
ruleInstance: Ref<RuleInstanceBase2, RuleInstanceBase2>;
|
|
17
|
-
formItemInstance: import('@carefrees/form-utils').FormItemInstanceBase;
|
|
18
|
-
form: import('@carefrees/form-utils').FormInstanceBase<any>;
|
|
19
|
-
newName: import('vue').ComputedRef<string>;
|
|
20
|
-
newSort: import('vue').ComputedRef<string>;
|
|
21
|
-
parentItem: import('vue').ComputedRef<import('../..').PartialComputedRefs<Omit<import('../useFormItemParentName').FormItemParentNamOptions, "isJoinParentField">>>;
|
|
22
|
-
deepRefData: Ref<any, any>;
|
|
23
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ref, watch, toValue } from "vue";
|
|
2
|
-
import { useFormInject } from "../useForm.mjs";
|
|
3
|
-
import { useFormItem } from "../useFormItem.mjs";
|
|
4
|
-
import { useFormItemParentNameInject } from "../useFormItemParentName.mjs";
|
|
5
|
-
import { useEffect } from "../useEffect.mjs";
|
|
6
|
-
import { RuleInstanceBase2 } from "../../instance/ruleIntsnace.mjs";
|
|
7
|
-
const useRegisterFormItem = (options) => {
|
|
8
|
-
const { name, rules, sort, isJoinParentField = true } = options;
|
|
9
|
-
const form = useFormInject();
|
|
10
|
-
const deepRefData = ref({});
|
|
11
|
-
const { newName, newSort, parentItem } = useFormItemParentNameInject({ name, sort, isJoinParentField });
|
|
12
|
-
const ruleInstance = ref(new RuleInstanceBase2());
|
|
13
|
-
const formItemInstance = useFormItem();
|
|
14
|
-
watch(
|
|
15
|
-
() => [form],
|
|
16
|
-
() => {
|
|
17
|
-
ruleInstance.value.instance = form;
|
|
18
|
-
formItemInstance.instance = form;
|
|
19
|
-
},
|
|
20
|
-
{ immediate: true }
|
|
21
|
-
);
|
|
22
|
-
watch(
|
|
23
|
-
() => [toValue(newName)],
|
|
24
|
-
() => {
|
|
25
|
-
ruleInstance.value.ctor(toValue(newName), rules || []);
|
|
26
|
-
formItemInstance.ctor(toValue(newName), toValue(ruleInstance));
|
|
27
|
-
},
|
|
28
|
-
{ immediate: true }
|
|
29
|
-
);
|
|
30
|
-
watch(
|
|
31
|
-
() => [toValue(newSort)],
|
|
32
|
-
() => {
|
|
33
|
-
ruleInstance.value.sort = toValue(newSort);
|
|
34
|
-
formItemInstance.sort = toValue(newSort);
|
|
35
|
-
},
|
|
36
|
-
{ immediate: true }
|
|
37
|
-
);
|
|
38
|
-
watch(
|
|
39
|
-
() => [toValue(parentItem)],
|
|
40
|
-
() => {
|
|
41
|
-
formItemInstance.parentDataField = toValue(toValue(parentItem).name);
|
|
42
|
-
},
|
|
43
|
-
{ immediate: true }
|
|
44
|
-
);
|
|
45
|
-
const updated = () => {
|
|
46
|
-
deepRefData.value = { __temp: (/* @__PURE__ */ new Date()).valueOf() };
|
|
47
|
-
};
|
|
48
|
-
formItemInstance.updated = updated;
|
|
49
|
-
ruleInstance.value.updated = updated;
|
|
50
|
-
useEffect(() => form.registerFormItem(formItemInstance));
|
|
51
|
-
return { ruleInstance, formItemInstance, form, newName, newSort, parentItem, deepRefData };
|
|
52
|
-
};
|
|
53
|
-
export {
|
|
54
|
-
useRegisterFormItem
|
|
55
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { RegisterFormItemOptions } from './register.FormItem';
|
|
2
|
-
export interface RegisterFormListOptions extends RegisterFormItemOptions {
|
|
3
|
-
}
|
|
4
|
-
/**注册表单List到表单实例中*/
|
|
5
|
-
export declare const useRegisterFormList: (options: RegisterFormListOptions) => {
|
|
6
|
-
ruleInstance: import('vue').Ref<import('../../instance/ruleIntsnace').RuleInstanceBase2, import('../../instance/ruleIntsnace').RuleInstanceBase2>;
|
|
7
|
-
formItemInstance: import('@carefrees/form-utils').FormItemInstanceBase;
|
|
8
|
-
formListInstance: import('@carefrees/form-utils').FormListInstanceBase;
|
|
9
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { watch, toValue } from "vue";
|
|
2
|
-
import { useRegisterFormItem } from "./register.FormItem.mjs";
|
|
3
|
-
import { useFormList } from "../useFormList.mjs";
|
|
4
|
-
import { useEffect } from "../useEffect.mjs";
|
|
5
|
-
const useRegisterFormList = (options) => {
|
|
6
|
-
const { ruleInstance, formItemInstance, form, newName, parentItem } = useRegisterFormItem(options);
|
|
7
|
-
const formListInstance = useFormList();
|
|
8
|
-
watch(
|
|
9
|
-
() => [toValue(newName)],
|
|
10
|
-
() => {
|
|
11
|
-
formListInstance.ctor(toValue(newName));
|
|
12
|
-
},
|
|
13
|
-
{ immediate: true }
|
|
14
|
-
);
|
|
15
|
-
watch(
|
|
16
|
-
() => [form, formItemInstance, toValue(ruleInstance)],
|
|
17
|
-
() => {
|
|
18
|
-
formListInstance.instance = form;
|
|
19
|
-
formListInstance.formItemInstance = formItemInstance;
|
|
20
|
-
formListInstance.rule = toValue(ruleInstance);
|
|
21
|
-
},
|
|
22
|
-
{ immediate: true }
|
|
23
|
-
);
|
|
24
|
-
watch(
|
|
25
|
-
() => [options.sort, toValue(parentItem)],
|
|
26
|
-
() => {
|
|
27
|
-
formListInstance.sort = toValue(parentItem.value.sort);
|
|
28
|
-
formListInstance.parentDataField = toValue(parentItem.value.name);
|
|
29
|
-
},
|
|
30
|
-
{ immediate: true }
|
|
31
|
-
);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
return form.registerFormList(newName.value, formListInstance);
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
ruleInstance,
|
|
37
|
-
formItemInstance,
|
|
38
|
-
formListInstance
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
export {
|
|
42
|
-
useRegisterFormList
|
|
43
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useMultipleFormInject } from "../useMultipleForm.mjs";
|
|
2
|
-
import { useEffect } from "../useEffect.mjs";
|
|
3
|
-
const useRegisterForm = (form, name) => {
|
|
4
|
-
const multipleForm = useMultipleFormInject();
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
if (name) return multipleForm.ctor(name, form);
|
|
7
|
-
});
|
|
8
|
-
return multipleForm;
|
|
9
|
-
};
|
|
10
|
-
export {
|
|
11
|
-
useRegisterForm
|
|
12
|
-
};
|
package/esm/hooks/useAttrs.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { StyleValue, ComputedRef } from 'vue';
|
|
2
|
-
import { ComputedRefBase } from '../interface';
|
|
3
|
-
export type AttrsOptions = {
|
|
4
|
-
/**列数据*/
|
|
5
|
-
colCount?: ComputedRefBase<number | undefined>;
|
|
6
|
-
/**规则校验失败错误提示位置*/
|
|
7
|
-
errorLayout?: ComputedRefBase<'left-bottom' | 'right-bottom' | 'top-right' | 'top-left' | undefined>;
|
|
8
|
-
/**label显示模式*/
|
|
9
|
-
labelMode?: ComputedRefBase<'left' | 'top' | 'hide' | undefined>;
|
|
10
|
-
/**是否显示label后的冒号*/
|
|
11
|
-
showColon?: ComputedRefBase<boolean | undefined>;
|
|
12
|
-
/**表单项 className*/
|
|
13
|
-
formItemClass?: ComputedRefBase<string | undefined>;
|
|
14
|
-
/**表单项 style*/
|
|
15
|
-
formItemStyle?: ComputedRefBase<StyleValue | undefined>;
|
|
16
|
-
/**表单项 label className*/
|
|
17
|
-
formItemLabelClass?: ComputedRefBase<string | undefined>;
|
|
18
|
-
/**表单项 label style*/
|
|
19
|
-
formItemLabelStyle?: ComputedRefBase<StyleValue | undefined>;
|
|
20
|
-
};
|
|
21
|
-
/**公共属性 Context */
|
|
22
|
-
export declare function useAttrsProvide(options: AttrsOptions): void;
|
|
23
|
-
/**子项中获取公共属性*/
|
|
24
|
-
export declare function useAttrsInject(): ComputedRef<AttrsOptions>;
|
package/esm/hooks/useAttrs.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { inject, computed, ref, provide, reactive } from "vue";
|
|
2
|
-
const attrsProvideSymbol = Symbol("carefrees-attrs");
|
|
3
|
-
function useAttrsProvide(options) {
|
|
4
|
-
const {
|
|
5
|
-
colCount = ref(4),
|
|
6
|
-
errorLayout = ref("left-bottom"),
|
|
7
|
-
labelMode = ref("top"),
|
|
8
|
-
showColon = ref(true),
|
|
9
|
-
formItemClass,
|
|
10
|
-
formItemStyle,
|
|
11
|
-
formItemLabelClass,
|
|
12
|
-
formItemLabelStyle
|
|
13
|
-
} = options;
|
|
14
|
-
const data = computed(() => {
|
|
15
|
-
return {
|
|
16
|
-
colCount,
|
|
17
|
-
errorLayout,
|
|
18
|
-
labelMode,
|
|
19
|
-
showColon,
|
|
20
|
-
formItemClass,
|
|
21
|
-
formItemStyle,
|
|
22
|
-
formItemLabelClass,
|
|
23
|
-
formItemLabelStyle
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
provide(attrsProvideSymbol, reactive(data));
|
|
27
|
-
}
|
|
28
|
-
function useAttrsInject() {
|
|
29
|
-
const attrs = inject(
|
|
30
|
-
attrsProvideSymbol,
|
|
31
|
-
computed(() => ({
|
|
32
|
-
colCount: ref(4),
|
|
33
|
-
errorLayout: ref("left-bottom"),
|
|
34
|
-
labelMode: ref("top"),
|
|
35
|
-
showColon: ref(true)
|
|
36
|
-
}))
|
|
37
|
-
);
|
|
38
|
-
return attrs;
|
|
39
|
-
}
|
|
40
|
-
export {
|
|
41
|
-
useAttrsInject,
|
|
42
|
-
useAttrsProvide
|
|
43
|
-
};
|
package/esm/hooks/useEffect.d.ts
DELETED
package/esm/hooks/useEffect.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ref, onMounted, onUnmounted } from "vue";
|
|
2
|
-
const useEffect = (fun) => {
|
|
3
|
-
const unRegisterRef = ref();
|
|
4
|
-
onMounted(() => {
|
|
5
|
-
unRegisterRef.value = fun();
|
|
6
|
-
});
|
|
7
|
-
onUnmounted(() => {
|
|
8
|
-
typeof unRegisterRef.value === "function" && unRegisterRef.value();
|
|
9
|
-
unRegisterRef.value = void 0;
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
useEffect
|
|
14
|
-
};
|
package/esm/hooks/useForm.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FormInstanceBase } from '@carefrees/form-utils';
|
|
2
|
-
import { Ref } from 'vue';
|
|
3
|
-
/**表单实例 Context */
|
|
4
|
-
export declare function useFormProvide<T = any>(form: FormInstanceBase<T>): void;
|
|
5
|
-
/**子项中获取表单实例*/
|
|
6
|
-
export declare function useFormInject<T = any>(): FormInstanceBase<T>;
|
|
7
|
-
/**初始化表单实例*/
|
|
8
|
-
export declare function useForm<T = any>(form?: FormInstanceBase<T>): Ref<FormInstanceBase<T>, FormInstanceBase<T>>;
|
package/esm/hooks/useForm.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FormInstanceBase } from "@carefrees/form-utils";
|
|
2
|
-
import { ref, provide, inject } from "vue";
|
|
3
|
-
const formProvideSymbol = Symbol("carefrees-form");
|
|
4
|
-
function useFormProvide(form) {
|
|
5
|
-
provide(formProvideSymbol, form);
|
|
6
|
-
}
|
|
7
|
-
function useFormInject() {
|
|
8
|
-
const form = inject(formProvideSymbol, new FormInstanceBase());
|
|
9
|
-
return form;
|
|
10
|
-
}
|
|
11
|
-
function useForm(form) {
|
|
12
|
-
const refForm = ref();
|
|
13
|
-
if (!refForm.value) {
|
|
14
|
-
if (form) {
|
|
15
|
-
refForm.value = form;
|
|
16
|
-
} else {
|
|
17
|
-
refForm.value = new FormInstanceBase();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return refForm;
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
useForm,
|
|
24
|
-
useFormInject,
|
|
25
|
-
useFormProvide
|
|
26
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FormItemInstanceBase } from '@carefrees/form-utils';
|
|
2
|
-
/**表单项实例 Context */
|
|
3
|
-
export declare function useFormItemProvide(formItem: FormItemInstanceBase): void;
|
|
4
|
-
/**子项中获取表单项实例*/
|
|
5
|
-
export declare function useFormItemInject(): FormItemInstanceBase;
|
|
6
|
-
/**s初始化 表单项实例*/
|
|
7
|
-
export declare function useFormItem(formItem?: FormItemInstanceBase): FormItemInstanceBase;
|
|
@@ -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,18 +0,0 @@
|
|
|
1
|
-
import { ComputedRef } from 'vue';
|
|
2
|
-
import { PartialComputedRefs } from '../interface';
|
|
3
|
-
export interface FormItemParentNamOptions {
|
|
4
|
-
/**字段*/
|
|
5
|
-
name: string;
|
|
6
|
-
/**排序*/
|
|
7
|
-
sort?: string;
|
|
8
|
-
/**是否拼接父级字段*/
|
|
9
|
-
isJoinParentField?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export type FormItemParentNameProviderProps = PartialComputedRefs<Omit<FormItemParentNamOptions, 'isJoinParentField'>>;
|
|
12
|
-
export declare const useFormItemParentNameProvide: (props: FormItemParentNameProviderProps) => void;
|
|
13
|
-
/**表单项获取父级字段*/
|
|
14
|
-
export declare const useFormItemParentNameInject: (options: FormItemParentNamOptions) => {
|
|
15
|
-
newName: ComputedRef<string>;
|
|
16
|
-
newSort: ComputedRef<string>;
|
|
17
|
-
parentItem: ComputedRef<PartialComputedRefs<Omit<FormItemParentNamOptions, "isJoinParentField">>>;
|
|
18
|
-
};
|
|
@@ -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,7 +0,0 @@
|
|
|
1
|
-
import { FormListInstanceBase } from '@carefrees/form-utils';
|
|
2
|
-
/**表单List实例 Context */
|
|
3
|
-
export declare function useFormListProvide(formList: FormListInstanceBase): void;
|
|
4
|
-
/**子项中获取表单List实例*/
|
|
5
|
-
export declare function useFormListInject(): FormListInstanceBase;
|
|
6
|
-
/**初始化 表单List实例*/
|
|
7
|
-
export declare function useFormList(formList?: FormListInstanceBase): FormListInstanceBase;
|
|
@@ -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,7 +0,0 @@
|
|
|
1
|
-
import { MultipleInstanceBase } from '@carefrees/form-utils';
|
|
2
|
-
/**多表单收集 Context */
|
|
3
|
-
export declare function useMultipleFormProvide(multipleForm?: MultipleInstanceBase): void;
|
|
4
|
-
/**子项中获取 多表单收集 实例*/
|
|
5
|
-
export declare function useMultipleFormInject(): MultipleInstanceBase;
|
|
6
|
-
/**初始化 多表单收集 实例*/
|
|
7
|
-
export declare function useMultipleForm(multipleForm?: MultipleInstanceBase): MultipleInstanceBase;
|
|
@@ -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
|
-
};
|