@refinitiv-ui/efx-grid 6.0.119 → 6.0.120

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.
Files changed (33) hide show
  1. package/lib/core/dist/core.js +97 -6
  2. package/lib/core/dist/core.min.js +1 -1
  3. package/lib/core/es6/data/DataView.js +7 -5
  4. package/lib/core/es6/grid/Core.js +1 -1
  5. package/lib/core/es6/grid/components/Cell.d.ts +2 -0
  6. package/lib/core/es6/grid/components/Cell.js +89 -0
  7. package/lib/filter-dialog/themes/base-checkbox.less +1 -1
  8. package/lib/filter-dialog/themes/elemental/dark/checkbox-list.js +1 -1
  9. package/lib/filter-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
  10. package/lib/filter-dialog/themes/elemental/light/checkbox-list.js +1 -1
  11. package/lib/filter-dialog/themes/elemental/light/es5/all-elements.js +1 -1
  12. package/lib/filter-dialog/themes/halo/dark/checkbox-list.js +1 -1
  13. package/lib/filter-dialog/themes/halo/dark/es5/all-elements.js +1 -1
  14. package/lib/filter-dialog/themes/halo/light/checkbox-list.js +1 -1
  15. package/lib/filter-dialog/themes/halo/light/es5/all-elements.js +1 -1
  16. package/lib/filter-dialog/themes/solar/charcoal/checkbox-list.js +1 -1
  17. package/lib/filter-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
  18. package/lib/filter-dialog/themes/solar/pearl/checkbox-list.js +1 -1
  19. package/lib/filter-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
  20. package/lib/grid/index.js +1 -1
  21. package/lib/rt-grid/dist/rt-grid.js +210 -87
  22. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  23. package/lib/rt-grid/es6/ColumnDefinition.js +7 -0
  24. package/lib/rt-grid/es6/Grid.js +106 -81
  25. package/lib/tr-grid-auto-tooltip/es6/AutoTooltip.js +18 -15
  26. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +6 -1
  27. package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +0 -2
  28. package/lib/tr-grid-row-dragging/es6/RowDragging.js +82 -77
  29. package/lib/tr-grid-row-selection/es6/RowSelection.js +155 -35
  30. package/lib/types/es6/Core/grid/components/Cell.d.ts +2 -0
  31. package/lib/types/es6/RowDragging.d.ts +0 -2
  32. package/lib/versions.json +5 -5
  33. package/package.json +1 -1
@@ -547,6 +547,13 @@ ColumnDefinition.getDataType = function(field) {
547
547
  return "";
548
548
  };
549
549
  /** @public
550
+ * @ignore
551
+ * @return {boolean|string|null}
552
+ */
553
+ ColumnDefinition.prototype.getTooltipValue = function() {
554
+ return this._tooltip;
555
+ };
556
+ /** @public
550
557
  * @return {string}
551
558
  */
