@bolttech/form-engine 0.1.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 +1172 -0
- package/index.js +2 -0
- package/index.js.map +1 -0
- package/package.json +50 -0
- package/src/adapters/react/Field.d.ts +4 -0
- package/src/adapters/react/Form.d.ts +5 -0
- package/src/adapters/react/Submit.d.ts +3 -0
- package/src/adapters/react/asFormField.d.ts +14 -0
- package/src/adapters/react/context.d.ts +5 -0
- package/src/adapters/react/index.d.ts +6 -0
- package/src/adapters/react/types.d.ts +185 -0
- package/src/adapters/react/useForceUpdate.d.ts +3 -0
- package/src/adapters/react/useForm.d.ts +51 -0
- package/src/adapters/react/useFormGroup.d.ts +15 -0
- package/src/core/apis/formatters.d.ts +16 -0
- package/src/core/apis/index.d.ts +4 -0
- package/src/core/apis/masks.d.ts +3 -0
- package/src/core/apis/validations.d.ts +11 -0
- package/src/core/apis/varOps.d.ts +4 -0
- package/src/core/constants/events.d.ts +23 -0
- package/src/core/constants/index.d.ts +5 -0
- package/src/core/constants/observer.d.ts +7 -0
- package/src/core/events/ObserverError.d.ts +7 -0
- package/src/core/events/events.types.d.ts +27 -0
- package/src/core/events/index.d.ts +2 -0
- package/src/core/handlers/common/templating.d.ts +2 -0
- package/src/core/handlers/field/api.d.ts +4 -0
- package/src/core/handlers/field/blur.d.ts +2 -0
- package/src/core/handlers/field/change.d.ts +2 -0
- package/src/core/handlers/field/clearFields.d.ts +4 -0
- package/src/core/handlers/field/data.d.ts +3 -0
- package/src/core/handlers/field/filter.d.ts +2 -0
- package/src/core/handlers/field/focus.d.ts +2 -0
- package/src/core/handlers/field/formatters.d.ts +4 -0
- package/src/core/handlers/field/htmlEventParser.d.ts +6 -0
- package/src/core/handlers/field/masks.d.ts +4 -0
- package/src/core/handlers/field/mount.d.ts +2 -0
- package/src/core/handlers/field/validations.d.ts +4 -0
- package/src/core/handlers/field/visibilityConditions.d.ts +4 -0
- package/src/core/handlers/flows.d.ts +36 -0
- package/src/core/handlers/form/hooks.d.ts +3 -0
- package/src/core/handlers/form/steps.d.ts +2 -0
- package/src/core/handlers/form/templating.d.ts +2 -0
- package/src/core/handlers/form/validate.d.ts +2 -0
- package/src/core/handlers/form/visibilityConditions.d.ts +4 -0
- package/src/core/index.d.ts +3 -0
- package/src/core/managers/Base.d.ts +19 -0
- package/src/core/managers/Factory.d.ts +52 -0
- package/src/core/managers/Field.d.ts +31 -0
- package/src/core/managers/Form.d.ts +32 -0
- package/src/core/managers/Scope.d.ts +12 -0
- package/src/core/managers/index.d.ts +1 -0
- package/src/core/types/index.d.ts +621 -0
- package/src/core/utils/credit-card.d.ts +16 -0
- package/src/core/utils/index.d.ts +4 -0
- package/src/core/utils/object.d.ts +24 -0
- package/src/core/utils/string.d.ts +3 -0
- package/src/index.d.ts +3 -0
- package/types.js +2 -0
- package/types.js.map +1 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { TComponent, TErrorMessages, TSchemaValidation, TSchemaValidations, TSchema, THooks, TIVars, TFormValues, TField, TChildrenOptions, TPropsMapping, TComponentPropsMapping, TScope } from '@core/types';
|
|
3
|
+
import { TLoggingEvent } from '@core/events/events.types';
|
|
4
|
+
declare type TFormProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Allow to set the form as read only mode.
|
|
7
|
+
*
|
|
8
|
+
* This will prevent any interaction with the form whatsoever
|
|
9
|
+
*/
|
|
10
|
+
disable?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Allow to specify a logical group across several forms so that we can get data with useFormGroup
|
|
13
|
+
*/
|
|
14
|
+
group?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Hooks to run on some life-cycles
|
|
17
|
+
*/
|
|
18
|
+
hooks?: THooks;
|
|
19
|
+
/**
|
|
20
|
+
* Form id. Will default to a internal one in case not given
|
|
21
|
+
*/
|
|
22
|
+
id?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Internal variables. This object will be used in the global scope
|
|
25
|
+
* namespace
|
|
26
|
+
*/
|
|
27
|
+
iVars?: TIVars;
|
|
28
|
+
/**
|
|
29
|
+
* Form initial values. This must map into form known fields
|
|
30
|
+
*/
|
|
31
|
+
initialValues?: Record<string, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Form schema that should contain form definition
|
|
34
|
+
*/
|
|
35
|
+
schema?: TSchema;
|
|
36
|
+
/**
|
|
37
|
+
* HTML autocomplete form prop
|
|
38
|
+
*/
|
|
39
|
+
autoComplete?: string;
|
|
40
|
+
/**
|
|
41
|
+
* ClassName in case you want to style form
|
|
42
|
+
*/
|
|
43
|
+
className?: string;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* Callback function that will run on each submit.
|
|
47
|
+
*
|
|
48
|
+
* NOTE: By default this function only runs if the form has no errors. If you
|
|
49
|
+
* want different behaviour, use submitOnValidOnly and set to false
|
|
50
|
+
*
|
|
51
|
+
* @param form - HTML original event
|
|
52
|
+
* @param values - Form generated value. Refer to its type
|
|
53
|
+
*/
|
|
54
|
+
onSubmit?(form: React.FormEvent<HTMLFormElement>, values: TFormValues): Promise<Record<string, unknown> | void> | Record<string, unknown> | void;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* Callback function that runs on each data change.
|
|
58
|
+
*
|
|
59
|
+
* You can who changed the data accessing to the arguments
|
|
60
|
+
*
|
|
61
|
+
* @param values - Form generated values
|
|
62
|
+
* @param component - The component configuration of the field that changed
|
|
63
|
+
* @param field - The current state of the changing field
|
|
64
|
+
*/
|
|
65
|
+
onData?(values: TFormValues, component?: TComponent, field?: TField): void;
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* Callback function that runs on each blur.
|
|
69
|
+
*
|
|
70
|
+
* You can what field was blurred accessing to the arguments
|
|
71
|
+
*
|
|
72
|
+
* @param values - Form generated values
|
|
73
|
+
* @param component - The component configuration of the field that was blurred
|
|
74
|
+
* @param field - The current state of the blurred field
|
|
75
|
+
*/
|
|
76
|
+
onBlur?(values: TFormValues, component?: TComponent, field?: TField): void;
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* Callback function that runs on each focus.
|
|
80
|
+
*
|
|
81
|
+
* You can what field was focused accessing to the arguments
|
|
82
|
+
*
|
|
83
|
+
* @param values - Form generated values
|
|
84
|
+
* @param component - The component configuration of the field that was focused
|
|
85
|
+
* @param field - The current state of the focused field
|
|
86
|
+
*/
|
|
87
|
+
onFocus?(values: TFormValues, component?: TComponent, field?: TField): void;
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* Callback that tells you when a given field was mounted
|
|
91
|
+
*
|
|
92
|
+
* @param values - Form generated values
|
|
93
|
+
* @param component - The component configuration of the field that was mounted
|
|
94
|
+
* @param field - The current state of the mounted field
|
|
95
|
+
*/
|
|
96
|
+
onFieldMount?(values: TFormValues, component?: TComponent, field?: TField): void;
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* This callback will be fired in each step change
|
|
100
|
+
*
|
|
101
|
+
* @param values - Form generated values
|
|
102
|
+
*/
|
|
103
|
+
onStep?(values: TFormValues): void;
|
|
104
|
+
/**
|
|
105
|
+
* Enables you to see what is happening under the hood. Subscribing the callback will enable logging
|
|
106
|
+
*
|
|
107
|
+
* @param log - Logging event
|
|
108
|
+
*/
|
|
109
|
+
onLog?(log: TLoggingEvent): void;
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* Notifies you about each form scope change and about who changed it
|
|
113
|
+
*
|
|
114
|
+
* @param scope - Form current scope with the update
|
|
115
|
+
* @param namespace - The namespace that was updated
|
|
116
|
+
* @param key - The key responsible for the update
|
|
117
|
+
*/
|
|
118
|
+
onScopeChange?(scope: TScope, namespace: string, key: string): void;
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* When a given field is rehydrated, this callback will be called
|
|
122
|
+
*
|
|
123
|
+
* @param values - Form generated values
|
|
124
|
+
* @param component - The component configuration of the field that was mounted
|
|
125
|
+
* @param field - The current state of the mounted field
|
|
126
|
+
*/
|
|
127
|
+
onFieldRehydrate?(values: TFormValues, component: TComponent, field: TField): void;
|
|
128
|
+
/**
|
|
129
|
+
* Allows you to pass a JSX so that the form shows it before rendering your schema
|
|
130
|
+
*
|
|
131
|
+
* @returns JSX
|
|
132
|
+
*/
|
|
133
|
+
renderLoading?(): ReactElement;
|
|
134
|
+
/**
|
|
135
|
+
* Called when the form was mounted
|
|
136
|
+
*
|
|
137
|
+
* @param values - Form generated values
|
|
138
|
+
*/
|
|
139
|
+
onFormMount?(values: TFormValues): void;
|
|
140
|
+
children?: ReactElement | ReactElement[];
|
|
141
|
+
/**
|
|
142
|
+
* Object to be used if you want to control the default values of the form.
|
|
143
|
+
*
|
|
144
|
+
* InitialValues will take precedence over this
|
|
145
|
+
*/
|
|
146
|
+
formattedDataDefaults?: Record<string, unknown>;
|
|
147
|
+
/**
|
|
148
|
+
* Override the default form behaviour witch is to prevent submit when there is an error
|
|
149
|
+
*/
|
|
150
|
+
submitOnValidOnly?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Allows to insert a wrapper for each field or replace the field rendering
|
|
153
|
+
*/
|
|
154
|
+
renderFieldWrapper?(component: TComponent, children: ReactElement[]): ReactElement;
|
|
155
|
+
};
|
|
156
|
+
declare type TMapper = Record<string, Record<string, unknown>>;
|
|
157
|
+
declare type TProvider = {
|
|
158
|
+
children?: ReactElement | ReactElement[] | string;
|
|
159
|
+
mapper: TMapper;
|
|
160
|
+
propsMapping: TPropsMapping;
|
|
161
|
+
};
|
|
162
|
+
declare type TContext = {
|
|
163
|
+
mapper: TMapper;
|
|
164
|
+
propsMapping: TPropsMapping;
|
|
165
|
+
};
|
|
166
|
+
declare type TChildWrapperProps = {
|
|
167
|
+
children: ReactElement | ReactElement[];
|
|
168
|
+
component: TComponent;
|
|
169
|
+
wrapper: new () => React.Component;
|
|
170
|
+
propsMapping: TComponentPropsMapping;
|
|
171
|
+
formId?: string;
|
|
172
|
+
onMount(values: TField): void;
|
|
173
|
+
onChange(values: TField): void;
|
|
174
|
+
onRehydrate(values: TField): void;
|
|
175
|
+
onFocus(values: TField): void;
|
|
176
|
+
onBlur(values: TField): void;
|
|
177
|
+
};
|
|
178
|
+
declare type TFormRefActions = {
|
|
179
|
+
submit(): void;
|
|
180
|
+
stepForward(): TFormValues;
|
|
181
|
+
stepBack(): TFormValues;
|
|
182
|
+
validateForm(opts?: TChildrenOptions): TFormValues;
|
|
183
|
+
values(opts: Pick<TChildrenOptions, 'scopeBlurredChildren' | 'scopeChangedChildren' | 'childrenScope'>): TFormValues;
|
|
184
|
+
};
|
|
185
|
+
export type { TComponent, TMapper, TChildrenOptions, TFormValues, TFormRefActions, TChildWrapperProps, TContext, TFormProps, TProvider, TErrorMessages, TSchemaValidation, TSchemaValidations, };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TChildrenOptions, TFormValues } from '@react/types';
|
|
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
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* This hooks lets you connect to your form/s in anywherer in your application. Even if you are outside the <FormProvider />
|
|
43
|
+
*
|
|
44
|
+
* You can connect to:
|
|
45
|
+
* - A specific form
|
|
46
|
+
* - Several forms identified by their id's
|
|
47
|
+
* - A group of forms
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
declare const useForm: ({ onValid, onData, onSubmit, id, ids, }: TProps) => THookReturn;
|
|
51
|
+
export default useForm;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TChildrenOptions, TFormValues } from '@react/types';
|
|
2
|
+
declare type TProps = {
|
|
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;
|
|
15
|
+
export { useFormGroup };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* This file will allow to expose functions to be used as formatters in schema and HOC
|
|
4
|
+
*
|
|
5
|
+
* Since it is a formatter, you can also expose its "undo" function that will allow form to make logic on the value without the
|
|
6
|
+
* formatter applied
|
|
7
|
+
*
|
|
8
|
+
* EG:
|
|
9
|
+
* splitter -> 22/33/4444
|
|
10
|
+
* undo_splitter -> 22334444
|
|
11
|
+
*
|
|
12
|
+
* This undo will be called when the form is filtering the data on the input if it has formatters configured
|
|
13
|
+
*/
|
|
14
|
+
import { TSchemaFormatters } from '@core/types';
|
|
15
|
+
declare const run: (value: any, componentFormatters: TSchemaFormatters, undo?: boolean) => string | number;
|
|
16
|
+
export { run };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TErrorMessages, TErrors, TFieldData, TVAvailableValidations } from '@core/types';
|
|
2
|
+
declare type TRuleValue = string | number | boolean | undefined;
|
|
3
|
+
export interface ICustomValidationValue {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
validations: Record<string, any>;
|
|
7
|
+
}
|
|
8
|
+
declare const run: (value: TRuleValue, rules: TVAvailableValidations, errorMessages?: TErrorMessages, formData?: TFieldData) => TErrors;
|
|
9
|
+
declare const generateCustomError: (name: string, message: string) => TErrors;
|
|
10
|
+
declare const hasError: (errors?: TErrors) => boolean;
|
|
11
|
+
export { run, generateCustomError, hasError };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const concatenate: (a: any, b: any) => any;
|
|
2
|
+
export declare const add: (a: any, b: any) => string;
|
|
3
|
+
export declare const subtract: (a: any, b: any) => number;
|
|
4
|
+
export declare const replaceAll: (value: string, searchValue: string, replaceValue: string) => string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TEventsKeys } from '@core/types';
|
|
2
|
+
export declare const enum EEVents {
|
|
3
|
+
ON_FIELD_VALIDATION_TOGGLE = "ON_FIELD_VALIDATION_TOGGLE",
|
|
4
|
+
ON_FIELD_MOUNT = "ON_FIELD_MOUNT",
|
|
5
|
+
ON_FIELD_CHANGE = "ON_FIELD_CHANGE",
|
|
6
|
+
ON_FIELD_BLUR = "ON_FIELD_BLUR",
|
|
7
|
+
ON_FIELD_FOCUS = "ON_FIELD_FOCUS",
|
|
8
|
+
ON_FIELD_REHYDRATE = "ON_FIELD_REHYDRATE",
|
|
9
|
+
RUN_FIELD_VALIDATIONS = "RUN_FIELD_VALIDATIONS",
|
|
10
|
+
RUN_FIELD_MASKS = "RUN_FIELD_MASKS",
|
|
11
|
+
RUN_FIELD_FORMATTERS = "RUN_FIELD_FORMATTERS",
|
|
12
|
+
ON_SCOPE_CHANGE = "ON_SCOPE_CHANGE",
|
|
13
|
+
ON_FORM_REHYDRATE = "ON_FORM_REHYDRATE",
|
|
14
|
+
ON_FORM_SUBMIT = "ON_FORM_SUBMIT",
|
|
15
|
+
ON_FORM_MOUNT = "ON_FORM_MOUNT",
|
|
16
|
+
ON_FORM_UN_MOUNT = "ON_FORM_UN_MOUNT",
|
|
17
|
+
ON_FORM_DATA = "ON_FORM_DATA",
|
|
18
|
+
NAVIGATE_STEP_FORWARD = "NAVIGATE_STEP_FORWARD",
|
|
19
|
+
NAVIGATE_STEP_BACK = "NAVIGATE_STEP_BACK",
|
|
20
|
+
VALIDATE_FORM = "VALIDATE_FORM",
|
|
21
|
+
LOG = "LOG"
|
|
22
|
+
}
|
|
23
|
+
export declare const CoreEvents: Record<TEventsKeys, TEventsKeys>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const DEFAULT_FORM_ID = "default_form_id";
|
|
2
|
+
declare const DEFAULT_FORM_HOOK_ID = "default_form_hook_id";
|
|
3
|
+
export { ALL_NAMESPACE_EVENTS, BUILD_EVENT, EXTRACT_EVENT_NAMESPACE, EXTRACT_CORE_NAMESPACE, } from '@core/constants/observer';
|
|
4
|
+
export { CoreEvents, EEVents } from '@core/constants/events';
|
|
5
|
+
export { DEFAULT_FORM_ID, DEFAULT_FORM_HOOK_ID };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TEventsKeys } from '@core';
|
|
2
|
+
import { EEVents } from '@core/constants';
|
|
3
|
+
declare const EXTRACT_EVENT_NAMESPACE: (event: TEventsKeys) => EEVents;
|
|
4
|
+
declare const BUILD_EVENT: (event: EEVents, namespace?: string, key?: string) => EEVents;
|
|
5
|
+
declare const ALL_NAMESPACE_EVENTS: (event: TEventsKeys) => EEVents;
|
|
6
|
+
declare const EXTRACT_CORE_NAMESPACE: (event: TEventsKeys) => EEVents;
|
|
7
|
+
export { ALL_NAMESPACE_EVENTS, BUILD_EVENT, EXTRACT_EVENT_NAMESPACE, EXTRACT_CORE_NAMESPACE, };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Field from '@core/managers/Field';
|
|
2
|
+
import { Form } from '@core/managers/Form';
|
|
3
|
+
import { TEventReducedSchema, TEventsKeys, TFormEventDirectives, TObserverData } from '@core/types';
|
|
4
|
+
export declare type TEventPublishPayload = {
|
|
5
|
+
checksum?: string;
|
|
6
|
+
} & {
|
|
7
|
+
[key in string]?: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare type TEventInformation = TObserverData & {
|
|
10
|
+
eventReducedSchema: TEventReducedSchema;
|
|
11
|
+
formEventDirectives: TFormEventDirectives;
|
|
12
|
+
form: Form;
|
|
13
|
+
field: Field;
|
|
14
|
+
coreEvent: TEventsKeys;
|
|
15
|
+
};
|
|
16
|
+
export declare enum EFlowLogging {
|
|
17
|
+
OBSERVER = "OBSERVER",
|
|
18
|
+
REACT_FIELD_ADAPTER = "REACT FIELD ADAPTER",
|
|
19
|
+
FIELD_HANDLER = "FIELD HANDLER"
|
|
20
|
+
}
|
|
21
|
+
export declare type TLoggingEvent = {
|
|
22
|
+
level: 'error' | 'info';
|
|
23
|
+
data?: any;
|
|
24
|
+
flow: EFlowLogging;
|
|
25
|
+
action: string;
|
|
26
|
+
error?: any;
|
|
27
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TComponent } from '@core';
|
|
2
|
+
import * as Events from '@core/events';
|
|
3
|
+
export declare const handler: ({ field, form, eventReducedSchema: { api }, }: Pick<Events.TEventInformation, 'form' | 'field' | 'eventReducedSchema'>) => void;
|
|
4
|
+
export declare const events: (component: TComponent) => string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as Events from '@core/events';
|
|
2
|
+
import { TComponent } from '@core';
|
|
3
|
+
export declare const handler: ({ form, eventReducedSchema, }: Pick<Events.TEventInformation, 'form' | 'eventReducedSchema' | 'field'>) => void;
|
|
4
|
+
export declare const events: (component: TComponent) => string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as Events from '@core/events';
|
|
2
|
+
import { TComponent } from '@core';
|
|
3
|
+
export declare const handler: ({ form, field, eventReducedSchema, }: Pick<Events.TEventInformation, 'form' | 'field' | 'eventReducedSchema'>) => void;
|
|
4
|
+
export declare const events: (component: TComponent) => string[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TSchema } from '@core';
|
|
2
|
+
import * as Events from '@core/events';
|
|
3
|
+
import * as change from '@core/handlers/field/change';
|
|
4
|
+
import * as mount from '@core/handlers/field/mount';
|
|
5
|
+
import * as blur from '@core/handlers/field/blur';
|
|
6
|
+
import * as focus from '@core/handlers/field/focus';
|
|
7
|
+
import * as templating from './common/templating';
|
|
8
|
+
import * as api from '@core/handlers/field/api';
|
|
9
|
+
import * as data from '@core/handlers/field/data';
|
|
10
|
+
import * as validations from '@core/handlers/field/validations';
|
|
11
|
+
import * as hooks from '@core/handlers/form/hooks';
|
|
12
|
+
import * as steps from '@core/handlers/form/steps';
|
|
13
|
+
import * as validate from '@core/handlers/form/validate';
|
|
14
|
+
import * as formLevelVisibilityConditions from '@core/handlers/form/visibilityConditions';
|
|
15
|
+
import * as formTemplating from '@core/handlers/form/templating';
|
|
16
|
+
declare const register: (observer: Events.Observer, flows: any, component?: any | TSchema) => void;
|
|
17
|
+
declare const fieldFlows: () => {
|
|
18
|
+
ON_FIELD_MOUNT: (typeof mount)[];
|
|
19
|
+
ON_FIELD_CHANGE: (typeof change | typeof api | typeof data)[];
|
|
20
|
+
ON_FIELD_REHYDRATE: (typeof validations)[];
|
|
21
|
+
ON_FIELD_BLUR: (typeof blur | typeof data)[];
|
|
22
|
+
ON_FIELD_FOCUS: (typeof focus)[];
|
|
23
|
+
};
|
|
24
|
+
declare const formFlows: () => {
|
|
25
|
+
[x: string]: (typeof formTemplating)[];
|
|
26
|
+
ON_SCOPE_CHANGE: (typeof formTemplating)[];
|
|
27
|
+
ON_FORM_MOUNT: (typeof templating | typeof steps | typeof validate | typeof formLevelVisibilityConditions)[];
|
|
28
|
+
VALIDATE_FORM: (typeof validate)[];
|
|
29
|
+
ON_FORM_SUBMIT: (typeof hooks)[];
|
|
30
|
+
ON_FORM_UN_MOUNT: (typeof hooks)[];
|
|
31
|
+
NAVIGATE_STEP_BACK: (typeof steps)[];
|
|
32
|
+
NAVIGATE_STEP_FORWARD: (typeof steps)[];
|
|
33
|
+
ON_FORM_REHYDRATE: (typeof formLevelVisibilityConditions)[];
|
|
34
|
+
ON_FIELD_CHANGE: (typeof formLevelVisibilityConditions)[];
|
|
35
|
+
};
|
|
36
|
+
export { register, fieldFlows, formFlows };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TSchema } from '@core';
|
|
2
|
+
import { TEventInformation } from '@core/events';
|
|
3
|
+
export declare const handler: ({ form, formEventDirectives, }: Pick<TEventInformation, 'form' | 'formEventDirectives'>) => void;
|
|
4
|
+
export declare const events: (schema: TSchema) => string[];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { TFormRefActions, TFormValues, TSchema, TComponent, TField, TEventsKeys, TObserverData, } from '@core/types';
|
|
2
|
+
export { TAvailableHooks } from '@core/types';
|
|
3
|
+
export { ALL_NAMESPACE_EVENTS, BUILD_EVENT, EXTRACT_EVENT_NAMESPACE, CoreEvents, } from '@core/constants';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Observer } from '@core/events';
|
|
2
|
+
import { EFlowLogging, TEventPublishPayload } from '@core/events/events.types';
|
|
3
|
+
import { TEventsKeys } from '@core';
|
|
4
|
+
declare class Base {
|
|
5
|
+
#private;
|
|
6
|
+
subscriptions: {
|
|
7
|
+
[x in TEventsKeys]?: () => void;
|
|
8
|
+
};
|
|
9
|
+
debounceTime: number;
|
|
10
|
+
constructor(observer: Observer);
|
|
11
|
+
subscribe(event: TEventsKeys, cb: (...data: any) => void): void;
|
|
12
|
+
subscribeBulk(events: TEventsKeys[], cb: (...data: any) => void): void;
|
|
13
|
+
publish(events: TEventsKeys, data?: TEventPublishPayload): void;
|
|
14
|
+
publishFor(events: TEventsKeys): any;
|
|
15
|
+
debounce: (fn: any, debounceTime?: number) => Promise<unknown>;
|
|
16
|
+
logError(file: EFlowLogging, event: string, method: string, error: unknown): void;
|
|
17
|
+
logInfo(file: EFlowLogging, event: string, method: string, extraData?: unknown): void;
|
|
18
|
+
}
|
|
19
|
+
export default Base;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import Form from '@core/managers/Form';
|
|
2
|
+
import { IObservable, TEvents, TEventsKeys, TObservable, TSchema, TScope } from '@core/types';
|
|
3
|
+
import { EEVents } from '@core/constants';
|
|
4
|
+
import { TEventPublishPayload, TLoggingEvent } from '@core/events/events.types';
|
|
5
|
+
declare class Observer implements IObservable {
|
|
6
|
+
#private;
|
|
7
|
+
regexBasedEvents: Record<string, {
|
|
8
|
+
regex: RegExp;
|
|
9
|
+
handlers: TObservable[];
|
|
10
|
+
}>;
|
|
11
|
+
events: TEvents;
|
|
12
|
+
history: {
|
|
13
|
+
[key in EEVents]?: string;
|
|
14
|
+
};
|
|
15
|
+
namespace: string;
|
|
16
|
+
enableLogging: boolean;
|
|
17
|
+
constructor(namespace: string, enableLogging?: boolean);
|
|
18
|
+
runForRegexBasedEvent(eventName: any, cb: (event: TEventsKeys) => void): boolean;
|
|
19
|
+
handleRegexSubscription(eventName: any, handler: TObservable): void;
|
|
20
|
+
/**
|
|
21
|
+
* This function lets you subscribe to a given event and register one callback to be called when someone published in it
|
|
22
|
+
*
|
|
23
|
+
* The callback you redister will, return you the published data and one function to unregister your callback from that event
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
subscribe(eventName: TEventsKeys, handler: TObservable): () => void;
|
|
27
|
+
unsubscribe(eventName: TEventsKeys, handler: TObservable): void;
|
|
28
|
+
isAsyncFunction(fn: (...data: any) => any): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Allows to publish data to a given event name
|
|
31
|
+
*
|
|
32
|
+
* Will iterate the subscriptions and call their handlers.
|
|
33
|
+
*
|
|
34
|
+
* When calling the handler, will also inject the unsubscribe function
|
|
35
|
+
*
|
|
36
|
+
* This methods also accepts one regex and will find the matchin events and
|
|
37
|
+
* publish in them
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
publish(eventName: TEventsKeys, data?: TEventPublishPayload): Promise<{}>;
|
|
41
|
+
publishForEvents(eventName: TEventsKeys, data: {}, events: TEvents): Promise<{}>;
|
|
42
|
+
logError(flow: Pick<TLoggingEvent, 'flow'>['flow'], event: string, method: string, error: unknown): void;
|
|
43
|
+
logInfo(flow: Pick<TLoggingEvent, 'flow'>['flow'], event: string, method: string, extraData?: any): void;
|
|
44
|
+
}
|
|
45
|
+
export declare const getFormInstance: (namespace?: string, opts?: {
|
|
46
|
+
schema?: TSchema;
|
|
47
|
+
initialScope?: TScope;
|
|
48
|
+
initialValues?: Record<string, any>;
|
|
49
|
+
newInstance?: boolean;
|
|
50
|
+
group?: string;
|
|
51
|
+
}) => Form, getGroupFormsIds: (group: string) => string[];
|
|
52
|
+
export { Observer };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as Events from '@core/events';
|
|
2
|
+
import { TField, TComponent, TErrors, TComponentPropsMapping, TEventReducedSchema, TEventsKeys } from '@core/types';
|
|
3
|
+
import Scope from '@core/managers/Scope';
|
|
4
|
+
import Base from '@core/managers/Base';
|
|
5
|
+
declare class Field extends Base {
|
|
6
|
+
#private;
|
|
7
|
+
scope: Scope;
|
|
8
|
+
constructor(observer: Events.Observer, component: TComponent, propsMapping: TComponentPropsMapping, scope: Scope);
|
|
9
|
+
get value(): any;
|
|
10
|
+
set value(value: any);
|
|
11
|
+
get component(): TComponent;
|
|
12
|
+
get data(): TField;
|
|
13
|
+
set data(data: TField);
|
|
14
|
+
set visibility(visible: boolean);
|
|
15
|
+
get scopedComponent(): TComponent;
|
|
16
|
+
set scopedComponent(component: TComponent);
|
|
17
|
+
get errors(): TErrors;
|
|
18
|
+
set errors(errors: TErrors);
|
|
19
|
+
get props(): Record<string, unknown>;
|
|
20
|
+
get mappings(): TComponentPropsMapping;
|
|
21
|
+
getFieldErrorMessages(data?: TField): string[];
|
|
22
|
+
fieldHasError(errors?: TErrors): boolean;
|
|
23
|
+
fieldValidationsHaveError(setErrorMessages?: boolean): boolean;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
Calculates and returns the version of the current scoped object for a given event
|
|
27
|
+
*/
|
|
28
|
+
eventReducedSchema(event: TEventsKeys): TEventReducedSchema;
|
|
29
|
+
rehydrate(): void;
|
|
30
|
+
}
|
|
31
|
+
export default Field;
|