extended-dynamic-forms 0.1.21 → 0.1.23
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 +134 -70
- package/dist/ExtendedForm.d.ts +4 -0
- package/dist/WizardForm.d.ts +25 -0
- package/dist/components/arrays/ArrayFieldItemTemplate.d.ts +3 -0
- package/dist/components/arrays/ArrayFieldTemplate.d.ts +3 -0
- package/dist/components/arrays/index.d.ts +2 -0
- package/dist/components/fields/AddressField.d.ts +3 -0
- package/dist/components/fields/CurrencyField.d.ts +4 -0
- package/dist/components/fields/PhoneField.d.ts +4 -0
- package/dist/components/index.d.ts +24 -0
- package/dist/components/templates/FieldTemplate.d.ts +4 -0
- package/dist/components/templates/SubmitButton.d.ts +4 -0
- package/dist/components/templates/index.d.ts +2 -0
- package/dist/conditionals/index.d.ts +1 -0
- package/dist/conditionals/v2/createConditionalEngineHook.d.ts +3 -0
- package/dist/conditionals/v2/effects/customHandlers.d.ts +35 -0
- package/dist/conditionals/v2/engines/schemaEngineConfig.d.ts +4 -0
- package/dist/conditionals/v2/engines/uiEngineConfig.d.ts +4 -0
- package/dist/conditionals/v2/engines/validationEngineConfig.d.ts +13 -0
- package/dist/conditionals/v2/hooks/useConditionalSchema.d.ts +4 -0
- package/dist/conditionals/v2/hooks/useConditionalUi.d.ts +4 -0
- package/dist/conditionals/v2/hooks/useConditionalValidation.d.ts +4 -0
- package/dist/conditionals/v2/index.d.ts +9 -0
- package/dist/conditionals/v2/types.d.ts +47 -0
- package/dist/conditionals/v2/utils/dynamicArrayItems.d.ts +59 -0
- package/dist/conditionals/v2/utils/jsonPatch.d.ts +9 -0
- package/dist/events/FormEventContext.d.ts +19 -0
- package/dist/events/FormEventHub.d.ts +27 -0
- package/dist/events/FormEventManager.d.ts +10 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.es.js +19075 -0
- package/dist/index.umd.js +162 -0
- package/dist/layouts/index.d.ts +2 -0
- package/dist/layouts/wizard/ProgressIndicator.d.ts +10 -0
- package/dist/layouts/wizard/StepNavigation.d.ts +11 -0
- package/dist/layouts/wizard/WizardLayout.d.ts +31 -0
- package/dist/layouts/wizard/WizardNavigation.d.ts +16 -0
- package/dist/layouts/wizard/WizardObjectFieldTemplate.d.ts +4 -0
- package/dist/layouts/wizard/WizardSectionTemplate.d.ts +11 -0
- package/dist/layouts/wizard/index.d.ts +7 -0
- package/dist/types/index.d.ts +47 -0
- package/dist/utils/formDataUtils.d.ts +22 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/schemaUtils.d.ts +24 -0
- package/dist/utils/validationUtils.d.ts +26 -0
- package/dist/vanilla-entry.d.ts +204 -0
- package/dist/widgets/date/DateWidget.d.ts +4 -0
- package/dist/widgets/enhanced/EnhancedWidgets.d.ts +37 -0
- package/dist/widgets/file/FileWidget.d.ts +4 -0
- package/dist/widgets/index.d.ts +33 -0
- package/dist/widgets/input/ColorWidget.d.ts +4 -0
- package/dist/widgets/input/RangeWidget.d.ts +4 -0
- package/dist/widgets/input/RatingWidget.d.ts +4 -0
- package/examples/conditional-v2-example.tsx +2 -2
- package/examples/form-devtools-example.tsx +7 -9
- package/examples/global-ui-rules-example.tsx +34 -19
- package/package.json +8 -3
- package/dist/extended-dynamic-forms.standalone.js +0 -882
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
|
|
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
|
|
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
|
|
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
|
-
-
|
|
49
|
-
-
|
|
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 {
|
|
73
|
+
import { UiRule, JsonLogicRule } from 'extended-dynamic-forms/conditionals/v2';
|
|
55
74
|
|
|
56
75
|
const uiRules: UiRule[] = [{
|
|
57
|
-
name: '
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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:
|
|
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
|
-
- **
|
|
129
|
-
- **Developer Experience**: Interactive playground with
|
|
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
|
-
- **
|
|
167
|
-
-
|
|
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
|
|
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.
|
|
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 (
|
|
318
|
+
## Three Pillars v2 Architecture with JsonLogic (Required Approach)
|
|
293
319
|
|
|
294
|
-
> ⚠️ **
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
###
|
|
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
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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 (
|
|
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:
|
|
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:
|
|
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: "
|
|
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:
|
|
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 |
|
|
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**:
|
|
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
|
-
- **
|
|
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/ #
|
|
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
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WebhookConfig } from './types';
|
|
2
|
+
|
|
3
|
+
export interface WizardStep {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WizardFormProps {
|
|
9
|
+
schema: any;
|
|
10
|
+
uiSchema: any;
|
|
11
|
+
webhooks?: WebhookConfig[];
|
|
12
|
+
formData?: any;
|
|
13
|
+
onSubmit?: (data: any) => void;
|
|
14
|
+
onStepChange?: (step: number, data: any) => void;
|
|
15
|
+
onFieldFocus?: (event: any) => void;
|
|
16
|
+
onFieldBlur?: (event: any) => void;
|
|
17
|
+
onFieldChange?: (event: any) => void;
|
|
18
|
+
onLiveChange?: (completeFlatData: any) => void;
|
|
19
|
+
showProgressBar?: boolean;
|
|
20
|
+
showStepDescription?: boolean;
|
|
21
|
+
submitButtonText?: string;
|
|
22
|
+
liveValidate?: boolean;
|
|
23
|
+
showErrorList?: boolean;
|
|
24
|
+
}
|
|
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;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AddressField } from './fields/AddressField';
|
|
2
|
+
import { PhoneField } from './fields/PhoneField';
|
|
3
|
+
import { CurrencyField } from './fields/CurrencyField';
|
|
4
|
+
import { ArrayFieldTemplate, ArrayFieldItemTemplate } from './arrays';
|
|
5
|
+
import { WizardObjectFieldTemplate, WizardSectionTemplate } from '../layouts/wizard';
|
|
6
|
+
import { SubmitButton } from './templates/SubmitButton';
|
|
7
|
+
import { FieldTemplate } from './templates/FieldTemplate';
|
|
8
|
+
|
|
9
|
+
export declare const customFields: {
|
|
10
|
+
address: import('react').FC<import('@rjsf/utils').FieldProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
11
|
+
phone: import('react').FC<import('@rjsf/utils').FieldProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
12
|
+
currency: import('react').FC<import('@rjsf/utils').FieldProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
13
|
+
};
|
|
14
|
+
export declare const customTemplates: {
|
|
15
|
+
FieldTemplate: import('react').FC<import('@rjsf/utils').FieldTemplateProps>;
|
|
16
|
+
ArrayFieldTemplate: (props: import('@rjsf/utils').ArrayFieldTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
ArrayFieldItemTemplate: (props: import('@rjsf/utils').ArrayFieldItemTemplateType) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
WizardObjectFieldTemplate: import('react').FC<import('@rjsf/utils').ObjectFieldTemplateProps>;
|
|
19
|
+
WizardSectionTemplate: import('react').FC<import('../layouts/wizard/WizardSectionTemplate').WizardSectionTemplateProps>;
|
|
20
|
+
ButtonTemplates: {
|
|
21
|
+
SubmitButton: import('react').FC<import('@rjsf/utils').SubmitButtonProps>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export { AddressField, PhoneField, CurrencyField, FieldTemplate, ArrayFieldTemplate, ArrayFieldItemTemplate, WizardObjectFieldTemplate, WizardSectionTemplate, SubmitButton, };
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EngineConfig, ValidationEffect } from '../types';
|
|
2
|
+
import { ErrorSchema } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
export interface ValidationConfig {
|
|
5
|
+
rules: ValidationEffect[];
|
|
6
|
+
}
|
|
7
|
+
export declare const validationEngineConfig: EngineConfig<ValidationEffect, ValidationConfig>;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a custom validation function compatible with RJSF
|
|
10
|
+
* @param validationConfig The validation configuration containing active rules
|
|
11
|
+
* @returns A validation function that can be passed to RJSF's customValidate prop
|
|
12
|
+
*/
|
|
13
|
+
export declare function createCustomValidate(validationConfig: ValidationConfig): (formData: any, errors: ErrorSchema) => ErrorSchema;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createConditionalEngineHook } from './createConditionalEngineHook';
|
|
2
|
+
export type { Rule, EngineConfig, ConditionalEngineHook, UiEffect, SchemaEffect, ValidationEffect, } from './types';
|
|
3
|
+
export { useConditionalUi, type UiRule } from './hooks/useConditionalUi';
|
|
4
|
+
export { useConditionalSchema, type SchemaRule, } from './hooks/useConditionalSchema';
|
|
5
|
+
export { useConditionalValidation, type ValidationRule, } from './hooks/useConditionalValidation';
|
|
6
|
+
export { createDynamicArrayItemsUiSchema, mergeItemUiSchema, arrayItemPatterns, type ArrayItemsFunction, type ArrayItemConditionalFn, } from './utils/dynamicArrayItems';
|
|
7
|
+
export { uiEngineConfig } from './engines/uiEngineConfig';
|
|
8
|
+
export { schemaEngineConfig } from './engines/schemaEngineConfig';
|
|
9
|
+
export { validationEngineConfig, createCustomValidate, } from './engines/validationEngineConfig';
|