extended-dynamic-forms 0.1.20 → 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.
Files changed (2) hide show
  1. package/README.md +60 -4
  2. package/package.json +1 -1
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
- - Step-aware conditional logic
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 scopes conditional logic to the current step. Use v2 `UiRule`s with field prefixes:
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
@@ -524,7 +547,7 @@ const migrationReport = generateMigrationReport(v1Rules, {
524
547
 
525
548
  ### Simple Wizard Form (Recommended)
526
549
 
527
- The `WizardForm` component automatically detects multi-step forms and handles navigation. Use it with Three Pillars v2:
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:
528
551
 
529
552
  ```tsx
530
553
  import { useState } from 'react';
@@ -532,9 +555,22 @@ import { WizardForm } from 'extended-dynamic-forms';
532
555
  import { useConditionalUi, UiRule } from 'extended-dynamic-forms/conditionals/v2';
533
556
  import schema from './schema.json';
534
557
  import baseUiSchema from './ui-schema.json';
535
- import uiRules from './ui-rules'; // Your v2 UI rules
536
558
  import webhooks from './webhooks.json';
537
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
+
538
574
  function App() {
539
575
  const [formData, setFormData] = useState({});
540
576
  const conditionalUiSchema = useConditionalUi(uiRules, baseUiSchema, formData);
@@ -550,6 +586,26 @@ function App() {
550
586
  />
551
587
  );
552
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
+ />
553
609
  ```
554
610
 
555
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.20",
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",