@bolttech/form-engine-core 1.0.10 → 1.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/credit-card.d.ts +743 -0
  3. package/credit-card.esm.js +1 -0
  4. package/currency.d.ts +131 -0
  5. package/currency.esm.js +1 -0
  6. package/date.d.ts +582 -0
  7. package/date.esm.js +1 -0
  8. package/document.d.ts +527 -0
  9. package/document.esm.js +1 -0
  10. package/index.d.ts +52 -5
  11. package/index.esm.js +1 -4570
  12. package/lite.d.ts +2393 -0
  13. package/lite.esm.js +1 -0
  14. package/package.json +34 -2
  15. package/src/constants/constants.d.ts +11 -0
  16. package/src/formatters/creditCard.d.ts +23 -0
  17. package/src/formatters/custom.d.ts +29 -0
  18. package/src/formatters/handler.d.ts +2 -0
  19. package/src/formatters/regex.d.ts +47 -0
  20. package/src/formatters/splitter.d.ts +17 -0
  21. package/src/formatters/string.d.ts +88 -0
  22. package/src/helpers/SafeSubject.d.ts +21 -0
  23. package/src/helpers/creditCard.d.ts +95 -0
  24. package/src/helpers/helpers.d.ts +66 -0
  25. package/src/helpers/lodash-replacements.d.ts +41 -0
  26. package/src/helpers/validation.d.ts +28 -0
  27. package/src/index.d.ts +15 -0
  28. package/src/interfaces/schema.d.ts +161 -0
  29. package/src/interfaces/state.d.ts +22 -0
  30. package/src/lite.d.ts +30 -0
  31. package/src/managers/field.d.ts +339 -0
  32. package/src/managers/form.d.ts +357 -0
  33. package/src/managers/formGroup.d.ts +110 -0
  34. package/src/managers/index.d.ts +3 -0
  35. package/src/masks/creditCard.d.ts +60 -0
  36. package/src/masks/currency.d.ts +29 -0
  37. package/src/masks/generic.d.ts +39 -0
  38. package/src/masks/handler.d.ts +2 -0
  39. package/src/masks/string.d.ts +37 -0
  40. package/src/plugins/credit-card.d.ts +4 -0
  41. package/src/plugins/currency.d.ts +2 -0
  42. package/src/plugins/date.d.ts +2 -0
  43. package/src/plugins/document.d.ts +2 -0
  44. package/src/registry.d.ts +20 -0
  45. package/src/types/event.d.ts +175 -0
  46. package/src/types/form.d.ts +55 -0
  47. package/src/types/mapper.d.ts +87 -0
  48. package/src/types/schema.d.ts +1001 -0
  49. package/src/types/template.d.ts +65 -0
  50. package/src/types/utility.d.ts +12 -0
  51. package/src/validations/creditCard.d.ts +52 -0
  52. package/src/validations/custom.d.ts +27 -0
  53. package/src/validations/date.d.ts +79 -0
  54. package/src/validations/document.d.ts +25 -0
  55. package/src/validations/handler.d.ts +2 -0
  56. package/src/validations/length.d.ts +39 -0
  57. package/src/validations/list.d.ts +32 -0
  58. package/src/validations/logical.d.ts +75 -0
  59. package/src/validations/multiple.d.ts +31 -0
  60. package/src/validations/namedRule.d.ts +22 -0
  61. package/src/validations/number.d.ts +145 -0
  62. package/src/validations/object.d.ts +44 -0
  63. package/src/validations/regex.d.ts +217 -0
  64. package/src/validations/string.d.ts +53 -0
