@dragonworks/ngx-dashboard 20.0.5 → 20.1.0

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/index.d.ts CHANGED
@@ -56,6 +56,53 @@ declare const CellIdUtils: {
56
56
  equals(a: CellId, b: CellId): boolean;
57
57
  };
58
58
 
59
+ /**
60
+ * Branded type for widget identifiers to ensure type safety when working with widget instances.
61
+ * This prevents accidentally mixing up widget IDs with other string values.
62
+ */
63
+ type WidgetId = string & {
64
+ __brand: 'WidgetId';
65
+ };
66
+ /**
67
+ * Utility functions for working with WidgetId branded type.
68
+ * WidgetIds are UUIDs that uniquely identify widget instances throughout their lifecycle,
69
+ * independent of their position on the dashboard grid.
70
+ */
71
+ declare const WidgetIdUtils: {
72
+ /**
73
+ * Generates a new unique WidgetId.
74
+ * Uses crypto.randomUUID() when available, falls back to timestamp-based ID for older browsers.
75
+ * @returns A new unique WidgetId
76
+ */
77
+ generate(): WidgetId;
78
+ /**
79
+ * Validates if a string is a valid WidgetId format.
80
+ * @param id - The string to validate
81
+ * @returns True if the string is a valid WidgetId format
82
+ */
83
+ validate(id: string): id is WidgetId;
84
+ /**
85
+ * Converts a WidgetId to a string for use as map keys or serialization.
86
+ * @param id - The WidgetId to convert
87
+ * @returns The string representation of the WidgetId
88
+ */
89
+ toString(id: WidgetId): string;
90
+ /**
91
+ * Creates a WidgetId from a string, validating the format.
92
+ * @param str - The string to convert to WidgetId
93
+ * @returns A WidgetId
94
+ * @throws Error if the string is not a valid WidgetId format
95
+ */
96
+ fromString(str: string): WidgetId;
97
+ /**
98
+ * Checks if two WidgetIds are equal.
99
+ * @param a - First WidgetId
100
+ * @param b - Second WidgetId
101
+ * @returns True if the WidgetIds are the same
102
+ */
103
+ equals(a: WidgetId, b: WidgetId): boolean;
104
+ };
105
+
59
106
  interface Widget {
60
107
  dashboardGetState?(): unknown;
61
108
  dashboardSetState?(state?: unknown): void;
@@ -88,9 +135,11 @@ interface CellPosition {
88
135
  }
89
136
  interface CellComponentPosition extends CellPosition {
90
137
  cellId: CellId;
138
+ widgetId: WidgetId;
91
139
  }
92
140
 
93
141
  interface CellData extends CellPosition {
142
+ widgetId: WidgetId;
94
143
  cellId: CellId;
95
144
  flat?: boolean;
96
145
  widgetFactory: WidgetFactory;
@@ -271,7 +320,7 @@ declare class DashboardComponent implements OnChanges {
271
320
  width: number;
272
321
  height: number;
273
322
  }>;
274
- cellsById: _angular_core.Signal<Record<string, _dragonworks_ngx_dashboard.CellData>>;
323
+ widgetsById: _angular_core.Signal<Record<string, _dragonworks_ngx_dashboard.CellData>>;
275
324
  resizeData: _angular_core.Signal<ResizeData | null>;
276
325
  dragData: _angular_core.Signal<_dragonworks_ngx_dashboard.DragData | null>;
277
326
  hoveredDropZone: _angular_core.Signal<{
@@ -301,15 +350,14 @@ declare class DashboardComponent implements OnChanges {
301
350
  toggleEditMode: () => void;
302
351
  setEditMode: (isEditMode: boolean) => void;
303
352
  addWidget: (cell: _dragonworks_ngx_dashboard.CellData) => void;
304
- removeWidget: (cellId: _dragonworks_ngx_dashboard.CellId) => void;
305
- updateWidgetPosition: (cellId: _dragonworks_ngx_dashboard.CellId, row: number, col: number) => void;
353
+ removeWidget: (widgetId: _dragonworks_ngx_dashboard.WidgetId) => void;
354
+ updateWidgetPosition: (widgetId: _dragonworks_ngx_dashboard.WidgetId, row: number, col: number) => void;
306
355
  createWidget: (row: number, col: number, widgetFactory: _dragonworks_ngx_dashboard.WidgetFactory, widgetState?: string) => void;
307
- updateCellSettings: (id: _dragonworks_ngx_dashboard.CellId, flat: boolean) => void;
308
- updateWidgetSpan: (id: _dragonworks_ngx_dashboard.CellId, rowSpan: number, colSpan: number) => void;
309
- updateWidgetState: (cellId: _dragonworks_ngx_dashboard.CellId, widgetState: unknown) => void;
310
- updateAllWidgetStates: (widgetStates: Map<string, unknown>) => void;
356
+ updateCellSettings: (widgetId: _dragonworks_ngx_dashboard.WidgetId, flat: boolean) => void;
357
+ updateWidgetSpan: (widgetId: _dragonworks_ngx_dashboard.WidgetId, rowSpan: number, colSpan: number) => void;
358
+ updateWidgetState: (widgetId: _dragonworks_ngx_dashboard.WidgetId, widgetState: unknown) => void;
359
+ updateAllWidgetStates: (cellStates: Map<string, unknown>) => void;
311
360
  clearDashboard: () => void;
312
- syncDragState: (dragData: _dragonworks_ngx_dashboard.DragData | null) => void;
313
361
  startDrag: (dragData: _dragonworks_ngx_dashboard.DragData) => void;
314
362
  endDrag: () => void;
315
363
  setHoveredDropZone: (zone: {
@@ -336,7 +384,7 @@ declare class DashboardComponent implements OnChanges {
336
384
  width: number;
337
385
  height: number;
338
386
  };
339
- cellsById: Record<string, _dragonworks_ngx_dashboard.CellData>;
387
+ widgetsById: Record<string, _dragonworks_ngx_dashboard.CellData>;
340
388
  resizeData: ResizeData | null;
341
389
  dragData: _dragonworks_ngx_dashboard.DragData | null;
342
390
  hoveredDropZone: {
@@ -363,7 +411,8 @@ declare class DashboardComponent implements OnChanges {
363
411
 
364
412
  declare class CellComponent {
365
413
  #private;
366
- id: _angular_core.InputSignal<CellId>;
414
+ widgetId: _angular_core.InputSignal<WidgetId>;
415
+ cellId: _angular_core.InputSignal<CellId>;
367
416
  widgetFactory: _angular_core.InputSignal<WidgetFactory<Widget> | undefined>;
368
417
  widgetState: _angular_core.InputSignal<unknown>;
369
418
  isEditMode: _angular_core.InputSignal<boolean>;
@@ -375,23 +424,23 @@ declare class CellComponent {
375
424
  draggable: _angular_core.InputSignal<boolean>;
376
425
  dragStart: _angular_core.OutputEmitterRef<DragData>;
377
426
  dragEnd: _angular_core.OutputEmitterRef<void>;
378
- edit: _angular_core.OutputEmitterRef<CellId>;
379
- delete: _angular_core.OutputEmitterRef<CellId>;
427
+ edit: _angular_core.OutputEmitterRef<WidgetId>;
428
+ delete: _angular_core.OutputEmitterRef<WidgetId>;
380
429
  settings: _angular_core.OutputEmitterRef<{
381
- id: CellId;
430
+ id: WidgetId;
382
431
  flat: boolean;
383
432
  }>;
384
433
  resizeStart: _angular_core.OutputEmitterRef<{
385
- id: CellId;
434
+ cellId: CellId;
386
435
  direction: "horizontal" | "vertical";
387
436
  }>;
388
437
  resizeMove: _angular_core.OutputEmitterRef<{
389
- id: CellId;
438
+ cellId: CellId;
390
439
  direction: "horizontal" | "vertical";
391
440
  delta: number;
392
441
  }>;
393
442
  resizeEnd: _angular_core.OutputEmitterRef<{
394
- id: CellId;
443
+ cellId: CellId;
395
444
  apply: boolean;
396
445
  }>;
397
446
  private container;
@@ -451,7 +500,7 @@ declare class CellComponent {
451
500
  */
452
501
  getCurrentWidgetState(): unknown | undefined;
453
502
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CellComponent, never>;
454
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<CellComponent, "lib-cell", never, { "id": { "alias": "id"; "required": true; "isSignal": true; }; "widgetFactory": { "alias": "widgetFactory"; "required": false; "isSignal": true; }; "widgetState": { "alias": "widgetState"; "required": false; "isSignal": true; }; "isEditMode": { "alias": "isEditMode"; "required": false; "isSignal": true; }; "flat": { "alias": "flat"; "required": false; "isSignal": true; }; "row": { "alias": "row"; "required": true; "isSignal": true; }; "column": { "alias": "column"; "required": true; "isSignal": true; }; "rowSpan": { "alias": "rowSpan"; "required": false; "isSignal": true; }; "colSpan": { "alias": "colSpan"; "required": false; "isSignal": true; }; "draggable": { "alias": "draggable"; "required": false; "isSignal": true; }; }, { "row": "rowChange"; "column": "columnChange"; "dragStart": "dragStart"; "dragEnd": "dragEnd"; "edit": "edit"; "delete": "delete"; "settings": "settings"; "resizeStart": "resizeStart"; "resizeMove": "resizeMove"; "resizeEnd": "resizeEnd"; }, never, never, true, never>;
503
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CellComponent, "lib-cell", never, { "widgetId": { "alias": "widgetId"; "required": true; "isSignal": true; }; "cellId": { "alias": "cellId"; "required": true; "isSignal": true; }; "widgetFactory": { "alias": "widgetFactory"; "required": false; "isSignal": true; }; "widgetState": { "alias": "widgetState"; "required": false; "isSignal": true; }; "isEditMode": { "alias": "isEditMode"; "required": false; "isSignal": true; }; "flat": { "alias": "flat"; "required": false; "isSignal": true; }; "row": { "alias": "row"; "required": true; "isSignal": true; }; "column": { "alias": "column"; "required": true; "isSignal": true; }; "rowSpan": { "alias": "rowSpan"; "required": false; "isSignal": true; }; "colSpan": { "alias": "colSpan"; "required": false; "isSignal": true; }; "draggable": { "alias": "draggable"; "required": false; "isSignal": true; }; }, { "row": "rowChange"; "column": "columnChange"; "dragStart": "dragStart"; "dragEnd": "dragEnd"; "edit": "edit"; "delete": "delete"; "settings": "settings"; "resizeStart": "resizeStart"; "resizeMove": "resizeMove"; "resizeEnd": "resizeEnd"; }, never, never, true, never>;
455
504
  }
456
505
 
457
506
  declare class DropZoneComponent {
@@ -525,9 +574,9 @@ declare class DashboardEditorComponent {
525
574
  createCellId(row: number, col: number): CellId;
526
575
  constructor();
527
576
  addWidget: (cellData: CellData) => void;
528
- updateCellPosition: (id: CellId, row: number, column: number) => void;
529
- updateCellSpan: (id: CellId, colSpan: number, rowSpan: number) => void;
530
- updateCellSettings: (id: CellId, flat: boolean) => void;
577
+ updateCellPosition: (id: WidgetId, row: number, column: number) => void;
578
+ updateCellSpan: (id: WidgetId, colSpan: number, rowSpan: number) => void;
579
+ updateCellSettings: (id: WidgetId, flat: boolean) => void;
531
580
  onDragOver: (event: {
532
581
  row: number;
533
582
  col: number;
@@ -538,28 +587,28 @@ declare class DashboardEditorComponent {
538
587
  }) => void;
539
588
  onDragExit: () => void;
540
589
  dragEnd: () => void;
541
- onCellDelete: (id: CellId) => void;
590
+ onCellDelete: (id: WidgetId) => void;
542
591
  onCellSettings: (event: {
543
- id: CellId;
592
+ id: WidgetId;
544
593
  flat: boolean;
545
594
  }) => void;
546
595
  onCellResize: (event: {
547
- id: CellId;
596
+ id: WidgetId;
548
597
  rowSpan: number;
549
598
  colSpan: number;
550
599
  }) => void;
551
600
  onCellDragStart: (dragData: DragData) => void;
552
601
  onCellResizeStart: (event: {
553
- id: CellId;
602
+ cellId: CellId;
554
603
  direction: "horizontal" | "vertical";
555
604
  }) => void;
556
605
  onCellResizeMove: (event: {
557
- id: CellId;
606
+ cellId: CellId;
558
607
  direction: "horizontal" | "vertical";
559
608
  delta: number;
560
609
  }) => void;
561
610
  onCellResizeEnd: (event: {
562
- id: CellId;
611
+ cellId: CellId;
563
612
  apply: boolean;
564
613
  }) => void;
565
614
  onDragDrop(event: {
@@ -674,5 +723,5 @@ declare class DefaultCellSettingsDialogProvider extends CellSettingsDialogProvid
674
723
  */
675
724
  declare const CELL_SETTINGS_DIALOG_PROVIDER: InjectionToken<CellSettingsDialogProvider>;
676
725
 
677
- export { CELL_SETTINGS_DIALOG_PROVIDER, CellIdUtils, CellSettingsDialogProvider, DEFAULT_RESERVED_SPACE, DashboardComponent, DashboardEditorComponent, DashboardService, DashboardViewerComponent, DefaultCellSettingsDialogProvider, WidgetListComponent, createDefaultDashboard, createEmptyDashboard, createFactoryFromComponent };
678
- export type { CellComponentPosition, CellData, CellDataDto, CellDisplayData, CellId, CellPosition, DashboardDataDto, DragData, ReservedSpace, Widget, WidgetComponentClass, WidgetFactory, WidgetMetadata };
726
+ export { CELL_SETTINGS_DIALOG_PROVIDER, CellIdUtils, CellSettingsDialogProvider, DEFAULT_RESERVED_SPACE, DashboardComponent, DashboardEditorComponent, DashboardService, DashboardViewerComponent, DefaultCellSettingsDialogProvider, WidgetIdUtils, WidgetListComponent, createDefaultDashboard, createEmptyDashboard, createFactoryFromComponent };
727
+ export type { CellComponentPosition, CellData, CellDataDto, CellDisplayData, CellId, CellPosition, DashboardDataDto, DragData, ReservedSpace, Widget, WidgetComponentClass, WidgetFactory, WidgetId, WidgetMetadata };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dragonworks/ngx-dashboard",
3
- "version": "20.0.5",
3
+ "version": "20.1.0",
4
4
  "description": "Angular library for building drag-and-drop grid dashboards with resizable cells and customizable widgets",
5
5
  "peerDependencies": {
6
- "@angular/common": "^20.0.0",
7
- "@angular/core": "^20.0.0",
8
- "@angular/material": "^20.0.0",
9
- "@angular/cdk": "^20.0.0"
6
+ "@angular/common": "^20.2.0",
7
+ "@angular/core": "^20.2.0",
8
+ "@angular/material": "^20.2.0",
9
+ "@angular/cdk": "^20.2.0"
10
10
  },
11
11
  "dependencies": {
12
12
  "tslib": "^2.3.0"