@hpcc-js/dgrid 3.5.9 → 3.7.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/LICENSE +43 -43
- package/README.md +31 -31
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +6 -8
- package/src/Common.css +587 -494
- package/src/Common.ts +178 -166
- package/src/DBStore.ts +91 -90
- package/src/DatasourceStore.ts +127 -126
- package/src/DatasourceTable.ts +62 -62
- package/src/RowFormatter.ts +147 -146
- package/src/Table.ts +263 -246
- package/src/__package__.ts +3 -3
- package/src/__tests__/index.ts +1 -1
- package/src/__tests__/test1.ts +50 -50
- package/src/dgrid-shim.ts +20 -12
- package/src/i18n.js +11 -11
- package/src/index.ts +10 -10
- package/types/Common.d.ts +8 -5
- package/types/RowFormatter.d.ts +1 -0
- package/types/Table.d.ts +7 -0
- package/types/dgrid-shim.d.ts +1 -1
package/src/Table.ts
CHANGED
|
@@ -1,246 +1,263 @@
|
|
|
1
|
-
import { Palette, PropertyExt, Field } from "@hpcc-js/common";
|
|
2
|
-
import { hashSum } from "@hpcc-js/util";
|
|
3
|
-
import { format as d3Format } from "d3-format";
|
|
4
|
-
import { select as d3Select } from "d3-selection";
|
|
5
|
-
import { Common } from "./Common.ts";
|
|
6
|
-
import { CellFormatter, CellRenderer, ColumnType, RowType } from "./RowFormatter.ts";
|
|
7
|
-
|
|
8
|
-
// ColumnPalette ---
|
|
9
|
-
export class ColumnFormat extends PropertyExt {
|
|
10
|
-
_owner: Table;
|
|
11
|
-
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
owner(): Table;
|
|
17
|
-
owner(_: Table): this;
|
|
18
|
-
owner(_?: Table): Table | this {
|
|
19
|
-
if (!arguments.length) return this._owner;
|
|
20
|
-
this._owner = _;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
valid(): boolean {
|
|
25
|
-
return !!this.column();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
formatterFunc(): CellFormatter | undefined {
|
|
29
|
-
const defaultFormatter = this._owner.formatterFunc();
|
|
30
|
-
if (this.valid() && this.format()) {
|
|
31
|
-
const numberFormatter = d3Format(this.format());
|
|
32
|
-
|
|
33
|
-
return function (this: ColumnType, cell: any, row: RowType): string {
|
|
34
|
-
if (typeof cell === "number")
|
|
35
|
-
return numberFormatter(cell);
|
|
36
|
-
return defaultFormatter.call(this, cell, row);
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return defaultFormatter;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
renderCellFunc(): CellRenderer | undefined {
|
|
43
|
-
const defaultRenderCell = this._owner.renderCellFunc();
|
|
44
|
-
const defaultFormatter = this.formatterFunc();
|
|
45
|
-
if (this.valid() && this.paletteID()) {
|
|
46
|
-
const columns = this._owner.columns();
|
|
47
|
-
const palette = Palette.rainbow(this.paletteID());
|
|
48
|
-
const min = this.min();
|
|
49
|
-
const max = this.max();
|
|
50
|
-
const valueColIdx = this.valueColumn() ? columns.indexOf(this.valueColumn()) : undefined;
|
|
51
|
-
return function (this: ColumnType, row: RowType, cell: any, cellElement: HTMLElement): HTMLElement | void {
|
|
52
|
-
if (defaultRenderCell) {
|
|
53
|
-
defaultRenderCell.call(this, row, cell, cellElement);
|
|
54
|
-
}
|
|
55
|
-
const value = valueColIdx ? row.__origRow[valueColIdx] : cell;
|
|
56
|
-
const background = palette(value, min, max);
|
|
57
|
-
const cellText: any = defaultFormatter.call(this, cell, row);
|
|
58
|
-
d3Select(cellElement)
|
|
59
|
-
.style("background", background)
|
|
60
|
-
.style("color", background && Palette.textColor(background))
|
|
61
|
-
.text(cellText?.html ?? cellText ?? cell)
|
|
62
|
-
;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return defaultRenderCell;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
ColumnFormat.prototype._class += " dgrid_Table.ColumnFormat";
|
|
69
|
-
|
|
70
|
-
export interface ColumnFormat {
|
|
71
|
-
column(): string;
|
|
72
|
-
column(_: string): this;
|
|
73
|
-
width(): number;
|
|
74
|
-
width(_: number): this;
|
|
75
|
-
format(): string;
|
|
76
|
-
format(_: string): this;
|
|
77
|
-
paletteID(): string;
|
|
78
|
-
paletteID(_: string): this;
|
|
79
|
-
min(): number;
|
|
80
|
-
min(_: number): this;
|
|
81
|
-
max(): number;
|
|
82
|
-
max(_: number): this;
|
|
83
|
-
valueColumn(): string;
|
|
84
|
-
valueColumn(_: string): this;
|
|
85
|
-
}
|
|
86
|
-
ColumnFormat.prototype.publish("column", null, "set", "Column", function (this: ColumnFormat) { return this._owner.columns(); }, { optional: true });
|
|
87
|
-
ColumnFormat.prototype.publish("width", null, "number", "Width", null, { optional: true });
|
|
88
|
-
ColumnFormat.prototype.publish("format", null, "string", "Format (d3-format)", null, { optional: true });
|
|
89
|
-
ColumnFormat.prototype.publish("paletteID", null, "set", "Color palette for this widget", ["", ...Palette.rainbow("default").switch()], { optional: true });
|
|
90
|
-
ColumnFormat.prototype.publish("min", 0, "number", "Min Value", null, { disable: (cf: ColumnFormat) => !cf.paletteID() });
|
|
91
|
-
ColumnFormat.prototype.publish("max", 100, "number", "Max Value", null, { disable: (cf: ColumnFormat) => !cf.paletteID() });
|
|
92
|
-
ColumnFormat.prototype.publish("valueColumn", null, "set", "Column", function (this: ColumnFormat) { return this._owner.columns(); }, { optional: true, disable: (cf: ColumnFormat) => !cf.paletteID() });
|
|
93
|
-
|
|
94
|
-
// Table ---
|
|
95
|
-
export class Table extends Common {
|
|
96
|
-
private _prevColsHash;
|
|
97
|
-
private _prevFieldsHash;
|
|
98
|
-
_colsRefresh = false;
|
|
99
|
-
_dataRefresh = false;
|
|
100
|
-
|
|
101
|
-
constructor() {
|
|
102
|
-
super();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
fields(): Field[];
|
|
106
|
-
fields(_: Field[]): this;
|
|
107
|
-
fields(_?: Field[]): Field[] | this {
|
|
108
|
-
const retVal = super.fields.apply(this, arguments as any);
|
|
109
|
-
if (arguments.length) {
|
|
110
|
-
const hash = hashSum({ _ });
|
|
111
|
-
if (this._prevFieldsHash !== hash) {
|
|
112
|
-
this._prevFieldsHash = hash;
|
|
113
|
-
this._colsRefresh = true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return retVal;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
columns(): string[];
|
|
120
|
-
columns(_: string[], asDefault?: boolean): this;
|
|
121
|
-
columns(_?: string[], asDefault?: boolean): string[] | this {
|
|
122
|
-
const retVal = super.columns.apply(this, arguments as any);
|
|
123
|
-
if (arguments.length) {
|
|
124
|
-
const hash = hashSum({ _ });
|
|
125
|
-
if (this._prevColsHash !== hash) {
|
|
126
|
-
this._prevColsHash = hash;
|
|
127
|
-
this._colsRefresh = true;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return retVal;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
data(): any;
|
|
134
|
-
data(_: any): this;
|
|
135
|
-
data(_?: any): any | this {
|
|
136
|
-
const retVal = super.data.apply(this, arguments as any);
|
|
137
|
-
if (arguments.length) {
|
|
138
|
-
this._dataRefresh = true;
|
|
139
|
-
}
|
|
140
|
-
return retVal;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
enter(domNode, element) {
|
|
144
|
-
super.enter(domNode, element);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
guessWidth(columns, data) {
|
|
148
|
-
const sortablePadding = this.sortable() ? 12 : 0;
|
|
149
|
-
for (const column of columns) {
|
|
150
|
-
if (column.children) {
|
|
151
|
-
let sampleData = [];
|
|
152
|
-
for (let i = 0; i < Math.min(3, data.length); ++i) {
|
|
153
|
-
sampleData = sampleData.concat(data[i][column.idx]);
|
|
154
|
-
}
|
|
155
|
-
this.guessWidth(column.children, sampleData);
|
|
156
|
-
} else {
|
|
157
|
-
column.width = data.reduce((prevVal: number, row) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this._columns[colIdx].
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
1
|
+
import { Palette, PropertyExt, Field, Utility } from "@hpcc-js/common";
|
|
2
|
+
import { hashSum } from "@hpcc-js/util";
|
|
3
|
+
import { format as d3Format } from "d3-format";
|
|
4
|
+
import { select as d3Select } from "d3-selection";
|
|
5
|
+
import { Common } from "./Common.ts";
|
|
6
|
+
import { CellFormatter, CellRenderer, ColumnType, RowType } from "./RowFormatter.ts";
|
|
7
|
+
|
|
8
|
+
// ColumnPalette ---
|
|
9
|
+
export class ColumnFormat extends PropertyExt {
|
|
10
|
+
_owner: Table;
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
owner(): Table;
|
|
17
|
+
owner(_: Table): this;
|
|
18
|
+
owner(_?: Table): Table | this {
|
|
19
|
+
if (!arguments.length) return this._owner;
|
|
20
|
+
this._owner = _;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
valid(): boolean {
|
|
25
|
+
return !!this.column();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
formatterFunc(): CellFormatter | undefined {
|
|
29
|
+
const defaultFormatter = this._owner.formatterFunc();
|
|
30
|
+
if (this.valid() && this.format()) {
|
|
31
|
+
const numberFormatter = d3Format(this.format());
|
|
32
|
+
|
|
33
|
+
return function (this: ColumnType, cell: any, row: RowType): string {
|
|
34
|
+
if (typeof cell === "number")
|
|
35
|
+
return numberFormatter(cell);
|
|
36
|
+
return defaultFormatter.call(this, cell, row);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return defaultFormatter;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
renderCellFunc(): CellRenderer | undefined {
|
|
43
|
+
const defaultRenderCell = this._owner.renderCellFunc();
|
|
44
|
+
const defaultFormatter = this.formatterFunc();
|
|
45
|
+
if (this.valid() && this.paletteID()) {
|
|
46
|
+
const columns = this._owner.columns();
|
|
47
|
+
const palette = Palette.rainbow(this.paletteID());
|
|
48
|
+
const min = this.min();
|
|
49
|
+
const max = this.max();
|
|
50
|
+
const valueColIdx = this.valueColumn() ? columns.indexOf(this.valueColumn()) : undefined;
|
|
51
|
+
return function (this: ColumnType, row: RowType, cell: any, cellElement: HTMLElement): HTMLElement | void {
|
|
52
|
+
if (defaultRenderCell) {
|
|
53
|
+
defaultRenderCell.call(this, row, cell, cellElement);
|
|
54
|
+
}
|
|
55
|
+
const value = valueColIdx ? row.__origRow[valueColIdx] : cell;
|
|
56
|
+
const background = palette(value, min, max);
|
|
57
|
+
const cellText: any = defaultFormatter.call(this, cell, row);
|
|
58
|
+
d3Select(cellElement)
|
|
59
|
+
.style("background", background)
|
|
60
|
+
.style("color", background && Palette.textColor(background))
|
|
61
|
+
.text(cellText?.html ?? cellText ?? cell)
|
|
62
|
+
;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return defaultRenderCell;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
ColumnFormat.prototype._class += " dgrid_Table.ColumnFormat";
|
|
69
|
+
|
|
70
|
+
export interface ColumnFormat {
|
|
71
|
+
column(): string;
|
|
72
|
+
column(_: string): this;
|
|
73
|
+
width(): number;
|
|
74
|
+
width(_: number): this;
|
|
75
|
+
format(): string;
|
|
76
|
+
format(_: string): this;
|
|
77
|
+
paletteID(): string;
|
|
78
|
+
paletteID(_: string): this;
|
|
79
|
+
min(): number;
|
|
80
|
+
min(_: number): this;
|
|
81
|
+
max(): number;
|
|
82
|
+
max(_: number): this;
|
|
83
|
+
valueColumn(): string;
|
|
84
|
+
valueColumn(_: string): this;
|
|
85
|
+
}
|
|
86
|
+
ColumnFormat.prototype.publish("column", null, "set", "Column", function (this: ColumnFormat) { return this._owner.columns(); }, { optional: true });
|
|
87
|
+
ColumnFormat.prototype.publish("width", null, "number", "Width", null, { optional: true });
|
|
88
|
+
ColumnFormat.prototype.publish("format", null, "string", "Format (d3-format)", null, { optional: true });
|
|
89
|
+
ColumnFormat.prototype.publish("paletteID", null, "set", "Color palette for this widget", ["", ...Palette.rainbow("default").switch()], { optional: true });
|
|
90
|
+
ColumnFormat.prototype.publish("min", 0, "number", "Min Value", null, { disable: (cf: ColumnFormat) => !cf.paletteID() });
|
|
91
|
+
ColumnFormat.prototype.publish("max", 100, "number", "Max Value", null, { disable: (cf: ColumnFormat) => !cf.paletteID() });
|
|
92
|
+
ColumnFormat.prototype.publish("valueColumn", null, "set", "Column", function (this: ColumnFormat) { return this._owner.columns(); }, { optional: true, disable: (cf: ColumnFormat) => !cf.paletteID() });
|
|
93
|
+
|
|
94
|
+
// Table ---
|
|
95
|
+
export class Table extends Common {
|
|
96
|
+
private _prevColsHash;
|
|
97
|
+
private _prevFieldsHash;
|
|
98
|
+
_colsRefresh = false;
|
|
99
|
+
_dataRefresh = false;
|
|
100
|
+
|
|
101
|
+
constructor() {
|
|
102
|
+
super();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fields(): Field[];
|
|
106
|
+
fields(_: Field[]): this;
|
|
107
|
+
fields(_?: Field[]): Field[] | this {
|
|
108
|
+
const retVal = super.fields.apply(this, arguments as any);
|
|
109
|
+
if (arguments.length) {
|
|
110
|
+
const hash = hashSum({ _ });
|
|
111
|
+
if (this._prevFieldsHash !== hash) {
|
|
112
|
+
this._prevFieldsHash = hash;
|
|
113
|
+
this._colsRefresh = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return retVal;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
columns(): string[];
|
|
120
|
+
columns(_: string[], asDefault?: boolean): this;
|
|
121
|
+
columns(_?: string[], asDefault?: boolean): string[] | this {
|
|
122
|
+
const retVal = super.columns.apply(this, arguments as any);
|
|
123
|
+
if (arguments.length) {
|
|
124
|
+
const hash = hashSum({ _ });
|
|
125
|
+
if (this._prevColsHash !== hash) {
|
|
126
|
+
this._prevColsHash = hash;
|
|
127
|
+
this._colsRefresh = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return retVal;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
data(): any;
|
|
134
|
+
data(_: any): this;
|
|
135
|
+
data(_?: any): any | this {
|
|
136
|
+
const retVal = super.data.apply(this, arguments as any);
|
|
137
|
+
if (arguments.length) {
|
|
138
|
+
this._dataRefresh = true;
|
|
139
|
+
}
|
|
140
|
+
return retVal;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
enter(domNode, element) {
|
|
144
|
+
super.enter(domNode, element);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
guessWidth(columns, data) {
|
|
148
|
+
const sortablePadding = this.sortable() ? 12 : 0;
|
|
149
|
+
for (const column of columns) {
|
|
150
|
+
if (column.children) {
|
|
151
|
+
let sampleData = [];
|
|
152
|
+
for (let i = 0; i < Math.min(3, data.length); ++i) {
|
|
153
|
+
sampleData = sampleData.concat(data[i][column.idx]);
|
|
154
|
+
}
|
|
155
|
+
this.guessWidth(column.children, sampleData);
|
|
156
|
+
} else {
|
|
157
|
+
column.width = data.reduce((prevVal: number, row) => {
|
|
158
|
+
let cell = ("" + row[column.idx]).trim();
|
|
159
|
+
if (this.renderHtml() && cell[0] === "<") {
|
|
160
|
+
cell = Utility.removeHTMLFromString(cell);
|
|
161
|
+
}
|
|
162
|
+
return Math.max(prevVal, this.textSize(cell, this.columnWidthAutoFontName(), this.columnWidthAutoFontSize()).width);
|
|
163
|
+
}, this.textSize("" + column.label, this.columnWidthAutoFontName(), this.columnWidthAutoFontSize(), true).width + sortablePadding) + 8; // +12 for the sort icon, +8 for the cell padding.
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_prevHash;
|
|
169
|
+
update(domNode, element) {
|
|
170
|
+
super.update(domNode, element);
|
|
171
|
+
const hash = this.hashSum();
|
|
172
|
+
if (this._prevHash !== hash) {
|
|
173
|
+
this._prevHash = hash;
|
|
174
|
+
this._colsRefresh = true;
|
|
175
|
+
}
|
|
176
|
+
if (this._colsRefresh) {
|
|
177
|
+
this._columns = this._store.columns(this.sortable(), this.formatterFunc(), this.renderCellFunc());
|
|
178
|
+
switch (this.columnWidth()) {
|
|
179
|
+
case "auto":
|
|
180
|
+
const sampleRows = this.data().filter((row, idx) => idx < this.columnWidthAutoSampleSize());
|
|
181
|
+
this.guessWidth(this._columns, sampleRows);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
const columns = this.columns();
|
|
185
|
+
for (const columnFormat of this.columnFormats()) {
|
|
186
|
+
if (columnFormat.valid()) {
|
|
187
|
+
const colIdx = columns.indexOf(columnFormat.column());
|
|
188
|
+
if (this._columns[colIdx]) {
|
|
189
|
+
this._columns[colIdx].hidden = columnFormat.width() === 0;
|
|
190
|
+
this._columns[colIdx].width = columnFormat.width() || this._columns[colIdx].width;
|
|
191
|
+
this._columns[colIdx].formatter = columnFormat.formatterFunc();
|
|
192
|
+
this._columns[colIdx].renderCell = columnFormat.renderCellFunc();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
this._dgrid.set("columns", this._columns.filter(col => !col.hidden));
|
|
197
|
+
this._colsRefresh = false;
|
|
198
|
+
}
|
|
199
|
+
if (this._colsRefresh || this._dataRefresh) {
|
|
200
|
+
if (this._colsRefresh) {
|
|
201
|
+
this._dgrid.refresh({});
|
|
202
|
+
} else {
|
|
203
|
+
this._dgrid.refresh();
|
|
204
|
+
}
|
|
205
|
+
this._colsRefresh = false;
|
|
206
|
+
this._dataRefresh = false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
exit(domNode, element) {
|
|
211
|
+
delete this._prevColsHash;
|
|
212
|
+
delete this._prevFieldsHash;
|
|
213
|
+
super.exit(domNode, element);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Cell ---
|
|
217
|
+
formatterFunc(): CellFormatter | undefined {
|
|
218
|
+
return function (this: ColumnType, cell: any, row: RowType): string | any {
|
|
219
|
+
switch (typeof cell) {
|
|
220
|
+
case "string":
|
|
221
|
+
return {
|
|
222
|
+
html: cell.replace(/\t/g, " ").trim()
|
|
223
|
+
};
|
|
224
|
+
case "undefined":
|
|
225
|
+
return "";
|
|
226
|
+
}
|
|
227
|
+
return cell;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
renderCellFunc(): CellRenderer | undefined {
|
|
232
|
+
return undefined; // Undefined will defualt to formatter ---
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Events ---
|
|
236
|
+
click(row, col, sel) {
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
dblclickColResize(column: string, dgridColumn: any): void {
|
|
240
|
+
this.guessWidth([dgridColumn], this.data());
|
|
241
|
+
this._dgrid.resizeColumn(dgridColumn.id, dgridColumn.width);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
Table.prototype._class += " dgrid_Table";
|
|
245
|
+
|
|
246
|
+
export interface Table {
|
|
247
|
+
columnWidth(): "auto" | "none";
|
|
248
|
+
columnWidth(_: "auto" | "none"): this;
|
|
249
|
+
columnWidthAutoSampleSize(): number;
|
|
250
|
+
columnWidthAutoSampleSize(_: number): this;
|
|
251
|
+
columnWidthAutoFontName(): string;
|
|
252
|
+
columnWidthAutoFontName(_: string): this;
|
|
253
|
+
columnWidthAutoFontSize(): number;
|
|
254
|
+
columnWidthAutoFontSize(_: number): this;
|
|
255
|
+
columnFormats(): ColumnFormat[];
|
|
256
|
+
columnFormats(_: ColumnFormat[]): this;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
Table.prototype.publish("columnWidth", "auto", "set", "Default column width", ["auto", "none"]);
|
|
260
|
+
Table.prototype.publish("columnWidthAutoSampleSize", 10, "number", "Number of rows to sample for auto column width");
|
|
261
|
+
Table.prototype.publish("columnWidthAutoFontName", "Verdana", "string", "Font name for auto column width calculation");
|
|
262
|
+
Table.prototype.publish("columnWidthAutoFontSize", 12, "number", "Font size for auto column width calculation");
|
|
263
|
+
Table.prototype.publish("columnFormats", [], "propertyArray", "Source Columns", null, { autoExpand: ColumnFormat });
|
package/src/__package__.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const PKG_NAME = "__PACKAGE_NAME__";
|
|
2
|
-
export const PKG_VERSION = "__PACKAGE_VERSION__";
|
|
3
|
-
export const BUILD_VERSION = "__BUILD_VERSION__";
|
|
1
|
+
export const PKG_NAME = "__PACKAGE_NAME__";
|
|
2
|
+
export const PKG_VERSION = "__PACKAGE_VERSION__";
|
|
3
|
+
export const BUILD_VERSION = "__BUILD_VERSION__";
|
package/src/__tests__/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Test } from "./test1";
|
|
1
|
+
export { Test } from "./test1";
|
package/src/__tests__/test1.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { Table } from "../Table";
|
|
2
|
-
|
|
3
|
-
export class Test extends Table {
|
|
4
|
-
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this
|
|
8
|
-
.columns(["Category", "Series-1", "Series-2", "Series-3", "Series-4"])
|
|
9
|
-
.data([
|
|
10
|
-
["A", -25, -23, -25, -22],
|
|
11
|
-
["B", -20, -21, -25, -21],
|
|
12
|
-
["C", -18, -20, -25, -19],
|
|
13
|
-
["D", -17, -17, -25, -18],
|
|
14
|
-
["E", -16, -15, -19, -18],
|
|
15
|
-
["F", -15, -14, -16, -16],
|
|
16
|
-
["G", -12, -10, -14, -15],
|
|
17
|
-
["H", -12, -8, -13, -15],
|
|
18
|
-
["I", -11, -6, -12, -12],
|
|
19
|
-
["J", -11, -6, -8, -12],
|
|
20
|
-
["K", -9, 0, -5, -10],
|
|
21
|
-
["L", -5, 1, -5, -9],
|
|
22
|
-
["M", -5, 2, -4, -8],
|
|
23
|
-
["N", -1, 4, -2, -7],
|
|
24
|
-
["O", 3, 7, 0, -5],
|
|
25
|
-
["P", 3, 8, 0, -3],
|
|
26
|
-
["Q", 4, 8, 7, 0],
|
|
27
|
-
["R", 6, 9, 11, 1],
|
|
28
|
-
["S", 9, 11, 11, 5],
|
|
29
|
-
["T", 10, 20, 12, 6],
|
|
30
|
-
["U", 12, 20, 16, 8],
|
|
31
|
-
["V", 12, 21, 18, 14],
|
|
32
|
-
["W", 14, 21, 18, 18],
|
|
33
|
-
["X", 15, 23, 21, 18],
|
|
34
|
-
["Y", 21, 23, 23, 21],
|
|
35
|
-
["Z", 23, 24, 24, 24]
|
|
36
|
-
])
|
|
37
|
-
.on("click", (row, column, selected) => {
|
|
38
|
-
console.info("click", row, column, selected);
|
|
39
|
-
})
|
|
40
|
-
;
|
|
41
|
-
// setTimeout(() => {
|
|
42
|
-
// this.data([
|
|
43
|
-
// // ["J", -11, -6, -8, -12],
|
|
44
|
-
// // ["K", -9, 0, -5, -10],
|
|
45
|
-
// // ["L", -5, 1, -5, -9],
|
|
46
|
-
// ]).lazyRender();
|
|
47
|
-
// }, 3000);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
1
|
+
import { Table } from "../Table";
|
|
2
|
+
|
|
3
|
+
export class Test extends Table {
|
|
4
|
+
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this
|
|
8
|
+
.columns(["Category", "Series-1", "Series-2", "Series-3", "Series-4"])
|
|
9
|
+
.data([
|
|
10
|
+
["A", -25, -23, -25, -22],
|
|
11
|
+
["B", -20, -21, -25, -21],
|
|
12
|
+
["C", -18, -20, -25, -19],
|
|
13
|
+
["D", -17, -17, -25, -18],
|
|
14
|
+
["E", -16, -15, -19, -18],
|
|
15
|
+
["F", -15, -14, -16, -16],
|
|
16
|
+
["G", -12, -10, -14, -15],
|
|
17
|
+
["H", -12, -8, -13, -15],
|
|
18
|
+
["I", -11, -6, -12, -12],
|
|
19
|
+
["J", -11, -6, -8, -12],
|
|
20
|
+
["K", -9, 0, -5, -10],
|
|
21
|
+
["L", -5, 1, -5, -9],
|
|
22
|
+
["M", -5, 2, -4, -8],
|
|
23
|
+
["N", -1, 4, -2, -7],
|
|
24
|
+
["O", 3, 7, 0, -5],
|
|
25
|
+
["P", 3, 8, 0, -3],
|
|
26
|
+
["Q", 4, 8, 7, 0],
|
|
27
|
+
["R", 6, 9, 11, 1],
|
|
28
|
+
["S", 9, 11, 11, 5],
|
|
29
|
+
["T", 10, 20, 12, 6],
|
|
30
|
+
["U", 12, 20, 16, 8],
|
|
31
|
+
["V", 12, 21, 18, 14],
|
|
32
|
+
["W", 14, 21, 18, 18],
|
|
33
|
+
["X", 15, 23, 21, 18],
|
|
34
|
+
["Y", 21, 23, 23, 21],
|
|
35
|
+
["Z", 23, 24, 24, 24]
|
|
36
|
+
])
|
|
37
|
+
.on("click", (row, column, selected) => {
|
|
38
|
+
console.info("click", row, column, selected);
|
|
39
|
+
})
|
|
40
|
+
;
|
|
41
|
+
// setTimeout(() => {
|
|
42
|
+
// this.data([
|
|
43
|
+
// // ["J", -11, -6, -8, -12],
|
|
44
|
+
// // ["K", -9, 0, -5, -10],
|
|
45
|
+
// // ["L", -5, 1, -5, -9],
|
|
46
|
+
// ]).lazyRender();
|
|
47
|
+
// }, 3000);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|