@hitesh0009/react-native-basic-form 1.1.0 → 1.1.2

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 ADDED
@@ -0,0 +1,2 @@
1
+ import type { FormProps } from "./types";
2
+ export declare const Form: React.FC<FormProps>;
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", scrollEnabled = true, showsHorizontalScrollIndicator = true }) => {
3
+ return (<View>
4
+ <FlatList scrollEnabled={scrollEnabled} showsHorizontalScrollIndicator={showsHorizontalScrollIndicator} 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
+ });
@@ -0,0 +1,2 @@
1
+ export { Form } from './Form';
2
+ export { FormProps, FormItem, FormInput, FormButton } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { Form } from './Form';
@@ -0,0 +1,30 @@
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
+ scrollEnabled?: boolean;
27
+ showsHorizontalScrollIndicator?: boolean;
28
+ multiline_input?: boolean;
29
+ textAlignVertical_input?: "top" | "center" | "bottom" | "auto" | undefined;
30
+ };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitesh0009/react-native-basic-form",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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",
@@ -22,15 +22,22 @@
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/hiteshjangir0009/react-native-basic-form.git"
24
24
  },
25
- "license": "ISC",
25
+ "license": "MIT",
26
26
  "author": "Hitesh Jangir",
27
27
  "type": "module",
28
- "main": "index.js",
28
+ "main": "dist/index.js",
29
+ "types": "dist/index.d.ts",
29
30
  "scripts": {
30
- "test": "echo \"Error: no test specified\" && exit 1"
31
+ "build": "tsc",
32
+ "prepublishOnly": "npm run build"
31
33
  },
32
34
  "peerDependencies": {
33
- "react": "19.1.1",
34
- "react-native": "0.82.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"
35
42
  }
36
- }
43
+ }
@@ -6,58 +6,56 @@ import {
6
6
  TouchableOpacity,
7
7
  View,
8
8
  } from "react-native";
9
- import React from "react";
9
+ import type { FormProps, FormItem } from "./types";
10
10
 
11
- const Form = ({
12
- data = [
13
- {
14
- lable: "",
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",
22
+ scrollEnabled= true,
23
+ showsHorizontalScrollIndicator= true
24
+
28
25
  }) => {
29
26
  return (
30
27
  <View>
31
- <FlatList
28
+ <FlatList<FormItem>
29
+ scrollEnabled={scrollEnabled}
30
+ showsHorizontalScrollIndicator={showsHorizontalScrollIndicator}
32
31
  data={data}
33
- keyExtractor={(_, index) => index.toString()}
34
- ItemSeparatorComponent={() => (
35
- <View style={{ height: gap_bwt_keys || 12 }} />
36
- )}
37
- renderItem={({ item, index }) => (
38
- <View style={{ gap: gap_bwt_keyValue || 10 }}>
39
- {item.lable && (
40
- <Text style={[styles.lable, lable_style]}>{item.lable}</Text>
32
+ keyExtractor={(item) => item.id}
33
+ ItemSeparatorComponent={() => <View style={{ height: gap_bwt_keys }} />}
34
+ renderItem={({ item }) => (
35
+ <View style={{ gap: gap_bwt_keyValue }}>
36
+ {item.label && (
37
+ <Text style={[styles.lable, lable_style]}>{item.label}</Text>
41
38
  )}
42
39
 
43
- {item.inputtext && (
40
+ {item.input && (
44
41
  <TextInput
45
42
  style={[styles.inputtext, inputtext_style]}
46
- placeholderTextColor={placeholderTextColor || "#999"}
47
- placeholder={item.inputtext.placeholder}
48
- multiline={multiline_input || false}
49
- textAlignVertical={textAlignVertical_input || "center"}
50
- value={item.inputtext.value}
51
- onChangeText={(val) => item.inputtext.onchangetext(val)}
43
+ placeholder={item.input.placeholder}
44
+ placeholderTextColor={placeholderTextColor}
45
+ multiline={multiline_input}
46
+ textAlignVertical={textAlignVertical_input}
47
+ value={item.input.value}
48
+ onChangeText={item.input.onChangeText}
52
49
  />
53
50
  )}
51
+
54
52
  {item.button && (
55
53
  <TouchableOpacity
56
54
  onPress={item.button.onPress}
57
55
  style={[styles.button_container, button_container_style]}
58
56
  >
59
57
  <Text style={[styles.button_text, buttontext_style]}>
60
- {item.button.lable}
58
+ {item.button.label}
61
59
  </Text>
62
60
  </TouchableOpacity>
63
61
  )}
@@ -68,8 +66,6 @@ const Form = ({
68
66
  );
69
67
  };
70
68
 
71
- export default Form;
72
-
73
69
  const styles = StyleSheet.create({
74
70
  lable: {
75
71
  color: "#000",
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+
2
+ export { Form } from './Form';
3
+ export { FormProps, FormItem, FormInput, FormButton } from './types.js';
package/src/types.ts ADDED
@@ -0,0 +1,39 @@
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
+ scrollEnabled?: boolean;
35
+ showsHorizontalScrollIndicator?: boolean;
36
+
37
+ multiline_input?: boolean;
38
+ textAlignVertical_input?: "top" | "center" | "bottom" | "auto" | undefined;
39
+ };
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
@@ -1,3 +0,0 @@
1
- import Form from "./src/Form";
2
-
3
- export const basic_form = Form;