bpm-core 0.0.112 → 0.0.113
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/fesm2022/bpm-core.mjs +202 -133
- package/fesm2022/bpm-core.mjs.map +1 -1
- package/lib/components/shared-components/form-field/shared-imports.d.ts +3 -3
- package/lib/functions/index.d.ts +1 -1
- package/lib/functions/validators.d.ts +59 -0
- package/package.json +1 -1
- package/public-api.d.ts +0 -1
- package/lib/classes/form-validation.d.ts +0 -19
- package/lib/classes/index.d.ts +0 -1
- package/lib/functions/is-valid-data.d.ts +0 -1
|
@@ -9,7 +9,7 @@ import { EnOnlyDirective } from "../../../directives/en.directive";
|
|
|
9
9
|
import { ArOnlyDirective } from "../../../directives/ar.directive";
|
|
10
10
|
import { NgClass } from "@angular/common";
|
|
11
11
|
import { TranslatePipe } from "../../../pipes/translate.pipe";
|
|
12
|
-
export declare const MatDatePickerImports: (typeof
|
|
13
|
-
export declare const MatFormImports: (typeof
|
|
14
|
-
export declare const Shareds: (typeof
|
|
12
|
+
export declare const MatDatePickerImports: (typeof MatDatepickerInput | typeof MatDatepickerToggle | typeof MatDatepickerModule)[];
|
|
13
|
+
export declare const MatFormImports: (typeof MatInput | typeof MatFormFieldModule | typeof MatFormField)[];
|
|
14
|
+
export declare const Shareds: (typeof NgClass | typeof ReactiveFormsModule | typeof TranslatePipe | typeof FormLabelComponent | typeof ValidationErrorsComponent | typeof InfoItemComponent)[];
|
|
15
15
|
export declare const TextLanguageDirectives: (typeof EnOnlyDirective | typeof ArOnlyDirective)[];
|
package/lib/functions/index.d.ts
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AbstractControl, FormArray, FormGroup, ValidationErrors, ValidatorFn } from "@angular/forms";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the form group is valid for a specific action.
|
|
4
|
+
* You should use this function to check form validity if you use `validateIfAction` function.
|
|
5
|
+
* @param action The action to check against.
|
|
6
|
+
* @param formGroup The form group or form array to validate.
|
|
7
|
+
* @returns {boolean} True if all controls are valid for the action, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidForAction(action: string, formGroup: FormGroup | FormArray): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Updates the value and validity of all controls.
|
|
12
|
+
* Use this function when your validators depend on the values of other controls.
|
|
13
|
+
* @param formGroup The FormGroup or FormArray to update.
|
|
14
|
+
* @returns {void}
|
|
15
|
+
*/
|
|
16
|
+
export declare function updateValueAndValidity(formGroup: FormGroup | FormArray): void;
|
|
17
|
+
/**
|
|
18
|
+
* Validates a control only when a certain condition is met.
|
|
19
|
+
* @param condition A function that returns a boolean indicating whether to apply the validator.
|
|
20
|
+
* @param validator A single ValidatorFn or an array of ValidatorFns to apply if the condition is true.
|
|
21
|
+
* @returns {ValidatorFn} A ValidatorFn that applies the given validator only when the condition is true.
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateOnlyWhen(condition: () => boolean, validator: ValidatorFn | ValidatorFn[]): ValidatorFn;
|
|
24
|
+
/**
|
|
25
|
+
* Validates a control if the current action is one of the specified actions.
|
|
26
|
+
* @param actions An array of action names to check against.
|
|
27
|
+
* @param validator A single ValidatorFn or an array of ValidatorFns to apply if the current action matches one of the actions.
|
|
28
|
+
* @returns {ValidatorFn} A ValidatorFn that applies the given validator only if the current action is one of the specified actions.
|
|
29
|
+
* */
|
|
30
|
+
export declare function validateIfAction(actions: string[], validator: ValidatorFn | ValidatorFn[]): ValidatorFn;
|
|
31
|
+
/**
|
|
32
|
+
* Logs the status of all controls in a FormGroup.
|
|
33
|
+
* It traverses the form structure and logs whether each control is valid or invalid.
|
|
34
|
+
* @param formGroup The FormGroup to log the status of.
|
|
35
|
+
* @returns {void} This function does not return anything, it logs the status to the console.
|
|
36
|
+
*/
|
|
37
|
+
export declare function logFormStatus(formGroup: FormGroup): void;
|
|
38
|
+
/**
|
|
39
|
+
* A collection of custom validators for various data types.
|
|
40
|
+
*/
|
|
41
|
+
export declare class DataValidators {
|
|
42
|
+
/**
|
|
43
|
+
* Validates that the control's value is a valid employee object.
|
|
44
|
+
*/
|
|
45
|
+
static employeeRequired(control: AbstractControl): ValidationErrors | null;
|
|
46
|
+
/**
|
|
47
|
+
* Validates that the control's value is a valid attachment object.
|
|
48
|
+
*/
|
|
49
|
+
static fileUploaderRequired(control: AbstractControl): ValidationErrors | null;
|
|
50
|
+
/**
|
|
51
|
+
* Validates that the control's value is a valid attachments list.
|
|
52
|
+
*/
|
|
53
|
+
static multiFileUploaderRequired(control: AbstractControl): ValidationErrors | null;
|
|
54
|
+
/**
|
|
55
|
+
* Validates that the control's value is a valid select object.
|
|
56
|
+
* The select object should have a 'key' property.
|
|
57
|
+
*/
|
|
58
|
+
static selectRequired(control: AbstractControl): ValidationErrors | null;
|
|
59
|
+
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export * from './lib/pipes';
|
|
|
7
7
|
export * from './lib/i18n';
|
|
8
8
|
export * from './lib/constants';
|
|
9
9
|
export * from './lib/interfaces';
|
|
10
|
-
export * from './lib/classes';
|
|
11
10
|
export * from './lib/hooks';
|
|
12
11
|
export * from './lib/functions';
|
|
13
12
|
export * from './lib/validators';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ValidationErrors } from "@angular/forms";
|
|
2
|
-
import { Section } from "../interfaces";
|
|
3
|
-
export type FormAction = 'SUBMIT' | 'APPROVE' | 'REJECT' | 'SENDBACK' | 'SAVE_CHANGES' | 'CANCEL' | 'SENDTODO' | string & {};
|
|
4
|
-
export type CustomValidatorFn = (fieldName: string, section: Section, action: FormAction) => ValidationErrors | null;
|
|
5
|
-
export declare class FormValidation {
|
|
6
|
-
private validators;
|
|
7
|
-
constructor(validators: Record<string, CustomValidatorFn[]>);
|
|
8
|
-
isFormValidForAction(section: Section, action: FormAction): boolean;
|
|
9
|
-
logFormControlsValidationStatus(section: Section, action?: FormAction): void;
|
|
10
|
-
}
|
|
11
|
-
export declare class BuiltInCustomValidators {
|
|
12
|
-
static required(fieldName: string, section: Section, action: FormAction): ValidationErrors | null;
|
|
13
|
-
static requiredIfAction(action: FormAction[]): CustomValidatorFn;
|
|
14
|
-
static requiredOnlyWhen(conditionFn: () => boolean): CustomValidatorFn;
|
|
15
|
-
static maxLength(max: number): CustomValidatorFn;
|
|
16
|
-
static minLength(min: number): CustomValidatorFn;
|
|
17
|
-
static ifAction(actions: FormAction[], validators: CustomValidatorFn[]): CustomValidatorFn[];
|
|
18
|
-
static validateOnlyWhen(conditionFn: () => boolean, validators: CustomValidatorFn[]): CustomValidatorFn[];
|
|
19
|
-
}
|
package/lib/classes/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './form-validation';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isValidData(data: any): boolean;
|