@refinitiv-ui/efx-grid 6.0.108 → 6.0.110

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.
@@ -175,6 +175,10 @@ declare class Core extends ElementWrapper {
175
175
 
176
176
  public setColumnStyle(colIndex: number, style: string, value: string, opt_type?: string|null): void;
177
177
 
178
+ public getColumnBackgroundColor(colIndex: number): string;
179
+
180
+ public setColumnBackgroundColor(colIndex: number, color?: string|null): void;
181
+
178
182
  public enableColumnClass(colIndex: number, clsName: string, enabled?: boolean|null, opt_type?: string|null): boolean;
179
183
 
180
184
  public hasColumnClass(colIndex: number, clsName: string, opt_type?: string|null): boolean;
@@ -127,7 +127,6 @@ let Core = function (opt_initializer) {
127
127
  _t._onRowHightlighted = _t._onRowHightlighted.bind(_t);
128
128
  _t._onGridClicked = _t._onGridClicked.bind(_t);
129
129
  _t._onKeyDown = _t._onKeyDown.bind(_t);
130
- _t._onKeyUp = _t._onKeyUp.bind(_t);
131
130
 
132
131
  _t._onWindowResize = _t._onWindowResize.bind(_t);
133
132
  _t._onSectionDataChanged = _t._onSectionDataChanged.bind(_t);
@@ -215,7 +214,6 @@ let Core = function (opt_initializer) {
215
214
 
216
215
 
217
216
  _t._element.addEventListener("keydown", _t._onKeyDown);
218
- _t._element.addEventListener("keyup", _t._onKeyUp);
219
217
  if (Util.isMobile || Util.isTouchDevice) {
220
218
  _t._element.addEventListener("touchmove", _t._onMouseMove, false);
221
219
  } else {
@@ -622,7 +620,7 @@ Core.prototype._hasPendingRowChange = false;
622
620
  * @return {string}
623
621
  */
624
622
  Core.getVersion = function () {
625
- return "5.1.110";
623
+ return "5.1.113";
626
624
  };
627
625
  /** {@link ElementWrapper#dispose}
628
626
  * @override
@@ -765,6 +763,9 @@ Core.prototype.getConfigObject = function (gridOptions) {
765
763
  if (columnDef["rightPinned"]) {
766
764
  column["rightPinned"] = columnDef["rightPinned"];
767
765
  }
766
+ if (columnDef["backgroundColor"]) {
767
+ column["backgroundColor"] = columnDef["backgroundColor"];
768
+ }
768
769
  }
769
770
 
770
771
  // It will be overwrite in rt-grid or atlas-blotter
@@ -2053,6 +2054,10 @@ Core.prototype._deserializeColumn = function (index, jsonObj) {
2053
2054
  if (value != null) {
2054
2055
  colDef["rightPinned"] = value ? true : false;
2055
2056
  }
2057
+ value = jsonObj["backgroundColor"];
2058
+ if (value != null) {
2059
+ this.setColumnBackgroundColor(index, value);
2060
+ }
2056
2061
 
2057
2062
  this.setColumnRenderingHandler(index, jsonObj["renderingHandler"]);
2058
2063
  this.setColumnDataBindingHandler(index, jsonObj["dataBindingHandler"]);
@@ -2312,6 +2317,56 @@ Core.prototype.setColumnStyle = function (colIndex, style, value, opt_type) {
2312
2317
  }
2313
2318
  };
2314
2319
 
2320
+ /** @public
2321
+ * @param {number} colIndex
2322
+ * @return {string}
2323
+ */
2324
+ Core.prototype.getColumnBackgroundColor = function(colIndex) {
2325
+ let colDef = this._getColumnDef(colIndex);
2326
+ return colDef["backgroundColor"] || "";
2327
+ };
2328
+ /** @public
2329
+ * @param {number} colIndex
2330
+ * @param {string=} color
2331
+ */
2332
+ Core.prototype.setColumnBackgroundColor = function(colIndex, color) {
2333
+ if(colIndex == null || typeof colIndex !== "number") {
2334
+ return;
2335
+ }
2336
+
2337
+ let colDef = this._getColumnDef(colIndex);
2338
+ if(colDef["backgroundColor"] === color) {
2339
+ return;
2340
+ }
2341
+
2342
+ colDef["backgroundColor"] = color;
2343
+ color = color != null ? color : "";
2344
+
2345
+ let sectionCount = this._settings.length;
2346
+ for(let i = 0; i < sectionCount; ++i) {
2347
+ let settings = this._settings[i];
2348
+ let section = settings.getSection();
2349
+ if(!section) {
2350
+ continue;
2351
+ }
2352
+
2353
+ if(settings.getType() !== "content") {
2354
+ let rowCount = section.getRowCount();
2355
+ for(let r = 0; r < rowCount; r++) {
2356
+ let cellSpan = section.getCellColSpan(colIndex, r);
2357
+ if(cellSpan > 1) { continue; }
2358
+ let cell = section.getCell(colIndex, r);
2359
+ if(cell) {
2360
+ cell.setStyle("backgroundColor", color);
2361
+ }
2362
+ }
2363
+ } else {
2364
+ let column = section.getColumn(colIndex);
2365
+ column.setStyle("backgroundColor", color);
2366
+ }
2367
+ }
2368
+ };
2369
+
2315
2370
  /** @public
2316
2371
  * @param {number} colIndex
2317
2372
  * @param {string} clsName
@@ -4971,6 +5026,9 @@ Core.prototype._dispatchRowExpansionBinding = function (e) {
4971
5026
  }
4972
5027
 
4973
5028
  let ctxRow = section.getContextRow(r);
5029
+ if(!ctxRow) {
5030
+ continue; // The row may have been pushed out of view due to row count or height changed during the binding
5031
+ }
4974
5032
  let parentId = dataView.getExpansionParentByRowId(rowId);
4975
5033
  if(parentId) { // dispatch to render row expansion
4976
5034
  e["originalRowData"] = dataView.getRowData(parentId);
@@ -5463,31 +5521,9 @@ Core.prototype._onKeyDown = function (e) {
5463
5521
 
5464
5522
  if(onTheEdge && !e.defaultPrevented) {
5465
5523
  if(onTheEdge > 0 && e.shiftKey) {
5466
- this._firstHiddenInput.focus(); // jump to the top
5467
- e.preventDefault();
5524
+ this._firstHiddenInput.focus(); // jump to the top and move out of grid
5468
5525
  } else if(onTheEdge < 0 && !e.shiftKey) {
5469
- this._lastHiddenInput.focus(); // skip to the end
5470
- e.preventDefault();
5471
- }
5472
- }
5473
- };
5474
- /** @private
5475
- * @param {Object} e
5476
- */
5477
- Core.prototype._onKeyUp = function (e) {
5478
- if(!_isTabCommand(e)) {
5479
- return;
5480
- }
5481
- var activeElem = _getActiveElement(this._element);
5482
- if(e.shiftKey) {
5483
- if(activeElem === this._lastHiddenInput) {
5484
- this._firstHiddenInput.focus();
5485
- e.preventDefault();
5486
- }
5487
- } else {
5488
- if(activeElem === this._firstHiddenInput) {
5489
- this._lastHiddenInput.focus();
5490
- e.preventDefault();
5526
+ this._lastHiddenInput.focus(); // skip to the end and move out of grid
5491
5527
  }
5492
5528
  }
5493
5529
  };
package/lib/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.108" };
3
+ window.EFX_GRID = { version: "6.0.110" };
@@ -17,6 +17,7 @@ import ColumnDraggingPlugin from "../../column-dragging/es6/ColumnDragging.js";
17
17
  import cssStr from "../../core/es6/tr-grid-theme.js";
18
18
 
19
19
  const coreGridStyle = css`${unsafeCSS(cssStr)}`;
20
+ let preloadPromise = null;
20
21
 
21
22
  /**
22
23
  * @typedef {Object} Grid~Config
@@ -89,7 +90,18 @@ class Grid extends ResponsiveElement {
89
90
 
90
91
  this._onResizeHandler = this._onResizeHandler.bind(this);
91
92
  this.resizedCallback = this.resizedCallback.bind(this);
93
+ this._preloadElfIcon = this._preloadElfIcon.bind(this);
92
94
  }
95
+
96
+ /**
97
+ * @protected
98
+ * @ignore
99
+ */
100
+ firstUpdated() {
101
+ // pre load elf svg icon
102
+ this._preloadElfIcon();
103
+ }
104
+
93
105
  /**
94
106
  * @protected
95
107
  * @ignore
@@ -221,7 +233,7 @@ class Grid extends ResponsiveElement {
221
233
  /**
222
234
  * @private
223
235
  */
224
- async _configChange() {
236
+ _configChange() {
225
237
  let gridElem;
226
238
  if (this.api) {
227
239
  // Remove old grid element and Realtime Grid's API
@@ -308,15 +320,6 @@ class Grid extends ResponsiveElement {
308
320
  // Inject icons and theme name
309
321
  ElfUtil.injectIcons(options, this);
310
322
 
311
- // pre load elf svg icon
312
- const { preloadd } = await import("@refinitiv-ui/elements/icon");
313
- if (preloadd) {
314
- const iconList = ElfUtil.prepareIconPreloading();
315
- if (iconList) {
316
- preload(...iconList);
317
- }
318
- }
319
-
320
323
  if (ElfUtil.isHaloTheme()) {
321
324
  if (options.borders == null) {
322
325
  options.borders = false;
@@ -369,6 +372,25 @@ class Grid extends ResponsiveElement {
369
372
  }
370
373
  }
371
374
 
375
+ /**
376
+ * @private
377
+ * Load preload icon for element framework v7
378
+ */
379
+ _preloadElfIcon() {
380
+ // pre load elf svg icon
381
+ if(!preloadPromise) { // import only one time
382
+ preloadPromise = import("@refinitiv-ui/elements/icon").then(function(e) {
383
+ let preload = e.preload;
384
+ if (preloadd) {
385
+ const iconList = ElfUtil.prepareIconPreloading();
386
+ if (iconList) {
387
+ preload(...iconList);
388
+ }
389
+ }
390
+ }).catch(function(){});
391
+ }
392
+ }
393
+
372
394
  /** Called when the element's size has changed
373
395
  * @public
374
396
  * @return {void}