@maro-tech/card 0.1.1 → 0.1.3

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": "@maro-tech/card",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "peerDependencies": {
6
6
  "@angular/cdk": "^21.2.0",
@@ -1,10 +1,10 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { InjectionToken, Type, OnChanges } from '@angular/core';
2
+ import { InjectionToken, Type, OnChanges, SimpleChanges } from '@angular/core';
3
3
  import { Observable } from 'rxjs';
4
4
  import { HttpParams } from '@angular/common/http';
5
5
  import * as lucide_angular from 'lucide-angular';
6
6
  import { UiSelectOption } from '@maro-tech/form';
7
- import { UiTableResponse, UiTableColumnConfig, UiTableFilter, UiTableRowAction, UiTableCellChange } from '@maro-tech/table';
7
+ import { UiTableColumnConfig, UiTableResponse, UiTableFilter, UiTableRowAction } from '@maro-tech/table';
8
8
 
9
9
  type ApiPluginMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
10
10
  interface ApiPluginConfig {
@@ -13,6 +13,11 @@ interface ApiPluginConfig {
13
13
  payload?: Record<string, unknown>;
14
14
  [key: string]: unknown;
15
15
  }
16
+ interface CardActionContext {
17
+ entity: string;
18
+ recordId?: string;
19
+ data?: Record<string, unknown> | null;
20
+ }
16
21
  interface UiEntityCardAction {
17
22
  id?: string;
18
23
  label: string;
@@ -32,6 +37,7 @@ interface UiEntityCardAction {
32
37
  payload?: Record<string, unknown>;
33
38
  redirectEntity?: string;
34
39
  condition?: string;
40
+ context?: CardActionContext;
35
41
  }
36
42
  interface UiEntityCardTab {
37
43
  id: string;
@@ -44,12 +50,9 @@ interface UiEntityCardTab {
44
50
  panels?: UiEntityCardTab[];
45
51
  actions?: UiEntityCardAction[];
46
52
  props?: Record<string, unknown> & {
47
- imageUrls?: string[];
48
- imageIds?: string[];
49
53
  images?: string;
50
54
  recordId?: string;
51
55
  recordIdKey?: string;
52
- imageBaseUrl?: string;
53
56
  fields?: Array<Record<string, unknown>>;
54
57
  warehouseId?: number | string;
55
58
  [key: string]: unknown;
@@ -91,7 +94,6 @@ interface UiCardTabField {
91
94
  value?: string | number | boolean | null | undefined;
92
95
  type: 'text' | 'number' | 'boolean' | 'date' | 'datetime' | 'enum' | 'image';
93
96
  enumMap?: Record<string, string>;
94
- imageBaseUrl?: string;
95
97
  }
96
98
  interface UiCardTabConfig {
97
99
  id: string;
@@ -105,35 +107,56 @@ interface UiCardTabConfig {
105
107
  panels?: UiCardTabConfig[];
106
108
  actions?: UiEntityCardAction[];
107
109
  props?: {
108
- imageUrls?: string[];
109
- imageIds?: string[];
110
110
  images?: string;
111
111
  maxHeight?: number;
112
112
  recordId?: string;
113
113
  recordIdKey?: string;
114
- imageBaseUrl?: string;
115
114
  fields?: UiCardTabField[];
116
115
  warehouseId?: number | string;
117
116
  [key: string]: unknown;
118
117
  };
119
118
  }
120
119
 
120
+ type CardData = Record<string, unknown>;
121
+ type CardField = UiCardTabField;
122
+ type CardAction = UiEntityCardAction;
123
+ interface CardSection {
124
+ id: string;
125
+ title?: string;
126
+ header?: boolean;
127
+ col?: number;
128
+ layout?: UiCardLayoutInput;
129
+ component?: string;
130
+ html?: string;
131
+ props?: Record<string, unknown>;
132
+ actions?: CardAction[];
133
+ tabs?: CardSection[];
134
+ panels?: CardSection[];
135
+ }
136
+ type CardTab = CardSection;
137
+ interface CardConfig {
138
+ title: string;
139
+ layout?: UiCardLayoutInput;
140
+ actions?: CardAction[];
141
+ tabs: CardSection[];
142
+ data?: CardData | null;
143
+ }
144
+ interface CardPanelInput {
145
+ config: CardSection;
146
+ data: CardData | null;
147
+ }
148
+ declare function normalizeCardConfig<T extends CardConfig>(config: T): T;
149
+ declare function resolveCardConfig<T extends CardConfig>(config: T, data: CardData | null): T;
150
+
121
151
  declare class CardComponent {
122
- readonly entity: _angular_core.InputSignal<string>;
123
- readonly recordId: _angular_core.InputSignal<string>;
124
152
  readonly tabs: _angular_core.InputSignal<UiCardTabConfig[]>;
125
153
  readonly data: _angular_core.InputSignal<Record<string, unknown> | null>;
126
154
  readonly layout: _angular_core.InputSignal<UiCardLayoutInput>;
127
155
  readonly embedded: _angular_core.InputSignal<boolean>;
128
156
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CardComponent, never>;
129
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CardComponent, "app-card", never, { "entity": { "alias": "entity"; "required": true; "isSignal": true; }; "recordId": { "alias": "recordId"; "required": false; "isSignal": true; }; "tabs": { "alias": "tabs"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; "layout": { "alias": "layout"; "required": false; "isSignal": true; }; "embedded": { "alias": "embedded"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
157
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CardComponent, "app-card", never, { "tabs": { "alias": "tabs"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; "layout": { "alias": "layout"; "required": false; "isSignal": true; }; "embedded": { "alias": "embedded"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
130
158
  }
131
159
 
132
- interface CardActionContext {
133
- entity: string;
134
- recordId?: string;
135
- data?: Record<string, unknown> | null;
136
- }
137
160
  declare const CARD_ACTION_REQUESTED = "card.action.requested";
138
161
  declare const CARD_ACTION_STARTED = "card.action.started";
139
162
  declare const CARD_ACTION_COMPLETED = "card.action.completed";
@@ -196,8 +219,6 @@ declare class CardSectionHeaderComponent {
196
219
  readonly variant: _angular_core.InputSignal<"tabs" | "panels">;
197
220
  readonly title: _angular_core.InputSignal<string>;
198
221
  readonly actions: _angular_core.InputSignal<UiEntityCardAction[]>;
199
- readonly entity: _angular_core.InputSignal<string>;
200
- readonly recordId: _angular_core.InputSignal<string>;
201
222
  readonly data: _angular_core.InputSignal<Record<string, unknown> | null>;
202
223
  private readonly eventBus;
203
224
  private readonly destroyRef;
@@ -208,7 +229,7 @@ declare class CardSectionHeaderComponent {
208
229
  onActionClick(action: UiEntityCardAction): void;
209
230
  private matchesContext;
210
231
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CardSectionHeaderComponent, never>;
211
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CardSectionHeaderComponent, "app-card-section-header", never, { "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "actions": { "alias": "actions"; "required": false; "isSignal": true; }; "entity": { "alias": "entity"; "required": true; "isSignal": true; }; "recordId": { "alias": "recordId"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
232
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CardSectionHeaderComponent, "app-card-section-header", never, { "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "actions": { "alias": "actions"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
212
233
  }
213
234
 
214
235
  declare class ImagesViewerComponent {
@@ -397,152 +418,58 @@ declare class HistoryTabComponent {
397
418
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<HistoryTabComponent, "app-history-tab", never, { "entity": { "alias": "entity"; "required": false; "isSignal": true; }; "primaryEntity": { "alias": "primaryEntity"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "entityLabels": { "alias": "entityLabels"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
398
419
  }
399
420
 
400
- declare const ACTION_API = "ACTION_API";
401
- declare const ACTION_FORM = "ACTION_FORM";
402
- declare const ACTION_PRINT = "ACTION_PRINT";
403
- type ActionType = string;
404
- declare const normalizeActionType: (value: string | null | undefined) => string | null;
405
- declare class CardTableDataService {
406
- private readonly http;
407
- private readonly baseUrl;
408
- getTableView(code: string, options: Record<string, unknown>): Observable<any>;
409
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<CardTableDataService, never>;
410
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<CardTableDataService>;
411
- }
412
- declare class CardTableWarehouseService {
413
- private readonly http;
414
- private readonly baseUrl;
415
- getWarehouses(): Observable<{
416
- items: any[];
417
- }>;
418
- getWarehouseItems(id: string | number): Observable<any[]>;
419
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<CardTableWarehouseService, never>;
420
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<CardTableWarehouseService>;
421
- }
422
- declare class CardTableBarcodeService {
423
- printBarcode(options: {
424
- barcode: string;
425
- title: string;
426
- }): void;
427
- private escape;
428
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<CardTableBarcodeService, never>;
429
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<CardTableBarcodeService>;
430
- }
431
- declare class CardTablePrintService {
432
- openPrintWindow(): Window | null;
433
- print(config: {
434
- html: string;
435
- title?: string;
436
- }): boolean;
437
- printInWindow(printWindow: Window, config: {
438
- html: string;
439
- title?: string;
440
- }): boolean;
441
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<CardTablePrintService, never>;
442
- static ɵprov: _angular_core.ɵɵInjectableDeclaration<CardTablePrintService>;
443
- }
444
-
445
- type TableViewHeaderAction = any;
446
- declare class CardTableComponent implements OnChanges {
447
- tab: UiCardTabConfig;
421
+ declare class TableComponent implements OnChanges {
422
+ config: UiCardTabConfig;
448
423
  data: Record<string, unknown> | null;
449
- private readonly tableViewsService;
450
- private readonly warehouseService;
451
- private readonly barcodePrintService;
424
+ private readonly http;
452
425
  private readonly eventBus;
453
- private readonly host;
454
- private readonly actionBus;
455
- private readonly tableColumnsSignal;
456
- private readonly tableRowsSignal;
457
- private readonly tablePaginationSignal;
458
- private readonly tableHeaderActionsSignal;
459
- private readonly editableColumnOptionsSignal;
460
- private readonly isTableLoadingSignal;
461
- private readonly isTableActionRunningSignal;
462
- private readonly activeEditableCellSignal;
463
- private readonly activeFormTargetSignal;
464
- readonly activeFormTarget: _angular_core.Signal<{
465
- formId: string;
466
- recordId: string;
467
- initialValue: Record<string, unknown>;
468
- } | null>;
426
+ private readonly columnsSignal;
427
+ private readonly rowsSignal;
428
+ private readonly paginationSignal;
429
+ readonly pageSizeOptionsSignal: _angular_core.WritableSignal<number[]>;
430
+ private readonly headerActionsSignal;
431
+ private readonly loadingSignal;
432
+ private readonly errorSignal;
433
+ readonly columns: _angular_core.Signal<UiTableColumnConfig[]>;
434
+ readonly rows: _angular_core.Signal<Record<string, unknown>[]>;
435
+ readonly headerActions: _angular_core.Signal<UiEntityCardAction[]>;
436
+ readonly isLoading: _angular_core.Signal<boolean>;
437
+ readonly error: _angular_core.Signal<string>;
469
438
  readonly tableData: _angular_core.Signal<UiTableResponse<Record<string, unknown>>>;
470
- private pageIndex;
439
+ private page;
471
440
  private pageSize;
472
441
  private sortField;
473
442
  private sortDirection;
474
- private tableViewColumns;
475
- private editableColumnsLoaded;
476
- private refreshAfterFormCompleted;
477
- ngOnChanges(): void;
443
+ private sourceColumns;
444
+ constructor();
445
+ ngOnChanges(changes: SimpleChanges): void;
478
446
  get disablePaging(): boolean;
479
- get tableColumns(): UiTableColumnConfig[];
480
- get tableHeaderActions(): TableViewHeaderAction[];
481
- get tableActions(): Array<{
482
- id?: string;
483
- label: string;
484
- icon?: string;
485
- variant?: 'primary' | 'ghost' | 'danger';
486
- type?: ActionType;
487
- component?: string;
488
- formId?: string;
489
- api?: string;
490
- method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
491
- title?: string;
492
- text?: string;
493
- submit?: boolean | string;
494
- payload?: Record<string, unknown>;
495
- size?: 'sm' | 'md' | 'lg';
496
- }>;
497
- get isTableLoading(): boolean;
498
- get isTableActionRunning(): boolean;
499
- get rowClickable(): boolean;
500
- onTablePageChange(event: UiTableFilter): void;
501
- onTableAction(event: {
447
+ onPageChange(event: UiTableFilter): void;
448
+ onAction(event: {
502
449
  action: UiTableRowAction;
503
450
  row: Record<string, unknown>;
504
451
  }): void;
505
- onHeaderAction(action: TableViewHeaderAction): void;
506
- onTableRowClick(row: Record<string, unknown>): void;
507
- onTableCellChange(event: UiTableCellChange<Record<string, unknown>>): void;
508
- onEditableCellActivate(row: Record<string, unknown>, columnKey: string, event: MouseEvent): void;
509
- isEditableCellActive(row: Record<string, unknown>, columnKey: string): boolean;
510
- resolveEditableDisplayValue(row: Record<string, unknown>, column: UiTableColumnConfig): string;
511
- private getCellValue;
512
- private runPrintAction;
513
- closeFormAction(): void;
514
- refreshTable(): void;
515
- onFormCompleted(response: unknown): void;
516
- onFormClosed(): void;
517
- private applyFormResultToRow;
518
- private loadTable;
519
- private runApiAction;
520
- private runFormAction;
521
- private runRowEditAction;
522
- private runHeaderFormAction;
523
- private normalizeTableColumns;
524
- private normalizeTableRows;
525
- private toTableRowData;
526
- private saveEditableColumnChange;
527
- private loadEditableColumnOptions;
528
- private resolveEditableColumnsConfig;
529
- private resolveEditableColumnPayload;
530
- private resolveEditableColumnOptions;
531
- private isEditEnabled;
532
- private isDeleteEnabled;
533
- private resolveTableSource;
534
- private resolveTableFilters;
535
- private resolveFiltersObject;
536
- private resolveTemplatePayload;
537
- private resolveTemplateString;
538
- private resolveTemplateValue;
539
- private resolvePageSize;
540
- private resolveEditCondition;
541
- private resolveEditableCondition;
542
- private notify;
543
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<CardTableComponent, never>;
544
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CardTableComponent, "app-card-table", never, { "tab": { "alias": "tab"; "required": true; }; "data": { "alias": "data"; "required": false; }; }, {}, never, never, true, never>;
452
+ onCellChange(event: {
453
+ column: UiTableColumnConfig;
454
+ row: Record<string, unknown>;
455
+ value: unknown;
456
+ }): void;
457
+ onHeaderAction(action: UiEntityCardAction): void;
458
+ private emitAction;
459
+ private load;
460
+ private setColumns;
461
+ private rowsFrom;
462
+ private tableName;
463
+ private editableColumns;
464
+ private tableEndpoint;
465
+ private editEnabled;
466
+ private numberProp;
467
+ private resolveObject;
468
+ private resolve;
469
+ private resolveValue;
470
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<TableComponent, never>;
471
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<TableComponent, "app-card-table", never, { "config": { "alias": "config"; "required": true; }; "data": { "alias": "data"; "required": false; }; }, {}, never, never, true, never>;
545
472
  }
546
473
 
547
- export { ACTION_API, ACTION_FORM, ACTION_PRINT, CARD_ACTION_COMPLETED, CARD_ACTION_FINISHED, CARD_ACTION_REQUESTED, CARD_ACTION_STARTED, CardComponent, CardCurrentUserService, CardDictionaryService, CardImageService, CardSectionHeaderComponent, CardTableBarcodeService, CardTableComponent, CardTableDataService, CardTablePrintService, CardTableWarehouseService, DocumentsComponent, ENTITY_UPDATED, HistoryTabComponent, ImagesViewerComponent, UI_CARD_API_BASE_URL, UI_CARD_TAB_REGISTRY, UI_ENTITY_CARD_HOST, UiEntityDocumentsService, cardApiParams, cardApiResourceUrl, normalizeActionType };
548
- export type { ActionType, ApiPluginConfig, ApiPluginMethod, CardActionContext, CardActionLifecycleEvent, CardActionRequestedEvent, CardDictionarySuggestItem, EntityUpdatedEvent, UiCardLayout, UiCardLayoutInput, UiCardTabComponent, UiCardTabConfig, UiCardTabField, UiCardTabRegistration, UiEntityCardAction, UiEntityCardHost, UiEntityCardResponse, UiEntityCardTab, UiEntityDocumentFile, UiEntityDocumentRecognitionStatus };
474
+ export { CARD_ACTION_COMPLETED, CARD_ACTION_FINISHED, CARD_ACTION_REQUESTED, CARD_ACTION_STARTED, CardComponent, CardCurrentUserService, CardDictionaryService, CardImageService, CardSectionHeaderComponent, DocumentsComponent, ENTITY_UPDATED, HistoryTabComponent, ImagesViewerComponent, TableComponent, UI_CARD_API_BASE_URL, UI_CARD_TAB_REGISTRY, UI_ENTITY_CARD_HOST, UiEntityDocumentsService, cardApiParams, cardApiResourceUrl, normalizeCardConfig, resolveCardConfig };
475
+ export type { ApiPluginConfig, ApiPluginMethod, CardAction, CardActionContext, CardActionLifecycleEvent, CardActionRequestedEvent, CardConfig, CardData, CardDictionarySuggestItem, CardField, CardPanelInput, CardSection, CardTab, EntityUpdatedEvent, UiCardLayout, UiCardLayoutInput, UiCardTabComponent, UiCardTabConfig, UiCardTabField, UiCardTabRegistration, UiEntityCardAction, UiEntityCardHost, UiEntityCardResponse, UiEntityCardTab, UiEntityDocumentFile, UiEntityDocumentRecognitionStatus };