extended-dynamic-forms 0.1.19 → 0.1.21
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 +65 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -66,13 +66,14 @@ const uiRules: UiRule[] = [{
|
|
|
66
66
|
|
|
67
67
|
### 🧙♂️ Multi-Step Wizard Forms
|
|
68
68
|
- Automatic step detection from schema structure
|
|
69
|
-
-
|
|
69
|
+
- **Full conditional logic support** with step-aware rule processing
|
|
70
70
|
- Built-in progress indicators and navigation
|
|
71
71
|
- Per-step validation
|
|
72
|
+
- Supports both v1 conditions (deprecated) and v2 Three Pillars architecture
|
|
72
73
|
|
|
73
74
|
**Step-Aware Conditional Logic**
|
|
74
75
|
|
|
75
|
-
The `WizardForm` automatically
|
|
76
|
+
The `WizardForm` automatically filters and transforms conditional rules to work within the current step's context. This means you can define conditions that reference fields across different steps, and the wizard will intelligently apply only the relevant rules for the active step:
|
|
76
77
|
|
|
77
78
|
```tsx
|
|
78
79
|
// Define steps with prefixed field names to avoid collisions
|
|
@@ -161,6 +162,28 @@ const uiRules: UiRule[] = [{
|
|
|
161
162
|
</html>
|
|
162
163
|
```
|
|
163
164
|
|
|
165
|
+
**Important Notes on Conditional Logic in Vanilla JS:**
|
|
166
|
+
- **Only v1 conditions are supported** - The Three Pillars v2 architecture requires React hooks
|
|
167
|
+
- Use the `conditionals` prop with v1 format: `{ rules: [...] }`
|
|
168
|
+
- Subject to v1's O(M×N) performance for array conditionals
|
|
169
|
+
- For v2 benefits, use the React-based API instead
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
// Vanilla JS supports only v1 conditionals
|
|
173
|
+
ExtendedDynamicForms.createForm({
|
|
174
|
+
container: '#my-form',
|
|
175
|
+
schema: schema,
|
|
176
|
+
conditionals: {
|
|
177
|
+
rules: [
|
|
178
|
+
{
|
|
179
|
+
conditions: { showField: true },
|
|
180
|
+
event: { type: 'show', params: { field: 'conditionalField' } }
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
164
187
|
**Perfect for:**
|
|
165
188
|
- WordPress/Drupal integrations
|
|
166
189
|
- Legacy applications
|
|
@@ -199,16 +222,18 @@ pnpm add extended-dynamic-forms
|
|
|
199
222
|
|
|
200
223
|
### Peer Dependencies
|
|
201
224
|
|
|
202
|
-
**Current Version**: `0.1.
|
|
225
|
+
**Current Version**: `0.1.19` - Optimized for **RJSF v6** with Three Pillars v2 architecture.
|
|
203
226
|
|
|
204
227
|
```json
|
|
205
228
|
{
|
|
206
|
-
"react": "^18.0.0",
|
|
207
|
-
"react-dom": "^18.0.0",
|
|
229
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
230
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
208
231
|
"antd": "^5.24.0"
|
|
209
232
|
}
|
|
210
233
|
```
|
|
211
234
|
|
|
235
|
+
> **React 19 Support**: This library supports both React 18 and React 19. See [REACT-19-COMPATIBILITY.md](./REACT-19-COMPATIBILITY.md) for migration details.
|
|
236
|
+
|
|
212
237
|
**RJSF Dependencies** (automatically handled):
|
|
213
238
|
- `@rjsf/core`: ^6.0.0+
|
|
214
239
|
- `@rjsf/utils`: ^6.0.0+
|
|
@@ -522,7 +547,7 @@ const migrationReport = generateMigrationReport(v1Rules, {
|
|
|
522
547
|
|
|
523
548
|
### Simple Wizard Form (Recommended)
|
|
524
549
|
|
|
525
|
-
The `WizardForm` component automatically detects multi-step forms and handles navigation.
|
|
550
|
+
The `WizardForm` component automatically detects multi-step forms and handles navigation. It fully supports conditional logic through either v1 conditions (deprecated) or the recommended Three Pillars v2 architecture:
|
|
526
551
|
|
|
527
552
|
```tsx
|
|
528
553
|
import { useState } from 'react';
|
|
@@ -530,9 +555,22 @@ import { WizardForm } from 'extended-dynamic-forms';
|
|
|
530
555
|
import { useConditionalUi, UiRule } from 'extended-dynamic-forms/conditionals/v2';
|
|
531
556
|
import schema from './schema.json';
|
|
532
557
|
import baseUiSchema from './ui-schema.json';
|
|
533
|
-
import uiRules from './ui-rules'; // Your v2 UI rules
|
|
534
558
|
import webhooks from './webhooks.json';
|
|
535
559
|
|
|
560
|
+
// Example: v2 Three Pillars approach (recommended)
|
|
561
|
+
const uiRules: UiRule[] = [
|
|
562
|
+
{
|
|
563
|
+
name: 'Show tax ID in company step when listed',
|
|
564
|
+
condition: (formData) => formData.STEP_COMPANY?.isListedCompany === true,
|
|
565
|
+
effect: [{ op: 'remove', path: '/STEP_COMPANY/taxId/ui:widget' }]
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: 'Show shareholding percentage for directors with shares',
|
|
569
|
+
condition: (formData) => formData.STEP_DIRECTORS?.directors?.some(d => d.hasShareholding),
|
|
570
|
+
effect: [{ op: 'remove', path: '/STEP_DIRECTORS/directors/items/shareholdingPercentage/ui:widget' }]
|
|
571
|
+
}
|
|
572
|
+
];
|
|
573
|
+
|
|
536
574
|
function App() {
|
|
537
575
|
const [formData, setFormData] = useState({});
|
|
538
576
|
const conditionalUiSchema = useConditionalUi(uiRules, baseUiSchema, formData);
|
|
@@ -548,6 +586,26 @@ function App() {
|
|
|
548
586
|
/>
|
|
549
587
|
);
|
|
550
588
|
}
|
|
589
|
+
|
|
590
|
+
// Alternative: v1 conditions approach (deprecated but still supported)
|
|
591
|
+
const v1Conditions = [
|
|
592
|
+
{
|
|
593
|
+
conditions: { "STEP_COMPANY.isListedCompany": true },
|
|
594
|
+
event: { type: "show", params: { field: "STEP_COMPANY.taxId" } }
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
conditions: { "STEP_DIRECTORS.directors[*].hasShareholding": true },
|
|
598
|
+
event: { type: "require", params: { field: "STEP_DIRECTORS.directors[*].shareholdingPercentage" } }
|
|
599
|
+
}
|
|
600
|
+
];
|
|
601
|
+
|
|
602
|
+
// Pass v1 conditions directly to WizardForm
|
|
603
|
+
<WizardForm
|
|
604
|
+
schema={schema}
|
|
605
|
+
uiSchema={uiSchema}
|
|
606
|
+
conditions={v1Conditions} // WizardForm handles step-aware transformation
|
|
607
|
+
onSubmit={(data) => console.log('Submitted:', data.formData)}
|
|
608
|
+
/>
|
|
551
609
|
```
|
|
552
610
|
|
|
553
611
|
### Basic Form with Three Pillars v2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extended-dynamic-forms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Extended React JSON Schema Form (RJSF) v6 with custom components, widgets, templates, layouts, and form events",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"antd": "^5.24.0",
|
|
61
|
-
"react": "^18.0.0",
|
|
62
|
-
"react-dom": "^18.0.0"
|
|
61
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
62
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@rjsf/antd": "file:../react-jsonschema-form/packages/antd",
|