@masterteam/data-table 0.0.2 → 0.0.4
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 +18 -9
- package/fesm2022/masterteam-data-table-config.mjs +21 -0
- package/fesm2022/masterteam-data-table-config.mjs.map +1 -0
- package/fesm2022/masterteam-data-table-icons.mjs +1 -1
- package/fesm2022/masterteam-data-table-icons.mjs.map +1 -1
- package/fesm2022/masterteam-data-table-legacy.mjs +160 -171
- package/fesm2022/masterteam-data-table-legacy.mjs.map +1 -1
- package/fesm2022/masterteam-data-table.mjs +9 -4
- package/fesm2022/masterteam-data-table.mjs.map +1 -1
- package/legacy/README.md +5 -0
- package/package.json +7 -3
- package/types/masterteam-data-table-config.d.ts +19 -0
- package/types/masterteam-data-table-icons.d.ts +1 -1
- package/types/masterteam-data-table-legacy.d.ts +5 -19
- package/types/masterteam-data-table.d.ts +3 -0
package/README.md
CHANGED
|
@@ -21,19 +21,25 @@ Every product page that shows the new grid renders `mt-standard-grid`
|
|
|
21
21
|
/>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
- **One header** (`mtStandardColumns`): sort, menu and filter on every data column, resize
|
|
25
|
-
move; no custom header renderers; control columns (no `field`/`valueGetter`, e.g. actions)
|
|
24
|
+
- **One header** (`mtStandardColumns`): sort, menu and filter on every data column, resize (no
|
|
25
|
+
upper limit; a page's `maxWidth` is dropped) and move; no custom header renderers; control columns (no `field`/`valueGetter`, e.g. actions)
|
|
26
26
|
keep the menu only. Backend limits are the only exceptions: `sortable: false`, and on a
|
|
27
27
|
server page `filter: false`.
|
|
28
28
|
- **One setup**: 44px rows and header, group panel and quick filter, pivot zone while pivoting,
|
|
29
29
|
Columns/Filters side bar at the logical end, status bar, pager 10/20/50/100 when needed,
|
|
30
|
-
context menu with CSV/Excel/PDF export, charts
|
|
30
|
+
context menu with CSV/Excel/PDF export, charts (Chart Range on every page; a server page
|
|
31
|
+
charts the rows it holds), the standard empty state (`emptyTitle`).
|
|
31
32
|
- **Inputs** (data and behaviour only): `rows`, `columns`, `rowId` (optional for local tables),
|
|
32
33
|
`label`, `loading`, `height` (px or `'auto'`), `selection`, `exportable`, `exportName`,
|
|
33
|
-
`
|
|
34
|
-
`
|
|
34
|
+
`exportFormats` (a narrower export permission), `exporter` (an owner-run export, e.g. a
|
|
35
|
+
server export, behind the same menu), `rowMenuItems`, `server` (`{ total, page, pageSize }`
|
|
36
|
+
for a server page), `paged` (off for a grid that scrolls every row in its own viewport),
|
|
37
|
+
`detail` (`{ renderer, params, isRowMaster }` for master/detail rows), `chartContext`
|
|
38
|
+
(chart titles; defaults to `label`), `view`, `search`, `emptyTitle`/`emptyDescription`;
|
|
39
|
+
page buttons project into `[mtGridToolbar]`.
|
|
35
40
|
- **Outputs**: `gridReady`, `rowClicked`, `selectionChanged`, `sortChanged`, `filterChanged`,
|
|
36
|
-
`paginationChanged`, `rowGroupOpened`, `viewChanged` (the captured view, persist it per user)
|
|
41
|
+
`paginationChanged`, `rowGroupOpened`, `viewChanged` (the captured view, persist it per user),
|
|
42
|
+
`chartsChanged` (persist a chart session).
|
|
37
43
|
- **Helpers**: `mtActionsColumn` / `MtActionsCell` (the standard row-actions column),
|
|
38
44
|
`mtTableColumns` (maps mt-table `ColumnDef[]` with `customCellTpl` onto grid columns),
|
|
39
45
|
`MtTemplateCell`, `MtTableText` (grid locale texts), `mtTablePrintConfiguration`.
|
|
@@ -88,8 +94,11 @@ and entity columns; `/data-grid/demo` remains the full grid reference.
|
|
|
88
94
|
## Existing consumers
|
|
89
95
|
|
|
90
96
|
Portal/Studio configuration, preferences, data sources and the dataset cache live in the
|
|
91
|
-
explicit `@masterteam/data-table/legacy` entry point
|
|
92
|
-
[legacy documentation](legacy/README.md).
|
|
97
|
+
explicit `@masterteam/data-table/legacy` entry point; see
|
|
98
|
+
[legacy documentation](legacy/README.md). Install the root configuration from
|
|
99
|
+
`@masterteam/data-table/config` (`provideMTDataTables`, `MT_DATA_TABLE_CONFIGURATION`):
|
|
100
|
+
legacy imports the grid, so importing it at startup puts the grid in the initial
|
|
101
|
+
bundle. Legacy re-exports both, so the token is the same either way. The compatibility renderer that turned `mt-table`
|
|
93
102
|
into a grid was removed on 2026-11-03. Which surfaces use the standard grid is listed in the
|
|
94
103
|
[integration notes](../../../.github/instructions/data-table/README.md).
|
|
95
104
|
|
|
@@ -100,6 +109,6 @@ into a grid was removed on 2026-11-03. Which surfaces use the standard grid is l
|
|
|
100
109
|
|
|
101
110
|
## Shared design-system icons
|
|
102
111
|
|
|
103
|
-
Use `provideMTGridIcons()` from `@masterteam/data-table/icons` in application providers. It loads the same packaged Masterteam glyph map used by the showcase before bootstrap. This optional DS bridge supplies icons only. Both apps must serve `assets/icons-map.generated.json`. Without this provider the independent grid uses fallback icons.
|
|
112
|
+
Use `provideMTGridIcons()` from `@masterteam/data-table/icons` in application providers. The entry imports only `@masterteam/data-grid/tokens`, never the grid. It loads the same packaged Masterteam glyph map used by the showcase before bootstrap. This optional DS bridge supplies icons only. Both apps must serve `assets/icons-map.generated.json`. Without this provider the independent grid uses fallback icons.
|
|
104
113
|
|
|
105
114
|
Calculated numeric chart ticks/aggregates use their supplied value, retaining percent and currency units from entity metadata. Ordinary cells retain the entity display text. Native `valueFormatter` overrides remain authoritative.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InjectionToken, makeEnvironmentProviders } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
const MT_DATA_TABLE_CONFIGURATION = new InjectionToken('MT_DATA_TABLE_CONFIGURATION', {
|
|
4
|
+
providedIn: 'root',
|
|
5
|
+
factory: () => ({ identity: () => null }),
|
|
6
|
+
});
|
|
7
|
+
/** Root installation of the data-table configuration (portal and Studio). */
|
|
8
|
+
function provideMTDataTables(configuration) {
|
|
9
|
+
return makeEnvironmentProviders([
|
|
10
|
+
typeof configuration === 'function'
|
|
11
|
+
? { provide: MT_DATA_TABLE_CONFIGURATION, useFactory: configuration }
|
|
12
|
+
: { provide: MT_DATA_TABLE_CONFIGURATION, useValue: configuration },
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Generated bundle index. Do not edit.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export { MT_DATA_TABLE_CONFIGURATION, provideMTDataTables };
|
|
21
|
+
//# sourceMappingURL=masterteam-data-table-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"masterteam-data-table-config.mjs","sources":["../../../../packages/masterteam/data-table/config/public-api.ts","../../../../packages/masterteam/data-table/config/masterteam-data-table-config.ts"],"sourcesContent":["import {\n InjectionToken,\n makeEnvironmentProviders,\n type EnvironmentProviders,\n} from '@angular/core';\n\n/*\n * Root configuration only. An application installs this at startup, so the\n * entry must not import the grid: anything it imports lands in the initial\n * bundle. `@masterteam/data-table/legacy` re-exports all of it.\n */\n\nexport interface MtTableScopeIdentity {\n readonly application: string;\n readonly tenant: string;\n readonly user: string;\n readonly actor: string;\n readonly template?: string | number | null;\n}\nexport interface MtDataTableConfiguration {\n readonly identity: () => MtTableScopeIdentity | null;\n readonly direction?: () => 'ltr' | 'rtl';\n}\n\nexport const MT_DATA_TABLE_CONFIGURATION =\n new InjectionToken<MtDataTableConfiguration>('MT_DATA_TABLE_CONFIGURATION', {\n providedIn: 'root',\n factory: () => ({ identity: () => null }),\n });\n\n/** Root installation of the data-table configuration (portal and Studio). */\nexport function provideMTDataTables(\n configuration: MtDataTableConfiguration | (() => MtDataTableConfiguration),\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n typeof configuration === 'function'\n ? { provide: MT_DATA_TABLE_CONFIGURATION, useFactory: configuration }\n : { provide: MT_DATA_TABLE_CONFIGURATION, useValue: configuration },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;MAwBa,2BAA2B,GACtC,IAAI,cAAc,CAA2B,6BAA6B,EAAE;AAC1E,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAC;AAC1C,CAAA;AAEH;AACM,SAAU,mBAAmB,CACjC,aAA0E,EAAA;AAE1E,IAAA,OAAO,wBAAwB,CAAC;QAC9B,OAAO,aAAa,KAAK;cACrB,EAAE,OAAO,EAAE,2BAA2B,EAAE,UAAU,EAAE,aAAa;cACjE,EAAE,OAAO,EAAE,2BAA2B,EAAE,QAAQ,EAAE,aAAa,EAAE;AACtE,KAAA,CAAC;AACJ;;ACvCA;;AAEG;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { makeEnvironmentProviders, provideAppInitializer, inject } from '@angular/core';
|
|
2
2
|
import { HttpClient, HttpBackend } from '@angular/common/http';
|
|
3
|
-
import { MT_GRID_ICONS } from '@masterteam/data-grid';
|
|
3
|
+
import { MT_GRID_ICONS } from '@masterteam/data-grid/tokens';
|
|
4
4
|
import { firstValueFrom } from 'rxjs';
|
|
5
5
|
|
|
6
6
|
/** Closest @masterteam/icons glyph for every grid semantic and historical alias. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-data-table-icons.mjs","sources":["../../../../packages/masterteam/data-table/icons/public-api.ts","../../../../packages/masterteam/data-table/icons/masterteam-data-table-icons.ts"],"sourcesContent":["import {\r\n inject,\r\n makeEnvironmentProviders,\r\n provideAppInitializer,\r\n} from '@angular/core';\r\nimport { HttpBackend } from '@angular/common/http';\r\nimport { MT_GRID_ICONS } from '@masterteam/data-grid';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport type {
|
|
1
|
+
{"version":3,"file":"masterteam-data-table-icons.mjs","sources":["../../../../packages/masterteam/data-table/icons/public-api.ts","../../../../packages/masterteam/data-table/icons/masterteam-data-table-icons.ts"],"sourcesContent":["import {\r\n inject,\r\n makeEnvironmentProviders,\r\n provideAppInitializer,\r\n} from '@angular/core';\r\nimport { HttpBackend } from '@angular/common/http';\r\n// The tokens entry only: the main entry would put the whole grid in the initial bundle.\r\nimport { MT_GRID_ICONS, type GridIconName } from '@masterteam/data-grid/tokens';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport type { MTIcon } from '@masterteam/icons';\r\nimport { firstValueFrom } from 'rxjs';\r\n\r\n/** Closest @masterteam/icons glyph for every grid semantic and historical alias. */\r\nconst glyphs = {\r\n 'sort-asc': 'arrow.arrow-up',\r\n 'sort-desc': 'arrow.arrow-down',\r\n 'sort-none': 'arrow.chevron-selector-vertical',\r\n reset: 'arrow.refresh-ccw-01',\r\n expand: 'arrow.chevron-right',\r\n collapse: 'arrow.chevron-down',\r\n pdf: 'file.file-06',\r\n export: 'general.download-01',\r\n asc: 'arrow.arrow-up',\r\n desc: 'arrow.arrow-down',\r\n hide: 'general.eye-off',\r\n blocked: 'general.slash-circle-01',\r\n pin: 'general.pin-01',\r\n columns: 'layout.columns-03',\r\n chevron: 'arrow.chevron-right',\r\n 'chevron-start': 'arrow.chevron-left-double',\r\n check: 'general.check',\r\n menu: 'general.dots-vertical',\r\n move: 'editor.move',\r\n left: 'arrow.arrow-left',\r\n right: 'arrow.arrow-right',\r\n close: 'general.x-close',\r\n copy: 'general.copy-01',\r\n cut: 'editor.scissors-01',\r\n paste: 'file.clipboard',\r\n save: 'general.download-01',\r\n 'tree-open': 'arrow.chevron-down',\r\n 'tree-closed': 'arrow.chevron-right',\r\n group: 'layout.rows-03',\r\n csv: 'file.file-06',\r\n excel: 'layout.table',\r\n search: 'general.search-lg',\r\n filter: 'general.filter-lines',\r\n cancel: 'general.x-close',\r\n 'small-down': 'arrow.chevron-down',\r\n grip: 'general.dots-grid',\r\n arrows: 'custom.arrows',\r\n 'tree-indeterminate': 'general.minus',\r\n aggregation: 'editor.type-01',\r\n pivot: 'layout.grid-01',\r\n 'filter-add': 'general.plus',\r\n cross: 'general.x-close',\r\n 'chevron-up': 'arrow.chevron-up',\r\n 'chevron-down': 'arrow.chevron-down',\r\n first: 'arrow.chevron-left-double',\r\n previous: 'arrow.chevron-left',\r\n next: 'arrow.chevron-right',\r\n last: 'arrow.chevron-right-double',\r\n chart: 'chart.bar-chart-01',\r\n maximize: 'arrow.expand-01',\r\n minimize: 'layout.minimize-01',\r\n 'chart-link': 'general.link-01',\r\n 'chart-unlink': 'general.link-broken-01',\r\n 'chart-edit': 'general.settings-04',\r\n 'chevron-right': 'arrow.chevron-right',\r\n 'eye-off': 'general.eye-off',\r\n minus: 'general.minus',\r\n values: 'editor.type-01',\r\n download: 'general.download-01',\r\n link: 'general.link-01',\r\n unlink: 'general.link-broken-01',\r\n settings: 'general.settings-04',\r\n 'chevron-left': 'arrow.chevron-left',\r\n 'chevron-end': 'arrow.chevron-right-double',\r\n 'filter-active': 'general.filter-funnel-01',\r\n 'filters-panel': 'general.filter-lines',\r\n 'pin-left': 'general.pin-01',\r\n 'pin-right': 'general.pin-01',\r\n unpin: 'general.pin-02',\r\n autosize: 'custom.arrows',\r\n 'chart-bar': 'chart.horizontal-bar-chart-01',\r\n 'chart-line': 'chart.line-chart-up-01',\r\n 'chart-pie': 'chart.pie-chart-01',\r\n 'chart-area': 'chart.bar-line-chart',\r\n 'chart-scatter': 'chart.bar-chart-10',\r\n data: 'dev.database-01',\r\n format: 'editor.paint',\r\n plus: 'general.plus',\r\n eye: 'general.eye',\r\n loading: 'general.loading-01',\r\n} satisfies Record<GridIconName, MTIcon>;\r\n\r\n/** Populated before bootstrap from the same packaged asset map used by mt-icon. */\r\nexport const gridDsIcons: Partial<Record<GridIconName, string>> = {};\r\nexport async function loadGridDsIcons(http: HttpClient): Promise<void> {\r\n const icons = await firstValueFrom(\r\n http.get<Record<string, string>>('assets/icons-map.generated.json'),\r\n );\r\n for (const [name, glyph] of Object.entries(glyphs)) {\r\n const svg = icons[glyph];\r\n if (!svg) throw new Error(`Missing DS grid glyph: ${glyph}`);\r\n gridDsIcons[name as GridIconName] = svg.replace(\r\n '<svg ',\r\n '<svg width=\"100%\" height=\"100%\" ',\r\n );\r\n }\r\n}\r\n\r\n/** The same Masterteam icon bridge for showcase and products. No grid UI or feature policy. */\r\nexport function provideMTGridIcons() {\r\n return makeEnvironmentProviders([\r\n { provide: MT_GRID_ICONS, useValue: gridDsIcons },\r\n provideAppInitializer(() =>\r\n loadGridDsIcons(new HttpClient(inject(HttpBackend))),\r\n ),\r\n ]);\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAYA;AACA,MAAM,MAAM,GAAG;AACb,IAAA,UAAU,EAAE,gBAAgB;AAC5B,IAAA,WAAW,EAAE,kBAAkB;AAC/B,IAAA,WAAW,EAAE,iCAAiC;AAC9C,IAAA,KAAK,EAAE,sBAAsB;AAC7B,IAAA,MAAM,EAAE,qBAAqB;AAC7B,IAAA,QAAQ,EAAE,oBAAoB;AAC9B,IAAA,GAAG,EAAE,cAAc;AACnB,IAAA,MAAM,EAAE,qBAAqB;AAC7B,IAAA,GAAG,EAAE,gBAAgB;AACrB,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,IAAI,EAAE,iBAAiB;AACvB,IAAA,OAAO,EAAE,yBAAyB;AAClC,IAAA,GAAG,EAAE,gBAAgB;AACrB,IAAA,OAAO,EAAE,mBAAmB;AAC5B,IAAA,OAAO,EAAE,qBAAqB;AAC9B,IAAA,eAAe,EAAE,2BAA2B;AAC5C,IAAA,KAAK,EAAE,eAAe;AACtB,IAAA,IAAI,EAAE,uBAAuB;AAC7B,IAAA,IAAI,EAAE,aAAa;AACnB,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,KAAK,EAAE,mBAAmB;AAC1B,IAAA,KAAK,EAAE,iBAAiB;AACxB,IAAA,IAAI,EAAE,iBAAiB;AACvB,IAAA,GAAG,EAAE,oBAAoB;AACzB,IAAA,KAAK,EAAE,gBAAgB;AACvB,IAAA,IAAI,EAAE,qBAAqB;AAC3B,IAAA,WAAW,EAAE,oBAAoB;AACjC,IAAA,aAAa,EAA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;AACF,KAAA,CAAC;AACJ;;ACxHA;;AAEG;;;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { MtTableText, mtTablePrintConfiguration } from '@masterteam/data-table';
|
|
2
2
|
export * from '@masterteam/data-table';
|
|
3
|
+
import { MT_DATA_TABLE_CONFIGURATION } from '@masterteam/data-table/config';
|
|
4
|
+
export { MT_DATA_TABLE_CONFIGURATION, provideMTDataTables } from '@masterteam/data-table/config';
|
|
3
5
|
import * as i0 from '@angular/core';
|
|
4
|
-
import {
|
|
6
|
+
import { inject, Injectable, input, computed, ChangeDetectionStrategy, Component, output, Injector, ElementRef, DestroyRef, viewChild, signal, afterNextRender, effect, untracked } from '@angular/core';
|
|
5
7
|
import { CHART_TYPES, parseGridViewState, MtDataGridComponent, applyGridViewState, captureGridViewState } from '@masterteam/data-grid';
|
|
6
8
|
import { CdkTrapFocus } from '@angular/cdk/a11y';
|
|
7
9
|
import * as i1 from '@angular/forms';
|
|
@@ -13,10 +15,162 @@ import { TableExportService } from '@masterteam/components/table';
|
|
|
13
15
|
import { Popover } from 'primeng/popover';
|
|
14
16
|
import { ConfirmationService } from '@masterteam/components/confirmation';
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// `MtTablePreferences` is `providedIn: 'root'`; the root provider only installs the configuration.
|
|
19
|
+
|
|
20
|
+
/** A shared, cancellable FIFO scheduler. Collapsing one record never cancels another. */
|
|
21
|
+
class MtDatasetScheduler {
|
|
22
|
+
concurrency;
|
|
23
|
+
active = 0;
|
|
24
|
+
queue = [];
|
|
25
|
+
constructor(concurrency = 4) {
|
|
26
|
+
this.concurrency = concurrency;
|
|
27
|
+
if (!Number.isInteger(concurrency) || concurrency < 1)
|
|
28
|
+
throw new Error('Invalid concurrency');
|
|
29
|
+
}
|
|
30
|
+
run(work, signal) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const abort = () => {
|
|
33
|
+
const index = this.queue.indexOf(start);
|
|
34
|
+
if (index >= 0)
|
|
35
|
+
this.queue.splice(index, 1);
|
|
36
|
+
reject(signal.reason ?? new DOMException('Aborted', 'AbortError'));
|
|
37
|
+
};
|
|
38
|
+
const start = () => {
|
|
39
|
+
if (signal.aborted) {
|
|
40
|
+
signal.removeEventListener('abort', abort);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.active++;
|
|
44
|
+
Promise.resolve()
|
|
45
|
+
.then(work)
|
|
46
|
+
.then(resolve, reject)
|
|
47
|
+
.finally(() => {
|
|
48
|
+
signal.removeEventListener('abort', abort);
|
|
49
|
+
this.active--;
|
|
50
|
+
this.drain();
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
if (signal.aborted) {
|
|
54
|
+
abort();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
58
|
+
this.queue.push(start);
|
|
59
|
+
this.drain();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
drain() {
|
|
63
|
+
while (this.active < this.concurrency && this.queue.length)
|
|
64
|
+
this.queue.shift()();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Values are scoped by the caller's complete authenticated query identity. */
|
|
68
|
+
class MtDatasetCache {
|
|
69
|
+
capacity;
|
|
70
|
+
entries = new Map();
|
|
71
|
+
constructor(capacity = 20) {
|
|
72
|
+
this.capacity = capacity;
|
|
73
|
+
if (!Number.isInteger(capacity) || capacity < 1)
|
|
74
|
+
throw new Error('Invalid cache capacity');
|
|
75
|
+
}
|
|
76
|
+
get(key) {
|
|
77
|
+
const value = this.entries.get(key);
|
|
78
|
+
if (value !== undefined) {
|
|
79
|
+
this.entries.delete(key);
|
|
80
|
+
this.entries.set(key, value);
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
set(key, value) {
|
|
85
|
+
this.entries.delete(key);
|
|
86
|
+
this.entries.set(key, value);
|
|
87
|
+
while (this.entries.size > this.capacity)
|
|
88
|
+
this.entries.delete(this.entries.keys().next().value);
|
|
89
|
+
}
|
|
90
|
+
clear() {
|
|
91
|
+
this.entries.clear();
|
|
92
|
+
}
|
|
93
|
+
get size() {
|
|
94
|
+
return this.entries.size;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
class MtIncompleteTableError extends Error {
|
|
99
|
+
constructor() {
|
|
100
|
+
super('The table response did not contain the complete requested result.');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function uniqueRows(rows, getRowId) {
|
|
104
|
+
const ids = rows.map(getRowId);
|
|
105
|
+
return (ids.every((id) => typeof id === 'string' && id.length > 0) &&
|
|
106
|
+
new Set(ids).size === ids.length);
|
|
107
|
+
}
|
|
108
|
+
/** Load every page of a small result before permitting client aggregation. A threshold is never a truncation limit. */
|
|
109
|
+
async function loadMtTableResult(source, query, signal, getRowId, clientAnalysisThreshold = 1000) {
|
|
110
|
+
if (!Number.isSafeInteger(query.offset) ||
|
|
111
|
+
query.offset < 0 ||
|
|
112
|
+
!Number.isSafeInteger(query.limit) ||
|
|
113
|
+
query.limit <= 0)
|
|
114
|
+
throw new Error('Invalid table page');
|
|
115
|
+
const first = await source.load(query, signal);
|
|
116
|
+
signal.throwIfAborted();
|
|
117
|
+
if (!Number.isSafeInteger(first.totalCount) ||
|
|
118
|
+
first.totalCount < 0 ||
|
|
119
|
+
first.rows.length > first.totalCount ||
|
|
120
|
+
!uniqueRows(first.rows, getRowId))
|
|
121
|
+
throw new MtIncompleteTableError();
|
|
122
|
+
if (source.processing === 'client') {
|
|
123
|
+
if (!first.complete ||
|
|
124
|
+
first.rows.length !== first.totalCount ||
|
|
125
|
+
!uniqueRows(first.rows, getRowId))
|
|
126
|
+
throw new MtIncompleteTableError();
|
|
127
|
+
return first;
|
|
128
|
+
}
|
|
129
|
+
if (first.totalCount > clientAnalysisThreshold) {
|
|
130
|
+
const expected = Math.max(0, Math.min(query.limit, first.totalCount - query.offset));
|
|
131
|
+
if (first.rows.length !== expected)
|
|
132
|
+
throw new MtIncompleteTableError();
|
|
133
|
+
return { ...first, complete: false };
|
|
134
|
+
}
|
|
135
|
+
const pages = [];
|
|
136
|
+
// A non-zero initial page cannot prove that earlier rows were loaded.
|
|
137
|
+
let offset = 0;
|
|
138
|
+
while (offset < first.totalCount) {
|
|
139
|
+
signal.throwIfAborted();
|
|
140
|
+
const page = offset === query.offset
|
|
141
|
+
? first
|
|
142
|
+
: await source.load({ ...query, offset }, signal);
|
|
143
|
+
signal.throwIfAborted();
|
|
144
|
+
if (page.totalCount !== first.totalCount ||
|
|
145
|
+
page.rows.length === 0 ||
|
|
146
|
+
page.rows.length > query.limit)
|
|
147
|
+
throw new MtIncompleteTableError();
|
|
148
|
+
pages.push(...page.rows);
|
|
149
|
+
offset += page.rows.length;
|
|
150
|
+
}
|
|
151
|
+
if (pages.length !== first.totalCount || !uniqueRows(pages, getRowId))
|
|
152
|
+
throw new MtIncompleteTableError();
|
|
153
|
+
return { ...first, rows: pages, complete: true };
|
|
154
|
+
}
|
|
155
|
+
function mtClientTableSource(key, rows) {
|
|
156
|
+
return {
|
|
157
|
+
key,
|
|
158
|
+
scopeKey: key,
|
|
159
|
+
processing: 'client',
|
|
160
|
+
capabilities: {
|
|
161
|
+
sort: true,
|
|
162
|
+
filter: true,
|
|
163
|
+
group: true,
|
|
164
|
+
pivot: true,
|
|
165
|
+
charts: true,
|
|
166
|
+
exportAll: true,
|
|
167
|
+
},
|
|
168
|
+
load: async (_query, signal) => {
|
|
169
|
+
signal.throwIfAborted();
|
|
170
|
+
return { rows, totalCount: rows.length, complete: true };
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
20
174
|
|
|
21
175
|
function captureMtTableChart(model, api, wholeTable = false) {
|
|
22
176
|
const rows = [];
|
|
@@ -240,171 +394,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
240
394
|
args: [{ providedIn: 'root' }]
|
|
241
395
|
}] });
|
|
242
396
|
|
|
243
|
-
/** Root installation of the data-table configuration and preferences (portal and Studio). */
|
|
244
|
-
function provideMTDataTables(configuration) {
|
|
245
|
-
return makeEnvironmentProviders([
|
|
246
|
-
MtTablePreferences,
|
|
247
|
-
typeof configuration === 'function'
|
|
248
|
-
? { provide: MT_DATA_TABLE_CONFIGURATION, useFactory: configuration }
|
|
249
|
-
: { provide: MT_DATA_TABLE_CONFIGURATION, useValue: configuration },
|
|
250
|
-
]);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/** A shared, cancellable FIFO scheduler. Collapsing one record never cancels another. */
|
|
254
|
-
class MtDatasetScheduler {
|
|
255
|
-
concurrency;
|
|
256
|
-
active = 0;
|
|
257
|
-
queue = [];
|
|
258
|
-
constructor(concurrency = 4) {
|
|
259
|
-
this.concurrency = concurrency;
|
|
260
|
-
if (!Number.isInteger(concurrency) || concurrency < 1)
|
|
261
|
-
throw new Error('Invalid concurrency');
|
|
262
|
-
}
|
|
263
|
-
run(work, signal) {
|
|
264
|
-
return new Promise((resolve, reject) => {
|
|
265
|
-
const abort = () => {
|
|
266
|
-
const index = this.queue.indexOf(start);
|
|
267
|
-
if (index >= 0)
|
|
268
|
-
this.queue.splice(index, 1);
|
|
269
|
-
reject(signal.reason ?? new DOMException('Aborted', 'AbortError'));
|
|
270
|
-
};
|
|
271
|
-
const start = () => {
|
|
272
|
-
if (signal.aborted) {
|
|
273
|
-
signal.removeEventListener('abort', abort);
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
this.active++;
|
|
277
|
-
Promise.resolve()
|
|
278
|
-
.then(work)
|
|
279
|
-
.then(resolve, reject)
|
|
280
|
-
.finally(() => {
|
|
281
|
-
signal.removeEventListener('abort', abort);
|
|
282
|
-
this.active--;
|
|
283
|
-
this.drain();
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
if (signal.aborted) {
|
|
287
|
-
abort();
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
signal.addEventListener('abort', abort, { once: true });
|
|
291
|
-
this.queue.push(start);
|
|
292
|
-
this.drain();
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
drain() {
|
|
296
|
-
while (this.active < this.concurrency && this.queue.length)
|
|
297
|
-
this.queue.shift()();
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
/** Values are scoped by the caller's complete authenticated query identity. */
|
|
301
|
-
class MtDatasetCache {
|
|
302
|
-
capacity;
|
|
303
|
-
entries = new Map();
|
|
304
|
-
constructor(capacity = 20) {
|
|
305
|
-
this.capacity = capacity;
|
|
306
|
-
if (!Number.isInteger(capacity) || capacity < 1)
|
|
307
|
-
throw new Error('Invalid cache capacity');
|
|
308
|
-
}
|
|
309
|
-
get(key) {
|
|
310
|
-
const value = this.entries.get(key);
|
|
311
|
-
if (value !== undefined) {
|
|
312
|
-
this.entries.delete(key);
|
|
313
|
-
this.entries.set(key, value);
|
|
314
|
-
}
|
|
315
|
-
return value;
|
|
316
|
-
}
|
|
317
|
-
set(key, value) {
|
|
318
|
-
this.entries.delete(key);
|
|
319
|
-
this.entries.set(key, value);
|
|
320
|
-
while (this.entries.size > this.capacity)
|
|
321
|
-
this.entries.delete(this.entries.keys().next().value);
|
|
322
|
-
}
|
|
323
|
-
clear() {
|
|
324
|
-
this.entries.clear();
|
|
325
|
-
}
|
|
326
|
-
get size() {
|
|
327
|
-
return this.entries.size;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
class MtIncompleteTableError extends Error {
|
|
332
|
-
constructor() {
|
|
333
|
-
super('The table response did not contain the complete requested result.');
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function uniqueRows(rows, getRowId) {
|
|
337
|
-
const ids = rows.map(getRowId);
|
|
338
|
-
return (ids.every((id) => typeof id === 'string' && id.length > 0) &&
|
|
339
|
-
new Set(ids).size === ids.length);
|
|
340
|
-
}
|
|
341
|
-
/** Load every page of a small result before permitting client aggregation. A threshold is never a truncation limit. */
|
|
342
|
-
async function loadMtTableResult(source, query, signal, getRowId, clientAnalysisThreshold = 1000) {
|
|
343
|
-
if (!Number.isSafeInteger(query.offset) ||
|
|
344
|
-
query.offset < 0 ||
|
|
345
|
-
!Number.isSafeInteger(query.limit) ||
|
|
346
|
-
query.limit <= 0)
|
|
347
|
-
throw new Error('Invalid table page');
|
|
348
|
-
const first = await source.load(query, signal);
|
|
349
|
-
signal.throwIfAborted();
|
|
350
|
-
if (!Number.isSafeInteger(first.totalCount) ||
|
|
351
|
-
first.totalCount < 0 ||
|
|
352
|
-
first.rows.length > first.totalCount ||
|
|
353
|
-
!uniqueRows(first.rows, getRowId))
|
|
354
|
-
throw new MtIncompleteTableError();
|
|
355
|
-
if (source.processing === 'client') {
|
|
356
|
-
if (!first.complete ||
|
|
357
|
-
first.rows.length !== first.totalCount ||
|
|
358
|
-
!uniqueRows(first.rows, getRowId))
|
|
359
|
-
throw new MtIncompleteTableError();
|
|
360
|
-
return first;
|
|
361
|
-
}
|
|
362
|
-
if (first.totalCount > clientAnalysisThreshold) {
|
|
363
|
-
const expected = Math.max(0, Math.min(query.limit, first.totalCount - query.offset));
|
|
364
|
-
if (first.rows.length !== expected)
|
|
365
|
-
throw new MtIncompleteTableError();
|
|
366
|
-
return { ...first, complete: false };
|
|
367
|
-
}
|
|
368
|
-
const pages = [];
|
|
369
|
-
// A non-zero initial page cannot prove that earlier rows were loaded.
|
|
370
|
-
let offset = 0;
|
|
371
|
-
while (offset < first.totalCount) {
|
|
372
|
-
signal.throwIfAborted();
|
|
373
|
-
const page = offset === query.offset
|
|
374
|
-
? first
|
|
375
|
-
: await source.load({ ...query, offset }, signal);
|
|
376
|
-
signal.throwIfAborted();
|
|
377
|
-
if (page.totalCount !== first.totalCount ||
|
|
378
|
-
page.rows.length === 0 ||
|
|
379
|
-
page.rows.length > query.limit)
|
|
380
|
-
throw new MtIncompleteTableError();
|
|
381
|
-
pages.push(...page.rows);
|
|
382
|
-
offset += page.rows.length;
|
|
383
|
-
}
|
|
384
|
-
if (pages.length !== first.totalCount || !uniqueRows(pages, getRowId))
|
|
385
|
-
throw new MtIncompleteTableError();
|
|
386
|
-
return { ...first, rows: pages, complete: true };
|
|
387
|
-
}
|
|
388
|
-
function mtClientTableSource(key, rows) {
|
|
389
|
-
return {
|
|
390
|
-
key,
|
|
391
|
-
scopeKey: key,
|
|
392
|
-
processing: 'client',
|
|
393
|
-
capabilities: {
|
|
394
|
-
sort: true,
|
|
395
|
-
filter: true,
|
|
396
|
-
group: true,
|
|
397
|
-
pivot: true,
|
|
398
|
-
charts: true,
|
|
399
|
-
exportAll: true,
|
|
400
|
-
},
|
|
401
|
-
load: async (_query, signal) => {
|
|
402
|
-
signal.throwIfAborted();
|
|
403
|
-
return { rows, totalCount: rows.length, complete: true };
|
|
404
|
-
},
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
|
|
408
397
|
/** Saved roles are configuration, never authority to enable a now-unavailable operation. */
|
|
409
398
|
function reconcileMtTableView(state, columns, policy) {
|
|
410
399
|
const definitions = new Map(columns.map((column, index) => [
|
|
@@ -1345,5 +1334,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
1345
1334
|
* Generated bundle index. Do not edit.
|
|
1346
1335
|
*/
|
|
1347
1336
|
|
|
1348
|
-
export {
|
|
1337
|
+
export { MtDataTableComponent, MtDatasetCache, MtDatasetScheduler, MtIncompleteTableError, MtTablePreferences, captureMtTableChart, loadMtTableResult, mtClientTableSource, mtTablePreferenceKey, parseMtTableCharts, reconcileMtTableView, restoreMtTableChart };
|
|
1349
1338
|
//# sourceMappingURL=masterteam-data-table-legacy.mjs.map
|