extended-dynamic-forms 0.1.21 → 0.1.22
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/dist/ExtendedForm.d.ts +4 -0
- package/dist/WizardForm.d.ts +26 -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/ConditionalActions.d.ts +13 -0
- package/dist/conditionals/ConditionalContext.d.ts +32 -0
- package/dist/conditionals/DynamicArrayConditionalEngine.d.ts +77 -0
- package/dist/conditionals/SimpleConditionalEngine.d.ts +41 -0
- package/dist/conditionals/SmartJsonRulesTransformer.d.ts +10 -0
- package/dist/conditionals/index.d.ts +7 -0
- package/dist/conditionals/v2/createConditionalEngineHook.d.ts +3 -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 +10 -0
- package/dist/conditionals/v2/migration.d.ts +76 -0
- package/dist/conditionals/v2/types.d.ts +37 -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/hooks/useFormDevTools.d.ts +48 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.es.js +20325 -0
- package/dist/index.umd.js +172 -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 +88 -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 +208 -0
- package/dist/widgets/date/DateWidget.d.ts +4 -0
- package/dist/widgets/enhanced/EnhancedWidgets.d.ts +36 -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/package.json +2 -2
- package/dist/extended-dynamic-forms.standalone.js +0 -882
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
conditions?: any[];
|
|
12
|
+
webhooks?: WebhookConfig[];
|
|
13
|
+
formData?: any;
|
|
14
|
+
onSubmit?: (data: any) => void;
|
|
15
|
+
onStepChange?: (step: number, data: any) => void;
|
|
16
|
+
onFieldFocus?: (event: any) => void;
|
|
17
|
+
onFieldBlur?: (event: any) => void;
|
|
18
|
+
onFieldChange?: (event: 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, 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;
|
|
@@ -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,13 @@
|
|
|
1
|
+
import { ConditionalAction, ConditionalActions } from '../types';
|
|
2
|
+
|
|
3
|
+
declare const remove: ConditionalAction;
|
|
4
|
+
declare const require: ConditionalAction;
|
|
5
|
+
declare const uiAppend: ConditionalAction;
|
|
6
|
+
declare const uiOverride: ConditionalAction;
|
|
7
|
+
declare const uiReplace: ConditionalAction;
|
|
8
|
+
declare const enable: ConditionalAction;
|
|
9
|
+
declare const disable: ConditionalAction;
|
|
10
|
+
declare const optional: ConditionalAction;
|
|
11
|
+
declare const show: ConditionalAction;
|
|
12
|
+
export declare const defaultActions: ConditionalActions;
|
|
13
|
+
export { remove, require, uiAppend, uiOverride, uiReplace, enable, disable, optional, show, };
|
|
@@ -0,0 +1,32 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 };
|
|
@@ -0,0 +1,7 @@
|
|
|
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';
|
|
@@ -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,10 @@
|
|
|
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';
|
|
10
|
+
export * from './migration';
|
|
@@ -0,0 +1,76 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ErrorSchema } from '@rjsf/utils';
|
|
2
|
+
|
|
3
|
+
export interface Rule<T> {
|
|
4
|
+
name: string;
|
|
5
|
+
condition: (formData: any) => boolean;
|
|
6
|
+
effect: T;
|
|
7
|
+
order?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface EngineConfig<T, C = any> {
|
|
10
|
+
applyEffects: (effects: T[], baseConfig: C, formData: any) => C;
|
|
11
|
+
defaultConfig: () => C;
|
|
12
|
+
}
|
|
13
|
+
export type ConditionalEngineHook<T, C = any> = (rules: Rule<T>[], baseConfig: C, formData: any) => C;
|
|
14
|
+
export interface UiEffect {
|
|
15
|
+
op: 'add' | 'remove' | 'replace';
|
|
16
|
+
path: string;
|
|
17
|
+
value?: any;
|
|
18
|
+
}
|
|
19
|
+
export interface SchemaEffect {
|
|
20
|
+
op: 'add' | 'remove' | 'replace';
|
|
21
|
+
path: string;
|
|
22
|
+
value?: any;
|
|
23
|
+
}
|
|
24
|
+
export interface ValidationEffect {
|
|
25
|
+
/**
|
|
26
|
+
* Name of the validation rule for debugging purposes
|
|
27
|
+
*/
|
|
28
|
+
name: string;
|
|
29
|
+
/**
|
|
30
|
+
* Determines if this validation should be applied based on current form data
|
|
31
|
+
*/
|
|
32
|
+
isActive: (formData: any) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Applies validation logic and adds errors to the ErrorSchema
|
|
35
|
+
*/
|
|
36
|
+
validate: (errors: ErrorSchema, formData: any) => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { UiSchema } from '@rjsf/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Function type for dynamic uiSchema.items in RJSF fork
|
|
5
|
+
* This enables O(n) performance for array conditionals
|
|
6
|
+
*/
|
|
7
|
+
export type ArrayItemsFunction = (itemData: any, index: number, formContext?: any) => UiSchema;
|
|
8
|
+
/**
|
|
9
|
+
* Function type for conditional logic applied to array items
|
|
10
|
+
*/
|
|
11
|
+
export type ArrayItemConditionalFn = (itemData: any, index: number, formContext?: any) => Partial<UiSchema>;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a dynamic uiSchema.items function for array fields
|
|
14
|
+
*
|
|
15
|
+
* @param baseItemUiSchema - Base UI schema applied to all array items
|
|
16
|
+
* @param conditionalLogic - Function that returns conditional UI schema modifications
|
|
17
|
+
* @returns Function compatible with RJSF fork's dynamic uiSchema.items
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const directorsUiSchema = {
|
|
22
|
+
* items: createDynamicArrayItemsUiSchema(
|
|
23
|
+
* { 'ui:order': ['name', 'hasShareholding', 'shareholdingPercentage'] },
|
|
24
|
+
* (itemData) => {
|
|
25
|
+
* if (!itemData?.hasShareholding) {
|
|
26
|
+
* return { shareholdingPercentage: { 'ui:widget': 'hidden' } };
|
|
27
|
+
* }
|
|
28
|
+
* return {};
|
|
29
|
+
* }
|
|
30
|
+
* )
|
|
31
|
+
* };
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function createDynamicArrayItemsUiSchema(baseItemUiSchema: UiSchema, conditionalLogic: ArrayItemConditionalFn): ArrayItemsFunction;
|
|
35
|
+
/**
|
|
36
|
+
* Safely merges UI schemas with proper handling of nested properties
|
|
37
|
+
*
|
|
38
|
+
* @param base - Base UI schema
|
|
39
|
+
* @param overrides - Conditional UI schema overrides
|
|
40
|
+
* @returns Merged UI schema
|
|
41
|
+
*/
|
|
42
|
+
export declare function mergeItemUiSchema(base: UiSchema, overrides: Partial<UiSchema>): UiSchema;
|
|
43
|
+
/**
|
|
44
|
+
* Helper to create common conditional patterns
|
|
45
|
+
*/
|
|
46
|
+
export declare const arrayItemPatterns: {
|
|
47
|
+
/**
|
|
48
|
+
* Show/hide a field based on a condition
|
|
49
|
+
*/
|
|
50
|
+
hideField: (fieldName: string, condition: (itemData: any) => boolean) => ArrayItemConditionalFn;
|
|
51
|
+
/**
|
|
52
|
+
* Make a field required based on a condition
|
|
53
|
+
*/
|
|
54
|
+
requireField: (fieldName: string, condition: (itemData: any) => boolean) => ArrayItemConditionalFn;
|
|
55
|
+
/**
|
|
56
|
+
* Apply styles to first/last items
|
|
57
|
+
*/
|
|
58
|
+
applyIndexStyles: (totalItems: number) => ArrayItemConditionalFn;
|
|
59
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple JSON Patch-like utility for applying operations to objects
|
|
3
|
+
* Supports add, remove, and replace operations with JSONPath-like syntax
|
|
4
|
+
*/
|
|
5
|
+
export declare function applyPatch(target: any, operations: Array<{
|
|
6
|
+
op: string;
|
|
7
|
+
path: string;
|
|
8
|
+
value?: any;
|
|
9
|
+
}>): any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { FormEventHub } from './FormEventHub';
|
|
3
|
+
|
|
4
|
+
export interface FormEventContextType {
|
|
5
|
+
eventHub: FormEventHub;
|
|
6
|
+
formData?: any;
|
|
7
|
+
}
|
|
8
|
+
export interface FormEventProviderProps {
|
|
9
|
+
eventHub: FormEventHub;
|
|
10
|
+
formData?: any;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare const FormEventProvider: React.FC<FormEventProviderProps>;
|
|
14
|
+
export declare const useFormEventHub: () => FormEventContextType;
|
|
15
|
+
export declare const useFieldEventHandlers: (fieldId: string, schema?: any, fieldPath?: string[]) => {
|
|
16
|
+
onFocus: (value: any) => Promise<void>;
|
|
17
|
+
onBlur: (value: any) => Promise<void>;
|
|
18
|
+
onChange: (value: any) => Promise<void>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FormEventHandlers, FieldEventHandlers, WebhookConfig } from '../types';
|
|
2
|
+
|
|
3
|
+
export declare class FormEventHub {
|
|
4
|
+
private formHandlers;
|
|
5
|
+
private fieldHandlers;
|
|
6
|
+
private webhooks;
|
|
7
|
+
private debounceTimers;
|
|
8
|
+
private webhookQueue;
|
|
9
|
+
private isProcessingQueue;
|
|
10
|
+
constructor(formHandlers: FormEventHandlers, fieldHandlers?: FieldEventHandlers, webhooks?: WebhookConfig[]);
|
|
11
|
+
handleBeforeSubmit(data: any): Promise<any>;
|
|
12
|
+
handleAfterSubmit(data: any): Promise<void>;
|
|
13
|
+
handleBeforeValidation(data: any): Promise<any>;
|
|
14
|
+
handleAfterValidation(data: any, errors: any): Promise<void>;
|
|
15
|
+
handleFieldEvent(eventType: 'focus' | 'blur' | 'change', fieldId: string, fieldValue: any, schema?: any, formData?: any, fieldPath?: string[]): Promise<void>;
|
|
16
|
+
private processWebhooks;
|
|
17
|
+
private debounceWebhook;
|
|
18
|
+
private queueWebhook;
|
|
19
|
+
private processWebhookQueue;
|
|
20
|
+
private callWebhook;
|
|
21
|
+
createFieldEventHandlers(fieldId: string, schema?: any, formData?: any, fieldPath?: string[]): {
|
|
22
|
+
onFocus: (value: any) => Promise<void>;
|
|
23
|
+
onBlur: (value: any) => Promise<void>;
|
|
24
|
+
onChange: (value: any) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
cleanup(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormEventHandlers } from '../types';
|
|
2
|
+
|
|
3
|
+
export declare class FormEventManager {
|
|
4
|
+
private handlers;
|
|
5
|
+
constructor(handlers: FormEventHandlers);
|
|
6
|
+
handleBeforeSubmit(data: any): Promise<any>;
|
|
7
|
+
handleAfterSubmit(data: any): Promise<void>;
|
|
8
|
+
handleBeforeValidation(data: any): Promise<any>;
|
|
9
|
+
handleAfterValidation(data: any, errors: any): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { FormEventManager } from './FormEventManager';
|
|
2
|
+
export { FormEventHub } from './FormEventHub';
|
|
3
|
+
export { FormEventProvider, useFormEventHub, useFieldEventHandlers, } from './FormEventContext';
|
|
4
|
+
export type { FormEventHandlers, FieldEventHandlers, FormFieldEvent, WebhookConfig, } from '../types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useFormDevTools';
|