@ieeesa-npm/presentation 0.13.5 → 0.13.7

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.
Files changed (32) hide show
  1. package/esm2022/lib/assets/constants.json +42 -0
  2. package/esm2022/lib/components/accordion/accordion.component.mjs +28 -0
  3. package/esm2022/lib/components/color-picker/color-picker.component.mjs +3 -3
  4. package/esm2022/lib/components/dynamic-form/dynamic-form.component.mjs +36 -3
  5. package/esm2022/lib/components/file-upload/file-upload.component.mjs +281 -0
  6. package/esm2022/lib/components/form-error/form-error.component.mjs +3 -3
  7. package/esm2022/lib/directives/dynamic-form-field/dynamic-form-field.directive.mjs +36 -2
  8. package/esm2022/lib/directives/file-upload/file-upload.directive.mjs +85 -0
  9. package/esm2022/lib/models/accordion-info.model.mjs +2 -0
  10. package/esm2022/lib/models/allowed-file-types.model.mjs +8 -0
  11. package/esm2022/lib/models/field-config.model.mjs +1 -1
  12. package/esm2022/lib/models/file-upload-presigned-url-res.model.mjs +2 -0
  13. package/esm2022/lib/models/form-control-types.model.mjs +2 -2
  14. package/esm2022/lib/services/file-upload.service.mjs +263 -0
  15. package/esm2022/public-api.mjs +8 -1
  16. package/fesm2022/ieeesa-npm-presentation.mjs +972 -234
  17. package/fesm2022/ieeesa-npm-presentation.mjs.map +1 -1
  18. package/lib/components/accordion/accordion.component.d.ts +11 -0
  19. package/lib/components/chips/chips.component.d.ts +40 -0
  20. package/lib/components/dynamic-form/dynamic-form.component.d.ts +23 -1
  21. package/lib/components/file-upload/file-upload.component.d.ts +340 -0
  22. package/lib/directives/dynamic-form-field/dynamic-form-field.directive.d.ts +5 -1
  23. package/lib/directives/file-upload/file-upload.directive.d.ts +42 -0
  24. package/lib/models/accordion-info.model.d.ts +5 -0
  25. package/lib/models/allowed-file-types.model.d.ts +5 -0
  26. package/lib/models/field-config.model.d.ts +8 -0
  27. package/lib/models/file-upload-presigned-url-res.model.d.ts +5 -0
  28. package/lib/models/form-control-types.model.d.ts +2 -1
  29. package/lib/services/file-upload.service.d.ts +365 -0
  30. package/package.json +1 -1
  31. package/public-api.d.ts +7 -0
  32. package/src/lib/assets/constants.json +42 -0
