@hitesh0009/react-native-basic-form 1.3.3 → 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 +18 -23
- package/dist/Form.js +4 -4
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/Form.tsx +2 -2
- package/src/types.ts +1 -0
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
|
-
- 🎨 **
|
|
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
|
|
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`
|
|
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` |
|
|
238
|
-
| `textStyle` | Button text style
|
|
239
|
-
| `labelStyle` | Label text style
|
|
240
|
-
| `spacing` |
|
|
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
|
@@ -14,10 +14,10 @@ export const Form = ({ schema = [] }) => {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
return (<>
|
|
17
|
-
{schema.map((block, blockIndex) => (<View key={blockIndex} style={{
|
|
18
|
-
|
|
19
|
-
|
|
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
|
</>);
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
package/src/Form.tsx
CHANGED
|
@@ -42,10 +42,10 @@ export const Form: React.FC<FormProps> = ({ schema = [] }) => {
|
|
|
42
42
|
{schema.map((block, blockIndex) => (
|
|
43
43
|
<View
|
|
44
44
|
key={blockIndex}
|
|
45
|
-
style={{
|
|
45
|
+
style={[{
|
|
46
46
|
flexDirection: block.layout || "column",
|
|
47
47
|
gap: block.spacing || 20,
|
|
48
|
-
}}
|
|
48
|
+
},block.style]}
|
|
49
49
|
>
|
|
50
50
|
{block.children.map(RenderField)}
|
|
51
51
|
</View>
|