@bolttech/form-engine-core 1.0.1-beta.2 → 1.0.1
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 +140 -85
- package/package.json +9 -9
- package/src/constants/constants.d.ts +2 -1
- package/src/formatters/string.d.ts +2 -2
- package/src/helpers/creditCard.d.ts +1 -1
- package/src/helpers/helpers.d.ts +2 -4
- package/src/index.d.ts +1 -0
- package/src/interfaces/schema.d.ts +28 -6
- package/src/managers/field.d.ts +0 -1
- package/src/managers/form.d.ts +9 -3
- package/src/managers/formGroup.d.ts +4 -2
- package/src/masks/generic.d.ts +1 -1
- package/src/masks/handler.d.ts +1 -1
- package/src/masks/string.d.ts +2 -0
- package/src/types/event.d.ts +75 -8
- package/src/types/mapper.d.ts +12 -20
- package/src/types/schema.d.ts +204 -37
- package/src/types/template.d.ts +21 -6
- package/src/validations/date.d.ts +1 -1
- package/src/validations/list.d.ts +1 -1
- package/src/validations/logical.d.ts +1 -1
- package/src/validations/string.d.ts +1 -1
- /package/{index.esm.d.ts → index.d.ts} +0 -0
package/src/types/schema.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/** @virtual */
|
|
3
2
|
import { TCurrencyCode, TCurrencyLocalCode } from '@gaignoux/currency';
|
|
4
3
|
import { OutgoingHttpHeaders } from 'http2';
|
|
5
4
|
import { TEvents } from './event';
|
|
6
5
|
import { TFormValues } from './form';
|
|
7
6
|
import { ALLOWED_RESET_PROPS_MUTATIONS } from '../constants/constants';
|
|
7
|
+
type TAllowedResetPropsMutations = (typeof ALLOWED_RESET_PROPS_MUTATIONS)[number];
|
|
8
|
+
/**
|
|
9
|
+
* @type TAllowedResetPropsMutationsEnum
|
|
10
|
+
* Represents the allowed properties to be changed on resetPropertyValues.
|
|
11
|
+
*
|
|
12
|
+
* @property {never} api - api property
|
|
13
|
+
* @property {never} apiSchema - apiSchema property
|
|
14
|
+
* @property {never} props - props property
|
|
15
|
+
* @property {never} validations - validations property
|
|
16
|
+
* @property {never} visibilityConditions - visibilityConditions property
|
|
17
|
+
* @property {never} resetValues - resetValues property
|
|
18
|
+
*
|
|
19
|
+
* @interface
|
|
20
|
+
*/
|
|
21
|
+
type TAllowedResetPropsMutationsEnum = Record<TAllowedResetPropsMutations, never>;
|
|
8
22
|
/**
|
|
9
23
|
* @type TLengthValidation
|
|
10
24
|
* Represents the validation rules based on the length of the input.
|
|
@@ -118,7 +132,7 @@ type TDateOperatorsValidation = '<' | '>' | '===' | '>=' | '<=' | '!==' | '!!ori
|
|
|
118
132
|
type TConditionsValidationSet = {
|
|
119
133
|
forceDefinedOrigin?: boolean;
|
|
120
134
|
forceDefinedTarget?: boolean;
|
|
121
|
-
origin?: string | number | boolean;
|
|
135
|
+
origin?: string | number | boolean | null;
|
|
122
136
|
condition: TDateOperatorsValidation;
|
|
123
137
|
target?: string | number | boolean;
|
|
124
138
|
};
|
|
@@ -398,36 +412,67 @@ type TDateValidation = {
|
|
|
398
412
|
* ```
|
|
399
413
|
*/
|
|
400
414
|
type TValidationMethods = {
|
|
415
|
+
/** Maximum value or length. */
|
|
401
416
|
max?: number;
|
|
417
|
+
/** Minimum value or length. */
|
|
402
418
|
min?: number;
|
|
419
|
+
/** Minimum value or length. */
|
|
403
420
|
lessThan?: number;
|
|
421
|
+
/** Minimum value or length. */
|
|
404
422
|
greaterThan?: number;
|
|
423
|
+
/** Length validation rule. */
|
|
405
424
|
length?: TLengthValidation;
|
|
425
|
+
/** Indicates if the field is required. */
|
|
406
426
|
required?: boolean;
|
|
427
|
+
/** Specific value to match. */
|
|
407
428
|
value?: unknown;
|
|
429
|
+
/** Regular expression for validation. */
|
|
408
430
|
regex?: string;
|
|
431
|
+
/** Indicates if the value should be a valid email. */
|
|
409
432
|
email?: boolean;
|
|
433
|
+
/** Indicates if the value should be a valid URL. */
|
|
410
434
|
url?: boolean;
|
|
435
|
+
/** Indicates if the value should contain only letters. */
|
|
411
436
|
onlyLetters?: boolean;
|
|
437
|
+
/** Indicates if spaces are not allowed. */
|
|
412
438
|
notAllowSpaces?: boolean;
|
|
439
|
+
/** Custom validation callback function. */
|
|
413
440
|
callback?: TCallbackValidation;
|
|
441
|
+
/** Indicates if the value should be a number. */
|
|
414
442
|
isNumber?: boolean;
|
|
443
|
+
/** Indicates if the value should be a boolean or a string that can be converted to a boolean. */
|
|
415
444
|
bool?: boolean | string;
|
|
445
|
+
/** Indicates if the value should exist or match a specific existence condition. */
|
|
416
446
|
exists?: boolean | string;
|
|
447
|
+
/** Indicates if there should be no extra spaces. */
|
|
417
448
|
hasNoExtraSpaces?: boolean;
|
|
449
|
+
/** Indicates if the field should not be empty. */
|
|
418
450
|
notEmpty?: boolean;
|
|
451
|
+
/** Validation rule for range between two values. */
|
|
419
452
|
between?: TBetweenValidation;
|
|
453
|
+
/** Indicates if the value should be sequential. */
|
|
420
454
|
sequential?: boolean;
|
|
455
|
+
/** Indicates if the value should not be repeated. */
|
|
421
456
|
repeated?: boolean;
|
|
457
|
+
/** Array of values that should be included. */
|
|
422
458
|
includes?: (string | number)[];
|
|
459
|
+
/** Array of valid credit card numbers. */
|
|
423
460
|
isCreditCard?: string[];
|
|
461
|
+
/** Validation rule for credit card matching. */
|
|
424
462
|
isCreditCodeMatch?: TCreditCardMatch;
|
|
463
|
+
/** Array of valid credit card numbers with length check. */
|
|
425
464
|
isCreditCardAndLength?: string[];
|
|
465
|
+
/** Document validation rule. */
|
|
426
466
|
document?: TDocumentValidation;
|
|
467
|
+
/** Conditional validation rules. */
|
|
427
468
|
conditions?: TConditionsValidation;
|
|
469
|
+
/** Multiple validation rules combined with a logical rule. */
|
|
428
470
|
multipleValidations?: TMultipleValidation;
|
|
471
|
+
/** Validation rule for checking if a date falls between two dates. */
|
|
429
472
|
betweenDates?: TBetweenDatesValidation;
|
|
473
|
+
/** Validation rule for date values. */
|
|
430
474
|
date?: TDateValidation;
|
|
475
|
+
/** Validation rule for valid date formats. */
|
|
431
476
|
validDate?: TDateFormatsValidation;
|
|
432
477
|
};
|
|
433
478
|
/**
|
|
@@ -446,9 +491,7 @@ type TValidationMethods = {
|
|
|
446
491
|
* },
|
|
447
492
|
* };
|
|
448
493
|
*/
|
|
449
|
-
type TGenericValidationRule =
|
|
450
|
-
[key: string]: TValidationMethods;
|
|
451
|
-
};
|
|
494
|
+
type TGenericValidationRule = Record<string, TValidationMethods>;
|
|
452
495
|
/**
|
|
453
496
|
* @type {TValidationMethods | TGenericValidationRule} TSchemaValidation
|
|
454
497
|
* Represents the schema validation which can be either a set of validation methods or a generic validation rule.
|
|
@@ -469,6 +512,7 @@ type TGenericValidationRule = {
|
|
|
469
512
|
* minLength: 8,
|
|
470
513
|
* },
|
|
471
514
|
* };
|
|
515
|
+
* @interface
|
|
472
516
|
*/
|
|
473
517
|
type TSchemaValidation = TValidationMethods | TGenericValidationRule;
|
|
474
518
|
/**
|
|
@@ -506,33 +550,44 @@ type TSplitterFormatterValue = {
|
|
|
506
550
|
* @property {number} [maxLength] - Truncates the input value to a specified maximum length if necessary.
|
|
507
551
|
*
|
|
508
552
|
* @example
|
|
509
|
-
* ```
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
553
|
+
* ```json
|
|
554
|
+
* {
|
|
555
|
+
* formatters: {
|
|
556
|
+
* dotEvery3chars: true,
|
|
557
|
+
* capitalize: true,
|
|
558
|
+
* uppercase: true,
|
|
559
|
+
* onlyNumbers: true,
|
|
560
|
+
* regex: '^[a-zA-Z0-9]+$',
|
|
561
|
+
* gapsCreditCard: [' ', ' '],
|
|
562
|
+
* callback: (value) => value.toString().toUpperCase(),
|
|
563
|
+
* splitter: [{ value: '-', position: 3 }],
|
|
564
|
+
* trim: true,
|
|
565
|
+
* maxLength: 15
|
|
566
|
+
* }
|
|
567
|
+
* }
|
|
522
568
|
* ```
|
|
523
569
|
*/
|
|
524
570
|
type TFormatters = {
|
|
571
|
+
/** Add a dot every 3 characters. */
|
|
525
572
|
dotEvery3chars?: boolean;
|
|
573
|
+
/** Capitalize the value. */
|
|
526
574
|
capitalize?: boolean;
|
|
575
|
+
/** Convert the value to uppercase. */
|
|
527
576
|
uppercase?: boolean;
|
|
577
|
+
/** Allow only numbers. */
|
|
528
578
|
onlyNumbers?: boolean;
|
|
579
|
+
/** Allow only letters. */
|
|
529
580
|
onlyLetters?: boolean;
|
|
581
|
+
/** Allow only float numbers with specific precision and decimal. */
|
|
530
582
|
onlyFloatNumber?: Pick<TCurrencyMask, 'precision' | 'decimal'>;
|
|
583
|
+
/** Regular expression for formatting. */
|
|
531
584
|
regex?: string;
|
|
532
|
-
gapsCreditCard?: string[];
|
|
533
|
-
callback?: (value: unknown) => unknown;
|
|
585
|
+
gapsCreditCard?: string[] | boolean;
|
|
586
|
+
callback?: ((value: unknown) => unknown) | null;
|
|
534
587
|
splitter?: TSplitterFormatterValue[];
|
|
588
|
+
/** Removes whitespace from both ends of this string and returns a new string, without modifying the original string. */
|
|
535
589
|
trim?: boolean;
|
|
590
|
+
/** Truncates the input value to a specified maximum length if necessary. */
|
|
536
591
|
maxLength?: number;
|
|
537
592
|
};
|
|
538
593
|
/**
|
|
@@ -612,15 +667,24 @@ type TMaskGeneric = {
|
|
|
612
667
|
* ```
|
|
613
668
|
*/
|
|
614
669
|
type TMasks = {
|
|
670
|
+
/** Mask for currency values. */
|
|
615
671
|
currency?: TCurrencyMask;
|
|
672
|
+
/** Array of generic masks. */
|
|
616
673
|
generic?: TMaskGeneric[];
|
|
617
|
-
|
|
674
|
+
/** Custom mask pattern. */
|
|
675
|
+
custom?: string | null;
|
|
676
|
+
/** Mask for securing credit card values. */
|
|
618
677
|
secureCreditCard?: boolean;
|
|
678
|
+
/** Mask for card values. */
|
|
619
679
|
card?: boolean;
|
|
680
|
+
/** Mask for card date values. */
|
|
620
681
|
cardDate?: boolean;
|
|
682
|
+
/** Mask for FEIN (Federal Employer Identification Number). */
|
|
621
683
|
fein?: boolean;
|
|
684
|
+
/** Value to replace all matches. */
|
|
622
685
|
replaceAll?: string | number;
|
|
623
|
-
callback
|
|
686
|
+
/** Custom mask callback function. */
|
|
687
|
+
callback?: (value: unknown) => string;
|
|
624
688
|
};
|
|
625
689
|
/**
|
|
626
690
|
* @type TVisibility
|
|
@@ -645,29 +709,57 @@ type TVisibility = {
|
|
|
645
709
|
showOnlyIfTrue?: boolean;
|
|
646
710
|
validations: TSchemaValidation;
|
|
647
711
|
fields: string[] | string;
|
|
648
|
-
events:
|
|
712
|
+
events: TEvents[];
|
|
649
713
|
};
|
|
650
714
|
/**
|
|
651
715
|
* @type TResetValueMethods
|
|
652
|
-
*
|
|
716
|
+
* @extends TVisibility with methods to reset values.
|
|
717
|
+
* @summary schema method to reset values from event
|
|
718
|
+
* much cool such wow
|
|
719
|
+
*
|
|
720
|
+
* @property {unknown[] | unknown} resettledValue - The values to reset.
|
|
721
|
+
* @property {Partial<TEvents>[]} events - events that will react to the value reset
|
|
722
|
+
* @property {string | string[]} fields - fields that will react to the value reset
|
|
723
|
+
* @property {TSchemaValidation} validations - validations to trigger the property reset
|
|
653
724
|
*
|
|
654
|
-
* @property {string[] | string} resettledValue - The values to reset.
|
|
655
725
|
*
|
|
656
726
|
* @example
|
|
657
727
|
* ```typescript
|
|
658
728
|
* const resetValueMethods: TResetValueMethods = {
|
|
659
729
|
* validations: { required: true },
|
|
660
730
|
* fields: ['fieldName'],
|
|
661
|
-
* resettledValue: ['']
|
|
731
|
+
* resettledValue: [''],
|
|
732
|
+
* events: ['ON_FIELD_CHANGE]
|
|
662
733
|
* };
|
|
663
734
|
* ```
|
|
735
|
+
* @interface
|
|
664
736
|
*/
|
|
665
737
|
type TResetValueMethods = Omit<TVisibility, 'showOnlyIfTrue' | 'validations'> & {
|
|
666
738
|
resettledValue: unknown[] | unknown;
|
|
667
739
|
validations?: TSchemaValidation;
|
|
668
740
|
};
|
|
741
|
+
/**
|
|
742
|
+
* @type TResetPathMethods
|
|
743
|
+
* Method to reset some field properties other than component props or field value
|
|
744
|
+
*
|
|
745
|
+
* @property {TAllowedResetPropsMutations} property property to be changed, ex: api, resetValues, etc..
|
|
746
|
+
* @property {string} path path where the property to be changed is located
|
|
747
|
+
* @property {string} field field that will recieve the property change
|
|
748
|
+
* @property {unknown} resettledValue value to be replaced onto the property
|
|
749
|
+
* @property {TSchemaValidation} validations validations rules to be validated to change the property value
|
|
750
|
+
* @property {Partial<TEvents>[]} events events to listen to apply this change
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* ```typescript
|
|
754
|
+
* const resetValueMethods: TResetValueMethods = {
|
|
755
|
+
* validations: { required: true },
|
|
756
|
+
* fields: ['fieldName'],
|
|
757
|
+
* resettledValue: ['']
|
|
758
|
+
* };
|
|
759
|
+
* ```
|
|
760
|
+
*/
|
|
669
761
|
type TResetPathMethods = {
|
|
670
|
-
property:
|
|
762
|
+
property: TAllowedResetPropsMutations;
|
|
671
763
|
path: string;
|
|
672
764
|
field: string;
|
|
673
765
|
resettledValue: unknown;
|
|
@@ -703,15 +795,25 @@ type TResetPathMethods = {
|
|
|
703
795
|
* ```
|
|
704
796
|
*/
|
|
705
797
|
type TApiConfig = {
|
|
798
|
+
/** The HTTP method for the request. */
|
|
706
799
|
method: 'GET' | 'POST';
|
|
800
|
+
/** The URL for the request. */
|
|
707
801
|
url: string;
|
|
802
|
+
/** The body payload for the request. */
|
|
708
803
|
body?: Record<string, unknown>;
|
|
804
|
+
/** The headers for the request. */
|
|
709
805
|
headers?: OutgoingHttpHeaders;
|
|
806
|
+
/** Query parameters for the request. */
|
|
710
807
|
queryParams?: Record<string, string>;
|
|
808
|
+
/** The path to extract the result from the response. */
|
|
711
809
|
resultPath?: string;
|
|
810
|
+
/** The fallback value if the request fails. */
|
|
712
811
|
fallbackValue?: unknown;
|
|
812
|
+
/** Validation conditions to execute the API call. */
|
|
713
813
|
preConditions?: TSchemaValidation;
|
|
814
|
+
/** Blocks request when field validation fails. */
|
|
714
815
|
blockRequestWhenInvalid?: boolean;
|
|
816
|
+
/** Custom transform callback for the request payload. */
|
|
715
817
|
transform?: {
|
|
716
818
|
callback(callbackPayload: {
|
|
717
819
|
payload: unknown;
|
|
@@ -732,7 +834,10 @@ type TProps = Record<string, unknown>;
|
|
|
732
834
|
* @property {Partial<Record<TEvents, string[]>>} eventMessages - The messages to be displayed for specific validation events.
|
|
733
835
|
* @property {TErrorMessages} messages - The general error messages for validation methods.
|
|
734
836
|
*
|
|
837
|
+
* @interface
|
|
838
|
+
*
|
|
735
839
|
* @example
|
|
840
|
+
* ```typescript
|
|
736
841
|
* const validations: TValidations = {
|
|
737
842
|
* methods: {
|
|
738
843
|
* max: 100,
|
|
@@ -750,15 +855,45 @@ type TProps = Record<string, unknown>;
|
|
|
750
855
|
* regex: 'Value does not match the pattern',
|
|
751
856
|
* },
|
|
752
857
|
* };
|
|
858
|
+
* ```
|
|
753
859
|
*/
|
|
754
860
|
type TValidations = {
|
|
755
861
|
methods: TSchemaValidation;
|
|
756
|
-
eventMessages?:
|
|
862
|
+
eventMessages?: TEventMessages;
|
|
757
863
|
messages?: TErrorMessages;
|
|
758
864
|
};
|
|
865
|
+
/**
|
|
866
|
+
* @type TValidations
|
|
867
|
+
* Represents the validation configuration for form fields, including methods, event-specific messages, and error messages.
|
|
868
|
+
*
|
|
869
|
+
* @property {TSchemaValidation} methods - The validation methods to be applied.
|
|
870
|
+
* @property {Partial<Record<TEvents, string[]>>} eventMessages - The messages to be displayed for specific validation events.
|
|
871
|
+
* @property {TErrorMessages} messages - The general error messages for validation methods.
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* ```typescript
|
|
875
|
+
* const eventMessages: {
|
|
876
|
+
* ON_FIELD_MOUNT: ['required'],
|
|
877
|
+
* ON_FIELD_CHANGE: ['regex', 'required'],
|
|
878
|
+
* ON_FIELD_BLUR: ['max', 'required'],
|
|
879
|
+
* },
|
|
880
|
+
* ```
|
|
881
|
+
* @interface
|
|
882
|
+
*/
|
|
883
|
+
type TEventMessages = Partial<Record<TEvents, TEventMessagesValidationMethods[]>>;
|
|
884
|
+
/**
|
|
885
|
+
* @type TEventMessagesValidationMethods
|
|
886
|
+
*
|
|
887
|
+
* allowed validation methods to trigger the event messages desc
|
|
888
|
+
*
|
|
889
|
+
* @property {keyof TValidationMethods | TAnyKey;} TEventMessagesValidationMethods - allowed validation methods to trigger the event messages
|
|
890
|
+
*/
|
|
891
|
+
type TEventMessagesValidationMethods = keyof TValidationMethods | TAnyKey;
|
|
892
|
+
type TAnyKey = string & NonNullable<unknown>;
|
|
759
893
|
/**
|
|
760
894
|
* @type TErrorMessages
|
|
761
895
|
* Represents the error messages for different validation methods.
|
|
896
|
+
* @property {string} default - the message to display regardless the validation
|
|
762
897
|
*
|
|
763
898
|
* @example
|
|
764
899
|
* ```typescript
|
|
@@ -768,14 +903,9 @@ type TValidations = {
|
|
|
768
903
|
* default: 'Default error message'
|
|
769
904
|
* };
|
|
770
905
|
* ```
|
|
906
|
+
* @interface
|
|
771
907
|
*/
|
|
772
|
-
type TErrorMessages =
|
|
773
|
-
[K in keyof TSchemaValidation]?: string;
|
|
774
|
-
} & {
|
|
775
|
-
default?: string;
|
|
776
|
-
} & {
|
|
777
|
-
[key: string]: string;
|
|
778
|
-
};
|
|
908
|
+
type TErrorMessages = Partial<Record<keyof TSchemaValidation | 'default' | (string & NonNullable<unknown>), string>>;
|
|
779
909
|
/**
|
|
780
910
|
* Represents an event configuration with a specific type.
|
|
781
911
|
*
|
|
@@ -785,13 +915,49 @@ type TErrorMessages = {
|
|
|
785
915
|
*/
|
|
786
916
|
type TEvent<T> = {
|
|
787
917
|
config: T;
|
|
788
|
-
events:
|
|
918
|
+
events: TEvents[];
|
|
789
919
|
};
|
|
790
920
|
/**
|
|
791
921
|
* Represents the API event configurations.
|
|
792
922
|
*
|
|
793
923
|
* @property {TEvent<TApiConfig>} [defaultConfig] - The default event configuration.
|
|
794
924
|
* @property {Record<string, TEvent<TApiConfig>>} [configs] - Named event configurations.
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```typescript
|
|
928
|
+
* const apiEvent: TApiEvent = {
|
|
929
|
+
* defaultConfig: {
|
|
930
|
+
* config: {
|
|
931
|
+
* method: 'POST',
|
|
932
|
+
* url: 'https://api.example.com/data',
|
|
933
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
934
|
+
* resultPath: 'data.results',
|
|
935
|
+
* fallbackValue: [],
|
|
936
|
+
* preConditions: {
|
|
937
|
+
* required: true,
|
|
938
|
+
* },
|
|
939
|
+
* blockRequestWhenInvalid: true,
|
|
940
|
+
* },
|
|
941
|
+
* events: ['ON_FIELD_MOUNT', 'ON_FIELD_CHANGE'],
|
|
942
|
+
* },
|
|
943
|
+
* configs: {
|
|
944
|
+
* example_config_name: {
|
|
945
|
+
* config: {
|
|
946
|
+
* method: 'POST',
|
|
947
|
+
* url: 'https://api.example.com/data',
|
|
948
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
949
|
+
* resultPath: 'data.results',
|
|
950
|
+
* fallbackValue: [],
|
|
951
|
+
* preConditions: {
|
|
952
|
+
* required: true,
|
|
953
|
+
* },
|
|
954
|
+
* blockRequestWhenInvalid: true,
|
|
955
|
+
* },
|
|
956
|
+
* events: ['ON_FIELD_MOUNT', 'ON_FIELD_CHANGE'],
|
|
957
|
+
* },
|
|
958
|
+
* },
|
|
959
|
+
* };
|
|
960
|
+
* ```
|
|
795
961
|
*/
|
|
796
962
|
type TApiEvent = {
|
|
797
963
|
defaultConfig?: TEvent<TApiConfig>;
|
|
@@ -825,6 +991,7 @@ type TApiResponse = {
|
|
|
825
991
|
* Represents the schema config structure
|
|
826
992
|
*
|
|
827
993
|
* @property {number} defaultAPIdebounceTimeMS - default API debounce time between request events.
|
|
994
|
+
* @property {boolean} defaultLogVerbose - flag to turn warning log messages on client.
|
|
828
995
|
* @property {number} [defaultStateRefreshTimeMS] - default state refresh between events side effects.
|
|
829
996
|
*/
|
|
830
997
|
type TSchemaFormConfig = {
|
|
@@ -832,4 +999,4 @@ type TSchemaFormConfig = {
|
|
|
832
999
|
defaultStateRefreshTimeMS?: number;
|
|
833
1000
|
defaultLogVerbose?: boolean;
|
|
834
1001
|
};
|
|
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, };
|
|
1002
|
+
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/template.d.ts
CHANGED
|
@@ -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 {
|
|
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:
|
|
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 {
|
|
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:
|
|
61
|
+
scope: TTemplateAvaliableScopes;
|
|
47
62
|
key?: string;
|
|
48
63
|
event: TMutationEvents;
|
|
49
64
|
};
|
|
50
|
-
export { TSubscribedTemplates, TTemplateEvent };
|
|
65
|
+
export { TSubscribedTemplates, TTemplateEvent, TTemplateAvaliableScopes, TTemplateAvaliableScopesEnum };
|
|
@@ -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
|
|
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
|
|
53
|
+
export declare const value: (value: unknown, validations?: TValidationMethods) => boolean;
|
|
File without changes
|