@tots/table 15.0.49 → 15.0.50

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.
Files changed (40) hide show
  1. package/{esm2022 → esm2020}/lib/columns/balance-currency-column/balance-currency-column.component.mjs +4 -4
  2. package/{esm2022 → esm2020}/lib/columns/balance-currency-icon-column/balance-currency-icon-column.component.mjs +4 -4
  3. package/{esm2022 → esm2020}/lib/columns/base-print-column/base-print-column.component.mjs +4 -4
  4. package/{esm2022 → esm2020}/lib/columns/boolean-column/boolean-column.component.mjs +4 -4
  5. package/{esm2022 → esm2020}/lib/columns/checkbox-column/checkbox-column.component.mjs +4 -4
  6. package/{esm2022 → esm2020}/lib/columns/currency-column/currency-column.component.mjs +4 -4
  7. package/{esm2022 → esm2020}/lib/columns/icon-button-column/icon-button-column.component.mjs +4 -4
  8. package/{esm2022 → esm2020}/lib/columns/more-menu-column/more-menu-column.component.mjs +4 -4
  9. package/{esm2022 → esm2020}/lib/columns/option-column/option-column.component.mjs +4 -4
  10. package/{esm2022 → esm2020}/lib/columns/status-column/status-column.component.mjs +4 -4
  11. package/{esm2022 → esm2020}/lib/columns/status-icon-column/status-icon-column.component.mjs +4 -4
  12. package/{esm2022 → esm2020}/lib/columns/string-column/string-column.component.mjs +4 -4
  13. package/{esm2022 → esm2020}/lib/columns/tots-base-column.component.mjs +4 -4
  14. package/{esm2022 → esm2020}/lib/columns/two-string-column/two-string-column.component.mjs +4 -4
  15. package/{esm2022 → esm2020}/lib/columns/user-column/user-column.component.mjs +4 -4
  16. package/{esm2022 → esm2020}/lib/components/loading-animation-renderer/loading-animation-renderer.component.mjs +4 -4
  17. package/{esm2022 → esm2020}/lib/components/tots-table/tots-table.component.mjs +4 -4
  18. package/{esm2022 → esm2020}/lib/components/tots-table-api/tots-table-api.component.mjs +4 -4
  19. package/{esm2022 → esm2020}/lib/components/tots-table-local/tots-table-local.component.mjs +4 -4
  20. package/{esm2022 → esm2020}/lib/entities/tots-table-default-config.mjs +4 -4
  21. package/esm2020/lib/table.module.mjs +129 -0
  22. package/fesm2015/tots-table.mjs +820 -0
  23. package/fesm2015/tots-table.mjs.map +1 -0
  24. package/{fesm2022 → fesm2020}/tots-table.mjs +106 -109
  25. package/{fesm2022 → fesm2020}/tots-table.mjs.map +1 -1
  26. package/lib/columns/base-print-column/base-print-column.component.d.ts +1 -1
  27. package/lib/columns/tots-base-column.component.d.ts +1 -1
  28. package/lib/components/tots-table/tots-table.component.d.ts +1 -1
  29. package/lib/components/tots-table-api/tots-table-api.component.d.ts +1 -1
  30. package/lib/components/tots-table-local/tots-table-local.component.d.ts +1 -1
  31. package/package.json +11 -5
  32. package/esm2022/lib/table.module.mjs +0 -129
  33. /package/{esm2022 → esm2020}/lib/entities/tots-action-table.mjs +0 -0
  34. /package/{esm2022 → esm2020}/lib/entities/tots-column.mjs +0 -0
  35. /package/{esm2022 → esm2020}/lib/entities/tots-table-api-config.mjs +0 -0
  36. /package/{esm2022 → esm2020}/lib/entities/tots-table-config.mjs +0 -0
  37. /package/{esm2022 → esm2020}/lib/entities/tots-table-local-config.mjs +0 -0
  38. /package/{esm2022 → esm2020}/lib/helpers/tots-table-helper.mjs +0 -0
  39. /package/{esm2022 → esm2020}/public-api.mjs +0 -0
  40. /package/{esm2022 → esm2020}/tots-table.mjs +0 -0
