extended-dynamic-forms 0.3.7 → 0.3.8
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 +52 -69
- package/dist/index.es.js +10742 -10658
- package/dist/index.umd.js +1373 -1373
- package/dist/widgets/index.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Extended Dynamic Forms
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Declarative Configuration (JSON-only)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Conditional logic is configured with pure JSON via `x-edf:rules` in your `schema` and `uiSchema`. Function-based conditions and external hooks are not required and should not be used in app code.
|
|
6
6
|
|
|
7
7
|
## Project Status
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ All conditional logic now uses **JsonLogic rules only** for conditions. Function
|
|
|
18
18
|
|
|
19
19
|
Extended Dynamic Forms is an extension library for React JSON Schema Form (RJSF) v6 that adds:
|
|
20
20
|
|
|
21
|
-
- **
|
|
21
|
+
- **Declarative conditionals** with O(N) performance (rules + dynamic arrays)
|
|
22
22
|
- **Multi-step wizard forms** with automatic step detection
|
|
23
23
|
- **Central event orchestration** with webhook support
|
|
24
24
|
- **25+ Ant Design components** for professional UI
|
|
@@ -51,71 +51,62 @@ npm run dev
|
|
|
51
51
|
|
|
52
52
|
## Core Architecture
|
|
53
53
|
|
|
54
|
-
###
|
|
54
|
+
### Declarative Conditionals (JSON-only)
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Embed rules directly inside your configs. EDF evaluates JsonLogic `condition` and applies JSON Patch `effect` internally. No hooks, functions, or classes in user code.
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
- UI rules → `uiSchema['x-edf:rules']`
|
|
59
|
+
- Schema rules → `schema['x-edf:rules']`
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}]
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
#### 2. Schema Logic Pillar
|
|
74
|
-
Modifies JSON Schema structure dynamically (use sparingly):
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
const schemaRules: SchemaRule[] = [{
|
|
78
|
-
name: 'Add premium fields',
|
|
79
|
-
condition: { "==": [{ "var": "accountType" }, "premium"] },
|
|
80
|
-
effect: [{ op: 'add', path: '/properties/premiumFeatures', value: {...} }]
|
|
81
|
-
}];
|
|
61
|
+
Example (UI rules):
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"x-edf:rules": [
|
|
65
|
+
{
|
|
66
|
+
"name": "Show license number when has license",
|
|
67
|
+
"condition": { "==": [{ "var": "hasDriversLicense" }, true] },
|
|
68
|
+
"effect": [{ "op": "remove", "path": "/licenseNumber/ui:widget" }]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
82
72
|
```
|
|
83
73
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
validate: (errors, formData) => {
|
|
95
|
-
if (!formData.parentConsent) {
|
|
96
|
-
errors.parentConsent.__errors = ['Parent consent required'];
|
|
97
|
-
}
|
|
74
|
+
Example (Schema rules):
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"x-edf:rules": [
|
|
78
|
+
{
|
|
79
|
+
"name": "Add premium fields",
|
|
80
|
+
"condition": { "==": [{ "var": "accountType" }, "premium"] },
|
|
81
|
+
"effect": [
|
|
82
|
+
{ "op": "add", "path": "/properties/premiumFeatures", "value": { "type": "object" } }
|
|
83
|
+
]
|
|
98
84
|
}
|
|
99
|
-
|
|
100
|
-
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
101
87
|
```
|
|
102
88
|
|
|
103
89
|
### Dynamic Arrays with O(N) Performance
|
|
104
90
|
|
|
105
|
-
|
|
91
|
+
Use declarative `ui:dynamicItems` with per-item JsonLogic. No functions:
|
|
106
92
|
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"directors": {
|
|
96
|
+
"items": {
|
|
97
|
+
"ui:dynamicItems": {
|
|
98
|
+
"base": { "shareholdingPercentage": { "ui:widget": "hidden" } },
|
|
99
|
+
"rules": [
|
|
100
|
+
{
|
|
101
|
+
"condition": { "===": [{ "var": "hasShareholding" }, true] },
|
|
102
|
+
"ui": { "shareholdingPercentage": { "ui:widget": "updown" } },
|
|
103
|
+
"otherwise": { "shareholdingPercentage": { "ui:widget": "hidden" } }
|
|
104
|
+
}
|
|
105
|
+
]
|
|
115
106
|
}
|
|
116
|
-
}
|
|
107
|
+
}
|
|
117
108
|
}
|
|
118
|
-
}
|
|
109
|
+
}
|
|
119
110
|
```
|
|
120
111
|
|
|
121
112
|
## Multi-Step Wizard Forms
|
|
@@ -127,7 +118,7 @@ import { WizardForm } from 'extended-dynamic-forms';
|
|
|
127
118
|
|
|
128
119
|
<WizardForm
|
|
129
120
|
schema={wizardSchema}
|
|
130
|
-
uiSchema={
|
|
121
|
+
uiSchema={uiSchema}
|
|
131
122
|
formData={formData}
|
|
132
123
|
onStepChange={(fromStep, toStep) => {
|
|
133
124
|
console.log(`Step ${fromStep} → ${toStep}`);
|
|
@@ -149,8 +140,8 @@ const schema = {
|
|
|
149
140
|
}
|
|
150
141
|
};
|
|
151
142
|
|
|
152
|
-
// Conditions
|
|
153
|
-
|
|
143
|
+
// Conditions refer to flattened form data (no STEP_ prefix)
|
|
144
|
+
// Example rule (in uiSchema.x-edf:rules): { "==": [{ "var": "hasDriversLicense" }, true] }
|
|
154
145
|
```
|
|
155
146
|
|
|
156
147
|
Note on wizard detection:
|
|
@@ -684,7 +675,7 @@ npm run format # Prettier
|
|
|
684
675
|
```
|
|
685
676
|
src/
|
|
686
677
|
├── components/ # Core form components
|
|
687
|
-
├── conditionals/ #
|
|
678
|
+
├── conditionals/ # Declarative conditional engines (internal)
|
|
688
679
|
│ └── v2/ # Current implementation
|
|
689
680
|
├── events/ # Event orchestration
|
|
690
681
|
├── layouts/ # Layout systems
|
|
@@ -718,16 +709,8 @@ Run `npm run dev` to explore examples.
|
|
|
718
709
|
Full TypeScript support with exported types:
|
|
719
710
|
|
|
720
711
|
```typescript
|
|
721
|
-
import {
|
|
722
|
-
|
|
723
|
-
WizardForm,
|
|
724
|
-
UiRule,
|
|
725
|
-
SchemaRule,
|
|
726
|
-
ValidationRule,
|
|
727
|
-
JsonLogicRule,
|
|
728
|
-
FormEvent,
|
|
729
|
-
WebhookConfig
|
|
730
|
-
} from 'extended-dynamic-forms';
|
|
712
|
+
import { ExtendedForm, WizardForm } from 'extended-dynamic-forms';
|
|
713
|
+
// Config is JSON-only; rules are embedded via x-edf:rules
|
|
731
714
|
```
|
|
732
715
|
|
|
733
716
|
## Contributing
|