@bolttech/form-engine-core 1.0.2-beta.2 → 1.1.0-beta.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/index.esm.js CHANGED
@@ -404,7 +404,7 @@ const regex$1 = (value, formatters) => {
404
404
  const getTypeCard = (value, availableOptions) => {
405
405
  const rawValue = removeGaps(value === null || value === void 0 ? void 0 : value.toString());
406
406
  const types = creditCardType(rawValue);
407
- const selected = (availableOptions === null || availableOptions === void 0 ? void 0 : availableOptions.length) ? types === null || types === void 0 ? void 0 : types.filter(({
407
+ const selected = typeof availableOptions === 'object' && availableOptions.length ? types === null || types === void 0 ? void 0 : types.filter(({
408
408
  type: id1
409
409
  }) => availableOptions.some(id2 => id2 === id1))[0] : types[0];
410
410
  return [selected, rawValue];
@@ -1641,7 +1641,7 @@ const callback = (value, validations) => {
1641
1641
  */
1642
1642
  const includes = (value, validations) => {
1643
1643
  if (!value || !Array.isArray(validations === null || validations === void 0 ? void 0 : validations.includes)) return false;
1644
- return !validations.includes.some(code => code === value || JSON.stringify(code) === value);
1644
+ return !(validations === null || validations === void 0 ? void 0 : validations.includes.some(code => code === value || JSON.stringify(code) === value));
1645
1645
  };
1646
1646
 
1647
1647
  /**
@@ -2526,7 +2526,6 @@ class FormField {
2526
2526
  this.name = schemaComponent.name;
2527
2527
  this.nameToSubmit = schemaComponent.nameToSubmit;
2528
2528
  this.component = schemaComponent.component;
2529
- this.path = path;
2530
2529
  this.children = children;
2531
2530
  this.validations = cloneDeep(schemaComponent.validations);
2532
2531
  this.visibilityConditions = cloneDeep(schemaComponent.visibilityConditions);
@@ -2784,7 +2783,7 @@ class FormField {
2784
2783
  var _a;
2785
2784
  if (typeof errors === 'undefined' || isEqual(errors, this.errors)) return;
2786
2785
  this._errors = errors;
2787
- this.errorsList = Object.values(this.errors);
2786
+ this.errorsList = Object.values(this.errors).filter(el => el !== undefined && el !== null);
2788
2787
  this.errorsString = this.errorsList.join(', ');
2789
2788
  /**
2790
2789
  * if any error receives a list of errors, set a prop for it, currently only supporting a single string
@@ -3137,7 +3136,7 @@ class FormField {
3137
3136
  this.propsSubject$.unsubscribe();
3138
3137
  this.errorSubject$.unsubscribe();
3139
3138
  this.apiEventQueueSubject$.unsubscribe();
3140
- this.dataSubject$.next({
3139
+ !this.dataSubject$.closed && this.dataSubject$.next({
3141
3140
  event: 'ON_FIELD_UNMOUNT',
3142
3141
  fieldIndex: this.name,
3143
3142
  formIndex: this.formIndex
@@ -3203,6 +3202,8 @@ class FormCore {
3203
3202
  this.queuedFieldResetPropertyEvents = new Map();
3204
3203
  this.queuedInitialValues = new Map();
3205
3204
  this._valid = false;
3205
+ this.stopEventsOnSubmit = false;
3206
+ this.submitted = false;
3206
3207
  this.index = entry.index;
3207
3208
  this.schema = entry.schema;
3208
3209
  this.fields = new Map();
@@ -3233,6 +3234,8 @@ class FormCore {
3233
3234
  this.mountSubject$.subscribe(this.mountActions.bind(this));
3234
3235
  this.initialValues = entry.initialValues || ((_j = entry.schema) === null || _j === void 0 ? void 0 : _j.initialValues);
3235
3236
  this.iVars = entry.iVars || ((_k = entry.schema) === null || _k === void 0 ? void 0 : _k.iVars) || {};
3237
+ this.stopEventsOnSubmit = (entry === null || entry === void 0 ? void 0 : entry.stopEventsOnSubmit) || false;
3238
+ this.submitted = false;
3236
3239
  }
3237
3240
  /**
3238
3241
  * mock function to simulate form mount onto the adapter
@@ -3246,6 +3249,13 @@ class FormCore {
3246
3249
  });
3247
3250
  });
3248
3251
  }
3252
+ /**
3253
+ *flag utility to prevent Subjects from emitting after form submission and stopEventsOnSubmit
3254
+ * @returns {boolean} - result of the flag utility.
3255
+ */
3256
+ submitChecker() {
3257
+ return !(this.stopEventsOnSubmit && this.submitted);
3258
+ }
3249
3259
  /**
3250
3260
  * callback function passed to field instance to notify field adapter mount status
3251
3261
  * once the field has all field instance properties set, this function will handle all
@@ -3704,6 +3714,9 @@ class FormCore {
3704
3714
  });
3705
3715
  }
3706
3716
  } else {
3717
+ fieldInstance.emitEvents({
3718
+ event: 'ON_FIELD_UNMOUNT'
3719
+ });
3707
3720
  if (fieldInstance.persistValue) {
3708
3721
  this.queuedInitialValues.set(fieldInstance.name, fieldInstance.value);
3709
3722
  }
@@ -3970,7 +3983,6 @@ class FormCore {
3970
3983
  });
3971
3984
  } else {
3972
3985
  currField.children = ((_a = structElement === null || structElement === void 0 ? void 0 : structElement.children) === null || _a === void 0 ? void 0 : _a.map(el => el.name)) || (currField === null || currField === void 0 ? void 0 : currField.children) || [];
3973
- currField.path = path;
3974
3986
  currField.originalSchema = structElement;
3975
3987
  currField.templateSubject$ = this.templateSubject$;
3976
3988
  }
@@ -4067,7 +4079,7 @@ class FormCore {
4067
4079
  subscribeFieldEvent({
4068
4080
  callback
4069
4081
  }) {
4070
- const sub = this.fieldEventSubject$.pipe(groupBy(payload => `${payload.event}|${payload.fieldName}`), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS)))).subscribe({
4082
+ const sub = this.fieldEventSubject$.pipe(filter(() => this.submitChecker()), groupBy(payload => `${payload.event}|${payload.fieldName}`), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS)))).subscribe({
4071
4083
  next: callback
4072
4084
  });
4073
4085
  return sub;
@@ -4091,7 +4103,7 @@ class FormCore {
4091
4103
  subscribeData(callback) {
4092
4104
  const sub = this.dataSubject$.pipe(filter(({
4093
4105
  formIndex
4094
- }) => this.index === formIndex), groupBy(payload => payload.event), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS))), map(({
4106
+ }) => this.index === formIndex && this.submitChecker()), groupBy(payload => payload.event), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS))), map(({
4095
4107
  fieldIndex
4096
4108
  }) => ({
4097
4109
  field: fieldIndex,
@@ -4109,7 +4121,7 @@ class FormCore {
4109
4121
  subscribeOnSubmit(callback) {
4110
4122
  const sub = this.submitSubject$.pipe(filter(({
4111
4123
  formIndex
4112
- }) => formIndex === this.index), map(({
4124
+ }) => formIndex === this.index && this.submitChecker()), map(({
4113
4125
  values
4114
4126
  }) => values)).subscribe({
4115
4127
  next: callback
@@ -4124,7 +4136,7 @@ class FormCore {
4124
4136
  subscribeFormValidation(callback) {
4125
4137
  const sub = this.formValidSubject$.pipe(filter(({
4126
4138
  formIndex
4127
- }) => this.index === formIndex), debounceTime(this.config.defaultStateRefreshTimeMS), map(() => ({
4139
+ }) => this.index === formIndex), map(() => ({
4128
4140
  formIndex: this.index,
4129
4141
  valid: this.valid
4130
4142
  })), distinctUntilKeyChanged('valid'), startWith({
@@ -4150,6 +4162,7 @@ class FormCore {
4150
4162
  formIndex: this.index,
4151
4163
  values
4152
4164
  });
4165
+ this.submitted = true;
4153
4166
  }
4154
4167
  /**
4155
4168
  * recycles all the Suscriptions, to be called from the adapter when the form leaves the page
@@ -4339,9 +4352,10 @@ class FormGroup {
4339
4352
  var _a, _b;
4340
4353
  (_a = this.forms.get(index)) === null || _a === void 0 ? void 0 : _a.submit();
4341
4354
  const res = (_b = this.forms.get(index)) === null || _b === void 0 ? void 0 : _b.getFormValues();
4355
+ const formMetadata = typeof (res === null || res === void 0 ? void 0 : res.metadata) === 'object' && res.metadata !== null ? res.metadata : {};
4342
4356
  isValid = isValid && ((res === null || res === void 0 ? void 0 : res.isValid) || false);
4343
4357
  values = Object.assign(Object.assign({}, values), (res === null || res === void 0 ? void 0 : res.values) || {});
4344
- metadata = Object.assign(Object.assign({}, metadata), (res === null || res === void 0 ? void 0 : res.metadata) || {});
4358
+ metadata = Object.assign(Object.assign({}, metadata), formMetadata);
4345
4359
  erroredFields = [...erroredFields, ...((res === null || res === void 0 ? void 0 : res.erroredFields) || [])];
4346
4360
  });
4347
4361
  isValid && callback && callback({
@@ -4384,7 +4398,7 @@ class FormGroup {
4384
4398
  formIndex
4385
4399
  }) => ids.includes(formIndex)), groupBy(({
4386
4400
  formIndex
4387
- }) => formIndex), mergeMap(group$ => group$.pipe(debounceTime(this.config.defaultStateRefreshTimeMS))), startWith({
4401
+ }) => formIndex), mergeMap(group$ => group$.pipe(debounceTime(0))), startWith({
4388
4402
  fieldTrigger: null
4389
4403
  }), map(() => ({
4390
4404
  groupValid: ids.every(id => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolttech/form-engine-core",
3
- "version": "1.0.2-beta.2",
3
+ "version": "1.1.0-beta.0",
4
4
  "module": "./index.esm.js",
5
5
  "type": "module",
6
6
  "main": "./index.esm.js",
@@ -60,7 +60,7 @@ export declare const onlyFloatNumber: (value: unknown, formatters: TFormatters)
60
60
  * console.log(trimmedValue); // Output: 'hello world'
61
61
  * ```
62
62
  */
63
- export declare const trim: (value: unknown, formatters: TFormatters) => unknown;
63
+ export declare const trim: (value: unknown, formatters?: TFormatters) => unknown;
64
64
  /**
65
65
  * Truncates the input value to a specified maximum length if necessary.
66
66
  *
@@ -85,4 +85,4 @@ export declare const trim: (value: unknown, formatters: TFormatters) => unknown;
85
85
  * console.log(result); // "Short" (no truncation since input is shorter than maxLength)
86
86
  * ```
87
87
  */
88
- export declare const maxLength: (value: string | number, formatters: TFormatters) => string | number;
88
+ export declare const maxLength: (value: string | number | null | undefined, formatters: TFormatters) => string | number | null | undefined;
@@ -67,7 +67,7 @@ export type TGetTypeCard = [ICreditCardType, string];
67
67
  * console.log(rawValue); // Output: '4111111111111111'
68
68
  * ```
69
69
  */
70
- export declare const getTypeCard: (value: string, availableOptions?: string[]) => TGetTypeCard;
70
+ export declare const getTypeCard: (value: string, availableOptions?: string[] | boolean) => TGetTypeCard;
71
71
  /**
72
72
  * Formats a credit card number according to its type's gaps and lengths.
73
73
  *
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { TEMPLATE_AVALIABLE_SCOPES } from '../constants/constants';
3
2
  import { TApiResponsePayload } from '../types/schema';
4
- import { TSubscribedTemplates } from '../types/template';
3
+ import { TSubscribedTemplates, TTemplateAvaliableScopes } from '../types/template';
5
4
  import { OutgoingHttpHeaders } from 'http2';
6
5
  /**
7
6
  * Makes an HTTP request using XMLHttpRequest.
@@ -34,7 +33,7 @@ declare function makeRequest(method: string, url: string, headers?: OutgoingHttp
34
33
  * ```
35
34
  */
36
35
  declare function extractFieldKeys(expression: string): {
37
- originScopeKeys: (typeof TEMPLATE_AVALIABLE_SCOPES)[number][];
36
+ originScopeKeys: TTemplateAvaliableScopes[];
38
37
  originFieldKeys: string[];
39
38
  originPropertyKeys: string[];
40
39
  };
@@ -44,7 +44,12 @@ import { TApiEvent, TFormatters, TMasks, TProps, TResetPathMethods, TResetValueM
44
44
  * },
45
45
  * visibilityConditions: [{ conditions: { field: 'age', value: 18 } }],
46
46
  * resetValues: [{ field: 'age', resetTo: '' }],
47
- * api: { defaultConfig: { config: { method: 'POST', url: 'https://api.example.com/submit' }, events: [{ eventName: 'ON_FORM_SUBMIT' }] } },
47
+ * api: {
48
+ * defaultConfig: {
49
+ * config: { method: 'POST', url: 'https://api.example.com/submit' },
50
+ * events: [{ eventName: 'ON_FIELD_BLUR' }]
51
+ * }
52
+ * },
48
53
  * formatters: { capitalize: true },
49
54
  * masks: { currency: { align: 'left', decimal: '.', precision: 2, prefix: '$', thousands: ',' } },
50
55
  * children: [],
@@ -54,24 +59,37 @@ import { TApiEvent, TFormatters, TMasks, TProps, TResetPathMethods, TResetValueM
54
59
  * ```
55
60
  */
56
61
  interface IComponentSchema {
62
+ /** The type of component (e.g., 'input', 'button'). */
57
63
  component: string;
64
+ /** The properties of the component. */
58
65
  props?: TProps;
66
+ /** The name of the component. */
59
67
  name: string;
68
+ /** The name of the field when submit values. */
60
69
  nameToSubmit?: string;
70
+ /** The validation methods for the component. */
61
71
  validations?: TValidations;
72
+ /** The API configuration for the component. */
62
73
  api?: TApiEvent;
74
+ /** The visibility conditions for the component. */
63
75
  visibilityConditions?: TVisibility[];
76
+ /** The reset value methods for the component. */
64
77
  resetValues?: TResetValueMethods[];
78
+ /** The reset property values for the component. */
65
79
  resetPropertyValues?: TResetPathMethods[];
80
+ /** The formatters for the component. */
66
81
  formatters?: TFormatters;
82
+ /** The masks for the component. */
67
83
  masks?: TMasks;
84
+ /** The child components. */
68
85
  children?: IComponentSchema[];
86
+ /** Visibility status the component will mount (to avoid SSR blinking) */
69
87
  visibility?: boolean;
88
+ /** Check this if you want the last visible value to be restored after a visiblity schema rule applied */
70
89
  persistValue?: boolean;
71
90
  }
72
91
  interface IComponentSchemaAsFormField<T> extends IComponentSchema {
73
92
  mapper?: TMapper<T>;
74
- order?: number;
75
93
  children?: IComponentSchemaAsFormField<T>[];
76
94
  }
77
95
  /**
@@ -79,20 +97,23 @@ interface IComponentSchemaAsFormField<T> extends IComponentSchema {
79
97
  * Represents the schema for a form.
80
98
  *
81
99
  * @property {string} index - The unique index or identifier for the form.
82
- * @property {string} [action] - The URL to which the form data will be submitted.
83
- * @property {string} [method] - The HTTP method used to submit the form (e.g., 'POST', 'GET').
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).
84
102
  * @property {Record<string, unknown>} [initialValues] - The initial values for the form fields.
85
103
  * @property {Record<string, unknown>} [iVars] - Dynamic key value pairs that change from any external source
86
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
87
107
  *
88
108
  * @example
89
109
  * ```typescript
90
110
  * const formSchema: IFormSchema = {
91
111
  * index: 'userForm',
92
- * action: 'https://api.example.com/submit',
93
- * method: 'POST',
94
112
  * initialValues: { name: '', email: '' },
95
113
  * iVars: iVarsState,
114
+ * config: {
115
+ * defaultLogVerbose: true
116
+ * },
96
117
  * components: [
97
118
  * { component: 'input', name: 'name', props: { placeholder: 'Enter your name' } },
98
119
  * { component: 'input', name: 'email', props: { placeholder: 'Enter your email' } }
@@ -108,5 +129,6 @@ interface IFormSchema {
108
129
  initialValues?: Record<string, unknown>;
109
130
  iVars?: Record<string, unknown>;
110
131
  components?: IComponentSchema[];
132
+ stopEventsOnSubmit?: boolean;
111
133
  }
112
134
  export { IFormSchema, IComponentSchema, IComponentSchemaAsFormField };
@@ -15,7 +15,6 @@ declare class FormField {
15
15
  name: string;
16
16
  nameToSubmit?: string;
17
17
  component: string;
18
- path?: string;
19
18
  children?: string[];
20
19
  originalSchema: IComponentSchemaAsFormField<unknown>;
21
20
  validations?: TValidations;
@@ -2,11 +2,10 @@ import { IFormField } from './field';
2
2
  import { Subject, Subscription } from 'rxjs';
3
3
  import { IComponentSchema, IComponentSchemaAsFormField, IFormSchema } from '../interfaces/schema';
4
4
  import { TSchemaFormConfig } from '../types/schema';
5
- import { TSubscribedTemplates, TTemplateEvent } from '../types/template';
5
+ import { TSubscribedTemplates, TTemplateAvaliableScopes, TTemplateEvent } from '../types/template';
6
6
  import { TEvents, TFieldEvent, TFieldValidationPayload, TFormDataPayload, TFormSubmitPayload, TFormValidationPayload, TMutationEvents } from '../types/event';
7
7
  import { TFormEntry, TFormValues } from '../types/form';
8
8
  import { TMapper } from '../types/mapper';
9
- import { TEMPLATE_AVALIABLE_SCOPES } from '../constants/constants';
10
9
  /**
11
10
  * Represents the core logic for managing a form, including field management, validation, and submission.
12
11
  */
@@ -45,6 +44,8 @@ declare class FormCore {
45
44
  }>;
46
45
  queuedInitialValues: Map<string, unknown>;
47
46
  _valid: boolean;
47
+ stopEventsOnSubmit: boolean;
48
+ submitted: boolean;
48
49
  /**
49
50
  * Creates an instance of FormCore.
50
51
  *
@@ -61,6 +62,11 @@ declare class FormCore {
61
62
  * mock function to simulate form mount onto the adapter
62
63
  */
63
64
  generateFields(): void;
65
+ /**
66
+ *flag utility to prevent Subjects from emitting after form submission and stopEventsOnSubmit
67
+ * @returns {boolean} - result of the flag utility.
68
+ */
69
+ private submitChecker;
64
70
  /**
65
71
  * callback function passed to field instance to notify field adapter mount status
66
72
  * once the field has all field instance properties set, this function will handle all
@@ -112,7 +118,7 @@ declare class FormCore {
112
118
  * @returns {unknown | undefined} The value of the property, or undefined if the field doesn't exist.
113
119
  */
114
120
  getValue({ scope, key, property, path, }: {
115
- scope: (typeof TEMPLATE_AVALIABLE_SCOPES)[number];
121
+ scope: TTemplateAvaliableScopes;
116
122
  key: string;
117
123
  property: string;
118
124
  path: string[];
@@ -35,5 +35,5 @@ import { TMasks } from '../types/schema';
35
35
  * console.log(maskedValue); // Output: 'ab***gh###'
36
36
  * ```
37
37
  */
38
- declare const _default: (value: string, masks: TMasks) => string;
38
+ declare const _default: (value: string, masks: TMasks | null) => string;
39
39
  export default _default;
@@ -1,2 +1,2 @@
1
1
  import { TMasks } from '../types/schema';
2
- export declare const masks: Record<keyof TMasks, (value: unknown, masks?: TMasks) => unknown>;
2
+ export declare const masks: Record<keyof TMasks, (value: unknown, masks?: TMasks | null) => unknown>;
@@ -1,15 +1,81 @@
1
1
  import { IFormField } from '../managers';
2
2
  import { TFormValues } from './form';
3
3
  /**
4
- * @type TEvents
4
+ * @type TEventEnum
5
5
  * Represents the different types of events that can occur on form fields.
6
+ * @property {never} ON_FIELD_MOUNT - when field mounts on page
7
+ * @property {never} ON_FIELD_UNMOUNT - when field unmounts on page (also triggered when form is unmounted from page)
8
+ * @property {never} ON_FIELD_CHANGE - when field changes value by user inout
9
+ * @property {never} ON_FIELD_BLUR - when field is blurred
10
+ * @property {never} ON_FIELD_FOCUS - when field is focused
11
+ * @property {never} ON_FIELD_CLICK - when field is clicked
12
+ * @property {never} ON_FIELD_KEYUP - when the pressing key button on field is lifted up
13
+ * @property {never} ON_FIELD_KEYDOWN - when a key button on field is pressed down
14
+ * @property {never} ON_FIELD_CLEARED - when a field was changed with a resetValues rule
15
+ * @property {never} ON_FORM_SUBMIT - when the form is submitted (only type="submit" buttons)
16
+ * @property {never} ON_FIELD_VALIDATION - when a field is validaded by a validation rule
17
+ * @property {never} ON_FORM_MOUNT - emitted when the form mounts
18
+ * @property {never} ON_API_FIELD_REQUEST - emitted when an api request from schema is called
19
+ * @property {never} ON_API_FIELD_RESPONSE - emitted when an api response from schema is received
6
20
  *
7
21
  * @example
8
22
  * ```typescript
9
23
  * const event: TEvents = 'ON_FIELD_CHANGE';
10
24
  * ```
11
25
  */
12
- type TEvents = 'ON_FIELD_MOUNT' | 'ON_FIELD_UNMOUNT' | 'ON_FIELD_CHANGE' | 'ON_FIELD_BLUR' | 'ON_FIELD_FOCUS' | 'ON_FIELD_CLICK' | 'ON_FIELD_KEYUP' | 'ON_FIELD_KEYDOWN' | 'ON_FIELD_CLEARED' | 'ON_FORM_SUBMIT' | 'ON_FIELD_VALIDATION' | 'ON_FORM_MOUNT' | 'ON_API_FIELD_REQUEST' | 'ON_API_FIELD_RESPONSE';
26
+ type TEventEnum = {
27
+ ON_FIELD_MOUNT: never;
28
+ ON_FIELD_UNMOUNT: never;
29
+ ON_FIELD_CHANGE: never;
30
+ ON_FIELD_BLUR: never;
31
+ ON_FIELD_FOCUS: never;
32
+ ON_FIELD_CLICK: never;
33
+ ON_FIELD_KEYUP: never;
34
+ ON_FIELD_KEYDOWN: never;
35
+ ON_FIELD_CLEARED: never;
36
+ ON_FORM_SUBMIT: never;
37
+ ON_FIELD_VALIDATION: never;
38
+ ON_FORM_MOUNT: never;
39
+ ON_API_FIELD_REQUEST: never;
40
+ ON_API_FIELD_RESPONSE: never;
41
+ };
42
+ type TEvents = keyof TEventEnum;
43
+ /**
44
+ * Represents the possible event properties for form fields callbacks.
45
+ * * Represents a mapping of event properties to their corresponding callback functions.
46
+ * @property {string} onChange - trigger bind component change event
47
+ * @property {string} onBlur - trigger bind component blur event
48
+ * @property {string} onFocus - trigger bind component focus event
49
+ * @property {string} onKeyDown - trigger bind component keydown event
50
+ * @property {string} onKeyUp - trigger bind component keyup event
51
+ * @property {string} onMount - triggered on field mount
52
+ * @property {string} onApiResponse - triggered when schema api call is completed
53
+ * @property {string} onApiRequest - triggered when schema api call starts
54
+ * @property {string} onClick - trigger bind component keyup event
55
+ * @property {string} onCleared - triggered when a resetValue rule apply on the target field
56
+ * @property {string} onUnmount - triggered when a field unmounts
57
+ */
58
+ type TEventPropsEnum = {
59
+ onChange: never;
60
+ onBlur: never;
61
+ onFocus: never;
62
+ onKeyDown: never;
63
+ onKeyUp: never;
64
+ onMount: never;
65
+ onApiResponse: never;
66
+ onApiRequest: never;
67
+ onClick: never;
68
+ onCleared: never;
69
+ onUnmount: never;
70
+ };
71
+ type TEventProps = keyof TEventPropsEnum;
72
+ type TEventDataPropsEnum = {
73
+ onFormMount: never;
74
+ onData: never;
75
+ onSubmit: never;
76
+ onValid: never;
77
+ };
78
+ type TEventDataProps = keyof TEventDataPropsEnum;
13
79
  /**
14
80
  * @type TMutationEvents
15
81
  * Represents the different types of events that can occur internally that triggers templating.
@@ -106,4 +172,4 @@ type TFormGroupOnValidEventPayload = {
106
172
  * Form Group onSubmit event emitted payload on callback function parameter
107
173
  */
108
174
  type TFormGroupOnSubmitEventPayload<T> = Record<string, TFormValues<T> | undefined>;
109
- export { TEvents, TMutationEvents, TMutationEnum, TValueChangeEvent, TFieldEvent, TFormDataPayload, TFormDataValues, TFormSubmitPayload, TFormGroupOnDataEventPayload, TFormGroupOnValidEventPayload, TFormGroupOnSubmitEventPayload, TFormValidationPayload, TFieldValidationPayload, };
175
+ export { TEvents, TEventEnum, TEventProps, TEventPropsEnum, TEventDataProps, TEventDataPropsEnum, TMutationEvents, TMutationEnum, TValueChangeEvent, TFieldEvent, TFormDataPayload, TFormDataValues, TFormSubmitPayload, TFormGroupOnDataEventPayload, TFormGroupOnValidEventPayload, TFormGroupOnSubmitEventPayload, TFormValidationPayload, TFieldValidationPayload, };
@@ -1,18 +1,13 @@
1
- import { TValueChangeEvent } from './event';
1
+ import { TEventDataPropsEnum, TEventPropsEnum, TValueChangeEvent } from './event';
2
2
  import { OneOf } from './utility';
3
+ type TComponentPropsMappingSubset = keyof (Pick<TEventPropsEnum, 'onBlur' | 'onChange' | 'onFocus' | 'onKeyDown' | 'onKeyUp' | 'onClick'> & Pick<TEventDataPropsEnum, 'onSubmit'>);
3
4
  /**
4
5
  * @type TComponentPropsMapping
5
6
  * Represents the mapping of component properties for various events and actions.
6
- *
7
- * @property {string} [getValue] - Function to get the value.
8
- * @property {string} [setValue] - Function to set the value.
9
- * @property {string} [onBlur] - Function to handle the blur event.
10
- * @property {string} [onClick] - Function to handle the click event.
11
- * @property {string} [onFocus] - Function to handle the focus event.
12
- * @property {string} [onKeyUp] - Function to handle the keyup event.
13
- * @property {string} [onKeyDown] - Function to handle the keydown event.
14
- * @property {string} [setErrorMessage] - Function to set the error message.
15
- * @property {string} [setErrorState] - Function to set the error state.
7
+ * @property {string} [getValue] - component function name to get the value.
8
+ * @property {string} [setValue] - component function name to set the value.
9
+ * @property {string} [setErrorMessage] - component function name to set the error message.
10
+ * @property {string} [setErrorState] - component function name to set the error state.
16
11
  *
17
12
  * @example
18
13
  * ```typescript
@@ -28,16 +23,11 @@ import { OneOf } from './utility';
28
23
  * setErrorState: 'setErrorStateFunction'
29
24
  * };
30
25
  * ```
26
+ * @interface
31
27
  */
32
- type TComponentPropsMapping = {
28
+ type TComponentPropsMapping = Partial<Record<TComponentPropsMappingSubset, string>> & {
33
29
  getValue?: string;
34
30
  setValue?: string;
35
- onBlur?: string;
36
- onClick?: string;
37
- onSubmit?: string;
38
- onFocus?: string;
39
- onKeyUp?: string;
40
- onKeyDown?: string;
41
31
  setErrorMessage?: string;
42
32
  setErrorState?: string;
43
33
  };
@@ -46,14 +36,15 @@ type TComponentPropsMapping = {
46
36
  * Represents the mapping of a component, including the component type,
47
37
  * name, events, and an optional function to handle value changes.
48
38
  *
49
- * @property {ElementType} component - The type of the component.
39
+ * @property {ElementType} component - The component that will represent the input.
40
+ * * @property {ElementType} asynccomponent - The component that will represent the input but dynamically imported (suspense/lazy).
50
41
  * @property {string} componentName - The name of the component.
51
42
  * @property {TComponentPropsMapping} [events] - Mapping event properties for the component.
52
43
  * @property {TValueChangeEvent} [valueChangeEvent] - Optional function to handle value changes.
53
44
  *
54
45
  * @example
55
46
  * ```typescript
56
- * const mappers: TMapper[] = [
47
+ * const mappers: TMapper<ElementType>[] = [
57
48
  * {
58
49
  * component: InputElement,
59
50
  * componentName: 'input',
@@ -83,6 +74,7 @@ type TComponentPropsMapping = {
83
74
  * },
84
75
  * ];
85
76
  * ```
77
+ * @interface
86
78
  */
87
79
  type TMapper<T> = {
88
80
  componentName: string;
@@ -118,7 +118,7 @@ type TDateOperatorsValidation = '<' | '>' | '===' | '>=' | '<=' | '!==' | '!!ori
118
118
  type TConditionsValidationSet = {
119
119
  forceDefinedOrigin?: boolean;
120
120
  forceDefinedTarget?: boolean;
121
- origin?: string | number | boolean;
121
+ origin?: string | number | boolean | null;
122
122
  condition: TDateOperatorsValidation;
123
123
  target?: string | number | boolean;
124
124
  };
@@ -398,36 +398,67 @@ type TDateValidation = {
398
398
  * ```
399
399
  */
400
400
  type TValidationMethods = {
401
+ /** Maximum value or length. */
401
402
  max?: number;
403
+ /** Minimum value or length. */
402
404
  min?: number;
405
+ /** Minimum value or length. */
403
406
  lessThan?: number;
407
+ /** Minimum value or length. */
404
408
  greaterThan?: number;
409
+ /** Length validation rule. */
405
410
  length?: TLengthValidation;
411
+ /** Indicates if the field is required. */
406
412
  required?: boolean;
413
+ /** Specific value to match. */
407
414
  value?: unknown;
415
+ /** Regular expression for validation. */
408
416
  regex?: string;
417
+ /** Indicates if the value should be a valid email. */
409
418
  email?: boolean;
419
+ /** Indicates if the value should be a valid URL. */
410
420
  url?: boolean;
421
+ /** Indicates if the value should contain only letters. */
411
422
  onlyLetters?: boolean;
423
+ /** Indicates if spaces are not allowed. */
412
424
  notAllowSpaces?: boolean;
425
+ /** Custom validation callback function. */
413
426
  callback?: TCallbackValidation;
427
+ /** Indicates if the value should be a number. */
414
428
  isNumber?: boolean;
429
+ /** Indicates if the value should be a boolean or a string that can be converted to a boolean. */
415
430
  bool?: boolean | string;
431
+ /** Indicates if the value should exist or match a specific existence condition. */
416
432
  exists?: boolean | string;
433
+ /** Indicates if there should be no extra spaces. */
417
434
  hasNoExtraSpaces?: boolean;
435
+ /** Indicates if the field should not be empty. */
418
436
  notEmpty?: boolean;
437
+ /** Validation rule for range between two values. */
419
438
  between?: TBetweenValidation;
439
+ /** Indicates if the value should be sequential. */
420
440
  sequential?: boolean;
441
+ /** Indicates if the value should not be repeated. */
421
442
  repeated?: boolean;
443
+ /** Array of values that should be included. */
422
444
  includes?: (string | number)[];
445
+ /** Array of valid credit card numbers. */
423
446
  isCreditCard?: string[];
447
+ /** Validation rule for credit card matching. */
424
448
  isCreditCodeMatch?: TCreditCardMatch;
449
+ /** Array of valid credit card numbers with length check. */
425
450
  isCreditCardAndLength?: string[];
451
+ /** Document validation rule. */
426
452
  document?: TDocumentValidation;
453
+ /** Conditional validation rules. */
427
454
  conditions?: TConditionsValidation;
455
+ /** Multiple validation rules combined with a logical rule. */
428
456
  multipleValidations?: TMultipleValidation;
457
+ /** Validation rule for checking if a date falls between two dates. */
429
458
  betweenDates?: TBetweenDatesValidation;
459
+ /** Validation rule for date values. */
430
460
  date?: TDateValidation;
461
+ /** Validation rule for valid date formats. */
431
462
  validDate?: TDateFormatsValidation;
432
463
  };
433
464
  /**
@@ -446,9 +477,7 @@ type TValidationMethods = {
446
477
  * },
447
478
  * };
448
479
  */
449
- type TGenericValidationRule = {
450
- [key: string]: TValidationMethods;
451
- };
480
+ type TGenericValidationRule = Record<string, TValidationMethods>;
452
481
  /**
453
482
  * @type {TValidationMethods | TGenericValidationRule} TSchemaValidation
454
483
  * Represents the schema validation which can be either a set of validation methods or a generic validation rule.
@@ -469,6 +498,7 @@ type TGenericValidationRule = {
469
498
  * minLength: 8,
470
499
  * },
471
500
  * };
501
+ * @interface
472
502
  */
473
503
  type TSchemaValidation = TValidationMethods | TGenericValidationRule;
474
504
  /**
@@ -522,17 +552,26 @@ type TSplitterFormatterValue = {
522
552
  * ```
523
553
  */
524
554
  type TFormatters = {
555
+ /** Add a dot every 3 characters. */
525
556
  dotEvery3chars?: boolean;
557
+ /** Capitalize the value. */
526
558
  capitalize?: boolean;
559
+ /** Convert the value to uppercase. */
527
560
  uppercase?: boolean;
561
+ /** Allow only numbers. */
528
562
  onlyNumbers?: boolean;
563
+ /** Allow only letters. */
529
564
  onlyLetters?: boolean;
565
+ /** Allow only float numbers with specific precision and decimal. */
530
566
  onlyFloatNumber?: Pick<TCurrencyMask, 'precision' | 'decimal'>;
567
+ /** Regular expression for formatting. */
531
568
  regex?: string;
532
- gapsCreditCard?: string[];
533
- callback?: (value: unknown) => unknown;
569
+ gapsCreditCard?: string[] | boolean;
570
+ callback?: ((value: unknown) => unknown) | null;
534
571
  splitter?: TSplitterFormatterValue[];
572
+ /** Removes whitespace from both ends of this string and returns a new string, without modifying the original string. */
535
573
  trim?: boolean;
574
+ /** Truncates the input value to a specified maximum length if necessary. */
536
575
  maxLength?: number;
537
576
  };
538
577
  /**
@@ -612,15 +651,24 @@ type TMaskGeneric = {
612
651
  * ```
613
652
  */
614
653
  type TMasks = {
654
+ /** Mask for currency values. */
615
655
  currency?: TCurrencyMask;
656
+ /** Array of generic masks. */
616
657
  generic?: TMaskGeneric[];
617
- custom?: string;
658
+ /** Custom mask pattern. */
659
+ custom?: string | null;
660
+ /** Mask for securing credit card values. */
618
661
  secureCreditCard?: boolean;
662
+ /** Mask for card values. */
619
663
  card?: boolean;
664
+ /** Mask for card date values. */
620
665
  cardDate?: boolean;
666
+ /** Mask for FEIN (Federal Employer Identification Number). */
621
667
  fein?: boolean;
668
+ /** Value to replace all matches. */
622
669
  replaceAll?: string | number;
623
- callback?(value: unknown): string;
670
+ /** Custom mask callback function. */
671
+ callback?: (value: unknown) => string;
624
672
  };
625
673
  /**
626
674
  * @type TVisibility
@@ -645,13 +693,19 @@ type TVisibility = {
645
693
  showOnlyIfTrue?: boolean;
646
694
  validations: TSchemaValidation;
647
695
  fields: string[] | string;
648
- events: Partial<TEvents>[];
696
+ events: TEvents[];
649
697
  };
650
698
  /**
651
699
  * @type TResetValueMethods
652
- * Extends TVisibility with methods to reset values.
700
+ * @extends TVisibility with methods to reset values.
701
+ * @summary schema method to reset values from event
702
+ * much cool such wow
703
+ *
704
+ * @property {unknown[] | unknown} resettledValue - The values to reset.
705
+ * @property {Partial<TEvents>[]} events - events that will react to the value reset
706
+ * @property {string | string[]} fields - fields that will react to the value reset
707
+ * @property {TSchemaValidation} validations - validations to trigger the property reset
653
708
  *
654
- * @property {string[] | string} resettledValue - The values to reset.
655
709
  *
656
710
  * @example
657
711
  * ```typescript
@@ -661,11 +715,32 @@ type TVisibility = {
661
715
  * resettledValue: ['']
662
716
  * };
663
717
  * ```
718
+ * @interface
664
719
  */
665
720
  type TResetValueMethods = Omit<TVisibility, 'showOnlyIfTrue' | 'validations'> & {
666
721
  resettledValue: unknown[] | unknown;
667
722
  validations?: TSchemaValidation;
668
723
  };
724
+ /**
725
+ * @type TResetPathMethods
726
+ * Method to reset some field properties other than component props or field value
727
+ *
728
+ * @property {(typeof ALLOWED_RESET_PROPS_MUTATIONS)[number]} property property to be changed, ex: api, resetValues, etc..
729
+ * @property {string} path path where the property to be changed is located
730
+ * @property {string} field field that will recieve the property change
731
+ * @property {unknown} resettledValue value to be replaced onto the property
732
+ * @property {TSchemaValidation} validations validations rules to be validated to change the property value
733
+ * @property {Partial<TEvents>[]} events events to listen to apply this change
734
+ *
735
+ * @example
736
+ * ```typescript
737
+ * const resetValueMethods: TResetValueMethods = {
738
+ * validations: { required: true },
739
+ * fields: ['fieldName'],
740
+ * resettledValue: ['']
741
+ * };
742
+ * ```
743
+ */
669
744
  type TResetPathMethods = {
670
745
  property: (typeof ALLOWED_RESET_PROPS_MUTATIONS)[number];
671
746
  path: string;
@@ -703,15 +778,25 @@ type TResetPathMethods = {
703
778
  * ```
704
779
  */
705
780
  type TApiConfig = {
781
+ /** The HTTP method for the request. */
706
782
  method: 'GET' | 'POST';
783
+ /** The URL for the request. */
707
784
  url: string;
785
+ /** The body payload for the request. */
708
786
  body?: Record<string, unknown>;
787
+ /** The headers for the request. */
709
788
  headers?: OutgoingHttpHeaders;
789
+ /** Query parameters for the request. */
710
790
  queryParams?: Record<string, string>;
791
+ /** The path to extract the result from the response. */
711
792
  resultPath?: string;
793
+ /** The fallback value if the request fails. */
712
794
  fallbackValue?: unknown;
795
+ /** Validation conditions to execute the API call. */
713
796
  preConditions?: TSchemaValidation;
797
+ /** Blocks request when field validation fails. */
714
798
  blockRequestWhenInvalid?: boolean;
799
+ /** Custom transform callback for the request payload. */
715
800
  transform?: {
716
801
  callback(callbackPayload: {
717
802
  payload: unknown;
@@ -750,15 +835,45 @@ type TProps = Record<string, unknown>;
750
835
  * regex: 'Value does not match the pattern',
751
836
  * },
752
837
  * };
838
+ * @interface
753
839
  */
754
840
  type TValidations = {
755
841
  methods: TSchemaValidation;
756
- eventMessages?: Partial<Record<TEvents, Partial<keyof TValidationMethods | (string & NonNullable<unknown>)>[]>>;
842
+ eventMessages?: TEventMessages;
757
843
  messages?: TErrorMessages;
758
844
  };
845
+ /**
846
+ * @type TValidations
847
+ * Represents the validation configuration for form fields, including methods, event-specific messages, and error messages.
848
+ *
849
+ * @property {TSchemaValidation} methods - The validation methods to be applied.
850
+ * @property {Partial<Record<TEvents, string[]>>} eventMessages - The messages to be displayed for specific validation events.
851
+ * @property {TErrorMessages} messages - The general error messages for validation methods.
852
+ *
853
+ * @example
854
+ * ```typescript
855
+ * const eventMessages: {
856
+ * ON_FIELD_MOUNT: ['required'],
857
+ * ON_FIELD_CHANGE: ['regex', 'required'],
858
+ * ON_FIELD_BLUR: ['max', 'required'],
859
+ * },
860
+ * ```
861
+ * @interface
862
+ */
863
+ type TEventMessages = Partial<Record<TEvents, TEventMessagesValidationMethods[]>>;
864
+ /**
865
+ * @type TEventMessagesValidationMethods
866
+ *
867
+ * allowed validation methods to trigger the event messages desc
868
+ *
869
+ * @property {keyof TValidationMethods | TAnyKey;} TEventMessagesValidationMethods - allowed validation methods to trigger the event messages
870
+ */
871
+ type TEventMessagesValidationMethods = keyof TValidationMethods | TAnyKey;
872
+ type TAnyKey = string & NonNullable<unknown>;
759
873
  /**
760
874
  * @type TErrorMessages
761
875
  * Represents the error messages for different validation methods.
876
+ * @property {string} default - the message to display regardless the validation
762
877
  *
763
878
  * @example
764
879
  * ```typescript
@@ -768,14 +883,9 @@ type TValidations = {
768
883
  * default: 'Default error message'
769
884
  * };
770
885
  * ```
886
+ * @interface
771
887
  */
772
- type TErrorMessages = {
773
- [K in keyof TSchemaValidation]?: string;
774
- } & {
775
- default?: string;
776
- } & {
777
- [key: string]: string;
778
- };
888
+ type TErrorMessages = Partial<Record<keyof TSchemaValidation | 'default' | (string & NonNullable<unknown>), string>>;
779
889
  /**
780
890
  * Represents an event configuration with a specific type.
781
891
  *
@@ -785,13 +895,49 @@ type TErrorMessages = {
785
895
  */
786
896
  type TEvent<T> = {
787
897
  config: T;
788
- events: Partial<TEvents>[];
898
+ events: TEvents[];
789
899
  };
790
900
  /**
791
901
  * Represents the API event configurations.
792
902
  *
793
903
  * @property {TEvent<TApiConfig>} [defaultConfig] - The default event configuration.
794
904
  * @property {Record<string, TEvent<TApiConfig>>} [configs] - Named event configurations.
905
+ *
906
+ * @example
907
+ * ```typescript
908
+ * const apiEvent: TApiEvent = {
909
+ * defaultConfig: {
910
+ * config: {
911
+ * method: 'POST',
912
+ * url: 'https://api.example.com/data',
913
+ * headers: { 'Content-Type': 'application/json' },
914
+ * resultPath: 'data.results',
915
+ * fallbackValue: [],
916
+ * preConditions: {
917
+ * required: true,
918
+ * },
919
+ * blockRequestWhenInvalid: true,
920
+ * },
921
+ * events: ['ON_FIELD_MOUNT', 'ON_FIELD_CHANGE'],
922
+ * },
923
+ * configs: {
924
+ * example_config_name: {
925
+ * config: {
926
+ * method: 'POST',
927
+ * url: 'https://api.example.com/data',
928
+ * headers: { 'Content-Type': 'application/json' },
929
+ * resultPath: 'data.results',
930
+ * fallbackValue: [],
931
+ * preConditions: {
932
+ * required: true,
933
+ * },
934
+ * blockRequestWhenInvalid: true,
935
+ * },
936
+ * events: ['ON_FIELD_MOUNT', 'ON_FIELD_CHANGE'],
937
+ * },
938
+ * },
939
+ * };
940
+ * ```
795
941
  */
796
942
  type TApiEvent = {
797
943
  defaultConfig?: TEvent<TApiConfig>;
@@ -825,6 +971,7 @@ type TApiResponse = {
825
971
  * Represents the schema config structure
826
972
  *
827
973
  * @property {number} defaultAPIdebounceTimeMS - default API debounce time between request events.
974
+ * @property {boolean} defaultLogVerbose - flag to turn warning log messages on client.
828
975
  * @property {number} [defaultStateRefreshTimeMS] - default state refresh between events side effects.
829
976
  */
830
977
  type TSchemaFormConfig = {
@@ -832,4 +979,4 @@ type TSchemaFormConfig = {
832
979
  defaultStateRefreshTimeMS?: number;
833
980
  defaultLogVerbose?: boolean;
834
981
  };
835
- export { TApiConfig, TErrorMessages, TValidations, TMasks, TProps, TResetValueMethods, TResetPathMethods, TFormatters, TValidationMethods, TGenericValidationRule, TSchemaValidation, TEvent, TVisibility, TApiEvent, TApiResponsePayload, TApiResponse, TSchemaFormConfig, TLengthValidation, TCreditCardMatch, TDocumentValidation, TCallbackValidation, TBetweenValidation, TMaskGeneric, TSplitterFormatterValue, TCurrencyMask, TDateOperatorsValidation, TConditionsValidationSet, TConditionsValidation, TMultipleValidation, TAvailableValidations, TDateValidation, TBetweenDatesValidation, TDateFormatsValidation, TDateInterval, };
982
+ export { TApiConfig, TErrorMessages, TValidations, TMasks, TProps, TResetValueMethods, TResetPathMethods, TFormatters, TValidationMethods, TGenericValidationRule, TSchemaValidation, TEvent, TVisibility, TApiEvent, TApiResponsePayload, TApiResponse, TSchemaFormConfig, TLengthValidation, TCreditCardMatch, TDocumentValidation, TCallbackValidation, TBetweenValidation, TMaskGeneric, TSplitterFormatterValue, TCurrencyMask, TDateOperatorsValidation, TConditionsValidationSet, TConditionsValidation, TMultipleValidation, TAvailableValidations, TDateValidation, TBetweenDatesValidation, TDateFormatsValidation, TDateInterval, TEventMessages, TEventMessagesValidationMethods, };
@@ -1,11 +1,26 @@
1
- import { TEMPLATE_AVALIABLE_SCOPES } from '../constants/constants';
2
1
  import { TMutationEvents } from './event';
2
+ import { TEMPLATE_AVALIABLE_SCOPES } from '../constants/constants';
3
+ type TTemplateAvaliableScopes = (typeof TEMPLATE_AVALIABLE_SCOPES)[number];
4
+ /**
5
+ * @type TTemplateAvaliableScopesEnum
6
+ * Represents the different types of events that can occur on form fields.
7
+ * @property {never} fields - scope related to field content ex: '${fields.fieldName.value}'
8
+ * @property {never} iVars - scope related to iVars content ex: '${iVars.test}'
9
+ * @property {never} form - scope related to form content ex: '${form.valid}'
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const scope: TTemplateAvaliableScopesEnum = 'fields';
14
+ * ```
15
+ * @interface
16
+ */
17
+ type TTemplateAvaliableScopesEnum = Record<TTemplateAvaliableScopes, never>;
3
18
  /**
4
19
  * @type TSubscribedTemplates
5
20
  * Represents the subscribed templates for dynamic updates.
6
21
  *
7
22
  * @property {string} originExpression - The expression to evaluate.
8
- * @property {(typeof TEMPLATE_AVALIABLE_SCOPES)[number][]} originScopeKeys - Origin scope of the updated template value
23
+ * @property {TTemplateAvaliableScopes[]} originScopeKeys - Origin scope of the updated template value
9
24
  * @property {string[]} originPropertyKeys - The properties of the origin fields.
10
25
  * @property {string[]} originFieldKeys - The keys of the origin fields.
11
26
  * @property {string} destinationKey - The key of the destination field.
@@ -27,7 +42,7 @@ import { TMutationEvents } from './event';
27
42
  */
28
43
  type TSubscribedTemplates = {
29
44
  originExpression: string;
30
- originScopeKeys: (typeof TEMPLATE_AVALIABLE_SCOPES)[number][];
45
+ originScopeKeys: TTemplateAvaliableScopes[];
31
46
  originPropertyKeys: string[];
32
47
  originFieldKeys: string[];
33
48
  destinationKey: string;
@@ -38,13 +53,13 @@ type TSubscribedTemplates = {
38
53
  * @type TTemplateEvent
39
54
  * Represents the event occuring on templates that changes property values.
40
55
  *
41
- * @property {(typeof TEMPLATE_AVALIABLE_SCOPES)[number]} scope - template scope triggering the event.
56
+ * @property {TTemplateAvaliableScopes} scope - template scope triggering the event.
42
57
  * @property {string} key - field triggering the template refresh
43
58
  * @property {TMutationEvents} event - template event triggering the template refresh.
44
59
  */
45
60
  type TTemplateEvent = {
46
- scope: (typeof TEMPLATE_AVALIABLE_SCOPES)[number];
61
+ scope: TTemplateAvaliableScopes;
47
62
  key?: string;
48
63
  event: TMutationEvents;
49
64
  };
50
- export { TSubscribedTemplates, TTemplateEvent };
65
+ export { TSubscribedTemplates, TTemplateEvent, TTemplateAvaliableScopes, TTemplateAvaliableScopesEnum };
@@ -4,3 +4,6 @@ export type AllowOnly<T, K extends keyof T> = Pick<T, K> & {
4
4
  };
5
5
  export type OneOf<T, K = keyof T> = K extends keyof T ? AllowOnly<T, K> : never;
6
6
  export type TValidationHandler = Record<string, (value: unknown, validations: TValidationMethods) => boolean>;
7
+ export type Prettify<T> = {
8
+ [K in keyof T]: T[K];
9
+ } & {};
@@ -56,7 +56,7 @@ export declare const betweenDates: (value: string, validations: TValidationMetho
56
56
  * console.log(result2); // true (date is outside the range)
57
57
  * ```
58
58
  */
59
- export declare const date: (value: string, validations: TValidationMethods) => boolean;
59
+ export declare const date: (value: string | null, validations: TValidationMethods) => boolean;
60
60
  /**
61
61
  * @function validDate
62
62
  * Validates that a date string is a valid date according to the given format.
@@ -29,4 +29,4 @@ import { TValidationMethods } from '../types/schema';
29
29
  * console.log(isValid); // Output: true or false based on validation
30
30
  * ```
31
31
  */
32
- export declare const includes: (value: unknown, validations: TValidationMethods) => boolean;
32
+ export declare const includes: (value: unknown, validations?: TValidationMethods | null) => boolean;
@@ -46,7 +46,7 @@ export declare const required: (value: unknown, validations: TValidationMethods)
46
46
  * console.log(result2); // false
47
47
  * ```
48
48
  */
49
- export declare const bool: (_: unknown, validations: TValidationMethods) => boolean;
49
+ export declare const bool: (_: unknown, validations: TValidationMethods | null) => boolean;
50
50
  /**
51
51
  * Validates that a value exists. Useful with iVars property.
52
52
  *
@@ -50,4 +50,4 @@ export declare const notEmpty: (value: unknown, validations: TValidationMethods)
50
50
  * console.log(result3); // false
51
51
  * ```
52
52
  */
53
- export declare const value: (value: unknown, validations: TValidationMethods) => boolean;
53
+ export declare const value: (value: unknown, validations?: TValidationMethods) => boolean;