mapa-library-ui 2.0.5 → 2.1.1
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/mapa-library-ui-src-lib-components-group-report.mjs +1287 -32
- package/fesm2022/mapa-library-ui-src-lib-components-group-report.mjs.map +1 -1
- package/fesm2022/mapa-library-ui-src-lib-components-table.mjs +2 -2
- package/fesm2022/mapa-library-ui-src-lib-components-table.mjs.map +1 -1
- package/fesm2022/mapa-library-ui.mjs +465 -462
- package/fesm2022/mapa-library-ui.mjs.map +1 -1
- package/index.d.ts +177 -179
- package/mapa-library-ui-2.1.1.tgz +0 -0
- package/package.json +1 -1
- package/src/lib/components/group-report/index.d.ts +12 -8
- package/src/lib/components/scale-parameterization/index.d.ts +17 -17
- package/mapa-library-ui-2.0.5.tgz +0 -0
|
@@ -1,29 +1,1274 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
1
|
+
import * as i2 from '@angular/common';
|
|
2
|
+
import { CommonModule, NgClass, NgTemplateOutlet, DatePipe } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { EventEmitter,
|
|
5
|
-
import * as
|
|
4
|
+
import { effect, EventEmitter, inject, DestroyRef, Input, Output, Directive, SecurityContext, Injectable, Pipe, InjectionToken, Injector, signal, Optional, Inject, Component, TemplateRef, contentChildren, ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core';
|
|
5
|
+
import * as i1 from '@angular/material/paginator';
|
|
6
|
+
import { MatPaginatorIntl, MatPaginatorModule } from '@angular/material/paginator';
|
|
7
|
+
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
8
|
+
import * as i1$3 from '@angular/material/checkbox';
|
|
9
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
10
|
+
import * as i2$1 from '@angular/material/icon';
|
|
6
11
|
import { MatIconModule } from '@angular/material/icon';
|
|
7
|
-
import * as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
12
|
+
import * as i3 from '@angular/material/menu';
|
|
13
|
+
import { MatMenuModule } from '@angular/material/menu';
|
|
14
|
+
import { RouterLink } from '@angular/router';
|
|
15
|
+
import { map, startWith } from 'rxjs/operators';
|
|
16
|
+
import * as i1$1 from '@angular/platform-browser';
|
|
17
|
+
import { getStoredAppLanguage, getIntlLocale } from 'mapa-frontend-i18n';
|
|
18
|
+
import * as i1$2 from '@angular/common/http';
|
|
19
|
+
|
|
20
|
+
function customPaginatorFactory(i18n, injector) {
|
|
21
|
+
const customPaginatorIntl = new MatPaginatorIntl();
|
|
22
|
+
effect(() => {
|
|
23
|
+
const paginatorTexts = i18n.textsSignal().paginator;
|
|
24
|
+
customPaginatorIntl.itemsPerPageLabel = paginatorTexts.itemsPerPage;
|
|
25
|
+
customPaginatorIntl.nextPageLabel = paginatorTexts.nextPage;
|
|
26
|
+
customPaginatorIntl.previousPageLabel = paginatorTexts.previousPage;
|
|
27
|
+
customPaginatorIntl.getRangeLabel = paginatorTexts.showingRangeLabel;
|
|
28
|
+
customPaginatorIntl.changes.next();
|
|
29
|
+
}, { injector });
|
|
30
|
+
return customPaginatorIntl;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class BubblePaginationDirective {
|
|
34
|
+
constructor(matPag, elementRef, ren) {
|
|
35
|
+
this.matPag = matPag;
|
|
36
|
+
this.elementRef = elementRef;
|
|
37
|
+
this.ren = ren;
|
|
38
|
+
this.pageIndexChangeEmitter = new EventEmitter();
|
|
39
|
+
this.showFirstButton = true;
|
|
40
|
+
this.showLastButton = true;
|
|
41
|
+
this.renderButtonsNumber = 2;
|
|
42
|
+
this.hideDefaultArrows = false;
|
|
43
|
+
this.buttonsRef = [];
|
|
44
|
+
this.removeButtonListeners = [];
|
|
45
|
+
this.rebuildQueued = false;
|
|
46
|
+
this.destroyRef = inject(DestroyRef);
|
|
47
|
+
}
|
|
48
|
+
ngAfterViewInit() {
|
|
49
|
+
this.styleDefaultPagination();
|
|
50
|
+
this.createBubbleDivRef();
|
|
51
|
+
this.renderButtons();
|
|
52
|
+
}
|
|
53
|
+
ngOnChanges(changes) {
|
|
54
|
+
if (!this.bubbleContainerRef) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if ((!changes?.['appCustomLength']?.firstChange &&
|
|
58
|
+
changes?.['appCustomLength']) ||
|
|
59
|
+
(!changes?.['bubblePageIndex']?.firstChange &&
|
|
60
|
+
changes?.['bubblePageIndex']) ||
|
|
61
|
+
(!changes?.['bubblePageSize']?.firstChange && changes?.['bubblePageSize'])) {
|
|
62
|
+
this.scheduleRebuildButtons();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ngOnDestroy() {
|
|
66
|
+
this.clearButtonListeners();
|
|
67
|
+
}
|
|
68
|
+
renderButtons() {
|
|
69
|
+
this.rebuildButtons();
|
|
70
|
+
this.matPag.page
|
|
71
|
+
.pipe(map((e) => [e.previousPageIndex ?? 0, e.pageIndex]), startWith([
|
|
72
|
+
this.getActivePageIndex(),
|
|
73
|
+
this.getActivePageIndex(),
|
|
74
|
+
]), takeUntilDestroyed(this.destroyRef))
|
|
75
|
+
.subscribe(([prev, curr]) => {
|
|
76
|
+
this.updateButtonsOnPageEvent(prev, curr);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
changeActiveButtonStyles(previousIndex, newIndex) {
|
|
80
|
+
if (!this.buttonsRef.length) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const previouslyActive = this.buttonsRef[previousIndex];
|
|
84
|
+
const currentActive = this.buttonsRef[newIndex];
|
|
85
|
+
try {
|
|
86
|
+
this.ren.removeClass(previouslyActive, 'g-bubble__active');
|
|
87
|
+
this.ren.addClass(currentActive, 'g-bubble__active');
|
|
88
|
+
}
|
|
89
|
+
catch { }
|
|
90
|
+
this.buttonsRef.forEach((button) => this.ren.setStyle(button, 'display', 'none'));
|
|
91
|
+
const renderElements = this.renderButtonsNumber;
|
|
92
|
+
const endDots = newIndex < this.buttonsRef.length - renderElements - 1;
|
|
93
|
+
const startDots = newIndex - renderElements > 0;
|
|
94
|
+
const firstButton = this.buttonsRef[0];
|
|
95
|
+
const lastButton = this.buttonsRef[this.buttonsRef.length - 1];
|
|
96
|
+
try {
|
|
97
|
+
if (this.showLastButton) {
|
|
98
|
+
this.ren.setStyle(this.dotsEndRef, 'display', endDots ? 'block' : 'none');
|
|
99
|
+
this.ren.setStyle(lastButton, 'display', endDots ? 'flex' : 'none');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch { }
|
|
103
|
+
try {
|
|
104
|
+
if (this.showFirstButton) {
|
|
105
|
+
this.ren.setStyle(this.dotsStartRef, 'display', startDots ? 'block' : 'none');
|
|
106
|
+
this.ren.setStyle(firstButton, 'display', startDots ? 'flex' : 'none');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch { }
|
|
110
|
+
const startingIndex = startDots ? newIndex - renderElements : 0;
|
|
111
|
+
const endingIndex = endDots
|
|
112
|
+
? newIndex + renderElements
|
|
113
|
+
: this.buttonsRef.length - 1;
|
|
114
|
+
for (let i = startingIndex; i <= endingIndex; i++) {
|
|
115
|
+
const button = this.buttonsRef[i];
|
|
116
|
+
this.ren.setStyle(button, 'display', 'flex');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
styleDefaultPagination() {
|
|
120
|
+
const nativeElement = this.elementRef.nativeElement;
|
|
121
|
+
const previousButton = nativeElement.querySelector('.mat-mdc-paginator-navigation-previous');
|
|
122
|
+
const nextButtonDefault = nativeElement.querySelector('.mat-mdc-paginator-navigation-next');
|
|
123
|
+
if (this.hideDefaultArrows) {
|
|
124
|
+
this.ren.setStyle(previousButton, 'display', 'none');
|
|
125
|
+
this.ren.setStyle(nextButtonDefault, 'display', 'none');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
createBubbleDivRef() {
|
|
129
|
+
const actionContainer = this.elementRef.nativeElement.querySelector('div.mat-mdc-paginator-range-actions');
|
|
130
|
+
const nextButtonDefault = this.elementRef.nativeElement.querySelector('button.mat-mdc-paginator-navigation-next');
|
|
131
|
+
const pageRange = this.elementRef.nativeElement.querySelector('div.mat-mdc-paginator-range-label');
|
|
132
|
+
this.bubbleContainerRef = this.ren.createElement('div');
|
|
133
|
+
this.ren.addClass(this.bubbleContainerRef, 'g-bubble-container');
|
|
134
|
+
if (actionContainer) {
|
|
135
|
+
this.ren.addClass(actionContainer, 'custom-paginator-container');
|
|
136
|
+
}
|
|
137
|
+
if (pageRange) {
|
|
138
|
+
this.ren.addClass(pageRange, 'custom-paginator-counter');
|
|
139
|
+
}
|
|
140
|
+
if (actionContainer) {
|
|
141
|
+
this.ren.insertBefore(actionContainer, this.bubbleContainerRef, nextButtonDefault);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
buildButtons(neededButtons) {
|
|
145
|
+
if (neededButtons <= 1) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.buttonsRef = [this.createButton(0)];
|
|
149
|
+
this.dotsStartRef = this.createDotsElement();
|
|
150
|
+
for (let index = 1; index < neededButtons - 1; index++) {
|
|
151
|
+
this.buttonsRef = [...this.buttonsRef, this.createButton(index)];
|
|
152
|
+
}
|
|
153
|
+
this.dotsEndRef = this.createDotsElement();
|
|
154
|
+
this.buttonsRef = [
|
|
155
|
+
...this.buttonsRef,
|
|
156
|
+
this.createButton(neededButtons - 1),
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
removeButtons() {
|
|
160
|
+
if (!this.bubbleContainerRef) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.clearButtonListeners();
|
|
164
|
+
while (this.bubbleContainerRef.firstChild) {
|
|
165
|
+
this.ren.removeChild(this.bubbleContainerRef, this.bubbleContainerRef.firstChild);
|
|
166
|
+
}
|
|
167
|
+
this.buttonsRef = [];
|
|
168
|
+
}
|
|
169
|
+
createButton(i) {
|
|
170
|
+
const bubbleButton = this.ren.createElement('button');
|
|
171
|
+
const text = this.ren.createText(String(i + 1));
|
|
172
|
+
this.ren.addClass(bubbleButton, 'g-bubble');
|
|
173
|
+
this.ren.setAttribute(bubbleButton, 'type', 'button');
|
|
174
|
+
this.ren.setStyle(bubbleButton, 'margin-right', '8px');
|
|
175
|
+
this.ren.appendChild(bubbleButton, text);
|
|
176
|
+
const removeClickListener = this.ren.listen(bubbleButton, 'click', () => {
|
|
177
|
+
this.switchPage(i);
|
|
178
|
+
});
|
|
179
|
+
this.removeButtonListeners.push(removeClickListener);
|
|
180
|
+
this.ren.appendChild(this.bubbleContainerRef, bubbleButton);
|
|
181
|
+
this.ren.setStyle(bubbleButton, 'display', 'none');
|
|
182
|
+
return bubbleButton;
|
|
183
|
+
}
|
|
184
|
+
createDotsElement() {
|
|
185
|
+
const dotsEl = this.ren.createElement('span');
|
|
186
|
+
const dotsText = this.ren.createText('...');
|
|
187
|
+
this.ren.setStyle(dotsEl, 'font-size', '18px');
|
|
188
|
+
this.ren.setStyle(dotsEl, 'margin-right', '8px');
|
|
189
|
+
this.ren.setStyle(dotsEl, 'padding-top', '6px');
|
|
190
|
+
this.ren.setStyle(dotsEl, 'color', '#919191');
|
|
191
|
+
this.ren.appendChild(dotsEl, dotsText);
|
|
192
|
+
this.ren.appendChild(this.bubbleContainerRef, dotsEl);
|
|
193
|
+
this.ren.setStyle(dotsEl, 'display', 'none');
|
|
194
|
+
return dotsEl;
|
|
195
|
+
}
|
|
196
|
+
switchPage(i) {
|
|
197
|
+
const previousPageIndex = this.matPag.pageIndex;
|
|
198
|
+
this.matPag.pageIndex = i;
|
|
199
|
+
this.matPag.page.emit({
|
|
200
|
+
previousPageIndex,
|
|
201
|
+
pageIndex: i,
|
|
202
|
+
pageSize: this.matPag.pageSize,
|
|
203
|
+
length: this.matPag.length,
|
|
204
|
+
});
|
|
205
|
+
this.pageIndexChangeEmitter.emit(i);
|
|
206
|
+
}
|
|
207
|
+
updateButtonsOnPageEvent(previousIndex, newIndex) {
|
|
208
|
+
const neededButtons = this.getNeededButtons();
|
|
209
|
+
if (neededButtons === this.buttonsRef.length) {
|
|
210
|
+
this.changeActiveButtonStyles(previousIndex, newIndex);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
this.rebuildButtons();
|
|
214
|
+
}
|
|
215
|
+
scheduleRebuildButtons() {
|
|
216
|
+
if (this.rebuildQueued) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.rebuildQueued = true;
|
|
220
|
+
Promise.resolve().then(() => {
|
|
221
|
+
this.rebuildQueued = false;
|
|
222
|
+
if (this.bubbleContainerRef) {
|
|
223
|
+
this.rebuildButtons();
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
rebuildButtons() {
|
|
228
|
+
const neededButtons = this.getNeededButtons();
|
|
229
|
+
const activePageIndex = Math.min(this.getActivePageIndex(), Math.max(neededButtons - 1, 0));
|
|
230
|
+
this.removeButtons();
|
|
231
|
+
this.matPag.pageIndex = activePageIndex;
|
|
232
|
+
if (neededButtons <= 1) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this.buildButtons(neededButtons);
|
|
236
|
+
this.changeActiveButtonStyles(activePageIndex, activePageIndex);
|
|
237
|
+
}
|
|
238
|
+
getNeededButtons() {
|
|
239
|
+
const pageSize = this.getPageSize();
|
|
240
|
+
const length = this.getLength();
|
|
241
|
+
if (!Number.isFinite(pageSize) || pageSize <= 0) {
|
|
242
|
+
return 0;
|
|
243
|
+
}
|
|
244
|
+
return Math.ceil(length / pageSize);
|
|
245
|
+
}
|
|
246
|
+
getActivePageIndex() {
|
|
247
|
+
return Math.max(this.bubblePageIndex ?? this.matPag.pageIndex ?? 0, 0);
|
|
248
|
+
}
|
|
249
|
+
getPageSize() {
|
|
250
|
+
return this.bubblePageSize || this.matPag.pageSize;
|
|
251
|
+
}
|
|
252
|
+
getLength() {
|
|
253
|
+
return this.appCustomLength ?? this.matPag.length ?? 0;
|
|
254
|
+
}
|
|
255
|
+
clearButtonListeners() {
|
|
256
|
+
this.removeButtonListeners.forEach((removeListener) => removeListener());
|
|
257
|
+
this.removeButtonListeners = [];
|
|
258
|
+
}
|
|
259
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: BubblePaginationDirective, deps: [{ token: i1.MatPaginator }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
260
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.21", type: BubblePaginationDirective, isStandalone: true, selector: "[appBubblePagination], [appStylePaginatorMv]", inputs: { showFirstButton: "showFirstButton", showLastButton: "showLastButton", renderButtonsNumber: "renderButtonsNumber", appCustomLength: "appCustomLength", hideDefaultArrows: "hideDefaultArrows", bubblePageIndex: "bubblePageIndex", bubblePageSize: "bubblePageSize" }, outputs: { pageIndexChangeEmitter: "pageIndexChangeEmitter" }, usesOnChanges: true, ngImport: i0 }); }
|
|
261
|
+
}
|
|
262
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: BubblePaginationDirective, decorators: [{
|
|
263
|
+
type: Directive,
|
|
264
|
+
args: [{
|
|
265
|
+
selector: '[appBubblePagination], [appStylePaginatorMv]',
|
|
266
|
+
standalone: true,
|
|
267
|
+
}]
|
|
268
|
+
}], ctorParameters: () => [{ type: i1.MatPaginator }, { type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { pageIndexChangeEmitter: [{
|
|
269
|
+
type: Output
|
|
270
|
+
}], showFirstButton: [{
|
|
271
|
+
type: Input
|
|
272
|
+
}], showLastButton: [{
|
|
273
|
+
type: Input
|
|
274
|
+
}], renderButtonsNumber: [{
|
|
275
|
+
type: Input
|
|
276
|
+
}], appCustomLength: [{
|
|
277
|
+
type: Input
|
|
278
|
+
}], hideDefaultArrows: [{
|
|
279
|
+
type: Input
|
|
280
|
+
}], bubblePageIndex: [{
|
|
281
|
+
type: Input
|
|
282
|
+
}], bubblePageSize: [{
|
|
283
|
+
type: Input
|
|
284
|
+
}] } });
|
|
285
|
+
|
|
286
|
+
function sanitizeHtmlContent(sanitizer, value) {
|
|
287
|
+
return sanitizer.sanitize(SecurityContext.HTML, value ?? "") ?? "";
|
|
288
|
+
}
|
|
289
|
+
class HtmlSanitizerService {
|
|
290
|
+
constructor(sanitizer) {
|
|
291
|
+
this.sanitizer = sanitizer;
|
|
292
|
+
}
|
|
293
|
+
sanitize(value) {
|
|
294
|
+
return sanitizeHtmlContent(this.sanitizer, value);
|
|
295
|
+
}
|
|
296
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: HtmlSanitizerService, deps: [{ token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
297
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: HtmlSanitizerService, providedIn: "root" }); }
|
|
298
|
+
}
|
|
299
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: HtmlSanitizerService, decorators: [{
|
|
300
|
+
type: Injectable,
|
|
301
|
+
args: [{
|
|
302
|
+
providedIn: "root",
|
|
303
|
+
}]
|
|
304
|
+
}], ctorParameters: () => [{ type: i1$1.DomSanitizer }] });
|
|
305
|
+
|
|
306
|
+
class SafeHtmlPipe {
|
|
307
|
+
constructor(htmlSanitizer) {
|
|
308
|
+
this.htmlSanitizer = htmlSanitizer;
|
|
309
|
+
}
|
|
310
|
+
transform(value) {
|
|
311
|
+
return this.htmlSanitizer.sanitize(value);
|
|
312
|
+
}
|
|
313
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: SafeHtmlPipe, deps: [{ token: HtmlSanitizerService }], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
314
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.21", ngImport: i0, type: SafeHtmlPipe, isStandalone: true, name: "safeHtml" }); }
|
|
315
|
+
}
|
|
316
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: SafeHtmlPipe, decorators: [{
|
|
317
|
+
type: Pipe,
|
|
318
|
+
args: [{
|
|
319
|
+
name: "safeHtml",
|
|
320
|
+
standalone: true,
|
|
321
|
+
}]
|
|
322
|
+
}], ctorParameters: () => [{ type: HtmlSanitizerService }] });
|
|
323
|
+
|
|
324
|
+
const MAPA_UI_TEXTS = new InjectionToken('MAPA_UI_TEXTS');
|
|
325
|
+
function formatPaginatorRange(page, pageSize, length) {
|
|
326
|
+
if (length === 0 || pageSize === 0) {
|
|
327
|
+
return `0 de ${length}`;
|
|
328
|
+
}
|
|
329
|
+
const safeLength = Math.max(length, 0);
|
|
330
|
+
const startIndex = page * pageSize;
|
|
331
|
+
const endIndex = startIndex < safeLength
|
|
332
|
+
? Math.min(startIndex + pageSize, safeLength)
|
|
333
|
+
: startIndex + pageSize;
|
|
334
|
+
return `${startIndex + 1} - ${endIndex} de ${safeLength}`;
|
|
335
|
+
}
|
|
336
|
+
function formatPaginatorShowingRange(page, pageSize, length) {
|
|
337
|
+
if (length === 0 || pageSize === 0) {
|
|
338
|
+
return 'Mostrando 0 - 0 de 0 item';
|
|
339
|
+
}
|
|
340
|
+
const safeLength = Math.max(length, 0);
|
|
341
|
+
const startIndex = page * pageSize;
|
|
342
|
+
const endIndex = startIndex < safeLength
|
|
343
|
+
? Math.min(startIndex + pageSize, safeLength)
|
|
344
|
+
: startIndex + pageSize;
|
|
345
|
+
const itemLabel = safeLength === 1 ? 'item' : 'itens';
|
|
346
|
+
return `Mostrando ${startIndex + 1} - ${endIndex} de ${safeLength} ${itemLabel}`;
|
|
347
|
+
}
|
|
348
|
+
const DEFAULT_MAPA_UI_TEXTS = {
|
|
349
|
+
common: {
|
|
350
|
+
selectAll: 'Selecionar todos',
|
|
351
|
+
retry: 'Tentar novamente',
|
|
352
|
+
},
|
|
353
|
+
filters: {
|
|
354
|
+
clear: 'Limpar filtros',
|
|
355
|
+
submit: 'Filtrar',
|
|
356
|
+
},
|
|
357
|
+
datepicker: {
|
|
358
|
+
startDatePlaceholder: 'Data inicial',
|
|
359
|
+
endDatePlaceholder: 'Data final',
|
|
360
|
+
},
|
|
361
|
+
capability: {
|
|
362
|
+
groupAverageTitle: 'Média geral do grupo',
|
|
363
|
+
individualAverageTitle: 'Média geral do indivíduo',
|
|
364
|
+
conceptTitle: 'Conceito',
|
|
365
|
+
resultTitle: 'Resultado',
|
|
366
|
+
positiveIndicatorsTitle: 'Indicadores positivos',
|
|
367
|
+
negativeIndicatorsTitle: 'Indicadores negativos',
|
|
368
|
+
riskIndicatorsTitle: 'Indicadores de risco',
|
|
369
|
+
precipitationRiskTitle: 'Risco de acidente por precipitação',
|
|
370
|
+
negligenceRiskTitle: 'Risco de acidente por negligência',
|
|
371
|
+
negativeDirectionLabel: 'Direção Negativa |',
|
|
372
|
+
positiveDirectionLabel: 'Direção Positiva |',
|
|
373
|
+
},
|
|
374
|
+
paginator: {
|
|
375
|
+
itemsPerPage: 'Itens por página',
|
|
376
|
+
nextPage: 'Próxima página',
|
|
377
|
+
previousPage: 'Página anterior',
|
|
378
|
+
rangeLabel: formatPaginatorRange,
|
|
379
|
+
showingRangeLabel: formatPaginatorShowingRange,
|
|
380
|
+
},
|
|
381
|
+
warning: {
|
|
382
|
+
lowReliabilityTitle: 'Nível baixo de confiabilidade no(s) teste(s):',
|
|
383
|
+
expirationLimitTitle: 'O prazo de validade do(s) teste(s) está no limite:',
|
|
384
|
+
},
|
|
385
|
+
table: {
|
|
386
|
+
emptyTitle: 'Não foram encontrados resultados',
|
|
387
|
+
emptySubtitle: '',
|
|
388
|
+
loading: 'Carregando resultados',
|
|
389
|
+
errorTitle: 'Não foi possível carregar os resultados.',
|
|
390
|
+
selectAllVisible: 'Selecionar todos os itens desta página',
|
|
391
|
+
selectionColumn: 'Seleção',
|
|
392
|
+
selectRow: 'Selecionar item',
|
|
393
|
+
selectNamedRow: (item) => `Selecionar ${item}`,
|
|
394
|
+
},
|
|
395
|
+
validation: {
|
|
396
|
+
cnpj: 'CNPJ inválido',
|
|
397
|
+
cpf: 'CPF inválido',
|
|
398
|
+
email: 'E-mail inválido',
|
|
399
|
+
max: (context) => `O valor máximo permitido é ${context?.max ?? ''}`.trim(),
|
|
400
|
+
maxLength: (context) => `O máximo permitido é ${context?.requiredLength ?? ''} caracteres`.trim(),
|
|
401
|
+
min: (context) => `O valor mínimo permitido é ${context?.min ?? ''}`.trim(),
|
|
402
|
+
minLength: (context) => `O mínimo permitido é ${context?.requiredLength ?? ''} caracteres`.trim(),
|
|
403
|
+
pattern: 'Formato inválido',
|
|
404
|
+
required: 'Campo obrigatório',
|
|
405
|
+
},
|
|
406
|
+
};
|
|
407
|
+
function getDefaultTexts() {
|
|
408
|
+
return DEFAULT_MAPA_UI_TEXTS;
|
|
409
|
+
}
|
|
410
|
+
function mergeMapaUiTexts(customTexts) {
|
|
411
|
+
const defaults = getDefaultTexts();
|
|
412
|
+
return {
|
|
413
|
+
common: { ...defaults.common, ...(customTexts?.common ?? {}) },
|
|
414
|
+
filters: { ...defaults.filters, ...(customTexts?.filters ?? {}) },
|
|
415
|
+
datepicker: { ...defaults.datepicker, ...(customTexts?.datepicker ?? {}) },
|
|
416
|
+
capability: { ...defaults.capability, ...(customTexts?.capability ?? {}) },
|
|
417
|
+
paginator: { ...defaults.paginator, ...(customTexts?.paginator ?? {}) },
|
|
418
|
+
warning: { ...defaults.warning, ...(customTexts?.warning ?? {}) },
|
|
419
|
+
table: { ...defaults.table, ...(customTexts?.table ?? {}) },
|
|
420
|
+
validation: { ...defaults.validation, ...(customTexts?.validation ?? {}) },
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
function provideMapaUiTexts(texts) {
|
|
424
|
+
return {
|
|
425
|
+
provide: MAPA_UI_TEXTS,
|
|
426
|
+
useValue: texts,
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
class MapaI18nService {
|
|
431
|
+
constructor(customTexts) {
|
|
432
|
+
this.injector = inject(Injector);
|
|
433
|
+
this.textsState = signal(mergeMapaUiTexts(), ...(ngDevMode ? [{ debugName: "textsState" }] : []));
|
|
434
|
+
this.textsSignal = this.textsState.asReadonly();
|
|
435
|
+
this.texts$ = toObservable(this.textsSignal, { injector: this.injector });
|
|
436
|
+
if (customTexts) {
|
|
437
|
+
this.textsState.set(mergeMapaUiTexts(customTexts));
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
get texts() {
|
|
441
|
+
return this.textsState();
|
|
442
|
+
}
|
|
443
|
+
setTexts(texts) {
|
|
444
|
+
this.textsState.set(mergeMapaUiTexts(texts));
|
|
445
|
+
}
|
|
446
|
+
resolveValidationText(key, context) {
|
|
447
|
+
return this.resolveText(this.texts.validation[key], context);
|
|
448
|
+
}
|
|
449
|
+
resolveText(value, context) {
|
|
450
|
+
return typeof value === "function" ? value(context) : value;
|
|
451
|
+
}
|
|
452
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaI18nService, deps: [{ token: MAPA_UI_TEXTS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
453
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaI18nService, providedIn: "root" }); }
|
|
454
|
+
}
|
|
455
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaI18nService, decorators: [{
|
|
456
|
+
type: Injectable,
|
|
457
|
+
args: [{
|
|
458
|
+
providedIn: "root",
|
|
459
|
+
}]
|
|
460
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
461
|
+
type: Optional
|
|
462
|
+
}, {
|
|
463
|
+
type: Inject,
|
|
464
|
+
args: [MAPA_UI_TEXTS]
|
|
465
|
+
}] }] });
|
|
466
|
+
|
|
467
|
+
const DAY_MONTH_YEAR_PATTERN = /^(\d{2})\/(\d{2})\/(\d{4})$/;
|
|
468
|
+
const MONTH_DAY_YEAR_PATTERN = /^(\d{2})\/(\d{2})\/(\d{4})$/;
|
|
469
|
+
const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}([T ].*)?$/;
|
|
470
|
+
const DOCS_LANGUAGE_STORAGE_KEY = "mapa-library-ui-docs-language";
|
|
471
|
+
function isValidDate(date) {
|
|
472
|
+
return !Number.isNaN(date.getTime());
|
|
473
|
+
}
|
|
474
|
+
function buildUtcDate(date, dayOffset, hours, minutes, seconds, milliseconds) {
|
|
475
|
+
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate() + dayOffset, hours, minutes, seconds, milliseconds));
|
|
476
|
+
}
|
|
477
|
+
function formatDateAsDayMonthYear(date) {
|
|
478
|
+
const day = `${date.getDate()}`.padStart(2, "0");
|
|
479
|
+
const month = `${date.getMonth() + 1}`.padStart(2, "0");
|
|
480
|
+
const year = `${date.getFullYear()}`;
|
|
481
|
+
return `${day}/${month}/${year}`;
|
|
482
|
+
}
|
|
483
|
+
function formatDateAsMonthDayYear(date) {
|
|
484
|
+
const day = `${date.getDate()}`.padStart(2, "0");
|
|
485
|
+
const month = `${date.getMonth() + 1}`.padStart(2, "0");
|
|
486
|
+
const year = `${date.getFullYear()}`;
|
|
487
|
+
return `${month}/${day}/${year}`;
|
|
488
|
+
}
|
|
489
|
+
function normalizeDateLocale(value) {
|
|
490
|
+
if (typeof value !== "string") {
|
|
491
|
+
return "pt-BR";
|
|
492
|
+
}
|
|
493
|
+
const normalizedValue = value.trim().toLowerCase();
|
|
494
|
+
if (normalizedValue.startsWith("en")) {
|
|
495
|
+
return "en";
|
|
496
|
+
}
|
|
497
|
+
if (normalizedValue.startsWith("es")) {
|
|
498
|
+
return "es";
|
|
499
|
+
}
|
|
500
|
+
return "pt-BR";
|
|
501
|
+
}
|
|
502
|
+
function getDocsStoredLanguage() {
|
|
503
|
+
if (typeof window === "undefined") {
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
try {
|
|
507
|
+
return window.localStorage.getItem(DOCS_LANGUAGE_STORAGE_KEY);
|
|
508
|
+
}
|
|
509
|
+
catch {
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function getActiveDateLocale() {
|
|
514
|
+
return normalizeDateLocale(getDocsStoredLanguage() ?? getStoredAppLanguage());
|
|
515
|
+
}
|
|
516
|
+
function isMonthFirstDateLocale(locale = getActiveDateLocale()) {
|
|
517
|
+
return normalizeDateLocale(locale) === "en";
|
|
518
|
+
}
|
|
519
|
+
function getActiveDateFormat(locale = getActiveDateLocale()) {
|
|
520
|
+
return isMonthFirstDateLocale(locale) ? "MM/DD/YYYY" : "DD/MM/YYYY";
|
|
521
|
+
}
|
|
522
|
+
function getDateInputMask(_locale = getActiveDateLocale()) {
|
|
523
|
+
return "00/00/0000";
|
|
524
|
+
}
|
|
525
|
+
function formatDateForLocale(date, locale = getActiveDateLocale()) {
|
|
526
|
+
return isMonthFirstDateLocale(locale)
|
|
527
|
+
? formatDateAsMonthDayYear(date)
|
|
528
|
+
: formatDateAsDayMonthYear(date);
|
|
529
|
+
}
|
|
530
|
+
function parseOrderedDate(value, pattern, order) {
|
|
531
|
+
const match = pattern.exec(value.trim());
|
|
532
|
+
if (!match) {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
const [, firstValue, secondValue, yearValue] = match;
|
|
536
|
+
const year = Number(yearValue);
|
|
537
|
+
const month = Number(order === "month-first" ? firstValue : secondValue);
|
|
538
|
+
const day = Number(order === "month-first" ? secondValue : firstValue);
|
|
539
|
+
const parsedDate = new Date(year, month - 1, day);
|
|
540
|
+
if (parsedDate.getFullYear() !== year ||
|
|
541
|
+
parsedDate.getMonth() !== month - 1 ||
|
|
542
|
+
parsedDate.getDate() !== day) {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
return parsedDate;
|
|
546
|
+
}
|
|
547
|
+
function parseLocaleDateValue(value, locale = getActiveDateLocale()) {
|
|
548
|
+
const normalizedLocale = normalizeDateLocale(locale);
|
|
549
|
+
const parsers = normalizedLocale === "en"
|
|
550
|
+
? [
|
|
551
|
+
() => parseOrderedDate(value, MONTH_DAY_YEAR_PATTERN, "month-first"),
|
|
552
|
+
() => parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, "day-first"),
|
|
553
|
+
]
|
|
554
|
+
: [
|
|
555
|
+
() => parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, "day-first"),
|
|
556
|
+
() => parseOrderedDate(value, MONTH_DAY_YEAR_PATTERN, "month-first"),
|
|
557
|
+
];
|
|
558
|
+
for (const parse of parsers) {
|
|
559
|
+
const parsedDate = parse();
|
|
560
|
+
if (parsedDate) {
|
|
561
|
+
return parsedDate;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
function parseDateValue(value, locale = getActiveDateLocale()) {
|
|
567
|
+
if (value instanceof Date) {
|
|
568
|
+
return isValidDate(value) ? new Date(value.getTime()) : null;
|
|
569
|
+
}
|
|
570
|
+
if (typeof value === "number") {
|
|
571
|
+
const parsedDate = new Date(value);
|
|
572
|
+
return isValidDate(parsedDate) ? parsedDate : null;
|
|
573
|
+
}
|
|
574
|
+
if (typeof value !== "string") {
|
|
575
|
+
return null;
|
|
576
|
+
}
|
|
577
|
+
const trimmedValue = value.trim();
|
|
578
|
+
if (!trimmedValue) {
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
const localeDate = parseLocaleDateValue(trimmedValue, locale);
|
|
582
|
+
if (localeDate) {
|
|
583
|
+
return localeDate;
|
|
584
|
+
}
|
|
585
|
+
if (DAY_MONTH_YEAR_PATTERN.test(trimmedValue) || MONTH_DAY_YEAR_PATTERN.test(trimmedValue)) {
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
const parsedDate = new Date(trimmedValue);
|
|
589
|
+
return isValidDate(parsedDate) ? parsedDate : null;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Parse estrito para o texto de um campo de data mascarado.
|
|
593
|
+
*
|
|
594
|
+
* Diferente de `parseDateValue`, não cai em `new Date(string)` para qualquer
|
|
595
|
+
* entrada. O motor de datas do V8 aceita fragmentos numéricos e devolve datas
|
|
596
|
+
* inventadas — `"2"` vira 01/02/2001 e `"251220"` vira o ano 251220 —, o que
|
|
597
|
+
* fazia os datepickers moverem o calendário a cada tecla enquanto o usuário
|
|
598
|
+
* ainda estava digitando.
|
|
599
|
+
*
|
|
600
|
+
* Aceita apenas uma data completa no formato do locale ativo (com validação de
|
|
601
|
+
* faixa de dia/mês) ou uma data ISO-8601, para não quebrar valores vindos de
|
|
602
|
+
* API que o consumidor grave direto no controle.
|
|
603
|
+
*/
|
|
604
|
+
function parseDateFieldValue(value, locale = getActiveDateLocale()) {
|
|
605
|
+
if (value instanceof Date || typeof value === "number") {
|
|
606
|
+
return parseDateValue(value, locale);
|
|
607
|
+
}
|
|
608
|
+
if (typeof value !== "string") {
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
const trimmedValue = value.trim();
|
|
612
|
+
if (!trimmedValue) {
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
const localeDate = parseLocaleDateValue(trimmedValue, locale);
|
|
616
|
+
if (localeDate) {
|
|
617
|
+
return localeDate;
|
|
618
|
+
}
|
|
619
|
+
return ISO_DATE_PATTERN.test(trimmedValue)
|
|
620
|
+
? parseDateValue(trimmedValue, locale)
|
|
621
|
+
: null;
|
|
622
|
+
}
|
|
623
|
+
function isDateValue(value) {
|
|
624
|
+
return parseDateValue(value) !== null;
|
|
625
|
+
}
|
|
626
|
+
function parseBrazilianDate(value) {
|
|
627
|
+
return parseOrderedDate(value, DAY_MONTH_YEAR_PATTERN, "day-first");
|
|
628
|
+
}
|
|
629
|
+
function normalizeDateInput(value) {
|
|
630
|
+
return parseDateValue(value);
|
|
631
|
+
}
|
|
632
|
+
function formatBrazilianDate(value) {
|
|
633
|
+
const date = normalizeDateInput(value);
|
|
634
|
+
return date ? formatDateAsDayMonthYear(date) : "";
|
|
635
|
+
}
|
|
636
|
+
function addDays(date, days) {
|
|
637
|
+
const nextDate = new Date(date);
|
|
638
|
+
nextDate.setDate(nextDate.getDate() + days);
|
|
639
|
+
return nextDate;
|
|
640
|
+
}
|
|
641
|
+
function formatLocaleDate(value, dateStyle = "short") {
|
|
642
|
+
const date = normalizeDateInput(value);
|
|
643
|
+
if (!date) {
|
|
644
|
+
return "";
|
|
645
|
+
}
|
|
646
|
+
return new Intl.DateTimeFormat(getIntlLocale(getActiveDateLocale()), {
|
|
647
|
+
dateStyle,
|
|
648
|
+
}).format(date);
|
|
649
|
+
}
|
|
650
|
+
function formatLocaleDateTime(value, options = {}) {
|
|
651
|
+
const date = normalizeDateInput(value);
|
|
652
|
+
if (!date) {
|
|
653
|
+
return "";
|
|
654
|
+
}
|
|
655
|
+
const { dateStyle = "short", timeStyle = "short" } = options;
|
|
656
|
+
return new Intl.DateTimeFormat(getIntlLocale(getActiveDateLocale()), {
|
|
657
|
+
dateStyle,
|
|
658
|
+
timeStyle,
|
|
659
|
+
}).format(date);
|
|
660
|
+
}
|
|
661
|
+
function getDefaultDateRange(days = 60) {
|
|
662
|
+
const today = new Date();
|
|
663
|
+
return {
|
|
664
|
+
startDate: formatBrazilianDate(addDays(today, -days)),
|
|
665
|
+
endDate: formatBrazilianDate(today),
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
function getRelativeDateRange(daysBack) {
|
|
669
|
+
const endDate = new Date();
|
|
670
|
+
endDate.setHours(23, 59, 59, 999);
|
|
671
|
+
const startDate = new Date();
|
|
672
|
+
startDate.setHours(0, 0, 0, 0);
|
|
673
|
+
startDate.setDate(startDate.getDate() - daysBack);
|
|
674
|
+
return { startDate, endDate };
|
|
675
|
+
}
|
|
676
|
+
function toUtcRangeStartIso(value) {
|
|
677
|
+
const date = normalizeDateInput(value);
|
|
678
|
+
return date ? buildUtcDate(date, 0, 3, 0, 0, 0).toISOString() : undefined;
|
|
679
|
+
}
|
|
680
|
+
function toUtcRangeEndIso(value) {
|
|
681
|
+
const date = normalizeDateInput(value);
|
|
682
|
+
return date ? buildUtcDate(date, 1, 2, 59, 59, 999).toISOString() : undefined;
|
|
683
|
+
}
|
|
684
|
+
function toUtcDayExclusiveEndIso(value) {
|
|
685
|
+
const date = normalizeDateInput(value);
|
|
686
|
+
return date ? buildUtcDate(date, 1, 3, 0, 0, 0).toISOString() : undefined;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
class MapaSvgIconComponent {
|
|
690
|
+
constructor(httpClient, cdr) {
|
|
691
|
+
this.httpClient = httpClient;
|
|
692
|
+
this.cdr = cdr;
|
|
693
|
+
this.svgIcon = "";
|
|
694
|
+
this.destroyRef = inject(DestroyRef);
|
|
695
|
+
}
|
|
696
|
+
ngOnChanges() {
|
|
697
|
+
if (!this.name) {
|
|
698
|
+
this.svgIcon = "";
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
if (this.color) {
|
|
702
|
+
this.httpClient
|
|
703
|
+
.get(`images/icons/${this.name}.svg`, { responseType: 'text' })
|
|
704
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
705
|
+
.subscribe((value) => {
|
|
706
|
+
this.svgIcon = this.applyColor(value);
|
|
707
|
+
this.cdr.markForCheck();
|
|
708
|
+
});
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
this.svgIcon = `<img src="images/icons/${this.name}.svg" alt="${this.name}" />`;
|
|
712
|
+
this.cdr.markForCheck();
|
|
713
|
+
}
|
|
714
|
+
applyColor(value) {
|
|
715
|
+
if (!this.color) {
|
|
716
|
+
return value;
|
|
717
|
+
}
|
|
718
|
+
return value
|
|
719
|
+
.replaceAll('fill="#50575E"', `fill="${this.color}"`)
|
|
720
|
+
.replaceAll('fill="#181818"', `fill="${this.color}"`)
|
|
721
|
+
.replaceAll('fill="#7def7b"', `fill="${this.color}"`)
|
|
722
|
+
.replaceAll('stroke="#50575E"', `stroke="${this.color}"`)
|
|
723
|
+
.replaceAll('stroke="#181818"', `stroke="${this.color}"`)
|
|
724
|
+
.replaceAll('stroke="#7def7b"', `stroke="${this.color}"`);
|
|
725
|
+
}
|
|
726
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaSvgIconComponent, deps: [{ token: i1$2.HttpClient }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
727
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.21", type: MapaSvgIconComponent, isStandalone: true, selector: "mapa-svg-icon", inputs: { name: "name", color: "color" }, usesOnChanges: true, ngImport: i0, template: "<span *ngIf=\"svgIcon\" class=\"mapa__svg-icon\" [innerHTML]=\"svgIcon | safeHtml\"></span>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: SafeHtmlPipe, name: "safeHtml" }] }); }
|
|
728
|
+
}
|
|
729
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaSvgIconComponent, decorators: [{
|
|
730
|
+
type: Component,
|
|
731
|
+
args: [{ selector: "mapa-svg-icon", standalone: true, imports: [CommonModule, SafeHtmlPipe], template: "<span *ngIf=\"svgIcon\" class=\"mapa__svg-icon\" [innerHTML]=\"svgIcon | safeHtml\"></span>\n" }]
|
|
732
|
+
}], ctorParameters: () => [{ type: i1$2.HttpClient }, { type: i0.ChangeDetectorRef }], propDecorators: { name: [{
|
|
733
|
+
type: Input
|
|
734
|
+
}], color: [{
|
|
735
|
+
type: Input
|
|
736
|
+
}] } });
|
|
737
|
+
|
|
738
|
+
/*
|
|
739
|
+
* Public API Surface of mapa-library-ui svg-icon
|
|
740
|
+
*/
|
|
741
|
+
|
|
742
|
+
class MapaTableCellDirective {
|
|
743
|
+
constructor() {
|
|
744
|
+
this.templateRef = inject(TemplateRef);
|
|
745
|
+
}
|
|
746
|
+
static ngTemplateContextGuard(_directive, context) {
|
|
747
|
+
return true;
|
|
748
|
+
}
|
|
749
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaTableCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
750
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.21", type: MapaTableCellDirective, isStandalone: true, selector: "ng-template[mapaTableCell]", inputs: { columnKey: ["mapaTableCell", "columnKey"] }, ngImport: i0 }); }
|
|
751
|
+
}
|
|
752
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaTableCellDirective, decorators: [{
|
|
753
|
+
type: Directive,
|
|
754
|
+
args: [{
|
|
755
|
+
selector: 'ng-template[mapaTableCell]',
|
|
756
|
+
standalone: true,
|
|
757
|
+
}]
|
|
758
|
+
}], propDecorators: { columnKey: [{
|
|
759
|
+
type: Input,
|
|
760
|
+
args: [{ required: true, alias: 'mapaTableCell' }]
|
|
761
|
+
}] } });
|
|
762
|
+
class MapaTableComponent {
|
|
763
|
+
constructor() {
|
|
764
|
+
this.columns = [];
|
|
765
|
+
this.data = [];
|
|
766
|
+
this.rowKey = 'id';
|
|
767
|
+
this.caption = '';
|
|
768
|
+
this.showSelectAll = true;
|
|
769
|
+
this.selectionLabelKey = 'name';
|
|
770
|
+
this.error = false;
|
|
771
|
+
/** @deprecated Prefer the individual state inputs. */
|
|
772
|
+
this.status = { loading: false, finished: false };
|
|
773
|
+
/** @deprecated Prefer `emptyTitle` and `emptySubtitle`. */
|
|
774
|
+
this.empty = { title: '', subtitle: null };
|
|
775
|
+
this.pageIndex = 1;
|
|
776
|
+
this.pageSize = 5;
|
|
777
|
+
this.totalCount = 0;
|
|
778
|
+
this.pageSizeOptions = [5, 10, 25, 100];
|
|
779
|
+
/** @deprecated The paginator derives its pages from `totalCount` and `pageSize`. */
|
|
780
|
+
this.totalPages = 0;
|
|
781
|
+
/** @deprecated Prefer `pagination`. */
|
|
782
|
+
this.showPaginator = true;
|
|
783
|
+
this.paginatorShowFirstButton = true;
|
|
784
|
+
this.paginatorShowLastButton = true;
|
|
785
|
+
this.paginatorRenderButtonsNumber = 2;
|
|
786
|
+
this.paginatorHideDefaultArrows = false;
|
|
787
|
+
this.sortActive = '';
|
|
788
|
+
this.sortDirection = '';
|
|
789
|
+
/** @deprecated Prefer projected cells for new integrations. */
|
|
790
|
+
this.menuItems = [];
|
|
791
|
+
this.pageChange = new EventEmitter();
|
|
792
|
+
this.sortChange = new EventEmitter();
|
|
793
|
+
this.selectionChange = new EventEmitter();
|
|
794
|
+
this.retry = new EventEmitter();
|
|
795
|
+
/** @deprecated Prefer `pageChange`. */
|
|
796
|
+
this.onChangePage = new EventEmitter();
|
|
797
|
+
/** @deprecated Prefer `sortChange`. */
|
|
798
|
+
this.onSortChange = new EventEmitter();
|
|
799
|
+
/** @deprecated Prefer `selectionChange`. */
|
|
800
|
+
this.selectedRows = new EventEmitter();
|
|
801
|
+
this.rowClick = new EventEmitter();
|
|
802
|
+
this.projectedCells = contentChildren(MapaTableCellDirective, ...(ngDevMode ? [{ debugName: "projectedCells" }] : []));
|
|
803
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
804
|
+
this.destroyRef = inject(DestroyRef);
|
|
805
|
+
this.i18n = inject(MapaI18nService);
|
|
806
|
+
this.localSort = { active: '', direction: '' };
|
|
807
|
+
this.filterValue = '';
|
|
808
|
+
}
|
|
809
|
+
get texts() {
|
|
810
|
+
return this.i18n.textsSignal();
|
|
811
|
+
}
|
|
812
|
+
get visibleData() {
|
|
813
|
+
this.observeFilterControl();
|
|
814
|
+
if (!this.filterValue)
|
|
815
|
+
return this.data;
|
|
816
|
+
return this.data.filter((row) => this.getFilterValue(row).includes(this.filterValue));
|
|
817
|
+
}
|
|
818
|
+
get isSelectable() {
|
|
819
|
+
return this.selectable ?? this.checkbox ?? false;
|
|
820
|
+
}
|
|
821
|
+
get isLoading() {
|
|
822
|
+
return this.loading ?? this.status.loading;
|
|
823
|
+
}
|
|
824
|
+
get isFinished() {
|
|
825
|
+
return this.finished ?? this.status.finished;
|
|
826
|
+
}
|
|
827
|
+
get resolvedEmptyTitle() {
|
|
828
|
+
return (this.emptyTitle ?? this.empty.title) || this.texts.table.emptyTitle;
|
|
829
|
+
}
|
|
830
|
+
get resolvedEmptySubtitle() {
|
|
831
|
+
return ((this.emptySubtitle ?? this.empty.subtitle) ||
|
|
832
|
+
this.texts.table.emptySubtitle ||
|
|
833
|
+
null);
|
|
834
|
+
}
|
|
835
|
+
get resolvedErrorTitle() {
|
|
836
|
+
return this.errorTitle || this.texts.table.errorTitle;
|
|
837
|
+
}
|
|
838
|
+
get resolvedErrorSubtitle() {
|
|
839
|
+
return this.errorSubtitle ?? null;
|
|
840
|
+
}
|
|
841
|
+
get resolvedRetryLabel() {
|
|
842
|
+
return this.retryLabel || this.texts.common.retry;
|
|
843
|
+
}
|
|
844
|
+
get zeroBasedPageIndex() {
|
|
845
|
+
return Math.max(this.pageIndex - 1, 0);
|
|
846
|
+
}
|
|
847
|
+
get shouldShowPaginator() {
|
|
848
|
+
const enabled = this.pagination ?? this.showPaginator;
|
|
849
|
+
return (enabled &&
|
|
850
|
+
!this.isLoading &&
|
|
851
|
+
!this.error &&
|
|
852
|
+
this.totalCount > this.data.length);
|
|
853
|
+
}
|
|
854
|
+
get skeletonRows() {
|
|
855
|
+
return Array.from({ length: Math.max(this.pageSize, 0) }, (_, index) => index);
|
|
856
|
+
}
|
|
857
|
+
skeletonColumnWidth(column) {
|
|
858
|
+
return (this.columnWidth(column) ||
|
|
859
|
+
(this.columns.length ? `${100 / this.columns.length}%` : '100%'));
|
|
860
|
+
}
|
|
861
|
+
columnWidth(column) {
|
|
862
|
+
return column.width || (this.isCompactColumn(column) ? '1%' : null);
|
|
863
|
+
}
|
|
864
|
+
rowIdentity(row, index) {
|
|
865
|
+
return this.getRowKey(row) || row || index;
|
|
866
|
+
}
|
|
867
|
+
getRowKey(row) {
|
|
868
|
+
const value = this.getColumnValue(row, this.rowKey);
|
|
869
|
+
return value == null ? '' : String(value);
|
|
870
|
+
}
|
|
871
|
+
isSelected(row) {
|
|
872
|
+
if (this.selectedKeys !== undefined) {
|
|
873
|
+
return new Set(this.selectedKeys.map(String)).has(this.getRowKey(row));
|
|
874
|
+
}
|
|
875
|
+
return this.selection?.isSelected(row) ?? false;
|
|
876
|
+
}
|
|
877
|
+
allVisibleSelected() {
|
|
878
|
+
const rows = this.visibleData;
|
|
879
|
+
return rows.length > 0 && rows.every((row) => this.isSelected(row));
|
|
880
|
+
}
|
|
881
|
+
someVisibleSelected() {
|
|
882
|
+
const selectedCount = this.visibleData.filter((row) => this.isSelected(row)).length;
|
|
883
|
+
return selectedCount > 0 && selectedCount < this.visibleData.length;
|
|
884
|
+
}
|
|
885
|
+
toggleRow(row, selected) {
|
|
886
|
+
if (this.selectedKeys !== undefined) {
|
|
887
|
+
const next = new Set(this.selectedKeys.map(String));
|
|
888
|
+
const key = this.getRowKey(row);
|
|
889
|
+
if (!key)
|
|
890
|
+
return;
|
|
891
|
+
selected ? next.add(key) : next.delete(key);
|
|
892
|
+
this.selectionChange.emit({ selectedKeys: Array.from(next) });
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
if (!this.selection)
|
|
896
|
+
return;
|
|
897
|
+
selected
|
|
898
|
+
? this.selection.select(row)
|
|
899
|
+
: this.selection.deselect(row);
|
|
900
|
+
this.emitLegacySelection();
|
|
901
|
+
}
|
|
902
|
+
toggleVisibleRows(selected) {
|
|
903
|
+
if (this.selectedKeys !== undefined) {
|
|
904
|
+
const next = new Set(this.selectedKeys.map(String));
|
|
905
|
+
for (const row of this.visibleData) {
|
|
906
|
+
const key = this.getRowKey(row);
|
|
907
|
+
if (!key)
|
|
908
|
+
continue;
|
|
909
|
+
selected ? next.add(key) : next.delete(key);
|
|
910
|
+
}
|
|
911
|
+
this.selectionChange.emit({ selectedKeys: Array.from(next) });
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
if (!this.selection)
|
|
915
|
+
return;
|
|
916
|
+
for (const row of this.visibleData) {
|
|
917
|
+
selected
|
|
918
|
+
? this.selection.select(row)
|
|
919
|
+
: this.selection.deselect(row);
|
|
920
|
+
}
|
|
921
|
+
this.emitLegacySelection();
|
|
922
|
+
}
|
|
923
|
+
selectionLabel(row) {
|
|
924
|
+
const value = this.getColumnValue(row, this.selectionLabelKey);
|
|
925
|
+
return value == null
|
|
926
|
+
? this.texts.table.selectRow
|
|
927
|
+
: this.texts.table.selectNamedRow(String(value));
|
|
928
|
+
}
|
|
929
|
+
cellTemplate(columnKey) {
|
|
930
|
+
return (this.projectedCells().find((cell) => cell.columnKey === columnKey)
|
|
931
|
+
?.templateRef ?? null);
|
|
932
|
+
}
|
|
933
|
+
isSortable(column) {
|
|
934
|
+
return column.sortable ?? column.sort ?? false;
|
|
935
|
+
}
|
|
936
|
+
ariaSort(column) {
|
|
937
|
+
if (!this.isSortable(column))
|
|
938
|
+
return null;
|
|
939
|
+
if (this.activeSort() !== column.key)
|
|
940
|
+
return 'none';
|
|
941
|
+
if (this.activeDirection() === 'asc')
|
|
942
|
+
return 'ascending';
|
|
943
|
+
if (this.activeDirection() === 'desc')
|
|
944
|
+
return 'descending';
|
|
945
|
+
return 'none';
|
|
946
|
+
}
|
|
947
|
+
sortIcon(column) {
|
|
948
|
+
if (this.activeSort() !== column.key || !this.activeDirection())
|
|
949
|
+
return 'unfold_more';
|
|
950
|
+
return this.activeDirection() === 'asc' ? 'arrow_upward' : 'arrow_downward';
|
|
951
|
+
}
|
|
952
|
+
changeSort(column) {
|
|
953
|
+
if (!this.isSortable(column))
|
|
954
|
+
return;
|
|
955
|
+
const current = this.activeSort() === column.key ? this.activeDirection() : '';
|
|
956
|
+
const direction = current === '' ? 'asc' : current === 'asc' ? 'desc' : '';
|
|
957
|
+
const active = direction ? column.key : '';
|
|
958
|
+
this.localSort = { active, direction };
|
|
959
|
+
this.sortChange.emit(this.localSort);
|
|
960
|
+
this.onSortChange.emit(this.localSort);
|
|
961
|
+
}
|
|
962
|
+
handlePage(event) {
|
|
963
|
+
this.pageChange.emit({
|
|
964
|
+
pageIndex: event.pageIndex + 1,
|
|
965
|
+
pageSize: event.pageSize,
|
|
966
|
+
});
|
|
967
|
+
this.onChangePage.emit(event);
|
|
968
|
+
}
|
|
969
|
+
cellValue(row, column) {
|
|
970
|
+
const value = this.getColumnValue(row, column.key);
|
|
971
|
+
if (value == null || value === '')
|
|
972
|
+
return column.fallback ?? '-';
|
|
973
|
+
if (typeof value === 'boolean')
|
|
974
|
+
return value ? 'true' : 'false';
|
|
975
|
+
if (typeof value === 'string' || typeof value === 'number')
|
|
976
|
+
return String(value);
|
|
977
|
+
return '';
|
|
978
|
+
}
|
|
979
|
+
dateValue(row, column) {
|
|
980
|
+
const value = this.getColumnValue(row, column.key);
|
|
981
|
+
if (typeof value === 'string') {
|
|
982
|
+
const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
|
983
|
+
if (dateOnly) {
|
|
984
|
+
const [, year, month, day] = dateOnly;
|
|
985
|
+
const localDate = new Date(Number(year), Number(month) - 1, Number(day));
|
|
986
|
+
return Number.isNaN(localDate.getTime()) ? null : localDate;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
return isDateValue(value) ? parseDateValue(value) : null;
|
|
990
|
+
}
|
|
991
|
+
dateFormat(column) {
|
|
992
|
+
return column.dateFormat ?? column.mask ?? null;
|
|
993
|
+
}
|
|
994
|
+
statusLabel(column, row) {
|
|
995
|
+
const labels = column.status?.label;
|
|
996
|
+
if (!labels)
|
|
997
|
+
return column.fallback ?? '-';
|
|
998
|
+
return labels[this.statusIndex(row, column.key)] ?? column.fallback ?? '-';
|
|
999
|
+
}
|
|
1000
|
+
statusBackground(column, row) {
|
|
1001
|
+
return column.status?.color?.[this.statusIndex(row, column.key)] ?? null;
|
|
1002
|
+
}
|
|
1003
|
+
statusTextColor(column, row) {
|
|
1004
|
+
return (column.status?.textColor?.[this.statusIndex(row, column.key)] ?? null);
|
|
1005
|
+
}
|
|
1006
|
+
cellClasses(column, row) {
|
|
1007
|
+
const record = this.asRow(row);
|
|
1008
|
+
const cellClass = record.styleClass?.key === column.key ? record.styleClass.class : '';
|
|
1009
|
+
return [
|
|
1010
|
+
cellClass || column.class || record.rowStyleClass || '',
|
|
1011
|
+
column.collapse
|
|
1012
|
+
? `mapa-data-table__cell--${this.normalizeCollapse(column.collapse)}`
|
|
1013
|
+
: '',
|
|
1014
|
+
].filter(Boolean);
|
|
1015
|
+
}
|
|
1016
|
+
isCenterAligned(column) {
|
|
1017
|
+
return column.align === 'center';
|
|
1018
|
+
}
|
|
1019
|
+
isEndAligned(column) {
|
|
1020
|
+
return ['end', 'right', 'flex-end'].includes(column.align ?? '');
|
|
1021
|
+
}
|
|
1022
|
+
getActionItems(row) {
|
|
1023
|
+
const rowActions = this.getMenuActionItems(row, 'actions');
|
|
1024
|
+
return rowActions.length ? rowActions : (this.actions ?? []);
|
|
1025
|
+
}
|
|
1026
|
+
getMenuItems(row) {
|
|
1027
|
+
const rowItems = this.getMenuActionItems(row, 'menu');
|
|
1028
|
+
return rowItems.length ? rowItems : this.menuItems;
|
|
1029
|
+
}
|
|
1030
|
+
emitAction(row, item, event) {
|
|
1031
|
+
event.stopPropagation();
|
|
1032
|
+
if (item.disabled)
|
|
1033
|
+
return;
|
|
1034
|
+
this.rowClick.emit({ row: this.asRow(row), action: item.action });
|
|
1035
|
+
}
|
|
1036
|
+
emitRowInteraction(event, row) {
|
|
1037
|
+
if (!this.rowClick.observed || this.isInteractiveTarget(event.target))
|
|
1038
|
+
return;
|
|
1039
|
+
this.rowClick.emit({ row: this.asRow(row), action: '' });
|
|
1040
|
+
}
|
|
1041
|
+
emitRowKeyboard(event, row) {
|
|
1042
|
+
if (!this.rowClick.observed || !['Enter', ' '].includes(event.key))
|
|
1043
|
+
return;
|
|
1044
|
+
event.preventDefault();
|
|
1045
|
+
this.rowClick.emit({ row: this.asRow(row), action: '' });
|
|
1046
|
+
}
|
|
1047
|
+
route(item) {
|
|
1048
|
+
return item.route ?? null;
|
|
1049
|
+
}
|
|
1050
|
+
queryParams(item) {
|
|
1051
|
+
return item.queryParams ?? null;
|
|
1052
|
+
}
|
|
1053
|
+
svgName(svg) {
|
|
1054
|
+
return svg.split('/').pop()?.split('.')[0] || '';
|
|
1055
|
+
}
|
|
1056
|
+
activeSort() {
|
|
1057
|
+
return this.sortActive || this.localSort.active;
|
|
1058
|
+
}
|
|
1059
|
+
activeDirection() {
|
|
1060
|
+
return this.sortDirection || this.localSort.direction;
|
|
1061
|
+
}
|
|
1062
|
+
emitLegacySelection() {
|
|
1063
|
+
if (!this.selection)
|
|
1064
|
+
return;
|
|
1065
|
+
this.selectedRows.emit(this.selection.selected.map((row) => ({ row })));
|
|
1066
|
+
}
|
|
1067
|
+
observeFilterControl() {
|
|
1068
|
+
if (this.observedFilter === this.filterControl)
|
|
1069
|
+
return;
|
|
1070
|
+
this.filterSubscription?.unsubscribe();
|
|
1071
|
+
this.observedFilter = this.filterControl;
|
|
1072
|
+
this.filterValue = `${this.filterControl?.value ?? ''}`
|
|
1073
|
+
.trim()
|
|
1074
|
+
.toLowerCase();
|
|
1075
|
+
this.filterSubscription = this.filterControl?.valueChanges
|
|
1076
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
1077
|
+
.subscribe((value) => {
|
|
1078
|
+
this.filterValue = `${value ?? ''}`.trim().toLowerCase();
|
|
1079
|
+
this.cdr.markForCheck();
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
getColumnValue(row, key) {
|
|
1083
|
+
if (!row || typeof row !== 'object')
|
|
1084
|
+
return null;
|
|
1085
|
+
return row[key];
|
|
1086
|
+
}
|
|
1087
|
+
statusIndex(row, key) {
|
|
1088
|
+
const value = this.getColumnValue(row, key);
|
|
1089
|
+
if (typeof value === 'boolean')
|
|
1090
|
+
return value ? 1 : 0;
|
|
1091
|
+
if (typeof value === 'number')
|
|
1092
|
+
return value;
|
|
1093
|
+
if (typeof value === 'string') {
|
|
1094
|
+
const parsed = Number(value);
|
|
1095
|
+
return Number.isNaN(parsed) ? 0 : parsed;
|
|
1096
|
+
}
|
|
1097
|
+
return 0;
|
|
1098
|
+
}
|
|
1099
|
+
normalizeCollapse(collapse) {
|
|
1100
|
+
return collapse === 'nowrap' ? 'no-wrap' : collapse;
|
|
1101
|
+
}
|
|
1102
|
+
isCompactColumn(column) {
|
|
1103
|
+
return ['actions', 'menu'].includes(column.key);
|
|
1104
|
+
}
|
|
1105
|
+
getFilterValue(value) {
|
|
1106
|
+
if (value == null)
|
|
1107
|
+
return '';
|
|
1108
|
+
if (['string', 'number', 'boolean'].includes(typeof value))
|
|
1109
|
+
return String(value).toLowerCase();
|
|
1110
|
+
if (Array.isArray(value))
|
|
1111
|
+
return value.map((item) => this.getFilterValue(item)).join(' ');
|
|
1112
|
+
if (typeof value === 'object')
|
|
1113
|
+
return Object.values(value)
|
|
1114
|
+
.map((item) => this.getFilterValue(item))
|
|
1115
|
+
.join(' ');
|
|
1116
|
+
return '';
|
|
1117
|
+
}
|
|
1118
|
+
getMenuActionItems(row, key) {
|
|
1119
|
+
const value = this.getColumnValue(row, key);
|
|
1120
|
+
if (!Array.isArray(value))
|
|
1121
|
+
return [];
|
|
1122
|
+
return value.filter((item) => !!item &&
|
|
1123
|
+
typeof item === 'object' &&
|
|
1124
|
+
'action' in item &&
|
|
1125
|
+
'text' in item);
|
|
1126
|
+
}
|
|
1127
|
+
asRow(row) {
|
|
1128
|
+
return row;
|
|
1129
|
+
}
|
|
1130
|
+
isInteractiveTarget(target) {
|
|
1131
|
+
return (target instanceof Element &&
|
|
1132
|
+
!!target.closest("a, button, input, select, textarea, [role='button'], [role='menuitem']"));
|
|
1133
|
+
}
|
|
1134
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1135
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.21", type: MapaTableComponent, isStandalone: true, selector: "mapa-table", inputs: { columns: "columns", data: "data", rowKey: "rowKey", caption: "caption", selectable: "selectable", showSelectAll: "showSelectAll", selectedKeys: "selectedKeys", selectionLabelKey: "selectionLabelKey", checkbox: "checkbox", selection: "selection", loading: "loading", finished: "finished", error: "error", emptyTitle: "emptyTitle", emptySubtitle: "emptySubtitle", errorTitle: "errorTitle", errorSubtitle: "errorSubtitle", retryLabel: "retryLabel", status: "status", empty: "empty", pagination: "pagination", pageIndex: "pageIndex", pageSize: "pageSize", totalCount: "totalCount", pageSizeOptions: "pageSizeOptions", totalPages: "totalPages", showPaginator: "showPaginator", paginatorShowFirstButton: "paginatorShowFirstButton", paginatorShowLastButton: "paginatorShowLastButton", paginatorRenderButtonsNumber: "paginatorRenderButtonsNumber", paginatorHideDefaultArrows: "paginatorHideDefaultArrows", sortActive: "sortActive", sortDirection: "sortDirection", actions: "actions", menuItems: "menuItems", menu: "menu", filterControl: "filterControl" }, outputs: { pageChange: "pageChange", sortChange: "sortChange", selectionChange: "selectionChange", retry: "retry", onChangePage: "onChangePage", onSortChange: "onSortChange", selectedRows: "selectedRows", rowClick: "rowClick" }, providers: [
|
|
1136
|
+
{
|
|
1137
|
+
provide: MatPaginatorIntl,
|
|
1138
|
+
useFactory: customPaginatorFactory,
|
|
1139
|
+
deps: [MapaI18nService, Injector],
|
|
1140
|
+
},
|
|
1141
|
+
], queries: [{ propertyName: "projectedCells", predicate: MapaTableCellDirective, isSignal: true }], ngImport: i0, template: "<section\n class=\"mapa-data-table\"\n [class.mapa-data-table--selectable]=\"isSelectable\"\n>\n <div class=\"mapa-data-table__frame\">\n @if (isLoading) {\n <table class=\"mapa-data-table__table\" aria-hidden=\"true\">\n <thead>\n <tr>\n @if (isSelectable) {\n <th class=\"mapa-data-table__selection-cell\"></th>\n }\n @for (column of columns; track column.key) {\n <th [style.width]=\"skeletonColumnWidth(column)\">\n {{ column.label }}\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of skeletonRows; track row) {\n <tr>\n @if (isSelectable) {\n <td class=\"mapa-data-table__selection-cell\">\n <span\n class=\"mapa-data-table__skeleton mapa-data-table__skeleton--checkbox\"\n ></span>\n </td>\n }\n @for (column of columns; track column.key) {\n <td [style.width]=\"skeletonColumnWidth(column)\">\n <span class=\"mapa-data-table__skeleton\"></span>\n </td>\n }\n </tr>\n }\n </tbody>\n </table>\n <span class=\"mapa-data-table__sr-only\" role=\"status\">\n {{ texts.table.loading }}\n </span>\n } @else if (error) {\n <div class=\"mapa-data-table__state\" role=\"alert\">\n <strong>{{ resolvedErrorTitle }}</strong>\n @if (resolvedErrorSubtitle) {\n <span>{{ resolvedErrorSubtitle }}</span>\n }\n @if (retry.observed) {\n <button type=\"button\" (click)=\"retry.emit()\">\n {{ resolvedRetryLabel }}\n </button>\n }\n </div>\n } @else if (visibleData.length > 0) {\n <table class=\"mapa-data-table__table\">\n @if (caption) {\n <caption class=\"mapa-data-table__sr-only\">\n {{\n caption\n }}\n </caption>\n }\n <thead>\n <tr>\n @if (isSelectable) {\n <th class=\"mapa-data-table__selection-cell\">\n @if (showSelectAll) {\n <mat-checkbox\n color=\"primary\"\n [checked]=\"allVisibleSelected()\"\n [indeterminate]=\"someVisibleSelected()\"\n [aria-label]=\"texts.table.selectAllVisible\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"toggleVisibleRows($event.checked)\"\n />\n } @else {\n <span class=\"mapa-data-table__sr-only\">\n {{ texts.table.selectionColumn }}\n </span>\n }\n </th>\n }\n @for (column of columns; track column.key) {\n <th\n [class.mapa-data-table__cell--center]=\"isCenterAligned(column)\"\n [class.mapa-data-table__cell--end]=\"isEndAligned(column)\"\n [style.width]=\"columnWidth(column)\"\n [attr.aria-sort]=\"ariaSort(column)\"\n >\n @if (isSortable(column)) {\n <button\n type=\"button\"\n class=\"mapa-data-table__sort\"\n (click)=\"changeSort(column)\"\n >\n <span [innerHTML]=\"column.label | safeHtml\"></span>\n <mat-icon aria-hidden=\"true\">{{\n sortIcon(column)\n }}</mat-icon>\n </button>\n } @else {\n <span [innerHTML]=\"column.label | safeHtml\"></span>\n }\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of visibleData; track rowIdentity(row, $index)) {\n <tr\n [class.mapa-data-table__row--selected]=\"isSelected(row)\"\n [class.mapa-data-table__row--interactive]=\"rowClick.observed\"\n [attr.tabindex]=\"rowClick.observed ? 0 : null\"\n (click)=\"emitRowInteraction($event, row)\"\n (keydown)=\"emitRowKeyboard($event, row)\"\n >\n @if (isSelectable) {\n <td class=\"mapa-data-table__selection-cell\">\n <mat-checkbox\n color=\"primary\"\n [checked]=\"isSelected(row)\"\n [aria-label]=\"selectionLabel(row)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"toggleRow(row, $event.checked)\"\n />\n </td>\n }\n @for (column of columns; track column.key) {\n <td\n [attr.data-label]=\"column.label\"\n [class.mapa-data-table__cell--center]=\"\n isCenterAligned(column)\n \"\n [class.mapa-data-table__cell--end]=\"isEndAligned(column)\"\n [style.width]=\"columnWidth(column)\"\n >\n <div\n class=\"mapa-data-table__cell-content\"\n [ngClass]=\"cellClasses(column, row)\"\n >\n @if (cellTemplate(column.key); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{\n $implicit: row,\n row,\n column,\n }\"\n ></ng-container>\n } @else if (column.key === \"actions\") {\n <div class=\"mapa-data-table__actions\">\n @for (item of getActionItems(row); track item) {\n @if (route(item); as actionRoute) {\n <a\n class=\"mapa-data-table__action\"\n [class.mapa-data-table__action--disabled]=\"\n item.disabled\n \"\n [attr.aria-disabled]=\"\n item.disabled ? 'true' : null\n \"\n [attr.tabindex]=\"item.disabled ? -1 : null\"\n [title]=\"item.text\"\n [routerLink]=\"item.disabled ? null : actionRoute\"\n [queryParams]=\"queryParams(item)\"\n (click)=\"$event.stopPropagation()\"\n >\n @if (item.icon) {\n <mat-icon aria-hidden=\"true\">{{\n item.icon\n }}</mat-icon>\n }\n @if (item.image) {\n <img [src]=\"item.image\" alt=\"\" />\n }\n @if (item.svg) {\n <mapa-svg-icon [name]=\"svgName(item.svg)\" />\n }\n @if (item.showText) {\n <span>{{ item.text }}</span>\n } @else {\n <span class=\"mapa-data-table__sr-only\">{{\n item.text\n }}</span>\n }\n </a>\n } @else {\n <button\n type=\"button\"\n class=\"mapa-data-table__action\"\n [disabled]=\"item.disabled\"\n [title]=\"item.text\"\n (click)=\"emitAction(row, item, $event)\"\n >\n @if (item.icon) {\n <mat-icon aria-hidden=\"true\">{{\n item.icon\n }}</mat-icon>\n }\n @if (item.image) {\n <img [src]=\"item.image\" alt=\"\" />\n }\n @if (item.svg) {\n <mapa-svg-icon [name]=\"svgName(item.svg)\" />\n }\n @if (item.showText) {\n <span>{{ item.text }}</span>\n } @else {\n <span class=\"mapa-data-table__sr-only\">{{\n item.text\n }}</span>\n }\n </button>\n }\n }\n </div>\n } @else if (column.key === \"menu\") {\n @if (getMenuItems(row).length > 0) {\n <button\n type=\"button\"\n class=\"mapa-data-table__menu-trigger\"\n [matMenuTriggerFor]=\"rowMenu\"\n [attr.aria-label]=\"column.label\"\n (click)=\"$event.stopPropagation()\"\n >\n <mat-icon aria-hidden=\"true\">more_vert</mat-icon>\n </button>\n <mat-menu #rowMenu=\"matMenu\">\n @for (item of getMenuItems(row); track item) {\n @if (route(item); as menuRoute) {\n <a\n mat-menu-item\n [disabled]=\"item.disabled\"\n [routerLink]=\"item.disabled ? null : menuRoute\"\n [queryParams]=\"queryParams(item)\"\n (click)=\"$event.stopPropagation()\"\n >\n @if (item.icon) {\n <mat-icon aria-hidden=\"true\">{{\n item.icon\n }}</mat-icon>\n }\n @if (item.image) {\n <img [src]=\"item.image\" alt=\"\" />\n }\n <span>{{ item.text }}</span>\n </a>\n } @else {\n <button\n mat-menu-item\n [disabled]=\"item.disabled\"\n (click)=\"emitAction(row, item, $event)\"\n >\n @if (item.icon) {\n <mat-icon aria-hidden=\"true\">{{\n item.icon\n }}</mat-icon>\n }\n @if (item.image) {\n <img [src]=\"item.image\" alt=\"\" />\n }\n <span>{{ item.text }}</span>\n </button>\n }\n }\n </mat-menu>\n }\n } @else if (dateFormat(column); as format) {\n @if (dateValue(row, column); as value) {\n {{ value | date: format }}\n } @else {\n {{ column.fallback ?? \"-\" }}\n }\n } @else if (column.status) {\n <span\n class=\"mapa-data-table__status\"\n [class.mapa-data-table__status--round]=\"\n column.status.style === 'round'\n \"\n [style.background-color]=\"statusBackground(column, row)\"\n [style.color]=\"statusTextColor(column, row)\"\n [innerHTML]=\"statusLabel(column, row) | safeHtml\"\n ></span>\n } @else {\n <span\n [innerHTML]=\"cellValue(row, column) | safeHtml\"\n ></span>\n }\n </div>\n </td>\n }\n </tr>\n }\n </tbody>\n </table>\n } @else if (isFinished) {\n <div class=\"mapa-data-table__state\">\n <strong>{{ resolvedEmptyTitle }}</strong>\n @if (resolvedEmptySubtitle) {\n <span>{{ resolvedEmptySubtitle }}</span>\n }\n </div>\n }\n </div>\n\n @if (shouldShowPaginator) {\n <mat-paginator\n class=\"mapa-data-table__paginator\"\n appBubblePagination\n [appCustomLength]=\"totalCount\"\n [bubblePageIndex]=\"zeroBasedPageIndex\"\n [pageIndex]=\"zeroBasedPageIndex\"\n [showFirstButton]=\"paginatorShowFirstButton\"\n [showLastButton]=\"paginatorShowLastButton\"\n [renderButtonsNumber]=\"paginatorRenderButtonsNumber\"\n [hideDefaultArrows]=\"paginatorHideDefaultArrows\"\n [bubblePageSize]=\"pageSize\"\n [length]=\"totalCount\"\n [pageSize]=\"pageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n (page)=\"handlePage($event)\"\n />\n }\n</section>\n", styles: [":host{display:block}.mapa-data-table{color:var(--mapa-color-text, #1a1a1a);font-family:var(--mapa-font-body, Asap, sans-serif)}.mapa-data-table__frame{background:var(--mapa-color-surface, #fff);border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .12));border-radius:14px;overflow-x:auto}.mapa-data-table__table{border-collapse:collapse;width:100%}.mapa-data-table th,.mapa-data-table td{border-bottom:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08));box-sizing:border-box;font-family:inherit;font-size:13px;font-weight:400;padding:.875rem 1rem;text-align:left;vertical-align:middle}.mapa-data-table th{background:var(--mapa-color-surface-muted, #fafbfc);color:var(--mapa-color-text-subtle, #555);font-size:.75rem;font-weight:600;letter-spacing:.02em;text-transform:uppercase;white-space:nowrap}.mapa-data-table td{color:var(--mapa-color-text, #1a1a1a)}.mapa-data-table tbody tr:last-child td{border-bottom:0}.mapa-data-table tbody tr:hover,.mapa-data-table__row--selected{background:var(--mapa-color-primary-soft, #FFF8F4)}.mapa-data-table__row--interactive{cursor:pointer}.mapa-data-table__row--interactive:focus-visible{outline:2px solid var(--mapa-color-primary, #ff560b);outline-offset:-3px}.mapa-data-table__selection-cell{width:4.5rem}.mapa-data-table__cell--center{text-align:center}.mapa-data-table__cell--end{text-align:right}.mapa-data-table__cell-content{min-width:0}.mapa-data-table__cell--ellipsis{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mapa-data-table__cell--no-wrap{white-space:nowrap}.mapa-data-table__cell--wrap{white-space:pre-wrap}.mapa-data-table__sort{align-items:center;background:transparent;border:0;color:inherit;cursor:pointer;display:inline-flex;font:inherit;gap:.25rem;padding:0;text-transform:inherit}.mapa-data-table__sort:focus-visible,.mapa-data-table__state button:focus-visible,.mapa-data-table__action:focus-visible,.mapa-data-table__menu-trigger:focus-visible{outline:2px solid var(--mapa-color-primary-dark, #50575E);outline-offset:3px}.mapa-data-table__sort mat-icon{font-size:1rem;height:1rem;width:1rem}.mapa-data-table__actions{align-items:center;display:inline-flex;gap:.5rem}.mapa-data-table__action,.mapa-data-table__menu-trigger{align-items:center;background:transparent;border:0;border-radius:6px;color:var(--mapa-color-primary-dark, #50575E);cursor:pointer;display:inline-flex;font:inherit;gap:.375rem;justify-content:center;min-height:36px;min-width:36px;padding:.375rem;text-decoration:none}.mapa-data-table__action:hover,.mapa-data-table__menu-trigger:hover{background:var(--mapa-color-primary-soft, #FFF8F4)}.mapa-data-table__action:disabled,.mapa-data-table__action--disabled{cursor:not-allowed;opacity:.45}.mapa-data-table__action img,.mapa-data-table__menu-trigger img{height:1.25rem;width:1.25rem}.mapa-data-table__status{border-radius:4px;display:inline-flex;padding:.25rem .5rem;white-space:nowrap}.mapa-data-table__status--round{border-radius:999px}.mapa-data-table__state{align-items:center;color:var(--mapa-color-text-subtle, #555);display:flex;flex-direction:column;gap:.625rem;justify-content:center;min-height:150px;padding:1.5rem;text-align:center}.mapa-data-table__state strong{color:var(--mapa-color-text, #1a1a1a)}.mapa-data-table__state button{background:var(--mapa-color-surface-warm, #fffaf6);border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .12));border-radius:10px;color:var(--mapa-color-text, #1a1a1a);cursor:pointer;font:inherit;min-height:40px;padding:.5rem .875rem}.mapa-data-table__skeleton{animation:mapa-data-table-shimmer 1.2s linear infinite;background:linear-gradient(90deg,#f0f2f4 25%,#e6e9ec,#f0f2f4 75%);background-size:200% 100%;border-radius:8px;display:block;height:1rem;max-width:14rem}.mapa-data-table__skeleton--checkbox{border-radius:3px;height:1.125rem;width:1.125rem}.mapa-data-table__sr-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}:host ::ng-deep .mapa-data-table__paginator{background:transparent;color:var(--mapa-color-text-subtle, #555);font-family:var(--mapa-font-body, Asap, sans-serif)}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-container{justify-content:space-between;min-height:72px}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-page-size{margin-right:min(10vw,8rem)}:host ::ng-deep .mapa-data-table__paginator .custom-paginator-container,:host ::ng-deep .mapa-data-table__paginator .g-bubble-container{align-items:center;display:flex;justify-content:flex-end}:host ::ng-deep .mapa-data-table__paginator .g-bubble-container{gap:.5rem}:host ::ng-deep .mapa-data-table__paginator .g-bubble{align-items:center;background:transparent;border:0;border-radius:4px;color:var(--mapa-color-text-subtle, #555);cursor:pointer;display:flex;font:inherit;justify-content:center;min-height:24px;min-width:24px;padding:1px 6px}:host ::ng-deep .mapa-data-table__paginator .g-bubble:hover{background:var(--mapa-color-border-soft, rgba(26, 26, 26, .08))}:host ::ng-deep .mapa-data-table__paginator .g-bubble:focus-visible{outline:2px solid var(--mapa-color-primary, #ff560b);outline-offset:2px}:host ::ng-deep .mapa-data-table__paginator .g-bubble__active{background:var(--mapa-color-primary-dark, #cf482b);color:var(--mapa-color-surface, #fff)}:host ::ng-deep .mapa-data-table__paginator .custom-paginator-counter{color:var(--mapa-color-text-subtle, #555);margin:0 .25rem 0 .625rem;white-space:nowrap}@media(max-width:760px){.mapa-data-table__frame{border:0;overflow:visible}.mapa-data-table thead{display:none}.mapa-data-table tbody{display:grid;gap:.75rem}.mapa-data-table tr{border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .12));border-radius:12px;display:grid;grid-template-columns:minmax(0,1fr);padding:.75rem}.mapa-data-table--selectable tr{grid-template-columns:auto minmax(0,1fr)}.mapa-data-table td{border:0;grid-column:1;padding:.375rem .5rem;text-align:left;width:auto}.mapa-data-table--selectable td:not(.mapa-data-table__selection-cell){grid-column:2}.mapa-data-table td:not(.mapa-data-table__selection-cell):before{color:var(--mapa-color-text-subtle, #555);content:attr(data-label);display:block;font-size:.6875rem;font-weight:600;text-transform:uppercase}.mapa-data-table__selection-cell{grid-column:1;grid-row:1/span 20;width:auto}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-container,:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-range-actions{justify-content:center}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-container{gap:.75rem;padding:.75rem 0}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-page-size{margin-right:0}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-range-label{padding:.5rem 0;text-align:center;width:100%}}@media(prefers-reduced-motion:reduce){.mapa-data-table__skeleton{animation:none}}@keyframes mapa-data-table-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}\n"], dependencies: [{ kind: "directive", type: BubblePaginationDirective, selector: "[appBubblePagination], [appStylePaginatorMv]", inputs: ["showFirstButton", "showLastButton", "renderButtonsNumber", "appCustomLength", "hideDefaultArrows", "bubblePageIndex", "bubblePageSize"], outputs: ["pageIndexChangeEmitter"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i1$3.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i3.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i3.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i3.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "ngmodule", type: MatPaginatorModule }, { kind: "component", type: i1.MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }, { kind: "component", type: MapaSvgIconComponent, selector: "mapa-svg-icon", inputs: ["name", "color"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "pipe", type: DatePipe, name: "date" }, { kind: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1142
|
+
}
|
|
1143
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaTableComponent, decorators: [{
|
|
1144
|
+
type: Component,
|
|
1145
|
+
args: [{ selector: 'mapa-table', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
1146
|
+
BubblePaginationDirective,
|
|
1147
|
+
DatePipe,
|
|
1148
|
+
MatCheckboxModule,
|
|
1149
|
+
MatIconModule,
|
|
1150
|
+
MatMenuModule,
|
|
1151
|
+
MatPaginatorModule,
|
|
1152
|
+
MapaSvgIconComponent,
|
|
1153
|
+
NgClass,
|
|
1154
|
+
NgTemplateOutlet,
|
|
1155
|
+
RouterLink,
|
|
1156
|
+
SafeHtmlPipe,
|
|
1157
|
+
], providers: [
|
|
1158
|
+
{
|
|
1159
|
+
provide: MatPaginatorIntl,
|
|
1160
|
+
useFactory: customPaginatorFactory,
|
|
1161
|
+
deps: [MapaI18nService, Injector],
|
|
1162
|
+
},
|
|
1163
|
+
], standalone: true, template: "<section\n class=\"mapa-data-table\"\n [class.mapa-data-table--selectable]=\"isSelectable\"\n>\n <div class=\"mapa-data-table__frame\">\n @if (isLoading) {\n <table class=\"mapa-data-table__table\" aria-hidden=\"true\">\n <thead>\n <tr>\n @if (isSelectable) {\n <th class=\"mapa-data-table__selection-cell\"></th>\n }\n @for (column of columns; track column.key) {\n <th [style.width]=\"skeletonColumnWidth(column)\">\n {{ column.label }}\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of skeletonRows; track row) {\n <tr>\n @if (isSelectable) {\n <td class=\"mapa-data-table__selection-cell\">\n <span\n class=\"mapa-data-table__skeleton mapa-data-table__skeleton--checkbox\"\n ></span>\n </td>\n }\n @for (column of columns; track column.key) {\n <td [style.width]=\"skeletonColumnWidth(column)\">\n <span class=\"mapa-data-table__skeleton\"></span>\n </td>\n }\n </tr>\n }\n </tbody>\n </table>\n <span class=\"mapa-data-table__sr-only\" role=\"status\">\n {{ texts.table.loading }}\n </span>\n } @else if (error) {\n <div class=\"mapa-data-table__state\" role=\"alert\">\n <strong>{{ resolvedErrorTitle }}</strong>\n @if (resolvedErrorSubtitle) {\n <span>{{ resolvedErrorSubtitle }}</span>\n }\n @if (retry.observed) {\n <button type=\"button\" (click)=\"retry.emit()\">\n {{ resolvedRetryLabel }}\n </button>\n }\n </div>\n } @else if (visibleData.length > 0) {\n <table class=\"mapa-data-table__table\">\n @if (caption) {\n <caption class=\"mapa-data-table__sr-only\">\n {{\n caption\n }}\n </caption>\n }\n <thead>\n <tr>\n @if (isSelectable) {\n <th class=\"mapa-data-table__selection-cell\">\n @if (showSelectAll) {\n <mat-checkbox\n color=\"primary\"\n [checked]=\"allVisibleSelected()\"\n [indeterminate]=\"someVisibleSelected()\"\n [aria-label]=\"texts.table.selectAllVisible\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"toggleVisibleRows($event.checked)\"\n />\n } @else {\n <span class=\"mapa-data-table__sr-only\">\n {{ texts.table.selectionColumn }}\n </span>\n }\n </th>\n }\n @for (column of columns; track column.key) {\n <th\n [class.mapa-data-table__cell--center]=\"isCenterAligned(column)\"\n [class.mapa-data-table__cell--end]=\"isEndAligned(column)\"\n [style.width]=\"columnWidth(column)\"\n [attr.aria-sort]=\"ariaSort(column)\"\n >\n @if (isSortable(column)) {\n <button\n type=\"button\"\n class=\"mapa-data-table__sort\"\n (click)=\"changeSort(column)\"\n >\n <span [innerHTML]=\"column.label | safeHtml\"></span>\n <mat-icon aria-hidden=\"true\">{{\n sortIcon(column)\n }}</mat-icon>\n </button>\n } @else {\n <span [innerHTML]=\"column.label | safeHtml\"></span>\n }\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of visibleData; track rowIdentity(row, $index)) {\n <tr\n [class.mapa-data-table__row--selected]=\"isSelected(row)\"\n [class.mapa-data-table__row--interactive]=\"rowClick.observed\"\n [attr.tabindex]=\"rowClick.observed ? 0 : null\"\n (click)=\"emitRowInteraction($event, row)\"\n (keydown)=\"emitRowKeyboard($event, row)\"\n >\n @if (isSelectable) {\n <td class=\"mapa-data-table__selection-cell\">\n <mat-checkbox\n color=\"primary\"\n [checked]=\"isSelected(row)\"\n [aria-label]=\"selectionLabel(row)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"toggleRow(row, $event.checked)\"\n />\n </td>\n }\n @for (column of columns; track column.key) {\n <td\n [attr.data-label]=\"column.label\"\n [class.mapa-data-table__cell--center]=\"\n isCenterAligned(column)\n \"\n [class.mapa-data-table__cell--end]=\"isEndAligned(column)\"\n [style.width]=\"columnWidth(column)\"\n >\n <div\n class=\"mapa-data-table__cell-content\"\n [ngClass]=\"cellClasses(column, row)\"\n >\n @if (cellTemplate(column.key); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{\n $implicit: row,\n row,\n column,\n }\"\n ></ng-container>\n } @else if (column.key === \"actions\") {\n <div class=\"mapa-data-table__actions\">\n @for (item of getActionItems(row); track item) {\n @if (route(item); as actionRoute) {\n <a\n class=\"mapa-data-table__action\"\n [class.mapa-data-table__action--disabled]=\"\n item.disabled\n \"\n [attr.aria-disabled]=\"\n item.disabled ? 'true' : null\n \"\n [attr.tabindex]=\"item.disabled ? -1 : null\"\n [title]=\"item.text\"\n [routerLink]=\"item.disabled ? null : actionRoute\"\n [queryParams]=\"queryParams(item)\"\n (click)=\"$event.stopPropagation()\"\n >\n @if (item.icon) {\n <mat-icon aria-hidden=\"true\">{{\n item.icon\n }}</mat-icon>\n }\n @if (item.image) {\n <img [src]=\"item.image\" alt=\"\" />\n }\n @if (item.svg) {\n <mapa-svg-icon [name]=\"svgName(item.svg)\" />\n }\n @if (item.showText) {\n <span>{{ item.text }}</span>\n } @else {\n <span class=\"mapa-data-table__sr-only\">{{\n item.text\n }}</span>\n }\n </a>\n } @else {\n <button\n type=\"button\"\n class=\"mapa-data-table__action\"\n [disabled]=\"item.disabled\"\n [title]=\"item.text\"\n (click)=\"emitAction(row, item, $event)\"\n >\n @if (item.icon) {\n <mat-icon aria-hidden=\"true\">{{\n item.icon\n }}</mat-icon>\n }\n @if (item.image) {\n <img [src]=\"item.image\" alt=\"\" />\n }\n @if (item.svg) {\n <mapa-svg-icon [name]=\"svgName(item.svg)\" />\n }\n @if (item.showText) {\n <span>{{ item.text }}</span>\n } @else {\n <span class=\"mapa-data-table__sr-only\">{{\n item.text\n }}</span>\n }\n </button>\n }\n }\n </div>\n } @else if (column.key === \"menu\") {\n @if (getMenuItems(row).length > 0) {\n <button\n type=\"button\"\n class=\"mapa-data-table__menu-trigger\"\n [matMenuTriggerFor]=\"rowMenu\"\n [attr.aria-label]=\"column.label\"\n (click)=\"$event.stopPropagation()\"\n >\n <mat-icon aria-hidden=\"true\">more_vert</mat-icon>\n </button>\n <mat-menu #rowMenu=\"matMenu\">\n @for (item of getMenuItems(row); track item) {\n @if (route(item); as menuRoute) {\n <a\n mat-menu-item\n [disabled]=\"item.disabled\"\n [routerLink]=\"item.disabled ? null : menuRoute\"\n [queryParams]=\"queryParams(item)\"\n (click)=\"$event.stopPropagation()\"\n >\n @if (item.icon) {\n <mat-icon aria-hidden=\"true\">{{\n item.icon\n }}</mat-icon>\n }\n @if (item.image) {\n <img [src]=\"item.image\" alt=\"\" />\n }\n <span>{{ item.text }}</span>\n </a>\n } @else {\n <button\n mat-menu-item\n [disabled]=\"item.disabled\"\n (click)=\"emitAction(row, item, $event)\"\n >\n @if (item.icon) {\n <mat-icon aria-hidden=\"true\">{{\n item.icon\n }}</mat-icon>\n }\n @if (item.image) {\n <img [src]=\"item.image\" alt=\"\" />\n }\n <span>{{ item.text }}</span>\n </button>\n }\n }\n </mat-menu>\n }\n } @else if (dateFormat(column); as format) {\n @if (dateValue(row, column); as value) {\n {{ value | date: format }}\n } @else {\n {{ column.fallback ?? \"-\" }}\n }\n } @else if (column.status) {\n <span\n class=\"mapa-data-table__status\"\n [class.mapa-data-table__status--round]=\"\n column.status.style === 'round'\n \"\n [style.background-color]=\"statusBackground(column, row)\"\n [style.color]=\"statusTextColor(column, row)\"\n [innerHTML]=\"statusLabel(column, row) | safeHtml\"\n ></span>\n } @else {\n <span\n [innerHTML]=\"cellValue(row, column) | safeHtml\"\n ></span>\n }\n </div>\n </td>\n }\n </tr>\n }\n </tbody>\n </table>\n } @else if (isFinished) {\n <div class=\"mapa-data-table__state\">\n <strong>{{ resolvedEmptyTitle }}</strong>\n @if (resolvedEmptySubtitle) {\n <span>{{ resolvedEmptySubtitle }}</span>\n }\n </div>\n }\n </div>\n\n @if (shouldShowPaginator) {\n <mat-paginator\n class=\"mapa-data-table__paginator\"\n appBubblePagination\n [appCustomLength]=\"totalCount\"\n [bubblePageIndex]=\"zeroBasedPageIndex\"\n [pageIndex]=\"zeroBasedPageIndex\"\n [showFirstButton]=\"paginatorShowFirstButton\"\n [showLastButton]=\"paginatorShowLastButton\"\n [renderButtonsNumber]=\"paginatorRenderButtonsNumber\"\n [hideDefaultArrows]=\"paginatorHideDefaultArrows\"\n [bubblePageSize]=\"pageSize\"\n [length]=\"totalCount\"\n [pageSize]=\"pageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n (page)=\"handlePage($event)\"\n />\n }\n</section>\n", styles: [":host{display:block}.mapa-data-table{color:var(--mapa-color-text, #1a1a1a);font-family:var(--mapa-font-body, Asap, sans-serif)}.mapa-data-table__frame{background:var(--mapa-color-surface, #fff);border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .12));border-radius:14px;overflow-x:auto}.mapa-data-table__table{border-collapse:collapse;width:100%}.mapa-data-table th,.mapa-data-table td{border-bottom:1px solid var(--mapa-color-border-soft, rgba(26, 26, 26, .08));box-sizing:border-box;font-family:inherit;font-size:13px;font-weight:400;padding:.875rem 1rem;text-align:left;vertical-align:middle}.mapa-data-table th{background:var(--mapa-color-surface-muted, #fafbfc);color:var(--mapa-color-text-subtle, #555);font-size:.75rem;font-weight:600;letter-spacing:.02em;text-transform:uppercase;white-space:nowrap}.mapa-data-table td{color:var(--mapa-color-text, #1a1a1a)}.mapa-data-table tbody tr:last-child td{border-bottom:0}.mapa-data-table tbody tr:hover,.mapa-data-table__row--selected{background:var(--mapa-color-primary-soft, #FFF8F4)}.mapa-data-table__row--interactive{cursor:pointer}.mapa-data-table__row--interactive:focus-visible{outline:2px solid var(--mapa-color-primary, #ff560b);outline-offset:-3px}.mapa-data-table__selection-cell{width:4.5rem}.mapa-data-table__cell--center{text-align:center}.mapa-data-table__cell--end{text-align:right}.mapa-data-table__cell-content{min-width:0}.mapa-data-table__cell--ellipsis{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mapa-data-table__cell--no-wrap{white-space:nowrap}.mapa-data-table__cell--wrap{white-space:pre-wrap}.mapa-data-table__sort{align-items:center;background:transparent;border:0;color:inherit;cursor:pointer;display:inline-flex;font:inherit;gap:.25rem;padding:0;text-transform:inherit}.mapa-data-table__sort:focus-visible,.mapa-data-table__state button:focus-visible,.mapa-data-table__action:focus-visible,.mapa-data-table__menu-trigger:focus-visible{outline:2px solid var(--mapa-color-primary-dark, #50575E);outline-offset:3px}.mapa-data-table__sort mat-icon{font-size:1rem;height:1rem;width:1rem}.mapa-data-table__actions{align-items:center;display:inline-flex;gap:.5rem}.mapa-data-table__action,.mapa-data-table__menu-trigger{align-items:center;background:transparent;border:0;border-radius:6px;color:var(--mapa-color-primary-dark, #50575E);cursor:pointer;display:inline-flex;font:inherit;gap:.375rem;justify-content:center;min-height:36px;min-width:36px;padding:.375rem;text-decoration:none}.mapa-data-table__action:hover,.mapa-data-table__menu-trigger:hover{background:var(--mapa-color-primary-soft, #FFF8F4)}.mapa-data-table__action:disabled,.mapa-data-table__action--disabled{cursor:not-allowed;opacity:.45}.mapa-data-table__action img,.mapa-data-table__menu-trigger img{height:1.25rem;width:1.25rem}.mapa-data-table__status{border-radius:4px;display:inline-flex;padding:.25rem .5rem;white-space:nowrap}.mapa-data-table__status--round{border-radius:999px}.mapa-data-table__state{align-items:center;color:var(--mapa-color-text-subtle, #555);display:flex;flex-direction:column;gap:.625rem;justify-content:center;min-height:150px;padding:1.5rem;text-align:center}.mapa-data-table__state strong{color:var(--mapa-color-text, #1a1a1a)}.mapa-data-table__state button{background:var(--mapa-color-surface-warm, #fffaf6);border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .12));border-radius:10px;color:var(--mapa-color-text, #1a1a1a);cursor:pointer;font:inherit;min-height:40px;padding:.5rem .875rem}.mapa-data-table__skeleton{animation:mapa-data-table-shimmer 1.2s linear infinite;background:linear-gradient(90deg,#f0f2f4 25%,#e6e9ec,#f0f2f4 75%);background-size:200% 100%;border-radius:8px;display:block;height:1rem;max-width:14rem}.mapa-data-table__skeleton--checkbox{border-radius:3px;height:1.125rem;width:1.125rem}.mapa-data-table__sr-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}:host ::ng-deep .mapa-data-table__paginator{background:transparent;color:var(--mapa-color-text-subtle, #555);font-family:var(--mapa-font-body, Asap, sans-serif)}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-container{justify-content:space-between;min-height:72px}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-page-size{margin-right:min(10vw,8rem)}:host ::ng-deep .mapa-data-table__paginator .custom-paginator-container,:host ::ng-deep .mapa-data-table__paginator .g-bubble-container{align-items:center;display:flex;justify-content:flex-end}:host ::ng-deep .mapa-data-table__paginator .g-bubble-container{gap:.5rem}:host ::ng-deep .mapa-data-table__paginator .g-bubble{align-items:center;background:transparent;border:0;border-radius:4px;color:var(--mapa-color-text-subtle, #555);cursor:pointer;display:flex;font:inherit;justify-content:center;min-height:24px;min-width:24px;padding:1px 6px}:host ::ng-deep .mapa-data-table__paginator .g-bubble:hover{background:var(--mapa-color-border-soft, rgba(26, 26, 26, .08))}:host ::ng-deep .mapa-data-table__paginator .g-bubble:focus-visible{outline:2px solid var(--mapa-color-primary, #ff560b);outline-offset:2px}:host ::ng-deep .mapa-data-table__paginator .g-bubble__active{background:var(--mapa-color-primary-dark, #cf482b);color:var(--mapa-color-surface, #fff)}:host ::ng-deep .mapa-data-table__paginator .custom-paginator-counter{color:var(--mapa-color-text-subtle, #555);margin:0 .25rem 0 .625rem;white-space:nowrap}@media(max-width:760px){.mapa-data-table__frame{border:0;overflow:visible}.mapa-data-table thead{display:none}.mapa-data-table tbody{display:grid;gap:.75rem}.mapa-data-table tr{border:1px solid var(--mapa-color-border, rgba(26, 26, 26, .12));border-radius:12px;display:grid;grid-template-columns:minmax(0,1fr);padding:.75rem}.mapa-data-table--selectable tr{grid-template-columns:auto minmax(0,1fr)}.mapa-data-table td{border:0;grid-column:1;padding:.375rem .5rem;text-align:left;width:auto}.mapa-data-table--selectable td:not(.mapa-data-table__selection-cell){grid-column:2}.mapa-data-table td:not(.mapa-data-table__selection-cell):before{color:var(--mapa-color-text-subtle, #555);content:attr(data-label);display:block;font-size:.6875rem;font-weight:600;text-transform:uppercase}.mapa-data-table__selection-cell{grid-column:1;grid-row:1/span 20;width:auto}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-container,:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-range-actions{justify-content:center}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-container{gap:.75rem;padding:.75rem 0}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-page-size{margin-right:0}:host ::ng-deep .mapa-data-table__paginator .mat-mdc-paginator-range-label{padding:.5rem 0;text-align:center;width:100%}}@media(prefers-reduced-motion:reduce){.mapa-data-table__skeleton{animation:none}}@keyframes mapa-data-table-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}\n"] }]
|
|
1164
|
+
}], propDecorators: { columns: [{
|
|
1165
|
+
type: Input
|
|
1166
|
+
}], data: [{
|
|
1167
|
+
type: Input
|
|
1168
|
+
}], rowKey: [{
|
|
1169
|
+
type: Input
|
|
1170
|
+
}], caption: [{
|
|
1171
|
+
type: Input
|
|
1172
|
+
}], selectable: [{
|
|
1173
|
+
type: Input
|
|
1174
|
+
}], showSelectAll: [{
|
|
1175
|
+
type: Input
|
|
1176
|
+
}], selectedKeys: [{
|
|
1177
|
+
type: Input
|
|
1178
|
+
}], selectionLabelKey: [{
|
|
1179
|
+
type: Input
|
|
1180
|
+
}], checkbox: [{
|
|
1181
|
+
type: Input
|
|
1182
|
+
}], selection: [{
|
|
1183
|
+
type: Input
|
|
1184
|
+
}], loading: [{
|
|
1185
|
+
type: Input
|
|
1186
|
+
}], finished: [{
|
|
1187
|
+
type: Input
|
|
1188
|
+
}], error: [{
|
|
1189
|
+
type: Input
|
|
1190
|
+
}], emptyTitle: [{
|
|
1191
|
+
type: Input
|
|
1192
|
+
}], emptySubtitle: [{
|
|
1193
|
+
type: Input
|
|
1194
|
+
}], errorTitle: [{
|
|
1195
|
+
type: Input
|
|
1196
|
+
}], errorSubtitle: [{
|
|
1197
|
+
type: Input
|
|
1198
|
+
}], retryLabel: [{
|
|
1199
|
+
type: Input
|
|
1200
|
+
}], status: [{
|
|
1201
|
+
type: Input
|
|
1202
|
+
}], empty: [{
|
|
1203
|
+
type: Input
|
|
1204
|
+
}], pagination: [{
|
|
1205
|
+
type: Input
|
|
1206
|
+
}], pageIndex: [{
|
|
1207
|
+
type: Input
|
|
1208
|
+
}], pageSize: [{
|
|
1209
|
+
type: Input
|
|
1210
|
+
}], totalCount: [{
|
|
1211
|
+
type: Input
|
|
1212
|
+
}], pageSizeOptions: [{
|
|
1213
|
+
type: Input
|
|
1214
|
+
}], totalPages: [{
|
|
1215
|
+
type: Input
|
|
1216
|
+
}], showPaginator: [{
|
|
1217
|
+
type: Input
|
|
1218
|
+
}], paginatorShowFirstButton: [{
|
|
1219
|
+
type: Input
|
|
1220
|
+
}], paginatorShowLastButton: [{
|
|
1221
|
+
type: Input
|
|
1222
|
+
}], paginatorRenderButtonsNumber: [{
|
|
1223
|
+
type: Input
|
|
1224
|
+
}], paginatorHideDefaultArrows: [{
|
|
1225
|
+
type: Input
|
|
1226
|
+
}], sortActive: [{
|
|
1227
|
+
type: Input
|
|
1228
|
+
}], sortDirection: [{
|
|
1229
|
+
type: Input
|
|
1230
|
+
}], actions: [{
|
|
1231
|
+
type: Input
|
|
1232
|
+
}], menuItems: [{
|
|
1233
|
+
type: Input
|
|
1234
|
+
}], menu: [{
|
|
1235
|
+
type: Input
|
|
1236
|
+
}], filterControl: [{
|
|
1237
|
+
type: Input
|
|
1238
|
+
}], pageChange: [{
|
|
1239
|
+
type: Output
|
|
1240
|
+
}], sortChange: [{
|
|
1241
|
+
type: Output
|
|
1242
|
+
}], selectionChange: [{
|
|
1243
|
+
type: Output
|
|
1244
|
+
}], retry: [{
|
|
1245
|
+
type: Output
|
|
1246
|
+
}], onChangePage: [{
|
|
1247
|
+
type: Output
|
|
1248
|
+
}], onSortChange: [{
|
|
1249
|
+
type: Output
|
|
1250
|
+
}], selectedRows: [{
|
|
1251
|
+
type: Output
|
|
1252
|
+
}], rowClick: [{
|
|
1253
|
+
type: Output
|
|
1254
|
+
}], projectedCells: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => MapaTableCellDirective), { isSignal: true }] }] } });
|
|
1255
|
+
|
|
1256
|
+
/*
|
|
1257
|
+
* Public API Surface of mapa-library-ui table
|
|
1258
|
+
*/
|
|
11
1259
|
|
|
12
1260
|
class MapaGroupReportComponent {
|
|
13
1261
|
constructor() {
|
|
14
1262
|
this.groupReport = [];
|
|
15
1263
|
this.showGroupReportGeneral = false;
|
|
16
1264
|
this.onSortChange = new EventEmitter();
|
|
17
|
-
this.dataSource = new MatTableDataSource([]);
|
|
18
1265
|
this.displayedColumns = [];
|
|
19
1266
|
this.columns = [];
|
|
20
1267
|
this.data = [];
|
|
21
|
-
|
|
22
|
-
ngAfterViewInit() {
|
|
23
|
-
this.dataSource.sort = this.sort;
|
|
1268
|
+
this.activeSort = { active: '', direction: '' };
|
|
24
1269
|
}
|
|
25
1270
|
ngOnChanges(changes) {
|
|
26
|
-
if (changes[
|
|
1271
|
+
if (changes['groupReport'] || changes['showGroupReportGeneral']) {
|
|
27
1272
|
this.refreshTableState();
|
|
28
1273
|
}
|
|
29
1274
|
}
|
|
@@ -31,6 +1276,8 @@ class MapaGroupReportComponent {
|
|
|
31
1276
|
return `${index}:${column.key}`;
|
|
32
1277
|
}
|
|
33
1278
|
handleSortChange(sort) {
|
|
1279
|
+
this.activeSort = sort;
|
|
1280
|
+
this.data = this.sortData(this.generateGroupData(), sort);
|
|
34
1281
|
this.onSortChange.emit(sort);
|
|
35
1282
|
}
|
|
36
1283
|
getDimensionCell(row, key) {
|
|
@@ -41,37 +1288,48 @@ class MapaGroupReportComponent {
|
|
|
41
1288
|
return this.getDimensionCell(row, key)?.value?.classification;
|
|
42
1289
|
}
|
|
43
1290
|
getDimensionLabel(row, key) {
|
|
44
|
-
return this.getDimensionCell(row, key)?.value?.label ??
|
|
1291
|
+
return this.getDimensionCell(row, key)?.value?.label ?? '-';
|
|
45
1292
|
}
|
|
46
1293
|
getGeneralValue(row) {
|
|
47
|
-
return typeof row.general ===
|
|
1294
|
+
return typeof row.general === 'number' ? row.general : null;
|
|
48
1295
|
}
|
|
49
1296
|
refreshTableState() {
|
|
50
1297
|
this.columns = this.generateColumns();
|
|
51
|
-
this.data = this.generateGroupData();
|
|
1298
|
+
this.data = this.sortData(this.generateGroupData(), this.activeSort);
|
|
52
1299
|
this.displayedColumns = this.columns.map((column) => column.key);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
1300
|
+
}
|
|
1301
|
+
sortData(data, sort) {
|
|
1302
|
+
if (!sort.active || !sort.direction) {
|
|
1303
|
+
return data;
|
|
57
1304
|
}
|
|
1305
|
+
const multiplier = sort.direction === 'asc' ? 1 : -1;
|
|
1306
|
+
return [...data].sort((left, right) => {
|
|
1307
|
+
const leftValue = this.getSortValue(left, sort.active);
|
|
1308
|
+
const rightValue = this.getSortValue(right, sort.active);
|
|
1309
|
+
return (String(leftValue).localeCompare(String(rightValue), undefined, {
|
|
1310
|
+
numeric: true,
|
|
1311
|
+
sensitivity: 'base',
|
|
1312
|
+
}) * multiplier);
|
|
1313
|
+
});
|
|
58
1314
|
}
|
|
59
1315
|
getSortValue(row, columnKey) {
|
|
60
1316
|
const cell = row[columnKey];
|
|
61
1317
|
if (this.isGroupReportDimensionCell(cell)) {
|
|
62
1318
|
return cell.value?.classification?.classificationId ?? 0;
|
|
63
1319
|
}
|
|
64
|
-
return typeof cell ===
|
|
1320
|
+
return typeof cell === 'number' || typeof cell === 'string' ? cell : '';
|
|
65
1321
|
}
|
|
66
1322
|
isGroupReportDimensionCell(value) {
|
|
67
|
-
return typeof value ===
|
|
1323
|
+
return typeof value === 'object' && value !== null && 'direction' in value;
|
|
68
1324
|
}
|
|
69
1325
|
generateColumns() {
|
|
70
|
-
const columns = [
|
|
71
|
-
|
|
1326
|
+
const columns = [
|
|
1327
|
+
{ key: 'name', label: '', sortable: false },
|
|
1328
|
+
];
|
|
1329
|
+
const existingKeys = new Set(['name']);
|
|
72
1330
|
if (this.showGroupReportGeneral) {
|
|
73
|
-
columns.push({ key:
|
|
74
|
-
existingKeys.add(
|
|
1331
|
+
columns.push({ key: 'general', label: '% Geral', sortable: false });
|
|
1332
|
+
existingKeys.add('general');
|
|
75
1333
|
}
|
|
76
1334
|
this.groupReport.forEach((reportItem) => {
|
|
77
1335
|
reportItem.dimensions?.forEach((dimension) => {
|
|
@@ -81,7 +1339,7 @@ class MapaGroupReportComponent {
|
|
|
81
1339
|
key,
|
|
82
1340
|
label: dimension.dimensionName,
|
|
83
1341
|
classification: dimension.classification,
|
|
84
|
-
|
|
1342
|
+
sortable: true,
|
|
85
1343
|
});
|
|
86
1344
|
existingKeys.add(key);
|
|
87
1345
|
}
|
|
@@ -134,20 +1392,17 @@ class MapaGroupReportComponent {
|
|
|
134
1392
|
};
|
|
135
1393
|
}
|
|
136
1394
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaGroupReportComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
137
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.21", type: MapaGroupReportComponent, isStandalone: true, selector: "mapa-group-report", inputs: { groupReport: "groupReport", showGroupReportGeneral: "showGroupReportGeneral" }, outputs: { onSortChange: "onSortChange" },
|
|
1395
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.21", type: MapaGroupReportComponent, isStandalone: true, selector: "mapa-group-report", inputs: { groupReport: "groupReport", showGroupReportGeneral: "showGroupReportGeneral" }, outputs: { onSortChange: "onSortChange" }, usesOnChanges: true, ngImport: i0, template: "<section class=\"mapa-group-report\">\n <mapa-table\n [columns]=\"columns\"\n [data]=\"data\"\n [finished]=\"true\"\n caption=\"Relat\u00F3rio de grupo por dimens\u00E3o\"\n (sortChange)=\"handleSortChange($event)\"\n >\n <ng-template mapaTableCell=\"name\" let-row>\n <div class=\"mapa-group-report__content--value\">\n <div class=\"mapa-group-report__content--title\">\n {{ $any(row).name }}\n </div>\n <div class=\"mapa-group-report__content--subtitle\">\n {{ $any(row).cpf }}\n </div>\n </div>\n </ng-template>\n\n @if (showGroupReportGeneral) {\n <ng-template mapaTableCell=\"general\" let-row>\n <div\n class=\"mapa-group-report__column mapa-group-report__column--center-cell\"\n >\n <div class=\"general\">\n {{ getGeneralValue($any(row)) | currency: \"\" : \"\" }}%\n </div>\n </div>\n </ng-template>\n }\n\n @for (column of columns; track trackColumn($index, column)) {\n @if (column.key !== \"name\" && column.key !== \"general\") {\n <ng-template [mapaTableCell]=\"column.key\" let-row>\n <div\n class=\"mapa-group-report__column mapa-group-report__column--center-cell\"\n >\n <div class=\"mapa-group-report__hover\">\n <span class=\"mapa-group-report__hover--main\">\n <span\n class=\"mapa__tag--bg\"\n [class.mapa__tag--contrast]=\"\n getDimensionClassification($any(row), column.key)\n ?.classificationId === 1\n \"\n [style.backgroundColor]=\"\n getDimensionClassification($any(row), column.key)\n ?.classificationColor\n \"\n >\n {{\n getDimensionClassification($any(row), column.key)\n ?.classificationName || \"-\"\n }}\n </span>\n </span>\n <span class=\"mapa-group-report__hover--hidden\">\n {{ getDimensionLabel($any(row), column.key) }}\n </span>\n </div>\n </div>\n </ng-template>\n }\n }\n </mapa-table>\n</section>\n", styles: [":host{display:block}.mapa-group-report{width:100%}.mapa-group-report mapa-table{display:block;width:100%}.mapa-group-report__column{display:flex;align-items:center}.mapa-group-report__column--center-cell{display:flex;align-items:center;justify-content:center;width:100%}.mapa-group-report__content--value{margin-right:40px}.mapa-group-report__content--title{color:var(--mapa-color-text, #1a1a1a);text-align:left;font-family:var(--mapa-font-heading, \"Asap\", \"Inter\", sans-serif);font-size:14px;font-style:normal;font-weight:500;line-height:20px}.mapa-group-report__content--subtitle{color:#77838f;text-align:left;font-family:var(--mapa-font-heading, \"Asap\", \"Inter\", sans-serif);font-size:12px;font-style:normal;font-weight:400;line-height:16px}.mapa-group-report__hover--hidden{display:none}.mapa-group-report__hover:hover .mapa-group-report__hover--main,.mapa-group-report__hover:focus-within .mapa-group-report__hover--main{display:none}.mapa-group-report__hover:hover .mapa-group-report__hover--hidden,.mapa-group-report__hover:focus-within .mapa-group-report__hover--hidden{display:flex}.mapa-group-report .general{border-radius:24px;border:1px solid #dcdcde;display:flex;justify-content:center;align-items:center;width:48px;height:48px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: MapaTableCellDirective, selector: "ng-template[mapaTableCell]", inputs: ["mapaTableCell"] }, { kind: "component", type: MapaTableComponent, selector: "mapa-table", inputs: ["columns", "data", "rowKey", "caption", "selectable", "showSelectAll", "selectedKeys", "selectionLabelKey", "checkbox", "selection", "loading", "finished", "error", "emptyTitle", "emptySubtitle", "errorTitle", "errorSubtitle", "retryLabel", "status", "empty", "pagination", "pageIndex", "pageSize", "totalCount", "pageSizeOptions", "totalPages", "showPaginator", "paginatorShowFirstButton", "paginatorShowLastButton", "paginatorRenderButtonsNumber", "paginatorHideDefaultArrows", "sortActive", "sortDirection", "actions", "menuItems", "menu", "filterControl"], outputs: ["pageChange", "sortChange", "selectionChange", "retry", "onChangePage", "onSortChange", "selectedRows", "rowClick"] }, { kind: "pipe", type: i2.CurrencyPipe, name: "currency" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
138
1396
|
}
|
|
139
1397
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.21", ngImport: i0, type: MapaGroupReportComponent, decorators: [{
|
|
140
1398
|
type: Component,
|
|
141
|
-
args: [{ selector:
|
|
1399
|
+
args: [{ selector: 'mapa-group-report', changeDetection: ChangeDetectionStrategy.OnPush, imports: [CommonModule, MapaTableCellDirective, MapaTableComponent], standalone: true, template: "<section class=\"mapa-group-report\">\n <mapa-table\n [columns]=\"columns\"\n [data]=\"data\"\n [finished]=\"true\"\n caption=\"Relat\u00F3rio de grupo por dimens\u00E3o\"\n (sortChange)=\"handleSortChange($event)\"\n >\n <ng-template mapaTableCell=\"name\" let-row>\n <div class=\"mapa-group-report__content--value\">\n <div class=\"mapa-group-report__content--title\">\n {{ $any(row).name }}\n </div>\n <div class=\"mapa-group-report__content--subtitle\">\n {{ $any(row).cpf }}\n </div>\n </div>\n </ng-template>\n\n @if (showGroupReportGeneral) {\n <ng-template mapaTableCell=\"general\" let-row>\n <div\n class=\"mapa-group-report__column mapa-group-report__column--center-cell\"\n >\n <div class=\"general\">\n {{ getGeneralValue($any(row)) | currency: \"\" : \"\" }}%\n </div>\n </div>\n </ng-template>\n }\n\n @for (column of columns; track trackColumn($index, column)) {\n @if (column.key !== \"name\" && column.key !== \"general\") {\n <ng-template [mapaTableCell]=\"column.key\" let-row>\n <div\n class=\"mapa-group-report__column mapa-group-report__column--center-cell\"\n >\n <div class=\"mapa-group-report__hover\">\n <span class=\"mapa-group-report__hover--main\">\n <span\n class=\"mapa__tag--bg\"\n [class.mapa__tag--contrast]=\"\n getDimensionClassification($any(row), column.key)\n ?.classificationId === 1\n \"\n [style.backgroundColor]=\"\n getDimensionClassification($any(row), column.key)\n ?.classificationColor\n \"\n >\n {{\n getDimensionClassification($any(row), column.key)\n ?.classificationName || \"-\"\n }}\n </span>\n </span>\n <span class=\"mapa-group-report__hover--hidden\">\n {{ getDimensionLabel($any(row), column.key) }}\n </span>\n </div>\n </div>\n </ng-template>\n }\n }\n </mapa-table>\n</section>\n", styles: [":host{display:block}.mapa-group-report{width:100%}.mapa-group-report mapa-table{display:block;width:100%}.mapa-group-report__column{display:flex;align-items:center}.mapa-group-report__column--center-cell{display:flex;align-items:center;justify-content:center;width:100%}.mapa-group-report__content--value{margin-right:40px}.mapa-group-report__content--title{color:var(--mapa-color-text, #1a1a1a);text-align:left;font-family:var(--mapa-font-heading, \"Asap\", \"Inter\", sans-serif);font-size:14px;font-style:normal;font-weight:500;line-height:20px}.mapa-group-report__content--subtitle{color:#77838f;text-align:left;font-family:var(--mapa-font-heading, \"Asap\", \"Inter\", sans-serif);font-size:12px;font-style:normal;font-weight:400;line-height:16px}.mapa-group-report__hover--hidden{display:none}.mapa-group-report__hover:hover .mapa-group-report__hover--main,.mapa-group-report__hover:focus-within .mapa-group-report__hover--main{display:none}.mapa-group-report__hover:hover .mapa-group-report__hover--hidden,.mapa-group-report__hover:focus-within .mapa-group-report__hover--hidden{display:flex}.mapa-group-report .general{border-radius:24px;border:1px solid #dcdcde;display:flex;justify-content:center;align-items:center;width:48px;height:48px}\n"] }]
|
|
142
1400
|
}], propDecorators: { groupReport: [{
|
|
143
1401
|
type: Input
|
|
144
1402
|
}], showGroupReportGeneral: [{
|
|
145
1403
|
type: Input
|
|
146
1404
|
}], onSortChange: [{
|
|
147
1405
|
type: Output
|
|
148
|
-
}], sort: [{
|
|
149
|
-
type: ViewChild,
|
|
150
|
-
args: [MatSort]
|
|
151
1406
|
}] } });
|
|
152
1407
|
|
|
153
1408
|
/*
|