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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ProgressIndicatorProps {
|
|
4
|
+
currentStep: number;
|
|
5
|
+
totalSteps: number;
|
|
6
|
+
progressPercentage: number;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
}
|
|
10
|
+
export declare const ProgressIndicator: React.FC<ProgressIndicatorProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { WizardStep } from './WizardLayout';
|
|
3
|
+
|
|
4
|
+
export interface StepNavigationProps {
|
|
5
|
+
steps: WizardStep[];
|
|
6
|
+
currentStep: number;
|
|
7
|
+
onStepChange?: (stepIndex: number) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
export declare const StepNavigation: React.FC<StepNavigationProps>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface WizardStep {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
icon?: React.ComponentType<{
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
completed?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface WizardLayoutProps {
|
|
14
|
+
title: string;
|
|
15
|
+
subtitle?: string;
|
|
16
|
+
steps: WizardStep[];
|
|
17
|
+
currentStep: number;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
onStepChange?: (stepIndex: number) => void;
|
|
20
|
+
onPrevious?: () => void;
|
|
21
|
+
onNext?: () => void;
|
|
22
|
+
onSubmit?: () => void;
|
|
23
|
+
canGoNext?: boolean;
|
|
24
|
+
canGoPrevious?: boolean;
|
|
25
|
+
isLastStep?: boolean;
|
|
26
|
+
submitLabel?: string;
|
|
27
|
+
nextLabel?: string;
|
|
28
|
+
previousLabel?: string;
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const WizardLayout: React.FC<WizardLayoutProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface WizardNavigationProps {
|
|
4
|
+
onPrevious?: () => void;
|
|
5
|
+
onNext?: () => void;
|
|
6
|
+
onSubmit?: () => void;
|
|
7
|
+
canGoNext?: boolean;
|
|
8
|
+
canGoPrevious?: boolean;
|
|
9
|
+
isLastStep?: boolean;
|
|
10
|
+
submitLabel?: string;
|
|
11
|
+
nextLabel?: string;
|
|
12
|
+
previousLabel?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
export declare const WizardNavigation: React.FC<WizardNavigationProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ObjectFieldTemplateProps } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
export interface WizardSectionTemplateProps extends ObjectFieldTemplateProps {
|
|
5
|
+
sectionTitle?: string;
|
|
6
|
+
sectionDescription?: string;
|
|
7
|
+
sectionIcon?: React.ComponentType<{
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare const WizardSectionTemplate: React.FC<WizardSectionTemplateProps>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { WizardLayout } from './WizardLayout';
|
|
2
|
+
export { ProgressIndicator } from './ProgressIndicator';
|
|
3
|
+
export { StepNavigation } from './StepNavigation';
|
|
4
|
+
export { WizardNavigation } from './WizardNavigation';
|
|
5
|
+
export { WizardObjectFieldTemplate } from './WizardObjectFieldTemplate';
|
|
6
|
+
export { WizardSectionTemplate } from './WizardSectionTemplate';
|
|
7
|
+
export type { WizardStep } from './WizardLayout';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FormProps } from '@rjsf/core';
|
|
2
|
+
import { RJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
export interface FormEventHandlers {
|
|
5
|
+
beforeSubmit?: (data: any) => Promise<any> | any;
|
|
6
|
+
afterSubmit?: (data: any) => Promise<void> | void;
|
|
7
|
+
beforeValidation?: (data: any) => Promise<any> | any;
|
|
8
|
+
afterValidation?: (data: any, errors: any) => Promise<void> | void;
|
|
9
|
+
}
|
|
10
|
+
export interface FormFieldEvent {
|
|
11
|
+
eventType: 'focus' | 'blur' | 'change';
|
|
12
|
+
fieldId: string;
|
|
13
|
+
fieldValue: any;
|
|
14
|
+
schema?: any;
|
|
15
|
+
formData?: any;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
fieldPath?: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface WebhookConfig {
|
|
20
|
+
url: string;
|
|
21
|
+
method?: 'POST' | 'PUT' | 'PATCH';
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
events?: ('focus' | 'blur' | 'change')[];
|
|
24
|
+
debounceMs?: number;
|
|
25
|
+
retries?: number;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface FieldEventHandlers {
|
|
29
|
+
onFieldFocus?: (event: FormFieldEvent) => Promise<void> | void;
|
|
30
|
+
onFieldBlur?: (event: FormFieldEvent) => Promise<void> | void;
|
|
31
|
+
onFieldChange?: (event: FormFieldEvent) => Promise<void> | void;
|
|
32
|
+
}
|
|
33
|
+
export interface ExtendedFormProps extends Omit<FormProps, 'validator'>, FormEventHandlers, FieldEventHandlers {
|
|
34
|
+
schema: RJSFSchema;
|
|
35
|
+
uiSchema?: UiSchema;
|
|
36
|
+
webhooks?: WebhookConfig[];
|
|
37
|
+
}
|
|
38
|
+
export interface CustomWidgetProps {
|
|
39
|
+
label?: string;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
readonly?: boolean;
|
|
43
|
+
autofocus?: boolean;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
help?: string;
|
|
46
|
+
rawErrors?: string[];
|
|
47
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const formDataUtils: {
|
|
2
|
+
/**
|
|
3
|
+
* Deep clone form data to avoid mutations
|
|
4
|
+
*/
|
|
5
|
+
cloneFormData: (data: any) => any;
|
|
6
|
+
/**
|
|
7
|
+
* Merge two form data objects
|
|
8
|
+
*/
|
|
9
|
+
mergeFormData: (current: any, updates: any) => any;
|
|
10
|
+
/**
|
|
11
|
+
* Get nested value from form data using dot notation
|
|
12
|
+
*/
|
|
13
|
+
getNestedValue: (data: any, path: string) => any;
|
|
14
|
+
/**
|
|
15
|
+
* Set nested value in form data using dot notation
|
|
16
|
+
*/
|
|
17
|
+
setNestedValue: (data: any, path: string, value: any) => any;
|
|
18
|
+
/**
|
|
19
|
+
* Remove empty values from form data
|
|
20
|
+
*/
|
|
21
|
+
removeEmptyValues: (data: any) => any;
|
|
22
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RJSFSchema } from '@rjsf/utils';
|
|
2
|
+
|
|
3
|
+
export declare const schemaUtils: {
|
|
4
|
+
/**
|
|
5
|
+
* Get required fields from schema
|
|
6
|
+
*/
|
|
7
|
+
getRequiredFields: (schema: RJSFSchema) => string[];
|
|
8
|
+
/**
|
|
9
|
+
* Check if a field is required
|
|
10
|
+
*/
|
|
11
|
+
isFieldRequired: (schema: RJSFSchema, fieldName: string) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Get field schema by path
|
|
14
|
+
*/
|
|
15
|
+
getFieldSchema: (schema: RJSFSchema, path: string) => RJSFSchema | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Merge two schemas
|
|
18
|
+
*/
|
|
19
|
+
mergeSchemas: (schema1: RJSFSchema, schema2: RJSFSchema) => RJSFSchema;
|
|
20
|
+
/**
|
|
21
|
+
* Get all field paths from schema
|
|
22
|
+
*/
|
|
23
|
+
getAllFieldPaths: (schema: RJSFSchema, prefix?: string) => string[];
|
|
24
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const validationUtils: {
|
|
2
|
+
/**
|
|
3
|
+
* Validate email format
|
|
4
|
+
*/
|
|
5
|
+
isValidEmail: (email: string) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Validate phone number format
|
|
8
|
+
*/
|
|
9
|
+
isValidPhone: (phone: string) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Validate URL format
|
|
12
|
+
*/
|
|
13
|
+
isValidUrl: (url: string) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Validate date format
|
|
16
|
+
*/
|
|
17
|
+
isValidDate: (date: string) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Validate number in range
|
|
20
|
+
*/
|
|
21
|
+
isInRange: (value: number, min?: number, max?: number) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Custom validation messages
|
|
24
|
+
*/
|
|
25
|
+
getValidationMessage: (type: string, params?: any) => string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { default as ReactDOM } from 'react-dom/client';
|
|
3
|
+
import { default as dayjs } from 'dayjs';
|
|
4
|
+
|
|
5
|
+
import * as antd from 'antd';
|
|
6
|
+
import * as ExtendedDynamicFormsExports from './index';
|
|
7
|
+
declare function createForm(config: {
|
|
8
|
+
container: string | HTMLElement;
|
|
9
|
+
schema: any;
|
|
10
|
+
uiSchema?: any;
|
|
11
|
+
formData?: any;
|
|
12
|
+
onChange?: (data: any) => void;
|
|
13
|
+
onSubmit?: (data: any) => void;
|
|
14
|
+
onError?: (errors: any) => void;
|
|
15
|
+
webhooks?: any;
|
|
16
|
+
widgets?: any;
|
|
17
|
+
fields?: any;
|
|
18
|
+
}): {
|
|
19
|
+
setFormData: (data: any) => void;
|
|
20
|
+
destroy: () => void;
|
|
21
|
+
};
|
|
22
|
+
declare function createWizardForm(config: {
|
|
23
|
+
container: string | HTMLElement;
|
|
24
|
+
schema: any;
|
|
25
|
+
uiSchema?: any;
|
|
26
|
+
formData?: any;
|
|
27
|
+
onStepChange?: (step: number, data: any) => void;
|
|
28
|
+
onSubmit?: (data: any) => void;
|
|
29
|
+
webhooks?: any;
|
|
30
|
+
}): {
|
|
31
|
+
destroy: () => void;
|
|
32
|
+
};
|
|
33
|
+
declare const ExtendedDynamicForms: {
|
|
34
|
+
utils: {
|
|
35
|
+
createSchema: (properties: any) => {
|
|
36
|
+
type: string;
|
|
37
|
+
properties: any;
|
|
38
|
+
required: string[];
|
|
39
|
+
};
|
|
40
|
+
createUiSchema: (fields: any) => any;
|
|
41
|
+
widgets: {
|
|
42
|
+
text: string;
|
|
43
|
+
textarea: string;
|
|
44
|
+
select: string;
|
|
45
|
+
checkbox: string;
|
|
46
|
+
radio: string;
|
|
47
|
+
date: string;
|
|
48
|
+
datetime: string;
|
|
49
|
+
email: string;
|
|
50
|
+
password: string;
|
|
51
|
+
number: string;
|
|
52
|
+
file: string;
|
|
53
|
+
hidden: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
validator: import('@rjsf/validator-ajv8/lib/validator.js').default<any, ExtendedDynamicFormsExports.RJSFSchema, any>;
|
|
57
|
+
ExtendedForm: React.ForwardRefExoticComponent<Omit<ExtendedDynamicFormsExports.ExtendedFormProps, "ref"> & React.RefAttributes<any>>;
|
|
58
|
+
WizardForm: typeof ExtendedDynamicFormsExports.WizardForm;
|
|
59
|
+
customFields: {
|
|
60
|
+
address: React.FC<ExtendedDynamicFormsExports.FieldProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
61
|
+
phone: React.FC<ExtendedDynamicFormsExports.FieldProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
62
|
+
currency: React.FC<ExtendedDynamicFormsExports.FieldProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
63
|
+
};
|
|
64
|
+
customTemplates: {
|
|
65
|
+
FieldTemplate: React.FC<ExtendedDynamicFormsExports.FieldTemplateProps>;
|
|
66
|
+
ArrayFieldTemplate: (props: ExtendedDynamicFormsExports.ArrayFieldTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
ArrayFieldItemTemplate: (props: import('@rjsf/utils').ArrayFieldItemTemplateType) => import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
WizardObjectFieldTemplate: React.FC<ExtendedDynamicFormsExports.ObjectFieldTemplateProps>;
|
|
69
|
+
WizardSectionTemplate: React.FC<import('./layouts/wizard/WizardSectionTemplate').WizardSectionTemplateProps>;
|
|
70
|
+
ButtonTemplates: {
|
|
71
|
+
SubmitButton: React.FC<import('@rjsf/utils').SubmitButtonProps>;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
AddressField: React.FC<ExtendedDynamicFormsExports.FieldProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
75
|
+
PhoneField: React.FC<ExtendedDynamicFormsExports.FieldProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
76
|
+
CurrencyField: React.FC<ExtendedDynamicFormsExports.FieldProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
77
|
+
FieldTemplate: React.FC<ExtendedDynamicFormsExports.FieldTemplateProps>;
|
|
78
|
+
ArrayFieldTemplate: (props: ExtendedDynamicFormsExports.ArrayFieldTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
ArrayFieldItemTemplate: (props: import('@rjsf/utils').ArrayFieldItemTemplateType) => import("react/jsx-runtime").JSX.Element;
|
|
80
|
+
WizardObjectFieldTemplate: React.FC<ExtendedDynamicFormsExports.ObjectFieldTemplateProps>;
|
|
81
|
+
WizardSectionTemplate: React.FC<import('./layouts/wizard/WizardSectionTemplate').WizardSectionTemplateProps>;
|
|
82
|
+
SubmitButton: React.FC<import('@rjsf/utils').SubmitButtonProps>;
|
|
83
|
+
customWidgets: {
|
|
84
|
+
TextWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
85
|
+
TextareaWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
86
|
+
SelectWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
87
|
+
CheckboxWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
88
|
+
RadioWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
89
|
+
UpDownWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
90
|
+
FileWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
91
|
+
tel: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
92
|
+
email: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
93
|
+
url: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
94
|
+
password: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
95
|
+
date: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
96
|
+
'datetime-local': React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
97
|
+
TelWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
98
|
+
EmailWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
99
|
+
URLWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
100
|
+
PasswordWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
101
|
+
DateWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
102
|
+
DateTimeWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
103
|
+
color: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
104
|
+
file: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
105
|
+
range: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
106
|
+
rating: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
107
|
+
};
|
|
108
|
+
ColorWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
109
|
+
DateWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
110
|
+
FileWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
111
|
+
RangeWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
112
|
+
RatingWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
113
|
+
EnhancedTextWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
114
|
+
EnhancedTextareaWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
115
|
+
EnhancedSelectWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
116
|
+
EnhancedCheckboxWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
117
|
+
EnhancedRadioWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
118
|
+
EnhancedNumberWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
119
|
+
TelephoneWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
120
|
+
EmailWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
121
|
+
URLWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
122
|
+
PasswordWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
123
|
+
DateTimeWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
124
|
+
FileUploadWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
125
|
+
enhancedWidgets: {
|
|
126
|
+
TextWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
127
|
+
TextareaWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
128
|
+
SelectWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
129
|
+
CheckboxWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
130
|
+
RadioWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
131
|
+
UpDownWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
132
|
+
FileWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
133
|
+
tel: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
134
|
+
email: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
135
|
+
url: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
136
|
+
password: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
137
|
+
date: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
138
|
+
'datetime-local': React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
139
|
+
TelWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
140
|
+
EmailWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
141
|
+
URLWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
142
|
+
PasswordWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
143
|
+
DateWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
144
|
+
DateTimeWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
145
|
+
};
|
|
146
|
+
WizardLayout: React.FC<import('./layouts/wizard/WizardLayout').WizardLayoutProps>;
|
|
147
|
+
ProgressIndicator: React.FC<import('./layouts/wizard/ProgressIndicator').ProgressIndicatorProps>;
|
|
148
|
+
StepNavigation: React.FC<import('./layouts/wizard/StepNavigation').StepNavigationProps>;
|
|
149
|
+
WizardNavigation: React.FC<import('./layouts/wizard/WizardNavigation').WizardNavigationProps>;
|
|
150
|
+
FormEventManager: typeof ExtendedDynamicFormsExports.FormEventManager;
|
|
151
|
+
FormEventHub: typeof ExtendedDynamicFormsExports.FormEventHub;
|
|
152
|
+
FormEventProvider: React.FC<import('./events/FormEventContext').FormEventProviderProps>;
|
|
153
|
+
useFormEventHub: () => import('./events/FormEventContext').FormEventContextType;
|
|
154
|
+
useFieldEventHandlers: (fieldId: string, schema?: any, fieldPath?: string[]) => {
|
|
155
|
+
onFocus: (value: any) => Promise<void>;
|
|
156
|
+
onBlur: (value: any) => Promise<void>;
|
|
157
|
+
onChange: (value: any) => Promise<void>;
|
|
158
|
+
};
|
|
159
|
+
createConditionalEngineHook: typeof ExtendedDynamicFormsExports.createConditionalEngineHook;
|
|
160
|
+
useConditionalUi: ExtendedDynamicFormsExports.ConditionalEngineHook<ExtendedDynamicFormsExports.UiEffect[]>;
|
|
161
|
+
useConditionalSchema: ExtendedDynamicFormsExports.ConditionalEngineHook<ExtendedDynamicFormsExports.SchemaEffect[]>;
|
|
162
|
+
useConditionalValidation: ExtendedDynamicFormsExports.ConditionalEngineHook<ExtendedDynamicFormsExports.ValidationEffect>;
|
|
163
|
+
createDynamicArrayItemsUiSchema: typeof ExtendedDynamicFormsExports.createDynamicArrayItemsUiSchema;
|
|
164
|
+
mergeItemUiSchema: typeof ExtendedDynamicFormsExports.mergeItemUiSchema;
|
|
165
|
+
arrayItemPatterns: {
|
|
166
|
+
hideField: (fieldName: string, condition: (itemData: any) => boolean) => ExtendedDynamicFormsExports.ArrayItemConditionalFn;
|
|
167
|
+
requireField: (fieldName: string, condition: (itemData: any) => boolean) => ExtendedDynamicFormsExports.ArrayItemConditionalFn;
|
|
168
|
+
applyIndexStyles: (totalItems: number) => ExtendedDynamicFormsExports.ArrayItemConditionalFn;
|
|
169
|
+
};
|
|
170
|
+
uiEngineConfig: ExtendedDynamicFormsExports.EngineConfig<ExtendedDynamicFormsExports.UiEffect[], ExtendedDynamicFormsExports.UiSchema>;
|
|
171
|
+
schemaEngineConfig: ExtendedDynamicFormsExports.EngineConfig<ExtendedDynamicFormsExports.SchemaEffect[], ExtendedDynamicFormsExports.RJSFSchema>;
|
|
172
|
+
validationEngineConfig: ExtendedDynamicFormsExports.EngineConfig<ExtendedDynamicFormsExports.ValidationEffect, import('./conditionals/v2/engines/validationEngineConfig').ValidationConfig>;
|
|
173
|
+
createCustomValidate: typeof ExtendedDynamicFormsExports.createCustomValidate;
|
|
174
|
+
deepEquals(obj1: any, obj2: any): boolean;
|
|
175
|
+
formDataUtils: {
|
|
176
|
+
cloneFormData: (data: any) => any;
|
|
177
|
+
mergeFormData: (current: any, updates: any) => any;
|
|
178
|
+
getNestedValue: (data: any, path: string) => any;
|
|
179
|
+
setNestedValue: (data: any, path: string, value: any) => any;
|
|
180
|
+
removeEmptyValues: (data: any) => any;
|
|
181
|
+
};
|
|
182
|
+
schemaUtils: {
|
|
183
|
+
getRequiredFields: (schema: ExtendedDynamicFormsExports.RJSFSchema) => string[];
|
|
184
|
+
isFieldRequired: (schema: ExtendedDynamicFormsExports.RJSFSchema, fieldName: string) => boolean;
|
|
185
|
+
getFieldSchema: (schema: ExtendedDynamicFormsExports.RJSFSchema, path: string) => ExtendedDynamicFormsExports.RJSFSchema | undefined;
|
|
186
|
+
mergeSchemas: (schema1: ExtendedDynamicFormsExports.RJSFSchema, schema2: ExtendedDynamicFormsExports.RJSFSchema) => ExtendedDynamicFormsExports.RJSFSchema;
|
|
187
|
+
getAllFieldPaths: (schema: ExtendedDynamicFormsExports.RJSFSchema, prefix?: string) => string[];
|
|
188
|
+
};
|
|
189
|
+
validationUtils: {
|
|
190
|
+
isValidEmail: (email: string) => boolean;
|
|
191
|
+
isValidPhone: (phone: string) => boolean;
|
|
192
|
+
isValidUrl: (url: string) => boolean;
|
|
193
|
+
isValidDate: (date: string) => boolean;
|
|
194
|
+
isInRange: (value: number, min?: number, max?: number) => boolean;
|
|
195
|
+
getValidationMessage: (type: string, params?: any) => string;
|
|
196
|
+
};
|
|
197
|
+
createForm: typeof createForm;
|
|
198
|
+
createWizardForm: typeof createWizardForm;
|
|
199
|
+
React: typeof React;
|
|
200
|
+
ReactDOM: typeof ReactDOM;
|
|
201
|
+
antd: typeof antd;
|
|
202
|
+
dayjs: typeof dayjs;
|
|
203
|
+
};
|
|
204
|
+
export default ExtendedDynamicForms;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { default as React, FC } from 'react';
|
|
2
|
+
import { WidgetProps } from '@rjsf/utils';
|
|
3
|
+
|
|
4
|
+
export declare const EnhancedTextWidget: FC<WidgetProps>;
|
|
5
|
+
export declare const EnhancedTextareaWidget: FC<WidgetProps>;
|
|
6
|
+
export declare const EnhancedSelectWidget: FC<WidgetProps>;
|
|
7
|
+
export declare const EnhancedCheckboxWidget: FC<WidgetProps>;
|
|
8
|
+
export declare const EnhancedRadioWidget: FC<WidgetProps>;
|
|
9
|
+
export declare const EnhancedNumberWidget: FC<WidgetProps>;
|
|
10
|
+
export declare const TelephoneWidget: FC<WidgetProps>;
|
|
11
|
+
export declare const EmailWidget: FC<WidgetProps>;
|
|
12
|
+
export declare const URLWidget: FC<WidgetProps>;
|
|
13
|
+
export declare const PasswordWidget: FC<WidgetProps>;
|
|
14
|
+
export declare const DateWidget: FC<WidgetProps>;
|
|
15
|
+
export declare const DateTimeWidget: FC<WidgetProps>;
|
|
16
|
+
export declare const FileUploadWidget: FC<WidgetProps>;
|
|
17
|
+
export declare const customWidgets: {
|
|
18
|
+
TextWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
19
|
+
TextareaWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
20
|
+
SelectWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
21
|
+
CheckboxWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
22
|
+
RadioWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
23
|
+
UpDownWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
24
|
+
FileWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
25
|
+
tel: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
26
|
+
email: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
27
|
+
url: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
28
|
+
password: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
29
|
+
date: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
30
|
+
'datetime-local': React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
31
|
+
TelWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
32
|
+
EmailWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
33
|
+
URLWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
34
|
+
PasswordWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
35
|
+
DateWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
36
|
+
DateTimeWidget: React.FC<WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ColorWidget } from './input/ColorWidget';
|
|
2
|
+
import { DateWidget } from './date/DateWidget';
|
|
3
|
+
import { FileWidget } from './file/FileWidget';
|
|
4
|
+
import { RangeWidget } from './input/RangeWidget';
|
|
5
|
+
import { RatingWidget } from './input/RatingWidget';
|
|
6
|
+
import { customWidgets as enhancedWidgets, EnhancedTextWidget, EnhancedTextareaWidget, EnhancedSelectWidget, EnhancedCheckboxWidget, EnhancedRadioWidget, EnhancedNumberWidget, TelephoneWidget, EmailWidget, URLWidget, PasswordWidget, DateTimeWidget, FileUploadWidget } from './enhanced/EnhancedWidgets';
|
|
7
|
+
|
|
8
|
+
export declare const customWidgets: {
|
|
9
|
+
TextWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
10
|
+
TextareaWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
11
|
+
SelectWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
12
|
+
CheckboxWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
13
|
+
RadioWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
14
|
+
UpDownWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
15
|
+
FileWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
16
|
+
tel: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
17
|
+
email: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
18
|
+
url: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
19
|
+
password: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
20
|
+
date: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
21
|
+
'datetime-local': import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
22
|
+
TelWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
23
|
+
EmailWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
24
|
+
URLWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
25
|
+
PasswordWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
26
|
+
DateWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
27
|
+
DateTimeWidget: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
28
|
+
color: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
29
|
+
file: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
30
|
+
range: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
31
|
+
rating: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
32
|
+
};
|
|
33
|
+
export { ColorWidget, DateWidget, FileWidget, RangeWidget, RatingWidget, EnhancedTextWidget, EnhancedTextareaWidget, EnhancedSelectWidget, EnhancedCheckboxWidget, EnhancedRadioWidget, EnhancedNumberWidget, TelephoneWidget, EmailWidget, URLWidget, PasswordWidget, DateTimeWidget, FileUploadWidget, enhancedWidgets, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ExtendedForm } from '../src/ExtendedForm';
|
|
3
3
|
import { RJSFSchema, UiSchema } from '@rjsf/utils';
|
|
4
|
-
import { useConditionalUi, UiRule } from '../src/conditionals/v2';
|
|
4
|
+
import { useConditionalUi, UiRule, JsonLogicRule } from '../src/conditionals/v2';
|
|
5
5
|
|
|
6
6
|
const schema: RJSFSchema = {
|
|
7
7
|
type: 'object',
|
|
@@ -40,7 +40,7 @@ export function ConditionalV2Example() {
|
|
|
40
40
|
const uiRules: UiRule[] = [
|
|
41
41
|
{
|
|
42
42
|
name: 'Hide shipping address when not required',
|
|
43
|
-
condition:
|
|
43
|
+
condition: { "!": { "var": "requiresShipping" } } as JsonLogicRule,
|
|
44
44
|
effect: [
|
|
45
45
|
{ op: 'add', path: '/shippingAddress/ui:widget', value: 'hidden' }
|
|
46
46
|
]
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
UiEffect,
|
|
19
19
|
SchemaEffect,
|
|
20
20
|
ValidationEffect,
|
|
21
|
+
JsonLogicRule,
|
|
21
22
|
} from '../src/conditionals/v2/types';
|
|
22
23
|
import {
|
|
23
24
|
useConditionalUi,
|
|
@@ -80,15 +81,14 @@ const baseUiSchema: UiSchema = {
|
|
|
80
81
|
const uiRules: Rule<UiEffect>[] = [
|
|
81
82
|
{
|
|
82
83
|
name: 'Hide shipping address when not required',
|
|
83
|
-
condition:
|
|
84
|
+
condition: { "!": { "var": "requiresShipping" } } as JsonLogicRule,
|
|
84
85
|
effect: [
|
|
85
86
|
{ op: 'add', path: '/shippingAddress/ui:widget', value: 'hidden' },
|
|
86
87
|
],
|
|
87
88
|
},
|
|
88
89
|
{
|
|
89
90
|
name: 'Show state dropdown for US/Canada',
|
|
90
|
-
condition:
|
|
91
|
-
formData.country === 'USA' || formData.country === 'Canada',
|
|
91
|
+
condition: { "or": [{ "==": [{ "var": "country" }, "USA"] }, { "==": [{ "var": "country" }, "Canada"] }] } as JsonLogicRule,
|
|
92
92
|
effect: [
|
|
93
93
|
{
|
|
94
94
|
op: 'add',
|
|
@@ -103,12 +103,12 @@ const uiRules: Rule<UiEffect>[] = [
|
|
|
103
103
|
const schemaRules: Rule<SchemaEffect>[] = [
|
|
104
104
|
{
|
|
105
105
|
name: 'Add spouse fields when married',
|
|
106
|
-
condition:
|
|
106
|
+
condition: { "===": [{ "var": "maritalStatus" }, "married"] } as JsonLogicRule,
|
|
107
107
|
effect: [{ op: 'add', path: '/required/-', value: 'spouseName' }],
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
name: 'Remove spouse field when not married',
|
|
111
|
-
condition:
|
|
111
|
+
condition: { "!==": [{ "var": "maritalStatus" }, "married"] } as JsonLogicRule,
|
|
112
112
|
effect: [{ op: 'remove', path: '/properties/spouseName' }],
|
|
113
113
|
},
|
|
114
114
|
];
|
|
@@ -119,8 +119,7 @@ const validationRules: Rule<ValidationEffect>[] = [
|
|
|
119
119
|
name: 'US ZIP code format validation',
|
|
120
120
|
effect: {
|
|
121
121
|
name: 'US ZIP code format',
|
|
122
|
-
isActive:
|
|
123
|
-
formData.country === 'USA' && formData.requiresShipping,
|
|
122
|
+
isActive: { "and": [{ "==": [{ "var": "country" }, "USA"] }, { "var": "requiresShipping" }] } as JsonLogicRule,
|
|
124
123
|
validate: (errors, formData) => {
|
|
125
124
|
if (
|
|
126
125
|
formData.shippingAddress?.zip &&
|
|
@@ -139,8 +138,7 @@ const validationRules: Rule<ValidationEffect>[] = [
|
|
|
139
138
|
name: 'Canadian postal code validation',
|
|
140
139
|
effect: {
|
|
141
140
|
name: 'Canadian postal code',
|
|
142
|
-
isActive:
|
|
143
|
-
formData.country === 'Canada' && formData.requiresShipping,
|
|
141
|
+
isActive: { "and": [{ "==": [{ "var": "country" }, "Canada"] }, { "var": "requiresShipping" }] } as JsonLogicRule,
|
|
144
142
|
validate: (errors, formData) => {
|
|
145
143
|
if (
|
|
146
144
|
formData.shippingAddress?.zip &&
|