@refinitiv-ui/efx-grid 6.0.57 → 6.0.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. package/lib/core/dist/core.js +25 -4
  2. package/lib/core/dist/core.min.js +1 -1
  3. package/lib/core/es6/data/DataTable.js +8 -0
  4. package/lib/core/es6/grid/Core.js +3 -1
  5. package/lib/core/es6/grid/event/EventListeners.js +3 -0
  6. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +3 -3
  7. package/lib/core/es6/grid/util/TrackLayout.d.ts +2 -0
  8. package/lib/core/es6/grid/util/TrackLayout.js +8 -0
  9. package/lib/grid/index.js +1 -1
  10. package/lib/rt-grid/dist/rt-grid.js +48 -16
  11. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  12. package/lib/rt-grid/es6/Grid.d.ts +3 -3
  13. package/lib/rt-grid/es6/Grid.js +16 -8
  14. package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +3 -1
  15. package/lib/tr-grid-column-stack/es6/ColumnStack.js +64 -8
  16. package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +1 -1
  17. package/lib/tr-grid-textformatting/es6/TextFormatting.js +35 -5
  18. package/lib/tr-grid-util/es6/ElementObserver.js +4 -2
  19. package/lib/tr-grid-util/es6/ElementWrapper.js +3 -2
  20. package/lib/tr-grid-util/es6/GridPlugin.js +5 -0
  21. package/lib/tr-grid-util/es6/SubTable.d.ts +4 -2
  22. package/lib/tr-grid-util/es6/SubTable.js +136 -72
  23. package/lib/tr-grid-util/es6/Table.d.ts +25 -10
  24. package/lib/tr-grid-util/es6/Table.js +103 -78
  25. package/lib/tr-grid-util/es6/formula/AdFinSubscription.js +1 -1
  26. package/lib/types/es6/ColumnStack.d.ts +3 -1
  27. package/lib/types/es6/Core/grid/util/TrackLayout.d.ts +2 -0
  28. package/lib/types/es6/RealtimeGrid/Grid.d.ts +3 -3
  29. package/lib/types/es6/TextFormatting.d.ts +1 -1
  30. package/lib/versions.json +3 -3
  31. package/package.json +1 -1
