@bolttech/form-engine 0.10.8 → 0.11.1
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 +127 -26
- package/asFormField-c36e1d6e.js +2 -0
- package/asFormField-c36e1d6e.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 -1
- package/src/core/handlers/common/templating.d.ts +0 -6
- package/src/core/handlers/field/clearFields.d.ts +1 -1
- package/src/core/handlers/flows.d.ts +3 -2
- package/src/core/handlers/form/templating.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 +27 -6
- 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-b207200a.js +0 -2
- package/asFormField-b207200a.js.map +0 -1
- /package/src/core/handlers/form/{changeFields.d.ts → bindFields.d.ts} +0 -0
|
@@ -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,7 +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",
|
|
27
|
-
|
|
28
|
+
BIND_FIELDS = "BIND_FIELDS",
|
|
28
29
|
LOG = "LOG"
|
|
29
30
|
}
|
|
30
31
|
export declare const CoreEvents: Record<TEventsKeys, TEventsKeys>;
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const template: {
|
|
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
2
|
export declare const handler: ({ field, form, }: Pick<Events.TEventInformation<unknown>, 'form' | 'field'>) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
import { TComponent } from
|
|
2
|
+
import { TComponent } from '@core';
|
|
3
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[];
|
|
@@ -12,7 +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
|
|
15
|
+
import * as bindFields from '@core/handlers/form/bindFields';
|
|
16
16
|
import * as formLevelVisibilityConditions from '@core/handlers/form/visibilityConditions';
|
|
17
17
|
import * as formTemplating from '@core/handlers/form/templating';
|
|
18
18
|
declare const register: (observer: Events.Observer, flows: any, component?: any | TSchema) => void;
|
|
@@ -23,6 +23,7 @@ declare const fieldFlows: () => {
|
|
|
23
23
|
ON_FIELD_KEYDOWN: (typeof filter)[];
|
|
24
24
|
ON_FIELD_REHYDRATE: (typeof validations)[];
|
|
25
25
|
ON_FIELD_CLEARED: (typeof filter)[];
|
|
26
|
+
ON_FIELD_BINDED: (typeof filter)[];
|
|
26
27
|
ON_FIELD_CLICK: (typeof api)[];
|
|
27
28
|
ON_FIELD_BLUR: (typeof blur | typeof data)[];
|
|
28
29
|
ON_FIELD_FOCUS: (typeof focus)[];
|
|
@@ -40,6 +41,6 @@ declare const formFlows: () => {
|
|
|
40
41
|
NAVIGATE_STEP_FORWARD: (typeof steps)[];
|
|
41
42
|
ON_FORM_REHYDRATE: (typeof formLevelVisibilityConditions)[];
|
|
42
43
|
ON_FIELD_CHANGE: (typeof formLevelVisibilityConditions)[];
|
|
43
|
-
|
|
44
|
+
BIND_FIELDS: (typeof bindFields)[];
|
|
44
45
|
};
|
|
45
46
|
export { register, fieldFlows, formFlows };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as Events from '@core/events';
|
|
2
|
-
export declare const handler: ({ form }: Pick<Events.TEventInformation<unknown>, 'form'>) => void;
|
|
2
|
+
export declare const handler: ({ form, }: Pick<Events.TEventInformation<unknown>, 'form'>) => void;
|
|
@@ -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,6 +2,7 @@
|
|
|
2
2
|
import { ICustomValidationValue } from '@core/apis/validations';
|
|
3
3
|
import { EEVents } from '@core/constants';
|
|
4
4
|
import { TEventInformation } from '@core/events';
|
|
5
|
+
import Field from "@core/managers/Field";
|
|
5
6
|
export declare type TObserverData<T> = {
|
|
6
7
|
data: any;
|
|
7
8
|
event: TEventsKeys;
|
|
@@ -64,6 +65,9 @@ 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
|
+
};
|
|
67
71
|
export declare type TSubmitValueData = Record<string, {
|
|
68
72
|
value?: unknown;
|
|
69
73
|
props?: Record<string, unknown>;
|
|
@@ -74,7 +78,7 @@ export declare type TFormRefActions = {
|
|
|
74
78
|
stepForward(index?: number | string): TFormValues;
|
|
75
79
|
stepBack(index?: number | string): TFormValues;
|
|
76
80
|
validateForm(opts?: TChildrenOptions): Promise<TFormValues>;
|
|
77
|
-
|
|
81
|
+
bindFields(payload: TSubmitValueData): void;
|
|
78
82
|
values(opts: Pick<TChildrenOptions, 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'>): TFormValues;
|
|
79
83
|
};
|
|
80
84
|
export declare type THookPayload = {
|
|
@@ -544,7 +548,7 @@ export declare type TErrors = Record<string, TError> | undefined;
|
|
|
544
548
|
export declare type TErrorMessages = Record<string, string>;
|
|
545
549
|
export declare type TSchemaValidations = TSchemaHandler<TSchemaValidation>;
|
|
546
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>>;
|
|
547
|
-
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>>;
|
|
548
552
|
export declare type TSchemaVisibilityConditions = {
|
|
549
553
|
/**
|
|
550
554
|
* Enables visibility of fields only if any or all validation conditions are positive.
|
|
@@ -575,6 +579,7 @@ export declare type TSchemaVisibilityConditions = {
|
|
|
575
579
|
*/
|
|
576
580
|
fieldNames?: string[];
|
|
577
581
|
}[];
|
|
582
|
+
export declare type TClearFieldValue = string | number | boolean;
|
|
578
583
|
export declare type TClearField = {
|
|
579
584
|
/**
|
|
580
585
|
* The clearValues runs validations on the target field and not on the field it is declaring.
|
|
@@ -590,9 +595,13 @@ export declare type TClearField = {
|
|
|
590
595
|
*/
|
|
591
596
|
fields: string[];
|
|
592
597
|
/**
|
|
593
|
-
* 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
|
|
599
|
+
*/
|
|
600
|
+
clearedValue: TClearFieldValue | TClearFieldValue[];
|
|
601
|
+
/**
|
|
602
|
+
* The cleared props from each component field on target fields array
|
|
594
603
|
*/
|
|
595
|
-
|
|
604
|
+
clearedProps?: Record<string, unknown> | Record<string, unknown>[];
|
|
596
605
|
};
|
|
597
606
|
export declare type TSchemaClearFields = TClearField[];
|
|
598
607
|
export declare type TSchemaApi = {
|
|
@@ -618,7 +627,7 @@ export declare type TFormEventDirectives = {
|
|
|
618
627
|
};
|
|
619
628
|
export declare type TComponent = {
|
|
620
629
|
/**
|
|
621
|
-
* 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.
|
|
622
631
|
*
|
|
623
632
|
* You can also mount here complex objects like
|
|
624
633
|
*
|
|
@@ -633,7 +642,7 @@ export declare type TComponent = {
|
|
|
633
642
|
*/
|
|
634
643
|
name: string;
|
|
635
644
|
/**
|
|
636
|
-
* 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
|
|
637
646
|
*
|
|
638
647
|
* @example - For React
|
|
639
648
|
* ```
|
|
@@ -728,6 +737,9 @@ export declare type TComponent = {
|
|
|
728
737
|
* ```
|
|
729
738
|
*/
|
|
730
739
|
validations?: TSchemaHandler<Pick<TEventReducedSchema, 'validations'>['validations']>;
|
|
740
|
+
/**
|
|
741
|
+
* Filters the component value based on a validation.
|
|
742
|
+
*/
|
|
731
743
|
filter?: Pick<TEventReducedSchema, 'validations'>['validations'];
|
|
732
744
|
/**
|
|
733
745
|
* Allows you to specify the conditions a given field will be visible
|
|
@@ -738,8 +750,17 @@ export declare type TComponent = {
|
|
|
738
750
|
* Will clear target fields in case they do not pass with the specified validations
|
|
739
751
|
*/
|
|
740
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
|
+
*/
|
|
741
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
|
+
*/
|
|
742
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
|
+
*/
|
|
743
764
|
formatters?: Omit<TSchemaHandler<Pick<TEventReducedSchema, 'formatters'>['formatters']>, 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS'>;
|
|
744
765
|
};
|
|
745
766
|
export declare type TEventReducedSchema = {
|
|
@@ -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 };
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../libs/form-engine/src/core/types/index.ts"],"sourcesContent":["import { ICustomValidationValue } from '@core/apis/validations';\nimport { EEVents } from '@core/constants';\nimport { TEventInformation } from '@core/events';\n\nexport type TObserverData<T> = {\n data: any;\n event: TEventsKeys;\n namespace: string;\n payload: T;\n};\n\nexport type TObservable = (data: any, unsubscribe: () => void) => any;\n\nexport type TEvents = Record<string, TObservable[]>;\n\nexport interface IObservable {\n events: TEvents;\n}\n\nexport type TScopeNamespaces =\n | 'global'\n | 'api'\n | 'hooks'\n | 'fields'\n | 'configs';\n\nexport type TSetGlobalScope = {\n namespace: TScopeNamespaces;\n key?: string;\n data: any;\n merge?: boolean;\n};\nexport type TScope = {\n global?: any;\n api?: any;\n hooks?: any;\n configs?: TConfigs & {\n disable?: boolean;\n enableLogging?: boolean;\n };\n fields?: any;\n};\n\nexport type TMapper = Record<string, Record<string, unknown>>;\n\nexport type TMaskGeneric = {\n to: number;\n from: number;\n mask: string;\n}[];\n\ntype TCurrencyMask = {\n locale: string;\n currency: string;\n};\n\nexport type TComponentMasks = {\n generic?: TMaskGeneric;\n cardNumber?: boolean;\n hideCardNumber?: boolean;\n cardMask?: boolean;\n cardDate?: boolean;\n currencyMask?: TCurrencyMask;\n feinMask?: boolean;\n replaceAll?: string | number;\n};\n\ntype TFormMessages = Record<\n string,\n { name: string; value?: any; values?: string[]; required?: boolean }\n>;\n\nexport type TChildrenOptions = {\n childrenScope?: string[];\n blurredChildren?: string[];\n changedChildren?: string[];\n scopeBlurredChildren?: boolean;\n scopeChangedChildren?: boolean;\n};\n\nexport type TFieldData = Record<string, TField>;\n\nexport type TSubmitValueData = Record<string, {\n value?: unknown,\n props?: Record<string,unknown>,\n}>\n\nexport type TFormRefActions = {\n submit(): void;\n step(index: number | string): TFormValues;\n stepForward(index?: number | string): TFormValues;\n stepBack(index?: number | string): TFormValues;\n validateForm(opts?: TChildrenOptions): Promise<TFormValues>;\n changeFields(payload: TSubmitValueData): void;\n values(\n opts: Pick<\n TChildrenOptions,\n 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'\n >,\n ): TFormValues;\n};\n\nexport type THookPayload = {\n setScope(data: TSetGlobalScope): void;\n};\n\nexport type THooks = {\n preMount?: () => Record<string, unknown>;\n preUnmount?: () => Record<string, unknown>;\n preSubmit?: (formData: TFormValues) => Record<string, unknown>;\n posSubmit?: (formData: TFormValues) => Record<string, unknown>;\n};\n\nexport type TIVars = Record<string, unknown>;\n\nexport type TEventsKeys = keyof typeof EEVents;\nexport enum TAvailableHooks {\n 'preMount' = 'preMount',\n 'preUnmount' = 'preUnmount',\n 'preSubmit' = 'preSubmit',\n 'postSubmit' = 'postSubmit',\n}\nexport type TField = {\n value?: string | number | boolean;\n errors?: TErrors;\n visible?: boolean;\n failedErrorMessages?: string[];\n mask?: string;\n changed?: boolean;\n keyup?: boolean;\n keydown?: boolean;\n blured?: boolean;\n focused?: boolean;\n name: string;\n mounted: boolean;\n metadata?: any;\n ignore?: boolean;\n schemaLocation?: {\n step: number;\n depth: number;\n index: number;\n };\n};\n\ntype TPathError = Omit<TSchemaValidation, 'path'> & {\n path?: string;\n paths?: string[];\n preventUnMountValidation?: boolean;\n};\n\nexport type TValidationDateFormats =\n | 'MMDDYYYY'\n | 'DDMMYYYY'\n | 'YYYYMMDD'\n | 'YYYYDDMM'\n | 'timestamp';\nexport type TValidationDateOperators = '<' | '>' | '===' | '>=' | '<=' | '!==';\n\nexport type TVAvailableValidationConditionsSet = {\n forceDefinedOrigin?: boolean;\n forceDefinedTarget?: boolean;\n origin?: string | number | boolean;\n condition: TValidationDateOperators;\n target?: string | number | boolean;\n};\n\nexport type TVAvailableValidationConditions = {\n rule: 'and' | 'or';\n set: TVAvailableValidationConditionsSet[];\n conditions?: TVAvailableValidationConditions;\n};\n\nexport type TVAvailableValidations = {\n /**\n * The bool function is a validation function that checks if a given value indicating whether the validation has failed or not.\n *\n * @example - in a test environment\n * ```\n * const result = bool({\n * validationValue: false,\n * });\n * console.log(result); // { fail: false }\n * ```\n *\n * @example - real json usage with field value\n * ```\n * {\n * validations: {\n * bool: '${fields.input.value}'\n * },\n * },\n * ```\n *\n * @example - real json usage with iVar value\n * ```\n * {\n * validations: {\n * bool: '${global.validation}'\n * },\n * },\n * ```\n */\n bool?: string | boolean;\n /**\n * Validation based on conditions\n *\n * @example - Compare own field to two. Origin and target default to field value\n * ```\n * conditions: {\n * rule: 'and',\n * set: [\n * {\n * condition: '===',\n * target: '2',\n * },\n * {\n * origin: '2',\n * condition: '===',\n * },\n * ],\n * },\n * ```\n * @example - Binded to Postcode field value. Must be greater than or equal two\n * ```\n * conditions: {\n * rule: 'or',\n * set: [\n * {\n * origin: '${fields.postcode.value}',\n * condition: '>',\n * target: '2',\n * },\n * {\n * origin: '${fields.postcode.value}',\n * condition: '===',\n * target: '2',\n * },\n * ],\n * },\n * ```\n * @example - Binded to Postcode field value. Must be equal to two\n * ```\n * conditions: {\n * rule: 'or',\n * set: [\n * {\n * origin: '${fields.postcode.value}',\n * condition: '===',\n * target: '2',\n * },\n * ],\n * },\n * ```\n */\n conditions?: TVAvailableValidationConditions;\n /**\n * Between validations\n *\n * @example - Between ages\n * ``` type teste = Pick<TVAvailableValidations, 'date'>\n * between: {\n * dates: [\n * {\n * operator: '>=',\n * origin: {\n * format: 'YYYYMMDD',\n * intervals: {\n * years: 18,\n * },\n * },\n * },\n * {\n * operator: '<=',\n * origin: {\n * format: 'YYYYMMDD',\n * intervals: {\n * years: 75,\n * },\n * },\n * }\n * ]\n * }\n * ```\n *\n * @example - Between numbers\n * ```\n * between: {\n * start: '3',\n * end: '4',\n * isIncludedBoundaries: true\n * },\n * ```\n *\n */\n between?: {\n /**\n * Array of date validations. To make it possible, ensure that the conditions is > and < in both date validations.\n */\n dates?: TVAvailableValidations['date'][];\n /**\n * The first number of the validation. If the current value is grater than this number, the validation will pass.\n */\n start?: number;\n /**\n * The second number of the validation. If the current value is lower than this number, the validation will pass.\n */\n end?: number;\n /**\n * If it's true, the comparision is transformed to >= and <=. So, the numbers that were passed are included in the validation.\n */\n isIncludedBoundaries?: boolean;\n };\n /**\n * Dates validations\n *\n * @example - Dates should be different\n * ```\n * date: {\n * operator: '!==',\n * origin: {\n * format: 'DDMMYYYY',\n * },\n * target: {\n * format: 'DDMMYYYY',\n * value: '10/10/2001',\n * },\n * },*\n * ```\n *\n * @example - Compare only valid dates using intervals\n * ```\n * date: {\n * onlyValidDate: true,\n * operator: '<',\n * origin: {\n * format: 'DD/MM/YYYY',\n * intervals: {\n * years: 1,\n * },\n * },\n * },\n * ```\n *\n * @example - Should have at max 85 years\n * ```\n * {\n * operator: '>',\n * origin: {\n * format: 'DDMMYYYY',\n * value: eightyFiveYearsDate,\n * intervals: {\n * years: 85,\n * },\n * },\n * }\n * }\n *\n * ```\n */\n date?: {\n /**\n * Flag to force only valid dates. Valid dates must be of min length of 8\n */\n onlyValidDate?: boolean;\n /**\n * List of operations you can do\n * - between origin and target dates\n * - between origin and intervals\n */\n operator: TValidationDateOperators;\n /**\n * The origin configurations\n */\n origin: {\n /**\n * Origin date value\n */\n value?: string | number;\n /**\n * The available date formats\n */\n format: TValidationDateFormats;\n /**\n * Intervals to compare with the original date.\n *\n * It will use todays date for comparison.\n *\n * @example\n *\n * origin date = 10/10/2022\n * interval.year = 1\n * operator = '==='\n *\n * It will compare (10/10/2022 + 1) with the current date and check if they are the same\n */\n intervals?: {\n years?: number;\n months?: number;\n days?: number;\n };\n };\n target?: {\n value: string | number;\n format: TValidationDateFormats;\n };\n };\n /**\n * Allow to define a maximum length for the input to have no error\n */\n length?: number;\n /**\n * Will look into the input length and send an error if if not greater than this value\n */\n greaterThan?: number | string;\n\n /**\n * Specifies a regular expression pattern that the value should match.\n */\n regex?: string;\n\n /**\n * Specifies the maximum length of the value (if it's a string).\n */\n maxLength?: number;\n\n /**\n * Specifies the minimum length of the value (if it's a string).\n */\n minLength?: number;\n\n /**\n * Specifies whether the field is required.\n */\n required?: boolean;\n\n /**\n * Specifies that the value should contain only letters.\n */\n onlyLetters?: boolean;\n\n /**\n * Specifies a value that the field should match.\n */\n value?: string | number | boolean;\n\n /**\n * Specifies that the field should not be empty.\n */\n notEmpty?: boolean;\n\n /**\n * A callback function that performs custom validation on the value.\n * @param value - The value to be validated.\n * @returns An object with validation results.\n */\n callback?(value: string | number): { fail: boolean; errorMessage?: string };\n\n /**\n * Specifies a numeric range for the value.\n */\n numericRange?: { start: number | string; end: number | string };\n\n /**\n * Specifies whether the value should be a number.\n */\n isNumber?: boolean;\n\n /**\n * Specifies that the field should not have extra spaces.\n */\n hasNoExtraSpaces?: boolean;\n\n /**\n * Specifies that the value should be an email address.\n */\n email?: boolean;\n\n /**\n * Specifies that the value should be less than a given number or string.\n */\n lessThan?: number | string;\n\n /**\n * Specifies that the value should be a sequential number.\n */\n sequentialNumber?: boolean;\n\n /**\n * Specifies that the value should not contain repeated numbers.\n */\n repeatedNumbers?: boolean;\n\n /**\n * Specifies that the value should be a URL.\n */\n url?: boolean;\n\n /**\n * Specifies a path error type.\n */\n path?: TPathError;\n\n /**\n * Specifies that the value should be a valid credit card number.\n */\n isCreditCard?: string[];\n\n /**\n * Specifies that the value should be a valid credit card number with a specific length.\n */\n isCreditCardAndLength?: string[];\n\n /**\n * Specifies that the value should match a credit card code with available options.\n */\n isCreditCodeMatch?: { numberCard: string; availableOptions: string[] };\n\n /**\n * Specifies custom validation options for the field.\n */\n customValidation?: ICustomValidationValue[];\n\n /**\n * Specifies that spaces are not allowed in the field.\n */\n notAllowSpaces?: true;\n\n /**\n * Specifies that the value should be in a predefined list of values.\n */\n isInTheList?: string[] | number[] | string;\n\n /**\n * Specifies field validation rules for nested fields.\n */\n fields?: {\n /**\n * The rule for validating nested fields (e.g., 'every').\n */\n rule: 'every';\n\n /**\n * An array of nested field validation configurations.\n */\n set: {\n /**\n * The binding for the nested field.\n */\n bind: string;\n\n /**\n * The field name for the nested field.\n */\n fieldName: string;\n\n /**\n * Validation options for the nested field, excluding the 'fields' property.\n */\n validations: Omit<TVAvailableValidations, 'fields'>;\n }[];\n };\n\n /**\n * Specifies that the value should be existed.\n */\n exists?: string | number;\n};\n\nexport type TGenericValidationRule = {\n [key: string]: TVAvailableValidations;\n};\n\nexport type TSchemaValidation = TVAvailableValidations | TGenericValidationRule;\n\nexport type TStepData = {\n navigated: boolean;\n index: number;\n data: Record<\n number,\n Pick<\n TFormValues,\n 'fields' | 'erroredFields' | 'formatted' | 'filteredFields'\n >\n >;\n currentStepSchema?: TComponent;\n isValid: boolean;\n numSteps?: number;\n};\n\nexport type TFormValues = {\n predictableErroredFields: string[];\n erroredFields: string[];\n fields: TFieldData;\n formatted: Record<string, unknown>;\n filteredFields?: Record<string, unknown>;\n form: {\n steps: TStepData;\n isValid: boolean;\n messages: string[];\n scope: TScope;\n };\n};\n\nexport type TError = {\n value: unknown;\n message?: string;\n fail: boolean;\n};\n\nexport type TErrors = Record<string, TError> | undefined;\n\n// TODO - object with the available errors has props\nexport type TErrorMessages = Record<string, string>;\n\nexport type TSchemaValidations = TSchemaHandler<TSchemaValidation>;\n\ntype TFormLevelSchemaHandler<T> = Partial<\n Record<\n | EEVents.AFTER_FIELD_API_CALL\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN\n | EEVents.ON_FORM_REHYDRATE\n | EEVents.ON_FORM_MOUNT\n | EEVents.ON_SCOPE_CHANGE,\n T\n >\n>;\n\ntype TSchemaHandler<T> = Partial<\n Record<\n | EEVents.AFTER_FIELD_API_CALL\n | EEVents.ON_FIELD_REHYDRATE\n | EEVents.ON_FIELD_CLEARED\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS\n | EEVents.ON_FIELD_CLICK,\n T\n >\n>;\n\nexport type TSchemaVisibilityConditions = {\n /**\n * Enables visibility of fields only if any or all validation conditions are positive.\n *\n * The default is false, so if all validations are false, the field will display, if any are positive,\n * the field will hide, as well as if all are positive.\n */\n showOnlyIfTrue?: boolean;\n /**\n * Allows you to choose the type of chain for validations.\n *\n * The default is OR, where at least one validation needs to be true to work. In the case of AND,\n * all validations must be true.\n */\n rule?: 'or' | 'and';\n /**\n * The validations that will say if the target field will be visible or not\n *\n * Those validations will run against your field (the one that has this directive)\n */\n validations: TSchemaValidation;\n /**\n * Target field that will have the visibility toggled\n */\n fieldName?: string;\n /**\n * Target fields that will have the visibility toggled\n */\n fieldNames?: string[];\n}[];\n\nexport type TClearField = {\n /**\n * The clearValues runs validations on the target field and not on the field it is declaring.\n * Therefore, set this prop with true if you want validations to be performed on the current field.\n */\n useCurrentFieldValidation?: boolean;\n /**\n * Validations to run for the target field\n */\n validations?: TSchemaValidation;\n /**\n * target fields that will be used in the validation specified\n */\n fields: string[];\n /**\n * The cleared values on the fields in case they do no pass the validation\n */\n clearedValue: string | number | boolean;\n};\n\nexport type TSchemaClearFields = TClearField[];\n\nexport type TSchemaApi = {\n /**\n * Specify a debounce time in miliseconds for your call\n */\n debounceTime?: number;\n method: 'GET' | 'POST' | 'PUT' | 'PATCH';\n url: string;\n headers?: HeadersInit | undefined;\n body?: Record<string, any>;\n fieldValueAsParams?: Record<string, string>;\n fieldValueAsPathParams?: string[];\n scope?: string;\n blockRequestWhenInvalid?: boolean;\n preConditions?: TSchemaValidation;\n}[];\n\nexport type TSchemaMasks = { cleanMask?: boolean } & TComponentMasks;\n\nexport type TFormEventDirectives = {\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TComponent = {\n /**\n * This name will be used latter to corelate the field with the value and you will be able to read it\n *\n * You can also mount here complex objects like\n *\n * name={a.b.c}\n *\n * that will result in\n * a: {\n * b: {\n * c: 'field_value'\n * }\n * }\n */\n name: string;\n /**\n * A component name that should map to the one you gave in the from mappings\n *\n * @example - For React\n * ```\n * const mappings: TMapper = {\n * input: { component: Input },\n * formGroup: { component: FormGroup },\n * };\n * ```\n *\n * The component name for the Input element will be \"input\" ending up like\n * ```\n * {\n * component: 'input'\n * }\n * ```\n */\n component: string;\n /**\n * You can attach metadata to your component that will be forwarded to you after on your frontend\n * callback methods link `onData`, `onBlur` etc\n */\n metadata?: Record<string, any>;\n /**\n * This property allows you to specify a virtual fieldName that can be in several fields\n *\n * USAGE - You have two fields but you want to have the value stored only under one name\n *\n */\n group?: string;\n wrapper?: new () => React.Component;\n children?: TComponent[];\n /**\n * Field error messages in case any validation fails\n *\n * @example - Set a default error message for all the validations\n *\n * ```\n * {\n * errorMessages: {\n * default: 'default error message'\n * }\n * }\n * ```\n *\n * @example - Set error message for a given validation\n *\n * ```\n * {\n * validations: {\n * ON_FIELD_CHANGE: {\n * required: true\n * }\n * },\n * errorMessages: {\n * required: 'This field is required'\n * }\n * }\n * ```\n *\n */\n errorMessages?: TErrorMessages;\n type?: 'text' | 'number' | string;\n /**\n * Allow you to set a initial state for this field\n */\n state?: {\n /**\n * Hide the field\n */\n hidden?: boolean;\n /**\n * Ignore value from field\n */\n ignoreValue?: boolean;\n };\n /**\n * This key lets you inject props directly into the component\n */\n props?: Record<string, unknown>;\n /**\n * Setup validations to be used in the field.\n *\n * You can setup validations in several life-cycle methods\n *\n * @example - Required validation\n * ```\n * validations: {\n ON_FIELD_CHANGE: {\n required: true,\n },\n },\n * ```\n */\n validations?: TSchemaHandler<\n Pick<TEventReducedSchema, 'validations'>['validations']\n >;\n filter?: Pick<TEventReducedSchema, 'validations'>['validations'];\n /**\n * Allows you to specify the conditions a given field will be visible\n * what will run when this field meets the specified life-cycle\n */\n visibilityConditions?: Omit<\n TSchemaHandler<\n Pick<TEventReducedSchema, 'visibilityConditions'>['visibilityConditions']\n >,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_CLEARED' | 'ON_FIELD_FOCUS'\n >;\n /**\n * Will clear target fields in case they do not pass with the specified validations\n */\n clearFields?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'clearFields'>['clearFields']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_CLEARED' | 'ON_FIELD_FOCUS'\n >;\n api?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'api'>['api']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS' | 'AFTER_FIELD_API_CALL'\n >;\n masks?: Partial<\n Record<\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN,\n Pick<TEventReducedSchema, 'masks'>['masks']\n >\n >;\n formatters?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'formatters'>['formatters']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS'\n >;\n};\n\nexport type TEventReducedSchema = {\n api: TSchemaApi;\n clearFields: TSchemaClearFields;\n formatters: TSchemaFormatters;\n masks: TSchemaMasks;\n validations: TSchemaValidation;\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TStep = {\n component: string;\n name: string;\n children: TComponent[];\n props?: Record<string, string>;\n};\n\nexport type TComponentPropsMapping = {\n getValue?: string;\n setValue?: string;\n onBlur?: string;\n onClick?: string;\n onFocus?: string;\n onKeyUp?: string;\n onKeyDown?: string;\n setErrorMessage?: string;\n setErrorState?: string;\n};\n\nexport type TPropsMapping = Record<string, TComponentPropsMapping>;\n\nexport type TSchema = {\n /**\n * Used to disable form submit input and prevent to submit form using enter event.\n * Default is false.\n */\n disableFormSubmit?: boolean;\n action?: string;\n method?: string;\n /**\n * Give some configurations to the form\n */\n configs?: TConfigs;\n /**\n * Allows you to expose some messages to the outside world when something happen\n */\n messages?: TFormMessages;\n /**\n * Specify some static field defaults before rendereing the form.\n *\n * If you have initialValues in the frontend setted, those will ovewride this\n */\n formattedDataDefaults?: Record<string, unknown>;\n /**\n * Form level props mapping\n */\n propsMapping?: TPropsMapping;\n visibilityConditions?: TFormLevelSchemaHandler<TSchemaVisibilityConditions>;\n /**\n * Entry point for the form should be a step (even if you have only one)\n */\n components: TStep[];\n /**\n * You can have many fields in the form, but be interested only in some\n *\n * You can put here the fields you want to read onSubmit for example\n *\n * You will receive those in TFormValues.filteredFields\n */\n filteredFields?: string[];\n /**\n * Schema level iVars.\n *\n * These iVars will go to the global scope namespace\n */\n iVars?: TIVars;\n};\n\nexport type TSplitterFormatterValue = {\n value: string;\n position: number;\n}[];\n\nexport type TSchemaFormatters = {\n splitter?: TSplitterFormatterValue;\n capitalize?: boolean;\n upperCase?: boolean;\n gapsCreditCard?: string[];\n onlyNumbers?: boolean;\n onlyLetters?: boolean;\n regex?: string;\n};\n\nexport type TConfigs = {\n observables?: { templates?: { exclude?: string[] } };\n};\n\nexport type TFlowType = {\n [x: string]: {\n events: (component?: TComponent) => EEVents[];\n handler: (args: TEventInformation<unknown>) => void;\n }[];\n};\n"],"names":["TAvailableHooks"],"mappings":"aAoHA,IAAYA,yDAAAA,QAKXA,qBAAA,GALWA,EAAAA,QAAeA,kBAAfA,wBAKX,CAAA,IAJC,SAAA,WACAA,EAAA,WAAA,aACAA,EAAA,UAAA,YACAA,EAAA,WAAA"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../libs/form-engine/src/core/types/index.ts"],"sourcesContent":["import { ICustomValidationValue } from '@core/apis/validations';\nimport { EEVents } from '@core/constants';\nimport { TEventInformation } from '@core/events';\nimport Field from \"@core/managers/Field\";\n\nexport type TObserverData<T> = {\n data: any;\n event: TEventsKeys;\n namespace: string;\n payload: T;\n};\n\nexport type TObservable = (data: any, unsubscribe: () => void) => any;\n\nexport type TEvents = Record<string, TObservable[]>;\n\nexport interface IObservable {\n events: TEvents;\n}\n\nexport type TScopeNamespaces =\n | 'global'\n | 'api'\n | 'hooks'\n | 'fields'\n | 'configs';\n\nexport type TSetGlobalScope = {\n namespace: TScopeNamespaces;\n key?: string;\n data: any;\n merge?: boolean;\n};\nexport type TScope = {\n global?: any;\n api?: any;\n hooks?: any;\n configs?: TConfigs & {\n disable?: boolean;\n enableLogging?: boolean;\n };\n fields?: any;\n};\n\nexport type TMapper = Record<string, Record<string, unknown>>;\n\nexport type TMaskGeneric = {\n to: number;\n from: number;\n mask: string;\n}[];\n\ntype TCurrencyMask = {\n locale: string;\n currency: string;\n};\n\nexport type TComponentMasks = {\n generic?: TMaskGeneric;\n cardNumber?: boolean;\n hideCardNumber?: boolean;\n cardMask?: boolean;\n cardDate?: boolean;\n currencyMask?: TCurrencyMask;\n feinMask?: boolean;\n replaceAll?: string | number;\n};\n\ntype TFormMessages = Record<\n string,\n { name: string; value?: any; values?: string[]; required?: boolean }\n>;\n\nexport type TChildrenOptions = {\n childrenScope?: string[];\n blurredChildren?: string[];\n changedChildren?: string[];\n scopeBlurredChildren?: boolean;\n scopeChangedChildren?: boolean;\n};\n\nexport type TFieldData = Record<string, TField>;\nexport type TFields = { [x in string]: Field };\n\nexport type TSubmitValueData = Record<string, {\n value?: unknown,\n props?: Record<string,unknown>,\n}>\n\nexport type TFormRefActions = {\n submit(): void;\n step(index: number | string): TFormValues;\n stepForward(index?: number | string): TFormValues;\n stepBack(index?: number | string): TFormValues;\n validateForm(opts?: TChildrenOptions): Promise<TFormValues>;\n bindFields(payload: TSubmitValueData): void;\n values(\n opts: Pick<\n TChildrenOptions,\n 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'\n >,\n ): TFormValues;\n};\n\nexport type THookPayload = {\n setScope(data: TSetGlobalScope): void;\n};\n\nexport type THooks = {\n preMount?: () => Record<string, unknown>;\n preUnmount?: () => Record<string, unknown>;\n preSubmit?: (formData: TFormValues) => Record<string, unknown>;\n posSubmit?: (formData: TFormValues) => Record<string, unknown>;\n};\n\nexport type TIVars = Record<string, unknown>;\n\nexport type TEventsKeys = keyof typeof EEVents;\nexport enum TAvailableHooks {\n 'preMount' = 'preMount',\n 'preUnmount' = 'preUnmount',\n 'preSubmit' = 'preSubmit',\n 'postSubmit' = 'postSubmit',\n}\nexport type TField = {\n value?: string | number | boolean;\n errors?: TErrors;\n visible?: boolean;\n failedErrorMessages?: string[];\n mask?: string;\n changed?: boolean;\n keyup?: boolean;\n keydown?: boolean;\n blured?: boolean;\n focused?: boolean;\n name: string;\n mounted: boolean;\n metadata?: any;\n ignore?: boolean;\n schemaLocation?: {\n step: number;\n depth: number;\n index: number;\n };\n};\n\ntype TPathError = Omit<TSchemaValidation, 'path'> & {\n path?: string;\n paths?: string[];\n preventUnMountValidation?: boolean;\n};\n\nexport type TValidationDateFormats =\n | 'MMDDYYYY'\n | 'DDMMYYYY'\n | 'YYYYMMDD'\n | 'YYYYDDMM'\n | 'timestamp';\nexport type TValidationDateOperators = '<' | '>' | '===' | '>=' | '<=' | '!==';\n\nexport type TVAvailableValidationConditionsSet = {\n forceDefinedOrigin?: boolean;\n forceDefinedTarget?: boolean;\n origin?: string | number | boolean;\n condition: TValidationDateOperators;\n target?: string | number | boolean;\n};\n\nexport type TVAvailableValidationConditions = {\n rule: 'and' | 'or';\n set: TVAvailableValidationConditionsSet[];\n conditions?: TVAvailableValidationConditions;\n};\n\nexport type TVAvailableValidations = {\n /**\n * The bool function is a validation function that checks if a given value indicating whether the validation has failed or not.\n *\n * @example - in a test environment\n * ```\n * const result = bool({\n * validationValue: false,\n * });\n * console.log(result); // { fail: false }\n * ```\n *\n * @example - real json usage with field value\n * ```\n * {\n * validations: {\n * bool: '${fields.input.value}'\n * },\n * },\n * ```\n *\n * @example - real json usage with iVar value\n * ```\n * {\n * validations: {\n * bool: '${global.validation}'\n * },\n * },\n * ```\n */\n bool?: string | boolean;\n /**\n * Validation based on conditions\n *\n * @example - Compare own field to two. Origin and target default to field value\n * ```\n * conditions: {\n * rule: 'and',\n * set: [\n * {\n * condition: '===',\n * target: '2',\n * },\n * {\n * origin: '2',\n * condition: '===',\n * },\n * ],\n * },\n * ```\n * @example - Binded to Postcode field value. Must be greater than or equal two\n * ```\n * conditions: {\n * rule: 'or',\n * set: [\n * {\n * origin: '${fields.postcode.value}',\n * condition: '>',\n * target: '2',\n * },\n * {\n * origin: '${fields.postcode.value}',\n * condition: '===',\n * target: '2',\n * },\n * ],\n * },\n * ```\n * @example - Binded to Postcode field value. Must be equal to two\n * ```\n * conditions: {\n * rule: 'or',\n * set: [\n * {\n * origin: '${fields.postcode.value}',\n * condition: '===',\n * target: '2',\n * },\n * ],\n * },\n * ```\n */\n conditions?: TVAvailableValidationConditions;\n /**\n * Between validations\n *\n * @example - Between ages\n * ``` type teste = Pick<TVAvailableValidations, 'date'>\n * between: {\n * dates: [\n * {\n * operator: '>=',\n * origin: {\n * format: 'YYYYMMDD',\n * intervals: {\n * years: 18,\n * },\n * },\n * },\n * {\n * operator: '<=',\n * origin: {\n * format: 'YYYYMMDD',\n * intervals: {\n * years: 75,\n * },\n * },\n * }\n * ]\n * }\n * ```\n *\n * @example - Between numbers\n * ```\n * between: {\n * start: '3',\n * end: '4',\n * isIncludedBoundaries: true\n * },\n * ```\n *\n */\n between?: {\n /**\n * Array of date validations. To make it possible, ensure that the conditions is > and < in both date validations.\n */\n dates?: TVAvailableValidations['date'][];\n /**\n * The first number of the validation. If the current value is grater than this number, the validation will pass.\n */\n start?: number;\n /**\n * The second number of the validation. If the current value is lower than this number, the validation will pass.\n */\n end?: number;\n /**\n * If it's true, the comparision is transformed to >= and <=. So, the numbers that were passed are included in the validation.\n */\n isIncludedBoundaries?: boolean;\n };\n /**\n * Dates validations\n *\n * @example - Dates should be different\n * ```\n * date: {\n * operator: '!==',\n * origin: {\n * format: 'DDMMYYYY',\n * },\n * target: {\n * format: 'DDMMYYYY',\n * value: '10/10/2001',\n * },\n * },*\n * ```\n *\n * @example - Compare only valid dates using intervals\n * ```\n * date: {\n * onlyValidDate: true,\n * operator: '<',\n * origin: {\n * format: 'DD/MM/YYYY',\n * intervals: {\n * years: 1,\n * },\n * },\n * },\n * ```\n *\n * @example - Should have at max 85 years\n * ```\n * {\n * operator: '>',\n * origin: {\n * format: 'DDMMYYYY',\n * value: eightyFiveYearsDate,\n * intervals: {\n * years: 85,\n * },\n * },\n * }\n * }\n *\n * ```\n */\n date?: {\n /**\n * Flag to force only valid dates. Valid dates must be of min length of 8\n */\n onlyValidDate?: boolean;\n /**\n * List of operations you can do\n * - between origin and target dates\n * - between origin and intervals\n */\n operator: TValidationDateOperators;\n /**\n * The origin configurations\n */\n origin: {\n /**\n * Origin date value\n */\n value?: string | number;\n /**\n * The available date formats\n */\n format: TValidationDateFormats;\n /**\n * Intervals to compare with the original date.\n *\n * It will use todays date for comparison.\n *\n * @example\n *\n * origin date = 10/10/2022\n * interval.year = 1\n * operator = '==='\n *\n * It will compare (10/10/2022 + 1) with the current date and check if they are the same\n */\n intervals?: {\n years?: number;\n months?: number;\n days?: number;\n };\n };\n target?: {\n value: string | number;\n format: TValidationDateFormats;\n };\n };\n /**\n * Allow to define a maximum length for the input to have no error\n */\n length?: number;\n /**\n * Will look into the input length and send an error if if not greater than this value\n */\n greaterThan?: number | string;\n\n /**\n * Specifies a regular expression pattern that the value should match.\n */\n regex?: string;\n\n /**\n * Specifies the maximum length of the value (if it's a string).\n */\n maxLength?: number;\n\n /**\n * Specifies the minimum length of the value (if it's a string).\n */\n minLength?: number;\n\n /**\n * Specifies whether the field is required.\n */\n required?: boolean;\n\n /**\n * Specifies that the value should contain only letters.\n */\n onlyLetters?: boolean;\n\n /**\n * Specifies a value that the field should match.\n */\n value?: string | number | boolean;\n\n /**\n * Specifies that the field should not be empty.\n */\n notEmpty?: boolean;\n\n /**\n * A callback function that performs custom validation on the value.\n * @param value - The value to be validated.\n * @returns An object with validation results.\n */\n callback?(value: string | number): { fail: boolean; errorMessage?: string };\n\n /**\n * Specifies a numeric range for the value.\n */\n numericRange?: { start: number | string; end: number | string };\n\n /**\n * Specifies whether the value should be a number.\n */\n isNumber?: boolean;\n\n /**\n * Specifies that the field should not have extra spaces.\n */\n hasNoExtraSpaces?: boolean;\n\n /**\n * Specifies that the value should be an email address.\n */\n email?: boolean;\n\n /**\n * Specifies that the value should be less than a given number or string.\n */\n lessThan?: number | string;\n\n /**\n * Specifies that the value should be a sequential number.\n */\n sequentialNumber?: boolean;\n\n /**\n * Specifies that the value should not contain repeated numbers.\n */\n repeatedNumbers?: boolean;\n\n /**\n * Specifies that the value should be a URL.\n */\n url?: boolean;\n\n /**\n * Specifies a path error type.\n */\n path?: TPathError;\n\n /**\n * Specifies that the value should be a valid credit card number.\n */\n isCreditCard?: string[];\n\n /**\n * Specifies that the value should be a valid credit card number with a specific length.\n */\n isCreditCardAndLength?: string[];\n\n /**\n * Specifies that the value should match a credit card code with available options.\n */\n isCreditCodeMatch?: { numberCard: string; availableOptions: string[] };\n\n /**\n * Specifies custom validation options for the field.\n */\n customValidation?: ICustomValidationValue[];\n\n /**\n * Specifies that spaces are not allowed in the field.\n */\n notAllowSpaces?: true;\n\n /**\n * Specifies that the value should be in a predefined list of values.\n */\n isInTheList?: string[] | number[] | string;\n\n /**\n * Specifies field validation rules for nested fields.\n */\n fields?: {\n /**\n * The rule for validating nested fields (e.g., 'every').\n */\n rule: 'every';\n\n /**\n * An array of nested field validation configurations.\n */\n set: {\n /**\n * The binding for the nested field.\n */\n bind: string;\n\n /**\n * The field name for the nested field.\n */\n fieldName: string;\n\n /**\n * Validation options for the nested field, excluding the 'fields' property.\n */\n validations: Omit<TVAvailableValidations, 'fields'>;\n }[];\n };\n\n /**\n * Specifies that the value should be existed.\n */\n exists?: string | number;\n};\n\nexport type TGenericValidationRule = {\n [key: string]: TVAvailableValidations;\n};\n\nexport type TSchemaValidation = TVAvailableValidations | TGenericValidationRule;\n\nexport type TStepData = {\n navigated: boolean;\n index: number;\n data: Record<\n number,\n Pick<\n TFormValues,\n 'fields' | 'erroredFields' | 'formatted' | 'filteredFields'\n >\n >;\n currentStepSchema?: TComponent;\n isValid: boolean;\n numSteps?: number;\n};\n\nexport type TFormValues = {\n predictableErroredFields: string[];\n erroredFields: string[];\n fields: TFieldData;\n formatted: Record<string, unknown>;\n filteredFields?: Record<string, unknown>;\n form: {\n steps: TStepData;\n isValid: boolean;\n messages: string[];\n scope: TScope;\n };\n};\n\nexport type TError = {\n value: unknown;\n message?: string;\n fail: boolean;\n};\n\nexport type TErrors = Record<string, TError> | undefined;\n\n// TODO - object with the available errors has props\nexport type TErrorMessages = Record<string, string>;\n\nexport type TSchemaValidations = TSchemaHandler<TSchemaValidation>;\n\ntype TFormLevelSchemaHandler<T> = Partial<\n Record<\n | EEVents.AFTER_FIELD_API_CALL\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN\n | EEVents.ON_FORM_REHYDRATE\n | EEVents.ON_FORM_MOUNT\n | EEVents.ON_SCOPE_CHANGE,\n T\n >\n>;\n\ntype TSchemaHandler<T> = Partial<\n Record<\n | EEVents.AFTER_FIELD_API_CALL\n | EEVents.ON_FIELD_REHYDRATE\n | EEVents.ON_FIELD_CLEARED\n | EEVents.ON_FIELD_BINDED\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS\n | EEVents.ON_FIELD_CLICK,\n T\n >\n>;\n\nexport type TSchemaVisibilityConditions = {\n /**\n * Enables visibility of fields only if any or all validation conditions are positive.\n *\n * The default is false, so if all validations are false, the field will display, if any are positive,\n * the field will hide, as well as if all are positive.\n */\n showOnlyIfTrue?: boolean;\n /**\n * Allows you to choose the type of chain for validations.\n *\n * The default is OR, where at least one validation needs to be true to work. In the case of AND,\n * all validations must be true.\n */\n rule?: 'or' | 'and';\n /**\n * The validations that will say if the target field will be visible or not\n *\n * Those validations will run against your field (the one that has this directive)\n */\n validations: TSchemaValidation;\n /**\n * Target field that will have the visibility toggled\n */\n fieldName?: string;\n /**\n * Target fields that will have the visibility toggled\n */\n fieldNames?: string[];\n}[];\n\nexport type TClearFieldValue = string | number | boolean;\n\nexport type TClearField = {\n /**\n * The clearValues runs validations on the target field and not on the field it is declaring.\n * Therefore, set this prop with true if you want validations to be performed on the current field.\n */\n useCurrentFieldValidation?: boolean;\n /**\n * Validations to run for the target field\n */\n validations?: TSchemaValidation;\n /**\n * target fields that will be used in the validation specified\n */\n fields: string[];\n /**\n * The cleared values on the fields in case they do not pass the validation\n */\n clearedValue: TClearFieldValue | TClearFieldValue[];\n /**\n * The cleared props from each component field on target fields array\n */\n clearedProps?: Record<string, unknown> | Record<string, unknown>[];\n};\n\nexport type TSchemaClearFields = TClearField[];\n\nexport type TSchemaApi = {\n /**\n * Specify a debounce time in miliseconds for your call\n */\n debounceTime?: number;\n method: 'GET' | 'POST' | 'PUT' | 'PATCH';\n url: string;\n headers?: HeadersInit | undefined;\n body?: Record<string, any>;\n fieldValueAsParams?: Record<string, string>;\n fieldValueAsPathParams?: string[];\n scope?: string;\n blockRequestWhenInvalid?: boolean;\n preConditions?: TSchemaValidation;\n}[];\n\nexport type TSchemaMasks = { cleanMask?: boolean } & TComponentMasks;\n\nexport type TFormEventDirectives = {\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TComponent = {\n /**\n * This name will be used later to correlate the field with the value, and you will be able to read it.\n *\n * You can also mount here complex objects like\n *\n * name={a.b.c}\n *\n * that will result in\n * a: {\n * b: {\n * c: 'field_value'\n * }\n * }\n */\n name: string;\n /**\n * A component name that should map to the one you gave in the form mappings\n *\n * @example - For React\n * ```\n * const mappings: TMapper = {\n * input: { component: Input },\n * formGroup: { component: FormGroup },\n * };\n * ```\n *\n * The component name for the Input element will be \"input\" ending up like\n * ```\n * {\n * component: 'input'\n * }\n * ```\n */\n component: string;\n /**\n * You can attach metadata to your component that will be forwarded to you after on your frontend\n * callback methods link `onData`, `onBlur` etc\n */\n metadata?: Record<string, any>;\n /**\n * This property allows you to specify a virtual fieldName that can be in several fields\n *\n * USAGE - You have two fields but you want to have the value stored only under one name\n *\n */\n group?: string;\n wrapper?: new () => React.Component;\n children?: TComponent[];\n /**\n * Field error messages in case any validation fails\n *\n * @example - Set a default error message for all the validations\n *\n * ```\n * {\n * errorMessages: {\n * default: 'default error message'\n * }\n * }\n * ```\n *\n * @example - Set error message for a given validation\n *\n * ```\n * {\n * validations: {\n * ON_FIELD_CHANGE: {\n * required: true\n * }\n * },\n * errorMessages: {\n * required: 'This field is required'\n * }\n * }\n * ```\n *\n */\n errorMessages?: TErrorMessages;\n type?: 'text' | 'number' | string;\n /**\n * Allow you to set a initial state for this field\n */\n state?: {\n /**\n * Hide the field\n */\n hidden?: boolean;\n /**\n * Ignore value from field\n */\n ignoreValue?: boolean;\n };\n /**\n * This key lets you inject props directly into the component\n */\n props?: Record<string, unknown>;\n /**\n * Setup validations to be used in the field.\n *\n * You can setup validations in several life-cycle methods\n *\n * @example - Required validation\n * ```\n * validations: {\n ON_FIELD_CHANGE: {\n required: true,\n },\n },\n * ```\n */\n validations?: TSchemaHandler<\n Pick<TEventReducedSchema, 'validations'>['validations']\n >;\n /**\n * Filters the component value based on a validation.\n */\n filter?: Pick<TEventReducedSchema, 'validations'>['validations'];\n /**\n * Allows you to specify the conditions a given field will be visible\n * what will run when this field meets the specified life-cycle\n */\n visibilityConditions?: Omit<\n TSchemaHandler<\n Pick<TEventReducedSchema, 'visibilityConditions'>['visibilityConditions']\n >,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_CLEARED' | 'ON_FIELD_FOCUS'\n >;\n /**\n * Will clear target fields in case they do not pass with the specified validations\n */\n clearFields?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'clearFields'>['clearFields']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_CLEARED' | 'ON_FIELD_FOCUS'\n >;\n /**\n * Allows you to make api calls using events emitted by the component.\n */\n api?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'api'>['api']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS' | 'AFTER_FIELD_API_CALL'\n >;\n /**\n * Allows you to display the value of the masked component by events\n */\n masks?: Partial<\n Record<\n | EEVents.ON_FIELD_BLUR\n | EEVents.ON_FIELD_MOUNT\n | EEVents.ON_FIELD_FOCUS\n | EEVents.ON_FIELD_CHANGE\n | EEVents.ON_FIELD_KEYUP\n | EEVents.ON_FIELD_KEYDOWN,\n Pick<TEventReducedSchema, 'masks'>['masks']\n >\n >;\n /**\n * Allows you to format the value that the field will receive for each event issuance\n */\n formatters?: Omit<\n TSchemaHandler<Pick<TEventReducedSchema, 'formatters'>['formatters']>,\n 'ON_FIELD_REHYDRATE' | 'ON_FIELD_FOCUS'\n >;\n};\n\nexport type TEventReducedSchema = {\n api: TSchemaApi;\n clearFields: TSchemaClearFields;\n formatters: TSchemaFormatters;\n masks: TSchemaMasks;\n validations: TSchemaValidation;\n visibilityConditions: TSchemaVisibilityConditions;\n};\n\nexport type TStep = {\n component: string;\n name: string;\n children: TComponent[];\n props?: Record<string, string>;\n};\n\nexport type TComponentPropsMapping = {\n getValue?: string;\n setValue?: string;\n onBlur?: string;\n onClick?: string;\n onFocus?: string;\n onKeyUp?: string;\n onKeyDown?: string;\n setErrorMessage?: string;\n setErrorState?: string;\n};\n\nexport type TPropsMapping = Record<string, TComponentPropsMapping>;\n\nexport type TSchema = {\n /**\n * Used to disable form submit input and prevent to submit form using enter event.\n * Default is false.\n */\n disableFormSubmit?: boolean;\n action?: string;\n method?: string;\n /**\n * Give some configurations to the form\n */\n configs?: TConfigs;\n /**\n * Allows you to expose some messages to the outside world when something happen\n */\n messages?: TFormMessages;\n /**\n * Specify some static field defaults before rendereing the form.\n *\n * If you have initialValues in the frontend setted, those will ovewride this\n */\n formattedDataDefaults?: Record<string, unknown>;\n /**\n * Form level props mapping\n */\n propsMapping?: TPropsMapping;\n visibilityConditions?: TFormLevelSchemaHandler<TSchemaVisibilityConditions>;\n /**\n * Entry point for the form should be a step (even if you have only one)\n */\n components: TStep[];\n /**\n * You can have many fields in the form, but be interested only in some\n *\n * You can put here the fields you want to read onSubmit for example\n *\n * You will receive those in TFormValues.filteredFields\n */\n filteredFields?: string[];\n /**\n * Schema level iVars.\n *\n * These iVars will go to the global scope namespace\n */\n iVars?: TIVars;\n};\n\nexport type TSplitterFormatterValue = {\n value: string;\n position: number;\n}[];\n\nexport type TSchemaFormatters = {\n splitter?: TSplitterFormatterValue;\n capitalize?: boolean;\n upperCase?: boolean;\n gapsCreditCard?: string[];\n onlyNumbers?: boolean;\n onlyLetters?: boolean;\n regex?: string;\n};\n\nexport type TConfigs = {\n observables?: { templates?: { exclude?: string[] } };\n};\n\nexport type TFlowType = {\n [x: string]: {\n events: (component?: TComponent) => EEVents[];\n handler: (args: TEventInformation<unknown>) => void;\n }[];\n};\n"],"names":["TAvailableHooks"],"mappings":"aAsHA,IAAYA,yDAAAA,QAKXA,qBAAA,GALWA,EAAAA,QAAeA,kBAAfA,wBAKX,CAAA,IAJC,SAAA,WACAA,EAAA,WAAA,aACAA,EAAA,UAAA,YACAA,EAAA,WAAA"}
|