@carefrees/form-utils-react-taro 0.0.4
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 +9 -0
- package/esm/formItem/index.d.ts +11 -0
- package/esm/formItem/index.js +70 -0
- package/esm/formList/index.d.ts +27 -0
- package/esm/formList/index.js +40 -0
- package/esm/hooks/attr/attr.FormItem.d.ts +48 -0
- package/esm/hooks/attr/attr.FormItem.js +61 -0
- package/esm/hooks/register/register.FormHideItem.d.ts +9 -0
- package/esm/hooks/register/register.FormHideItem.js +31 -0
- package/esm/hooks/register/register.FormItem.d.ts +23 -0
- package/esm/hooks/register/register.FormItem.js +42 -0
- package/esm/hooks/register/register.FormList.d.ts +9 -0
- package/esm/hooks/register/register.FormList.js +31 -0
- package/esm/hooks/register/register.form.d.ts +3 -0
- package/esm/hooks/register/register.form.js +17 -0
- package/esm/hooks/useAttrs.d.ts +25 -0
- package/esm/hooks/useAttrs.js +10 -0
- package/esm/hooks/useForm.d.ts +7 -0
- package/esm/hooks/useForm.js +13 -0
- package/esm/hooks/useFormItem.d.ts +7 -0
- package/esm/hooks/useFormItem.js +11 -0
- package/esm/hooks/useFormItemParentName.d.ts +30 -0
- package/esm/hooks/useFormItemParentName.js +61 -0
- package/esm/hooks/useFormList.d.ts +7 -0
- package/esm/hooks/useFormList.js +11 -0
- package/esm/hooks/useHtmlFor.d.ts +1 -0
- package/esm/hooks/useHtmlFor.js +10 -0
- package/esm/hooks/useMultipleForm.d.ts +13 -0
- package/esm/hooks/useMultipleForm.js +19 -0
- package/esm/hooks/useUpdate.d.ts +2 -0
- package/esm/hooks/useUpdate.js +10 -0
- package/esm/hooks/useWatch.d.ts +19 -0
- package/esm/hooks/useWatch.js +41 -0
- package/esm/index.d.ts +46 -0
- package/esm/index.js +61 -0
- package/esm/layout/index.d.ts +35 -0
- package/esm/layout/index.js +99 -0
- package/esm/layout/layout.formItem.d.ts +44 -0
- package/esm/layout/layout.formItem.js +113 -0
- package/esm/styles/index.css +200 -0
- package/lib/formItem/index.d.ts +11 -0
- package/lib/formItem/index.js +107 -0
- package/lib/formList/index.d.ts +27 -0
- package/lib/formList/index.js +77 -0
- package/lib/hooks/attr/attr.FormItem.d.ts +48 -0
- package/lib/hooks/attr/attr.FormItem.js +95 -0
- package/lib/hooks/register/register.FormHideItem.d.ts +9 -0
- package/lib/hooks/register/register.FormHideItem.js +65 -0
- package/lib/hooks/register/register.FormItem.d.ts +23 -0
- package/lib/hooks/register/register.FormItem.js +76 -0
- package/lib/hooks/register/register.FormList.d.ts +9 -0
- package/lib/hooks/register/register.FormList.js +65 -0
- package/lib/hooks/register/register.form.d.ts +3 -0
- package/lib/hooks/register/register.form.js +51 -0
- package/lib/hooks/useAttrs.d.ts +25 -0
- package/lib/hooks/useAttrs.js +47 -0
- package/lib/hooks/useForm.d.ts +7 -0
- package/lib/hooks/useForm.js +53 -0
- package/lib/hooks/useFormItem.d.ts +7 -0
- package/lib/hooks/useFormItem.js +51 -0
- package/lib/hooks/useFormItemParentName.d.ts +30 -0
- package/lib/hooks/useFormItemParentName.js +101 -0
- package/lib/hooks/useFormList.d.ts +7 -0
- package/lib/hooks/useFormList.js +51 -0
- package/lib/hooks/useHtmlFor.d.ts +1 -0
- package/lib/hooks/useHtmlFor.js +44 -0
- package/lib/hooks/useMultipleForm.d.ts +13 -0
- package/lib/hooks/useMultipleForm.js +62 -0
- package/lib/hooks/useUpdate.d.ts +2 -0
- package/lib/hooks/useUpdate.js +44 -0
- package/lib/hooks/useWatch.d.ts +19 -0
- package/lib/hooks/useWatch.js +78 -0
- package/lib/index.d.ts +46 -0
- package/lib/index.js +317 -0
- package/lib/layout/index.d.ts +35 -0
- package/lib/layout/index.js +146 -0
- package/lib/layout/layout.formItem.d.ts +44 -0
- package/lib/layout/layout.formItem.js +157 -0
- package/lib/styles/index.css +200 -0
- package/package.json +32 -0
- package/src/formItem/index.tsx +103 -0
- package/src/formList/index.tsx +59 -0
- package/src/hooks/attr/attr.FormItem.tsx +131 -0
- package/src/hooks/register/register.FormHideItem.ts +29 -0
- package/src/hooks/register/register.FormItem.ts +52 -0
- package/src/hooks/register/register.FormList.ts +31 -0
- package/src/hooks/register/register.form.ts +18 -0
- package/src/hooks/useAttrs.ts +35 -0
- package/src/hooks/useForm.ts +23 -0
- package/src/hooks/useFormItem.ts +21 -0
- package/src/hooks/useFormItemParentName.ts +49 -0
- package/src/hooks/useFormList.ts +21 -0
- package/src/hooks/useHtmlFor.ts +9 -0
- package/src/hooks/useMultipleForm.ts +36 -0
- package/src/hooks/useUpdate.ts +12 -0
- package/src/hooks/useWatch.ts +61 -0
- package/src/index.tsx +102 -0
- package/src/layout/index.tsx +152 -0
- package/src/layout/layout.formItem.tsx +152 -0
- package/src/styles/index.css +208 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LayoutFormItemProps } from './../layout/layout.formItem';
|
|
2
|
+
import { FormItemAttrOptions } from '../hooks/attr/attr.FormItem';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface FormItemProps extends FormItemAttrOptions, LayoutFormItemProps {
|
|
5
|
+
/**不进行样式渲染*/
|
|
6
|
+
noStyle?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**表单项*/
|
|
9
|
+
export declare const FormItem: React.MemoExoticComponent<(props: Partial<FormItemProps>) => import("react/jsx-runtime").JSX.Element>;
|
|
10
|
+
/**隐藏表单项*/
|
|
11
|
+
export declare const FormHideItem: React.MemoExoticComponent<(props: FormItemProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__layout_layout_formItem_js_c84059c5__ from "../layout/layout.formItem.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_attr_attr_FormItem_js_9b75aef3__ from "../hooks/attr/attr.FormItem.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useFormItemParentName_js_ed96cda3__ from "../hooks/useFormItemParentName.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormHideItem_js_2b23597a__ from "../hooks/register/register.FormHideItem.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
7
|
+
const FormItemInstance = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
8
|
+
const { labelMode, noStyle, onlyRuleStyle, label, helpText, extra, errorLayout, required, showColon, colSpan, rowSpan, ...rest } = props;
|
|
9
|
+
const { children, ruleInstance, formItemInstance, htmlFor, validateResult } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_attr_attr_FormItem_js_9b75aef3__.useFormItemAttr)({
|
|
10
|
+
...rest
|
|
11
|
+
});
|
|
12
|
+
if (noStyle) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__hooks_useFormItemParentName_js_ed96cda3__.FormItemParentNameProvider, {
|
|
13
|
+
name: formItemInstance.name,
|
|
14
|
+
sort: formItemInstance.sort,
|
|
15
|
+
children: children
|
|
16
|
+
});
|
|
17
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__hooks_useFormItemParentName_js_ed96cda3__.FormItemParentNameProvider, {
|
|
18
|
+
name: formItemInstance.name,
|
|
19
|
+
sort: formItemInstance.sort,
|
|
20
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__layout_layout_formItem_js_c84059c5__.LayoutFormItem, {
|
|
21
|
+
labelMode: labelMode,
|
|
22
|
+
onlyRuleStyle: onlyRuleStyle,
|
|
23
|
+
required: required || ruleInstance?.isRequired?.(),
|
|
24
|
+
label: label,
|
|
25
|
+
helpText: helpText,
|
|
26
|
+
extra: extra,
|
|
27
|
+
errorLayout: errorLayout,
|
|
28
|
+
showColon: showColon,
|
|
29
|
+
colSpan: colSpan,
|
|
30
|
+
rowSpan: rowSpan,
|
|
31
|
+
htmlFor: htmlFor,
|
|
32
|
+
validateResult: validateResult,
|
|
33
|
+
children: children
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
const FormItem = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
38
|
+
const { name } = props;
|
|
39
|
+
if (name) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FormItemInstance, {
|
|
40
|
+
...props,
|
|
41
|
+
name: name
|
|
42
|
+
});
|
|
43
|
+
const { labelMode, onlyRuleStyle, label, helpText, extra, errorLayout, required, showColon, colSpan, rowSpan, children } = props;
|
|
44
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__layout_layout_formItem_js_c84059c5__.LayoutFormItem, {
|
|
45
|
+
labelMode: labelMode,
|
|
46
|
+
onlyRuleStyle: onlyRuleStyle,
|
|
47
|
+
required: required,
|
|
48
|
+
label: label,
|
|
49
|
+
helpText: helpText,
|
|
50
|
+
extra: extra,
|
|
51
|
+
errorLayout: errorLayout,
|
|
52
|
+
showColon: showColon,
|
|
53
|
+
colSpan: colSpan,
|
|
54
|
+
rowSpan: rowSpan,
|
|
55
|
+
children: children
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
const FormHideItem = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
59
|
+
const { name, sort, isJoinParentField } = props;
|
|
60
|
+
const { isHide } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormHideItem_js_2b23597a__.useRegisterFormHideItem)({
|
|
61
|
+
name,
|
|
62
|
+
sort: sort,
|
|
63
|
+
isJoinParentField
|
|
64
|
+
});
|
|
65
|
+
if (isHide) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Fragment, {});
|
|
66
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FormItemInstance, {
|
|
67
|
+
...props
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
export { FormHideItem, FormItem };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RegisterFormListOptions } from './../hooks/register/register.FormList';
|
|
2
|
+
import { RuleInstanceBase, FormItemInstanceBase, FormListInstanceBase } from '@carefrees/form-utils';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface FormListChildrenProps {
|
|
5
|
+
/**数据集合*/
|
|
6
|
+
fields: {
|
|
7
|
+
name: number;
|
|
8
|
+
key: number;
|
|
9
|
+
}[];
|
|
10
|
+
/**添加*/
|
|
11
|
+
onAdd: (initialValue?: Object) => void;
|
|
12
|
+
/**删除*/
|
|
13
|
+
onDelete: (index: number | number[]) => void;
|
|
14
|
+
/**移动*/
|
|
15
|
+
onMove: (from: number, to: number) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface FormListProps extends RegisterFormListOptions {
|
|
18
|
+
children: (options: FormListChildrenProps, instances: {
|
|
19
|
+
ruleInstance: RuleInstanceBase;
|
|
20
|
+
formItemInstance: FormItemInstanceBase;
|
|
21
|
+
formListInstance: FormListInstanceBase;
|
|
22
|
+
}) => React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/**form list 组件*/
|
|
25
|
+
export declare const FormList: React.MemoExoticComponent<(props: FormListProps) => import("react/jsx-runtime").JSX.Element>;
|
|
26
|
+
/**隐藏 form list item 组件*/
|
|
27
|
+
export declare const FormHideList: React.MemoExoticComponent<(props: FormListProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormList_js_6f2f394b__ from "../hooks/register/register.FormList.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useFormList_js_058846bf__ from "../hooks/useFormList.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useFormItemParentName_js_ed96cda3__ from "../hooks/useFormItemParentName.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormHideItem_js_2b23597a__ from "../hooks/register/register.FormHideItem.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
7
|
+
const FormList = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
8
|
+
const { children, ...rest } = props;
|
|
9
|
+
const { formListInstance, ruleInstance, formItemInstance } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormList_js_6f2f394b__.useRegisterFormList)(rest);
|
|
10
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__hooks_useFormList_js_058846bf__.FormListInstanceContext.Provider, {
|
|
11
|
+
value: formListInstance,
|
|
12
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__hooks_useFormItemParentName_js_ed96cda3__.FormItemParentNameProvider, {
|
|
13
|
+
name: formListInstance.name,
|
|
14
|
+
sort: formListInstance.sort,
|
|
15
|
+
children: children({
|
|
16
|
+
fields: formListInstance.getFields(),
|
|
17
|
+
onAdd: formListInstance.onAdd,
|
|
18
|
+
onDelete: formListInstance.onDelete,
|
|
19
|
+
onMove: formListInstance.onMove
|
|
20
|
+
}, {
|
|
21
|
+
ruleInstance,
|
|
22
|
+
formItemInstance,
|
|
23
|
+
formListInstance
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
const FormHideList = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
29
|
+
const { name, sort, isJoinParentField } = props;
|
|
30
|
+
const { isHide } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_register_register_FormHideItem_js_2b23597a__.useRegisterFormHideItem)({
|
|
31
|
+
name,
|
|
32
|
+
sort: sort,
|
|
33
|
+
isJoinParentField
|
|
34
|
+
});
|
|
35
|
+
if (isHide) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Fragment, {});
|
|
36
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FormList, {
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
export { FormHideList, FormList };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RuleInstanceBase, FormInstanceBase, FormItemInstanceBase } from '@carefrees/form-utils';
|
|
2
|
+
import { RegisterFormItemOptions } from '../register/register.FormItem';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface FormItemAttrOptions extends RegisterFormItemOptions {
|
|
5
|
+
/**依赖更新项*/
|
|
6
|
+
dependencies?: string[];
|
|
7
|
+
/**通知 只用于校验规则提示 字段 */
|
|
8
|
+
noticeOnlyRuleDataField?: string[];
|
|
9
|
+
/**通知父级字段监听方法更新*/
|
|
10
|
+
isNoticeParentField?: boolean;
|
|
11
|
+
/**通知watch监听方法更新*/
|
|
12
|
+
noticeWatchField?: string[];
|
|
13
|
+
/**是否保护值(不进行表单项组件卸载重置初始值)*/
|
|
14
|
+
preserve?: boolean;
|
|
15
|
+
/**重写规则*/
|
|
16
|
+
useRules?: (ruleInstance: RuleInstanceBase, form: FormInstanceBase, formItemInstance: FormItemInstanceBase) => void;
|
|
17
|
+
/**输入框属性重写*/
|
|
18
|
+
useAttrs?: (attrs: any, form: FormInstanceBase, formItemInstance: FormItemInstanceBase) => any;
|
|
19
|
+
/**输入框属性*/
|
|
20
|
+
attrs?: any;
|
|
21
|
+
/**传递组件字段*/
|
|
22
|
+
valuePropName?: string;
|
|
23
|
+
/**取值字段(默认和valuePropName值相同)*/
|
|
24
|
+
getValuePath?: string;
|
|
25
|
+
/**自定义获取值*/
|
|
26
|
+
getValueFromEvent?: (event: any, form: FormInstanceBase, formItemInstance: FormItemInstanceBase) => any;
|
|
27
|
+
/**值格式化*/
|
|
28
|
+
formatValue?: (value: any, form: FormInstanceBase, formItemInstance: FormItemInstanceBase, event: any) => any;
|
|
29
|
+
/**触发数据更新之后触发(用于数据联动之类的)*/
|
|
30
|
+
onAfterUpdate?: (value: any, form: FormInstanceBase, formItemInstance: FormItemInstanceBase, event: any) => void;
|
|
31
|
+
/**事件名称*/
|
|
32
|
+
trigger?: string;
|
|
33
|
+
/**子元素*/
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
/**表单项参数*/
|
|
37
|
+
export declare const useFormItemAttr: (options: FormItemAttrOptions) => {
|
|
38
|
+
children: string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>;
|
|
39
|
+
form: FormInstanceBase<any>;
|
|
40
|
+
formItemInstance: FormItemInstanceBase;
|
|
41
|
+
ruleInstance: RuleInstanceBase;
|
|
42
|
+
onChange: (event: any) => void;
|
|
43
|
+
htmlFor: string;
|
|
44
|
+
validateResult: {
|
|
45
|
+
tip: string | (string | undefined)[];
|
|
46
|
+
isInvalid: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__ from "@carefrees/form-utils";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__register_register_FormItem_js_448be97f__ from "../register/register.FormItem.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useHtmlFor_js_30172224__ from "../useHtmlFor.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
|
+
const useFormItemAttr = (options)=>{
|
|
6
|
+
const { trigger = 'onChange', dependencies, noticeOnlyRuleDataField, isNoticeParentField, noticeWatchField, preserve, valuePropName = 'value', getValuePath = valuePropName, getValueFromEvent, formatValue, onAfterUpdate, useAttrs, useRules, attrs, children, ...rest } = options;
|
|
7
|
+
const { formItemInstance, form, ruleInstance, newName } = (0, __WEBPACK_EXTERNAL_MODULE__register_register_FormItem_js_448be97f__.useRegisterFormItem)({
|
|
8
|
+
...rest
|
|
9
|
+
});
|
|
10
|
+
formItemInstance.dependencies = dependencies;
|
|
11
|
+
formItemInstance.noticeOnlyRuleDataField = noticeOnlyRuleDataField;
|
|
12
|
+
formItemInstance.isNoticeParentField = isNoticeParentField;
|
|
13
|
+
formItemInstance.onAfterUpdate = onAfterUpdate;
|
|
14
|
+
formItemInstance.noticeWatchField = noticeWatchField;
|
|
15
|
+
formItemInstance.preserve = preserve;
|
|
16
|
+
const oldValue = form.getFieldValue(newName);
|
|
17
|
+
const onValueChange = (event)=>{
|
|
18
|
+
try {
|
|
19
|
+
let value = event;
|
|
20
|
+
const target = event?.detail || event?.target;
|
|
21
|
+
if ('function' == typeof getValueFromEvent) value = getValueFromEvent(event, form, formItemInstance);
|
|
22
|
+
else if (event && target && 'object' == typeof target && getValuePath in target) value = (0, __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.get)(target, getValuePath);
|
|
23
|
+
if ('function' == typeof formatValue) value = formatValue(value, form, formItemInstance, event);
|
|
24
|
+
if (oldValue !== value) {
|
|
25
|
+
form.updatedFieldValue(newName, value, 'validate');
|
|
26
|
+
formItemInstance.onAfterUpdate?.(value, form, formItemInstance, event);
|
|
27
|
+
if (Array.isArray(formItemInstance.noticeWatchField) && formItemInstance.noticeWatchField.length) form.noticeWatch(formItemInstance.noticeWatchField);
|
|
28
|
+
if (Array.isArray(formItemInstance.noticeOnlyRuleDataField) && formItemInstance.noticeOnlyRuleDataField.length) form.onlyValidate(formItemInstance.noticeOnlyRuleDataField);
|
|
29
|
+
if (formItemInstance.isNoticeParentField && formItemInstance.parentDataField) form.notice(formItemInstance.parentDataField);
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.log(error);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
formItemInstance.onChange = onValueChange;
|
|
36
|
+
const htmlFor = (0, __WEBPACK_EXTERNAL_MODULE__useHtmlFor_js_30172224__.useHtmlFor)(newName);
|
|
37
|
+
formItemInstance.htmlFor = htmlFor;
|
|
38
|
+
const control = {
|
|
39
|
+
[trigger]: onValueChange,
|
|
40
|
+
...attrs,
|
|
41
|
+
name: newName,
|
|
42
|
+
id: htmlFor,
|
|
43
|
+
[valuePropName]: oldValue
|
|
44
|
+
};
|
|
45
|
+
const newControl = useAttrs?.(control, form, formItemInstance) || control;
|
|
46
|
+
formItemInstance.control = newControl;
|
|
47
|
+
useRules?.(ruleInstance, form, formItemInstance);
|
|
48
|
+
const validateResult = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>ruleInstance.getValidateResult(), [
|
|
49
|
+
ruleInstance.messages
|
|
50
|
+
]);
|
|
51
|
+
return {
|
|
52
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.isValidElement)(children) ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.cloneElement)(children, newControl) : children,
|
|
53
|
+
form,
|
|
54
|
+
formItemInstance,
|
|
55
|
+
ruleInstance,
|
|
56
|
+
onChange: onValueChange,
|
|
57
|
+
htmlFor,
|
|
58
|
+
validateResult
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export { useFormItemAttr };
|
|
@@ -0,0 +1,9 @@
|
|
|
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: any;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__ from "@carefrees/form-utils";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useFormItemParentName_js_a729dfb1__ from "../useFormItemParentName.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useForm_js_2c14e707__ from "../useForm.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useUpdate_js_b5f1687a__ from "../useUpdate.js";
|
|
6
|
+
const useRegisterFormHideItem = (options)=>{
|
|
7
|
+
const { name, sort, isJoinParentField = true } = options;
|
|
8
|
+
const form = (0, __WEBPACK_EXTERNAL_MODULE__useForm_js_2c14e707__.useFormInstance)();
|
|
9
|
+
const _update = (0, __WEBPACK_EXTERNAL_MODULE__useUpdate_js_b5f1687a__.useUpdate)();
|
|
10
|
+
const { newName, newSort } = (0, __WEBPACK_EXTERNAL_MODULE__useFormItemParentName_js_a729dfb1__.useFormItemParentName)({
|
|
11
|
+
name,
|
|
12
|
+
sort,
|
|
13
|
+
isJoinParentField
|
|
14
|
+
});
|
|
15
|
+
const hideItemInstance = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.FormHideItemInstanceBase().ctor(newName)).current;
|
|
16
|
+
const isHide = form.getFieldHideValue(newName);
|
|
17
|
+
hideItemInstance.instance = form;
|
|
18
|
+
hideItemInstance.updated = _update.current;
|
|
19
|
+
hideItemInstance.sort = newSort;
|
|
20
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
21
|
+
const unMount = form.registerFormHideItem(hideItemInstance);
|
|
22
|
+
return ()=>unMount();
|
|
23
|
+
}, [
|
|
24
|
+
newName
|
|
25
|
+
]);
|
|
26
|
+
return {
|
|
27
|
+
form,
|
|
28
|
+
isHide
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export { useRegisterFormHideItem };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 注册组件
|
|
3
|
+
*/
|
|
4
|
+
import { RuleInstanceBase } from '@carefrees/form-utils';
|
|
5
|
+
import type { RuleItem } from 'async-validator';
|
|
6
|
+
export interface RegisterFormItemOptions {
|
|
7
|
+
/**字段*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**规则*/
|
|
10
|
+
rules?: RuleItem[];
|
|
11
|
+
/**排序值*/
|
|
12
|
+
sort?: string;
|
|
13
|
+
/**是否拼接父级字段*/
|
|
14
|
+
isJoinParentField?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**注册表单项到表单实例中*/
|
|
17
|
+
export declare const useRegisterFormItem: (options: RegisterFormItemOptions) => {
|
|
18
|
+
ruleInstance: RuleInstanceBase;
|
|
19
|
+
formItemInstance: import("@carefrees/form-utils").FormItemInstanceBase;
|
|
20
|
+
form: import("@carefrees/form-utils").FormInstanceBase<any>;
|
|
21
|
+
parentName: string;
|
|
22
|
+
newName: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__ from "@carefrees/form-utils";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useUpdate_js_b5f1687a__ from "../useUpdate.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useForm_js_2c14e707__ from "../useForm.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useFormItem_js_cd5761e5__ from "../useFormItem.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useFormItemParentName_js_a729dfb1__ from "../useFormItemParentName.js";
|
|
7
|
+
const useRegisterFormItem = (options)=>{
|
|
8
|
+
const { name, rules, sort, isJoinParentField = true } = options;
|
|
9
|
+
const form = (0, __WEBPACK_EXTERNAL_MODULE__useForm_js_2c14e707__.useFormInstance)();
|
|
10
|
+
const { newName, newSort, parentName } = (0, __WEBPACK_EXTERNAL_MODULE__useFormItemParentName_js_a729dfb1__.useFormItemParentName)({
|
|
11
|
+
name,
|
|
12
|
+
sort,
|
|
13
|
+
isJoinParentField
|
|
14
|
+
});
|
|
15
|
+
const ruleInstance = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.RuleInstanceBase()).current;
|
|
16
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>ruleInstance.ctor(newName, rules), [
|
|
17
|
+
rules,
|
|
18
|
+
newName
|
|
19
|
+
]);
|
|
20
|
+
ruleInstance.instance = form;
|
|
21
|
+
ruleInstance.sort = newSort;
|
|
22
|
+
const formItemInstance = (0, __WEBPACK_EXTERNAL_MODULE__useFormItem_js_cd5761e5__.useFormItem)();
|
|
23
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>formItemInstance.ctor(newName, ruleInstance), []);
|
|
24
|
+
formItemInstance.instance = form;
|
|
25
|
+
formItemInstance.sort = newSort;
|
|
26
|
+
formItemInstance.parentDataField = parentName;
|
|
27
|
+
const _updated = (0, __WEBPACK_EXTERNAL_MODULE__useUpdate_js_b5f1687a__.useUpdate)();
|
|
28
|
+
formItemInstance.updated = _updated.current;
|
|
29
|
+
ruleInstance.updated = _updated.current;
|
|
30
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
31
|
+
const unMount = form.registerFormItem(formItemInstance);
|
|
32
|
+
return ()=>unMount();
|
|
33
|
+
}, []);
|
|
34
|
+
return {
|
|
35
|
+
ruleInstance,
|
|
36
|
+
formItemInstance,
|
|
37
|
+
form,
|
|
38
|
+
parentName,
|
|
39
|
+
newName
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export { useRegisterFormItem };
|
|
@@ -0,0 +1,9 @@
|
|
|
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("@carefrees/form-utils").RuleInstanceBase;
|
|
7
|
+
formItemInstance: import("@carefrees/form-utils").FormItemInstanceBase;
|
|
8
|
+
formListInstance: import("@carefrees/form-utils").FormListInstanceBase;
|
|
9
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__register_FormItem_js_53f62622__ from "./register.FormItem.js";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useFormList_js_fe5717d9__ from "../useFormList.js";
|
|
4
|
+
const useRegisterFormList = (options)=>{
|
|
5
|
+
const { ...rest } = options;
|
|
6
|
+
const { ruleInstance, formItemInstance, form, newName, parentName } = (0, __WEBPACK_EXTERNAL_MODULE__register_FormItem_js_53f62622__.useRegisterFormItem)({
|
|
7
|
+
...rest
|
|
8
|
+
});
|
|
9
|
+
const formListInstance = (0, __WEBPACK_EXTERNAL_MODULE__useFormList_js_fe5717d9__.useFormList)();
|
|
10
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>formListInstance.ctor(newName), [
|
|
11
|
+
newName
|
|
12
|
+
]);
|
|
13
|
+
formListInstance.instance = form;
|
|
14
|
+
formListInstance.rule = ruleInstance;
|
|
15
|
+
formListInstance.sort = options.sort;
|
|
16
|
+
formListInstance.formItemInstance = formItemInstance;
|
|
17
|
+
formListInstance.parentDataField = parentName;
|
|
18
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
19
|
+
const unMount = form.registerFormList(options.name, formListInstance);
|
|
20
|
+
return ()=>unMount();
|
|
21
|
+
}, [
|
|
22
|
+
options.name,
|
|
23
|
+
formListInstance
|
|
24
|
+
]);
|
|
25
|
+
return {
|
|
26
|
+
ruleInstance,
|
|
27
|
+
formItemInstance,
|
|
28
|
+
formListInstance
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export { useRegisterFormList };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__useMultipleForm_js_ddedf30e__ from "../useMultipleForm.js";
|
|
3
|
+
const useRegisterForm = (form, name)=>{
|
|
4
|
+
const multipleForm = (0, __WEBPACK_EXTERNAL_MODULE__useMultipleForm_js_ddedf30e__.useMultipleFormInstance)();
|
|
5
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
6
|
+
let onMounted;
|
|
7
|
+
if (name) onMounted = multipleForm.ctor(name, form);
|
|
8
|
+
return ()=>{
|
|
9
|
+
onMounted?.();
|
|
10
|
+
};
|
|
11
|
+
}, [
|
|
12
|
+
name,
|
|
13
|
+
form
|
|
14
|
+
]);
|
|
15
|
+
return multipleForm;
|
|
16
|
+
};
|
|
17
|
+
export { useRegisterForm };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LayoutFormItemProps } from '../layout/layout.formItem';
|
|
2
|
+
export interface AttrsOptions {
|
|
3
|
+
/**列数据*/
|
|
4
|
+
colCount?: number;
|
|
5
|
+
/**规则校验失败错误提示位置*/
|
|
6
|
+
errorLayout?: LayoutFormItemProps['errorLayout'];
|
|
7
|
+
/**label显示模式*/
|
|
8
|
+
labelMode?: LayoutFormItemProps['labelMode'];
|
|
9
|
+
/**是否显示label后的冒号*/
|
|
10
|
+
showColon?: boolean;
|
|
11
|
+
/**表单项 className*/
|
|
12
|
+
formItemClassName?: string;
|
|
13
|
+
/**表单项 style*/
|
|
14
|
+
formItemStyle?: React.CSSProperties;
|
|
15
|
+
/**表单项 label className*/
|
|
16
|
+
formItemLabelClassName?: string;
|
|
17
|
+
/**表单项 label style*/
|
|
18
|
+
formItemLabelStyle?: React.CSSProperties;
|
|
19
|
+
/**输入框底部边框*/
|
|
20
|
+
inputBordered?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**公共属性 Context */
|
|
23
|
+
export declare const AttrsContext: import("react").Context<AttrsOptions>;
|
|
24
|
+
/**子项中获取公共属性*/
|
|
25
|
+
export declare const useAttrs: () => AttrsOptions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
const AttrsContext = (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)({
|
|
3
|
+
colCount: 4,
|
|
4
|
+
errorLayout: 'left-bottom',
|
|
5
|
+
labelMode: 'top',
|
|
6
|
+
showColon: true,
|
|
7
|
+
inputBordered: true
|
|
8
|
+
});
|
|
9
|
+
const useAttrs = ()=>(0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(AttrsContext);
|
|
10
|
+
export { AttrsContext, useAttrs };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormInstanceBase } from '@carefrees/form-utils';
|
|
2
|
+
/**表单实例 Context */
|
|
3
|
+
export declare const FormInstanceContext: import("react").Context<FormInstanceBase<any>>;
|
|
4
|
+
/**子项中获取表单实例*/
|
|
5
|
+
export declare function useFormInstance<T = any>(): FormInstanceBase<T>;
|
|
6
|
+
/**初始化表单实例*/
|
|
7
|
+
export declare function useForm<T = any>(form?: FormInstanceBase<T>): FormInstanceBase<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__ from "@carefrees/form-utils";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
const FormInstanceContext = (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)(new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.FormInstanceBase());
|
|
4
|
+
function useFormInstance() {
|
|
5
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(FormInstanceContext);
|
|
6
|
+
}
|
|
7
|
+
function useForm(form) {
|
|
8
|
+
const ref = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)();
|
|
9
|
+
if (!ref.current) if (form) ref.current = form;
|
|
10
|
+
else ref.current = new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.FormInstanceBase();
|
|
11
|
+
return ref.current;
|
|
12
|
+
}
|
|
13
|
+
export { FormInstanceContext, useForm, useFormInstance };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormItemInstanceBase } from '@carefrees/form-utils';
|
|
2
|
+
/**表单项实例 Context */
|
|
3
|
+
export declare const FormItemInstanceContext: import("react").Context<FormItemInstanceBase>;
|
|
4
|
+
/**子项中获取表单项实例*/
|
|
5
|
+
export declare const useFormItemInstance: () => FormItemInstanceBase;
|
|
6
|
+
/**s初始化 表单项实例*/
|
|
7
|
+
export declare const useFormItem: (formItem?: FormItemInstanceBase) => FormItemInstanceBase;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__ from "@carefrees/form-utils";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
const FormItemInstanceContext = (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)(new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.FormItemInstanceBase());
|
|
4
|
+
const useFormItemInstance = ()=>(0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(FormItemInstanceContext);
|
|
5
|
+
const useFormItem = (formItem)=>{
|
|
6
|
+
const ref = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)();
|
|
7
|
+
if (!ref.current) if (formItem) ref.current = formItem;
|
|
8
|
+
else ref.current = new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.FormItemInstanceBase();
|
|
9
|
+
return ref.current;
|
|
10
|
+
};
|
|
11
|
+
export { FormItemInstanceContext, useFormItem, useFormItemInstance };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const FormItemParentNameContext: import("react").Context<{
|
|
2
|
+
name: string;
|
|
3
|
+
sort: string;
|
|
4
|
+
}>;
|
|
5
|
+
export interface FormItemParentNamOptions {
|
|
6
|
+
/**字段*/
|
|
7
|
+
name: string;
|
|
8
|
+
/**排序*/
|
|
9
|
+
sort?: string;
|
|
10
|
+
/**是否拼接父级字段*/
|
|
11
|
+
isJoinParentField?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface FormItemParentNameProviderProps extends Omit<FormItemParentNamOptions, 'isJoinParentField'> {
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare const FormItemParentNameProvider: (props: FormItemParentNameProviderProps) => import("react").FunctionComponentElement<import("react").ProviderProps<{
|
|
17
|
+
name: string;
|
|
18
|
+
sort: string;
|
|
19
|
+
}>>;
|
|
20
|
+
/**表单项获取父级字段*/
|
|
21
|
+
export declare const useFormItemParentName: (options: FormItemParentNamOptions) => {
|
|
22
|
+
newName: string;
|
|
23
|
+
newSort: string;
|
|
24
|
+
parentItem: {
|
|
25
|
+
name: string;
|
|
26
|
+
sort: string;
|
|
27
|
+
};
|
|
28
|
+
parentName: string;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
+
const FormItemParentNameContext = (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)({
|
|
3
|
+
name: '',
|
|
4
|
+
sort: ''
|
|
5
|
+
});
|
|
6
|
+
const FormItemParentNameProvider = (props)=>{
|
|
7
|
+
const { name, sort, children } = props;
|
|
8
|
+
const value = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
9
|
+
name,
|
|
10
|
+
sort
|
|
11
|
+
}), [
|
|
12
|
+
name,
|
|
13
|
+
sort
|
|
14
|
+
]);
|
|
15
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_react__.createElement)(FormItemParentNameContext.Provider, {
|
|
16
|
+
value,
|
|
17
|
+
children
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const useFormItemParentName = (options)=>{
|
|
21
|
+
const { isJoinParentField = true, sort, name } = options;
|
|
22
|
+
const parentItem = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(FormItemParentNameContext);
|
|
23
|
+
const parentName = parentItem.name;
|
|
24
|
+
const parentSort = parentItem.sort;
|
|
25
|
+
const newName = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
26
|
+
if (parentName && isJoinParentField) {
|
|
27
|
+
if (/^\./.test(`${name}`)) ;
|
|
28
|
+
else if (name) return [
|
|
29
|
+
parentName,
|
|
30
|
+
'.',
|
|
31
|
+
name
|
|
32
|
+
].filter(Boolean).join('');
|
|
33
|
+
return [
|
|
34
|
+
parentName,
|
|
35
|
+
name
|
|
36
|
+
].filter(Boolean).join('');
|
|
37
|
+
}
|
|
38
|
+
return [
|
|
39
|
+
name
|
|
40
|
+
].filter(Boolean).join('');
|
|
41
|
+
}, [
|
|
42
|
+
isJoinParentField,
|
|
43
|
+
name,
|
|
44
|
+
parentName
|
|
45
|
+
]);
|
|
46
|
+
const newSort = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
|
|
47
|
+
isJoinParentField ? parentSort : '',
|
|
48
|
+
sort
|
|
49
|
+
].filter(Boolean).join('-'), [
|
|
50
|
+
isJoinParentField,
|
|
51
|
+
parentSort,
|
|
52
|
+
sort
|
|
53
|
+
]);
|
|
54
|
+
return {
|
|
55
|
+
newName,
|
|
56
|
+
newSort,
|
|
57
|
+
parentItem,
|
|
58
|
+
parentName: parentName
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export { FormItemParentNameContext, FormItemParentNameProvider, useFormItemParentName };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormListInstanceBase } from '@carefrees/form-utils';
|
|
2
|
+
/**表单List实例 Context */
|
|
3
|
+
export declare const FormListInstanceContext: import("react").Context<FormListInstanceBase>;
|
|
4
|
+
/**子项中获取表单List实例*/
|
|
5
|
+
export declare const useFormListInstance: () => FormListInstanceBase;
|
|
6
|
+
/**初始化 表单List实例*/
|
|
7
|
+
export declare const useFormList: (formList?: FormListInstanceBase) => FormListInstanceBase;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__ from "@carefrees/form-utils";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
+
const FormListInstanceContext = (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)(new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.FormListInstanceBase());
|
|
4
|
+
const useFormListInstance = ()=>(0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(FormListInstanceContext);
|
|
5
|
+
const useFormList = (formList)=>{
|
|
6
|
+
const ref = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)();
|
|
7
|
+
if (!ref.current) if (formList) ref.current = formList;
|
|
8
|
+
else ref.current = new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.FormListInstanceBase();
|
|
9
|
+
return ref.current;
|
|
10
|
+
};
|
|
11
|
+
export { FormListInstanceContext, useFormList, useFormListInstance };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useHtmlFor: (suffix: string) => string;
|