@eternalcodestudio/primeng-table 20.0.8 → 20.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/index.d.ts CHANGED
@@ -5,15 +5,56 @@ import { Observable } from 'rxjs';
5
5
  import { HttpResponse, HttpHeaders } from '@angular/common/http';
6
6
  import { SortMeta, MenuItem } from 'primeng/api';
7
7
 
8
+ /**
9
+ * Abstract service for handling HTTP requests for **ECS Primeng table**.
10
+ *
11
+ * Provides a consistent interface for making GET and POST requests to the backend.
12
+ * Implementations must define how requests are executed, including error handling,
13
+ * headers, and response processing.
14
+ */
8
15
  declare abstract class ECSPrimengTableHttpService {
16
+ /**
17
+ * Performs a GET request to the specified service endpoint.
18
+ *
19
+ * @template T The expected response type.
20
+ * @param servicePoint The endpoint URL or path for the GET request.
21
+ * @param responseType Optional. The type of response expected, either `'json'` (default) or `'blob'`.
22
+ * @returns An Observable of `HttpResponse<T>`, containing the full HTTP response.
23
+ */
9
24
  abstract handleHttpGetRequest<T>(servicePoint: string, responseType?: 'json' | 'blob'): Observable<HttpResponse<T>>;
25
+ /**
26
+ * Performs a POST request to the specified service endpoint.
27
+ *
28
+ * @template T The expected response type.
29
+ * @param servicePoint The endpoint URL or path for the POST request.
30
+ * @param data The payload to send in the POST request body.
31
+ * @param httpOptions Optional HTTP headers to include in the request.
32
+ * @param responseType Optional. The type of response expected, either `'json'` (default) or `'blob'`.
33
+ * @returns An Observable of `HttpResponse<T>`, containing the full HTTP response.
34
+ */
10
35
  abstract handleHttpPostRequest<T>(servicePoint: string, data: any, httpOptions?: HttpHeaders | null, responseType?: 'json' | 'blob'): Observable<HttpResponse<T>>;
11
36
  static ɵfac: i0.ɵɵFactoryDeclaration<ECSPrimengTableHttpService, never>;
12
37
  static ɵprov: i0.ɵɵInjectableDeclaration<ECSPrimengTableHttpService>;
13
38
  }
14
39
 
