@guiexpert/table 1.0.1 → 1.0.2
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/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/lib/table/action/shortcut.service.ts +3 -3
- package/src/lib/table/mouse-handler.ts +0 -1
- package/src/lib/table/renderer/checkbox-boolean-property-cell-renderer.ts +16 -11
- package/src/lib/table/renderer/date-to-int-date-cell-renderer.ts +10 -5
- package/src/lib/table/renderer/progress-bar-cell-renderer.ts +60 -0
- package/src/lib/table/renderer/star-rating-cell-renderer.ts +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/table",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"typedoc:json": "npx typedoc --json ../../apps/table-website/src/assets/json/doctype.json src/index.ts",
|
|
6
6
|
"typedoc:docs": "npx typedoc --out ../../apps/table-website/src/assets/docs src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -134,6 +134,9 @@ export * from "./lib/table/renderer/true-false-cell-renderer";
|
|
|
134
134
|
export * from "./lib/table/renderer/date-to-tec-cell-renderer";
|
|
135
135
|
export * from "./lib/table/renderer/renderer-cleanup-fn.type";
|
|
136
136
|
export * from "./lib/table/renderer/number-cell-renderer";
|
|
137
|
+
export * from "./lib/table/renderer/star-rating-cell-renderer";
|
|
138
|
+
export * from "./lib/table/renderer/progress-bar-cell-renderer";
|
|
139
|
+
|
|
137
140
|
export * from "./lib/table/renderer/edit/edit-cell-renderer.type";
|
|
138
141
|
export * from "./lib/table/renderer/edit/edit-input-pipe.if";
|
|
139
142
|
export * from "./lib/table/renderer/edit/edit-input-pipe-for-number";
|
|
@@ -33,7 +33,7 @@ export class ShortcutService {
|
|
|
33
33
|
}
|
|
34
34
|
Object.assign(this.shortcutActionIdMapping, this.tableScope.tableOptions.shortcutActionIdMapping);
|
|
35
35
|
if (this.isDebug()) {
|
|
36
|
-
console.
|
|
36
|
+
console.debug("ShortcutService", this.shortcutActionIdMapping);
|
|
37
37
|
}
|
|
38
38
|
// add key down listener:
|
|
39
39
|
this.tableScope.hostElement.addEventListener("keydown", this.onKeyDown.bind(this));
|
|
@@ -66,7 +66,7 @@ export class ShortcutService {
|
|
|
66
66
|
|
|
67
67
|
private emit(actionId: ActionId): boolean {
|
|
68
68
|
if (this.isDebug()) {
|
|
69
|
-
console.
|
|
69
|
+
console.debug("ShortcutService emit:", actionId);
|
|
70
70
|
}
|
|
71
71
|
let ret = false;
|
|
72
72
|
for (const l of this.listener) {
|
|
@@ -81,7 +81,7 @@ export class ShortcutService {
|
|
|
81
81
|
private findEnty(evt: KeyboardEvent): ActionId | undefined {
|
|
82
82
|
const tokens = this.getTokenByEvent(evt);
|
|
83
83
|
if (this.isDebug()) {
|
|
84
|
-
console.
|
|
84
|
+
console.debug("ShortcutService tokens:", tokens);
|
|
85
85
|
}
|
|
86
86
|
for (const key in this.shortcutActionIdMapping) {
|
|
87
87
|
const shortcutTokens = key
|
|
@@ -44,7 +44,6 @@ export class MouseHandler {
|
|
|
44
44
|
|
|
45
45
|
private onHostElementClicked(event: MouseEvent) {
|
|
46
46
|
const mouseTargetData: MouseTargetData = new MouseTargetData(event.target, this.tableScope);
|
|
47
|
-
console.info(mouseTargetData)
|
|
48
47
|
if (mouseTargetData.action === 'toggleExpandCollapseAll'){
|
|
49
48
|
this.expandedAll = !this.expandedAll;
|
|
50
49
|
this.tableScope.toggleExpandCollapseAll(this.expandedAll);
|
|
@@ -11,7 +11,8 @@ export class CheckboxBooleanPropertyCellRenderer<T> implements CellRendererIf {
|
|
|
11
11
|
|
|
12
12
|
constructor(
|
|
13
13
|
public property: string,
|
|
14
|
-
public skipCheckableCheck: boolean = true
|
|
14
|
+
public skipCheckableCheck: boolean = true,
|
|
15
|
+
public readonly: boolean = false
|
|
15
16
|
) {
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -24,11 +25,12 @@ export class CheckboxBooleanPropertyCellRenderer<T> implements CellRendererIf {
|
|
|
24
25
|
_cellValue: any,
|
|
25
26
|
domService: DomServiceIf): RendererCleanupFnType | undefined {
|
|
26
27
|
|
|
27
|
-
if (this.skipCheckableCheck || areaModel.isRowCheckable(rowIndex)) {
|
|
28
|
+
if (this.readonly || this.skipCheckableCheck || areaModel.isRowCheckable(rowIndex)) {
|
|
28
29
|
domService.addClass(cellDiv, "ge-table-row-checkbox-div");
|
|
29
30
|
const row = areaModel.getRowByIndex(rowIndex);
|
|
30
|
-
const
|
|
31
|
-
const checked =
|
|
31
|
+
const boxChecked = areaModel.getValueByT(row, this.property) === true;
|
|
32
|
+
const checked = boxChecked ? "checked" : "";
|
|
33
|
+
const readonly = this.readonly ? " readonly " : "";
|
|
32
34
|
|
|
33
35
|
domService.addClass(cellDiv, "ge-padding-property-checkbox");
|
|
34
36
|
cellDiv.innerHTML = `
|
|
@@ -40,16 +42,19 @@ export class CheckboxBooleanPropertyCellRenderer<T> implements CellRendererIf {
|
|
|
40
42
|
data-property-index="${this.property}"
|
|
41
43
|
data-input-type="checkbox"
|
|
42
44
|
${checked}
|
|
45
|
+
${readonly}
|
|
43
46
|
class="ge-input-checkbox">`;
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
inputEle.addEventListener("click", (_ele: HTMLInputElement, _evt: MouseEvent) => {
|
|
48
|
+
if (!this.readonly) {
|
|
49
|
+
const inputEle = cellDiv.querySelector<HTMLInputElement>(".ge-input-checkbox");
|
|
50
|
+
if (inputEle) {
|
|
49
51
|
// @ts-ignore
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
inputEle.addEventListener("click", (_ele: HTMLInputElement, _evt: MouseEvent) => {
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
row[this.property] = !row[this.property];
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
return undefined;
|
|
@@ -15,18 +15,23 @@ export class DateToIntlDDMMYYYYCellRenderer implements CellRendererIf {
|
|
|
15
15
|
|
|
16
16
|
render(
|
|
17
17
|
cellDiv: HTMLDivElement,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
rowIndex: number,
|
|
19
|
+
columnIndex: number,
|
|
20
|
+
areaIdent: AreaIdent,
|
|
21
21
|
_areaModel: AreaModelIf,
|
|
22
22
|
cellValue: any,
|
|
23
23
|
_domService: DomServiceIf): RendererCleanupFnType | undefined {
|
|
24
24
|
if (cellValue) {
|
|
25
|
+
let dateStr = '';
|
|
25
26
|
try {
|
|
26
|
-
|
|
27
|
+
dateStr = this.formatter.format(new Date(cellValue));
|
|
27
28
|
} catch (e) {
|
|
28
|
-
|
|
29
|
+
dateStr = cellValue;
|
|
29
30
|
}
|
|
31
|
+
cellDiv.innerHTML = `
|
|
32
|
+
<div class="ge-table-label-div" data-row-index="${rowIndex}" data-col-index="${columnIndex}" data-area="${areaIdent}" style="position: relative; background: transparent; width: 100%; height: 100%;">
|
|
33
|
+
<div class="ge-table-label" data-row-index="${rowIndex}" data-col-index="${columnIndex}" data-area="${areaIdent}">${dateStr}</div>
|
|
34
|
+
</div>`;
|
|
30
35
|
}
|
|
31
36
|
return undefined;
|
|
32
37
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {CellRendererIf} from "./cell-render.if";
|
|
2
|
+
import {DomServiceIf} from "../service/dom-service.if";
|
|
3
|
+
import {AreaIdent} from "../data/tablemodel/area-ident.type";
|
|
4
|
+
import {RendererCleanupFnType} from "./renderer-cleanup-fn.type";
|
|
5
|
+
import {AreaModelObjectyArray} from "../data/tablemodel/areamodel/area-model-object-array";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Works with AreaModelObjectArray only
|
|
9
|
+
*/
|
|
10
|
+
export class ProgressBarCellRenderer<T> implements CellRendererIf {
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
public property: string,
|
|
14
|
+
public maxValue: number=100,
|
|
15
|
+
public labelVisible = false
|
|
16
|
+
) {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
render(
|
|
20
|
+
cellDiv: HTMLDivElement,
|
|
21
|
+
rowIndex: number,
|
|
22
|
+
columnIndex: number,
|
|
23
|
+
areaIdent: AreaIdent,
|
|
24
|
+
areaModel: AreaModelObjectyArray<T>,
|
|
25
|
+
_cellValue: any,
|
|
26
|
+
domService: DomServiceIf): RendererCleanupFnType | undefined {
|
|
27
|
+
|
|
28
|
+
domService.addClass(cellDiv, "ge-star-rating-div");
|
|
29
|
+
const row = areaModel.getRowByIndex(rowIndex);
|
|
30
|
+
const count: number = Number('' + areaModel.getValueByT(row, this.property));
|
|
31
|
+
|
|
32
|
+
if (!isNaN(count)) {
|
|
33
|
+
const per = count * 100 / this.maxValue;
|
|
34
|
+
const label = this.labelVisible? (Math.round(per) + '%'):'';
|
|
35
|
+
cellDiv.innerHTML = `
|
|
36
|
+
<div class="ge-table-label-div"
|
|
37
|
+
data-row-index="${rowIndex}"
|
|
38
|
+
data-col-index="${columnIndex}"
|
|
39
|
+
data-area="${areaIdent}"
|
|
40
|
+
title="${label}"
|
|
41
|
+
style="position: relative; background: transparent; width: 100%; height: 100%;">
|
|
42
|
+
<div class="ge-table-progress-container"
|
|
43
|
+
style="width:100%;height:50%;padding:0;margin-top:6px;"
|
|
44
|
+
data-row-index="${rowIndex}"
|
|
45
|
+
data-col-index="${columnIndex}"
|
|
46
|
+
data-area="${areaIdent}">
|
|
47
|
+
<div class="ge-table-progress-bar"
|
|
48
|
+
style="width:${per}%;height:100%;padding:0;margin:0;"
|
|
49
|
+
data-row-index="${rowIndex}"
|
|
50
|
+
data-col-index="${columnIndex}"
|
|
51
|
+
data-area="${areaIdent}">
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {CellRendererIf} from "./cell-render.if";
|
|
2
|
+
import {DomServiceIf} from "../service/dom-service.if";
|
|
3
|
+
import {AreaIdent} from "../data/tablemodel/area-ident.type";
|
|
4
|
+
import {RendererCleanupFnType} from "./renderer-cleanup-fn.type";
|
|
5
|
+
import {AreaModelObjectyArray} from "../data/tablemodel/areamodel/area-model-object-array";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Works with AreaModelObjectArray only
|
|
9
|
+
*/
|
|
10
|
+
export class StarRatingCellRenderer<T> implements CellRendererIf {
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
public property: string
|
|
14
|
+
) {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
render(
|
|
18
|
+
cellDiv: HTMLDivElement,
|
|
19
|
+
rowIndex: number,
|
|
20
|
+
columnIndex: number,
|
|
21
|
+
areaIdent: AreaIdent,
|
|
22
|
+
areaModel: AreaModelObjectyArray<T>,
|
|
23
|
+
_cellValue: any,
|
|
24
|
+
domService: DomServiceIf): RendererCleanupFnType | undefined {
|
|
25
|
+
|
|
26
|
+
domService.addClass(cellDiv, "ge-star-rating-div");
|
|
27
|
+
const row = areaModel.getRowByIndex(rowIndex);
|
|
28
|
+
const count: number = Number('' + areaModel.getValueByT(row, this.property));
|
|
29
|
+
|
|
30
|
+
if (!isNaN(count)) {
|
|
31
|
+
const sb: string[] = [];
|
|
32
|
+
for (let i = 0; i < count; i++) {
|
|
33
|
+
sb.push('★');
|
|
34
|
+
}
|
|
35
|
+
const text = sb.join(' ');
|
|
36
|
+
cellDiv.innerHTML = `
|
|
37
|
+
<div class="ge-table-label-div" data-row-index="${rowIndex}" data-col-index="${columnIndex}" data-area="${areaIdent}" style="position: relative; background: transparent; width: 100%; height: 100%;">
|
|
38
|
+
<div class="ge-table-label" data-row-index="${rowIndex}" data-col-index="${columnIndex}" data-area="${areaIdent}">${text}</div>
|
|
39
|
+
</div>`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|