@refinitiv-ui/efx-grid 6.0.58 → 6.0.60
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/core/dist/core.js +4 -4
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.js +1 -1
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +3 -3
- package/lib/grid/index.js +1 -1
- package/lib/grid/lib/efx-grid.d.ts +0 -1
- package/lib/grid/lib/efx-grid.js +8 -5
- package/lib/grid/themes/base.less +1 -1
- package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
- package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/grid/themes/halo/light/efx-grid.js +1 -1
- package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/grid/themes/solar/charcoal/efx-grid.js +1 -1
- package/lib/grid/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/grid/themes/solar/pearl/efx-grid.js +1 -1
- package/lib/grid/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +8 -8
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +3 -3
- package/lib/rt-grid/es6/Grid.js +8 -8
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +3 -1
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +64 -8
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +65 -14
- package/lib/tr-grid-rowcoloring/es6/RowColoring.d.ts +2 -0
- package/lib/tr-grid-rowcoloring/es6/RowColoring.js +162 -118
- package/lib/tr-grid-util/es6/CellPainter.d.ts +4 -0
- package/lib/tr-grid-util/es6/CellPainter.js +43 -15
- package/lib/tr-grid-util/es6/ElementObserver.js +4 -2
- package/lib/tr-grid-util/es6/ElementWrapper.js +3 -2
- package/lib/tr-grid-util/es6/GridPlugin.js +5 -0
- package/lib/tr-grid-util/es6/SubTable.d.ts +4 -2
- package/lib/tr-grid-util/es6/SubTable.js +157 -79
- package/lib/tr-grid-util/es6/Table.d.ts +27 -10
- package/lib/tr-grid-util/es6/Table.js +104 -78
- package/lib/tr-grid-util/es6/formula/AdFinSubscription.js +1 -1
- package/lib/types/es6/ColumnStack.d.ts +3 -1
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +3 -3
- package/lib/types/es6/RowColoring.d.ts +2 -0
- package/lib/types/es6/TextFormatting.d.ts +1 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +2 -1
- package/lib/versions.json +4 -4
- package/package.json +3 -3
@@ -62,6 +62,10 @@ CellPainter.prototype._conditions = null;
|
|
62
62
|
/** @type {Object}
|
63
63
|
* @private
|
64
64
|
*/
|
65
|
+
CellPainter.prototype._effectiveStyles = null;
|
66
|
+
/** @type {Object}
|
67
|
+
* @private
|
68
|
+
*/
|
65
69
|
CellPainter.prototype._blinkCondition = null;
|
66
70
|
/** @type {!Array}
|
67
71
|
* @private
|
@@ -185,6 +189,7 @@ CellPainter.prototype.reset = function() {
|
|
185
189
|
CellPainter.prototype.resetColoring = function() {
|
186
190
|
// reset coloring type to allow other extensions to be able to set their new mode
|
187
191
|
this._setColoringType(0);
|
192
|
+
this._effectiveStyles = null;
|
188
193
|
this._conditions.length = 0;
|
189
194
|
};
|
190
195
|
|
@@ -284,6 +289,18 @@ CellPainter.prototype._setColoringType = function(enumType) {
|
|
284
289
|
}
|
285
290
|
};
|
286
291
|
/** @public
|
292
|
+
* @param {Object} mapping Effective styles mapping
|
293
|
+
*/
|
294
|
+
CellPainter.prototype.setEffectiveStyles = function(mapping) {
|
295
|
+
this._effectiveStyles = mapping;
|
296
|
+
};
|
297
|
+
/** @public
|
298
|
+
* @return {Object}
|
299
|
+
*/
|
300
|
+
CellPainter.prototype.getEffectiveStyles = function() {
|
301
|
+
return this._effectiveStyles;
|
302
|
+
};
|
303
|
+
/** @public
|
287
304
|
* @param {Array.<CellPainter~Condition>} conditions
|
288
305
|
*/
|
289
306
|
CellPainter.prototype.setConditions = function(conditions) {
|
@@ -901,9 +918,17 @@ CellPainter.clearCellStyle = function(cell, styles) {
|
|
901
918
|
elem.classList.remove(elem._coloringCssClass);
|
902
919
|
}
|
903
920
|
|
904
|
-
styles
|
905
|
-
|
906
|
-
|
921
|
+
if(!styles){
|
922
|
+
styles = CellPainter.supportedStyles;
|
923
|
+
}
|
924
|
+
if(Array.isArray(styles)){
|
925
|
+
for(var i = styles.length; --i >= 0;) {
|
926
|
+
elem.style[styles[i]] = ""; // WARNING: Very slow
|
927
|
+
}
|
928
|
+
} else {
|
929
|
+
for(var key in styles) {
|
930
|
+
elem.style[key] = ""; // WARNING: Very slow
|
931
|
+
}
|
907
932
|
}
|
908
933
|
};
|
909
934
|
/** @private
|
@@ -1025,26 +1050,29 @@ CellPainter.prototype._paintCell = function(cell, rowData, min, max) {
|
|
1025
1050
|
}
|
1026
1051
|
|
1027
1052
|
var styles = this._getStyles(rowData, min, max);
|
1053
|
+
|
1054
|
+
var elStyle = elem.style;
|
1055
|
+
|
1028
1056
|
var cssClass = styles["cssClass"]; // Can be an empty string
|
1057
|
+
if (elem._coloringCssClass && elem._coloringCssClass !== cssClass) {
|
1058
|
+
elem.classList.remove(elem._coloringCssClass);
|
1059
|
+
elem._coloringCssClass = null;
|
1060
|
+
}
|
1029
1061
|
if (cssClass != null) { // Predefined colors mode
|
1030
|
-
if (elem._coloringCssClass && elem._coloringCssClass !== cssClass) {
|
1031
|
-
elem.classList.remove(elem._coloringCssClass);
|
1032
|
-
elem._coloringCssClass = null;
|
1033
|
-
}
|
1034
1062
|
if (cssClass) {
|
1035
1063
|
elem.classList.add(cssClass);
|
1036
1064
|
elem._coloringCssClass = cssClass;
|
1037
1065
|
}
|
1038
1066
|
} else {
|
1039
|
-
if
|
1040
|
-
|
1041
|
-
|
1067
|
+
if(styles["backgroundColor"]){
|
1068
|
+
elStyle.backgroundColor = styles["backgroundColor"];
|
1069
|
+
} else if(!this._effectiveStyles || this._effectiveStyles["backgroundColor"]){
|
1070
|
+
elStyle.backgroundColor = "";
|
1042
1071
|
}
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
elStyle[styleName] = styles[styleName] || "";
|
1072
|
+
if(styles["color"]){
|
1073
|
+
elStyle.color = styles["color"];
|
1074
|
+
} else if(!this._effectiveStyles || this._effectiveStyles["color"]){
|
1075
|
+
elStyle.color = "";
|
1048
1076
|
}
|
1049
1077
|
}
|
1050
1078
|
};
|
@@ -38,7 +38,8 @@ ElementObserver._getNewId = function () {
|
|
38
38
|
return id;
|
39
39
|
};
|
40
40
|
|
41
|
-
/**
|
41
|
+
/** Observe any element
|
42
|
+
* @private
|
42
43
|
* @param {Element} elem
|
43
44
|
* @param {Function} listener
|
44
45
|
* @param {Object=} opt_option
|
@@ -101,7 +102,8 @@ ElementObserver.addLanguageListener = function(element) {
|
|
101
102
|
ElementObserver._addObserver(document.documentElement, _onLanguageMutated.bind(null, element));
|
102
103
|
};
|
103
104
|
|
104
|
-
/**
|
105
|
+
/** Add a listener to a html attribute
|
106
|
+
* @public
|
105
107
|
* @param {Element} element An element within the DOM tree to watch for changes
|
106
108
|
* @param {Function} listener A function which will be called on each attribute change
|
107
109
|
* @param {string=} attributeName If not specified, listener will be called on every attribute change
|
@@ -63,7 +63,8 @@ ElementWrapper.prototype.getMousePosition = function(e, retObj) {
|
|
63
63
|
*/
|
64
64
|
ElementWrapper.prototype.addEventListener = function(type, listener) {
|
65
65
|
ElementWrapper.base(this, "addEventListener", type, listener);
|
66
|
-
|
66
|
+
// TODO: This won't work with Custom Element
|
67
|
+
if(this._elem["on" + type] !== undefined) { // eslint-disable-line
|
67
68
|
this._elem.addEventListener(type, listener, false);
|
68
69
|
}
|
69
70
|
};
|
@@ -74,7 +75,7 @@ ElementWrapper.prototype.addEventListener = function(type, listener) {
|
|
74
75
|
*/
|
75
76
|
ElementWrapper.prototype.removeEventListener = function(type, listener) {
|
76
77
|
ElementWrapper.base(this, "removeEventListener", type, listener);
|
77
|
-
if(this._elem["on" + type]
|
78
|
+
if(this._elem["on" + type] !== undefined) { // eslint-disable-line
|
78
79
|
this._elem.removeEventListener(type, listener, false);
|
79
80
|
}
|
80
81
|
};
|
@@ -259,6 +259,11 @@ GridPlugin.prototype.getColumnIndex = function (colRef) {
|
|
259
259
|
* @return {Array.<number>} column indices
|
260
260
|
*/
|
261
261
|
GridPlugin.prototype.getColumnIndices = function (colRefs) {
|
262
|
+
var api = this.getGridApi();
|
263
|
+
if(api.getColumnIndices) {
|
264
|
+
return api.getColumnIndices(colRefs);
|
265
|
+
}
|
266
|
+
|
262
267
|
// TODO: Unify the below logics
|
263
268
|
if(this._compositeGrid) {
|
264
269
|
var allFields = this._compositeGrid.getColumnFields();
|
@@ -30,9 +30,9 @@ declare class SubTable extends ElementWrapper {
|
|
30
30
|
|
31
31
|
public getAllCells(): (Element)[];
|
32
32
|
|
33
|
-
public getAllRows():
|
33
|
+
public getAllRows(): (Element)[];
|
34
34
|
|
35
|
-
public getRows():
|
35
|
+
public getRows(): (Element)[];
|
36
36
|
|
37
37
|
public getRow(r: number): Element|null;
|
38
38
|
|
@@ -70,5 +70,7 @@ declare class SubTable extends ElementWrapper {
|
|
70
70
|
|
71
71
|
declare function tdElem(e: Event|null): number;
|
72
72
|
|
73
|
+
declare function trElem(colIndex: number, rowIndex?: number|null): number;
|
74
|
+
|
73
75
|
export default SubTable;
|
74
76
|
export { SubTable };
|
@@ -2,6 +2,18 @@ import { Dom } from "./Dom.js";
|
|
2
2
|
import { Ext } from "./Ext.js";
|
3
3
|
import { ElementWrapper } from "./ElementWrapper.js";
|
4
4
|
|
5
|
+
/** @private
|
6
|
+
* @function
|
7
|
+
* @param {Element} parentElem tr element
|
8
|
+
* @param {number} count Number of elements to be added
|
9
|
+
* @param {string} childTag Tag name of the cells
|
10
|
+
*/
|
11
|
+
var _addElements = function(parentElem, count, childTag) {
|
12
|
+
for(var i = count; --i >= 0;) {
|
13
|
+
parentElem.appendChild(document.createElement(childTag));
|
14
|
+
}
|
15
|
+
};
|
16
|
+
|
5
17
|
/** SubTable represents a single tbody, thead, or tfoot element within table element
|
6
18
|
* @constructor
|
7
19
|
* @extends {ElementWrapper}
|
@@ -39,6 +51,12 @@ SubTable.prototype._defaultRowHeight = null;
|
|
39
51
|
SubTable.prototype._render;
|
40
52
|
|
41
53
|
|
54
|
+
/** @private
|
55
|
+
* @return {string} tagName
|
56
|
+
*/
|
57
|
+
SubTable.prototype._getCellTagName = function() {
|
58
|
+
return this._elem.tagName === "THEAD" ? "TH" : "TD";
|
59
|
+
};
|
42
60
|
/** @public
|
43
61
|
* @ignore
|
44
62
|
* @param {number=} opt_count
|
@@ -49,12 +67,10 @@ SubTable.prototype.addColumns = function(opt_count) {
|
|
49
67
|
|
50
68
|
this._colCount += opt_count;
|
51
69
|
|
52
|
-
var
|
70
|
+
var cellTag = this._getCellTagName();
|
71
|
+
var rows = this._elem.children; // TODO: Must include all suspended rows
|
53
72
|
for(var r = rows.length; --r >= 0;) {
|
54
|
-
|
55
|
-
for(var c = 0; c < opt_count; ++c) {
|
56
|
-
tr.insertCell(-1);
|
57
|
-
}
|
73
|
+
_addElements(rows[r], opt_count, cellTag);
|
58
74
|
}
|
59
75
|
};
|
60
76
|
/** @public
|
@@ -68,7 +84,7 @@ SubTable.prototype.removeColumns = function(opt_count) {
|
|
68
84
|
if(opt_count <= 0) { return; }
|
69
85
|
|
70
86
|
this._colCount -= opt_count;
|
71
|
-
var rows = this.
|
87
|
+
var rows = this._elem.children; // TODO: Must include all suspended rows
|
72
88
|
for(var r = rows.length; --r >= 0;) {
|
73
89
|
Dom.removeChildren(rows[r], opt_count);
|
74
90
|
}
|
@@ -100,9 +116,7 @@ SubTable.prototype.setColumnCount = function(val) {
|
|
100
116
|
*/
|
101
117
|
SubTable.prototype.insertRow = function(at) {
|
102
118
|
var row = this._elem.insertRow(at);
|
103
|
-
|
104
|
-
row.insertCell();
|
105
|
-
}
|
119
|
+
_addElements(row, this._colCount, this._getCellTagName());
|
106
120
|
return row;
|
107
121
|
};
|
108
122
|
|
@@ -158,7 +172,7 @@ SubTable.prototype.setDefaultRowHeight = function(val) {
|
|
158
172
|
this._defaultRowHeight = val;
|
159
173
|
var minHeight = (this._defaultRowHeight != null) ? this._defaultRowHeight + "px" : "";
|
160
174
|
|
161
|
-
this._applyDefaultRowHeight(this.
|
175
|
+
this._applyDefaultRowHeight(this._elem.children, minHeight);
|
162
176
|
};
|
163
177
|
|
164
178
|
/** @public
|
@@ -194,7 +208,7 @@ SubTable.prototype.getCellsInColumn = function(c) {
|
|
194
208
|
if(c < 0 || c >= this._colCount) {
|
195
209
|
return null;
|
196
210
|
}
|
197
|
-
var rows = this.
|
211
|
+
var rows = this._elem.children;
|
198
212
|
var rowCount = rows.length;
|
199
213
|
var ary = new Array(rowCount);
|
200
214
|
for(var r = 0; r < rowCount; ++r) {
|
@@ -209,13 +223,22 @@ SubTable.prototype.getCellsInColumn = function(c) {
|
|
209
223
|
*/
|
210
224
|
SubTable.prototype.getCellsInRow = function(r) {
|
211
225
|
var tr = this.getRow(r);
|
212
|
-
|
226
|
+
if(tr) {
|
227
|
+
var cells = tr.cells;
|
228
|
+
var len = cells.length;
|
229
|
+
var ary = new Array(len);
|
230
|
+
for(var i = 0; i < len; ++i) {
|
231
|
+
ary[i] = cells[i];
|
232
|
+
}
|
233
|
+
return ary;
|
234
|
+
}
|
235
|
+
return null;
|
213
236
|
};
|
214
237
|
/** @public
|
215
238
|
* @return {!Array.<Element>} Array of td (HTMLTableCellElement) elements
|
216
239
|
*/
|
217
240
|
SubTable.prototype.getAllCells = function() {
|
218
|
-
var rows = this.
|
241
|
+
var rows = this._elem.children;
|
219
242
|
var rowCount = rows.length;
|
220
243
|
var colCount = this._colCount;
|
221
244
|
var cellCount = 0;
|
@@ -229,14 +252,20 @@ SubTable.prototype.getAllCells = function() {
|
|
229
252
|
return ary;
|
230
253
|
};
|
231
254
|
/** @public
|
232
|
-
* @return {
|
255
|
+
* @return {!Array.<Element>} Array of tr (HTMLTableRowElement) elements
|
233
256
|
*/
|
234
257
|
SubTable.prototype.getAllRows = function() {
|
235
|
-
|
258
|
+
var chdr = this._elem.children;
|
259
|
+
var len = chdr ? chdr.length : 0;
|
260
|
+
var ary = new Array(len);
|
261
|
+
for(var i = 0; i < len; ++i) {
|
262
|
+
ary[i] = chdr[i];
|
263
|
+
}
|
264
|
+
return ary;
|
236
265
|
};
|
237
266
|
/** @public
|
238
267
|
* @function
|
239
|
-
* @return {
|
268
|
+
* @return {!Array.<Element>} Array of tr (HTMLTableRowElement) elements
|
240
269
|
*/
|
241
270
|
SubTable.prototype.getRows = SubTable.prototype.getAllRows;
|
242
271
|
/** @public
|
@@ -251,7 +280,7 @@ SubTable.prototype.getRow = function(r) {
|
|
251
280
|
* @return {!Array.<Array.<string>>}
|
252
281
|
*/
|
253
282
|
SubTable.prototype.getTextContents = function() {
|
254
|
-
var rows = this.
|
283
|
+
var rows = this._elem.children;
|
255
284
|
var rowCount = rows.length;
|
256
285
|
var rowContents = new Array(rowCount);
|
257
286
|
for(var r = 0; r < rowCount; ++r) {
|
@@ -281,7 +310,7 @@ SubTable.prototype.getCellTextContent = function(c, r) {
|
|
281
310
|
* @return {string}
|
282
311
|
*/
|
283
312
|
SubTable.prototype.getColumnTextContent = function(c) { // New-line delimited
|
284
|
-
var rows = this.
|
313
|
+
var rows = this._elem.children;
|
285
314
|
var rowCount = rows.length;
|
286
315
|
if(c >= 0 && c < this._colCount && rowCount > 0) {
|
287
316
|
var str = rows[0].cells[c].textContent;
|
@@ -311,7 +340,7 @@ SubTable.prototype.getRowTextContent = function(r) { // Tab delimited
|
|
311
340
|
* @return {string}
|
312
341
|
*/
|
313
342
|
SubTable.prototype.getTableTextContent = function() { // Tab delimited
|
314
|
-
var rowCount = this.
|
343
|
+
var rowCount = this._elem.children.length;
|
315
344
|
if(rowCount > 0) {
|
316
345
|
var str = this.getRowTextContent(0);
|
317
346
|
for(var r = 1; r < rowCount; ++r) {
|
@@ -326,9 +355,10 @@ SubTable.prototype.getTableTextContent = function() { // Tab delimited
|
|
326
355
|
*/
|
327
356
|
SubTable.prototype.toString = function() {
|
328
357
|
var str = this.getElement().outerHTML;
|
358
|
+
str = str.replace(/>\s+</g, "><");
|
329
359
|
str = str.replace(/><tr/g, ">\n\t<tr");
|
330
360
|
str = str.replace(/><td/g, ">\n\t\t<td");
|
331
|
-
str = str.replace(/><
|
361
|
+
str = str.replace(/><th/g, ">\n\t\t<th"); // TH can occur in thead
|
332
362
|
str = str.replace(/><\/tr/g, ">\n\t</tr");
|
333
363
|
var tagName = this.getElement().tagName.toLowerCase();
|
334
364
|
str = str.replace("</" + tagName, "\n</" + tagName);
|
@@ -340,39 +370,40 @@ SubTable.prototype.toString = function() {
|
|
340
370
|
* @return {number}
|
341
371
|
*/
|
342
372
|
SubTable.prototype.getColumnIndex = function(e) {
|
343
|
-
if(e) {
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
373
|
+
if(!e) {
|
374
|
+
return -1;
|
375
|
+
}
|
376
|
+
var len, i;
|
377
|
+
var tgt = /** @type{Node} */(e.target); // TODO: Support Shadow Root
|
378
|
+
if(this._elem.contains(tgt)) {
|
379
|
+
var tdElem = Dom.closestTagName(tgt, "TD");
|
380
|
+
if(!tdElem) {
|
381
|
+
tdElem = Dom.closestTagName(tgt, "TH");
|
382
|
+
}
|
383
|
+
if(tdElem) {
|
384
|
+
var chdr = tdElem.parentElement.children;
|
385
|
+
len = chdr.length;
|
386
|
+
for(i = 0; i < len; ++i) {
|
387
|
+
if(tdElem === chdr[i]) {
|
388
|
+
return i;
|
389
|
+
}
|
350
390
|
}
|
351
|
-
|
352
|
-
|
353
|
-
|
391
|
+
}
|
392
|
+
} else { // In case of the target is not a child of this element
|
393
|
+
var rows = this._elem.children;
|
394
|
+
var cells = (rows[0]) ? rows[0].cells : null;
|
395
|
+
if(cells) {
|
396
|
+
var pos = Dom.getRelativePosition(e, this._elem);
|
397
|
+
var x = pos["x"];
|
398
|
+
if(x >= 0) {
|
399
|
+
len = cells.length;
|
354
400
|
for(i = 0; i < len; ++i) {
|
355
|
-
|
401
|
+
x -= cells[i].offsetWidth;
|
402
|
+
if(x < 0) { // Not include the right border
|
356
403
|
return i;
|
357
404
|
}
|
358
405
|
}
|
359
406
|
}
|
360
|
-
} else { // In case of the target is not a child of this element
|
361
|
-
var rows = this.getRows();
|
362
|
-
var cells = (rows[0]) ? rows[0].cells : null;
|
363
|
-
if(cells) {
|
364
|
-
var pos = Dom.getRelativePosition(e, this._elem);
|
365
|
-
var x = pos["x"];
|
366
|
-
if(x >= 0) {
|
367
|
-
len = cells.length;
|
368
|
-
for(i = 0; i < len; ++i) {
|
369
|
-
x -= cells[i].offsetWidth;
|
370
|
-
if(x < 0) { // Not include the right border
|
371
|
-
return i;
|
372
|
-
}
|
373
|
-
}
|
374
|
-
}
|
375
|
-
}
|
376
407
|
}
|
377
408
|
}
|
378
409
|
return -1;
|
@@ -382,27 +413,36 @@ SubTable.prototype.getColumnIndex = function(e) {
|
|
382
413
|
* @return {number}
|
383
414
|
*/
|
384
415
|
SubTable.prototype.getRowIndex = function(e) {
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
416
|
+
if(!e) {
|
417
|
+
return -1;
|
418
|
+
}
|
419
|
+
var rows = this._elem.children; // This return HTML collection
|
420
|
+
var rowCount = rows ? rows.length : 0;
|
421
|
+
if(!rowCount) {
|
422
|
+
return -1;
|
423
|
+
}
|
424
|
+
var i;
|
425
|
+
var tgt = /** @type{Node} */(e.target); // TODO: Support Shadow Root
|
426
|
+
if(this._elem.contains(tgt)) {
|
427
|
+
var trElem = Dom.closestTagName(tgt, "TR");
|
428
|
+
if(trElem) {
|
429
|
+
for(i = 0; i < rowCount; ++i) {
|
430
|
+
var row = rows[i];
|
431
|
+
if(row === trElem) {
|
432
|
+
return i;
|
433
|
+
}
|
393
434
|
}
|
394
435
|
}
|
436
|
+
}
|
395
437
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
return i;
|
405
|
-
}
|
438
|
+
// In case of the target is not a child of this element
|
439
|
+
var pos = Dom.getRelativePosition(e, this._elem);
|
440
|
+
var y = pos["y"];
|
441
|
+
if(y >= 0) {
|
442
|
+
for(i = 0; i < rowCount; ++i) {
|
443
|
+
y -= rows[i].offsetHeight;
|
444
|
+
if(y < 0) { // Not include the right border
|
445
|
+
return i;
|
406
446
|
}
|
407
447
|
}
|
408
448
|
}
|
@@ -458,31 +498,69 @@ SubTable.prototype.setCellRenderer = function(func) {
|
|
458
498
|
* @param {string=} opt_elementType
|
459
499
|
*/
|
460
500
|
SubTable.prototype.cloak = function(elem, opt_elementType) {
|
461
|
-
|
462
|
-
|
463
|
-
|
501
|
+
if(elem) {
|
502
|
+
this._elem = elem;
|
503
|
+
var rows = elem.getElementsByTagName("TR");
|
504
|
+
this._colCount = rows[0] ? rows[0].children.length : 0;
|
505
|
+
}
|
464
506
|
};
|
465
507
|
|
466
508
|
/** @public
|
467
|
-
* @param {number} c1
|
468
|
-
* @param {number} c2
|
469
|
-
* @param {number} r1
|
470
|
-
* @param {number} r2
|
509
|
+
* @param {number} c1 Starting column index
|
510
|
+
* @param {number} c2 Destination column index
|
511
|
+
* @param {number} r1 Starting row index
|
512
|
+
* @param {number} r2 Destination row index
|
471
513
|
* @return {Element} Top left cell element
|
472
514
|
*/
|
473
515
|
SubTable.prototype.spanBlock = function (c1, c2, r1, r2) { // WARNING: It's c c r r
|
474
|
-
var cell =
|
475
|
-
|
476
|
-
|
516
|
+
var cell = this.getCell(c1, r1);
|
517
|
+
if(!cell) {
|
518
|
+
return null;
|
519
|
+
}
|
520
|
+
if(c2 < c1) {
|
521
|
+
c2 = c1;
|
522
|
+
}
|
523
|
+
if(r2 < r1) {
|
524
|
+
r2 = r1;
|
525
|
+
}
|
526
|
+
var curColSpan = +cell.getAttribute("colspan");
|
527
|
+
var curRowSpan = +cell.getAttribute("rowspan");
|
528
|
+
var c3 = (curColSpan) ? c1 + curColSpan - 1 : c1;
|
529
|
+
var r3 = (curRowSpan) ? r1 + curRowSpan - 1 : r1;
|
530
|
+
|
531
|
+
// TODO: Optimize below logics
|
532
|
+
var c, r;
|
533
|
+
for(c = c3; c >= c1; --c) {
|
534
|
+
for(r = r3; r >= r1; --r) {
|
535
|
+
cell = this.getCell(c, r);
|
536
|
+
if(cell) {
|
537
|
+
cell.style.display = "";
|
538
|
+
}
|
539
|
+
}
|
540
|
+
}
|
541
|
+
|
542
|
+
for(c = c2; c >= c1; --c) {
|
543
|
+
for(r = r2; r >= r1; --r) {
|
477
544
|
cell = this.getCell(c, r);
|
478
545
|
if(cell) {
|
479
546
|
cell.style.display = "none";
|
480
547
|
}
|
481
548
|
}
|
482
549
|
}
|
483
|
-
|
484
|
-
|
485
|
-
|
550
|
+
|
551
|
+
if(cell) { // The last cell from the loop is the top left cell
|
552
|
+
var colSpan = (c2 - c1 + 1);
|
553
|
+
var rowSpan = (r2 - r1 + 1);
|
554
|
+
if(colSpan > 1) {
|
555
|
+
cell.setAttribute("colspan", colSpan);
|
556
|
+
} else {
|
557
|
+
cell.removeAttribute("colspan");
|
558
|
+
}
|
559
|
+
if(colSpan > 1) {
|
560
|
+
cell.setAttribute("rowspan", rowSpan);
|
561
|
+
} else {
|
562
|
+
cell.removeAttribute("rowspan");
|
563
|
+
}
|
486
564
|
cell.style.display = "";
|
487
565
|
}
|
488
566
|
return cell;
|
@@ -526,7 +604,7 @@ SubTable.parseTableContent = function(tbl) {
|
|
526
604
|
};
|
527
605
|
|
528
606
|
/** @private
|
529
|
-
* @param {!NodeList<!Element>|Array.<Element>} rows
|
607
|
+
* @param {!(NodeList<!Element>|Array.<Element>)} rows
|
530
608
|
* @param {string} minHeight
|
531
609
|
*/
|
532
610
|
SubTable.prototype._applyDefaultRowHeight = function(rows, minHeight) {
|
@@ -3,17 +3,32 @@ import { Ext } from "./Ext.js";
|
|
3
3
|
import { ElementWrapper } from "./ElementWrapper.js";
|
4
4
|
import { SubTable } from "./SubTable.js";
|
5
5
|
|
6
|
+
declare namespace Table {
|
7
|
+
|
8
|
+
type Options = {
|
9
|
+
colCount?: number|null,
|
10
|
+
rowCount?: number|null,
|
11
|
+
cellWidth?: number|null,
|
12
|
+
cellHeight?: number|null,
|
13
|
+
width?: number|null,
|
14
|
+
height?: number|null,
|
15
|
+
header?: number|null,
|
16
|
+
footer?: number|null
|
17
|
+
};
|
18
|
+
|
19
|
+
}
|
20
|
+
|
6
21
|
declare class Table extends ElementWrapper {
|
7
22
|
|
8
|
-
constructor(elem?:
|
23
|
+
constructor(elem?: Element|null, options?: Table.Options|null);
|
9
24
|
|
10
25
|
public getTableElement(): Element|null;
|
11
26
|
|
12
27
|
public setCRWH(col: number, row: number, width: number, height: number): void;
|
13
28
|
|
14
|
-
public init(options:
|
29
|
+
public init(options: Table.Options|null): void;
|
15
30
|
|
16
|
-
public addColumns(
|
31
|
+
public addColumns(count?: number|null): (Element)[]|null;
|
17
32
|
|
18
33
|
public removeColumns(opt_count?: number|null): void;
|
19
34
|
|
@@ -21,9 +36,9 @@ declare class Table extends ElementWrapper {
|
|
21
36
|
|
22
37
|
public setColumnCount(val: number): void;
|
23
38
|
|
24
|
-
public addRows(
|
39
|
+
public addRows(count?: number|null): (Element)[];
|
25
40
|
|
26
|
-
public removeRows(
|
41
|
+
public removeRows(count?: number|null): void;
|
27
42
|
|
28
43
|
public removeAllRows(): void;
|
29
44
|
|
@@ -43,21 +58,23 @@ declare class Table extends ElementWrapper {
|
|
43
58
|
|
44
59
|
public getAllRows(): (Element)[];
|
45
60
|
|
61
|
+
public getRows(): (Element)[];
|
62
|
+
|
46
63
|
public getRow(r: number): Element|null;
|
47
64
|
|
48
65
|
public spanBlock(c1: number, c2: number, r1: number, r2: number): Element|null;
|
49
66
|
|
50
67
|
public spanHorizontally(r: number, bool: boolean): Element|null;
|
51
68
|
|
52
|
-
public setColMinWidths(val: number|string|(string|number)[]|null,
|
69
|
+
public setColMinWidths(val: number|string|(string|number)[]|null, colIndex?: number|null): void;
|
53
70
|
|
54
|
-
public setColumnWidths(val: number|string|(string|number)[]|null,
|
71
|
+
public setColumnWidths(val: number|string|(string|number)[]|null, colIndex?: number|null): void;
|
55
72
|
|
56
|
-
public setColBackgroundColors(val: string|(string)[]|null,
|
73
|
+
public setColBackgroundColors(val: string|(string)[]|null, colIndex?: number|null): void;
|
57
74
|
|
58
|
-
public setColBGColors(val: string|(string)[]|null,
|
75
|
+
public setColBGColors(val: string|(string)[]|null, colIndex?: number|null): void;
|
59
76
|
|
60
|
-
public setColBorders(val: number|string|(number|string)[]|null,
|
77
|
+
public setColBorders(val: number|string|(number|string)[]|null, colIndex?: number|null): void;
|
61
78
|
|
62
79
|
public setSize(width: number, height: number): void;
|
63
80
|
|