@energycap/components 0.39.21-ECAP-25650-file-upload-validation-support.20240806-1029 → 0.39.21-ECAP-25650-file-upload-validation-support.20240806-1611
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/esm2020/lib/controls/file-upload/file-upload.component.mjs +48 -31
- package/fesm2015/energycap-components.mjs +49 -31
- package/fesm2015/energycap-components.mjs.map +1 -1
- package/fesm2020/energycap-components.mjs +47 -30
- package/fesm2020/energycap-components.mjs.map +1 -1
- package/lib/controls/file-upload/file-upload.component.d.ts +12 -9
- package/package.json +1 -1
@@ -23,7 +23,16 @@ export type FileValidatorCallback = (file: File | null | undefined, base64: stri
|
|
23
23
|
export declare class FileUploadComponent extends FormControlBase implements OnInit, OnChanges {
|
24
24
|
protected validationMessageService: ValidationMessageService;
|
25
25
|
protected formGroupHelper: FormGroupHelper;
|
26
|
-
static getFormModel(validators: ValidatorFn[], disabled?: boolean,
|
26
|
+
static getFormModel(validators: ValidatorFn[], disabled?: boolean,
|
27
|
+
/** Any validators required to make sure the selected file is valid. It is recommended that you use `FileUploadComponent.getFileValidator` to help construct the validator(s). NOTE: This currently only works when multiSelect is false. */
|
28
|
+
fileValidators?: AsyncValidatorFn | AsyncValidatorFn[]): FormGroup<FileUploadFormGroup>;
|
29
|
+
/**
|
30
|
+
* Helper function that returns an async validator to be used with the file upload control.
|
31
|
+
* This is useful for when the file needs to be validated before it can be uploaded.
|
32
|
+
*
|
33
|
+
* @param callback The callback function that will be called to validate the file. Parameters for the callback are the file and the base64 string for the file.
|
34
|
+
* base64 is null if the fileOutput input on the FileUploadComponent is set to raw. Using fileOutput set to base64 is recommended for images.
|
35
|
+
*/
|
27
36
|
static getFileValidator(callback: FileValidatorCallback): AsyncValidatorFn;
|
28
37
|
formModel: FormGroup<FileUploadFormGroup>;
|
29
38
|
/**
|
@@ -91,19 +100,13 @@ export declare class FileUploadComponent extends FormControlBase implements OnIn
|
|
91
100
|
* @param base64FileString Optional: Will have a value provided if the fileOutput is set to base64
|
92
101
|
*/
|
93
102
|
private processFile;
|
103
|
+
/** Patches the form with the selected file in order to trigger control validation */
|
104
|
+
private validateFile;
|
94
105
|
/**
|
95
106
|
* Based on the fileOutput return whether this component is expected to deliver a base64 output
|
96
107
|
* @returns
|
97
108
|
*/
|
98
109
|
private isBase64FileOutput;
|
99
|
-
/**
|
100
|
-
* When the file was selected and processed patch the file information that the hosting form will
|
101
|
-
* be looking for.
|
102
|
-
* @param file
|
103
|
-
* @param base64FileString
|
104
|
-
* @param onFileSelectedResult
|
105
|
-
*/
|
106
|
-
private patchProcessedFile;
|
107
110
|
/** Maps the files to an array of File objects and sends them along
|
108
111
|
* to the derived onMultipleFileSelected method in the hosting component
|
109
112
|
*/
|
package/package.json
CHANGED