@masterteam/client-components 0.0.34 → 0.0.36

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/client-components",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "publishConfig": {
5
5
  "directory": "../../../dist/masterteam/client-components",
6
6
  "linkDirectory": true,
@@ -16,9 +16,9 @@
16
16
  "rxjs": "^7.8.2",
17
17
  "tailwindcss": "^4.2.2",
18
18
  "tailwindcss-primeui": "^0.6.1",
19
- "@masterteam/forms": "^0.0.70",
20
- "@masterteam/components": "^0.0.156",
21
- "@masterteam/dashboard-builder": "^0.0.26"
19
+ "@masterteam/components": "^0.0.159",
20
+ "@masterteam/dashboard-builder": "^0.0.27",
21
+ "@masterteam/forms": "^0.0.72"
22
22
  },
23
23
  "dependencies": {
24
24
  "tslib": "^2.8.1"
@@ -1,9 +1,10 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import { TemplateRef, OnDestroy, WritableSignal } from '@angular/core';
3
+ import { TableAction, TableActionShape, ColumnDef, TableFilters } from '@masterteam/components/table';
3
4
  import * as _masterteam_components_entities from '@masterteam/components/entities';
4
5
  import { EntityData, EntityConfiguration } from '@masterteam/components/entities';
5
6
  import { DashboardBuilderData } from '@masterteam/dashboard-builder';
6
- import { TableAction, TableActionShape, ColumnDef, TableFilters } from '@masterteam/components/table';
7
+ import { RuntimeAction } from '@masterteam/components/runtime-action';
7
8
  import { Observable } from 'rxjs';
8
9
 
9
10
  type ClientListMode = 'auto' | 'override';
@@ -34,6 +35,63 @@ interface ClientListBaseConfiguration {
34
35
  rowActions?: TableAction[];
35
36
  actionShape?: TableActionShape;
36
37
  dataLoaded?: ClientListDataLoadedHandler;
38
+ /**
39
+ * Lazy backend-driven per-row actions. When enabled, ClientList fetches
40
+ * each row's available `RuntimeAction[]` only when the user opens the row's
41
+ * 3-dots menu (default `loadStrategy: 'onMenuOpen'`), then merges them into
42
+ * the row's action list. Replaces the eager fan-out of one HTTP per visible
43
+ * row that callers used to wire by hand.
44
+ */
45
+ runtimeRecordActions?: ClientListRuntimeRecordActionsConfig;
46
+ }
47
+ interface ClientListRuntimeRecordActionsContext {
48
+ listKey: string;
49
+ contextKey: string | null;
50
+ instanceId: number | null;
51
+ moduleId: number;
52
+ row: RuntimeTableDisplayRow;
53
+ recordId: number;
54
+ }
55
+ interface ClientListRuntimeRecordActionsConfig {
56
+ /** Master flag — set to false to disable without removing the config block. */
57
+ enabled: boolean;
58
+ /**
59
+ * `onMenuOpen` (default): fetch when the 3-dots popover opens for a row.
60
+ * Requires `actionShape: 'popover'`. `eager`: fetch for every visible row
61
+ * after the list loads (legacy behavior, kept for opt-in).
62
+ */
63
+ loadStrategy?: 'onMenuOpen' | 'eager';
64
+ /**
65
+ * Endpoint template. `{instanceId}` is replaced with the list's
66
+ * `instanceId`. Defaults to
67
+ * `LevelData/{instanceId}/workspace-record-actions`.
68
+ */
69
+ endpoint?: string;
70
+ /**
71
+ * Query params per row. Defaults to
72
+ * `{ targetType: 'ModuleData', targetId: recordId, moduleKey? }`.
73
+ */
74
+ buildParams?: (ctx: ClientListRuntimeRecordActionsContext) => Record<string, string | number>;
75
+ /** Cache TTL in ms. `null` = until manual invalidation. Default: 60_000. */
76
+ cacheTtlMs?: number | null;
77
+ /** Read the record id from a row. Defaults to `row.Id ?? row.id ?? row.ModuleDataId`. */
78
+ resolveRecordId?: (row: RuntimeTableDisplayRow) => number | null;
79
+ /** Read the module key from a row (for the `moduleKey` query param). */
80
+ resolveModuleKey?: (row: RuntimeTableDisplayRow, ctx: {
81
+ listKey: string;
82
+ moduleId: number;
83
+ }) => string | null;
84
+ /**
85
+ * Called after a runtime action executes successfully (the list also
86
+ * auto-reloads and the per-row cache is invalidated). Use this to refresh
87
+ * any external state the consumer owns.
88
+ */
89
+ onActionExecuted?: (action: RuntimeAction, ctx: ClientListRuntimeRecordActionsContext) => void;
90
+ /**
91
+ * Visual: icon used for runtime action buttons (popover entries). Defaults
92
+ * to `media.play-circle`.
93
+ */
94
+ actionIcon?: string;
37
95
  }
38
96
  interface ClientListTableDisplayConfig {
39
97
  pageSize?: number;
@@ -287,6 +345,7 @@ interface NormalizedClientListConfiguration {
287
345
  rowActions: TableAction[];
288
346
  actionShape?: TableActionShape;
289
347
  dataLoaded?: ClientListDataLoadedHandler;
348
+ runtimeRecordActions?: ClientListRuntimeRecordActionsConfig;
290
349
  }
291
350
  interface ClientListContentTemplateContext {
292
351
  $implicit: ClientListState;
@@ -332,6 +391,8 @@ declare class ClientListStateService {
332
391
  declare class ClientList implements OnDestroy {
333
392
  private readonly api;
334
393
  protected readonly state: ClientListStateService;
394
+ private readonly runtimeActions;
395
+ private readonly runtimeRunner;
335
396
  readonly configurations: _angular_core.InputSignal<ClientListConfiguration[]>;
336
397
  readonly defaultTake: _angular_core.InputSignal<number>;
337
398
  readonly loaded: _angular_core.OutputEmitterRef<string>;
@@ -351,6 +412,32 @@ declare class ClientList implements OnDestroy {
351
412
  toggleExpanded(key: string): void;
352
413
  onTableRowClick(item: ClientListState, row: RuntimeTableDisplayRow): void;
353
414
  onCardClick(item: ClientListState, card: ClientListCard): void;
415
+ /**
416
+ * Called by the table view when a row's 3-dots menu is opened. Triggers a
417
+ * lazy fetch of that row's runtime actions when `runtimeRecordActions` is
418
+ * enabled with the default `onMenuOpen` strategy. Skips when the cache is
419
+ * still warm — the service handles in-flight dedupe and TTL.
420
+ */
421
+ onRowActionsRequested(item: ClientListState, row: RuntimeTableDisplayRow): void;
422
+ /**
423
+ * Per-row predicate used by the popover skeleton state.
424
+ */
425
+ isRowActionsLoading(item: ClientListState, row: RuntimeTableDisplayRow): boolean;
426
+ /**
427
+ * Per-list merged row-actions, keyed by item.key. Static `rowActions` are
428
+ * augmented with one entry per distinct runtime `actionKey` discovered for
429
+ * any row in the list, and re-evaluated when the runtime cache changes.
430
+ */
431
+ protected readonly mergedRowActionsByKey: _angular_core.Signal<ReadonlyMap<string, TableAction[]>>;
432
+ /** Fallback used by the template when no entry exists for an item.key. */
433
+ private readonly emptyActions;
434
+ private readonly rowActionsLoadingFnCache;
435
+ rowActionsFor(item: ClientListState): TableAction[];
436
+ rowActionsLoadingFnFor(item: ClientListState): (row: RuntimeTableDisplayRow) => boolean;
437
+ private computeMergedRowActions;
438
+ private executeRuntimeAction;
439
+ private toRuntimeActionsContext;
440
+ private resolveRecordId;
354
441
  templateContext(item: ClientListState): ClientListContentTemplateContext;
355
442
  defaultTitle(item: ClientListState): string;
356
443
  ngOnDestroy(): void;
@@ -370,6 +457,7 @@ declare class ClientList implements OnDestroy {
370
457
  private resolvePositiveInteger;
371
458
  private cleanupStaleResources;
372
459
  private notifyDataLoaded;
460
+ private maybeEagerLoadRuntimeActions;
373
461
  private toTableQuery;
374
462
  private createTableRequestSignature;
375
463
  private createCardsRequestSignature;
@@ -403,6 +491,42 @@ declare class ClientListApiService {
403
491
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<ClientListApiService>;
404
492
  }
405
493
 
494
+ /**
495
+ * Lazy per-row runtime actions. Fetches `workspace-record-actions` only when
496
+ * the row's 3-dots menu is opened (or for every visible row when the list
497
+ * opts in to `eager`), with per-row caching, in-flight dedupe, and a single
498
+ * cache-invalidation hook tied to action execution.
499
+ */
500
+ declare class ClientListRuntimeActionsService {
501
+ private readonly http;
502
+ private readonly cache;
503
+ private readonly inFlightKeys;
504
+ private readonly inFlight;
505
+ /** Actions keyed by `${listKey}:${recordId}`. */
506
+ readonly actionsByRowKey: _angular_core.Signal<ReadonlyMap<string, RuntimeAction[]>>;
507
+ /** Row keys currently being fetched. Drives the popover skeleton state. */
508
+ readonly loadingRowKeys: _angular_core.Signal<ReadonlySet<string>>;
509
+ rowKey(listKey: string, recordId: number): string;
510
+ has(listKey: string, recordId: number, ttlMs: number | null | undefined): boolean;
511
+ /**
512
+ * Fetch (or reuse cached/in-flight) per-row runtime actions for a row.
513
+ * Returns an Observable so callers can chain off the result; the cache and
514
+ * loading signals are also kept in sync so the table popover skeleton and
515
+ * the merged-actions computation react automatically.
516
+ */
517
+ request(config: ClientListRuntimeRecordActionsConfig, ctx: ClientListRuntimeRecordActionsContext): Observable<RuntimeAction[]>;
518
+ invalidateRow(listKey: string, recordId: number): void;
519
+ invalidateList(listKey: string): void;
520
+ clearAll(): void;
521
+ private writeCache;
522
+ private markLoading;
523
+ private resolveEndpoint;
524
+ private buildParams;
525
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ClientListRuntimeActionsService, never>;
526
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<ClientListRuntimeActionsService>;
527
+ }
528
+ declare function defaultResolveRecordId(row: RuntimeTableDisplayRow): number | null;
529
+
406
530
  /**
407
531
  * Toolbar state for a single client-list instance: search term, column filters,
408
532
  * group column, and active tab. Kept as mutable signals so both the table view
@@ -430,5 +554,5 @@ declare class ClientListToolbarService {
430
554
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<ClientListToolbarService>;
431
555
  }
432
556
 
433
- export { ClientList, ClientListApiService, ClientListStateService, ClientListToolbarService };
434
- export type { ClientListAreaType, ClientListBaseConfiguration, ClientListBaseState, ClientListCard, ClientListCardModule, ClientListCardProperty, ClientListCardsPayload, ClientListCardsState, ClientListClickableItem, ClientListCollapseConfig, ClientListConfiguration, ClientListContentTemplateContext, ClientListDataLoadedHandler, ClientListFetchCardDisplayOrderItem, ClientListFetchCardGroup, ClientListFetchCatalog, ClientListFetchProjection, ClientListFetchProjectionMeta, ClientListFetchPropertyMeta, ClientListFetchQueryRequest, ClientListFetchQueryResponse, ClientListFetchRecord, ClientListFetchRequestDisplay, ClientListFetchRequestFilter, ClientListFetchSchema, ClientListFetchTableColumn, ClientListFetchValueCell, ClientListFormConfiguration, ClientListInformativeChartLink, ClientListInformativeConfiguration, ClientListInformativeDashboardPayload, ClientListInformativeState, ClientListItemClickedEvent, ClientListLayoutConfig, ClientListLazyLoadEvent, ClientListMode, ClientListRuntimeContext, ClientListState, ClientListTableDisplayConfig, ClientListTableQuery, ClientListTableSettingsCatalogResponse, ClientListTableSettingsColumn, ClientListTableState, ClientListToolbarBucket, ClientListType, NormalizedClientListConfiguration, NormalizedClientListTableDisplayConfig, Response, RuntimeEntityColumnDef, RuntimeTableDisplayRow, RuntimeTableRowsResponse };
557
+ export { ClientList, ClientListApiService, ClientListRuntimeActionsService, ClientListStateService, ClientListToolbarService, defaultResolveRecordId };
558
+ export type { ClientListAreaType, ClientListBaseConfiguration, ClientListBaseState, ClientListCard, ClientListCardModule, ClientListCardProperty, ClientListCardsPayload, ClientListCardsState, ClientListClickableItem, ClientListCollapseConfig, ClientListConfiguration, ClientListContentTemplateContext, ClientListDataLoadedHandler, ClientListFetchCardDisplayOrderItem, ClientListFetchCardGroup, ClientListFetchCatalog, ClientListFetchProjection, ClientListFetchProjectionMeta, ClientListFetchPropertyMeta, ClientListFetchQueryRequest, ClientListFetchQueryResponse, ClientListFetchRecord, ClientListFetchRequestDisplay, ClientListFetchRequestFilter, ClientListFetchSchema, ClientListFetchTableColumn, ClientListFetchValueCell, ClientListFormConfiguration, ClientListInformativeChartLink, ClientListInformativeConfiguration, ClientListInformativeDashboardPayload, ClientListInformativeState, ClientListItemClickedEvent, ClientListLayoutConfig, ClientListLazyLoadEvent, ClientListMode, ClientListRuntimeContext, ClientListRuntimeRecordActionsConfig, ClientListRuntimeRecordActionsContext, ClientListState, ClientListTableDisplayConfig, ClientListTableQuery, ClientListTableSettingsCatalogResponse, ClientListTableSettingsColumn, ClientListTableState, ClientListToolbarBucket, ClientListType, NormalizedClientListConfiguration, NormalizedClientListTableDisplayConfig, Response, RuntimeEntityColumnDef, RuntimeTableDisplayRow, RuntimeTableRowsResponse };