@@ -0,0 +1,161 @@
1
+ import { TMapper } from '../types/mapper';
2
+ import { TApiEvent, TFormatters, TMasks, TProps, TResetPathMethods, TResetValueMethods, TSchemaFormConfig, TValidations, TVisibility } from '../types/schema';
3
+ /**
4
+ * @interface IComponentSchema
5
+ * Represents the schema for a component within a form.
6
+ *
7
+ * @property {string} component - The type of component (e.g., 'input', 'button').
8
+ * @property {TProps} props - The properties of the component.
9
+ * @property {string} name - The name of the component.
10
+ * @property {string} nameToSubmit - The name of the field when submit values (optional).
11
+ * @property {TValidations} [validations] - The validation methods for the component.
12
+ * @property {TVisibility[]} [visibilityConditions] - The visibility conditions for the component.
13
+ * @property {TResetValueMethods[]} [resetValues] - The reset value methods for the component.
14
+ * @property {TApiEvent} [api] - The API configuration for the component.
15
+ * @property {TFormatters} [formatters] - The formatters for the component.
16
+ * @property {TMasks} [masks] - The masks for the component.
17
+ * @property {IComponentSchema[]} [children] - The child components.
18
+ * @property {boolean} visibility - visibility status the component will mount (to avoid SSR blinking)
19
+ * @property {boolean} persistValue - check this if you want the last visible value to be restored after a visiblity schema rule applied
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const schema: IComponentSchema = {
24
+ * component: 'input',
25
+ * props: { type: 'text', placeholder: 'Enter your name' },
26
+ * name: 'name',
27
+ * nameToSubmit: 'applicant.firstName',
28
+ * validations: {
29
+ * methods: {
30
+ * required: true,
31
+ * regex: '^([0-9]+)*$',
32
+ * max: 5,
33
+ * },
34
+ * eventMessages: {
35
+ * ON_FIELD_MOUNT: ['required'],
36
+ * ON_FIELD_CHANGE: ['regex', 'required'],
37
+ * ON_FIELD_BLUR: ['max', 'required'],
38
+ * },
39
+ * messages: {
40
+ * default: 'This field is required',
41
+ * regex: 'Only numbers are available.',
42
+ * max: 'Max of 5',
43
+ * },
44
+ * },
45
+ * visibilityConditions: [{ conditions: { field: 'age', value: 18 } }],
46
+ * resetValues: [{ field: 'age', resetTo: '' }],
47
+ * api: {
48
+ * defaultConfig: {
49
+ * config: { method: 'POST', url: 'https://api.example.com/submit' },
50
+ * events: [{ eventName: 'ON_FIELD_BLUR' }]
51
+ * }
52
+ * },
53
+ * formatters: { capitalize: true },
54
+ * masks: { currency: { align: 'left', decimal: '.', precision: 2, prefix: '$', thousands: ',' } },
55
+ * children: [],
56
+ * visibility: true,
57
+ * persistValue: true,
58
+ * };
59
+ * ```
60
+ */
61
+ interface IComponentSchema {
62
+ /** The type of component (e.g., 'input', 'button'). */
63
+ component: string;
64
+ /** The properties of the component. */
65
+ props?: TProps;
66
+ /** The name of the component. */
67
+ name: string;
68
+ /** The name of the field when submit values. */
69
+ nameToSubmit?: string;
70
+ /** The validation methods for the component. */
71
+ validations?: TValidations;
72
+ /** The API configuration for the component. */
73
+ api?: TApiEvent;
74
+ /** The visibility conditions for the component. */
75
+ visibilityConditions?: TVisibility[];
76
+ /** The reset value methods for the component. */
77
+ resetValues?: TResetValueMethods[];
78
+ /** The reset property values for the component. */
79
+ resetPropertyValues?: TResetPathMethods[];
80
+ /** The formatters for the component. */
81
+ formatters?: TFormatters;
82
+ /** The masks for the component. */
83
+ masks?: TMasks;
84
+ /** The child components. */
85
+ children?: IComponentSchema[];
86
+ /** Visibility status the component will mount (to avoid SSR blinking) */
87
+ visibility?: boolean;
88
+ /** Check this if you want the last visible value to be restored after a visiblity schema rule applied */
89
+ persistValue?: boolean;
90
+ }
91
+ interface IComponentSchemaAsFormField<T> extends IComponentSchema {
92
+ mapper?: TMapper<T>;
93
+ children?: IComponentSchemaAsFormField<T>[];
94
+ }
95
+ /**
96
+ * @interface IFormSchema
97
+ * Represents the schema for a form.
98
+ *
99
+ * @property {string} index - The unique index or identifier for the form.
100
+ * @property {string} [action] - The URL to which the form data will be submitted. (experimental)
101
+ * @property {string} [method] - The HTTP method used to submit the form (e.g., 'POST', 'GET') (experimental).
102
+ * @property {Record<string, unknown>} [initialValues] - The initial values for the form fields.
103
+ * @property {Record<string, unknown>} [iVars] - Dynamic key value pairs that change from any external source
104
+ * @property {IComponentSchema[]} [components] - The list of components included in the form.
105
+ * @property {boolean} [stopEventsOnSubmit] - stop all the events declared as callback on useForm/Form once form is submitted
106
+ * @property {TSchemaFormConfig} [config] - form configurations to change event debouncers and debugging tools
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const formSchema: IFormSchema = {
111
+ * index: 'userForm',
112
+ * initialValues: { name: '', email: '' },
113
+ * iVars: iVarsState,
114
+ * config: {
115
+ * defaultLogVerbose: true
116
+ * },
117
+ * components: [
118
+ * { component: 'input', name: 'name', props: { placeholder: 'Enter your name' } },
119
+ * { component: 'input', name: 'email', props: { placeholder: 'Enter your email' } }
120
+ * ]
121
+ * };
122
+ * ```
123
+ */
124
+ interface IFormSchema {
125
+ index: string;
126
+ action?: string;
127
+ method?: string;
128
+ config?: TSchemaFormConfig;
129
+ initialValues?: Record<string, unknown>;
130
+ iVars?: Record<string, unknown>;
131
+ components?: IComponentSchema[];
132
+ stopEventsOnSubmit?: boolean;
133
+ /** Pre-fetched API response data for SSR. Keys are field names, values contain the API responses to hydrate. */
134
+ prefetchedData?: Record<string, TPrefetchedFieldData>;
135
+ }
136
+ /**
137
+ * Represents pre-fetched API data for a single field.
138
+ * Used to hydrate API response caches during SSR so templates referencing API data resolve correctly.
139
+ *
140
+ * @property {unknown} [defaultResponse] - The pre-fetched response for the field's default API config.
141
+ * @property {Record<string, unknown>} [namedResponses] - Pre-fetched responses for named API configs.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const prefetchedData = {
146
+ * countryField: {
147
+ * defaultResponse: [{ id: 'BR', label: 'Brazil' }, { id: 'US', label: 'United States' }],
148
+ * },
149
+ * stateField: {
150
+ * namedResponses: { statesByCountry: [{ id: 'SP', label: 'São Paulo' }] },
151
+ * },
152
+ * };
153
+ * ```
154
+ */
155
+ interface TPrefetchedFieldData {
156
+ /** The pre-fetched response for the field's default API config. */
157
+ defaultResponse?: unknown;
158
+ /** Pre-fetched responses keyed by named API config name. */
159
+ namedResponses?: Record<string, unknown>;
160
+ }
161
+ export { IFormSchema, IComponentSchema, IComponentSchemaAsFormField, TPrefetchedFieldData };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @interface IState
3
+ * Represents the state of a form component.
4
+ *
5
+ * @property {string[]} errors - The list of error messages.
6
+ * @property {boolean} visibility - The visibility state of the component.
7
+ * @property {Record<string, unknown>} props - The properties of the component.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const state: IState = {
12
+ * visibility: true,
13
+ * props: { type: 'text', value: 'John' }
14
+ * };
15
+ * ```
16
+ */
17
+ interface IState {
18
+ visibility: boolean;
19
+ props: Record<string, unknown>;
20
+ errors: Record<string, unknown>;
21
+ }
22
+ export { IState };
package/src/lite.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Lite entry point for form-engine-core.
3
+ *
4
+ * This entry point excludes credit-card and document validation modules,
5
+ * reducing bundle size for consumers who don't need them.
6
+ *
7
+ * To add credit card support:
8
+ * import '@bolttech/form-engine-core/credit-card';
9
+ *
10
+ * To add document validation support:
11
+ * import '@bolttech/form-engine-core/document';
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { FormCore, FormGroup } from '@bolttech/form-engine-core/lite';
16
+ * import '@bolttech/form-engine-core/credit-card'; // optional
17
+ * ```
18
+ */
19
+ export * from './types/event';
20
+ export * from './types/form';
21
+ export * from './types/schema';
22
+ export * from './types/template';
23
+ export * from './types/mapper';
24
+ export * from './types/utility';
25
+ export * from './interfaces/schema';
26
+ export * from './interfaces/state';
27
+ export * from './managers/form';
28
+ export * from './managers/formGroup';
29
+ export * from './managers/field';
30
+ export { registerValidations, registerFormatters, registerMasks, validationRegistry, formatterRegistry, maskRegistry } from './registry';
@@ -0,0 +1,339 @@
1
+ import { Subject, Subscription, BehaviorSubject } 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
+ children?: string[];
19
+ originalSchema: IComponentSchemaAsFormField<unknown>;
20
+ validations?: TValidations;
21
+ visibilityConditions?: TVisibility[];
22
+ resetValues?: TResetValueMethods[];
23
+ resetPropertyValues?: TResetPathMethods[];
24
+ apiSchema?: TApiEvent;
25
+ formatters?: TFormatters;
26
+ masks?: TMasks;
27
+ valuePropName?: string;
28
+ config: Required<TSchemaFormConfig>;
29
+ mapper: TMapper<unknown>;
30
+ errorsString: string;
31
+ errorsList: string[];
32
+ private _props;
33
+ private _adapterProps;
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
+ formValuesStateSubject$: BehaviorSubject<TFormValues<unknown>>;
60
+ validateVisibility: (payload: {
61
+ event: TEvents;
62
+ key: string;
63
+ }) => void;
64
+ resetValue: (payload: {
65
+ event: TEvents;
66
+ key: string;
67
+ }) => void;
68
+ resetProperty: (payload: {
69
+ event: TEvents;
70
+ key: string;
71
+ }) => void;
72
+ getFormValues: () => TFormValues<unknown>;
73
+ valueChangeEvent: TValueChangeEvent;
74
+ submitEvent: () => void;
75
+ persistValue?: boolean;
76
+ /**
77
+ * Creates an instance of FormField.
78
+ *
79
+ * @param {object} options - Configuration options for the form field.
80
+ * @param {IComponentSchema} options.schemaComponent - The schema definition for the form field.
81
+ * @param {TSchemaFormConfig} options.config - The schema default configuration for debounced actions.
82
+ * @param {string} [options.path] - The path within the form field (used internally during recursion).
83
+ * @param {string[]} options.children - An array of children fields names.
84
+ * @param {Function} options.validateVisibility - A function to validate the visibility of the field.
85
+ * @param {Function} options.resetValue - A function to reset the field value.
86
+ * @param {Function} options.resetProperty - A function to reset a field property.
87
+ * @param {Subject<{ key: string }>} options.templateSubject$ - A subject for template updates.
88
+ * @param {Subject<TFieldEvent>} options.fieldEventSubject$, - Subject for basic event mapped field emissions, except onData to form instance
89
+ * @param {Subject<{ key: string; event: TEvents }>} options.dataSubject$, - Subject to emit onData events to form instance
90
+ * @param {Subject<{ key: string }>} options.formValidNotification$, - Subject to emit field valid change to form instance
91
+ * @param {TMapper<unknown>} options.mapper, - component generic mapper containing render parameters for adapters
92
+ * @param {() => TFormValues<unknown>} options.getFormValues, - form instance function that builds onData parameter payload from fields
93
+ */
94
+ constructor({ formIndex, schemaComponent, config, children, validateVisibility, resetValue, resetProperty, templateSubject$, fieldEventSubject$, dataSubject$, fieldValidNotification$, mountSubject$, mapper, formValuesStateSubject$, submitEvent, visibility, persistValue, }: {
95
+ formIndex: string;
96
+ schemaComponent: IComponentSchema;
97
+ config?: TSchemaFormConfig;
98
+ path?: string;
99
+ children?: string[];
100
+ validateVisibility: (payload: {
101
+ event: TEvents;
102
+ key: string;
103
+ }) => void;
104
+ resetValue: (payload: {
105
+ event: TEvents;
106
+ key: string;
107
+ }) => void;
108
+ resetProperty: (payload: {
109
+ event: TEvents;
110
+ key: string;
111
+ }) => void;
112
+ submitEvent: () => void;
113
+ templateSubject$: Subject<TTemplateEvent>;
114
+ fieldEventSubject$: Subject<TFieldEvent>;
115
+ dataSubject$: Subject<TFormDataPayload>;
116
+ fieldValidNotification$: Subject<TFieldValidationPayload>;
117
+ mountSubject$: Subject<{
118
+ key: string;
119
+ status: boolean;
120
+ }>;
121
+ formValuesStateSubject$: BehaviorSubject<TFormValues<unknown>>;
122
+ mapper: TMapper<unknown>;
123
+ visibility?: boolean;
124
+ persistValue?: boolean;
125
+ });
126
+ /**
127
+ * method to initialize all recycled Subjects and initialize Observers on field instance creation or rerender
128
+ * due to some visibility conditions unmounts the field from the adapter if they are children of it and avoid
129
+ * emissions to unsubscribed fields
130
+ */
131
+ initializeObservers(): void;
132
+ /**
133
+ * Retrieves the raw props sent from the adapter.
134
+ *
135
+ * @returns {string} - raw props from the adapter
136
+ */
137
+ get adapterProps(): string;
138
+ /**
139
+ * compares adapter props changes and emits the change if they effectively changed
140
+ * preventing an emission from the adapter of the same props that can overwrite other prop
141
+ * changes via templating
142
+ */
143
+ set adapterProps(props: Record<string, unknown>);
144
+ /**
145
+ * Retrieves the properties associated with the form field.
146
+ *
147
+ * @returns {Record<string, unknown>} - The properties of the form field.
148
+ */
149
+ get props(): Record<string, unknown>;
150
+ /**
151
+ * Sets the properties of the form field and notifies subscribers about the change.
152
+ *
153
+ * @param {Record<string, unknown>} props - The new properties to be set.
154
+ */
155
+ set props(props: Record<string, unknown>);
156
+ /**
157
+ * Static function to remove templates form the component props that will be shown when
158
+ * the field mounts and the template routine executes, to be used on the adapter
159
+ *
160
+ * @param {unknown} props - the properties from the adapter components.
161
+ */
162
+ static filterProps(props: unknown): unknown;
163
+ /**
164
+ * Retrieves the current state value of the form field.
165
+ *
166
+ * @returns {Record<string,unknown>} - The current state value of the form field.
167
+ */
168
+ get stateValue(): Record<string, unknown>;
169
+ get metadata(): unknown;
170
+ /**
171
+ * Retrieves the current value of the form field.
172
+ *
173
+ * @returns {unknown} - The current value of the form field.
174
+ */
175
+ get value(): unknown;
176
+ /**
177
+ * Sets the value of the form field and notifies subscribers about the change.
178
+ *
179
+ * @param {unknown} value - The new value to be set.
180
+ */
181
+ set value(value: unknown);
182
+ /**
183
+ * Retrieves the visibility status of the form field.
184
+ *
185
+ * @returns {boolean} - The visibility status of the form field.
186
+ */
187
+ get visibility(): boolean;
188
+ /**
189
+ * Sets the visibility status of the form field and notifies subscribers about the change.
190
+ *
191
+ * @param {boolean} visible - The new visibility status to be set.
192
+ */
193
+ set visibility(visible: boolean);
194
+ /**
195
+ * sets valid field state and notifies form instance via formValidNotification$
196
+ */
197
+ set valid(valid: boolean);
198
+ /**
199
+ * Retrieves the validity status of the form field.
200
+ *
201
+ * @returns {boolean} - The validity status of the form field.
202
+ */
203
+ get valid(): boolean;
204
+ /**
205
+ * triggers field valid notification to handle the form instance valid notification
206
+ *
207
+ * Note: since form unmount can occur before field unmount, this subject might already be closed by form instance
208
+ * quick workaround is to check if the subject is already closed before emitting
209
+ * if form instance onValid or template form.valid doesn't work properly, might be due to this workaround
210
+ */
211
+ triggerFieldValidNotification(): void;
212
+ /**
213
+ * Retrieves the error messages associated with the form field.
214
+ *
215
+ * @returns {TErrorMessages} - The error messages associated with the form field.
216
+ */
217
+ get errors(): TErrorMessages;
218
+ /**
219
+ * Sets the error messages associated with the form field and notifies subscribers about the change.
220
+ *
221
+ * @param {TErrorMessages} errors - The new error messages to be set.
222
+ */
223
+ set errors(errors: TErrorMessages);
224
+ /**
225
+ * Retrieves the API response data associated with the form field.
226
+ *
227
+ * @returns {TApiResponse} - The API response data associated with the form field.
228
+ */
229
+ get api(): TApiResponse;
230
+ /**
231
+ * Sets the API response data associated with the form field and notifies subscribers about the change.
232
+ *
233
+ * @param {TApiResponse} response - The new API response data to be set.
234
+ */
235
+ set api(response: TApiResponse);
236
+ /**
237
+ * notifies templates and event binded field configurations that a request starts it's processing
238
+ */
239
+ notifyApiRequest(): void;
240
+ /** Retrieves the mounted status of the field.
241
+ *
242
+ * @returns {boolean} - the mounted status of the field.
243
+ */
244
+ get mounted(): boolean;
245
+ /**
246
+ * sets the mountedStatus and notifies the form that the field was mounted on the adapter
247
+ * and it's ready to be handled by the form instance
248
+ *
249
+ * @param {boolean} mountedStatus - the mounted status to be set from the mountField function.
250
+ */
251
+ set mounted(mountedStatus: boolean);
252
+ /**
253
+ * Mounts the form field by initializing necessary subjects and combining their streams.
254
+ *
255
+ * @param {object} mountOpts - Adapter mount options.
256
+ * @param {(value: unknown) => unknown} prop.valueSubscription - Adapter value change function
257
+ * @param {(payload: Partial<IState>) => unknown} prop.propsSubscription - Adapter prop change function
258
+ * @returns {void}
259
+ */
260
+ mountField({ valueSubscription, propsSubscription, }: {
261
+ valueSubscription: (value: Record<string, unknown>) => void;
262
+ propsSubscription: (payload: Partial<IState>) => void;
263
+ }): void;
264
+ /**
265
+ * Sets the value of the form field and emits associated events.
266
+ *
267
+ * @param {unknown} prop.value - The new value to be set.
268
+ * @param {TEvents} prop.event - The event associated with setting the value.
269
+ * @returns {void}
270
+ */
271
+ emitValue(prop: {
272
+ value: unknown;
273
+ event: TEvents;
274
+ }): void;
275
+ /**
276
+ * Emits events to trigger field-related actions such as validation, visibility checks, value resets, and API requests.
277
+ *
278
+ * @param {TEvents} event - The event type that triggers the field actions.
279
+ * @returns {void}
280
+ */
281
+ emitEvents({ event }: {
282
+ event: TEvents;
283
+ }): void;
284
+ /**
285
+ * Sets the validity state of the field based on the provided validation rules and triggers error message updates.
286
+ *
287
+ * @param {TEvents} event - The event type associated with the field action.
288
+ * @returns {void}
289
+ */
290
+ setFieldValidity({ event }: {
291
+ event: TEvents;
292
+ }): void;
293
+ /**
294
+ * Formats the field value using the specified formatters, if available.
295
+ *
296
+ * @param {unknown} value - The value to be formatted.
297
+ * @returns {unknown} - The formatted value.
298
+ */
299
+ formatValue(value: unknown): unknown;
300
+ /**
301
+ * Masks the field value using the specified masks, if available.
302
+ *
303
+ * @param {unknown} value - The value to be masked.
304
+ * @returns {unknown} - The masked value.
305
+ */
306
+ maskValue(value: unknown): unknown;
307
+ checkApiRequestValidations(config: TApiConfig): boolean;
308
+ /**
309
+ * Makes an API request based on the field's API configuration and event type, updating the field's API response data.
310
+ *
311
+ * @param {TEvents} event - The event type associated with the API request.
312
+ * @returns {Promise<void>}
313
+ */
314
+ apiRequest({ event }: {
315
+ event: TEvents;
316
+ }): Promise<void>;
317
+ /**
318
+ * Unsubscribes from all subject subscriptions associated with the field, cleaning up resources.
319
+ *
320
+ * @returns {void}
321
+ */
322
+ destroyField(): void;
323
+ /**
324
+ * Subscribes to changes in the field state and executes the provided callback function.
325
+ *
326
+ * @param {Function} callback - The callback function to be executed when the field state changes.
327
+ * @returns {void}
328
+ */
329
+ subscribeState(callback: (payload: Partial<IState>) => void): void;
330
+ /**
331
+ * Subscribes to changes in the field value and executes the provided callback function.
332
+ *
333
+ * @param {Function} callback - The callback function to be executed when the field value changes.
334
+ * @returns {void}
335
+ */
336
+ subscribeValue(callback: (value: unknown) => void): void;
337
+ }
338
+ type IFormField = FormField;
339
+ export { IFormField, FormField };