s4y-ui 2.1.7 → 2.1.8
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/fesm2022/s4y-ui.mjs +123 -129
- package/fesm2022/s4y-ui.mjs.map +1 -1
- package/lib/components/table/directive/table-sort.directive.d.ts +27 -0
- package/lib/components/table/index.d.ts +1 -1
- package/lib/components/table/table.component.d.ts +6 -0
- package/package.json +1 -1
- package/src/scss/styles.scss +5 -0
- package/src/scss/styles.scss.map +1 -1
- package/lib/components/table/actions/sortTable.directive.d.ts +0 -25
package/fesm2022/s4y-ui.mjs
CHANGED
|
@@ -1004,8 +1004,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
|
|
|
1004
1004
|
class TableComponent {
|
|
1005
1005
|
headers = input([]);
|
|
1006
1006
|
data = input([]);
|
|
1007
|
+
sortedData = computed(() => {
|
|
1008
|
+
const originalData = this.data();
|
|
1009
|
+
const sortName = this.sortBy();
|
|
1010
|
+
const direction = this.sortDirection();
|
|
1011
|
+
if (!originalData.length)
|
|
1012
|
+
return originalData;
|
|
1013
|
+
if (!sortName)
|
|
1014
|
+
return originalData;
|
|
1015
|
+
return originalData.sort((a, b) => {
|
|
1016
|
+
const valueA = a[sortName];
|
|
1017
|
+
const valueB = b[sortName];
|
|
1018
|
+
if (typeof valueA === 'string' && typeof valueB === 'string') {
|
|
1019
|
+
return direction === 'asc'
|
|
1020
|
+
? valueA.localeCompare(valueB)
|
|
1021
|
+
: valueB.localeCompare(valueA);
|
|
1022
|
+
}
|
|
1023
|
+
if (typeof valueA === 'number' && typeof valueB === 'number') {
|
|
1024
|
+
return direction === 'asc' ? valueA - valueB : valueB - valueA;
|
|
1025
|
+
}
|
|
1026
|
+
return 0;
|
|
1027
|
+
});
|
|
1028
|
+
});
|
|
1029
|
+
sortDirection = signal('asc');
|
|
1007
1030
|
isLoading = input(false);
|
|
1008
1031
|
hasError = input(false);
|
|
1032
|
+
currentThElement;
|
|
1009
1033
|
maxScreen = input(true);
|
|
1010
1034
|
rowTemplate;
|
|
1011
1035
|
headTemplate;
|
|
@@ -1016,13 +1040,23 @@ class TableComponent {
|
|
|
1016
1040
|
tableStyle = input({});
|
|
1017
1041
|
errorMessageDefault = input('Não foi possível carregar os dados.');
|
|
1018
1042
|
emptyMessageDefault = input(' Não encontramos dados para exibir.');
|
|
1043
|
+
constructor() { }
|
|
1044
|
+
sortBy = signal(undefined);
|
|
1045
|
+
sortData() {
|
|
1046
|
+
if (!this.data().length)
|
|
1047
|
+
return;
|
|
1048
|
+
if (!this.sortBy())
|
|
1049
|
+
return;
|
|
1050
|
+
this.data;
|
|
1051
|
+
console.log('Reorndenador');
|
|
1052
|
+
}
|
|
1019
1053
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: TableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1020
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.7", type: TableComponent, isStandalone: true, selector: "s4y-table", inputs: { headers: { classPropertyName: "headers", publicName: "headers", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, isLoading: { classPropertyName: "isLoading", publicName: "isLoading", isSignal: true, isRequired: false, transformFunction: null }, hasError: { classPropertyName: "hasError", publicName: "hasError", isSignal: true, isRequired: false, transformFunction: null }, maxScreen: { classPropertyName: "maxScreen", publicName: "maxScreen", isSignal: true, isRequired: false, transformFunction: null }, tableStyle: { classPropertyName: "tableStyle", publicName: "tableStyle", isSignal: true, isRequired: false, transformFunction: null }, errorMessageDefault: { classPropertyName: "errorMessageDefault", publicName: "errorMessageDefault", isSignal: true, isRequired: false, transformFunction: null }, emptyMessageDefault: { classPropertyName: "emptyMessageDefault", publicName: "emptyMessageDefault", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "rowTemplate", first: true, predicate: ["rowTemplate"], descendants: true }, { propertyName: "headTemplate", first: true, predicate: ["headTemplate"], descendants: true }, { propertyName: "emptyTemplate", first: true, predicate: ["emptyTemplate"], descendants: true }, { propertyName: "errorTemplate", first: true, predicate: ["errorTemplate"], descendants: true }, { propertyName: "customEmptyTemplate", first: true, predicate: ["customEmptyTemplate"], descendants: true }, { propertyName: "customErrorTemplate", first: true, predicate: ["customErrorTemplate"], descendants: true }], ngImport: i0, template: "<div class=\"s4y-table-container\" [ngStyle]=\"tableStyle()\">\r\n <table class=\"s4y-table\">\r\n <thead>\r\n <ng-container [ngTemplateOutlet]=\"headTemplate\"></ng-container>\r\n </thead>\r\n <tbody>\r\n @if (isLoading()) {\r\n <tr class=\"loading\">\r\n <td [colSpan]=\"headers().length\">\r\n <s4y-spinner></s4y-spinner>\r\n </td>\r\n </tr>\r\n } @else if (hasError()) {\r\n @if (errorTemplate) {\r\n <tr class=\"error\">\r\n <td [colSpan]=\"headers().length\">\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\"></ng-container>\r\n </td>\r\n </tr>\r\n } @else if (customErrorTemplate) {\r\n <ng-container [ngTemplateOutlet]=\"customErrorTemplate\"></ng-container>\r\n } @else {\r\n <tr class=\"error\">\r\n <td [colSpan]=\"headers().length\">\r\n {{ errorMessageDefault() }}\r\n </td>\r\n </tr>\r\n }\r\n } @else {\r\n <ng-container [ngTemplateOutlet]=\"tableContent\"></ng-container>\r\n }\r\n </tbody>\r\n </table>\r\n</div>\r\n\r\n<ng-template #SortIcon>\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n viewBox=\"0 0 24 24\"\r\n fill=\"currentColor\"\r\n >\r\n <path\r\n d=\"M4.86885 11H2.6665L6 3H8L11.3334 11H9.13113L8.7213 10H5.27869L4.86885 11ZM6.09836 8H7.90163L7 5.8L6.09836 8ZM18.9999 16V3H16.9999V16H13.9999L17.9999 21L21.9999 16H18.9999ZM10.9999 13H2.99992V15H7.85414L2.99992 19V21H10.9999V19H6.14605L10.9999 15V13Z\"\r\n ></path>\r\n </svg>\r\n</ng-template>\r\n\r\n<ng-template #tableContent>\r\n @for (item of
|
|
1054
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.7", type: TableComponent, isStandalone: true, selector: "s4y-table", inputs: { headers: { classPropertyName: "headers", publicName: "headers", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, isLoading: { classPropertyName: "isLoading", publicName: "isLoading", isSignal: true, isRequired: false, transformFunction: null }, hasError: { classPropertyName: "hasError", publicName: "hasError", isSignal: true, isRequired: false, transformFunction: null }, maxScreen: { classPropertyName: "maxScreen", publicName: "maxScreen", isSignal: true, isRequired: false, transformFunction: null }, tableStyle: { classPropertyName: "tableStyle", publicName: "tableStyle", isSignal: true, isRequired: false, transformFunction: null }, errorMessageDefault: { classPropertyName: "errorMessageDefault", publicName: "errorMessageDefault", isSignal: true, isRequired: false, transformFunction: null }, emptyMessageDefault: { classPropertyName: "emptyMessageDefault", publicName: "emptyMessageDefault", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "rowTemplate", first: true, predicate: ["rowTemplate"], descendants: true }, { propertyName: "headTemplate", first: true, predicate: ["headTemplate"], descendants: true }, { propertyName: "emptyTemplate", first: true, predicate: ["emptyTemplate"], descendants: true }, { propertyName: "errorTemplate", first: true, predicate: ["errorTemplate"], descendants: true }, { propertyName: "customEmptyTemplate", first: true, predicate: ["customEmptyTemplate"], descendants: true }, { propertyName: "customErrorTemplate", first: true, predicate: ["customErrorTemplate"], descendants: true }], ngImport: i0, template: "<div class=\"s4y-table-container\" [ngStyle]=\"tableStyle()\">\r\n <table class=\"s4y-table\">\r\n <thead>\r\n <ng-container [ngTemplateOutlet]=\"headTemplate\"></ng-container>\r\n </thead>\r\n <tbody>\r\n @if (isLoading()) {\r\n <tr class=\"loading\">\r\n <td [colSpan]=\"headers().length\">\r\n <s4y-spinner></s4y-spinner>\r\n </td>\r\n </tr>\r\n } @else if (hasError()) {\r\n @if (errorTemplate) {\r\n <tr class=\"error\">\r\n <td [colSpan]=\"headers().length\">\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\"></ng-container>\r\n </td>\r\n </tr>\r\n } @else if (customErrorTemplate) {\r\n <ng-container [ngTemplateOutlet]=\"customErrorTemplate\"></ng-container>\r\n } @else {\r\n <tr class=\"error\">\r\n <td [colSpan]=\"headers().length\">\r\n {{ errorMessageDefault() }}\r\n </td>\r\n </tr>\r\n }\r\n } @else {\r\n <ng-container [ngTemplateOutlet]=\"tableContent\"></ng-container>\r\n }\r\n </tbody>\r\n </table>\r\n</div>\r\n\r\n<ng-template #SortIcon>\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n viewBox=\"0 0 24 24\"\r\n fill=\"currentColor\"\r\n >\r\n <path\r\n d=\"M4.86885 11H2.6665L6 3H8L11.3334 11H9.13113L8.7213 10H5.27869L4.86885 11ZM6.09836 8H7.90163L7 5.8L6.09836 8ZM18.9999 16V3H16.9999V16H13.9999L17.9999 21L21.9999 16H18.9999ZM10.9999 13H2.99992V15H7.85414L2.99992 19V21H10.9999V19H6.14605L10.9999 15V13Z\"\r\n ></path>\r\n </svg>\r\n</ng-template>\r\n\r\n<ng-template #tableContent>\r\n @for (item of sortedData(); track $index) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"rowTemplate\"\r\n [ngTemplateOutletContext]=\"{ $implicit: item, idx: $index }\"\r\n >\r\n </ng-container>\r\n } @empty {\r\n @if (emptyTemplate) {\r\n <tr class=\"empty-content\">\r\n <td [colSpan]=\"headers().length\">\r\n <ng-container [ngTemplateOutlet]=\"emptyTemplate\"></ng-container>\r\n </td>\r\n </tr>\r\n } @else if (customEmptyTemplate) {\r\n <ng-container [ngTemplateOutlet]=\"customEmptyTemplate\"></ng-container>\r\n } @else {\r\n <tr class=\"empty-content\">\r\n <td [colSpan]=\"headers().length\">\r\n {{ emptyMessageDefault() }}\r\n </td>\r\n </tr>\r\n }\r\n }\r\n</ng-template>\r\n", styles: [".s4y-table-container{overflow:auto;min-height:30rem}@media screen and (min-width: 320px) and (max-width: 480px){.s4y-table-container{width:90dvw;padding-bottom:1.4rem;margin:0 auto}}@media screen and (min-width: 481px) and (max-width: 767px){.s4y-table-container{width:90dvw;padding-bottom:1.4rem;margin:0 auto}}@media screen and (min-width: 768px) and (max-width: 1024px){.s4y-table-container{width:90dvw;padding-bottom:1.4rem;margin:0 auto}}.s4y-table{border:1px solid var(--gray-200);border-collapse:collapse;width:100%}@media screen and (min-width: 320px) and (max-width: 480px){.s4y-table tr{white-space:nowrap}}@media screen and (min-width: 481px) and (max-width: 767px){.s4y-table tr{white-space:nowrap}}@media screen and (min-width: 768px) and (max-width: 1024px){.s4y-table tr{white-space:nowrap}}.s4y-table .s4y-table-head-th__content{display:flex;justify-content:space-between}.s4y-table thead{background-color:#eaeaea}.s4y-table thead tr{font-size:1.3rem;height:5rem;font-weight:700}.s4y-table tbody tr{border-bottom:1px solid var(--gray-400);background-color:#fff;font-size:1.3rem;line-height:5rem;font-weight:400}.s4y-table tfoot{background-color:#eaeaea}.s4y-table th,.s4y-table td{text-align:start;padding:0 .4rem}.s4y-table td:first-child,.s4y-table td:last-child,.s4y-table th:first-child,.s4y-table th:last-child{padding:0 1.4rem}.s4y-table th.sorted{background-color:var(--primary-color);color:#fff}.s4y-table td.sorted{background-color:var(--gray-200)}.s4y-table tr.empty-content,.s4y-table tr.loading,.s4y-table tr.error{border:none}.s4y-table tr.empty-content td,.s4y-table tr.loading td,.s4y-table tr.error td{text-align:center;height:28rem;background-color:transparent;color:var(--gray-900);font-weight:700;border:none}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: SpinnerComponent, selector: "s4y-spinner", inputs: ["size", "color"] }], encapsulation: i0.ViewEncapsulation.None });
|
|
1021
1055
|
}
|
|
1022
1056
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: TableComponent, decorators: [{
|
|
1023
1057
|
type: Component,
|
|
1024
|
-
args: [{ selector: 's4y-table', imports: [CommonModule, SpinnerComponent], encapsulation: ViewEncapsulation.None, template: "<div class=\"s4y-table-container\" [ngStyle]=\"tableStyle()\">\r\n <table class=\"s4y-table\">\r\n <thead>\r\n <ng-container [ngTemplateOutlet]=\"headTemplate\"></ng-container>\r\n </thead>\r\n <tbody>\r\n @if (isLoading()) {\r\n <tr class=\"loading\">\r\n <td [colSpan]=\"headers().length\">\r\n <s4y-spinner></s4y-spinner>\r\n </td>\r\n </tr>\r\n } @else if (hasError()) {\r\n @if (errorTemplate) {\r\n <tr class=\"error\">\r\n <td [colSpan]=\"headers().length\">\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\"></ng-container>\r\n </td>\r\n </tr>\r\n } @else if (customErrorTemplate) {\r\n <ng-container [ngTemplateOutlet]=\"customErrorTemplate\"></ng-container>\r\n } @else {\r\n <tr class=\"error\">\r\n <td [colSpan]=\"headers().length\">\r\n {{ errorMessageDefault() }}\r\n </td>\r\n </tr>\r\n }\r\n } @else {\r\n <ng-container [ngTemplateOutlet]=\"tableContent\"></ng-container>\r\n }\r\n </tbody>\r\n </table>\r\n</div>\r\n\r\n<ng-template #SortIcon>\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n viewBox=\"0 0 24 24\"\r\n fill=\"currentColor\"\r\n >\r\n <path\r\n d=\"M4.86885 11H2.6665L6 3H8L11.3334 11H9.13113L8.7213 10H5.27869L4.86885 11ZM6.09836 8H7.90163L7 5.8L6.09836 8ZM18.9999 16V3H16.9999V16H13.9999L17.9999 21L21.9999 16H18.9999ZM10.9999 13H2.99992V15H7.85414L2.99992 19V21H10.9999V19H6.14605L10.9999 15V13Z\"\r\n ></path>\r\n </svg>\r\n</ng-template>\r\n\r\n<ng-template #tableContent>\r\n @for (item of
|
|
1025
|
-
}], propDecorators: { rowTemplate: [{
|
|
1058
|
+
args: [{ selector: 's4y-table', imports: [CommonModule, SpinnerComponent], encapsulation: ViewEncapsulation.None, template: "<div class=\"s4y-table-container\" [ngStyle]=\"tableStyle()\">\r\n <table class=\"s4y-table\">\r\n <thead>\r\n <ng-container [ngTemplateOutlet]=\"headTemplate\"></ng-container>\r\n </thead>\r\n <tbody>\r\n @if (isLoading()) {\r\n <tr class=\"loading\">\r\n <td [colSpan]=\"headers().length\">\r\n <s4y-spinner></s4y-spinner>\r\n </td>\r\n </tr>\r\n } @else if (hasError()) {\r\n @if (errorTemplate) {\r\n <tr class=\"error\">\r\n <td [colSpan]=\"headers().length\">\r\n <ng-container [ngTemplateOutlet]=\"errorTemplate\"></ng-container>\r\n </td>\r\n </tr>\r\n } @else if (customErrorTemplate) {\r\n <ng-container [ngTemplateOutlet]=\"customErrorTemplate\"></ng-container>\r\n } @else {\r\n <tr class=\"error\">\r\n <td [colSpan]=\"headers().length\">\r\n {{ errorMessageDefault() }}\r\n </td>\r\n </tr>\r\n }\r\n } @else {\r\n <ng-container [ngTemplateOutlet]=\"tableContent\"></ng-container>\r\n }\r\n </tbody>\r\n </table>\r\n</div>\r\n\r\n<ng-template #SortIcon>\r\n <svg\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n viewBox=\"0 0 24 24\"\r\n fill=\"currentColor\"\r\n >\r\n <path\r\n d=\"M4.86885 11H2.6665L6 3H8L11.3334 11H9.13113L8.7213 10H5.27869L4.86885 11ZM6.09836 8H7.90163L7 5.8L6.09836 8ZM18.9999 16V3H16.9999V16H13.9999L17.9999 21L21.9999 16H18.9999ZM10.9999 13H2.99992V15H7.85414L2.99992 19V21H10.9999V19H6.14605L10.9999 15V13Z\"\r\n ></path>\r\n </svg>\r\n</ng-template>\r\n\r\n<ng-template #tableContent>\r\n @for (item of sortedData(); track $index) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"rowTemplate\"\r\n [ngTemplateOutletContext]=\"{ $implicit: item, idx: $index }\"\r\n >\r\n </ng-container>\r\n } @empty {\r\n @if (emptyTemplate) {\r\n <tr class=\"empty-content\">\r\n <td [colSpan]=\"headers().length\">\r\n <ng-container [ngTemplateOutlet]=\"emptyTemplate\"></ng-container>\r\n </td>\r\n </tr>\r\n } @else if (customEmptyTemplate) {\r\n <ng-container [ngTemplateOutlet]=\"customEmptyTemplate\"></ng-container>\r\n } @else {\r\n <tr class=\"empty-content\">\r\n <td [colSpan]=\"headers().length\">\r\n {{ emptyMessageDefault() }}\r\n </td>\r\n </tr>\r\n }\r\n }\r\n</ng-template>\r\n", styles: [".s4y-table-container{overflow:auto;min-height:30rem}@media screen and (min-width: 320px) and (max-width: 480px){.s4y-table-container{width:90dvw;padding-bottom:1.4rem;margin:0 auto}}@media screen and (min-width: 481px) and (max-width: 767px){.s4y-table-container{width:90dvw;padding-bottom:1.4rem;margin:0 auto}}@media screen and (min-width: 768px) and (max-width: 1024px){.s4y-table-container{width:90dvw;padding-bottom:1.4rem;margin:0 auto}}.s4y-table{border:1px solid var(--gray-200);border-collapse:collapse;width:100%}@media screen and (min-width: 320px) and (max-width: 480px){.s4y-table tr{white-space:nowrap}}@media screen and (min-width: 481px) and (max-width: 767px){.s4y-table tr{white-space:nowrap}}@media screen and (min-width: 768px) and (max-width: 1024px){.s4y-table tr{white-space:nowrap}}.s4y-table .s4y-table-head-th__content{display:flex;justify-content:space-between}.s4y-table thead{background-color:#eaeaea}.s4y-table thead tr{font-size:1.3rem;height:5rem;font-weight:700}.s4y-table tbody tr{border-bottom:1px solid var(--gray-400);background-color:#fff;font-size:1.3rem;line-height:5rem;font-weight:400}.s4y-table tfoot{background-color:#eaeaea}.s4y-table th,.s4y-table td{text-align:start;padding:0 .4rem}.s4y-table td:first-child,.s4y-table td:last-child,.s4y-table th:first-child,.s4y-table th:last-child{padding:0 1.4rem}.s4y-table th.sorted{background-color:var(--primary-color);color:#fff}.s4y-table td.sorted{background-color:var(--gray-200)}.s4y-table tr.empty-content,.s4y-table tr.loading,.s4y-table tr.error{border:none}.s4y-table tr.empty-content td,.s4y-table tr.loading td,.s4y-table tr.error td{text-align:center;height:28rem;background-color:transparent;color:var(--gray-900);font-weight:700;border:none}\n"] }]
|
|
1059
|
+
}], ctorParameters: () => [], propDecorators: { rowTemplate: [{
|
|
1026
1060
|
type: ContentChild,
|
|
1027
1061
|
args: ['rowTemplate']
|
|
1028
1062
|
}], headTemplate: [{
|
|
@@ -1042,149 +1076,109 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
|
|
|
1042
1076
|
args: ['customErrorTemplate']
|
|
1043
1077
|
}] } });
|
|
1044
1078
|
|
|
1045
|
-
class
|
|
1079
|
+
class TableSortDirective {
|
|
1046
1080
|
el;
|
|
1047
1081
|
renderer;
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1082
|
+
table;
|
|
1083
|
+
s4ySortableColumnName = input();
|
|
1084
|
+
oldSortableColumnName;
|
|
1085
|
+
oldThElement;
|
|
1086
|
+
spanElement;
|
|
1087
|
+
isAscending = true;
|
|
1088
|
+
constructor(el, renderer, table) {
|
|
1053
1089
|
this.el = el;
|
|
1054
1090
|
this.renderer = renderer;
|
|
1091
|
+
this.table = table;
|
|
1055
1092
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
this.icon = this.createIcon();
|
|
1059
|
-
if (this.icon && this.s4yColumnName()) {
|
|
1060
|
-
this.applySortButton();
|
|
1061
|
-
}
|
|
1093
|
+
ngAfterContentInit() {
|
|
1094
|
+
this.insertIconInHeader();
|
|
1062
1095
|
}
|
|
1063
|
-
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
this.renderer.appendChild(span, this.icon);
|
|
1079
|
-
this.renderer.appendChild(thContainer, headerText);
|
|
1080
|
-
this.renderer.appendChild(thContainer, span);
|
|
1081
|
-
this.renderer.appendChild(thElement, thContainer);
|
|
1082
|
-
this.applyStyleInThContainer(thContainer);
|
|
1083
|
-
this.renderer.listen(span, 'click', () => this.toggleSort());
|
|
1084
|
-
}
|
|
1085
|
-
toggleSort() {
|
|
1086
|
-
this.isSortedAsc = !this.isSortedAsc;
|
|
1096
|
+
emitSortableColumnName() {
|
|
1097
|
+
const currentSorted = this.table.sortBy();
|
|
1098
|
+
const sortByColumnName = this.s4ySortableColumnName();
|
|
1099
|
+
if (!sortByColumnName)
|
|
1100
|
+
return;
|
|
1101
|
+
this.oldSortableColumnName = currentSorted;
|
|
1102
|
+
this.oldThElement = this.table.currentThElement;
|
|
1103
|
+
this.table.currentThElement = this.el.nativeElement;
|
|
1104
|
+
this.isAscending = !this.isAscending;
|
|
1105
|
+
this.table.sortBy.set(sortByColumnName);
|
|
1106
|
+
this.table.sortDirection.set(this.isAscending ? 'asc' : 'desc');
|
|
1107
|
+
if (this.oldThElement) {
|
|
1108
|
+
this.renderer.removeClass(this.oldThElement, 's4y-active-sort');
|
|
1109
|
+
}
|
|
1110
|
+
this.renderer.addClass(this.el.nativeElement, 's4y-active-sort');
|
|
1087
1111
|
this.updateSortIcon();
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
data.sort((a, b) => {
|
|
1100
|
-
const columnA = a[columnName];
|
|
1101
|
-
const columnB = b[columnName];
|
|
1102
|
-
if (columnA < columnB) {
|
|
1103
|
-
return this.isSortedAsc ? -1 : 1;
|
|
1104
|
-
}
|
|
1105
|
-
if (columnA > columnB) {
|
|
1106
|
-
return this.isSortedAsc ? 1 : -1;
|
|
1107
|
-
}
|
|
1108
|
-
return 0;
|
|
1109
|
-
});
|
|
1110
|
-
this.updateSortIcon();
|
|
1111
|
-
this.applySortedClass();
|
|
1112
|
-
console.log('Dados ordenados:', data); // Dados ordenados no console
|
|
1112
|
+
}
|
|
1113
|
+
get thElement() {
|
|
1114
|
+
return this.el.nativeElement;
|
|
1115
|
+
}
|
|
1116
|
+
insertIconInHeader() {
|
|
1117
|
+
if (!this.thElement)
|
|
1118
|
+
return;
|
|
1119
|
+
const isThElement = this.thElement.tagName == 'TH';
|
|
1120
|
+
if (!isThElement) {
|
|
1121
|
+
console.error('Metódo disponível apenas em elementos TH');
|
|
1122
|
+
return;
|
|
1113
1123
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1124
|
+
this.createSpanElement();
|
|
1125
|
+
const extractOriginalContentTHElement = this.thElement.textContent;
|
|
1126
|
+
const containerEl = this.createElement('div');
|
|
1127
|
+
const contentEl = this.createElement('p');
|
|
1128
|
+
contentEl.textContent = extractOriginalContentTHElement;
|
|
1129
|
+
this.clearOldContent();
|
|
1130
|
+
this.setStyleInContainerIconElements(containerEl);
|
|
1131
|
+
containerEl.appendChild(contentEl);
|
|
1132
|
+
if (this.spanElement) {
|
|
1133
|
+
containerEl.appendChild(this.spanElement);
|
|
1116
1134
|
}
|
|
1135
|
+
this.thElement.appendChild(containerEl);
|
|
1117
1136
|
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
.closest('table')
|
|
1124
|
-
.querySelectorAll('td');
|
|
1125
|
-
const thElement = this.el.nativeElement;
|
|
1126
|
-
const isAlreadySorted = thElement.classList.contains('sorted');
|
|
1127
|
-
if (isAlreadySorted) {
|
|
1128
|
-
thElements.forEach((th) => {
|
|
1129
|
-
this.renderer.removeClass(th, 'sorted');
|
|
1130
|
-
});
|
|
1131
|
-
tdElements.forEach((td) => {
|
|
1132
|
-
this.renderer.removeClass(td, 'sorted');
|
|
1133
|
-
});
|
|
1137
|
+
createElement(name) {
|
|
1138
|
+
return this.renderer.createElement(name);
|
|
1139
|
+
}
|
|
1140
|
+
clearOldContent() {
|
|
1141
|
+
if (!this.thElement)
|
|
1134
1142
|
return;
|
|
1135
|
-
|
|
1136
|
-
thElements.forEach((th) => {
|
|
1137
|
-
this.renderer.removeClass(th, 'sorted');
|
|
1138
|
-
});
|
|
1139
|
-
tdElements.forEach((td) => {
|
|
1140
|
-
this.renderer.removeClass(td, 'sorted');
|
|
1141
|
-
});
|
|
1142
|
-
this.renderer.addClass(thElement, 'sorted');
|
|
1143
|
-
const columnIndex = Array.from(thElements).indexOf(thElement);
|
|
1144
|
-
const trElements = this.el.nativeElement
|
|
1145
|
-
.closest('table')
|
|
1146
|
-
.querySelectorAll('tr');
|
|
1147
|
-
trElements.forEach((tr) => {
|
|
1148
|
-
const td = tr.children[columnIndex];
|
|
1149
|
-
if (td) {
|
|
1150
|
-
this.renderer.addClass(td, 'sorted');
|
|
1151
|
-
}
|
|
1152
|
-
});
|
|
1143
|
+
this.thElement.textContent = '';
|
|
1153
1144
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1145
|
+
setStyleInContainerIconElements(container) {
|
|
1146
|
+
const style = `
|
|
1147
|
+
display: flex;
|
|
1148
|
+
align-items: center;
|
|
1149
|
+
justify-content: space-between;
|
|
1150
|
+
`;
|
|
1151
|
+
this.renderer.setAttribute(container, 'style', style);
|
|
1152
|
+
}
|
|
1153
|
+
createSpanElement() {
|
|
1154
|
+
this.spanElement = this.createElement('span');
|
|
1155
|
+
this.spanElement.innerHTML = this.ascIcon;
|
|
1158
1156
|
}
|
|
1159
1157
|
updateSortIcon() {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
>
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
</svg>`;
|
|
1174
|
-
svgIconDesc = `<svg xmlns="http://www.w3.org/2000/svg"
|
|
1175
|
-
width="1.8rem"
|
|
1176
|
-
height="1.8rem"
|
|
1177
|
-
viewBox="0 0 24 24"
|
|
1178
|
-
fill="currentColor"><path d="M4.86885 11H2.6665L6 3H8L11.3334 11H9.13113L8.7213 10H5.27869L4.86885 11ZM6.09836 8H7.90163L7 5.8L6.09836 8ZM21.9999 8L17.9999 3L13.9999 8H16.9999V21H18.9999V8H21.9999ZM10.9999 13H2.99992V15H7.85414L2.99992 19V21H10.9999V19H6.14605L10.9999 15V13Z"></path></svg>`;
|
|
1179
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SortTableDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1180
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.7", type: SortTableDirective, isStandalone: true, selector: "[s4ySortTable]", inputs: { s4yColumnName: { classPropertyName: "s4yColumnName", publicName: "s4yColumnName", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
1158
|
+
if (!this.spanElement)
|
|
1159
|
+
return;
|
|
1160
|
+
const iconSvg = this.isAscending ? this.ascIcon : this.descIcon;
|
|
1161
|
+
this.spanElement.innerHTML = iconSvg;
|
|
1162
|
+
}
|
|
1163
|
+
get ascIcon() {
|
|
1164
|
+
return '<svg style="height: 1.8rem; width: 1.8rem;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 3L23 8H20V20H18V8H15L19 3ZM14 18V20H3V18H14ZM14 11V13H3V11H14ZM12 4V6H3V4H12Z"></path></svg>';
|
|
1165
|
+
}
|
|
1166
|
+
get descIcon() {
|
|
1167
|
+
return '<svg style="height: 1.8rem; width: 1.8rem;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M20 4V16H23L19 21L15 16H18V4H20ZM12 18V20H3V18H12ZM14 11V13H3V11H14ZM14 4V6H3V4H14Z"></path></svg>';
|
|
1168
|
+
}
|
|
1169
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: TableSortDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: TableComponent }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1170
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.7", type: TableSortDirective, isStandalone: true, selector: "[s4ySortableColumnName]", inputs: { s4ySortableColumnName: { classPropertyName: "s4ySortableColumnName", publicName: "s4ySortableColumnName", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "emitSortableColumnName()" } }, ngImport: i0 });
|
|
1181
1171
|
}
|
|
1182
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type:
|
|
1172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: TableSortDirective, decorators: [{
|
|
1183
1173
|
type: Directive,
|
|
1184
1174
|
args: [{
|
|
1185
|
-
selector: '[
|
|
1175
|
+
selector: '[s4ySortableColumnName]',
|
|
1176
|
+
standalone: true,
|
|
1186
1177
|
}]
|
|
1187
|
-
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }]
|
|
1178
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: TableComponent }], propDecorators: { emitSortableColumnName: [{
|
|
1179
|
+
type: HostListener,
|
|
1180
|
+
args: ['click']
|
|
1181
|
+
}] } });
|
|
1188
1182
|
|
|
1189
1183
|
const modalFadeCombined = trigger('modalFadeCombined', [
|
|
1190
1184
|
transition(':enter', [
|
|
@@ -2682,5 +2676,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
|
|
|
2682
2676
|
* Generated bundle index. Do not edit.
|
|
2683
2677
|
*/
|
|
2684
2678
|
|
|
2685
|
-
export { AsideComponent, AvatarComponent, BreadcrumbComponent, BreadcrumbItemDirective, BreadcrumbService, ButtonComponent, CheckboxComponent, ClickOutsideDirective, DashboardContainerComponent, DashboardLayoutComponent, DashboardModule, DashboardRoutesComponent, DrawerComponent, ErrorMessageComponent, FormFieldComponent, FormFieldPasswordComponent, FormsKitModule, HintComponent, InputComponent, InputPrefixComponent, InputSufixComponent, LabelComponent, LoadingModalComponent, LoadingModalService, MaskDirective, ModalComponent, ModalConfirmationComponent, ModalConfirmationService, NavbarComponent, PaginationComponent, RadioComponent, SearchBarComponent, SelectComponent, SliderComponent,
|
|
2679
|
+
export { AsideComponent, AvatarComponent, BreadcrumbComponent, BreadcrumbItemDirective, BreadcrumbService, ButtonComponent, CheckboxComponent, ClickOutsideDirective, DashboardContainerComponent, DashboardLayoutComponent, DashboardModule, DashboardRoutesComponent, DrawerComponent, ErrorMessageComponent, FormFieldComponent, FormFieldPasswordComponent, FormsKitModule, HintComponent, InputComponent, InputPrefixComponent, InputSufixComponent, LabelComponent, LoadingModalComponent, LoadingModalService, MaskDirective, ModalComponent, ModalConfirmationComponent, ModalConfirmationService, NavbarComponent, PaginationComponent, RadioComponent, SearchBarComponent, SelectComponent, SliderComponent, SpinnerComponent, StepComponent, StepPanelComponent, StepperComponent, SvgComponent, SvgService, TableComponent, TableSortDirective, ToastComponent, ToastService, ToggleComponent, TooltipComponent, TooltipDirective, TooltipModule, TooltipPosition };
|
|
2686
2680
|
//# sourceMappingURL=s4y-ui.mjs.map
|