@bolttech/form-engine-core 1.0.2-beta.2 → 1.0.3

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.
Files changed (46) hide show
  1. package/index.d.ts +2327 -0
  2. package/index.esm.js +154 -82
  3. package/package.json +9 -10
  4. package/index.esm.d.ts +0 -1
  5. package/src/constants/constants.d.ts +0 -10
  6. package/src/formatters/creditCard.d.ts +0 -23
  7. package/src/formatters/custom.d.ts +0 -29
  8. package/src/formatters/handler.d.ts +0 -2
  9. package/src/formatters/regex.d.ts +0 -47
  10. package/src/formatters/splitter.d.ts +0 -17
  11. package/src/formatters/string.d.ts +0 -88
  12. package/src/helpers/SafeSubject.d.ts +0 -11
  13. package/src/helpers/creditCard.d.ts +0 -95
  14. package/src/helpers/helpers.d.ts +0 -67
  15. package/src/helpers/validation.d.ts +0 -27
  16. package/src/index.d.ts +0 -10
  17. package/src/interfaces/schema.d.ts +0 -112
  18. package/src/interfaces/state.d.ts +0 -22
  19. package/src/managers/field.d.ts +0 -326
  20. package/src/managers/form.d.ts +0 -346
  21. package/src/managers/formGroup.d.ts +0 -110
  22. package/src/managers/index.d.ts +0 -3
  23. package/src/masks/creditCard.d.ts +0 -60
  24. package/src/masks/generic.d.ts +0 -39
  25. package/src/masks/handler.d.ts +0 -2
  26. package/src/masks/string.d.ts +0 -99
  27. package/src/types/event.d.ts +0 -109
  28. package/src/types/form.d.ts +0 -55
  29. package/src/types/mapper.d.ts +0 -95
  30. package/src/types/schema.d.ts +0 -835
  31. package/src/types/template.d.ts +0 -50
  32. package/src/types/utility.d.ts +0 -6
  33. package/src/validations/creditCard.d.ts +0 -52
  34. package/src/validations/custom.d.ts +0 -25
  35. package/src/validations/date.d.ts +0 -79
  36. package/src/validations/document.d.ts +0 -25
  37. package/src/validations/handler.d.ts +0 -2
  38. package/src/validations/length.d.ts +0 -39
  39. package/src/validations/list.d.ts +0 -32
  40. package/src/validations/logical.d.ts +0 -75
  41. package/src/validations/multiple.d.ts +0 -31
  42. package/src/validations/namedRule.d.ts +0 -22
  43. package/src/validations/number.d.ts +0 -145
  44. package/src/validations/object.d.ts +0 -44
  45. package/src/validations/regex.d.ts +0 -217
  46. package/src/validations/string.d.ts +0 -53
