coer-elements 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. package/Signals/{index.d.ts → index.ts} +3 -3
  2. package/Signals/src/breakpoint.signal.ts +3 -0
  3. package/Signals/src/isLoading.signal.ts +2 -0
  4. package/Signals/src/isModalOpen.signal.ts +2 -0
  5. package/Tools/{index.d.ts → index.ts} +8 -8
  6. package/Tools/src/Breadcrumbs.class.ts +84 -0
  7. package/Tools/src/ControlValue.ts +63 -0
  8. package/Tools/src/DateTime.class.ts +27 -0
  9. package/Tools/src/Files.class.ts +119 -0
  10. package/Tools/src/Page.class.ts +195 -0
  11. package/Tools/src/Screen.class.ts +50 -0
  12. package/Tools/src/Source.class.ts +106 -0
  13. package/Tools/src/Tools.ts +217 -0
  14. package/components/index.ts +2 -0
  15. package/components/src/coer-alert/coer-alert.component.html +56 -0
  16. package/components/src/coer-alert/coer-alert.component.scss +100 -0
  17. package/components/src/coer-alert/coer-alert.component.ts +249 -0
  18. package/components/src/components.module.ts +97 -0
  19. package/esm2022/index.mjs +2 -4
  20. package/fesm2022/coer-elements.mjs +0 -1006
  21. package/fesm2022/coer-elements.mjs.map +1 -1
  22. package/index.d.ts +1 -3
  23. package/package.json +1 -1
  24. package/styles/index.css +249 -17
  25. package/styles/index.scss +98 -2
  26. package/README.md +0 -24
  27. package/Signals/src/breakpoint.signal.d.ts +0 -1
  28. package/Signals/src/isLoading.signal.d.ts +0 -1
  29. package/Signals/src/isModalOpen.signal.d.ts +0 -1
  30. package/Tools/src/Breadcrumbs.class.d.ts +0 -18
  31. package/Tools/src/ControlValue.d.ts +0 -23
  32. package/Tools/src/DateTime.class.d.ts +0 -11
  33. package/Tools/src/Files.class.d.ts +0 -16
  34. package/Tools/src/Page.class.d.ts +0 -66
  35. package/Tools/src/Screen.class.d.ts +0 -11
  36. package/Tools/src/Source.class.d.ts +0 -20
  37. package/Tools/src/Tools.d.ts +0 -33
  38. package/components/index.d.ts +0 -2
  39. package/components/src/coer-alert/coer-alert.component.d.ts +0 -23
  40. package/components/src/components.module.d.ts +0 -10
  41. package/esm2022/Signals/index.mjs +0 -4
  42. package/esm2022/Signals/src/breakpoint.signal.mjs +0 -4
  43. package/esm2022/Signals/src/isLoading.signal.mjs +0 -3
  44. package/esm2022/Signals/src/isModalOpen.signal.mjs +0 -3
  45. package/esm2022/Tools/index.mjs +0 -9
  46. package/esm2022/Tools/src/Breadcrumbs.class.mjs +0 -63
  47. package/esm2022/Tools/src/ControlValue.mjs +0 -44
  48. package/esm2022/Tools/src/DateTime.class.mjs +0 -22
  49. package/esm2022/Tools/src/Files.class.mjs +0 -93
  50. package/esm2022/Tools/src/Page.class.mjs +0 -160
  51. package/esm2022/Tools/src/Screen.class.mjs +0 -43
  52. package/esm2022/Tools/src/Source.class.mjs +0 -79
  53. package/esm2022/Tools/src/Tools.mjs +0 -200
  54. package/esm2022/components/index.mjs +0 -3
  55. package/esm2022/components/src/coer-alert/coer-alert.component.mjs +0 -227
  56. package/esm2022/components/src/components.module.mjs +0 -92
  57. package/esm2022/interfaces/index.mjs +0 -7
  58. package/esm2022/interfaces/src/IAppSource.interface.mjs +0 -2
  59. package/esm2022/interfaces/src/IBreadcrumb.interface.mjs +0 -2
  60. package/esm2022/interfaces/src/ICoerRef.interface.mjs +0 -2
  61. package/esm2022/interfaces/src/IGoBack.interface.mjs +0 -2
  62. package/esm2022/interfaces/src/IPatch.interface.mjs +0 -2
  63. package/esm2022/interfaces/src/IScreenSize.interface.mjs +0 -2
  64. package/interfaces/index.d.ts +0 -6
  65. package/interfaces/src/IAppSource.interface.d.ts +0 -4
  66. package/interfaces/src/IBreadcrumb.interface.d.ts +0 -6
  67. package/interfaces/src/ICoerRef.interface.d.ts +0 -10
  68. package/interfaces/src/IGoBack.interface.d.ts +0 -6
  69. package/interfaces/src/IPatch.interface.d.ts +0 -5
  70. package/interfaces/src/IScreenSize.interface.d.ts +0 -5
  71. package/styles/coer.scss +0 -96
