tailjng 0.0.43 → 0.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/settings/header-generator.js +1 -1
- package/fesm2022/tailjng.mjs +201 -101
- package/fesm2022/tailjng.mjs.map +1 -1
- package/lib/services/crud/converter-crud.service.d.ts +3 -1
- package/lib/services/transformer/transform.service.d.ts +86 -0
- package/package.json +2 -2
- package/src/lib/components/badge/badge.component.html +2 -2
- package/src/lib/components/badge/badge.component.ts +1 -1
- package/src/lib/components/card/card-crud-complete/complete-crud-card.component.html +16 -14
- package/src/lib/components/card/card-crud-complete/complete-crud-card.component.ts +12 -5
- package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.component.html +93 -83
- package/src/lib/components/select/select-multi-dropdown/multi-dropdown-select.component.ts +188 -64
- package/src/lib/components/table/table-complete/complete-table.component.html +2 -3
- package/src/lib/components/table/table-crud-complete/complete-crud-table.component.html +3 -3
- package/src/lib/components/table/table-crud-complete/complete-crud-table.component.ts +0 -5
package/fesm2022/tailjng.mjs
CHANGED
|
@@ -598,13 +598,192 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
598
598
|
}]
|
|
599
599
|
}] });
|
|
600
600
|
|
|
601
|
-
class
|
|
601
|
+
class JTransformService {
|
|
602
602
|
currencyPipe;
|
|
603
603
|
calendarService;
|
|
604
604
|
constructor(currencyPipe, calendarService) {
|
|
605
605
|
this.currencyPipe = currencyPipe;
|
|
606
606
|
this.calendarService = calendarService;
|
|
607
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Verify if the value is a valid JSON string.
|
|
610
|
+
* @param value
|
|
611
|
+
* @returns
|
|
612
|
+
*/
|
|
613
|
+
isJson(value) {
|
|
614
|
+
try {
|
|
615
|
+
JSON.parse(value);
|
|
616
|
+
return true;
|
|
617
|
+
}
|
|
618
|
+
catch (e) {
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Parse a JSON string and return the array.
|
|
624
|
+
* @param value The JSON string to parse.
|
|
625
|
+
* @returns The parsed array.
|
|
626
|
+
*/
|
|
627
|
+
parseJson(value) {
|
|
628
|
+
return JSON.parse(value);
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Capitalize the first letter of each word and lowercase the rest.
|
|
632
|
+
* @param name The input string to capitalize.
|
|
633
|
+
* @returns The capitalized string.
|
|
634
|
+
*/
|
|
635
|
+
capitalizeText(name) {
|
|
636
|
+
return name
|
|
637
|
+
.trim()
|
|
638
|
+
.toLowerCase()
|
|
639
|
+
.split(' ')
|
|
640
|
+
.filter(Boolean)
|
|
641
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
642
|
+
.join(' ');
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Format a number as currency.
|
|
646
|
+
* @param value
|
|
647
|
+
* @param currency
|
|
648
|
+
* @returns
|
|
649
|
+
*/
|
|
650
|
+
formatCurrency(value, currency) {
|
|
651
|
+
const transformedValue = this.currencyPipe.transform(value, currency, 'symbol', '1.2-2');
|
|
652
|
+
return transformedValue ? transformedValue.replace('US', '') : null;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Format a date to DMY format.
|
|
656
|
+
* @param value
|
|
657
|
+
* @returns
|
|
658
|
+
*/
|
|
659
|
+
formatDate(value) {
|
|
660
|
+
return this.calendarService.formatDateStringToDMY(`${value}`);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Format a date to long format.
|
|
664
|
+
* @param value
|
|
665
|
+
* @returns
|
|
666
|
+
*/
|
|
667
|
+
formatDateText(value) {
|
|
668
|
+
return this.calendarService.formatDateStringToLong(`${value}`);
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Format a date-time to locale string.
|
|
672
|
+
* @param value
|
|
673
|
+
* @returns
|
|
674
|
+
*/
|
|
675
|
+
formatDateTime(value) {
|
|
676
|
+
return new Date(value).toLocaleString();
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Format a date-time to string.
|
|
680
|
+
* @param value
|
|
681
|
+
* @returns
|
|
682
|
+
*/
|
|
683
|
+
formatDateTimeText(value) {
|
|
684
|
+
return new Date(value).toString();
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Format a value to relative time.
|
|
688
|
+
* @param value
|
|
689
|
+
* @returns
|
|
690
|
+
*/
|
|
691
|
+
formatRelativeTime(value) {
|
|
692
|
+
return this.calendarService.formatRelativeDate(value);
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Format to get the first word of a string.
|
|
696
|
+
* @param value
|
|
697
|
+
* @returns
|
|
698
|
+
*/
|
|
699
|
+
formatFirstWord(value) {
|
|
700
|
+
return value.split(' ')[0];
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Format a phone number to Ecuadorian format.
|
|
704
|
+
* @param value
|
|
705
|
+
* @returns
|
|
706
|
+
*/
|
|
707
|
+
formatPhoneEcuadorian(value) {
|
|
708
|
+
if (value.startsWith('+593')) {
|
|
709
|
+
const restOfNumber = value.slice(4);
|
|
710
|
+
return `+593 ${restOfNumber}`;
|
|
711
|
+
}
|
|
712
|
+
if (value.startsWith('0')) {
|
|
713
|
+
return `+593 ${value.replace(/^0/, '')}`;
|
|
714
|
+
}
|
|
715
|
+
if (value.startsWith('9')) {
|
|
716
|
+
return `+593 ${value}`;
|
|
717
|
+
}
|
|
718
|
+
return value;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Clean value based on the column type.
|
|
722
|
+
* @param value
|
|
723
|
+
* @param column
|
|
724
|
+
* @returns
|
|
725
|
+
*/
|
|
726
|
+
cleanValue(value, column) {
|
|
727
|
+
let cleaned = value;
|
|
728
|
+
if (typeof cleaned === 'string') {
|
|
729
|
+
cleaned = cleaned.trim();
|
|
730
|
+
}
|
|
731
|
+
return cleaned;
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Parse a currency string to number.
|
|
735
|
+
* @param value
|
|
736
|
+
* @returns
|
|
737
|
+
*/
|
|
738
|
+
parseCurrency(value) {
|
|
739
|
+
return value ? parseFloat(value.replace(/[^\d,.-]/g, '').replace(',', '.')) : null;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Parse a date text to ISO format.
|
|
743
|
+
* @param value
|
|
744
|
+
* @returns
|
|
745
|
+
*/
|
|
746
|
+
parseDateText(value) {
|
|
747
|
+
const parsedDate = this.calendarService.parseDateString(value);
|
|
748
|
+
return parsedDate ?? value;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Parse a date to ISO format.
|
|
752
|
+
* @param value
|
|
753
|
+
* @returns
|
|
754
|
+
*/
|
|
755
|
+
parseDate(value) {
|
|
756
|
+
const date = new Date(value);
|
|
757
|
+
return isNaN(date.getTime()) ? value : date.toISOString().substring(0, 10);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Parse a date-time to ISO format.
|
|
761
|
+
* @param value
|
|
762
|
+
* @returns
|
|
763
|
+
*/
|
|
764
|
+
parseDateTime(value) {
|
|
765
|
+
const date = new Date(value);
|
|
766
|
+
return isNaN(date.getTime()) ? value : date.toISOString();
|
|
767
|
+
}
|
|
768
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JTransformService, deps: [{ token: i1.CurrencyPipe }, { token: JCalendarService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
769
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JTransformService, providedIn: 'root' });
|
|
770
|
+
}
|
|
771
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JTransformService, decorators: [{
|
|
772
|
+
type: Injectable,
|
|
773
|
+
args: [{
|
|
774
|
+
providedIn: 'root'
|
|
775
|
+
}]
|
|
776
|
+
}], ctorParameters: () => [{ type: i1.CurrencyPipe }, { type: JCalendarService }] });
|
|
777
|
+
|
|
778
|
+
class JConverterCrudService {
|
|
779
|
+
currencyPipe;
|
|
780
|
+
calendarService;
|
|
781
|
+
transformService;
|
|
782
|
+
constructor(currencyPipe, calendarService, transformService) {
|
|
783
|
+
this.currencyPipe = currencyPipe;
|
|
784
|
+
this.calendarService = calendarService;
|
|
785
|
+
this.transformService = transformService;
|
|
786
|
+
}
|
|
608
787
|
/**
|
|
609
788
|
* Get the correct sort key from the sortColumn object or string.
|
|
610
789
|
* @param sortColumn The column to sort by, can be a string or an object with a 'col' property.
|
|
@@ -636,45 +815,31 @@ class JConverterCrudService {
|
|
|
636
815
|
*/
|
|
637
816
|
formatData(value, column) {
|
|
638
817
|
if (column.isdollar && value !== null) {
|
|
639
|
-
|
|
640
|
-
return transformedValue ? transformedValue.replace('US', '') : null;
|
|
818
|
+
return this.transformService.formatCurrency(value, 'USD');
|
|
641
819
|
}
|
|
642
820
|
if (column.isCurrency && value !== null) {
|
|
643
|
-
return this.
|
|
821
|
+
return this.transformService.formatCurrency(value, 'USD');
|
|
644
822
|
}
|
|
645
823
|
if (column.isDate && value !== null) {
|
|
646
|
-
return this.
|
|
824
|
+
return this.transformService.formatDate(value);
|
|
647
825
|
}
|
|
648
826
|
if (column.isDateText && value !== null) {
|
|
649
|
-
return this.
|
|
827
|
+
return this.transformService.formatDateText(value);
|
|
650
828
|
}
|
|
651
829
|
if (column.isDateTime && value !== null) {
|
|
652
|
-
return
|
|
830
|
+
return this.transformService.formatDateTime(value);
|
|
653
831
|
}
|
|
654
832
|
if (column.isDateTimeText && value !== null) {
|
|
655
|
-
return
|
|
833
|
+
return this.transformService.formatDateTimeText(value);
|
|
656
834
|
}
|
|
657
835
|
if (column.isRelativeTime && value !== null) {
|
|
658
|
-
return this.
|
|
836
|
+
return this.transformService.formatRelativeTime(value);
|
|
659
837
|
}
|
|
660
838
|
if (column.isFirstWord && value !== null) {
|
|
661
|
-
return
|
|
839
|
+
return this.transformService.formatFirstWord(value);
|
|
662
840
|
}
|
|
663
841
|
if (column.isPhoneEcuadorian && value !== null) {
|
|
664
|
-
|
|
665
|
-
if (value.startsWith('+593')) {
|
|
666
|
-
const restOfNumber = value.slice(4);
|
|
667
|
-
return `+593 ${restOfNumber}`;
|
|
668
|
-
}
|
|
669
|
-
// Si el número empieza con 0, reemplazar el 0 por +593
|
|
670
|
-
if (value.startsWith('0')) {
|
|
671
|
-
return `+593 ${value.replace(/^0/, '')}`;
|
|
672
|
-
}
|
|
673
|
-
// Si el número empieza con 9 (y no tiene +593), agregar +593 al principio
|
|
674
|
-
if (value.startsWith('9')) {
|
|
675
|
-
return `+593 ${value}`;
|
|
676
|
-
}
|
|
677
|
-
return value;
|
|
842
|
+
return this.transformService.formatPhoneEcuadorian(value);
|
|
678
843
|
}
|
|
679
844
|
// Si no se aplica ningún formato, retornar el valor original
|
|
680
845
|
return value;
|
|
@@ -690,43 +855,25 @@ class JConverterCrudService {
|
|
|
690
855
|
if (value === null || value === undefined || value === 'S/N') {
|
|
691
856
|
return null;
|
|
692
857
|
}
|
|
693
|
-
let cleaned = value;
|
|
694
|
-
if (
|
|
695
|
-
|
|
696
|
-
}
|
|
697
|
-
if (column.isdollar && typeof cleaned === 'string') {
|
|
698
|
-
cleaned = cleaned.replace(/[^\d,.-]/g, '').replace(',', '.');
|
|
699
|
-
return cleaned ? parseFloat(cleaned) : null;
|
|
858
|
+
let cleaned = this.transformService.cleanValue(value, column);
|
|
859
|
+
if (column.isdollar || column.isCurrency) {
|
|
860
|
+
return this.transformService.parseCurrency(cleaned);
|
|
700
861
|
}
|
|
701
|
-
if (column.
|
|
702
|
-
|
|
703
|
-
return cleaned ? parseFloat(cleaned) : null;
|
|
862
|
+
if (column.isDateText) {
|
|
863
|
+
return this.transformService.parseDateText(cleaned);
|
|
704
864
|
}
|
|
705
|
-
if (column.
|
|
706
|
-
|
|
707
|
-
return fecha ?? cleaned;
|
|
865
|
+
if (column.isDate) {
|
|
866
|
+
return this.transformService.parseDate(cleaned);
|
|
708
867
|
}
|
|
709
|
-
if (column.
|
|
710
|
-
|
|
711
|
-
return isNaN(fecha.getTime()) ? cleaned : fecha.toISOString().substring(0, 10);
|
|
868
|
+
if (column.isDateTime || column.isDateTimeText) {
|
|
869
|
+
return this.transformService.parseDateTime(cleaned);
|
|
712
870
|
}
|
|
713
|
-
if (column.
|
|
714
|
-
const fecha = new Date(cleaned);
|
|
715
|
-
return isNaN(fecha.getTime()) ? cleaned : fecha.toISOString();
|
|
716
|
-
}
|
|
717
|
-
if (column.isDateTimeText && typeof cleaned === 'string') {
|
|
718
|
-
const fecha = new Date(cleaned);
|
|
719
|
-
return isNaN(fecha.getTime()) ? cleaned : fecha.toISOString();
|
|
720
|
-
}
|
|
721
|
-
if (column.isRelativeTime) {
|
|
722
|
-
return cleaned;
|
|
723
|
-
}
|
|
724
|
-
if (column.isFirstWord) {
|
|
871
|
+
if (column.isRelativeTime || column.isFirstWord) {
|
|
725
872
|
return cleaned;
|
|
726
873
|
}
|
|
727
874
|
return cleaned;
|
|
728
875
|
}
|
|
729
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JConverterCrudService, deps: [{ token: i1.CurrencyPipe }, { token: JCalendarService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
876
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JConverterCrudService, deps: [{ token: i1.CurrencyPipe }, { token: JCalendarService }, { token: JTransformService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
730
877
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JConverterCrudService, providedIn: 'root' });
|
|
731
878
|
}
|
|
732
879
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JConverterCrudService, decorators: [{
|
|
@@ -734,7 +881,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
734
881
|
args: [{
|
|
735
882
|
providedIn: 'root'
|
|
736
883
|
}]
|
|
737
|
-
}], ctorParameters: () => [{ type: i1.CurrencyPipe }, { type: JCalendarService }] });
|
|
884
|
+
}], ctorParameters: () => [{ type: i1.CurrencyPipe }, { type: JCalendarService }, { type: JTransformService }] });
|
|
738
885
|
|
|
739
886
|
class JParamsHttpService {
|
|
740
887
|
/**
|
|
@@ -985,53 +1132,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImpo
|
|
|
985
1132
|
}]
|
|
986
1133
|
}] });
|
|
987
1134
|
|
|
988
|
-
class JTransformService {
|
|
989
|
-
/**
|
|
990
|
-
* Verify if the value is a valid JSON string.
|
|
991
|
-
* @param value
|
|
992
|
-
* @returns
|
|
993
|
-
*/
|
|
994
|
-
isJson(value) {
|
|
995
|
-
try {
|
|
996
|
-
JSON.parse(value);
|
|
997
|
-
return true;
|
|
998
|
-
}
|
|
999
|
-
catch (e) {
|
|
1000
|
-
return false;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
/**
|
|
1004
|
-
* Parse a JSON string and return the array.
|
|
1005
|
-
* @param value The JSON string to parse.
|
|
1006
|
-
* @returns The parsed array.
|
|
1007
|
-
*/
|
|
1008
|
-
parseJson(value) {
|
|
1009
|
-
return JSON.parse(value);
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Capitalize the first letter of each word and lowercase the rest.
|
|
1013
|
-
* @param name The input string to capitalize.
|
|
1014
|
-
* @returns The capitalized string.
|
|
1015
|
-
*/
|
|
1016
|
-
capitalizeText(name) {
|
|
1017
|
-
return name
|
|
1018
|
-
.trim()
|
|
1019
|
-
.toLowerCase()
|
|
1020
|
-
.split(' ')
|
|
1021
|
-
.filter(Boolean)
|
|
1022
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
1023
|
-
.join(' ');
|
|
1024
|
-
}
|
|
1025
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JTransformService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1026
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JTransformService, providedIn: 'root' });
|
|
1027
|
-
}
|
|
1028
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: JTransformService, decorators: [{
|
|
1029
|
-
type: Injectable,
|
|
1030
|
-
args: [{
|
|
1031
|
-
providedIn: 'root'
|
|
1032
|
-
}]
|
|
1033
|
-
}] });
|
|
1034
|
-
|
|
1035
1135
|
class JIconsService {
|
|
1036
1136
|
icons = {
|
|
1037
1137
|
info: Info,
|