@guiexpert/angular-table 16.1.55 → 16.1.56
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/README.md +8 -8
- package/esm2022/guiexpert-angular-table.mjs +5 -0
- package/esm2022/lib/component-renderer.if.mjs +2 -0
- package/esm2022/lib/service/dom-service.mjs +56 -0
- package/esm2022/lib/service/render-wrapper-factory.mjs +22 -0
- package/esm2022/lib/service/renderer-wrapper.mjs +44 -0
- package/esm2022/lib/table.component.mjs +113 -0
- package/esm2022/public-api.mjs +9 -0
- package/fesm2022/guiexpert-angular-table.mjs +237 -0
- package/fesm2022/guiexpert-angular-table.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/component-renderer.if.d.ts +4 -0
- package/lib/service/dom-service.d.ts +17 -0
- package/lib/service/render-wrapper-factory.d.ts +13 -0
- package/lib/service/renderer-wrapper.d.ts +14 -0
- package/lib/table.component.d.ts +43 -0
- package/package.json +22 -37
- package/{projects/angular-table/src/public-api.ts → public-api.d.ts} +0 -4
- package/.editorconfig +0 -16
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/tasks.json +0 -42
- package/angular.json +0 -40
- package/projects/angular-table/README.md +0 -119
- package/projects/angular-table/ng-package.json +0 -7
- package/projects/angular-table/package.json +0 -19
- package/projects/angular-table/src/lib/component-renderer.if.ts +0 -12
- package/projects/angular-table/src/lib/service/dom-service.spec.ts +0 -17
- package/projects/angular-table/src/lib/service/dom-service.ts +0 -63
- package/projects/angular-table/src/lib/service/render-wrapper-factory.ts +0 -24
- package/projects/angular-table/src/lib/service/renderer-wrapper.ts +0 -86
- package/projects/angular-table/src/lib/table.component.css +0 -5
- package/projects/angular-table/src/lib/table.component.spec.ts +0 -28
- package/projects/angular-table/src/lib/table.component.ts +0 -169
- package/projects/angular-table/tsconfig.lib.json +0 -14
- package/projects/angular-table/tsconfig.lib.prod.json +0 -10
- package/projects/angular-table/tsconfig.spec.json +0 -14
- package/tsconfig.json +0 -38
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ApplicationRef, ChangeDetectorRef, EnvironmentInjector, NgZone, Type } from "@angular/core";
|
|
2
|
+
import { ComponentRendererIf } from "../component-renderer.if";
|
|
3
|
+
import { RendererWrapper } from "./renderer-wrapper";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class RenderWrapperFactory {
|
|
6
|
+
private readonly appRef;
|
|
7
|
+
private readonly injector;
|
|
8
|
+
private readonly zone;
|
|
9
|
+
constructor(appRef: ApplicationRef, injector: EnvironmentInjector, zone: NgZone);
|
|
10
|
+
create<T>(componentType: Type<ComponentRendererIf<T>>, cdr: ChangeDetectorRef): RendererWrapper<ComponentRendererIf<T>>;
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RenderWrapperFactory, never>;
|
|
12
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<RenderWrapperFactory>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AreaIdent, AreaModelIf, CellRendererIf, DomServiceIf, RendererCleanupFnType } from "@guiexpert/table";
|
|
2
|
+
import { ApplicationRef, ChangeDetectorRef, EnvironmentInjector, EventEmitter, NgZone, Type } from "@angular/core";
|
|
3
|
+
import { ComponentRendererIf } from "../component-renderer.if";
|
|
4
|
+
export declare class RendererWrapper<T extends ComponentRendererIf<T>> implements CellRendererIf {
|
|
5
|
+
private componentType;
|
|
6
|
+
private appRef;
|
|
7
|
+
private injector;
|
|
8
|
+
private cdr;
|
|
9
|
+
private readonly zone;
|
|
10
|
+
readonly event$: EventEmitter<any>;
|
|
11
|
+
private readonly closed$;
|
|
12
|
+
constructor(componentType: Type<ComponentRendererIf<T>>, appRef: ApplicationRef, injector: EnvironmentInjector, cdr: ChangeDetectorRef, zone: NgZone);
|
|
13
|
+
render(cellDiv: HTMLDivElement, rowIndex: number, columnIndex: number, areaIdent: AreaIdent, areaModel: AreaModelIf, cellValue: any, domService: DomServiceIf): RendererCleanupFnType | undefined;
|
|
14
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ElementRef, NgZone, OnDestroy, OnInit, Renderer2 } from "@angular/core";
|
|
2
|
+
import { Subject } from "rxjs";
|
|
3
|
+
import { EventListenerIf, FocusModelIf, GeModelChangeEvent, GeMouseEvent, SelectionModelIf, TableApi, TableModelIf, TableOptionsIf } from '@guiexpert/table';
|
|
4
|
+
import { DomService } from "./service/dom-service";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class TableComponent implements OnInit, OnDestroy, EventListenerIf {
|
|
7
|
+
private readonly renderer;
|
|
8
|
+
private readonly elementRef;
|
|
9
|
+
private readonly zone;
|
|
10
|
+
private readonly domService;
|
|
11
|
+
tableReady: Subject<TableApi>;
|
|
12
|
+
mouseMoved: Subject<GeMouseEvent>;
|
|
13
|
+
mouseDragging: Subject<GeMouseEvent>;
|
|
14
|
+
mouseDraggingEnded: Subject<GeMouseEvent>;
|
|
15
|
+
contextmenu: Subject<GeMouseEvent>;
|
|
16
|
+
mouseClicked: Subject<GeMouseEvent>;
|
|
17
|
+
modelChanged: Subject<GeModelChangeEvent>;
|
|
18
|
+
selectionChanged: Subject<SelectionModelIf>;
|
|
19
|
+
focusChanged: Subject<FocusModelIf>;
|
|
20
|
+
checkboxChanged: Subject<any[]>;
|
|
21
|
+
tableModel?: TableModelIf;
|
|
22
|
+
tableOptions: TableOptionsIf;
|
|
23
|
+
debounceMouseClickDelay: number;
|
|
24
|
+
private debounceMouseClick;
|
|
25
|
+
private tableScope?;
|
|
26
|
+
private alive;
|
|
27
|
+
constructor(renderer: Renderer2, elementRef: ElementRef, zone: NgZone, domService: DomService);
|
|
28
|
+
onSelectionChanged(model: SelectionModelIf): void;
|
|
29
|
+
onFocusChanged(model: FocusModelIf): void;
|
|
30
|
+
onContextmenu(evt: GeMouseEvent): void;
|
|
31
|
+
onMouseMoved(evt: GeMouseEvent): void;
|
|
32
|
+
onMouseClicked(evt: GeMouseEvent): void;
|
|
33
|
+
onCheckboxChanged(arr: any[]): void;
|
|
34
|
+
onModelChanged(evt: GeModelChangeEvent): void;
|
|
35
|
+
ngOnInit(): void;
|
|
36
|
+
ngOnDestroy(): void;
|
|
37
|
+
onMouseDragging(evt: GeMouseEvent): void;
|
|
38
|
+
onMouseDraggingEnd(evt: GeMouseEvent): void;
|
|
39
|
+
private initModel;
|
|
40
|
+
private init;
|
|
41
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TableComponent, never>;
|
|
42
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TableComponent, "guiexpert-table", never, { "tableModel": { "alias": "tableModel"; "required": false; }; "tableOptions": { "alias": "tableOptions"; "required": false; }; "debounceMouseClickDelay": { "alias": "debounceMouseClickDelay"; "required": false; }; }, { "tableReady": "tableReady"; "mouseMoved": "mouseMoved"; "mouseDragging": "mouseDragging"; "mouseDraggingEnded": "mouseDraggingEnded"; "contextmenu": "contextmenu"; "mouseClicked": "mouseClicked"; "modelChanged": "modelChanged"; "selectionChanged": "selectionChanged"; "focusChanged": "focusChanged"; "checkboxChanged": "checkboxChanged"; }, never, never, true, never>;
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/angular-table",
|
|
3
|
-
"version": "16.1.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
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"
|
|
3
|
+
"version": "16.1.56",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^16.2.12",
|
|
6
|
+
"@angular/core": "^16.2.12"
|
|
13
7
|
},
|
|
14
|
-
"private": false,
|
|
15
8
|
"dependencies": {
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
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.55",
|
|
25
|
-
"rxjs": "~7.8.0",
|
|
26
|
-
"tslib": "^2.3.0",
|
|
27
|
-
"zone.js": "~0.14.2"
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"url": "https://github.com/guiexperttable/angluar-14-table"
|
|
28
13
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"module": "fesm2022/guiexpert-angular-table.mjs",
|
|
16
|
+
"typings": "index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": {
|
|
19
|
+
"default": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./index.d.ts",
|
|
23
|
+
"esm2022": "./esm2022/guiexpert-angular-table.mjs",
|
|
24
|
+
"esm": "./esm2022/guiexpert-angular-table.mjs",
|
|
25
|
+
"default": "./fesm2022/guiexpert-angular-table.mjs"
|
|
26
|
+
}
|
|
42
27
|
}
|
|
43
|
-
}
|
|
28
|
+
}
|
package/.editorconfig
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
|
package/.vscode/extensions.json
DELETED
package/.vscode/launch.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
package/.vscode/tasks.json
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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/angular.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
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.
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@guiexpert/angular-table",
|
|
3
|
-
"version": "16.1.55",
|
|
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
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
});
|