@bolttech/form-engine 0.10.7 → 0.11.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/CHANGELOG.md +18 -0
- package/README.md +159 -23
- package/asFormField-c0e3ada2.js +2 -0
- package/asFormField-c0e3ada2.js.map +1 -0
- package/index.js +1 -1
- package/package.json +1 -1
- package/react.js +1 -1
- package/react.js.map +1 -1
- package/src/adapters/react/asFormField.d.ts +3 -13
- package/src/adapters/react/types.d.ts +92 -2
- package/src/adapters/react/useForm.d.ts +3 -42
- package/src/adapters/react/useFormGroup.d.ts +2 -14
- package/src/core/constants/events.d.ts +2 -0
- package/src/core/events/events.types.d.ts +1 -1
- package/src/core/handlers/common/templating.d.ts +1 -7
- package/src/core/handlers/field/api.d.ts +1 -1
- package/src/core/handlers/field/blur.d.ts +1 -1
- package/src/core/handlers/field/change.d.ts +1 -1
- package/src/core/handlers/field/clearFields.d.ts +2 -2
- package/src/core/handlers/field/data.d.ts +1 -1
- package/src/core/handlers/field/filter.d.ts +1 -1
- package/src/core/handlers/field/focus.d.ts +1 -1
- package/src/core/handlers/field/formatters.d.ts +1 -1
- package/src/core/handlers/field/htmlEventParser.d.ts +1 -1
- package/src/core/handlers/field/keydown.d.ts +1 -1
- package/src/core/handlers/field/keyup.d.ts +1 -1
- package/src/core/handlers/field/masks.d.ts +1 -1
- package/src/core/handlers/field/mount.d.ts +1 -1
- package/src/core/handlers/field/validations.d.ts +1 -1
- package/src/core/handlers/field/visibilityConditions.d.ts +1 -1
- package/src/core/handlers/flows.d.ts +3 -0
- package/src/core/handlers/form/bindFields.d.ts +3 -0
- package/src/core/handlers/form/hooks.d.ts +1 -1
- package/src/core/handlers/form/steps.d.ts +1 -1
- package/src/core/handlers/form/templating.d.ts +1 -1
- package/src/core/handlers/form/validate.d.ts +1 -1
- package/src/core/handlers/form/visibilityConditions.d.ts +1 -1
- package/src/core/managers/Field.d.ts +2 -0
- package/src/core/managers/Form.d.ts +3 -7
- package/src/core/types/index.d.ts +34 -8
- package/src/core/utils/common.d.ts +9 -0
- package/src/core/utils/index.d.ts +2 -0
- package/src/core/utils/object.d.ts +3 -4
- package/src/core/utils/value.d.ts +2 -0
- package/types.js.map +1 -1
- package/asFormField-4c6294c9.js +0 -2
- package/asFormField-4c6294c9.js.map +0 -1
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
Comp: (new () => React.Component) | any;
|
|
5
|
-
propsMapping: Record<string, string>;
|
|
6
|
-
}
|
|
7
|
-
declare type DecoratorProps<OriginalComponentProps = Record<string, unknown>> = OriginalComponentProps & Pick<TComponent, 'validations' | 'masks' | 'clearFields' | 'api' | 'errorMessages' | 'filter' | 'formatters' | 'visibilityConditions'> & {
|
|
8
|
-
formId?: string;
|
|
9
|
-
visibility?: boolean;
|
|
10
|
-
name: string;
|
|
11
|
-
value?: any;
|
|
12
|
-
};
|
|
13
|
-
declare const asFormField: <OriginalComponentProps>({ Comp, propsMapping }: HocProps) => ({ name, validations, errorMessages, masks, filter, formatters, visibilityConditions, formId, visibility, value, ...props }: DecoratorProps<OriginalComponentProps>) => ReactElement;
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { TAsFormFieldProps, TDecoratorProps } from '@react/types';
|
|
3
|
+
declare const asFormField: <OriginalComponentProps>({ Comp, propsMapping }: TAsFormFieldProps) => ({ name, validations, errorMessages, masks, filter, formatters, visibilityConditions, formId, visibility, value, ...props }: TDecoratorProps<OriginalComponentProps>) => ReactElement;
|
|
14
4
|
export default asFormField;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
import { TComponent, TErrorMessages, TSchemaValidation, TSchemaValidations, TSchema, THooks, TIVars, TFormValues, TField, TChildrenOptions, TPropsMapping, TComponentPropsMapping, TScope } from '@core/types';
|
|
3
3
|
import { TLoggingEvent } from '@core/events/events.types';
|
|
4
4
|
declare type TFormProps = {
|
|
@@ -206,4 +206,94 @@ declare type TFormRefActions = {
|
|
|
206
206
|
validateForm(opts?: TChildrenOptions): TFormValues;
|
|
207
207
|
values(opts: Pick<TChildrenOptions, 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'>): TFormValues;
|
|
208
208
|
};
|
|
209
|
-
|
|
209
|
+
declare type TUseFormProps = {
|
|
210
|
+
/**
|
|
211
|
+
* The if of the form you want to connect to
|
|
212
|
+
*/
|
|
213
|
+
id?: string;
|
|
214
|
+
/**
|
|
215
|
+
* And array of ids of forms you want to connect to
|
|
216
|
+
*/
|
|
217
|
+
ids?: string[];
|
|
218
|
+
/**
|
|
219
|
+
* Callback to be called when form validity toggled
|
|
220
|
+
* @param data All the available form data
|
|
221
|
+
* @param field
|
|
222
|
+
*/
|
|
223
|
+
onValid?(data: TFormValues | Record<string, TFormValues>, field: TField): void;
|
|
224
|
+
/**
|
|
225
|
+
* Callback to be called when the form generates some new data
|
|
226
|
+
* @param data All the available form data
|
|
227
|
+
*/
|
|
228
|
+
onData?(data: TFormValues | Record<string, TFormValues>): void;
|
|
229
|
+
/**
|
|
230
|
+
* Callback to be called when the form submits
|
|
231
|
+
* @param data All the available form data
|
|
232
|
+
*/
|
|
233
|
+
onSubmit?(data: TFormValues | Record<string, TFormValues>): void;
|
|
234
|
+
};
|
|
235
|
+
declare type TUseFormGroupProps = {
|
|
236
|
+
/**
|
|
237
|
+
* And array of ids of forms you want to connect to
|
|
238
|
+
*/
|
|
239
|
+
ids?: string[];
|
|
240
|
+
/**
|
|
241
|
+
* The if of the form group you want to merge
|
|
242
|
+
*/
|
|
243
|
+
group?: string;
|
|
244
|
+
/**
|
|
245
|
+
* Callback to be called when the form generates some new data
|
|
246
|
+
* @param data All the available form data
|
|
247
|
+
*/
|
|
248
|
+
onData?(data: Record<string, TFormValues>): void;
|
|
249
|
+
/**
|
|
250
|
+
* Callback to be called when the form submits
|
|
251
|
+
* @param data All the available form data
|
|
252
|
+
*/
|
|
253
|
+
onSubmit?(data: Record<string, TFormValues>): void;
|
|
254
|
+
};
|
|
255
|
+
declare type THookReturn = {
|
|
256
|
+
/**
|
|
257
|
+
* A function that lets you start the form submission
|
|
258
|
+
*/
|
|
259
|
+
submitForm(): void;
|
|
260
|
+
/**
|
|
261
|
+
* You can call this function to get all the updated form data.
|
|
262
|
+
*
|
|
263
|
+
* @param opts Options to configure your form data. The aggregate prop is only available on useFormGroup.
|
|
264
|
+
*/
|
|
265
|
+
formData(opts?: TChildrenOptions & {
|
|
266
|
+
aggregate?: boolean;
|
|
267
|
+
}): TFormValues | Record<string, TFormValues>;
|
|
268
|
+
};
|
|
269
|
+
interface TAsFormFieldProps {
|
|
270
|
+
/**
|
|
271
|
+
* The component to be used as form field.
|
|
272
|
+
*/
|
|
273
|
+
Comp: (new () => React.Component) | any;
|
|
274
|
+
/**
|
|
275
|
+
* Link for the TPropsMapping likely props mapper from default form.
|
|
276
|
+
*/
|
|
277
|
+
propsMapping: TPropsMapping;
|
|
278
|
+
}
|
|
279
|
+
declare type TDecorator = {
|
|
280
|
+
/**
|
|
281
|
+
* Form id that you need to create and integrate the field.
|
|
282
|
+
*/
|
|
283
|
+
formId?: string;
|
|
284
|
+
/**
|
|
285
|
+
* It's a prop that you can use to hide the component and control this state outside the component.
|
|
286
|
+
*/
|
|
287
|
+
visibility?: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* Name of the component similar to name prop name on TComponent type.
|
|
290
|
+
* This name will be used later to correlate the field with the value, and you will be able to read it.
|
|
291
|
+
*/
|
|
292
|
+
name: string;
|
|
293
|
+
/**
|
|
294
|
+
* The value of the field that you can control outside the component.
|
|
295
|
+
*/
|
|
296
|
+
value?: any;
|
|
297
|
+
};
|
|
298
|
+
declare type TDecoratorProps<OriginalComponentProps = Record<string, unknown>> = OriginalComponentProps & Pick<TComponent, 'validations' | 'masks' | 'clearFields' | 'api' | 'errorMessages' | 'filter' | 'formatters' | 'visibilityConditions'> & TDecorator;
|
|
299
|
+
export type { TComponent, TMapper, TChildrenOptions, TFormValues, TFormRefActions, TChildWrapperProps, TContext, TFormProps, TProvider, TErrorMessages, TSchemaValidation, TSchemaValidations, TUseFormProps, TUseFormGroupProps, THookReturn, TAsFormFieldProps, TDecoratorProps, };
|
|
@@ -1,45 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TField } from '@core';
|
|
3
|
-
declare type TProps = {
|
|
4
|
-
/**
|
|
5
|
-
* The if of the form you want to connect to
|
|
6
|
-
*/
|
|
7
|
-
id?: string;
|
|
8
|
-
/**
|
|
9
|
-
* And array of ids of forms you want to connect to
|
|
10
|
-
*/
|
|
11
|
-
ids?: string[];
|
|
12
|
-
/**
|
|
13
|
-
* Callback to be called when form validity toggled
|
|
14
|
-
* @param data All the available form data
|
|
15
|
-
* @param field
|
|
16
|
-
*/
|
|
17
|
-
onValid?(data: TFormValues, field: TField): void;
|
|
18
|
-
/**
|
|
19
|
-
* Callback to be called when the form generates some new data
|
|
20
|
-
* @param data All the available form data
|
|
21
|
-
*/
|
|
22
|
-
onData?(data: TFormValues): void;
|
|
23
|
-
/**
|
|
24
|
-
* Callback to be called when the form submits
|
|
25
|
-
* @param data All the available form data
|
|
26
|
-
*/
|
|
27
|
-
onSubmit?(data: TFormValues): void;
|
|
28
|
-
};
|
|
29
|
-
declare type THookReturn = {
|
|
30
|
-
/**
|
|
31
|
-
* A function that lets you start the form submission
|
|
32
|
-
*/
|
|
33
|
-
submitForm(): void;
|
|
34
|
-
/**
|
|
35
|
-
* You can call this function to get all the updated form data
|
|
36
|
-
*
|
|
37
|
-
* @param opts Options to configure your form data
|
|
38
|
-
*/
|
|
39
|
-
formData(opts?: TChildrenOptions): TFormValues;
|
|
40
|
-
};
|
|
1
|
+
import { THookReturn, TUseFormProps } from '@react/types';
|
|
41
2
|
/**
|
|
42
|
-
* This hooks lets you connect to your form/s in
|
|
3
|
+
* This hooks lets you connect to your form/s in anywhere in your application. Even if you are outside the <FormProvider />
|
|
43
4
|
*
|
|
44
5
|
* You can connect to:
|
|
45
6
|
* - A specific form
|
|
@@ -47,5 +8,5 @@ declare type THookReturn = {
|
|
|
47
8
|
* - A group of forms
|
|
48
9
|
*
|
|
49
10
|
*/
|
|
50
|
-
declare const useForm: ({ onValid, onData, onSubmit, id, ids, }:
|
|
11
|
+
declare const useForm: ({ onValid, onData, onSubmit, id, ids, }: TUseFormProps) => THookReturn;
|
|
51
12
|
export default useForm;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare
|
|
3
|
-
ids?: string[];
|
|
4
|
-
group?: string;
|
|
5
|
-
onData?(data: Record<string, TFormValues>): void;
|
|
6
|
-
onSubmit?(data: Record<string, TFormValues>): void;
|
|
7
|
-
};
|
|
8
|
-
declare type THookReturn = {
|
|
9
|
-
submitForm(): void;
|
|
10
|
-
formData(opts?: TChildrenOptions & {
|
|
11
|
-
aggregate?: boolean;
|
|
12
|
-
}): Record<string, TFormValues>;
|
|
13
|
-
};
|
|
14
|
-
declare const useFormGroup: ({ group, onData, onSubmit, ids, }: TProps) => THookReturn;
|
|
1
|
+
import { THookReturn, TUseFormGroupProps } from '@react/types';
|
|
2
|
+
declare const useFormGroup: ({ group, onData, onSubmit, ids, }: TUseFormGroupProps) => THookReturn;
|
|
15
3
|
export { useFormGroup };
|
|
@@ -10,6 +10,7 @@ export declare const enum EEVents {
|
|
|
10
10
|
ON_FIELD_CLICK = "ON_FIELD_CLICK",
|
|
11
11
|
ON_FIELD_KEYUP = "ON_FIELD_KEYUP",
|
|
12
12
|
ON_FIELD_KEYDOWN = "ON_FIELD_KEYDOWN",
|
|
13
|
+
ON_FIELD_BINDED = "ON_FIELD_BINDED",
|
|
13
14
|
AFTER_FIELD_API_CALL = "AFTER_FIELD_API_CALL",
|
|
14
15
|
RUN_FIELD_VALIDATIONS = "RUN_FIELD_VALIDATIONS",
|
|
15
16
|
RUN_FIELD_MASKS = "RUN_FIELD_MASKS",
|
|
@@ -24,6 +25,7 @@ export declare const enum EEVents {
|
|
|
24
25
|
NAVIGATE_STEP_FORWARD = "NAVIGATE_STEP_FORWARD",
|
|
25
26
|
NAVIGATE_STEP_BACK = "NAVIGATE_STEP_BACK",
|
|
26
27
|
VALIDATE_FORM = "VALIDATE_FORM",
|
|
28
|
+
BIND_FIELDS = "BIND_FIELDS",
|
|
27
29
|
LOG = "LOG"
|
|
28
30
|
}
|
|
29
31
|
export declare const CoreEvents: Record<TEventsKeys, TEventsKeys>;
|
|
@@ -6,7 +6,7 @@ export declare type TEventPublishPayload = {
|
|
|
6
6
|
} & {
|
|
7
7
|
[key in string]?: unknown;
|
|
8
8
|
};
|
|
9
|
-
export declare type TEventInformation = TObserverData & {
|
|
9
|
+
export declare type TEventInformation<T> = TObserverData<T> & {
|
|
10
10
|
eventReducedSchema: TEventReducedSchema;
|
|
11
11
|
formEventDirectives: TFormEventDirectives;
|
|
12
12
|
form: Form;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const
|
|
3
|
-
BEGIN: string;
|
|
4
|
-
END: string;
|
|
5
|
-
DEFAULT_SPLITTER: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const extractTargetString: (target: string, form: any, field?: any) => string | number | boolean | Record<string, unknown>;
|
|
8
|
-
export declare const handler: ({ field, form, }: Pick<Events.TEventInformation, 'form' | 'field'>) => void;
|
|
2
|
+
export declare const handler: ({ field, form, }: Pick<Events.TEventInformation<unknown>, 'form' | 'field'>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TComponent } from '@core';
|
|
2
2
|
import * as Events from '@core/events';
|
|
3
|
-
export declare const handler: ({ field, form, eventReducedSchema: { api }, }: Pick<Events.TEventInformation
|
|
3
|
+
export declare const handler: ({ field, form, eventReducedSchema: { api }, }: Pick<Events.TEventInformation<unknown>, 'form' | 'field' | 'eventReducedSchema'>) => void;
|
|
4
4
|
export declare const events: (component: TComponent) => string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ field, }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ field, }: Pick<Events.TEventInformation<unknown>, 'field' | 'eventReducedSchema'>) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ field, data, }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ field, data, }: Pick<Events.TEventInformation<unknown>, 'field' | 'data'>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
import { TComponent } from
|
|
3
|
-
export declare const handler: ({ field, form, eventReducedSchema, }: Pick<Events.TEventInformation
|
|
2
|
+
import { TComponent } from '@core';
|
|
3
|
+
export declare const handler: ({ field, form, eventReducedSchema, }: Pick<Events.TEventInformation<unknown>, 'form' | 'eventReducedSchema' | 'field'>) => void;
|
|
4
4
|
export declare const events: (component: TComponent) => string[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TFormValues } from '@core';
|
|
2
2
|
import { TEventInformation } from '@core/events';
|
|
3
|
-
export declare const handler: ({ form, field, }: Pick<TEventInformation
|
|
3
|
+
export declare const handler: ({ form, field, }: Pick<TEventInformation<unknown>, 'form' | 'field'>) => TFormValues;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ field, data, eventReducedSchema: { formatters }, }: Events.TEventInformation) => void;
|
|
2
|
+
export declare const handler: ({ field, data, eventReducedSchema: { formatters }, }: Events.TEventInformation<unknown>) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ field }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ field }: Pick<Events.TEventInformation<unknown>, 'field'>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TComponent } from '@core';
|
|
2
2
|
import { TEventInformation } from '@core/events';
|
|
3
|
-
export declare const handler: ({ data, field, eventReducedSchema: { formatters }, }: TEventInformation) => void;
|
|
3
|
+
export declare const handler: ({ data, field, eventReducedSchema: { formatters }, }: TEventInformation<unknown>) => void;
|
|
4
4
|
export declare const events: (component: TComponent) => string[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TEventInformation } from '@core/events';
|
|
2
|
-
export declare const handler: ({ field, data: { event } }: TEventInformation) => {
|
|
2
|
+
export declare const handler: ({ field, data: { event } }: TEventInformation<unknown>) => {
|
|
3
3
|
parsedEventValue: any;
|
|
4
4
|
metadata: any;
|
|
5
5
|
isDeletingValue: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ field, data, }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ field, data, }: Pick<Events.TEventInformation<unknown>, 'field' | 'data'>) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ field, data, }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ field, data, }: Pick<Events.TEventInformation<unknown>, 'field' | 'data'>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TComponent } from '@core';
|
|
2
2
|
import * as Events from '@core/events';
|
|
3
|
-
export declare const handler: ({ field, eventReducedSchema: { masks }, }: Events.TEventInformation) => void;
|
|
3
|
+
export declare const handler: ({ field, eventReducedSchema: { masks }, }: Events.TEventInformation<unknown>) => void;
|
|
4
4
|
export declare const events: (component: TComponent) => string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ form, field, }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ form, field, }: Pick<Events.TEventInformation<unknown>, 'form' | 'field'>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TComponent } from '@core';
|
|
2
2
|
import * as Events from '@core/events';
|
|
3
|
-
export declare const handler: ({ field, eventReducedSchema: { validations }, form, }: Pick<Events.TEventInformation
|
|
3
|
+
export declare const handler: ({ field, eventReducedSchema: { validations }, form, }: Pick<Events.TEventInformation<unknown>, 'field' | 'eventReducedSchema' | 'form'>) => void;
|
|
4
4
|
export declare const events: (component: TComponent) => string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TComponent } from '@core';
|
|
2
2
|
import * as Events from '@core/events';
|
|
3
|
-
export declare const handler: ({ form, field, eventReducedSchema, }: Pick<Events.TEventInformation
|
|
3
|
+
export declare const handler: ({ form, field, eventReducedSchema, }: Pick<Events.TEventInformation<unknown>, 'form' | 'field' | 'eventReducedSchema'>) => void;
|
|
4
4
|
export declare const events: (component: TComponent) => string[];
|
|
@@ -12,6 +12,7 @@ import * as validations from '@core/handlers/field/validations';
|
|
|
12
12
|
import * as hooks from '@core/handlers/form/hooks';
|
|
13
13
|
import * as steps from '@core/handlers/form/steps';
|
|
14
14
|
import * as validate from '@core/handlers/form/validate';
|
|
15
|
+
import * as bindFields from '@core/handlers/form/bindFields';
|
|
15
16
|
import * as formLevelVisibilityConditions from '@core/handlers/form/visibilityConditions';
|
|
16
17
|
import * as formTemplating from '@core/handlers/form/templating';
|
|
17
18
|
declare const register: (observer: Events.Observer, flows: any, component?: any | TSchema) => void;
|
|
@@ -22,6 +23,7 @@ declare const fieldFlows: () => {
|
|
|
22
23
|
ON_FIELD_KEYDOWN: (typeof filter)[];
|
|
23
24
|
ON_FIELD_REHYDRATE: (typeof validations)[];
|
|
24
25
|
ON_FIELD_CLEARED: (typeof filter)[];
|
|
26
|
+
ON_FIELD_BINDED: (typeof filter)[];
|
|
25
27
|
ON_FIELD_CLICK: (typeof api)[];
|
|
26
28
|
ON_FIELD_BLUR: (typeof blur | typeof data)[];
|
|
27
29
|
ON_FIELD_FOCUS: (typeof focus)[];
|
|
@@ -39,5 +41,6 @@ declare const formFlows: () => {
|
|
|
39
41
|
NAVIGATE_STEP_FORWARD: (typeof steps)[];
|
|
40
42
|
ON_FORM_REHYDRATE: (typeof formLevelVisibilityConditions)[];
|
|
41
43
|
ON_FIELD_CHANGE: (typeof formLevelVisibilityConditions)[];
|
|
44
|
+
BIND_FIELDS: (typeof bindFields)[];
|
|
42
45
|
};
|
|
43
46
|
export { register, fieldFlows, formFlows };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TEventInformation } from '@core/events';
|
|
2
2
|
import { THookPayload } from '@core/types';
|
|
3
|
-
export declare const handler: ({ form, }: Pick<TEventInformation
|
|
3
|
+
export declare const handler: ({ form, }: Pick<TEventInformation<unknown>, 'form'>) => THookPayload;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ form, event, payload, }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ form, event, payload, }: Pick<Events.TEventInformation<unknown>, 'form' | 'event' | 'payload'>) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ form }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ form, }: Pick<Events.TEventInformation<unknown>, 'form'>) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ form, payload, }: Pick<Events.TEventInformation
|
|
2
|
+
export declare const handler: ({ form, payload, }: Pick<Events.TEventInformation<unknown>, 'form' | 'payload'>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TSchema } from '@core';
|
|
2
2
|
import { TEventInformation } from '@core/events';
|
|
3
|
-
export declare const handler: ({ form, formEventDirectives, }: Pick<TEventInformation
|
|
3
|
+
export declare const handler: ({ form, formEventDirectives, }: Pick<TEventInformation<unknown>, 'form' | 'formEventDirectives'>) => void;
|
|
4
4
|
export declare const events: (schema: TSchema) => string[];
|
|
@@ -9,6 +9,8 @@ declare class Field extends Base {
|
|
|
9
9
|
get value(): any;
|
|
10
10
|
set value(value: any);
|
|
11
11
|
get component(): TComponent;
|
|
12
|
+
get componentProps(): Record<string, unknown>;
|
|
13
|
+
set componentProps(props: Record<string, unknown>);
|
|
12
14
|
get data(): TField;
|
|
13
15
|
set data(data: TField);
|
|
14
16
|
set visibility(visible: boolean);
|
|
@@ -2,7 +2,7 @@ import Field from '@core/managers/Field';
|
|
|
2
2
|
import Scope from '@core/managers/Scope';
|
|
3
3
|
import Base from '@core/managers/Base';
|
|
4
4
|
import * as Events from '@core/events';
|
|
5
|
-
import { TComponent, TFormValues, TSchema, TStepData, TComponentPropsMapping, TFormEventDirectives, TEventsKeys } from '@core/types';
|
|
5
|
+
import { TComponent, TFormValues, TSchema, TStepData, TComponentPropsMapping, TFormEventDirectives, TEventsKeys, TFields } from '@core/types';
|
|
6
6
|
declare class Form extends Base {
|
|
7
7
|
#private;
|
|
8
8
|
formData: TFormValues;
|
|
@@ -11,18 +11,14 @@ declare class Form extends Base {
|
|
|
11
11
|
scopedSchema: TSchema;
|
|
12
12
|
scope: Scope;
|
|
13
13
|
initialValues: Record<string, unknown>;
|
|
14
|
-
steps: Record<number,
|
|
15
|
-
[x in string]: Field;
|
|
16
|
-
}>;
|
|
14
|
+
steps: Record<number, TFields>;
|
|
17
15
|
group: string;
|
|
18
16
|
constructor(formId: string, observer: Events.Observer, scope: Scope, schema: TSchema, opts: {
|
|
19
17
|
initialValues: Record<string, unknown>;
|
|
20
18
|
}, group: any);
|
|
21
19
|
get step(): TStepData;
|
|
22
20
|
set step(step: TStepData);
|
|
23
|
-
get fields():
|
|
24
|
-
[x: string]: Field;
|
|
25
|
-
};
|
|
21
|
+
get fields(): TFields;
|
|
26
22
|
eventReducedSchema(event: TEventsKeys): TFormEventDirectives;
|
|
27
23
|
getFieldInstance(component: TComponent, propsMapping?: TComponentPropsMapping): Field;
|
|
28
24
|
rehydrate(): void;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import { ICustomValidationValue } from '@core/apis/validations';
|
|
3
3
|
import { EEVents } from '@core/constants';
|
|
4
4
|
import { TEventInformation } from '@core/events';
|
|
5
|
-
|
|
5
|
+
import Field from "@core/managers/Field";
|
|
6
|
+
export declare type TObserverData<T> = {
|
|
6
7
|
data: any;
|
|
7
8
|
event: TEventsKeys;
|
|
8
9
|
namespace: string;
|
|
9
|
-
payload:
|
|
10
|
+
payload: T;
|
|
10
11
|
};
|
|
11
12
|
export declare type TObservable = (data: any, unsubscribe: () => void) => any;
|
|
12
13
|
export declare type TEvents = Record<string, TObservable[]>;
|
|
@@ -64,12 +65,20 @@ export declare type TChildrenOptions = {
|
|
|
64
65
|
scopeChangedChildren?: boolean;
|
|
65
66
|
};
|
|
66
67
|
export declare type TFieldData = Record<string, TField>;
|
|
68
|
+
export declare type TFields = {
|
|
69
|
+
[x in string]: Field;
|
|
70
|
+
};
|
|
71
|
+
export declare type TSubmitValueData = Record<string, {
|
|
72
|
+
value?: unknown;
|
|
73
|
+
props?: Record<string, unknown>;
|
|
74
|
+
}>;
|
|
67
75
|
export declare type TFormRefActions = {
|
|
68
76
|
submit(): void;
|
|
69
77
|
step(index: number | string): TFormValues;
|
|
70
78
|
stepForward(index?: number | string): TFormValues;
|
|
71
79
|
stepBack(index?: number | string): TFormValues;
|
|
72
80
|
validateForm(opts?: TChildrenOptions): Promise<TFormValues>;
|
|
81
|
+
bindFields(payload: TSubmitValueData): void;
|
|
73
82
|
values(opts: Pick<TChildrenOptions, 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'>): TFormValues;
|
|
74
83
|
};
|
|
75
84
|
export declare type THookPayload = {
|
|
@@ -539,7 +548,7 @@ export declare type TErrors = Record<string, TError> | undefined;
|
|
|
539
548
|
export declare type TErrorMessages = Record<string, string>;
|
|
540
549
|
export declare type TSchemaValidations = TSchemaHandler<TSchemaValidation>;
|
|
541
550
|
declare type TFormLevelSchemaHandler<T> = Partial<Record<EEVents.AFTER_FIELD_API_CALL | EEVents.ON_FIELD_CHANGE | EEVents.ON_FIELD_KEYUP | EEVents.ON_FIELD_KEYDOWN | EEVents.ON_FORM_REHYDRATE | EEVents.ON_FORM_MOUNT | EEVents.ON_SCOPE_CHANGE, T>>;
|
|
542
|
-
declare type TSchemaHandler<T> = Partial<Record<EEVents.AFTER_FIELD_API_CALL | EEVents.ON_FIELD_REHYDRATE | EEVents.ON_FIELD_CLEARED | EEVents.ON_FIELD_CHANGE | EEVents.ON_FIELD_KEYUP | EEVents.ON_FIELD_KEYDOWN | EEVents.ON_FIELD_BLUR | EEVents.ON_FIELD_MOUNT | EEVents.ON_FIELD_FOCUS | EEVents.ON_FIELD_CLICK, T>>;
|
|
551
|
+
declare type TSchemaHandler<T> = Partial<Record<EEVents.AFTER_FIELD_API_CALL | EEVents.ON_FIELD_REHYDRATE | EEVents.ON_FIELD_CLEARED | EEVents.ON_FIELD_BINDED | EEVents.ON_FIELD_CHANGE | EEVents.ON_FIELD_KEYUP | EEVents.ON_FIELD_KEYDOWN | EEVents.ON_FIELD_BLUR | EEVents.ON_FIELD_MOUNT | EEVents.ON_FIELD_FOCUS | EEVents.ON_FIELD_CLICK, T>>;
|
|
543
552
|
export declare type TSchemaVisibilityConditions = {
|
|
544
553
|
/**
|
|
545
554
|
* Enables visibility of fields only if any or all validation conditions are positive.
|
|
@@ -570,6 +579,7 @@ export declare type TSchemaVisibilityConditions = {
|
|
|
570
579
|
*/
|
|
571
580
|
fieldNames?: string[];
|
|
572
581
|
}[];
|
|
582
|
+
export declare type TClearFieldValue = string | number | boolean;
|
|
573
583
|
export declare type TClearField = {
|
|
574
584
|
/**
|
|
575
585
|
* The clearValues runs validations on the target field and not on the field it is declaring.
|
|
@@ -585,9 +595,13 @@ export declare type TClearField = {
|
|
|
585
595
|
*/
|
|
586
596
|
fields: string[];
|
|
587
597
|
/**
|
|
588
|
-
* The cleared values on the fields in case they do
|
|
598
|
+
* The cleared values on the fields in case they do not pass the validation
|
|
589
599
|
*/
|
|
590
|
-
clearedValue:
|
|
600
|
+
clearedValue: TClearFieldValue | TClearFieldValue[];
|
|
601
|
+
/**
|
|
602
|
+
* The cleared props from each component field on target fields array
|
|
603
|
+
*/
|
|
604
|
+
clearedProps?: Record<string, unknown> | Record<string, unknown>[];
|
|
591
605
|
};
|
|
592
606
|
export declare type TSchemaClearFields = TClearField[];
|
|
593
607
|
export declare type TSchemaApi = {
|
|
@@ -613,7 +627,7 @@ export declare type TFormEventDirectives = {
|
|
|
613
627
|
};
|
|
614
628
|
export declare type TComponent = {
|
|
615
629
|
/**
|
|
616
|
-
* This name will be used
|
|
630
|
+
* This name will be used later to correlate the field with the value, and you will be able to read it.
|
|
617
631
|
*
|
|
618
632
|
* You can also mount here complex objects like
|
|
619
633
|
*
|
|
@@ -628,7 +642,7 @@ export declare type TComponent = {
|
|
|
628
642
|
*/
|
|
629
643
|
name: string;
|
|
630
644
|
/**
|
|
631
|
-
* A component name that should map to the one you gave in the
|
|
645
|
+
* A component name that should map to the one you gave in the form mappings
|
|
632
646
|
*
|
|
633
647
|
* @example - For React
|
|
634
648
|
* ```
|
|
@@ -723,6 +737,9 @@ export declare type TComponent = {
|
|
|
723
737
|
* ```
|
|
724
738
|
*/
|
|
725
739
|
validations?: TSchemaHandler<Pick<TEventReducedSchema, 'validations'>['validations']>;
|
|
740
|
+
/**
|
|
741
|
+
* Filters the component value based on a validation.
|
|
742
|
+
*/
|
|
726
743
|
filter?: Pick<TEventReducedSchema, 'validations'>['validations'];
|
|
727
744
|
/**
|
|
728
745
|
* Allows you to specify the conditions a given field will be visible
|
|
@@ -733,8 +750,17 @@ export declare type TComponent = {
|
|
|
733
750
|
* Will clear target fields in case they do not pass with the specified validations
|
|
734
751
|
*/
|
|
735
752
|
clearFields?: Omit<TSchemaHandler<Pick<TEventReducedSchema, 'clearFields'>['clearFields']>, 'ON_FIELD_REHYDRATE' | 'ON_FIELD_CLEARED' | 'ON_FIELD_FOCUS'>;
|
|
753
|
+
/**
|
|
754
|
+
* Allows you to make api calls using events emitted by the component.
|
|
755
|
+
*/
|
|
736
756
|
api?: Omit<TSchemaHandler<Pick<TEventReducedSchema, 'api'>['api']>, 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS' | 'AFTER_FIELD_API_CALL'>;
|
|
757
|
+
/**
|
|
758
|
+
* Allows you to display the value of the masked component by events
|
|
759
|
+
*/
|
|
737
760
|
masks?: Partial<Record<EEVents.ON_FIELD_BLUR | EEVents.ON_FIELD_MOUNT | EEVents.ON_FIELD_FOCUS | EEVents.ON_FIELD_CHANGE | EEVents.ON_FIELD_KEYUP | EEVents.ON_FIELD_KEYDOWN, Pick<TEventReducedSchema, 'masks'>['masks']>>;
|
|
761
|
+
/**
|
|
762
|
+
* Allows you to format the value that the field will receive for each event issuance
|
|
763
|
+
*/
|
|
738
764
|
formatters?: Omit<TSchemaHandler<Pick<TEventReducedSchema, 'formatters'>['formatters']>, 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS'>;
|
|
739
765
|
};
|
|
740
766
|
export declare type TEventReducedSchema = {
|
|
@@ -832,7 +858,7 @@ export declare type TConfigs = {
|
|
|
832
858
|
export declare type TFlowType = {
|
|
833
859
|
[x: string]: {
|
|
834
860
|
events: (component?: TComponent) => EEVents[];
|
|
835
|
-
handler: (args: TEventInformation) => void;
|
|
861
|
+
handler: (args: TEventInformation<unknown>) => void;
|
|
836
862
|
}[];
|
|
837
863
|
};
|
|
838
864
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Scope from '@core/managers/Scope';
|
|
2
|
+
declare const template: {
|
|
3
|
+
BEGIN: string;
|
|
4
|
+
END: string;
|
|
5
|
+
DEFAULT_SPLITTER: string;
|
|
6
|
+
};
|
|
7
|
+
declare const getScopedField: <T>(scope: T, childrenScope?: string[]) => T;
|
|
8
|
+
declare const extractTargetString: <T>(target: string, formScope: Scope, scope?: Scope) => T;
|
|
9
|
+
export { getScopedField, extractTargetString, template };
|
|
@@ -2,3 +2,5 @@ export * as object from '@core/utils/object';
|
|
|
2
2
|
export * as creditCard from '@core/utils/credit-card';
|
|
3
3
|
export type { ICreditCardType } from '@core/utils/credit-card';
|
|
4
4
|
export * as string from '@core/utils/string';
|
|
5
|
+
export * as common from '@core/utils/common';
|
|
6
|
+
export * as value from '@core/utils/value';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Form from
|
|
2
|
-
import Field from
|
|
1
|
+
import Form from '@core/managers/Form';
|
|
2
|
+
import Field from '@core/managers/Field';
|
|
3
3
|
/**
|
|
4
4
|
* Encapsulates in a given object, at a given path the provided value
|
|
5
5
|
*
|
|
@@ -24,5 +24,4 @@ import Field from "@core/managers/Field";
|
|
|
24
24
|
* @returns One new object with the new value at the provided path merged with the given object
|
|
25
25
|
*/
|
|
26
26
|
declare const encapsulateIn: (origin: Record<string, unknown>, path: string, value: string, form: Form, field: Field) => Record<string, unknown>;
|
|
27
|
-
|
|
28
|
-
export { encapsulateIn, getValueByPath };
|
|
27
|
+
export { encapsulateIn };
|