@bolttech/form-engine-core 1.1.0-beta.0 → 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.
- package/CHANGELOG.md +16 -0
- package/credit-card.d.ts +743 -0
- package/credit-card.esm.js +1 -0
- package/currency.d.ts +131 -0
- package/currency.esm.js +1 -0
- package/date.d.ts +582 -0
- package/date.esm.js +1 -0
- package/document.d.ts +527 -0
- package/document.esm.js +1 -0
- package/index.d.ts +2393 -0
- package/index.esm.js +1 -4435
- package/lite.d.ts +2393 -0
- package/lite.esm.js +1 -0
- package/package.json +41 -10
- package/src/constants/constants.d.ts +2 -1
- package/src/helpers/SafeSubject.d.ts +12 -2
- package/src/helpers/helpers.d.ts +6 -6
- package/src/helpers/lodash-replacements.d.ts +41 -0
- package/src/helpers/validation.d.ts +2 -1
- package/src/index.d.ts +5 -0
- package/src/interfaces/schema.d.ts +28 -1
- package/src/lite.d.ts +30 -0
- package/src/managers/field.d.ts +17 -3
- package/src/managers/form.d.ts +7 -2
- package/src/masks/currency.d.ts +29 -0
- package/src/masks/handler.d.ts +1 -1
- package/src/masks/string.d.ts +0 -62
- package/src/plugins/credit-card.d.ts +4 -0
- package/src/plugins/currency.d.ts +2 -0
- package/src/plugins/date.d.ts +2 -0
- package/src/plugins/document.d.ts +2 -0
- package/src/registry.d.ts +20 -0
- package/src/types/schema.d.ts +42 -23
- package/src/types/utility.d.ts +7 -4
- package/src/validations/custom.d.ts +3 -1
- package/index.esm.d.ts +0 -1
package/src/types/schema.d.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/** @virtual */
|
|
3
2
|
import { TCurrencyCode, TCurrencyLocalCode } from '@gaignoux/currency';
|
|
4
|
-
import { OutgoingHttpHeaders } from 'http2';
|
|
5
3
|
import { TEvents } from './event';
|
|
6
4
|
import { TFormValues } from './form';
|
|
7
5
|
import { ALLOWED_RESET_PROPS_MUTATIONS } from '../constants/constants';
|
|
6
|
+
type TAllowedResetPropsMutations = (typeof ALLOWED_RESET_PROPS_MUTATIONS)[number];
|
|
7
|
+
/**
|
|
8
|
+
* @type TAllowedResetPropsMutationsEnum
|
|
9
|
+
* Represents the allowed properties to be changed on resetPropertyValues.
|
|
10
|
+
*
|
|
11
|
+
* @property {never} api - api property
|
|
12
|
+
* @property {never} apiSchema - apiSchema property
|
|
13
|
+
* @property {never} props - props property
|
|
14
|
+
* @property {never} validations - validations property
|
|
15
|
+
* @property {never} visibilityConditions - visibilityConditions property
|
|
16
|
+
* @property {never} resetValues - resetValues property
|
|
17
|
+
*
|
|
18
|
+
* @interface
|
|
19
|
+
*/
|
|
20
|
+
type TAllowedResetPropsMutationsEnum = Record<TAllowedResetPropsMutations, never>;
|
|
8
21
|
/**
|
|
9
22
|
* @type TLengthValidation
|
|
10
23
|
* Represents the validation rules based on the length of the input.
|
|
@@ -33,7 +46,7 @@ type TLengthValidation = {
|
|
|
33
46
|
* const callbackValidation: TCallbackValidation = (value) => typeof value === 'string';
|
|
34
47
|
* ```
|
|
35
48
|
*/
|
|
36
|
-
type TCallbackValidation = (value: unknown) => boolean;
|
|
49
|
+
type TCallbackValidation = (value: unknown, formValues: Pick<TFormValues<unknown>, 'values' | 'metadata'>) => boolean;
|
|
37
50
|
/**
|
|
38
51
|
* @type TBetweenValidation
|
|
39
52
|
* Represents validation rules that check if a value is between a range.
|
|
@@ -536,19 +549,21 @@ type TSplitterFormatterValue = {
|
|
|
536
549
|
* @property {number} [maxLength] - Truncates the input value to a specified maximum length if necessary.
|
|
537
550
|
*
|
|
538
551
|
* @example
|
|
539
|
-
* ```
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
+
* ```json
|
|
553
|
+
* {
|
|
554
|
+
* formatters: {
|
|
555
|
+
* dotEvery3chars: true,
|
|
556
|
+
* capitalize: true,
|
|
557
|
+
* uppercase: true,
|
|
558
|
+
* onlyNumbers: true,
|
|
559
|
+
* regex: '^[a-zA-Z0-9]+$',
|
|
560
|
+
* gapsCreditCard: [' ', ' '],
|
|
561
|
+
* callback: (value) => value.toString().toUpperCase(),
|
|
562
|
+
* splitter: [{ value: '-', position: 3 }],
|
|
563
|
+
* trim: true,
|
|
564
|
+
* maxLength: 15
|
|
565
|
+
* }
|
|
566
|
+
* }
|
|
552
567
|
* ```
|
|
553
568
|
*/
|
|
554
569
|
type TFormatters = {
|
|
@@ -712,7 +727,8 @@ type TVisibility = {
|
|
|
712
727
|
* const resetValueMethods: TResetValueMethods = {
|
|
713
728
|
* validations: { required: true },
|
|
714
729
|
* fields: ['fieldName'],
|
|
715
|
-
* resettledValue: ['']
|
|
730
|
+
* resettledValue: [''],
|
|
731
|
+
* events: ['ON_FIELD_CHANGE]
|
|
716
732
|
* };
|
|
717
733
|
* ```
|
|
718
734
|
* @interface
|
|
@@ -725,7 +741,7 @@ type TResetValueMethods = Omit<TVisibility, 'showOnlyIfTrue' | 'validations'> &
|
|
|
725
741
|
* @type TResetPathMethods
|
|
726
742
|
* Method to reset some field properties other than component props or field value
|
|
727
743
|
*
|
|
728
|
-
* @property {
|
|
744
|
+
* @property {TAllowedResetPropsMutations} property property to be changed, ex: api, resetValues, etc..
|
|
729
745
|
* @property {string} path path where the property to be changed is located
|
|
730
746
|
* @property {string} field field that will recieve the property change
|
|
731
747
|
* @property {unknown} resettledValue value to be replaced onto the property
|
|
@@ -742,7 +758,7 @@ type TResetValueMethods = Omit<TVisibility, 'showOnlyIfTrue' | 'validations'> &
|
|
|
742
758
|
* ```
|
|
743
759
|
*/
|
|
744
760
|
type TResetPathMethods = {
|
|
745
|
-
property:
|
|
761
|
+
property: TAllowedResetPropsMutations;
|
|
746
762
|
path: string;
|
|
747
763
|
field: string;
|
|
748
764
|
resettledValue: unknown;
|
|
@@ -755,7 +771,7 @@ type TResetPathMethods = {
|
|
|
755
771
|
*
|
|
756
772
|
* @property {'GET' | 'POST'} method - The HTTP method for the request.
|
|
757
773
|
* @property {string} url - The URL for the request.
|
|
758
|
-
* @property {
|
|
774
|
+
* @property {Record<string, string>} [headers] - The headers for the request.
|
|
759
775
|
* @property {Record<string, string>} queryParams - query parameters for request.
|
|
760
776
|
* @property {string} [resultPath] - The path to extract the result from the response.
|
|
761
777
|
* @property {unknown} [fallbackValue] - The fallback value if the request fails.
|
|
@@ -785,7 +801,7 @@ type TApiConfig = {
|
|
|
785
801
|
/** The body payload for the request. */
|
|
786
802
|
body?: Record<string, unknown>;
|
|
787
803
|
/** The headers for the request. */
|
|
788
|
-
headers?:
|
|
804
|
+
headers?: Record<string, string>;
|
|
789
805
|
/** Query parameters for the request. */
|
|
790
806
|
queryParams?: Record<string, string>;
|
|
791
807
|
/** The path to extract the result from the response. */
|
|
@@ -817,7 +833,10 @@ type TProps = Record<string, unknown>;
|
|
|
817
833
|
* @property {Partial<Record<TEvents, string[]>>} eventMessages - The messages to be displayed for specific validation events.
|
|
818
834
|
* @property {TErrorMessages} messages - The general error messages for validation methods.
|
|
819
835
|
*
|
|
836
|
+
* @interface
|
|
837
|
+
*
|
|
820
838
|
* @example
|
|
839
|
+
* ```typescript
|
|
821
840
|
* const validations: TValidations = {
|
|
822
841
|
* methods: {
|
|
823
842
|
* max: 100,
|
|
@@ -835,7 +854,7 @@ type TProps = Record<string, unknown>;
|
|
|
835
854
|
* regex: 'Value does not match the pattern',
|
|
836
855
|
* },
|
|
837
856
|
* };
|
|
838
|
-
*
|
|
857
|
+
* ```
|
|
839
858
|
*/
|
|
840
859
|
type TValidations = {
|
|
841
860
|
methods: TSchemaValidation;
|
|
@@ -979,4 +998,4 @@ type TSchemaFormConfig = {
|
|
|
979
998
|
defaultStateRefreshTimeMS?: number;
|
|
980
999
|
defaultLogVerbose?: boolean;
|
|
981
1000
|
};
|
|
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, };
|
|
1001
|
+
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, TAllowedResetPropsMutationsEnum, };
|
package/src/types/utility.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { TFormValues } from './form';
|
|
1
2
|
import { TValidationMethods } from './schema';
|
|
2
3
|
export type AllowOnly<T, K extends keyof T> = Pick<T, K> & {
|
|
3
4
|
[P in keyof Omit<T, K>]?: never;
|
|
4
5
|
};
|
|
5
6
|
export type OneOf<T, K = keyof T> = K extends keyof T ? AllowOnly<T, K> : never;
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type TValidationPayload = [
|
|
8
|
+
unknown,
|
|
9
|
+
TValidationMethods,
|
|
10
|
+
TFormValues<unknown>?
|
|
11
|
+
];
|
|
12
|
+
export type TValidationHandler = Record<string, (...args: TValidationPayload) => boolean>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { TFormValues } from '../types/form';
|
|
1
2
|
import { TValidationMethods } from '../types/schema';
|
|
2
3
|
/**
|
|
3
4
|
* Executes a custom callback validation function if provided.
|
|
4
5
|
*
|
|
5
6
|
* @param value - The value to be validated.
|
|
6
7
|
* @param validations - An object containing validation methods, including a custom callback function.
|
|
8
|
+
* @param formValues - An object containing the form state, NOTE: validations might be dirty here
|
|
7
9
|
* @returns `true` if the custom callback validation function returns `true`, otherwise `false`.
|
|
8
10
|
*
|
|
9
11
|
* @example
|
|
@@ -22,4 +24,4 @@ import { TValidationMethods } from '../types/schema';
|
|
|
22
24
|
* };
|
|
23
25
|
* ```
|
|
24
26
|
*/
|
|
25
|
-
export declare const callback: (value: unknown, validations: TValidationMethods) => boolean;
|
|
27
|
+
export declare const callback: (value: unknown, validations: TValidationMethods, { values, metadata }?: TFormValues<unknown>) => boolean;
|
package/index.esm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/index";
|