@masterteam/data-table 0.0.4 → 0.0.6
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/README.md +20 -8
- package/fesm2022/masterteam-data-table-legacy.mjs +3 -1
- package/fesm2022/masterteam-data-table-legacy.mjs.map +1 -1
- package/fesm2022/masterteam-data-table.mjs +240 -61
- package/fesm2022/masterteam-data-table.mjs.map +1 -1
- package/package.json +3 -3
- package/types/masterteam-data-table.d.ts +53 -5
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, computed, ChangeDetectionStrategy, ViewEncapsulation, Component, inject, Injectable, output, untracked } from '@angular/core';
|
|
2
|
+
import { input, computed, ChangeDetectionStrategy, ViewEncapsulation, Component, inject, Injectable, output, viewChild, untracked } from '@angular/core';
|
|
3
3
|
import { currencyUnitOf, EntityPreview, EntityText, EntityRuntimeContextStore } from '@masterteam/components/entities';
|
|
4
|
-
import { TableValueResolver, TableExportService } from '@masterteam/components/table';
|
|
5
|
-
import { AUTO_GROUP_COLUMN_ID, applyGridViewState, captureGridViewState
|
|
4
|
+
import { TableValueResolver, TableExportService, TableActionsMenu } from '@masterteam/components/table';
|
|
5
|
+
import { AUTO_GROUP_COLUMN_ID, MtDataGridComponent, applyGridViewState, captureGridViewState } from '@masterteam/data-grid';
|
|
6
6
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
7
7
|
import { TranslocoService } from '@jsverse/transloco';
|
|
8
|
+
import { observeOn, asapScheduler } from 'rxjs';
|
|
8
9
|
import { EmptyState } from '@masterteam/components/empty-state';
|
|
9
10
|
import { Button } from '@masterteam/components/button';
|
|
10
11
|
import { ConfirmationService } from '@masterteam/components/confirmation';
|
|
11
12
|
import { Popover } from 'primeng/popover';
|
|
13
|
+
import { Skeleton } from 'primeng/skeleton';
|
|
12
14
|
import { NgTemplateOutlet } from '@angular/common';
|
|
13
15
|
|
|
14
16
|
const NUMERIC = new Set([
|
|
@@ -251,7 +253,9 @@ function mtEntityCellValues(entity) {
|
|
|
251
253
|
display,
|
|
252
254
|
identity: null,
|
|
253
255
|
sort: null,
|
|
254
|
-
filter
|
|
256
|
+
// A client-side grid gives every column a filter (the standard header), so a
|
|
257
|
+
// collection filters on its display text rather than never matching.
|
|
258
|
+
filter: display || null,
|
|
255
259
|
aggregate: null,
|
|
256
260
|
export: display,
|
|
257
261
|
};
|
|
@@ -303,26 +307,26 @@ class MtDataTableEntityCell {
|
|
|
303
307
|
: null;
|
|
304
308
|
}
|
|
305
309
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: MtDataTableEntityCell, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
306
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: MtDataTableEntityCell, isStandalone: true, selector: "mt-data-table-entity-cell", inputs: { params: { classPropertyName: "params", publicName: "params", isSignal: true, isRequired: true, transformFunction: null } }, host: { classAttribute: "mt-entity-grid-cell" }, providers: [EntityRuntimeContextStore], ngImport: i0, template: `@if (entity(); as value) {
|
|
307
|
-
@if (simpleText()) {
|
|
308
|
-
<mt-entity-text [data]="value" />
|
|
309
|
-
} @else {
|
|
310
|
-
<mt-entity-preview [data]="value" attachmentShape="compact" />
|
|
311
|
-
}
|
|
312
|
-
} @else {
|
|
313
|
-
{{ params().valueFormatted }}
|
|
310
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: MtDataTableEntityCell, isStandalone: true, selector: "mt-data-table-entity-cell", inputs: { params: { classPropertyName: "params", publicName: "params", isSignal: true, isRequired: true, transformFunction: null } }, host: { classAttribute: "mt-entity-grid-cell" }, providers: [EntityRuntimeContextStore], ngImport: i0, template: `@if (entity(); as value) {
|
|
311
|
+
@if (simpleText()) {
|
|
312
|
+
<mt-entity-text [data]="value" />
|
|
313
|
+
} @else {
|
|
314
|
+
<mt-entity-preview [data]="value" attachmentShape="compact" />
|
|
315
|
+
}
|
|
316
|
+
} @else {
|
|
317
|
+
{{ params().valueFormatted }}
|
|
314
318
|
}`, isInline: true, styles: [".mt-entity-grid-cell{display:block;width:100%;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}\n", ".mt-entity-grid-cell *{white-space:nowrap}\n", ".mt-entity-grid-cell .inline-flex{max-width:100%;overflow:hidden}\n", ".mt-entity-grid-cell mt-entity-text .font-semibold{font-weight:400}\n"], dependencies: [{ kind: "component", type: EntityPreview, selector: "mt-entity-preview", inputs: ["data", "attachmentShape"] }, { kind: "component", type: EntityText, selector: "mt-entity-text", inputs: ["data", "name", "value"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
315
319
|
}
|
|
316
320
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: MtDataTableEntityCell, decorators: [{
|
|
317
321
|
type: Component,
|
|
318
|
-
args: [{ selector: 'mt-data-table-entity-cell', encapsulation: ViewEncapsulation.None, host: { class: 'mt-entity-grid-cell' }, imports: [EntityPreview, EntityText], providers: [EntityRuntimeContextStore], template: `@if (entity(); as value) {
|
|
319
|
-
@if (simpleText()) {
|
|
320
|
-
<mt-entity-text [data]="value" />
|
|
321
|
-
} @else {
|
|
322
|
-
<mt-entity-preview [data]="value" attachmentShape="compact" />
|
|
323
|
-
}
|
|
324
|
-
} @else {
|
|
325
|
-
{{ params().valueFormatted }}
|
|
322
|
+
args: [{ selector: 'mt-data-table-entity-cell', encapsulation: ViewEncapsulation.None, host: { class: 'mt-entity-grid-cell' }, imports: [EntityPreview, EntityText], providers: [EntityRuntimeContextStore], template: `@if (entity(); as value) {
|
|
323
|
+
@if (simpleText()) {
|
|
324
|
+
<mt-entity-text [data]="value" />
|
|
325
|
+
} @else {
|
|
326
|
+
<mt-entity-preview [data]="value" attachmentShape="compact" />
|
|
327
|
+
}
|
|
328
|
+
} @else {
|
|
329
|
+
{{ params().valueFormatted }}
|
|
326
330
|
}`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".mt-entity-grid-cell{display:block;width:100%;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}\n", ".mt-entity-grid-cell *{white-space:nowrap}\n", ".mt-entity-grid-cell .inline-flex{max-width:100%;overflow:hidden}\n", ".mt-entity-grid-cell mt-entity-text .font-semibold{font-weight:400}\n"] }]
|
|
327
331
|
}], propDecorators: { params: [{ type: i0.Input, args: [{ isSignal: true, alias: "params", required: true }] }] } });
|
|
328
332
|
/** Optional native export callback: preserves typed numbers/dates and exports entity labels. */
|
|
@@ -408,7 +412,10 @@ function mtEntityColumn(options) {
|
|
|
408
412
|
? {
|
|
409
413
|
valueFormatter: ({ value }) => labels.get(value) ?? String(value ?? ''),
|
|
410
414
|
}
|
|
411
|
-
:
|
|
415
|
+
: viewType === 'Date' || viewType === 'DateTime'
|
|
416
|
+
? // mt-table's date ranges included both ends (>= from, <= to).
|
|
417
|
+
{ inRangeInclusive: true }
|
|
418
|
+
: undefined,
|
|
412
419
|
comparator: category
|
|
413
420
|
? (a, b) => (labels.get(a) ?? '').localeCompare(labels.get(b) ?? '')
|
|
414
421
|
: undefined,
|
|
@@ -866,7 +873,12 @@ class MtTableText {
|
|
|
866
873
|
initialValue: this.transloco.getActiveLang(),
|
|
867
874
|
equal: () => false,
|
|
868
875
|
});
|
|
869
|
-
|
|
876
|
+
/**
|
|
877
|
+
* Delivered on the microtask queue: a translation can load synchronously while a template
|
|
878
|
+
* renders (a `transloco` pipe asking for it, e.g. the standard grid's Export / Print
|
|
879
|
+
* buttons), and writing this signal during render throws NG0600.
|
|
880
|
+
*/
|
|
881
|
+
translationEvents = toSignal(this.transloco.events$.pipe(observeOn(asapScheduler)));
|
|
870
882
|
gridLocale = computed(() => {
|
|
871
883
|
this.translationEvents();
|
|
872
884
|
const language = this.language();
|
|
@@ -1024,7 +1036,16 @@ const EXPORT_FORMATS = [
|
|
|
1024
1036
|
const STATUS_BAR = {
|
|
1025
1037
|
panels: ['totalAndFilteredRowCount', 'selectedRowCount', 'aggregation'],
|
|
1026
1038
|
};
|
|
1027
|
-
|
|
1039
|
+
/**
|
|
1040
|
+
* A server page holds one page of rows, so the grid's own row count would count that page
|
|
1041
|
+
* only; the pager already shows the server total.
|
|
1042
|
+
*/
|
|
1043
|
+
const SERVER_STATUS_BAR = {
|
|
1044
|
+
panels: ['selectedRowCount', 'aggregation'],
|
|
1045
|
+
};
|
|
1046
|
+
/** mt-table's rows-per-page choices and default, so every migrated page keeps them. */
|
|
1047
|
+
const PAGE_SIZES = [5, 10, 20, 50, 100];
|
|
1048
|
+
const DEFAULT_PAGE_SIZE = 10;
|
|
1028
1049
|
function controlColumnIds(columns) {
|
|
1029
1050
|
const ids = new Set();
|
|
1030
1051
|
const visit = (defs) => defs.forEach((def) => {
|
|
@@ -1058,10 +1079,20 @@ class MtStandardGridComponent {
|
|
|
1058
1079
|
loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
1059
1080
|
/** Grid height in px, or `'auto'` to grow with its rows (the page layout decides). */
|
|
1060
1081
|
height = input(560, ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
1082
|
+
/**
|
|
1083
|
+
* Row height in px for a page whose cells stack two lines (mt-table rows grew with their
|
|
1084
|
+
* content); the standard 44px when omitted.
|
|
1085
|
+
*/
|
|
1086
|
+
rowHeight = input(undefined, ...(ngDevMode ? [{ debugName: "rowHeight" }] : /* istanbul ignore next */ []));
|
|
1061
1087
|
/** Row checkboxes with the header select-all. */
|
|
1062
1088
|
selection = input(false, ...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
|
|
1063
1089
|
/** Export permission: the CSV, Excel and PDF items of the context menu. */
|
|
1064
1090
|
exportable = input(true, ...(ngDevMode ? [{ debugName: "exportable" }] : /* istanbul ignore next */ []));
|
|
1091
|
+
/**
|
|
1092
|
+
* Also show mt-table's Export (Excel) and Print (PDF) buttons above the grid, for the pages
|
|
1093
|
+
* that had them in their table caption. They follow `exportable` and `exportFormats`.
|
|
1094
|
+
*/
|
|
1095
|
+
exportButtons = input(false, ...(ngDevMode ? [{ debugName: "exportButtons" }] : /* istanbul ignore next */ []));
|
|
1065
1096
|
exportName = input('export', ...(ngDevMode ? [{ debugName: "exportName" }] : /* istanbul ignore next */ []));
|
|
1066
1097
|
/** The formats the Export menu offers (a narrower export permission). */
|
|
1067
1098
|
exportFormats = input(EXPORT_FORMATS, ...(ngDevMode ? [{ debugName: "exportFormats" }] : /* istanbul ignore next */ []));
|
|
@@ -1076,6 +1107,21 @@ class MtStandardGridComponent {
|
|
|
1076
1107
|
server = input(null, ...(ngDevMode ? [{ debugName: "server" }] : /* istanbul ignore next */ []));
|
|
1077
1108
|
/** The pager. A page whose grid scrolls every row inside its own viewport turns it off. */
|
|
1078
1109
|
paged = input(true, ...(ngDevMode ? [{ debugName: "paged" }] : /* istanbul ignore next */ []));
|
|
1110
|
+
/**
|
|
1111
|
+
* Rows per page when the grid pages its own rows (mt-table's default 10). A server page
|
|
1112
|
+
* uses `server.pageSize`; a saved view's page size wins over both.
|
|
1113
|
+
*/
|
|
1114
|
+
pageSize = input(DEFAULT_PAGE_SIZE, ...(ngDevMode ? [{ debugName: "pageSize" }] : /* istanbul ignore next */ []));
|
|
1115
|
+
/** Rows that open something on click get the pointer cursor (mt-table's clickable rows). */
|
|
1116
|
+
clickableRows = input(false, ...(ngDevMode ? [{ debugName: "clickableRows" }] : /* istanbul ignore next */ []));
|
|
1117
|
+
/**
|
|
1118
|
+
* mt-table's `cellClickFilter`: a click on a cell of a pick-list column (status, lookup,
|
|
1119
|
+
* user, checkbox: the set-filter columns) filters the grid by that value, and a second
|
|
1120
|
+
* click clears it, instead of opening the row.
|
|
1121
|
+
*/
|
|
1122
|
+
cellClickFilter = input(false, ...(ngDevMode ? [{ debugName: "cellClickFilter" }] : /* istanbul ignore next */ []));
|
|
1123
|
+
/** Extra classes on a row, e.g. a status colour on the whole row or stripes. */
|
|
1124
|
+
rowClass = input(null, ...(ngDevMode ? [{ debugName: "rowClass" }] : /* istanbul ignore next */ []));
|
|
1079
1125
|
/** A detail row under expandable rows. */
|
|
1080
1126
|
detail = input(null, ...(ngDevMode ? [{ debugName: "detail" }] : /* istanbul ignore next */ []));
|
|
1081
1127
|
/** Where the grid sits (e.g. a record path), shown in chart titles; defaults to the label. */
|
|
@@ -1104,7 +1150,7 @@ class MtStandardGridComponent {
|
|
|
1104
1150
|
return height === 'auto' ? 400 : height;
|
|
1105
1151
|
}, ...(ngDevMode ? [{ debugName: "gridHeight" }] : /* istanbul ignore next */ []));
|
|
1106
1152
|
standardColumns = computed(() => mtStandardColumns(this.columns(), { server: this.server() !== null }), ...(ngDevMode ? [{ debugName: "standardColumns" }] : /* istanbul ignore next */ []));
|
|
1107
|
-
/**
|
|
1153
|
+
/** On a server page the server supplies the group counts. */
|
|
1108
1154
|
serverGroups = computed(() => this.server() !== null, ...(ngDevMode ? [{ debugName: "serverGroups" }] : /* istanbul ignore next */ []));
|
|
1109
1155
|
autoGroupColumnDef = computed(() => this.serverGroups()
|
|
1110
1156
|
? { cellRendererParams: { suppressCount: true } }
|
|
@@ -1127,7 +1173,27 @@ class MtStandardGridComponent {
|
|
|
1127
1173
|
processCellCallback: (mtEntityExportValue),
|
|
1128
1174
|
}), ...(ngDevMode ? [{ debugName: "exportParams" }] : /* istanbul ignore next */ []));
|
|
1129
1175
|
// Template `?.` yields null; the grid needs undefined for client-side paging.
|
|
1130
|
-
|
|
1176
|
+
gridPageSize = computed(() => this.server()?.pageSize ?? this.pageSize(), ...(ngDevMode ? [{ debugName: "gridPageSize" }] : /* istanbul ignore next */ []));
|
|
1177
|
+
gridStatusBar = computed(() => this.server() ? SERVER_STATUS_BAR : STATUS_BAR, ...(ngDevMode ? [{ debugName: "gridStatusBar" }] : /* istanbul ignore next */ []));
|
|
1178
|
+
excelButton = computed(() => this.exportButtons() && this.excelAllowed(), ...(ngDevMode ? [{ debugName: "excelButton" }] : /* istanbul ignore next */ []));
|
|
1179
|
+
printButton = computed(() => this.exportButtons() &&
|
|
1180
|
+
this.exportable() &&
|
|
1181
|
+
this.exportFormats().includes('pdf'), ...(ngDevMode ? [{ debugName: "printButton" }] : /* istanbul ignore next */ []));
|
|
1182
|
+
/** The page's row classes plus the pointer cursor on clickable rows. */
|
|
1183
|
+
gridRowClass = computed(() => {
|
|
1184
|
+
const clickable = this.clickableRows();
|
|
1185
|
+
const rowClass = this.rowClass();
|
|
1186
|
+
if (!clickable && !rowClass)
|
|
1187
|
+
return undefined;
|
|
1188
|
+
return (params) => {
|
|
1189
|
+
const own = rowClass?.(params);
|
|
1190
|
+
const classes = typeof own === 'string' ? [own] : [...(own ?? [])];
|
|
1191
|
+
if (params.data !== undefined &&
|
|
1192
|
+
(typeof clickable === 'function' ? clickable(params.data) : clickable))
|
|
1193
|
+
classes.push('mt-standard-grid-row-clickable');
|
|
1194
|
+
return classes;
|
|
1195
|
+
};
|
|
1196
|
+
}, ...(ngDevMode ? [{ debugName: "gridRowClass" }] : /* istanbul ignore next */ []));
|
|
1131
1197
|
serverTotal = computed(() => this.server()?.total, ...(ngDevMode ? [{ debugName: "serverTotal" }] : /* istanbul ignore next */ []));
|
|
1132
1198
|
serverPage = computed(() => this.server()?.page, ...(ngDevMode ? [{ debugName: "serverPage" }] : /* istanbul ignore next */ []));
|
|
1133
1199
|
pagedTotal = computed(() => this.paged() ? this.serverTotal() : undefined, ...(ngDevMode ? [{ debugName: "pagedTotal" }] : /* istanbul ignore next */ []));
|
|
@@ -1138,10 +1204,14 @@ class MtStandardGridComponent {
|
|
|
1138
1204
|
chartTitle = computed(() => this.chartContext() ?? this.label(), ...(ngDevMode ? [{ debugName: "chartTitle" }] : /* istanbul ignore next */ []));
|
|
1139
1205
|
csvAllowed = computed(() => this.exportable() && this.exportFormats().includes('csv'), ...(ngDevMode ? [{ debugName: "csvAllowed" }] : /* istanbul ignore next */ []));
|
|
1140
1206
|
excelAllowed = computed(() => this.exportable() && this.exportFormats().includes('excel'), ...(ngDevMode ? [{ debugName: "excelAllowed" }] : /* istanbul ignore next */ []));
|
|
1141
|
-
statusBar = STATUS_BAR;
|
|
1142
1207
|
pageSizes = PAGE_SIZES;
|
|
1143
1208
|
fit = { type: 'fitGridWidth' };
|
|
1144
1209
|
api = null;
|
|
1210
|
+
grid = viewChild(MtDataGridComponent, ...(ngDevMode ? [{ debugName: "grid" }] : /* istanbul ignore next */ []));
|
|
1211
|
+
/** The grid's api: from gridReady, else straight from the grid (a click can come first). */
|
|
1212
|
+
gridApi() {
|
|
1213
|
+
return this.api ?? this.grid()?.api ?? null;
|
|
1214
|
+
}
|
|
1145
1215
|
identities = new WeakMap();
|
|
1146
1216
|
nextIdentity = 0;
|
|
1147
1217
|
identity(row) {
|
|
@@ -1171,9 +1241,77 @@ class MtStandardGridComponent {
|
|
|
1171
1241
|
return;
|
|
1172
1242
|
this.viewChanged.emit(captureGridViewState(this.api));
|
|
1173
1243
|
}
|
|
1244
|
+
onPaginationChanged(event) {
|
|
1245
|
+
this.paginationChanged.emit(event);
|
|
1246
|
+
// mt-table remembered the rows per page; the saved view carries it now.
|
|
1247
|
+
if (event.newPageSize)
|
|
1248
|
+
this.onViewChange();
|
|
1249
|
+
}
|
|
1250
|
+
/** The Export menu and the Export / Print buttons: the owner's exporter, else the grid's. */
|
|
1251
|
+
exportAs(format, api = this.gridApi()) {
|
|
1252
|
+
if (!api)
|
|
1253
|
+
return;
|
|
1254
|
+
const exporter = this.exporter();
|
|
1255
|
+
if (exporter) {
|
|
1256
|
+
exporter(format);
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
const controls = controlColumnIds(this.columns());
|
|
1260
|
+
if (format === 'pdf') {
|
|
1261
|
+
this.printService.printPdf(mtTablePrintConfiguration(api, this.leafColumns().filter((column) => !controls.has(column.colId ?? '')), this.exportName()));
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
const columnKeys = [
|
|
1265
|
+
...(api.getRowGroupColumns().length ? [AUTO_GROUP_COLUMN_ID] : []),
|
|
1266
|
+
...(api.getPivotResultColumns().length
|
|
1267
|
+
? api.getPivotResultColumns()
|
|
1268
|
+
: api
|
|
1269
|
+
.getColumnState()
|
|
1270
|
+
.filter((column) => !column.hide && !controls.has(column.colId))
|
|
1271
|
+
.map((column) => column.colId)),
|
|
1272
|
+
];
|
|
1273
|
+
if (format === 'csv')
|
|
1274
|
+
api.exportDataAsCsv({ ...this.exportParams(), columnKeys });
|
|
1275
|
+
else
|
|
1276
|
+
void api.exportDataAsExcel({ ...this.exportParams(), columnKeys });
|
|
1277
|
+
}
|
|
1174
1278
|
onRowClicked(event) {
|
|
1175
|
-
if (event.node.data
|
|
1176
|
-
|
|
1279
|
+
if (event.node.data === undefined)
|
|
1280
|
+
return;
|
|
1281
|
+
if (this.cellClickFilter() && this.filterByCell(event))
|
|
1282
|
+
return;
|
|
1283
|
+
this.rowClicked.emit(event.node.data);
|
|
1284
|
+
}
|
|
1285
|
+
/** Toggles a one-value set filter from the clicked cell; false when the cell does not filter. */
|
|
1286
|
+
filterByCell(event) {
|
|
1287
|
+
const column = event.colDef;
|
|
1288
|
+
const api = this.gridApi();
|
|
1289
|
+
// A column's id is its colId, else its field (the grid's own rule).
|
|
1290
|
+
const colId = column?.colId ?? column?.field;
|
|
1291
|
+
if (!api || !column || !colId || column.filter !== 'set')
|
|
1292
|
+
return false;
|
|
1293
|
+
const params = {
|
|
1294
|
+
data: event.node.data,
|
|
1295
|
+
rowIndex: event.node.sourceIndex,
|
|
1296
|
+
column,
|
|
1297
|
+
};
|
|
1298
|
+
const value = column.filterValueGetter
|
|
1299
|
+
? column.filterValueGetter(params)
|
|
1300
|
+
: column.valueGetter
|
|
1301
|
+
? column.valueGetter(params)
|
|
1302
|
+
: column.field
|
|
1303
|
+
? event.node.data[column.field]
|
|
1304
|
+
: undefined;
|
|
1305
|
+
if (value == null || value === '')
|
|
1306
|
+
return false;
|
|
1307
|
+
const keyCreator = column.filterParams?.keyCreator;
|
|
1308
|
+
const key = keyCreator ? keyCreator({ value }) : String(value);
|
|
1309
|
+
const current = api.getColumnFilterModel(colId);
|
|
1310
|
+
const active = current?.filterType === 'set' &&
|
|
1311
|
+
current.values.length === 1 &&
|
|
1312
|
+
current.values[0] === key;
|
|
1313
|
+
api.setColumnFilterModel(colId, active ? null : { filterType: 'set', values: [key] });
|
|
1314
|
+
return true;
|
|
1177
1315
|
}
|
|
1178
1316
|
onSelectionChanged(event) {
|
|
1179
1317
|
this.selectionChanged.emit(event.selectedNodes.flatMap((node) => node.data === undefined ? [] : [node.data]));
|
|
@@ -1186,16 +1324,6 @@ class MtStandardGridComponent {
|
|
|
1186
1324
|
}, ...(ngDevMode ? [{ debugName: "leafColumns" }] : /* istanbul ignore next */ []));
|
|
1187
1325
|
/** The standard context menu: default items, an Export submenu, then the page's row items. */
|
|
1188
1326
|
contextMenu = (params) => {
|
|
1189
|
-
const controls = controlColumnIds(this.columns());
|
|
1190
|
-
const columnKeys = [
|
|
1191
|
-
...(params.api.getRowGroupColumns().length ? [AUTO_GROUP_COLUMN_ID] : []),
|
|
1192
|
-
...(params.api.getPivotResultColumns().length
|
|
1193
|
-
? params.api.getPivotResultColumns()
|
|
1194
|
-
: params.api
|
|
1195
|
-
.getColumnState()
|
|
1196
|
-
.filter((column) => !column.hide && !controls.has(column.colId))
|
|
1197
|
-
.map((column) => column.colId)),
|
|
1198
|
-
];
|
|
1199
1327
|
const items = params.defaultItems.flatMap((item) => {
|
|
1200
1328
|
if (item === 'pdfExport')
|
|
1201
1329
|
return [];
|
|
@@ -1204,17 +1332,6 @@ class MtStandardGridComponent {
|
|
|
1204
1332
|
const formats = this.exportFormats();
|
|
1205
1333
|
if (!this.exportable() || formats.length === 0)
|
|
1206
1334
|
return [];
|
|
1207
|
-
const exporter = this.exporter();
|
|
1208
|
-
const clientExport = {
|
|
1209
|
-
csv: () => params.api.exportDataAsCsv({ ...this.exportParams(), columnKeys }),
|
|
1210
|
-
excel: () => {
|
|
1211
|
-
void params.api.exportDataAsExcel({
|
|
1212
|
-
...this.exportParams(),
|
|
1213
|
-
columnKeys,
|
|
1214
|
-
});
|
|
1215
|
-
},
|
|
1216
|
-
pdf: () => this.printService.printPdf(mtTablePrintConfiguration(params.api, this.leafColumns().filter((column) => !controls.has(column.colId ?? '')), this.exportName())),
|
|
1217
|
-
};
|
|
1218
1335
|
return [
|
|
1219
1336
|
{
|
|
1220
1337
|
name: this.text.text('export'),
|
|
@@ -1222,7 +1339,7 @@ class MtStandardGridComponent {
|
|
|
1222
1339
|
subMenu: formats.map((format) => ({
|
|
1223
1340
|
name: this.text.text(format),
|
|
1224
1341
|
icon: format,
|
|
1225
|
-
action:
|
|
1342
|
+
action: () => this.exportAs(format, params.api),
|
|
1226
1343
|
})),
|
|
1227
1344
|
},
|
|
1228
1345
|
];
|
|
@@ -1232,15 +1349,35 @@ class MtStandardGridComponent {
|
|
|
1232
1349
|
return rowItems.length ? [...items, 'separator', ...rowItems] : items;
|
|
1233
1350
|
};
|
|
1234
1351
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: MtStandardGridComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1235
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.8", type: MtStandardGridComponent, isStandalone: true, selector: "mt-standard-grid", inputs: { rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: true, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: true, transformFunction: null }, rowId: { classPropertyName: "rowId", publicName: "rowId", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, exportable: { classPropertyName: "exportable", publicName: "exportable", isSignal: true, isRequired: false, transformFunction: null }, exportName: { classPropertyName: "exportName", publicName: "exportName", isSignal: true, isRequired: false, transformFunction: null }, exportFormats: { classPropertyName: "exportFormats", publicName: "exportFormats", isSignal: true, isRequired: false, transformFunction: null }, exporter: { classPropertyName: "exporter", publicName: "exporter", isSignal: true, isRequired: false, transformFunction: null }, rowMenuItems: { classPropertyName: "rowMenuItems", publicName: "rowMenuItems", isSignal: true, isRequired: false, transformFunction: null }, server: { classPropertyName: "server", publicName: "server", isSignal: true, isRequired: false, transformFunction: null }, paged: { classPropertyName: "paged", publicName: "paged", isSignal: true, isRequired: false, transformFunction: null }, detail: { classPropertyName: "detail", publicName: "detail", isSignal: true, isRequired: false, transformFunction: null }, chartContext: { classPropertyName: "chartContext", publicName: "chartContext", isSignal: true, isRequired: false, transformFunction: null }, search: { classPropertyName: "search", publicName: "search", isSignal: true, isRequired: false, transformFunction: null }, emptyTitle: { classPropertyName: "emptyTitle", publicName: "emptyTitle", isSignal: true, isRequired: false, transformFunction: null }, emptyDescription: { classPropertyName: "emptyDescription", publicName: "emptyDescription", isSignal: true, isRequired: false, transformFunction: null }, view: { classPropertyName: "view", publicName: "view", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { gridReady: "gridReady", rowClicked: "rowClicked", selectionChanged: "selectionChanged", sortChanged: "sortChanged", filterChanged: "filterChanged", paginationChanged: "paginationChanged", rowGroupOpened: "rowGroupOpened", viewChanged: "viewChanged", chartsChanged: "chartsChanged" }, ngImport: i0, template: "<div class=\"mt-standard-grid\">\n <div class=\"mt-standard-grid-toolbar\">\n <ng-content select=\"[mtGridToolbar]\" />\n </div>\n <mt-data-grid\n [rowData]=\"rows()\"\n [columnDefs]=\"standardColumns()\"\n [getRowId]=\"rowId()\"\n [dataProcessing]=\"server() ? 'external' : 'client'\"\n [height]=\"gridHeight()\"\n [autoHeight]=\"height() === 'auto'\"\n [autoSizeStrategy]=\"fit\"\n [ariaLabel]=\"label()\"\n [loading]=\"loading()\"\n [direction]=\"direction()\"\n [localeText]=\"text.gridLocale()\"\n [showQuickFilter]=\"true\"\n [quickFilterText]=\"search()\"\n rowGroupPanelShow=\"always\"\n pivotPanelShow=\"onlyWhenPivoting\"\n [sideBar]=\"sideBar()\"\n [statusBar]=\"statusBar\"\n [rowSelection]=\"selectionOptions()\"\n [cellSelection]=\"true\"\n [enableCharts]=\"true\"\n [chartContext]=\"chartTitle()\"\n [chartRecordsLabel]=\"label()\"\n [animateRows]=\"true\"\n [suppressCutToClipboard]=\"true\"\n [suppressCsvExport]=\"!csvAllowed()\"\n [suppressExcelExport]=\"!excelAllowed()\"\n [suppressPdfExport]=\"true\"\n [defaultCsvExportParams]=\"exportParams()\"\n [defaultExcelExportParams]=\"exportParams()\"\n [getContextMenuItems]=\"contextMenu\"\n groupDisplayType=\"groupRows\"\n [groupMaintainOrder]=\"serverGroups()\"\n [autoGroupColumnDef]=\"autoGroupColumnDef()\"\n [groupDefaultExpanded]=\"-1\"\n [pagination]=\"paged()\"\n paginationPanelShow=\"whenNeeded\"\n [paginationPageSize]=\"pageSize()\"\n [paginationPageSizeSelector]=\"pageSizes\"\n [paginationTotalRows]=\"pagedTotal()\"\n [paginationCurrentPage]=\"pagedPage()\"\n [masterDetail]=\"detail() !== null\"\n [detailCellRenderer]=\"detailRenderer()\"\n [detailCellRendererParams]=\"detailParams()\"\n [detailRowAutoHeight]=\"true\"\n [isRowMaster]=\"isRowMaster()\"\n [noRowsTemplate]=\"emptyTitle() ? emptyState : undefined\"\n (gridReady)=\"onReady($event)\"\n (rowClicked)=\"onRowClicked($event)\"\n (selectionChanged)=\"onSelectionChanged($event)\"\n (sortChanged)=\"sortChanged.emit($event); onViewChange()\"\n (filterChanged)=\"filterChanged.emit($event); onViewChange()\"\n (paginationChanged)=\"paginationChanged.emit($event)\"\n (rowGroupOpened)=\"rowGroupOpened.emit($event)\"\n (chartCreated)=\"chartsChanged.emit()\"\n (chartDestroyed)=\"chartsChanged.emit()\"\n (chartOptionsChanged)=\"chartsChanged.emit()\"\n (columnRowGroupChanged)=\"onViewChange()\"\n (columnValueChanged)=\"onViewChange()\"\n (columnPivotChanged)=\"onViewChange()\"\n (columnPivotModeChanged)=\"onViewChange()\"\n (columnMoved)=\"onViewChange()\"\n (columnPinned)=\"onViewChange()\"\n (columnVisible)=\"onViewChange()\"\n (columnResized)=\"$event.finished && onViewChange()\"\n />\n</div>\n<ng-template #emptyState>\n <mt-empty-state\n [title]=\"emptyTitle() ?? ''\"\n [description]=\"emptyDescription() ?? ''\"\n />\n</ng-template>\n", styles: [":host{display:block}.mt-standard-grid{display:flex;flex-direction:column;gap:12px}.mt-standard-grid-toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px}.mt-standard-grid-toolbar:empty{display:none}\n"], dependencies: [{ kind: "component", type: MtDataGridComponent, selector: "mt-data-grid", inputs: ["rowData", "dataProcessing", "columnDefs", "getRowId", "height", "autoHeight", "autoHeightMaxRows", "autoHeightMinRows", "rowHeight", "animateRows", "headerHeight", "groupHeaderHeight", "direction", "localeText", "localeTextResolver", "ariaLabel", "loading", "noRowsText", "loadingText", "noRowsTemplate", "autoSizeStrategy", "columnMenu", "mainMenuItems", "autoSizePadding", "quickFilterText", "showQuickFilter", "includeHiddenColumnsInQuickFilter", "quickFilterParser", "quickFilterMatcher", "cacheQuickFilter", "applyQuickFilterBeforePivotOrAgg", "filtersToolPanelDef", "isExternalFilterPresent", "doesExternalFilterPass", "floatingFiltersHeight", "rowSelection", "selectionColumnDef", "rowNumbers", "rowDragManaged", "rowDragEntireRow", "rowDragMultiRow", "suppressMoveWhenRowDragging", "cellSelection", "statusBar", "suppressContextMenu", "allowContextMenuWithControlKey", "preventDefaultOnContextMenu", "getContextMenuItems", "suppressCsvExport", "suppressExcelExport", "suppressPdfExport", "defaultPdfExportParams", "excelStyles", "processCellForClipboard", "processHeaderForClipboard", "processGroupHeaderForClipboard", "copySelectedRows", "copyHeadersToClipboard", "copyGroupHeadersToClipboard", "clipboardDelimiter", "suppressCopyRowsToClipboard", "suppressCopySingleCellRanges", "suppressCutToClipboard", "defaultCsvExportParams", "defaultExcelExportParams", "groupDisplayType", "groupRowRenderer", "groupRowRendererParams", "suppressGroupRowsSticky", "groupHideOpenParents", "groupHideParentOfSingleChild", "groupRemoveSingleChildren", "groupRemoveLowestSingleChildren", "showOpenedGroup", "groupAggFiltering", "suppressAggFilteredOnly", "aggregateOnlyChangedColumns", "suppressColumnMoveAnimation", "pivotRowTotals", "pivotColumnGroupTotals", "pivotMaxGeneratedColumns", "pivotDefaultExpanded", "pivotSuppressAutoColumn", "suppressExpandablePivotGroups", "processPivotResultColDef", "processPivotResultColGroupDef", "processUnpinnedColumns", "rowGroupPanelShow", "pivotPanelShow", "pivotPanelHint", "groupDefaultExpanded", "autoGroupColumnDef", "groupTotalRow", "grandTotalRow", "aggFuncs", "suppressRowGroupHidesColumns", "suppressMakeColumnVisibleAfterUnGroup", "sideBar", "pivotMode", "suppressAggFuncInHeader", "enableCharts", "chartThemes", "customChartThemes", "chartToolPanelsDef", "chartThemeOverrides", "chartContext", "chartRecordsLabel", "getChartToolbarItems", "groupMaintainOrder", "treeData", "getDataPath", "masterDetail", "isRowMaster", "detailCellRenderer", "detailCellRendererParams", "detailRowHeight", "detailRowAutoHeight", "singleClickEdit", "suppressClickEdit", "stopEditingWhenCellsLoseFocus", "undoRedoCellEditing", "undoRedoCellEditingLimit", "pagination", "paginationPanelShow", "paginationPageSize", "paginationTotalRows", "paginationCurrentPage", "paginationPageSizeSelector", "rowGroupPanelSuppressSort"], outputs: ["displayedColumnsChanged", "columnEverythingChanged", "pivotMaxColumnsExceeded", "gridReady", "sortChanged", "cellFocused", "columnResized", "columnMoved", "columnPinned", "columnVisible", "columnGroupOpened", "filterChanged", "filterModified", "filterOpened", "rowSelected", "selectionChanged", "rowClicked", "rowDragEnter", "rowDragMove", "rowDragLeave", "rowDragEnd", "cellSelectionChanged", "contextMenuVisibleChanged", "rowGroupOpened", "columnRowGroupChanged", "expandOrCollapseAll", "cellEditingStarted", "cellEditingStopped", "cellValueChanged", "pasteStart", "pasteEnd", "fillStart", "fillEnd", "paginationChanged", "toolPanelVisibleChanged", "toolPanelSizeChanged", "columnValueChanged", "columnPivotChanged", "columnPivotModeChanged", "chartCreated", "chartDestroyed", "chartRangeSelectionChanged", "chartOptionsChanged"] }, { kind: "component", type: EmptyState, selector: "mt-empty-state", inputs: ["variant", "illustration", "title", "description", "actionLabel", "actionIcon"], outputs: ["actionClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1352
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: MtStandardGridComponent, isStandalone: true, selector: "mt-standard-grid", inputs: { rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: true, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: true, transformFunction: null }, rowId: { classPropertyName: "rowId", publicName: "rowId", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, rowHeight: { classPropertyName: "rowHeight", publicName: "rowHeight", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, exportable: { classPropertyName: "exportable", publicName: "exportable", isSignal: true, isRequired: false, transformFunction: null }, exportButtons: { classPropertyName: "exportButtons", publicName: "exportButtons", isSignal: true, isRequired: false, transformFunction: null }, exportName: { classPropertyName: "exportName", publicName: "exportName", isSignal: true, isRequired: false, transformFunction: null }, exportFormats: { classPropertyName: "exportFormats", publicName: "exportFormats", isSignal: true, isRequired: false, transformFunction: null }, exporter: { classPropertyName: "exporter", publicName: "exporter", isSignal: true, isRequired: false, transformFunction: null }, rowMenuItems: { classPropertyName: "rowMenuItems", publicName: "rowMenuItems", isSignal: true, isRequired: false, transformFunction: null }, server: { classPropertyName: "server", publicName: "server", isSignal: true, isRequired: false, transformFunction: null }, paged: { classPropertyName: "paged", publicName: "paged", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, clickableRows: { classPropertyName: "clickableRows", publicName: "clickableRows", isSignal: true, isRequired: false, transformFunction: null }, cellClickFilter: { classPropertyName: "cellClickFilter", publicName: "cellClickFilter", isSignal: true, isRequired: false, transformFunction: null }, rowClass: { classPropertyName: "rowClass", publicName: "rowClass", isSignal: true, isRequired: false, transformFunction: null }, detail: { classPropertyName: "detail", publicName: "detail", isSignal: true, isRequired: false, transformFunction: null }, chartContext: { classPropertyName: "chartContext", publicName: "chartContext", isSignal: true, isRequired: false, transformFunction: null }, search: { classPropertyName: "search", publicName: "search", isSignal: true, isRequired: false, transformFunction: null }, emptyTitle: { classPropertyName: "emptyTitle", publicName: "emptyTitle", isSignal: true, isRequired: false, transformFunction: null }, emptyDescription: { classPropertyName: "emptyDescription", publicName: "emptyDescription", isSignal: true, isRequired: false, transformFunction: null }, view: { classPropertyName: "view", publicName: "view", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { gridReady: "gridReady", rowClicked: "rowClicked", selectionChanged: "selectionChanged", sortChanged: "sortChanged", filterChanged: "filterChanged", paginationChanged: "paginationChanged", rowGroupOpened: "rowGroupOpened", viewChanged: "viewChanged", chartsChanged: "chartsChanged" }, viewQueries: [{ propertyName: "grid", first: true, predicate: MtDataGridComponent, descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"mt-standard-grid\">\n <div class=\"mt-standard-grid-toolbar\">\n <ng-content select=\"[mtGridToolbar]\" />\n @if (excelButton() || printButton()) {\n <mt-table-actions-menu\n class=\"mt-standard-grid-export\"\n [exportable]=\"excelButton()\"\n [printable]=\"printButton()\"\n (exportRequested)=\"exportAs('excel')\"\n (printRequested)=\"exportAs('pdf')\"\n />\n }\n </div>\n <mt-data-grid\n [rowData]=\"rows()\"\n [columnDefs]=\"standardColumns()\"\n [getRowId]=\"rowId()\"\n [dataProcessing]=\"server() ? 'external' : 'client'\"\n [height]=\"gridHeight()\"\n [rowHeight]=\"rowHeight()\"\n [autoHeight]=\"height() === 'auto'\"\n [autoSizeStrategy]=\"fit\"\n [ariaLabel]=\"label()\"\n [loading]=\"loading()\"\n [direction]=\"direction()\"\n [localeText]=\"text.gridLocale()\"\n [showQuickFilter]=\"true\"\n [quickFilterText]=\"search()\"\n rowGroupPanelShow=\"always\"\n pivotPanelShow=\"onlyWhenPivoting\"\n [sideBar]=\"sideBar()\"\n [statusBar]=\"gridStatusBar()\"\n [getRowClass]=\"gridRowClass()\"\n [rowSelection]=\"selectionOptions()\"\n [cellSelection]=\"true\"\n [enableCharts]=\"true\"\n [chartContext]=\"chartTitle()\"\n [chartRecordsLabel]=\"label()\"\n [animateRows]=\"true\"\n [suppressCutToClipboard]=\"true\"\n [suppressCsvExport]=\"!csvAllowed()\"\n [suppressExcelExport]=\"!excelAllowed()\"\n [suppressPdfExport]=\"true\"\n [defaultCsvExportParams]=\"exportParams()\"\n [defaultExcelExportParams]=\"exportParams()\"\n [getContextMenuItems]=\"contextMenu\"\n groupDisplayType=\"groupRows\"\n [groupMaintainOrder]=\"true\"\n [autoGroupColumnDef]=\"autoGroupColumnDef()\"\n [groupDefaultExpanded]=\"-1\"\n [pagination]=\"paged()\"\n paginationPanelShow=\"whenNeeded\"\n [paginationPageSize]=\"gridPageSize()\"\n [paginationPageSizeSelector]=\"pageSizes\"\n [paginationTotalRows]=\"pagedTotal()\"\n [paginationCurrentPage]=\"pagedPage()\"\n [masterDetail]=\"detail() !== null\"\n [detailCellRenderer]=\"detailRenderer()\"\n [detailCellRendererParams]=\"detailParams()\"\n [detailRowAutoHeight]=\"true\"\n [isRowMaster]=\"isRowMaster()\"\n [noRowsTemplate]=\"emptyTitle() ? emptyState : undefined\"\n (gridReady)=\"onReady($event)\"\n (rowClicked)=\"onRowClicked($event)\"\n (selectionChanged)=\"onSelectionChanged($event)\"\n (sortChanged)=\"sortChanged.emit($event); onViewChange()\"\n (filterChanged)=\"filterChanged.emit($event); onViewChange()\"\n (paginationChanged)=\"onPaginationChanged($event)\"\n (rowGroupOpened)=\"rowGroupOpened.emit($event)\"\n (chartCreated)=\"chartsChanged.emit()\"\n (chartDestroyed)=\"chartsChanged.emit()\"\n (chartOptionsChanged)=\"chartsChanged.emit()\"\n (columnRowGroupChanged)=\"onViewChange()\"\n (columnValueChanged)=\"onViewChange()\"\n (columnPivotChanged)=\"onViewChange()\"\n (columnPivotModeChanged)=\"onViewChange()\"\n (columnMoved)=\"onViewChange()\"\n (columnPinned)=\"onViewChange()\"\n (columnVisible)=\"onViewChange()\"\n (columnResized)=\"$event.finished && onViewChange()\"\n />\n</div>\n<ng-template #emptyState>\n <mt-empty-state\n [title]=\"emptyTitle() ?? ''\"\n [description]=\"emptyDescription() ?? ''\"\n />\n</ng-template>\n", styles: [":host{display:block}.mt-standard-grid{display:flex;flex-direction:column;gap:12px}.mt-standard-grid-toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px}.mt-standard-grid-toolbar:empty{display:none}.mt-standard-grid-export{margin-inline-start:auto}:host ::ng-deep .mt-standard-grid-row-clickable{cursor:pointer}\n"], dependencies: [{ kind: "component", type: MtDataGridComponent, selector: "mt-data-grid", inputs: ["rowData", "dataProcessing", "columnDefs", "getRowId", "height", "autoHeight", "autoHeightMaxRows", "autoHeightMinRows", "rowHeight", "getRowClass", "animateRows", "headerHeight", "groupHeaderHeight", "direction", "localeText", "localeTextResolver", "ariaLabel", "loading", "noRowsText", "loadingText", "noRowsTemplate", "autoSizeStrategy", "columnMenu", "mainMenuItems", "autoSizePadding", "quickFilterText", "showQuickFilter", "includeHiddenColumnsInQuickFilter", "quickFilterParser", "quickFilterMatcher", "cacheQuickFilter", "applyQuickFilterBeforePivotOrAgg", "filtersToolPanelDef", "isExternalFilterPresent", "doesExternalFilterPass", "floatingFiltersHeight", "rowSelection", "selectionColumnDef", "rowNumbers", "rowDragManaged", "rowDragEntireRow", "rowDragMultiRow", "suppressMoveWhenRowDragging", "cellSelection", "statusBar", "suppressContextMenu", "allowContextMenuWithControlKey", "preventDefaultOnContextMenu", "getContextMenuItems", "suppressCsvExport", "suppressExcelExport", "suppressPdfExport", "defaultPdfExportParams", "excelStyles", "processCellForClipboard", "processHeaderForClipboard", "processGroupHeaderForClipboard", "copySelectedRows", "copyHeadersToClipboard", "copyGroupHeadersToClipboard", "clipboardDelimiter", "suppressCopyRowsToClipboard", "suppressCopySingleCellRanges", "suppressCutToClipboard", "defaultCsvExportParams", "defaultExcelExportParams", "groupDisplayType", "groupRowRenderer", "groupRowRendererParams", "suppressGroupRowsSticky", "groupHideOpenParents", "groupHideParentOfSingleChild", "groupRemoveSingleChildren", "groupRemoveLowestSingleChildren", "showOpenedGroup", "groupAggFiltering", "suppressAggFilteredOnly", "aggregateOnlyChangedColumns", "suppressColumnMoveAnimation", "pivotRowTotals", "pivotColumnGroupTotals", "pivotMaxGeneratedColumns", "pivotDefaultExpanded", "pivotSuppressAutoColumn", "suppressExpandablePivotGroups", "processPivotResultColDef", "processPivotResultColGroupDef", "processUnpinnedColumns", "rowGroupPanelShow", "pivotPanelShow", "pivotPanelHint", "groupDefaultExpanded", "autoGroupColumnDef", "groupTotalRow", "grandTotalRow", "aggFuncs", "suppressRowGroupHidesColumns", "suppressMakeColumnVisibleAfterUnGroup", "sideBar", "pivotMode", "suppressAggFuncInHeader", "enableCharts", "chartThemes", "customChartThemes", "chartToolPanelsDef", "chartThemeOverrides", "chartContext", "chartRecordsLabel", "getChartToolbarItems", "groupMaintainOrder", "treeData", "getDataPath", "masterDetail", "isRowMaster", "detailCellRenderer", "detailCellRendererParams", "detailRowHeight", "detailRowAutoHeight", "singleClickEdit", "suppressClickEdit", "stopEditingWhenCellsLoseFocus", "undoRedoCellEditing", "undoRedoCellEditingLimit", "pagination", "paginationPanelShow", "paginationPageSize", "paginationTotalRows", "paginationCurrentPage", "paginationPageSizeSelector", "rowGroupPanelSuppressSort"], outputs: ["displayedColumnsChanged", "columnEverythingChanged", "pivotMaxColumnsExceeded", "gridReady", "sortChanged", "cellFocused", "columnResized", "columnMoved", "columnPinned", "columnVisible", "columnGroupOpened", "filterChanged", "filterModified", "filterOpened", "rowSelected", "selectionChanged", "rowClicked", "rowDragEnter", "rowDragMove", "rowDragLeave", "rowDragEnd", "cellSelectionChanged", "contextMenuVisibleChanged", "rowGroupOpened", "columnRowGroupChanged", "expandOrCollapseAll", "cellEditingStarted", "cellEditingStopped", "cellValueChanged", "pasteStart", "pasteEnd", "fillStart", "fillEnd", "paginationChanged", "toolPanelVisibleChanged", "toolPanelSizeChanged", "columnValueChanged", "columnPivotChanged", "columnPivotModeChanged", "chartCreated", "chartDestroyed", "chartRangeSelectionChanged", "chartOptionsChanged"] }, { kind: "component", type: EmptyState, selector: "mt-empty-state", inputs: ["variant", "illustration", "title", "description", "actionLabel", "actionIcon"], outputs: ["actionClick"] }, { kind: "component", type: TableActionsMenu, selector: "mt-table-actions-menu", inputs: ["exportable", "printable", "groupable", "groupColumns", "activeGroup"], outputs: ["exportRequested", "printRequested", "groupChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1236
1353
|
}
|
|
1237
1354
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: MtStandardGridComponent, decorators: [{
|
|
1238
1355
|
type: Component,
|
|
1239
|
-
args: [{ selector: 'mt-standard-grid', imports: [MtDataGridComponent, EmptyState], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mt-standard-grid\">\n <div class=\"mt-standard-grid-toolbar\">\n <ng-content select=\"[mtGridToolbar]\" />\n </div>\n <mt-data-grid\n [rowData]=\"rows()\"\n [columnDefs]=\"standardColumns()\"\n [getRowId]=\"rowId()\"\n [dataProcessing]=\"server() ? 'external' : 'client'\"\n [height]=\"gridHeight()\"\n [autoHeight]=\"height() === 'auto'\"\n [autoSizeStrategy]=\"fit\"\n [ariaLabel]=\"label()\"\n [loading]=\"loading()\"\n [direction]=\"direction()\"\n [localeText]=\"text.gridLocale()\"\n [showQuickFilter]=\"true\"\n [quickFilterText]=\"search()\"\n rowGroupPanelShow=\"always\"\n pivotPanelShow=\"onlyWhenPivoting\"\n [sideBar]=\"sideBar()\"\n [statusBar]=\"
|
|
1240
|
-
}], propDecorators: { rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: true }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: true }] }], rowId: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowId", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }], exportable: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportable", required: false }] }], exportName: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportName", required: false }] }], exportFormats: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportFormats", required: false }] }], exporter: [{ type: i0.Input, args: [{ isSignal: true, alias: "exporter", required: false }] }], rowMenuItems: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowMenuItems", required: false }] }], server: [{ type: i0.Input, args: [{ isSignal: true, alias: "server", required: false }] }], paged: [{ type: i0.Input, args: [{ isSignal: true, alias: "paged", required: false }] }], detail: [{ type: i0.Input, args: [{ isSignal: true, alias: "detail", required: false }] }], chartContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "chartContext", required: false }] }], search: [{ type: i0.Input, args: [{ isSignal: true, alias: "search", required: false }] }], emptyTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyTitle", required: false }] }], emptyDescription: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyDescription", required: false }] }], view: [{ type: i0.Input, args: [{ isSignal: true, alias: "view", required: false }] }], gridReady: [{ type: i0.Output, args: ["gridReady"] }], rowClicked: [{ type: i0.Output, args: ["rowClicked"] }], selectionChanged: [{ type: i0.Output, args: ["selectionChanged"] }], sortChanged: [{ type: i0.Output, args: ["sortChanged"] }], filterChanged: [{ type: i0.Output, args: ["filterChanged"] }], paginationChanged: [{ type: i0.Output, args: ["paginationChanged"] }], rowGroupOpened: [{ type: i0.Output, args: ["rowGroupOpened"] }], viewChanged: [{ type: i0.Output, args: ["viewChanged"] }], chartsChanged: [{ type: i0.Output, args: ["chartsChanged"] }] } });
|
|
1356
|
+
args: [{ selector: 'mt-standard-grid', imports: [MtDataGridComponent, EmptyState, TableActionsMenu], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mt-standard-grid\">\n <div class=\"mt-standard-grid-toolbar\">\n <ng-content select=\"[mtGridToolbar]\" />\n @if (excelButton() || printButton()) {\n <mt-table-actions-menu\n class=\"mt-standard-grid-export\"\n [exportable]=\"excelButton()\"\n [printable]=\"printButton()\"\n (exportRequested)=\"exportAs('excel')\"\n (printRequested)=\"exportAs('pdf')\"\n />\n }\n </div>\n <mt-data-grid\n [rowData]=\"rows()\"\n [columnDefs]=\"standardColumns()\"\n [getRowId]=\"rowId()\"\n [dataProcessing]=\"server() ? 'external' : 'client'\"\n [height]=\"gridHeight()\"\n [rowHeight]=\"rowHeight()\"\n [autoHeight]=\"height() === 'auto'\"\n [autoSizeStrategy]=\"fit\"\n [ariaLabel]=\"label()\"\n [loading]=\"loading()\"\n [direction]=\"direction()\"\n [localeText]=\"text.gridLocale()\"\n [showQuickFilter]=\"true\"\n [quickFilterText]=\"search()\"\n rowGroupPanelShow=\"always\"\n pivotPanelShow=\"onlyWhenPivoting\"\n [sideBar]=\"sideBar()\"\n [statusBar]=\"gridStatusBar()\"\n [getRowClass]=\"gridRowClass()\"\n [rowSelection]=\"selectionOptions()\"\n [cellSelection]=\"true\"\n [enableCharts]=\"true\"\n [chartContext]=\"chartTitle()\"\n [chartRecordsLabel]=\"label()\"\n [animateRows]=\"true\"\n [suppressCutToClipboard]=\"true\"\n [suppressCsvExport]=\"!csvAllowed()\"\n [suppressExcelExport]=\"!excelAllowed()\"\n [suppressPdfExport]=\"true\"\n [defaultCsvExportParams]=\"exportParams()\"\n [defaultExcelExportParams]=\"exportParams()\"\n [getContextMenuItems]=\"contextMenu\"\n groupDisplayType=\"groupRows\"\n [groupMaintainOrder]=\"true\"\n [autoGroupColumnDef]=\"autoGroupColumnDef()\"\n [groupDefaultExpanded]=\"-1\"\n [pagination]=\"paged()\"\n paginationPanelShow=\"whenNeeded\"\n [paginationPageSize]=\"gridPageSize()\"\n [paginationPageSizeSelector]=\"pageSizes\"\n [paginationTotalRows]=\"pagedTotal()\"\n [paginationCurrentPage]=\"pagedPage()\"\n [masterDetail]=\"detail() !== null\"\n [detailCellRenderer]=\"detailRenderer()\"\n [detailCellRendererParams]=\"detailParams()\"\n [detailRowAutoHeight]=\"true\"\n [isRowMaster]=\"isRowMaster()\"\n [noRowsTemplate]=\"emptyTitle() ? emptyState : undefined\"\n (gridReady)=\"onReady($event)\"\n (rowClicked)=\"onRowClicked($event)\"\n (selectionChanged)=\"onSelectionChanged($event)\"\n (sortChanged)=\"sortChanged.emit($event); onViewChange()\"\n (filterChanged)=\"filterChanged.emit($event); onViewChange()\"\n (paginationChanged)=\"onPaginationChanged($event)\"\n (rowGroupOpened)=\"rowGroupOpened.emit($event)\"\n (chartCreated)=\"chartsChanged.emit()\"\n (chartDestroyed)=\"chartsChanged.emit()\"\n (chartOptionsChanged)=\"chartsChanged.emit()\"\n (columnRowGroupChanged)=\"onViewChange()\"\n (columnValueChanged)=\"onViewChange()\"\n (columnPivotChanged)=\"onViewChange()\"\n (columnPivotModeChanged)=\"onViewChange()\"\n (columnMoved)=\"onViewChange()\"\n (columnPinned)=\"onViewChange()\"\n (columnVisible)=\"onViewChange()\"\n (columnResized)=\"$event.finished && onViewChange()\"\n />\n</div>\n<ng-template #emptyState>\n <mt-empty-state\n [title]=\"emptyTitle() ?? ''\"\n [description]=\"emptyDescription() ?? ''\"\n />\n</ng-template>\n", styles: [":host{display:block}.mt-standard-grid{display:flex;flex-direction:column;gap:12px}.mt-standard-grid-toolbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px}.mt-standard-grid-toolbar:empty{display:none}.mt-standard-grid-export{margin-inline-start:auto}:host ::ng-deep .mt-standard-grid-row-clickable{cursor:pointer}\n"] }]
|
|
1357
|
+
}], propDecorators: { rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: true }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: true }] }], rowId: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowId", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], rowHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowHeight", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }], exportable: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportable", required: false }] }], exportButtons: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportButtons", required: false }] }], exportName: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportName", required: false }] }], exportFormats: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportFormats", required: false }] }], exporter: [{ type: i0.Input, args: [{ isSignal: true, alias: "exporter", required: false }] }], rowMenuItems: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowMenuItems", required: false }] }], server: [{ type: i0.Input, args: [{ isSignal: true, alias: "server", required: false }] }], paged: [{ type: i0.Input, args: [{ isSignal: true, alias: "paged", required: false }] }], pageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSize", required: false }] }], clickableRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "clickableRows", required: false }] }], cellClickFilter: [{ type: i0.Input, args: [{ isSignal: true, alias: "cellClickFilter", required: false }] }], rowClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "rowClass", required: false }] }], detail: [{ type: i0.Input, args: [{ isSignal: true, alias: "detail", required: false }] }], chartContext: [{ type: i0.Input, args: [{ isSignal: true, alias: "chartContext", required: false }] }], search: [{ type: i0.Input, args: [{ isSignal: true, alias: "search", required: false }] }], emptyTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyTitle", required: false }] }], emptyDescription: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyDescription", required: false }] }], view: [{ type: i0.Input, args: [{ isSignal: true, alias: "view", required: false }] }], gridReady: [{ type: i0.Output, args: ["gridReady"] }], rowClicked: [{ type: i0.Output, args: ["rowClicked"] }], selectionChanged: [{ type: i0.Output, args: ["selectionChanged"] }], sortChanged: [{ type: i0.Output, args: ["sortChanged"] }], filterChanged: [{ type: i0.Output, args: ["filterChanged"] }], paginationChanged: [{ type: i0.Output, args: ["paginationChanged"] }], rowGroupOpened: [{ type: i0.Output, args: ["rowGroupOpened"] }], viewChanged: [{ type: i0.Output, args: ["viewChanged"] }], chartsChanged: [{ type: i0.Output, args: ["chartsChanged"] }], grid: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MtDataGridComponent), { isSignal: true }] }] } });
|
|
1241
1358
|
|
|
1242
1359
|
/** The standard row-actions column id. */
|
|
1243
1360
|
const MT_ACTIONS_COLUMN_ID = '$actions';
|
|
1361
|
+
/** Deleting, or anything the page flagged `danger` (mt-table's rule). */
|
|
1362
|
+
function isDestructive(action) {
|
|
1363
|
+
return (!!action &&
|
|
1364
|
+
(action.color === 'danger' ||
|
|
1365
|
+
action.confirmation?.confirmationType === 'delete'));
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Width that fits the inline buttons (mt-table sized the column to its content): small
|
|
1369
|
+
* buttons are 32px with a 4px gap, a labelled one adds roughly its text, plus the padding.
|
|
1370
|
+
*/
|
|
1371
|
+
function actionsWidth(actions, shape, lazy) {
|
|
1372
|
+
const inline = shape === 'popover'
|
|
1373
|
+
? actions.filter((action) => action.placement === 'inline')
|
|
1374
|
+
: actions;
|
|
1375
|
+
const menu = shape === 'popover' &&
|
|
1376
|
+
(lazy || actions.some((action) => action.placement !== 'inline'));
|
|
1377
|
+
const buttons = inline.length + (menu ? 1 : 0);
|
|
1378
|
+
const labels = inline.reduce((sum, action) => sum + (action.label ? action.label.length * 7 + 8 : 0), 0);
|
|
1379
|
+
return Math.min(320, Math.max(120, 24 + buttons * 32 + Math.max(0, buttons - 1) * 4 + labels));
|
|
1380
|
+
}
|
|
1244
1381
|
/**
|
|
1245
1382
|
* The standard row-actions cell: inline buttons, or a ⋮ menu for `shape: 'popover'`, with the
|
|
1246
1383
|
* action's confirmation popup. The page owns the operations; the grid only hosts the cell.
|
|
@@ -1256,7 +1393,22 @@ class MtActionsCell {
|
|
|
1256
1393
|
: [];
|
|
1257
1394
|
}, ...(ngDevMode ? [{ debugName: "actions" }] : /* istanbul ignore next */ []));
|
|
1258
1395
|
inline = computed(() => this.actions().filter((action) => this.params()['shape'] !== 'popover' || action.placement === 'inline'), ...(ngDevMode ? [{ debugName: "inline" }] : /* istanbul ignore next */ []));
|
|
1259
|
-
|
|
1396
|
+
/**
|
|
1397
|
+
* The ⋮ menu, destructive actions last behind a divider, as in mt-table: colour alone is no
|
|
1398
|
+
* separation for an irreversible item. Order within each group is the page's.
|
|
1399
|
+
*/
|
|
1400
|
+
menu = computed(() => {
|
|
1401
|
+
const menu = this.actions().filter((action) => this.params()['shape'] === 'popover' && action.placement !== 'inline');
|
|
1402
|
+
return [
|
|
1403
|
+
...menu.filter((action) => !isDestructive(action)),
|
|
1404
|
+
...menu.filter(isDestructive),
|
|
1405
|
+
];
|
|
1406
|
+
}, ...(ngDevMode ? [{ debugName: "menu" }] : /* istanbul ignore next */ []));
|
|
1407
|
+
/** The divider goes above the first destructive item, never at the top of the menu. */
|
|
1408
|
+
firstDestructive(index) {
|
|
1409
|
+
const menu = this.menu();
|
|
1410
|
+
return (index > 0 && isDestructive(menu[index]) && !isDestructive(menu[index - 1]));
|
|
1411
|
+
}
|
|
1260
1412
|
hasMenu = computed(() => !this.params().node.group &&
|
|
1261
1413
|
!this.params().node.footer &&
|
|
1262
1414
|
this.params()['shape'] === 'popover' &&
|
|
@@ -1292,24 +1444,25 @@ class MtActionsCell {
|
|
|
1292
1444
|
this.confirmation.confirm(config);
|
|
1293
1445
|
}
|
|
1294
1446
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: MtActionsCell, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1295
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: MtActionsCell, isStandalone: true, selector: "mt-actions-cell", inputs: { params: { classPropertyName: "params", publicName: "params", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "click": "$event.stopPropagation()", "pointerdown": "$event.stopPropagation()" } }, ngImport: i0, template: "@for (action of inline(); track $index) {\n <mt-button\n [icon]=\"action.icon\"\n [label]=\"action.label\"\n [ariaLabel]=\"action.tooltip || action.label || label()\"\n [tooltip]=\"action.tooltip\"\n [severity]=\"action.color || 'secondary'\"\n [variant]=\"action.variant || 'text'\"\n size=\"small\"\n [loading]=\"busy(action)\"\n (click)=\"run(action, $event)\"\n />\n}\n@if (hasMenu()) {\n <mt-button\n icon=\"general.dots-vertical\"\n severity=\"secondary\"\n variant=\"text\"\n size=\"small\"\n [ariaLabel]=\"label()\"\n (click)=\"open($event, popover)\"\n />\n <p-popover #popover appendTo=\"body\">\n <div class=\"flex min-w-40 flex-col gap-1\" [attr.aria-label]=\"label()\">\n @if (loading()) {\n <
|
|
1447
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: MtActionsCell, isStandalone: true, selector: "mt-actions-cell", inputs: { params: { classPropertyName: "params", publicName: "params", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "click": "$event.stopPropagation()", "pointerdown": "$event.stopPropagation()" } }, ngImport: i0, template: "@for (action of inline(); track $index) {\n <mt-button\n [icon]=\"action.icon\"\n [label]=\"action.label\"\n [ariaLabel]=\"action.tooltip || action.label || label()\"\n [tooltip]=\"action.tooltip\"\n [severity]=\"action.color || 'secondary'\"\n [variant]=\"action.variant || 'text'\"\n size=\"small\"\n [loading]=\"busy(action)\"\n (click)=\"run(action, $event)\"\n />\n}\n@if (hasMenu()) {\n <mt-button\n icon=\"general.dots-vertical\"\n severity=\"secondary\"\n variant=\"text\"\n size=\"small\"\n [ariaLabel]=\"label()\"\n (click)=\"open($event, popover)\"\n />\n <p-popover #popover appendTo=\"body\">\n <div class=\"flex min-w-40 flex-col gap-1\" [attr.aria-label]=\"label()\">\n @if (loading()) {\n <div\n role=\"status\"\n class=\"flex flex-col gap-2 p-2\"\n [attr.aria-label]=\"params()['loadingLabel']\"\n >\n <p-skeleton height=\"1.5rem\" />\n <p-skeleton height=\"1.5rem\" />\n <p-skeleton height=\"1.5rem\" />\n </div>\n } @else {\n @for (action of menu(); track $index) {\n @if (firstDestructive($index)) {\n <hr\n class=\"my-1 border-0 border-t border-surface-200 dark:border-surface-700\"\n />\n }\n <mt-button\n [icon]=\"action.icon\"\n [label]=\"action.label || action.tooltip\"\n [severity]=\"action.color || 'secondary'\"\n variant=\"text\"\n size=\"small\"\n [loading]=\"busy(action)\"\n (click)=\"run(action, $event); popover.hide()\"\n />\n }\n }\n </div>\n </p-popover>\n}\n", styles: [":host{display:flex;align-items:center;justify-content:center;gap:4px;height:100%}\n"], dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Popover, selector: "p-popover", inputs: ["ariaLabel", "ariaLabelledBy", "dismissable", "style", "styleClass", "appendTo", "autoZIndex", "ariaCloseLabel", "baseZIndex", "focusOnShow", "showTransitionOptions", "hideTransitionOptions", "motionOptions"], outputs: ["onShow", "onHide"] }, { kind: "component", type: Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1296
1448
|
}
|
|
1297
1449
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: MtActionsCell, decorators: [{
|
|
1298
1450
|
type: Component,
|
|
1299
|
-
args: [{ selector: 'mt-actions-cell', imports: [Button, Popover], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1451
|
+
args: [{ selector: 'mt-actions-cell', imports: [Button, Popover, Skeleton], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1300
1452
|
'(click)': '$event.stopPropagation()',
|
|
1301
1453
|
'(pointerdown)': '$event.stopPropagation()',
|
|
1302
|
-
}, template: "@for (action of inline(); track $index) {\n <mt-button\n [icon]=\"action.icon\"\n [label]=\"action.label\"\n [ariaLabel]=\"action.tooltip || action.label || label()\"\n [tooltip]=\"action.tooltip\"\n [severity]=\"action.color || 'secondary'\"\n [variant]=\"action.variant || 'text'\"\n size=\"small\"\n [loading]=\"busy(action)\"\n (click)=\"run(action, $event)\"\n />\n}\n@if (hasMenu()) {\n <mt-button\n icon=\"general.dots-vertical\"\n severity=\"secondary\"\n variant=\"text\"\n size=\"small\"\n [ariaLabel]=\"label()\"\n (click)=\"open($event, popover)\"\n />\n <p-popover #popover appendTo=\"body\">\n <div class=\"flex min-w-40 flex-col gap-1\" [attr.aria-label]=\"label()\">\n @if (loading()) {\n <
|
|
1454
|
+
}, template: "@for (action of inline(); track $index) {\n <mt-button\n [icon]=\"action.icon\"\n [label]=\"action.label\"\n [ariaLabel]=\"action.tooltip || action.label || label()\"\n [tooltip]=\"action.tooltip\"\n [severity]=\"action.color || 'secondary'\"\n [variant]=\"action.variant || 'text'\"\n size=\"small\"\n [loading]=\"busy(action)\"\n (click)=\"run(action, $event)\"\n />\n}\n@if (hasMenu()) {\n <mt-button\n icon=\"general.dots-vertical\"\n severity=\"secondary\"\n variant=\"text\"\n size=\"small\"\n [ariaLabel]=\"label()\"\n (click)=\"open($event, popover)\"\n />\n <p-popover #popover appendTo=\"body\">\n <div class=\"flex min-w-40 flex-col gap-1\" [attr.aria-label]=\"label()\">\n @if (loading()) {\n <div\n role=\"status\"\n class=\"flex flex-col gap-2 p-2\"\n [attr.aria-label]=\"params()['loadingLabel']\"\n >\n <p-skeleton height=\"1.5rem\" />\n <p-skeleton height=\"1.5rem\" />\n <p-skeleton height=\"1.5rem\" />\n </div>\n } @else {\n @for (action of menu(); track $index) {\n @if (firstDestructive($index)) {\n <hr\n class=\"my-1 border-0 border-t border-surface-200 dark:border-surface-700\"\n />\n }\n <mt-button\n [icon]=\"action.icon\"\n [label]=\"action.label || action.tooltip\"\n [severity]=\"action.color || 'secondary'\"\n variant=\"text\"\n size=\"small\"\n [loading]=\"busy(action)\"\n (click)=\"run(action, $event); popover.hide()\"\n />\n }\n }\n </div>\n </p-popover>\n}\n", styles: [":host{display:flex;align-items:center;justify-content:center;gap:4px;height:100%}\n"] }]
|
|
1303
1455
|
}], propDecorators: { params: [{ type: i0.Input, args: [{ isSignal: true, alias: "params", required: true }] }] } });
|
|
1304
1456
|
/** The standard row-actions control column, pinned at the end edge (menu-only header). */
|
|
1305
1457
|
function mtActionsColumn(options) {
|
|
1458
|
+
// At least the header label and its menu button; more when inline buttons need it.
|
|
1459
|
+
const width = actionsWidth(options.actions, options.shape ?? 'flat', !!options.requestActions);
|
|
1306
1460
|
return {
|
|
1307
1461
|
colId: MT_ACTIONS_COLUMN_ID,
|
|
1308
1462
|
headerName: options.label,
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
maxWidth: 120,
|
|
1463
|
+
width,
|
|
1464
|
+
minWidth: width,
|
|
1465
|
+
maxWidth: width,
|
|
1313
1466
|
suppressSizeToFit: true,
|
|
1314
1467
|
resizable: false,
|
|
1315
1468
|
pinned: options.rtl ? 'left' : 'right',
|
|
@@ -1358,6 +1511,15 @@ function width(value) {
|
|
|
1358
1511
|
// A percentage of a typical 1200px page; px values stay as they are.
|
|
1359
1512
|
return text.endsWith('%') ? parsed * 12 : parsed;
|
|
1360
1513
|
}
|
|
1514
|
+
/**
|
|
1515
|
+
* mt-table's typed cells (date and dateTime through the date format, boolean as Yes/No)
|
|
1516
|
+
* render as entity cells of the matching view type, so they keep the host's formats.
|
|
1517
|
+
*/
|
|
1518
|
+
const TYPED_VIEW = {
|
|
1519
|
+
date: 'Date',
|
|
1520
|
+
dateTime: 'DateTime',
|
|
1521
|
+
boolean: 'Checkbox',
|
|
1522
|
+
};
|
|
1361
1523
|
function filterType(column) {
|
|
1362
1524
|
if (column.filterable === false)
|
|
1363
1525
|
return false;
|
|
@@ -1419,6 +1581,23 @@ function mtTableColumn(column, rows) {
|
|
|
1419
1581
|
cellRenderer: MtTemplateCell,
|
|
1420
1582
|
cellRendererParams: { template: column.customCellTpl },
|
|
1421
1583
|
};
|
|
1584
|
+
const typed = TYPED_VIEW[column.type ?? ''];
|
|
1585
|
+
if (typed && !column.exportValue) {
|
|
1586
|
+
// The entity column's own getters sort, filter and export the typed value.
|
|
1587
|
+
const { valueGetter: _raw, filter: _filter, ...rest } = base;
|
|
1588
|
+
return mtEntityColumn({
|
|
1589
|
+
...rest,
|
|
1590
|
+
key: column.key,
|
|
1591
|
+
label: column.label,
|
|
1592
|
+
viewType: typed,
|
|
1593
|
+
entity: (row) => {
|
|
1594
|
+
const value = read(row);
|
|
1595
|
+
return value == null || value === ''
|
|
1596
|
+
? null
|
|
1597
|
+
: { viewType: typed, value };
|
|
1598
|
+
},
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1422
1601
|
const sample = rows.map(read).find(isEntity);
|
|
1423
1602
|
if (column.type === 'entity' || sample)
|
|
1424
1603
|
return mtEntityColumn({
|