@@ -0,0 +1,820 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Injectable, Component, Input, ViewContainerRef, Inject, ViewChild, EventEmitter, Output, NgModule } from '@angular/core';
3
+ import { TotsQuery } from '@tots/core';
4
+ import * as i1 from '@angular/common';
5
+ import { CommonModule } from '@angular/common';
6
+ import * as i2 from '@angular/material/icon';
7
+ import { MatIconModule } from '@angular/material/icon';
8
+ import * as i3 from '@angular/material/button';
9
+ import { MatButtonModule } from '@angular/material/button';
10
+ import * as i4 from '@angular/material/menu';
11
+ import { MatMenuModule } from '@angular/material/menu';
12
+ import * as i1$1 from '@angular/material/checkbox';
13
+ import { MatCheckboxModule } from '@angular/material/checkbox';
14
+ import { Subject, tap } from 'rxjs';
15
+ import * as i3$1 from '@angular/material/table';
16
+ import { MatTableModule } from '@angular/material/table';
17
+ import * as i4$1 from '@angular/material/paginator';
18
+ import { MatPaginatorModule } from '@angular/material/paginator';
19
+ import * as i5 from '@angular/material/progress-bar';
20
+ import { MatProgressBarModule } from '@angular/material/progress-bar';
21
+ import { MatProgressSpinner, MatProgressSpinnerModule } from '@angular/material/progress-spinner';
22
+
23
+ class TotsColumn {
24
+ constructor() {
25
+ this.key = '';
26
+ this.title = '';
27
+ this.is_show = true;
28
+ this.hasOrder = false;
29
+ }
30
+ }
31
+
32
+ class TotsTableConfig {
33
+ constructor() {
34
+ this.id = '';
35
+ this.columns = [];
36
+ this.classes = '';
37
+ }
38
+ }
39
+
40
+ const TOTS_TABLE_DEFAULT_CONFIG = new InjectionToken('tots_table_default_config');
41
+ class TotsTableDefaultConfig {
42
+ }
43
+ TotsTableDefaultConfig.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableDefaultConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
44
+ TotsTableDefaultConfig.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableDefaultConfig });
45
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableDefaultConfig, decorators: [{
46
+ type: Injectable
47
+ }] });
48
+
49
+ class TotsActionTable {
50
+ constructor() {
51
+ this.key = '';
52
+ }
53
+ }
54
+
55
+ class TotsTableApiConfig {
56
+ constructor() {
57
+ this.id = '';
58
+ this.columns = [];
59
+ this.query = new TotsQuery();
60
+ this.classes = '';
61
+ }
62
+ }
63
+
64
+ class TotsTableLocalConfig extends TotsTableConfig {
65
+ constructor() {
66
+ super(...arguments);
67
+ this.searchKeys = [];
68
+ }
69
+ }
70
+
71
+ class TotsTableHelper {
72
+ /**
73
+ * Obtiene el valor de un objeto a traves de la KEY
74
+ * @param item
75
+ * @param key
76
+ * @returns
77
+ */
78
+ static getItemValueByKey(item, key) {
79
+ if (key == undefined || item == undefined) {
80
+ return '';
81
+ }
82
+ if (typeof key == 'string' && item[key] != undefined) {
83
+ return item[key];
84
+ }
85
+ let valueFinal = item;
86
+ for (const keyObj of key) {
87
+ if (valueFinal[keyObj] == undefined) {
88
+ return '';
89
+ }
90
+ valueFinal = valueFinal[keyObj];
91
+ }
92
+ return valueFinal;
93
+ }
94
+ }
95
+
96
+ class TotsBaseColumnComponent {
97
+ getItemValue() {
98
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.field_key);
99
+ }
100
+ }
101
+ TotsBaseColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsBaseColumnComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
102
+ TotsBaseColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: TotsBaseColumnComponent, selector: "tots-base-column", inputs: { column: "column", item: "item", onAction: "onAction", index: "index" }, ngImport: i0, template: '', isInline: true });
103
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsBaseColumnComponent, decorators: [{
104
+ type: Component,
105
+ args: [{
106
+ selector: 'tots-base-column',
107
+ template: ''
108
+ }]
109
+ }], propDecorators: { column: [{
110
+ type: Input
111
+ }], item: [{
112
+ type: Input
113
+ }], onAction: [{
114
+ type: Input
115
+ }], index: [{
116
+ type: Input
117
+ }] } });
118
+
119
+ class StringColumnComponent extends TotsBaseColumnComponent {
120
+ getItemValue() {
121
+ let value = TotsTableHelper.getItemValueByKey(this.item, this.column.field_key);
122
+ if (this.column.extra && this.column.extra.cutSeparator) {
123
+ return value.split(this.column.extra.cutSeparator)[0];
124
+ }
125
+ return value;
126
+ }
127
+ get prepend() {
128
+ var _a;
129
+ return (_a = this.column.extra) === null || _a === void 0 ? void 0 : _a.prepend;
130
+ }
131
+ }
132
+ StringColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: StringColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
133
+ StringColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: StringColumnComponent, selector: "tots-string-column", usesInheritance: true, ngImport: i0, template: "<span class=\"prefix\" *ngIf=\"prepend\"> {{ prepend }} </span>\n{{getItemValue()}}", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
134
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: StringColumnComponent, decorators: [{
135
+ type: Component,
136
+ args: [{ selector: 'tots-string-column', template: "<span class=\"prefix\" *ngIf=\"prepend\"> {{ prepend }} </span>\n{{getItemValue()}}" }]
137
+ }] });
138
+
139
+ class MoreMenuColumnComponent extends TotsBaseColumnComponent {
140
+ clickButton(itemAction, $event) {
141
+ this.onAction.next({ key: itemAction.key, item: this.item });
142
+ $event.preventDefault();
143
+ return false;
144
+ }
145
+ }
146
+ MoreMenuColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: MoreMenuColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
147
+ MoreMenuColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: MoreMenuColumnComponent, selector: "tots-more-menu-column", usesInheritance: true, ngImport: i0, template: "<button mat-icon-button [matMenuTriggerFor]=\"actions\" (click)=\"$event.stopPropagation()\"><mat-icon>more_vert</mat-icon></button>\n<mat-menu #actions=\"matMenu\">\n <button mat-menu-item *ngFor=\"let button of column.extra?.actions\" (click)=\"clickButton(button, $event)\" class=\"{{button.class}}\">\n <mat-icon *ngIf=\"button.icon\">{{ button.icon }}</mat-icon> {{ button.title }}\n </button>\n</mat-menu>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i4.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { kind: "component", type: i4.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i4.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }] });
148
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: MoreMenuColumnComponent, decorators: [{
149
+ type: Component,
150
+ args: [{ selector: 'tots-more-menu-column', template: "<button mat-icon-button [matMenuTriggerFor]=\"actions\" (click)=\"$event.stopPropagation()\"><mat-icon>more_vert</mat-icon></button>\n<mat-menu #actions=\"matMenu\">\n <button mat-menu-item *ngFor=\"let button of column.extra?.actions\" (click)=\"clickButton(button, $event)\" class=\"{{button.class}}\">\n <mat-icon *ngIf=\"button.icon\">{{ button.icon }}</mat-icon> {{ button.title }}\n </button>\n</mat-menu>" }]
151
+ }] });
152
+
153
+ class BooleanColumnComponent extends TotsBaseColumnComponent {
154
+ }
155
+ BooleanColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BooleanColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
156
+ BooleanColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: BooleanColumnComponent, selector: "tots-boolean-column", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"getItemValue() == true||getItemValue() == 1; else textNo\">YES</ng-container>\n<ng-template #textNo>NO</ng-template>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
157
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BooleanColumnComponent, decorators: [{
158
+ type: Component,
159
+ args: [{ selector: 'tots-boolean-column', template: "<ng-container *ngIf=\"getItemValue() == true||getItemValue() == 1; else textNo\">YES</ng-container>\n<ng-template #textNo>NO</ng-template>" }]
160
+ }] });
161
+
162
+ class TwoStringColumnComponent extends TotsBaseColumnComponent {
163
+ getSubtitleValue() {
164
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.extra.field_subtitle_key);
165
+ }
166
+ }
167
+ TwoStringColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TwoStringColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
168
+ TwoStringColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: TwoStringColumnComponent, selector: "tots-two-string-column", usesInheritance: true, ngImport: i0, template: "<div class=\"first-line\"><strong>{{getItemValue()}}</strong></div>\n<div class=\"second-line\">{{getSubtitleValue()}}</div>", styles: [""] });
169
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TwoStringColumnComponent, decorators: [{
170
+ type: Component,
171
+ args: [{ selector: 'tots-two-string-column', template: "<div class=\"first-line\"><strong>{{getItemValue()}}</strong></div>\n<div class=\"second-line\">{{getSubtitleValue()}}</div>" }]
172
+ }] });
173
+
174
+ class IconButtonColumnComponent extends TotsBaseColumnComponent {
175
+ clickButton($event) {
176
+ this.onAction.next({ key: this.column.extra.action, item: this.item });
177
+ $event.stopPropagation();
178
+ return false;
179
+ }
180
+ getIconName() {
181
+ return this.column.extra.icon;
182
+ }
183
+ getButtonColor() {
184
+ return this.column.extra.matColor;
185
+ }
186
+ getClasses() {
187
+ return this.column.extra.classes;
188
+ }
189
+ }
190
+ IconButtonColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: IconButtonColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
191
+ IconButtonColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: IconButtonColumnComponent, selector: "tots-icon-button-column", usesInheritance: true, ngImport: i0, template: "<button mat-icon-button [color]=\"getButtonColor()\" [class]=\"getClasses()\" (click)=\"clickButton($event)\">\n <mat-icon>{{getIconName()}}</mat-icon>\n</button>", styles: [""], dependencies: [{ kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }] });
192
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: IconButtonColumnComponent, decorators: [{
193
+ type: Component,
194
+ args: [{ selector: 'tots-icon-button-column', template: "<button mat-icon-button [color]=\"getButtonColor()\" [class]=\"getClasses()\" (click)=\"clickButton($event)\">\n <mat-icon>{{getIconName()}}</mat-icon>\n</button>" }]
195
+ }] });
196
+
197
+ class CheckboxColumnComponent extends TotsBaseColumnComponent {
198
+ onChange(event) {
199
+ let key = 'select-item';
200
+ if (!event.checked) {
201
+ key = 'unselect-item';
202
+ }
203
+ this.onAction.next({ key: key, item: this.item });
204
+ }
205
+ }
206
+ CheckboxColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: CheckboxColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
207
+ CheckboxColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: CheckboxColumnComponent, selector: "tots-checkbox-column", usesInheritance: true, ngImport: i0, template: "<div class=\"tots-checkbox-column\">\n <mat-checkbox (change)=\"onChange($event)\" (click)=\"$event.stopPropagation();\"></mat-checkbox>\n</div>", styles: [""], dependencies: [{ kind: "component", type: i1$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }] });
208
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: CheckboxColumnComponent, decorators: [{
209
+ type: Component,
210
+ args: [{ selector: 'tots-checkbox-column', template: "<div class=\"tots-checkbox-column\">\n <mat-checkbox (change)=\"onChange($event)\" (click)=\"$event.stopPropagation();\"></mat-checkbox>\n</div>" }]
211
+ }] });
212
+
213
+ class OptionColumnComponent extends TotsBaseColumnComponent {
214
+ getItemValue() {
215
+ let value = TotsTableHelper.getItemValueByKey(this.item, this.column.field_key);
216
+ for (const item of this.column.extra.options) {
217
+ if (item[this.column.extra.field_rel_key] == value) {
218
+ return item[this.column.extra.field_print_key];
219
+ }
220
+ }
221
+ return '';
222
+ }
223
+ }
224
+ OptionColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: OptionColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
225
+ OptionColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: OptionColumnComponent, selector: "tots-option-column", usesInheritance: true, ngImport: i0, template: "{{getItemValue()}}", styles: [""] });
226
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: OptionColumnComponent, decorators: [{
227
+ type: Component,
228
+ args: [{ selector: 'tots-option-column', template: "{{getItemValue()}}" }]
229
+ }] });
230
+
231
+ class UserColumnComponent extends TotsBaseColumnComponent {
232
+ getFirstname() {
233
+ var _a;
234
+ if ((_a = this.column.extra) === null || _a === void 0 ? void 0 : _a.field_firstname_key) {
235
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.extra.field_firstname_key);
236
+ }
237
+ return '';
238
+ }
239
+ getLastname() {
240
+ var _a;
241
+ if ((_a = this.column.extra) === null || _a === void 0 ? void 0 : _a.field_lastname_key) {
242
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.extra.field_lastname_key);
243
+ }
244
+ return '';
245
+ }
246
+ getFullname() {
247
+ return this.getFirstname() + ' ' + this.getLastname();
248
+ }
249
+ getPhoto() {
250
+ var _a;
251
+ if ((_a = this.column.extra) === null || _a === void 0 ? void 0 : _a.field_photo_key) {
252
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.extra.field_photo_key);
253
+ }
254
+ return '';
255
+ }
256
+ getSubtitle() {
257
+ var _a;
258
+ if ((_a = this.column.extra) === null || _a === void 0 ? void 0 : _a.field_subtitle_key) {
259
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.extra.field_subtitle_key);
260
+ }
261
+ return '';
262
+ }
263
+ isOnline() {
264
+ var _a;
265
+ if ((_a = this.column.extra) === null || _a === void 0 ? void 0 : _a.field_online_key) {
266
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.extra.field_online_key);
267
+ }
268
+ return false;
269
+ }
270
+ }
271
+ UserColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: UserColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
272
+ UserColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: UserColumnComponent, selector: "tots-user-column", usesInheritance: true, ngImport: i0, template: "<div class=\"user-avatar-component\">\n <div class=\"avatar\" *ngIf=\"getPhoto() != ''\">\n <img mat-card-avatar [src]=\"getPhoto()\" alt=\"{{ getFullname() }}\" class=\"cover-image\" onerror=\"this.src='/assets/img/user-avatar-empty.svg';\">\n </div>\n <div class=\"texts\">\n <div class=\"user\"> {{ getFullname() }} </div>\n <div class=\"body-2\" *ngIf=\"getSubtitle() != ''\"> {{ getSubtitle() }} </div>\n </div>\n <div class=\"check\" *ngIf=\"column.extra?.field_is_online && isOnline()\"><mat-icon>check</mat-icon></div>\n</div>", styles: [".user-avatar-component{display:flex;align-items:center;position:relative}.user-avatar-component .avatar{width:40px;min-width:40px;height:40px;min-height:40px;border-radius:40px;overflow:hidden;margin-right:16px}.user-avatar-component .avatar img{width:40px;min-width:40px;height:40px;min-height:40px}.user-avatar-component .texts .user{font-size:1.1em}.user-avatar-component .texts .body-2{color:#636363;font-size:.9em}.user-avatar-component .check{position:absolute;border:2px solid white;border-radius:200px;top:0;left:0;color:#24b524;background-color:#d7ffa3;width:1em;height:1em;display:flex;align-items:center;justify-content:center}.user-avatar-component .check mat-icon{line-height:1em;font-size:1em;width:1em;height:1em}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
273
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: UserColumnComponent, decorators: [{
274
+ type: Component,
275
+ args: [{ selector: 'tots-user-column', template: "<div class=\"user-avatar-component\">\n <div class=\"avatar\" *ngIf=\"getPhoto() != ''\">\n <img mat-card-avatar [src]=\"getPhoto()\" alt=\"{{ getFullname() }}\" class=\"cover-image\" onerror=\"this.src='/assets/img/user-avatar-empty.svg';\">\n </div>\n <div class=\"texts\">\n <div class=\"user\"> {{ getFullname() }} </div>\n <div class=\"body-2\" *ngIf=\"getSubtitle() != ''\"> {{ getSubtitle() }} </div>\n </div>\n <div class=\"check\" *ngIf=\"column.extra?.field_is_online && isOnline()\"><mat-icon>check</mat-icon></div>\n</div>", styles: [".user-avatar-component{display:flex;align-items:center;position:relative}.user-avatar-component .avatar{width:40px;min-width:40px;height:40px;min-height:40px;border-radius:40px;overflow:hidden;margin-right:16px}.user-avatar-component .avatar img{width:40px;min-width:40px;height:40px;min-height:40px}.user-avatar-component .texts .user{font-size:1.1em}.user-avatar-component .texts .body-2{color:#636363;font-size:.9em}.user-avatar-component .check{position:absolute;border:2px solid white;border-radius:200px;top:0;left:0;color:#24b524;background-color:#d7ffa3;width:1em;height:1em;display:flex;align-items:center;justify-content:center}.user-avatar-component .check mat-icon{line-height:1em;font-size:1em;width:1em;height:1em}\n"] }]
276
+ }] });
277
+
278
+ class CurrencyColumnComponent extends TotsBaseColumnComponent {
279
+ }
280
+ CurrencyColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: CurrencyColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
281
+ CurrencyColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: CurrencyColumnComponent, selector: "tots-currency-column", usesInheritance: true, ngImport: i0, template: "<span [ngClass]=\"{'tots-currency-column-positive': getItemValue() > 0, 'tots-currency-column-negative': getItemValue() < 0}\">{{getItemValue()|currency}}</span>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: i1.CurrencyPipe, name: "currency" }] });
282
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: CurrencyColumnComponent, decorators: [{
283
+ type: Component,
284
+ args: [{ selector: 'tots-currency-column', template: "<span [ngClass]=\"{'tots-currency-column-positive': getItemValue() > 0, 'tots-currency-column-negative': getItemValue() < 0}\">{{getItemValue()|currency}}</span>" }]
285
+ }] });
286
+
287
+ class StatusColumnComponent extends OptionColumnComponent {
288
+ getBackgroundColor() {
289
+ let value = TotsTableHelper.getItemValueByKey(this.item, this.column.field_key);
290
+ for (const item of this.column.extra.options) {
291
+ if (item[this.column.extra.field_rel_key] == value && item['background_color'] != undefined) {
292
+ return item['background_color'];
293
+ }
294
+ }
295
+ return '';
296
+ }
297
+ getFontColor() {
298
+ let value = TotsTableHelper.getItemValueByKey(this.item, this.column.field_key);
299
+ for (const item of this.column.extra.options) {
300
+ if (item[this.column.extra.field_rel_key] == value && item['font_color'] != undefined) {
301
+ return item['font_color'];
302
+ }
303
+ }
304
+ return '';
305
+ }
306
+ }
307
+ StatusColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: StatusColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
308
+ StatusColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: StatusColumnComponent, selector: "tots-status-column", usesInheritance: true, ngImport: i0, template: "<span class=\"tots-status-column\" [ngStyle]=\"{'background-color': getBackgroundColor(), 'color': getFontColor()}\">{{getItemValue()}}</span>", styles: [".tots-status-column{display:inline-block;padding:3px 10px;background-color:#e7e7e7;color:#08081699;font-size:x-small;font-weight:700;text-transform:uppercase}\n"], dependencies: [{ kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
309
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: StatusColumnComponent, decorators: [{
310
+ type: Component,
311
+ args: [{ selector: 'tots-status-column', template: "<span class=\"tots-status-column\" [ngStyle]=\"{'background-color': getBackgroundColor(), 'color': getFontColor()}\">{{getItemValue()}}</span>", styles: [".tots-status-column{display:inline-block;padding:3px 10px;background-color:#e7e7e7;color:#08081699;font-size:x-small;font-weight:700;text-transform:uppercase}\n"] }]
312
+ }] });
313
+
314
+ class BalanceCurrencyColumnComponent extends TotsBaseColumnComponent {
315
+ getBalance() {
316
+ return this.getDebit() - this.getCredit();
317
+ }
318
+ getDebit() {
319
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.extra.field_key_debit);
320
+ }
321
+ getCredit() {
322
+ return TotsTableHelper.getItemValueByKey(this.item, this.column.extra.field_key_credit);
323
+ }
324
+ }
325
+ BalanceCurrencyColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BalanceCurrencyColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
326
+ BalanceCurrencyColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: BalanceCurrencyColumnComponent, selector: "tots-balance-currency-column", usesInheritance: true, ngImport: i0, template: "<span [ngClass]=\"{'tots-balance-column-positive': getBalance() > 0, 'tots-balance-column-negative': getBalance() < 0}\">{{getBalance()|currency}}</span>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: i1.CurrencyPipe, name: "currency" }] });
327
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BalanceCurrencyColumnComponent, decorators: [{
328
+ type: Component,
329
+ args: [{ selector: 'tots-balance-currency-column', template: "<span [ngClass]=\"{'tots-balance-column-positive': getBalance() > 0, 'tots-balance-column-negative': getBalance() < 0}\">{{getBalance()|currency}}</span>" }]
330
+ }] });
331
+
332
+ class StatusIconColumnComponent extends OptionColumnComponent {
333
+ getFontColor() {
334
+ let value = TotsTableHelper.getItemValueByKey(this.item, this.column.field_key);
335
+ for (const item of this.column.extra.options) {
336
+ if (item[this.column.extra.field_rel_key] == value && item['font_color'] != undefined) {
337
+ return item['font_color'];
338
+ }
339
+ }
340
+ return '';
341
+ }
342
+ }
343
+ StatusIconColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: StatusIconColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
344
+ StatusIconColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: StatusIconColumnComponent, selector: "tots-status-icon-column", usesInheritance: true, ngImport: i0, template: "<span class=\"tots-status-icon-column\" [ngStyle]=\"{'color': getFontColor()}\"><mat-icon>{{getItemValue()}}</mat-icon></span>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
345
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: StatusIconColumnComponent, decorators: [{
346
+ type: Component,
347
+ args: [{ selector: 'tots-status-icon-column', template: "<span class=\"tots-status-icon-column\" [ngStyle]=\"{'color': getFontColor()}\"><mat-icon>{{getItemValue()}}</mat-icon></span>" }]
348
+ }] });
349
+
350
+ class BalanceCurrencyIconColumnComponent extends BalanceCurrencyColumnComponent {
351
+ getIconPositive() {
352
+ return this.column.extra.icon_positive;
353
+ }
354
+ getIconNegative() {
355
+ return this.column.extra.icon_negative;
356
+ }
357
+ getIconNeutral() {
358
+ return this.column.extra.icon_neutral;
359
+ }
360
+ }
361
+ BalanceCurrencyIconColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BalanceCurrencyIconColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
362
+ BalanceCurrencyIconColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: BalanceCurrencyIconColumnComponent, selector: "tots-balance-currency-icon-column", usesInheritance: true, ngImport: i0, template: "<span [ngClass]=\"{'tots-balance-column-positive': getBalance() > 0, 'tots-balance-column-negative': getBalance() < 0}\">\n <mat-icon *ngIf=\"getBalance() > 0\">{{getIconPositive()}}</mat-icon>\n <mat-icon *ngIf=\"getBalance() < 0\">{{getIconNegative()}}</mat-icon>\n <mat-icon *ngIf=\"getBalance() == 0\">{{getIconNeutral()}}</mat-icon>\n</span>", styles: [""], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
363
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BalanceCurrencyIconColumnComponent, decorators: [{
364
+ type: Component,
365
+ args: [{ selector: 'tots-balance-currency-icon-column', template: "<span [ngClass]=\"{'tots-balance-column-positive': getBalance() > 0, 'tots-balance-column-negative': getBalance() < 0}\">\n <mat-icon *ngIf=\"getBalance() > 0\">{{getIconPositive()}}</mat-icon>\n <mat-icon *ngIf=\"getBalance() < 0\">{{getIconNegative()}}</mat-icon>\n <mat-icon *ngIf=\"getBalance() == 0\">{{getIconNeutral()}}</mat-icon>\n</span>" }]
366
+ }] });
367
+
368
+ class BasePrintColumnComponent {
369
+ constructor(viewContainerRef) {
370
+ this.viewContainerRef = viewContainerRef;
371
+ }
372
+ ngOnInit() {
373
+ const view = this.viewContainerRef.createComponent(this.column.component);
374
+ view.instance.column = this.column;
375
+ view.instance.item = this.item;
376
+ view.instance.onAction = this.onAction;
377
+ view.instance.index = this.index;
378
+ }
379
+ }
380
+ BasePrintColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BasePrintColumnComponent, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
381
+ BasePrintColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: BasePrintColumnComponent, selector: "tots-base-print-column", inputs: { column: "column", item: "item", onAction: "onAction", index: "index" }, ngImport: i0, template: "<div #contentColumn></div>", styles: [""] });
382
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: BasePrintColumnComponent, decorators: [{
383
+ type: Component,
384
+ args: [{ selector: 'tots-base-print-column', template: "<div #contentColumn></div>" }]
385
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; }, propDecorators: { column: [{
386
+ type: Input
387
+ }], item: [{
388
+ type: Input
389
+ }], onAction: [{
390
+ type: Input
391
+ }], index: [{
392
+ type: Input
393
+ }] } });
394
+
395
+ class LoadingAnimationRendererComponent {
396
+ //#region Setup
397
+ constructor(totsTableDefaultConfig, viewContainerRef) {
398
+ this.totsTableDefaultConfig = totsTableDefaultConfig;
399
+ this.viewContainerRef = viewContainerRef;
400
+ }
401
+ ngOnInit() {
402
+ this.setLoader();
403
+ }
404
+ ngOnDestroy() {
405
+ var _a;
406
+ (_a = this.loadingComponentContainer) === null || _a === void 0 ? void 0 : _a.clear();
407
+ }
408
+ setLoader() {
409
+ if (this.totsTableDefaultConfig.loadingComponent) {
410
+ this.loadingComponent = this.viewContainerRef.createComponent(this.totsTableDefaultConfig.loadingComponent);
411
+ }
412
+ else {
413
+ this.loadingComponent = this.viewContainerRef.createComponent(MatProgressSpinner);
414
+ this.loadingComponent.instance.diameter = 50;
415
+ this.loadingComponent.instance.mode = "indeterminate";
416
+ }
417
+ }
418
+ }
419
+ LoadingAnimationRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: LoadingAnimationRendererComponent, deps: [{ token: TOTS_TABLE_DEFAULT_CONFIG }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
420
+ LoadingAnimationRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: LoadingAnimationRendererComponent, selector: "tots-loading-animation-renderer", viewQueries: [{ propertyName: "loadingComponentContainer", first: true, predicate: ["loadingComponentContainer"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: "<ng-container #loadingComponentContainer></ng-container>", styles: [""] });
421
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: LoadingAnimationRendererComponent, decorators: [{
422
+ type: Component,
423
+ args: [{ selector: 'tots-loading-animation-renderer', template: "<ng-container #loadingComponentContainer></ng-container>" }]
424
+ }], ctorParameters: function () {
425
+ return [{ type: TotsTableDefaultConfig, decorators: [{
426
+ type: Inject,
427
+ args: [TOTS_TABLE_DEFAULT_CONFIG]
428
+ }] }, { type: i0.ViewContainerRef }];
429
+ }, propDecorators: { loadingComponentContainer: [{
430
+ type: ViewChild,
431
+ args: ['loadingComponentContainer', { read: ViewContainerRef }]
432
+ }] } });
433
+
434
+ class TotsTableComponent {
435
+ constructor(totsTableDefaultConfig, changeDectetor) {
436
+ this.totsTableDefaultConfig = totsTableDefaultConfig;
437
+ this.changeDectetor = changeDectetor;
438
+ this.config = new TotsTableConfig();
439
+ this.pageIndex = 0;
440
+ this.pageSize = 50;
441
+ this.hasPagination = true;
442
+ this.onAction = new EventEmitter();
443
+ this.privateActions = new Subject();
444
+ this.isLoading = true;
445
+ this.firstLoad = true;
446
+ this.displayColumns = [];
447
+ this.messageNotFound = this.totsTableDefaultConfig.messageNotFound || "No results found, please try with other search terms";
448
+ }
449
+ ngOnInit() {
450
+ this.loadConfig();
451
+ this.loadItems();
452
+ }
453
+ onClickOrder(column) {
454
+ if (!column.hasOrder) {
455
+ return;
456
+ }
457
+ let orderColumn = column.order;
458
+ this.config.columns.forEach(c => c.order = undefined);
459
+ column.order = orderColumn == 'asc' ? 'desc' : 'asc';
460
+ this.onAction.emit({ key: 'click-order', item: column });
461
+ }
462
+ onClickRow(item) {
463
+ this.onAction.emit({ key: 'click-row', item: item });
464
+ }
465
+ onPageChange(event) {
466
+ this.onAction.emit({ key: 'page-change', item: event });
467
+ }
468
+ loadItems() {
469
+ var _a;
470
+ this.isLoading = true;
471
+ return (_a = this.config.obs) === null || _a === void 0 ? void 0 : _a.pipe(tap(res => this.dataItems = res)).pipe(tap(res => this.onAction.emit({ key: 'loaded-items', item: undefined }))).subscribe(() => this.stopLoading());
472
+ }
473
+ stopLoading() {
474
+ this.isLoading = false;
475
+ this.firstLoad = false;
476
+ }
477
+ loadConfig() {
478
+ this.loadColumns();
479
+ this.privateActions.subscribe(action => {
480
+ this.onAction.emit(action);
481
+ });
482
+ }
483
+ loadColumns() {
484
+ this.displayColumns = this.config.columns.filter(c => c.is_show || c.is_show == undefined).map(c => c.key);
485
+ }
486
+ getDataItems() {
487
+ return this.dataItems;
488
+ }
489
+ refreshDataItems(newData) {
490
+ this.dataItems = newData;
491
+ }
492
+ detectChanges() {
493
+ this.changeDectetor.detectChanges();
494
+ }
495
+ }
496
+ TotsTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableComponent, deps: [{ token: TOTS_TABLE_DEFAULT_CONFIG }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
497
+ TotsTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: TotsTableComponent, selector: "tots-table", inputs: { config: "config", pageIndex: "pageIndex", pageSize: "pageSize", hasPagination: "hasPagination", messageNotFound: "messageNotFound" }, outputs: { onAction: "onAction" }, ngImport: i0, template: "<div class=\"tots-table-container {{config.classes}}\">\n <table mat-table [dataSource]=\"dataItems != undefined ? dataItems!.data : []\">\n\n <ng-container *ngFor=\"let column of config.columns\" [matColumnDef]=\"column.key\" [stickyEnd]=\"column.extra?.stickyEnd ?? false\">\n <!-- TH-->\n <th mat-header-cell *matHeaderCellDef [ngClass]=\"{'tots-tr-has-order': column.hasOrder}\" (click)=\"onClickOrder(column)\">\n {{ column.title }}\n <mat-icon [ngClass]=\"{'sort_active': column.order == 'asc'}\">arrow_drop_up</mat-icon>\n <mat-icon [ngClass]=\"{'sort_active': column.order == 'desc'}\">arrow_drop_down</mat-icon>\n </th>\n <!-- TD -->\n <td mat-cell *matCellDef=\"let item; let index = index;\" [ngStyle]=\"{'width': column.extra?.width ? column.extra.width : 'auto'}\"><tots-base-print-column [column]=\"column\" [item]=\"item\" [index]=\"index\" [onAction]=\"privateActions\"></tots-base-print-column></td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayColumns;\" (click)=\"onClickRow(row)\" [class]=\"row.classCustom\" [ngClass]=\"{'tots-cell-selected': row.isSelected}\"></tr>\n\n <!-- Row shown when there is no matching data. -->\n <ng-container *ngIf=\"!isLoading\">\n <tr class=\"tots-table-not-data\" *matNoDataRow><td class=\"mat-cell\" [colSpan]=\"config.columns.length\">{{ messageNotFound }}</td></tr>\n </ng-container>\n </table>\n\n <div *ngIf=\"isLoading && firstLoad\" class=\"tots-table-loading\">\n <tots-loading-animation-renderer></tots-loading-animation-renderer>\n </div>\n\n <div class=\"tots-table-bar-loading\">\n <mat-progress-bar *ngIf=\"isLoading && !firstLoad\" [mode]=\"'indeterminate'\"></mat-progress-bar>\n </div>\n\n <!-- Paginator -->\n <mat-paginator *ngIf=\"dataItems && dataItems.data.length > 0 && hasPagination\" [pageIndex]=\"pageIndex-1\" [length]=\"dataItems!.total\" [pageSize]=\"pageSize\" [pageSizeOptions]=\"[5, 10, 25, 50, 100]\" (page)=\"onPageChange($event)\"></mat-paginator>\n</div>\n", styles: [".tots-table-container .mat-mdc-header-cell{position:relative}.tots-table-container .mat-mdc-header-cell mat-icon{display:none}.tots-table-container .tots-tr-has-order{cursor:pointer}.tots-table-container .tots-tr-has-order:hover mat-icon{opacity:.5}.tots-table-container .tots-tr-has-order mat-icon{display:inline;opacity:.3;position:absolute}.tots-table-container .tots-tr-has-order mat-icon:nth-of-type(1){top:12px}.tots-table-container .tots-tr-has-order mat-icon:nth-of-type(2){top:20px}.tots-table-container .tots-tr-has-order .sort_active{opacity:1!important}.tots-table-container .tots-table-loading{display:flex;justify-content:center;text-align:center}.tots-table-container .tots-table-bar-loading{height:4px}.tots-table-container .tots-table-not-data{font-size:large;text-align:center}.tots-table-container .tots-table-not-data td{padding:24px}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i3$1.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i3$1.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i3$1.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i3$1.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { kind: "directive", type: i3$1.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i3$1.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i3$1.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i3$1.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i3$1.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i3$1.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "directive", type: i3$1.MatNoDataRow, selector: "ng-template[matNoDataRow]" }, { kind: "component", type: i4$1.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "component", type: i5.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "component", type: BasePrintColumnComponent, selector: "tots-base-print-column", inputs: ["column", "item", "onAction", "index"] }, { kind: "component", type: LoadingAnimationRendererComponent, selector: "tots-loading-animation-renderer" }] });
498
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableComponent, decorators: [{
499
+ type: Component,
500
+ args: [{ selector: 'tots-table', template: "<div class=\"tots-table-container {{config.classes}}\">\n <table mat-table [dataSource]=\"dataItems != undefined ? dataItems!.data : []\">\n\n <ng-container *ngFor=\"let column of config.columns\" [matColumnDef]=\"column.key\" [stickyEnd]=\"column.extra?.stickyEnd ?? false\">\n <!-- TH-->\n <th mat-header-cell *matHeaderCellDef [ngClass]=\"{'tots-tr-has-order': column.hasOrder}\" (click)=\"onClickOrder(column)\">\n {{ column.title }}\n <mat-icon [ngClass]=\"{'sort_active': column.order == 'asc'}\">arrow_drop_up</mat-icon>\n <mat-icon [ngClass]=\"{'sort_active': column.order == 'desc'}\">arrow_drop_down</mat-icon>\n </th>\n <!-- TD -->\n <td mat-cell *matCellDef=\"let item; let index = index;\" [ngStyle]=\"{'width': column.extra?.width ? column.extra.width : 'auto'}\"><tots-base-print-column [column]=\"column\" [item]=\"item\" [index]=\"index\" [onAction]=\"privateActions\"></tots-base-print-column></td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"displayColumns\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: displayColumns;\" (click)=\"onClickRow(row)\" [class]=\"row.classCustom\" [ngClass]=\"{'tots-cell-selected': row.isSelected}\"></tr>\n\n <!-- Row shown when there is no matching data. -->\n <ng-container *ngIf=\"!isLoading\">\n <tr class=\"tots-table-not-data\" *matNoDataRow><td class=\"mat-cell\" [colSpan]=\"config.columns.length\">{{ messageNotFound }}</td></tr>\n </ng-container>\n </table>\n\n <div *ngIf=\"isLoading && firstLoad\" class=\"tots-table-loading\">\n <tots-loading-animation-renderer></tots-loading-animation-renderer>\n </div>\n\n <div class=\"tots-table-bar-loading\">\n <mat-progress-bar *ngIf=\"isLoading && !firstLoad\" [mode]=\"'indeterminate'\"></mat-progress-bar>\n </div>\n\n <!-- Paginator -->\n <mat-paginator *ngIf=\"dataItems && dataItems.data.length > 0 && hasPagination\" [pageIndex]=\"pageIndex-1\" [length]=\"dataItems!.total\" [pageSize]=\"pageSize\" [pageSizeOptions]=\"[5, 10, 25, 50, 100]\" (page)=\"onPageChange($event)\"></mat-paginator>\n</div>\n", styles: [".tots-table-container .mat-mdc-header-cell{position:relative}.tots-table-container .mat-mdc-header-cell mat-icon{display:none}.tots-table-container .tots-tr-has-order{cursor:pointer}.tots-table-container .tots-tr-has-order:hover mat-icon{opacity:.5}.tots-table-container .tots-tr-has-order mat-icon{display:inline;opacity:.3;position:absolute}.tots-table-container .tots-tr-has-order mat-icon:nth-of-type(1){top:12px}.tots-table-container .tots-tr-has-order mat-icon:nth-of-type(2){top:20px}.tots-table-container .tots-tr-has-order .sort_active{opacity:1!important}.tots-table-container .tots-table-loading{display:flex;justify-content:center;text-align:center}.tots-table-container .tots-table-bar-loading{height:4px}.tots-table-container .tots-table-not-data{font-size:large;text-align:center}.tots-table-container .tots-table-not-data td{padding:24px}\n"] }]
501
+ }], ctorParameters: function () {
502
+ return [{ type: TotsTableDefaultConfig, decorators: [{
503
+ type: Inject,
504
+ args: [TOTS_TABLE_DEFAULT_CONFIG]
505
+ }] }, { type: i0.ChangeDetectorRef }];
506
+ }, propDecorators: { config: [{
507
+ type: Input
508
+ }], pageIndex: [{
509
+ type: Input
510
+ }], pageSize: [{
511
+ type: Input
512
+ }], hasPagination: [{
513
+ type: Input
514
+ }], messageNotFound: [{
515
+ type: Input
516
+ }], onAction: [{
517
+ type: Output
518
+ }] } });
519
+
520
+ class TotsTableApiComponent {
521
+ constructor() {
522
+ this.config = new TotsTableApiConfig();
523
+ this.hasPagination = true;
524
+ this.isPaginationStartIndexInZero = false;
525
+ this.onAction = new EventEmitter();
526
+ this.configTable = new TotsTableConfig();
527
+ }
528
+ ngOnInit() {
529
+ this.loadConfig();
530
+ }
531
+ onTableAction(action) {
532
+ if (action.key == 'page-change') {
533
+ this.config.query.per_page = action.item.pageSize;
534
+ if (this.isPaginationStartIndexInZero) {
535
+ this.config.query.page = action.item.pageIndex;
536
+ }
537
+ else {
538
+ this.config.query.page = action.item.pageIndex + 1;
539
+ }
540
+ this.configTable.obs = this.config.service.list(this.config.query);
541
+ }
542
+ this.onAction.emit(action);
543
+ }
544
+ loadConfig() {
545
+ this.configTable.id = this.config.id;
546
+ this.configTable.columns = this.config.columns;
547
+ this.configTable.obs = this.config.service.list(this.config.query);
548
+ this.configTable.classes = this.config.classes;
549
+ }
550
+ refreshQueryAndLoadItems() {
551
+ this.configTable.obs = this.config.service.list(this.config.query);
552
+ return this.loadItems();
553
+ }
554
+ loadItems() {
555
+ return this.tableComp.loadItems();
556
+ }
557
+ getDataItems() {
558
+ return this.tableComp.getDataItems();
559
+ }
560
+ setObs(obs) {
561
+ this.configTable.obs = obs;
562
+ }
563
+ }
564
+ TotsTableApiComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableApiComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
565
+ TotsTableApiComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: TotsTableApiComponent, selector: "tots-table-api", inputs: { config: "config", hasPagination: "hasPagination", isPaginationStartIndexInZero: "isPaginationStartIndexInZero" }, outputs: { onAction: "onAction" }, viewQueries: [{ propertyName: "tableComp", first: true, predicate: ["tableComp"], descendants: true }], ngImport: i0, template: "<tots-table #tableComp [config]=\"configTable\" [pageIndex]=\"config.query.page\" [pageSize]=\"config.query.per_page\" (onAction)=\"onTableAction($event)\" [hasPagination]=\"hasPagination\"></tots-table>\n", styles: [""], dependencies: [{ kind: "component", type: TotsTableComponent, selector: "tots-table", inputs: ["config", "pageIndex", "pageSize", "hasPagination", "messageNotFound"], outputs: ["onAction"] }] });
566
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableApiComponent, decorators: [{
567
+ type: Component,
568
+ args: [{ selector: 'tots-table-api', template: "<tots-table #tableComp [config]=\"configTable\" [pageIndex]=\"config.query.page\" [pageSize]=\"config.query.per_page\" (onAction)=\"onTableAction($event)\" [hasPagination]=\"hasPagination\"></tots-table>\n" }]
569
+ }], propDecorators: { tableComp: [{
570
+ type: ViewChild,
571
+ args: ['tableComp']
572
+ }], config: [{
573
+ type: Input
574
+ }], hasPagination: [{
575
+ type: Input
576
+ }], isPaginationStartIndexInZero: [{
577
+ type: Input
578
+ }], onAction: [{
579
+ type: Output
580
+ }] } });
581
+
582
+ class TotsTableLocalComponent {
583
+ constructor() {
584
+ this.configTable = new TotsTableLocalConfig();
585
+ this.hasPagination = true;
586
+ this.isPaginationStartIndexInZero = false;
587
+ this.onAction = new EventEmitter();
588
+ this.dataTotals = 0;
589
+ this.page = 1;
590
+ this.perPage = 50;
591
+ }
592
+ ngOnInit() {
593
+ this.loadConfig();
594
+ }
595
+ onFilterItems() {
596
+ if (this.dataItems == undefined) {
597
+ return;
598
+ }
599
+ let items = [...this.dataItems];
600
+ if (this.orderKey != undefined) {
601
+ if (this.orderType == 'asc') {
602
+ items = items.sort((a, b) => (a[this.orderKey] > b[this.orderKey]) ? 1 : ((b[this.orderKey] > a[this.orderKey]) ? -1 : 0));
603
+ }
604
+ else {
605
+ items = items.sort((a, b) => (a[this.orderKey] < b[this.orderKey]) ? 1 : ((b[this.orderKey] < a[this.orderKey]) ? -1 : 0));
606
+ }
607
+ }
608
+ // Aplicar busqueda
609
+ if (this.searchQuery != undefined && this.searchQuery != '') {
610
+ items = items.filter(item => {
611
+ let isMatch = false;
612
+ this.configTable.searchKeys.forEach(key => {
613
+ if (item[key] != undefined && item[key].toString().toLowerCase().includes(this.searchQuery.toLowerCase())) {
614
+ isMatch = true;
615
+ }
616
+ });
617
+ return isMatch;
618
+ });
619
+ this.dataTotals = items.length;
620
+ }
621
+ else {
622
+ this.dataTotals = this.dataItems.length;
623
+ }
624
+ let startIndex = (this.page - 1) * this.perPage;
625
+ let endIndex = startIndex + this.perPage;
626
+ this.setDataItems(this.generateListResponse(items.slice(startIndex, endIndex)));
627
+ }
628
+ onPagination(action) {
629
+ this.perPage = action.item.pageSize;
630
+ if (this.isPaginationStartIndexInZero) {
631
+ this.page = action.item.pageIndex;
632
+ }
633
+ else {
634
+ this.page = action.item.pageIndex + 1;
635
+ }
636
+ this.onFilterItems();
637
+ }
638
+ onOrder(column) {
639
+ this.orderType = column.order;
640
+ this.orderKey = column.field_key;
641
+ this.onFilterItems();
642
+ }
643
+ onTableAction(action) {
644
+ if (action.key == 'page-change') {
645
+ this.onPagination(action);
646
+ }
647
+ else if (action.key == 'click-order') {
648
+ this.onOrder(action.item);
649
+ }
650
+ this.onAction.emit(action);
651
+ }
652
+ loadConfig() {
653
+ if (this.configTable.obs == undefined) {
654
+ return;
655
+ }
656
+ this.setObs(this.configTable.obs);
657
+ }
658
+ refreshQueryAndLoadItems() {
659
+ return this.loadItems();
660
+ }
661
+ loadItems() {
662
+ return this.tableComp.loadItems();
663
+ }
664
+ getDataItems() {
665
+ return this.tableComp.getDataItems();
666
+ }
667
+ setDataItems(items) {
668
+ this.tableComp.refreshDataItems(items);
669
+ }
670
+ setObs(obs) {
671
+ this.configTable.obs = obs.pipe(tap(res => this.dataItems = res.data));
672
+ }
673
+ onSearch(query) {
674
+ this.page = 1;
675
+ this.searchQuery = query;
676
+ this.onFilterItems();
677
+ }
678
+ generateListResponse(items) {
679
+ // calcular la iultima pagina
680
+ let lastPage = Math.ceil(this.dataTotals / this.perPage);
681
+ return {
682
+ current_page: this.page,
683
+ first_page_url: '',
684
+ from: '',
685
+ last_page: lastPage,
686
+ last_page_url: '',
687
+ next_page_url: '',
688
+ path: '',
689
+ per_page: this.perPage,
690
+ prev_page_url: '',
691
+ to: '',
692
+ total: this.dataTotals,
693
+ data: items
694
+ };
695
+ }
696
+ }
697
+ TotsTableLocalComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableLocalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
698
+ TotsTableLocalComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.3", type: TotsTableLocalComponent, selector: "tots-table-local", inputs: { configTable: "configTable", hasPagination: "hasPagination", isPaginationStartIndexInZero: "isPaginationStartIndexInZero" }, outputs: { onAction: "onAction" }, viewQueries: [{ propertyName: "tableComp", first: true, predicate: ["tableComp"], descendants: true }], ngImport: i0, template: "<tots-table #tableComp [config]=\"configTable\" [pageIndex]=\"page\" [pageSize]=\"perPage\" (onAction)=\"onTableAction($event)\" [hasPagination]=\"hasPagination\"></tots-table>\n", styles: [""], dependencies: [{ kind: "component", type: TotsTableComponent, selector: "tots-table", inputs: ["config", "pageIndex", "pageSize", "hasPagination", "messageNotFound"], outputs: ["onAction"] }] });
699
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableLocalComponent, decorators: [{
700
+ type: Component,
701
+ args: [{ selector: 'tots-table-local', template: "<tots-table #tableComp [config]=\"configTable\" [pageIndex]=\"page\" [pageSize]=\"perPage\" (onAction)=\"onTableAction($event)\" [hasPagination]=\"hasPagination\"></tots-table>\n" }]
702
+ }], propDecorators: { tableComp: [{
703
+ type: ViewChild,
704
+ args: ['tableComp']
705
+ }], configTable: [{
706
+ type: Input
707
+ }], hasPagination: [{
708
+ type: Input
709
+ }], isPaginationStartIndexInZero: [{
710
+ type: Input
711
+ }], onAction: [{
712
+ type: Output
713
+ }] } });
714
+
715
+ class TotsTableModule {
716
+ }
717
+ TotsTableModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
718
+ TotsTableModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.3", ngImport: i0, type: TotsTableModule, declarations: [TotsTableComponent,
719
+ BasePrintColumnComponent,
720
+ StringColumnComponent,
721
+ TotsTableApiComponent,
722
+ MoreMenuColumnComponent,
723
+ BooleanColumnComponent,
724
+ TwoStringColumnComponent,
725
+ IconButtonColumnComponent,
726
+ CheckboxColumnComponent,
727
+ OptionColumnComponent,
728
+ UserColumnComponent,
729
+ CurrencyColumnComponent,
730
+ StatusColumnComponent,
731
+ BalanceCurrencyColumnComponent,
732
+ StatusIconColumnComponent,
733
+ BalanceCurrencyIconColumnComponent,
734
+ LoadingAnimationRendererComponent,
735
+ TotsTableLocalComponent], imports: [CommonModule,
736
+ // Angular Material
737
+ MatIconModule,
738
+ MatTableModule,
739
+ MatPaginatorModule,
740
+ MatButtonModule,
741
+ MatMenuModule,
742
+ MatCheckboxModule,
743
+ MatProgressSpinnerModule,
744
+ MatProgressBarModule], exports: [TotsTableComponent,
745
+ TotsTableApiComponent,
746
+ TotsTableLocalComponent] });
747
+ TotsTableModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableModule, providers: [
748
+ {
749
+ provide: TOTS_TABLE_DEFAULT_CONFIG,
750
+ useClass: TotsTableDefaultConfig
751
+ }
752
+ ], imports: [CommonModule,
753
+ // Angular Material
754
+ MatIconModule,
755
+ MatTableModule,
756
+ MatPaginatorModule,
757
+ MatButtonModule,
758
+ MatMenuModule,
759
+ MatCheckboxModule,
760
+ MatProgressSpinnerModule,
761
+ MatProgressBarModule] });
762
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.3", ngImport: i0, type: TotsTableModule, decorators: [{
763
+ type: NgModule,
764
+ args: [{
765
+ declarations: [
766
+ TotsTableComponent,
767
+ BasePrintColumnComponent,
768
+ StringColumnComponent,
769
+ TotsTableApiComponent,
770
+ MoreMenuColumnComponent,
771
+ BooleanColumnComponent,
772
+ TwoStringColumnComponent,
773
+ IconButtonColumnComponent,
774
+ CheckboxColumnComponent,
775
+ OptionColumnComponent,
776
+ UserColumnComponent,
777
+ CurrencyColumnComponent,
778
+ StatusColumnComponent,
779
+ BalanceCurrencyColumnComponent,
780
+ StatusIconColumnComponent,
781
+ BalanceCurrencyIconColumnComponent,
782
+ LoadingAnimationRendererComponent,
783
+ TotsTableLocalComponent
784
+ ],
785
+ imports: [
786
+ CommonModule,
787
+ // Angular Material
788
+ MatIconModule,
789
+ MatTableModule,
790
+ MatPaginatorModule,
791
+ MatButtonModule,
792
+ MatMenuModule,
793
+ MatCheckboxModule,
794
+ MatProgressSpinnerModule,
795
+ MatProgressBarModule
796
+ ],
797
+ exports: [
798
+ TotsTableComponent,
799
+ TotsTableApiComponent,
800
+ TotsTableLocalComponent,
801
+ ],
802
+ providers: [
803
+ {
804
+ provide: TOTS_TABLE_DEFAULT_CONFIG,
805
+ useClass: TotsTableDefaultConfig
806
+ }
807
+ ]
808
+ }]
809
+ }] });
810
+
811
+ /*
812
+ * Public API Surface of table
813
+ */
814
+
815
+ /**
816
+ * Generated bundle index. Do not edit.
817
+ */
818
+
819
+ export { BalanceCurrencyColumnComponent, BalanceCurrencyIconColumnComponent, BooleanColumnComponent, CheckboxColumnComponent, CurrencyColumnComponent, IconButtonColumnComponent, MoreMenuColumnComponent, OptionColumnComponent, StatusColumnComponent, StatusIconColumnComponent, StringColumnComponent, TOTS_TABLE_DEFAULT_CONFIG, TotsActionTable, TotsBaseColumnComponent, TotsColumn, TotsTableApiComponent, TotsTableApiConfig, TotsTableComponent, TotsTableConfig, TotsTableDefaultConfig, TotsTableHelper, TotsTableLocalComponent, TotsTableLocalConfig, TotsTableModule, TwoStringColumnComponent, UserColumnComponent };
820
+ //# sourceMappingURL=tots-table.mjs.map