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
package/dist/types/index.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ export interface ExtendedFormProps extends Omit<FormProps, 'validator'>, FormEve
|
|
|
34
34
|
schema: RJSFSchema;
|
|
35
35
|
uiSchema?: UiSchema;
|
|
36
36
|
webhooks?: WebhookConfig[];
|
|
37
|
-
conditionals?: ConditionalConfig;
|
|
38
37
|
}
|
|
39
38
|
export interface CustomWidgetProps {
|
|
40
39
|
label?: string;
|
|
@@ -46,43 +45,3 @@ export interface CustomWidgetProps {
|
|
|
46
45
|
help?: string;
|
|
47
46
|
rawErrors?: string[];
|
|
48
47
|
}
|
|
49
|
-
export interface ConditionalRule {
|
|
50
|
-
conditions: Record<string, any>;
|
|
51
|
-
event: ConditionalEvent;
|
|
52
|
-
order?: number;
|
|
53
|
-
priority?: number;
|
|
54
|
-
}
|
|
55
|
-
export interface ConditionalEvent {
|
|
56
|
-
type: string;
|
|
57
|
-
params?: Record<string, any>;
|
|
58
|
-
}
|
|
59
|
-
export interface ConditionalAction {
|
|
60
|
-
(params: any, schema: RJSFSchema, uiSchema: UiSchema, formData: any): void;
|
|
61
|
-
propTypes?: any;
|
|
62
|
-
validate?: (params: any, schema: RJSFSchema, uiSchema: UiSchema) => void;
|
|
63
|
-
}
|
|
64
|
-
export interface ConditionalActions {
|
|
65
|
-
[actionType: string]: ConditionalAction;
|
|
66
|
-
}
|
|
67
|
-
export interface ConditionalEngine {
|
|
68
|
-
new (rules: ConditionalRule[], schema: RJSFSchema): ConditionalEngineInstance;
|
|
69
|
-
}
|
|
70
|
-
export interface ConditionalEngineInstance {
|
|
71
|
-
addRule(rule: ConditionalRule): void;
|
|
72
|
-
run(formData: any): Promise<ConditionalEvent[]>;
|
|
73
|
-
}
|
|
74
|
-
export interface ConditionalConfig {
|
|
75
|
-
rules?: ConditionalRule[];
|
|
76
|
-
engine?: ConditionalEngine;
|
|
77
|
-
extraActions?: ConditionalActions;
|
|
78
|
-
onSchemaChange?: (schemas: {
|
|
79
|
-
schema: RJSFSchema;
|
|
80
|
-
uiSchema: UiSchema;
|
|
81
|
-
}) => void;
|
|
82
|
-
}
|
|
83
|
-
export interface ConditionalState {
|
|
84
|
-
currentSchema: RJSFSchema;
|
|
85
|
-
currentUiSchema: UiSchema;
|
|
86
|
-
rules: ConditionalRule[];
|
|
87
|
-
isProcessing: boolean;
|
|
88
|
-
}
|
package/dist/vanilla-entry.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ declare function createForm(config: {
|
|
|
12
12
|
onChange?: (data: any) => void;
|
|
13
13
|
onSubmit?: (data: any) => void;
|
|
14
14
|
onError?: (errors: any) => void;
|
|
15
|
-
conditionals?: any;
|
|
16
15
|
webhooks?: any;
|
|
17
16
|
widgets?: any;
|
|
18
17
|
fields?: any;
|
|
@@ -27,7 +26,6 @@ declare function createWizardForm(config: {
|
|
|
27
26
|
formData?: any;
|
|
28
27
|
onStepChange?: (step: number, data: any) => void;
|
|
29
28
|
onSubmit?: (data: any) => void;
|
|
30
|
-
conditionals?: any;
|
|
31
29
|
webhooks?: any;
|
|
32
30
|
}): {
|
|
33
31
|
destroy: () => void;
|
|
@@ -83,25 +81,25 @@ declare const ExtendedDynamicForms: {
|
|
|
83
81
|
WizardSectionTemplate: React.FC<import('./layouts/wizard/WizardSectionTemplate').WizardSectionTemplateProps>;
|
|
84
82
|
SubmitButton: React.FC<import('@rjsf/utils').SubmitButtonProps>;
|
|
85
83
|
customWidgets: {
|
|
86
|
-
TextWidget:
|
|
87
|
-
TextareaWidget:
|
|
88
|
-
SelectWidget:
|
|
89
|
-
CheckboxWidget:
|
|
90
|
-
RadioWidget:
|
|
91
|
-
UpDownWidget:
|
|
92
|
-
FileWidget:
|
|
93
|
-
tel:
|
|
94
|
-
email:
|
|
95
|
-
url:
|
|
96
|
-
password:
|
|
97
|
-
date:
|
|
98
|
-
'datetime-local':
|
|
99
|
-
TelWidget:
|
|
100
|
-
EmailWidget:
|
|
101
|
-
URLWidget:
|
|
102
|
-
PasswordWidget:
|
|
103
|
-
DateWidget:
|
|
104
|
-
DateTimeWidget:
|
|
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>>;
|
|
105
103
|
color: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
106
104
|
file: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
107
105
|
range: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
@@ -112,38 +110,38 @@ declare const ExtendedDynamicForms: {
|
|
|
112
110
|
FileWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
113
111
|
RangeWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
114
112
|
RatingWidget: React.FC<ExtendedDynamicFormsExports.WidgetProps<any, ExtendedDynamicFormsExports.RJSFSchema, any>>;
|
|
115
|
-
EnhancedTextWidget:
|
|
116
|
-
EnhancedTextareaWidget:
|
|
117
|
-
EnhancedSelectWidget:
|
|
118
|
-
EnhancedCheckboxWidget:
|
|
119
|
-
EnhancedRadioWidget:
|
|
120
|
-
EnhancedNumberWidget:
|
|
121
|
-
TelephoneWidget:
|
|
122
|
-
EmailWidget:
|
|
123
|
-
URLWidget:
|
|
124
|
-
PasswordWidget:
|
|
125
|
-
DateTimeWidget:
|
|
126
|
-
FileUploadWidget:
|
|
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>>;
|
|
127
125
|
enhancedWidgets: {
|
|
128
|
-
TextWidget:
|
|
129
|
-
TextareaWidget:
|
|
130
|
-
SelectWidget:
|
|
131
|
-
CheckboxWidget:
|
|
132
|
-
RadioWidget:
|
|
133
|
-
UpDownWidget:
|
|
134
|
-
FileWidget:
|
|
135
|
-
tel:
|
|
136
|
-
email:
|
|
137
|
-
url:
|
|
138
|
-
password:
|
|
139
|
-
date:
|
|
140
|
-
'datetime-local':
|
|
141
|
-
TelWidget:
|
|
142
|
-
EmailWidget:
|
|
143
|
-
URLWidget:
|
|
144
|
-
PasswordWidget:
|
|
145
|
-
DateWidget:
|
|
146
|
-
DateTimeWidget:
|
|
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>>;
|
|
147
145
|
};
|
|
148
146
|
WizardLayout: React.FC<import('./layouts/wizard/WizardLayout').WizardLayoutProps>;
|
|
149
147
|
ProgressIndicator: React.FC<import('./layouts/wizard/ProgressIndicator').ProgressIndicatorProps>;
|
|
@@ -158,22 +156,21 @@ declare const ExtendedDynamicForms: {
|
|
|
158
156
|
onBlur: (value: any) => Promise<void>;
|
|
159
157
|
onChange: (value: any) => Promise<void>;
|
|
160
158
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
Engine: any;
|
|
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;
|
|
177
174
|
deepEquals(obj1: any, obj2: any): boolean;
|
|
178
175
|
formDataUtils: {
|
|
179
176
|
cloneFormData: (data: any) => any;
|
|
@@ -197,7 +194,6 @@ declare const ExtendedDynamicForms: {
|
|
|
197
194
|
isInRange: (value: number, min?: number, max?: number) => boolean;
|
|
198
195
|
getValidationMessage: (type: string, params?: any) => string;
|
|
199
196
|
};
|
|
200
|
-
useFormDevTools(formData: any, uiRules?: import('./conditionals/v2').Rule<import('./conditionals/v2').UiEffect>[], schemaRules?: import('./conditionals/v2').Rule<import('./conditionals/v2').SchemaEffect>[], validationRules?: import('./conditionals/v2').Rule<import('./conditionals/v2').ValidationEffect>[], options?: ExtendedDynamicFormsExports.DevToolsOptions): ExtendedDynamicFormsExports.DevToolsOutput;
|
|
201
197
|
createForm: typeof createForm;
|
|
202
198
|
createWizardForm: typeof createWizardForm;
|
|
203
199
|
React: typeof React;
|
|
@@ -1,36 +1,37 @@
|
|
|
1
|
+
import { default as React, FC } from 'react';
|
|
1
2
|
import { WidgetProps } from '@rjsf/utils';
|
|
2
3
|
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
8
|
-
export declare
|
|
9
|
-
export declare
|
|
10
|
-
export declare
|
|
11
|
-
export declare
|
|
12
|
-
export declare
|
|
13
|
-
export declare
|
|
14
|
-
export declare
|
|
15
|
-
export declare
|
|
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>;
|
|
16
17
|
export declare const customWidgets: {
|
|
17
|
-
TextWidget:
|
|
18
|
-
TextareaWidget:
|
|
19
|
-
SelectWidget:
|
|
20
|
-
CheckboxWidget:
|
|
21
|
-
RadioWidget:
|
|
22
|
-
UpDownWidget:
|
|
23
|
-
FileWidget:
|
|
24
|
-
tel:
|
|
25
|
-
email:
|
|
26
|
-
url:
|
|
27
|
-
password:
|
|
28
|
-
date:
|
|
29
|
-
'datetime-local':
|
|
30
|
-
TelWidget:
|
|
31
|
-
EmailWidget:
|
|
32
|
-
URLWidget:
|
|
33
|
-
PasswordWidget:
|
|
34
|
-
DateWidget:
|
|
35
|
-
DateTimeWidget:
|
|
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>>;
|
|
36
37
|
};
|
package/dist/widgets/index.d.ts
CHANGED
|
@@ -6,25 +6,25 @@ import { RatingWidget } from './input/RatingWidget';
|
|
|
6
6
|
import { customWidgets as enhancedWidgets, EnhancedTextWidget, EnhancedTextareaWidget, EnhancedSelectWidget, EnhancedCheckboxWidget, EnhancedRadioWidget, EnhancedNumberWidget, TelephoneWidget, EmailWidget, URLWidget, PasswordWidget, DateTimeWidget, FileUploadWidget } from './enhanced/EnhancedWidgets';
|
|
7
7
|
|
|
8
8
|
export declare const customWidgets: {
|
|
9
|
-
TextWidget:
|
|
10
|
-
TextareaWidget:
|
|
11
|
-
SelectWidget:
|
|
12
|
-
CheckboxWidget:
|
|
13
|
-
RadioWidget:
|
|
14
|
-
UpDownWidget:
|
|
15
|
-
FileWidget:
|
|
16
|
-
tel:
|
|
17
|
-
email:
|
|
18
|
-
url:
|
|
19
|
-
password:
|
|
20
|
-
date:
|
|
21
|
-
'datetime-local':
|
|
22
|
-
TelWidget:
|
|
23
|
-
EmailWidget:
|
|
24
|
-
URLWidget:
|
|
25
|
-
PasswordWidget:
|
|
26
|
-
DateWidget:
|
|
27
|
-
DateTimeWidget:
|
|
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
28
|
color: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
29
29
|
file: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
30
30
|
range: import('react').FC<import('@rjsf/utils').WidgetProps<any, import('@rjsf/utils').RJSFSchema, any>>;
|
|
@@ -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 &&
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ExtendedForm } from '../src/ExtendedForm';
|
|
3
3
|
import { RJSFSchema, UiSchema, IChangeEvent } from '@rjsf/utils';
|
|
4
|
-
import { useConditionalUi, UiRule } from '../src/conditionals/v2';
|
|
4
|
+
import { useConditionalUi, UiRule, JsonLogicRule } from '../src/conditionals/v2';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Global UI Rules Example
|
|
@@ -175,7 +175,7 @@ const globalUiRules: UiRule[] = [
|
|
|
175
175
|
// Rule 1: Show shipping address when shipping is required
|
|
176
176
|
{
|
|
177
177
|
name: 'Show shipping address when shipping required',
|
|
178
|
-
condition:
|
|
178
|
+
condition: { "===": [{ "var": "requiresShipping" }, true] } as JsonLogicRule,
|
|
179
179
|
effect: [
|
|
180
180
|
{ op: 'remove', path: '/shippingAddress/ui:widget' }
|
|
181
181
|
],
|
|
@@ -185,7 +185,7 @@ const globalUiRules: UiRule[] = [
|
|
|
185
185
|
// Rule 2: Show delivery instructions when shipping is required
|
|
186
186
|
{
|
|
187
187
|
name: 'Show delivery instructions when shipping required',
|
|
188
|
-
condition:
|
|
188
|
+
condition: { "===": [{ "var": "requiresShipping" }, true] } as JsonLogicRule,
|
|
189
189
|
effect: [
|
|
190
190
|
{ op: 'replace', path: '/deliveryInstructions/ui:widget', value: 'textarea' }
|
|
191
191
|
],
|
|
@@ -195,7 +195,7 @@ const globalUiRules: UiRule[] = [
|
|
|
195
195
|
// Rule 3: Show express shipping option when shipping is required
|
|
196
196
|
{
|
|
197
197
|
name: 'Show express shipping option when shipping required',
|
|
198
|
-
condition:
|
|
198
|
+
condition: { "===": [{ "var": "requiresShipping" }, true] } as JsonLogicRule,
|
|
199
199
|
effect: [
|
|
200
200
|
{ op: 'remove', path: '/expressShipping/ui:widget' }
|
|
201
201
|
],
|
|
@@ -205,9 +205,12 @@ const globalUiRules: UiRule[] = [
|
|
|
205
205
|
// Rule 4: Show state dropdown only for USA
|
|
206
206
|
{
|
|
207
207
|
name: 'Show state field for USA',
|
|
208
|
-
condition:
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
condition: {
|
|
209
|
+
"and": [
|
|
210
|
+
{ "===": [{ "var": "requiresShipping" }, true] },
|
|
211
|
+
{ "===": [{ "var": "shippingAddress.country" }, "USA"] }
|
|
212
|
+
]
|
|
213
|
+
} as JsonLogicRule,
|
|
211
214
|
effect: [
|
|
212
215
|
{ op: 'remove', path: '/shippingAddress/state/ui:widget' },
|
|
213
216
|
{ op: 'add', path: '/shippingAddress/province/ui:widget', value: 'hidden' },
|
|
@@ -219,9 +222,12 @@ const globalUiRules: UiRule[] = [
|
|
|
219
222
|
// Rule 5: Show province dropdown only for Canada
|
|
220
223
|
{
|
|
221
224
|
name: 'Show province field for Canada',
|
|
222
|
-
condition:
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
condition: {
|
|
226
|
+
"and": [
|
|
227
|
+
{ "===": [{ "var": "requiresShipping" }, true] },
|
|
228
|
+
{ "===": [{ "var": "shippingAddress.country" }, "Canada"] }
|
|
229
|
+
]
|
|
230
|
+
} as JsonLogicRule,
|
|
225
231
|
effect: [
|
|
226
232
|
{ op: 'add', path: '/shippingAddress/state/ui:widget', value: 'hidden' },
|
|
227
233
|
{ op: 'remove', path: '/shippingAddress/province/ui:widget' },
|
|
@@ -233,9 +239,12 @@ const globalUiRules: UiRule[] = [
|
|
|
233
239
|
// Rule 6: Show region text field for Mexico and Other
|
|
234
240
|
{
|
|
235
241
|
name: 'Show region field for Mexico and Other countries',
|
|
236
|
-
condition:
|
|
237
|
-
|
|
238
|
-
|
|
242
|
+
condition: {
|
|
243
|
+
"and": [
|
|
244
|
+
{ "===": [{ "var": "requiresShipping" }, true] },
|
|
245
|
+
{ "in": [{ "var": "shippingAddress.country" }, ["Mexico", "Other"]] }
|
|
246
|
+
]
|
|
247
|
+
} as JsonLogicRule,
|
|
239
248
|
effect: [
|
|
240
249
|
{ op: 'add', path: '/shippingAddress/state/ui:widget', value: 'hidden' },
|
|
241
250
|
{ op: 'add', path: '/shippingAddress/province/ui:widget', value: 'hidden' },
|
|
@@ -247,9 +256,12 @@ const globalUiRules: UiRule[] = [
|
|
|
247
256
|
// Rule 7: Show international details only for "Other" countries
|
|
248
257
|
{
|
|
249
258
|
name: 'Show international details for non-North American countries',
|
|
250
|
-
condition:
|
|
251
|
-
|
|
252
|
-
|
|
259
|
+
condition: {
|
|
260
|
+
"and": [
|
|
261
|
+
{ "===": [{ "var": "requiresShipping" }, true] },
|
|
262
|
+
{ "===": [{ "var": "shippingAddress.country" }, "Other"] }
|
|
263
|
+
]
|
|
264
|
+
} as JsonLogicRule,
|
|
253
265
|
effect: [
|
|
254
266
|
{ op: 'replace', path: '/shippingAddress/internationalDetails/ui:widget', value: 'textarea' }
|
|
255
267
|
],
|
|
@@ -259,9 +271,12 @@ const globalUiRules: UiRule[] = [
|
|
|
259
271
|
// Rule 8: Reorder fields to put international details at end when visible
|
|
260
272
|
{
|
|
261
273
|
name: 'Reorder fields for international shipping',
|
|
262
|
-
condition:
|
|
263
|
-
|
|
264
|
-
|
|
274
|
+
condition: {
|
|
275
|
+
"and": [
|
|
276
|
+
{ "===": [{ "var": "requiresShipping" }, true] },
|
|
277
|
+
{ "===": [{ "var": "shippingAddress.country" }, "Other"] }
|
|
278
|
+
]
|
|
279
|
+
} as JsonLogicRule,
|
|
265
280
|
effect: [
|
|
266
281
|
{
|
|
267
282
|
op: 'replace',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extended-dynamic-forms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Extended React JSON Schema Form (RJSF) v6 with custom components, widgets, templates, layouts, and form events",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"require": "./dist/index.umd.js",
|
|
21
21
|
"types": "./dist/index.d.ts"
|
|
22
22
|
},
|
|
23
|
+
"./conditionals/v2": {
|
|
24
|
+
"import": "./dist/index.es.js",
|
|
25
|
+
"require": "./dist/index.umd.js",
|
|
26
|
+
"types": "./dist/index.d.ts"
|
|
27
|
+
},
|
|
23
28
|
"./dist/style.css": "./dist/style.css"
|
|
24
29
|
},
|
|
25
30
|
"scripts": {
|
|
@@ -36,7 +41,10 @@
|
|
|
36
41
|
"prepublishOnly": "npm run build",
|
|
37
42
|
"playground": "cd playground && npm install && npm run dev",
|
|
38
43
|
"playground:build": "cd playground && npm run build",
|
|
39
|
-
"serve:examples": "npx http-server examples/vanilla-js -p 8080 -o"
|
|
44
|
+
"serve:examples": "npx http-server examples/vanilla-js -p 8080 -o",
|
|
45
|
+
"setup:dev": "git clone https://github.com/rjsf-team/react-jsonschema-form ../react-jsonschema-form && cd ../react-jsonschema-form && npm install && npm run build",
|
|
46
|
+
"link:rjsf": "cd ../react-jsonschema-form/packages/core && npm link && cd ../antd && npm link && cd ../utils && npm link && cd ../validator-ajv8 && npm link",
|
|
47
|
+
"dev:install": "npm run setup:dev && npm run link:rjsf && npm install"
|
|
40
48
|
},
|
|
41
49
|
"keywords": [
|
|
42
50
|
"react",
|
|
@@ -95,8 +103,10 @@
|
|
|
95
103
|
"vitest": "^1.0.0"
|
|
96
104
|
},
|
|
97
105
|
"dependencies": {
|
|
106
|
+
"@types/json-logic-js": "^2.0.8",
|
|
98
107
|
"date-fns": "^4.1.0",
|
|
99
108
|
"dayjs": "^1.11.13",
|
|
109
|
+
"json-logic-js": "^2.0.5",
|
|
100
110
|
"json-rules-engine-simplified": "^0.2.0"
|
|
101
111
|
},
|
|
102
112
|
"type": "module"
|
|
@@ -1,13 +0,0 @@
|
|
|
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, };
|