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 +134 -70
- package/dist/WizardForm.d.ts +2 -3
- package/dist/conditionals/index.d.ts +1 -7
- package/dist/conditionals/v2/effects/customHandlers.d.ts +35 -0
- package/dist/conditionals/v2/index.d.ts +1 -2
- package/dist/conditionals/v2/types.d.ts +13 -3
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.es.js +7754 -9004
- package/dist/index.umd.js +28 -38
- package/dist/types/index.d.ts +0 -41
- package/dist/vanilla-entry.d.ts +65 -69
- package/dist/widgets/enhanced/EnhancedWidgets.d.ts +33 -32
- package/dist/widgets/index.d.ts +19 -19
- 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 +12 -2
- package/dist/conditionals/ConditionalActions.d.ts +0 -13
- package/dist/conditionals/ConditionalContext.d.ts +0 -32
- package/dist/conditionals/DynamicArrayConditionalEngine.d.ts +0 -77
- package/dist/conditionals/SimpleConditionalEngine.d.ts +0 -41
- package/dist/conditionals/SmartJsonRulesTransformer.d.ts +0 -10
- package/dist/conditionals/v2/migration.d.ts +0 -76
- package/dist/hooks/useFormDevTools.d.ts +0 -48
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { RJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
|
-
import { ConditionalRule, ConditionalConfig, ConditionalState } from '../types';
|
|
4
|
-
import { DynamicArrayConditionalEngine } from './DynamicArrayConditionalEngine';
|
|
5
|
-
|
|
6
|
-
interface ConditionalContextType {
|
|
7
|
-
state: ConditionalState;
|
|
8
|
-
processor: DynamicArrayConditionalEngine | null;
|
|
9
|
-
processConditionals: (formData: any) => Promise<void>;
|
|
10
|
-
updateRules: (rules: ConditionalRule[]) => void;
|
|
11
|
-
addAction: (actionType: string, actionFunction: any) => void;
|
|
12
|
-
removeAction: (actionType: string) => void;
|
|
13
|
-
getAvailableActions: () => string[];
|
|
14
|
-
}
|
|
15
|
-
export interface ConditionalProviderProps {
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
schema: RJSFSchema;
|
|
18
|
-
uiSchema?: UiSchema;
|
|
19
|
-
config?: ConditionalConfig;
|
|
20
|
-
onSchemaChange?: (schemas: {
|
|
21
|
-
schema: RJSFSchema;
|
|
22
|
-
uiSchema: UiSchema;
|
|
23
|
-
}) => void;
|
|
24
|
-
}
|
|
25
|
-
export declare const ConditionalProvider: React.FC<ConditionalProviderProps>;
|
|
26
|
-
export declare const useConditionals: () => ConditionalContextType;
|
|
27
|
-
export declare const useConditionalSchema: () => {
|
|
28
|
-
schema: RJSFSchema;
|
|
29
|
-
uiSchema: UiSchema;
|
|
30
|
-
isProcessing: boolean;
|
|
31
|
-
};
|
|
32
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { RJSFSchema, UiSchema } from '@rjsf/utils';
|
|
2
|
-
import { ConditionalRule, ConditionalEvent, ConditionalActions, ConditionalEngineInstance } from '../types';
|
|
3
|
-
|
|
4
|
-
export declare class DynamicArrayConditionalEngine implements ConditionalEngineInstance {
|
|
5
|
-
private originalRules;
|
|
6
|
-
private engine;
|
|
7
|
-
private expandedRules;
|
|
8
|
-
constructor(rules: ConditionalRule[], schema: RJSFSchema, uiSchema?: UiSchema, extraActions?: ConditionalActions);
|
|
9
|
-
/**
|
|
10
|
-
* Expand array patterns like directors[*] based on actual form data
|
|
11
|
-
*/
|
|
12
|
-
expandArrayPatterns(rules: ConditionalRule[], formData: any): ConditionalRule[];
|
|
13
|
-
/**
|
|
14
|
-
* Check if a rule contains array patterns like [*]
|
|
15
|
-
*/
|
|
16
|
-
private hasArrayPatterns;
|
|
17
|
-
/**
|
|
18
|
-
* Expand a single rule that contains array patterns
|
|
19
|
-
*/
|
|
20
|
-
private expandSingleRule;
|
|
21
|
-
/**
|
|
22
|
-
* Find all array patterns like "directors[*]" in a rule
|
|
23
|
-
*/
|
|
24
|
-
private findArrayPatterns;
|
|
25
|
-
/**
|
|
26
|
-
* Expand a rule for a specific array index
|
|
27
|
-
*/
|
|
28
|
-
private expandRuleForIndex;
|
|
29
|
-
/**
|
|
30
|
-
* Get nested value from object using dot notation
|
|
31
|
-
*/
|
|
32
|
-
private getNestedValue;
|
|
33
|
-
/**
|
|
34
|
-
* Pre-process uiSchema to ensure array items have proper template structure
|
|
35
|
-
*/
|
|
36
|
-
private preprocessUiSchemaForArrays;
|
|
37
|
-
/**
|
|
38
|
-
* Main processing method - implement ConditionalEngineInstance interface
|
|
39
|
-
*/
|
|
40
|
-
processFormData(formData: any): Promise<{
|
|
41
|
-
schema: RJSFSchema;
|
|
42
|
-
uiSchema: UiSchema;
|
|
43
|
-
formData: any;
|
|
44
|
-
}>;
|
|
45
|
-
/**
|
|
46
|
-
* Get the original unexpanded rules
|
|
47
|
-
*/
|
|
48
|
-
getOriginalRules(): ConditionalRule[];
|
|
49
|
-
/**
|
|
50
|
-
* Get the current expanded rules
|
|
51
|
-
*/
|
|
52
|
-
getCurrentRules(): ConditionalRule[];
|
|
53
|
-
/**
|
|
54
|
-
* Manually set rules (useful for testing)
|
|
55
|
-
*/
|
|
56
|
-
setRules(rules: ConditionalRule[]): void;
|
|
57
|
-
/**
|
|
58
|
-
* Add a rule to the engine (implement ConditionalEngineInstance interface)
|
|
59
|
-
*/
|
|
60
|
-
addRule(rule: ConditionalRule): void;
|
|
61
|
-
/**
|
|
62
|
-
* Run the conditional engine and return events (implement ConditionalEngineInstance interface)
|
|
63
|
-
*/
|
|
64
|
-
run(formData: any): Promise<ConditionalEvent[]>;
|
|
65
|
-
/**
|
|
66
|
-
* Add an action to the engine (for ConditionalContext compatibility)
|
|
67
|
-
*/
|
|
68
|
-
addAction(actionType: string, actionFunction: any): void;
|
|
69
|
-
/**
|
|
70
|
-
* Remove an action from the engine (for ConditionalContext compatibility)
|
|
71
|
-
*/
|
|
72
|
-
removeAction(actionType: string): void;
|
|
73
|
-
/**
|
|
74
|
-
* Get available actions (for ConditionalContext compatibility)
|
|
75
|
-
*/
|
|
76
|
-
getAvailableActions(): string[];
|
|
77
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { RJSFSchema, UiSchema } from '@rjsf/utils';
|
|
2
|
-
import { ConditionalRule, ConditionalEvent, ConditionalActions, ConditionalEngineInstance } from '../types';
|
|
3
|
-
|
|
4
|
-
export declare class SimpleConditionalEngine implements ConditionalEngineInstance {
|
|
5
|
-
private rules;
|
|
6
|
-
private actions;
|
|
7
|
-
private originalSchema;
|
|
8
|
-
private originalUiSchema;
|
|
9
|
-
constructor(rules: ConditionalRule[], schema: RJSFSchema, uiSchema?: UiSchema, extraActions?: ConditionalActions);
|
|
10
|
-
/**
|
|
11
|
-
* Get nested value from object using dot notation with array index support
|
|
12
|
-
*/
|
|
13
|
-
private getNestedValue;
|
|
14
|
-
/**
|
|
15
|
-
* Evaluate a single condition against form data
|
|
16
|
-
*/
|
|
17
|
-
private evaluateCondition;
|
|
18
|
-
/**
|
|
19
|
-
* Evaluate field-level condition
|
|
20
|
-
*/
|
|
21
|
-
private evaluateFieldCondition;
|
|
22
|
-
addRule(rule: ConditionalRule): void;
|
|
23
|
-
run(formData: any): Promise<ConditionalEvent[]>;
|
|
24
|
-
processEvents(events: ConditionalEvent[], schema: RJSFSchema, uiSchema: UiSchema, formData: any): {
|
|
25
|
-
schema: RJSFSchema;
|
|
26
|
-
uiSchema: UiSchema;
|
|
27
|
-
};
|
|
28
|
-
processFormData(formData: any): Promise<{
|
|
29
|
-
schema: RJSFSchema;
|
|
30
|
-
uiSchema: UiSchema;
|
|
31
|
-
formData: any;
|
|
32
|
-
}>;
|
|
33
|
-
runAndProcess(formData: any, schema: RJSFSchema, uiSchema: UiSchema): Promise<{
|
|
34
|
-
schema: RJSFSchema;
|
|
35
|
-
uiSchema: UiSchema;
|
|
36
|
-
events: ConditionalEvent[];
|
|
37
|
-
}>;
|
|
38
|
-
getAvailableActions(): string[];
|
|
39
|
-
addAction(actionType: string, actionFunction: any): void;
|
|
40
|
-
removeAction(actionType: string): void;
|
|
41
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ConditionalRule } from '../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Smart transformation of JSON Rules Engine rules to internal format
|
|
5
|
-
*
|
|
6
|
-
* Handles show/hide pairs intelligently by converting them to single remove rules
|
|
7
|
-
* Also handles rules that are already in internal format
|
|
8
|
-
*/
|
|
9
|
-
export declare function smartTransformJsonRulesEngine(rules: any[]): ConditionalRule[];
|
|
10
|
-
export { smartTransformJsonRulesEngine as transformJsonRulesEngine };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { UiRule } from './hooks/useConditionalUi';
|
|
2
|
-
import { SchemaRule } from './hooks/useConditionalSchema';
|
|
3
|
-
|
|
4
|
-
interface V1Rule {
|
|
5
|
-
conditions: Record<string, any>;
|
|
6
|
-
event: {
|
|
7
|
-
type: string;
|
|
8
|
-
params?: any;
|
|
9
|
-
};
|
|
10
|
-
order?: number;
|
|
11
|
-
}
|
|
12
|
-
interface JsonRulesEngineRule {
|
|
13
|
-
conditions: {
|
|
14
|
-
all?: JsonRulesEngineCondition[];
|
|
15
|
-
any?: JsonRulesEngineCondition[];
|
|
16
|
-
};
|
|
17
|
-
event: {
|
|
18
|
-
type: string;
|
|
19
|
-
params?: any;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
interface JsonRulesEngineCondition {
|
|
23
|
-
fact: string;
|
|
24
|
-
operator: string;
|
|
25
|
-
value: any;
|
|
26
|
-
all?: JsonRulesEngineCondition[];
|
|
27
|
-
any?: JsonRulesEngineCondition[];
|
|
28
|
-
}
|
|
29
|
-
export interface MigrationReport {
|
|
30
|
-
totalRules: number;
|
|
31
|
-
migratedRules: number;
|
|
32
|
-
manualReviewRequired: Array<{
|
|
33
|
-
rule: any;
|
|
34
|
-
reason: string;
|
|
35
|
-
suggestion: string;
|
|
36
|
-
}>;
|
|
37
|
-
warnings: string[];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Analyzes v1 rules and suggests which pillar they belong to
|
|
41
|
-
*/
|
|
42
|
-
export declare function analyzeRules(rules: V1Rule[]): {
|
|
43
|
-
uiRules: V1Rule[];
|
|
44
|
-
schemaRules: V1Rule[];
|
|
45
|
-
validationRules: V1Rule[];
|
|
46
|
-
unknown: V1Rule[];
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Migrates v1 rules to v2 UI rules
|
|
50
|
-
*/
|
|
51
|
-
export declare function migrateV1ToUiRules(rules: V1Rule[]): {
|
|
52
|
-
rules: UiRule[];
|
|
53
|
-
report: MigrationReport;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Migrates v1 rules to v2 Schema rules
|
|
57
|
-
*/
|
|
58
|
-
export declare function migrateV1ToSchemaRules(rules: V1Rule[]): {
|
|
59
|
-
rules: SchemaRule[];
|
|
60
|
-
report: MigrationReport;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Migrates JSON Rules Engine format to Three Pillars format
|
|
64
|
-
*/
|
|
65
|
-
export declare function migrateJsonRulesEngine(rules: JsonRulesEngineRule[]): {
|
|
66
|
-
uiRules: UiRule[];
|
|
67
|
-
report: MigrationReport;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Generates a comprehensive migration report
|
|
71
|
-
*/
|
|
72
|
-
export declare function generateMigrationReport(v1Rules: V1Rule[], options?: {
|
|
73
|
-
includeExamples?: boolean;
|
|
74
|
-
outputFormat?: 'markdown' | 'json';
|
|
75
|
-
}): string;
|
|
76
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Rule, UiEffect, SchemaEffect, ValidationEffect } from '../conditionals/v2/types';
|
|
2
|
-
|
|
3
|
-
export interface DevToolsOptions {
|
|
4
|
-
enabled: boolean;
|
|
5
|
-
logToConsole?: boolean;
|
|
6
|
-
captureHistory?: boolean;
|
|
7
|
-
historySize?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface RuleEvaluation {
|
|
10
|
-
ruleName: string;
|
|
11
|
-
pillar: 'UI' | 'Schema' | 'Validation';
|
|
12
|
-
active: boolean;
|
|
13
|
-
error?: string;
|
|
14
|
-
timestamp: number;
|
|
15
|
-
}
|
|
16
|
-
export interface DevToolsHistory {
|
|
17
|
-
formData: any;
|
|
18
|
-
evaluations: RuleEvaluation[];
|
|
19
|
-
timestamp: number;
|
|
20
|
-
}
|
|
21
|
-
export interface DevToolsOutput {
|
|
22
|
-
evaluations: RuleEvaluation[];
|
|
23
|
-
history: DevToolsHistory[];
|
|
24
|
-
activeRules: {
|
|
25
|
-
ui: string[];
|
|
26
|
-
schema: string[];
|
|
27
|
-
validation: string[];
|
|
28
|
-
};
|
|
29
|
-
hasErrors: boolean;
|
|
30
|
-
errors: RuleEvaluation[];
|
|
31
|
-
summary: {
|
|
32
|
-
totalRules: number;
|
|
33
|
-
activeCount: number;
|
|
34
|
-
errorCount: number;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Debugging hook for the Three Pillars conditional system.
|
|
39
|
-
* Provides visibility into which rules are active and any errors that occur.
|
|
40
|
-
*
|
|
41
|
-
* @param formData - Current form data
|
|
42
|
-
* @param uiRules - UI pillar rules
|
|
43
|
-
* @param schemaRules - Schema pillar rules
|
|
44
|
-
* @param validationRules - Validation pillar rules
|
|
45
|
-
* @param options - DevTools configuration options
|
|
46
|
-
* @returns DevToolsOutput with evaluation results and debugging information
|
|
47
|
-
*/
|
|
48
|
-
export declare function useFormDevTools(formData: any, uiRules?: Rule<UiEffect>[], schemaRules?: Rule<SchemaEffect>[], validationRules?: Rule<ValidationEffect>[], options?: DevToolsOptions): DevToolsOutput;
|