@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,46 @@
|
|
|
1
|
+
import type { MObject } from '@fairys/valtio-form-basic/esm/common';
|
|
2
|
+
import { FairysValtioFormInstance, useFairysValtioFormInstance } from '@fairys/valtio-form-basic/esm/common';
|
|
3
|
+
import { useMemo, type ReactNode } from 'react';
|
|
4
|
+
import { FairysValtioFormLayoutAttrsProps } from './layout';
|
|
5
|
+
import { RuleItem } from 'async-validator';
|
|
6
|
+
|
|
7
|
+
export interface FairysValtioFormAttrsProps<T extends MObject<T> = object> extends FairysValtioFormLayoutAttrsProps {
|
|
8
|
+
/**表单实例*/
|
|
9
|
+
form?: FairysValtioFormInstance<T>;
|
|
10
|
+
/**子元素*/
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/**表单项规则(如果表单项没有指定规则,则使用全局规则,如果表单项指定规则,则使用表单项规则)*/
|
|
13
|
+
rules?: Record<PropertyKey, RuleItem[]>;
|
|
14
|
+
/**表单初始值*/
|
|
15
|
+
formData?: FairysValtioFormInstance<T>['state'];
|
|
16
|
+
/**表单隐藏状态*/
|
|
17
|
+
hideState?: FairysValtioFormInstance<T>['hideState'];
|
|
18
|
+
/**
|
|
19
|
+
* 初始化表单数据类型,默认值为 deepCopy
|
|
20
|
+
* - deepCopy:使用深度拷贝初始化表单数据
|
|
21
|
+
* - immutable:直接使用对象(注意:当传递的不是`valtio`的`proxy`对象时,会使用`valtio`中的`proxy`声明)
|
|
22
|
+
*/
|
|
23
|
+
initFormDataType?: 'deepCopy' | 'immutable';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 表单属性处理
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
*
|
|
31
|
+
* ```tsx
|
|
32
|
+
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function useFairysValtioForm<T extends MObject<T> = object>(props: FairysValtioFormAttrsProps<T>) {
|
|
36
|
+
const { form, rules, formData, hideState, initFormDataType = 'deepCopy', ...rest } = props;
|
|
37
|
+
const formInstance = useFairysValtioFormInstance(form);
|
|
38
|
+
/**表单规则*/
|
|
39
|
+
formInstance.rules = rules;
|
|
40
|
+
/**初始化表单值*/
|
|
41
|
+
useMemo(() => formInstance.ctor({ formData, hideState, initFormDataType }), []);
|
|
42
|
+
return {
|
|
43
|
+
...rest,
|
|
44
|
+
formInstance,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { createContext, useContext, useMemo, useRef } from 'react';
|
|
2
|
+
import { proxy, useSnapshot } from 'valtio';
|
|
3
|
+
import { ViewProps, StyleSheet } from 'react-native';
|
|
4
|
+
import type { FairysValtioFormLayoutContextOptions as _FairysValtioFormLayoutContextOptions } from '@fairys/valtio-form-basic';
|
|
5
|
+
import { layoutStyles } from 'styles/layout';
|
|
6
|
+
|
|
7
|
+
export interface FairysValtioFormLayoutContextOptions
|
|
8
|
+
extends Omit<
|
|
9
|
+
_FairysValtioFormLayoutContextOptions,
|
|
10
|
+
| 'formItemStyle'
|
|
11
|
+
| 'formItemLabelStyle'
|
|
12
|
+
| 'formItemBodyStyle'
|
|
13
|
+
| 'formItemClassName'
|
|
14
|
+
| 'formItemLabelClassName'
|
|
15
|
+
| 'formItemBodyClassName'
|
|
16
|
+
| ''
|
|
17
|
+
> {
|
|
18
|
+
/**表单项 style*/
|
|
19
|
+
formItemStyle?: ViewProps['style'];
|
|
20
|
+
/**表单项 label style*/
|
|
21
|
+
formItemLabelStyle?: ViewProps['style'];
|
|
22
|
+
/**表单项 body style*/
|
|
23
|
+
formItemBodyStyle?: ViewProps['style'];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface FairysValtioFormLayoutAttrsProps extends FairysValtioFormLayoutContextOptions {
|
|
27
|
+
/**
|
|
28
|
+
* @description gap 属性是用来设置网格行与列之间的间隙,该属性是row-gap and column-gap的简写形式。
|
|
29
|
+
*/
|
|
30
|
+
gap?: string | number;
|
|
31
|
+
/**标题*/
|
|
32
|
+
title?: React.ReactNode;
|
|
33
|
+
/**额外内容*/
|
|
34
|
+
extra?: React.ReactNode;
|
|
35
|
+
/**内容*/
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
/**布局样式*/
|
|
38
|
+
style?: ViewProps['style'];
|
|
39
|
+
/**头部样式*/
|
|
40
|
+
headerStyle?: ViewProps['style'];
|
|
41
|
+
headerTextStyle?: ViewProps['style'];
|
|
42
|
+
/**额外内容样式*/
|
|
43
|
+
headerExtraStyle?: ViewProps['style'];
|
|
44
|
+
/**内容样式*/
|
|
45
|
+
bodyStyle?: ViewProps['style'];
|
|
46
|
+
/**是否边框*/
|
|
47
|
+
bordered?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class FairysValtioFormLayoutInstance {
|
|
51
|
+
state = proxy<FairysValtioFormLayoutContextOptions>({
|
|
52
|
+
colCount: 1,
|
|
53
|
+
errorLayout: 'bottom-right',
|
|
54
|
+
labelMode: 'between',
|
|
55
|
+
itemBorderType: 'bottom',
|
|
56
|
+
});
|
|
57
|
+
updated = (options: FairysValtioFormLayoutContextOptions = {}) => {
|
|
58
|
+
const keys = Object.keys(options);
|
|
59
|
+
for (let index = 0; index < keys.length; index++) {
|
|
60
|
+
const key = keys[index];
|
|
61
|
+
this.state[key] = options[key];
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const useFairysValtioFormLayoutInstance = (instance?: FairysValtioFormLayoutInstance) => {
|
|
67
|
+
const ref = useRef<FairysValtioFormLayoutInstance>();
|
|
68
|
+
if (!ref.current) {
|
|
69
|
+
if (instance) {
|
|
70
|
+
ref.current = instance;
|
|
71
|
+
} else {
|
|
72
|
+
ref.current = new FairysValtioFormLayoutInstance();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return ref.current;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const FairysValtioFormLayoutContext = createContext<FairysValtioFormLayoutInstance>(
|
|
79
|
+
new FairysValtioFormLayoutInstance(),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
export const useFairysValtioFormLayoutContext = () => {
|
|
83
|
+
const instance = useContext(FairysValtioFormLayoutContext);
|
|
84
|
+
const state = useSnapshot(instance.state);
|
|
85
|
+
return [state, instance] as const;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 布局属性处理
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
*
|
|
93
|
+
* ```tsx
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
export function useFairysValtioFormLayoutAttrs(props: FairysValtioFormLayoutAttrsProps) {
|
|
99
|
+
const formLayoutInstance = useFairysValtioFormLayoutInstance();
|
|
100
|
+
const [state] = useFairysValtioFormLayoutContext();
|
|
101
|
+
const parent_colCount = state.colCount || 1;
|
|
102
|
+
const parent_errorLayout = state.errorLayout || 'bottom-right';
|
|
103
|
+
const parent_labelMode = state.labelMode || 'between';
|
|
104
|
+
const parent_formItemStyle = state.formItemStyle;
|
|
105
|
+
const parent_formItemLabelStyle = state.formItemLabelStyle;
|
|
106
|
+
const parent_formItemBodyStyle = state.formItemBodyStyle;
|
|
107
|
+
const parent_borderedType = state.itemBorderType || 'bottom';
|
|
108
|
+
const parent_itemBorderColor = state.itemBorderColor;
|
|
109
|
+
const parent_isInvalidBorderRed = state.isInvalidBorderRed;
|
|
110
|
+
const parent_isInvalidTextRed = state.isInvalidTextRed;
|
|
111
|
+
const parent_showColon = state.showColon;
|
|
112
|
+
|
|
113
|
+
const {
|
|
114
|
+
colCount = parent_colCount,
|
|
115
|
+
errorLayout = parent_errorLayout,
|
|
116
|
+
labelMode = parent_labelMode,
|
|
117
|
+
formItemStyle = parent_formItemStyle,
|
|
118
|
+
formItemLabelStyle = parent_formItemLabelStyle,
|
|
119
|
+
formItemBodyStyle = parent_formItemBodyStyle,
|
|
120
|
+
itemBorderType = parent_borderedType,
|
|
121
|
+
itemBorderColor = parent_itemBorderColor,
|
|
122
|
+
isInvalidBorderRed = parent_isInvalidBorderRed,
|
|
123
|
+
isInvalidTextRed = parent_isInvalidTextRed,
|
|
124
|
+
showColon = parent_showColon,
|
|
125
|
+
gap,
|
|
126
|
+
style,
|
|
127
|
+
headerStyle,
|
|
128
|
+
headerTextStyle,
|
|
129
|
+
headerExtraStyle,
|
|
130
|
+
bodyStyle,
|
|
131
|
+
bordered,
|
|
132
|
+
} = props;
|
|
133
|
+
|
|
134
|
+
useMemo(
|
|
135
|
+
() =>
|
|
136
|
+
formLayoutInstance.updated({
|
|
137
|
+
colCount,
|
|
138
|
+
errorLayout,
|
|
139
|
+
labelMode,
|
|
140
|
+
formItemStyle,
|
|
141
|
+
formItemLabelStyle,
|
|
142
|
+
formItemBodyStyle,
|
|
143
|
+
itemBorderType,
|
|
144
|
+
itemBorderColor,
|
|
145
|
+
isInvalidBorderRed,
|
|
146
|
+
isInvalidTextRed,
|
|
147
|
+
showColon,
|
|
148
|
+
} as FairysValtioFormLayoutContextOptions),
|
|
149
|
+
[
|
|
150
|
+
colCount,
|
|
151
|
+
errorLayout,
|
|
152
|
+
labelMode,
|
|
153
|
+
formItemStyle,
|
|
154
|
+
formItemLabelStyle,
|
|
155
|
+
formItemBodyStyle,
|
|
156
|
+
itemBorderType,
|
|
157
|
+
itemBorderColor,
|
|
158
|
+
isInvalidBorderRed,
|
|
159
|
+
isInvalidTextRed,
|
|
160
|
+
showColon,
|
|
161
|
+
],
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const _layoutStyle = useMemo(
|
|
165
|
+
() => [
|
|
166
|
+
StyleSheet.flatten([
|
|
167
|
+
layoutStyles['fairys-valtio-form-layout'],
|
|
168
|
+
bordered && layoutStyles['fairys-valtio-form-layout.bordered'],
|
|
169
|
+
style,
|
|
170
|
+
]),
|
|
171
|
+
],
|
|
172
|
+
[bordered, style],
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
const _headerStyle = useMemo(
|
|
176
|
+
() => [StyleSheet.flatten([layoutStyles['fairys-valtio-form-layout-header'], headerStyle])],
|
|
177
|
+
[headerStyle],
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const _headerTitleStyle = useMemo(
|
|
181
|
+
() => [StyleSheet.flatten([layoutStyles['fairys-valtio-form-layout-header-title'], headerTextStyle])],
|
|
182
|
+
[headerTextStyle],
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const _headerExtraStyle = useMemo(
|
|
186
|
+
() => [StyleSheet.flatten([layoutStyles['fairys-valtio-form-layout-header-extra'], headerExtraStyle])],
|
|
187
|
+
[headerExtraStyle],
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const _bodyStyle = useMemo(
|
|
191
|
+
() => [StyleSheet.flatten([layoutStyles['fairys-valtio-form-layout-body'], bodyStyle])],
|
|
192
|
+
[bodyStyle],
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
const styleBase = useMemo(() => {
|
|
196
|
+
const css: ViewProps['style'] = {};
|
|
197
|
+
if (typeof gap === 'string') {
|
|
198
|
+
css.gap = Number(gap);
|
|
199
|
+
}
|
|
200
|
+
if (typeof gap === 'number') {
|
|
201
|
+
css.gap = gap;
|
|
202
|
+
}
|
|
203
|
+
return css;
|
|
204
|
+
}, [colCount, gap]);
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
colCount,
|
|
208
|
+
errorLayout,
|
|
209
|
+
labelMode,
|
|
210
|
+
itemBorderType,
|
|
211
|
+
formLayoutInstance,
|
|
212
|
+
//======================
|
|
213
|
+
layoutStyle: _layoutStyle,
|
|
214
|
+
//======================
|
|
215
|
+
headerStyle: _headerStyle,
|
|
216
|
+
headerTitleStyle: _headerTitleStyle,
|
|
217
|
+
headerExtraStyle: _headerExtraStyle,
|
|
218
|
+
//======================
|
|
219
|
+
bodyStyle: StyleSheet.flatten([styleBase, _bodyStyle]),
|
|
220
|
+
} as FairysValtioFormLayoutAttrsReturn;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface FairysValtioFormLayoutAttrsReturn {
|
|
224
|
+
/**列数*/
|
|
225
|
+
colCount: number;
|
|
226
|
+
/**规则校验失败错误提示位置*/
|
|
227
|
+
errorLayout: string;
|
|
228
|
+
/**
|
|
229
|
+
* label显示模式
|
|
230
|
+
* @platform RN 支持 between
|
|
231
|
+
*/
|
|
232
|
+
labelMode: string;
|
|
233
|
+
/**
|
|
234
|
+
* 底部边框类型
|
|
235
|
+
*/
|
|
236
|
+
itemBorderType: string;
|
|
237
|
+
/**表单布局实例*/
|
|
238
|
+
formLayoutInstance: FairysValtioFormLayoutInstance;
|
|
239
|
+
/**布局样式*/
|
|
240
|
+
layoutStyle: ViewProps['style'];
|
|
241
|
+
/**头部样式*/
|
|
242
|
+
headerStyle: ViewProps['style'];
|
|
243
|
+
/**头部标题样式*/
|
|
244
|
+
headerTitleStyle: ViewProps['style'];
|
|
245
|
+
/**头部额外内容样式*/
|
|
246
|
+
headerExtraStyle: ViewProps['style'];
|
|
247
|
+
/**内容样式*/
|
|
248
|
+
bodyStyle: ViewProps['style'];
|
|
249
|
+
}
|
package/src/index.tsx
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/src/layout.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Fragment } from 'react';
|
|
2
|
+
import { View, Text } from 'react-native';
|
|
3
|
+
import type { FairysValtioFormLayoutAttrsProps } from 'hooks/layout';
|
|
4
|
+
import { FairysValtioFormLayoutContext, useFairysValtioFormLayoutAttrs } from 'hooks/layout';
|
|
5
|
+
|
|
6
|
+
export interface FairysRNValtioFormLayoutProps extends FairysValtioFormLayoutAttrsProps {}
|
|
7
|
+
|
|
8
|
+
export function FairysRNValtioFormLayout(props: FairysRNValtioFormLayoutProps) {
|
|
9
|
+
const { children, title, extra } = props;
|
|
10
|
+
const { formLayoutInstance, layoutStyle, headerStyle, bodyStyle, headerTitleStyle, headerExtraStyle } =
|
|
11
|
+
useFairysValtioFormLayoutAttrs(props);
|
|
12
|
+
return (
|
|
13
|
+
<FairysValtioFormLayoutContext.Provider value={formLayoutInstance}>
|
|
14
|
+
<View style={layoutStyle}>
|
|
15
|
+
{title || extra ? (
|
|
16
|
+
<View style={headerStyle}>
|
|
17
|
+
<View>
|
|
18
|
+
<Text style={headerTitleStyle}>{title}</Text>
|
|
19
|
+
</View>
|
|
20
|
+
<View>
|
|
21
|
+
<Text style={headerExtraStyle}>{extra}</Text>
|
|
22
|
+
</View>
|
|
23
|
+
</View>
|
|
24
|
+
) : (
|
|
25
|
+
<Fragment />
|
|
26
|
+
)}
|
|
27
|
+
<View style={bodyStyle}>{children}</View>
|
|
28
|
+
</View>
|
|
29
|
+
</FairysValtioFormLayoutContext.Provider>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const formItemStyles = StyleSheet.create({
|
|
4
|
+
'fairys-valtio-form-item': {
|
|
5
|
+
padding: 4,
|
|
6
|
+
fontSize: 12,
|
|
7
|
+
position: 'relative',
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flexDirection: 'column',
|
|
10
|
+
},
|
|
11
|
+
'fairys-valtio-form-item.border-bottom': {
|
|
12
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
13
|
+
borderBottomColor: '#d1d5db',
|
|
14
|
+
},
|
|
15
|
+
'fairys-valtio-form-item.border-bottom.red': {
|
|
16
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
17
|
+
borderBottomColor: 'red',
|
|
18
|
+
},
|
|
19
|
+
'fairys-valtio-form-item-container': {
|
|
20
|
+
flex: 1,
|
|
21
|
+
height: '100%',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
},
|
|
24
|
+
'fairys-valtio-form-item-container.between': {
|
|
25
|
+
flexDirection: 'row',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'space-between',
|
|
28
|
+
gap: 8,
|
|
29
|
+
},
|
|
30
|
+
'fairys-valtio-form-item-container.top': {
|
|
31
|
+
flexDirection: 'column',
|
|
32
|
+
gap: 4,
|
|
33
|
+
},
|
|
34
|
+
'fairys-valtio-form-item-container.left': {
|
|
35
|
+
flexDirection: 'row',
|
|
36
|
+
gap: 8,
|
|
37
|
+
},
|
|
38
|
+
'fairys-valtio-form-item-label': {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
position: 'relative',
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
justifyContent: 'flex-start',
|
|
44
|
+
},
|
|
45
|
+
'fairys-valtio-form-item-label.left': {
|
|
46
|
+
justifyContent: 'flex-end',
|
|
47
|
+
},
|
|
48
|
+
'fairys-valtio-form-item-label.required': {
|
|
49
|
+
color: 'red',
|
|
50
|
+
marginEnd: 4,
|
|
51
|
+
},
|
|
52
|
+
'fairys-valtio-form-item-label.show-colon': {
|
|
53
|
+
textAlign: 'center',
|
|
54
|
+
marginHorizontal: 2,
|
|
55
|
+
fontSize: 12,
|
|
56
|
+
},
|
|
57
|
+
'fairys-valtio-form-item-label.show-colon.red': {
|
|
58
|
+
color: 'red',
|
|
59
|
+
},
|
|
60
|
+
'fairys-valtio-form-item-label-text': {
|
|
61
|
+
fontSize: 12,
|
|
62
|
+
color: '#1f2937',
|
|
63
|
+
},
|
|
64
|
+
'fairys-valtio-form-item-label-text.red': {
|
|
65
|
+
color: 'red',
|
|
66
|
+
},
|
|
67
|
+
'fairys-valtio-form-item-body': {
|
|
68
|
+
position: 'relative',
|
|
69
|
+
flex: 1,
|
|
70
|
+
display: 'flex',
|
|
71
|
+
},
|
|
72
|
+
'fairys-valtio-form-item-body.left': {
|
|
73
|
+
flexDirection: 'row',
|
|
74
|
+
justifyContent: 'flex-start',
|
|
75
|
+
},
|
|
76
|
+
'fairys-valtio-form-item-body.top': {
|
|
77
|
+
flexDirection: 'row',
|
|
78
|
+
justifyContent: 'flex-end',
|
|
79
|
+
},
|
|
80
|
+
'fairys-valtio-form-item-body.between': {
|
|
81
|
+
flexDirection: 'row',
|
|
82
|
+
justifyContent: 'flex-end',
|
|
83
|
+
},
|
|
84
|
+
'fairys-valtio-form-item-body.border-bottom': {
|
|
85
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
86
|
+
borderBottomColor: '#d1d5db',
|
|
87
|
+
},
|
|
88
|
+
'fairys-valtio-form-item-body.border-bottom.red': {
|
|
89
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
90
|
+
borderBottomColor: 'red',
|
|
91
|
+
},
|
|
92
|
+
'fairys-valtio-form-item-body-input': {
|
|
93
|
+
minHeight: 32,
|
|
94
|
+
display: 'flex',
|
|
95
|
+
flexDirection: 'row',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
flex: 1,
|
|
98
|
+
},
|
|
99
|
+
'fairys-valtio-form-item-body-input.between': {
|
|
100
|
+
justifyContent: 'flex-end',
|
|
101
|
+
textAlign: 'right',
|
|
102
|
+
},
|
|
103
|
+
'fairys-valtio-form-item-body-input.not.between': {
|
|
104
|
+
justifyContent: 'flex-start',
|
|
105
|
+
textAlign: 'left',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
},
|
|
108
|
+
'fairys-valtio-form-item-body-extra': {
|
|
109
|
+
display: 'flex',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
justifyContent: 'center',
|
|
112
|
+
},
|
|
113
|
+
'fairys-valtio-form-item-body-extra-text': {
|
|
114
|
+
fontSize: 12,
|
|
115
|
+
},
|
|
116
|
+
'fairys-valtio-form-item-help': {
|
|
117
|
+
fontSize: 10,
|
|
118
|
+
width: '100%',
|
|
119
|
+
},
|
|
120
|
+
'fairys-valtio-form-item-body-error': {
|
|
121
|
+
width: '100%',
|
|
122
|
+
display: 'flex',
|
|
123
|
+
flexDirection: 'row',
|
|
124
|
+
color: 'red',
|
|
125
|
+
position: 'absolute',
|
|
126
|
+
fontSize: 10,
|
|
127
|
+
zIndex: 10,
|
|
128
|
+
},
|
|
129
|
+
'fairys-valtio-form-item-body-error-text': {
|
|
130
|
+
color: 'red',
|
|
131
|
+
fontSize: 10,
|
|
132
|
+
},
|
|
133
|
+
'fairys-valtio-form-item-body-error.bottom-left': {
|
|
134
|
+
bottom: -14,
|
|
135
|
+
left: 0,
|
|
136
|
+
justifyContent: 'flex-start',
|
|
137
|
+
},
|
|
138
|
+
'fairys-valtio-form-item-body-error.bottom-right': {
|
|
139
|
+
bottom: -14,
|
|
140
|
+
right: 0,
|
|
141
|
+
justifyContent: 'flex-end',
|
|
142
|
+
},
|
|
143
|
+
'fairys-valtio-form-item-body-error.top-right': {
|
|
144
|
+
top: -4,
|
|
145
|
+
right: 0,
|
|
146
|
+
justifyContent: 'flex-end',
|
|
147
|
+
},
|
|
148
|
+
'fairys-valtio-form-item-body-error.top-left': {
|
|
149
|
+
top: -4,
|
|
150
|
+
left: 0,
|
|
151
|
+
justifyContent: 'flex-start',
|
|
152
|
+
},
|
|
153
|
+
'fairys-valtio-form-item-body-error.left-border-top': {
|
|
154
|
+
left: 0,
|
|
155
|
+
bottom: -2,
|
|
156
|
+
justifyContent: 'flex-start',
|
|
157
|
+
},
|
|
158
|
+
'fairys-valtio-form-item-body-error.right-border-top': {
|
|
159
|
+
right: 0,
|
|
160
|
+
bottom: -2,
|
|
161
|
+
justifyContent: 'flex-end',
|
|
162
|
+
},
|
|
163
|
+
'input.between': {
|
|
164
|
+
textAlign: 'right',
|
|
165
|
+
},
|
|
166
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const layoutStyles = StyleSheet.create({
|
|
4
|
+
'fairys-valtio-form-layout': {
|
|
5
|
+
fontSize: 12,
|
|
6
|
+
width: '100%',
|
|
7
|
+
borderRadius: 8,
|
|
8
|
+
},
|
|
9
|
+
'fairys-valtio-form-layout.bordered': {
|
|
10
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
11
|
+
borderColor: '#d1d5db',
|
|
12
|
+
},
|
|
13
|
+
'fairys-valtio-form-layout-header': {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
justifyContent: 'space-between',
|
|
18
|
+
paddingVertical: 10,
|
|
19
|
+
paddingHorizontal: 8,
|
|
20
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
21
|
+
borderBottomColor: '#d1d5db',
|
|
22
|
+
},
|
|
23
|
+
'fairys-valtio-form-layout-header-title': {
|
|
24
|
+
fontSize: 14,
|
|
25
|
+
fontWeight: 'bold',
|
|
26
|
+
},
|
|
27
|
+
'fairys-valtio-form-layout-header-extra': {
|
|
28
|
+
fontSize: 12,
|
|
29
|
+
},
|
|
30
|
+
'fairys-valtio-form-layout-body': {
|
|
31
|
+
paddingHorizontal: 8,
|
|
32
|
+
width: '100%',
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
flexWrap: 'wrap',
|
|
36
|
+
gap: 2,
|
|
37
|
+
},
|
|
38
|
+
});
|