react-form-dto 0.0.9 β 1.0.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/README.md +117 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
# React Form DTO
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
**Schema-first, DTO-driven form framework for React and Material UI (MUI v7)**
|
|
9
|
+
|
|
10
|
+
React Form DTO is a **high-level form framework** for building complex, dynamic, and enterprise-scale forms using declarative JSON or TypeScript DTOsβrather than verbose, repetitive JSX.
|
|
11
|
+
|
|
12
|
+
It is designed for **schema-driven UIs**, backend-configured workflows, admin panels, and internal tools where forms must be **configurable, scalable, and predictable**.
|
|
6
13
|
|
|
7
14
|
---
|
|
8
15
|
|
|
9
16
|
## Why React Form DTO?
|
|
10
17
|
|
|
11
|
-
Most form libraries
|
|
18
|
+
Most form libraries solve **state management**.
|
|
19
|
+
React Form DTO solves **form architecture**.
|
|
20
|
+
|
|
21
|
+
It operates at a higher abstraction level where **layout, validation, rendering, and behavior** are defined in a single schema.
|
|
12
22
|
|
|
13
|
-
|
|
23
|
+
### Use this library when:
|
|
14
24
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
25
|
+
- Forms are generated from backend schemas or configuration APIs
|
|
26
|
+
- UI logic must be reused across multiple applications
|
|
27
|
+
- Forms are large, dynamic, or conditional
|
|
28
|
+
- You need imperative control (wizards, modals, async flows)
|
|
29
|
+
- Your design system is based on Material UI
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
### Key Advantages
|
|
21
32
|
|
|
22
33
|
- π **DTO-first design** β define forms entirely in JSON or TypeScript
|
|
23
|
-
- π¨ **Material UI v7 native** β
|
|
24
|
-
- π§± **Composable
|
|
25
|
-
- π― **Imperative API** β programmatic
|
|
26
|
-
- π **Conditional rendering** β
|
|
27
|
-
- π§© **
|
|
28
|
-
- π‘οΈ **Strong TypeScript typing** β
|
|
34
|
+
- π¨ **Material UI v7 native** β accessibility and consistency by default
|
|
35
|
+
- π§± **Composable structure** β Form β Section β Field
|
|
36
|
+
- π― **Imperative API** β programmatic control via refs
|
|
37
|
+
- π **Conditional rendering** β dynamic visibility and logic
|
|
38
|
+
- π§© **Extensible renderers** β plug in custom components
|
|
39
|
+
- π‘οΈ **Strong TypeScript typing** β safe, predictable APIs
|
|
40
|
+
- π **Enterprise-ready** β optimized for large, config-driven forms
|
|
29
41
|
|
|
30
42
|
---
|
|
31
43
|
|
|
@@ -33,22 +45,43 @@ Most form libraries focus on low-level state management. React Form DTO operates
|
|
|
33
45
|
|
|
34
46
|
| Feature | React Form DTO | React Hook Form | Formik |
|
|
35
47
|
|------|---------------|----------------|--------|
|
|
36
|
-
| Schema/DTO driven | β
Native | β Manual | β Manual |
|
|
48
|
+
| Schema / DTO driven | β
Native | β Manual | β Manual |
|
|
37
49
|
| MUI-first | β
Yes | β οΈ Partial | β οΈ Partial |
|
|
38
50
|
| Imperative API | β
First-class | β οΈ Limited | β οΈ Limited |
|
|
39
51
|
| Large dynamic forms | β
Excellent | β οΈ Medium | β Poor |
|
|
40
52
|
| Boilerplate | β
Minimal | β High | β High |
|
|
41
53
|
|
|
42
|
-
> React Form DTO is **not a replacement** for React Hook Form.
|
|
54
|
+
> **Note:** React Form DTO is **not a replacement** for React Hook Form.
|
|
55
|
+
> It is a **higher-level abstraction** for schema-driven UI generation.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## What This Library Is Not
|
|
60
|
+
|
|
61
|
+
- β A low-level form state library
|
|
62
|
+
- β A visual form builder
|
|
63
|
+
- β A replacement for small hand-crafted forms
|
|
64
|
+
- β A design system
|
|
65
|
+
|
|
66
|
+
React Form DTO excels when **forms are data, not components**.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Documentation & Demo
|
|
71
|
+
|
|
72
|
+
- π **Documentation:** See full DTO reference, APIs, and advanced examples [Documentation](https://shakir-afridi.github.io/react-form-dto/docs)
|
|
73
|
+
- π **Storybook:** Interactive component playground and live demos [Live Demo](https://shakir-afridi.github.io/react-form-dto/storybook)
|
|
43
74
|
|
|
44
75
|
---
|
|
45
76
|
|
|
46
77
|
## Installation
|
|
47
78
|
|
|
48
79
|
```bash
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
npm install react-form-dto
|
|
81
|
+
# or
|
|
82
|
+
yarn add react-form-dto
|
|
83
|
+
# or
|
|
84
|
+
pnpm add react-form-dto
|
|
52
85
|
```
|
|
53
86
|
|
|
54
87
|
### Requirements
|
|
@@ -59,7 +92,25 @@ npm install
|
|
|
59
92
|
|
|
60
93
|
---
|
|
61
94
|
|
|
62
|
-
##
|
|
95
|
+
## Core Concepts
|
|
96
|
+
|
|
97
|
+
### DTO as Source of Truth
|
|
98
|
+
|
|
99
|
+
All structure, layout, validation, and behavior live in a single schema.
|
|
100
|
+
|
|
101
|
+
### Stateless Rendering
|
|
102
|
+
|
|
103
|
+
The UI is derived entirely from the DTO and internal state.
|
|
104
|
+
|
|
105
|
+
### Imperative Escape Hatch
|
|
106
|
+
|
|
107
|
+
Refs enable workflows that declarative-only approaches struggle with.
|
|
108
|
+
|
|
109
|
+
### Renderer Isolation
|
|
110
|
+
|
|
111
|
+
Field logic is decoupled from presentation, enabling customization.
|
|
112
|
+
|
|
113
|
+
## Quick Start
|
|
63
114
|
|
|
64
115
|
```tsx
|
|
65
116
|
import { FormBuilder, type FormBuilderHandle } from 'react-form-dto';
|
|
@@ -201,12 +252,14 @@ const profileForm: FormDTO = {
|
|
|
201
252
|
- `date`
|
|
202
253
|
- `email`
|
|
203
254
|
- `password`
|
|
255
|
+
- `textarea`
|
|
204
256
|
|
|
205
257
|
### Selection Inputs
|
|
206
258
|
|
|
207
259
|
- `select`
|
|
208
260
|
- `autocomplete`
|
|
209
261
|
- `multi-autocomplete`
|
|
262
|
+
- `radio`
|
|
210
263
|
|
|
211
264
|
### Boolean Inputs
|
|
212
265
|
|
|
@@ -395,14 +448,23 @@ validations: {
|
|
|
395
448
|
|
|
396
449
|
---
|
|
397
450
|
|
|
398
|
-
##
|
|
451
|
+
## Real-World Enterprise Usage
|
|
399
452
|
|
|
400
|
-
|
|
401
|
-
|
|
453
|
+
```text
|
|
454
|
+
Backend β returns FormDTO
|
|
455
|
+
Frontend β renders form dynamically
|
|
456
|
+
Backend updates β UI changes without redeploy
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
This enables:
|
|
460
|
+
|
|
461
|
+
- Backend-driven workflows
|
|
462
|
+
- Feature flags via schemas
|
|
463
|
+
- Faster iteration without frontend releases
|
|
402
464
|
|
|
403
465
|
---
|
|
404
466
|
|
|
405
|
-
##
|
|
467
|
+
## Other Use Cases
|
|
406
468
|
|
|
407
469
|
- Admin dashboards
|
|
408
470
|
- Internal enterprise tools
|
|
@@ -412,6 +474,23 @@ validations: {
|
|
|
412
474
|
|
|
413
475
|
---
|
|
414
476
|
|
|
477
|
+
## Performance Characteristics
|
|
478
|
+
|
|
479
|
+
- Independent field rendering
|
|
480
|
+
- Section-level isolation
|
|
481
|
+
- Optimized for 100+ field forms
|
|
482
|
+
- No unnecessary re-renders across sections
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## Incremental Adoption Strategy
|
|
487
|
+
|
|
488
|
+
- Use React Form DTO for large dynamic forms
|
|
489
|
+
- Keep React Hook Form for small custom forms
|
|
490
|
+
- Share validation logic between both
|
|
491
|
+
|
|
492
|
+
---
|
|
493
|
+
|
|
415
494
|
## Roadmap (Suggested)
|
|
416
495
|
|
|
417
496
|
- Field registry API (`registerFieldType`)
|
|
@@ -423,11 +502,18 @@ validations: {
|
|
|
423
502
|
|
|
424
503
|
## π€ Contributing
|
|
425
504
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
505
|
+
Contributions are welcome and encouraged.
|
|
506
|
+
|
|
507
|
+
1. Fork the repository
|
|
508
|
+
2. Create a feature branch
|
|
509
|
+
`git checkout -b feature/my-feature`
|
|
510
|
+
3. Commit your changes
|
|
511
|
+
`git commit -m "Add my feature"`
|
|
512
|
+
4. Push to the branch
|
|
513
|
+
`git push origin feature/my-feature`
|
|
514
|
+
5. Open a Pull Request
|
|
515
|
+
|
|
516
|
+
Please keep changes focused and well-documented.
|
|
431
517
|
|
|
432
518
|
---
|
|
433
519
|
|
|
@@ -437,4 +523,4 @@ MIT
|
|
|
437
523
|
|
|
438
524
|
---
|
|
439
525
|
|
|
440
|
-
**React Form DTO β Schema-first forms for Material UI**
|
|
526
|
+
**React Form DTO β Schema-first forms for Material UI**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-form-dto",
|
|
3
3
|
"description": "A React library for building forms using DTOs with MUI and TypeScript.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"main": "dist/react-form-dto.umd.js",
|
|
6
6
|
"module": "dist/react-form-dto.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|