coer-elements 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/Tools/index.d.ts +8 -0
- package/Tools/src/Breadcrumbs.class.d.ts +18 -0
- package/Tools/src/ControlValue.d.ts +23 -0
- package/Tools/src/DateTime.class.d.ts +11 -0
- package/Tools/src/Files.class.d.ts +16 -0
- package/Tools/src/Page.class.d.ts +66 -0
- package/Tools/src/Screen.class.d.ts +11 -0
- package/Tools/src/Source.class.d.ts +20 -0
- package/Tools/src/Tools.d.ts +33 -0
- package/components/index.d.ts +2 -0
- package/components/src/coer-alert/coer-alert.component.d.ts +23 -0
- package/components/src/components.module.d.ts +10 -0
- package/esm2022/Tools/index.mjs +9 -0
- package/esm2022/Tools/src/Breadcrumbs.class.mjs +63 -0
- package/esm2022/Tools/src/ControlValue.mjs +44 -0
- package/esm2022/Tools/src/DateTime.class.mjs +22 -0
- package/esm2022/Tools/src/Files.class.mjs +93 -0
- package/esm2022/Tools/src/Page.class.mjs +160 -0
- package/esm2022/Tools/src/Screen.class.mjs +43 -0
- package/esm2022/Tools/src/Source.class.mjs +79 -0
- package/esm2022/Tools/src/Tools.mjs +200 -0
- package/esm2022/components/index.mjs +3 -0
- package/esm2022/components/src/coer-alert/coer-alert.component.mjs +227 -0
- package/esm2022/components/src/components.module.mjs +92 -0
- package/esm2022/index.mjs +2 -2
- package/esm2022/interfaces/index.mjs +7 -0
- package/esm2022/interfaces/src/IAppSource.interface.mjs +2 -0
- package/esm2022/interfaces/src/IBreadcrumb.interface.mjs +2 -0
- package/esm2022/interfaces/src/ICoerRef.interface.mjs +2 -0
- package/esm2022/interfaces/src/IGoBack.interface.mjs +2 -0
- package/esm2022/interfaces/src/IPatch.interface.mjs +2 -0
- package/esm2022/interfaces/src/IScreenSize.interface.mjs +2 -0
- package/fesm2022/coer-elements.mjs +1000 -0
- package/fesm2022/coer-elements.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/interfaces/index.d.ts +6 -0
- package/interfaces/src/IAppSource.interface.d.ts +4 -0
- package/interfaces/src/IBreadcrumb.interface.d.ts +6 -0
- package/interfaces/src/ICoerRef.interface.d.ts +10 -0
- package/interfaces/src/IGoBack.interface.d.ts +6 -0
- package/interfaces/src/IPatch.interface.d.ts +5 -0
- package/interfaces/src/IScreenSize.interface.d.ts +5 -0
- package/package.json +14 -1
@@ -1,4 +1,1004 @@
|
|
1
|
+
import * as i0 from '@angular/core';
|
2
|
+
import { forwardRef, Component, NgModule, inject, Inject, signal } from '@angular/core';
|
3
|
+
import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
4
|
+
import moment from 'moment';
|
5
|
+
import * as XLSX from 'xlsx';
|
6
|
+
import { RouterModule, Router, ActivatedRoute } from '@angular/router';
|
7
|
+
import { CommonModule } from '@angular/common';
|
8
|
+
import * as bootstrap from 'bootstrap';
|
9
|
+
import Swal from 'sweetalert2';
|
10
|
+
import { Observable } from 'rxjs';
|
11
|
+
|
12
|
+
class Breadcrumbs {
|
13
|
+
static { this.storage = 'COER-System'; }
|
14
|
+
/** */
|
15
|
+
static Add(page, path) {
|
16
|
+
const breadcrumbs = this.Get();
|
17
|
+
const paths = breadcrumbs.map(item => item.path);
|
18
|
+
if (!paths.includes(path)) {
|
19
|
+
breadcrumbs.push({ page, path });
|
20
|
+
this.Save(breadcrumbs);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
/** */
|
24
|
+
static Get() {
|
25
|
+
let storage = sessionStorage.getItem(this.storage);
|
26
|
+
if (storage) {
|
27
|
+
storage = JSON.parse(storage);
|
28
|
+
if (storage.hasOwnProperty('breadcrumbs')) {
|
29
|
+
return Tools.BreakReference(storage.breadcrumbs);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return [];
|
33
|
+
}
|
34
|
+
/** Source */
|
35
|
+
static GetFirst() {
|
36
|
+
const breadcrumbs = this.Get();
|
37
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
38
|
+
}
|
39
|
+
/** */
|
40
|
+
static Save(breadcrumbs) {
|
41
|
+
let storage = sessionStorage.getItem(this.storage);
|
42
|
+
if (storage)
|
43
|
+
storage = JSON.parse(storage);
|
44
|
+
storage = Object.assign({}, storage, { breadcrumbs });
|
45
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
46
|
+
}
|
47
|
+
/** */
|
48
|
+
static Remove(path) {
|
49
|
+
let breadcrumbs = this.Get();
|
50
|
+
const index = breadcrumbs.findIndex(x => x.path.toLowerCase().trim() === path.toLowerCase().trim());
|
51
|
+
if (index >= 0) {
|
52
|
+
breadcrumbs = Tools.BreakReference(breadcrumbs).splice(0, index + 1);
|
53
|
+
this.Save(breadcrumbs);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
/** */
|
57
|
+
static SetLast(page, path) {
|
58
|
+
const breadcrumbs = this.Get();
|
59
|
+
if (breadcrumbs.length > 0) {
|
60
|
+
breadcrumbs[breadcrumbs.length - 1] = { page, path };
|
61
|
+
this.Save(breadcrumbs);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
/** */
|
65
|
+
static RemoveLast() {
|
66
|
+
const breadcrumbs = this.Get();
|
67
|
+
if (breadcrumbs.length > 0) {
|
68
|
+
breadcrumbs.pop();
|
69
|
+
this.Save(breadcrumbs);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
const CONTROL_VALUE = (component) => {
|
75
|
+
return {
|
76
|
+
provide: NG_VALUE_ACCESSOR,
|
77
|
+
useExisting: forwardRef(() => component),
|
78
|
+
multi: true
|
79
|
+
};
|
80
|
+
};
|
81
|
+
class ControlValue {
|
82
|
+
constructor() {
|
83
|
+
this._isTouched = false;
|
84
|
+
}
|
85
|
+
get isTouched() {
|
86
|
+
return this._isTouched;
|
87
|
+
}
|
88
|
+
/** */
|
89
|
+
SetValue(value) {
|
90
|
+
if (typeof this._UpdateValue === 'function') {
|
91
|
+
this._UpdateValue(value);
|
92
|
+
}
|
93
|
+
this._value = value;
|
94
|
+
}
|
95
|
+
/** */
|
96
|
+
SetTouched(isTouched) {
|
97
|
+
if (typeof this._IsTouched === 'function') {
|
98
|
+
this._IsTouched(isTouched);
|
99
|
+
}
|
100
|
+
this._isTouched = isTouched;
|
101
|
+
}
|
102
|
+
/** */
|
103
|
+
writeValue(value) {
|
104
|
+
this._value = value;
|
105
|
+
}
|
106
|
+
/** */
|
107
|
+
registerOnChange(callback) {
|
108
|
+
this._UpdateValue = callback;
|
109
|
+
}
|
110
|
+
/** */
|
111
|
+
registerOnTouched(callback) {
|
112
|
+
this._IsTouched = callback;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
class DateTime {
|
117
|
+
/** Get UTC Offset */
|
118
|
+
static GetUTCOffset() {
|
119
|
+
return moment().utcOffset();
|
120
|
+
}
|
121
|
+
/** Convert UTC Date to Local Zone */
|
122
|
+
static ToLocalZone(utcDate) {
|
123
|
+
return moment(utcDate).add(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
124
|
+
}
|
125
|
+
/** Convert Local Zone Date to UTC */
|
126
|
+
static ToUTC(utcDate) {
|
127
|
+
return moment(utcDate).subtract(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
128
|
+
}
|
129
|
+
/** DD MMM YYYY */
|
130
|
+
static GetDateFormat(date) {
|
131
|
+
if ((typeof date === 'string'))
|
132
|
+
date = date.replaceAll('/', '-');
|
133
|
+
return moment(date).parseZone().local(true).format('DD MMM YYYY');
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
class Files {
|
138
|
+
static { this.EXCEL_EXTENSIONS = ['xls', 'xlsx', 'csv']; }
|
139
|
+
/** Get Extension File */
|
140
|
+
static GetExtension(file) {
|
141
|
+
const fileName = file.name;
|
142
|
+
if (fileName.includes('.')) {
|
143
|
+
let worlds = fileName.split('.');
|
144
|
+
if (worlds.length > 0) {
|
145
|
+
let extension = worlds.pop();
|
146
|
+
extension = extension.trim().toLowerCase();
|
147
|
+
if (extension.length > 0)
|
148
|
+
return extension;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
return null;
|
152
|
+
}
|
153
|
+
/** Is Excel File */
|
154
|
+
static IsExcel(file) {
|
155
|
+
const EXTENSION = Files.GetExtension(file);
|
156
|
+
return Tools.IsNotNull(EXTENSION)
|
157
|
+
? this.EXCEL_EXTENSIONS.includes(EXTENSION)
|
158
|
+
: false;
|
159
|
+
}
|
160
|
+
/** Read excel file */
|
161
|
+
static ReadExcel(file) {
|
162
|
+
return new Promise(Resolve => {
|
163
|
+
let columns = [];
|
164
|
+
let rows = [];
|
165
|
+
const reader = new FileReader();
|
166
|
+
reader.readAsArrayBuffer(file);
|
167
|
+
reader.onload = () => {
|
168
|
+
const dataBytes = new Uint8Array(reader.result);
|
169
|
+
if (dataBytes) {
|
170
|
+
const workbook = XLSX.read(dataBytes, {});
|
171
|
+
const sheet = workbook.Sheets[workbook.SheetNames[0]];
|
172
|
+
let dataSheet = XLSX.utils.sheet_to_json(sheet, {
|
173
|
+
header: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
|
174
|
+
});
|
175
|
+
//Get Headers
|
176
|
+
for (const column in dataSheet[0]) {
|
177
|
+
columns.push(Tools.FirstCharToLower(String(dataSheet[0][column]).replaceAll(' ', '')));
|
178
|
+
}
|
179
|
+
//Get Rows
|
180
|
+
rows = XLSX.utils.sheet_to_json(sheet, { header: columns });
|
181
|
+
rows.shift();
|
182
|
+
rows = rows.map(row => {
|
183
|
+
const item = Tools.BreakReference(row);
|
184
|
+
delete item['__rowNum__'];
|
185
|
+
return item;
|
186
|
+
});
|
187
|
+
}
|
188
|
+
Resolve({ columns, rows });
|
189
|
+
};
|
190
|
+
reader.onerror = () => { Resolve({ columns, rows }); };
|
191
|
+
});
|
192
|
+
}
|
193
|
+
/** Export to excel file */
|
194
|
+
static ExportExcel(data, fileName = 'coer_report', sheetName = 'Sheet1') {
|
195
|
+
sheetName = Tools.CleanUpBlanks(sheetName);
|
196
|
+
fileName = Tools.CleanUpBlanks(fileName);
|
197
|
+
if (fileName.endsWith('.xls') || fileName.endsWith('.xlsx') || fileName.endsWith('.csv')) {
|
198
|
+
if (fileName.includes('.xls')) {
|
199
|
+
fileName = fileName.replaceAll('.xls', '.xlsx');
|
200
|
+
}
|
201
|
+
if (fileName.includes('.csv')) {
|
202
|
+
fileName = fileName.replaceAll('.csv', '.xlsx');
|
203
|
+
}
|
204
|
+
}
|
205
|
+
else {
|
206
|
+
fileName += '.xlsx';
|
207
|
+
}
|
208
|
+
const WORK_SHEET = XLSX.utils.json_to_sheet(data);
|
209
|
+
const WORK_BOOK = XLSX.utils.book_new();
|
210
|
+
XLSX.utils.book_append_sheet(WORK_BOOK, WORK_SHEET, 'Sheet1');
|
211
|
+
XLSX.writeFile(WORK_BOOK, fileName);
|
212
|
+
}
|
213
|
+
/** Convert file to string base64 */
|
214
|
+
static ConvertToBase64(file) {
|
215
|
+
return new Promise(Resolve => {
|
216
|
+
const reader = new FileReader();
|
217
|
+
reader.readAsDataURL(file);
|
218
|
+
reader.onload = () => {
|
219
|
+
Resolve(reader.result?.toString() || '');
|
220
|
+
};
|
221
|
+
reader.onerror = () => {
|
222
|
+
Resolve('');
|
223
|
+
};
|
224
|
+
});
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
class CoerAlert {
|
229
|
+
/** */
|
230
|
+
Success(message = null, title = null, icon = null, autohide = 3000) {
|
231
|
+
//Title
|
232
|
+
if (!title || title == '')
|
233
|
+
title = 'Success';
|
234
|
+
const alertSuccessTitle = document.getElementById('alert-success-title');
|
235
|
+
alertSuccessTitle.textContent = title;
|
236
|
+
//Icon
|
237
|
+
icon = this.GetIcon(title, icon, 'bi-check-circle fa-beat');
|
238
|
+
const alertSuccessIcon = document.getElementById('alert-success-icon');
|
239
|
+
this.SetIcon(alertSuccessIcon, icon);
|
240
|
+
//Message
|
241
|
+
if (!message)
|
242
|
+
message = '';
|
243
|
+
const alertSuccessMessage = document.getElementById('alert-success-message');
|
244
|
+
alertSuccessMessage.innerHTML = message;
|
245
|
+
//Toast
|
246
|
+
const alertSuccess = document.getElementById('alert-success');
|
247
|
+
this.SetAutoHide(alertSuccess, autohide);
|
248
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertSuccess);
|
249
|
+
toast.show();
|
250
|
+
}
|
251
|
+
/** */
|
252
|
+
Error(message = null, title = null, icon = null, autohide = 3000) {
|
253
|
+
//Title
|
254
|
+
if (!title || title == '')
|
255
|
+
title = 'Error';
|
256
|
+
const alertErrorTitle = document.getElementById('alert-error-title');
|
257
|
+
alertErrorTitle.textContent = title;
|
258
|
+
//Icon
|
259
|
+
icon = this.GetIcon(title, icon, 'bi-exclamation-octagon fa-beat');
|
260
|
+
const alertErrorIcon = document.getElementById('alert-error-icon');
|
261
|
+
this.SetIcon(alertErrorIcon, icon);
|
262
|
+
//Message
|
263
|
+
if (!message)
|
264
|
+
message = '';
|
265
|
+
const alertErrorBody = document.getElementById('alert-error-message');
|
266
|
+
alertErrorBody.innerHTML = message;
|
267
|
+
//Toast
|
268
|
+
const alertError = document.getElementById('alert-error');
|
269
|
+
this.SetAutoHide(alertError, autohide);
|
270
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertError);
|
271
|
+
toast.show();
|
272
|
+
}
|
273
|
+
/** */
|
274
|
+
Info(message = null, title = null, icon = null, autohide = 3000) {
|
275
|
+
//Title
|
276
|
+
if (!title || title == '')
|
277
|
+
title = 'Info';
|
278
|
+
const alertInfoTitle = document.getElementById('alert-info-title');
|
279
|
+
alertInfoTitle.textContent = title;
|
280
|
+
//Icon
|
281
|
+
icon = this.GetIcon(title, icon, 'bi-info-circle fa-beat');
|
282
|
+
const alertInfoIcon = document.getElementById('alert-info-icon');
|
283
|
+
this.SetIcon(alertInfoIcon, icon);
|
284
|
+
//Message
|
285
|
+
if (!message)
|
286
|
+
message = '';
|
287
|
+
const alertInfoBody = document.getElementById('alert-info-message');
|
288
|
+
alertInfoBody.innerHTML = message;
|
289
|
+
//Toast
|
290
|
+
const alertInfo = document.getElementById('alert-info');
|
291
|
+
this.SetAutoHide(alertInfo, autohide);
|
292
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertInfo);
|
293
|
+
toast.show();
|
294
|
+
}
|
295
|
+
/** */
|
296
|
+
Warning(message = null, title = null, icon = null, autohide = 3000) {
|
297
|
+
//Title
|
298
|
+
if (!title || title == '')
|
299
|
+
title = 'Warning';
|
300
|
+
const alertWarningTitle = document.getElementById('alert-warning-title');
|
301
|
+
alertWarningTitle.textContent = title;
|
302
|
+
//Icon
|
303
|
+
icon = this.GetIcon(title, icon, 'bi-exclamation-triangle-fill fa-beat');
|
304
|
+
const alertWarningIcon = document.getElementById('alert-warning-icon');
|
305
|
+
this.SetIcon(alertWarningIcon, icon);
|
306
|
+
//Message
|
307
|
+
if (!message)
|
308
|
+
message = '';
|
309
|
+
const alertWarningBody = document.getElementById('alert-warning-message');
|
310
|
+
alertWarningBody.innerHTML = message;
|
311
|
+
//Toast
|
312
|
+
const alertWarning = document.getElementById('alert-warning');
|
313
|
+
this.SetAutoHide(alertWarning, autohide);
|
314
|
+
const toast = bootstrap.Toast.getOrCreateInstance(alertWarning);
|
315
|
+
toast.show();
|
316
|
+
}
|
317
|
+
/** */
|
318
|
+
Close(alert) {
|
319
|
+
return new Promise(Resolve => {
|
320
|
+
const element = document.getElementById(alert);
|
321
|
+
const toast = bootstrap.Toast.getOrCreateInstance(element);
|
322
|
+
toast.hide();
|
323
|
+
setTimeout(() => { Resolve(); }, 200);
|
324
|
+
});
|
325
|
+
}
|
326
|
+
/** */
|
327
|
+
Confirm(message = 'Proceed?', alertType = 'warning', icon = null) {
|
328
|
+
return new Promise(Resolve => {
|
329
|
+
let color;
|
330
|
+
let iconType;
|
331
|
+
switch (alertType) {
|
332
|
+
case 'danger':
|
333
|
+
{
|
334
|
+
if (icon == null)
|
335
|
+
icon = 'bi-exclamation-octagon';
|
336
|
+
iconType = 'error';
|
337
|
+
color = '#dc3545'; //red
|
338
|
+
break;
|
339
|
+
}
|
340
|
+
;
|
341
|
+
case 'success':
|
342
|
+
{
|
343
|
+
if (icon == null)
|
344
|
+
icon = 'bi-check-circle';
|
345
|
+
iconType = 'info';
|
346
|
+
color = '#198754'; //green
|
347
|
+
break;
|
348
|
+
}
|
349
|
+
;
|
350
|
+
case 'info':
|
351
|
+
{
|
352
|
+
if (icon == null)
|
353
|
+
icon = 'bi-info-circle';
|
354
|
+
iconType = 'error';
|
355
|
+
color = '#0d6efd'; //blue
|
356
|
+
break;
|
357
|
+
}
|
358
|
+
;
|
359
|
+
default: {
|
360
|
+
if (icon == null)
|
361
|
+
icon = 'bi-exclamation-triangle-fill';
|
362
|
+
iconType = 'warning';
|
363
|
+
color = '#ffc107'; //yellow
|
364
|
+
break;
|
365
|
+
}
|
366
|
+
}
|
367
|
+
switch (icon) {
|
368
|
+
case 'delete':
|
369
|
+
icon = 'fa-regular fa-trash-can';
|
370
|
+
break;
|
371
|
+
}
|
372
|
+
Swal.fire({
|
373
|
+
icon: iconType,
|
374
|
+
iconColor: 'transparent',
|
375
|
+
iconHtml: `<i class="${icon}" style="color: ${color};"></i>`,
|
376
|
+
html: message,
|
377
|
+
showConfirmButton: true,
|
378
|
+
confirmButtonText: 'Yes',
|
379
|
+
confirmButtonColor: color,
|
380
|
+
focusConfirm: true,
|
381
|
+
showDenyButton: true,
|
382
|
+
denyButtonColor: color,
|
383
|
+
focusDeny: false,
|
384
|
+
reverseButtons: true,
|
385
|
+
allowOutsideClick: false,
|
386
|
+
allowEscapeKey: false,
|
387
|
+
allowEnterKey: true,
|
388
|
+
customClass: {
|
389
|
+
denyButton: 'sweet-alert-button',
|
390
|
+
confirmButton: 'sweet-alert-button'
|
391
|
+
}
|
392
|
+
}).then(({ value }) => setTimeout(() => Resolve(value)));
|
393
|
+
});
|
394
|
+
}
|
395
|
+
/** */
|
396
|
+
SetIcon(element, icon) {
|
397
|
+
for (const item of [...element.classList.value.split(' ')]) {
|
398
|
+
if (item.length > 0) {
|
399
|
+
element.classList.remove(item);
|
400
|
+
element.classList.remove('q');
|
401
|
+
}
|
402
|
+
}
|
403
|
+
icon = icon.trim();
|
404
|
+
const hasWhiteSpaces = / /;
|
405
|
+
if (hasWhiteSpaces.test(icon)) {
|
406
|
+
const classes = icon.split(' ');
|
407
|
+
for (const icon of classes)
|
408
|
+
element.classList.add(icon);
|
409
|
+
}
|
410
|
+
else
|
411
|
+
element.classList.add(icon);
|
412
|
+
}
|
413
|
+
/** */
|
414
|
+
SetAutoHide(element, autohide) {
|
415
|
+
element.removeAttribute('data-bs-autohide');
|
416
|
+
element.removeAttribute('data-bs-delay');
|
417
|
+
if (autohide && autohide > 0) {
|
418
|
+
if (autohide < 1000)
|
419
|
+
autohide = 1000;
|
420
|
+
element.setAttribute('data-bs-autohide', 'true');
|
421
|
+
element.setAttribute('data-bs-delay', String(autohide));
|
422
|
+
}
|
423
|
+
else
|
424
|
+
element.setAttribute('data-bs-autohide', 'false');
|
425
|
+
}
|
426
|
+
/** */
|
427
|
+
GetIcon(title, icon, iconDefault) {
|
428
|
+
if (icon == null || icon == '') {
|
429
|
+
title = title.replaceAll(' ', '').toUpperCase();
|
430
|
+
switch (title) {
|
431
|
+
case 'ENABLED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
432
|
+
case 'ACTIVE': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
433
|
+
case 'ACTIVED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
|
434
|
+
case 'DISABLE': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
|
435
|
+
case 'DISABLED': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
|
436
|
+
case 'DELETE': return 'fa-regular fa-trash-can';
|
437
|
+
case 'DELETED': return 'fa-regular fa-trash-can';
|
438
|
+
default: return iconDefault;
|
439
|
+
}
|
440
|
+
}
|
441
|
+
return icon;
|
442
|
+
}
|
443
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoerAlert, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
444
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: CoerAlert, selector: "coer-alert", ngImport: i0, template: "<aside class=\"toast-container coer-alert\">\r\n <!-- Success -->\r\n <div id=\"alert-success\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-success-icon\"></i>\r\n <strong id=\"alert-success-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-success')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-success-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Error -->\r\n <div id=\"alert-error\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-error-icon\"></i>\r\n <strong id=\"alert-error-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-error')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-error-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Info -->\r\n <div id=\"alert-info\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-info-icon\"></i>\r\n <strong id=\"alert-info-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-info')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-info-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Warning -->\r\n <div id=\"alert-warning\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-warning-icon\"></i>\r\n <strong id=\"alert-warning-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-warning')\" class=\"btn-close\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-warning-message\"></pre>\r\n </div>\r\n </div>\r\n</aside>", styles: [".text-blue{color:#0d6efd!important}.text-blue-bold{color:#0d6efd!important;font-weight:700!important}.background-blue{background-color:#0d6efd!important}.background-border-blue{background-color:#0d6efd!important;border-color:#0d6efd!important}.text-gray{color:#6c757d!important}.text-gray-bold{color:#6c757d!important;font-weight:700!important}.background-gray{background-color:#6c757d!important}.background-border-gray{background-color:#6c757d!important;border-color:#6c757d!important}.text-green{color:#198754!important}.text-green-bold{color:#198754!important;font-weight:700!important}.background-green{background-color:#198754!important}.background-border-green{background-color:#198754!important;border-color:#198754!important}.text-yellow{color:#ffc107!important}.text-yellow-bold{color:#ffc107!important;font-weight:700!important}.background-yellow{background-color:#ffc107!important}.background-border-yellow{background-color:#ffc107!important;border-color:#ffc107!important}.text-red{color:#dc3545!important}.text-red-bold{color:#dc3545!important;font-weight:700!important}.background-red{background-color:#dc3545!important}.background-border-red{background-color:#dc3545!important;border-color:#dc3545!important}.text-white{color:#f5f5f5!important}.text-white-bold{color:#f5f5f5!important;font-weight:700!important}.background-white{background-color:#f5f5f5!important}.background-border-white{background-color:#f5f5f5!important;border-color:#f5f5f5!important}.text-black{color:#252525!important}.text-black-bold{color:#252525!important;font-weight:700!important}.background-black{background-color:#252525!important}.background-border-black{background-color:#252525!important;border-color:#252525!important}.text-orange{color:#fd6031!important}.text-orange-bold{color:#fd6031!important;font-weight:700!important}.background-orange{background-color:#fd6031!important}.background-border-orange{background-color:#fd6031!important;border-color:#fd6031!important}aside.toast-container{position:fixed;bottom:0;right:0;padding:15px!important;z-index:2000!important}aside.toast-container i,aside.toast-container svg{display:flex;align-items:center}aside.toast-container strong{margin:0 auto 0 5px}aside.toast-container div.toast,aside.toast-container div.toast-header{border-top-left-radius:10px;border-top-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast-body{min-height:36px}aside.toast-container pre{font-family:Roboto,RobotoFallback,Noto Kufi Arabic,Helvetica,Arial,sans-serif;white-space:pre-wrap;font-size:medium}aside.toast-container button{margin:0 2px!important;width:10px!important;height:10px!important;box-shadow:none!important;outline:none!important;border:none!important}aside.toast-container div#alert-success div.toast-header,aside.toast-container div#alert-success div.toast-body{background-color:#198754}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:#0d6efd}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:#dc3545}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:#ffc107;border-color:#252525;color:#252525}aside.toast-container div#alert-success:hover,aside.toast-container div#alert-info:hover,aside.toast-container div#alert-error:hover,aside.toast-container div#alert-warning:hover{transform:scale(1.01);box-shadow:2px 2px 10px #789;cursor:default}button.sweet-alert-button{width:100px!important;height:40px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 5px!important;outline:none!important;border:none!important;box-shadow:none!important}aside.toast-container>*{border:none!important;z-index:2000!important;margin:15px 0 0!important}\n"] }); }
|
445
|
+
}
|
446
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoerAlert, decorators: [{
|
447
|
+
type: Component,
|
448
|
+
args: [{ selector: 'coer-alert', template: "<aside class=\"toast-container coer-alert\">\r\n <!-- Success -->\r\n <div id=\"alert-success\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-success-icon\"></i>\r\n <strong id=\"alert-success-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-success')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-success-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Error -->\r\n <div id=\"alert-error\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-error-icon\"></i>\r\n <strong id=\"alert-error-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-error')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-error-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Info -->\r\n <div id=\"alert-info\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-info-icon\"></i>\r\n <strong id=\"alert-info-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-info')\" class=\"btn-close btn-close-white\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-info-message\"></pre>\r\n </div>\r\n </div>\r\n\r\n\r\n <!-- Warning -->\r\n <div id=\"alert-warning\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\" class=\"toast\">\r\n <div class=\"toast-header\">\r\n <i id=\"alert-warning-icon\"></i>\r\n <strong id=\"alert-warning-title\"></strong>\r\n <button type=\"button\" (click)=\"Close('alert-warning')\" class=\"btn-close\"></button>\r\n </div>\r\n\r\n <div class=\"toast-body\">\r\n <pre id=\"alert-warning-message\"></pre>\r\n </div>\r\n </div>\r\n</aside>", styles: [".text-blue{color:#0d6efd!important}.text-blue-bold{color:#0d6efd!important;font-weight:700!important}.background-blue{background-color:#0d6efd!important}.background-border-blue{background-color:#0d6efd!important;border-color:#0d6efd!important}.text-gray{color:#6c757d!important}.text-gray-bold{color:#6c757d!important;font-weight:700!important}.background-gray{background-color:#6c757d!important}.background-border-gray{background-color:#6c757d!important;border-color:#6c757d!important}.text-green{color:#198754!important}.text-green-bold{color:#198754!important;font-weight:700!important}.background-green{background-color:#198754!important}.background-border-green{background-color:#198754!important;border-color:#198754!important}.text-yellow{color:#ffc107!important}.text-yellow-bold{color:#ffc107!important;font-weight:700!important}.background-yellow{background-color:#ffc107!important}.background-border-yellow{background-color:#ffc107!important;border-color:#ffc107!important}.text-red{color:#dc3545!important}.text-red-bold{color:#dc3545!important;font-weight:700!important}.background-red{background-color:#dc3545!important}.background-border-red{background-color:#dc3545!important;border-color:#dc3545!important}.text-white{color:#f5f5f5!important}.text-white-bold{color:#f5f5f5!important;font-weight:700!important}.background-white{background-color:#f5f5f5!important}.background-border-white{background-color:#f5f5f5!important;border-color:#f5f5f5!important}.text-black{color:#252525!important}.text-black-bold{color:#252525!important;font-weight:700!important}.background-black{background-color:#252525!important}.background-border-black{background-color:#252525!important;border-color:#252525!important}.text-orange{color:#fd6031!important}.text-orange-bold{color:#fd6031!important;font-weight:700!important}.background-orange{background-color:#fd6031!important}.background-border-orange{background-color:#fd6031!important;border-color:#fd6031!important}aside.toast-container{position:fixed;bottom:0;right:0;padding:15px!important;z-index:2000!important}aside.toast-container i,aside.toast-container svg{display:flex;align-items:center}aside.toast-container strong{margin:0 auto 0 5px}aside.toast-container div.toast,aside.toast-container div.toast-header{border-top-left-radius:10px;border-top-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast,aside.toast-container div.toast-body{border-bottom-left-radius:10px;border-bottom-right-radius:10px;color:#f5f5f5}aside.toast-container div.toast-body{min-height:36px}aside.toast-container pre{font-family:Roboto,RobotoFallback,Noto Kufi Arabic,Helvetica,Arial,sans-serif;white-space:pre-wrap;font-size:medium}aside.toast-container button{margin:0 2px!important;width:10px!important;height:10px!important;box-shadow:none!important;outline:none!important;border:none!important}aside.toast-container div#alert-success div.toast-header,aside.toast-container div#alert-success div.toast-body{background-color:#198754}aside.toast-container div#alert-info div.toast-header,aside.toast-container div#alert-info div.toast-body{background-color:#0d6efd}aside.toast-container div#alert-error div.toast-header,aside.toast-container div#alert-error div.toast-body{background-color:#dc3545}aside.toast-container div#alert-warning div.toast-header,aside.toast-container div#alert-warning div.toast-body{background-color:#ffc107;border-color:#252525;color:#252525}aside.toast-container div#alert-success:hover,aside.toast-container div#alert-info:hover,aside.toast-container div#alert-error:hover,aside.toast-container div#alert-warning:hover{transform:scale(1.01);box-shadow:2px 2px 10px #789;cursor:default}button.sweet-alert-button{width:100px!important;height:40px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 5px!important;outline:none!important;border:none!important;box-shadow:none!important}aside.toast-container>*{border:none!important;z-index:2000!important;margin:15px 0 0!important}\n"] }]
|
449
|
+
}] });
|
450
|
+
|
451
|
+
//import { CoerButton } from './coer-button/coer-button.component';
|
452
|
+
//import { CoerCheckbox } from './coer-checkbox/coer-checkbox.component';
|
453
|
+
//import { CoerFilebox } from './coer-filebox/coer-filebox.component';
|
454
|
+
//import { CoerForm } from './coer-form/coer-form.component';
|
455
|
+
//import { CoerGrid } from './coer-grid/coer-grid.component';
|
456
|
+
//import { CoerModal } from './coer-modal/coer-modal.component';
|
457
|
+
//import { CoerNumberBox } from './coer-numberbox/coer-numberbox.component';
|
458
|
+
//import { CoerPageTitle } from './coer-page-title/coer-page-title.component';
|
459
|
+
//import { CoerSelectbox } from './coer-selectbox/coer-selectbox.component';
|
460
|
+
//import { CoerSwitch } from './coer-switch/coer-switch.component';
|
461
|
+
//import { CoerTab } from './coer-tab/coer-tab.component';
|
462
|
+
//import { CoerTextarea } from './coer-textarea/coer-textarea.component';
|
463
|
+
//import { CoerTextBox } from './coer-textbox/coer-textbox.component';
|
464
|
+
class ComponentsModule {
|
465
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
466
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: ComponentsModule, declarations: [CoerAlert], imports: [CommonModule,
|
467
|
+
RouterModule,
|
468
|
+
FormsModule,
|
469
|
+
ReactiveFormsModule], exports: [CoerAlert] }); }
|
470
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ComponentsModule, imports: [CommonModule,
|
471
|
+
RouterModule,
|
472
|
+
FormsModule,
|
473
|
+
ReactiveFormsModule] }); }
|
474
|
+
}
|
475
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ComponentsModule, decorators: [{
|
476
|
+
type: NgModule,
|
477
|
+
args: [{
|
478
|
+
imports: [
|
479
|
+
CommonModule,
|
480
|
+
RouterModule,
|
481
|
+
FormsModule,
|
482
|
+
ReactiveFormsModule,
|
483
|
+
//PipesModule,
|
484
|
+
//MatButtonModule,
|
485
|
+
//MatCheckboxModule,
|
486
|
+
//MatInputModule,
|
487
|
+
//MatFormFieldModule,
|
488
|
+
//MatSlideToggleModule,
|
489
|
+
//MatTabsModule,
|
490
|
+
//DirectivesModule
|
491
|
+
],
|
492
|
+
declarations: [
|
493
|
+
CoerAlert,
|
494
|
+
//CoerButton,
|
495
|
+
//CoerCheckbox,
|
496
|
+
//CoerFilebox,
|
497
|
+
//CoerForm,
|
498
|
+
//CoerGrid,
|
499
|
+
//CoerModal,
|
500
|
+
//CoerNumberBox,
|
501
|
+
//CoerPageTitle,
|
502
|
+
//CoerSelectbox,
|
503
|
+
//CoerSwitch,
|
504
|
+
//CoerTextarea,
|
505
|
+
//CoerTab,
|
506
|
+
//CoerTextBox,
|
507
|
+
],
|
508
|
+
exports: [
|
509
|
+
CoerAlert,
|
510
|
+
//CoerButton,
|
511
|
+
//CoerCheckbox,
|
512
|
+
//CoerFilebox,
|
513
|
+
//CoerForm,
|
514
|
+
//CoerGrid,
|
515
|
+
//CoerModal,
|
516
|
+
//CoerNumberBox,
|
517
|
+
//CoerPageTitle,
|
518
|
+
//CoerSelectbox,
|
519
|
+
//CoerSwitch,
|
520
|
+
//CoerTextarea,
|
521
|
+
//CoerTab,
|
522
|
+
//CoerTextBox,
|
523
|
+
]
|
524
|
+
}]
|
525
|
+
}] });
|
526
|
+
|
527
|
+
class Page {
|
528
|
+
constructor(page) {
|
529
|
+
//Injection
|
530
|
+
this.alert = inject(CoerAlert);
|
531
|
+
this.router = inject(Router);
|
532
|
+
this.activatedRoute = inject(ActivatedRoute);
|
533
|
+
/** */
|
534
|
+
this.isUpdate = false;
|
535
|
+
/** */
|
536
|
+
this.isLoading = false;
|
537
|
+
/** */
|
538
|
+
this.isReady = false;
|
539
|
+
/** */
|
540
|
+
this.enableAnimations = false;
|
541
|
+
/** */
|
542
|
+
this.breadcrumbs = [];
|
543
|
+
/** */
|
544
|
+
this.pageResponse = null;
|
545
|
+
/** */
|
546
|
+
this.goBack = { show: false };
|
547
|
+
//Private Variables
|
548
|
+
this._page = '';
|
549
|
+
this._source = null;
|
550
|
+
this._preventDestroy = false;
|
551
|
+
/** */
|
552
|
+
this.GoBack = (path) => (() => {
|
553
|
+
if (path)
|
554
|
+
Breadcrumbs.Remove(path);
|
555
|
+
else
|
556
|
+
Breadcrumbs.RemoveLast();
|
557
|
+
});
|
558
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
559
|
+
this.IsNotNull = Tools.IsNotNull;
|
560
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
561
|
+
this.IsNull = Tools.IsNull;
|
562
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
563
|
+
this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
|
564
|
+
this.SetPageName(page);
|
565
|
+
this.SetSource();
|
566
|
+
this.GetSource();
|
567
|
+
this.GetNavigation();
|
568
|
+
this.SetGoBack();
|
569
|
+
this.GetPageResponse();
|
570
|
+
}
|
571
|
+
ngAfterViewInit() {
|
572
|
+
this.routeParams = this.activatedRoute.snapshot.params;
|
573
|
+
this.queryParams = this.activatedRoute.snapshot.queryParams;
|
574
|
+
setTimeout(() => {
|
575
|
+
this.isReady = true;
|
576
|
+
this.RunPage();
|
577
|
+
setTimeout(() => { this.enableAnimations = true; }, 1000);
|
578
|
+
});
|
579
|
+
}
|
580
|
+
ngOnDestroy() {
|
581
|
+
if (!this._preventDestroy)
|
582
|
+
Source.ClearPageResponse();
|
583
|
+
}
|
584
|
+
/** Main method. Starts after ngAfterViewInit() */
|
585
|
+
RunPage() { }
|
586
|
+
;
|
587
|
+
/** Rename the last breadcrumb and update the url id */
|
588
|
+
SetPageName(name, id = null) {
|
589
|
+
this._page = name;
|
590
|
+
let path = this.router.url;
|
591
|
+
if (path.includes('?'))
|
592
|
+
path = path.split('?')[0];
|
593
|
+
if (id) {
|
594
|
+
const PATH_ARRAY = path.split('/');
|
595
|
+
const PATH_ID = Tools.BreakReference(PATH_ARRAY).pop();
|
596
|
+
if (PATH_ID) {
|
597
|
+
PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
|
598
|
+
path = PATH_ARRAY.join('/');
|
599
|
+
}
|
600
|
+
}
|
601
|
+
if (this.breadcrumbs.length > 0) {
|
602
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
|
603
|
+
this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
|
604
|
+
Breadcrumbs.SetLast(name, path);
|
605
|
+
}
|
606
|
+
this.router.navigateByUrl(path);
|
607
|
+
}
|
608
|
+
/** */
|
609
|
+
SetSource() {
|
610
|
+
Source.Set(this._page);
|
611
|
+
}
|
612
|
+
/** */
|
613
|
+
GetSource() {
|
614
|
+
this._source = Source.Get();
|
615
|
+
}
|
616
|
+
/** */
|
617
|
+
GetPageResponse() {
|
618
|
+
this.pageResponse = Source.GetPageResponse();
|
619
|
+
}
|
620
|
+
/** */
|
621
|
+
GetNavigation() {
|
622
|
+
if (this._source) {
|
623
|
+
this.breadcrumbs = Breadcrumbs.Get().map(item => Object.assign({
|
624
|
+
page: item.page,
|
625
|
+
path: item.path,
|
626
|
+
click: this.GoBack(item.path)
|
627
|
+
}));
|
628
|
+
}
|
629
|
+
else
|
630
|
+
this.breadcrumbs = [{ page: this._page }];
|
631
|
+
}
|
632
|
+
/** */
|
633
|
+
SetGoBack() {
|
634
|
+
if (this._source) {
|
635
|
+
this.goBack = {
|
636
|
+
show: true,
|
637
|
+
path: this._source.path,
|
638
|
+
click: this.GoBack()
|
639
|
+
};
|
640
|
+
}
|
641
|
+
}
|
642
|
+
/** Navigate to previous page */
|
643
|
+
GoToSource(pageResponse = null) {
|
644
|
+
if (this._source) {
|
645
|
+
Breadcrumbs.RemoveLast();
|
646
|
+
this.SetPageResponse(pageResponse);
|
647
|
+
Tools.Sleep().then(_ => this.router.navigateByUrl(this._source.path));
|
648
|
+
}
|
649
|
+
}
|
650
|
+
;
|
651
|
+
/** */
|
652
|
+
SetPageResponse(pageResponse = null) {
|
653
|
+
if (Tools.IsNotNull(pageResponse)) {
|
654
|
+
this._preventDestroy = true;
|
655
|
+
Source.SetPageResponse(pageResponse);
|
656
|
+
}
|
657
|
+
}
|
658
|
+
;
|
659
|
+
/** */
|
660
|
+
ReloadPage() {
|
661
|
+
Breadcrumbs.RemoveLast();
|
662
|
+
Tools.Sleep().then(_ => window.location.reload());
|
663
|
+
}
|
664
|
+
/** */
|
665
|
+
Log(value, log = null) {
|
666
|
+
if (Tools.IsNotNull(log))
|
667
|
+
console.log({ log, value });
|
668
|
+
else
|
669
|
+
console.log(value);
|
670
|
+
}
|
671
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: Page, deps: [{ token: String }], target: i0.ɵɵFactoryTarget.Component }); }
|
672
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: Page, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
|
673
|
+
}
|
674
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: Page, decorators: [{
|
675
|
+
type: Component,
|
676
|
+
args: [{ template: '' }]
|
677
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
678
|
+
type: Inject,
|
679
|
+
args: [String]
|
680
|
+
}] }] });
|
681
|
+
|
682
|
+
class Screen {
|
683
|
+
static get WINDOW_WIDTH() {
|
684
|
+
return window.innerWidth;
|
685
|
+
}
|
686
|
+
static get WINDOW_HEIGHT() {
|
687
|
+
return window.innerHeight;
|
688
|
+
}
|
689
|
+
static get DEVICE_WIDTH() {
|
690
|
+
return window.screen.width;
|
691
|
+
}
|
692
|
+
static get DEVICE_HEIGHT() {
|
693
|
+
return window.screen.height;
|
694
|
+
}
|
695
|
+
static get BREAKPOINT() {
|
696
|
+
if (window.innerWidth < 576)
|
697
|
+
return 'xs';
|
698
|
+
else if (window.innerWidth >= 576 && window.innerWidth < 768)
|
699
|
+
return 'sm';
|
700
|
+
else if (window.innerWidth >= 768 && window.innerWidth < 992)
|
701
|
+
return 'md';
|
702
|
+
else if (window.innerWidth >= 992 && window.innerWidth < 1200)
|
703
|
+
return 'lg';
|
704
|
+
else if (window.innerWidth >= 1200 && window.innerWidth < 1400)
|
705
|
+
return 'xl';
|
706
|
+
else
|
707
|
+
return 'xxl';
|
708
|
+
}
|
709
|
+
/** */
|
710
|
+
static { this.Resize = new Observable(subscriber => {
|
711
|
+
window.addEventListener("load", () => {
|
712
|
+
window.dispatchEvent(new Event('resize'));
|
713
|
+
});
|
714
|
+
window.onresize = () => {
|
715
|
+
subscriber.next({
|
716
|
+
width: window.innerWidth,
|
717
|
+
height: window.innerHeight,
|
718
|
+
breakpoin: this.BREAKPOINT
|
719
|
+
});
|
720
|
+
};
|
721
|
+
}); }
|
722
|
+
}
|
723
|
+
|
724
|
+
class Source {
|
725
|
+
static { this.storage = 'COER-System'; }
|
726
|
+
/** */
|
727
|
+
static Set(page) {
|
728
|
+
const ROUTER = inject(Router);
|
729
|
+
let path = ROUTER.url;
|
730
|
+
if (path.includes('?'))
|
731
|
+
path = path.split('?')[0];
|
732
|
+
Breadcrumbs.Add(page, path);
|
733
|
+
const breadcrumbs = Breadcrumbs.Get();
|
734
|
+
if (breadcrumbs.length >= 2) {
|
735
|
+
breadcrumbs.pop();
|
736
|
+
const breadcrumb = breadcrumbs.pop();
|
737
|
+
this.Save({ page: breadcrumb.page, path: breadcrumb.path });
|
738
|
+
}
|
739
|
+
else
|
740
|
+
this.Save(null);
|
741
|
+
}
|
742
|
+
/** */
|
743
|
+
static Save(source) {
|
744
|
+
let storage = sessionStorage.getItem(this.storage);
|
745
|
+
if (storage)
|
746
|
+
storage = JSON.parse(storage);
|
747
|
+
storage = Object.assign({}, storage, { source });
|
748
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
749
|
+
}
|
750
|
+
/** */
|
751
|
+
static Get() {
|
752
|
+
let storage = sessionStorage.getItem(this.storage);
|
753
|
+
if (storage) {
|
754
|
+
storage = JSON.parse(storage);
|
755
|
+
if (storage.hasOwnProperty('source')) {
|
756
|
+
return storage.source;
|
757
|
+
}
|
758
|
+
}
|
759
|
+
return null;
|
760
|
+
}
|
761
|
+
/** */
|
762
|
+
static GetRoot() {
|
763
|
+
const breadcrumbs = Breadcrumbs.Get();
|
764
|
+
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
765
|
+
}
|
766
|
+
/** */
|
767
|
+
static SetPageResponse(pageResponse) {
|
768
|
+
let storage = sessionStorage.getItem(this.storage);
|
769
|
+
storage = JSON.parse(storage);
|
770
|
+
storage = Object.assign({}, storage, { pageResponse });
|
771
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
772
|
+
}
|
773
|
+
/** */
|
774
|
+
static GetPageResponse() {
|
775
|
+
let storage = sessionStorage.getItem(this.storage);
|
776
|
+
if (storage) {
|
777
|
+
storage = JSON.parse(storage);
|
778
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
779
|
+
return Tools.BreakReference(storage.pageResponse);
|
780
|
+
}
|
781
|
+
}
|
782
|
+
return null;
|
783
|
+
}
|
784
|
+
/** */
|
785
|
+
static ClearPageResponse() {
|
786
|
+
let storage = sessionStorage.getItem(this.storage);
|
787
|
+
storage = JSON.parse(storage);
|
788
|
+
if (storage.hasOwnProperty('pageResponse')) {
|
789
|
+
delete storage.pageResponse;
|
790
|
+
}
|
791
|
+
storage = Object.assign({}, storage);
|
792
|
+
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
793
|
+
}
|
794
|
+
/** Clear Source */
|
795
|
+
static Reset() {
|
796
|
+
sessionStorage.removeItem(this.storage);
|
797
|
+
}
|
798
|
+
}
|
799
|
+
|
800
|
+
const reference_signal = signal({});
|
801
|
+
const Tools = {
|
802
|
+
/** Generate a Guid */
|
803
|
+
GetGuid: (seed = 'coer-system') => {
|
804
|
+
let time = new Date().getTime();
|
805
|
+
seed = seed.toString().trim();
|
806
|
+
return seed + `-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
|
807
|
+
const random = (time + Math.random() * 16) % 16 | 0;
|
808
|
+
time = Math.floor(time / 16);
|
809
|
+
return (c == 'x' ? random : (random & 0x3 | 0x8)).toString(16);
|
810
|
+
});
|
811
|
+
},
|
812
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
813
|
+
IsNull: (value) => {
|
814
|
+
if (value === undefined)
|
815
|
+
return true;
|
816
|
+
if (value === null)
|
817
|
+
return true;
|
818
|
+
return false;
|
819
|
+
},
|
820
|
+
/** Returns true if the value is not null or undefined, false otherwise */
|
821
|
+
IsNotNull: (value) => {
|
822
|
+
if (value === undefined)
|
823
|
+
return false;
|
824
|
+
if (value === null)
|
825
|
+
return false;
|
826
|
+
return true;
|
827
|
+
},
|
828
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
829
|
+
IsOnlyWhiteSpace: (value) => {
|
830
|
+
if (value === undefined)
|
831
|
+
return true;
|
832
|
+
if (value === null)
|
833
|
+
return true;
|
834
|
+
if (value.toString().trim() === '')
|
835
|
+
return true;
|
836
|
+
return false;
|
837
|
+
},
|
838
|
+
/** Break reference of a object or array */
|
839
|
+
BreakReference: (object) => {
|
840
|
+
if (object === undefined)
|
841
|
+
return undefined;
|
842
|
+
if (object === null)
|
843
|
+
return null;
|
844
|
+
const OBJECT = JSON.parse(JSON.stringify(object));
|
845
|
+
return (Array.isArray(OBJECT)) ? [...OBJECT] : { ...OBJECT };
|
846
|
+
},
|
847
|
+
/** Clean extra whitespaces */
|
848
|
+
CleanUpBlanks: (text) => {
|
849
|
+
if (Tools.IsNull(text))
|
850
|
+
return '';
|
851
|
+
let worlds = String(text).split(' ');
|
852
|
+
worlds = worlds.filter(x => x.length > 0);
|
853
|
+
return worlds.join(' ');
|
854
|
+
},
|
855
|
+
/** Get properties of an object */
|
856
|
+
GetObjectProperties: (obj) => {
|
857
|
+
const properties = [];
|
858
|
+
if (Tools.IsNull(obj))
|
859
|
+
return properties;
|
860
|
+
for (const property in obj)
|
861
|
+
properties.push(String(property));
|
862
|
+
return properties;
|
863
|
+
},
|
864
|
+
/**
|
865
|
+
* Set an index and merge more arrays of the same type
|
866
|
+
* @returns A new array
|
867
|
+
* */
|
868
|
+
SetIndex: (array, ...args) => {
|
869
|
+
let index = 0;
|
870
|
+
for (const arg of args) {
|
871
|
+
array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
|
872
|
+
}
|
873
|
+
return Tools.BreakReference(array).map(item => Object.assign({ index: index++ }, item));
|
874
|
+
},
|
875
|
+
/** Set First Char To Lower */
|
876
|
+
FirstCharToLower: (text) => {
|
877
|
+
if (Tools.IsNull(text))
|
878
|
+
return '';
|
879
|
+
const textArray = [];
|
880
|
+
for (let i = 0; i < text.length; i++) {
|
881
|
+
if (i === 0)
|
882
|
+
textArray.push(text[i].toLowerCase());
|
883
|
+
else
|
884
|
+
textArray.push(text[i]);
|
885
|
+
}
|
886
|
+
return textArray.join('');
|
887
|
+
},
|
888
|
+
/** Set First Char To Upper */
|
889
|
+
FirstCharToUpper: (text) => {
|
890
|
+
if (Tools.IsNull(text))
|
891
|
+
return '';
|
892
|
+
const textArray = [];
|
893
|
+
for (let i = 0; i < text.length; i++) {
|
894
|
+
if (i === 0)
|
895
|
+
textArray.push(text[i].toUpperCase());
|
896
|
+
else
|
897
|
+
textArray.push(text[i]);
|
898
|
+
}
|
899
|
+
return textArray.join('');
|
900
|
+
},
|
901
|
+
/** Sort an array in ascending order by property */
|
902
|
+
SortBy: (array, property, propertyType = 'string') => {
|
903
|
+
switch (propertyType) {
|
904
|
+
case 'string': {
|
905
|
+
return array.sort((x, y) => {
|
906
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
907
|
+
return -1;
|
908
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
909
|
+
return 1;
|
910
|
+
else
|
911
|
+
return 0;
|
912
|
+
});
|
913
|
+
}
|
914
|
+
case 'number': {
|
915
|
+
return array.sort((x, y) => Number(x[property] - Number(y[property])));
|
916
|
+
}
|
917
|
+
}
|
918
|
+
},
|
919
|
+
/** Sort an array in descending order by property */
|
920
|
+
SortByDesc: (array, property, propertyType = 'string') => {
|
921
|
+
switch (propertyType) {
|
922
|
+
case 'string': {
|
923
|
+
return array.sort((x, y) => {
|
924
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
925
|
+
return 1;
|
926
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
927
|
+
return -1;
|
928
|
+
else
|
929
|
+
return 0;
|
930
|
+
});
|
931
|
+
}
|
932
|
+
case 'number': {
|
933
|
+
return array.sort((x, y) => Number(Number(y[property])) - x[property]);
|
934
|
+
}
|
935
|
+
}
|
936
|
+
},
|
937
|
+
/** Return a string with forman numeric */
|
938
|
+
GetNumericFormat: (value, decimals = 0) => {
|
939
|
+
if (value == undefined
|
940
|
+
|| value == null
|
941
|
+
|| value.toString().trim() == ''
|
942
|
+
|| isNaN(Number(value))) {
|
943
|
+
return '0';
|
944
|
+
}
|
945
|
+
let valueInteger = '';
|
946
|
+
let valueDecimal = '';
|
947
|
+
value = value.toString().replaceAll(' ', '');
|
948
|
+
if (value.includes('.') || (decimals > 0)) {
|
949
|
+
valueInteger = value.includes('.') ? value.split('.')[0] : value;
|
950
|
+
if (decimals > 0) {
|
951
|
+
const PADDING = decimals - valueDecimal.length;
|
952
|
+
valueDecimal = value.includes('.') ? value.split('.')[1] : '';
|
953
|
+
for (let i = 0; i < PADDING; i++)
|
954
|
+
valueDecimal += '0';
|
955
|
+
valueDecimal = valueDecimal.substring(0, decimals);
|
956
|
+
valueDecimal = `.${valueDecimal}`;
|
957
|
+
}
|
958
|
+
}
|
959
|
+
else {
|
960
|
+
valueInteger = value;
|
961
|
+
}
|
962
|
+
let counter = 0;
|
963
|
+
const VALUE_INTEGER_ARRAY = [];
|
964
|
+
for (const char of valueInteger.split('').reverse()) {
|
965
|
+
if (counter == 3) {
|
966
|
+
VALUE_INTEGER_ARRAY.push(',');
|
967
|
+
counter = 0;
|
968
|
+
}
|
969
|
+
VALUE_INTEGER_ARRAY.push(char);
|
970
|
+
++counter;
|
971
|
+
}
|
972
|
+
valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
|
973
|
+
return `${valueInteger}${valueDecimal}`;
|
974
|
+
},
|
975
|
+
/** Wait the time indicated */
|
976
|
+
Sleep: (milliseconds = 0, reference = null) => {
|
977
|
+
if (Tools.IsNull(reference)) {
|
978
|
+
return new Promise(Resolve => setTimeout(Resolve, milliseconds));
|
979
|
+
}
|
980
|
+
else
|
981
|
+
return new Promise(Resolve => {
|
982
|
+
reference = reference.replaceAll(' ', '_').toLowerCase();
|
983
|
+
if (reference_signal().hasOwnProperty(reference)) {
|
984
|
+
clearInterval(reference_signal()[reference]);
|
985
|
+
}
|
986
|
+
reference_signal.set(Object.assign(reference_signal(), {
|
987
|
+
[reference]: setTimeout(() => {
|
988
|
+
Resolve();
|
989
|
+
clearInterval(reference_signal()[reference]);
|
990
|
+
const _reference = { ...reference_signal() };
|
991
|
+
delete _reference[reference];
|
992
|
+
reference_signal.set({ ..._reference });
|
993
|
+
}, milliseconds)
|
994
|
+
}));
|
995
|
+
});
|
996
|
+
}
|
997
|
+
};
|
998
|
+
|
1
999
|
/**
|
2
1000
|
* Generated bundle index. Do not edit.
|
3
1001
|
*/
|
1002
|
+
|
1003
|
+
export { Breadcrumbs, CONTROL_VALUE, ControlValue, DateTime, Files, Page, Screen, Source, Tools };
|
4
1004
|
//# sourceMappingURL=coer-elements.mjs.map
|