40
+ /**
41
+ * Abstract service for handling notifications in **ECS Primeng table**.
42
+ *
43
+ * Provides a consistent interface for displaying and clearing toast notifications.
44
+ * Implementations must define how the notifications are managed.
45
+ */
15
46
  declare abstract class ECSPrimengTableNotificationService {
47
+ /**
48
+ * Displays a toast notification.
49
+ *
50
+ * @param severity The severity level of the notification (e.g., 'success', 'info', 'warn', 'error').
51
+ * @param title The title of the toast message.
52
+ * @param message The detailed message of the toast.
53
+ */
16
54
  abstract showToast(severity: string, title: string, message: string): void;
55
+ /**
56
+ * Clears all currently displayed toast notifications.
57
+ */
17
58
  abstract clearToasts(): void;
18
59
  static ɵfac: i0.ɵɵFactoryDeclaration<ECSPrimengTableNotificationService, never>;
19
60
  static ɵprov: i0.ɵɵInjectableDeclaration<ECSPrimengTableNotificationService>;
@@ -86,21 +127,12 @@ interface ITableButton {
86
127
  tooltip?: string;
87
128
  }
88
129
 
89
- /**
90
- * Interface representing the request structure for PrimeNG post requests.
91
- */
92
130
  interface ITableQueryRequest {
93
- /** Gets or sets the current page number.*/
94
131
  page: number;
95
- /** Gets or sets the number of items to display per page.*/
96
132
  pageSize: number;
97
- /** Gets or sets a list of sorting configurations for the table.*/
98
133
  sort?: any;
99
- /** Gets or sets a dictionary containing filter configurations for each column.*/
100
134
  filter: any;
101
- /** Gets or sets a global filter string applied to all columns.*/
102
135
  globalFilter?: string | null;
103
- /** Gets or sets a list of columns to be included in the response.*/
104
136
  columns?: string[];
105
137
  dateFormat: string;
106
138
  dateTimezone: string;
@@ -311,6 +343,12 @@ interface IPredefinedFilter {
311
343
  * **_Do not modify this property manually._**
312
344
  */
313
345
  imageBlobFetchError?: boolean;
346
+ /**
347
+ * Optional. The action to execute when the predefined filter is clicked.
348
+ * @param rowData The row data object of the clicked row.
349
+ * @param option The IPredefinedFilter data of the predefined element clicked.
350
+ */
351
+ action?: (rowData: any, option: IPredefinedFilter) => void;
314
352
  }
315
353
 
316
354
  interface ITableConfiguration {
@@ -366,11 +404,39 @@ interface ITableOptions {
366
404
  * @default []
367
405
  */
368
406
  data?: any[];
407
+ /**
408
+ * Configurations related to options that are at the header of the table.
409
+ */
369
410
  header?: {
411
+ /**
412
+ * A collection of `ITableButton` to be shown in the table header.
413
+ *
414
+ * @default []
415
+ */
370
416
  buttons?: ITableButton[];
417
+ /**
418
+ * When set to `false`, the **clear sorts** button will be hidden.
419
+ *
420
+ * @default true
421
+ */
371
422
  clearSortsEnabled?: boolean;
423
+ /**
424
+ * Allows customization of the **clear sorts** button icon. You may use any other icons from PrimeNG or third-party providers such as Material Icons or Font Awesome.
425
+ *
426
+ * @default "pi pi-sort-alt-slash"
427
+ */
372
428
  clearSortsIcon?: string;
429
+ /**
430
+ * When set to `false`, the **clear filters** button will be hidden.
431
+ *
432
+ * @default true
433
+ */
373
434
  clearFiltersEnabled?: boolean;
435
+ /**
436
+ * Allows customization of the **clear filters** button icon. Other icons from PrimeNG or third-party libraries (e.g., Material Icons, Font Awesome) may also be used.
437
+ *
438
+ * @default "pi pi-filter-slash"
439
+ */
374
440
  clearFiltersIcon?: string;
375
441
  };
376
442
  /**
@@ -391,6 +457,12 @@ interface ITableOptions {
391
457
  * @default true
392
458
  */
393
459
  selectorEnabled?: boolean;
460
+ /**
461
+ * Can be used to specifiy a different icon to be used by the column selector.
462
+ * You can replace it with any icon from PrimeNG or other libraries such as Font Awesome or Material Icons.
463
+ *
464
+ * @default "pi pi-pen-to-square"
465
+ */
394
466
  selectorIcon?: string;
395
467
  /**
396
468
  * The combination of non-selectable columns and user-selected columns
@@ -404,30 +476,151 @@ interface ITableOptions {
404
476
  * Configurations related to the rows of the table.
405
477
  */
406
478
  rows?: {
479
+ /**
480
+ * Function to dynamically assign CSS classes to a row.
481
+ *
482
+ * Receives the `rowData` object for the current row and returns:
483
+ * - A string with a single CSS class name
484
+ * - An array of class names
485
+ * - A Set of class names
486
+ * - An object with class keys and truthy/falsy values
487
+ *
488
+ * The returned classes are applied to the row in addition to any global or default styles.
489
+ * Useful for changing appearance of a row based on column values.
490
+ *
491
+ * Example:
492
+ * ```ts
493
+ * class: (rowData) => {
494
+ * const classes = [];
495
+ * if (rowData.status === "Unemployed") classes.push("unemployedRow");
496
+ * return classes;
497
+ * }
498
+ * ```
499
+ */
407
500
  class?: (rowData: any) => string | string[] | Set<string> | {
408
501
  [klass: string]: any;
409
502
  };
503
+ /**
504
+ * Function to dynamically assign inline styles to a row.
505
+ *
506
+ * Receives the `rowData` object for the current row and returns an object
507
+ * with CSS properties to apply inline. This allows dynamic styling based
508
+ * on the row's content or values.
509
+ *
510
+ * If not provided, no dynamic styles are applied.
511
+ *
512
+ * Example:
513
+ * ```ts
514
+ * style: (rowData) => {
515
+ * if (rowData.status === "Full-time") {
516
+ * return { fontWeight: "bold", fontStyle: "italic" };
517
+ * }
518
+ * return {};
519
+ * }
520
+ * ```
521
+ */
410
522
  style?: (rowData: any) => {
411
523
  [klass: string]: any;
412
524
  };
525
+ /**
526
+ * Configurations related to the action column for the rows.
527
+ */
413
528
  action?: {
529
+ /**
530
+ * A collection of `ITableButton` to be shown by this column to perform actions over rows. At least one button needs to be enable the row actions column.
531
+ *
532
+ * @default []
533
+ */
414
534
  buttons?: ITableButton[];
535
+ /**
536
+ * The header label for the row actions column.
537
+ *
538
+ * @default "Actions"
539
+ */
415
540
  header?: string;
541
+ /**
542
+ * If `true`, the column will appear on the right side of the table. Otherwise, it will appear on the left.
543
+ *
544
+ * @default true
545
+ */
416
546
  alignmentRight?: boolean;
547
+ /**
548
+ * The fixed column width in pixels.
549
+ *
550
+ * @default 150
551
+ */
417
552
  width?: number;
553
+ /**
554
+ * If `true`, the column remains visible when horizontally scrolling the table.
555
+ *
556
+ * @default true
557
+ */
418
558
  frozen?: boolean;
559
+ /**
560
+ * If `true`, users can resize the column.
561
+ *
562
+ * @default false
563
+ */
419
564
  resizable?: boolean;
420
565
  };
566
+ /**
567
+ * Configurations related to the row checkbox selector.
568
+ */
421
569
  checkboxSelector?: {
570
+ /**
571
+ * If `true`, a new column with checkboxes will be displayed. Users can select or unselect rows using these checkboxes. Additionally an option to filter by this column will be enabled.
572
+ *
573
+ * @default false
574
+ */
422
575
  enabled?: boolean;
576
+ /**
577
+ * The header label for the checkbox selection column.
578
+ *
579
+ * @default "Selected"
580
+ */
423
581
  header?: string;
582
+ /**
583
+ * If `true`, the column will appear on the right side of the table. Otherwise, it will appear on the left.
584
+ *
585
+ * @default false
586
+ */
424
587
  alignmentRight?: boolean;
588
+ /**
589
+ * The fixed column width in pixels.
590
+ *
591
+ * @default 150
592
+ */
425
593
  width?: number;
594
+ /**
595
+ * If `true`, the column remains visible when horizontally scrolling the table.
596
+ *
597
+ * @default true
598
+ */
426
599
  frozen?: boolean;
600
+ /**
601
+ * If `true`, users can resize the column.
602
+ *
603
+ * @default false
604
+ */
427
605
  resizable?: boolean;
428
606
  };
607
+ /**
608
+ * Configurations related to the single row selector.
609
+ */
429
610
  singleSelector?: {
611
+ /**
612
+ * If set to `true`, users can click a row to select it. You can then subscribe to selection events to execute custom actions.
613
+ *
614
+ * @default false
615
+ */
430
616
  enabled?: boolean;
617
+ /**
618
+ * When `true`, users must hold **CTRL** and click on a selected row to unselect it. When `false`, users can unselect a row simply by clicking it again.
619
+ *
620
+ * On mobile devices (phones or tablets), the **CTRL** key configuration is ignored. Users can unselect a previously selected row by simply clicking it, as mobile devices do not have a **CTRL** key.
621
+ *
622
+ * @default true
623
+ */
431
624
  metakey?: boolean;
432
625
  };
433
626
  };
@@ -439,14 +632,17 @@ interface ITableOptions {
439
632
  * When set to `true`, the table will calculate the maximum height dynamically
440
633
  * so that it exactly fits its container. This takes precedence over the `height` property.
441
634
  *
635
+ * Ignored if a `cssFormula` has been provided.
636
+ *
442
637
  * @default true
443
638
  */
444
639
  fitToContainer?: boolean;
445
640
  /**
446
641
  * Fixed vertical height for the table when `fitToContainer` is `false`.
447
642
  *
643
+ * - If a `cssFormula` has been provided, this property is ignored.
448
644
  * - If `fitToContainer` from `verticalScroll` is `true`, this property is ignored.
449
- * - If set to a value `<= 0`, this is ignored and there will be only verticall scroll enabled if `fitToContainer` from `verticalScroll` is `true`.
645
+ * - If set to a value `<= 0`, this is ignored.
450
646
  *
451
647
  * Use this property to enable vertical scrolling with a fixed height when you do not want
452
648
  * the table to dynamically fit its container.
@@ -454,6 +650,15 @@ interface ITableOptions {
454
650
  * @default 0
455
651
  */
456
652
  height?: number;
653
+ /**
654
+ * A CSS string used to define the table's vertical height.
655
+ *
656
+ * Can be a fixed value (e.g., `"500px"`) or a CSS formula (e.g., `"calc(100vh - 200px)"`).
657
+ * When provided, this value **overrides** both `fitToContainer` and `height`.
658
+ *
659
+ * @default undefined
660
+ */
661
+ cssFormula?: string;
457
662
  };
458
663
  /** Configurations related to the global filter functionality of the table. */
459
664
  globalFilter?: {
@@ -475,6 +680,15 @@ interface ITableOptions {
475
680
  */
476
681
  maxLength?: number;
477
682
  };
683
+ /**
684
+ * Predefined filters for table columns.
685
+ *
686
+ * Restricts filter options to a known set of values for a column.
687
+ * Suitable for columns with a limited number of distinct values.
688
+ * Supports plain text, tags, icons, and images. Works with `list` data types.
689
+ *
690
+ * @default {}
691
+ */
478
692
  predefinedFilters?: {
479
693
  [key: string]: IPredefinedFilter[];
480
694
  };
@@ -561,21 +775,19 @@ interface ITableOptions {
561
775
  */
562
776
  titleAllowUserEdit?: boolean;
563
777
  };
778
+ /**
779
+ * Defines the number of seconds the user must hold the mouse button on a cell before its content is copied to the clipboard. Set to a value <= 0 to turn off this feature entirely
780
+ *
781
+ * @default 0.5
782
+ */
564
783
  copyToClipboardTime?: number;
565
784
  }
566
785
  declare const DEFAULT_TABLE_OPTIONS: ITableOptions;
567
786
 
568
- /**
569
- * Interface representing the return structure for PrimeNG post requests when gathering data to represent in a table.
570
- */
571
787
  interface ITablePagedResponse {
572
- /** The current page number.*/
573
788
  page: number;
574
- /** Total number of records available from filter.*/
575
789
  totalRecords: number;
576
- /** Total number of records available (without filters).*/
577
790
  totalRecordsNotFiltered: number;
578
- /** Dynamic data representing the response content of data for the table.*/
579
791
  data: any;
580
792
  }
581
793
 
@@ -625,6 +837,7 @@ declare class ECSPrimengTableService {
625
837
  * handleButtonsClick(deleteAction, { rowID: 1, name: 'John Doe' });
626
838
  */
627
839
  handleButtonsClick(action: (rowData: any) => void, rowData?: any): void;
840
+ handlePredefinedFilterClick(action: (rowData: any, option: IPredefinedFilter) => void, rowData: any | undefined, option: IPredefinedFilter): void;
628
841
  getColumnStyle(col: any, headerCols?: boolean): Record<string, string>;
629
842
  fetchTableViews(tableViewSaveAs: TableViewSaveMode, recoverListEndpoint: string, tableViewSaveKey: string): ITableView[] | Observable<HttpResponse<ITableView[]>>;
630
843
  sortViews(tableSaveViewList: ITableView[]): void;
@@ -770,7 +983,6 @@ declare class ECSPrimengTable implements OnInit, AfterViewInit {
770
983
  * @returns {string} A string indicating the number of selected values for the specified column.
771
984
  */
772
985
  predefinedFiltersSelectedValuesText(columnKeyName: string): string;
773
- handleButtonsClick(action: (rowData: any) => void, rowData?: any): void;
774
986
  /**
775
987
  * Checks if the provided column metadata matches a specific style of the predefined filters
776
988
  * that need to be applied to an item on a row.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eternalcodestudio/primeng-table",
3
- "version": "20.0.8",
3
+ "version": "20.0.10",
4
4
  "description": "ECS reusable Angular PrimeNG table component with advanced server-side filters. Designed to offload filtering logic to any backend API.",
5
5
  "author": "ECS (Eternal CODE Studio)",
6
6
  "license": "MIT",