@bolttech/form-engine-core 0.0.2-beta.5 → 0.0.2-beta.7
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/README.md +295 -1457
- package/index.esm.js +198 -54
- package/package.json +1 -1
- package/src/helpers/helpers.d.ts +2 -1
- package/src/managers/field.d.ts +16 -2
- package/src/managers/form.d.ts +21 -2
- package/src/managers/formGroup.d.ts +12 -6
- package/src/types/event.d.ts +31 -1
- package/src/types/schema.d.ts +30 -11
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { TFormValues } from '../types/form';
|
|
2
2
|
import { TMapper } from '../types/mapper';
|
|
3
3
|
import { TFormCore } from './form';
|
|
4
|
+
import { TSchemaFormConfig } from '../types/schema';
|
|
5
|
+
import { TFormGroupOnDataEventPayload, TFormGroupOnValidEventPayload } from '../types/event';
|
|
4
6
|
/**
|
|
5
7
|
* Represents a group that manages multiple forms.
|
|
6
8
|
*/
|
|
7
9
|
declare class FormGroup {
|
|
8
10
|
forms: Map<string, TFormCore>;
|
|
11
|
+
config: Required<TSchemaFormConfig>;
|
|
9
12
|
/**
|
|
10
13
|
* Creates an instance of FormGroup.
|
|
11
14
|
*/
|
|
12
|
-
constructor(
|
|
15
|
+
constructor(entry?: {
|
|
16
|
+
config?: TSchemaFormConfig;
|
|
17
|
+
});
|
|
13
18
|
/**
|
|
14
19
|
* Creates an empty form with given index
|
|
15
20
|
*
|
|
@@ -82,12 +87,13 @@ declare class FormGroup {
|
|
|
82
87
|
submitMultipleFormsByIndex<T>(indexes: string[], callback?: (payload: TFormValues<T>) => void): void;
|
|
83
88
|
onDataSubscription<T>({ ids, callback, }: {
|
|
84
89
|
ids: string[];
|
|
85
|
-
callback: (payload:
|
|
86
|
-
formId: string;
|
|
87
|
-
formField: string;
|
|
88
|
-
values?: TFormValues<T>;
|
|
89
|
-
}>) => void;
|
|
90
|
+
callback: (payload: TFormGroupOnDataEventPayload<T>) => void;
|
|
90
91
|
}): import("rxjs").Subscription;
|
|
92
|
+
onValidSubscription({ ids, callback, }: {
|
|
93
|
+
ids: string[];
|
|
94
|
+
callback: (payload: TFormGroupOnValidEventPayload) => void;
|
|
95
|
+
}): import("rxjs").Subscription;
|
|
96
|
+
destroy: () => void;
|
|
91
97
|
}
|
|
92
98
|
type TFormGroup = FormGroup;
|
|
93
99
|
export { TFormGroup, FormGroup };
|
package/src/types/event.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IFormField } from '../managers';
|
|
2
|
+
import { TFormValues } from './form';
|
|
2
3
|
/**
|
|
3
4
|
* @type TEvents
|
|
4
5
|
* Represents the different types of events that can occur on form fields.
|
|
@@ -41,9 +42,38 @@ declare enum TMutationEnum {
|
|
|
41
42
|
type TValueChangeEvent = (value: unknown, opts?: {
|
|
42
43
|
props: Record<string, unknown>;
|
|
43
44
|
}) => void;
|
|
45
|
+
/**
|
|
46
|
+
* @type TFieldEvent
|
|
47
|
+
* Event emitted on all basic form events, except onData
|
|
48
|
+
*/
|
|
44
49
|
type TFieldEvent = {
|
|
45
50
|
event: TEvents;
|
|
46
51
|
fieldName: string;
|
|
47
52
|
fieldInstance?: IFormField;
|
|
48
53
|
};
|
|
49
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @type TFormValidationPayload
|
|
56
|
+
* Form onValid event emmited payload on callback function parameter
|
|
57
|
+
*/
|
|
58
|
+
type TFormValidationPayload = {
|
|
59
|
+
fieldTrigger: string;
|
|
60
|
+
valid: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @type TFormGroupOnDataEventPayload
|
|
64
|
+
* Form Group onData event emitted payload on callback function parameter
|
|
65
|
+
*/
|
|
66
|
+
type TFormGroupOnDataEventPayload<T> = Record<string, {
|
|
67
|
+
formId: string;
|
|
68
|
+
formField: string;
|
|
69
|
+
values?: TFormValues<T>;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* @type TFormGroupOnValidEventPayload
|
|
73
|
+
* Form Group onValid event emitted payload on callback function parameter
|
|
74
|
+
*/
|
|
75
|
+
type TFormGroupOnValidEventPayload = {
|
|
76
|
+
groupValid: boolean;
|
|
77
|
+
forms: Record<string, boolean>;
|
|
78
|
+
};
|
|
79
|
+
export { TEvents, TMutationEvents, TMutationEnum, TValueChangeEvent, TFieldEvent, TFormGroupOnDataEventPayload, TFormGroupOnValidEventPayload, TFormValidationPayload, };
|
package/src/types/schema.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { TCurrencyCode, TCurrencyLocalCode } from '@gaignoux/currency';
|
|
4
4
|
import { OutgoingHttpHeaders } from 'http2';
|
|
5
5
|
import { TEvents } from './event';
|
|
6
|
+
import { TFormValues } from './form';
|
|
6
7
|
/**
|
|
7
8
|
* @type TLengthValidation
|
|
8
9
|
* Represents the validation rules based on the length of the input.
|
|
@@ -700,6 +701,12 @@ type TApiConfig = {
|
|
|
700
701
|
fallbackValue?: unknown;
|
|
701
702
|
preConditions?: TSchemaValidation;
|
|
702
703
|
blockRequestWhenInvalid?: boolean;
|
|
704
|
+
transform?: {
|
|
705
|
+
callback(callbackPayload: {
|
|
706
|
+
payload: unknown;
|
|
707
|
+
formValues: TFormValues<unknown>;
|
|
708
|
+
}): unknown;
|
|
709
|
+
};
|
|
703
710
|
};
|
|
704
711
|
/**
|
|
705
712
|
* @type TProps
|
|
@@ -735,7 +742,7 @@ type TProps = Record<string, unknown>;
|
|
|
735
742
|
*/
|
|
736
743
|
type TValidations = {
|
|
737
744
|
methods: TSchemaValidation;
|
|
738
|
-
eventMessages?: Partial<Record<TEvents, string[]>>;
|
|
745
|
+
eventMessages?: Partial<Record<TEvents, Partial<keyof TValidationMethods | (string & NonNullable<unknown>)>[]>>;
|
|
739
746
|
messages?: TErrorMessages;
|
|
740
747
|
};
|
|
741
748
|
/**
|
|
@@ -751,7 +758,13 @@ type TValidations = {
|
|
|
751
758
|
* };
|
|
752
759
|
* ```
|
|
753
760
|
*/
|
|
754
|
-
type TErrorMessages =
|
|
761
|
+
type TErrorMessages = {
|
|
762
|
+
[K in keyof TSchemaValidation]?: string;
|
|
763
|
+
} & {
|
|
764
|
+
default?: string;
|
|
765
|
+
} & {
|
|
766
|
+
[key: string]: string;
|
|
767
|
+
};
|
|
755
768
|
/**
|
|
756
769
|
* Represents an event configuration with a specific type.
|
|
757
770
|
*
|
|
@@ -773,19 +786,25 @@ type TApiEvent = {
|
|
|
773
786
|
defaultConfig?: TEvent<TApiConfig>;
|
|
774
787
|
configs?: Record<string, TEvent<TApiConfig>>;
|
|
775
788
|
};
|
|
789
|
+
/**
|
|
790
|
+
* Represents the API response return payload for handling.
|
|
791
|
+
*
|
|
792
|
+
* @property {unknown} response - The default response.
|
|
793
|
+
* @property {number | null} status - response http status number.
|
|
794
|
+
*/
|
|
795
|
+
type TApiResponsePayload = {
|
|
796
|
+
response: unknown;
|
|
797
|
+
status: number | null;
|
|
798
|
+
};
|
|
776
799
|
/**
|
|
777
800
|
* Represents the API response structure.
|
|
778
801
|
*
|
|
779
|
-
* @property {
|
|
780
|
-
* @property {Record<string,
|
|
802
|
+
* @property {TApiResponsePayload} default - The default response.
|
|
803
|
+
* @property {Record<string, TApiResponsePayload>} [named] - Named responses.
|
|
781
804
|
*/
|
|
782
805
|
type TApiResponse = {
|
|
783
|
-
default:
|
|
784
|
-
|
|
785
|
-
};
|
|
786
|
-
named?: Record<string, {
|
|
787
|
-
response: unknown;
|
|
788
|
-
}>;
|
|
806
|
+
default: TApiResponsePayload;
|
|
807
|
+
named?: Record<string, TApiResponsePayload>;
|
|
789
808
|
};
|
|
790
809
|
/**
|
|
791
810
|
* Represents the schema config structure
|
|
@@ -797,4 +816,4 @@ type TSchemaFormConfig = {
|
|
|
797
816
|
defaultAPIdebounceTimeMS?: number;
|
|
798
817
|
defaultStateRefreshTimeMS?: number;
|
|
799
818
|
};
|
|
800
|
-
export { TApiConfig, TErrorMessages, TValidations, TMasks, TProps, TResetValueMethods, TFormatters, TValidationMethods, TGenericValidationRule, TSchemaValidation, TEvent, TVisibility, TApiEvent, TApiResponse, TSchemaFormConfig, TLengthValidation, TCreditCardMatch, TDocumentValidation, TCallbackValidation, TBetweenValidation, TMaskGeneric, TSplitterFormatterValue, TCurrencyMask, TDateOperatorsValidation, TConditionsValidationSet, TConditionsValidation, TMultipleValidation, TAvailableValidations, TDateValidation, TBetweenDatesValidation, TDateFormatsValidation, TDateInterval, };
|
|
819
|
+
export { TApiConfig, TErrorMessages, TValidations, TMasks, TProps, TResetValueMethods, 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, };
|