@hitesh0009/react-native-basic-form 1.1.10 → 1.2.0
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/dist/Form.js +19 -2
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
- package/src/Form.tsx +33 -1
- package/src/types.ts +6 -0
package/dist/Form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FlatList, Image, StyleSheet, Text, TextInput, TouchableOpacity, View, } from "react-native";
|
|
2
|
-
export const Form = ({ data, gap_bwt_keyValue = 10, gap_bwt_keys = 12, lableStyle, inputTextStyle, buttonContainerStyle, buttonTextStyle, headerIcon, headerIconStyle, headerTextStyle, imageProps, flatlistProps, textInputProps, textProp, headerText, headerContainerStyle, containerStyle, imageContainerStyle, touchableOpacityProp, inputTextContainerStyle, inputTextGroupContainerStyle, ButtonContainerStyle, buttonGroupContainerStyle, buttonGroupStyle, }) => {
|
|
2
|
+
export const Form = ({ data, gap_bwt_keyValue = 10, gap_bwt_keys = 12, lableStyle, inputTextStyle, buttonContainerStyle, buttonTextStyle, headerIcon, headerIconStyle, headerTextStyle, imageProps, flatlistProps, textInputProps, textProp, headerText, headerContainerStyle, containerStyle, imageContainerStyle, touchableOpacityProp, inputTextContainerStyle, inputTextGroupContainerStyle, ButtonContainerStyle, buttonGroupContainerStyle, buttonGroupStyle, inputButtonGroupContainerStyle }) => {
|
|
3
3
|
return (<View style={[{ gap: 20 }, containerStyle]}>
|
|
4
4
|
{(headerIcon || headerText) && (<View style={[{ flexDirection: "row", gap: 10 }, headerContainerStyle]}>
|
|
5
5
|
{headerIcon && (<View style={imageContainerStyle}>
|
|
@@ -10,7 +10,7 @@ export const Form = ({ data, gap_bwt_keyValue = 10, gap_bwt_keys = 12, lableStyl
|
|
|
10
10
|
</Text>)}
|
|
11
11
|
</View>)}
|
|
12
12
|
|
|
13
|
-
<FlatList
|
|
13
|
+
<FlatList data={data} {...flatlistProps} ItemSeparatorComponent={() => <View style={{ height: gap_bwt_keys }}/>} renderItem={({ item }) => (<View style={{ gap: gap_bwt_keyValue }}>
|
|
14
14
|
{item.label && (<Text style={[styles.lable, lableStyle]}>{item.label}</Text>)}
|
|
15
15
|
|
|
16
16
|
{item.input && (<View style={inputTextContainerStyle}>
|
|
@@ -40,6 +40,23 @@ export const Form = ({ data, gap_bwt_keyValue = 10, gap_bwt_keys = 12, lableStyl
|
|
|
40
40
|
</Text>
|
|
41
41
|
</TouchableOpacity>))}
|
|
42
42
|
</View>)}
|
|
43
|
+
|
|
44
|
+
{item.inputButtonGroup && (<View style={[
|
|
45
|
+
{ flexDirection: "row", gap: 10 },
|
|
46
|
+
inputButtonGroupContainerStyle,
|
|
47
|
+
]}>
|
|
48
|
+
<View style={inputTextContainerStyle}>
|
|
49
|
+
<TextInput {...textInputProps} style={[styles.inputtext, inputTextStyle]} placeholder={item.inputButtonGroup.input.placeholder} value={item.inputButtonGroup.input.value} onChangeText={item.inputButtonGroup.input.onChangeText} keyboardType={item.inputButtonGroup.input.keyboardType}/>
|
|
50
|
+
</View>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<TouchableOpacity onPress={item.inputButtonGroup.button.onPress} style={[styles.button_container, buttonGroupStyle]}>
|
|
54
|
+
<Text style={[styles.button_text, buttonTextStyle]}>
|
|
55
|
+
{item.inputButtonGroup.button.label}
|
|
56
|
+
</Text>
|
|
57
|
+
</TouchableOpacity>
|
|
58
|
+
|
|
59
|
+
</View>)}
|
|
43
60
|
</View>)}/>
|
|
44
61
|
</View>);
|
|
45
62
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export type FormButton = {
|
|
|
11
11
|
label: string;
|
|
12
12
|
onPress: () => void;
|
|
13
13
|
};
|
|
14
|
+
export type ForminputButtonGroup = {
|
|
15
|
+
input: FormInput;
|
|
16
|
+
button: FormButton;
|
|
17
|
+
};
|
|
14
18
|
export type FormItem = {
|
|
15
19
|
id: string;
|
|
16
20
|
label?: string;
|
|
@@ -18,6 +22,7 @@ export type FormItem = {
|
|
|
18
22
|
button?: FormButton;
|
|
19
23
|
buttonGroup?: FormButton[];
|
|
20
24
|
inputTextGroup?: FormInput[];
|
|
25
|
+
inputButtonGroup?: ForminputButtonGroup;
|
|
21
26
|
};
|
|
22
27
|
export type FormProps = {
|
|
23
28
|
data: FormItem[];
|
|
@@ -45,4 +50,5 @@ export type FormProps = {
|
|
|
45
50
|
buttonGroupContainerStyle?: ViewStyle;
|
|
46
51
|
buttonGroupStyle?: ViewStyle;
|
|
47
52
|
inputTextGroupContainerStyle?: ViewStyle;
|
|
53
|
+
inputButtonGroupContainerStyle?: ViewStyle;
|
|
48
54
|
};
|
package/package.json
CHANGED
package/src/Form.tsx
CHANGED
|
@@ -39,6 +39,8 @@ export const Form: React.FC<FormProps> = ({
|
|
|
39
39
|
|
|
40
40
|
buttonGroupContainerStyle,
|
|
41
41
|
buttonGroupStyle,
|
|
42
|
+
|
|
43
|
+
inputButtonGroupContainerStyle
|
|
42
44
|
}) => {
|
|
43
45
|
return (
|
|
44
46
|
<View style={[{ gap: 20 }, containerStyle]}>
|
|
@@ -62,7 +64,6 @@ export const Form: React.FC<FormProps> = ({
|
|
|
62
64
|
)}
|
|
63
65
|
|
|
64
66
|
<FlatList<FormItem>
|
|
65
|
-
keyExtractor={(item,index) => item.id ?? index}
|
|
66
67
|
data={data}
|
|
67
68
|
{...flatlistProps}
|
|
68
69
|
ItemSeparatorComponent={() => <View style={{ height: gap_bwt_keys }} />}
|
|
@@ -133,6 +134,37 @@ export const Form: React.FC<FormProps> = ({
|
|
|
133
134
|
))}
|
|
134
135
|
</View>
|
|
135
136
|
)}
|
|
137
|
+
|
|
138
|
+
{item.inputButtonGroup && (
|
|
139
|
+
<View
|
|
140
|
+
style={[
|
|
141
|
+
{ flexDirection: "row", gap: 10 },
|
|
142
|
+
inputButtonGroupContainerStyle,
|
|
143
|
+
]}
|
|
144
|
+
>
|
|
145
|
+
<View style={inputTextContainerStyle}>
|
|
146
|
+
<TextInput
|
|
147
|
+
{...textInputProps}
|
|
148
|
+
style={[styles.inputtext, inputTextStyle]}
|
|
149
|
+
placeholder={item.inputButtonGroup.input.placeholder}
|
|
150
|
+
value={item.inputButtonGroup.input.value}
|
|
151
|
+
onChangeText={item.inputButtonGroup.input.onChangeText}
|
|
152
|
+
keyboardType={item.inputButtonGroup.input.keyboardType}
|
|
153
|
+
/>
|
|
154
|
+
</View>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
<TouchableOpacity
|
|
158
|
+
onPress={item.inputButtonGroup.button.onPress}
|
|
159
|
+
style={[styles.button_container, buttonGroupStyle]}
|
|
160
|
+
>
|
|
161
|
+
<Text style={[styles.button_text, buttonTextStyle]}>
|
|
162
|
+
{item.inputButtonGroup.button.label}
|
|
163
|
+
</Text>
|
|
164
|
+
</TouchableOpacity>
|
|
165
|
+
|
|
166
|
+
</View>
|
|
167
|
+
)}
|
|
136
168
|
</View>
|
|
137
169
|
)}
|
|
138
170
|
/>
|
package/src/types.ts
CHANGED
|
@@ -24,6 +24,10 @@ export type FormButton = {
|
|
|
24
24
|
label: string;
|
|
25
25
|
onPress: () => void;
|
|
26
26
|
};
|
|
27
|
+
export type ForminputButtonGroup = {
|
|
28
|
+
input:FormInput
|
|
29
|
+
button:FormButton
|
|
30
|
+
};
|
|
27
31
|
|
|
28
32
|
export type FormItem = {
|
|
29
33
|
id: string;
|
|
@@ -32,6 +36,7 @@ export type FormItem = {
|
|
|
32
36
|
button?: FormButton;
|
|
33
37
|
buttonGroup?: FormButton[];
|
|
34
38
|
inputTextGroup?: FormInput[];
|
|
39
|
+
inputButtonGroup?:ForminputButtonGroup
|
|
35
40
|
};
|
|
36
41
|
|
|
37
42
|
export type FormProps = {
|
|
@@ -65,4 +70,5 @@ export type FormProps = {
|
|
|
65
70
|
buttonGroupContainerStyle?: ViewStyle;
|
|
66
71
|
buttonGroupStyle?: ViewStyle;
|
|
67
72
|
inputTextGroupContainerStyle?:ViewStyle
|
|
73
|
+
inputButtonGroupContainerStyle?:ViewStyle
|
|
68
74
|
};
|