extended-dynamic-forms 0.1.14 → 0.1.17
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 +251 -385
- package/dist/ExtendedForm.d.ts +1 -1
- package/dist/WizardForm.d.ts +26 -0
- package/dist/components/fields/AddressField.d.ts +0 -1
- package/dist/components/index.d.ts +10 -1
- 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 -4
- package/dist/events/index.d.ts +2 -2
- package/dist/index.d.ts +4 -5
- package/dist/index.es.js +43858 -14797
- package/dist/index.umd.js +390 -104
- package/dist/layouts/index.d.ts +2 -3
- 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/style.css +1 -1
- package/dist/types/index.d.ts +41 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/vanilla-wrapper.d.ts +0 -2
- package/package.json +39 -16
- package/dist/components/ui/badge.d.ts +0 -9
- package/dist/components/ui/button.d.ts +0 -11
- package/dist/components/ui/calendar.d.ts +0 -8
- package/dist/components/ui/card.d.ts +0 -8
- package/dist/components/ui/checkbox.d.ts +0 -4
- package/dist/components/ui/date-picker.d.ts +0 -13
- package/dist/components/ui/input.d.ts +0 -5
- package/dist/components/ui/label.d.ts +0 -5
- package/dist/components/ui/popover.d.ts +0 -6
- package/dist/components/ui/select.d.ts +0 -13
- package/dist/components/ui/slider.d.ts +0 -4
- package/dist/components/ui/textarea.d.ts +0 -5
- package/dist/conditionals/ConditionalForm.d.ts +0 -7
- package/dist/conditionals/initialStateUtils.d.ts +0 -18
- package/dist/conditionals/types.d.ts +0 -65
- package/dist/conditionals/utils.d.ts +0 -22
- package/dist/layouts/grid/GridLayout.d.ts +0 -11
- package/dist/layouts/horizontal/HorizontalLayout.d.ts +0 -10
- package/dist/layouts/vertical/VerticalLayout.d.ts +0 -9
- package/dist/lib/utils.d.ts +0 -3
package/dist/ExtendedForm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ExtendedFormProps } from './types';
|
|
3
3
|
|
|
4
|
-
export declare const ExtendedForm: React.
|
|
4
|
+
export declare const ExtendedForm: React.ForwardRefExoticComponent<Omit<ExtendedFormProps, "ref"> & React.RefAttributes<any>>;
|
|
@@ -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;
|
|
@@ -2,6 +2,9 @@ import { AddressField } from './fields/AddressField';
|
|
|
2
2
|
import { PhoneField } from './fields/PhoneField';
|
|
3
3
|
import { CurrencyField } from './fields/CurrencyField';
|
|
4
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';
|
|
5
8
|
|
|
6
9
|
export declare const customFields: {
|
|
7
10
|
address: import('react').FC<import('@rjsf/utils').FieldProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
@@ -9,7 +12,13 @@ export declare const customFields: {
|
|
|
9
12
|
currency: import('react').FC<import('@rjsf/utils').FieldProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
10
13
|
};
|
|
11
14
|
export declare const customTemplates: {
|
|
15
|
+
FieldTemplate: import('react').FC<import('@rjsf/utils').FieldTemplateProps>;
|
|
12
16
|
ArrayFieldTemplate: (props: import('@rjsf/utils').ArrayFieldTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
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
|
+
};
|
|
14
23
|
};
|
|
15
|
-
export { AddressField, PhoneField, CurrencyField, ArrayFieldTemplate, ArrayFieldItemTemplate, };
|
|
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 };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
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';
|
package/dist/events/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { FormEventManager } from './FormEventManager';
|
|
2
2
|
export { FormEventHub } from './FormEventHub';
|
|
3
|
-
export { FormEventProvider, useFormEventHub, useFieldEventHandlers } from './FormEventContext';
|
|
4
|
-
export type { FormEventHandlers, FieldEventHandlers, FormFieldEvent, WebhookConfig } from '../types';
|
|
3
|
+
export { FormEventProvider, useFormEventHub, useFieldEventHandlers, } from './FormEventContext';
|
|
4
|
+
export type { FormEventHandlers, FieldEventHandlers, FormFieldEvent, WebhookConfig, } from '../types';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,13 +3,12 @@ export * from './components';
|
|
|
3
3
|
export * from './widgets';
|
|
4
4
|
export * from './layouts';
|
|
5
5
|
export * from './events';
|
|
6
|
+
export * from './conditionals';
|
|
6
7
|
export * from './types';
|
|
7
8
|
export * from './utils';
|
|
8
|
-
export * from './lib/utils';
|
|
9
9
|
export type { FormProps, IChangeEvent } from '@rjsf/core';
|
|
10
|
-
export type { RJSFSchema, UiSchema, WidgetProps, FieldProps, ArrayFieldTemplateProps, ObjectFieldTemplateProps, FieldTemplateProps, ErrorSchema, RJSFValidationError } from '@rjsf/utils';
|
|
10
|
+
export type { RJSFSchema, UiSchema, WidgetProps, FieldProps, ArrayFieldTemplateProps, ObjectFieldTemplateProps, FieldTemplateProps, ErrorSchema, RJSFValidationError, } from '@rjsf/utils';
|
|
11
11
|
export { default as validator } from '@rjsf/validator-ajv8';
|
|
12
|
-
export { generateTheme } from '@rjsf/shadcn';
|
|
13
12
|
export { ExtendedForm } from './ExtendedForm';
|
|
14
|
-
export {
|
|
15
|
-
export type {
|
|
13
|
+
export { WizardForm } from './WizardForm';
|
|
14
|
+
export type { WizardFormProps, WizardStep } from './WizardForm';
|