coer-elements 0.0.5 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/esm2022/index.mjs +2 -2
  2. package/esm2022/{Tools → tools}/index.mjs +1 -1
  3. package/esm2022/{Tools → tools}/src/Breadcrumbs.class.mjs +2 -2
  4. package/esm2022/{Tools → tools}/src/ControlValue.mjs +1 -1
  5. package/esm2022/{Tools → tools}/src/DateTime.class.mjs +1 -1
  6. package/esm2022/{Tools → tools}/src/Files.class.mjs +2 -2
  7. package/esm2022/tools/src/Page.class.mjs +162 -0
  8. package/esm2022/{Tools → tools}/src/Screen.class.mjs +1 -1
  9. package/esm2022/tools/src/Source.class.mjs +80 -0
  10. package/esm2022/{Tools → tools}/src/Tools.mjs +1 -1
  11. package/fesm2022/coer-elements.mjs +333 -333
  12. package/fesm2022/coer-elements.mjs.map +1 -1
  13. package/index.d.ts +1 -1
  14. package/package.json +1 -1
  15. package/{Tools → tools}/src/Breadcrumbs.class.ts +1 -1
  16. package/{Tools → tools}/src/Files.class.ts +1 -1
  17. package/{Tools → tools}/src/Page.class.ts +4 -2
  18. package/{Tools → tools}/src/Source.class.ts +2 -1
  19. package/Signals/index.ts +0 -3
  20. package/Signals/src/breakpoint.signal.ts +0 -3
  21. package/Signals/src/isLoading.signal.ts +0 -2
  22. package/Signals/src/isModalOpen.signal.ts +0 -2
  23. package/esm2022/Tools/src/Page.class.mjs +0 -160
  24. package/esm2022/Tools/src/Source.class.mjs +0 -79
  25. /package/{Tools → tools}/index.d.ts +0 -0
  26. /package/{Tools → tools}/index.ts +0 -0
  27. /package/{Tools → tools}/src/Breadcrumbs.class.d.ts +0 -0
  28. /package/{Tools → tools}/src/ControlValue.d.ts +0 -0
  29. /package/{Tools → tools}/src/ControlValue.ts +0 -0
  30. /package/{Tools → tools}/src/DateTime.class.d.ts +0 -0
  31. /package/{Tools → tools}/src/DateTime.class.ts +0 -0
  32. /package/{Tools → tools}/src/Files.class.d.ts +0 -0
  33. /package/{Tools → tools}/src/Page.class.d.ts +0 -0
  34. /package/{Tools → tools}/src/Screen.class.d.ts +0 -0
  35. /package/{Tools → tools}/src/Screen.class.ts +0 -0
  36. /package/{Tools → tools}/src/Source.class.d.ts +0 -0
  37. /package/{Tools → tools}/src/Tools.d.ts +0 -0
  38. /package/{Tools → tools}/src/Tools.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { forwardRef, Component, NgModule, inject, Inject, signal } from '@angular/core';
2
+ import { signal, forwardRef, Component, NgModule, inject, Inject } from '@angular/core';
3
3
  import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
4
4
  import moment from 'moment';
5
5
  import * as XLSX from 'xlsx';
@@ -9,6 +9,205 @@ import * as bootstrap from 'bootstrap';
9
9
  import Swal from 'sweetalert2';
10
10
  import { Observable } from 'rxjs';
11
11
 
