coer-elements 1.0.14 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- package/Tools/Page.class.ts +1 -1
- package/components/index.ts +0 -1
- package/package.json +5 -2
- package/dist_browser/Tools/Breadcrumbs.class.js +0 -66
- package/dist_browser/Tools/ControlValue.js +0 -49
- package/dist_browser/Tools/DateTime.class.js +0 -25
- package/dist_browser/Tools/Files.class.js +0 -99
- package/dist_browser/Tools/Page.class.js +0 -213
- package/dist_browser/Tools/Screen.class.js +0 -68
- package/dist_browser/Tools/Source.class.js +0 -83
- package/dist_browser/Tools/Tools.js +0 -227
- package/dist_browser/index.js +0 -8
- package/dist_node/Tools/Breadcrumbs.class.js +0 -69
- package/dist_node/Tools/ControlValue.js +0 -53
- package/dist_node/Tools/DateTime.class.js +0 -28
- package/dist_node/Tools/Files.class.js +0 -102
- package/dist_node/Tools/Page.class.js +0 -216
- package/dist_node/Tools/Screen.class.js +0 -71
- package/dist_node/Tools/Source.class.js +0 -86
- package/dist_node/Tools/Tools.js +0 -230
- package/dist_node/components/coer-alert/coer-alert.component.js +0 -317
- package/dist_node/components/index.js +0 -168
- package/dist_node/index.js +0 -24
- package/dist_node/interfaces/index.js +0 -2
@@ -1,216 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
7
|
-
var _, done = false;
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
9
|
-
var context = {};
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
14
|
-
if (kind === "accessor") {
|
15
|
-
if (result === void 0) continue;
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
20
|
-
}
|
21
|
-
else if (_ = accept(result)) {
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
23
|
-
else descriptor[key] = _;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
27
|
-
done = true;
|
28
|
-
};
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
30
|
-
var useValue = arguments.length > 2;
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
33
|
-
}
|
34
|
-
return useValue ? value : void 0;
|
35
|
-
};
|
36
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
37
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
38
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
39
|
-
};
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
41
|
-
exports.Page = void 0;
|
42
|
-
var core_1 = require("@angular/core");
|
43
|
-
var Breadcrumbs_class_1 = require("./Breadcrumbs.class");
|
44
|
-
var Source_class_1 = require("./Source.class");
|
45
|
-
var components_1 = require("../components");
|
46
|
-
var router_1 = require("@angular/router");
|
47
|
-
var Tools_1 = require("./Tools");
|
48
|
-
var Page = function () {
|
49
|
-
var _classDecorators = [(0, core_1.Component)({ template: '' })];
|
50
|
-
var _classDescriptor;
|
51
|
-
var _classExtraInitializers = [];
|
52
|
-
var _classThis;
|
53
|
-
var Page = _classThis = /** @class */ (function () {
|
54
|
-
function Page_1(page) {
|
55
|
-
//Injection
|
56
|
-
this.alert = (0, core_1.inject)(components_1.CoerAlert);
|
57
|
-
this.router = (0, core_1.inject)(router_1.Router);
|
58
|
-
this.activatedRoute = (0, core_1.inject)(router_1.ActivatedRoute);
|
59
|
-
/** */
|
60
|
-
this.isUpdate = false;
|
61
|
-
/** */
|
62
|
-
this.isLoading = false;
|
63
|
-
/** */
|
64
|
-
this.isReady = false;
|
65
|
-
/** */
|
66
|
-
this.enableAnimations = false;
|
67
|
-
/** */
|
68
|
-
this.breadcrumbs = [];
|
69
|
-
/** */
|
70
|
-
this.pageResponse = null;
|
71
|
-
/** */
|
72
|
-
this.goBack = { show: false };
|
73
|
-
//Private Variables
|
74
|
-
this._page = '';
|
75
|
-
this._source = null;
|
76
|
-
this._preventDestroy = false;
|
77
|
-
/** */
|
78
|
-
this.GoBack = function (path) { return (function () {
|
79
|
-
if (path)
|
80
|
-
Breadcrumbs_class_1.Breadcrumbs.Remove(path);
|
81
|
-
else
|
82
|
-
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
83
|
-
}); };
|
84
|
-
/** Returns true if the value is null or undefined, false otherwise */
|
85
|
-
this.IsNotNull = Tools_1.Tools.IsNotNull;
|
86
|
-
/** Returns true if the value is null or undefined, false otherwise */
|
87
|
-
this.IsNull = Tools_1.Tools.IsNull;
|
88
|
-
/** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
|
89
|
-
this.IsOnlyWhiteSpace = Tools_1.Tools.IsOnlyWhiteSpace;
|
90
|
-
this.SetPageName(page);
|
91
|
-
this.SetSource();
|
92
|
-
this.GetSource();
|
93
|
-
this.GetNavigation();
|
94
|
-
this.SetGoBack();
|
95
|
-
this.GetPageResponse();
|
96
|
-
}
|
97
|
-
Page_1.prototype.ngAfterViewInit = function () {
|
98
|
-
var _this = this;
|
99
|
-
this.routeParams = this.activatedRoute.snapshot.params;
|
100
|
-
this.queryParams = this.activatedRoute.snapshot.queryParams;
|
101
|
-
setTimeout(function () {
|
102
|
-
_this.isReady = true;
|
103
|
-
_this.RunPage();
|
104
|
-
setTimeout(function () { _this.enableAnimations = true; }, 1000);
|
105
|
-
});
|
106
|
-
};
|
107
|
-
Page_1.prototype.ngOnDestroy = function () {
|
108
|
-
if (!this._preventDestroy)
|
109
|
-
Source_class_1.Source.ClearPageResponse();
|
110
|
-
};
|
111
|
-
/** Main method. Starts after ngAfterViewInit() */
|
112
|
-
Page_1.prototype.RunPage = function () { };
|
113
|
-
;
|
114
|
-
/** Rename the last breadcrumb and update the url id */
|
115
|
-
Page_1.prototype.SetPageName = function (name, id) {
|
116
|
-
if (id === void 0) { id = null; }
|
117
|
-
this._page = name;
|
118
|
-
var path = this.router.url;
|
119
|
-
if (path.includes('?'))
|
120
|
-
path = path.split('?')[0];
|
121
|
-
if (id) {
|
122
|
-
var PATH_ARRAY = path.split('/');
|
123
|
-
var PATH_ID = Tools_1.Tools.BreakReference(PATH_ARRAY).pop();
|
124
|
-
if (PATH_ID) {
|
125
|
-
PATH_ARRAY[PATH_ARRAY.length - 1] = String(id);
|
126
|
-
path = PATH_ARRAY.join('/');
|
127
|
-
}
|
128
|
-
}
|
129
|
-
if (this.breadcrumbs.length > 0) {
|
130
|
-
this.breadcrumbs[this.breadcrumbs.length - 1].page = name;
|
131
|
-
this.breadcrumbs[this.breadcrumbs.length - 1].path = path;
|
132
|
-
Breadcrumbs_class_1.Breadcrumbs.SetLast(name, path);
|
133
|
-
}
|
134
|
-
this.router.navigateByUrl(path);
|
135
|
-
};
|
136
|
-
/** */
|
137
|
-
Page_1.prototype.SetSource = function () {
|
138
|
-
Source_class_1.Source.Set(this._page);
|
139
|
-
};
|
140
|
-
/** */
|
141
|
-
Page_1.prototype.GetSource = function () {
|
142
|
-
this._source = Source_class_1.Source.Get();
|
143
|
-
};
|
144
|
-
/** */
|
145
|
-
Page_1.prototype.GetPageResponse = function () {
|
146
|
-
this.pageResponse = Source_class_1.Source.GetPageResponse();
|
147
|
-
};
|
148
|
-
/** */
|
149
|
-
Page_1.prototype.GetNavigation = function () {
|
150
|
-
var _this = this;
|
151
|
-
if (this._source) {
|
152
|
-
this.breadcrumbs = Breadcrumbs_class_1.Breadcrumbs.Get().map(function (item) { return Object.assign({
|
153
|
-
page: item.page,
|
154
|
-
path: item.path,
|
155
|
-
click: _this.GoBack(item.path)
|
156
|
-
}); });
|
157
|
-
}
|
158
|
-
else
|
159
|
-
this.breadcrumbs = [{ page: this._page }];
|
160
|
-
};
|
161
|
-
/** */
|
162
|
-
Page_1.prototype.SetGoBack = function () {
|
163
|
-
if (this._source) {
|
164
|
-
this.goBack = {
|
165
|
-
show: true,
|
166
|
-
path: this._source.path,
|
167
|
-
click: this.GoBack()
|
168
|
-
};
|
169
|
-
}
|
170
|
-
};
|
171
|
-
/** Navigate to previous page */
|
172
|
-
Page_1.prototype.GoToSource = function (pageResponse) {
|
173
|
-
var _this = this;
|
174
|
-
if (pageResponse === void 0) { pageResponse = null; }
|
175
|
-
if (this._source) {
|
176
|
-
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
177
|
-
this.SetPageResponse(pageResponse);
|
178
|
-
Tools_1.Tools.Sleep().then(function (_) { return _this.router.navigateByUrl(_this._source.path); });
|
179
|
-
}
|
180
|
-
};
|
181
|
-
;
|
182
|
-
/** */
|
183
|
-
Page_1.prototype.SetPageResponse = function (pageResponse) {
|
184
|
-
if (pageResponse === void 0) { pageResponse = null; }
|
185
|
-
if (Tools_1.Tools.IsNotNull(pageResponse)) {
|
186
|
-
this._preventDestroy = true;
|
187
|
-
Source_class_1.Source.SetPageResponse(pageResponse);
|
188
|
-
}
|
189
|
-
};
|
190
|
-
;
|
191
|
-
/** */
|
192
|
-
Page_1.prototype.ReloadPage = function () {
|
193
|
-
Breadcrumbs_class_1.Breadcrumbs.RemoveLast();
|
194
|
-
Tools_1.Tools.Sleep().then(function (_) { return window.location.reload(); });
|
195
|
-
};
|
196
|
-
/** */
|
197
|
-
Page_1.prototype.Log = function (value, log) {
|
198
|
-
if (log === void 0) { log = null; }
|
199
|
-
if (Tools_1.Tools.IsNotNull(log))
|
200
|
-
console.log({ log: log, value: value });
|
201
|
-
else
|
202
|
-
console.log(value);
|
203
|
-
};
|
204
|
-
return Page_1;
|
205
|
-
}());
|
206
|
-
__setFunctionName(_classThis, "Page");
|
207
|
-
(function () {
|
208
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
209
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
210
|
-
Page = _classThis = _classDescriptor.value;
|
211
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
212
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
213
|
-
})();
|
214
|
-
return Page = _classThis;
|
215
|
-
}();
|
216
|
-
exports.Page = Page;
|
@@ -1,71 +0,0 @@
|
|
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;
|
@@ -1,86 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Source = void 0;
|
4
|
-
var Breadcrumbs_class_1 = require("./Breadcrumbs.class");
|
5
|
-
var router_1 = require("@angular/router");
|
6
|
-
var core_1 = require("@angular/core");
|
7
|
-
var Tools_1 = require("./Tools");
|
8
|
-
var Source = /** @class */ (function () {
|
9
|
-
function Source() {
|
10
|
-
}
|
11
|
-
/** */
|
12
|
-
Source.Set = function (page) {
|
13
|
-
var ROUTER = (0, core_1.inject)(router_1.Router);
|
14
|
-
var path = ROUTER.url;
|
15
|
-
if (path.includes('?'))
|
16
|
-
path = path.split('?')[0];
|
17
|
-
Breadcrumbs_class_1.Breadcrumbs.Add(page, path);
|
18
|
-
var breadcrumbs = Breadcrumbs_class_1.Breadcrumbs.Get();
|
19
|
-
if (breadcrumbs.length >= 2) {
|
20
|
-
breadcrumbs.pop();
|
21
|
-
var breadcrumb = breadcrumbs.pop();
|
22
|
-
this.Save({ page: breadcrumb.page, path: breadcrumb.path });
|
23
|
-
}
|
24
|
-
else
|
25
|
-
this.Save(null);
|
26
|
-
};
|
27
|
-
/** */
|
28
|
-
Source.Save = function (source) {
|
29
|
-
var storage = sessionStorage.getItem(this.storage);
|
30
|
-
if (storage)
|
31
|
-
storage = JSON.parse(storage);
|
32
|
-
storage = Object.assign({}, storage, { source: source });
|
33
|
-
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
34
|
-
};
|
35
|
-
/** */
|
36
|
-
Source.Get = function () {
|
37
|
-
var storage = sessionStorage.getItem(this.storage);
|
38
|
-
if (storage) {
|
39
|
-
storage = JSON.parse(storage);
|
40
|
-
if (storage.hasOwnProperty('source')) {
|
41
|
-
return storage.source;
|
42
|
-
}
|
43
|
-
}
|
44
|
-
return null;
|
45
|
-
};
|
46
|
-
/** */
|
47
|
-
Source.GetRoot = function () {
|
48
|
-
var breadcrumbs = Breadcrumbs_class_1.Breadcrumbs.Get();
|
49
|
-
return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
|
50
|
-
};
|
51
|
-
/** */
|
52
|
-
Source.SetPageResponse = function (pageResponse) {
|
53
|
-
var storage = sessionStorage.getItem(this.storage);
|
54
|
-
storage = JSON.parse(storage);
|
55
|
-
storage = Object.assign({}, storage, { pageResponse: pageResponse });
|
56
|
-
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
57
|
-
};
|
58
|
-
/** */
|
59
|
-
Source.GetPageResponse = function () {
|
60
|
-
var storage = sessionStorage.getItem(this.storage);
|
61
|
-
if (storage) {
|
62
|
-
storage = JSON.parse(storage);
|
63
|
-
if (storage.hasOwnProperty('pageResponse')) {
|
64
|
-
return Tools_1.Tools.BreakReference(storage.pageResponse);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
return null;
|
68
|
-
};
|
69
|
-
/** */
|
70
|
-
Source.ClearPageResponse = function () {
|
71
|
-
var storage = sessionStorage.getItem(this.storage);
|
72
|
-
storage = JSON.parse(storage);
|
73
|
-
if (storage.hasOwnProperty('pageResponse')) {
|
74
|
-
delete storage.pageResponse;
|
75
|
-
}
|
76
|
-
storage = Object.assign({}, storage);
|
77
|
-
sessionStorage.setItem(this.storage, JSON.stringify(storage));
|
78
|
-
};
|
79
|
-
/** Clear Source */
|
80
|
-
Source.Reset = function () {
|
81
|
-
sessionStorage.removeItem(this.storage);
|
82
|
-
};
|
83
|
-
Source.storage = 'COER-System';
|
84
|
-
return Source;
|
85
|
-
}());
|
86
|
-
exports.Source = Source;
|
package/dist_node/Tools/Tools.js
DELETED
@@ -1,230 +0,0 @@
|
|
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
|
-
};
|