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

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 CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  # 🚀 React Native Basic Form
3
2
 
4
3
  ### Control your entire form using JSON — not JSX.
@@ -57,7 +56,7 @@ A **schema-driven, fully customizable form renderer for React Native**.
57
56
 
58
57
  - 🧩 **Schema-based rendering**
59
58
  - 📐 **Row / Column layouts**
60
- - 🎨 **Fully customizable styles**
59
+ - 🎨 **Field-level & block-level styling**
61
60
  - 🧠 **No internal state** (you control values & handlers)
62
61
  - 🌍 **Language-agnostic** (i18n handled by user)
63
62
  - 🛡 **Type-safe** with TypeScript
@@ -96,6 +95,7 @@ const formSchema = [
96
95
  {
97
96
  layout: 'column',
98
97
  spacing: 20,
98
+ style: { padding: 16 }, // 👈 block-level styling
99
99
  children: [
100
100
  {
101
101
  type: 'input',
@@ -157,12 +157,13 @@ The form renderer handles **how** it is rendered.
157
157
 
158
158
  ### 2. Layout Blocks
159
159
 
160
- Each schema block controls layout only.
160
+ Each schema block controls layout and grouping.
161
161
 
162
162
  ```ts
163
163
  {
164
164
  layout: 'row',
165
165
  spacing: 12,
166
+ style: { alignItems: 'center' },
166
167
  children: [...]
167
168
  }
168
169
  ```
@@ -194,6 +195,7 @@ Supported field types:
194
195
  type: 'input',
195
196
  label: 'Age',
196
197
  spacing: 8,
198
+ style: { borderColor: '#16a34a' },
197
199
  inputProps: {
198
200
  placeholder: 'Enter age',
199
201
  keyboardType: 'numeric',
@@ -222,7 +224,7 @@ All standard **React Native `TextInputProps`** are supported via `inputProps`.
222
224
  }
223
225
  ```
224
226
 
225
- All standard **`TouchableOpacity` behavior** is supported via `buttonProps`.
227
+ All standard **`TouchableOpacity` props** are supported via `buttonProps`.
226
228
 
227
229
  ---
228
230
 
@@ -232,19 +234,20 @@ Styling is **fully user-controlled**.
232
234
 
233
235
  ### Field-level props
234
236
 
235
- | Prop | Description |
236
- | ------------ | ---------------------------------------- |
237
- | `style` | Container style |
238
- | `textStyle` | Button text style |
239
- | `labelStyle` | Label text style |
240
- | `spacing` | Vertical spacing between label and field |
237
+ | Prop | Description |
238
+ | ------------ | ----------------------------- |
239
+ | `style` | Field container style |
240
+ | `textStyle` | Button text style |
241
+ | `labelStyle` | Label text style |
242
+ | `spacing` | Space between label and field |
241
243
 
242
244
  ### Block-level props
243
245
 
244
- | Prop | Description |
245
- | --------- | -------------------- |
246
- | `layout` | `row` or `column` |
247
- | `spacing` | Space between fields |
246
+ | Prop | Description |
247
+ | --------- | ---------------------------------- |
248
+ | `layout` | `row` or `column` |
249
+ | `spacing` | Space between fields |
250
+ | `style` | Wrapper `View` style for the block |
248
251
 
249
252
  ---
250
253
 
@@ -266,20 +269,13 @@ No translation logic is included.
266
269
 
267
270
  The library exposes a **strict schema contract**.
268
271
 
269
- ### Types Overview
270
-
271
272
  ```ts
272
- export type FormField = FormInput | FormButton;
273
-
274
273
  export type FormItem = {
275
274
  layout?: 'row' | 'column';
276
275
  spacing?: number;
276
+ style?: ViewStyle;
277
277
  children: FormField[];
278
278
  };
279
-
280
- export type FormProps = {
281
- schema: FormItem[];
282
- };
283
279
  ```
284
280
 
285
281
  TypeScript will:
@@ -349,4 +345,3 @@ Please keep PRs:
349
345
  ## 📄 License
350
346
 
351
347
  MIT
352
-
package/dist/Form.js CHANGED
@@ -6,18 +6,18 @@ 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
  }
15
15
  };
16
16
  return (<>
17
- {schema.map((block, blockIndex) => (<View key={blockIndex} style={{
18
- flexDirection: block.layout || "column",
19
- gap: block.spacing || 20,
20
- }}>
17
+ {schema.map((block, blockIndex) => (<View key={blockIndex} style={[{
18
+ flexDirection: block.layout || "column",
19
+ gap: block.spacing || 20,
20
+ }, block.style]}>
21
21
  {block.children.map(RenderField)}
22
22
  </View>))}
23
23
  </>);
@@ -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
@@ -22,6 +22,7 @@ export type FormItem = {
22
22
  layout?: ViewStyle['flexDirection'];
23
23
  spacing?: number;
24
24
  children: FormField[];
25
+ style: ViewStyle;
25
26
  };
26
27
  export type FormProps = {
27
28
  schema: FormItem[];
@@ -29,12 +30,11 @@ export type FormProps = {
29
30
  export type ButtonProps = {
30
31
  label?: string;
31
32
  buttonText?: string;
32
- onPress?: TouchableOpacityProps['onPress'];
33
33
  style?: ViewStyle;
34
34
  textStyle?: TextStyle;
35
35
  spacing?: number;
36
36
  labelStyle?: TextStyle;
37
- };
37
+ } & TouchableOpacityProps;
38
38
  export type InputProps = {
39
39
  label?: string;
40
40
  style?: TextInputProps['style'];
@@ -43,7 +43,7 @@ export type InputProps = {
43
43
  placeholder?: TextInputProps['placeholder'];
44
44
  value?: TextInputProps['value'];
45
45
  onChangeText?: TextInputProps['onChangeText'];
46
- };
46
+ } & TextInputProps;
47
47
  export type IconProps = {
48
48
  icon?: ImageProps['source'];
49
49
  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.4",
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
  );
@@ -40,10 +42,10 @@ export const Form:React.FC<FormProps> = ({ schema = [] }) => {
40
42
  {schema.map((block, blockIndex) => (
41
43
  <View
42
44
  key={blockIndex}
43
- style={{
45
+ style={[{
44
46
  flexDirection: block.layout || "column",
45
47
  gap: block.spacing || 20,
46
- }}
48
+ },block.style]}
47
49
  >
48
50
  {block.children.map(RenderField)}
49
51
  </View>
@@ -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,
@@ -35,22 +34,23 @@ export type FormItem = {
35
34
  layout?: ViewStyle['flexDirection'];
36
35
  spacing?: number;
37
36
  children: FormField[];
37
+ style:ViewStyle
38
38
  };
39
39
 
40
40
  export type FormProps = {
41
41
  schema: FormItem[];
42
42
  };
43
43
 
44
+
44
45
  // Buttons.types.ts
45
46
  export type ButtonProps = {
46
47
  label?: string;
47
48
  buttonText?: string;
48
- onPress?: TouchableOpacityProps['onPress'];
49
49
  style?: ViewStyle;
50
50
  textStyle?: TextStyle;
51
51
  spacing?: number;
52
52
  labelStyle?: TextStyle;
53
- };
53
+ } & TouchableOpacityProps;
54
54
 
55
55
  // Input.types.ts
56
56
  export type InputProps = {
@@ -61,7 +61,7 @@ export type InputProps = {
61
61
  placeholder?:TextInputProps['placeholder'],
62
62
  value?:TextInputProps['value'],
63
63
  onChangeText?:TextInputProps['onChangeText'],
64
- };
64
+ }& TextInputProps;
65
65
 
66
66
  // Icon.types.ts
67
67
  export type IconProps = {