12
+ const reference_signal = signal({});
13
+ const Tools = {
14
+ /** Generate a Guid */
15
+ GetGuid: (seed = 'coer-system') => {
16
+ let time = new Date().getTime();
17
+ seed = seed.toString().trim();
18
+ return seed + `-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
19
+ const random = (time + Math.random() * 16) % 16 | 0;
20
+ time = Math.floor(time / 16);
21
+ return (c == 'x' ? random : (random & 0x3 | 0x8)).toString(16);
22
+ });
23
+ },
24
+ /** Returns true if the value is null or undefined, false otherwise */
25
+ IsNull: (value) => {
26
+ if (value === undefined)
27
+ return true;
28
+ if (value === null)
29
+ return true;
30
+ return false;
31
+ },
32
+ /** Returns true if the value is not null or undefined, false otherwise */
33
+ IsNotNull: (value) => {
34
+ if (value === undefined)
35
+ return false;
36
+ if (value === null)
37
+ return false;
38
+ return true;
39
+ },
40
+ /** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
41
+ IsOnlyWhiteSpace: (value) => {
42
+ if (value === undefined)
43
+ return true;
44
+ if (value === null)
45
+ return true;
46
+ if (value.toString().trim() === '')
47
+ return true;
48
+ return false;
49
+ },
50
+ /** Break reference of a object or array */
51
+ BreakReference: (object) => {
52
+ if (object === undefined)
53
+ return undefined;
54
+ if (object === null)
55
+ return null;
56
+ const OBJECT = JSON.parse(JSON.stringify(object));
57
+ return (Array.isArray(OBJECT)) ? [...OBJECT] : { ...OBJECT };
58
+ },
59
+ /** Clean extra whitespaces */
60
+ CleanUpBlanks: (text) => {
61
+ if (Tools.IsNull(text))
62
+ return '';
63
+ let worlds = String(text).split(' ');
64
+ worlds = worlds.filter(x => x.length > 0);
65
+ return worlds.join(' ');
66
+ },
67
+ /** Get properties of an object */
68
+ GetObjectProperties: (obj) => {
69
+ const properties = [];
70
+ if (Tools.IsNull(obj))
71
+ return properties;
72
+ for (const property in obj)
73
+ properties.push(String(property));
74
+ return properties;
75
+ },
76
+ /**
77
+ * Set an index and merge more arrays of the same type
78
+ * @returns A new array
79
+ * */
80
+ SetIndex: (array, ...args) => {
81
+ let index = 0;
82
+ for (const arg of args) {
83
+ array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
84
+ }
85
+ return Tools.BreakReference(array).map(item => Object.assign({ index: index++ }, item));
86
+ },
87
+ /** Set First Char To Lower */
88
+ FirstCharToLower: (text) => {
89
+ if (Tools.IsNull(text))
90
+ return '';
91
+ const textArray = [];
92
+ for (let i = 0; i < text.length; i++) {
93
+ if (i === 0)
94
+ textArray.push(text[i].toLowerCase());
95
+ else
96
+ textArray.push(text[i]);
97
+ }
98
+ return textArray.join('');
99
+ },
100
+ /** Set First Char To Upper */
101
+ FirstCharToUpper: (text) => {
102
+ if (Tools.IsNull(text))
103
+ return '';
104
+ const textArray = [];
105
+ for (let i = 0; i < text.length; i++) {
106
+ if (i === 0)
107
+ textArray.push(text[i].toUpperCase());
108
+ else
109
+ textArray.push(text[i]);
110
+ }
111
+ return textArray.join('');
112
+ },
113
+ /** Sort an array in ascending order by property */
114
+ SortBy: (array, property, propertyType = 'string') => {
115
+ switch (propertyType) {
116
+ case 'string': {
117
+ return array.sort((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((x, y) => Number(x[property] - Number(y[property])));
128
+ }
129
+ }
130
+ },
131
+ /** Sort an array in descending order by property */
132
+ SortByDesc: (array, property, propertyType = 'string') => {
133
+ switch (propertyType) {
134
+ case 'string': {
135
+ return array.sort((x, y) => {
136
+ if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
137
+ return 1;
138
+ else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
139
+ return -1;
140
+ else
141
+ return 0;
142
+ });
143
+ }
144
+ case 'number': {
145
+ return array.sort((x, y) => Number(Number(y[property])) - x[property]);
146
+ }
147
+ }
148
+ },
149
+ /** Return a string with forman numeric */
150
+ GetNumericFormat: (value, decimals = 0) => {
151
+ if (value == undefined
152
+ || value == null
153
+ || value.toString().trim() == ''
154
+ || isNaN(Number(value))) {
155
+ return '0';
156
+ }
157
+ let valueInteger = '';
158
+ let valueDecimal = '';
159
+ value = value.toString().replaceAll(' ', '');
160
+ if (value.includes('.') || (decimals > 0)) {
161
+ valueInteger = value.includes('.') ? value.split('.')[0] : value;
162
+ if (decimals > 0) {
163
+ const PADDING = decimals - valueDecimal.length;
164
+ valueDecimal = value.includes('.') ? value.split('.')[1] : '';
165
+ for (let i = 0; i < PADDING; i++)
166
+ valueDecimal += '0';
167
+ valueDecimal = valueDecimal.substring(0, decimals);
168
+ valueDecimal = `.${valueDecimal}`;
169
+ }
170
+ }
171
+ else {
172
+ valueInteger = value;
173
+ }
174
+ let counter = 0;
175
+ const VALUE_INTEGER_ARRAY = [];
176
+ for (const char of valueInteger.split('').reverse()) {
177
+ if (counter == 3) {
178
+ VALUE_INTEGER_ARRAY.push(',');
179
+ counter = 0;
180
+ }
181
+ VALUE_INTEGER_ARRAY.push(char);
182
+ ++counter;
183
+ }
184
+ valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
185
+ return `${valueInteger}${valueDecimal}`;
186
+ },
187
+ /** Wait the time indicated */
188
+ Sleep: (milliseconds = 0, reference = null) => {
189
+ if (Tools.IsNull(reference)) {
190
+ return new Promise(Resolve => setTimeout(Resolve, milliseconds));
191
+ }
192
+ else
193
+ return new Promise(Resolve => {
194
+ reference = reference.replaceAll(' ', '_').toLowerCase();
195
+ if (reference_signal().hasOwnProperty(reference)) {
196
+ clearInterval(reference_signal()[reference]);
197
+ }
198
+ reference_signal.set(Object.assign(reference_signal(), {
199
+ [reference]: setTimeout(() => {
200
+ Resolve();
201
+ clearInterval(reference_signal()[reference]);
202
+ const _reference = { ...reference_signal() };
203
+ delete _reference[reference];
204
+ reference_signal.set({ ..._reference });
205
+ }, milliseconds)
206
+ }));
207
+ });
208
+ }
209
+ };
210
+
12
211
  class Breadcrumbs {
13
212
  static { this.storage = 'COER-System'; }
14
213
  /** */
@@ -524,63 +723,139 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
524
723
  }]
525
724
  }] });
526
725
 
527
- class Page {
528
- constructor(page) {
529
- //Injection
530
- this.alert = inject(CoerAlert);
531
- this.router = inject(Router);
532
- this.activatedRoute = inject(ActivatedRoute);
533
- /** */
534
- this.isUpdate = false;
535
- /** */
536
- this.isLoading = false;
537
- /** */
538
- this.isReady = false;
539
- /** */
540
- this.enableAnimations = false;
541
- /** */
542
- this.breadcrumbs = [];
543
- /** */
544
- this.pageResponse = null;
545
- /** */
546
- this.goBack = { show: false };
547
- //Private Variables
548
- this._page = '';
549
- this._source = null;
550
- this._preventDestroy = false;
551
- /** */
552
- this.GoBack = (path) => (() => {
553
- if (path)
554
- Breadcrumbs.Remove(path);
555
- else
556
- Breadcrumbs.RemoveLast();
557
- });
558
- /** Returns true if the value is null or undefined, false otherwise */
559
- this.IsNotNull = Tools.IsNotNull;
560
- /** Returns true if the value is null or undefined, false otherwise */
561
- this.IsNull = Tools.IsNull;
562
- /** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
563
- this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
564
- this.SetPageName(page);
565
- this.SetSource();
566
- this.GetSource();
567
- this.GetNavigation();
568
- this.SetGoBack();
569
- this.GetPageResponse();
570
- }
571
- ngAfterViewInit() {
572
- this.routeParams = this.activatedRoute.snapshot.params;
573
- this.queryParams = this.activatedRoute.snapshot.queryParams;
574
- setTimeout(() => {
575
- this.isReady = true;
576
- this.RunPage();
577
- setTimeout(() => { this.enableAnimations = true; }, 1000);
578
- });
579
- }
580
- ngOnDestroy() {
581
- if (!this._preventDestroy)
582
- Source.ClearPageResponse();
583
- }
726
+ class Source {
727
+ static { this.storage = 'COER-System'; }
728
+ /** */
729
+ static Set(page) {
730
+ const ROUTER = inject(Router);
731
+ let path = ROUTER.url;
732
+ if (path.includes('?'))
733
+ path = path.split('?')[0];
734
+ Breadcrumbs.Add(page, path);
735
+ const breadcrumbs = Breadcrumbs.Get();
736
+ if (breadcrumbs.length >= 2) {
737
+ breadcrumbs.pop();
738
+ const breadcrumb = breadcrumbs.pop();
739
+ this.Save({ page: breadcrumb.page, path: breadcrumb.path });
740
+ }
741
+ else
742
+ this.Save(null);
743
+ }
744
+ /** */
745
+ static Save(source) {
746
+ let storage = sessionStorage.getItem(this.storage);
747
+ if (storage)
748
+ storage = JSON.parse(storage);
749
+ storage = Object.assign({}, storage, { source });
750
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
751
+ }
752
+ /** */
753
+ static Get() {
754
+ let storage = sessionStorage.getItem(this.storage);
755
+ if (storage) {
756
+ storage = JSON.parse(storage);
757
+ if (storage.hasOwnProperty('source')) {
758
+ return storage.source;
759
+ }
760
+ }
761
+ return null;
762
+ }
763
+ /** */
764
+ static GetRoot() {
765
+ const breadcrumbs = Breadcrumbs.Get();
766
+ return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
767
+ }
768
+ /** */
769
+ static SetPageResponse(pageResponse) {
770
+ let storage = sessionStorage.getItem(this.storage);
771
+ storage = JSON.parse(storage);
772
+ storage = Object.assign({}, storage, { pageResponse });
773
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
774
+ }
775
+ /** */
776
+ static GetPageResponse() {
777
+ let storage = sessionStorage.getItem(this.storage);
778
+ if (storage) {
779
+ storage = JSON.parse(storage);
780
+ if (storage.hasOwnProperty('pageResponse')) {
781
+ return Tools.BreakReference(storage.pageResponse);
782
+ }
783
+ }
784
+ return null;
785
+ }
786
+ /** */
787
+ static ClearPageResponse() {
788
+ let storage = sessionStorage.getItem(this.storage);
789
+ storage = JSON.parse(storage);
790
+ if (storage.hasOwnProperty('pageResponse')) {
791
+ delete storage.pageResponse;
792
+ }
793
+ storage = Object.assign({}, storage);
794
+ sessionStorage.setItem(this.storage, JSON.stringify(storage));
795
+ }
796
+ /** Clear Source */
797
+ static Reset() {
798
+ sessionStorage.removeItem(this.storage);
799
+ }
800
+ }
801
+
802
+ class Page {
803
+ constructor(page) {
804
+ //Injection
805
+ this.alert = inject(CoerAlert);
806
+ this.router = inject(Router);
807
+ this.activatedRoute = inject(ActivatedRoute);
808
+ /** */
809
+ this.isUpdate = false;
810
+ /** */
811
+ this.isLoading = false;
812
+ /** */
813
+ this.isReady = false;
814
+ /** */
815
+ this.enableAnimations = false;
816
+ /** */
817
+ this.breadcrumbs = [];
818
+ /** */
819
+ this.pageResponse = null;
820
+ /** */
821
+ this.goBack = { show: false };
822
+ //Private Variables
823
+ this._page = '';
824
+ this._source = null;
825
+ this._preventDestroy = false;
826
+ /** */
827
+ this.GoBack = (path) => (() => {
828
+ if (path)
829
+ Breadcrumbs.Remove(path);
830
+ else
831
+ Breadcrumbs.RemoveLast();
832
+ });
833
+ /** Returns true if the value is null or undefined, false otherwise */
834
+ this.IsNotNull = Tools.IsNotNull;
835
+ /** Returns true if the value is null or undefined, false otherwise */
836
+ this.IsNull = Tools.IsNull;
837
+ /** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
838
+ this.IsOnlyWhiteSpace = Tools.IsOnlyWhiteSpace;
839
+ this.SetPageName(page);
840
+ this.SetSource();
841
+ this.GetSource();
842
+ this.GetNavigation();
843
+ this.SetGoBack();
844
+ this.GetPageResponse();
845
+ }
846
+ ngAfterViewInit() {
847
+ this.routeParams = this.activatedRoute.snapshot.params;
848
+ this.queryParams = this.activatedRoute.snapshot.queryParams;
849
+ setTimeout(() => {
850
+ this.isReady = true;
851
+ this.RunPage();
852
+ setTimeout(() => { this.enableAnimations = true; }, 1000);
853
+ });
854
+ }
855
+ ngOnDestroy() {
856
+ if (!this._preventDestroy)
857
+ Source.ClearPageResponse();
858
+ }
584
859
  /** Main method. Starts after ngAfterViewInit() */
585
860
  RunPage() { }
586
861
  ;
@@ -721,281 +996,6 @@ class Screen {
721
996
  }); }
722
997
  }
723
998
 
724
- class Source {
725
- static { this.storage = 'COER-System'; }
726
- /** */
727
- static Set(page) {
728
- const ROUTER = inject(Router);
729
- let path = ROUTER.url;
730
- if (path.includes('?'))
731
- path = path.split('?')[0];
732
- Breadcrumbs.Add(page, path);
733
- const breadcrumbs = Breadcrumbs.Get();
734
- if (breadcrumbs.length >= 2) {
735
- breadcrumbs.pop();
736
- const breadcrumb = breadcrumbs.pop();
737
- this.Save({ page: breadcrumb.page, path: breadcrumb.path });
738
- }
739
- else
740
- this.Save(null);
741
- }
742
- /** */
743
- static Save(source) {
744
- let storage = sessionStorage.getItem(this.storage);
745
- if (storage)
746
- storage = JSON.parse(storage);
747
- storage = Object.assign({}, storage, { source });
748
- sessionStorage.setItem(this.storage, JSON.stringify(storage));
749
- }
750
- /** */
751
- static Get() {
752
- let storage = sessionStorage.getItem(this.storage);
753
- if (storage) {
754
- storage = JSON.parse(storage);
755
- if (storage.hasOwnProperty('source')) {
756
- return storage.source;
757
- }
758
- }
759
- return null;
760
- }
761
- /** */
762
- static GetRoot() {
763
- const breadcrumbs = Breadcrumbs.Get();
764
- return (breadcrumbs.length > 0) ? breadcrumbs.shift() : null;
765
- }
766
- /** */
767
- static SetPageResponse(pageResponse) {
768
- let storage = sessionStorage.getItem(this.storage);
769
- storage = JSON.parse(storage);
770
- storage = Object.assign({}, storage, { pageResponse });
771
- sessionStorage.setItem(this.storage, JSON.stringify(storage));
772
- }
773
- /** */
774
- static GetPageResponse() {
775
- let storage = sessionStorage.getItem(this.storage);
776
- if (storage) {
777
- storage = JSON.parse(storage);
778
- if (storage.hasOwnProperty('pageResponse')) {
779
- return Tools.BreakReference(storage.pageResponse);
780
- }
781
- }
782
- return null;
783
- }
784
- /** */
785
- static ClearPageResponse() {
786
- let storage = sessionStorage.getItem(this.storage);
787
- storage = JSON.parse(storage);
788
- if (storage.hasOwnProperty('pageResponse')) {
789
- delete storage.pageResponse;
790
- }
791
- storage = Object.assign({}, storage);
792
- sessionStorage.setItem(this.storage, JSON.stringify(storage));
793
- }
794
- /** Clear Source */
795
- static Reset() {
796
- sessionStorage.removeItem(this.storage);
797
- }
798
- }
799
-
800
- const reference_signal = signal({});
801
- const Tools = {
802
- /** Generate a Guid */
803
- GetGuid: (seed = 'coer-system') => {
804
- let time = new Date().getTime();
805
- seed = seed.toString().trim();
806
- return seed + `-xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, (c) => {
807
- const random = (time + Math.random() * 16) % 16 | 0;
808
- time = Math.floor(time / 16);
809
- return (c == 'x' ? random : (random & 0x3 | 0x8)).toString(16);
810
- });
811
- },
812
- /** Returns true if the value is null or undefined, false otherwise */
813
- IsNull: (value) => {
814
- if (value === undefined)
815
- return true;
816
- if (value === null)
817
- return true;
818
- return false;
819
- },
820
- /** Returns true if the value is not null or undefined, false otherwise */
821
- IsNotNull: (value) => {
822
- if (value === undefined)
823
- return false;
824
- if (value === null)
825
- return false;
826
- return true;
827
- },
828
- /** Returns true if the value is null or undefined or contains only whitespace, false otherwise */
829
- IsOnlyWhiteSpace: (value) => {
830
- if (value === undefined)
831
- return true;
832
- if (value === null)
833
- return true;
834
- if (value.toString().trim() === '')
835
- return true;
836
- return false;
837
- },
838
- /** Break reference of a object or array */
839
- BreakReference: (object) => {
840
- if (object === undefined)
841
- return undefined;
842
- if (object === null)
843
- return null;
844
- const OBJECT = JSON.parse(JSON.stringify(object));
845
- return (Array.isArray(OBJECT)) ? [...OBJECT] : { ...OBJECT };
846
- },
847
- /** Clean extra whitespaces */
848
- CleanUpBlanks: (text) => {
849
- if (Tools.IsNull(text))
850
- return '';
851
- let worlds = String(text).split(' ');
852
- worlds = worlds.filter(x => x.length > 0);
853
- return worlds.join(' ');
854
- },
855
- /** Get properties of an object */
856
- GetObjectProperties: (obj) => {
857
- const properties = [];
858
- if (Tools.IsNull(obj))
859
- return properties;
860
- for (const property in obj)
861
- properties.push(String(property));
862
- return properties;
863
- },
864
- /**
865
- * Set an index and merge more arrays of the same type
866
- * @returns A new array
867
- * */
868
- SetIndex: (array, ...args) => {
869
- let index = 0;
870
- for (const arg of args) {
871
- array = Tools.BreakReference(array).concat(Tools.BreakReference(arg));
872
- }
873
- return Tools.BreakReference(array).map(item => Object.assign({ index: index++ }, item));
874
- },
875
- /** Set First Char To Lower */
876
- FirstCharToLower: (text) => {
877
- if (Tools.IsNull(text))
878
- return '';
879
- const textArray = [];
880
- for (let i = 0; i < text.length; i++) {
881
- if (i === 0)
882
- textArray.push(text[i].toLowerCase());
883
- else
884
- textArray.push(text[i]);
885
- }
886
- return textArray.join('');
887
- },
888
- /** Set First Char To Upper */
889
- FirstCharToUpper: (text) => {
890
- if (Tools.IsNull(text))
891
- return '';
892
- const textArray = [];
893
- for (let i = 0; i < text.length; i++) {
894
- if (i === 0)
895
- textArray.push(text[i].toUpperCase());
896
- else
897
- textArray.push(text[i]);
898
- }
899
- return textArray.join('');
900
- },
901
- /** Sort an array in ascending order by property */
902
- SortBy: (array, property, propertyType = 'string') => {
903
- switch (propertyType) {
904
- case 'string': {
905
- return array.sort((x, y) => {
906
- if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
907
- return -1;
908
- else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
909
- return 1;
910
- else
911
- return 0;
912
- });
913
- }
914
- case 'number': {
915
- return array.sort((x, y) => Number(x[property] - Number(y[property])));
916
- }
917
- }
918
- },
919
- /** Sort an array in descending order by property */
920
- SortByDesc: (array, property, propertyType = 'string') => {
921
- switch (propertyType) {
922
- case 'string': {
923
- return array.sort((x, y) => {
924
- if (String(x[property]).toUpperCase().trim() < String(y[property]).toUpperCase().trim())
925
- return 1;
926
- else if (String(x[property]).toUpperCase().trim() > String(y[property]).toUpperCase().trim())
927
- return -1;
928
- else
929
- return 0;
930
- });
931
- }
932
- case 'number': {
933
- return array.sort((x, y) => Number(Number(y[property])) - x[property]);
934
- }
935
- }
936
- },
937
- /** Return a string with forman numeric */
938
- GetNumericFormat: (value, decimals = 0) => {
939
- if (value == undefined
940
- || value == null
941
- || value.toString().trim() == ''
942
- || isNaN(Number(value))) {
943
- return '0';
944
- }
945
- let valueInteger = '';
946
- let valueDecimal = '';
947
- value = value.toString().replaceAll(' ', '');
948
- if (value.includes('.') || (decimals > 0)) {
949
- valueInteger = value.includes('.') ? value.split('.')[0] : value;
950
- if (decimals > 0) {
951
- const PADDING = decimals - valueDecimal.length;
952
- valueDecimal = value.includes('.') ? value.split('.')[1] : '';
953
- for (let i = 0; i < PADDING; i++)
954
- valueDecimal += '0';
955
- valueDecimal = valueDecimal.substring(0, decimals);
956
- valueDecimal = `.${valueDecimal}`;
957
- }
958
- }
959
- else {
960
- valueInteger = value;
961
- }
962
- let counter = 0;
963
- const VALUE_INTEGER_ARRAY = [];
964
- for (const char of valueInteger.split('').reverse()) {
965
- if (counter == 3) {
966
- VALUE_INTEGER_ARRAY.push(',');
967
- counter = 0;
968
- }
969
- VALUE_INTEGER_ARRAY.push(char);
970
- ++counter;
971
- }
972
- valueInteger = VALUE_INTEGER_ARRAY.reverse().join('');
973
- return `${valueInteger}${valueDecimal}`;
974
- },
975
- /** Wait the time indicated */
976
- Sleep: (milliseconds = 0, reference = null) => {
977
- if (Tools.IsNull(reference)) {
978
- return new Promise(Resolve => setTimeout(Resolve, milliseconds));
979
- }
980
- else
981
- return new Promise(Resolve => {
982
- reference = reference.replaceAll(' ', '_').toLowerCase();
983
- if (reference_signal().hasOwnProperty(reference)) {
984
- clearInterval(reference_signal()[reference]);
985
- }
986
- reference_signal.set(Object.assign(reference_signal(), {
987
- [reference]: setTimeout(() => {
988
- Resolve();
989
- clearInterval(reference_signal()[reference]);
990
- const _reference = { ...reference_signal() };
991
- delete _reference[reference];
992
- reference_signal.set({ ..._reference });
993
- }, milliseconds)
994
- }));
995
- });
996
- }
997
- };
998
-
999
999
  /**
1000
1000
  * Generated bundle index. Do not edit.
1001
1001
  */