@@ -49,7 +49,7 @@ SubTable.prototype.addColumns = function(opt_count) {
49
49
 
50
50
  this._colCount += opt_count;
51
51
 
52
- var rows = this.getRows(); // TODO: Must include all suspended rows
52
+ var rows = this._elem.children; // TODO: Must include all suspended rows
53
53
  for(var r = rows.length; --r >= 0;) {
54
54
  var tr = rows[r];
55
55
  for(var c = 0; c < opt_count; ++c) {
@@ -68,7 +68,7 @@ SubTable.prototype.removeColumns = function(opt_count) {
68
68
  if(opt_count <= 0) { return; }
69
69
 
70
70
  this._colCount -= opt_count;
71
- var rows = this.getRows(); // TODO: Must include all suspended rows
71
+ var rows = this._elem.children; // TODO: Must include all suspended rows
72
72
  for(var r = rows.length; --r >= 0;) {
73
73
  Dom.removeChildren(rows[r], opt_count);
74
74
  }
@@ -158,7 +158,7 @@ SubTable.prototype.setDefaultRowHeight = function(val) {
158
158
  this._defaultRowHeight = val;
159
159
  var minHeight = (this._defaultRowHeight != null) ? this._defaultRowHeight + "px" : "";
160
160
 
161
- this._applyDefaultRowHeight(this.getRows(), minHeight);
161
+ this._applyDefaultRowHeight(this._elem.children, minHeight);
162
162
  };
163
163
 
164
164
  /** @public
@@ -194,7 +194,7 @@ SubTable.prototype.getCellsInColumn = function(c) {
194
194
  if(c < 0 || c >= this._colCount) {
195
195
  return null;
196
196
  }
197
- var rows = this.getRows();
197
+ var rows = this._elem.children;
198
198
  var rowCount = rows.length;
199
199
  var ary = new Array(rowCount);
200
200
  for(var r = 0; r < rowCount; ++r) {
@@ -209,13 +209,22 @@ SubTable.prototype.getCellsInColumn = function(c) {
209
209
  */
210
210
  SubTable.prototype.getCellsInRow = function(r) {
211
211
  var tr = this.getRow(r);
212
- return (tr) ? tr.cells : null;
212
+ if(tr) {
213
+ var cells = tr.cells;
214
+ var len = cells.length;
215
+ var ary = new Array(len);
216
+ for(var i = 0; i < len; ++i) {
217
+ ary[i] = cells[i];
218
+ }
219
+ return ary;
220
+ }
221
+ return null;
213
222
  };
214
223
  /** @public
215
224
  * @return {!Array.<Element>} Array of td (HTMLTableCellElement) elements
216
225
  */
217
226
  SubTable.prototype.getAllCells = function() {
218
- var rows = this.getRows();
227
+ var rows = this._elem.children;
219
228
  var rowCount = rows.length;
220
229
  var colCount = this._colCount;
221
230
  var cellCount = 0;
@@ -229,14 +238,20 @@ SubTable.prototype.getAllCells = function() {
229
238
  return ary;
230
239
  };
231
240
  /** @public
232
- * @return {HTMLCollection} Array like collection of tr (HTMLTableRowElement) elements
241
+ * @return {!Array.<Element>} Array of tr (HTMLTableRowElement) elements
233
242
  */
234
243
  SubTable.prototype.getAllRows = function() {
235
- return this._elem.children;
244
+ var chdr = this._elem.children;
245
+ var len = chdr ? chdr.length : 0;
246
+ var ary = new Array(len);
247
+ for(var i = 0; i < len; ++i) {
248
+ ary[i] = chdr[i];
249
+ }
250
+ return ary;
236
251
  };
237
252
  /** @public
238
253
  * @function
239
- * @return {HTMLCollection} Array like collection of tr (HTMLTableRowElement) elements
254
+ * @return {!Array.<Element>} Array of tr (HTMLTableRowElement) elements
240
255
  */
241
256
  SubTable.prototype.getRows = SubTable.prototype.getAllRows;
242
257
  /** @public
@@ -251,7 +266,7 @@ SubTable.prototype.getRow = function(r) {
251
266
  * @return {!Array.<Array.<string>>}
252
267
  */
253
268
  SubTable.prototype.getTextContents = function() {
254
- var rows = this.getRows();
269
+ var rows = this._elem.children;
255
270
  var rowCount = rows.length;
256
271
  var rowContents = new Array(rowCount);
257
272
  for(var r = 0; r < rowCount; ++r) {
@@ -281,7 +296,7 @@ SubTable.prototype.getCellTextContent = function(c, r) {
281
296
  * @return {string}
282
297
  */
283
298
  SubTable.prototype.getColumnTextContent = function(c) { // New-line delimited
284
- var rows = this.getRows();
299
+ var rows = this._elem.children;
285
300
  var rowCount = rows.length;
286
301
  if(c >= 0 && c < this._colCount && rowCount > 0) {
287
302
  var str = rows[0].cells[c].textContent;
@@ -311,7 +326,7 @@ SubTable.prototype.getRowTextContent = function(r) { // Tab delimited
311
326
  * @return {string}
312
327
  */
313
328
  SubTable.prototype.getTableTextContent = function() { // Tab delimited
314
- var rowCount = this.getRows().length;
329
+ var rowCount = this._elem.children.length;
315
330
  if(rowCount > 0) {
316
331
  var str = this.getRowTextContent(0);
317
332
  for(var r = 1; r < rowCount; ++r) {
@@ -326,9 +341,10 @@ SubTable.prototype.getTableTextContent = function() { // Tab delimited
326
341
  */
327
342
  SubTable.prototype.toString = function() {
328
343
  var str = this.getElement().outerHTML;
344
+ str = str.replace(/>\s+</g, "><");
329
345
  str = str.replace(/><tr/g, ">\n\t<tr");
330
346
  str = str.replace(/><td/g, ">\n\t\t<td");
331
- str = str.replace(/><td/g, ">\n\t\t<th"); // TH can occur in thead
347
+ str = str.replace(/><th/g, ">\n\t\t<th"); // TH can occur in thead
332
348
  str = str.replace(/><\/tr/g, ">\n\t</tr");
333
349
  var tagName = this.getElement().tagName.toLowerCase();
334
350
  str = str.replace("</" + tagName, "\n</" + tagName);
@@ -340,39 +356,40 @@ SubTable.prototype.toString = function() {
340
356
  * @return {number}
341
357
  */
342
358
  SubTable.prototype.getColumnIndex = function(e) {
343
- if(e) {
344
- var len, i;
345
- var tgt = /** @type{Node} */(e.target);
346
- if(this._elem.contains(tgt)) {
347
- var tdElem = Dom.closestTagName(tgt, "TD");
348
- if(!tdElem) {
349
- tdElem = Dom.closestTagName(tgt, "TH");
359
+ if(!e) {
360
+ return -1;
361
+ }
362
+ var len, i;
363
+ var tgt = /** @type{Node} */(e.target); // TODO: Support Shadow Root
364
+ if(this._elem.contains(tgt)) {
365
+ var tdElem = Dom.closestTagName(tgt, "TD");
366
+ if(!tdElem) {
367
+ tdElem = Dom.closestTagName(tgt, "TH");
368
+ }
369
+ if(tdElem) {
370
+ var chdr = tdElem.parentElement.children;
371
+ len = chdr.length;
372
+ for(i = 0; i < len; ++i) {
373
+ if(tdElem === chdr[i]) {
374
+ return i;
375
+ }
350
376
  }
351
- if(tdElem) {
352
- var chdr = tdElem.parentElement.children;
353
- len = chdr.length;
377
+ }
378
+ } else { // In case of the target is not a child of this element
379
+ var rows = this._elem.children;
380
+ var cells = (rows[0]) ? rows[0].cells : null;
381
+ if(cells) {
382
+ var pos = Dom.getRelativePosition(e, this._elem);
383
+ var x = pos["x"];
384
+ if(x >= 0) {
385
+ len = cells.length;
354
386
  for(i = 0; i < len; ++i) {
355
- if(tdElem === chdr[i]) {
387
+ x -= cells[i].offsetWidth;
388
+ if(x < 0) { // Not include the right border
356
389
  return i;
357
390
  }
358
391
  }
359
392
  }
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
393
  }
377
394
  }
378
395
  return -1;
@@ -382,27 +399,36 @@ SubTable.prototype.getColumnIndex = function(e) {
382
399
  * @return {number}
383
400
  */
384
401
  SubTable.prototype.getRowIndex = function(e) {
385
- var rows = this.getRows();
386
- if(rows && e) {
387
- var jLen = rows.length;
388
- var tgtElem = e.target; // TODO: Support Shadow Root
389
- for(var j = 0; j < jLen; ++j) {
390
- var row = rows[j];
391
- if(row === tgtElem) {
392
- return j;
402
+ if(!e) {
403
+ return -1;
404
+ }
405
+ var rows = this._elem.children; // This return HTML collection
406
+ var rowCount = rows ? rows.length : 0;
407
+ if(!rowCount) {
408
+ return -1;
409
+ }
410
+ var i;
411
+ var tgt = /** @type{Node} */(e.target); // TODO: Support Shadow Root
412
+ if(this._elem.contains(tgt)) {
413
+ var trElem = Dom.closestTagName(tgt, "TR");
414
+ if(trElem) {
415
+ for(i = 0; i < rowCount; ++i) {
416
+ var row = rows[i];
417
+ if(row === trElem) {
418
+ return i;
419
+ }
393
420
  }
394
421
  }
422
+ }
395
423
 
396
- // In case of the target is not a child of this element
397
- var pos = Dom.getRelativePosition(e, this._elem);
398
- var y = pos["y"];
399
- if(y >= 0) {
400
- var len = rows.length;
401
- for(var i = 0; i < len; ++i) {
402
- y -= rows[i].offsetHeight;
403
- if(y < 0) { // Not include the right border
404
- return i;
405
- }
424
+ // In case of the target is not a child of this element
425
+ var pos = Dom.getRelativePosition(e, this._elem);
426
+ var y = pos["y"];
427
+ if(y >= 0) {
428
+ for(i = 0; i < rowCount; ++i) {
429
+ y -= rows[i].offsetHeight;
430
+ if(y < 0) { // Not include the right border
431
+ return i;
406
432
  }
407
433
  }
408
434
  }
@@ -458,31 +484,69 @@ SubTable.prototype.setCellRenderer = function(func) {
458
484
  * @param {string=} opt_elementType
459
485
  */
460
486
  SubTable.prototype.cloak = function(elem, opt_elementType) {
461
- SubTable["base"](this, "cloak", elem, "tr");
462
- var rows = elem.getElementsByTagName("TR");
463
- this._colCount = rows[0] ? rows[0].children.length : 0;
487
+ if(elem) {
488
+ this._elem = elem;
489
+ var rows = elem.getElementsByTagName("TR");
490
+ this._colCount = rows[0] ? rows[0].children.length : 0;
491
+ }
464
492
  };
465
493
 
466
494
  /** @public
467
- * @param {number} c1
468
- * @param {number} c2
469
- * @param {number} r1
470
- * @param {number} r2
495
+ * @param {number} c1 Starting column index
496
+ * @param {number} c2 Destination column index
497
+ * @param {number} r1 Starting row index
498
+ * @param {number} r2 Destination row index
471
499
  * @return {Element} Top left cell element
472
500
  */
473
501
  SubTable.prototype.spanBlock = function (c1, c2, r1, r2) { // WARNING: It's c c r r
474
- var cell = null;
475
- for(var c = c2; c >= c1; --c) {
476
- for(var r = r2; r >= r1; --r) {
502
+ var cell = this.getCell(c1, r1);
503
+ if(!cell) {
504
+ return null;
505
+ }
506
+ if(c2 < c1) {
507
+ c2 = c1;
508
+ }
509
+ if(r2 < r1) {
510
+ r2 = r1;
511
+ }
512
+ var curColSpan = +cell.getAttribute("colspan");
513
+ var curRowSpan = +cell.getAttribute("rowspan");
514
+ var c3 = (curColSpan) ? c1 + curColSpan - 1 : c1;
515
+ var r3 = (curRowSpan) ? r1 + curRowSpan - 1 : r1;
516
+
517
+ // TODO: Optimize below logics
518
+ var c, r;
519
+ for(c = c3; c >= c1; --c) {
520
+ for(r = r3; r >= r1; --r) {
521
+ cell = this.getCell(c, r);
522
+ if(cell) {
523
+ cell.style.display = "";
524
+ }
525
+ }
526
+ }
527
+
528
+ for(c = c2; c >= c1; --c) {
529
+ for(r = r2; r >= r1; --r) {
477
530
  cell = this.getCell(c, r);
478
531
  if(cell) {
479
532
  cell.style.display = "none";
480
533
  }
481
534
  }
482
535
  }
483
- if(cell) {
484
- cell.setAttribute("colspan", (c2 - c1 + 1));
485
- cell.setAttribute("rowspan", (r2 - r1 + 1));
536
+
537
+ if(cell) { // The last cell from the loop is the top left cell
538
+ var colSpan = (c2 - c1 + 1);
539
+ var rowSpan = (r2 - r1 + 1);
540
+ if(colSpan > 1) {
541
+ cell.setAttribute("colspan", colSpan);
542
+ } else {
543
+ cell.removeAttribute("colspan");
544
+ }
545
+ if(colSpan > 1) {
546
+ cell.setAttribute("rowspan", rowSpan);
547
+ } else {
548
+ cell.removeAttribute("rowspan");
549
+ }
486
550
  cell.style.display = "";
487
551
  }
488
552
  return cell;
@@ -526,7 +590,7 @@ SubTable.parseTableContent = function(tbl) {
526
590
  };
527
591
 
528
592
  /** @private
529
- * @param {!NodeList<!Element>|Array.<Element>} rows
593
+ * @param {!(NodeList<!Element>|Array.<Element>)} rows
530
594
  * @param {string} minHeight
531
595
  */
532
596
  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?: (Element|number)|null, opt_colCount?: (number|any)|null, opt_rowCount?: number|null);
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: any): void;
29
+ public init(options: Table.Options|null): void;
15
30
 
16
- public addColumns(opt_count?: number|null): (Element)[]|null;
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(opt_count?: number|null): (Element)[];
39
+ public addRows(count?: number|null): (Element)[];
25
40
 
26
- public removeRows(opt_count?: number|null): void;
41
+ public removeRows(count?: number|null): void;
27
42
 
28
43
  public removeAllRows(): void;
29
44
 
@@ -49,15 +64,15 @@ declare class Table extends ElementWrapper {
49
64
 
50
65
  public spanHorizontally(r: number, bool: boolean): Element|null;
51
66
 
52
- public setColMinWidths(val: number|string|(string|number)[]|null, opt_at?: number|null): void;
67
+ public setColMinWidths(val: number|string|(string|number)[]|null, colIndex?: number|null): void;
53
68
 
54
- public setColumnWidths(val: number|string|(string|number)[]|null, opt_at?: number|null): void;
69
+ public setColumnWidths(val: number|string|(string|number)[]|null, colIndex?: number|null): void;
55
70
 
56
- public setColBackgroundColors(val: string|(string)[]|null, opt_at?: number|null): void;
71
+ public setColBackgroundColors(val: string|(string)[]|null, colIndex?: number|null): void;
57
72
 
58
- public setColBGColors(val: string|(string)[]|null, opt_at?: number|null): void;
73
+ public setColBGColors(val: string|(string)[]|null, colIndex?: number|null): void;
59
74
 
60
- public setColBorders(val: number|string|(number|string)[]|null, opt_at?: number|null): void;
75
+ public setColBorders(val: number|string|(number|string)[]|null, colIndex?: number|null): void;
61
76
 
62
77
  public setSize(width: number, height: number): void;
63
78