@hitesh0009/react-native-basic-form 1.3.2 → 1.3.3

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 CHANGED
@@ -6,9 +6,9 @@ export const Form = ({ schema = [] }) => {
6
6
  const RenderField = (field, index) => {
7
7
  switch (field.type) {
8
8
  case "button":
9
- return (<Buttons key={index} label={field.label} style={field.style} textStyle={field.textStyle} spacing={field.spacing} {...(field.buttonProps || {})}/>);
9
+ return (<Buttons key={index} label={field.label} style={field.style} textStyle={field.textStyle} spacing={field.spacing} labelStyle={field.labelStyle} {...(field.buttonProps || {})}/>);
10
10
  case "input":
11
- return (<InputText key={index} label={field.label} style={field.style} spacing={field.spacing} {...(field.inputProps || {})}/>);
11
+ return (<InputText key={index} label={field.label} style={field.style} spacing={field.spacing} labelStyle={field.labelStyle} {...(field.inputProps || {})}/>);
12
12
  default:
13
13
  return null;
14
14
  }
@@ -1,11 +1,11 @@
1
1
  import { Text, TouchableOpacity, View } from "react-native";
2
2
  import React from "react";
3
3
  import FormText from "./Text";
4
- const Buttons = ({ label, buttonText, onPress, style, textStyle, spacing, labelStyle, }) => {
4
+ const Buttons = ({ label, buttonText, onPress, style, textStyle, spacing, labelStyle, ...touchableProps }) => {
5
5
  return (<View style={{ gap: spacing !== null && spacing !== void 0 ? spacing : 13 }}>
6
6
  <FormText label={label || " "} style={labelStyle}/>
7
7
 
8
- <TouchableOpacity onPress={onPress} style={[
8
+ <TouchableOpacity {...touchableProps} onPress={onPress} style={[
9
9
  {
10
10
  backgroundColor: "#2563eb",
11
11
  padding: 14,
@@ -1,18 +1,11 @@
1
1
  import { StyleSheet, TextInput, View } from 'react-native';
2
2
  import React from 'react';
3
3
  import FormText from './Text';
4
- const InputText = ({ label, placeholder, value, onChangeText, style, spacing, labelStyle, }) => {
4
+ const InputText = ({ label, style, spacing = 13, labelStyle, ...textInputProps }) => {
5
5
  return (<View style={{ gap: spacing || 13 }}>
6
6
  <FormText label={label || ' '} style={labelStyle}/>
7
- <TextInput placeholder={placeholder} value={value} onChangeText={onChangeText} style={[
8
- {
9
- borderWidth: 1,
10
- borderColor: '#ccc',
11
- padding: 10,
12
- borderRadius: 6,
13
- },
14
- style,
15
- ]}/>
7
+ <TextInput {...textInputProps} // 👈 forward EVERYTHING
8
+ style={style}/>
16
9
  </View>);
17
10
  };
18
11
  export default InputText;
package/dist/types.d.ts CHANGED
@@ -29,12 +29,11 @@ export type FormProps = {
29
29
  export type ButtonProps = {
30
30
  label?: string;
31
31
  buttonText?: string;
32
- onPress?: TouchableOpacityProps['onPress'];
33
32
  style?: ViewStyle;
34
33
  textStyle?: TextStyle;
35
34
  spacing?: number;
36
35
  labelStyle?: TextStyle;
37
- };
36
+ } & TouchableOpacityProps;
38
37
  export type InputProps = {
39
38
  label?: string;
40
39
  style?: TextInputProps['style'];
@@ -43,7 +42,7 @@ export type InputProps = {
43
42
  placeholder?: TextInputProps['placeholder'];
44
43
  value?: TextInputProps['value'];
45
44
  onChangeText?: TextInputProps['onChangeText'];
46
- };
45
+ } & TextInputProps;
47
46
  export type IconProps = {
48
47
  icon?: ImageProps['source'];
49
48
  style?: ImageStyle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitesh0009/react-native-basic-form",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
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",
package/src/Form.tsx CHANGED
@@ -4,8 +4,8 @@ import InputText from "./components/InputText";
4
4
  import Buttons from "./components/Buttons";
5
5
  import { FormField, FormProps } from "./types";
6
6
 
7
- export const Form:React.FC<FormProps> = ({ schema = [] }) => {
8
- const RenderField = (field:FormField, index:number) => {
7
+ export const Form: React.FC<FormProps> = ({ schema = [] }) => {
8
+ const RenderField = (field: FormField, index: number) => {
9
9
  switch (field.type) {
10
10
  case "button":
11
11
  return (
@@ -15,6 +15,7 @@ export const Form:React.FC<FormProps> = ({ schema = [] }) => {
15
15
  style={field.style}
16
16
  textStyle={field.textStyle}
17
17
  spacing={field.spacing}
18
+ labelStyle={field.labelStyle}
18
19
  {...(field.buttonProps || {})}
19
20
  />
20
21
  );
@@ -26,6 +27,7 @@ export const Form:React.FC<FormProps> = ({ schema = [] }) => {
26
27
  label={field.label}
27
28
  style={field.style}
28
29
  spacing={field.spacing}
30
+ labelStyle={field.labelStyle}
29
31
  {...(field.inputProps || {})}
30
32
  />
31
33
  );
@@ -11,12 +11,14 @@ const Buttons: React.FC<ButtonProps> = ({
11
11
  textStyle,
12
12
  spacing,
13
13
  labelStyle,
14
+ ...touchableProps
14
15
  }) => {
15
16
  return (
16
17
  <View style={{ gap: spacing ?? 13 }}>
17
18
  <FormText label={label || " "} style={labelStyle} />
18
19
 
19
20
  <TouchableOpacity
21
+ {...touchableProps}
20
22
  onPress={onPress}
21
23
  style={[
22
24
  {
@@ -4,30 +4,18 @@ import FormText from './Text';
4
4
  import { InputProps } from '../types';
5
5
 
6
6
  const InputText:React.FC<InputProps> = ({
7
- label,
8
- placeholder,
9
- value,
10
- onChangeText,
7
+ label,
11
8
  style,
12
- spacing,
9
+ spacing = 13,
13
10
  labelStyle,
11
+ ...textInputProps
14
12
  }) => {
15
13
  return (
16
14
  <View style={{ gap: spacing || 13 }}>
17
15
  <FormText label={label || ' '} style={labelStyle} />
18
16
  <TextInput
19
- placeholder={placeholder}
20
- value={value}
21
- onChangeText={onChangeText}
22
- style={[
23
- {
24
- borderWidth: 1,
25
- borderColor: '#ccc',
26
- padding: 10,
27
- borderRadius: 6,
28
- },
29
- style,
30
- ]}
17
+ {...textInputProps} // 👈 forward EVERYTHING
18
+ style={style}
31
19
  />
32
20
  </View>
33
21
  );
package/src/types.ts CHANGED
@@ -1,7 +1,6 @@
1
- // types.ts
2
1
  import type {
3
- ImageProps,
4
- ImageStyle,
2
+ ImageProps,
3
+ ImageStyle,
5
4
  TextInputProps,
6
5
  TextStyle,
7
6
  TouchableOpacityProps,
@@ -41,16 +40,16 @@ export type FormProps = {
41
40
  schema: FormItem[];
42
41
  };
43
42
 
43
+
44
44
  // Buttons.types.ts
45
45
  export type ButtonProps = {
46
46
  label?: string;
47
47
  buttonText?: string;
48
- onPress?: TouchableOpacityProps['onPress'];
49
48
  style?: ViewStyle;
50
49
  textStyle?: TextStyle;
51
50
  spacing?: number;
52
51
  labelStyle?: TextStyle;
53
- };
52
+ } & TouchableOpacityProps;
54
53
 
55
54
  // Input.types.ts
56
55
  export type InputProps = {
@@ -61,7 +60,7 @@ export type InputProps = {
61
60
  placeholder?:TextInputProps['placeholder'],
62
61
  value?:TextInputProps['value'],
63
62
  onChangeText?:TextInputProps['onChangeText'],
64
- };
63
+ }& TextInputProps;
65
64
 
66
65
  // Icon.types.ts
67
66
  export type IconProps = {