@carefrees/form-utils-react-taro 0.0.4 → 0.0.5
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/esm/formItem/index.d.ts +3 -4
- package/esm/formItem/index.js +4 -5
- package/esm/formList/index.d.ts +1 -1
- package/esm/formList/index.js +5 -8
- package/esm/hooks/attr/attr.FormItem.d.ts +1 -1
- package/esm/hooks/attr/attr.FormItem.js +3 -4
- package/esm/index.d.ts +1 -12
- package/esm/index.js +5 -17
- package/esm/layout/index.d.ts +1 -1
- package/esm/layout/index.js +3 -3
- package/esm/layout/layout.formItem.js +2 -2
- package/lib/formItem/index.d.ts +3 -4
- package/lib/formItem/index.js +4 -5
- package/lib/formList/index.d.ts +1 -1
- package/lib/formList/index.js +5 -8
- package/lib/hooks/attr/attr.FormItem.d.ts +1 -1
- package/lib/hooks/attr/attr.FormItem.js +3 -4
- package/lib/index.d.ts +1 -12
- package/lib/index.js +23 -155
- package/lib/layout/index.d.ts +1 -1
- package/lib/layout/index.js +3 -3
- package/lib/layout/layout.formItem.js +2 -2
- package/package.json +4 -3
- package/src/formItem/index.tsx +3 -4
- package/src/formList/index.tsx +7 -4
- package/src/hooks/attr/attr.FormItem.tsx +1 -2
- package/src/index.tsx +2 -14
- package/src/layout/index.tsx +2 -1
- package/src/layout/layout.formItem.tsx +1 -1
- package/esm/hooks/register/register.FormHideItem.d.ts +0 -9
- package/esm/hooks/register/register.FormHideItem.js +0 -31
- package/esm/hooks/register/register.FormItem.d.ts +0 -23
- package/esm/hooks/register/register.FormItem.js +0 -42
- package/esm/hooks/register/register.FormList.d.ts +0 -9
- package/esm/hooks/register/register.FormList.js +0 -31
- package/esm/hooks/register/register.form.d.ts +0 -3
- package/esm/hooks/register/register.form.js +0 -17
- package/esm/hooks/useAttrs.d.ts +0 -25
- package/esm/hooks/useAttrs.js +0 -10
- package/esm/hooks/useForm.d.ts +0 -7
- package/esm/hooks/useForm.js +0 -13
- package/esm/hooks/useFormItem.d.ts +0 -7
- package/esm/hooks/useFormItem.js +0 -11
- package/esm/hooks/useFormItemParentName.d.ts +0 -30
- package/esm/hooks/useFormItemParentName.js +0 -61
- package/esm/hooks/useFormList.d.ts +0 -7
- package/esm/hooks/useFormList.js +0 -11
- package/esm/hooks/useHtmlFor.d.ts +0 -1
- package/esm/hooks/useHtmlFor.js +0 -10
- package/esm/hooks/useMultipleForm.d.ts +0 -13
- package/esm/hooks/useMultipleForm.js +0 -19
- package/esm/hooks/useUpdate.d.ts +0 -2
- package/esm/hooks/useUpdate.js +0 -10
- package/esm/hooks/useWatch.d.ts +0 -19
- package/esm/hooks/useWatch.js +0 -41
- package/lib/hooks/register/register.FormHideItem.d.ts +0 -9
- package/lib/hooks/register/register.FormHideItem.js +0 -65
- package/lib/hooks/register/register.FormItem.d.ts +0 -23
- package/lib/hooks/register/register.FormItem.js +0 -76
- package/lib/hooks/register/register.FormList.d.ts +0 -9
- package/lib/hooks/register/register.FormList.js +0 -65
- package/lib/hooks/register/register.form.d.ts +0 -3
- package/lib/hooks/register/register.form.js +0 -51
- package/lib/hooks/useAttrs.d.ts +0 -25
- package/lib/hooks/useAttrs.js +0 -47
- package/lib/hooks/useForm.d.ts +0 -7
- package/lib/hooks/useForm.js +0 -53
- package/lib/hooks/useFormItem.d.ts +0 -7
- package/lib/hooks/useFormItem.js +0 -51
- package/lib/hooks/useFormItemParentName.d.ts +0 -30
- package/lib/hooks/useFormItemParentName.js +0 -101
- package/lib/hooks/useFormList.d.ts +0 -7
- package/lib/hooks/useFormList.js +0 -51
- package/lib/hooks/useHtmlFor.d.ts +0 -1
- package/lib/hooks/useHtmlFor.js +0 -44
- package/lib/hooks/useMultipleForm.d.ts +0 -13
- package/lib/hooks/useMultipleForm.js +0 -62
- package/lib/hooks/useUpdate.d.ts +0 -2
- package/lib/hooks/useUpdate.js +0 -44
- package/lib/hooks/useWatch.d.ts +0 -19
- package/lib/hooks/useWatch.js +0 -78
- package/src/hooks/register/register.FormHideItem.ts +0 -29
- package/src/hooks/register/register.FormItem.ts +0 -52
- package/src/hooks/register/register.FormList.ts +0 -31
- package/src/hooks/register/register.form.ts +0 -18
- package/src/hooks/useAttrs.ts +0 -35
- package/src/hooks/useForm.ts +0 -23
- package/src/hooks/useFormItem.ts +0 -21
- package/src/hooks/useFormItemParentName.ts +0 -49
- package/src/hooks/useFormList.ts +0 -21
- package/src/hooks/useHtmlFor.ts +0 -9
- package/src/hooks/useMultipleForm.ts +0 -36
- package/src/hooks/useUpdate.ts +0 -12
- package/src/hooks/useWatch.ts +0 -61
package/esm/hooks/useForm.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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 };
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
package/esm/hooks/useFormItem.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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 };
|
|
@@ -1,30 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,61 +0,0 @@
|
|
|
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 };
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
package/esm/hooks/useFormList.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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 };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useHtmlFor: (suffix: string) => string;
|
package/esm/hooks/useHtmlFor.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
-
let localId = 0;
|
|
3
|
-
const useHtmlFor = (suffix)=>{
|
|
4
|
-
const count = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(localId++);
|
|
5
|
-
return (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>`carefree-form-item_${count.current.toString(32)}_${suffix}`, [
|
|
6
|
-
count.current,
|
|
7
|
-
suffix
|
|
8
|
-
]);
|
|
9
|
-
};
|
|
10
|
-
export { useHtmlFor };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MultipleInstanceBase } from '@carefrees/form-utils';
|
|
2
|
-
/**多表单收集 Context */
|
|
3
|
-
export declare const MultipleFormInstanceContext: import("react").Context<MultipleInstanceBase>;
|
|
4
|
-
/**子项中获取 多表单收集 实例*/
|
|
5
|
-
export declare const useMultipleFormInstance: () => MultipleInstanceBase;
|
|
6
|
-
/**初始化 多表单收集 实例*/
|
|
7
|
-
export declare const useMultipleForm: (multipleForm?: MultipleInstanceBase) => MultipleInstanceBase;
|
|
8
|
-
export interface MultipleFormProviderProps {
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
multipleForm?: MultipleInstanceBase;
|
|
11
|
-
}
|
|
12
|
-
/**多表单收集 Provider */
|
|
13
|
-
export declare const MultipleFormProvider: (props: MultipleFormProviderProps) => import("react").FunctionComponentElement<import("react").ProviderProps<MultipleInstanceBase>>;
|
|
@@ -1,19 +0,0 @@
|
|
|
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 MultipleFormInstanceContext = (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)(new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.MultipleInstanceBase());
|
|
4
|
-
const useMultipleFormInstance = ()=>(0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(MultipleFormInstanceContext);
|
|
5
|
-
const useMultipleForm = (multipleForm)=>{
|
|
6
|
-
const ref = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)();
|
|
7
|
-
if (!ref.current) if (multipleForm) ref.current = multipleForm;
|
|
8
|
-
else ref.current = new __WEBPACK_EXTERNAL_MODULE__carefrees_form_utils_f42d2666__.MultipleInstanceBase();
|
|
9
|
-
return ref.current;
|
|
10
|
-
};
|
|
11
|
-
const MultipleFormProvider = (props)=>{
|
|
12
|
-
const { children, multipleForm } = props;
|
|
13
|
-
const multipleFormInstance = useMultipleForm(multipleForm);
|
|
14
|
-
return (0, __WEBPACK_EXTERNAL_MODULE_react__.createElement)(MultipleFormInstanceContext.Provider, {
|
|
15
|
-
value: multipleFormInstance,
|
|
16
|
-
children
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
export { MultipleFormInstanceContext, MultipleFormProvider, useMultipleForm, useMultipleFormInstance };
|
package/esm/hooks/useUpdate.d.ts
DELETED
package/esm/hooks/useUpdate.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
-
const useUpdate = ()=>{
|
|
3
|
-
const [, _update] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)({});
|
|
4
|
-
const refUpdate = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(()=>void 0);
|
|
5
|
-
refUpdate.current = ()=>{
|
|
6
|
-
_update({});
|
|
7
|
-
};
|
|
8
|
-
return refUpdate;
|
|
9
|
-
};
|
|
10
|
-
export { useUpdate };
|
package/esm/hooks/useWatch.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FormInstanceBase } from '@carefrees/form-utils';
|
|
2
|
-
export declare class WatchInstanceBase {
|
|
3
|
-
/**监听字段*/
|
|
4
|
-
name: string;
|
|
5
|
-
/**表单实例*/
|
|
6
|
-
form: FormInstanceBase;
|
|
7
|
-
/**老值*/
|
|
8
|
-
oldValue: any;
|
|
9
|
-
/**更新值*/
|
|
10
|
-
dispatch: (value: any) => void;
|
|
11
|
-
/**回调*/
|
|
12
|
-
callBack?: (value: any, form: FormInstanceBase) => void;
|
|
13
|
-
/**更新*/
|
|
14
|
-
updated: () => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 字段监听
|
|
18
|
-
*/
|
|
19
|
-
export declare const useWatch: (name: string, form: FormInstanceBase, callBack?: (value: any, form: FormInstanceBase) => void) => [any, FormInstanceBase, WatchInstanceBase];
|
package/esm/hooks/useWatch.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE__useForm_js_e31b00cd__ from "./useForm.js";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__useFormItem_js_ee04de55__ from "./useFormItem.js";
|
|
4
|
-
class WatchInstanceBase {
|
|
5
|
-
name;
|
|
6
|
-
form;
|
|
7
|
-
oldValue;
|
|
8
|
-
dispatch;
|
|
9
|
-
callBack;
|
|
10
|
-
updated = ()=>{
|
|
11
|
-
const newValue = this.form.getFieldValue(this.name);
|
|
12
|
-
if (this.oldValue === newValue) return;
|
|
13
|
-
if (this.callBack) this.callBack(newValue, this.form);
|
|
14
|
-
else this.dispatch(newValue);
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const useWatch = (name, form, callBack)=>{
|
|
18
|
-
const formInstance = form || (0, __WEBPACK_EXTERNAL_MODULE__useForm_js_e31b00cd__.useFormInstance)();
|
|
19
|
-
const [oldValue, setValue] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(formInstance.getFieldValue(name));
|
|
20
|
-
const watch = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(new WatchInstanceBase()).current;
|
|
21
|
-
watch.name = name;
|
|
22
|
-
watch.oldValue = oldValue;
|
|
23
|
-
watch.dispatch = setValue;
|
|
24
|
-
watch.callBack = callBack;
|
|
25
|
-
watch.form = formInstance;
|
|
26
|
-
const formItemInstance = (0, __WEBPACK_EXTERNAL_MODULE__useFormItem_js_ee04de55__.useFormItem)();
|
|
27
|
-
(0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>formItemInstance.ctor(name), []);
|
|
28
|
-
formItemInstance.instance = formInstance;
|
|
29
|
-
formItemInstance.isWatch = true;
|
|
30
|
-
formItemInstance.updated = watch.updated;
|
|
31
|
-
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
32
|
-
const unMount = formInstance.registerFormItem(formItemInstance);
|
|
33
|
-
return ()=>unMount();
|
|
34
|
-
}, []);
|
|
35
|
-
return [
|
|
36
|
-
oldValue,
|
|
37
|
-
formInstance,
|
|
38
|
-
watch
|
|
39
|
-
];
|
|
40
|
-
};
|
|
41
|
-
export { WatchInstanceBase, useWatch };
|
|
@@ -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: any;
|
|
8
|
-
};
|
|
9
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
useRegisterFormHideItem: ()=>useRegisterFormHideItem
|
|
28
|
-
});
|
|
29
|
-
const external_react_namespaceObject = require("react");
|
|
30
|
-
const form_utils_namespaceObject = require("@carefrees/form-utils");
|
|
31
|
-
const external_useFormItemParentName_js_namespaceObject = require("../useFormItemParentName.js");
|
|
32
|
-
const external_useForm_js_namespaceObject = require("../useForm.js");
|
|
33
|
-
const external_useUpdate_js_namespaceObject = require("../useUpdate.js");
|
|
34
|
-
const useRegisterFormHideItem = (options)=>{
|
|
35
|
-
const { name, sort, isJoinParentField = true } = options;
|
|
36
|
-
const form = (0, external_useForm_js_namespaceObject.useFormInstance)();
|
|
37
|
-
const _update = (0, external_useUpdate_js_namespaceObject.useUpdate)();
|
|
38
|
-
const { newName, newSort } = (0, external_useFormItemParentName_js_namespaceObject.useFormItemParentName)({
|
|
39
|
-
name,
|
|
40
|
-
sort,
|
|
41
|
-
isJoinParentField
|
|
42
|
-
});
|
|
43
|
-
const hideItemInstance = (0, external_react_namespaceObject.useRef)(new form_utils_namespaceObject.FormHideItemInstanceBase().ctor(newName)).current;
|
|
44
|
-
const isHide = form.getFieldHideValue(newName);
|
|
45
|
-
hideItemInstance.instance = form;
|
|
46
|
-
hideItemInstance.updated = _update.current;
|
|
47
|
-
hideItemInstance.sort = newSort;
|
|
48
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
49
|
-
const unMount = form.registerFormHideItem(hideItemInstance);
|
|
50
|
-
return ()=>unMount();
|
|
51
|
-
}, [
|
|
52
|
-
newName
|
|
53
|
-
]);
|
|
54
|
-
return {
|
|
55
|
-
form,
|
|
56
|
-
isHide
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
exports.useRegisterFormHideItem = __webpack_exports__.useRegisterFormHideItem;
|
|
60
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
61
|
-
"useRegisterFormHideItem"
|
|
62
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
63
|
-
Object.defineProperty(exports, '__esModule', {
|
|
64
|
-
value: true
|
|
65
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
useRegisterFormItem: ()=>useRegisterFormItem
|
|
28
|
-
});
|
|
29
|
-
const external_react_namespaceObject = require("react");
|
|
30
|
-
const form_utils_namespaceObject = require("@carefrees/form-utils");
|
|
31
|
-
const external_useUpdate_js_namespaceObject = require("../useUpdate.js");
|
|
32
|
-
const external_useForm_js_namespaceObject = require("../useForm.js");
|
|
33
|
-
const external_useFormItem_js_namespaceObject = require("../useFormItem.js");
|
|
34
|
-
const external_useFormItemParentName_js_namespaceObject = require("../useFormItemParentName.js");
|
|
35
|
-
const useRegisterFormItem = (options)=>{
|
|
36
|
-
const { name, rules, sort, isJoinParentField = true } = options;
|
|
37
|
-
const form = (0, external_useForm_js_namespaceObject.useFormInstance)();
|
|
38
|
-
const { newName, newSort, parentName } = (0, external_useFormItemParentName_js_namespaceObject.useFormItemParentName)({
|
|
39
|
-
name,
|
|
40
|
-
sort,
|
|
41
|
-
isJoinParentField
|
|
42
|
-
});
|
|
43
|
-
const ruleInstance = (0, external_react_namespaceObject.useRef)(new form_utils_namespaceObject.RuleInstanceBase()).current;
|
|
44
|
-
(0, external_react_namespaceObject.useMemo)(()=>ruleInstance.ctor(newName, rules), [
|
|
45
|
-
rules,
|
|
46
|
-
newName
|
|
47
|
-
]);
|
|
48
|
-
ruleInstance.instance = form;
|
|
49
|
-
ruleInstance.sort = newSort;
|
|
50
|
-
const formItemInstance = (0, external_useFormItem_js_namespaceObject.useFormItem)();
|
|
51
|
-
(0, external_react_namespaceObject.useMemo)(()=>formItemInstance.ctor(newName, ruleInstance), []);
|
|
52
|
-
formItemInstance.instance = form;
|
|
53
|
-
formItemInstance.sort = newSort;
|
|
54
|
-
formItemInstance.parentDataField = parentName;
|
|
55
|
-
const _updated = (0, external_useUpdate_js_namespaceObject.useUpdate)();
|
|
56
|
-
formItemInstance.updated = _updated.current;
|
|
57
|
-
ruleInstance.updated = _updated.current;
|
|
58
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
59
|
-
const unMount = form.registerFormItem(formItemInstance);
|
|
60
|
-
return ()=>unMount();
|
|
61
|
-
}, []);
|
|
62
|
-
return {
|
|
63
|
-
ruleInstance,
|
|
64
|
-
formItemInstance,
|
|
65
|
-
form,
|
|
66
|
-
parentName,
|
|
67
|
-
newName
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
exports.useRegisterFormItem = __webpack_exports__.useRegisterFormItem;
|
|
71
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
72
|
-
"useRegisterFormItem"
|
|
73
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
74
|
-
Object.defineProperty(exports, '__esModule', {
|
|
75
|
-
value: true
|
|
76
|
-
});
|
|
@@ -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("@carefrees/form-utils").RuleInstanceBase;
|
|
7
|
-
formItemInstance: import("@carefrees/form-utils").FormItemInstanceBase;
|
|
8
|
-
formListInstance: import("@carefrees/form-utils").FormListInstanceBase;
|
|
9
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
useRegisterFormList: ()=>useRegisterFormList
|
|
28
|
-
});
|
|
29
|
-
const external_react_namespaceObject = require("react");
|
|
30
|
-
const external_register_FormItem_js_namespaceObject = require("./register.FormItem.js");
|
|
31
|
-
const external_useFormList_js_namespaceObject = require("../useFormList.js");
|
|
32
|
-
const useRegisterFormList = (options)=>{
|
|
33
|
-
const { ...rest } = options;
|
|
34
|
-
const { ruleInstance, formItemInstance, form, newName, parentName } = (0, external_register_FormItem_js_namespaceObject.useRegisterFormItem)({
|
|
35
|
-
...rest
|
|
36
|
-
});
|
|
37
|
-
const formListInstance = (0, external_useFormList_js_namespaceObject.useFormList)();
|
|
38
|
-
(0, external_react_namespaceObject.useMemo)(()=>formListInstance.ctor(newName), [
|
|
39
|
-
newName
|
|
40
|
-
]);
|
|
41
|
-
formListInstance.instance = form;
|
|
42
|
-
formListInstance.rule = ruleInstance;
|
|
43
|
-
formListInstance.sort = options.sort;
|
|
44
|
-
formListInstance.formItemInstance = formItemInstance;
|
|
45
|
-
formListInstance.parentDataField = parentName;
|
|
46
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
47
|
-
const unMount = form.registerFormList(options.name, formListInstance);
|
|
48
|
-
return ()=>unMount();
|
|
49
|
-
}, [
|
|
50
|
-
options.name,
|
|
51
|
-
formListInstance
|
|
52
|
-
]);
|
|
53
|
-
return {
|
|
54
|
-
ruleInstance,
|
|
55
|
-
formItemInstance,
|
|
56
|
-
formListInstance
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
exports.useRegisterFormList = __webpack_exports__.useRegisterFormList;
|
|
60
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
61
|
-
"useRegisterFormList"
|
|
62
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
63
|
-
Object.defineProperty(exports, '__esModule', {
|
|
64
|
-
value: true
|
|
65
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
useRegisterForm: ()=>useRegisterForm
|
|
28
|
-
});
|
|
29
|
-
const external_react_namespaceObject = require("react");
|
|
30
|
-
const external_useMultipleForm_js_namespaceObject = require("../useMultipleForm.js");
|
|
31
|
-
const useRegisterForm = (form, name)=>{
|
|
32
|
-
const multipleForm = (0, external_useMultipleForm_js_namespaceObject.useMultipleFormInstance)();
|
|
33
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
34
|
-
let onMounted;
|
|
35
|
-
if (name) onMounted = multipleForm.ctor(name, form);
|
|
36
|
-
return ()=>{
|
|
37
|
-
onMounted?.();
|
|
38
|
-
};
|
|
39
|
-
}, [
|
|
40
|
-
name,
|
|
41
|
-
form
|
|
42
|
-
]);
|
|
43
|
-
return multipleForm;
|
|
44
|
-
};
|
|
45
|
-
exports.useRegisterForm = __webpack_exports__.useRegisterForm;
|
|
46
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
47
|
-
"useRegisterForm"
|
|
48
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
49
|
-
Object.defineProperty(exports, '__esModule', {
|
|
50
|
-
value: true
|
|
51
|
-
});
|
package/lib/hooks/useAttrs.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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;
|
package/lib/hooks/useAttrs.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
useAttrs: ()=>useAttrs,
|
|
28
|
-
AttrsContext: ()=>AttrsContext
|
|
29
|
-
});
|
|
30
|
-
const external_react_namespaceObject = require("react");
|
|
31
|
-
const AttrsContext = (0, external_react_namespaceObject.createContext)({
|
|
32
|
-
colCount: 4,
|
|
33
|
-
errorLayout: 'left-bottom',
|
|
34
|
-
labelMode: 'top',
|
|
35
|
-
showColon: true,
|
|
36
|
-
inputBordered: true
|
|
37
|
-
});
|
|
38
|
-
const useAttrs = ()=>(0, external_react_namespaceObject.useContext)(AttrsContext);
|
|
39
|
-
exports.AttrsContext = __webpack_exports__.AttrsContext;
|
|
40
|
-
exports.useAttrs = __webpack_exports__.useAttrs;
|
|
41
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
42
|
-
"AttrsContext",
|
|
43
|
-
"useAttrs"
|
|
44
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
45
|
-
Object.defineProperty(exports, '__esModule', {
|
|
46
|
-
value: true
|
|
47
|
-
});
|