@masterteam/components 0.0.241 → 0.0.242
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/masterteam-components-page.mjs +2 -2
- package/fesm2022/masterteam-components-page.mjs.map +1 -1
- package/fesm2022/masterteam-components-sidebar.mjs +2 -2
- package/fesm2022/masterteam-components-sidebar.mjs.map +1 -1
- package/fesm2022/masterteam-components-table.mjs +82 -4
- package/fesm2022/masterteam-components-table.mjs.map +1 -1
- package/fesm2022/masterteam-components-topbar.mjs +2 -2
- package/fesm2022/masterteam-components-topbar.mjs.map +1 -1
- package/package.json +1 -1
- package/types/masterteam-components-table.d.ts +27 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, booleanAttribute, output, viewChild, computed, ChangeDetectionStrategy, Component, model, inject,
|
|
2
|
+
import { input, booleanAttribute, output, viewChild, computed, signal, ChangeDetectionStrategy, Component, model, inject, DestroyRef, forwardRef, Injectable, contentChild, effect } from '@angular/core';
|
|
3
3
|
import { NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
import { Card } from '@masterteam/components/card';
|
|
5
5
|
import * as i1$1 from '@angular/forms';
|
|
@@ -35,6 +35,13 @@ import { MTDateFormatPipe } from '@masterteam/components';
|
|
|
35
35
|
import { ConfirmationService } from '@masterteam/components/confirmation';
|
|
36
36
|
import { EntityPreview } from '@masterteam/components/entities';
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Up to this many actions render as their own buttons instead of hiding behind
|
|
40
|
+
* the `⋯`. Export / print / group-by is exactly three, so the common table
|
|
41
|
+
* shows them all at a glance; anything richer keeps the menu rather than
|
|
42
|
+
* crowding the caption.
|
|
43
|
+
*/
|
|
44
|
+
const FLAT_ACTION_LIMIT = 3;
|
|
38
45
|
/**
|
|
39
46
|
* Top-right `⋯` menu. Uses PrimeNG TieredMenu (popup mode) so submenu
|
|
40
47
|
* cascading, keyboard navigation, and outside-click-to-close come for free.
|
|
@@ -108,18 +115,45 @@ class TableActionsMenu {
|
|
|
108
115
|
}
|
|
109
116
|
return items;
|
|
110
117
|
}, ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
118
|
+
/** True while the actions render as individual buttons. */
|
|
119
|
+
isFlat = computed(() => this.items().length > 0 && this.items().length <= FLAT_ACTION_LIMIT, ...(ngDevMode ? [{ debugName: "isFlat" }] : /* istanbul ignore next */ []));
|
|
120
|
+
/**
|
|
121
|
+
* What the popup renders. In `⋯` mode that's the whole action list; in flat
|
|
122
|
+
* mode the buttons *are* the top level, so the popup only ever shows the
|
|
123
|
+
* children of the button that opened it (the group-by column list).
|
|
124
|
+
*/
|
|
125
|
+
openSubmenu = signal(null, ...(ngDevMode ? [{ debugName: "openSubmenu" }] : /* istanbul ignore next */ []));
|
|
126
|
+
menuModel = computed(() => this.openSubmenu() ?? this.items(), ...(ngDevMode ? [{ debugName: "menuModel" }] : /* istanbul ignore next */ []));
|
|
111
127
|
toggle(event) {
|
|
128
|
+
this.openSubmenu.set(null);
|
|
129
|
+
this.menu()?.toggle(event);
|
|
130
|
+
}
|
|
131
|
+
/** Flat-mode click: run a leaf action, or open a parent's submenu. */
|
|
132
|
+
activate(event, item) {
|
|
133
|
+
const children = item.items;
|
|
134
|
+
if (!children?.length) {
|
|
135
|
+
item.command?.({});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
this.openSubmenu.set(children);
|
|
112
139
|
this.menu()?.toggle(event);
|
|
113
140
|
}
|
|
114
141
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TableActionsMenu, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
115
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: TableActionsMenu, isStandalone: true, selector: "mt-table-actions-menu", inputs: { exportable: { classPropertyName: "exportable", publicName: "exportable", isSignal: true, isRequired: false, transformFunction: null }, printable: { classPropertyName: "printable", publicName: "printable", isSignal: true, isRequired: false, transformFunction: null }, groupable: { classPropertyName: "groupable", publicName: "groupable", isSignal: true, isRequired: false, transformFunction: null }, groupColumns: { classPropertyName: "groupColumns", publicName: "groupColumns", isSignal: true, isRequired: false, transformFunction: null }, activeGroup: { classPropertyName: "activeGroup", publicName: "activeGroup", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { exportRequested: "exportRequested", printRequested: "printRequested", groupChange: "groupChange" }, viewQueries: [{ propertyName: "menu", first: true, predicate: ["menu"], descendants: true, isSignal: true }], ngImport: i0, template: "<mt-button\r\n (click)=\"toggle($event)\"\r\n
|
|
142
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: TableActionsMenu, isStandalone: true, selector: "mt-table-actions-menu", inputs: { exportable: { classPropertyName: "exportable", publicName: "exportable", isSignal: true, isRequired: false, transformFunction: null }, printable: { classPropertyName: "printable", publicName: "printable", isSignal: true, isRequired: false, transformFunction: null }, groupable: { classPropertyName: "groupable", publicName: "groupable", isSignal: true, isRequired: false, transformFunction: null }, groupColumns: { classPropertyName: "groupColumns", publicName: "groupColumns", isSignal: true, isRequired: false, transformFunction: null }, activeGroup: { classPropertyName: "activeGroup", publicName: "activeGroup", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { exportRequested: "exportRequested", printRequested: "printRequested", groupChange: "groupChange" }, viewQueries: [{ propertyName: "menu", first: true, predicate: ["menu"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (isFlat()) {\r\n @for (item of items(); track item.labelKey ?? item.rawLabel) {\r\n <mt-button\r\n (click)=\"activate($event, item)\"\r\n [icon]=\"item.iconKey\"\r\n [label]=\"item.badge\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"\r\n item.labelKey ? (item.labelKey | transloco) : (item.rawLabel ?? '')\r\n \"\r\n />\r\n }\r\n} @else {\r\n <mt-button\r\n (click)=\"toggle($event)\"\r\n icon=\"general.dots-horizontal\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"'components.table.actions' | transloco\"\r\n />\r\n}\r\n\r\n<p-tieredMenu\r\n #menu\r\n [model]=\"menuModel()\"\r\n [popup]=\"true\"\r\n appendTo=\"body\"\r\n styleClass=\"mt-table-actions-menu\"\r\n>\r\n <ng-template #item let-item let-hasSubmenu=\"hasSubmenu\">\r\n <button\r\n type=\"button\"\r\n class=\"flex items-center gap-2.5 w-full px-2.5 py-2 text-sm cursor-pointer text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-surface-700 transition-colors\"\r\n [class.bg-primary-50]=\"item.selected\"\r\n [class.dark:bg-primary-950]=\"item.selected\"\r\n [class.text-primary-700]=\"item.selected\"\r\n >\r\n @if (item.iconKey) {\r\n @if (item.useAvatar) {\r\n <mt-avatar [icon]=\"item.iconKey\" shape=\"circle\" />\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center justify-center w-7 h-7 rounded-full shrink-0\"\r\n [class]=\"toneClass[item.iconTone ?? 'secondary']\"\r\n >\r\n <mt-icon [icon]=\"item.iconKey\" class=\"text-sm\" />\r\n </span>\r\n }\r\n }\r\n <span class=\"flex-1 text-start truncate\">\r\n @if (item.labelKey) {\r\n {{ item.labelKey | transloco }}\r\n } @else {\r\n {{ item.rawLabel }}\r\n }\r\n </span>\r\n @if (item.badge) {\r\n <span\r\n class=\"text-xs px-1.5 py-0.5 rounded-full bg-primary-50 text-primary-700 dark:bg-primary-950 dark:text-primary-300 shrink-0\"\r\n >\r\n {{ item.badge }}\r\n </span>\r\n }\r\n @if (hasSubmenu) {\r\n <mt-icon\r\n icon=\"arrow.chevron-right\"\r\n class=\"text-xs text-gray-400 shrink-0\"\r\n />\r\n }\r\n </button>\r\n </ng-template>\r\n</p-tieredMenu>\r\n", dependencies: [{ kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { 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"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "ngmodule", type: TieredMenuModule }, { kind: "component", type: i1.TieredMenu, selector: "p-tieredMenu, p-tieredmenu, p-tiered-menu", inputs: ["model", "popup", "style", "styleClass", "breakpoint", "autoZIndex", "baseZIndex", "autoDisplay", "showTransitionOptions", "hideTransitionOptions", "id", "ariaLabel", "ariaLabelledBy", "disabled", "tabindex", "appendTo", "motionOptions"], outputs: ["onShow", "onHide"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i2.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
116
143
|
}
|
|
117
144
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: TableActionsMenu, decorators: [{
|
|
118
145
|
type: Component,
|
|
119
|
-
args: [{ selector: 'mt-table-actions-menu', standalone: true, imports: [Avatar, Button, Icon, TieredMenuModule, TranslocoModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "<mt-button\r\n (click)=\"toggle($event)\"\r\n
|
|
146
|
+
args: [{ selector: 'mt-table-actions-menu', standalone: true, imports: [Avatar, Button, Icon, TieredMenuModule, TranslocoModule], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (isFlat()) {\r\n @for (item of items(); track item.labelKey ?? item.rawLabel) {\r\n <mt-button\r\n (click)=\"activate($event, item)\"\r\n [icon]=\"item.iconKey\"\r\n [label]=\"item.badge\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"\r\n item.labelKey ? (item.labelKey | transloco) : (item.rawLabel ?? '')\r\n \"\r\n />\r\n }\r\n} @else {\r\n <mt-button\r\n (click)=\"toggle($event)\"\r\n icon=\"general.dots-horizontal\"\r\n severity=\"secondary\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [tooltip]=\"'components.table.actions' | transloco\"\r\n />\r\n}\r\n\r\n<p-tieredMenu\r\n #menu\r\n [model]=\"menuModel()\"\r\n [popup]=\"true\"\r\n appendTo=\"body\"\r\n styleClass=\"mt-table-actions-menu\"\r\n>\r\n <ng-template #item let-item let-hasSubmenu=\"hasSubmenu\">\r\n <button\r\n type=\"button\"\r\n class=\"flex items-center gap-2.5 w-full px-2.5 py-2 text-sm cursor-pointer text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-surface-700 transition-colors\"\r\n [class.bg-primary-50]=\"item.selected\"\r\n [class.dark:bg-primary-950]=\"item.selected\"\r\n [class.text-primary-700]=\"item.selected\"\r\n >\r\n @if (item.iconKey) {\r\n @if (item.useAvatar) {\r\n <mt-avatar [icon]=\"item.iconKey\" shape=\"circle\" />\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center justify-center w-7 h-7 rounded-full shrink-0\"\r\n [class]=\"toneClass[item.iconTone ?? 'secondary']\"\r\n >\r\n <mt-icon [icon]=\"item.iconKey\" class=\"text-sm\" />\r\n </span>\r\n }\r\n }\r\n <span class=\"flex-1 text-start truncate\">\r\n @if (item.labelKey) {\r\n {{ item.labelKey | transloco }}\r\n } @else {\r\n {{ item.rawLabel }}\r\n }\r\n </span>\r\n @if (item.badge) {\r\n <span\r\n class=\"text-xs px-1.5 py-0.5 rounded-full bg-primary-50 text-primary-700 dark:bg-primary-950 dark:text-primary-300 shrink-0\"\r\n >\r\n {{ item.badge }}\r\n </span>\r\n }\r\n @if (hasSubmenu) {\r\n <mt-icon\r\n icon=\"arrow.chevron-right\"\r\n class=\"text-xs text-gray-400 shrink-0\"\r\n />\r\n }\r\n </button>\r\n </ng-template>\r\n</p-tieredMenu>\r\n" }]
|
|
120
147
|
}], propDecorators: { exportable: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportable", required: false }] }], printable: [{ type: i0.Input, args: [{ isSignal: true, alias: "printable", required: false }] }], groupable: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupable", required: false }] }], groupColumns: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupColumns", required: false }] }], activeGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeGroup", required: false }] }], exportRequested: [{ type: i0.Output, args: ["exportRequested"] }], printRequested: [{ type: i0.Output, args: ["printRequested"] }], groupChange: [{ type: i0.Output, args: ["groupChange"] }], menu: [{ type: i0.ViewChild, args: ['menu', { isSignal: true }] }] } });
|
|
121
148
|
|
|
122
149
|
class TableValueResolver {
|
|
150
|
+
/**
|
|
151
|
+
* View types the table knows how to filter/sort/export. Deliberately a
|
|
152
|
+
* subset of `EntityViewType` — the richer ones (`Location`, `Connection`,
|
|
153
|
+
* `LookupModuleCheckList`, `LeafDetails`) have no scalar the table could
|
|
154
|
+
* compare, so they stay out and simply render. Anything listed here also
|
|
155
|
+
* needs a branch in `getColumnFilterType` and `getEntityValueByType`.
|
|
156
|
+
*/
|
|
123
157
|
static ALL_ENTITY_VIEW_TYPES = [
|
|
124
158
|
'Text',
|
|
125
159
|
'LongText',
|
|
@@ -132,6 +166,7 @@ class TableValueResolver {
|
|
|
132
166
|
'Checkbox',
|
|
133
167
|
'User',
|
|
134
168
|
'Lookup',
|
|
169
|
+
'LookupMatrix',
|
|
135
170
|
'PhaseGate',
|
|
136
171
|
'Attachment',
|
|
137
172
|
];
|
|
@@ -148,6 +183,7 @@ class TableValueResolver {
|
|
|
148
183
|
'Checkbox',
|
|
149
184
|
'User',
|
|
150
185
|
'Lookup',
|
|
186
|
+
'LookupMatrix',
|
|
151
187
|
'PhaseGate',
|
|
152
188
|
]);
|
|
153
189
|
static FILTERABLE_ENTITY_VIEW_TYPES = new Set(TableValueResolver.ALL_ENTITY_VIEW_TYPES.filter((viewType) => viewType !== 'Attachment'));
|
|
@@ -227,6 +263,7 @@ class TableValueResolver {
|
|
|
227
263
|
return 'boolean';
|
|
228
264
|
case 'Status':
|
|
229
265
|
case 'Lookup':
|
|
266
|
+
case 'LookupMatrix':
|
|
230
267
|
case 'PhaseGate':
|
|
231
268
|
return 'select';
|
|
232
269
|
case 'User':
|
|
@@ -730,6 +767,13 @@ class TableValueResolver {
|
|
|
730
767
|
: new Date(String(resolvedValue)).getTime();
|
|
731
768
|
return Number.isNaN(timestamp) ? null : timestamp;
|
|
732
769
|
}
|
|
770
|
+
/**
|
|
771
|
+
* Resolves an entity column's view type from the column def, falling back to
|
|
772
|
+
* a sample row's cell. Public because grouping decides what it can bucket
|
|
773
|
+
* from the entity view type, which is finer-grained than the filter type
|
|
774
|
+
* (`Lookup` and `LookupMatrix` both filter as `select`-ish but only the view
|
|
775
|
+
* type says whether the values are categorical).
|
|
776
|
+
*/
|
|
733
777
|
static getEntityViewType(column, row) {
|
|
734
778
|
const explicitViewType = column.viewType;
|
|
735
779
|
if (TableValueResolver.isEntityViewType(explicitViewType)) {
|
|
@@ -1424,6 +1468,20 @@ const GROUPABLE_FILTER_TYPES = new Set([
|
|
|
1424
1468
|
'boolean',
|
|
1425
1469
|
'user',
|
|
1426
1470
|
]);
|
|
1471
|
+
/**
|
|
1472
|
+
* Entity view types whose values are categorical enough to bucket rows by.
|
|
1473
|
+
* Entity columns are judged on this rather than their filter type: a
|
|
1474
|
+
* `LookupMatrix` (e.g. a risk Classification) filters as free text but its
|
|
1475
|
+
* values are a small fixed set, so it groups perfectly well.
|
|
1476
|
+
*/
|
|
1477
|
+
const GROUPABLE_ENTITY_VIEW_TYPES = new Set([
|
|
1478
|
+
'Status',
|
|
1479
|
+
'Lookup',
|
|
1480
|
+
'LookupMatrix',
|
|
1481
|
+
'PhaseGate',
|
|
1482
|
+
'User',
|
|
1483
|
+
'Checkbox',
|
|
1484
|
+
]);
|
|
1427
1485
|
/** Bucket every row whose grouped value is missing/empty falls into. */
|
|
1428
1486
|
const EMPTY_GROUP_KEY = '__mt_group_empty__';
|
|
1429
1487
|
/**
|
|
@@ -1464,6 +1522,10 @@ class TableGroupingController {
|
|
|
1464
1522
|
return col.groupable;
|
|
1465
1523
|
if (col.type === 'custom')
|
|
1466
1524
|
return false;
|
|
1525
|
+
if (col.type === 'entity') {
|
|
1526
|
+
const viewType = TableValueResolver.getEntityViewType(col, sampleRow);
|
|
1527
|
+
return !!viewType && GROUPABLE_ENTITY_VIEW_TYPES.has(viewType);
|
|
1528
|
+
}
|
|
1467
1529
|
const filterType = TableValueResolver.getColumnFilterType(col, sampleRow);
|
|
1468
1530
|
return filterType !== null && GROUPABLE_FILTER_TYPES.has(filterType);
|
|
1469
1531
|
});
|
|
@@ -1561,6 +1623,14 @@ class TableGroupingController {
|
|
|
1561
1623
|
const color = obj['color'];
|
|
1562
1624
|
if (typeof color === 'string' && color.length > 0)
|
|
1563
1625
|
return color;
|
|
1626
|
+
// Entity cells carry the color on the resolved value, not the wrapper.
|
|
1627
|
+
const value = obj['value'];
|
|
1628
|
+
if (value && typeof value === 'object') {
|
|
1629
|
+
const valueColor = value['color'];
|
|
1630
|
+
if (typeof valueColor === 'string' && valueColor.length > 0) {
|
|
1631
|
+
return valueColor;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1564
1634
|
}
|
|
1565
1635
|
return null;
|
|
1566
1636
|
}
|
|
@@ -1765,7 +1835,15 @@ class Table {
|
|
|
1765
1835
|
return applyLocalSort ? this.sortData(result) : result;
|
|
1766
1836
|
}, ...(ngDevMode ? [{ debugName: "filteredData" }] : /* istanbul ignore next */ []));
|
|
1767
1837
|
renderedColumns = computed(() => {
|
|
1768
|
-
const
|
|
1838
|
+
const visible = this.columns().filter((column) => !column.filterOnly);
|
|
1839
|
+
// The grouped column's value is already the group header — repeating it in
|
|
1840
|
+
// every row is noise. Never hide the last one, or the table would render
|
|
1841
|
+
// with no columns at all. Export/print still read the full `columns()`.
|
|
1842
|
+
const groupedKey = this.groupBy();
|
|
1843
|
+
const withoutGrouped = groupedKey
|
|
1844
|
+
? visible.filter((column) => column.key !== groupedKey)
|
|
1845
|
+
: visible;
|
|
1846
|
+
const columns = withoutGrouped.length ? withoutGrouped : visible;
|
|
1769
1847
|
if (columns.length > 0 || !this.loading()) {
|
|
1770
1848
|
return columns;
|
|
1771
1849
|
}
|