@hitesh0009/react-native-basic-form 1.0.0 → 1.1.1
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.d.ts +2 -0
- package/dist/Form.js +35 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.js +1 -0
- package/package.json +23 -7
- package/src/{Form.js → Form.tsx} +24 -33
- package/src/index.ts +3 -0
- package/src/types.ts +36 -0
- package/tsconfig.json +26 -0
- package/index.js +0 -3
package/dist/Form.d.ts
ADDED
package/dist/Form.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FlatList, StyleSheet, Text, TextInput, TouchableOpacity, View, } from "react-native";
|
|
2
|
+
export const Form = ({ data, gap_bwt_keyValue = 10, gap_bwt_keys = 12, lable_style, inputtext_style, button_container_style, buttontext_style, placeholderTextColor = "#999", multiline_input = false, textAlignVertical_input = "center", }) => {
|
|
3
|
+
return (<View>
|
|
4
|
+
<FlatList data={data} keyExtractor={(item) => item.id} ItemSeparatorComponent={() => <View style={{ height: gap_bwt_keys }}/>} renderItem={({ item }) => (<View style={{ gap: gap_bwt_keyValue }}>
|
|
5
|
+
{item.label && (<Text style={[styles.lable, lable_style]}>{item.label}</Text>)}
|
|
6
|
+
|
|
7
|
+
{item.input && (<TextInput style={[styles.inputtext, inputtext_style]} placeholder={item.input.placeholder} placeholderTextColor={placeholderTextColor} multiline={multiline_input} textAlignVertical={textAlignVertical_input} value={item.input.value} onChangeText={item.input.onChangeText}/>)}
|
|
8
|
+
|
|
9
|
+
{item.button && (<TouchableOpacity onPress={item.button.onPress} style={[styles.button_container, button_container_style]}>
|
|
10
|
+
<Text style={[styles.button_text, buttontext_style]}>
|
|
11
|
+
{item.button.label}
|
|
12
|
+
</Text>
|
|
13
|
+
</TouchableOpacity>)}
|
|
14
|
+
</View>)}/>
|
|
15
|
+
</View>);
|
|
16
|
+
};
|
|
17
|
+
const styles = StyleSheet.create({
|
|
18
|
+
lable: {
|
|
19
|
+
color: "#000",
|
|
20
|
+
fontSize: 14,
|
|
21
|
+
},
|
|
22
|
+
inputtext: {
|
|
23
|
+
color: "#000",
|
|
24
|
+
fontSize: 12,
|
|
25
|
+
borderWidth: 1,
|
|
26
|
+
borderColor: "#b1b0b0",
|
|
27
|
+
borderRadius: 10,
|
|
28
|
+
padding: 10,
|
|
29
|
+
},
|
|
30
|
+
button_container: {},
|
|
31
|
+
button_text: {
|
|
32
|
+
color: "#000",
|
|
33
|
+
fontSize: 14,
|
|
34
|
+
},
|
|
35
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Form } from './Form';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
export type FormInput = {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
value: string;
|
|
5
|
+
onChangeText: (text: string) => void;
|
|
6
|
+
};
|
|
7
|
+
export type FormButton = {
|
|
8
|
+
label: string;
|
|
9
|
+
onPress: () => void;
|
|
10
|
+
};
|
|
11
|
+
export type FormItem = {
|
|
12
|
+
id: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
input?: FormInput;
|
|
15
|
+
button?: FormButton;
|
|
16
|
+
};
|
|
17
|
+
export type FormProps = {
|
|
18
|
+
data: FormItem[];
|
|
19
|
+
gap_bwt_keyValue?: number;
|
|
20
|
+
gap_bwt_keys?: number;
|
|
21
|
+
lable_style?: TextStyle;
|
|
22
|
+
inputtext_style?: TextStyle;
|
|
23
|
+
button_container_style?: ViewStyle;
|
|
24
|
+
buttontext_style?: TextStyle;
|
|
25
|
+
placeholderTextColor?: string;
|
|
26
|
+
multiline_input?: boolean;
|
|
27
|
+
textAlignVertical_input?: "top" | "center" | "bottom" | "auto" | undefined;
|
|
28
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitesh0009/react-native-basic-form",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A lightweight, data-driven form renderer for React Native with fully controlled inputs and flexible styling.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
6
|
+
"react-native",
|
|
7
|
+
"react",
|
|
8
|
+
"form",
|
|
9
|
+
"forms",
|
|
10
|
+
"ui",
|
|
11
|
+
"component",
|
|
12
|
+
"controlled",
|
|
13
|
+
"data-driven",
|
|
14
|
+
"flatlist",
|
|
15
|
+
"mobile"
|
|
7
16
|
],
|
|
8
17
|
"homepage": "https://github.com/hiteshjangir0009/react-native-basic-form#readme",
|
|
9
18
|
"bugs": {
|
|
@@ -13,15 +22,22 @@
|
|
|
13
22
|
"type": "git",
|
|
14
23
|
"url": "git+https://github.com/hiteshjangir0009/react-native-basic-form.git"
|
|
15
24
|
},
|
|
16
|
-
"license": "
|
|
25
|
+
"license": "MIT",
|
|
17
26
|
"author": "Hitesh Jangir",
|
|
18
27
|
"type": "module",
|
|
19
|
-
"main": "index.js",
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
20
30
|
"scripts": {
|
|
21
|
-
"
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"prepublishOnly": "npm run build"
|
|
22
33
|
},
|
|
23
34
|
"peerDependencies": {
|
|
24
|
-
"react": "
|
|
25
|
-
"react-native": "0.
|
|
35
|
+
"react": ">=17",
|
|
36
|
+
"react-native": ">=0.70"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/react": "^19.2.10",
|
|
40
|
+
"react-native": "*",
|
|
41
|
+
"typescript": "^5.3.0"
|
|
26
42
|
}
|
|
27
43
|
}
|
package/src/{Form.js → Form.tsx}
RENAMED
|
@@ -6,58 +6,51 @@ import {
|
|
|
6
6
|
TouchableOpacity,
|
|
7
7
|
View,
|
|
8
8
|
} from "react-native";
|
|
9
|
-
import
|
|
9
|
+
import type { FormProps, FormItem } from "./types";
|
|
10
10
|
|
|
11
|
-
const Form = ({
|
|
12
|
-
data
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
inputtext: { placeholder: "", value: "", onchangetext: () => {} },
|
|
16
|
-
button: { lable: "", onPress: () => {} },
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
gap_bwt_keyValue,
|
|
20
|
-
gap_bwt_keys,
|
|
11
|
+
export const Form: React.FC<FormProps> = ({
|
|
12
|
+
data,
|
|
13
|
+
gap_bwt_keyValue = 10,
|
|
14
|
+
gap_bwt_keys = 12,
|
|
21
15
|
lable_style,
|
|
22
16
|
inputtext_style,
|
|
23
17
|
button_container_style,
|
|
24
18
|
buttontext_style,
|
|
25
|
-
placeholderTextColor,
|
|
26
|
-
multiline_input,
|
|
27
|
-
textAlignVertical_input,
|
|
19
|
+
placeholderTextColor = "#999",
|
|
20
|
+
multiline_input = false,
|
|
21
|
+
textAlignVertical_input = "center",
|
|
28
22
|
}) => {
|
|
29
23
|
return (
|
|
30
24
|
<View>
|
|
31
|
-
<FlatList
|
|
25
|
+
<FlatList<FormItem>
|
|
32
26
|
data={data}
|
|
33
|
-
keyExtractor={(
|
|
34
|
-
ItemSeparatorComponent={() =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{item.lable && (
|
|
40
|
-
<Text style={[styles.lable, lable_style]}>{item.lable}</Text>
|
|
27
|
+
keyExtractor={(item) => item.id}
|
|
28
|
+
ItemSeparatorComponent={() => <View style={{ height: gap_bwt_keys }} />}
|
|
29
|
+
renderItem={({ item }) => (
|
|
30
|
+
<View style={{ gap: gap_bwt_keyValue }}>
|
|
31
|
+
{item.label && (
|
|
32
|
+
<Text style={[styles.lable, lable_style]}>{item.label}</Text>
|
|
41
33
|
)}
|
|
42
34
|
|
|
43
|
-
{item.
|
|
35
|
+
{item.input && (
|
|
44
36
|
<TextInput
|
|
45
37
|
style={[styles.inputtext, inputtext_style]}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
multiline={multiline_input
|
|
49
|
-
textAlignVertical={textAlignVertical_input
|
|
50
|
-
value={item.
|
|
51
|
-
onChangeText={
|
|
38
|
+
placeholder={item.input.placeholder}
|
|
39
|
+
placeholderTextColor={placeholderTextColor}
|
|
40
|
+
multiline={multiline_input}
|
|
41
|
+
textAlignVertical={textAlignVertical_input}
|
|
42
|
+
value={item.input.value}
|
|
43
|
+
onChangeText={item.input.onChangeText}
|
|
52
44
|
/>
|
|
53
45
|
)}
|
|
46
|
+
|
|
54
47
|
{item.button && (
|
|
55
48
|
<TouchableOpacity
|
|
56
49
|
onPress={item.button.onPress}
|
|
57
50
|
style={[styles.button_container, button_container_style]}
|
|
58
51
|
>
|
|
59
52
|
<Text style={[styles.button_text, buttontext_style]}>
|
|
60
|
-
{item.button.
|
|
53
|
+
{item.button.label}
|
|
61
54
|
</Text>
|
|
62
55
|
</TouchableOpacity>
|
|
63
56
|
)}
|
|
@@ -68,8 +61,6 @@ const Form = ({
|
|
|
68
61
|
);
|
|
69
62
|
};
|
|
70
63
|
|
|
71
|
-
export default Form;
|
|
72
|
-
|
|
73
64
|
const styles = StyleSheet.create({
|
|
74
65
|
lable: {
|
|
75
66
|
color: "#000",
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TextStyle, ViewStyle, } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type FormInput = {
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
onChangeText: (text: string) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type FormButton = {
|
|
10
|
+
label: string;
|
|
11
|
+
onPress: () => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type FormItem = {
|
|
15
|
+
id: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
input?: FormInput;
|
|
18
|
+
button?: FormButton;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type FormProps = {
|
|
22
|
+
data: FormItem[];
|
|
23
|
+
|
|
24
|
+
gap_bwt_keyValue?: number;
|
|
25
|
+
gap_bwt_keys?: number;
|
|
26
|
+
|
|
27
|
+
lable_style?: TextStyle;
|
|
28
|
+
inputtext_style?: TextStyle;
|
|
29
|
+
button_container_style?: ViewStyle;
|
|
30
|
+
buttontext_style?: TextStyle;
|
|
31
|
+
|
|
32
|
+
placeholderTextColor?: string;
|
|
33
|
+
|
|
34
|
+
multiline_input?: boolean;
|
|
35
|
+
textAlignVertical_input?: "top" | "center" | "bottom" | "auto" | undefined;
|
|
36
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2019",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"jsx": "react-native",
|
|
6
|
+
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": false,
|
|
12
|
+
"emitDeclarationOnly": false,
|
|
13
|
+
|
|
14
|
+
"strict": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
|
|
17
|
+
"moduleResolution": "node",
|
|
18
|
+
|
|
19
|
+
"lib": ["ES2019"],
|
|
20
|
+
"types": ["react", "react-native"],
|
|
21
|
+
|
|
22
|
+
"esModuleInterop": true,
|
|
23
|
+
"forceConsistentCasingInFileNames": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["src"]
|
|
26
|
+
}
|
package/index.js
DELETED