@ea-controls/mat-table-extensions 0.0.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/.editorconfig +17 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/tasks.json +42 -0
- package/README.md +160 -0
- package/angular.json +137 -0
- package/package.json +42 -0
- package/projects/mat-table-extensions/README.md +63 -0
- package/projects/mat-table-extensions/ng-package.json +7 -0
- package/projects/mat-table-extensions/package.json +24 -0
- package/projects/mat-table-extensions/src/lib/cell.ts +58 -0
- package/projects/mat-table-extensions/src/lib/index.ts +3 -0
- package/projects/mat-table-extensions/src/lib/module.ts +21 -0
- package/projects/mat-table-extensions/src/lib/row.ts +38 -0
- package/projects/mat-table-extensions/src/public-api.ts +6 -0
- package/projects/mat-table-extensions/tsconfig.lib.json +15 -0
- package/projects/mat-table-extensions/tsconfig.lib.prod.json +11 -0
- package/projects/mat-table-extensions/tsconfig.spec.json +15 -0
- package/projects/mat-table-extensions-examples/public/favicon.ico +0 -0
- package/projects/mat-table-extensions-examples/src/app/app.component.html +6 -0
- package/projects/mat-table-extensions-examples/src/app/app.component.scss +29 -0
- package/projects/mat-table-extensions-examples/src/app/app.component.spec.ts +29 -0
- package/projects/mat-table-extensions-examples/src/app/app.component.ts +14 -0
- package/projects/mat-table-extensions-examples/src/app/app.config.ts +9 -0
- package/projects/mat-table-extensions-examples/src/app/app.routes.ts +9 -0
- package/projects/mat-table-extensions-examples/src/app/basic/basic.component.html +66 -0
- package/projects/mat-table-extensions-examples/src/app/basic/basic.component.scss +0 -0
- package/projects/mat-table-extensions-examples/src/app/basic/basic.component.spec.ts +23 -0
- package/projects/mat-table-extensions-examples/src/app/basic/basic.component.ts +33 -0
- package/projects/mat-table-extensions-examples/src/app/sticky/sticky.component.html +83 -0
- package/projects/mat-table-extensions-examples/src/app/sticky/sticky.component.scss +0 -0
- package/projects/mat-table-extensions-examples/src/app/sticky/sticky.component.spec.ts +23 -0
- package/projects/mat-table-extensions-examples/src/app/sticky/sticky.component.ts +57 -0
- package/projects/mat-table-extensions-examples/src/index.html +15 -0
- package/projects/mat-table-extensions-examples/src/main.ts +6 -0
- package/projects/mat-table-extensions-examples/src/styles.scss +4 -0
- package/projects/mat-table-extensions-examples/tsconfig.app.json +15 -0
- package/projects/mat-table-extensions-examples/tsconfig.spec.json +15 -0
- package/tsconfig.json +35 -0
package/.editorconfig
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Editor configuration, see https://editorconfig.org
|
2
|
+
root = true
|
3
|
+
|
4
|
+
[*]
|
5
|
+
charset = utf-8
|
6
|
+
indent_style = space
|
7
|
+
indent_size = 2
|
8
|
+
insert_final_newline = true
|
9
|
+
trim_trailing_whitespace = true
|
10
|
+
|
11
|
+
[*.ts]
|
12
|
+
quote_type = single
|
13
|
+
ij_typescript_use_double_quotes = false
|
14
|
+
|
15
|
+
[*.md]
|
16
|
+
max_line_length = off
|
17
|
+
trim_trailing_whitespace = false
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
3
|
+
"version": "0.2.0",
|
4
|
+
"configurations": [
|
5
|
+
{
|
6
|
+
"name": "ng serve",
|
7
|
+
"type": "chrome",
|
8
|
+
"request": "launch",
|
9
|
+
"preLaunchTask": "npm: start",
|
10
|
+
"url": "http://localhost:4200/"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"name": "ng test",
|
14
|
+
"type": "chrome",
|
15
|
+
"request": "launch",
|
16
|
+
"preLaunchTask": "npm: test",
|
17
|
+
"url": "http://localhost:9876/debug.html"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
3
|
+
"version": "2.0.0",
|
4
|
+
"tasks": [
|
5
|
+
{
|
6
|
+
"type": "npm",
|
7
|
+
"script": "start",
|
8
|
+
"isBackground": true,
|
9
|
+
"problemMatcher": {
|
10
|
+
"owner": "typescript",
|
11
|
+
"pattern": "$tsc",
|
12
|
+
"background": {
|
13
|
+
"activeOnStart": true,
|
14
|
+
"beginsPattern": {
|
15
|
+
"regexp": "(.*?)"
|
16
|
+
},
|
17
|
+
"endsPattern": {
|
18
|
+
"regexp": "bundle generation complete"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"type": "npm",
|
25
|
+
"script": "test",
|
26
|
+
"isBackground": true,
|
27
|
+
"problemMatcher": {
|
28
|
+
"owner": "typescript",
|
29
|
+
"pattern": "$tsc",
|
30
|
+
"background": {
|
31
|
+
"activeOnStart": true,
|
32
|
+
"beginsPattern": {
|
33
|
+
"regexp": "(.*?)"
|
34
|
+
},
|
35
|
+
"endsPattern": {
|
36
|
+
"regexp": "bundle generation complete"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
package/README.md
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
# MatTableExtensions
|
2
|
+
|
3
|
+
Angular directives that allows to extend Angular [mat-table](https://material.angular.io/components/table/overview) features
|
4
|
+
|
5
|
+
## Multiple Headers/Footer
|
6
|
+
|
7
|
+
Usually mat-table only allows one header and footer inside [matColumnDef] directive
|
8
|
+
|
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>
|
18
|
+
```
|
19
|
+
|
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>
|
29
|
+
|
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>
|
33
|
+
```
|
34
|
+
|
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
|
+
```
|
51
|
+
|
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
|
+
export interface PeriodicElement {
|
62
|
+
name: string;
|
63
|
+
position: number;
|
64
|
+
weight: number;
|
65
|
+
symbol: string;
|
66
|
+
}
|
67
|
+
|
68
|
+
const ELEMENT_DATA: PeriodicElement[] = [
|
69
|
+
{ position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H' },
|
70
|
+
{ position: 2, name: 'Helium', weight: 4.0026, symbol: 'He' },
|
71
|
+
{ position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li' },
|
72
|
+
{ position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be' },
|
73
|
+
{ position: 5, name: 'Boron', weight: 10.811, symbol: 'B' },
|
74
|
+
{ position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C' },
|
75
|
+
{ position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N' },
|
76
|
+
{ position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O' },
|
77
|
+
{ position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F' },
|
78
|
+
{ position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne' },
|
79
|
+
];
|
80
|
+
|
81
|
+
@Component({
|
82
|
+
selector: 'app-basic',
|
83
|
+
imports: [MatExtraTableModule],
|
84
|
+
templateUrl: './basic.component.html'
|
85
|
+
})
|
86
|
+
export class BasicComponent {
|
87
|
+
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
|
88
|
+
dataSource = ELEMENT_DATA;
|
89
|
+
}
|
90
|
+
|
91
|
+
```
|
92
|
+
|
93
|
+
```html
|
94
|
+
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
95
|
+
|
96
|
+
<!-- POSITION -->
|
97
|
+
<ng-container matColumnDef="position">
|
98
|
+
<th mat-header-cell *matHeaderCellDef> 1. from html </th>
|
99
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'">
|
100
|
+
<input type="text">
|
101
|
+
</th>
|
102
|
+
|
103
|
+
<td mat-cell *matCellDef="let data"> xxxxxxxxxx from html </td>
|
104
|
+
|
105
|
+
<td mat-footer-cell *matFooterCellDef> f1 </td>
|
106
|
+
<th mat-footer-cell *matExtraFooterCellDef="'filter'" [attr.colspan]="2">f2</th>
|
107
|
+
</ng-container>
|
108
|
+
|
109
|
+
<!-- NAME -->
|
110
|
+
<ng-container matColumnDef="name">
|
111
|
+
<th mat-header-cell *matHeaderCellDef> Name </th>
|
112
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'">
|
113
|
+
<input type="text">
|
114
|
+
</th>
|
115
|
+
|
116
|
+
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
|
117
|
+
|
118
|
+
<td mat-footer-cell *matFooterCellDef> f1 </td>
|
119
|
+
<th mat-footer-cell *matExtraFooterCellDef="'filter'" [attr.colspan]="4">f2</th>
|
120
|
+
</ng-container>
|
121
|
+
|
122
|
+
<!-- WEIGHT -->
|
123
|
+
<ng-container matColumnDef="weight">
|
124
|
+
<th mat-header-cell *matHeaderCellDef> Weight </th>
|
125
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'">
|
126
|
+
<input type="text">
|
127
|
+
</th>
|
128
|
+
|
129
|
+
<td mat-cell *matCellDef="let element"> {{element.weight}} </td>
|
130
|
+
|
131
|
+
<td mat-footer-cell *matFooterCellDef> f1 </td>
|
132
|
+
</ng-container>
|
133
|
+
|
134
|
+
<!-- SYMBOL -->
|
135
|
+
<ng-container matColumnDef="symbol">
|
136
|
+
<th mat-header-cell *matHeaderCellDef> Symbol </th>
|
137
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'">
|
138
|
+
<input type="text">
|
139
|
+
</th>
|
140
|
+
|
141
|
+
<td mat-cell *matCellDef="let element"> {{element.symbol}} </td>
|
142
|
+
|
143
|
+
<td mat-footer-cell *matFooterCellDef> f1 </td>
|
144
|
+
</ng-container>
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
<!-- HEADERS -->
|
149
|
+
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
150
|
+
<tr mat-header-row *matExtraHeaderRowDef="displayedColumns; name: 'filter'"></tr>
|
151
|
+
|
152
|
+
<!-- CELLS -->
|
153
|
+
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
154
|
+
|
155
|
+
<!-- FOOTER -->
|
156
|
+
<tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>
|
157
|
+
<tr mat-footer-row *matExtraFooterRowDef="['position', 'name']; name: 'filter'"></tr>
|
158
|
+
|
159
|
+
</table>
|
160
|
+
```
|
package/angular.json
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
3
|
+
"version": 1,
|
4
|
+
"newProjectRoot": "projects",
|
5
|
+
"projects": {
|
6
|
+
"mat-table-extensions": {
|
7
|
+
"projectType": "library",
|
8
|
+
"root": "projects/mat-table-extensions",
|
9
|
+
"sourceRoot": "projects/mat-table-extensions/src",
|
10
|
+
"prefix": "lib",
|
11
|
+
"architect": {
|
12
|
+
"build": {
|
13
|
+
"builder": "@angular-devkit/build-angular:ng-packagr",
|
14
|
+
"options": {
|
15
|
+
"project": "projects/mat-table-extensions/ng-package.json"
|
16
|
+
},
|
17
|
+
"configurations": {
|
18
|
+
"production": {
|
19
|
+
"tsConfig": "projects/mat-table-extensions/tsconfig.lib.prod.json"
|
20
|
+
},
|
21
|
+
"development": {
|
22
|
+
"tsConfig": "projects/mat-table-extensions/tsconfig.lib.json"
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"defaultConfiguration": "production"
|
26
|
+
},
|
27
|
+
"test": {
|
28
|
+
"builder": "@angular-devkit/build-angular:karma",
|
29
|
+
"options": {
|
30
|
+
"tsConfig": "projects/mat-table-extensions/tsconfig.spec.json",
|
31
|
+
"polyfills": [
|
32
|
+
"zone.js",
|
33
|
+
"zone.js/testing"
|
34
|
+
]
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
},
|
39
|
+
"mat-table-extensions-examples": {
|
40
|
+
"projectType": "application",
|
41
|
+
"schematics": {
|
42
|
+
"@schematics/angular:component": {
|
43
|
+
"style": "scss"
|
44
|
+
}
|
45
|
+
},
|
46
|
+
"root": "projects/mat-table-extensions-examples",
|
47
|
+
"sourceRoot": "projects/mat-table-extensions-examples/src",
|
48
|
+
"prefix": "app",
|
49
|
+
"architect": {
|
50
|
+
"build": {
|
51
|
+
"builder": "@angular-devkit/build-angular:application",
|
52
|
+
"options": {
|
53
|
+
"outputPath": "dist/mat-table-extensions-examples",
|
54
|
+
"index": "projects/mat-table-extensions-examples/src/index.html",
|
55
|
+
"browser": "projects/mat-table-extensions-examples/src/main.ts",
|
56
|
+
"polyfills": [
|
57
|
+
"zone.js"
|
58
|
+
],
|
59
|
+
"tsConfig": "projects/mat-table-extensions-examples/tsconfig.app.json",
|
60
|
+
"inlineStyleLanguage": "scss",
|
61
|
+
"assets": [
|
62
|
+
{
|
63
|
+
"glob": "**/*",
|
64
|
+
"input": "projects/mat-table-extensions-examples/public"
|
65
|
+
}
|
66
|
+
],
|
67
|
+
"styles": [
|
68
|
+
"@angular/material/prebuilt-themes/azure-blue.css",
|
69
|
+
"projects/mat-table-extensions-examples/src/styles.scss"
|
70
|
+
],
|
71
|
+
"scripts": []
|
72
|
+
},
|
73
|
+
"configurations": {
|
74
|
+
"production": {
|
75
|
+
"budgets": [
|
76
|
+
{
|
77
|
+
"type": "initial",
|
78
|
+
"maximumWarning": "500kB",
|
79
|
+
"maximumError": "1MB"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"type": "anyComponentStyle",
|
83
|
+
"maximumWarning": "4kB",
|
84
|
+
"maximumError": "8kB"
|
85
|
+
}
|
86
|
+
],
|
87
|
+
"outputHashing": "all"
|
88
|
+
},
|
89
|
+
"development": {
|
90
|
+
"optimization": false,
|
91
|
+
"extractLicenses": false,
|
92
|
+
"sourceMap": true
|
93
|
+
}
|
94
|
+
},
|
95
|
+
"defaultConfiguration": "production"
|
96
|
+
},
|
97
|
+
"serve": {
|
98
|
+
"builder": "@angular-devkit/build-angular:dev-server",
|
99
|
+
"configurations": {
|
100
|
+
"production": {
|
101
|
+
"buildTarget": "mat-table-extensions-examples:build:production"
|
102
|
+
},
|
103
|
+
"development": {
|
104
|
+
"buildTarget": "mat-table-extensions-examples:build:development"
|
105
|
+
}
|
106
|
+
},
|
107
|
+
"defaultConfiguration": "development"
|
108
|
+
},
|
109
|
+
"extract-i18n": {
|
110
|
+
"builder": "@angular-devkit/build-angular:extract-i18n"
|
111
|
+
},
|
112
|
+
"test": {
|
113
|
+
"builder": "@angular-devkit/build-angular:karma",
|
114
|
+
"options": {
|
115
|
+
"polyfills": [
|
116
|
+
"zone.js",
|
117
|
+
"zone.js/testing"
|
118
|
+
],
|
119
|
+
"tsConfig": "projects/mat-table-extensions-examples/tsconfig.spec.json",
|
120
|
+
"inlineStyleLanguage": "scss",
|
121
|
+
"assets": [
|
122
|
+
{
|
123
|
+
"glob": "**/*",
|
124
|
+
"input": "projects/mat-table-extensions-examples/public"
|
125
|
+
}
|
126
|
+
],
|
127
|
+
"styles": [
|
128
|
+
"@angular/material/prebuilt-themes/azure-blue.css",
|
129
|
+
"projects/mat-table-extensions-examples/src/styles.scss"
|
130
|
+
],
|
131
|
+
"scripts": []
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"name": "@ea-controls/mat-table-extensions",
|
3
|
+
"version": "0.0.0",
|
4
|
+
"scripts": {
|
5
|
+
"ng": "ng",
|
6
|
+
"start": "ng serve",
|
7
|
+
"build": "ng build",
|
8
|
+
"watch": "ng build --watch --configuration development",
|
9
|
+
"test": "ng test",
|
10
|
+
"publish": "ng build mat-table-extensions && npm publish"
|
11
|
+
},
|
12
|
+
"private": false,
|
13
|
+
"dependencies": {
|
14
|
+
"@angular/animations": "^19.1.0",
|
15
|
+
"@angular/cdk": "^19.1.5",
|
16
|
+
"@angular/common": "^19.1.0",
|
17
|
+
"@angular/compiler": "^19.1.0",
|
18
|
+
"@angular/core": "^19.1.0",
|
19
|
+
"@angular/forms": "^19.1.0",
|
20
|
+
"@angular/material": "^19.1.5",
|
21
|
+
"@angular/platform-browser": "^19.1.0",
|
22
|
+
"@angular/platform-browser-dynamic": "^19.1.0",
|
23
|
+
"@angular/router": "^19.1.0",
|
24
|
+
"rxjs": "~7.8.0",
|
25
|
+
"tslib": "^2.3.0",
|
26
|
+
"zone.js": "~0.15.0"
|
27
|
+
},
|
28
|
+
"devDependencies": {
|
29
|
+
"@angular-devkit/build-angular": "^19.1.8",
|
30
|
+
"@angular/cli": "^19.1.6",
|
31
|
+
"@angular/compiler-cli": "^19.1.0",
|
32
|
+
"@types/jasmine": "~5.1.0",
|
33
|
+
"jasmine-core": "~5.5.0",
|
34
|
+
"karma": "~6.4.0",
|
35
|
+
"karma-chrome-launcher": "~3.2.0",
|
36
|
+
"karma-coverage": "~2.2.0",
|
37
|
+
"karma-jasmine": "~5.1.0",
|
38
|
+
"karma-jasmine-html-reporter": "~2.1.0",
|
39
|
+
"ng-packagr": "^19.1.0",
|
40
|
+
"typescript": "~5.7.2"
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# MatTableExtensions
|
2
|
+
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.1.0.
|
4
|
+
|
5
|
+
## Code scaffolding
|
6
|
+
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
ng generate component component-name
|
11
|
+
```
|
12
|
+
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
ng generate --help
|
17
|
+
```
|
18
|
+
|
19
|
+
## Building
|
20
|
+
|
21
|
+
To build the library, run:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
ng build mat-table-extensions
|
25
|
+
```
|
26
|
+
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
28
|
+
|
29
|
+
### Publishing the Library
|
30
|
+
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
32
|
+
|
33
|
+
1. Navigate to the `dist` directory:
|
34
|
+
```bash
|
35
|
+
cd dist/mat-table-extensions
|
36
|
+
```
|
37
|
+
|
38
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
39
|
+
```bash
|
40
|
+
npm publish
|
41
|
+
```
|
42
|
+
|
43
|
+
## Running unit tests
|
44
|
+
|
45
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
ng test
|
49
|
+
```
|
50
|
+
|
51
|
+
## Running end-to-end tests
|
52
|
+
|
53
|
+
For end-to-end (e2e) testing, run:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
ng e2e
|
57
|
+
```
|
58
|
+
|
59
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
60
|
+
|
61
|
+
## Additional Resources
|
62
|
+
|
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.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"name": "mat-table-extensions",
|
3
|
+
"version": "19.0.2",
|
4
|
+
"peerDependencies": {
|
5
|
+
"@angular/common": "^19.1.0",
|
6
|
+
"@angular/core": "^19.1.0"
|
7
|
+
},
|
8
|
+
"dependencies": {
|
9
|
+
"tslib": "^2.3.0"
|
10
|
+
},
|
11
|
+
"sideEffects": false,
|
12
|
+
"publishConfig": {
|
13
|
+
"access": "public"
|
14
|
+
},
|
15
|
+
"keywords": [
|
16
|
+
"angular",
|
17
|
+
"mat-table",
|
18
|
+
"angular-material",
|
19
|
+
"cdk",
|
20
|
+
"table",
|
21
|
+
"grid"
|
22
|
+
],
|
23
|
+
"author": "Edwin Arias"
|
24
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { Directive, inject, input, effect } from "@angular/core";
|
2
|
+
import { MatHeaderCellDef, MatTable, MatColumnDef, MatFooterCellDef } from "@angular/material/table";
|
3
|
+
|
4
|
+
@Directive({
|
5
|
+
selector: '[matExtraHeaderCellDef]',
|
6
|
+
providers: [{ provide: MatHeaderCellDef, useExisting: MatExtraHeaderCellDefDirective }]
|
7
|
+
})
|
8
|
+
export class MatExtraHeaderCellDefDirective extends MatHeaderCellDef {
|
9
|
+
|
10
|
+
private _table = inject(MatTable);
|
11
|
+
private _column = inject(MatColumnDef);
|
12
|
+
public _prefix = input('', { alias: 'matExtraHeaderCellDef' })
|
13
|
+
|
14
|
+
constructor() {
|
15
|
+
super();
|
16
|
+
|
17
|
+
let column = new MatColumnDef();
|
18
|
+
|
19
|
+
effect(() => {
|
20
|
+
if (this._table) {
|
21
|
+
column.name = `h_${this._column.name}_${this._prefix()}`;
|
22
|
+
column.sticky = this._column.sticky;
|
23
|
+
column.stickyEnd = this._column.stickyEnd;
|
24
|
+
column.cssClassFriendlyName = this._column.cssClassFriendlyName;
|
25
|
+
column.headerCell = this;
|
26
|
+
this._table.addColumnDef(column);
|
27
|
+
}
|
28
|
+
});
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
@Directive({
|
33
|
+
selector: '[matExtraFooterCellDef]',
|
34
|
+
providers: [{ provide: MatFooterCellDef, useExisting: MatExtraFooterCellDefDirective }]
|
35
|
+
})
|
36
|
+
export class MatExtraFooterCellDefDirective extends MatFooterCellDef {
|
37
|
+
|
38
|
+
private _table = inject(MatTable);
|
39
|
+
private _column = inject(MatColumnDef);
|
40
|
+
public _prefix = input('', { alias: 'matExtraFooterCellDef' })
|
41
|
+
|
42
|
+
constructor() {
|
43
|
+
super();
|
44
|
+
|
45
|
+
let column = new MatColumnDef();
|
46
|
+
|
47
|
+
effect(() => {
|
48
|
+
if (this._table) {
|
49
|
+
column.name = `f_${this._column.name}_${this._prefix()}`;
|
50
|
+
column.sticky = this._column.sticky;
|
51
|
+
column.stickyEnd = this._column.stickyEnd;
|
52
|
+
column.cssClassFriendlyName = this._column.cssClassFriendlyName;
|
53
|
+
column.footerCell = this;
|
54
|
+
this._table.addColumnDef(column);
|
55
|
+
}
|
56
|
+
});
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { NgModule } from "@angular/core";
|
2
|
+
import { MatExtraFooterCellDefDirective, MatExtraFooterRowDefDirective, MatExtraHeaderCellDefDirective, MatExtraHeaderRowDefDirective } from ".";
|
3
|
+
import { MatTableModule } from "@angular/material/table";
|
4
|
+
|
5
|
+
@NgModule({
|
6
|
+
imports: [
|
7
|
+
MatExtraHeaderCellDefDirective,
|
8
|
+
MatExtraFooterCellDefDirective,
|
9
|
+
MatExtraHeaderRowDefDirective,
|
10
|
+
MatExtraFooterRowDefDirective,
|
11
|
+
MatTableModule
|
12
|
+
],
|
13
|
+
exports: [
|
14
|
+
MatExtraHeaderCellDefDirective,
|
15
|
+
MatExtraFooterCellDefDirective,
|
16
|
+
MatExtraHeaderRowDefDirective,
|
17
|
+
MatExtraFooterRowDefDirective,
|
18
|
+
MatTableModule
|
19
|
+
],
|
20
|
+
})
|
21
|
+
export class MatExtraTableModule { }
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { CdkHeaderRowDef, CdkFooterRowDef } from "@angular/cdk/table";
|
2
|
+
import { Directive, booleanAttribute, input, effect } from "@angular/core";
|
3
|
+
|
4
|
+
@Directive({
|
5
|
+
selector: '[matExtraHeaderRowDef]',
|
6
|
+
providers: [{ provide: CdkHeaderRowDef, useExisting: MatExtraHeaderRowDefDirective }],
|
7
|
+
inputs: [
|
8
|
+
{ name: 'columns', alias: 'matExtraHeaderRowDef' },
|
9
|
+
{ name: 'sticky', alias: 'matExtraHeaderRowDefSticky', transform: booleanAttribute },
|
10
|
+
],
|
11
|
+
})
|
12
|
+
export class MatExtraHeaderRowDefDirective extends CdkHeaderRowDef {
|
13
|
+
|
14
|
+
public _prefix = input.required({ alias: 'matExtraHeaderRowDefName' })
|
15
|
+
|
16
|
+
constructor() {
|
17
|
+
super();
|
18
|
+
effect(() => this.columns = [...this.columns].map(c => `h_${c}_${this._prefix()}`));
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
@Directive({
|
23
|
+
selector: '[matExtraFooterRowDef]',
|
24
|
+
providers: [{ provide: CdkFooterRowDef, useExisting: MatExtraFooterRowDefDirective }],
|
25
|
+
inputs: [
|
26
|
+
{ name: 'columns', alias: 'matExtraFooterRowDef' },
|
27
|
+
{ name: 'sticky', alias: 'matExtraFooterRowDefSticky', transform: booleanAttribute },
|
28
|
+
],
|
29
|
+
})
|
30
|
+
export class MatExtraFooterRowDefDirective extends CdkFooterRowDef {
|
31
|
+
|
32
|
+
public _prefix = input.required({ alias: 'matExtraFooterRowDefName' })
|
33
|
+
|
34
|
+
constructor() {
|
35
|
+
super();
|
36
|
+
effect(() => this.columns = [...this.columns].map(c => `f_${c}_${this._prefix()}`));
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
3
|
+
{
|
4
|
+
"extends": "../../tsconfig.json",
|
5
|
+
"compilerOptions": {
|
6
|
+
"outDir": "../../out-tsc/lib",
|
7
|
+
"declaration": true,
|
8
|
+
"declarationMap": true,
|
9
|
+
"inlineSources": true,
|
10
|
+
"types": []
|
11
|
+
},
|
12
|
+
"exclude": [
|
13
|
+
"**/*.spec.ts"
|
14
|
+
]
|
15
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
3
|
+
{
|
4
|
+
"extends": "./tsconfig.lib.json",
|
5
|
+
"compilerOptions": {
|
6
|
+
"declarationMap": false
|
7
|
+
},
|
8
|
+
"angularCompilerOptions": {
|
9
|
+
"compilationMode": "partial"
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
3
|
+
{
|
4
|
+
"extends": "../../tsconfig.json",
|
5
|
+
"compilerOptions": {
|
6
|
+
"outDir": "../../out-tsc/spec",
|
7
|
+
"types": [
|
8
|
+
"jasmine"
|
9
|
+
]
|
10
|
+
},
|
11
|
+
"include": [
|
12
|
+
"**/*.spec.ts",
|
13
|
+
"**/*.d.ts"
|
14
|
+
]
|
15
|
+
}
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/* Navbar container */
|
2
|
+
.navbar {
|
3
|
+
overflow: hidden;
|
4
|
+
background-color: #333;
|
5
|
+
font-family: Arial, Helvetica, sans-serif;
|
6
|
+
margin-bottom: 1rem;
|
7
|
+
}
|
8
|
+
|
9
|
+
/* Navbar links */
|
10
|
+
.navbar a {
|
11
|
+
float: left;
|
12
|
+
display: block;
|
13
|
+
color: #f2f2f2;
|
14
|
+
text-align: center;
|
15
|
+
padding: 14px 16px;
|
16
|
+
text-decoration: none;
|
17
|
+
}
|
18
|
+
|
19
|
+
/* Change color on hover */
|
20
|
+
.navbar a:hover {
|
21
|
+
background-color: #ddd;
|
22
|
+
color: black;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* Active/current link */
|
26
|
+
.navbar a.active {
|
27
|
+
background-color: #4CAF50;
|
28
|
+
color: white;
|
29
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
2
|
+
import { AppComponent } from './app.component';
|
3
|
+
|
4
|
+
describe('AppComponent', () => {
|
5
|
+
beforeEach(async () => {
|
6
|
+
await TestBed.configureTestingModule({
|
7
|
+
imports: [AppComponent],
|
8
|
+
}).compileComponents();
|
9
|
+
});
|
10
|
+
|
11
|
+
it('should create the app', () => {
|
12
|
+
const fixture = TestBed.createComponent(AppComponent);
|
13
|
+
const app = fixture.componentInstance;
|
14
|
+
expect(app).toBeTruthy();
|
15
|
+
});
|
16
|
+
|
17
|
+
it(`should have the 'mat-table-extensions-examples' title`, () => {
|
18
|
+
const fixture = TestBed.createComponent(AppComponent);
|
19
|
+
const app = fixture.componentInstance;
|
20
|
+
expect(app.title).toEqual('mat-table-extensions-examples');
|
21
|
+
});
|
22
|
+
|
23
|
+
it('should render title', () => {
|
24
|
+
const fixture = TestBed.createComponent(AppComponent);
|
25
|
+
fixture.detectChanges();
|
26
|
+
const compiled = fixture.nativeElement as HTMLElement;
|
27
|
+
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, mat-table-extensions-examples');
|
28
|
+
});
|
29
|
+
});
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Component } from '@angular/core';
|
2
|
+
import { RouterModule } from '@angular/router';
|
3
|
+
|
4
|
+
@Component({
|
5
|
+
selector: 'app-root',
|
6
|
+
imports: [
|
7
|
+
RouterModule
|
8
|
+
],
|
9
|
+
templateUrl: './app.component.html',
|
10
|
+
styleUrl: './app.component.scss'
|
11
|
+
})
|
12
|
+
export class AppComponent {
|
13
|
+
|
14
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
2
|
+
import { provideRouter } from '@angular/router';
|
3
|
+
|
4
|
+
import { routes } from './app.routes';
|
5
|
+
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
6
|
+
|
7
|
+
export const appConfig: ApplicationConfig = {
|
8
|
+
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideAnimationsAsync()]
|
9
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Routes } from '@angular/router';
|
2
|
+
import { BasicComponent } from './basic/basic.component';
|
3
|
+
import { StickyComponent } from './sticky/sticky.component';
|
4
|
+
|
5
|
+
export const routes: Routes = [
|
6
|
+
{ path: '', redirectTo: 'basic', pathMatch: 'full' },
|
7
|
+
{ path: 'basic', component: BasicComponent },
|
8
|
+
{ path: 'sticky', component: StickyComponent },
|
9
|
+
];
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
2
|
+
|
3
|
+
<!-- POSITION -->
|
4
|
+
<ng-container matColumnDef="position">
|
5
|
+
<th mat-header-cell *matHeaderCellDef> 1. from html </th>
|
6
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'">
|
7
|
+
<input type="text">
|
8
|
+
</th>
|
9
|
+
|
10
|
+
<td mat-cell *matCellDef="let data"> xxxxxxxxxx from html </td>
|
11
|
+
|
12
|
+
<td mat-footer-cell *matFooterCellDef> f1 </td>
|
13
|
+
<td mat-footer-cell *matExtraFooterCellDef="'filter'" [attr.colspan]="2">f2</td>
|
14
|
+
</ng-container>
|
15
|
+
|
16
|
+
<!-- NAME -->
|
17
|
+
<ng-container matColumnDef="name">
|
18
|
+
<th mat-header-cell *matHeaderCellDef> Name </th>
|
19
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'">
|
20
|
+
<input type="text">
|
21
|
+
</th>
|
22
|
+
|
23
|
+
<td mat-cell *matCellDef="let element"> {{element.name}} </td>
|
24
|
+
|
25
|
+
<td mat-footer-cell *matFooterCellDef> f1 </td>
|
26
|
+
<td mat-footer-cell *matExtraFooterCellDef="'filter'" [attr.colspan]="4">f2</td>
|
27
|
+
</ng-container>
|
28
|
+
|
29
|
+
<!-- WEIGHT -->
|
30
|
+
<ng-container matColumnDef="weight">
|
31
|
+
<th mat-header-cell *matHeaderCellDef> Weight </th>
|
32
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'">
|
33
|
+
<input type="text">
|
34
|
+
</th>
|
35
|
+
|
36
|
+
<td mat-cell *matCellDef="let element"> {{element.weight}} </td>
|
37
|
+
|
38
|
+
<td mat-footer-cell *matFooterCellDef> f1 </td>
|
39
|
+
</ng-container>
|
40
|
+
|
41
|
+
<!-- SYMBOL -->
|
42
|
+
<ng-container matColumnDef="symbol">
|
43
|
+
<th mat-header-cell *matHeaderCellDef> Symbol </th>
|
44
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'">
|
45
|
+
<input type="text">
|
46
|
+
</th>
|
47
|
+
|
48
|
+
<td mat-cell *matCellDef="let element"> {{element.symbol}} </td>
|
49
|
+
|
50
|
+
<td mat-footer-cell *matFooterCellDef> f1 </td>
|
51
|
+
</ng-container>
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<!-- HEADERS -->
|
56
|
+
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
57
|
+
<tr mat-header-row *matExtraHeaderRowDef="displayedColumns; name: 'filter'"></tr>
|
58
|
+
|
59
|
+
<!-- CELLS -->
|
60
|
+
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
61
|
+
|
62
|
+
<!-- FOOTER -->
|
63
|
+
<tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>
|
64
|
+
<tr mat-footer-row *matExtraFooterRowDef="['position', 'name']; name: 'filter'"></tr>
|
65
|
+
|
66
|
+
</table>
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
2
|
+
|
3
|
+
import { BasicComponent } from './basic.component';
|
4
|
+
|
5
|
+
describe('BasicComponent', () => {
|
6
|
+
let component: BasicComponent;
|
7
|
+
let fixture: ComponentFixture<BasicComponent>;
|
8
|
+
|
9
|
+
beforeEach(async () => {
|
10
|
+
await TestBed.configureTestingModule({
|
11
|
+
imports: [BasicComponent]
|
12
|
+
})
|
13
|
+
.compileComponents();
|
14
|
+
|
15
|
+
fixture = TestBed.createComponent(BasicComponent);
|
16
|
+
component = fixture.componentInstance;
|
17
|
+
fixture.detectChanges();
|
18
|
+
});
|
19
|
+
|
20
|
+
it('should create', () => {
|
21
|
+
expect(component).toBeTruthy();
|
22
|
+
});
|
23
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { Component } from '@angular/core';
|
2
|
+
import { MatExtraTableModule } from '@ea-controls/mat-table-extensions';
|
3
|
+
|
4
|
+
export interface PeriodicElement {
|
5
|
+
name: string;
|
6
|
+
position: number;
|
7
|
+
weight: number;
|
8
|
+
symbol: string;
|
9
|
+
}
|
10
|
+
|
11
|
+
const ELEMENT_DATA: PeriodicElement[] = [
|
12
|
+
{ position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H' },
|
13
|
+
{ position: 2, name: 'Helium', weight: 4.0026, symbol: 'He' },
|
14
|
+
{ position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li' },
|
15
|
+
{ position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be' },
|
16
|
+
{ position: 5, name: 'Boron', weight: 10.811, symbol: 'B' },
|
17
|
+
{ position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C' },
|
18
|
+
{ position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N' },
|
19
|
+
{ position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O' },
|
20
|
+
{ position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F' },
|
21
|
+
{ position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne' },
|
22
|
+
];
|
23
|
+
|
24
|
+
@Component({
|
25
|
+
selector: 'app-basic',
|
26
|
+
imports: [MatExtraTableModule],
|
27
|
+
templateUrl: './basic.component.html',
|
28
|
+
styleUrl: './basic.component.scss'
|
29
|
+
})
|
30
|
+
export class BasicComponent {
|
31
|
+
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
|
32
|
+
dataSource = ELEMENT_DATA;
|
33
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
<div>
|
2
|
+
<button mat-raised-button (click)="tables.push(tables.length)">Add table</button>
|
3
|
+
<button mat-raised-button (click)="tables.pop()">Remove table</button>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div>
|
7
|
+
Sticky Headers:
|
8
|
+
<mat-button-toggle-group multiple [value]="['header-1']" #stickyHeaders="matButtonToggleGroup"
|
9
|
+
class="example-sticky-toggle-group">
|
10
|
+
<mat-button-toggle value="header-1"> Row 1 </mat-button-toggle>
|
11
|
+
<mat-button-toggle value="header-2"> Row 2 </mat-button-toggle>
|
12
|
+
</mat-button-toggle-group>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div>
|
16
|
+
Sticky Footers:
|
17
|
+
<mat-button-toggle-group multiple [value]="['footer-1']" #stickyFooters="matButtonToggleGroup"
|
18
|
+
class="example-sticky-toggle-group">
|
19
|
+
<mat-button-toggle value="footer-1"> Row 1 </mat-button-toggle>
|
20
|
+
<mat-button-toggle value="footer-2"> Row 2 </mat-button-toggle>
|
21
|
+
</mat-button-toggle-group>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div>
|
25
|
+
Sticky Columns:
|
26
|
+
<mat-button-toggle-group multiple [value]="['position', 'symbol']" #stickyColumns="matButtonToggleGroup"
|
27
|
+
class="example-sticky-toggle-group">
|
28
|
+
<mat-button-toggle value="position"> Position </mat-button-toggle>
|
29
|
+
<mat-button-toggle value="name"> Name </mat-button-toggle>
|
30
|
+
<mat-button-toggle value="weight"> Weight </mat-button-toggle>
|
31
|
+
<mat-button-toggle value="symbol"> Symbol </mat-button-toggle>
|
32
|
+
</mat-button-toggle-group>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<section class="example-container mat-elevation-z8" tabindex="0">
|
36
|
+
@for (table of tables; track table) {
|
37
|
+
<mat-table [dataSource]="dataSource">
|
38
|
+
<ng-container matColumnDef="position" [sticky]="isSticky(stickyColumns, 'position')">
|
39
|
+
<th mat-header-cell *matHeaderCellDef> Position </th>
|
40
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'"> <input type="text"> </th>
|
41
|
+
<td mat-footer-cell mat-cell *matCellDef="let element"> {{element.position}} </td>
|
42
|
+
<td mat-footer-cell *matFooterCellDef> Position Footer </td>
|
43
|
+
</ng-container>
|
44
|
+
|
45
|
+
<ng-container matColumnDef="name" [sticky]="isSticky(stickyColumns, 'name')">
|
46
|
+
<th mat-header-cell *matHeaderCellDef> Name </th>
|
47
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'"> <input type="text"> </th>
|
48
|
+
<td mat-footer-cell mat-cell *matCellDef="let element"> {{element.name}} </td>
|
49
|
+
<td mat-footer-cell *matFooterCellDef> Name Footer </td>
|
50
|
+
</ng-container>
|
51
|
+
|
52
|
+
<ng-container matColumnDef="weight" [stickyEnd]="isSticky(stickyColumns, 'weight')">
|
53
|
+
<th mat-header-cell *matHeaderCellDef> Weight </th>
|
54
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'"> <input type="text"> </th>
|
55
|
+
<td mat-footer-cell mat-cell *matCellDef="let element"> {{element.weight}} </td>
|
56
|
+
<td mat-footer-cell *matFooterCellDef> Weight Footer </td>
|
57
|
+
</ng-container>
|
58
|
+
|
59
|
+
<ng-container matColumnDef="symbol" [stickyEnd]="isSticky(stickyColumns, 'symbol')">
|
60
|
+
<th mat-header-cell *matHeaderCellDef> Symbol </th>
|
61
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'"> <input type="text"> </th>
|
62
|
+
<td mat-footer-cell mat-cell *matCellDef="let element"> {{element.symbol}} </td>
|
63
|
+
<td mat-footer-cell *matFooterCellDef> Symbol Footer </td>
|
64
|
+
</ng-container>
|
65
|
+
|
66
|
+
<ng-container matColumnDef="filler">
|
67
|
+
<th mat-header-cell *matHeaderCellDef> Filler header cell </th>
|
68
|
+
<th mat-header-cell *matExtraHeaderCellDef="'filter'"> <input type="text"> </th>
|
69
|
+
<td mat-footer-cell mat-cell *matCellDef="let element"> Filler data cell </td>
|
70
|
+
<td mat-footer-cell *matFooterCellDef> Filler footer cell </td>
|
71
|
+
</ng-container>
|
72
|
+
|
73
|
+
<tr mat-header-row *matExtraHeaderRowDef="displayedColumns; sticky: true; name: 'filter'"></tr>
|
74
|
+
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: isSticky(stickyHeaders, 'header-1')"></tr>
|
75
|
+
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: isSticky(stickyHeaders, 'header-2')"></tr>
|
76
|
+
|
77
|
+
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
78
|
+
|
79
|
+
<tr mat-footer-row *matFooterRowDef="displayedColumns; sticky: isSticky(stickyFooters, 'footer-1')"></tr>
|
80
|
+
<tr mat-footer-row *matFooterRowDef="displayedColumns; sticky: isSticky(stickyFooters, 'footer-2')"></tr>
|
81
|
+
</mat-table>
|
82
|
+
}
|
83
|
+
</section>
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
2
|
+
|
3
|
+
import { StickyComponent } from './sticky.component';
|
4
|
+
|
5
|
+
describe('StickyComponent', () => {
|
6
|
+
let component: StickyComponent;
|
7
|
+
let fixture: ComponentFixture<StickyComponent>;
|
8
|
+
|
9
|
+
beforeEach(async () => {
|
10
|
+
await TestBed.configureTestingModule({
|
11
|
+
imports: [StickyComponent]
|
12
|
+
})
|
13
|
+
.compileComponents();
|
14
|
+
|
15
|
+
fixture = TestBed.createComponent(StickyComponent);
|
16
|
+
component = fixture.componentInstance;
|
17
|
+
fixture.detectChanges();
|
18
|
+
});
|
19
|
+
|
20
|
+
it('should create', () => {
|
21
|
+
expect(component).toBeTruthy();
|
22
|
+
});
|
23
|
+
});
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { Component } from '@angular/core';
|
2
|
+
import { MatButtonModule } from '@angular/material/button';
|
3
|
+
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
4
|
+
import { MatExtraTableModule } from '@ea-controls/mat-table-extensions';
|
5
|
+
import { MatButtonToggleGroup } from '@angular/material/button-toggle';
|
6
|
+
|
7
|
+
export interface PeriodicElement {
|
8
|
+
name: string;
|
9
|
+
position: number;
|
10
|
+
weight: number;
|
11
|
+
symbol: string;
|
12
|
+
}
|
13
|
+
|
14
|
+
const ELEMENT_DATA: PeriodicElement[] = [
|
15
|
+
{ position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H' },
|
16
|
+
{ position: 2, name: 'Helium', weight: 4.0026, symbol: 'He' },
|
17
|
+
{ position: 3, name: 'Lithium', weight: 6.941, symbol: 'Li' },
|
18
|
+
{ position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be' },
|
19
|
+
{ position: 5, name: 'Boron', weight: 10.811, symbol: 'B' },
|
20
|
+
{ position: 6, name: 'Carbon', weight: 12.0107, symbol: 'C' },
|
21
|
+
{ position: 7, name: 'Nitrogen', weight: 14.0067, symbol: 'N' },
|
22
|
+
{ position: 8, name: 'Oxygen', weight: 15.9994, symbol: 'O' },
|
23
|
+
{ position: 9, name: 'Fluorine', weight: 18.9984, symbol: 'F' },
|
24
|
+
{ position: 10, name: 'Neon', weight: 20.1797, symbol: 'Ne' },
|
25
|
+
];
|
26
|
+
|
27
|
+
|
28
|
+
@Component({
|
29
|
+
selector: 'app-sticky',
|
30
|
+
imports: [MatExtraTableModule, MatButtonModule, MatButtonToggleModule],
|
31
|
+
templateUrl: './sticky.component.html',
|
32
|
+
styleUrl: './sticky.component.scss'
|
33
|
+
})
|
34
|
+
export class StickyComponent {
|
35
|
+
|
36
|
+
displayedColumns: string[] = [];
|
37
|
+
dataSource = ELEMENT_DATA;
|
38
|
+
|
39
|
+
tables = [0];
|
40
|
+
|
41
|
+
constructor() {
|
42
|
+
this.displayedColumns.length = 24;
|
43
|
+
this.displayedColumns.fill('filler');
|
44
|
+
|
45
|
+
// The first two columns should be position and name; the last two columns: weight, symbol
|
46
|
+
this.displayedColumns[0] = 'position';
|
47
|
+
this.displayedColumns[1] = 'name';
|
48
|
+
this.displayedColumns[22] = 'weight';
|
49
|
+
this.displayedColumns[23] = 'symbol';
|
50
|
+
}
|
51
|
+
|
52
|
+
/** Whether the button toggle group contains the id as an active value. */
|
53
|
+
isSticky(buttonToggleGroup: MatButtonToggleGroup, id: string) {
|
54
|
+
return (buttonToggleGroup.value || []).indexOf(id) !== -1;
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>MatTableExtensionsExamples</title>
|
6
|
+
<base href="/">
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
8
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
9
|
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
10
|
+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<app-root></app-root>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
3
|
+
{
|
4
|
+
"extends": "../../tsconfig.json",
|
5
|
+
"compilerOptions": {
|
6
|
+
"outDir": "../../out-tsc/app",
|
7
|
+
"types": []
|
8
|
+
},
|
9
|
+
"files": [
|
10
|
+
"src/main.ts"
|
11
|
+
],
|
12
|
+
"include": [
|
13
|
+
"src/**/*.d.ts"
|
14
|
+
]
|
15
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
3
|
+
{
|
4
|
+
"extends": "../../tsconfig.json",
|
5
|
+
"compilerOptions": {
|
6
|
+
"outDir": "../../out-tsc/spec",
|
7
|
+
"types": [
|
8
|
+
"jasmine"
|
9
|
+
]
|
10
|
+
},
|
11
|
+
"include": [
|
12
|
+
"src/**/*.spec.ts",
|
13
|
+
"src/**/*.d.ts"
|
14
|
+
]
|
15
|
+
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
3
|
+
{
|
4
|
+
"compileOnSave": false,
|
5
|
+
"compilerOptions": {
|
6
|
+
"outDir": "./dist/out-tsc",
|
7
|
+
"strict": true,
|
8
|
+
"noImplicitOverride": true,
|
9
|
+
"noPropertyAccessFromIndexSignature": true,
|
10
|
+
"paths": {
|
11
|
+
"mat-table-extensions": [
|
12
|
+
"./dist/mat-table-extensions"
|
13
|
+
],
|
14
|
+
"@ea-controls/mat-table-extensions": [
|
15
|
+
"./projects/mat-table-extensions/src/public-api"
|
16
|
+
]
|
17
|
+
},
|
18
|
+
"noImplicitReturns": true,
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
20
|
+
"skipLibCheck": true,
|
21
|
+
"isolatedModules": true,
|
22
|
+
"esModuleInterop": true,
|
23
|
+
"experimentalDecorators": true,
|
24
|
+
"moduleResolution": "bundler",
|
25
|
+
"importHelpers": true,
|
26
|
+
"target": "ES2022",
|
27
|
+
"module": "ES2022"
|
28
|
+
},
|
29
|
+
"angularCompilerOptions": {
|
30
|
+
"enableI18nLegacyMessageIdFormat": false,
|
31
|
+
"strictInjectionParameters": true,
|
32
|
+
"strictInputAccessModifiers": true,
|
33
|
+
"strictTemplates": true
|
34
|
+
}
|
35
|
+
}
|