@guiexpert/angular-table 16.0.38 → 16.1.52
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 +8 -8
- package/angular.json +40 -0
- package/package.json +37 -22
- package/projects/angular-table/README.md +119 -0
- package/projects/angular-table/ng-package.json +7 -0
- package/projects/angular-table/package.json +19 -0
- package/projects/angular-table/src/lib/component-renderer.if.ts +12 -0
- package/projects/angular-table/src/lib/service/dom-service.spec.ts +17 -0
- package/projects/angular-table/src/lib/service/dom-service.ts +63 -0
- package/projects/angular-table/src/lib/service/render-wrapper-factory.ts +24 -0
- package/projects/angular-table/src/lib/service/renderer-wrapper.ts +86 -0
- package/projects/angular-table/src/lib/table.component.css +5 -0
- package/projects/angular-table/src/lib/table.component.spec.ts +28 -0
- package/projects/angular-table/src/lib/table.component.ts +169 -0
- package/{public-api.d.ts → projects/angular-table/src/public-api.ts} +4 -0
- package/projects/angular-table/tsconfig.lib.json +14 -0
- package/projects/angular-table/tsconfig.lib.prod.json +10 -0
- package/projects/angular-table/tsconfig.spec.json +14 -0
- package/tsconfig.json +38 -0
- package/esm2022/guiexpert-angular-table.mjs +0 -5
- package/esm2022/lib/component-renderer.if.mjs +0 -2
- package/esm2022/lib/service/dom-service.mjs +0 -56
- package/esm2022/lib/service/render-wrapper-factory.mjs +0 -22
- package/esm2022/lib/service/renderer-wrapper.mjs +0 -44
- package/esm2022/lib/table.component.mjs +0 -113
- package/esm2022/public-api.mjs +0 -9
- package/fesm2022/guiexpert-angular-table.mjs +0 -237
- package/fesm2022/guiexpert-angular-table.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/component-renderer.if.d.ts +0 -4
- package/lib/service/dom-service.d.ts +0 -17
- package/lib/service/render-wrapper-factory.d.ts +0 -13
- package/lib/service/renderer-wrapper.d.ts +0 -14
- package/lib/table.component.d.ts +0 -43
package/.editorconfig
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
|
|
14
|
+
[*.md]
|
|
15
|
+
max_line_length = off
|
|
16
|
+
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
CHANGED
|
@@ -11,14 +11,14 @@ This is the UI-agnostic table component for your next web app. 😊
|
|
|
11
11
|
### Version compatibility
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
| Angular
|
|
15
|
-
|
|
16
|
-
| 19.x.x
|
|
17
|
-
| 18.x.x
|
|
18
|
-
| 17.x.x
|
|
19
|
-
| 16.x.x
|
|
20
|
-
| 15.x.x
|
|
21
|
-
| 14.x.x
|
|
14
|
+
| Angular | @guiexpert/angular-table |
|
|
15
|
+
|:----------|:-------------------------|
|
|
16
|
+
| 19.x.x | ^19.0.0 |
|
|
17
|
+
| 18.x.x | ^18.0.0 |
|
|
18
|
+
| 17.x.x | ^17.0.0 |
|
|
19
|
+
| 16.x.x | ^16.0.7 |
|
|
20
|
+
| 15.x.x | ^15.0.2 |
|
|
21
|
+
| 14.x.x | ^14.0.3 |
|
|
22
22
|
|
|
|
23
23
|
|
|
24
24
|
|
package/angular.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"newProjectRoot": "projects",
|
|
5
|
+
"projects": {
|
|
6
|
+
"angular-table": {
|
|
7
|
+
"projectType": "library",
|
|
8
|
+
"root": "projects/angular-table",
|
|
9
|
+
"sourceRoot": "projects/angular-table/src",
|
|
10
|
+
"prefix": "lib",
|
|
11
|
+
"architect": {
|
|
12
|
+
"build": {
|
|
13
|
+
"builder": "@angular-devkit/build-angular:ng-packagr",
|
|
14
|
+
"options": {
|
|
15
|
+
"project": "projects/angular-table/ng-package.json"
|
|
16
|
+
},
|
|
17
|
+
"configurations": {
|
|
18
|
+
"production": {
|
|
19
|
+
"tsConfig": "projects/angular-table/tsconfig.lib.prod.json"
|
|
20
|
+
},
|
|
21
|
+
"development": {
|
|
22
|
+
"tsConfig": "projects/angular-table/tsconfig.lib.json"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"defaultConfiguration": "production"
|
|
26
|
+
},
|
|
27
|
+
"test": {
|
|
28
|
+
"builder": "@angular-devkit/build-angular:karma",
|
|
29
|
+
"options": {
|
|
30
|
+
"tsConfig": "projects/angular-table/tsconfig.spec.json",
|
|
31
|
+
"polyfills": [
|
|
32
|
+
"zone.js",
|
|
33
|
+
"zone.js/testing"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/angular-table",
|
|
3
|
-
"version": "16.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "16.1.52",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"inst": "pnpm install -f",
|
|
6
|
+
"ng": "ng",
|
|
7
|
+
"start": "ng serve",
|
|
8
|
+
"build": "ng build",
|
|
9
|
+
"watch": "ng build --watch --configuration development",
|
|
10
|
+
"test": "ng test",
|
|
11
|
+
"npm-update-table": "pnpm update @guiexpert/table",
|
|
12
|
+
"npm-pub": "npm publish --tag a16"
|
|
7
13
|
},
|
|
14
|
+
"private": false,
|
|
8
15
|
"dependencies": {
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
16
|
+
"@angular/animations": "^16.2.12",
|
|
17
|
+
"@angular/common": "^16.2.12",
|
|
18
|
+
"@angular/compiler": "^16.2.12",
|
|
19
|
+
"@angular/core": "^16.2.12",
|
|
20
|
+
"@angular/forms": "^16.2.12",
|
|
21
|
+
"@angular/platform-browser": "^16.2.12",
|
|
22
|
+
"@angular/platform-browser-dynamic": "^16.2.12",
|
|
23
|
+
"@angular/router": "^16.2.12",
|
|
24
|
+
"@guiexpert/table": "^1.1.51",
|
|
25
|
+
"rxjs": "~7.8.0",
|
|
26
|
+
"tslib": "^2.3.0",
|
|
27
|
+
"zone.js": "~0.14.2"
|
|
13
28
|
},
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@angular-devkit/build-angular": "^16.2.10",
|
|
31
|
+
"@angular/cli": "^16.2.10",
|
|
32
|
+
"@angular/compiler-cli": "^16.2.12",
|
|
33
|
+
"@types/jasmine": "~5.1.0",
|
|
34
|
+
"jasmine-core": "~5.1.0",
|
|
35
|
+
"karma": "~6.4.0",
|
|
36
|
+
"karma-chrome-launcher": "~3.2.0",
|
|
37
|
+
"karma-coverage": "~2.2.0",
|
|
38
|
+
"karma-jasmine": "~5.1.0",
|
|
39
|
+
"karma-jasmine-html-reporter": "~2.1.0",
|
|
40
|
+
"ng-packagr": "^16.2.3",
|
|
41
|
+
"typescript": "~5.1.6"
|
|
27
42
|
}
|
|
28
|
-
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @guiexpert/angular-table
|
|
2
|
+
|
|
3
|
+
This is the angular component of the GuiExpert Table Project.
|
|
4
|
+
|
|
5
|
+
## Become a master at creating web applications with large tables
|
|
6
|
+
|
|
7
|
+
This is the UI-agnostic table component for your next web app. 😊
|
|
8
|
+
|
|
9
|
+
<img src="https://raw.githubusercontent.com/guiexperttable/website-astro/main/src/assets/screens/heatmap.png" width="50%">
|
|
10
|
+
|
|
11
|
+
### Version compatibility
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
| Angular | @guiexpert/angular-table |
|
|
15
|
+
|:---------|:-------------------------|
|
|
16
|
+
| 19.x.x | ^19.0.0 |
|
|
17
|
+
| 18.x.x | ^18.0.0 |
|
|
18
|
+
| 17.x.x | ^17.0.0 |
|
|
19
|
+
| 16.x.x | ^16.0.7 |
|
|
20
|
+
| 15.x.x | ^15.0.2 |
|
|
21
|
+
| 14.x.x | ^14.0.3 |
|
|
22
|
+
|
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
- Handle large datasets easily
|
|
27
|
+
- Excellent performance for large tables by vertical and horizontal virtual scrolling
|
|
28
|
+
- Fully-featured (advanced sorting and filtering)
|
|
29
|
+
- Highly customizable orderData grid
|
|
30
|
+
- Outstanding performance
|
|
31
|
+
- No third-party dependencies
|
|
32
|
+
- UI-agnostic
|
|
33
|
+
- Column Interactions (resize, reorder)
|
|
34
|
+
- Sorting Rows
|
|
35
|
+
- Row, Column, and Range Selection
|
|
36
|
+
- Single and Multi Selection
|
|
37
|
+
- UI-agnostic
|
|
38
|
+
- Row and Column Spanning
|
|
39
|
+
- Fixed Columns (Left and Right)
|
|
40
|
+
- Tree table (Hierarchical View)
|
|
41
|
+
- Accessibility support: Keyboard Shortcuts
|
|
42
|
+
- Custom Filtering
|
|
43
|
+
- In-place Cell Editing
|
|
44
|
+
- Userdefined Key and Mouse Events
|
|
45
|
+
- Customizable Look & Feel (via CSS variables)
|
|
46
|
+
- Row sorting
|
|
47
|
+
- Column Reordering (Drag and Drop)
|
|
48
|
+
- State Persistence (Row Sorting, Column Order, Selection)
|
|
49
|
+
- Customizable Cell Contents via Renderer for Header, Body and Footer
|
|
50
|
+
- Full control over the HTML structure and style
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Links
|
|
54
|
+
|
|
55
|
+
- [Demos](https://gui.expert/demos)
|
|
56
|
+
- [Documentation](https://gui.expert/doc)
|
|
57
|
+
- [API](https://gui.expert/api)
|
|
58
|
+
|
|
59
|
+
## Get Started
|
|
60
|
+
|
|
61
|
+
Add the following two NPM packages to your existing angular project (run this in your project root directory):
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
npm install --save @guiexpert/table @guiexpert/angular-table
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Import the (standalone) TableComponent in your angular module:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
@NgModule({
|
|
71
|
+
imports: [
|
|
72
|
+
CommonModule,
|
|
73
|
+
TableComponent, ...
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Add guiexpert-table component to a template:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
<guiexpert-table
|
|
80
|
+
[tableModel]="tableModel"
|
|
81
|
+
[tableOptions]="tableOptions"
|
|
82
|
+
class="table-div"
|
|
83
|
+
></guiexpert-table>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
Add two properties (tableModel and tableOptions) to the component:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
import {
|
|
91
|
+
TableFactory,
|
|
92
|
+
TableModelIf,
|
|
93
|
+
TableOptions,
|
|
94
|
+
TableOptionsIf
|
|
95
|
+
} from "@guiexpert/table";
|
|
96
|
+
|
|
97
|
+
tableModel: TableModelIf = TableFactory.createTableModel({
|
|
98
|
+
headerData: [
|
|
99
|
+
['Header 1', 'Header 2']
|
|
100
|
+
],
|
|
101
|
+
bodyData: [
|
|
102
|
+
['Text 1a', 'Text 2a'],
|
|
103
|
+
['Text 1b', 'Text 2b'],
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
tableOptions = {
|
|
108
|
+
...new TableOptions(),
|
|
109
|
+
hoverColumnVisible: false,
|
|
110
|
+
defaultRowHeights: {
|
|
111
|
+
header: 40,
|
|
112
|
+
body: 34,
|
|
113
|
+
footer: 0
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
There are numerous possibilities to create table models.
|
|
119
|
+
Please refer to the [Documentation](https://gui.expert/doc) for further information or the [Demo](https://gui.expert/demos) section for examples.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guiexpert/angular-table",
|
|
3
|
+
"version": "16.0.38",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^16.2.12",
|
|
6
|
+
"@angular/core": "^16.2.12"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"git-config": "git config --global url.\"https://\".insteadOf ssh://",
|
|
13
|
+
"npm-pub:angular-table": "npm publish ../../dist/angular-table --access public --tag a16"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"url": "https://github.com/guiexperttable/angluar-14-table"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {AreaIdent, AreaModelIf, RendererCleanupFnType} from "@guiexpert/table";
|
|
2
|
+
|
|
3
|
+
export interface ComponentRendererIf<T> {
|
|
4
|
+
|
|
5
|
+
setData(
|
|
6
|
+
rowIndex: number,
|
|
7
|
+
columnIndex: number,
|
|
8
|
+
areaIdent: AreaIdent,
|
|
9
|
+
areaModel: AreaModelIf,
|
|
10
|
+
cellValue: any): RendererCleanupFnType | undefined;
|
|
11
|
+
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import {DomService} from "angular-table";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
describe('DomService', () => {
|
|
7
|
+
let service: DomService;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({});
|
|
11
|
+
service = TestBed.inject(DomService);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should be created', () => {
|
|
15
|
+
expect(service).toBeTruthy();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {Injectable, Renderer2} from "@angular/core";
|
|
2
|
+
import {DomServiceIf} from "@guiexpert/table";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: "root"
|
|
7
|
+
})
|
|
8
|
+
export class DomService implements DomServiceIf {
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
readonly renderer: Renderer2,
|
|
12
|
+
) {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setStyle(el: any, style: string, value: any): any {
|
|
16
|
+
this.renderer.setStyle(el, style, value);
|
|
17
|
+
return el;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
appendText(parent: HTMLDivElement, text: string): HTMLDivElement {
|
|
22
|
+
const div = this.renderer.createText(text);
|
|
23
|
+
this.renderer.appendChild(parent, div);
|
|
24
|
+
return div;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
addClass(div: HTMLDivElement, clazz: string) {
|
|
29
|
+
if (clazz.includes(' ')) {
|
|
30
|
+
clazz.split(' ').forEach(c => this.renderer.addClass(div, c))
|
|
31
|
+
} else {
|
|
32
|
+
this.renderer.addClass(div, clazz);
|
|
33
|
+
}
|
|
34
|
+
return div;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
removeClass(div: HTMLDivElement, clazz: string) {
|
|
38
|
+
if (clazz.includes(" ")) {
|
|
39
|
+
clazz.split(" ").forEach(c => div.classList.remove(c));
|
|
40
|
+
} else {
|
|
41
|
+
div.classList.remove(clazz);
|
|
42
|
+
}
|
|
43
|
+
return div;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
appendChild(parent: HTMLElement, child: HTMLElement): void {
|
|
47
|
+
this.renderer.appendChild(parent, child);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
createElement<T>(name: string): T {
|
|
51
|
+
return this.renderer.createElement(name);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
createText(text: string): HTMLElement {
|
|
55
|
+
return this.renderer.createText(text);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setAttribute(ele: HTMLElement, key: string, value: string): void {
|
|
59
|
+
this.renderer.setAttribute(ele, key, value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {ApplicationRef, ChangeDetectorRef, EnvironmentInjector, Injectable, NgZone, Type} from "@angular/core";
|
|
2
|
+
import {ComponentRendererIf} from "../component-renderer.if";
|
|
3
|
+
import {RendererWrapper} from "./renderer-wrapper";
|
|
4
|
+
|
|
5
|
+
@Injectable({
|
|
6
|
+
providedIn: "root"
|
|
7
|
+
})
|
|
8
|
+
export class RenderWrapperFactory {
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
private readonly appRef: ApplicationRef,
|
|
12
|
+
private readonly injector: EnvironmentInjector,
|
|
13
|
+
private readonly zone: NgZone
|
|
14
|
+
) {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
create<T>(
|
|
18
|
+
componentType: Type<ComponentRendererIf<T>>,
|
|
19
|
+
cdr: ChangeDetectorRef
|
|
20
|
+
) {
|
|
21
|
+
return new RendererWrapper(componentType, this.appRef, this.injector, cdr, this.zone);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {AreaIdent, AreaModelIf, CellRendererIf, DomServiceIf, RendererCleanupFnType} from "@guiexpert/table";
|
|
2
|
+
import {
|
|
3
|
+
ApplicationRef,
|
|
4
|
+
ChangeDetectorRef,
|
|
5
|
+
createComponent,
|
|
6
|
+
EnvironmentInjector,
|
|
7
|
+
EventEmitter,
|
|
8
|
+
NgZone,
|
|
9
|
+
Type
|
|
10
|
+
} from "@angular/core";
|
|
11
|
+
import {ComponentRendererIf} from "../component-renderer.if";
|
|
12
|
+
import {Subject, takeUntil} from "rxjs";
|
|
13
|
+
import {Observable} from "rxjs/internal/Observable";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export class RendererWrapper<T extends ComponentRendererIf<T>>
|
|
17
|
+
implements CellRendererIf {
|
|
18
|
+
|
|
19
|
+
public readonly event$ = new EventEmitter<any>();
|
|
20
|
+
private readonly closed$ = new Subject<number>();
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private componentType: Type<ComponentRendererIf<T>>,
|
|
24
|
+
private appRef: ApplicationRef,
|
|
25
|
+
private injector: EnvironmentInjector,
|
|
26
|
+
private cdr: ChangeDetectorRef,
|
|
27
|
+
private readonly zone: NgZone
|
|
28
|
+
) {
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
render(
|
|
32
|
+
cellDiv: HTMLDivElement,
|
|
33
|
+
rowIndex: number,
|
|
34
|
+
columnIndex: number,
|
|
35
|
+
areaIdent: AreaIdent,
|
|
36
|
+
areaModel: AreaModelIf,
|
|
37
|
+
cellValue: any,
|
|
38
|
+
domService: DomServiceIf): RendererCleanupFnType | undefined {
|
|
39
|
+
|
|
40
|
+
const componentRef = createComponent(this.componentType, {
|
|
41
|
+
environmentInjector: this.injector
|
|
42
|
+
});
|
|
43
|
+
componentRef.instance.setData(
|
|
44
|
+
rowIndex,
|
|
45
|
+
columnIndex,
|
|
46
|
+
areaIdent,
|
|
47
|
+
areaModel,
|
|
48
|
+
cellValue);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const emmiterNames = Object.keys(componentRef.instance)
|
|
52
|
+
.filter(key => {
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
const t = componentRef.instance[key];
|
|
55
|
+
return t['subscribe']
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
const observables: Observable[] = (emmiterNames.map(key => (componentRef.instance[key] as Observable)));
|
|
60
|
+
observables.forEach(obs => obs
|
|
61
|
+
.pipe(
|
|
62
|
+
takeUntil(this.closed$)
|
|
63
|
+
)
|
|
64
|
+
.subscribe((event: any) => {
|
|
65
|
+
console.info('RendererWrapper event >', event); // TODO hmm?
|
|
66
|
+
this.event$.next(event);
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
cellDiv.appendChild(componentRef.location.nativeElement);
|
|
71
|
+
|
|
72
|
+
this.appRef.attachView(componentRef.hostView);
|
|
73
|
+
|
|
74
|
+
this.zone.run(() => {
|
|
75
|
+
this.cdr.detectChanges();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
// clean up:
|
|
80
|
+
this.appRef.detachView(componentRef.hostView);
|
|
81
|
+
this.closed$.next(Date.now());
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import {TableComponent} from "./table.component";
|
|
4
|
+
import {DomService} from "./service/dom-service";
|
|
5
|
+
import {RenderWrapperFactory} from "./service/render-wrapper-factory";
|
|
6
|
+
import {RendererWrapper} from "./service/renderer-wrapper";
|
|
7
|
+
|
|
8
|
+
describe('TableComponent', () => {
|
|
9
|
+
let component: TableComponent;
|
|
10
|
+
let fixture: ComponentFixture<TableComponent>;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
await TestBed.configureTestingModule({
|
|
14
|
+
imports: [
|
|
15
|
+
TableComponent, DomService, RenderWrapperFactory, RendererWrapper
|
|
16
|
+
]
|
|
17
|
+
})
|
|
18
|
+
.compileComponents();
|
|
19
|
+
|
|
20
|
+
fixture = TestBed.createComponent(TableComponent);
|
|
21
|
+
component = fixture.componentInstance;
|
|
22
|
+
fixture.detectChanges();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should create', () => {
|
|
26
|
+
expect(component).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
});
|