@@ -0,0 +1,217 @@
1
+ import { signal } from "@angular/core";
2
+ const reference_signal = signal<any>({});
3
+
4
+ export const Tools = {
5
+ /** Generate a Guid */
6
+ GetGuid: (seed: string = 'coer-system') => {
7
+ let time = new Date().getTime();
8
+ seed = seed.toString().trim()
9
+ return seed + `-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
10
+ const random = (time + Math.random() * 16) % 16 | 0
11
+ time = Math.floor(time / 16)
12
+ return (c == 'x' ? random : (random & 0x3 | 0x8)).toString(16)
13
+ })
14
+ },
15
+
16
+
17
+ /** Returns true if the value is null or undefined, false otherwise */
18
+ IsNull: <T>(value: T | null | undefined): boolean => {
19
+ if (value === undefined) return true;
20
+ if (value === null) return true;
21
+ return false;
22
+ },
23
+
24
+
25
+ /** Returns true if the value is not null or undefined, false otherwise */
26
+ IsNotNull: <T>(value: T | null | undefined): boolean => {
27
+ if (value === undefined) return false;
28
+ if (value === null) return false;
29
+ return true;
30
+ },
31
+
32
+
33
+ /** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
34
+ IsOnlyWhiteSpace: <T>(value: T | null | undefined): boolean => {
35
+ if (value === undefined) return true;
36
+ if (value === null) return true;
37
+ if((value as string).toString().trim() === '') return true;
38
+ return false;
39
+ },
40
+
41
+
42
+ /** Break reference of a object or array */
43
+ BreakReference: <T>(object: T): T => {
44
+ if (object === undefined) return undefined as T;
45
+ if (object === null) return null as T;
46
+ const OBJECT = JSON.parse(JSON.stringify(object))
47
+ return (Array.isArray(OBJECT)) ? [...OBJECT] : { ...OBJECT }
48
+ },
49
+
50
+
51
+ /** Clean extra whitespaces */
52
+ CleanUpBlanks: (text: string | number): string => {
53
+ if(Tools.IsNull(text)) return '';
54
+ let worlds: string[] = String(text).split(' ');
55
+ worlds = worlds.filter(x => x.length > 0);
56
+ return worlds.join(' ');
57
+ },
58
+
59
+
60
+ /** Get properties of an object */
61
+ GetObjectProperties: <T>(obj: T | null | undefined): string[] => {
62
+ const properties: string[] = [];
63
+ if(Tools.IsNull(obj)) return properties;
64
+ for(const property in obj) properties.push(String(property));
65
+ return properties;
66
+ },
67
+
68
+
69
+ /**
70
+ * Set an index and merge more arrays of the same type
71
+ * @returns A new array
72
+ * */
73
+ SetIndex: <T>(array: T[], ...args: T[][]): T[] => {
74
+ let index = 0;
75
+ for (const arg of args) {
76
+ array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
77
+ }
78
+
79
+ return Tools.BreakReference(array).map(item => Object.assign({ index: index++ }, item));
80
+ },
81
+
82
+
83
+ /** Set First Char To Lower */
84
+ FirstCharToLower: (text: string | null | undefined): string => {
85
+ if (Tools.IsNull(text)) return '';
86
+
87
+ const textArray: string[] = [];
88
+ for(let i = 0; i < text!.length; i++) {
89
+ if(i === 0) textArray.push(text![i].toLowerCase());
90
+ else textArray.push(text![i]);
91
+ }
92
+
93
+ return textArray.join('');
94
+ },
95
+
96
+
97
+ /** Set First Char To Upper */
98
+ FirstCharToUpper: (text: string | null | undefined): string => {
99
+ if (Tools.IsNull(text)) return '';
100
+
101
+ const textArray: string[] = [];
102
+ for(let i = 0; i < text!.length; i++) {
103
+ if(i === 0) textArray.push(text![i].toUpperCase());
104
+ else textArray.push(text![i]);
105
+ }
106
+
107
+ return textArray.join('');
108
+ },
109
+
110
+
111
+ /** Sort an array in ascending order by property */
112
+ SortBy: <T>(array: T[], property: string, propertyType: 'string' | 'number' = 'string'): T[] => {
113
+ switch (propertyType) {
114
+ case 'string': {
115
+ return array.sort((x: any, y: any) => {
116
+ if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim()) return -1;
117
+ else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim()) return 1;
118
+ else return 0;
119
+ });
120
+ }
121
+
122
+ case 'number': {
123
+ return array.sort((x: any, y: any) => Number(x[property] - Number(y[property])));
124
+ }
125
+ }
126
+ },
127
+
128
+
129
+ /** Sort an array in descending order by property */
130
+ SortByDesc: <T>(array: T[], property: string, propertyType: 'string' | 'number' = 'string'): T[] => {
131
+ switch (propertyType) {
132
+ case 'string': {
133
+ return array.sort((x: any, y: any) => {
134
+ if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim()) return 1;
135
+ else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim()) return -1;
136
+ else return 0;
137
+ });
138
+ }
139
+
140
+ case 'number': {
141
+ return array.sort((x: any, y: any) => Number(Number(y[property])) - x[property]);
142
+ }
143
+ }
144
+ },
145
+
146
+
147
+ /** Return a string with forman numeric */
148
+ GetNumericFormat: (value: string | number | null | undefined, decimals: number = 0): string => {
149
+ if (value == undefined
150
+ || value == null
151
+ || value.toString().trim() == ''
152
+ || isNaN(Number(value))) {
153
+ return '0';
154
+ }
155
+
156
+ let valueInteger = '';
157
+ let valueDecimal = '';
158
+ value = value.toString().replaceAll(' ', '');
159
+
160
+ if (value.includes('.') || (decimals > 0)) {
161
+ valueInteger = value.includes('.') ? value.split('.')[0] : value;
162
+
163
+ if (decimals > 0) {
164
+ const PADDING = decimals - valueDecimal.length;
165
+ valueDecimal = value.includes('.') ? value.split('.')[1] : '';
166
+ for(let i = 0; i < PADDING; i++) valueDecimal += '0';
167
+ valueDecimal = valueDecimal.substring(0, decimals);
168
+ valueDecimal = `.${valueDecimal}`;
169
+ }
170
+ }
171
+
172
+ else {
173
+ valueInteger = value;
174
+ }
175
+
176
+ let counter = 0;
177
+ const VALUE_INTEGER_ARRAY: string[] = [];
178
+ for(const char of valueInteger.split('').reverse()) {
179
+ if (counter == 3) {
180
+ VALUE_INTEGER_ARRAY.push(',');
181
+ counter = 0;
182
+ }
183
+
184
+ VALUE_INTEGER_ARRAY.push(char);
185
+ ++counter;
186
+ }
187
+
188
+ valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
189
+ return `${valueInteger}${valueDecimal}`;
190
+ },
191
+
192
+
193
+ /** Wait the time indicated */
194
+ Sleep: (milliseconds: number = 0, reference: string | null = null) => {
195
+ if (Tools.IsNull(reference)) {
196
+ return new Promise(Resolve => setTimeout(Resolve, milliseconds));
197
+ }
198
+
199
+ else return new Promise<void>(Resolve => {
200
+ reference = reference!.replaceAll(' ', '_').toLowerCase();
201
+
202
+ if (reference_signal().hasOwnProperty(reference)) {
203
+ clearInterval(reference_signal()[reference!]);
204
+ }
205
+
206
+ reference_signal.set(Object.assign(reference_signal(), {
207
+ [reference!]: setTimeout(() => {
208
+ Resolve();
209
+ clearInterval(reference_signal()[reference!]);
210
+ const _reference = { ...reference_signal() };
211
+ delete _reference[reference!];
212
+ reference_signal.set({ ..._reference });
213
+ }, milliseconds)
214
+ }));
215
+ });
216
+ }
217
+ };
@@ -0,0 +1,2 @@
1
+ export * from './src/components.module';
2
+ export * from './src/coer-alert/coer-alert.component';
@@ -0,0 +1,56 @@
1
+ <aside class="toast-container coer-alert">
2
+ <!-- Success -->
3
+ <div id="alert-success" role="alert" aria-live="assertive" aria-atomic="true" class="toast">
4
+ <div class="toast-header">
5
+ <i id="alert-success-icon"></i>
6
+ <strong id="alert-success-title"></strong>
7
+ <button type="button" (click)="Close('alert-success')" class="btn-close btn-close-white"></button>
8
+ </div>
9
+
10
+ <div class="toast-body">
11
+ <pre id="alert-success-message"></pre>
12
+ </div>
13
+ </div>
14
+
15
+
16
+ <!-- Error -->
17
+ <div id="alert-error" role="alert" aria-live="assertive" aria-atomic="true" class="toast">
18
+ <div class="toast-header">
19
+ <i id="alert-error-icon"></i>
20
+ <strong id="alert-error-title"></strong>
21
+ <button type="button" (click)="Close('alert-error')" class="btn-close btn-close-white"></button>
22
+ </div>
23
+
24
+ <div class="toast-body">
25
+ <pre id="alert-error-message"></pre>
26
+ </div>
27
+ </div>
28
+
29
+
30
+ <!-- Info -->
31
+ <div id="alert-info" role="alert" aria-live="assertive" aria-atomic="true" class="toast">
32
+ <div class="toast-header">
33
+ <i id="alert-info-icon"></i>
34
+ <strong id="alert-info-title"></strong>
35
+ <button type="button" (click)="Close('alert-info')" class="btn-close btn-close-white"></button>
36
+ </div>
37
+
38
+ <div class="toast-body">
39
+ <pre id="alert-info-message"></pre>
40
+ </div>
41
+ </div>
42
+
43
+
44
+ <!-- Warning -->
45
+ <div id="alert-warning" role="alert" aria-live="assertive" aria-atomic="true" class="toast">
46
+ <div class="toast-header">
47
+ <i id="alert-warning-icon"></i>
48
+ <strong id="alert-warning-title"></strong>
49
+ <button type="button" (click)="Close('alert-warning')" class="btn-close"></button>
50
+ </div>
51
+
52
+ <div class="toast-body">
53
+ <pre id="alert-warning-message"></pre>
54
+ </div>
55
+ </div>
56
+ </aside>
@@ -0,0 +1,100 @@
1
+ @import "../../../styles/colors.scss";
2
+
3
+ aside.toast-container {
4
+ position: fixed;
5
+ bottom: 0px;
6
+ right: 0px;
7
+ padding: 15px !important;
8
+ z-index: 2000 !important;
9
+
10
+ i, svg {
11
+ display: flex;
12
+ align-items: center;
13
+ }
14
+
15
+ strong {
16
+ margin: 0px auto 0px 5px;
17
+ }
18
+
19
+ div.toast,
20
+ div.toast-header {
21
+ border-top-left-radius: 10px;
22
+ border-top-right-radius: 10px;
23
+ color: $white;
24
+ }
25
+
26
+ div.toast,
27
+ div.toast-body {
28
+ border-bottom-left-radius: 10px;
29
+ border-bottom-right-radius: 10px;
30
+ color: $white;
31
+ }
32
+
33
+ div.toast-body {
34
+ min-height: 36px;
35
+ }
36
+
37
+ pre {
38
+ font-family: Roboto, RobotoFallback, "Noto Kufi Arabic", Helvetica, Arial, sans-serif;
39
+ white-space: pre-wrap;
40
+ font-size: medium;
41
+ }
42
+
43
+ button {
44
+ margin: 0px 2px !important;
45
+ width: 10px !important;
46
+ height: 10px !important;
47
+ box-shadow: none !important;
48
+ outline: none !important;
49
+ border: none !important;
50
+ }
51
+
52
+ div#alert-success div.toast-header,
53
+ div#alert-success div.toast-body {
54
+ background-color: $green;
55
+ }
56
+
57
+ div#alert-info div.toast-header,
58
+ div#alert-info div.toast-body {
59
+ background-color: $blue;
60
+ }
61
+
62
+ div#alert-error div.toast-header,
63
+ div#alert-error div.toast-body {
64
+ background-color: $red;
65
+ }
66
+
67
+ div#alert-warning div.toast-header,
68
+ div#alert-warning div.toast-body {
69
+ background-color: $yellow;
70
+ border-color: $black;
71
+ color: $black;
72
+ }
73
+
74
+ div#alert-success:hover,
75
+ div#alert-info:hover,
76
+ div#alert-error:hover,
77
+ div#alert-warning:hover {
78
+ transform: scale(1.01);
79
+ box-shadow: 2px 2px 10px lightslategray;
80
+ cursor: default;
81
+ }
82
+ }
83
+
84
+ button.sweet-alert-button {
85
+ width: 100px !important;
86
+ height: 40px !important;
87
+ display: flex !important;
88
+ align-items: center !important;
89
+ justify-content: center !important;
90
+ margin: 0px 5px !important;
91
+ outline: none !important;
92
+ border: none !important;
93
+ box-shadow: none !important;
94
+ }
95
+
96
+ aside.toast-container > * {
97
+ border: none !important;
98
+ z-index: 2000 !important;
99
+ margin: 15px 0px 0px 0px !important;
100
+ }
@@ -0,0 +1,249 @@
1
+ import { Component } from '@angular/core';
2
+ import * as bootstrap from 'bootstrap';
3
+ import Swal from 'sweetalert2'
4
+
5
+ @Component({
6
+ selector: 'coer-alert',
7
+ templateUrl: './coer-alert.component.html',
8
+ styleUrls: ['./coer-alert.component.scss']
9
+ })
10
+ export class CoerAlert {
11
+
12
+ /** */
13
+ public Success(message: string | null = null, title: string | null = null, icon: string | null = null, autohide: number | null = 3000): void {
14
+ //Title
15
+ if (!title || title == '') title = 'Success';
16
+ const alertSuccessTitle = document.getElementById('alert-success-title')!;
17
+ alertSuccessTitle.textContent = title;
18
+
19
+ //Icon
20
+ icon = this.GetIcon(title, icon, 'bi-check-circle fa-beat');
21
+ const alertSuccessIcon = document.getElementById('alert-success-icon')!;
22
+ this.SetIcon(alertSuccessIcon, icon);
23
+
24
+ //Message
25
+ if (!message) message = '';
26
+ const alertSuccessMessage = document.getElementById('alert-success-message')!;
27
+ alertSuccessMessage.innerHTML = message;
28
+
29
+ //Toast
30
+ const alertSuccess = document.getElementById('alert-success')!;
31
+ this.SetAutoHide(alertSuccess, autohide);
32
+
33
+ const toast = bootstrap.Toast.getOrCreateInstance(alertSuccess);
34
+ toast.show();
35
+ }
36
+
37
+
38
+ /** */
39
+ public Error(message: string | null = null, title: string | null = null, icon: string | null = null, autohide: number | null = 3000): void {
40
+ //Title
41
+ if (!title || title == '') title = 'Error';
42
+ const alertErrorTitle = document.getElementById('alert-error-title')!;
43
+ alertErrorTitle.textContent = title;
44
+
45
+ //Icon
46
+ icon = this.GetIcon(title, icon, 'bi-exclamation-octagon fa-beat');
47
+ const alertErrorIcon = document.getElementById('alert-error-icon')!;
48
+ this.SetIcon(alertErrorIcon, icon);
49
+
50
+ //Message
51
+ if (!message) message = '';
52
+ const alertErrorBody = document.getElementById('alert-error-message')!;
53
+ alertErrorBody.innerHTML = message;
54
+
55
+ //Toast
56
+ const alertError = document.getElementById('alert-error')!;
57
+ this.SetAutoHide(alertError, autohide);
58
+
59
+ const toast = bootstrap.Toast.getOrCreateInstance(alertError);
60
+ toast.show();
61
+ }
62
+
63
+
64
+ /** */
65
+ public Info(message: string | null = null, title: string | null = null, icon: string | null = null, autohide: number | null = 3000): void {
66
+ //Title
67
+ if (!title || title == '') title = 'Info';
68
+ const alertInfoTitle = document.getElementById('alert-info-title')!;
69
+ alertInfoTitle.textContent = title;
70
+
71
+ //Icon
72
+ icon = this.GetIcon(title, icon, 'bi-info-circle fa-beat');
73
+ const alertInfoIcon = document.getElementById('alert-info-icon')!;
74
+ this.SetIcon(alertInfoIcon, icon);
75
+
76
+ //Message
77
+ if (!message) message = '';
78
+ const alertInfoBody = document.getElementById('alert-info-message')!;
79
+ alertInfoBody.innerHTML = message;
80
+
81
+ //Toast
82
+ const alertInfo = document.getElementById('alert-info')!;
83
+ this.SetAutoHide(alertInfo, autohide);
84
+
85
+ const toast = bootstrap.Toast.getOrCreateInstance(alertInfo);
86
+ toast.show();
87
+ }
88
+
89
+
90
+ /** */
91
+ public Warning(message: string | null = null, title: string | null = null, icon: string | null = null, autohide: number | null = 3000): void {
92
+ //Title
93
+ if (!title || title == '') title = 'Warning';
94
+ const alertWarningTitle = document.getElementById('alert-warning-title')!;
95
+ alertWarningTitle.textContent = title;
96
+
97
+ //Icon
98
+ icon = this.GetIcon(title, icon, 'bi-exclamation-triangle-fill fa-beat');
99
+ const alertWarningIcon = document.getElementById('alert-warning-icon')!;
100
+ this.SetIcon(alertWarningIcon, icon);
101
+
102
+ //Message
103
+ if (!message) message = '';
104
+ const alertWarningBody = document.getElementById('alert-warning-message')!;
105
+ alertWarningBody.innerHTML = message;
106
+
107
+ //Toast
108
+ const alertWarning = document.getElementById('alert-warning')!;
109
+ this.SetAutoHide(alertWarning, autohide);
110
+
111
+ const toast = bootstrap.Toast.getOrCreateInstance(alertWarning);
112
+ toast.show();
113
+ }
114
+
115
+
116
+ /** */
117
+ protected Close(alert: 'alert-success' | 'alert-error' | 'alert-info' | 'alert-warning') {
118
+ return new Promise<void>(Resolve => {
119
+ const element = document.getElementById(alert)!;
120
+ const toast = bootstrap.Toast.getOrCreateInstance(element);
121
+ toast.hide();
122
+
123
+ setTimeout(() => { Resolve() }, 200);
124
+ })
125
+ }
126
+
127
+
128
+ /** */
129
+ public Confirm(
130
+ message: string = 'Proceed?',
131
+ alertType: 'warning' | 'danger' | 'success' | 'info' = 'warning',
132
+ icon: string | null = null) {
133
+ return new Promise<boolean>(Resolve => {
134
+ let color: string;
135
+ let iconType: 'warning' | 'error' | 'success' | 'info';
136
+ switch(alertType) {
137
+ case 'danger': {
138
+ if (icon == null) icon = 'bi-exclamation-octagon';
139
+ iconType = 'error';
140
+ color = '#dc3545'; //red
141
+ break;
142
+ };
143
+
144
+ case 'success': {
145
+ if (icon == null) icon = 'bi-check-circle';
146
+ iconType = 'info';
147
+ color = '#198754'; //green
148
+ break;
149
+ };
150
+
151
+ case 'info': {
152
+ if (icon == null) icon = 'bi-info-circle';
153
+ iconType = 'error';
154
+ color = '#0d6efd'; //blue
155
+ break
156
+ };
157
+
158
+ default: {
159
+ if (icon == null) icon = 'bi-exclamation-triangle-fill';
160
+ iconType = 'warning';
161
+ color = '#ffc107'; //yellow
162
+ break;
163
+ }
164
+ }
165
+
166
+ switch(icon) {
167
+ case 'delete': icon = 'fa-regular fa-trash-can'; break;
168
+ }
169
+
170
+ Swal.fire({
171
+ icon: iconType,
172
+ iconColor: 'transparent',
173
+ iconHtml: `<i class="${icon}" style="color: ${color};"></i>`,
174
+ html: message,
175
+ showConfirmButton: true,
176
+ confirmButtonText: 'Yes',
177
+ confirmButtonColor: color,
178
+ focusConfirm: true,
179
+ showDenyButton: true,
180
+ denyButtonColor: color,
181
+ focusDeny: false,
182
+ reverseButtons: true,
183
+ allowOutsideClick: false,
184
+ allowEscapeKey: false,
185
+ allowEnterKey: true,
186
+ customClass: {
187
+ denyButton: 'sweet-alert-button',
188
+ confirmButton: 'sweet-alert-button'
189
+ }
190
+ }).then(({ value }) => setTimeout(() => Resolve(value)));
191
+ });
192
+ }
193
+
194
+
195
+ /** */
196
+ private SetIcon(element: HTMLElement, icon: string): void {
197
+ for (const item of [...element.classList.value.split(' ')]) {
198
+ if (item.length > 0) {
199
+ element.classList.remove(item);
200
+ element.classList.remove('q');
201
+ }
202
+ }
203
+
204
+ icon = icon.trim();
205
+ const hasWhiteSpaces: RegExp = / /;
206
+ if (hasWhiteSpaces.test(icon)) {
207
+ const classes = icon.split(' ');
208
+ for (const icon of classes) element.classList.add(icon);
209
+ }
210
+
211
+ else element.classList.add(icon);
212
+ }
213
+
214
+
215
+ /** */
216
+ private SetAutoHide(element: HTMLElement, autohide: number | null): void {
217
+ element.removeAttribute('data-bs-autohide');
218
+ element.removeAttribute('data-bs-delay');
219
+
220
+ if (autohide && autohide > 0) {
221
+ if (autohide < 1000) autohide = 1000;
222
+ element.setAttribute('data-bs-autohide', 'true');
223
+ element.setAttribute('data-bs-delay', String(autohide));
224
+ }
225
+
226
+ else element.setAttribute('data-bs-autohide', 'false');
227
+ }
228
+
229
+
230
+ /** */
231
+ private GetIcon(title: string, icon: string | null, iconDefault: string): string {
232
+ if (icon == null || icon == '') {
233
+ title = title.replaceAll(' ', '').toUpperCase();
234
+
235
+ switch(title) {
236
+ case 'ENABLED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
237
+ case 'ACTIVE': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
238
+ case 'ACTIVED': return 'fa-solid fa-thumbs-up fa-flip-horizontal';
239
+ case 'DISABLE': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
240
+ case 'DISABLED': return 'fa-solid fa-thumbs-down fa-flip-horizontal';
241
+ case 'DELETE': return 'fa-regular fa-trash-can';
242
+ case 'DELETED': return 'fa-regular fa-trash-can';
243
+ default: return iconDefault;
244
+ }
245
+ }
246
+
247
+ return icon;
248
+ }
249
+ }