extended-dynamic-forms 0.3.7 → 0.3.9
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 +53 -69
- package/dist/components/index.d.ts +1 -0
- package/dist/components/templates/ObjectFieldTemplate.d.ts +5 -0
- package/dist/index.es.js +17629 -17306
- package/dist/index.umd.js +1576 -1576
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/pathHelpers.d.ts +5 -0
- 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:
|
|
@@ -213,6 +204,7 @@ Notes:
|
|
|
213
204
|
- EDF includes `LayoutGridField` out of the box. Just set `ui:field: 'LayoutGridField'` on the step object.
|
|
214
205
|
- EDF variant uses `'ui:layoutGrid'` with AntD gutter and 24-grid spans. The RJSF canonical layout (`'ui:layout'` with 12-grid widths) is also parsed.
|
|
215
206
|
- You can still override or extend via the `fields` prop if needed.
|
|
207
|
+
- LayoutGridField now writes nested updates immutably using path metadata. This is enabled by default; set `ui:options.pathAware: false` on a step to fall back to the previous shallow merge behaviour.
|
|
216
208
|
|
|
217
209
|
## Event System & Webhooks
|
|
218
210
|
|
|
@@ -684,7 +676,7 @@ npm run format # Prettier
|
|
|
684
676
|
```
|
|
685
677
|
src/
|
|
686
678
|
├── components/ # Core form components
|
|
687
|
-
├── conditionals/ #
|
|
679
|
+
├── conditionals/ # Declarative conditional engines (internal)
|
|
688
680
|
│ └── v2/ # Current implementation
|
|
689
681
|
├── events/ # Event orchestration
|
|
690
682
|
├── layouts/ # Layout systems
|
|
@@ -718,16 +710,8 @@ Run `npm run dev` to explore examples.
|
|
|
718
710
|
Full TypeScript support with exported types:
|
|
719
711
|
|
|
720
712
|
```typescript
|
|
721
|
-
import {
|
|
722
|
-
|
|
723
|
-
WizardForm,
|
|
724
|
-
UiRule,
|
|
725
|
-
SchemaRule,
|
|
726
|
-
ValidationRule,
|
|
727
|
-
JsonLogicRule,
|
|
728
|
-
FormEvent,
|
|
729
|
-
WebhookConfig
|
|
730
|
-
} from 'extended-dynamic-forms';
|
|
713
|
+
import { ExtendedForm, WizardForm } from 'extended-dynamic-forms';
|
|
714
|
+
// Config is JSON-only; rules are embedded via x-edf:rules
|
|
731
715
|
```
|
|
732
716
|
|
|
733
717
|
## Contributing
|
|
@@ -17,6 +17,7 @@ export declare const customFields: {
|
|
|
17
17
|
};
|
|
18
18
|
export declare const customTemplates: {
|
|
19
19
|
FieldTemplate: React.FC<import('@rjsf/utils').FieldTemplateProps>;
|
|
20
|
+
ObjectFieldTemplate: React.FC<import('@rjsf/utils').ObjectFieldTemplateProps>;
|
|
20
21
|
ArrayFieldTemplate: (props: import('@rjsf/utils').ArrayFieldTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
ArrayFieldItemTemplate: (props: import('@rjsf/utils').ArrayFieldItemTemplateType) => import("react/jsx-runtime").JSX.Element;
|
|
22
23
|
WizardObjectFieldTemplate: React.FC<import('@rjsf/utils').ObjectFieldTemplateProps>;
|