@bolttech/form-engine-core 0.0.2-beta.5 → 0.0.2-beta.6

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.
@@ -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
- export { TEvents, TMutationEvents, TMutationEnum, TValueChangeEvent, TFieldEvent, };
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, };
@@ -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 = Partial<Record<keyof TSchemaValidation & 'default', string>>;
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 {{ response: unknown }} default - The default response.
780
- * @property {Record<string, { response: unknown }>} [named] - Named responses.
802
+ * @property {TApiResponsePayload} default - The default response.
803
+ * @property {Record<string, TApiResponsePayload>} [named] - Named responses.
781
804
  */
782
805
  type TApiResponse = {
783
- default: {
784
- response: unknown;
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, };