@masterteam/data-table 0.0.8 → 0.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masterteam/data-table",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Masterteam entity-aware tables and portal renderer for the independent data grid.",
5
5
  "publishConfig": {
6
6
  "directory": "../../../dist/masterteam/data-table",
@@ -14,9 +14,9 @@
14
14
  "@angular/forms": "^21.2.8",
15
15
  "@jsverse/transloco": "^8.3.0",
16
16
  "primeng": "21.1.5",
17
- "@masterteam/components": "^0.0.339",
17
+ "@masterteam/components": "^0.0.342",
18
18
  "@masterteam/icons": "^0.0.17",
19
- "@masterteam/data-grid": "^0.0.5"
19
+ "@masterteam/data-grid": "^0.0.6"
20
20
  },
21
21
  "dependencies": {
22
22
  "tslib": "^2.8.1"
@@ -1,4 +1,5 @@
1
1
  import { InjectionToken, EnvironmentProviders } from '@angular/core';
2
+ import { MtChartState } from '@masterteam/data-grid';
2
3
 
3
4
  interface MtTableScopeIdentity {
4
5
  readonly application: string;
@@ -14,6 +15,42 @@ interface MtDataTableConfiguration {
14
15
  declare const MT_DATA_TABLE_CONFIGURATION: InjectionToken<MtDataTableConfiguration>;
15
16
  /** Root installation of the data-table configuration (portal and Studio). */
16
17
  declare function provideMTDataTables(configuration: MtDataTableConfiguration | (() => MtDataTableConfiguration)): EnvironmentProviders;
18
+ /** One grid on a page: its level, optional module and role (e.g. `client-list-native`). */
19
+ interface MtTableViewIdentity {
20
+ readonly level: number | string;
21
+ readonly module?: string | null;
22
+ readonly role: string;
23
+ }
24
+ /** The browser-storage key of a view's preferences; charts append `:charts:<scope>`. */
25
+ declare function mtTablePreferenceKey(identity: MtTableScopeIdentity, view: MtTableViewIdentity): string;
26
+ /** The charts of one grid: its view identity and a scope within it (`'default'`). */
27
+ interface MtGridChartStoreKey {
28
+ readonly view: MtTableViewIdentity;
29
+ readonly scope: string;
30
+ }
31
+ /**
32
+ * Where `mt-standard-grid` keeps its charts (`chartPersistence`). The default is the
33
+ * browser-only `MtLocalChartStore`; `provideMTGridServerCharts()` installs the backend one.
34
+ */
35
+ interface MtGridChartStore {
36
+ /**
37
+ * The saved charts, oldest first. A store that also asks a server answers with its local
38
+ * copy, then calls `onRemoteChange` once if the server holds a different set and nothing
39
+ * was written for the key in the meantime; the grid adopts it only when the user has not
40
+ * changed a chart since the restore.
41
+ */
42
+ read(key: MtGridChartStoreKey, onRemoteChange?: (charts: readonly MtChartState[]) => void): Promise<readonly MtChartState[]>;
43
+ /** Replaces the saved charts; fire-and-forget (the grid debounces its calls). */
44
+ write(key: MtGridChartStoreKey, charts: readonly MtChartState[]): void;
45
+ /** Removes the saved charts. */
46
+ clear(key: MtGridChartStoreKey): void;
47
+ /** Optional: warms a cache for many keys at once, e.g. every grid of a level. */
48
+ prefetch?(hint: {
49
+ readonly level: number | string;
50
+ }): Promise<void>;
51
+ }
52
+ /** The chart store of every `mt-standard-grid` below it; `MtLocalChartStore` when absent. */
53
+ declare const MT_GRID_CHART_STORE: InjectionToken<MtGridChartStore>;
17
54
 
18
- export { MT_DATA_TABLE_CONFIGURATION, provideMTDataTables };
19
- export type { MtDataTableConfiguration, MtTableScopeIdentity };
55
+ export { MT_DATA_TABLE_CONFIGURATION, MT_GRID_CHART_STORE, mtTablePreferenceKey, provideMTDataTables };
56
+ export type { MtDataTableConfiguration, MtGridChartStore, MtGridChartStoreKey, MtTableScopeIdentity, MtTableViewIdentity };
@@ -2,8 +2,8 @@ import { MtTableText } from '@masterteam/data-table';
2
2
  export * from '@masterteam/data-table';
3
3
  import { MtSortModel, MtFilterModel, MtColDef, MtCreateRangeChartParams, MtChartModel, MtGridApi, MtGridViewState, MtColumnDef, MtCellRenderer, MtDetailCellRendererParams, MtDataGridComponent, MtSideBar, MtContextMenuItem } from '@masterteam/data-grid';
4
4
  import { TableAction } from '@masterteam/components/table';
5
- import { MtTableScopeIdentity } from '@masterteam/data-table/config';
6
- export { MT_DATA_TABLE_CONFIGURATION, MtDataTableConfiguration, MtTableScopeIdentity, provideMTDataTables } from '@masterteam/data-table/config';
5
+ import { MtTableViewIdentity } from '@masterteam/data-table/config';
6
+ export { MT_DATA_TABLE_CONFIGURATION, MtDataTableConfiguration, MtTableScopeIdentity, MtTableViewIdentity, mtTablePreferenceKey, provideMTDataTables } from '@masterteam/data-table/config';
7
7
  import * as _angular_core from '@angular/core';
8
8
  import { MTMenuItem } from '@masterteam/components/menu';
9
9
 
@@ -106,12 +106,6 @@ declare function captureMtTableChart<T>(model: MtChartModel, api: MtGridApi<T>,
106
106
  declare function restoreMtTableChart<T>(saved: MtSavedTableChart, api: MtGridApi<T>): MtCreateRangeChartParams | null;
107
107
  declare function parseMtTableCharts(value: unknown): readonly MtSavedTableChart[];
108
108
 
109
- interface MtTableViewIdentity {
110
- readonly level: number | string;
111
- readonly module?: string | null;
112
- readonly role: string;
113
- }
114
- declare function mtTablePreferenceKey(identity: MtTableScopeIdentity, view: MtTableViewIdentity): string;
115
109
  /** Local storage is optional (private browsing/quota/security errors must not break a table). */
116
110
  declare class MtTablePreferences {
117
111
  private readonly configuration;
@@ -253,5 +247,5 @@ declare class MtDataTableComponent<T extends object> {
253
247
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<MtDataTableComponent<any>, "mt-data-table", never, { "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "columns": { "alias": "columns"; "required": true; "isSignal": true; }; "getRowId": { "alias": "getRowId"; "required": true; "isSignal": true; }; "source": { "alias": "source"; "required": false; "isSignal": true; }; "profile": { "alias": "profile"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "showHeading": { "alias": "showHeading"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "rowHeight": { "alias": "rowHeight"; "required": false; "isSignal": true; }; "fitColumns": { "alias": "fitColumns"; "required": false; "isSignal": true; }; "rowActions": { "alias": "rowActions"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "masterDetail": { "alias": "masterDetail"; "required": false; "isSignal": true; }; "detailRenderer": { "alias": "detailRenderer"; "required": false; "isSignal": true; }; "detailRendererParams": { "alias": "detailRendererParams"; "required": false; "isSignal": true; }; "isRowMaster": { "alias": "isRowMaster"; "required": false; "isSignal": true; }; "detailAutoHeight": { "alias": "detailAutoHeight"; "required": false; "isSignal": true; }; "detailHeight": { "alias": "detailHeight"; "required": false; "isSignal": true; }; "selectable": { "alias": "selectable"; "required": false; "isSignal": true; }; "groupable": { "alias": "groupable"; "required": false; "isSignal": true; }; "readOnly": { "alias": "readOnly"; "required": false; "isSignal": true; }; "viewIdentity": { "alias": "viewIdentity"; "required": false; "isSignal": true; }; "exporter": { "alias": "exporter"; "required": false; "isSignal": true; }; "exportFormats": { "alias": "exportFormats"; "required": false; "isSignal": true; }; }, { "columnLoadRequested": "columnLoadRequested"; "rowClick": "rowClick"; "selectionChange": "selectionChange"; "focusChange": "focusChange"; "viewStateChange": "viewStateChange"; }, never, ["[tableActions]"], true, never>;
254
248
  }
255
249
 
256
- export { MtDataTableComponent, MtDatasetCache, MtDatasetScheduler, MtIncompleteTableError, MtTablePreferences, captureMtTableChart, loadMtTableResult, mtClientTableSource, mtTablePreferenceKey, parseMtTableCharts, reconcileMtTableView, restoreMtTableChart };
257
- export type { MtDataTableProfile, MtSavedTableChart, MtTableCapabilities, MtTableDataSource, MtTableExportFormat, MtTableExportRequest, MtTableExporter, MtTablePage, MtTableQuery, MtTableRowAction, MtTableViewIdentity };
250
+ export { MtDataTableComponent, MtDatasetCache, MtDatasetScheduler, MtIncompleteTableError, MtTablePreferences, captureMtTableChart, loadMtTableResult, mtClientTableSource, parseMtTableCharts, reconcileMtTableView, restoreMtTableChart };
251
+ export type { MtDataTableProfile, MtSavedTableChart, MtTableCapabilities, MtTableDataSource, MtTableExportFormat, MtTableExportRequest, MtTableExporter, MtTablePage, MtTableQuery, MtTableRowAction };
@@ -1,9 +1,11 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { Signal, TemplateRef } from '@angular/core';
2
+ import { Signal, InjectionToken, Provider, TemplateRef } from '@angular/core';
3
3
  import { EntityData, EntityViewType } from '@masterteam/components/entities';
4
4
  import * as _masterteam_data_grid from '@masterteam/data-grid';
5
- import { MtChartCategoryValue, MtCellRendererParams, MtColumnDef, MtExportCellParams, MtGridApi, MtColDef, MtCellRenderer, MtDetailCellRendererParams, MtContextMenuItem, MtRowClassParams, MtGridViewState, MtGridReadyEvent, MtSortModel, MtFilterChangedEvent, MtPaginationChangedEvent, MtRowGroupOpenedEvent, MtSideBarDef, MtRowSelectionOptions, MtStatusBarOptions, MtRowClickedEvent, MtSelectionChangedEvent, MtGetContextMenuItemsParams } from '@masterteam/data-grid';
5
+ import { MtChartCategoryValue, MtCellRendererParams, MtColumnDef, MtExportCellParams, MtGridApi, MtColDef, MtCellRenderer, MtDetailCellRendererParams, MtContextMenuItem, MtRowClassParams, MtGridViewState, MtGridReadyEvent, MtSortModel, MtFilterChangedEvent, MtPaginationChangedEvent, MtRowGroupOpenedEvent, MtSideBarDef, MtRowSelectionOptions, MtStatusBarOptions, MtCellSelectionOptions, MtChartStateChangedEvent, MtCellSelectionChangedEvent, MtChartType, MtRowClickedEvent, MtSelectionChangedEvent, MtGetContextMenuItemsParams, MtChartState } from '@masterteam/data-grid';
6
6
  import { TablePrintConfig, TableAction, TableActionShape, ColumnDef } from '@masterteam/components/table';
7
+ import { MtTableViewIdentity, MtGridChartStore, MtGridChartStoreKey, MtTableScopeIdentity } from '@masterteam/data-table/config';
8
+ import { MTMenuItem } from '@masterteam/components/menu';
7
9
  import { Popover } from 'primeng/popover';
8
10
 
9
11
  type MtCellScalar = string | number | boolean | Date | null;
@@ -85,6 +87,15 @@ declare const TEXT: {
85
87
  readonly incomplete: readonly ["Whole-table analysis is unavailable until the complete result is loaded.", "يتاح تحليل الجدول بعد تحميل جميع النتائج."];
86
88
  readonly chart: readonly ["Chart table", "رسم بياني للجدول"];
87
89
  readonly chartSelection: readonly ["Chart selection", "رسم بياني للتحديد"];
90
+ readonly chartAction: readonly ["Chart", "مخطط"];
91
+ readonly chartTypes: readonly ["Chart type", "نوع المخطط"];
92
+ readonly chartColumn: readonly ["Column", "أعمدة"];
93
+ readonly chartBar: readonly ["Bar", "أشرطة"];
94
+ readonly chartLine: readonly ["Line", "خطي"];
95
+ readonly chartPie: readonly ["Pie", "دائري"];
96
+ readonly chartDoughnut: readonly ["Doughnut", "حلقي"];
97
+ readonly chartNeedsCells: readonly ["Select cells to create a chart", "حدّد خلايا لإنشاء مخطط"];
98
+ readonly chartThisPage: readonly ["this page", "هذه الصفحة"];
88
99
  };
89
100
  type MtTableTextKey = keyof typeof TEXT;
90
101
  /** Product translations override package defaults. Language changes remain reactive. */
@@ -138,6 +149,11 @@ interface MtStandardGridServerPage {
138
149
  readonly page: number;
139
150
  readonly pageSize: number;
140
151
  }
152
+ /** Where a grid keeps its charts: its view identity and a scope within it (`'default'`). */
153
+ interface MtStandardGridChartPersistence {
154
+ readonly view: MtTableViewIdentity;
155
+ readonly scope?: string;
156
+ }
141
157
  /** The formats of the standard Export menu. */
142
158
  type MtStandardGridExportFormat = 'csv' | 'excel' | 'pdf';
143
159
  /** A detail row under expandable rows (master/detail). */
@@ -151,8 +167,9 @@ interface MtStandardGridDetail<T> {
151
167
  * The one standard grid for product pages (user decision 2026-11-03). Every page that shows
152
168
  * the new grid renders this component, so every grid has the same header (sort, menu and
153
169
  * filter on every data column; the menu only on control columns), the same geometry, the same
154
- * top strip (group panel, quick filter, pivot zone while pivoting), the same Columns and
155
- * Filters side bar, status bar, pager, context menu, CSV/Excel export and charts.
170
+ * top strip (group panel, quick filter, Chart button, pivot zone while pivoting), the same
171
+ * Columns, Filters and Charts side bar, status bar, pager, context menu, CSV/Excel export and
172
+ * live charts that dock into the Charts panel.
156
173
  *
157
174
  * A page supplies data, entity columns, the row id, permissions and behaviour hooks only;
158
175
  * there is deliberately no input for header templates, heights or feature toggles.
@@ -193,6 +210,11 @@ declare class MtStandardGridComponent<T extends object> {
193
210
  readonly exporter: _angular_core.InputSignal<((format: MtStandardGridExportFormat) => void) | null>;
194
211
  /** Page-specific row actions, appended to the standard context menu of a data row. */
195
212
  readonly rowMenuItems: _angular_core.InputSignal<((row: T) => readonly MtContextMenuItem<T>[]) | null>;
213
+ /**
214
+ * The row's primary actions (an "Open record"), shown first: above the standard
215
+ * clipboard, export and chart items, with a separator after them.
216
+ */
217
+ readonly rowMenuLeadItems: _angular_core.InputSignal<((row: T) => readonly MtContextMenuItem<T>[]) | null>;
196
218
  /** Server paging; sorting, filtering and paging then belong to the owner (external data). */
197
219
  readonly server: _angular_core.InputSignal<MtStandardGridServerPage | null>;
198
220
  /** The pager. A page whose grid scrolls every row inside its own viewport turns it off. */
@@ -223,6 +245,13 @@ declare class MtStandardGridComponent<T extends object> {
223
245
  readonly emptyDescription: _angular_core.InputSignal<string | null>;
224
246
  /** A saved view applied once when the grid is ready. */
225
247
  readonly view: _angular_core.InputSignal<MtGridViewState | null>;
248
+ /**
249
+ * Keeps the grid's charts per view (and `scope`, default `'default'`) in the
250
+ * `MT_GRID_CHART_STORE`, else the browser-only `MtLocalChartStore`. Saved charts return
251
+ * docked into the Charts panel once the grid has loaded; every change is saved 600ms
252
+ * later. Null (the default) keeps charts for the visit only.
253
+ */
254
+ readonly chartPersistence: _angular_core.InputSignal<MtStandardGridChartPersistence | null>;
226
255
  readonly gridReady: _angular_core.OutputEmitterRef<MtGridReadyEvent<T>>;
227
256
  readonly rowClicked: _angular_core.OutputEmitterRef<T>;
228
257
  readonly selectionChanged: _angular_core.OutputEmitterRef<readonly T[]>;
@@ -232,7 +261,7 @@ declare class MtStandardGridComponent<T extends object> {
232
261
  readonly rowGroupOpened: _angular_core.OutputEmitterRef<MtRowGroupOpenedEvent<T>>;
233
262
  /** The captured view after any column, sort, filter or grouping change (persist it per user). */
234
263
  readonly viewChanged: _angular_core.OutputEmitterRef<MtGridViewState>;
235
- /** A chart was opened, changed or closed (persist the chart session). */
264
+ /** A chart was created, opened, docked, moved, changed, restored or removed. */
236
265
  readonly chartsChanged: _angular_core.OutputEmitterRef<void>;
237
266
  /** Fixed height in px; in `'auto'` mode the grid sizes itself and this is its fallback. */
238
267
  protected readonly gridHeight: _angular_core.Signal<number>;
@@ -263,10 +292,15 @@ declare class MtStandardGridComponent<T extends object> {
263
292
  protected readonly detailRenderer: _angular_core.Signal<MtCellRenderer<T> | undefined>;
264
293
  protected readonly detailParams: _angular_core.Signal<MtDetailCellRendererParams<T, any> | undefined>;
265
294
  protected readonly isRowMaster: _angular_core.Signal<((row: T) => boolean) | undefined>;
295
+ /** The charts' context line; a server page's charts cover the loaded page only. */
266
296
  protected readonly chartTitle: _angular_core.Signal<string>;
267
297
  protected readonly csvAllowed: _angular_core.Signal<boolean>;
268
298
  protected readonly excelAllowed: _angular_core.Signal<boolean>;
299
+ /** A cell range exists: the Chart button charts it. */
300
+ protected readonly hasRange: _angular_core.WritableSignal<boolean>;
301
+ protected readonly chartTypeItems: _angular_core.Signal<MTMenuItem[]>;
269
302
  protected readonly statusBar: MtStatusBarOptions;
303
+ protected readonly cellSelection: MtCellSelectionOptions;
270
304
  protected readonly pageSizes: readonly number[];
271
305
  protected readonly fit: {
272
306
  readonly type: "fitGridWidth";
@@ -279,7 +313,48 @@ declare class MtStandardGridComponent<T extends object> {
279
313
  private nextIdentity;
280
314
  private identity;
281
315
  private applyingView;
316
+ private readonly chartStore;
317
+ private readonly tableConfiguration;
318
+ /**
319
+ * The identity the stores key charts by (application, tenant, user, actor, template), read
320
+ * afresh each time: the configuration's `identity` need not be signal-backed.
321
+ */
322
+ private chartIdentity;
323
+ /** The grid's api once ready, for the chart restore. */
324
+ private readonly readyApi;
325
+ private chartSession;
326
+ /** Grid chart events caused by a restore or a key change are not user changes. */
327
+ private chartEventsMuted;
328
+ private chartWrite;
329
+ private chartWriteTimer?;
330
+ private destroyed;
331
+ constructor();
282
332
  protected onReady(event: MtGridReadyEvent<T>): void;
333
+ /**
334
+ * Starts a session per persistence key and identity, and restores its charts, docked,
335
+ * once the grid is ready and loaded: not loading, and holding rows or done with a load. A
336
+ * new key first saves what is pending under the old one and removes the old key's charts;
337
+ * a new identity (another user or actor) drops the pending change instead, since the
338
+ * store would save it for the new identity.
339
+ */
340
+ private syncCharts;
341
+ private restoreSavedCharts;
342
+ /** A later server answer replaces the restored charts while the user has changed none. */
343
+ private adoptRemoteCharts;
344
+ /** Removes every chart; a pending "Chart removed" Undo would put its chart into the new set. */
345
+ private removeCharts;
346
+ private muteChartEvents;
347
+ /** Every chart action: `chartsChanged`, and a save 600ms after the user's last change. */
348
+ protected onChartStateChanged(event: MtChartStateChangedEvent): void;
349
+ private scheduleChartWrite;
350
+ /** Saves the pending change now; an empty set clears the stored one. */
351
+ private flushChartWrite;
352
+ protected onCellSelection(event: MtCellSelectionChangedEvent): void;
353
+ /**
354
+ * The Chart button: a live chart of the current cell ranges, open on the page and not
355
+ * following later selections. Without a type the grid picks the recommended one.
356
+ */
357
+ protected createChart(chartType?: MtChartType): void;
283
358
  protected onViewChange(): void;
284
359
  protected onPaginationChanged(event: MtPaginationChangedEvent): void;
285
360
  /** The Export menu and the Export / Print buttons: the owner's exporter, else the grid's. */
@@ -292,8 +367,133 @@ declare class MtStandardGridComponent<T extends object> {
292
367
  /** The standard context menu: default items, an Export submenu, then the page's row items. */
293
368
  protected readonly contextMenu: (params: MtGetContextMenuItemsParams<T>) => readonly MtContextMenuItem<T>[];
294
369
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<MtStandardGridComponent<any>, never>;
295
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<MtStandardGridComponent<any>, "mt-standard-grid", never, { "rows": { "alias": "rows"; "required": true; "isSignal": true; }; "columns": { "alias": "columns"; "required": true; "isSignal": true; }; "rowId": { "alias": "rowId"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": true; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "rowHeight": { "alias": "rowHeight"; "required": false; "isSignal": true; }; "selection": { "alias": "selection"; "required": false; "isSignal": true; }; "exportable": { "alias": "exportable"; "required": false; "isSignal": true; }; "exportButtons": { "alias": "exportButtons"; "required": false; "isSignal": true; }; "exportName": { "alias": "exportName"; "required": false; "isSignal": true; }; "exportFormats": { "alias": "exportFormats"; "required": false; "isSignal": true; }; "exporter": { "alias": "exporter"; "required": false; "isSignal": true; }; "rowMenuItems": { "alias": "rowMenuItems"; "required": false; "isSignal": true; }; "server": { "alias": "server"; "required": false; "isSignal": true; }; "paged": { "alias": "paged"; "required": false; "isSignal": true; }; "pageSize": { "alias": "pageSize"; "required": false; "isSignal": true; }; "clickableRows": { "alias": "clickableRows"; "required": false; "isSignal": true; }; "cellClickFilter": { "alias": "cellClickFilter"; "required": false; "isSignal": true; }; "rowClass": { "alias": "rowClass"; "required": false; "isSignal": true; }; "detail": { "alias": "detail"; "required": false; "isSignal": true; }; "chartContext": { "alias": "chartContext"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; "emptyTitle": { "alias": "emptyTitle"; "required": false; "isSignal": true; }; "emptyDescription": { "alias": "emptyDescription"; "required": false; "isSignal": true; }; "view": { "alias": "view"; "required": false; "isSignal": true; }; }, { "gridReady": "gridReady"; "rowClicked": "rowClicked"; "selectionChanged": "selectionChanged"; "sortChanged": "sortChanged"; "filterChanged": "filterChanged"; "paginationChanged": "paginationChanged"; "rowGroupOpened": "rowGroupOpened"; "viewChanged": "viewChanged"; "chartsChanged": "chartsChanged"; }, never, ["[mtGridToolbar]"], true, never>;
370
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<MtStandardGridComponent<any>, "mt-standard-grid", never, { "rows": { "alias": "rows"; "required": true; "isSignal": true; }; "columns": { "alias": "columns"; "required": true; "isSignal": true; }; "rowId": { "alias": "rowId"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": true; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "rowHeight": { "alias": "rowHeight"; "required": false; "isSignal": true; }; "selection": { "alias": "selection"; "required": false; "isSignal": true; }; "exportable": { "alias": "exportable"; "required": false; "isSignal": true; }; "exportButtons": { "alias": "exportButtons"; "required": false; "isSignal": true; }; "exportName": { "alias": "exportName"; "required": false; "isSignal": true; }; "exportFormats": { "alias": "exportFormats"; "required": false; "isSignal": true; }; "exporter": { "alias": "exporter"; "required": false; "isSignal": true; }; "rowMenuItems": { "alias": "rowMenuItems"; "required": false; "isSignal": true; }; "rowMenuLeadItems": { "alias": "rowMenuLeadItems"; "required": false; "isSignal": true; }; "server": { "alias": "server"; "required": false; "isSignal": true; }; "paged": { "alias": "paged"; "required": false; "isSignal": true; }; "pageSize": { "alias": "pageSize"; "required": false; "isSignal": true; }; "clickableRows": { "alias": "clickableRows"; "required": false; "isSignal": true; }; "cellClickFilter": { "alias": "cellClickFilter"; "required": false; "isSignal": true; }; "rowClass": { "alias": "rowClass"; "required": false; "isSignal": true; }; "detail": { "alias": "detail"; "required": false; "isSignal": true; }; "chartContext": { "alias": "chartContext"; "required": false; "isSignal": true; }; "search": { "alias": "search"; "required": false; "isSignal": true; }; "emptyTitle": { "alias": "emptyTitle"; "required": false; "isSignal": true; }; "emptyDescription": { "alias": "emptyDescription"; "required": false; "isSignal": true; }; "view": { "alias": "view"; "required": false; "isSignal": true; }; "chartPersistence": { "alias": "chartPersistence"; "required": false; "isSignal": true; }; }, { "gridReady": "gridReady"; "rowClicked": "rowClicked"; "selectionChanged": "selectionChanged"; "sortChanged": "sortChanged"; "filterChanged": "filterChanged"; "paginationChanged": "paginationChanged"; "rowGroupOpened": "rowGroupOpened"; "viewChanged": "viewChanged"; "chartsChanged": "chartsChanged"; }, never, ["[mtGridToolbar]"], true, never>;
371
+ }
372
+
373
+ /**
374
+ * The saved charts of one grid, oldest first: definitions only (column ids, stable row ids,
375
+ * options and placement), never chart data or record values.
376
+ */
377
+ interface MtGridChartDocument {
378
+ readonly version: 2;
379
+ readonly charts: readonly MtChartState[];
380
+ }
381
+ /** Most charts one grid keeps; older ones are dropped first. */
382
+ declare const MT_GRID_CHARTS_MAX = 20;
383
+ /** A range with more row ids than this is saved as `rowIds: null` (every row). */
384
+ declare const MT_GRID_CHART_MAX_ROW_IDS = 1000;
385
+ /** Largest saved document, in characters (browser storage) or UTF-8 bytes (server). */
386
+ declare const MT_GRID_CHARTS_MAX_LENGTH = 131072;
387
+ /**
388
+ * Reads a saved chart set: a v2 document, a v2 chart array (the server's `charts`) or a
389
+ * version-1 array, which migrates. Invalid charts are dropped one by one, duplicate ids
390
+ * keep their first chart, and only the newest {@link MT_GRID_CHARTS_MAX} survive; anything
391
+ * else reads as no charts.
392
+ */
393
+ declare function parseMtGridCharts(value: unknown): readonly MtChartState[];
394
+ /** The newest charts whose measure fits `limit`, dropping the oldest first; may be empty. */
395
+ declare function fitMtGridCharts(charts: readonly MtChartState[], measure: (charts: readonly MtChartState[]) => number, limit?: number): readonly MtChartState[];
396
+ /**
397
+ * The v2 document text to store: the charts validated, then the oldest dropped until the
398
+ * text fits `limit` characters. Null when there is nothing to keep (no charts, or not even
399
+ * one fits), which means the stored document is removed rather than left stale.
400
+ */
401
+ declare function serializeMtGridCharts(charts: readonly MtChartState[], limit?: number): string | null;
402
+
403
+ /**
404
+ * The default chart store: the browser's local storage, per signed-in identity. The key is
405
+ * the view's preference key plus `:charts:<scope>` (the one Studio used for its version-1
406
+ * charts, which therefore migrate). Without an identity it keeps nothing; storage errors
407
+ * (private browsing, quota, blocked storage) never reach the grid.
408
+ */
409
+ declare class MtLocalChartStore implements MtGridChartStore {
410
+ private readonly configuration;
411
+ /** The storage key of a grid's charts; null without an identity. */
412
+ storageKey(key: MtGridChartStoreKey): string | null;
413
+ /** The saved charts, read synchronously. */
414
+ readNow(key: MtGridChartStoreKey): readonly MtChartState[];
415
+ read(key: MtGridChartStoreKey): Promise<readonly MtChartState[]>;
416
+ write(key: MtGridChartStoreKey, charts: readonly MtChartState[]): void;
417
+ clear(key: MtGridChartStoreKey): void;
418
+ private remove;
419
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<MtLocalChartStore, never>;
420
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<MtLocalChartStore>;
421
+ }
422
+ /** Options of {@link provideMTGridServerCharts}. */
423
+ interface MtGridServerChartsOptions {
424
+ /** Relative URL of the caller's chart sets; the host adds the API base. Default `grid-charts/me`. */
425
+ readonly endpoint?: string;
426
+ }
427
+ declare const MT_GRID_SERVER_CHARTS_OPTIONS: InjectionToken<MtGridServerChartsOptions>;
428
+ /**
429
+ * The server key of a grid's charts: the JSON of application, template, level, module, role
430
+ * and scope. A key over 400 characters becomes `h:<FNV-1a 64 hex>:<first 300 characters>`.
431
+ * User, actor and tenant are left out: the server takes them from the token.
432
+ */
433
+ declare function mtGridChartServerKey(identity: Pick<MtTableScopeIdentity, 'application' | 'template'>, key: MtGridChartStoreKey): string;
434
+ /**
435
+ * Charts that follow the user across browsers: the local store first, then the caller's
436
+ * `grid-charts` set on the server (`provideMTGridServerCharts`).
437
+ *
438
+ * - `read` answers with the local copy at once, then asks the server (or a level prefetch).
439
+ * When the server's stored set differs and nothing was written for the key since the read
440
+ * began, it replaces the local copy and calls `onRemoteChange`. A key the server has never
441
+ * stored keeps the local copy, which a non-empty local set then seeds on the server: the
442
+ * version-1 Studio charts that migrate locally, or a grid that used the local store before.
443
+ * - `write` and `clear` update the local copy at once, then PUT the set; a clear PUTs an empty
444
+ * set, so other browsers see the removal instead of a key the server never stored. One
445
+ * request per key runs at a time and the latest one waits for it. Failures are silent:
446
+ * the key stays marked unsynced in local storage and the next write, or the next read,
447
+ * sends it again, so a set changed just before a refresh is not replaced by the older
448
+ * server copy.
449
+ * - What it remembers in memory (prefetched levels, the sets it knows) is per signed-in
450
+ * user and actor, since the server key leaves them out: switching actor never answers
451
+ * with the previous actor's sets.
452
+ */
453
+ declare class MtServerChartStore implements MtGridChartStore {
454
+ private readonly http;
455
+ private readonly local;
456
+ private readonly configuration;
457
+ private readonly endpoint;
458
+ /** Writes per server key: a server answer that started before the latest write loses. */
459
+ private readonly writes;
460
+ /** Server sets known without a GET: a level prefetch, or what this store sent last. */
461
+ private readonly known;
462
+ /** Level prefetches; true once the level's sets are in `known`. */
463
+ private readonly levels;
464
+ /** The request running per server key and the latest one waiting for it. */
465
+ private readonly sending;
466
+ /** The server key of a grid's charts; null without an identity. */
467
+ gridKey(key: MtGridChartStoreKey): string | null;
468
+ /** A server key (or a level) of the signed-in user and actor; null without an identity. */
469
+ private slot;
470
+ read(key: MtGridChartStoreKey, onRemoteChange?: (charts: readonly MtChartState[]) => void): Promise<readonly MtChartState[]>;
471
+ write(key: MtGridChartStoreKey, charts: readonly MtChartState[]): void;
472
+ clear(key: MtGridChartStoreKey): void;
473
+ /** One GET for every set the caller saved at a numeric level; later reads use it. */
474
+ prefetch(hint: {
475
+ readonly level: number | string;
476
+ }): Promise<void>;
477
+ /**
478
+ * The server's set: known, from a level prefetch (absent there = never stored), else a GET;
479
+ * null when the server could not answer.
480
+ */
481
+ private remote;
482
+ /**
483
+ * PUTs the set after the request already running for the key. An empty set is PUT too (not
484
+ * DELETEd): the server then knows the charts were removed, not never saved.
485
+ */
486
+ private send;
487
+ private unsynced;
488
+ private mark;
489
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<MtServerChartStore, never>;
490
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<MtServerChartStore>;
296
491
  }
492
+ /**
493
+ * Keeps every `mt-standard-grid` chart set below it on the server as well as locally. Use it
494
+ * in application providers, or in a component's `providers` for that subtree only.
495
+ */
496
+ declare function provideMTGridServerCharts(options?: MtGridServerChartsOptions): Provider[];
297
497
 
298
498
  /** The standard row-actions column id. */
299
499
  declare const MT_ACTIONS_COLUMN_ID = "$actions";
@@ -362,5 +562,5 @@ declare function mtTableColumns<T extends object>(columns: readonly ColumnDef[],
362
562
  readonly rtl?: boolean;
363
563
  }): MtColumnDef<T>[];
364
564
 
365
- export { MT_ACTIONS_COLUMN_ID, MtActionsCell, MtDataTableEntityCell, MtStandardGridComponent, MtTableText, MtTemplateCell, mtActionsColumn, mtEntityCategoryValues, mtEntityCellValues, mtEntityColumn, mtEntityExportValue, mtIsControlColumn, mtStandardColumns, mtTableColumns, mtTablePrintConfiguration };
366
- export type { MtActionsColumnOptions, MtCellScalar, MtEntityCellValues, MtEntityColumnOptions, MtStandardGridDetail, MtStandardGridExportFormat, MtStandardGridServerPage, MtTableTextKey };
565
+ export { MT_ACTIONS_COLUMN_ID, MT_GRID_CHARTS_MAX, MT_GRID_CHARTS_MAX_LENGTH, MT_GRID_CHART_MAX_ROW_IDS, MT_GRID_SERVER_CHARTS_OPTIONS, MtActionsCell, MtDataTableEntityCell, MtLocalChartStore, MtServerChartStore, MtStandardGridComponent, MtTableText, MtTemplateCell, fitMtGridCharts, mtActionsColumn, mtEntityCategoryValues, mtEntityCellValues, mtEntityColumn, mtEntityExportValue, mtGridChartServerKey, mtIsControlColumn, mtStandardColumns, mtTableColumns, mtTablePrintConfiguration, parseMtGridCharts, provideMTGridServerCharts, serializeMtGridCharts };
566
+ export type { MtActionsColumnOptions, MtCellScalar, MtEntityCellValues, MtEntityColumnOptions, MtGridChartDocument, MtGridServerChartsOptions, MtStandardGridChartPersistence, MtStandardGridDetail, MtStandardGridExportFormat, MtStandardGridServerPage, MtTableTextKey };