@ea-controls/mat-table-extensions 19.0.3 → 19.0.4

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.
Files changed (2) hide show
  1. package/README.md +135 -36
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,63 +1,162 @@
1
1
  # MatTableExtensions
2
2
 
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.1.0.
3
+ Angular directives that allows to extend Angular [mat-table](https://material.angular.io/components/table/overview) features
4
4
 
5
- ## Code scaffolding
5
+ ## Multiple Headers/Footer
6
6
 
7
- Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
7
+ Usually mat-table only allows one header and footer inside [matColumnDef] directive
8
8
 
9
- ```bash
10
- ng generate component component-name
9
+ ```html
10
+ <table mat-table>
11
+ <ng-container matColumnDef="position">
12
+ <th mat-header-cell *matHeaderCellDef> No. </th> <!-- Only one header -->
13
+ <td mat-cell *matCellDef="let element"> {{element.position}} </td>
14
+ </ng-container>
15
+
16
+ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
17
+ </table>
11
18
  ```
12
19
 
13
- For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
20
+ With current library, now you can add more of them
21
+
22
+ ```html
23
+ <table mat-table>
24
+ <ng-container matColumnDef="position">
25
+ <th mat-header-cell *matHeaderCellDef> No. </th>
26
+ <th mat-header-cell *matExtraHeaderCellDef="'extra-header-name'"> Extra Header </th> <!-- Extra header cell-->
27
+ <td mat-cell *matCellDef="let element"> {{element.position}} </td>
28
+ </ng-container>
14
29
 
15
- ```bash
16
- ng generate --help
30
+ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
31
+ <tr mat-header-row *matExtraHeaderRowDef="displayedColumns; name: 'extra-header-name'"></tr> <!-- Extra header row -->
32
+ </table>
17
33
  ```
18
34
 
19
- ## Building
35
+ ### Steps
36
+
37
+ 1. Import `MatExtraTableModule`
38
+ 1. Add new `*matExtraHeaderCellDef` instead `*matHeaderCellDef` for extra headers
39
+ 1. You have to send any string value as cell identifier
40
+ > Replace `extra-header-name` with your custom name
41
+ 1. Notice you can use `*matHeaderRowDef` normally, new directive is only used when you need extra header cell
42
+ 1. Add new `*matExtraHeaderRowDef` instead `*matHeaderRowDef` for extra rows using extra header cells
43
+ 1. `name` is required to find extra header, it have to be the same use in `matExtraHeaderCellDef` attribute
44
+ > *matExtraHeaderRowDef="displayedColumns; `name`: 'extra-header-name'>"
45
+ 1. Notice you can use `*matHeaderRowDef` normally, new directive is only used when you need extra header row
46
+ 1. Similar tags you can use when extra footer is required
47
+
48
+ ```html
49
+ <td mat-footer-cell *matExtraFooterCellDef="'extra-footer-name'">Footer</th> <!-- Extra footer cell -->
50
+ ```
20
51
 
21
- To build the library, run:
52
+ ```html
53
+ <tr mat-header-row *matExtraFooterRowDef="displayedColumns; name: 'extra-footer-name'"></tr> <!-- Extra footer row -->
54
+ ```
55
+
56
+
57
+ ### Full example
58
+
59
+ ```ts
60
+
61
+ import { MatExtraTableModule } from '@ea-controls/mat-table-extensions';
62
+
63
+ export interface PeriodicElement {
64
+ name: string;
65
+ position: number;
66
+ weight: number;
67
+ symbol: string;
68
+ }
69
+
70
+ const ELEMENT_DATA: PeriodicElement[] = [
71
+ { position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H' },
72
+ { position: 2, name: 'Helium', weight: 4.0026, symbol: 'He' },
73
+ { position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li' },
74
+ { position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be' },
75
+ { position: 5, name: 'Boron', weight: 10.811, symbol: 'B' },
76
+ { position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C' },
77
+ { position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N' },
78
+ { position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O' },
79
+ { position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F' },
80
+ { position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne' },
81
+ ];
82
+
83
+ @Component({
84
+ selector: 'app-basic',
85
+ imports: [MatExtraTableModule],
86
+ templateUrl: './basic.component.html'
87
+ })
88
+ export class BasicComponent {
89
+ displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
90
+ dataSource = ELEMENT_DATA;
91
+ }
22
92
 
23
- ```bash
24
- ng build mat-table-extensions
25
93
  ```
26
94
 
27
- This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
95
+ ```html
96
+ <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
28
97
 
29
- ### Publishing the Library
98
+ <!-- POSITION -->
99
+ <ng-container matColumnDef="position">
100
+ <th mat-header-cell *matHeaderCellDef> 1. from html </th>
101
+ <th mat-header-cell *matExtraHeaderCellDef="'filter'">
102
+ <input type="text">
103
+ </th>
30
104
 
31
- Once the project is built, you can publish your library by following these steps:
105
+ <td mat-cell *matCellDef="let data"> xxxxxxxxxx from html </td>
32
106
 
33
- 1. Navigate to the `dist` directory:
34
- ```bash
35
- cd dist/mat-table-extensions
36
- ```
107
+ <td mat-footer-cell *matFooterCellDef> f1 </td>
108
+ <th mat-footer-cell *matExtraFooterCellDef="'filter'" [attr.colspan]="2">f2</th>
109
+ </ng-container>
37
110
 
38
- 2. Run the `npm publish` command to publish your library to the npm registry:
39
- ```bash
40
- npm publish
41
- ```
111
+ <!-- NAME -->
112
+ <ng-container matColumnDef="name">
113
+ <th mat-header-cell *matHeaderCellDef> Name </th>
114
+ <th mat-header-cell *matExtraHeaderCellDef="'filter'">
115
+ <input type="text">
116
+ </th>
42
117
 
43
- ## Running unit tests
118
+ <td mat-cell *matCellDef="let element"> {{element.name}} </td>
44
119
 
45
- To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
120
+ <td mat-footer-cell *matFooterCellDef> f1 </td>
121
+ <th mat-footer-cell *matExtraFooterCellDef="'filter'" [attr.colspan]="4">f2</th>
122
+ </ng-container>
46
123
 
47
- ```bash
48
- ng test
49
- ```
124
+ <!-- WEIGHT -->
125
+ <ng-container matColumnDef="weight">
126
+ <th mat-header-cell *matHeaderCellDef> Weight </th>
127
+ <th mat-header-cell *matExtraHeaderCellDef="'filter'">
128
+ <input type="text">
129
+ </th>
50
130
 
51
- ## Running end-to-end tests
131
+ <td mat-cell *matCellDef="let element"> {{element.weight}} </td>
52
132
 
53
- For end-to-end (e2e) testing, run:
133
+ <td mat-footer-cell *matFooterCellDef> f1 </td>
134
+ </ng-container>
54
135
 
55
- ```bash
56
- ng e2e
57
- ```
136
+ <!-- SYMBOL -->
137
+ <ng-container matColumnDef="symbol">
138
+ <th mat-header-cell *matHeaderCellDef> Symbol </th>
139
+ <th mat-header-cell *matExtraHeaderCellDef="'filter'">
140
+ <input type="text">
141
+ </th>
142
+
143
+ <td mat-cell *matCellDef="let element"> {{element.symbol}} </td>
144
+
145
+ <td mat-footer-cell *matFooterCellDef> f1 </td>
146
+ </ng-container>
147
+
148
+
149
+
150
+ <!-- HEADERS -->
151
+ <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
152
+ <tr mat-header-row *matExtraHeaderRowDef="displayedColumns; name: 'filter'"></tr>
58
153
 
59
- Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
154
+ <!-- CELLS -->
155
+ <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
60
156
 
61
- ## Additional Resources
157
+ <!-- FOOTER -->
158
+ <tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>
159
+ <tr mat-footer-row *matExtraFooterRowDef="['position', 'name']; name: 'filter'"></tr>
62
160
 
63
- For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
161
+ </table>
162
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ea-controls/mat-table-extensions",
3
- "version": "19.0.3",
3
+ "version": "19.0.4",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.1.0",
6
6
  "@angular/core": "^19.1.0"