552
559
  ColumnDefinition.prototype.getTooltip = function() {
@@ -274,11 +274,11 @@ let _hasFieldOrId = function(colDef, str) {
274
274
  };
275
275
 
276
276
  /** Compare the difference in the 'id' property.
277
- * @private
278
- * @param {Object} obj1
279
- * @param {Object} obj2
280
- * @returns {boolean} If the id property of two objects is equal, the return will be true, otherwise it will be false.
281
- */
277
+ * @private
278
+ * @param {Object} obj1
279
+ * @param {Object} obj2
280
+ * @returns {boolean} If the id property of two objects is equal, the return will be true, otherwise it will be false.
281
+ */
282
282
  let _hasMatchingId = function(obj1, obj2) {
283
283
  if(!obj1 || !obj2 || !obj1.id || !obj2.id) { // Handle nullable, if the object or id have null, it's means difference value
284
284
  return false;
@@ -286,6 +286,25 @@ let _hasMatchingId = function(obj1, obj2) {
286
286
  return obj1.id === obj2.id;
287
287
  };
288
288
 
289
+ /** @private
290
+ * @param {Object} e
291
+ */
292
+ let _preventDefault = function(e) {
293
+ if(e) {
294
+ e.preventDefault();
295
+ }
296
+ };
297
+ /** @private
298
+ * @param {number=} id
299
+ * @returns {number} Always return 0
300
+ */
301
+ let _clearTimeout = function(id) {
302
+ if(id) {
303
+ clearTimeout(id);
304
+ }
305
+ return 0;
306
+ };
307
+
289
308
  /** @constructor
290
309
  * @extends {EventDispatcher}
291
310
  * @param {(Element|null)=} placeholder
@@ -596,10 +615,6 @@ Grid.prototype._topSection = true;
596
615
  * @private
597
616
  */
598
617
  Grid.prototype._focusingArgs = null;
599
- /** @type {number}
600
- * @private
601
- */
602
- Grid.prototype._scrolledRow = -1;
603
618
  /** @type {boolean}
604
619
  * @private
605
620
  */
@@ -614,10 +629,8 @@ Grid.prototype.dispose = function() {
614
629
  clearInterval(this._autoLayoutTimer);
615
630
  this._autoLayoutTimer = 0;
616
631
  }
617
- if(this._pollingTimerId) {
618
- clearTimeout(this._pollingTimerId);
619
- this._pollingTimerId = 0;
620
- }
632
+ this._pollingTimerId = _clearTimeout(this._pollingTimerId);
633
+
621
634
  this.removeAllColumns(); // Some conflators are reset
622
635
  this.removeAllRows(); // Some conflators are reset
623
636
  this._sorter.dispose();
@@ -640,9 +653,8 @@ Grid.prototype.dispose = function() {
640
653
  }
641
654
 
642
655
  if(this._focusingArgs) {
643
- if(this._focusingArgs.id) {
644
- clearTimeout(this._focusingArgs.id);
645
- }
656
+ _clearTimeout(this._focusingArgs.id);
657
+ _clearTimeout(this._focusingArgs.timeoutId);
646
658
  this._focusingArgs = null;
647
659
  }
648
660
  };
@@ -947,6 +959,7 @@ Grid.prototype.initialize = function(gridOption) {
947
959
  this.addListener(gridOption, "beforeContentBinding");
948
960
  this.addListener(gridOption, "firstRendered");
949
961
  this.addListener(gridOption, "afterContentBinding");
962
+ this.addListener(gridOption, "tabNavigation");
950
963
 
951
964
  if(gridOption["autoDateConversion"]) {
952
965
  t._autoDateConversion = true;
@@ -3463,12 +3476,15 @@ Grid.prototype._renderColumnHeader = function(colIndex, arg) {
3463
3476
  let colName = colDef.getName();
3464
3477
  let colTooltip = colDef.getTooltip();
3465
3478
  let headerAlignment = colDef.getHeaderAlignment();
3479
+ let tooltipValue = colDef.getTooltipValue();
3466
3480
 
3467
3481
  for(let r = 0; r < rowCount; ++r) {
3468
3482
  let tCell = tSection.getCell(colIndex, r, false);
3469
3483
  // Default behaviors
3470
3484
  tCell.setContent(colName);
3471
- tCell.setTooltip(colTooltip);
3485
+ tCell.setTooltipInfo("columnDefault", tooltipValue);
3486
+ tCell.setTooltipInfo("columnTooltip", colTooltip);
3487
+ tCell.updateTooltip();
3472
3488
  tCell.setStyle("textAlign", headerAlignment);
3473
3489
 
3474
3490
  if(customRenderer) {
@@ -4216,38 +4232,49 @@ Grid.prototype.getVScrollView = function () {
4216
4232
  return this._grid.getVScrollView();
4217
4233
  };
4218
4234
 
4219
- /** @private
4220
- * @param {Element} el
4221
- * @return {boolean}
4222
- */
4223
- function isFocusableContent(el) {
4224
- if(el) {
4225
- return (el.tagName !== "SPAN" && !el.disabled);
4226
- }
4227
- return false;
4228
- }
4229
4235
  /** @private
4230
4236
  * @param {Object} cell
4237
+ * @param {Object} args
4231
4238
  * @return {boolean}
4232
4239
  */
4233
- function focusCell(cell) {
4240
+ Grid.prototype._focusCell = function(cell, args) {
4234
4241
  if(cell) {
4235
4242
  let cellContent = cell.getContent();
4236
- if(cellContent && isFocusableContent(cellContent)) {
4237
- cellContent.focus();
4238
- return true;
4243
+ if(cellContent) {
4244
+ let nfe = null;
4245
+ if(this.hasListener("tabNavigation")) {
4246
+ let tabNavArg = {
4247
+ "shiftKey": args.shiftKey,
4248
+ "activeElement": args.activeElement,
4249
+ "cellContent": cellContent,
4250
+ "cell": cell,
4251
+ "colIndex": args.colIndex,
4252
+ "rowIndex": args.rowIndex,
4253
+ "field": args.fields ? args.fields[args.colIndex] : ""
4254
+ };
4255
+ this._dispatch("tabNavigation", tabNavArg);
4256
+ nfe = tabNavArg.nextFocusableElement;
4257
+ } else if(cellContent.tagName !== "SPAN") {
4258
+ nfe = cellContent;
4259
+ }
4260
+
4261
+ if(nfe && nfe !== args.activeElement && !nfe.disabled) {
4262
+ nfe.focus();
4263
+ return true;
4264
+ }
4239
4265
  }
4240
4266
  }
4241
4267
  return false;
4242
- }
4268
+ };
4243
4269
  /** @private
4244
4270
  */
4245
4271
  Grid.prototype._onVScroll = function() {
4246
4272
  let args = this._focusingArgs;
4247
4273
  if(args) {
4274
+ args.timeoutId = _clearTimeout(args.timeoutId);
4248
4275
  this._focusingArgs = null;
4249
4276
  let cell = this._grid.getCell("content", args.colIndex, args.rowIndex);
4250
- if(!focusCell(cell)) {
4277
+ if(!this._focusCell(cell, args)) {
4251
4278
  if(args.shiftKey) {
4252
4279
  this._focusPrevCellContent(args);
4253
4280
  } else {
@@ -4258,6 +4285,11 @@ Grid.prototype._onVScroll = function() {
4258
4285
  };
4259
4286
  /** @private
4260
4287
  */
4288
+ Grid.prototype._onScrollTimeout = function() {
4289
+ this._focusingArgs = null;
4290
+ };
4291
+ /** @private
4292
+ */
4261
4293
  Grid.prototype._selfScrollToRow = function() {
4262
4294
  let args = this._focusingArgs;
4263
4295
  if(args) {
@@ -4267,20 +4299,14 @@ Grid.prototype._selfScrollToRow = function() {
4267
4299
  };
4268
4300
  /** @private
4269
4301
  * @param {Object} args
4270
- * @param {number} colIndex
4271
- * @param {number} rowIndex
4272
4302
  */
4273
- Grid.prototype._requestScroll = function(args, colIndex, rowIndex) {
4274
- if(this._focusingArgs || this._scrolledRow === args.rowIndex) {
4275
- return; // Avoid infinite loop
4303
+ Grid.prototype._requestScroll = function(args) {
4304
+ if(!this._focusingArgs) {
4305
+ this._focusingArgs = args;
4306
+ args.event = null; // The event is invalid after the scroll
4307
+ args.id = setTimeout(this._selfScrollToRow, 0); // Avoid event loop protection
4308
+ args.timeoutId = setTimeout(this._onScrollTimeout, 100); // To avoid a fail case where scroll cannot be performed
4276
4309
  }
4277
-
4278
- this._scrolledRow = args.rowIndex;
4279
- this._focusingArgs = args;
4280
- args.colIndex = colIndex;
4281
- args.rowIndex = rowIndex;
4282
- args.event = null; // The event is invalid after the scroll
4283
- args.id = setTimeout(this._selfScrollToRow); // Avoid event loop protection
4284
4310
  };
4285
4311
  /** @private
4286
4312
  * @param {Object} args
@@ -4304,28 +4330,27 @@ Grid.prototype._focusNextCellContent = function(args) {
4304
4330
  startIdx = i;
4305
4331
  }
4306
4332
  }
4307
- // If the current focus is on a valid content, starts on the next cell
4308
- if(args.event && args.validContent) {
4309
- startIdx++;
4310
- }
4311
4333
 
4312
4334
  let grid = this._grid;
4313
4335
  let section = grid.getSection("content");
4314
4336
  let viewInfo = grid.getVerticalViewInfo();
4315
4337
  let lastFullRow = viewInfo.lastFullRow;
4316
4338
  let rowCount = this.getRowCount();
4339
+
4340
+ args.fields = grid.getColumnFields();
4317
4341
  for(let r = rowIndex; r < rowCount; r++) {
4342
+ args.rowIndex = r;
4318
4343
  for(i = startIdx; i < len; i++) {
4319
4344
  let c = focusableColIndices[i];
4345
+ args.colIndex = c;
4320
4346
  if(r > lastFullRow) {
4321
- this._requestScroll(args, c, r);
4347
+ _preventDefault(args.event);
4348
+ this._requestScroll(args);
4322
4349
  return;
4323
4350
  } else {
4324
4351
  let cell = section.getCell(c, r);
4325
- if(focusCell(cell)) {
4326
- if(args.event) {
4327
- args.event.preventDefault();
4328
- }
4352
+ if(this._focusCell(cell, args)) {
4353
+ _preventDefault(args.event);
4329
4354
  return;
4330
4355
  }
4331
4356
  }
@@ -4333,9 +4358,8 @@ Grid.prototype._focusNextCellContent = function(args) {
4333
4358
  startIdx = 0;
4334
4359
  }
4335
4360
 
4336
- if(args.validContent) { // The current focus on the last focusable content
4337
- this._grid.getHiddenInput().focus();
4338
- }
4361
+ // The current focus on the last focusable content
4362
+ this._grid.getHiddenInput().focus();
4339
4363
  };
4340
4364
  /** @private
4341
4365
  * @param {Object} args
@@ -4359,27 +4383,26 @@ Grid.prototype._focusPrevCellContent = function(args) {
4359
4383
  startIdx = i;
4360
4384
  }
4361
4385
  }
4362
- // If the current focus is on a valid content, starts on the next cell
4363
- if(args.event && args.validContent) {
4364
- --startIdx;
4365
- }
4366
4386
 
4367
4387
  let grid = this._grid;
4368
4388
  let section = grid.getSection("content");
4369
4389
  let viewInfo = grid.getVerticalViewInfo();
4370
4390
  let firstFullRow = viewInfo.firstFullRow;
4391
+
4392
+ args.fields = this.getColumnFields();
4371
4393
  for(let r = rowIndex; r >= 0; r--) {
4394
+ args.rowIndex = r;
4372
4395
  for(i = startIdx; i >= 0; i--) {
4373
4396
  let c = focusableColIndices[i];
4397
+ args.colIndex = c;
4374
4398
  if(r < firstFullRow) {
4375
- this._requestScroll(args, c, r);
4399
+ _preventDefault(args.event);
4400
+ this._requestScroll(args);
4376
4401
  return;
4377
4402
  } else {
4378
4403
  let cell = section.getCell(c, r);
4379
- if(focusCell(cell)) {
4380
- if(args.event) {
4381
- args.event.preventDefault();
4382
- }
4404
+ if(this._focusCell(cell, args)) {
4405
+ _preventDefault(args.event);
4383
4406
  return;
4384
4407
  }
4385
4408
  }
@@ -4387,15 +4410,18 @@ Grid.prototype._focusPrevCellContent = function(args) {
4387
4410
  startIdx = len - 1;
4388
4411
  }
4389
4412
 
4390
- if(args.validContent) { // The current focus on the last focusable content
4391
- this._grid.getHiddenInput(true).focus();
4392
- }
4413
+ // The current focus on the last focusable content
4414
+ this._grid.getHiddenInput(true).focus();
4393
4415
  };
4394
4416
 
4395
4417
  /** @private
4396
4418
  * @param {Object} e
4397
4419
  */
4398
4420
  Grid.prototype._onTabNavigation = function(e) {
4421
+ if(this._focusingArgs) {
4422
+ return; // Cannot do another tab navigation while waiting for scrolling
4423
+ }
4424
+
4399
4425
  let colDefs = this.getColumnDefinitions();
4400
4426
  let colCount = colDefs.length;
4401
4427
 
@@ -4410,19 +4436,8 @@ Grid.prototype._onTabNavigation = function(e) {
4410
4436
  return;
4411
4437
  }
4412
4438
 
4413
- this._scrolledRow = -1; // Reset the scroll loop protector
4414
4439
  let keyEvt = e.event;
4415
4440
  let pos = this.getRelativePosition(keyEvt);
4416
- let validContent = true;
4417
- let activeElement = e.activeElement;
4418
- if(activeElement) {
4419
- validContent = !activeElement.classList.contains("valigner");
4420
- }
4421
-
4422
- if(validContent) {
4423
- let content = pos["cell"] ? pos["cell"].getContent() : null;
4424
- validContent = isFocusableContent(content);
4425
- }
4426
4441
  let startingRowIndex = pos["rowIndex"];
4427
4442
  if(e.onTheEdge) {
4428
4443
  let viewInfo = this._grid.getVerticalViewInfo();
@@ -4434,7 +4449,7 @@ Grid.prototype._onTabNavigation = function(e) {
4434
4449
  colIndex: pos["colIndex"],
4435
4450
  rowIndex: startingRowIndex,
4436
4451
  focusableColIndices: focusableColIndices,
4437
- validContent: validContent
4452
+ activeElement: e.activeElement
4438
4453
  };
4439
4454
 
4440
4455
  if(keyEvt.shiftKey) {
@@ -4444,5 +4459,15 @@ Grid.prototype._onTabNavigation = function(e) {
4444
4459
  }
4445
4460
  };
4446
4461
 
4462
+ /** @public
4463
+ * @ignore
4464
+ * @return {!Object}
4465
+ */
4466
+ Grid.prototype._getEventHandlers = function() {
4467
+ return {
4468
+ "tabNavigation": this._onTabNavigation
4469
+ };
4470
+ };
4471
+
4447
4472
  export { Grid };
4448
4473
  export default Grid;
@@ -417,28 +417,31 @@ AutoTooltipPlugin.prototype._updateNonContentSection = function (section, colInd
417
417
  var elem = cell.getContent();
418
418
  if(!elem) { return false; }
419
419
 
420
- // Set tooltip only if text's length is longer than column width.
421
- var tooltip = cell.getAttribute("tooltip") || cell.getTooltip();
420
+ var tooltipInfo = cell.getTooltipInfo();
421
+ if(tooltipInfo) {
422
+ if(tooltipInfo["userTooltip"] != null ||
423
+ tooltipInfo["groupHeaderDefault"] != null ||
424
+ tooltipInfo["columnDefault"] != null) {
425
+
426
+ cell.setTooltipInfo("clippedText", false);
427
+ cell.removeAttribute("ef-title");
428
+ continue;
429
+ }
430
+ }
422
431
 
432
+ // Set tooltip only if text's length is longer than column width.
423
433
  var sw = elem.scrollWidth;
424
434
  if(sw && sw > elem.offsetWidth) {
425
- if(!tooltip) {
426
- tooltip = cell.getTextContent(); // TODO: Allow custom tooltip text
427
- cell._autoTooltip = true;
428
- }
429
- } else {
430
- if(cell._autoTooltip) {
431
- tooltip = "";
432
- cell._autoTooltip = false;
433
- }
434
- }
435
+ cell.setTooltipInfo("clippedText", true);
435
436
 
436
- cell.setTooltip(tooltip); // TODO: Avoiding using getter and setter in the same loop
437
- if(tooltip) {
438
- cell.setAttribute("ef-title", tooltip); // to make sure ef-title value will actually change
437
+ var tooltip = cell.getTextContent();
438
+ cell.setTooltipInfo("clippedTextTooltip", tooltip);
439
+ cell.setAttribute("ef-title", tooltip);
439
440
  } else {
441
+ cell.setTooltipInfo("clippedText", false);
440
442
  cell.removeAttribute("ef-title");
441
443
  }
444
+ cell.updateTooltip();
442
445
  }
443
446
  return true;
444
447
  };
@@ -516,6 +516,9 @@ ColumnGroupingPlugin.prototype._applyGrouping = function () {
516
516
  cell.removeClass("no-sort");
517
517
  cell.removeClass("selected-group");
518
518
  cell.removeAttribute("group-id");
519
+ cell.setTooltipInfo("groupHeaderDefault", false);
520
+ cell.setTooltipInfo("groupHeaderTooltip", null);
521
+ cell.updateTooltip();
519
522
  }
520
523
  }
521
524
  }
@@ -909,7 +912,9 @@ ColumnGroupingPlugin.prototype._renderGroup = function(groupDef, section) {
909
912
  if(cell) {
910
913
  // Overide the defaults
911
914
  cell.setStyle("text-align", groupDef["alignment"] || "");
912
- cell.setTooltip(ColumnGroupingPlugin._getTooltip(groupDef));
915
+ cell.setTooltipInfo("groupHeaderDefault", groupDef["tooltip"]);
916
+ cell.setTooltipInfo("groupHeaderTooltip", ColumnGroupingPlugin._getTooltip(groupDef));
917
+ cell.updateTooltip();
913
918
  cell.setContent(groupDef["name"] || groupDef["title"]);
914
919
 
915
920
  // Additional cell settings must be removed in the _applyGrouping() method
@@ -73,8 +73,6 @@ declare class RowDraggingPlugin extends GridPlugin {
73
73
 
74
74
  public setJETDragContent(content: any): void;
75
75
 
76
- public setJETDragContent(content: any): void;
77
-
78
76
  }
79
77
 
80
78
  export default RowDraggingPlugin;