@@ -1,326 +0,0 @@
1
- import { Subject, Subscription } from 'rxjs';
2
- import { TApiConfig, TApiEvent, TApiResponse, TErrorMessages, TFormatters, TMasks, TResetPathMethods, TResetValueMethods, TSchemaFormConfig, TValidations, TVisibility } from '../types/schema';
3
- import { IComponentSchema, IComponentSchemaAsFormField } from '../interfaces/schema';
4
- import { IState } from '../interfaces/state';
5
- import { TEvents, TFieldEvent, TFieldValidationPayload, TFormDataPayload, TValueChangeEvent } from '../types/event';
6
- import { TMapper } from '../types/mapper';
7
- import { SafeSubject } from '../helpers/SafeSubject';
8
- import { TTemplateEvent } from '../types/template';
9
- import { TFormValues } from '../types/form';
10
- /**
11
- * Represents a form field with observables for managing form state, validations, and API requests.
12
- */
13
- declare class FormField {
14
- formIndex: string;
15
- name: string;
16
- nameToSubmit?: string;
17
- component: string;
18
- path?: string;
19
- children?: string[];
20
- originalSchema: IComponentSchemaAsFormField<unknown>;
21
- validations?: TValidations;
22
- visibilityConditions?: TVisibility[];
23
- resetValues?: TResetValueMethods[];
24
- resetPropertyValues?: TResetPathMethods[];
25
- apiSchema?: TApiEvent;
26
- formatters?: TFormatters;
27
- masks?: TMasks;
28
- valuePropName?: string;
29
- config: Required<TSchemaFormConfig>;
30
- mapper: TMapper<unknown>;
31
- errorsString: string;
32
- errorsList: string[];
33
- private _props;
34
- private _value;
35
- private _stateValue;
36
- private _metadata;
37
- private _visibility;
38
- private _errors;
39
- private _api;
40
- private _valid;
41
- private _mounted;
42
- propsSubject$: SafeSubject<Record<string, unknown>>;
43
- errorSubject$: SafeSubject<Record<string, unknown>>;
44
- valueSubject$: SafeSubject<Record<string, unknown>>;
45
- valueSubscription$: Subscription;
46
- visibilitySubject$: SafeSubject<boolean>;
47
- fieldEventSubject$: Subject<TFieldEvent>;
48
- apiEventQueueSubject$: SafeSubject<{
49
- event: TEvents;
50
- }>;
51
- fieldStateSubscription$: Subscription;
52
- templateSubject$: Subject<TTemplateEvent>;
53
- dataSubject$: Subject<TFormDataPayload>;
54
- fieldValidNotification$: Subject<TFieldValidationPayload>;
55
- mountSubject$: Subject<{
56
- key: string;
57
- status: boolean;
58
- }>;
59
- validateVisibility: (payload: {
60
- event: TEvents;
61
- key: string;
62
- }) => void;
63
- resetValue: (payload: {
64
- event: TEvents;
65
- key: string;
66
- }) => void;
67
- resetProperty: (payload: {
68
- event: TEvents;
69
- key: string;
70
- }) => void;
71
- getFormValues: () => TFormValues<unknown>;
72
- valueChangeEvent: TValueChangeEvent;
73
- submitEvent: () => void;
74
- persistValue?: boolean;
75
- /**
76
- * Creates an instance of FormField.
77
- *
78
- * @param {object} options - Configuration options for the form field.
79
- * @param {IComponentSchema} options.schemaComponent - The schema definition for the form field.
80
- * @param {TSchemaFormConfig} options.config - The schema default configuration for debounced actions.
81
- * @param {string} [options.path] - The path within the form field (used internally during recursion).
82
- * @param {string[]} options.children - An array of children fields names.
83
- * @param {Function} options.validateVisibility - A function to validate the visibility of the field.
84
- * @param {Function} options.resetValue - A function to reset the field value.
85
- * @param {Function} options.resetProperty - A function to reset a field property.
86
- * @param {Subject<{ key: string }>} options.templateSubject$ - A subject for template updates.
87
- * @param {Subject<TFieldEvent>} options.fieldEventSubject$, - Subject for basic event mapped field emissions, except onData to form instance
88
- * @param {Subject<{ key: string; event: TEvents }>} options.dataSubject$, - Subject to emit onData events to form instance
89
- * @param {Subject<{ key: string }>} options.formValidNotification$, - Subject to emit field valid change to form instance
90
- * @param {TMapper<unknown>} options.mapper, - component generic mapper containing render parameters for adapters
91
- * @param {() => TFormValues<unknown>} options.getFormValues, - form instance function that builds onData parameter payload from fields
92
- */
93
- constructor({ formIndex, schemaComponent, config, path, children, validateVisibility, resetValue, resetProperty, templateSubject$, fieldEventSubject$, dataSubject$, fieldValidNotification$, mountSubject$, mapper, getFormValues, submitEvent, visibility, persistValue, }: {
94
- formIndex: string;
95
- schemaComponent: IComponentSchema;
96
- config?: TSchemaFormConfig;
97
- path?: string;
98
- children?: string[];
99
- validateVisibility: (payload: {
100
- event: TEvents;
101
- key: string;
102
- }) => void;
103
- resetValue: (payload: {
104
- event: TEvents;
105
- key: string;
106
- }) => void;
107
- resetProperty: (payload: {
108
- event: TEvents;
109
- key: string;
110
- }) => void;
111
- submitEvent: () => void;
112
- templateSubject$: Subject<TTemplateEvent>;
113
- fieldEventSubject$: Subject<TFieldEvent>;
114
- dataSubject$: Subject<TFormDataPayload>;
115
- fieldValidNotification$: Subject<TFieldValidationPayload>;
116
- mountSubject$: Subject<{
117
- key: string;
118
- status: boolean;
119
- }>;
120
- mapper: TMapper<unknown>;
121
- getFormValues: () => TFormValues<unknown>;
122
- visibility?: boolean;
123
- persistValue?: boolean;
124
- });
125
- /**
126
- * method to initialize all recycled Subjects and initialize Observers on field instance creation or rerender
127
- * due to some visibility conditions unmounts the field from the adapter if they are children of it and avoid
128
- * emissions to unsubscribed fields
129
- */
130
- initializeObservers(): void;
131
- /**
132
- * Retrieves the properties associated with the form field.
133
- *
134
- * @returns {Record<string, unknown>} - The properties of the form field.
135
- */
136
- get props(): Record<string, unknown>;
137
- /**
138
- * Sets the properties of the form field and notifies subscribers about the change.
139
- *
140
- * @param {Record<string, unknown>} props - The new properties to be set.
141
- */
142
- set props(props: Record<string, unknown>);
143
- /**
144
- * Static function to remove templates form the component props that will be shown when
145
- * the field mounts and the template routine executes, to be used on the adapter
146
- *
147
- * @param {unknown} props - the properties from the adapter components.
148
- */
149
- static filterProps(props: unknown): unknown;
150
- /**
151
- * Retrieves the current state value of the form field.
152
- *
153
- * @returns {Record<string,unknown>} - The current state value of the form field.
154
- */
155
- get stateValue(): Record<string, unknown>;
156
- get metadata(): unknown;
157
- /**
158
- * Retrieves the current value of the form field.
159
- *
160
- * @returns {unknown} - The current value of the form field.
161
- */
162
- get value(): unknown;
163
- /**
164
- * Sets the value of the form field and notifies subscribers about the change.
165
- *
166
- * @param {unknown} value - The new value to be set.
167
- */
168
- set value(value: unknown);
169
- /**
170
- * Retrieves the visibility status of the form field.
171
- *
172
- * @returns {boolean} - The visibility status of the form field.
173
- */
174
- get visibility(): boolean;
175
- /**
176
- * Sets the visibility status of the form field and notifies subscribers about the change.
177
- *
178
- * @param {boolean} visible - The new visibility status to be set.
179
- */
180
- set visibility(visible: boolean);
181
- /**
182
- * sets valid field state and notifies form instance via formValidNotification$
183
- */
184
- set valid(valid: boolean);
185
- /**
186
- * Retrieves the validity status of the form field.
187
- *
188
- * @returns {boolean} - The validity status of the form field.
189
- */
190
- get valid(): boolean;
191
- /**
192
- * triggers field valid notification to handle the form instance valid notification
193
- *
194
- * Note: since form unmount can occur before field unmount, this subject might already be closed by form instance
195
- * quick workaround is to check if the subject is already closed before emitting
196
- * if form instance onValid or template form.valid doesn't work properly, might be due to this workaround
197
- */
198
- triggerFieldValidNotification(): void;
199
- /**
200
- * Retrieves the error messages associated with the form field.
201
- *
202
- * @returns {TErrorMessages} - The error messages associated with the form field.
203
- */
204
- get errors(): TErrorMessages;
205
- /**
206
- * Sets the error messages associated with the form field and notifies subscribers about the change.
207
- *
208
- * @param {TErrorMessages} errors - The new error messages to be set.
209
- */
210
- set errors(errors: TErrorMessages);
211
- /**
212
- * Retrieves the API response data associated with the form field.
213
- *
214
- * @returns {TApiResponse} - The API response data associated with the form field.
215
- */
216
- get api(): TApiResponse;
217
- /**
218
- * Sets the API response data associated with the form field and notifies subscribers about the change.
219
- *
220
- * @param {TApiResponse} response - The new API response data to be set.
221
- */
222
- set api(response: TApiResponse);
223
- /**
224
- * notifies templates and event binded field configurations that a request starts it's processing
225
- */
226
- notifyApiRequest(): void;
227
- /** Retrieves the mounted status of the field.
228
- *
229
- * @returns {boolean} - the mounted status of the field.
230
- */
231
- get mounted(): boolean;
232
- /**
233
- * sets the mountedStatus and notifies the form that the field was mounted on the adapter
234
- * and it's ready to be handled by the form instance
235
- *
236
- * @param {boolean} mountedStatus - the mounted status to be set from the mountField function.
237
- */
238
- set mounted(mountedStatus: boolean);
239
- /**
240
- * Mounts the form field by initializing necessary subjects and combining their streams.
241
- *
242
- * @param {object} mountOpts - Adapter mount options.
243
- * @param {(value: unknown) => unknown} prop.valueSubscription - Adapter value change function
244
- * @param {(payload: Partial<IState>) => unknown} prop.propsSubscription - Adapter prop change function
245
- * @returns {void}
246
- */
247
- mountField({ valueSubscription, propsSubscription, }: {
248
- valueSubscription: (value: Record<string, unknown>) => void;
249
- propsSubscription: (payload: Partial<IState>) => void;
250
- }): void;
251
- /**
252
- * Sets the value of the form field and emits associated events.
253
- *
254
- * @param {unknown} prop.value - The new value to be set.
255
- * @param {TEvents} prop.event - The event associated with setting the value.
256
- * @returns {void}
257
- */
258
- emitValue(prop: {
259
- value: unknown;
260
- event: TEvents;
261
- }): void;
262
- /**
263
- * Emits events to trigger field-related actions such as validation, visibility checks, value resets, and API requests.
264
- *
265
- * @param {TEvents} event - The event type that triggers the field actions.
266
- * @returns {void}
267
- */
268
- emitEvents({ event }: {
269
- event: TEvents;
270
- }): void;
271
- /**
272
- * Sets the validity state of the field based on the provided validation rules and triggers error message updates.
273
- *
274
- * @param {TEvents} event - The event type associated with the field action.
275
- * @returns {void}
276
- */
277
- setFieldValidity({ event }: {
278
- event: TEvents;
279
- }): void;
280
- /**
281
- * Formats the field value using the specified formatters, if available.
282
- *
283
- * @param {unknown} value - The value to be formatted.
284
- * @returns {unknown} - The formatted value.
285
- */
286
- formatValue(value: unknown): unknown;
287
- /**
288
- * Masks the field value using the specified masks, if available.
289
- *
290
- * @param {unknown} value - The value to be masked.
291
- * @returns {unknown} - The masked value.
292
- */
293
- maskValue(value: unknown): unknown;
294
- checkApiRequestValidations(config: TApiConfig): boolean;
295
- /**
296
- * Makes an API request based on the field's API configuration and event type, updating the field's API response data.
297
- *
298
- * @param {TEvents} event - The event type associated with the API request.
299
- * @returns {Promise<void>}
300
- */
301
- apiRequest({ event }: {
302
- event: TEvents;
303
- }): Promise<void>;
304
- /**
305
- * Unsubscribes from all subject subscriptions associated with the field, cleaning up resources.
306
- *
307
- * @returns {void}
308
- */
309
- destroyField(): void;
310
- /**
311
- * Subscribes to changes in the field state and executes the provided callback function.
312
- *
313
- * @param {Function} callback - The callback function to be executed when the field state changes.
314
- * @returns {void}
315
- */
316
- subscribeState(callback: (payload: Partial<IState>) => void): void;
317
- /**
318
- * Subscribes to changes in the field value and executes the provided callback function.
319
- *
320
- * @param {Function} callback - The callback function to be executed when the field value changes.
321
- * @returns {void}
322
- */
323
- subscribeValue(callback: (value: unknown) => void): void;
324
- }
325
- type IFormField = FormField;
326
- export { IFormField, FormField };
@@ -1,346 +0,0 @@
1
- import { IFormField } from './field';
2
- import { Subject, Subscription } from 'rxjs';
3
- import { IComponentSchema, IComponentSchemaAsFormField, IFormSchema } from '../interfaces/schema';
4
- import { TSchemaFormConfig } from '../types/schema';
5
- import { TSubscribedTemplates, TTemplateEvent } from '../types/template';
6
- import { TEvents, TFieldEvent, TFieldValidationPayload, TFormDataPayload, TFormSubmitPayload, TFormValidationPayload, TMutationEvents } from '../types/event';
7
- import { TFormEntry, TFormValues } from '../types/form';
8
- import { TMapper } from '../types/mapper';
9
- import { TEMPLATE_AVALIABLE_SCOPES } from '../constants/constants';
10
- /**
11
- * Represents the core logic for managing a form, including field management, validation, and submission.
12
- */
13
- declare class FormCore {
14
- index: string;
15
- schema?: IFormSchema;
16
- fields: Map<string, IFormField>;
17
- private _iVars;
18
- templateSubject$: Subject<TTemplateEvent>;
19
- templateSubscription$: Subscription;
20
- submitSubject$: Subject<TFormSubmitPayload<unknown>>;
21
- mountSubject$: Subject<{
22
- key: string;
23
- status: boolean;
24
- }>;
25
- fieldEventSubject$: Subject<TFieldEvent>;
26
- dataSubject$: Subject<TFormDataPayload>;
27
- formValidSubject$: Subject<TFormValidationPayload>;
28
- fieldValidNotification$: Subject<TFieldValidationPayload>;
29
- subscribedTemplates: TSubscribedTemplates[];
30
- action?: string;
31
- method?: string;
32
- config: Required<TSchemaFormConfig>;
33
- mappers: Map<string, TMapper<unknown>>;
34
- queuedFieldVisibilityEvents: Map<string, {
35
- hasError: boolean;
36
- showOnlyIfTrue?: boolean;
37
- }>;
38
- queuedFieldResetValuesEvents: Map<string, {
39
- value: unknown;
40
- }>;
41
- queuedFieldResetPropertyEvents: Map<string, {
42
- property: string;
43
- path: string;
44
- value: unknown;
45
- }>;
46
- queuedInitialValues: Map<string, unknown>;
47
- _valid: boolean;
48
- /**
49
- * Creates an instance of FormCore.
50
- *
51
- * @param {TFormEntry & Omit<IFormSchema, 'components'>} entry - Configuration options for the form.
52
- * @param {IFormSchema} entry.schema - The schema definition for the form.
53
- * @param {Record<string, unknown> | IFormSchema.initialValues} [entry.initialValues] - Initial values for the form fields.
54
- * @param {string} [entry.action] - The action attribute of the form.
55
- * @param {string} [entry.method] - The method attribute of the form.
56
- * @param {IFormSchema.iVars} [entry.iVars] - The internal variables of the form.
57
- * @param {((payload: {field: string;data: TFormValues;}) => void) | undefined} [entry.onData] - A callback function to handle data emission.
58
- */
59
- constructor(entry: TFormEntry & Omit<IFormSchema, 'components'>);
60
- /**
61
- * mock function to simulate form mount onto the adapter
62
- */
63
- generateFields(): void;
64
- /**
65
- * callback function passed to field instance to notify field adapter mount status
66
- * once the field has all field instance properties set, this function will handle all
67
- * field routines
68
- *
69
- * @param { string } entry.key field unique identifier
70
- * @param { boolean } entry.status mount status notified from field
71
- */
72
- mountActions({ key, status }: {
73
- key: string;
74
- status: boolean;
75
- }): void;
76
- /**
77
- * initialValues setter to handle field values set externally from the adapter
78
- *
79
- * @param { Record<string, unknown> | undefined } payload initialValues to set onto fields
80
- */
81
- set initialValues(payload: Record<string, unknown> | undefined);
82
- /**
83
- * Retrieves the internal variables (iVars) of the form.
84
- *
85
- * @returns {Record<string, unknown>} - The internal variables of the form.
86
- */
87
- get iVars(): Record<string, unknown>;
88
- /**
89
- * Sets the internal variables (iVars) of the form and notifies subscribers about the change.
90
- *
91
- * @param {Record<string, unknown>} payload - The new internal variables to be set.
92
- */
93
- set iVars(payload: Record<string, unknown>);
94
- /**
95
- * Validates all form fields and sets the form valid flag
96
- *
97
- */
98
- validateForm(): boolean;
99
- get valid(): boolean;
100
- set valid(valid: boolean);
101
- /**
102
- * Subscribes to templates for dynamic updates.
103
- */
104
- subscribeTemplates(): void;
105
- /**
106
- * Gets the value of a property from a field.
107
- *
108
- * @param {object} options - Options for getting the value.
109
- * @param {string} options.key - The key of the field.
110
- * @param {string} options.property - The property to retrieve.
111
- * @param {string[]} options.path - The path to the property if it's nested.
112
- * @returns {unknown | undefined} The value of the property, or undefined if the field doesn't exist.
113
- */
114
- getValue({ scope, key, property, path, }: {
115
- scope: (typeof TEMPLATE_AVALIABLE_SCOPES)[number];
116
- key: string;
117
- property: string;
118
- path: string[];
119
- }): unknown | undefined;
120
- /**
121
- * Sets the value of a property in a field.
122
- *
123
- * @param {object} options - Options for setting the value.
124
- * @param {string} options.key - The key of the field.
125
- * @param {string} options.property - The property to set.
126
- * @param {string[]} options.path - The path to the property if it's nested.
127
- * @param {unknown} options.originKey - field that called templating
128
- * @param {unknown} options.value - The value to set.
129
- * @param {TMutationEvents} options.event - Internal Event for template Handling.
130
- */
131
- setValue({ key, property, path, originKey, value, }: {
132
- key: string;
133
- property: string;
134
- path: string[];
135
- originKey?: string;
136
- value: unknown;
137
- event: TMutationEvents;
138
- }): void;
139
- /**
140
- * Extracts parameters from an expression.
141
- *
142
- * @param {string} expression - The expression containing parameters.
143
- * @returns {string[]} An array of extracted parameters.
144
- */
145
- extractParams(expression: string): unknown[];
146
- /**
147
- * Replaces expressions marked by ${...} in the expression string with the provided values.
148
- *
149
- * @param {string} expression - The expression string containing the marked expressions.
150
- * @param {string[]} values - The values to be inserted into the marked expressions.
151
- * @returns {string} The expression string with the replacements made.
152
- */
153
- replaceExpression(expression: string, values: unknown[]): string;
154
- /**
155
- * Checks if an expression string contains string concatenation within a marked expression.
156
- *
157
- * @param {string} expression - The expression string to be checked.
158
- * @returns {boolean} True if the expression contains string concatenation, otherwise false.
159
- */
160
- hasStringConcatenation(expression: string): boolean;
161
- /**
162
- * Refreshes templates with updated values.
163
- *
164
- * @param {object} options - Options for refreshing templates.
165
- * @param {string} options.key - The key of the field triggering the update.
166
- * @param {TMutationEvents} options.event - Internal event descriptor to handle templating.
167
- */
168
- refreshTemplates({ key, event }: TTemplateEvent): void;
169
- /**
170
- * executes events that were stored due to field unavaliability
171
- *
172
- * @param {string} field field to check
173
- */
174
- checkFieldEventQueues(field: string): void;
175
- /**
176
- * Validates and collects the names of form fields in the provided schema structure.
177
- *
178
- * @param {IComponentSchema[]} [struct] - The schema structure of the form components.
179
- * @param {string[]} [indexes=[]] - An array to collect the names of the form fields.
180
- * @returns {string[]} - An array of form field names.
181
- * @throws {Error} - Throws an error if a field name matches the reserved name defined by `IVARPROPNAME`.
182
- * @private
183
- */
184
- private static checkIndexes;
185
- /**
186
- * @internal
187
- * Update field visibility accordingly.
188
- *
189
- * @param {object} options - options to set field visibility
190
- * @param {string} options.field - Field name to be updated.
191
- * @param {boolean} options.hasError - Condition to be used as visibility.
192
- * @param {boolean|undefined} options.showOnlyIfTrue - Flag to be considered when update field visibility. If it's true, then considered error, if it's false, always considered the opposite.
193
- */
194
- private setFieldVisibility;
195
- /**
196
- * Validates visibility conditions for a given event and updates field visibility accordingly.
197
- *
198
- * @param {object} options - Options for validating visibility.
199
- * @param {TEvents} options.event - The event triggering visibility validation.
200
- * @param {string} options.key - The key of the field.
201
- */
202
- validateVisibility({ event, key }: {
203
- event: TEvents;
204
- key: string;
205
- }): void;
206
- /**
207
- * @internal
208
- * Update field value and emit change and cleared event.
209
- *
210
- * @param {options} options to reset the field value
211
- * @param {string} options.key - Field name to be updated.
212
- * @param {unknown} options.value - Value to be inserted into field.
213
- */
214
- private setResetFieldValue;
215
- /**
216
- * Resets field values based on reset conditions defined in the schema.
217
- *
218
- * @param {object} options - Options for resetting field values.
219
- * @param {TEvents} options.event - The event triggering the reset.
220
- * @param {string} options.key - The key of the field.
221
- */
222
- resetValue({ event, key }: {
223
- event: TEvents;
224
- key: string;
225
- }): void;
226
- /**
227
- * @internal
228
- * Update field property and emit template change.
229
- *
230
- * @param {object} options - Options for resetting field property
231
- * @param {string} options.key - Field name to be updated.
232
- * @param {string} options.property - field property to change.
233
- * @param {string} options.path - field property path to change.
234
- * @param {unknown} options.value - Value to be inserted into field.
235
- */
236
- private setResetPathValue;
237
- /**
238
- * Resets field properties based on reset conditions defined in the schema.
239
- *
240
- * @param {object} options - Options for resetting field property.
241
- * @param {TEvents} options.event - The event triggering the reset.
242
- * @param {string} options.key - The key of the field.
243
- */
244
- resetProperty({ event, key }: {
245
- event: TEvents;
246
- key: string;
247
- }): void;
248
- /**
249
- * Adds a field onto the form instance regardless there is a schema or not
250
- *
251
- * @param fieldSchema
252
- * @param mapperElement
253
- */
254
- addField({ fieldSchema, mapperElement, path, }: {
255
- fieldSchema: IComponentSchema;
256
- mapperElement?: TMapper<unknown>;
257
- path?: string;
258
- }): void;
259
- /**
260
- * function to be called from the adapter to remove a field when a field is removed from it
261
- *
262
- * @param {{ key: string }} entry.key
263
- */
264
- removeField({ key }: {
265
- key: string;
266
- }): void;
267
- /**
268
- * Serializes the schema structure to create form fields.
269
- *
270
- * @param {IComponentSchema[]} [struct] - The schema structure to serialize.
271
- * @param {string} [path] - The path of the parent component.
272
- */
273
- serializeStructure(struct?: IComponentSchemaAsFormField<unknown>[], path?: string): void;
274
- /**
275
- * Refreshes form fields based on changes in the schema structure.
276
- *
277
- * @param {IComponentSchema[]} struct - The updated schema structure.
278
- */
279
- refreshFields(struct: IComponentSchemaAsFormField<unknown>[]): void;
280
- /**
281
- * Gets a form field by its key.
282
- *
283
- * @param {object} options - Options for getting the form field.
284
- * @param {string} options.key - The key of the form field.
285
- * @returns {IFormField | undefined} The form field, or undefined if not found.
286
- */
287
- getField({ key }: {
288
- key: string;
289
- }): IFormField | undefined;
290
- /**
291
- * Prints the current values of all form fields.
292
- */
293
- printValues(): void;
294
- /**
295
- * Gets the current values of all form fields.
296
- *
297
- * @returns {TFormValues} The current form values.
298
- */
299
- getFormValues<T>(): TFormValues<T>;
300
- /**
301
- * function to be called to events sent from the adapter
302
- *
303
- * @param {{callback: (payload: TFieldEvent) => void}} entry.callback callback function from the adapter
304
- * @returns
305
- */
306
- subscribeFieldEvent({ callback, }: {
307
- callback: (payload: TFieldEvent) => void;
308
- }): Subscription;
309
- /**
310
- * to be called from the adapter when the form mounts
311
- *
312
- * @param {(payload: TFormValues<T>) => void} callback
313
- * @returns Subscription
314
- */
315
- subscribeOnMount<T>(callback: (payload: TFormValues<T>) => void): Subscription;
316
- /**
317
- *
318
- * @param {(payload: { field: string; data: TFormValues }) => void} callback callback function to call onData
319
- */
320
- subscribeData<T>(callback: (payload: {
321
- field: string;
322
- data: TFormValues<T>;
323
- }) => void): Subscription;
324
- /**
325
- * method to register a callback function to be called when the form is valid
326
- *
327
- * @param {(payload: TFormValues<T>) => void} callback callback function to call when the submit action occurs
328
- */
329
- subscribeOnSubmit<T>(callback: (payload: TFormValues<T>) => void): Subscription;
330
- /**
331
- * method to check whenever the validity status of the form changes, only emits on status change
332
- *
333
- * @param {(payload: TFormValidationPayload) => void} callback callback function to call onValid
334
- */
335
- subscribeFormValidation(callback: (payload: TFormValidationPayload) => void): Subscription;
336
- /**
337
- * Submits the form by triggering form field events and invoking the onSubmit callback.
338
- */
339
- submit<T>(): void;
340
- /**
341
- * recycles all the Suscriptions, to be called from the adapter when the form leaves the page
342
- */
343
- destroy(): void;
344
- }
345
- type TFormCore = FormCore;
346
- export { TFormCore, FormCore };