mat-table-ext 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 +16 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/tasks.json +42 -0
- package/README.md +27 -0
- package/angular.json +150 -0
- package/package.json +45 -0
- package/projects/mat-table-ext/.browserslistrc +16 -0
- package/projects/mat-table-ext/README.md +24 -0
- package/projects/mat-table-ext/assets/pinIcon.svg +1 -0
- package/projects/mat-table-ext/assets/pinLeft.svg +11 -0
- package/projects/mat-table-ext/assets/pinNone.svg +5 -0
- package/projects/mat-table-ext/assets/pinRight.svg +11 -0
- package/projects/mat-table-ext/assets/pinned.svg +2 -0
- package/projects/mat-table-ext/karma.conf.js +44 -0
- package/projects/mat-table-ext/ng-package.json +9 -0
- package/projects/mat-table-ext/package.json +34 -0
- package/projects/mat-table-ext/src/lib/components/column-pinning/column-pinning.component.html +7 -0
- package/projects/mat-table-ext/src/lib/components/column-pinning/column-pinning.component.scss +9 -0
- package/projects/mat-table-ext/src/lib/components/column-pinning/column-pinning.component.spec.ts +23 -0
- package/projects/mat-table-ext/src/lib/components/column-pinning/column-pinning.component.ts +48 -0
- package/projects/mat-table-ext/src/lib/components/editing/editing.component.html +55 -0
- package/projects/mat-table-ext/src/lib/components/editing/editing.component.scss +19 -0
- package/projects/mat-table-ext/src/lib/components/editing/editing.component.spec.ts +23 -0
- package/projects/mat-table-ext/src/lib/components/editing/editing.component.ts +110 -0
- package/projects/mat-table-ext/src/lib/components/filter-columns-component/filter-columns-component.component.html +26 -0
- package/projects/mat-table-ext/src/lib/components/filter-columns-component/filter-columns-component.component.scss +0 -0
- package/projects/mat-table-ext/src/lib/components/filter-columns-component/filter-columns-component.component.spec.ts +23 -0
- package/projects/mat-table-ext/src/lib/components/filter-columns-component/filter-columns-component.component.ts +54 -0
- package/projects/mat-table-ext/src/lib/directives/resize-column.directive.ts +103 -0
- package/projects/mat-table-ext/src/lib/mat-table-ext.component.html +285 -0
- package/projects/mat-table-ext/src/lib/mat-table-ext.component.spec.ts +25 -0
- package/projects/mat-table-ext/src/lib/mat-table-ext.component.ts +985 -0
- package/projects/mat-table-ext/src/lib/mat-table-ext.module.ts +127 -0
- package/projects/mat-table-ext/src/lib/mat-table-ext.scss +189 -0
- package/projects/mat-table-ext/src/lib/mat-table-ext.service.spec.ts +16 -0
- package/projects/mat-table-ext/src/lib/mat-table-ext.service.ts +12 -0
- package/projects/mat-table-ext/src/lib/models/tableExtModels.ts +85 -0
- package/projects/mat-table-ext/src/public-api.ts +11 -0
- package/projects/mat-table-ext/src/test.ts +27 -0
- package/projects/mat-table-ext/tsconfig.lib.json +15 -0
- package/projects/mat-table-ext/tsconfig.lib.prod.json +10 -0
- package/projects/mat-table-ext/tsconfig.spec.json +17 -0
- package/projects/mat-table-ext-example/.browserslistrc +16 -0
- package/projects/mat-table-ext-example/karma.conf.js +44 -0
- package/projects/mat-table-ext-example/src/app/app.component.html +577 -0
- package/projects/mat-table-ext-example/src/app/app.component.scss +0 -0
- package/projects/mat-table-ext-example/src/app/app.component.spec.ts +31 -0
- package/projects/mat-table-ext-example/src/app/app.component.ts +173 -0
- package/projects/mat-table-ext-example/src/app/app.module.ts +40 -0
- package/projects/mat-table-ext-example/src/app/service/custom-table.service.spec.ts +16 -0
- package/projects/mat-table-ext-example/src/app/service/custom-table.service.ts +18 -0
- package/projects/mat-table-ext-example/src/assets/.gitkeep +0 -0
- package/projects/mat-table-ext-example/src/assets/data.json +100003 -0
- package/projects/mat-table-ext-example/src/environments/environment.prod.ts +3 -0
- package/projects/mat-table-ext-example/src/environments/environment.ts +16 -0
- package/projects/mat-table-ext-example/src/favicon.ico +0 -0
- package/projects/mat-table-ext-example/src/index.html +14 -0
- package/projects/mat-table-ext-example/src/main.ts +12 -0
- package/projects/mat-table-ext-example/src/polyfills.ts +53 -0
- package/projects/mat-table-ext-example/src/styles.scss +1 -0
- package/projects/mat-table-ext-example/src/test.ts +26 -0
- package/projects/mat-table-ext-example/tsconfig.app.json +15 -0
- package/projects/mat-table-ext-example/tsconfig.spec.json +18 -0
- package/tsconfig.json +38 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Component, TemplateRef, ViewChild } from '@angular/core';
|
|
2
|
+
import { MatTableDataSource } from '@angular/material/table';
|
|
3
|
+
import { CustomTableService } from './service/custom-table.service';
|
|
4
|
+
import { MTExColumn } from '../../../mat-table-ext/src/lib/models/tableExtModels';
|
|
5
|
+
export const EXAMPLE_DATA: any[] = [
|
|
6
|
+
{
|
|
7
|
+
position: 1,
|
|
8
|
+
name: 'Boron',
|
|
9
|
+
weight: 10.811,
|
|
10
|
+
symbol: 'B',
|
|
11
|
+
gender: 'male',
|
|
12
|
+
mobile: '13198765432',
|
|
13
|
+
tele: '567891234',
|
|
14
|
+
city: 'Berlin',
|
|
15
|
+
address: 'Bernauer Str.111,13355',
|
|
16
|
+
date: '1423456765768',
|
|
17
|
+
website: 'www.matero.com',
|
|
18
|
+
company: 'matero',
|
|
19
|
+
email: 'Boron@gmail.com',
|
|
20
|
+
status: false,
|
|
21
|
+
cost: 4,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
position: 2,
|
|
25
|
+
name: 'Helium',
|
|
26
|
+
weight: 8.0026,
|
|
27
|
+
symbol: 'He',
|
|
28
|
+
gender: 'female',
|
|
29
|
+
mobile: '13034676675',
|
|
30
|
+
tele: '80675432',
|
|
31
|
+
city: 'Shanghai',
|
|
32
|
+
address: '88 Songshan Road',
|
|
33
|
+
date: '1423456765768',
|
|
34
|
+
website: 'www.matero.com',
|
|
35
|
+
company: 'matero',
|
|
36
|
+
email: 'Helium@gmail.com',
|
|
37
|
+
status: true,
|
|
38
|
+
cost: 5,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
position: 3,
|
|
42
|
+
name: 'Nitrogen',
|
|
43
|
+
weight: 14.0067,
|
|
44
|
+
symbol: 'N',
|
|
45
|
+
gender: 'male',
|
|
46
|
+
mobile: '15811112222',
|
|
47
|
+
tele: '345678912',
|
|
48
|
+
city: 'Sydney',
|
|
49
|
+
address: 'Circular Quay, Sydney NSW 2000',
|
|
50
|
+
date: '1423456765768',
|
|
51
|
+
website: 'www.matero.com',
|
|
52
|
+
company: 'matero',
|
|
53
|
+
email: 'Nitrogen@gmail.com',
|
|
54
|
+
status: true,
|
|
55
|
+
cost: 2,
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
@Component({
|
|
59
|
+
selector: 'app-root',
|
|
60
|
+
templateUrl: './app.component.html',
|
|
61
|
+
styleUrls: ['./app.component.scss'],
|
|
62
|
+
})
|
|
63
|
+
export class AppComponent {
|
|
64
|
+
title = 'mat-table-ext-example';
|
|
65
|
+
isLoading: boolean = false;
|
|
66
|
+
public dataSource: any = new MatTableDataSource(EXAMPLE_DATA);
|
|
67
|
+
stickyColumn: any = false;
|
|
68
|
+
columnResizable: any = false;
|
|
69
|
+
stickyFooter: any = false;
|
|
70
|
+
stickyHeader: any = false;
|
|
71
|
+
inlineRowEditing: any = false;
|
|
72
|
+
popupRowEditing: any = false;
|
|
73
|
+
inCellEditing: any = false;
|
|
74
|
+
deleteRow: any = false;
|
|
75
|
+
stripedRows: any = false;
|
|
76
|
+
rowSelection: any = false;
|
|
77
|
+
multiRowSelection: any = false;
|
|
78
|
+
simpleFilter: any = true;
|
|
79
|
+
selectionFilter: any = false;
|
|
80
|
+
toolbarToggle: any = true;
|
|
81
|
+
toolbarHeight: string = '';
|
|
82
|
+
showFirstLastButtons: any = false;
|
|
83
|
+
columnPinnable: any = false;
|
|
84
|
+
columnHidable: any = false;
|
|
85
|
+
exportButtonEnable: any = true;
|
|
86
|
+
@ViewChild('cellTemplate1') cellTemplate1!: TemplateRef<any>;
|
|
87
|
+
@ViewChild('cellTemplate2') cellTemplate2!: TemplateRef<any>;
|
|
88
|
+
|
|
89
|
+
public columns: MTExColumn[] = [
|
|
90
|
+
{ header: 'Position', field: 'position', width: '200px',type:'string' },
|
|
91
|
+
{ header: 'Name', field: 'name', width: '200px', pinned: 'left', type: 'string' },
|
|
92
|
+
{ header: 'Weight', field: 'weight', width: '200px', pinned: 'left', type: 'string' },
|
|
93
|
+
{ header: 'Symbol', field: 'symbol', width: '200px', type: 'string' },
|
|
94
|
+
{ header: 'Gender', field: 'gender', width: '200px', type: 'selection',options:['male','female'] }
|
|
95
|
+
];
|
|
96
|
+
multiSelectRow: any = true;
|
|
97
|
+
topSearchFilter: any = false;
|
|
98
|
+
tableHeight: string = '';
|
|
99
|
+
tableWidth: string = '';
|
|
100
|
+
isExpandEnable: any = false;
|
|
101
|
+
dragEnable: any = false;
|
|
102
|
+
sorting: any = false;
|
|
103
|
+
infiniteScroll: any = false;
|
|
104
|
+
scrollbarH: any = false;
|
|
105
|
+
paginationEnable: any = true;
|
|
106
|
+
headerTemplateRefCtrl: any = false;
|
|
107
|
+
cellTemplateRefCtrl: any = false;
|
|
108
|
+
toolbarTemplateRefCtrl: any = false;
|
|
109
|
+
popupTemplateRefCtrl: any = false;
|
|
110
|
+
inlineTemplateRefCtrl: any = false;
|
|
111
|
+
cellEditingTemplateRefCtrl: any = false;
|
|
112
|
+
constructor(public service: CustomTableService) {
|
|
113
|
+
// this.loadPage(10);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
ngOnInit(): void {}
|
|
117
|
+
|
|
118
|
+
showhidecolumn(op: string) {
|
|
119
|
+
switch (op) {
|
|
120
|
+
case 'inlineRowEditing': {
|
|
121
|
+
this.inlineRowEditing = !this.inlineRowEditing;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case 'popupRowEditing': {
|
|
125
|
+
this.popupRowEditing = !this.popupRowEditing;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case 'enableDelete': {
|
|
129
|
+
this.deleteRow = !this.deleteRow;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case 'select': {
|
|
133
|
+
this.multiRowSelection = !this.multiRowSelection;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
showData(event: any, property: string) {
|
|
140
|
+
console.log(property, event);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
onScroll(event: any) {
|
|
144
|
+
let pageLimit: number = 10;
|
|
145
|
+
let scrollHeight = event.target.scrollHeight;
|
|
146
|
+
let scrollTop = event.target.scrollTop;
|
|
147
|
+
let clientHeight = event.target.clientHeight;
|
|
148
|
+
let scrollPosition = scrollHeight - (scrollTop + clientHeight);
|
|
149
|
+
console.log('scrollPosition', scrollPosition);
|
|
150
|
+
if (scrollPosition <= 5 && this.infiniteScroll) {
|
|
151
|
+
this.loadPage(pageLimit);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
loadPage(limit: number) {
|
|
156
|
+
this.isLoading = true;
|
|
157
|
+
let offset = this.dataSource ? this.dataSource.data.length : 0;
|
|
158
|
+
this.service.getResults(offset, limit).subscribe((results: any) => {
|
|
159
|
+
if (this.dataSource) {
|
|
160
|
+
const rows = [...this.dataSource.data, ...results.data];
|
|
161
|
+
this.dataSource = new MatTableDataSource(rows);
|
|
162
|
+
} else {
|
|
163
|
+
const rows = [...results.data];
|
|
164
|
+
this.dataSource = new MatTableDataSource(rows);
|
|
165
|
+
}
|
|
166
|
+
this.isLoading = false;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
onSelectionChange(event: any) {
|
|
171
|
+
console.log('Selection Change: ', event);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
3
|
+
import { AppComponent } from './app.component';
|
|
4
|
+
import { MatTableExtModule } from 'mat-table-ext';
|
|
5
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
6
|
+
import { MatDialogModule } from '@angular/material/dialog';
|
|
7
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
8
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
9
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
10
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
11
|
+
import { MatDividerModule } from '@angular/material/divider';
|
|
12
|
+
import { MatCardModule } from '@angular/material/card';
|
|
13
|
+
import { MatInputModule } from '@angular/material/input';
|
|
14
|
+
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
15
|
+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
16
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
17
|
+
|
|
18
|
+
@NgModule({
|
|
19
|
+
declarations: [AppComponent],
|
|
20
|
+
imports: [
|
|
21
|
+
BrowserModule,
|
|
22
|
+
BrowserAnimationsModule,
|
|
23
|
+
MatTableExtModule,
|
|
24
|
+
MatCheckboxModule,
|
|
25
|
+
MatDialogModule,
|
|
26
|
+
ReactiveFormsModule,
|
|
27
|
+
FormsModule,
|
|
28
|
+
MatSelectModule,
|
|
29
|
+
HttpClientModule,
|
|
30
|
+
MatIconModule,
|
|
31
|
+
MatDividerModule,
|
|
32
|
+
MatCardModule,
|
|
33
|
+
MatFormFieldModule,
|
|
34
|
+
MatInputModule,
|
|
35
|
+
MatSlideToggleModule,
|
|
36
|
+
],
|
|
37
|
+
providers: [],
|
|
38
|
+
bootstrap: [AppComponent],
|
|
39
|
+
})
|
|
40
|
+
export class AppModule {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { CustomTableService } from './custom-table.service';
|
|
4
|
+
|
|
5
|
+
describe('CustomTableService', () => {
|
|
6
|
+
let service: CustomTableService;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({});
|
|
10
|
+
service = TestBed.inject(CustomTableService);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be created', () => {
|
|
14
|
+
expect(service).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject, delay, map, Observable, of } from 'rxjs';
|
|
3
|
+
import data from '../../assets/data.json';
|
|
4
|
+
const companyData = data as any[];
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: 'root',
|
|
7
|
+
})
|
|
8
|
+
export class CustomTableService {
|
|
9
|
+
public selectedRow = new BehaviorSubject<any>(null);
|
|
10
|
+
public selectedRowIndex = new BehaviorSubject<any>(null);
|
|
11
|
+
constructor() {}
|
|
12
|
+
getResults(offset: number, limit: number): Observable<any> {
|
|
13
|
+
return of(companyData.slice(offset, offset + limit)).pipe(
|
|
14
|
+
delay(new Date(Date.now() + 250)),
|
|
15
|
+
map((d) => ({ data: d }))
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
File without changes
|