@fairys/rn-valtio-form-basic 0.0.12
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 +0 -0
- package/esm/form.d.ts +16 -0
- package/esm/form.item.d.ts +18 -0
- package/esm/form.item.js +104 -0
- package/esm/form.js +23 -0
- package/esm/hooks/form.d.ts +58 -0
- package/esm/hooks/form.item.d.ts +118 -0
- package/esm/hooks/form.item.js +292 -0
- package/esm/hooks/form.js +17 -0
- package/esm/hooks/layout.d.ts +12109 -0
- package/esm/hooks/layout.js +142 -0
- package/esm/index.d.ts +9 -0
- package/esm/index.js +9 -0
- package/esm/layout.d.ts +4 -0
- package/esm/layout.js +38 -0
- package/esm/styles/form.item.d.ts +164 -0
- package/esm/styles/form.item.js +166 -0
- package/esm/styles/layout.d.ts +36 -0
- package/esm/styles/layout.js +38 -0
- package/package.json +35 -0
- package/src/form.item.tsx +135 -0
- package/src/form.tsx +38 -0
- package/src/hooks/form.item.ts +492 -0
- package/src/hooks/form.ts +46 -0
- package/src/hooks/layout.ts +249 -0
- package/src/index.tsx +9 -0
- package/src/layout.tsx +31 -0
- package/src/styles/form.item.ts +166 -0
- package/src/styles/layout.ts +38 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createContext, useContext, useMemo, useRef } from "react";
|
|
2
|
+
import { proxy, useSnapshot } from "valtio";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
import { layoutStyles } from "../styles/layout.js";
|
|
5
|
+
class FairysValtioFormLayoutInstance {
|
|
6
|
+
state = proxy({
|
|
7
|
+
colCount: 1,
|
|
8
|
+
errorLayout: 'bottom-right',
|
|
9
|
+
labelMode: 'between',
|
|
10
|
+
itemBorderType: 'bottom'
|
|
11
|
+
});
|
|
12
|
+
updated = (options = {})=>{
|
|
13
|
+
const keys = Object.keys(options);
|
|
14
|
+
for(let index = 0; index < keys.length; index++){
|
|
15
|
+
const key = keys[index];
|
|
16
|
+
this.state[key] = options[key];
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const useFairysValtioFormLayoutInstance = (instance)=>{
|
|
21
|
+
const ref = useRef();
|
|
22
|
+
if (!ref.current) if (instance) ref.current = instance;
|
|
23
|
+
else ref.current = new FairysValtioFormLayoutInstance();
|
|
24
|
+
return ref.current;
|
|
25
|
+
};
|
|
26
|
+
const FairysValtioFormLayoutContext = createContext(new FairysValtioFormLayoutInstance());
|
|
27
|
+
const useFairysValtioFormLayoutContext = ()=>{
|
|
28
|
+
const instance = useContext(FairysValtioFormLayoutContext);
|
|
29
|
+
const state = useSnapshot(instance.state);
|
|
30
|
+
return [
|
|
31
|
+
state,
|
|
32
|
+
instance
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
function useFairysValtioFormLayoutAttrs(props) {
|
|
36
|
+
const formLayoutInstance = useFairysValtioFormLayoutInstance();
|
|
37
|
+
const [state] = useFairysValtioFormLayoutContext();
|
|
38
|
+
const parent_colCount = state.colCount || 1;
|
|
39
|
+
const parent_errorLayout = state.errorLayout || 'bottom-right';
|
|
40
|
+
const parent_labelMode = state.labelMode || 'between';
|
|
41
|
+
const parent_formItemStyle = state.formItemStyle;
|
|
42
|
+
const parent_formItemLabelStyle = state.formItemLabelStyle;
|
|
43
|
+
const parent_formItemBodyStyle = state.formItemBodyStyle;
|
|
44
|
+
const parent_borderedType = state.itemBorderType || 'bottom';
|
|
45
|
+
const parent_itemBorderColor = state.itemBorderColor;
|
|
46
|
+
const parent_isInvalidBorderRed = state.isInvalidBorderRed;
|
|
47
|
+
const parent_isInvalidTextRed = state.isInvalidTextRed;
|
|
48
|
+
const parent_showColon = state.showColon;
|
|
49
|
+
const { colCount = parent_colCount, errorLayout = parent_errorLayout, labelMode = parent_labelMode, formItemStyle = parent_formItemStyle, formItemLabelStyle = parent_formItemLabelStyle, formItemBodyStyle = parent_formItemBodyStyle, itemBorderType = parent_borderedType, itemBorderColor = parent_itemBorderColor, isInvalidBorderRed = parent_isInvalidBorderRed, isInvalidTextRed = parent_isInvalidTextRed, showColon = parent_showColon, gap, style, headerStyle, headerTextStyle, headerExtraStyle, bodyStyle, bordered } = props;
|
|
50
|
+
useMemo(()=>formLayoutInstance.updated({
|
|
51
|
+
colCount,
|
|
52
|
+
errorLayout,
|
|
53
|
+
labelMode,
|
|
54
|
+
formItemStyle,
|
|
55
|
+
formItemLabelStyle,
|
|
56
|
+
formItemBodyStyle,
|
|
57
|
+
itemBorderType,
|
|
58
|
+
itemBorderColor,
|
|
59
|
+
isInvalidBorderRed,
|
|
60
|
+
isInvalidTextRed,
|
|
61
|
+
showColon
|
|
62
|
+
}), [
|
|
63
|
+
colCount,
|
|
64
|
+
errorLayout,
|
|
65
|
+
labelMode,
|
|
66
|
+
formItemStyle,
|
|
67
|
+
formItemLabelStyle,
|
|
68
|
+
formItemBodyStyle,
|
|
69
|
+
itemBorderType,
|
|
70
|
+
itemBorderColor,
|
|
71
|
+
isInvalidBorderRed,
|
|
72
|
+
isInvalidTextRed,
|
|
73
|
+
showColon
|
|
74
|
+
]);
|
|
75
|
+
const _layoutStyle = useMemo(()=>[
|
|
76
|
+
StyleSheet.flatten([
|
|
77
|
+
layoutStyles["fairys-valtio-form-layout"],
|
|
78
|
+
bordered && layoutStyles["fairys-valtio-form-layout.bordered"],
|
|
79
|
+
style
|
|
80
|
+
])
|
|
81
|
+
], [
|
|
82
|
+
bordered,
|
|
83
|
+
style
|
|
84
|
+
]);
|
|
85
|
+
const _headerStyle = useMemo(()=>[
|
|
86
|
+
StyleSheet.flatten([
|
|
87
|
+
layoutStyles["fairys-valtio-form-layout-header"],
|
|
88
|
+
headerStyle
|
|
89
|
+
])
|
|
90
|
+
], [
|
|
91
|
+
headerStyle
|
|
92
|
+
]);
|
|
93
|
+
const _headerTitleStyle = useMemo(()=>[
|
|
94
|
+
StyleSheet.flatten([
|
|
95
|
+
layoutStyles["fairys-valtio-form-layout-header-title"],
|
|
96
|
+
headerTextStyle
|
|
97
|
+
])
|
|
98
|
+
], [
|
|
99
|
+
headerTextStyle
|
|
100
|
+
]);
|
|
101
|
+
const _headerExtraStyle = useMemo(()=>[
|
|
102
|
+
StyleSheet.flatten([
|
|
103
|
+
layoutStyles["fairys-valtio-form-layout-header-extra"],
|
|
104
|
+
headerExtraStyle
|
|
105
|
+
])
|
|
106
|
+
], [
|
|
107
|
+
headerExtraStyle
|
|
108
|
+
]);
|
|
109
|
+
const _bodyStyle = useMemo(()=>[
|
|
110
|
+
StyleSheet.flatten([
|
|
111
|
+
layoutStyles["fairys-valtio-form-layout-body"],
|
|
112
|
+
bodyStyle
|
|
113
|
+
])
|
|
114
|
+
], [
|
|
115
|
+
bodyStyle
|
|
116
|
+
]);
|
|
117
|
+
const styleBase = useMemo(()=>{
|
|
118
|
+
const css = {};
|
|
119
|
+
if ('string' == typeof gap) css.gap = Number(gap);
|
|
120
|
+
if ('number' == typeof gap) css.gap = gap;
|
|
121
|
+
return css;
|
|
122
|
+
}, [
|
|
123
|
+
colCount,
|
|
124
|
+
gap
|
|
125
|
+
]);
|
|
126
|
+
return {
|
|
127
|
+
colCount,
|
|
128
|
+
errorLayout,
|
|
129
|
+
labelMode,
|
|
130
|
+
itemBorderType,
|
|
131
|
+
formLayoutInstance,
|
|
132
|
+
layoutStyle: _layoutStyle,
|
|
133
|
+
headerStyle: _headerStyle,
|
|
134
|
+
headerTitleStyle: _headerTitleStyle,
|
|
135
|
+
headerExtraStyle: _headerExtraStyle,
|
|
136
|
+
bodyStyle: StyleSheet.flatten([
|
|
137
|
+
styleBase,
|
|
138
|
+
_bodyStyle
|
|
139
|
+
])
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export { FairysValtioFormLayoutContext, FairysValtioFormLayoutInstance, useFairysValtioFormLayoutAttrs, useFairysValtioFormLayoutContext, useFairysValtioFormLayoutInstance };
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from '@fairys/valtio-form-basic/esm/common';
|
|
2
|
+
export * from './hooks/form';
|
|
3
|
+
export * from './styles/form.item';
|
|
4
|
+
export * from './styles/layout';
|
|
5
|
+
export * from './hooks/form.item';
|
|
6
|
+
export * from './hooks/layout';
|
|
7
|
+
export * from './form.item';
|
|
8
|
+
export * from './layout';
|
|
9
|
+
export * from './form';
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "@fairys/valtio-form-basic/esm/common";
|
|
2
|
+
export * from "./hooks/form.js";
|
|
3
|
+
export * from "./styles/form.item.js";
|
|
4
|
+
export * from "./styles/layout.js";
|
|
5
|
+
export * from "./hooks/form.item.js";
|
|
6
|
+
export * from "./hooks/layout.js";
|
|
7
|
+
export * from "./form.item.js";
|
|
8
|
+
export * from "./layout.js";
|
|
9
|
+
export * from "./form.js";
|
package/esm/layout.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FairysValtioFormLayoutAttrsProps } from './hooks/layout';
|
|
2
|
+
export interface FairysRNValtioFormLayoutProps extends FairysValtioFormLayoutAttrsProps {
|
|
3
|
+
}
|
|
4
|
+
export declare function FairysRNValtioFormLayout(props: FairysRNValtioFormLayoutProps): import("react/jsx-runtime").JSX.Element;
|
package/esm/layout.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { Text, View } from "react-native";
|
|
4
|
+
import { FairysValtioFormLayoutContext, useFairysValtioFormLayoutAttrs } from "./hooks/layout.js";
|
|
5
|
+
function FairysRNValtioFormLayout(props) {
|
|
6
|
+
const { children, title, extra } = props;
|
|
7
|
+
const { formLayoutInstance, layoutStyle, headerStyle, bodyStyle, headerTitleStyle, headerExtraStyle } = useFairysValtioFormLayoutAttrs(props);
|
|
8
|
+
return /*#__PURE__*/ jsx(FairysValtioFormLayoutContext.Provider, {
|
|
9
|
+
value: formLayoutInstance,
|
|
10
|
+
children: /*#__PURE__*/ jsxs(View, {
|
|
11
|
+
style: layoutStyle,
|
|
12
|
+
children: [
|
|
13
|
+
title || extra ? /*#__PURE__*/ jsxs(View, {
|
|
14
|
+
style: headerStyle,
|
|
15
|
+
children: [
|
|
16
|
+
/*#__PURE__*/ jsx(View, {
|
|
17
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
18
|
+
style: headerTitleStyle,
|
|
19
|
+
children: title
|
|
20
|
+
})
|
|
21
|
+
}),
|
|
22
|
+
/*#__PURE__*/ jsx(View, {
|
|
23
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
24
|
+
style: headerExtraStyle,
|
|
25
|
+
children: extra
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
}) : /*#__PURE__*/ jsx(Fragment, {}),
|
|
30
|
+
/*#__PURE__*/ jsx(View, {
|
|
31
|
+
style: bodyStyle,
|
|
32
|
+
children: children
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export { FairysRNValtioFormLayout };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export declare const formItemStyles: {
|
|
2
|
+
'fairys-valtio-form-item': {
|
|
3
|
+
padding: number;
|
|
4
|
+
fontSize: number;
|
|
5
|
+
position: "relative";
|
|
6
|
+
display: "flex";
|
|
7
|
+
flexDirection: "column";
|
|
8
|
+
};
|
|
9
|
+
'fairys-valtio-form-item.border-bottom': {
|
|
10
|
+
borderBottomWidth: number;
|
|
11
|
+
borderBottomColor: string;
|
|
12
|
+
};
|
|
13
|
+
'fairys-valtio-form-item.border-bottom.red': {
|
|
14
|
+
borderBottomWidth: number;
|
|
15
|
+
borderBottomColor: string;
|
|
16
|
+
};
|
|
17
|
+
'fairys-valtio-form-item-container': {
|
|
18
|
+
flex: number;
|
|
19
|
+
height: "100%";
|
|
20
|
+
display: "flex";
|
|
21
|
+
};
|
|
22
|
+
'fairys-valtio-form-item-container.between': {
|
|
23
|
+
flexDirection: "row";
|
|
24
|
+
alignItems: "center";
|
|
25
|
+
justifyContent: "space-between";
|
|
26
|
+
gap: number;
|
|
27
|
+
};
|
|
28
|
+
'fairys-valtio-form-item-container.top': {
|
|
29
|
+
flexDirection: "column";
|
|
30
|
+
gap: number;
|
|
31
|
+
};
|
|
32
|
+
'fairys-valtio-form-item-container.left': {
|
|
33
|
+
flexDirection: "row";
|
|
34
|
+
gap: number;
|
|
35
|
+
};
|
|
36
|
+
'fairys-valtio-form-item-label': {
|
|
37
|
+
display: "flex";
|
|
38
|
+
alignItems: "center";
|
|
39
|
+
position: "relative";
|
|
40
|
+
flexDirection: "row";
|
|
41
|
+
justifyContent: "flex-start";
|
|
42
|
+
};
|
|
43
|
+
'fairys-valtio-form-item-label.left': {
|
|
44
|
+
justifyContent: "flex-end";
|
|
45
|
+
};
|
|
46
|
+
'fairys-valtio-form-item-label.required': {
|
|
47
|
+
color: string;
|
|
48
|
+
marginEnd: number;
|
|
49
|
+
};
|
|
50
|
+
'fairys-valtio-form-item-label.show-colon': {
|
|
51
|
+
textAlign: "center";
|
|
52
|
+
marginHorizontal: number;
|
|
53
|
+
fontSize: number;
|
|
54
|
+
};
|
|
55
|
+
'fairys-valtio-form-item-label.show-colon.red': {
|
|
56
|
+
color: string;
|
|
57
|
+
};
|
|
58
|
+
'fairys-valtio-form-item-label-text': {
|
|
59
|
+
fontSize: number;
|
|
60
|
+
color: string;
|
|
61
|
+
};
|
|
62
|
+
'fairys-valtio-form-item-label-text.red': {
|
|
63
|
+
color: string;
|
|
64
|
+
};
|
|
65
|
+
'fairys-valtio-form-item-body': {
|
|
66
|
+
position: "relative";
|
|
67
|
+
flex: number;
|
|
68
|
+
display: "flex";
|
|
69
|
+
};
|
|
70
|
+
'fairys-valtio-form-item-body.left': {
|
|
71
|
+
flexDirection: "row";
|
|
72
|
+
justifyContent: "flex-start";
|
|
73
|
+
};
|
|
74
|
+
'fairys-valtio-form-item-body.top': {
|
|
75
|
+
flexDirection: "row";
|
|
76
|
+
justifyContent: "flex-end";
|
|
77
|
+
};
|
|
78
|
+
'fairys-valtio-form-item-body.between': {
|
|
79
|
+
flexDirection: "row";
|
|
80
|
+
justifyContent: "flex-end";
|
|
81
|
+
};
|
|
82
|
+
'fairys-valtio-form-item-body.border-bottom': {
|
|
83
|
+
borderBottomWidth: number;
|
|
84
|
+
borderBottomColor: string;
|
|
85
|
+
};
|
|
86
|
+
'fairys-valtio-form-item-body.border-bottom.red': {
|
|
87
|
+
borderBottomWidth: number;
|
|
88
|
+
borderBottomColor: string;
|
|
89
|
+
};
|
|
90
|
+
'fairys-valtio-form-item-body-input': {
|
|
91
|
+
minHeight: number;
|
|
92
|
+
display: "flex";
|
|
93
|
+
flexDirection: "row";
|
|
94
|
+
alignItems: "center";
|
|
95
|
+
flex: number;
|
|
96
|
+
};
|
|
97
|
+
'fairys-valtio-form-item-body-input.between': {
|
|
98
|
+
justifyContent: "flex-end";
|
|
99
|
+
textAlign: "right";
|
|
100
|
+
};
|
|
101
|
+
'fairys-valtio-form-item-body-input.not.between': {
|
|
102
|
+
justifyContent: "flex-start";
|
|
103
|
+
textAlign: "left";
|
|
104
|
+
alignItems: "center";
|
|
105
|
+
};
|
|
106
|
+
'fairys-valtio-form-item-body-extra': {
|
|
107
|
+
display: "flex";
|
|
108
|
+
alignItems: "center";
|
|
109
|
+
justifyContent: "center";
|
|
110
|
+
};
|
|
111
|
+
'fairys-valtio-form-item-body-extra-text': {
|
|
112
|
+
fontSize: number;
|
|
113
|
+
};
|
|
114
|
+
'fairys-valtio-form-item-help': {
|
|
115
|
+
fontSize: number;
|
|
116
|
+
width: "100%";
|
|
117
|
+
};
|
|
118
|
+
'fairys-valtio-form-item-body-error': {
|
|
119
|
+
width: "100%";
|
|
120
|
+
display: "flex";
|
|
121
|
+
flexDirection: "row";
|
|
122
|
+
color: string;
|
|
123
|
+
position: "absolute";
|
|
124
|
+
fontSize: number;
|
|
125
|
+
zIndex: number;
|
|
126
|
+
};
|
|
127
|
+
'fairys-valtio-form-item-body-error-text': {
|
|
128
|
+
color: string;
|
|
129
|
+
fontSize: number;
|
|
130
|
+
};
|
|
131
|
+
'fairys-valtio-form-item-body-error.bottom-left': {
|
|
132
|
+
bottom: number;
|
|
133
|
+
left: number;
|
|
134
|
+
justifyContent: "flex-start";
|
|
135
|
+
};
|
|
136
|
+
'fairys-valtio-form-item-body-error.bottom-right': {
|
|
137
|
+
bottom: number;
|
|
138
|
+
right: number;
|
|
139
|
+
justifyContent: "flex-end";
|
|
140
|
+
};
|
|
141
|
+
'fairys-valtio-form-item-body-error.top-right': {
|
|
142
|
+
top: number;
|
|
143
|
+
right: number;
|
|
144
|
+
justifyContent: "flex-end";
|
|
145
|
+
};
|
|
146
|
+
'fairys-valtio-form-item-body-error.top-left': {
|
|
147
|
+
top: number;
|
|
148
|
+
left: number;
|
|
149
|
+
justifyContent: "flex-start";
|
|
150
|
+
};
|
|
151
|
+
'fairys-valtio-form-item-body-error.left-border-top': {
|
|
152
|
+
left: number;
|
|
153
|
+
bottom: number;
|
|
154
|
+
justifyContent: "flex-start";
|
|
155
|
+
};
|
|
156
|
+
'fairys-valtio-form-item-body-error.right-border-top': {
|
|
157
|
+
right: number;
|
|
158
|
+
bottom: number;
|
|
159
|
+
justifyContent: "flex-end";
|
|
160
|
+
};
|
|
161
|
+
'input.between': {
|
|
162
|
+
textAlign: "right";
|
|
163
|
+
};
|
|
164
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
const formItemStyles = StyleSheet.create({
|
|
3
|
+
'fairys-valtio-form-item': {
|
|
4
|
+
padding: 4,
|
|
5
|
+
fontSize: 12,
|
|
6
|
+
position: 'relative',
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexDirection: 'column'
|
|
9
|
+
},
|
|
10
|
+
'fairys-valtio-form-item.border-bottom': {
|
|
11
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
12
|
+
borderBottomColor: '#d1d5db'
|
|
13
|
+
},
|
|
14
|
+
'fairys-valtio-form-item.border-bottom.red': {
|
|
15
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
16
|
+
borderBottomColor: 'red'
|
|
17
|
+
},
|
|
18
|
+
'fairys-valtio-form-item-container': {
|
|
19
|
+
flex: 1,
|
|
20
|
+
height: '100%',
|
|
21
|
+
display: 'flex'
|
|
22
|
+
},
|
|
23
|
+
'fairys-valtio-form-item-container.between': {
|
|
24
|
+
flexDirection: 'row',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
justifyContent: 'space-between',
|
|
27
|
+
gap: 8
|
|
28
|
+
},
|
|
29
|
+
'fairys-valtio-form-item-container.top': {
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
gap: 4
|
|
32
|
+
},
|
|
33
|
+
'fairys-valtio-form-item-container.left': {
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
gap: 8
|
|
36
|
+
},
|
|
37
|
+
'fairys-valtio-form-item-label': {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
position: 'relative',
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
justifyContent: 'flex-start'
|
|
43
|
+
},
|
|
44
|
+
'fairys-valtio-form-item-label.left': {
|
|
45
|
+
justifyContent: 'flex-end'
|
|
46
|
+
},
|
|
47
|
+
'fairys-valtio-form-item-label.required': {
|
|
48
|
+
color: 'red',
|
|
49
|
+
marginEnd: 4
|
|
50
|
+
},
|
|
51
|
+
'fairys-valtio-form-item-label.show-colon': {
|
|
52
|
+
textAlign: 'center',
|
|
53
|
+
marginHorizontal: 2,
|
|
54
|
+
fontSize: 12
|
|
55
|
+
},
|
|
56
|
+
'fairys-valtio-form-item-label.show-colon.red': {
|
|
57
|
+
color: 'red'
|
|
58
|
+
},
|
|
59
|
+
'fairys-valtio-form-item-label-text': {
|
|
60
|
+
fontSize: 12,
|
|
61
|
+
color: '#1f2937'
|
|
62
|
+
},
|
|
63
|
+
'fairys-valtio-form-item-label-text.red': {
|
|
64
|
+
color: 'red'
|
|
65
|
+
},
|
|
66
|
+
'fairys-valtio-form-item-body': {
|
|
67
|
+
position: 'relative',
|
|
68
|
+
flex: 1,
|
|
69
|
+
display: 'flex'
|
|
70
|
+
},
|
|
71
|
+
'fairys-valtio-form-item-body.left': {
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
justifyContent: 'flex-start'
|
|
74
|
+
},
|
|
75
|
+
'fairys-valtio-form-item-body.top': {
|
|
76
|
+
flexDirection: 'row',
|
|
77
|
+
justifyContent: 'flex-end'
|
|
78
|
+
},
|
|
79
|
+
'fairys-valtio-form-item-body.between': {
|
|
80
|
+
flexDirection: 'row',
|
|
81
|
+
justifyContent: 'flex-end'
|
|
82
|
+
},
|
|
83
|
+
'fairys-valtio-form-item-body.border-bottom': {
|
|
84
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
85
|
+
borderBottomColor: '#d1d5db'
|
|
86
|
+
},
|
|
87
|
+
'fairys-valtio-form-item-body.border-bottom.red': {
|
|
88
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
89
|
+
borderBottomColor: 'red'
|
|
90
|
+
},
|
|
91
|
+
'fairys-valtio-form-item-body-input': {
|
|
92
|
+
minHeight: 32,
|
|
93
|
+
display: 'flex',
|
|
94
|
+
flexDirection: 'row',
|
|
95
|
+
alignItems: 'center',
|
|
96
|
+
flex: 1
|
|
97
|
+
},
|
|
98
|
+
'fairys-valtio-form-item-body-input.between': {
|
|
99
|
+
justifyContent: 'flex-end',
|
|
100
|
+
textAlign: 'right'
|
|
101
|
+
},
|
|
102
|
+
'fairys-valtio-form-item-body-input.not.between': {
|
|
103
|
+
justifyContent: 'flex-start',
|
|
104
|
+
textAlign: 'left',
|
|
105
|
+
alignItems: 'center'
|
|
106
|
+
},
|
|
107
|
+
'fairys-valtio-form-item-body-extra': {
|
|
108
|
+
display: 'flex',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
justifyContent: 'center'
|
|
111
|
+
},
|
|
112
|
+
'fairys-valtio-form-item-body-extra-text': {
|
|
113
|
+
fontSize: 12
|
|
114
|
+
},
|
|
115
|
+
'fairys-valtio-form-item-help': {
|
|
116
|
+
fontSize: 10,
|
|
117
|
+
width: '100%'
|
|
118
|
+
},
|
|
119
|
+
'fairys-valtio-form-item-body-error': {
|
|
120
|
+
width: '100%',
|
|
121
|
+
display: 'flex',
|
|
122
|
+
flexDirection: 'row',
|
|
123
|
+
color: 'red',
|
|
124
|
+
position: 'absolute',
|
|
125
|
+
fontSize: 10,
|
|
126
|
+
zIndex: 10
|
|
127
|
+
},
|
|
128
|
+
'fairys-valtio-form-item-body-error-text': {
|
|
129
|
+
color: 'red',
|
|
130
|
+
fontSize: 10
|
|
131
|
+
},
|
|
132
|
+
'fairys-valtio-form-item-body-error.bottom-left': {
|
|
133
|
+
bottom: -14,
|
|
134
|
+
left: 0,
|
|
135
|
+
justifyContent: 'flex-start'
|
|
136
|
+
},
|
|
137
|
+
'fairys-valtio-form-item-body-error.bottom-right': {
|
|
138
|
+
bottom: -14,
|
|
139
|
+
right: 0,
|
|
140
|
+
justifyContent: 'flex-end'
|
|
141
|
+
},
|
|
142
|
+
'fairys-valtio-form-item-body-error.top-right': {
|
|
143
|
+
top: -4,
|
|
144
|
+
right: 0,
|
|
145
|
+
justifyContent: 'flex-end'
|
|
146
|
+
},
|
|
147
|
+
'fairys-valtio-form-item-body-error.top-left': {
|
|
148
|
+
top: -4,
|
|
149
|
+
left: 0,
|
|
150
|
+
justifyContent: 'flex-start'
|
|
151
|
+
},
|
|
152
|
+
'fairys-valtio-form-item-body-error.left-border-top': {
|
|
153
|
+
left: 0,
|
|
154
|
+
bottom: -2,
|
|
155
|
+
justifyContent: 'flex-start'
|
|
156
|
+
},
|
|
157
|
+
'fairys-valtio-form-item-body-error.right-border-top': {
|
|
158
|
+
right: 0,
|
|
159
|
+
bottom: -2,
|
|
160
|
+
justifyContent: 'flex-end'
|
|
161
|
+
},
|
|
162
|
+
'input.between': {
|
|
163
|
+
textAlign: 'right'
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
export { formItemStyles };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const layoutStyles: {
|
|
2
|
+
'fairys-valtio-form-layout': {
|
|
3
|
+
fontSize: number;
|
|
4
|
+
width: "100%";
|
|
5
|
+
borderRadius: number;
|
|
6
|
+
};
|
|
7
|
+
'fairys-valtio-form-layout.bordered': {
|
|
8
|
+
borderWidth: number;
|
|
9
|
+
borderColor: string;
|
|
10
|
+
};
|
|
11
|
+
'fairys-valtio-form-layout-header': {
|
|
12
|
+
display: "flex";
|
|
13
|
+
flexDirection: "row";
|
|
14
|
+
alignItems: "center";
|
|
15
|
+
justifyContent: "space-between";
|
|
16
|
+
paddingVertical: number;
|
|
17
|
+
paddingHorizontal: number;
|
|
18
|
+
borderBottomWidth: number;
|
|
19
|
+
borderBottomColor: string;
|
|
20
|
+
};
|
|
21
|
+
'fairys-valtio-form-layout-header-title': {
|
|
22
|
+
fontSize: number;
|
|
23
|
+
fontWeight: "bold";
|
|
24
|
+
};
|
|
25
|
+
'fairys-valtio-form-layout-header-extra': {
|
|
26
|
+
fontSize: number;
|
|
27
|
+
};
|
|
28
|
+
'fairys-valtio-form-layout-body': {
|
|
29
|
+
paddingHorizontal: number;
|
|
30
|
+
width: "100%";
|
|
31
|
+
display: "flex";
|
|
32
|
+
flexDirection: "row";
|
|
33
|
+
flexWrap: "wrap";
|
|
34
|
+
gap: number;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
const layoutStyles = StyleSheet.create({
|
|
3
|
+
'fairys-valtio-form-layout': {
|
|
4
|
+
fontSize: 12,
|
|
5
|
+
width: '100%',
|
|
6
|
+
borderRadius: 8
|
|
7
|
+
},
|
|
8
|
+
'fairys-valtio-form-layout.bordered': {
|
|
9
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
10
|
+
borderColor: '#d1d5db'
|
|
11
|
+
},
|
|
12
|
+
'fairys-valtio-form-layout-header': {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'space-between',
|
|
17
|
+
paddingVertical: 10,
|
|
18
|
+
paddingHorizontal: 8,
|
|
19
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
20
|
+
borderBottomColor: '#d1d5db'
|
|
21
|
+
},
|
|
22
|
+
'fairys-valtio-form-layout-header-title': {
|
|
23
|
+
fontSize: 14,
|
|
24
|
+
fontWeight: 'bold'
|
|
25
|
+
},
|
|
26
|
+
'fairys-valtio-form-layout-header-extra': {
|
|
27
|
+
fontSize: 12
|
|
28
|
+
},
|
|
29
|
+
'fairys-valtio-form-layout-body': {
|
|
30
|
+
paddingHorizontal: 8,
|
|
31
|
+
width: '100%',
|
|
32
|
+
display: 'flex',
|
|
33
|
+
flexDirection: 'row',
|
|
34
|
+
flexWrap: 'wrap',
|
|
35
|
+
gap: 2
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export { layoutStyles };
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fairys/rn-valtio-form-basic",
|
|
3
|
+
"author": "SunLxy <1011771396@qq.com>",
|
|
4
|
+
"description": "rn表单框架组件",
|
|
5
|
+
"homepage": "https://github.com/autumn-fairy-tales/valtio-form-basic",
|
|
6
|
+
"version": "0.0.12",
|
|
7
|
+
"main": "esm/index.js",
|
|
8
|
+
"types": "esm/index.d.ts",
|
|
9
|
+
"module": "esm/index.js",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "carefrees-rslib build --esm",
|
|
13
|
+
"watch": "carefrees-rslib build --watch --esm"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/autumn-fairy-tales/valtio-form-basic.git",
|
|
21
|
+
"directory": "packages/rn-valtio-form"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"src",
|
|
25
|
+
"esm"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@fairys/valtio-form-basic": "^0.0.12"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"react-native": "0.76.9",
|
|
32
|
+
"@types/react": "~18.2.21",
|
|
33
|
+
"react": "^18.0.0"
|
|
34
|
+
}
|
|
35
|
+
}
|