extended-dynamic-forms 0.1.22 → 0.2.0

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # Extended Dynamic Forms
2
2
 
3
+ ## 🚨 BREAKING CHANGE: v0.2.0 - JsonLogic Only Conditions
4
+
5
+ > **⚠️ IMPORTANT**: Starting with v0.2.0, Extended Dynamic Forms **ONLY** supports JsonLogic for conditional logic. Function-based conditions are no longer supported. This is a breaking change that improves security, performance, and maintainability.
6
+ >
7
+ > **Migration Required**: If you are using function-based conditions like `condition: (formData) => ...`, you must migrate to JsonLogic format: `condition: { "==": [{ "var": "fieldName" }, "value"] }`
8
+
9
+ ## ⚠️ Project Status: Active Development & Documentation Refinement
10
+
11
+ **Important Notice**: This project is currently undergoing significant documentation updates to better reflect the actual implementation. Some features described in this README may not be fully implemented or may differ from the documentation. We are actively working to align the documentation with the codebase.
12
+
13
+ **Known Issues**:
14
+ - The project currently uses local file dependencies that require a specific directory structure to build
15
+ - The project requires RJSF packages from a sibling directory (../react-jsonschema-form/)
16
+ - Some playground demos use deprecated v1 conditional patterns (01-simple-conditionals.demo.tsx)
17
+ - Array drag-and-drop functionality mentioned in documentation is not implemented
18
+ - Test coverage is limited for UI components and event systems
19
+ - Several documented features have incomplete implementations
20
+ - Significant dead code: 76% of utility functions are unused (13 out of 17 functions)
21
+ - JSON Patch implementation in v2 doesn't fully comply with RFC 6902 (no move/copy/test operations)
22
+
3
23
  **A revolutionary extension library for [React JSON Schema Form (RJSF)](https://github.com/rjsf-team/react-jsonschema-form)** that transforms schema-driven forms into sophisticated, enterprise-ready applications with O(N) performance and professional UI components.
4
24
 
5
25
  Built on top of the excellent RJSF v6 foundation, this library introduces the **Three Pillars v2 Architecture** for conditional logic, multi-step wizard orchestration, central event systems with webhook integration, and a comprehensive suite of 25+ Ant Design components.
@@ -35,32 +55,31 @@ This library transforms RJSF from a simple form generator into a complete enterp
35
55
 
36
56
  ## Core Features
37
57
 
38
- ### 🚀 Three Pillars v2 Architecture (Recommended)
39
- - **UI Logic Pillar**: Control form appearance with JSON Patch operations
40
- - **Schema Logic Pillar**: Modify data structure when truly needed
41
- - **Validation Logic Pillar**: Dynamic validation rules without schema changes
58
+ ### 🚀 Three Pillars v2 Architecture with JsonLogic
59
+ - **UI Logic Pillar**: Control form appearance with JsonLogic conditions and JSON Patch operations
60
+ - **Schema Logic Pillar**: Modify data structure with JsonLogic rules when truly needed
61
+ - **Validation Logic Pillar**: Dynamic validation rules with JsonLogic conditions
42
62
  - **O(N) Performance**: Superior array handling vs v1's O(M×N)
63
+ - **JsonLogic-Only**: Secure, data-driven conditions without code execution
43
64
  - **React Hooks**: Modern, declarative API with `useConditionalUi`, `useConditionalSchema`, `useConditionalValidation`
44
65
 
45
- ### 🎯 Declarative Conditional Logic
46
- - Define complex form behavior without code
66
+ ### 🎯 Declarative Conditional Logic with JsonLogic
67
+ - Define complex form behavior with secure JsonLogic rules
47
68
  - Dynamic array support with per-item evaluation
48
- - Compatible with `json-rules-engine` format
49
- - Built-in migration utilities from v1 to v2
50
-
51
- For example, you can integrate existing business logic:
69
+ - No code execution - all conditions are data-driven
70
+ - Type-safe with comprehensive TypeScript support
52
71
 
53
72
  ```tsx
54
- import { engine } from './rules-engine'; // Your configured json-rules-engine instance
73
+ import { UiRule, JsonLogicRule } from 'extended-dynamic-forms/conditionals/v2';
55
74
 
56
75
  const uiRules: UiRule[] = [{
57
- name: 'Apply business logic for premium users',
58
- // The condition can be a promise-based async function
59
- condition: async (formData) => {
60
- const { events } = await engine.run(formData);
61
- return events.some(event => event.type === 'show-premium-feature');
62
- },
63
- effect: [...]
76
+ name: 'Show premium features for premium users',
77
+ condition: {
78
+ "==": [{ "var": "accountType" }, "premium"]
79
+ } as JsonLogicRule,
80
+ effect: [
81
+ { op: 'remove', path: '/premiumFeatures/ui:widget' }
82
+ ]
64
83
  }];
65
84
  ```
66
85
 
@@ -92,10 +111,12 @@ const schema = {
92
111
  }
93
112
  };
