coer-elements 1.0.5 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/Signals/index.ts +1 -1
- package/Tools/Files.class.ts +1 -1
- package/Tools/Screen.class.ts +1 -1
- package/Tools/{index.ts → Tools.ts} +1 -1
- package/dist_browser/Tools/DateTime.class.js +25 -0
- package/dist_browser/Tools/Files.class.js +99 -0
- package/dist_browser/Tools/Screen.class.js +68 -0
- package/dist_browser/Tools/Tools.js +227 -0
- package/dist_browser/index.js +4 -150
- package/dist_node/Tools/DateTime.class.js +28 -0
- package/dist_node/Tools/Files.class.js +102 -0
- package/dist_node/Tools/Screen.class.js +71 -0
- package/dist_node/Tools/Tools.js +230 -0
- package/dist_node/index.js +16 -149
- package/dist_node/interfaces/index.js +2 -0
- package/index.ts +1 -1
- package/package.json +2 -2
- package/tsconfig.json +7 -1
package/Signals/index.ts
CHANGED
package/Tools/Files.class.ts
CHANGED
package/Tools/Screen.class.ts
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
import moment from "moment";
|
2
|
+
var DateTime = /** @class */ (function () {
|
3
|
+
function DateTime() {
|
4
|
+
}
|
5
|
+
/** Get UTC Offset */
|
6
|
+
DateTime.GetUTCOffset = function () {
|
7
|
+
return moment().utcOffset();
|
8
|
+
};
|
9
|
+
/** Convert UTC Date to Local Zone */
|
10
|
+
DateTime.ToLocalZone = function (utcDate) {
|
11
|
+
return moment(utcDate).add(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
12
|
+
};
|
13
|
+
/** Convert Local Zone Date to UTC */
|
14
|
+
DateTime.ToUTC = function (utcDate) {
|
15
|
+
return moment(utcDate).subtract(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
16
|
+
};
|
17
|
+
/** DD MMM YYYY */
|
18
|
+
DateTime.GetDateFormat = function (date) {
|
19
|
+
if ((typeof date === 'string'))
|
20
|
+
date = date.replaceAll('/', '-');
|
21
|
+
return moment(date).parseZone().local(true).format('DD MMM YYYY');
|
22
|
+
};
|
23
|
+
return DateTime;
|
24
|
+
}());
|
25
|
+
export { DateTime };
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import { Tools } from "./Tools";
|
2
|
+
import * as XLSX from 'xlsx';
|
3
|
+
var Files = /** @class */ (function () {
|
4
|
+
function Files() {
|
5
|
+
}
|
6
|
+
/** Get Extension File */
|
7
|
+
Files.GetExtension = function (file) {
|
8
|
+
var fileName = file.name;
|
9
|
+
if (fileName.includes('.')) {
|
10
|
+
var worlds = fileName.split('.');
|
11
|
+
if (worlds.length > 0) {
|
12
|
+
var extension = worlds.pop();
|
13
|
+
extension = extension.trim().toLowerCase();
|
14
|
+
if (extension.length > 0)
|
15
|
+
return extension;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
return null;
|
19
|
+
};
|
20
|
+
/** Is Excel File */
|
21
|
+
Files.IsExcel = function (file) {
|
22
|
+
var EXTENSION = Files.GetExtension(file);
|
23
|
+
return Tools.IsNotNull(EXTENSION)
|
24
|
+
? this.EXCEL_EXTENSIONS.includes(EXTENSION)
|
25
|
+
: false;
|
26
|
+
};
|
27
|
+
/** Read excel file */
|
28
|
+
Files.ReadExcel = function (file) {
|
29
|
+
return new Promise(function (Resolve) {
|
30
|
+
var columns = [];
|
31
|
+
var rows = [];
|
32
|
+
var reader = new FileReader();
|
33
|
+
reader.readAsArrayBuffer(file);
|
34
|
+
reader.onload = function () {
|
35
|
+
var dataBytes = new Uint8Array(reader.result);
|
36
|
+
if (dataBytes) {
|
37
|
+
var workbook = XLSX.read(dataBytes, {});
|
38
|
+
var sheet = workbook.Sheets[workbook.SheetNames[0]];
|
39
|
+
var dataSheet = XLSX.utils.sheet_to_json(sheet, {
|
40
|
+
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']
|
41
|
+
});
|
42
|
+
//Get Headers
|
43
|
+
for (var column in dataSheet[0]) {
|
44
|
+
columns.push(Tools.FirstCharToLower(String(dataSheet[0][column]).replaceAll(' ', '')));
|
45
|
+
}
|
46
|
+
//Get Rows
|
47
|
+
rows = XLSX.utils.sheet_to_json(sheet, { header: columns });
|
48
|
+
rows.shift();
|
49
|
+
rows = rows.map(function (row) {
|
50
|
+
var item = Tools.BreakReference(row);
|
51
|
+
delete item['__rowNum__'];
|
52
|
+
return item;
|
53
|
+
});
|
54
|
+
}
|
55
|
+
Resolve({ columns: columns, rows: rows });
|
56
|
+
};
|
57
|
+
reader.onerror = function () { Resolve({ columns: columns, rows: rows }); };
|
58
|
+
});
|
59
|
+
};
|
60
|
+
/** Export to excel file */
|
61
|
+
Files.ExportExcel = function (data, fileName, sheetName) {
|
62
|
+
if (fileName === void 0) { fileName = 'coer_report'; }
|
63
|
+
if (sheetName === void 0) { sheetName = 'Sheet1'; }
|
64
|
+
sheetName = Tools.CleanUpBlanks(sheetName);
|
65
|
+
fileName = Tools.CleanUpBlanks(fileName);
|
66
|
+
if (fileName.endsWith('.xls') || fileName.endsWith('.xlsx') || fileName.endsWith('.csv')) {
|
67
|
+
if (fileName.includes('.xls')) {
|
68
|
+
fileName = fileName.replaceAll('.xls', '.xlsx');
|
69
|
+
}
|
70
|
+
if (fileName.includes('.csv')) {
|
71
|
+
fileName = fileName.replaceAll('.csv', '.xlsx');
|
72
|
+
}
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
fileName += '.xlsx';
|
76
|
+
}
|
77
|
+
var WORK_SHEET = XLSX.utils.json_to_sheet(data);
|
78
|
+
var WORK_BOOK = XLSX.utils.book_new();
|
79
|
+
XLSX.utils.book_append_sheet(WORK_BOOK, WORK_SHEET, 'Sheet1');
|
80
|
+
XLSX.writeFile(WORK_BOOK, fileName);
|
81
|
+
};
|
82
|
+
/** Convert file to string base64 */
|
83
|
+
Files.ConvertToBase64 = function (file) {
|
84
|
+
return new Promise(function (Resolve) {
|
85
|
+
var reader = new FileReader();
|
86
|
+
reader.readAsDataURL(file);
|
87
|
+
reader.onload = function () {
|
88
|
+
var _a;
|
89
|
+
Resolve(((_a = reader.result) === null || _a === void 0 ? void 0 : _a.toString()) || '');
|
90
|
+
};
|
91
|
+
reader.onerror = function () {
|
92
|
+
Resolve('');
|
93
|
+
};
|
94
|
+
});
|
95
|
+
};
|
96
|
+
Files.EXCEL_EXTENSIONS = ['xls', 'xlsx', 'csv'];
|
97
|
+
return Files;
|
98
|
+
}());
|
99
|
+
export { Files };
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { Observable } from "rxjs";
|
2
|
+
var Screen = /** @class */ (function () {
|
3
|
+
function Screen() {
|
4
|
+
}
|
5
|
+
Object.defineProperty(Screen, "WINDOW_WIDTH", {
|
6
|
+
get: function () {
|
7
|
+
return window.innerWidth;
|
8
|
+
},
|
9
|
+
enumerable: false,
|
10
|
+
configurable: true
|
11
|
+
});
|
12
|
+
Object.defineProperty(Screen, "WINDOW_HEIGHT", {
|
13
|
+
get: function () {
|
14
|
+
return window.innerHeight;
|
15
|
+
},
|
16
|
+
enumerable: false,
|
17
|
+
configurable: true
|
18
|
+
});
|
19
|
+
Object.defineProperty(Screen, "DEVICE_WIDTH", {
|
20
|
+
get: function () {
|
21
|
+
return window.screen.width;
|
22
|
+
},
|
23
|
+
enumerable: false,
|
24
|
+
configurable: true
|
25
|
+
});
|
26
|
+
Object.defineProperty(Screen, "DEVICE_HEIGHT", {
|
27
|
+
get: function () {
|
28
|
+
return window.screen.height;
|
29
|
+
},
|
30
|
+
enumerable: false,
|
31
|
+
configurable: true
|
32
|
+
});
|
33
|
+
Object.defineProperty(Screen, "BREAKPOINT", {
|
34
|
+
get: function () {
|
35
|
+
if (window.innerWidth < 576)
|
36
|
+
return 'xs';
|
37
|
+
else if (window.innerWidth >= 576 && window.innerWidth < 768)
|
38
|
+
return 'sm';
|
39
|
+
else if (window.innerWidth >= 768 && window.innerWidth < 992)
|
40
|
+
return 'md';
|
41
|
+
else if (window.innerWidth >= 992 && window.innerWidth < 1200)
|
42
|
+
return 'lg';
|
43
|
+
else if (window.innerWidth >= 1200 && window.innerWidth < 1400)
|
44
|
+
return 'xl';
|
45
|
+
else
|
46
|
+
return 'xxl';
|
47
|
+
},
|
48
|
+
enumerable: false,
|
49
|
+
configurable: true
|
50
|
+
});
|
51
|
+
var _a;
|
52
|
+
_a = Screen;
|
53
|
+
/** */
|
54
|
+
Screen.Resize = new Observable(function (subscriber) {
|
55
|
+
window.addEventListener("load", function () {
|
56
|
+
window.dispatchEvent(new Event('resize'));
|
57
|
+
});
|
58
|
+
window.onresize = function () {
|
59
|
+
subscriber.next({
|
60
|
+
width: window.innerWidth,
|
61
|
+
height: window.innerHeight,
|
62
|
+
breakpoin: _a.BREAKPOINT
|
63
|
+
});
|
64
|
+
};
|
65
|
+
});
|
66
|
+
return Screen;
|
67
|
+
}());
|
68
|
+
export { Screen };
|
@@ -0,0 +1,227 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
14
|
+
if (ar || !(i in from)) {
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
16
|
+
ar[i] = from[i];
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
20
|
+
};
|
21
|
+
import { Guid } from "guid-typescript";
|
22
|
+
import { signal } from "@angular/core";
|
23
|
+
var reference_signal = signal({});
|
24
|
+
export var Tools = {
|
25
|
+
/** Generate a Guid */
|
26
|
+
GetGuid: function (seed) {
|
27
|
+
if (seed === void 0) { seed = 'coer-system'; }
|
28
|
+
return "".concat(seed, "-").concat(Guid.create().toString());
|
29
|
+
},
|
30
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
31
|
+
IsNull: function (value) {
|
32
|
+
if (value === undefined)
|
33
|
+
return true;
|
34
|
+
if (value === null)
|
35
|
+
return true;
|
36
|
+
return false;
|
37
|
+
},
|
38
|
+
/** Returns true if the value is not null or undefined, false otherwise */
|
39
|
+
IsNotNull: function (value) {
|
40
|
+
if (value === undefined)
|
41
|
+
return false;
|
42
|
+
if (value === null)
|
43
|
+
return false;
|
44
|
+
return true;
|
45
|
+
},
|
46
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
47
|
+
IsOnlyWhiteSpace: function (value) {
|
48
|
+
if (value === undefined)
|
49
|
+
return true;
|
50
|
+
if (value === null)
|
51
|
+
return true;
|
52
|
+
if (value.toString().trim() === '')
|
53
|
+
return true;
|
54
|
+
return false;
|
55
|
+
},
|
56
|
+
/** Break reference of a object or array */
|
57
|
+
BreakReference: function (object) {
|
58
|
+
if (object === undefined)
|
59
|
+
return undefined;
|
60
|
+
if (object === null)
|
61
|
+
return null;
|
62
|
+
var OBJECT = JSON.parse(JSON.stringify(object));
|
63
|
+
return (Array.isArray(OBJECT)) ? __spreadArray([], OBJECT, true) : __assign({}, OBJECT);
|
64
|
+
},
|
65
|
+
/** Clean extra whitespaces */
|
66
|
+
CleanUpBlanks: function (text) {
|
67
|
+
if (Tools.IsNull(text))
|
68
|
+
return '';
|
69
|
+
var worlds = String(text).split(' ');
|
70
|
+
worlds = worlds.filter(function (x) { return x.length > 0; });
|
71
|
+
return worlds.join(' ');
|
72
|
+
},
|
73
|
+
/** Get properties of an object */
|
74
|
+
GetObjectProperties: function (obj) {
|
75
|
+
var properties = [];
|
76
|
+
if (Tools.IsNull(obj))
|
77
|
+
return properties;
|
78
|
+
for (var property in obj)
|
79
|
+
properties.push(String(property));
|
80
|
+
return properties;
|
81
|
+
},
|
82
|
+
/**
|
83
|
+
* Set an index and merge more arrays of the same type
|
84
|
+
* @returns A new array
|
85
|
+
* */
|
86
|
+
SetIndex: function (array) {
|
87
|
+
var args = [];
|
88
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
89
|
+
args[_i - 1] = arguments[_i];
|
90
|
+
}
|
91
|
+
var index = 0;
|
92
|
+
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
93
|
+
var arg = args_1[_a];
|
94
|
+
array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
|
95
|
+
}
|
96
|
+
return Tools.BreakReference(array).map(function (item) { return Object.assign({ index: index++ }, item); });
|
97
|
+
},
|
98
|
+
/** Set First Char To Lower */
|
99
|
+
FirstCharToLower: function (text) {
|
100
|
+
if (Tools.IsNull(text))
|
101
|
+
return '';
|
102
|
+
var textArray = [];
|
103
|
+
for (var i = 0; i < text.length; i++) {
|
104
|
+
if (i === 0)
|
105
|
+
textArray.push(text[i].toLowerCase());
|
106
|
+
else
|
107
|
+
textArray.push(text[i]);
|
108
|
+
}
|
109
|
+
return textArray.join('');
|
110
|
+
},
|
111
|
+
/** Set First Char To Upper */
|
112
|
+
FirstCharToUpper: function (text) {
|
113
|
+
if (Tools.IsNull(text))
|
114
|
+
return '';
|
115
|
+
var textArray = [];
|
116
|
+
for (var i = 0; i < text.length; i++) {
|
117
|
+
if (i === 0)
|
118
|
+
textArray.push(text[i].toUpperCase());
|
119
|
+
else
|
120
|
+
textArray.push(text[i]);
|
121
|
+
}
|
122
|
+
return textArray.join('');
|
123
|
+
},
|
124
|
+
/** Sort an array in ascending order by property */
|
125
|
+
SortBy: function (array, property, propertyType) {
|
126
|
+
if (propertyType === void 0) { propertyType = 'string'; }
|
127
|
+
switch (propertyType) {
|
128
|
+
case 'string': {
|
129
|
+
return array.sort(function (x, y) {
|
130
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
131
|
+
return -1;
|
132
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
133
|
+
return 1;
|
134
|
+
else
|
135
|
+
return 0;
|
136
|
+
});
|
137
|
+
}
|
138
|
+
case 'number': {
|
139
|
+
return array.sort(function (x, y) { return Number(x[property] - Number(y[property])); });
|
140
|
+
}
|
141
|
+
}
|
142
|
+
},
|
143
|
+
/** Sort an array in descending order by property */
|
144
|
+
SortByDesc: function (array, property, propertyType) {
|
145
|
+
if (propertyType === void 0) { propertyType = 'string'; }
|
146
|
+
switch (propertyType) {
|
147
|
+
case 'string': {
|
148
|
+
return array.sort(function (x, y) {
|
149
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
150
|
+
return 1;
|
151
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
152
|
+
return -1;
|
153
|
+
else
|
154
|
+
return 0;
|
155
|
+
});
|
156
|
+
}
|
157
|
+
case 'number': {
|
158
|
+
return array.sort(function (x, y) { return Number(Number(y[property])) - x[property]; });
|
159
|
+
}
|
160
|
+
}
|
161
|
+
},
|
162
|
+
/** Return a string with forman numeric */
|
163
|
+
GetNumericFormat: function (value, decimals) {
|
164
|
+
if (decimals === void 0) { decimals = 0; }
|
165
|
+
if (value == undefined
|
166
|
+
|| value == null
|
167
|
+
|| value.toString().trim() == ''
|
168
|
+
|| isNaN(Number(value))) {
|
169
|
+
return '0';
|
170
|
+
}
|
171
|
+
var valueInteger = '';
|
172
|
+
var valueDecimal = '';
|
173
|
+
value = value.toString().replaceAll(' ', '');
|
174
|
+
if (value.includes('.') || (decimals > 0)) {
|
175
|
+
valueInteger = value.includes('.') ? value.split('.')[0] : value;
|
176
|
+
if (decimals > 0) {
|
177
|
+
var PADDING = decimals - valueDecimal.length;
|
178
|
+
valueDecimal = value.includes('.') ? value.split('.')[1] : '';
|
179
|
+
for (var i = 0; i < PADDING; i++)
|
180
|
+
valueDecimal += '0';
|
181
|
+
valueDecimal = valueDecimal.substring(0, decimals);
|
182
|
+
valueDecimal = ".".concat(valueDecimal);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
else {
|
186
|
+
valueInteger = value;
|
187
|
+
}
|
188
|
+
var counter = 0;
|
189
|
+
var VALUE_INTEGER_ARRAY = [];
|
190
|
+
for (var _i = 0, _a = valueInteger.split('').reverse(); _i < _a.length; _i++) {
|
191
|
+
var char = _a[_i];
|
192
|
+
if (counter == 3) {
|
193
|
+
VALUE_INTEGER_ARRAY.push(',');
|
194
|
+
counter = 0;
|
195
|
+
}
|
196
|
+
VALUE_INTEGER_ARRAY.push(char);
|
197
|
+
++counter;
|
198
|
+
}
|
199
|
+
valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
|
200
|
+
return "".concat(valueInteger).concat(valueDecimal);
|
201
|
+
},
|
202
|
+
/** Wait the time indicated */
|
203
|
+
Sleep: function (milliseconds, reference) {
|
204
|
+
if (milliseconds === void 0) { milliseconds = 0; }
|
205
|
+
if (reference === void 0) { reference = null; }
|
206
|
+
if (Tools.IsNull(reference)) {
|
207
|
+
return new Promise(function (Resolve) { return setTimeout(Resolve, milliseconds); });
|
208
|
+
}
|
209
|
+
else
|
210
|
+
return new Promise(function (Resolve) {
|
211
|
+
var _a;
|
212
|
+
reference = reference.replaceAll(' ', '_').toLowerCase();
|
213
|
+
if (reference_signal().hasOwnProperty(reference)) {
|
214
|
+
clearInterval(reference_signal()[reference]);
|
215
|
+
}
|
216
|
+
reference_signal.set(Object.assign(reference_signal(), (_a = {},
|
217
|
+
_a[reference] = setTimeout(function () {
|
218
|
+
Resolve();
|
219
|
+
clearInterval(reference_signal()[reference]);
|
220
|
+
var _reference = __assign({}, reference_signal());
|
221
|
+
delete _reference[reference];
|
222
|
+
reference_signal.set(__assign({}, _reference));
|
223
|
+
}, milliseconds),
|
224
|
+
_a)));
|
225
|
+
});
|
226
|
+
}
|
227
|
+
};
|
package/dist_browser/index.js
CHANGED
@@ -1,150 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
14
|
-
if (ar || !(i in from)) {
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
16
|
-
ar[i] = from[i];
|
17
|
-
}
|
18
|
-
}
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
20
|
-
};
|
21
|
-
export var Tools = {
|
22
|
-
/** Returns true if the value is null or undefined, false otherwise */
|
23
|
-
IsNull: function (value) {
|
24
|
-
if (value === undefined)
|
25
|
-
return true;
|
26
|
-
if (value === null)
|
27
|
-
return true;
|
28
|
-
return false;
|
29
|
-
},
|
30
|
-
/** Returns true if the value is not null or undefined, false otherwise */
|
31
|
-
IsNotNull: function (value) {
|
32
|
-
if (value === undefined)
|
33
|
-
return false;
|
34
|
-
if (value === null)
|
35
|
-
return false;
|
36
|
-
return true;
|
37
|
-
},
|
38
|
-
/** Break reference of a object or array */
|
39
|
-
BreakReference: function (object) {
|
40
|
-
if (object === undefined)
|
41
|
-
return undefined;
|
42
|
-
if (object === null)
|
43
|
-
return null;
|
44
|
-
var OBJECT = JSON.parse(JSON.stringify(object));
|
45
|
-
return (Array.isArray(OBJECT)) ? __spreadArray([], OBJECT, true) : __assign({}, OBJECT);
|
46
|
-
},
|
47
|
-
/** Clean extra whitespaces */
|
48
|
-
CleanUpBlanks: function (text) {
|
49
|
-
if (Tools.IsNull(text))
|
50
|
-
return '';
|
51
|
-
var worlds = String(text).split(' ');
|
52
|
-
worlds = worlds.filter(function (x) { return x.length > 0; });
|
53
|
-
return worlds.join(' ');
|
54
|
-
},
|
55
|
-
/** Get properties of an object */
|
56
|
-
GetObjectProperties: function (obj) {
|
57
|
-
var properties = [];
|
58
|
-
if (Tools.IsNull(obj))
|
59
|
-
return properties;
|
60
|
-
for (var property in obj)
|
61
|
-
properties.push(String(property));
|
62
|
-
return properties;
|
63
|
-
},
|
64
|
-
/**
|
65
|
-
* Set an index and merge more arrays of the same type
|
66
|
-
* @returns A new array
|
67
|
-
* */
|
68
|
-
SetIndex: function (array) {
|
69
|
-
var args = [];
|
70
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
71
|
-
args[_i - 1] = arguments[_i];
|
72
|
-
}
|
73
|
-
var index = 0;
|
74
|
-
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
75
|
-
var arg = args_1[_a];
|
76
|
-
array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
|
77
|
-
}
|
78
|
-
return Tools.BreakReference(array).map(function (item) { return Object.assign({ index: index++ }, item); });
|
79
|
-
},
|
80
|
-
/** Set First Char To Lower */
|
81
|
-
FirstCharToLower: function (text) {
|
82
|
-
if (Tools.IsNull(text))
|
83
|
-
return '';
|
84
|
-
var textArray = [];
|
85
|
-
for (var i = 0; i < text.length; i++) {
|
86
|
-
if (i === 0)
|
87
|
-
textArray.push(text[i].toLowerCase());
|
88
|
-
else
|
89
|
-
textArray.push(text[i]);
|
90
|
-
}
|
91
|
-
return textArray.join('');
|
92
|
-
},
|
93
|
-
/** Set First Char To Upper */
|
94
|
-
FirstCharToUpper: function (text) {
|
95
|
-
if (Tools.IsNull(text))
|
96
|
-
return '';
|
97
|
-
var textArray = [];
|
98
|
-
for (var i = 0; i < text.length; i++) {
|
99
|
-
if (i === 0)
|
100
|
-
textArray.push(text[i].toUpperCase());
|
101
|
-
else
|
102
|
-
textArray.push(text[i]);
|
103
|
-
}
|
104
|
-
return textArray.join('');
|
105
|
-
},
|
106
|
-
/**
|
107
|
-
* Sort an array in ascending order by property
|
108
|
-
* @returns A new array
|
109
|
-
* */
|
110
|
-
SortBy: function (array, property, propertyType) {
|
111
|
-
if (propertyType === void 0) { propertyType = 'string'; }
|
112
|
-
switch (propertyType) {
|
113
|
-
case 'string': {
|
114
|
-
return __spreadArray([], array, true).sort(function (x, y) {
|
115
|
-
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
116
|
-
return -1;
|
117
|
-
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
118
|
-
return 1;
|
119
|
-
else
|
120
|
-
return 0;
|
121
|
-
});
|
122
|
-
}
|
123
|
-
case 'number': {
|
124
|
-
return array.sort(function (x, y) { return Number(x[property] - Number(y[property])); });
|
125
|
-
}
|
126
|
-
}
|
127
|
-
},
|
128
|
-
/**
|
129
|
-
* Sort an array in descending order by property
|
130
|
-
* @returns A new array
|
131
|
-
* */
|
132
|
-
SortByDesc: function (array, property, propertyType) {
|
133
|
-
if (propertyType === void 0) { propertyType = 'string'; }
|
134
|
-
switch (propertyType) {
|
135
|
-
case 'string': {
|
136
|
-
return array.sort(function (x, y) {
|
137
|
-
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
138
|
-
return 1;
|
139
|
-
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
140
|
-
return -1;
|
141
|
-
else
|
142
|
-
return 0;
|
143
|
-
});
|
144
|
-
}
|
145
|
-
case 'number': {
|
146
|
-
return array.sort(function (x, y) { return Number(Number(y[property])) - x[property]; });
|
147
|
-
}
|
148
|
-
}
|
149
|
-
}
|
150
|
-
};
|
1
|
+
export * from './Tools/Tools';
|
2
|
+
export * from './Tools/DateTime.class';
|
3
|
+
export * from './Tools/Files.class';
|
4
|
+
export * from './Tools/Screen.class';
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.DateTime = void 0;
|
4
|
+
var moment_1 = require("moment");
|
5
|
+
var DateTime = /** @class */ (function () {
|
6
|
+
function DateTime() {
|
7
|
+
}
|
8
|
+
/** Get UTC Offset */
|
9
|
+
DateTime.GetUTCOffset = function () {
|
10
|
+
return (0, moment_1.default)().utcOffset();
|
11
|
+
};
|
12
|
+
/** Convert UTC Date to Local Zone */
|
13
|
+
DateTime.ToLocalZone = function (utcDate) {
|
14
|
+
return (0, moment_1.default)(utcDate).add(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
15
|
+
};
|
16
|
+
/** Convert Local Zone Date to UTC */
|
17
|
+
DateTime.ToUTC = function (utcDate) {
|
18
|
+
return (0, moment_1.default)(utcDate).subtract(DateTime.GetUTCOffset(), 'minutes').format('YYYY-MM-DD HH:mm:ss');
|
19
|
+
};
|
20
|
+
/** DD MMM YYYY */
|
21
|
+
DateTime.GetDateFormat = function (date) {
|
22
|
+
if ((typeof date === 'string'))
|
23
|
+
date = date.replaceAll('/', '-');
|
24
|
+
return (0, moment_1.default)(date).parseZone().local(true).format('DD MMM YYYY');
|
25
|
+
};
|
26
|
+
return DateTime;
|
27
|
+
}());
|
28
|
+
exports.DateTime = DateTime;
|
@@ -0,0 +1,102 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Files = void 0;
|
4
|
+
var Tools_1 = require("./Tools");
|
5
|
+
var XLSX = require("xlsx");
|
6
|
+
var Files = /** @class */ (function () {
|
7
|
+
function Files() {
|
8
|
+
}
|
9
|
+
/** Get Extension File */
|
10
|
+
Files.GetExtension = function (file) {
|
11
|
+
var fileName = file.name;
|
12
|
+
if (fileName.includes('.')) {
|
13
|
+
var worlds = fileName.split('.');
|
14
|
+
if (worlds.length > 0) {
|
15
|
+
var extension = worlds.pop();
|
16
|
+
extension = extension.trim().toLowerCase();
|
17
|
+
if (extension.length > 0)
|
18
|
+
return extension;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
return null;
|
22
|
+
};
|
23
|
+
/** Is Excel File */
|
24
|
+
Files.IsExcel = function (file) {
|
25
|
+
var EXTENSION = Files.GetExtension(file);
|
26
|
+
return Tools_1.Tools.IsNotNull(EXTENSION)
|
27
|
+
? this.EXCEL_EXTENSIONS.includes(EXTENSION)
|
28
|
+
: false;
|
29
|
+
};
|
30
|
+
/** Read excel file */
|
31
|
+
Files.ReadExcel = function (file) {
|
32
|
+
return new Promise(function (Resolve) {
|
33
|
+
var columns = [];
|
34
|
+
var rows = [];
|
35
|
+
var reader = new FileReader();
|
36
|
+
reader.readAsArrayBuffer(file);
|
37
|
+
reader.onload = function () {
|
38
|
+
var dataBytes = new Uint8Array(reader.result);
|
39
|
+
if (dataBytes) {
|
40
|
+
var workbook = XLSX.read(dataBytes, {});
|
41
|
+
var sheet = workbook.Sheets[workbook.SheetNames[0]];
|
42
|
+
var dataSheet = XLSX.utils.sheet_to_json(sheet, {
|
43
|
+
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']
|
44
|
+
});
|
45
|
+
//Get Headers
|
46
|
+
for (var column in dataSheet[0]) {
|
47
|
+
columns.push(Tools_1.Tools.FirstCharToLower(String(dataSheet[0][column]).replaceAll(' ', '')));
|
48
|
+
}
|
49
|
+
//Get Rows
|
50
|
+
rows = XLSX.utils.sheet_to_json(sheet, { header: columns });
|
51
|
+
rows.shift();
|
52
|
+
rows = rows.map(function (row) {
|
53
|
+
var item = Tools_1.Tools.BreakReference(row);
|
54
|
+
delete item['__rowNum__'];
|
55
|
+
return item;
|
56
|
+
});
|
57
|
+
}
|
58
|
+
Resolve({ columns: columns, rows: rows });
|
59
|
+
};
|
60
|
+
reader.onerror = function () { Resolve({ columns: columns, rows: rows }); };
|
61
|
+
});
|
62
|
+
};
|
63
|
+
/** Export to excel file */
|
64
|
+
Files.ExportExcel = function (data, fileName, sheetName) {
|
65
|
+
if (fileName === void 0) { fileName = 'coer_report'; }
|
66
|
+
if (sheetName === void 0) { sheetName = 'Sheet1'; }
|
67
|
+
sheetName = Tools_1.Tools.CleanUpBlanks(sheetName);
|
68
|
+
fileName = Tools_1.Tools.CleanUpBlanks(fileName);
|
69
|
+
if (fileName.endsWith('.xls') || fileName.endsWith('.xlsx') || fileName.endsWith('.csv')) {
|
70
|
+
if (fileName.includes('.xls')) {
|
71
|
+
fileName = fileName.replaceAll('.xls', '.xlsx');
|
72
|
+
}
|
73
|
+
if (fileName.includes('.csv')) {
|
74
|
+
fileName = fileName.replaceAll('.csv', '.xlsx');
|
75
|
+
}
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
fileName += '.xlsx';
|
79
|
+
}
|
80
|
+
var WORK_SHEET = XLSX.utils.json_to_sheet(data);
|
81
|
+
var WORK_BOOK = XLSX.utils.book_new();
|
82
|
+
XLSX.utils.book_append_sheet(WORK_BOOK, WORK_SHEET, 'Sheet1');
|
83
|
+
XLSX.writeFile(WORK_BOOK, fileName);
|
84
|
+
};
|
85
|
+
/** Convert file to string base64 */
|
86
|
+
Files.ConvertToBase64 = function (file) {
|
87
|
+
return new Promise(function (Resolve) {
|
88
|
+
var reader = new FileReader();
|
89
|
+
reader.readAsDataURL(file);
|
90
|
+
reader.onload = function () {
|
91
|
+
var _a;
|
92
|
+
Resolve(((_a = reader.result) === null || _a === void 0 ? void 0 : _a.toString()) || '');
|
93
|
+
};
|
94
|
+
reader.onerror = function () {
|
95
|
+
Resolve('');
|
96
|
+
};
|
97
|
+
});
|
98
|
+
};
|
99
|
+
Files.EXCEL_EXTENSIONS = ['xls', 'xlsx', 'csv'];
|
100
|
+
return Files;
|
101
|
+
}());
|
102
|
+
exports.Files = Files;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Screen = void 0;
|
4
|
+
var rxjs_1 = require("rxjs");
|
5
|
+
var Screen = /** @class */ (function () {
|
6
|
+
function Screen() {
|
7
|
+
}
|
8
|
+
Object.defineProperty(Screen, "WINDOW_WIDTH", {
|
9
|
+
get: function () {
|
10
|
+
return window.innerWidth;
|
11
|
+
},
|
12
|
+
enumerable: false,
|
13
|
+
configurable: true
|
14
|
+
});
|
15
|
+
Object.defineProperty(Screen, "WINDOW_HEIGHT", {
|
16
|
+
get: function () {
|
17
|
+
return window.innerHeight;
|
18
|
+
},
|
19
|
+
enumerable: false,
|
20
|
+
configurable: true
|
21
|
+
});
|
22
|
+
Object.defineProperty(Screen, "DEVICE_WIDTH", {
|
23
|
+
get: function () {
|
24
|
+
return window.screen.width;
|
25
|
+
},
|
26
|
+
enumerable: false,
|
27
|
+
configurable: true
|
28
|
+
});
|
29
|
+
Object.defineProperty(Screen, "DEVICE_HEIGHT", {
|
30
|
+
get: function () {
|
31
|
+
return window.screen.height;
|
32
|
+
},
|
33
|
+
enumerable: false,
|
34
|
+
configurable: true
|
35
|
+
});
|
36
|
+
Object.defineProperty(Screen, "BREAKPOINT", {
|
37
|
+
get: function () {
|
38
|
+
if (window.innerWidth < 576)
|
39
|
+
return 'xs';
|
40
|
+
else if (window.innerWidth >= 576 && window.innerWidth < 768)
|
41
|
+
return 'sm';
|
42
|
+
else if (window.innerWidth >= 768 && window.innerWidth < 992)
|
43
|
+
return 'md';
|
44
|
+
else if (window.innerWidth >= 992 && window.innerWidth < 1200)
|
45
|
+
return 'lg';
|
46
|
+
else if (window.innerWidth >= 1200 && window.innerWidth < 1400)
|
47
|
+
return 'xl';
|
48
|
+
else
|
49
|
+
return 'xxl';
|
50
|
+
},
|
51
|
+
enumerable: false,
|
52
|
+
configurable: true
|
53
|
+
});
|
54
|
+
var _a;
|
55
|
+
_a = Screen;
|
56
|
+
/** */
|
57
|
+
Screen.Resize = new rxjs_1.Observable(function (subscriber) {
|
58
|
+
window.addEventListener("load", function () {
|
59
|
+
window.dispatchEvent(new Event('resize'));
|
60
|
+
});
|
61
|
+
window.onresize = function () {
|
62
|
+
subscriber.next({
|
63
|
+
width: window.innerWidth,
|
64
|
+
height: window.innerHeight,
|
65
|
+
breakpoin: _a.BREAKPOINT
|
66
|
+
});
|
67
|
+
};
|
68
|
+
});
|
69
|
+
return Screen;
|
70
|
+
}());
|
71
|
+
exports.Screen = Screen;
|
@@ -0,0 +1,230 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
15
|
+
if (ar || !(i in from)) {
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
17
|
+
ar[i] = from[i];
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
21
|
+
};
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
23
|
+
exports.Tools = void 0;
|
24
|
+
var guid_typescript_1 = require("guid-typescript");
|
25
|
+
var core_1 = require("@angular/core");
|
26
|
+
var reference_signal = (0, core_1.signal)({});
|
27
|
+
exports.Tools = {
|
28
|
+
/** Generate a Guid */
|
29
|
+
GetGuid: function (seed) {
|
30
|
+
if (seed === void 0) { seed = 'coer-system'; }
|
31
|
+
return "".concat(seed, "-").concat(guid_typescript_1.Guid.create().toString());
|
32
|
+
},
|
33
|
+
/** Returns true if the value is null or undefined, false otherwise */
|
34
|
+
IsNull: function (value) {
|
35
|
+
if (value === undefined)
|
36
|
+
return true;
|
37
|
+
if (value === null)
|
38
|
+
return true;
|
39
|
+
return false;
|
40
|
+
},
|
41
|
+
/** Returns true if the value is not null or undefined, false otherwise */
|
42
|
+
IsNotNull: function (value) {
|
43
|
+
if (value === undefined)
|
44
|
+
return false;
|
45
|
+
if (value === null)
|
46
|
+
return false;
|
47
|
+
return true;
|
48
|
+
},
|
49
|
+
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
50
|
+
IsOnlyWhiteSpace: function (value) {
|
51
|
+
if (value === undefined)
|
52
|
+
return true;
|
53
|
+
if (value === null)
|
54
|
+
return true;
|
55
|
+
if (value.toString().trim() === '')
|
56
|
+
return true;
|
57
|
+
return false;
|
58
|
+
},
|
59
|
+
/** Break reference of a object or array */
|
60
|
+
BreakReference: function (object) {
|
61
|
+
if (object === undefined)
|
62
|
+
return undefined;
|
63
|
+
if (object === null)
|
64
|
+
return null;
|
65
|
+
var OBJECT = JSON.parse(JSON.stringify(object));
|
66
|
+
return (Array.isArray(OBJECT)) ? __spreadArray([], OBJECT, true) : __assign({}, OBJECT);
|
67
|
+
},
|
68
|
+
/** Clean extra whitespaces */
|
69
|
+
CleanUpBlanks: function (text) {
|
70
|
+
if (exports.Tools.IsNull(text))
|
71
|
+
return '';
|
72
|
+
var worlds = String(text).split(' ');
|
73
|
+
worlds = worlds.filter(function (x) { return x.length > 0; });
|
74
|
+
return worlds.join(' ');
|
75
|
+
},
|
76
|
+
/** Get properties of an object */
|
77
|
+
GetObjectProperties: function (obj) {
|
78
|
+
var properties = [];
|
79
|
+
if (exports.Tools.IsNull(obj))
|
80
|
+
return properties;
|
81
|
+
for (var property in obj)
|
82
|
+
properties.push(String(property));
|
83
|
+
return properties;
|
84
|
+
},
|
85
|
+
/**
|
86
|
+
* Set an index and merge more arrays of the same type
|
87
|
+
* @returns A new array
|
88
|
+
* */
|
89
|
+
SetIndex: function (array) {
|
90
|
+
var args = [];
|
91
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
92
|
+
args[_i - 1] = arguments[_i];
|
93
|
+
}
|
94
|
+
var index = 0;
|
95
|
+
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
96
|
+
var arg = args_1[_a];
|
97
|
+
array = exports.Tools.BreakReference(array).concat(exports.Tools.BreakReference(arg));
|
98
|
+
}
|
99
|
+
return exports.Tools.BreakReference(array).map(function (item) { return Object.assign({ index: index++ }, item); });
|
100
|
+
},
|
101
|
+
/** Set First Char To Lower */
|
102
|
+
FirstCharToLower: function (text) {
|
103
|
+
if (exports.Tools.IsNull(text))
|
104
|
+
return '';
|
105
|
+
var textArray = [];
|
106
|
+
for (var i = 0; i < text.length; i++) {
|
107
|
+
if (i === 0)
|
108
|
+
textArray.push(text[i].toLowerCase());
|
109
|
+
else
|
110
|
+
textArray.push(text[i]);
|
111
|
+
}
|
112
|
+
return textArray.join('');
|
113
|
+
},
|
114
|
+
/** Set First Char To Upper */
|
115
|
+
FirstCharToUpper: function (text) {
|
116
|
+
if (exports.Tools.IsNull(text))
|
117
|
+
return '';
|
118
|
+
var textArray = [];
|
119
|
+
for (var i = 0; i < text.length; i++) {
|
120
|
+
if (i === 0)
|
121
|
+
textArray.push(text[i].toUpperCase());
|
122
|
+
else
|
123
|
+
textArray.push(text[i]);
|
124
|
+
}
|
125
|
+
return textArray.join('');
|
126
|
+
},
|
127
|
+
/** Sort an array in ascending order by property */
|
128
|
+
SortBy: function (array, property, propertyType) {
|
129
|
+
if (propertyType === void 0) { propertyType = 'string'; }
|
130
|
+
switch (propertyType) {
|
131
|
+
case 'string': {
|
132
|
+
return array.sort(function (x, y) {
|
133
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
134
|
+
return -1;
|
135
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
136
|
+
return 1;
|
137
|
+
else
|
138
|
+
return 0;
|
139
|
+
});
|
140
|
+
}
|
141
|
+
case 'number': {
|
142
|
+
return array.sort(function (x, y) { return Number(x[property] - Number(y[property])); });
|
143
|
+
}
|
144
|
+
}
|
145
|
+
},
|
146
|
+
/** Sort an array in descending order by property */
|
147
|
+
SortByDesc: function (array, property, propertyType) {
|
148
|
+
if (propertyType === void 0) { propertyType = 'string'; }
|
149
|
+
switch (propertyType) {
|
150
|
+
case 'string': {
|
151
|
+
return array.sort(function (x, y) {
|
152
|
+
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
153
|
+
return 1;
|
154
|
+
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
155
|
+
return -1;
|
156
|
+
else
|
157
|
+
return 0;
|
158
|
+
});
|
159
|
+
}
|
160
|
+
case 'number': {
|
161
|
+
return array.sort(function (x, y) { return Number(Number(y[property])) - x[property]; });
|
162
|
+
}
|
163
|
+
}
|
164
|
+
},
|
165
|
+
/** Return a string with forman numeric */
|
166
|
+
GetNumericFormat: function (value, decimals) {
|
167
|
+
if (decimals === void 0) { decimals = 0; }
|
168
|
+
if (value == undefined
|
169
|
+
|| value == null
|
170
|
+
|| value.toString().trim() == ''
|
171
|
+
|| isNaN(Number(value))) {
|
172
|
+
return '0';
|
173
|
+
}
|
174
|
+
var valueInteger = '';
|
175
|
+
var valueDecimal = '';
|
176
|
+
value = value.toString().replaceAll(' ', '');
|
177
|
+
if (value.includes('.') || (decimals > 0)) {
|
178
|
+
valueInteger = value.includes('.') ? value.split('.')[0] : value;
|
179
|
+
if (decimals > 0) {
|
180
|
+
var PADDING = decimals - valueDecimal.length;
|
181
|
+
valueDecimal = value.includes('.') ? value.split('.')[1] : '';
|
182
|
+
for (var i = 0; i < PADDING; i++)
|
183
|
+
valueDecimal += '0';
|
184
|
+
valueDecimal = valueDecimal.substring(0, decimals);
|
185
|
+
valueDecimal = ".".concat(valueDecimal);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
else {
|
189
|
+
valueInteger = value;
|
190
|
+
}
|
191
|
+
var counter = 0;
|
192
|
+
var VALUE_INTEGER_ARRAY = [];
|
193
|
+
for (var _i = 0, _a = valueInteger.split('').reverse(); _i < _a.length; _i++) {
|
194
|
+
var char = _a[_i];
|
195
|
+
if (counter == 3) {
|
196
|
+
VALUE_INTEGER_ARRAY.push(',');
|
197
|
+
counter = 0;
|
198
|
+
}
|
199
|
+
VALUE_INTEGER_ARRAY.push(char);
|
200
|
+
++counter;
|
201
|
+
}
|
202
|
+
valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
|
203
|
+
return "".concat(valueInteger).concat(valueDecimal);
|
204
|
+
},
|
205
|
+
/** Wait the time indicated */
|
206
|
+
Sleep: function (milliseconds, reference) {
|
207
|
+
if (milliseconds === void 0) { milliseconds = 0; }
|
208
|
+
if (reference === void 0) { reference = null; }
|
209
|
+
if (exports.Tools.IsNull(reference)) {
|
210
|
+
return new Promise(function (Resolve) { return setTimeout(Resolve, milliseconds); });
|
211
|
+
}
|
212
|
+
else
|
213
|
+
return new Promise(function (Resolve) {
|
214
|
+
var _a;
|
215
|
+
reference = reference.replaceAll(' ', '_').toLowerCase();
|
216
|
+
if (reference_signal().hasOwnProperty(reference)) {
|
217
|
+
clearInterval(reference_signal()[reference]);
|
218
|
+
}
|
219
|
+
reference_signal.set(Object.assign(reference_signal(), (_a = {},
|
220
|
+
_a[reference] = setTimeout(function () {
|
221
|
+
Resolve();
|
222
|
+
clearInterval(reference_signal()[reference]);
|
223
|
+
var _reference = __assign({}, reference_signal());
|
224
|
+
delete _reference[reference];
|
225
|
+
reference_signal.set(__assign({}, _reference));
|
226
|
+
}, milliseconds),
|
227
|
+
_a)));
|
228
|
+
});
|
229
|
+
}
|
230
|
+
};
|
package/dist_node/index.js
CHANGED
@@ -1,153 +1,20 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
t[p] = s[p];
|
8
|
-
}
|
9
|
-
return t;
|
10
|
-
};
|
11
|
-
return __assign.apply(this, arguments);
|
12
|
-
};
|
13
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
14
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
15
|
-
if (ar || !(i in from)) {
|
16
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
17
|
-
ar[i] = from[i];
|
18
|
-
}
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
19
7
|
}
|
20
|
-
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
21
15
|
};
|
22
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
if (value === undefined)
|
28
|
-
return true;
|
29
|
-
if (value === null)
|
30
|
-
return true;
|
31
|
-
return false;
|
32
|
-
},
|
33
|
-
/** Returns true if the value is not null or undefined, false otherwise */
|
34
|
-
IsNotNull: function (value) {
|
35
|
-
if (value === undefined)
|
36
|
-
return false;
|
37
|
-
if (value === null)
|
38
|
-
return false;
|
39
|
-
return true;
|
40
|
-
},
|
41
|
-
/** Break reference of a object or array */
|
42
|
-
BreakReference: function (object) {
|
43
|
-
if (object === undefined)
|
44
|
-
return undefined;
|
45
|
-
if (object === null)
|
46
|
-
return null;
|
47
|
-
var OBJECT = JSON.parse(JSON.stringify(object));
|
48
|
-
return (Array.isArray(OBJECT)) ? __spreadArray([], OBJECT, true) : __assign({}, OBJECT);
|
49
|
-
},
|
50
|
-
/** Clean extra whitespaces */
|
51
|
-
CleanUpBlanks: function (text) {
|
52
|
-
if (exports.Tools.IsNull(text))
|
53
|
-
return '';
|
54
|
-
var worlds = String(text).split(' ');
|
55
|
-
worlds = worlds.filter(function (x) { return x.length > 0; });
|
56
|
-
return worlds.join(' ');
|
57
|
-
},
|
58
|
-
/** Get properties of an object */
|
59
|
-
GetObjectProperties: function (obj) {
|
60
|
-
var properties = [];
|
61
|
-
if (exports.Tools.IsNull(obj))
|
62
|
-
return properties;
|
63
|
-
for (var property in obj)
|
64
|
-
properties.push(String(property));
|
65
|
-
return properties;
|
66
|
-
},
|
67
|
-
/**
|
68
|
-
* Set an index and merge more arrays of the same type
|
69
|
-
* @returns A new array
|
70
|
-
* */
|
71
|
-
SetIndex: function (array) {
|
72
|
-
var args = [];
|
73
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
74
|
-
args[_i - 1] = arguments[_i];
|
75
|
-
}
|
76
|
-
var index = 0;
|
77
|
-
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
78
|
-
var arg = args_1[_a];
|
79
|
-
array = exports.Tools.BreakReference(array).concat(exports.Tools.BreakReference(arg));
|
80
|
-
}
|
81
|
-
return exports.Tools.BreakReference(array).map(function (item) { return Object.assign({ index: index++ }, item); });
|
82
|
-
},
|
83
|
-
/** Set First Char To Lower */
|
84
|
-
FirstCharToLower: function (text) {
|
85
|
-
if (exports.Tools.IsNull(text))
|
86
|
-
return '';
|
87
|
-
var textArray = [];
|
88
|
-
for (var i = 0; i < text.length; i++) {
|
89
|
-
if (i === 0)
|
90
|
-
textArray.push(text[i].toLowerCase());
|
91
|
-
else
|
92
|
-
textArray.push(text[i]);
|
93
|
-
}
|
94
|
-
return textArray.join('');
|
95
|
-
},
|
96
|
-
/** Set First Char To Upper */
|
97
|
-
FirstCharToUpper: function (text) {
|
98
|
-
if (exports.Tools.IsNull(text))
|
99
|
-
return '';
|
100
|
-
var textArray = [];
|
101
|
-
for (var i = 0; i < text.length; i++) {
|
102
|
-
if (i === 0)
|
103
|
-
textArray.push(text[i].toUpperCase());
|
104
|
-
else
|
105
|
-
textArray.push(text[i]);
|
106
|
-
}
|
107
|
-
return textArray.join('');
|
108
|
-
},
|
109
|
-
/**
|
110
|
-
* Sort an array in ascending order by property
|
111
|
-
* @returns A new array
|
112
|
-
* */
|
113
|
-
SortBy: function (array, property, propertyType) {
|
114
|
-
if (propertyType === void 0) { propertyType = 'string'; }
|
115
|
-
switch (propertyType) {
|
116
|
-
case 'string': {
|
117
|
-
return __spreadArray([], array, true).sort(function (x, y) {
|
118
|
-
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
119
|
-
return -1;
|
120
|
-
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
121
|
-
return 1;
|
122
|
-
else
|
123
|
-
return 0;
|
124
|
-
});
|
125
|
-
}
|
126
|
-
case 'number': {
|
127
|
-
return array.sort(function (x, y) { return Number(x[property] - Number(y[property])); });
|
128
|
-
}
|
129
|
-
}
|
130
|
-
},
|
131
|
-
/**
|
132
|
-
* Sort an array in descending order by property
|
133
|
-
* @returns A new array
|
134
|
-
* */
|
135
|
-
SortByDesc: function (array, property, propertyType) {
|
136
|
-
if (propertyType === void 0) { propertyType = 'string'; }
|
137
|
-
switch (propertyType) {
|
138
|
-
case 'string': {
|
139
|
-
return array.sort(function (x, y) {
|
140
|
-
if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
|
141
|
-
return 1;
|
142
|
-
else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
|
143
|
-
return -1;
|
144
|
-
else
|
145
|
-
return 0;
|
146
|
-
});
|
147
|
-
}
|
148
|
-
case 'number': {
|
149
|
-
return array.sort(function (x, y) { return Number(Number(y[property])) - x[property]; });
|
150
|
-
}
|
151
|
-
}
|
152
|
-
}
|
153
|
-
};
|
17
|
+
__exportStar(require("./Tools/Tools"), exports);
|
18
|
+
__exportStar(require("./Tools/DateTime.class"), exports);
|
19
|
+
__exportStar(require("./Tools/Files.class"), exports);
|
20
|
+
__exportStar(require("./Tools/Screen.class"), exports);
|
package/index.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "coer-elements",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.7",
|
4
4
|
"author": "Christian Omar Escamilla Rodríguez",
|
5
5
|
"keywords": [
|
6
6
|
"coer",
|
@@ -22,13 +22,13 @@
|
|
22
22
|
"push": "npm publish --access public"
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
+
"@angular/core": "^17.3.0",
|
25
26
|
"guid-typescript": "^1.0.9",
|
26
27
|
"moment": "^2.30.1",
|
27
28
|
"rxjs": "^7.8.1",
|
28
29
|
"xlsx": "^0.18.5"
|
29
30
|
},
|
30
31
|
"devDependencies": {
|
31
|
-
"@types/xlsx": "^0.0.36",
|
32
32
|
"typescript": "^5.5.4"
|
33
33
|
}
|
34
34
|
}
|
package/tsconfig.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
|
+
"compileOnSave": false,
|
2
3
|
"compilerOptions": {
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
4
4
|
"outDir": "./dist/out-tsc",
|
5
5
|
"strict": true,
|
6
6
|
"noImplicitOverride": true,
|
@@ -19,5 +19,11 @@
|
|
19
19
|
"useDefineForClassFields": false,
|
20
20
|
"lib": ["ES2022", "dom"],
|
21
21
|
"baseUrl": "./"
|
22
|
+
},
|
23
|
+
"angularCompilerOptions": {
|
24
|
+
"enableI18nLegacyMessageIdFormat": false,
|
25
|
+
"strictInjectionParameters": true,
|
26
|
+
"strictInputAccessModifiers": true,
|
27
|
+
"strictTemplates": true
|
22
28
|
}
|
23
29
|
}
|