@carefrees/form-utils-react-native 0.0.7 → 0.0.8
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 +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 +27 -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 -4
- package/src/index.tsx +1 -5
- package/src/layout/index.tsx +1 -24
- package/src/layout/layout.formItem.tsx +0 -12
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__ from "react-native";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useAttrs_js_86d21a28__ from "../hooks/useAttrs.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__ from "../styles/index.js";
|
|
6
|
+
const LayoutFormItem = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)((props)=>{
|
|
7
|
+
const { formItemLabelStyle, formItemStyle, labelMode: p_labelMode = 'top', errorLayout: p_errorLayout = 'left-bottom', showColon: p_showColon = true, colCount = 1, inputBordered: p_inputBordered = true } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_useAttrs_js_86d21a28__.useAttrs)();
|
|
8
|
+
const { children, labelMode = p_labelMode, onlyRuleStyle, label, helpText, extra, showColon = p_showColon, colSpan = 1, validateResult, htmlFor, required, errorLayout = p_errorLayout, style, labelStyle, inputBordered = p_inputBordered } = props;
|
|
9
|
+
const tip = validateResult?.tip;
|
|
10
|
+
const isInvalid = !!validateResult?.isInvalid;
|
|
11
|
+
const _errorLayout = 'between' === labelMode ? 'right-bottom' : errorLayout;
|
|
12
|
+
const _isLabel = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>label && 'hide' !== labelMode, [
|
|
13
|
+
label,
|
|
14
|
+
labelMode
|
|
15
|
+
]);
|
|
16
|
+
const _isShowColon = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>showColon && ('left' === labelMode || 'between' === labelMode), [
|
|
17
|
+
showColon,
|
|
18
|
+
labelMode
|
|
19
|
+
]);
|
|
20
|
+
const widthStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
|
|
21
|
+
if (colCount >= colSpan) return {
|
|
22
|
+
width: `${100 / colCount * colSpan}%`
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
width: "100%"
|
|
26
|
+
};
|
|
27
|
+
}, [
|
|
28
|
+
colSpan,
|
|
29
|
+
colCount
|
|
30
|
+
]);
|
|
31
|
+
const warpStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
|
|
32
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item"],
|
|
33
|
+
onlyRuleStyle && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item.only-rule-style"],
|
|
34
|
+
widthStyles,
|
|
35
|
+
formItemStyle,
|
|
36
|
+
style
|
|
37
|
+
].filter(Boolean), [
|
|
38
|
+
style,
|
|
39
|
+
widthStyles,
|
|
40
|
+
onlyRuleStyle,
|
|
41
|
+
formItemStyle
|
|
42
|
+
]);
|
|
43
|
+
const containerStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
|
|
44
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-container"],
|
|
45
|
+
'left' === labelMode && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-container.left"],
|
|
46
|
+
'between' === labelMode && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-container.between"]
|
|
47
|
+
].filter(Boolean), [
|
|
48
|
+
labelMode
|
|
49
|
+
]);
|
|
50
|
+
const labelWarpStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
|
|
51
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-label-warp"],
|
|
52
|
+
'left' === labelMode && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-label-warp.left"],
|
|
53
|
+
('left' === labelMode || 'between' == labelMode) && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-label-warp.minHeight"],
|
|
54
|
+
formItemLabelStyle,
|
|
55
|
+
labelStyle
|
|
56
|
+
].filter(Boolean), [
|
|
57
|
+
labelMode,
|
|
58
|
+
labelStyle,
|
|
59
|
+
formItemLabelStyle
|
|
60
|
+
]);
|
|
61
|
+
const bodyStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
|
|
62
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-body"],
|
|
63
|
+
'between' === labelMode && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-body-com.between"]
|
|
64
|
+
].filter(Boolean), [
|
|
65
|
+
labelMode
|
|
66
|
+
]);
|
|
67
|
+
const bodyInputStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
|
|
68
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-body-input"],
|
|
69
|
+
inputBordered && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-body-input.input-bordered"],
|
|
70
|
+
'between' === labelMode && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-body-com.between"]
|
|
71
|
+
].filter(Boolean), [
|
|
72
|
+
labelMode,
|
|
73
|
+
inputBordered
|
|
74
|
+
]);
|
|
75
|
+
const errorStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
|
|
76
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-body-error"],
|
|
77
|
+
_errorLayout && __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase[`carefrees-form-item-body-error.${_errorLayout}`]
|
|
78
|
+
].filter(Boolean), [
|
|
79
|
+
_errorLayout
|
|
80
|
+
]);
|
|
81
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
82
|
+
style: warpStyles,
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
85
|
+
style: containerStyles,
|
|
86
|
+
children: [
|
|
87
|
+
_isLabel ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
88
|
+
style: labelWarpStyles,
|
|
89
|
+
children: [
|
|
90
|
+
required ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
91
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.Text, {
|
|
92
|
+
style: [
|
|
93
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase.fontSize14,
|
|
94
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-label.required"]
|
|
95
|
+
],
|
|
96
|
+
children: "*"
|
|
97
|
+
})
|
|
98
|
+
}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Fragment, {}),
|
|
99
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
100
|
+
style: __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-label"],
|
|
101
|
+
children: 'string' == typeof label ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.Text, {
|
|
102
|
+
style: __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase.fontSize14,
|
|
103
|
+
children: label
|
|
104
|
+
}) : label
|
|
105
|
+
}),
|
|
106
|
+
_isShowColon ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
107
|
+
style: [
|
|
108
|
+
__WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-label.show-colon"]
|
|
109
|
+
],
|
|
110
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.Text, {
|
|
111
|
+
style: __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase.fontSize14,
|
|
112
|
+
children: ":"
|
|
113
|
+
})
|
|
114
|
+
}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Fragment, {})
|
|
115
|
+
]
|
|
116
|
+
}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Fragment, {}),
|
|
117
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
118
|
+
style: bodyStyles,
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
121
|
+
style: bodyInputStyles,
|
|
122
|
+
children: children
|
|
123
|
+
}),
|
|
124
|
+
helpText ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
125
|
+
style: __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-body-help"],
|
|
126
|
+
children: 'string' == typeof helpText ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.Text, {
|
|
127
|
+
style: __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase.fontSize12,
|
|
128
|
+
children: helpText
|
|
129
|
+
}) : helpText
|
|
130
|
+
}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Fragment, {}),
|
|
131
|
+
isInvalid ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
132
|
+
style: errorStyles,
|
|
133
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.Text, {
|
|
134
|
+
style: __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["error-text"],
|
|
135
|
+
children: tip
|
|
136
|
+
})
|
|
137
|
+
}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Fragment, {})
|
|
138
|
+
]
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}),
|
|
142
|
+
extra ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.View, {
|
|
143
|
+
style: __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase["carefrees-form-item-extra"],
|
|
144
|
+
children: 'string' == typeof extra ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.Text, {
|
|
145
|
+
style: __WEBPACK_EXTERNAL_MODULE__styles_index_js_2b6f3fb9__.StylesBase.fontSize14,
|
|
146
|
+
children: extra
|
|
147
|
+
}) : extra
|
|
148
|
+
}) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react__.Fragment, {})
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
export { LayoutFormItem };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
export declare const StylesBase: {
|
|
2
|
+
'carefrees-form': {
|
|
3
|
+
fontSize: number;
|
|
4
|
+
};
|
|
5
|
+
'carefrees-form-layout': {
|
|
6
|
+
width: "100%";
|
|
7
|
+
borderRadius: number;
|
|
8
|
+
paddingBottom: number;
|
|
9
|
+
position: "relative";
|
|
10
|
+
};
|
|
11
|
+
'carefrees-form-layout.bordered': {
|
|
12
|
+
borderColor: string;
|
|
13
|
+
borderWidth: number;
|
|
14
|
+
borderStyle: "solid";
|
|
15
|
+
};
|
|
16
|
+
'carefrees-form-layout-header': {
|
|
17
|
+
display: "flex";
|
|
18
|
+
justifyContent: "space-between";
|
|
19
|
+
alignItems: "center";
|
|
20
|
+
flexDirection: "row";
|
|
21
|
+
borderBottomColor: string;
|
|
22
|
+
borderBottomWidth: number;
|
|
23
|
+
paddingTop: number;
|
|
24
|
+
paddingBottom: number;
|
|
25
|
+
marginBlockEnd: number;
|
|
26
|
+
paddingInlineStart: number;
|
|
27
|
+
paddingInlineEnd: number;
|
|
28
|
+
};
|
|
29
|
+
'carefrees-form-layout-header.bordered': {
|
|
30
|
+
paddingInlineStart: number;
|
|
31
|
+
paddingInlineEnd: number;
|
|
32
|
+
};
|
|
33
|
+
isAllColSpan: {
|
|
34
|
+
width: "100%";
|
|
35
|
+
};
|
|
36
|
+
title: {
|
|
37
|
+
fontSize: number;
|
|
38
|
+
fontWeight: 600;
|
|
39
|
+
color: string;
|
|
40
|
+
};
|
|
41
|
+
'carefrees-form-layout-header-title': {
|
|
42
|
+
fontSize: number;
|
|
43
|
+
fontWeight: 600;
|
|
44
|
+
color: string;
|
|
45
|
+
};
|
|
46
|
+
extra: {
|
|
47
|
+
fontSize: number;
|
|
48
|
+
fontWeight: 500;
|
|
49
|
+
color: string;
|
|
50
|
+
};
|
|
51
|
+
'carefrees-form-layout-header-extra': {
|
|
52
|
+
fontSize: number;
|
|
53
|
+
fontWeight: 500;
|
|
54
|
+
color: string;
|
|
55
|
+
};
|
|
56
|
+
'carefrees-form-layout-body': {
|
|
57
|
+
width: "100%";
|
|
58
|
+
display: "flex";
|
|
59
|
+
flexDirection: "row";
|
|
60
|
+
flexWrap: "wrap";
|
|
61
|
+
paddingInlineStart: number;
|
|
62
|
+
paddingInlineEnd: number;
|
|
63
|
+
gap: number;
|
|
64
|
+
};
|
|
65
|
+
'carefrees-form-item': {
|
|
66
|
+
display: "flex";
|
|
67
|
+
flexDirection: "row";
|
|
68
|
+
alignItems: "flex-start";
|
|
69
|
+
padding: number;
|
|
70
|
+
color: string;
|
|
71
|
+
};
|
|
72
|
+
'carefrees-form-item.only-rule-style': {
|
|
73
|
+
padding: number;
|
|
74
|
+
};
|
|
75
|
+
'carefrees-form-item-container': {
|
|
76
|
+
display: "flex";
|
|
77
|
+
flexDirection: "column";
|
|
78
|
+
gap: number;
|
|
79
|
+
height: "100%";
|
|
80
|
+
flex: number;
|
|
81
|
+
};
|
|
82
|
+
'carefrees-form-item-container.left': {
|
|
83
|
+
flexDirection: "row";
|
|
84
|
+
gap: number;
|
|
85
|
+
textAlign: "left";
|
|
86
|
+
};
|
|
87
|
+
'carefrees-form-item-label-warp.left': {
|
|
88
|
+
justifyContent: "flex-end";
|
|
89
|
+
};
|
|
90
|
+
'carefrees-form-item-container.between': {
|
|
91
|
+
gap: number;
|
|
92
|
+
textAlign: "left";
|
|
93
|
+
flexDirection: "row";
|
|
94
|
+
justifyContent: "space-between";
|
|
95
|
+
};
|
|
96
|
+
'carefrees-form-item-body-com.between': {
|
|
97
|
+
justifyContent: "flex-end";
|
|
98
|
+
textAlign: "right";
|
|
99
|
+
};
|
|
100
|
+
'carefrees-form-item-label-warp': {
|
|
101
|
+
display: "flex";
|
|
102
|
+
flexDirection: "row";
|
|
103
|
+
justifyContent: "flex-start";
|
|
104
|
+
};
|
|
105
|
+
'carefrees-form-item-label-warp.minHeight': {
|
|
106
|
+
minHeight: number;
|
|
107
|
+
alignItems: "center";
|
|
108
|
+
};
|
|
109
|
+
'carefrees-form-item-label': {
|
|
110
|
+
display: "flex";
|
|
111
|
+
alignItems: "center";
|
|
112
|
+
justifyContent: "flex-start";
|
|
113
|
+
position: "relative";
|
|
114
|
+
fontSize: number;
|
|
115
|
+
color: string;
|
|
116
|
+
};
|
|
117
|
+
'carefrees-form-item-label.show-colon': {
|
|
118
|
+
textAlign: "center";
|
|
119
|
+
margin: number;
|
|
120
|
+
marginInlineEnd: number;
|
|
121
|
+
marginInlineStart: number;
|
|
122
|
+
};
|
|
123
|
+
'carefrees-form-item-label.required': {
|
|
124
|
+
color: string;
|
|
125
|
+
margin: number;
|
|
126
|
+
marginInlineEnd: number;
|
|
127
|
+
};
|
|
128
|
+
'carefrees-form-item-body': {
|
|
129
|
+
position: "relative";
|
|
130
|
+
display: "flex";
|
|
131
|
+
flexDirection: "column";
|
|
132
|
+
alignItems: "flex-start";
|
|
133
|
+
justifyContent: "flex-start";
|
|
134
|
+
gap: number;
|
|
135
|
+
flex: number;
|
|
136
|
+
};
|
|
137
|
+
'carefrees-form-item-body-input': {
|
|
138
|
+
width: "100%";
|
|
139
|
+
flex: number;
|
|
140
|
+
display: "flex";
|
|
141
|
+
justifyContent: "flex-start";
|
|
142
|
+
alignItems: "center";
|
|
143
|
+
flexDirection: "row";
|
|
144
|
+
};
|
|
145
|
+
'carefrees-form-item-body-input.input-bordered': {
|
|
146
|
+
borderWidth: number;
|
|
147
|
+
borderBottomColor: string;
|
|
148
|
+
borderBottomWidth: number;
|
|
149
|
+
borderStyle: "solid";
|
|
150
|
+
};
|
|
151
|
+
'carefrees-form-item-body-help': {
|
|
152
|
+
width: "100%";
|
|
153
|
+
};
|
|
154
|
+
'carefrees-form-item-body-error': {
|
|
155
|
+
position: "absolute";
|
|
156
|
+
width: "100%";
|
|
157
|
+
color: string;
|
|
158
|
+
top: "auto";
|
|
159
|
+
left: number;
|
|
160
|
+
right: number;
|
|
161
|
+
bottom: number;
|
|
162
|
+
paddingTop: number;
|
|
163
|
+
zIndex: number;
|
|
164
|
+
fontSize: number;
|
|
165
|
+
display: "flex";
|
|
166
|
+
flexDirection: "row";
|
|
167
|
+
justifyContent: "flex-start";
|
|
168
|
+
};
|
|
169
|
+
'error-text': {
|
|
170
|
+
fontSize: number;
|
|
171
|
+
color: string;
|
|
172
|
+
};
|
|
173
|
+
'carefrees-form-item-body-error.right-bottom': {
|
|
174
|
+
top: "auto";
|
|
175
|
+
left: number;
|
|
176
|
+
right: number;
|
|
177
|
+
bottom: number;
|
|
178
|
+
justifyContent: "flex-end";
|
|
179
|
+
};
|
|
180
|
+
'carefrees-form-item-body-error.top-left': {
|
|
181
|
+
top: number;
|
|
182
|
+
left: number;
|
|
183
|
+
right: number;
|
|
184
|
+
bottom: "auto";
|
|
185
|
+
justifyContent: "flex-start";
|
|
186
|
+
};
|
|
187
|
+
'carefrees-form-item-body-error.top-right': {
|
|
188
|
+
top: number;
|
|
189
|
+
left: number;
|
|
190
|
+
right: number;
|
|
191
|
+
bottom: "auto";
|
|
192
|
+
justifyContent: "flex-end";
|
|
193
|
+
};
|
|
194
|
+
'carefrees-form-item-extra': {};
|
|
195
|
+
fontSize12: {
|
|
196
|
+
fontSize: number;
|
|
197
|
+
};
|
|
198
|
+
fontSize14: {
|
|
199
|
+
fontSize: number;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__ from "react-native";
|
|
2
|
+
const StylesBase = __WEBPACK_EXTERNAL_MODULE_react_native_4af9217e__.StyleSheet.create({
|
|
3
|
+
'carefrees-form': {
|
|
4
|
+
fontSize: 14
|
|
5
|
+
},
|
|
6
|
+
'carefrees-form-layout': {
|
|
7
|
+
width: '100%',
|
|
8
|
+
borderRadius: 4,
|
|
9
|
+
paddingBottom: 8,
|
|
10
|
+
position: 'relative'
|
|
11
|
+
},
|
|
12
|
+
'carefrees-form-layout.bordered': {
|
|
13
|
+
borderColor: '#e0e0e0',
|
|
14
|
+
borderWidth: 1,
|
|
15
|
+
borderStyle: 'solid'
|
|
16
|
+
},
|
|
17
|
+
'carefrees-form-layout-header': {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
justifyContent: 'space-between',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
borderBottomColor: '#e0e0e0',
|
|
23
|
+
borderBottomWidth: 1,
|
|
24
|
+
paddingTop: 5,
|
|
25
|
+
paddingBottom: 5,
|
|
26
|
+
marginBlockEnd: 4,
|
|
27
|
+
paddingInlineStart: 2,
|
|
28
|
+
paddingInlineEnd: 2
|
|
29
|
+
},
|
|
30
|
+
'carefrees-form-layout-header.bordered': {
|
|
31
|
+
paddingInlineStart: 8,
|
|
32
|
+
paddingInlineEnd: 8
|
|
33
|
+
},
|
|
34
|
+
isAllColSpan: {
|
|
35
|
+
width: '100%'
|
|
36
|
+
},
|
|
37
|
+
title: {
|
|
38
|
+
fontSize: 16,
|
|
39
|
+
fontWeight: 600,
|
|
40
|
+
color: '#1d2129'
|
|
41
|
+
},
|
|
42
|
+
'carefrees-form-layout-header-title': {
|
|
43
|
+
fontSize: 16,
|
|
44
|
+
fontWeight: 600,
|
|
45
|
+
color: '#1d2129'
|
|
46
|
+
},
|
|
47
|
+
extra: {
|
|
48
|
+
fontSize: 14,
|
|
49
|
+
fontWeight: 500,
|
|
50
|
+
color: '#1d2129'
|
|
51
|
+
},
|
|
52
|
+
'carefrees-form-layout-header-extra': {
|
|
53
|
+
fontSize: 14,
|
|
54
|
+
fontWeight: 500,
|
|
55
|
+
color: '#1d2129'
|
|
56
|
+
},
|
|
57
|
+
'carefrees-form-layout-body': {
|
|
58
|
+
width: '100%',
|
|
59
|
+
display: 'flex',
|
|
60
|
+
flexDirection: 'row',
|
|
61
|
+
flexWrap: 'wrap',
|
|
62
|
+
paddingInlineStart: 2,
|
|
63
|
+
paddingInlineEnd: 2,
|
|
64
|
+
gap: 2
|
|
65
|
+
},
|
|
66
|
+
'carefrees-form-item': {
|
|
67
|
+
display: 'flex',
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
alignItems: 'flex-start',
|
|
70
|
+
padding: 8,
|
|
71
|
+
color: 'rgba(0, 0, 0, 0.88)'
|
|
72
|
+
},
|
|
73
|
+
'carefrees-form-item.only-rule-style': {
|
|
74
|
+
padding: 0
|
|
75
|
+
},
|
|
76
|
+
'carefrees-form-item-container': {
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'column',
|
|
79
|
+
gap: 4,
|
|
80
|
+
height: '100%',
|
|
81
|
+
flex: 1
|
|
82
|
+
},
|
|
83
|
+
'carefrees-form-item-container.left': {
|
|
84
|
+
flexDirection: 'row',
|
|
85
|
+
gap: 8,
|
|
86
|
+
textAlign: 'left'
|
|
87
|
+
},
|
|
88
|
+
'carefrees-form-item-label-warp.left': {
|
|
89
|
+
justifyContent: 'flex-end'
|
|
90
|
+
},
|
|
91
|
+
'carefrees-form-item-container.between': {
|
|
92
|
+
gap: 8,
|
|
93
|
+
textAlign: 'left',
|
|
94
|
+
flexDirection: 'row',
|
|
95
|
+
justifyContent: 'space-between'
|
|
96
|
+
},
|
|
97
|
+
'carefrees-form-item-body-com.between': {
|
|
98
|
+
justifyContent: 'flex-end',
|
|
99
|
+
textAlign: 'right'
|
|
100
|
+
},
|
|
101
|
+
'carefrees-form-item-label-warp': {
|
|
102
|
+
display: 'flex',
|
|
103
|
+
flexDirection: 'row',
|
|
104
|
+
justifyContent: 'flex-start'
|
|
105
|
+
},
|
|
106
|
+
'carefrees-form-item-label-warp.minHeight': {
|
|
107
|
+
minHeight: 32,
|
|
108
|
+
alignItems: 'center'
|
|
109
|
+
},
|
|
110
|
+
'carefrees-form-item-label': {
|
|
111
|
+
display: 'flex',
|
|
112
|
+
alignItems: 'center',
|
|
113
|
+
justifyContent: 'flex-start',
|
|
114
|
+
position: 'relative',
|
|
115
|
+
fontSize: 14,
|
|
116
|
+
color: 'rgba(0, 0, 0, 0.88)'
|
|
117
|
+
},
|
|
118
|
+
'carefrees-form-item-label.show-colon': {
|
|
119
|
+
textAlign: 'center',
|
|
120
|
+
margin: 0,
|
|
121
|
+
marginInlineEnd: 2,
|
|
122
|
+
marginInlineStart: 2
|
|
123
|
+
},
|
|
124
|
+
'carefrees-form-item-label.required': {
|
|
125
|
+
color: 'red',
|
|
126
|
+
margin: 0,
|
|
127
|
+
marginInlineEnd: 2
|
|
128
|
+
},
|
|
129
|
+
'carefrees-form-item-body': {
|
|
130
|
+
position: 'relative',
|
|
131
|
+
display: 'flex',
|
|
132
|
+
flexDirection: 'column',
|
|
133
|
+
alignItems: 'flex-start',
|
|
134
|
+
justifyContent: 'flex-start',
|
|
135
|
+
gap: 4,
|
|
136
|
+
flex: 1
|
|
137
|
+
},
|
|
138
|
+
'carefrees-form-item-body-input': {
|
|
139
|
+
width: '100%',
|
|
140
|
+
flex: 1,
|
|
141
|
+
display: 'flex',
|
|
142
|
+
justifyContent: 'flex-start',
|
|
143
|
+
alignItems: 'center',
|
|
144
|
+
flexDirection: 'row'
|
|
145
|
+
},
|
|
146
|
+
'carefrees-form-item-body-input.input-bordered': {
|
|
147
|
+
borderWidth: 0,
|
|
148
|
+
borderBottomColor: '#e0e0e0',
|
|
149
|
+
borderBottomWidth: 1,
|
|
150
|
+
borderStyle: 'solid'
|
|
151
|
+
},
|
|
152
|
+
'carefrees-form-item-body-help': {
|
|
153
|
+
width: '100%'
|
|
154
|
+
},
|
|
155
|
+
'carefrees-form-item-body-error': {
|
|
156
|
+
position: 'absolute',
|
|
157
|
+
width: '100%',
|
|
158
|
+
color: 'red',
|
|
159
|
+
top: 'auto',
|
|
160
|
+
left: 0,
|
|
161
|
+
right: 0,
|
|
162
|
+
bottom: -16,
|
|
163
|
+
paddingTop: 2,
|
|
164
|
+
zIndex: 10,
|
|
165
|
+
fontSize: 12,
|
|
166
|
+
display: 'flex',
|
|
167
|
+
flexDirection: 'row',
|
|
168
|
+
justifyContent: 'flex-start'
|
|
169
|
+
},
|
|
170
|
+
'error-text': {
|
|
171
|
+
fontSize: 12,
|
|
172
|
+
color: 'red'
|
|
173
|
+
},
|
|
174
|
+
'carefrees-form-item-body-error.right-bottom': {
|
|
175
|
+
top: 'auto',
|
|
176
|
+
left: 0,
|
|
177
|
+
right: 0,
|
|
178
|
+
bottom: -16,
|
|
179
|
+
justifyContent: 'flex-end'
|
|
180
|
+
},
|
|
181
|
+
'carefrees-form-item-body-error.top-left': {
|
|
182
|
+
top: -16,
|
|
183
|
+
left: 0,
|
|
184
|
+
right: 0,
|
|
185
|
+
bottom: 'auto',
|
|
186
|
+
justifyContent: 'flex-start'
|
|
187
|
+
},
|
|
188
|
+
'carefrees-form-item-body-error.top-right': {
|
|
189
|
+
top: -16,
|
|
190
|
+
left: 0,
|
|
191
|
+
right: 0,
|
|
192
|
+
bottom: 'auto',
|
|
193
|
+
justifyContent: 'flex-end'
|
|
194
|
+
},
|
|
195
|
+
'carefrees-form-item-extra': {},
|
|
196
|
+
fontSize12: {
|
|
197
|
+
fontSize: 12
|
|
198
|
+
},
|
|
199
|
+
fontSize14: {
|
|
200
|
+
fontSize: 14
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
export { StylesBase };
|
package/package.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"author": "SunLxy <1011771396@qq.com>",
|
|
4
4
|
"description": "react-native 表单组件",
|
|
5
5
|
"homepage": "https://github.com/SunLxy/carefrees-form-utils",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.8",
|
|
7
7
|
"main": "esm/index.js",
|
|
8
8
|
"types": "esm/index.d.ts",
|
|
9
9
|
"module": "esm/index.js",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "carefrees-rslib build",
|
|
13
|
-
"watch": "carefrees-rslib build --watch"
|
|
12
|
+
"build": "carefrees-rslib build --esm",
|
|
13
|
+
"watch": "carefrees-rslib build --watch --esm"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"esm"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@carefrees/form-utils": "^0.0.
|
|
24
|
-
"@carefrees/form-utils-react-hooks": "^0.0.
|
|
23
|
+
"@carefrees/form-utils": "^0.0.8",
|
|
24
|
+
"@carefrees/form-utils-react-hooks": "^0.0.8"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"react-native": "0.76.9",
|
|
28
27
|
"@types/react": "18.2.21",
|
|
29
|
-
"react": "^18.2.0"
|
|
28
|
+
"react": "^18.2.0",
|
|
29
|
+
"react-native": "0.76.9"
|
|
30
30
|
}
|
|
31
|
-
}
|
|
31
|
+
}
|
package/src/formItem/index.tsx
CHANGED
|
@@ -21,7 +21,6 @@ const FormItemInstance = memo((props: FormItemProps) => {
|
|
|
21
21
|
required,
|
|
22
22
|
showColon,
|
|
23
23
|
colSpan,
|
|
24
|
-
rowSpan,
|
|
25
24
|
...rest
|
|
26
25
|
} = props;
|
|
27
26
|
const { children, ruleInstance, formItemInstance, htmlFor, validateResult } = useFormItemAttr({ ...rest });
|
|
@@ -44,7 +43,6 @@ const FormItemInstance = memo((props: FormItemProps) => {
|
|
|
44
43
|
errorLayout={errorLayout}
|
|
45
44
|
showColon={showColon}
|
|
46
45
|
colSpan={colSpan}
|
|
47
|
-
rowSpan={rowSpan}
|
|
48
46
|
htmlFor={htmlFor}
|
|
49
47
|
validateResult={validateResult}
|
|
50
48
|
>
|
|
@@ -60,19 +58,8 @@ export const FormItem = memo((props: Partial<FormItemProps>) => {
|
|
|
60
58
|
if (name) {
|
|
61
59
|
return <FormItemInstance {...props} name={name} />;
|
|
62
60
|
}
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
onlyRuleStyle,
|
|
66
|
-
label,
|
|
67
|
-
helpText,
|
|
68
|
-
extra,
|
|
69
|
-
errorLayout,
|
|
70
|
-
required,
|
|
71
|
-
showColon,
|
|
72
|
-
colSpan,
|
|
73
|
-
rowSpan,
|
|
74
|
-
children,
|
|
75
|
-
} = props;
|
|
61
|
+
const { labelMode, onlyRuleStyle, label, helpText, extra, errorLayout, required, showColon, colSpan, children } =
|
|
62
|
+
props;
|
|
76
63
|
return (
|
|
77
64
|
<LayoutFormItem
|
|
78
65
|
labelMode={labelMode}
|
|
@@ -84,7 +71,6 @@ export const FormItem = memo((props: Partial<FormItemProps>) => {
|
|
|
84
71
|
errorLayout={errorLayout}
|
|
85
72
|
showColon={showColon}
|
|
86
73
|
colSpan={colSpan}
|
|
87
|
-
rowSpan={rowSpan}
|
|
88
74
|
>
|
|
89
75
|
{children}
|
|
90
76
|
</LayoutFormItem>
|
package/src/hooks/useAttrs.ts
CHANGED
|
@@ -14,12 +14,8 @@ export interface AttrsOptions {
|
|
|
14
14
|
labelMode?: 'left' | 'top' | 'between' | 'hide';
|
|
15
15
|
/**是否显示label后的冒号*/
|
|
16
16
|
showColon?: boolean;
|
|
17
|
-
/**表单项 className*/
|
|
18
|
-
formItemClassName?: string;
|
|
19
17
|
/**表单项 style*/
|
|
20
18
|
formItemStyle?: ViewProps['style'];
|
|
21
|
-
/**表单项 label className*/
|
|
22
|
-
formItemLabelClassName?: string;
|
|
23
19
|
/**表单项 label style*/
|
|
24
20
|
formItemLabelStyle?: ViewProps['style'];
|
|
25
21
|
/**
|
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>
|