94
113
 
95
- // Use v2 UiRules to handle step-aware conditionals
114
+ // Use v2 UiRules with JsonLogic to handle step-aware conditionals
96
115
  const uiRules: UiRule[] = [{
97
116
  name: 'Show SSN only for US Citizens in Personal step',
98
- condition: (formData) => !formData.STEP_PERSONAL?.isUSCitizen,
117
+ condition: {
118
+ "!": { "var": "STEP_PERSONAL.isUSCitizen" }
119
+ } as JsonLogicRule,
99
120
  effect: [
100
121
  { op: 'add', path: '/STEP_PERSONAL/properties/ssn/ui:widget', value: 'hidden' }
101
122
  ]
@@ -125,8 +146,8 @@ const uiRules: UiRule[] = [{
125
146
  - **TypeScript**: Full type safety and IntelliSense with comprehensive interface definitions
126
147
  - **Performance**: Optimized re-renders and memoization with intelligent caching
127
148
  - **Extensible**: Add custom widgets, fields, and actions with clean APIs
128
- - **Well-Tested**: Extensive test suite covering all major features and edge cases
129
- - **Developer Experience**: Interactive playground with dozens of real-world demos
149
+ - **Test Coverage**: Focused on conditional logic and wizard forms (UI components have limited coverage)
150
+ - **Developer Experience**: Interactive playground with real-world demos (note: some deprecated)
130
151
 
131
152
  ### 🌐 Standalone JavaScript Support
132
153
 
@@ -163,10 +184,10 @@ const uiRules: UiRule[] = [{
163
184
  ```
164
185
 
165
186
  **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: [...] }`
187
+ - **JsonLogic is NOT supported in vanilla JS** - The JsonLogic runtime requires React hooks
188
+ - Only v1 conditions are supported with the `conditionals` prop
168
189
  - Subject to v1's O(M×N) performance for array conditionals
169
- - For v2 benefits, use the React-based API instead
190
+ - For JsonLogic and v2 benefits, you must use the React-based API
170
191
 
171
192
  ```javascript
172
193
  // Vanilla JS supports only v1 conditionals
@@ -199,6 +220,11 @@ Special thanks to the RJSF team and contributors for creating such a flexible an
199
220
 
200
221
  ## Installation
201
222
 
223
+ > ⚠️ **Important Note**: This library currently uses local file dependencies for RJSF packages (pointing to `../react-jsonschema-form/`). This means:
224
+ > - The library cannot be installed directly from npm without modifications
225
+ > - You need the RJSF source code in a sibling directory for development
226
+ > - Consider using a monorepo structure or git submodules for proper dependency management
227
+
202
228
  ### React Projects
203
229
 
204
230
  ```bash
@@ -222,7 +248,7 @@ pnpm add extended-dynamic-forms
222
248
 
223
249
  ### Peer Dependencies
224
250
 
225
- **Current Version**: `0.1.19` - Optimized for **RJSF v6** with Three Pillars v2 architecture.
251
+ **Current Version**: `0.2.0` - Built for **RJSF v6** with Three Pillars v2 architecture (JsonLogic-only).
226
252
 
227
253
  ```json
228
254
  {
@@ -289,31 +315,35 @@ function App() {
289
315
  }
290
316
  ```
291
317
 
292
- ## Three Pillars v2 Architecture (Recommended Approach)
318
+ ## Three Pillars v2 Architecture with JsonLogic (Required Approach)
293
319
 
294
- > ⚠️ **IMPORTANT**: The v1 conditional system is deprecated. We strongly recommend using the Three Pillars v2 architecture for all new implementations.
320
+ > ⚠️ **BREAKING CHANGE**: As of v0.2.0, the Three Pillars v2 system ONLY supports JsonLogic conditions. Function-based conditions are no longer supported for security and maintainability reasons.
295
321
 
296
- The Three Pillars v2 system provides superior performance, cleaner separation of concerns, and better maintainability. It consists of three independent pillars:
322
+ The Three Pillars v2 system with JsonLogic provides superior performance, cleaner separation of concerns, and better security. It consists of three independent pillars:
297
323
 
298
324
  ### 1. UI Logic Pillar (`useConditionalUi`)
299
325
 
300
- Controls form appearance using JSON Patch operations:
326
+ Controls form appearance using JSON Patch operations with JsonLogic conditions:
301
327
 
302
328
  ```tsx
303
329
  // Note: v2 conditionals require deep import for optimal tree-shaking
304
- import { useConditionalUi, UiRule } from 'extended-dynamic-forms/conditionals/v2';
330
+ import { useConditionalUi, UiRule, JsonLogicRule } from 'extended-dynamic-forms/conditionals/v2';
305
331
 
306
- // Define UI rules with JSON Patch operations
332
+ // Define UI rules with JsonLogic conditions and JSON Patch operations
307
333
  const uiRules: UiRule[] = [
308
334
  {
309
335
  name: 'Show shipping address when required',
310
- condition: (formData) => formData.requiresShipping === true,
336
+ condition: {
337
+ "==": [{ "var": "requiresShipping" }, true]
338
+ } as JsonLogicRule,
311
339
  effect: [{ op: 'remove', path: '/shippingAddress/ui:widget' }],
312
340
  order: 1
313
341
  },
314
342
  {
315
343
  name: 'Dynamic country fields',
316
- condition: (formData) => formData.shippingAddress?.country === 'USA',
344
+ condition: {
345
+ "==": [{ "var": "shippingAddress.country" }, "USA"]
346
+ } as JsonLogicRule,
317
347
  effect: [
318
348
  { op: 'remove', path: '/shippingAddress/state/ui:widget' },
319
349
  { op: 'add', path: '/shippingAddress/province/ui:widget', value: 'hidden' }
@@ -353,12 +383,14 @@ function MyForm() {
353
383
  Modifies JSON Schema structure (use sparingly - prefer UI or Validation pillars):
354
384
 
355
385
  ```tsx
356
- import { useConditionalSchema, SchemaRule } from 'extended-dynamic-forms/conditionals/v2';
386
+ import { useConditionalSchema, SchemaRule, JsonLogicRule } from 'extended-dynamic-forms/conditionals/v2';
357
387
 
358
388
  const schemaRules: SchemaRule[] = [
359
389
  {
360
390
  name: 'Add premium fields',
361
- condition: (formData) => formData.accountType === 'premium',
391
+ condition: {
392
+ "==": [{ "var": "accountType" }, "premium"]
393
+ } as JsonLogicRule,
362
394
  effect: [
363
395
  {
364
396
  op: 'add',
@@ -383,12 +415,14 @@ Adds conditional validation without modifying schema:
383
415
 
384
416
  ```tsx
385
417
  import { useMemo } from 'react';
386
- import { useConditionalValidation, ValidationRule, createCustomValidate } from 'extended-dynamic-forms/conditionals/v2';
418
+ import { useConditionalValidation, ValidationRule, JsonLogicRule, createCustomValidate } from 'extended-dynamic-forms/conditionals/v2';
387
419
 
388
420
  const validationRules: ValidationRule[] = [
389
421
  {
390
422
  name: 'Require consent for minors',
391
- condition: (formData) => formData.age < 18,
423
+ condition: {
424
+ "<": [{ "var": "age" }, 18]
425
+ } as JsonLogicRule,
392
426
  effect: {
393
427
  type: 'validation',
394
428
  validate: (errors, formData) => {
@@ -436,6 +470,8 @@ One of the most significant breakthroughs in v2 is the `createDynamicArrayItemsU
436
470
  - **No Rule Explosion**: Unlike v1's wildcard expansion, no rules are multiplied by array size
437
471
  - **React-Optimized**: Leverages React's rendering cycle for optimal performance
438
472
 
473
+ > **Note**: `createDynamicArrayItemsUiSchema` still supports function-based conditions as it evaluates per-item during render. This is not a security risk as the functions are defined in your code, not from user input.
474
+
439
475
  ```tsx
440
476
  import { createDynamicArrayItemsUiSchema } from 'extended-dynamic-forms/conditionals/v2';
441
477
 
@@ -521,26 +557,31 @@ function MyForm() {
521
557
  }
522
558
  ```
523
559
 
524
- ### Migration from v1 to v2
560
+ ### JsonLogic Conditions (Required)
561
+
562
+ As of v0.2.0, v2 ONLY supports JsonLogic conditions for security and maintainability:
525
563
 
526
564
  ```tsx
527
- import {
528
- migrateV1ToUiRules,
529
- generateMigrationReport,
530
- analyzeRules
531
- } from 'extended-dynamic-forms/conditionals/v2';
532
-
533
- // Analyze existing rules
534
- const analysis = analyzeRules(v1Rules);
535
-
536
- // Auto-migrate UI rules
537
- const { rules: migratedRules, report } = migrateV1ToUiRules(v1Rules);
538
-
539
- // Generate detailed migration report
540
- const migrationReport = generateMigrationReport(v1Rules, {
541
- includeExamples: true,
542
- outputFormat: 'markdown'
543
- });
565
+ import { JsonLogicRule, UiRule } from 'extended-dynamic-forms/conditionals/v2';
566
+
567
+ // JsonLogic rule examples
568
+ const simpleRule: UiRule = {
569
+ name: 'Show field B when A is true',
570
+ condition: { "==": [{ "var": "fieldA" }, true] } as JsonLogicRule,
571
+ effect: [{ op: 'remove', path: '/fieldB/ui:widget' }]
572
+ };
573
+
574
+ const complexRule: UiRule = {
575
+ name: 'Complex business logic',
576
+ condition: {
577
+ "and": [
578
+ { "==": [{ "var": "accountType" }, "premium"] },
579
+ { ">": [{ "var": "revenue" }, 100000] },
580
+ { "in": [{ "var": "country" }, ["USA", "Canada", "UK"]] }
581
+ ]
582
+ } as JsonLogicRule,
583
+ effect: [{ op: 'remove', path: '/advancedFeatures/ui:widget' }]
584
+ };
544
585
  ```
545
586
 
546
587
  ## Quick Start
@@ -557,16 +598,23 @@ import schema from './schema.json';
557
598
  import baseUiSchema from './ui-schema.json';
558
599
  import webhooks from './webhooks.json';
559
600
 
560
- // Example: v2 Three Pillars approach (recommended)
601
+ // Example: v2 Three Pillars approach with JsonLogic (required)
561
602
  const uiRules: UiRule[] = [
562
603
  {
563
604
  name: 'Show tax ID in company step when listed',
564
- condition: (formData) => formData.STEP_COMPANY?.isListedCompany === true,
605
+ condition: {
606
+ "==": [{ "var": "STEP_COMPANY.isListedCompany" }, true]
607
+ } as JsonLogicRule,
565
608
  effect: [{ op: 'remove', path: '/STEP_COMPANY/taxId/ui:widget' }]
566
609
  },
567
610
  {
568
611
  name: 'Show shareholding percentage for directors with shares',
569
- condition: (formData) => formData.STEP_DIRECTORS?.directors?.some(d => d.hasShareholding),
612
+ condition: {
613
+ "some": [
614
+ { "var": "STEP_DIRECTORS.directors" },
615
+ { "var": "hasShareholding" }
616
+ ]
617
+ } as JsonLogicRule,
570
618
  effect: [{ op: 'remove', path: '/STEP_DIRECTORS/directors/items/shareholdingPercentage/ui:widget' }]
571
619
  }
572
620
  ];
@@ -595,7 +643,7 @@ const v1Conditions = [
595
643
  },
596
644
  {
597
645
  conditions: { "STEP_DIRECTORS.directors[*].hasShareholding": true },
598
- event: { type: "require", params: { field: "STEP_DIRECTORS.directors[*].shareholdingPercentage" } }
646
+ event: { type: "show", params: { field: "STEP_DIRECTORS.directors[*].shareholdingPercentage" } }
599
647
  }
600
648
  ];
601
649
 
@@ -612,7 +660,7 @@ const v1Conditions = [
612
660
 
613
661
  ```tsx
614
662
  import { ExtendedForm } from 'extended-dynamic-forms';
615
- import { useConditionalUi, UiRule } from 'extended-dynamic-forms/conditionals/v2';
663
+ import { useConditionalUi, UiRule, JsonLogicRule } from 'extended-dynamic-forms/conditionals/v2';
616
664
 
617
665
  const schema = {
618
666
  type: 'object',
@@ -628,11 +676,13 @@ const baseUiSchema = {
628
676
  school: { 'ui:widget': 'text' }
629
677
  };
630
678
 
631
- // Define UI rules outside component
679
+ // Define UI rules outside component with JsonLogic
632
680
  const uiRules: UiRule[] = [
633
681
  {
634
682
  name: 'Show student fields when student',
635
- condition: (formData) => !formData.isStudent,
683
+ condition: {
684
+ "!": { "var": "isStudent" }
685
+ } as JsonLogicRule,
636
686
  effect: [
637
687
  { op: 'add', path: '/studentId/ui:widget', value: 'hidden' },
638
688
  { op: 'add', path: '/school/ui:widget', value: 'hidden' }
@@ -715,6 +765,14 @@ All standard RJSF widgets are enhanced with:
715
765
  - **Error States**: Proper error indication and messaging
716
766
  - **Accessibility**: Enhanced ARIA support
717
767
 
768
+ ### Array Templates
769
+
770
+ The library provides Ant Design Card-based array templates for better visual organization:
771
+ - **ArrayFieldTemplate**: Card container with proper spacing and visual hierarchy
772
+ - **ArrayFieldItemTemplate**: Individual array items with integrated add/remove buttons
773
+ - **Visual Design**: Clean card-based layout for array management
774
+ - **Note**: Drag-and-drop reordering is not currently implemented
775
+
718
776
  ## Central Event Orchestration System
719
777
 
720
778
  ### Field-Level Event Handling
@@ -1004,7 +1062,7 @@ Extended Dynamic Forms uses a layered architecture that cleanly extends RJSF:
1004
1062
  | **Array Conditionals** | ❌ None | ✅ Per-Item O(N) Performance |
1005
1063
  | **TypeScript** | Partial | ✅ Comprehensive Type Definitions |
1006
1064
  | **Standalone JS** | ❌ React Only | ✅ Complete UMD Bundle |
1007
- | **Testing** | Basic | ✅ Extensive Test Coverage |
1065
+ | **Testing** | Basic | ⚠️ Focused on Conditionals/Wizards |
1008
1066
  | **Performance** | Standard | ✅ Optimized with Caching |
1009
1067
  | **Validation** | Basic | ✅ Dynamic + Custom Rules |
1010
1068
  | **Developer Tools** | Limited | ✅ Interactive Playground |
@@ -1013,11 +1071,15 @@ Extended Dynamic Forms uses a layered architecture that cleanly extends RJSF:
1013
1071
 
1014
1072
  ### 🚀 Quick Start
1015
1073
 
1074
+ > **Development Setup Note**: Due to local file dependencies, you need:
1075
+ > 1. Clone RJSF repository in a sibling directory: `../react-jsonschema-form/`
1076
+ > 2. Ensure the RJSF packages are built and available
1077
+
1016
1078
  ```bash
1017
- # Clone and setup
1079
+ # Clone and setup (requires specific directory structure)
1018
1080
  git clone https://github.com/user/extended-dynamic-forms.git
1019
1081
  cd extended-dynamic-forms
1020
- npm install
1082
+ npm install # Note: Will fail without ../react-jsonschema-form/ directory
1021
1083
 
1022
1084
  # Start development with playground
1023
1085
  npm run dev # Launches interactive playground
@@ -1045,11 +1107,11 @@ npm run serve:examples # Serve vanilla JS examples
1045
1107
 
1046
1108
  ### 🧪 Testing
1047
1109
 
1048
- **Test Coverage**: Extensive test suite with focus on:
1049
- - **Conditional Logic**: Comprehensive coverage for v1 and v2 systems
1110
+ **Test Coverage**: Test suite focuses primarily on:
1111
+ - **Conditional Logic**: Comprehensive coverage for v1 and v2 systems (16+ test files)
1050
1112
  - **Wizard Forms**: Step navigation and validation
1051
1113
  - **Performance**: Array conditional optimization
1052
- - **Integration**: Component interaction testing
1114
+ - **Note**: Limited coverage for UI components, event system, and utility functions
1053
1115
 
1054
1116
  ```bash
1055
1117
  npm run test # Run complete test suite
@@ -1077,7 +1139,7 @@ src/
1077
1139
  ├── events/ # Central event orchestration
1078
1140
  ├── widgets/ # Enhanced component suite
1079
1141
  ├── components/ # Field and template components
1080
- └── utils/ # Form manipulation utilities
1142
+ └── utils/ # Utilities (Note: 76% are unused)
1081
1143
  ```
1082
1144
 
1083
1145
  ## Examples & Demos
@@ -1095,6 +1157,8 @@ npm run playground
1095
1157
 
1096
1158
  ### 📚 Demo Categories
1097
1159
 
1160
+ > **Note**: Some playground demos may be outdated. The v1 conditional demo (`/playground/src/demos/conditionals/01-deprecated-v1-conditions.demo.tsx`) is deprecated and should not be used as a reference for new implementations.
1161
+
1098
1162
  #### **Three Pillars v2 Demonstrations**
1099
1163
  - **Global UI Rules**: Dynamic show/hide with JSON Patch operations
1100
1164
  - **Dynamic Array Items**: Per-item conditional logic with O(N) performance
@@ -8,7 +8,6 @@ export interface WizardStep {
8
8
  export interface WizardFormProps {
9
9
  schema: any;
10
10
  uiSchema: any;
11
- conditions?: any[];
12
11
  webhooks?: WebhookConfig[];
13
12
  formData?: any;
14
13
  onSubmit?: (data: any) => void;
@@ -16,11 +15,11 @@ export interface WizardFormProps {
16
15
  onFieldFocus?: (event: any) => void;
17
16
  onFieldBlur?: (event: any) => void;
18
17
  onFieldChange?: (event: any) => void;
18
+ onLiveChange?: (completeFlatData: any) => void;
19
19
  showProgressBar?: boolean;
20
20
  showStepDescription?: boolean;
21
21
  submitButtonText?: string;
22
22
  liveValidate?: boolean;
23
23
  showErrorList?: boolean;
24
24
  }
25
- export declare function WizardForm({ schema, uiSchema, conditions, // JSON Rules Engine format conditions
26
- webhooks, formData: initialFormData, onSubmit, onStepChange, onFieldFocus, onFieldBlur, onFieldChange, showProgressBar, showStepDescription, submitButtonText, liveValidate, showErrorList, }: WizardFormProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function WizardForm({ schema, uiSchema, webhooks, formData: initialFormData, onSubmit, onStepChange, onFieldFocus, onFieldBlur, onFieldChange, onLiveChange, showProgressBar, showStepDescription, submitButtonText, liveValidate, showErrorList, }: WizardFormProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1 @@
1
- export { SimpleConditionalEngine as ConditionalProcessor } from './SimpleConditionalEngine';
2
- export { SimpleConditionalEngine } from './SimpleConditionalEngine';
3
- export { DynamicArrayConditionalEngine } from './DynamicArrayConditionalEngine';
4
- export { defaultActions, remove, require, uiAppend, uiOverride, uiReplace, enable, disable, optional, show, } from './ConditionalActions';
5
- export { smartTransformJsonRulesEngine as transformJsonRulesEngine } from './SmartJsonRulesTransformer';
6
- export { smartTransformJsonRulesEngine } from './SmartJsonRulesTransformer';
7
- export { default as Engine } from 'json-rules-engine-simplified';
1
+ export * from './v2';
@@ -0,0 +1,35 @@
1
+ import { RJSFSchema } from '@rjsf/utils';
2
+
3
+ export interface JsonPatchOperation {
4
+ op: 'add' | 'remove' | 'replace';
5
+ path: string;
6
+ value?: any;
7
+ }
8
+ export interface CustomSchemaOperation {
9
+ op: 'require' | 'optional';
10
+ path: string;
11
+ field: string;
12
+ }
13
+ export type SchemaEffect = JsonPatchOperation | CustomSchemaOperation;
14
+ /**
15
+ * Apply a series of effects (JSON Patch or custom) to a schema
16
+ */
17
+ export declare function applySchemaEffects(schema: RJSFSchema, effects: SchemaEffect[]): RJSFSchema;
18
+ /**
19
+ * Helper to extract parent path from a field path
20
+ * e.g., "/properties/address/properties/street" -> "/properties/address"
21
+ */
22
+ export declare function fieldPathToParentPath(fieldPath: string): string;
23
+ /**
24
+ * Helper to extract field name from a path
25
+ * e.g., "/properties/address/properties/street" -> "street"
26
+ */
27
+ export declare function extractFieldName(fieldPath: string): string;
28
+ /**
29
+ * Create a require effect
30
+ */
31
+ export declare function createRequireEffect(parentPath: string, fieldName: string): CustomSchemaOperation;
32
+ /**
33
+ * Create an optional effect
34
+ */
35
+ export declare function createOptionalEffect(parentPath: string, fieldName: string): CustomSchemaOperation;
@@ -1,5 +1,5 @@
1
1
  export { createConditionalEngineHook } from './createConditionalEngineHook';
2
- export type { Rule, EngineConfig, ConditionalEngineHook, UiEffect, SchemaEffect, ValidationEffect, } from './types';
2
+ export type { Rule, EngineConfig, ConditionalEngineHook, UiEffect, SchemaEffect, ValidationEffect, JsonLogicRule, } from './types';
3
3
  export { useConditionalUi, type UiRule } from './hooks/useConditionalUi';
4
4
  export { useConditionalSchema, type SchemaRule, } from './hooks/useConditionalSchema';
5
5
  export { useConditionalValidation, type ValidationRule, } from './hooks/useConditionalValidation';
@@ -7,4 +7,3 @@ export { createDynamicArrayItemsUiSchema, mergeItemUiSchema, arrayItemPatterns,
7
7
  export { uiEngineConfig } from './engines/uiEngineConfig';
8
8
  export { schemaEngineConfig } from './engines/schemaEngineConfig';
9
9
  export { validationEngineConfig, createCustomValidate, } from './engines/validationEngineConfig';
10
- export * from './migration';
@@ -1,8 +1,12 @@
1
1
  import { ErrorSchema } from '@rjsf/utils';
2
+ import { RulesLogic } from 'json-logic-js';
2
3
 
4
+ export type JsonLogicRule = RulesLogic;
5
+ export type ConditionPredicate = (formData: any) => boolean;
6
+ export type Condition = ConditionPredicate | JsonLogicRule;
3
7
  export interface Rule<T> {
4
8
  name: string;
5
- condition: (formData: any) => boolean;
9
+ condition: Condition;
6
10
  effect: T;
7
11
  order?: number;
8
12
  }
@@ -16,11 +20,17 @@ export interface UiEffect {
16
20
  path: string;
17
21
  value?: any;
18
22
  }
19
- export interface SchemaEffect {
23
+ export interface JsonPatchSchemaEffect {
20
24
  op: 'add' | 'remove' | 'replace';
21
25
  path: string;
22
26
  value?: any;
23
27
  }
28
+ export interface CustomSchemaEffect {
29
+ op: 'require' | 'optional';
30
+ path: string;
31
+ field: string;
32
+ }
33
+ export type SchemaEffect = JsonPatchSchemaEffect | CustomSchemaEffect;
24
34
  export interface ValidationEffect {
25
35
  /**
26
36
  * Name of the validation rule for debugging purposes
@@ -29,7 +39,7 @@ export interface ValidationEffect {
29
39
  /**
30
40
  * Determines if this validation should be applied based on current form data
31
41
  */
32
- isActive: (formData: any) => boolean;
42
+ isActive: Condition;
33
43
  /**
34
44
  * Applies validation logic and adds errors to the ErrorSchema
35
45
  */
@@ -1 +1 @@
1
- export * from './useFormDevTools';
1
+ export {};