@@ -0,0 +1,365 @@
1
+ import { HttpBackend, HttpClient, HttpEvent } from '@angular/common/http';
2
+ import { OnDestroy } from '@angular/core';
3
+ import { AlertsService, HttpService, LoaderNotificationService } from '@ieeesa-npm/utility';
4
+ import { FileUploadPresignedUrl } from '../models/file-upload-presigned-url-res.model';
5
+ import { Observable, Subject } from 'rxjs';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * This service interacts with the server to obtain pre-signed URLs for file upload and uploads files to Amazon S3.
9
+ * @class FileUploadService
10
+ */
11
+ export declare class FileUploadService implements OnDestroy {
12
+ httpService: HttpService;
13
+ alertService: AlertsService;
14
+ loaderNotificationService: LoaderNotificationService;
15
+ destroy$: Subject<boolean>;
16
+ constants: {
17
+ ariaLabel: {
18
+ clear: string;
19
+ warning: string;
20
+ previousMonth: string;
21
+ nextMonth: string;
22
+ menuIcon: string;
23
+ close: string;
24
+ search: string;
25
+ addFormGroup: string;
26
+ };
27
+ button: {
28
+ cancel: string;
29
+ ok: string;
30
+ add: string;
31
+ };
32
+ modalConfig: {
33
+ ariaLabel: string;
34
+ autoFocus: string;
35
+ width: string;
36
+ };
37
+ chips: {
38
+ noOfDefaultVisibleChips: number;
39
+ label: {
40
+ viewAll: string; /**
41
+ * This service interacts with the server to obtain pre-signed URLs for file upload and uploads files to Amazon S3.
42
+ * @class FileUploadService
43
+ */
44
+ viewLess: string;
45
+ };
46
+ ariaLabel: {
47
+ chipsList: string;
48
+ };
49
+ icons: {
50
+ arrow: {
51
+ id: number;
52
+ iconURL: string;
53
+ toolTip: string;
54
+ ariaLabel: string;
55
+ };
56
+ remove: {
57
+ id: number;
58
+ iconURL: string;
59
+ toolTip: string;
60
+ ariaLabel: string;
61
+ };
62
+ };
63
+ };
64
+ dataTable: {
65
+ label: {
66
+ clearAll: string;
67
+ };
68
+ message: {
69
+ noRecordFound: string;
70
+ };
71
+ ariaLabel: {
72
+ search: string;
73
+ selectAll: string;
74
+ select: string;
75
+ link: string;
76
+ pagination: string;
77
+ };
78
+ buttons: {
79
+ id: number; /**
80
+ * Sets the base URL for API requests.
81
+ * @param {string} apiBaseUrl -API base URL.
82
+ * @memberof FileUploadService
83
+ */
84
+ iconURL: string;
85
+ toolTip: string;
86
+ ariaLabel: string;
87
+ }[];
88
+ };
89
+ datePicker: {
90
+ selectDateLabel: string;
91
+ dateFormatLabel: string;
92
+ startDateLabel: string;
93
+ endDateLabel: string;
94
+ };
95
+ dropdown: {
96
+ placeholderText: string;
97
+ };
98
+ filter: {
99
+ label: {
100
+ filterBy: string;
101
+ applyButton: string;
102
+ clearAll: string;
103
+ };
104
+ buttons: {
105
+ id: number;
106
+ iconURL: string;
107
+ toolTip: string;
108
+ ariaLabel: string;
109
+ }[];
110
+ };
111
+ textarea: {
112
+ maxLengthDefault: number;
113
+ leftCharacters: string;
114
+ };
115
+ autocomplete: {
116
+ /**
117
+ * Gets file upload progress.
118
+ * @param {*} message
119
+ * @memberof FileUploadService
120
+ */
121
+ minCharToSearch: number;
122
+ debounceTime: number;
123
+ };
124
+ header: {
125
+ alt: {
126
+ logo: string;
127
+ };
128
+ ariaLabel: {
129
+ helpLink: string;
130
+ hamburgerMenu: string;
131
+ };
132
+ label: {
133
+ signOut: string;
134
+ };
135
+ buttons: {
136
+ id: number; /**
137
+ * Return distinct message for sent, upload progress, & response events.
138
+ * @param {HttpEvent<any>} event
139
+ * @param {(File | FileList)} file
140
+ * @return {*}
141
+ * @memberof FileUploadService
142
+ */
143
+ iconURL: string;
144
+ toolTip: string;
145
+ ariaLabel: string;
146
+ }[];
147
+ userProfileMenuOptions: {
148
+ id: number;
149
+ iconURL: string;
150
+ label: string;
151
+ ariaLabel: string;
152
+ toolTip: string;
153
+ isToolTipNeeded: boolean;
154
+ }[];
155
+ };
156
+ footer: {
157
+ alt: {
158
+ logo: string;
159
+ };
160
+ links: {
161
+ label: string;
162
+ ariaLabel: string;
163
+ redirectUrl: string;
164
+ }[];
165
+ ieeeLogo: string;
166
+ copyright: {
167
+ link: string;
168
+ textPart1: string;
169
+ textPart2: string;
170
+ hyperLinkPart3: string;
171
+ textPart4: string;
172
+ };
173
+ };
174
+ welcome: {
175
+ buttons: {
176
+ label: string;
177
+ ariaLabel: string;
178
+ url: string; /**
179
+ * Retrieves presigned URL for downloading files to Amazon S3 bucket.
180
+ * @param {(File | FileList)} file
181
+ * @return {Observable<string>}
182
+ * @memberof FileUploadService
183
+ */
184
+ }[];
185
+ };
186
+ breadcrumb: {
187
+ label: {
188
+ dashboard: string;
189
+ };
190
+ };
191
+ loader: {
192
+ ariaLabel: {
193
+ spinner: string;
194
+ };
195
+ };
196
+ defaultWelcomeBgColor: string;
197
+ timePicker: {
198
+ defaultTimeFormat: number;
199
+ };
200
+ colorPicker: {
201
+ selectLabel: string;
202
+ cancelLabel: string;
203
+ defaultColor: string;
204
+ ariaLabel: string;
205
+ ariaDescription: string;
206
+ ariaDescribedById: string;
207
+ };
208
+ fileUpload: {
209
+ label: {
210
+ fileUpload: string;
211
+ allowedFileSize1: string;
212
+ allowedFileSize2: string;
213
+ allowedFileFormat: string;
214
+ browseFiles: string;
215
+ uploadProgress: string;
216
+ };
217
+ ariaLabel: {
218
+ fileUpload: string;
219
+ browseFiles: string;
220
+ fileUploadIcon: string;
221
+ removeFileIcon: string;
222
+ deleteFileIcon: string;
223
+ fileDownload: string;
224
+ fileUploadInput: string;
225
+ };
226
+ iconUrl: {
227
+ fileUploadIcon: string;
228
+ fileRemoveIcon: string;
229
+ deleteIcon: string;
230
+ };
231
+ buttons: {
232
+ id: number;
233
+ ariaLabel: string;
234
+ iconURL: string;
235
+ toolTip: string;
236
+ disabled: boolean;
237
+ }[]; /**
238
+ * Validates the file types of the uploaded files.
239
+ * @param {(File | FileList)} files
240
+ * @param {string[]} allowedFileTypes
241
+ * @param {boolean} isMultiFileUpload
242
+ * @return {boolean} -Returns true if all files have valid extensions, otherwise false.
243
+ * @memberof FileUploadService
244
+ */
245
+ message: {
246
+ error: {
247
+ errorReadingFile: string;
248
+ invalidFileFormat: string;
249
+ invalidFileSize: string;
250
+ "2025": string;
251
+ "2026": string;
252
+ };
253
+ };
254
+ };
255
+ };
256
+ apiBaseUrl: string;
257
+ fileByteArray: Uint8Array | undefined;
258
+ httpClient: HttpClient;
259
+ isFileUploading: boolean;
260
+ constructor(httpService: HttpService, handler: HttpBackend, alertService: AlertsService, loaderNotificationService: LoaderNotificationService);
261
+ /**
262
+ * Sets the base URL for API requests.
263
+ * @param {string} apiBaseUrl -API base URL.
264
+ * @memberof FileUploadService
265
+ */
266
+ setApiBaseUrl(apiBaseUrl: string): void;
267
+ /**
268
+ * Retrieves presigned URL for uploading files to Amazon S3 bucket.
269
+ * @param {(File | FileList)} file
270
+ * @return {Observable<FileUploadPresignedUrl>}
271
+ * @memberof FileUploadService
272
+ */
273
+ getFileUploadPresignedUrl(file: File | FileList): Observable<FileUploadPresignedUrl>;
274
+ /**
275
+ * Uploads file to AWS S3 using a presigned URL.
276
+ * @param {string} presignedUrl
277
+ * @param {(File | FileList)} file
278
+ * @return {Observable<any>} -Returns an observable that emits the response after uploading the file to S3.
279
+ * @memberof FileUploadService
280
+ */
281
+ uploadFileToS3(presignedUrl: string, file: File | FileList): Observable<any>;
282
+ /**
283
+ * Gets file upload progress.
284
+ * @param {*} message
285
+ * @memberof FileUploadService
286
+ */
287
+ showProgress(message: any): void;
288
+ /**
289
+ * Return distinct message for sent, upload progress, & response events.
290
+ * @param {HttpEvent<any>} event
291
+ * @param {(File | FileList)} file
292
+ * @return {*}
293
+ * @memberof FileUploadService
294
+ */
295
+ getEventMessage(event: HttpEvent<any>, file: File | FileList): string | true;
296
+ /**
297
+ * Converts file to byte array.
298
+ * @param {File} file
299
+ * @memberof FileUploadService
300
+ */
301
+ convertFileToByteArray(file: File): void;
302
+ /**
303
+ * Resets file byte array format to undefined.
304
+ * @memberof FileUploadService
305
+ */
306
+ clearFileByteArray(): void;
307
+ /**
308
+ * Sets file upload status.
309
+ * @param {boolean} status
310
+ * @memberof FileUploadService
311
+ */
312
+ setFileUploadStatus(status: boolean): void;
313
+ /**
314
+ * Returns file upload status.
315
+ * @return {boolean}
316
+ * @memberof FileUploadService
317
+ */
318
+ getFileUploadStatus(): boolean;
319
+ /**
320
+ * Retrieves presigned URL for downloading files to Amazon S3 bucket.
321
+ * @param {(File | FileList)} file
322
+ * @return {Observable<string>}
323
+ * @memberof FileUploadService
324
+ */
325
+ getFileDownloadPresignedUrls(file: File | FileList): Observable<string>;
326
+ /**
327
+ * Downloads file to AWS S3 using a presigned URL.
328
+ * @return {Observable<any>}
329
+ * @memberof FileUploadService
330
+ */
331
+ downloadFile(fileDownloadPresignedUrl: string): Observable<any>;
332
+ /**
333
+ * Validates the total size of the files uploaded.
334
+ * @param {(File | FileList)} files -The files to be validated.
335
+ * @param {number} maxFileSize
336
+ * @param {boolean} isMultiFileUpload
337
+ * @return {boolean} -Returns true if the total size of files is within the specified limit, otherwise false.
338
+ * @memberof FileUploadService
339
+ */
340
+ validateFileSize(files: File | FileList, maxFileSize: number, isMultiFileUpload: boolean): boolean;
341
+ /**
342
+ * Validates the file types of the uploaded files.
343
+ * @param {(File | FileList)} files
344
+ * @param {string[]} allowedFileTypes
345
+ * @param {boolean} isMultiFileUpload
346
+ * @return {boolean} -Returns true if all files have valid extensions, otherwise false.
347
+ * @memberof FileUploadService
348
+ */
349
+ validateFileTypes(files: File | FileList, allowedFileTypes: string[], isMultiFileUpload: boolean): boolean;
350
+ /**
351
+ * Extracts and returns the extension of a file from its name.
352
+ * @private
353
+ * @param {string} fileName
354
+ * @return {string} -The file extension in lowercase.
355
+ * @memberof FileUploadService
356
+ */
357
+ private getFileExtension;
358
+ /**
359
+ * Implementation of ngOnDestroy lifecycle hook method to unsubscribe the open observable subscriptions.
360
+ * @memberof FileUploadService
361
+ */
362
+ ngOnDestroy(): void;
363
+ static ɵfac: i0.ɵɵFactoryDeclaration<FileUploadService, never>;
364
+ static ɵprov: i0.ɵɵInjectableDeclaration<FileUploadService>;
365
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ieeesa-npm/presentation",
3
- "version": "0.13.5",
3
+ "version": "0.13.7",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^16.1.0",
6
6
  "@angular/core": "^16.1.0",
package/public-api.d.ts CHANGED
@@ -32,10 +32,13 @@ export * from './lib/components/tabs/tabs.component';
32
32
  export * from './lib/components/slide-toggle/slide-toggle.component';
33
33
  export * from './lib/components/card/card.component';
34
34
  export * from './lib/components/color-picker/color-picker.component';
35
+ export * from './lib/components/file-upload/file-upload.component';
36
+ export * from './lib/components/accordion/accordion.component';
35
37
  export * from './lib/directives/dynamic-form-field/dynamic-form-field.directive';
36
38
  export * from './lib/directives/focus-invalid-form-field/focus-invalid-form-field.directive';
37
39
  export * from './lib/directives/set-background/set-background.directive';
38
40
  export * from './lib/directives/text-truncated/text-truncated.directive';
41
+ export * from './lib/directives/file-upload/file-upload.directive';
39
42
  export * from './lib/models/align-type.model';
40
43
  export * from './lib/models/app-config-info.model';
41
44
  export * from './lib/models/autocomplete-option.model';
@@ -77,6 +80,10 @@ export * from './lib/models/button-type.model';
77
80
  export * from './lib/models/card-button.model';
78
81
  export * from './lib/models/card-info.model';
79
82
  export * from './lib/models/color-format.model';
83
+ export * from './lib/models/allowed-file-types.model';
84
+ export * from './lib/models/file-upload-presigned-url-res.model';
85
+ export * from './lib/models/accordion-info.model';
80
86
  export * from './lib/services/datepicker.service';
81
87
  export * from './lib/services/form-utility.service';
88
+ export * from './lib/services/file-upload.service';
82
89
  export * from './lib/presentation.module';
@@ -252,5 +252,47 @@
252
252
  "ariaLabel": "Color Picker",
253
253
  "ariaDescription": "Choose background color.",
254
254
  "ariaDescribedById": "ariaColorPicker"
255
+ },
256
+ "fileUpload": {
257
+ "label": {
258
+ "fileUpload": "Drag and Drop your files here or Click 'Browse Files'.",
259
+ "allowedFileSize1": "Allowed File size up to",
260
+ "allowedFileSize2": "mb only;",
261
+ "allowedFileFormat": "Allowed file format(s): ",
262
+ "browseFiles": "Browse Files",
263
+ "uploadProgress": "Uploading... please wait"
264
+ },
265
+ "ariaLabel": {
266
+ "fileUpload": "Drag and Drop your files here or Click 'Browse Files'.",
267
+ "browseFiles": "Browse Files",
268
+ "fileUploadIcon": "File upload icon",
269
+ "removeFileIcon": "Remove file icon",
270
+ "deleteFileIcon": "Delete file icon",
271
+ "fileDownload": "File download",
272
+ "fileUploadInput": "File upload"
273
+ },
274
+ "iconUrl": {
275
+ "fileUploadIcon": "assets/images/sprites/sprites.svg#icon-file-upload",
276
+ "fileRemoveIcon": "assets/images/sprites/sprites.svg#icon-file-remove",
277
+ "deleteIcon": "assets/images/sprites/sprites.svg#icon-file-delete-upload"
278
+ },
279
+ "buttons": [
280
+ {
281
+ "id": 1,
282
+ "ariaLabel": "File upload icon.",
283
+ "iconURL": "assets/images/sprites/sprites.svg#icon-file-upload",
284
+ "toolTip": "",
285
+ "disabled": true
286
+ }
287
+ ],
288
+ "message": {
289
+ "error": {
290
+ "errorReadingFile": "File is damaged or unreadable.",
291
+ "invalidFileFormat": "Invalid file format. Please upload SVG, PNG and JPG file format only.",
292
+ "invalidFileSize": "File size exceeds the maximum limit.",
293
+ "2025": "Unable to establish connection. Please try again later.",
294
+ "2026": "Invalid file format. Please upload SVG, PNG and JPG file format only."
295
+ }
296
+ }
255
297
  }
256
298
  }