@carefrees/form-utils-react-native 0.0.7 → 0.0.9
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 +636 -0
- package/esm/formItem/index.d.ts +10 -0
- package/esm/formItem/index.js +67 -0
- package/esm/formList/index.d.ts +27 -0
- package/esm/formList/index.js +37 -0
- package/esm/hooks/attr/attr.FormItem.d.ts +48 -0
- package/esm/hooks/attr/attr.FormItem.js +60 -0
- package/esm/hooks/useAttrs.d.ts +25 -0
- package/esm/hooks/useAttrs.js +10 -0
- package/esm/index.d.ts +34 -0
- package/esm/index.js +42 -0
- package/esm/layout/index.d.ts +30 -0
- package/esm/layout/index.js +98 -0
- package/esm/layout/layout.formItem.d.ts +38 -0
- package/esm/layout/layout.formItem.js +152 -0
- package/esm/styles/index.d.ts +201 -0
- package/esm/styles/index.js +203 -0
- package/package.json +8 -8
- package/src/formItem/index.tsx +2 -16
- package/src/hooks/useAttrs.ts +0 -6
- package/src/index.tsx +1 -5
- package/src/layout/index.tsx +1 -24
- package/src/layout/layout.formItem.tsx +0 -12
package/src/index.tsx
CHANGED
|
@@ -15,8 +15,6 @@ export interface FormProps<T = any> extends FormLayoutProps {
|
|
|
15
15
|
children?: React.ReactNode;
|
|
16
16
|
form?: FormInstanceBase;
|
|
17
17
|
style?: ViewProps['style'];
|
|
18
|
-
className?: string;
|
|
19
|
-
layoutClassName?: string;
|
|
20
18
|
layoutStyle?: ViewProps['style'];
|
|
21
19
|
/**表单数据*/
|
|
22
20
|
formData?: any;
|
|
@@ -41,7 +39,6 @@ export function Form<T = any>(props: FormProps<T>) {
|
|
|
41
39
|
children,
|
|
42
40
|
form,
|
|
43
41
|
style,
|
|
44
|
-
className,
|
|
45
42
|
formData,
|
|
46
43
|
hideData,
|
|
47
44
|
hideRuleData,
|
|
@@ -51,7 +48,6 @@ export function Form<T = any>(props: FormProps<T>) {
|
|
|
51
48
|
onFinishFailed,
|
|
52
49
|
onValuesChange,
|
|
53
50
|
layoutStyle,
|
|
54
|
-
layoutClassName,
|
|
55
51
|
...rest
|
|
56
52
|
} = props;
|
|
57
53
|
const formInstance = useForm(form);
|
|
@@ -71,7 +67,7 @@ export function Form<T = any>(props: FormProps<T>) {
|
|
|
71
67
|
return (
|
|
72
68
|
<FormInstanceContext.Provider value={formInstance}>
|
|
73
69
|
<View style={style}>
|
|
74
|
-
<FormLayout {...rest}
|
|
70
|
+
<FormLayout {...rest} style={layoutStyle}>
|
|
75
71
|
{children}
|
|
76
72
|
</FormLayout>
|
|
77
73
|
</View>
|
package/src/layout/index.tsx
CHANGED
|
@@ -12,11 +12,6 @@ export interface FormLayoutProps extends AttrsOptions {
|
|
|
12
12
|
children?: React.ReactNode;
|
|
13
13
|
/**是否占据整行*/
|
|
14
14
|
isAllColSpan?: boolean;
|
|
15
|
-
className?: string;
|
|
16
|
-
/**头部ClassName*/
|
|
17
|
-
headerClassName?: string;
|
|
18
|
-
/**内容ClassName*/
|
|
19
|
-
bodyClassName?: string;
|
|
20
15
|
style?: ViewProps['style'];
|
|
21
16
|
/**头部样式*/
|
|
22
17
|
headerStyle?: ViewProps['style'];
|
|
@@ -39,9 +34,7 @@ export const FormLayout = memo((props: FormLayoutProps) => {
|
|
|
39
34
|
errorLayout: p_errorLayout = 'left-bottom',
|
|
40
35
|
labelMode: p_labelMode = 'left',
|
|
41
36
|
showColon: p_showColon = true,
|
|
42
|
-
formItemClassName: p_formItemClassName,
|
|
43
37
|
formItemStyle: p_formItemStyle,
|
|
44
|
-
formItemLabelClassName: p_formItemLabelClassName,
|
|
45
38
|
formItemLabelStyle: p_formItemLabelStyle,
|
|
46
39
|
} = useAttrs();
|
|
47
40
|
const {
|
|
@@ -50,18 +43,13 @@ export const FormLayout = memo((props: FormLayoutProps) => {
|
|
|
50
43
|
extra,
|
|
51
44
|
children,
|
|
52
45
|
isAllColSpan,
|
|
53
|
-
className,
|
|
54
|
-
headerClassName,
|
|
55
|
-
bodyClassName,
|
|
56
46
|
style,
|
|
57
47
|
headerStyle,
|
|
58
48
|
bodyStyle,
|
|
59
49
|
errorLayout = p_errorLayout,
|
|
60
50
|
labelMode = p_labelMode,
|
|
61
51
|
showColon = p_showColon,
|
|
62
|
-
formItemClassName = p_formItemClassName,
|
|
63
52
|
formItemStyle = p_formItemStyle,
|
|
64
|
-
formItemLabelClassName = p_formItemLabelClassName,
|
|
65
53
|
formItemLabelStyle = p_formItemLabelStyle,
|
|
66
54
|
bordered = false,
|
|
67
55
|
gap,
|
|
@@ -75,21 +63,10 @@ export const FormLayout = memo((props: FormLayoutProps) => {
|
|
|
75
63
|
errorLayout,
|
|
76
64
|
labelMode,
|
|
77
65
|
showColon,
|
|
78
|
-
formItemClassName,
|
|
79
66
|
formItemStyle,
|
|
80
|
-
formItemLabelClassName,
|
|
81
67
|
formItemLabelStyle,
|
|
82
68
|
};
|
|
83
|
-
}, [
|
|
84
|
-
colCount,
|
|
85
|
-
errorLayout,
|
|
86
|
-
labelMode,
|
|
87
|
-
showColon,
|
|
88
|
-
formItemClassName,
|
|
89
|
-
formItemStyle,
|
|
90
|
-
formItemLabelClassName,
|
|
91
|
-
formItemLabelStyle,
|
|
92
|
-
]);
|
|
69
|
+
}, [colCount, errorLayout, labelMode, showColon, formItemStyle, formItemLabelStyle]);
|
|
93
70
|
|
|
94
71
|
const styleBase = useMemo(() => {
|
|
95
72
|
const css: ViewProps['style'] = {};
|
|
@@ -26,12 +26,6 @@ export interface LayoutFormItemProps {
|
|
|
26
26
|
* @default 1
|
|
27
27
|
*/
|
|
28
28
|
colSpan?: number;
|
|
29
|
-
/**
|
|
30
|
-
* 表单项占据行数
|
|
31
|
-
* @default 1
|
|
32
|
-
*/
|
|
33
|
-
rowSpan?: number;
|
|
34
|
-
|
|
35
29
|
htmlFor?: string;
|
|
36
30
|
/**规则验证结果*/
|
|
37
31
|
validateResult?: {
|
|
@@ -40,9 +34,7 @@ export interface LayoutFormItemProps {
|
|
|
40
34
|
};
|
|
41
35
|
// 样式部分
|
|
42
36
|
style?: ViewProps['style'];
|
|
43
|
-
className?: string;
|
|
44
37
|
labelStyle?: ViewProps['style'];
|
|
45
|
-
labelClassName?: string;
|
|
46
38
|
/**底部边框*/
|
|
47
39
|
inputBordered?: boolean;
|
|
48
40
|
}
|
|
@@ -50,8 +42,6 @@ export interface LayoutFormItemProps {
|
|
|
50
42
|
/**布局组件 表单项*/
|
|
51
43
|
export const LayoutFormItem = memo((props: LayoutFormItemProps) => {
|
|
52
44
|
const {
|
|
53
|
-
formItemClassName,
|
|
54
|
-
formItemLabelClassName,
|
|
55
45
|
formItemLabelStyle,
|
|
56
46
|
formItemStyle,
|
|
57
47
|
labelMode: p_labelMode = 'top',
|
|
@@ -75,8 +65,6 @@ export const LayoutFormItem = memo((props: LayoutFormItemProps) => {
|
|
|
75
65
|
required,
|
|
76
66
|
errorLayout = p_errorLayout,
|
|
77
67
|
style,
|
|
78
|
-
className,
|
|
79
|
-
labelClassName,
|
|
80
68
|
labelStyle,
|
|
81
69
|
inputBordered = p_inputBordered,
|
|
82
70
|
} = props;
|