@refinitiv-ui/efx-grid 6.0.116 → 6.0.117

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.
@@ -10817,7 +10817,209 @@ LayoutGrid._proto = LayoutGrid.prototype;
10817
10817
  /* harmony default export */ const grid_LayoutGrid = (LayoutGrid);
10818
10818
 
10819
10819
 
10820
+ ;// CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/Color.js
10821
+ /** @namespace */
10822
+ let Color = {};
10823
+
10824
+ /** @private
10825
+ * @constant
10826
+ * @type {RegExp}
10827
+ */
10828
+ const NumRegExp = /\d+/g;
10829
+
10830
+ /** Convert CSS rgb or rgba formats to CSS hex color string (with # prefix)
10831
+ * @public
10832
+ * @param {string} rgbCode RGB values without # prefix
10833
+ * @return {string} RGB in hex code (with # prefix)
10834
+ * @example
10835
+ * rgb2Hex("rgb(255, 255, 0)"); // "#FFFF00"
10836
+ * rgb2Hex("rgba(255, 255, 0, 1)"); // "#FFFF00"
10837
+ * rgb2Hex("255 255.0"); // "#FFFF00"
10838
+ * rgb2Hex("#FFFF00"); // "#FFFF00"
10839
+ * rgb2Hex("#1a1a1a"); // "#1a1a1a"
10840
+ * rgb2Hex("2552550"); // "2552550"
10841
+ * rgb2Hex("invalid"); // "invalid"
10842
+ * rgb2Hex(null); // ""
10843
+ */
10844
+ let rgb2Hex = function (rgbCode) {
10845
+ if(!rgbCode || typeof rgbCode !== "string") {
10846
+ return "";
10847
+ }
10848
+ if(rgbCode.charAt(0) === "#") {
10849
+ return rgbCode;
10850
+ }
10851
+ let rgb = rgbCode.match(NumRegExp);
10852
+ if(!rgb || rgb.length < 3) {
10853
+ return rgbCode;
10854
+ }
10855
+
10856
+ let hex = "#";
10857
+ for(let i = 0; i < 3; i++) {
10858
+ let num = +rgb[i];
10859
+ if(!(num >= 16)) { // Handle NaN case
10860
+ hex += "0";
10861
+ }
10862
+ hex += (num) ? num.toString(16).toUpperCase() : "0";
10863
+ }
10864
+ return hex;
10865
+ };
10866
+
10867
+ /** @public
10868
+ * @function
10869
+ * @param {Array.<number>} triplet
10870
+ * @return {string} resultColor
10871
+ */
10872
+ let num2Hex = function (triplet) {
10873
+ let rgb = triplet[2] | (triplet[1] << 8) | (triplet[0] << 16);
10874
+ return ("#" + (0x1000000 + rgb).toString(16).slice(1));
10875
+ };
10876
+ /** Note that Chrome, IE, and Firefox store color in rgb representation.
10877
+ * @public
10878
+ * @function
10879
+ * @param {Array.<number>} triplet
10880
+ * @return {string} Color string in RGB represetation (e.g. rgb(100, 44, 1))
10881
+ */
10882
+ let num2Rgb = function (triplet) {
10883
+ return "rgb(" + triplet[0] + ", " + triplet[1] + ", " + triplet[2] + ")";
10884
+ };
10885
+ /** @public
10886
+ * @function
10887
+ * @param {string} hex
10888
+ * @return {Array.<number>} Array of size 3 which contains [red, green, blue]
10889
+ */
10890
+ let hex2Num = function (hex) {
10891
+ let hexInt = parseInt(hex.replace(/[^0-9A-F]/gi, ""), 16);
10892
+ let r = (hexInt >> 16) & 255;
10893
+ let g = (hexInt >> 8) & 255;
10894
+ let b = hexInt & 255;
10895
+ return [r, g, b];
10896
+ };
10897
+ /** @public
10898
+ * @function
10899
+ * @param {string} hex Color string with leading # character (e.g. #FFAA00)
10900
+ * @return {string} Color string in RGB represetation (e.g. rgb(100, 44, 1))
10901
+ */
10902
+ let hex2Rgb = function (hex) {
10903
+ if(hex) {
10904
+ let hexInt = parseInt(hex.replace(/[^0-9A-F]/gi, ""), 16);
10905
+ let r = (hexInt >> 16) & 255;
10906
+ let g = (hexInt >> 8) & 255;
10907
+ let b = hexInt & 255;
10908
+ return "rgb(" + r + ", " + g + ", " + b + ")";
10909
+ }
10910
+ return "";
10911
+ };
10912
+
10913
+ /** @public
10914
+ * @function
10915
+ * @param {number} color A color component (e.g., R, G, or B) with value between 0 and 255 (inclusive)
10916
+ * @return {number} Normalized luminance value between 0 and 1
10917
+ */
10918
+ let getColorLuminance = function (color) {
10919
+ if(!color || color < 0) {
10920
+ return 0;
10921
+ }
10922
+ if(color >= 255) {
10923
+ return 1;
10924
+ }
10925
+ let normalizedColor = color / 255;
10926
+ if(normalizedColor <= 0.03928) {
10927
+ return normalizedColor / 12.92;
10928
+ }
10929
+ return Math.pow((normalizedColor + 0.055) / 1.055, 2.4);
10930
+ };
10931
+ /** The relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white (https://www.w3.org/TR/WCAG20/#relativeluminancedef)
10932
+ * @public
10933
+ * @function
10934
+ * @param {Array.<number>} triplet
10935
+ * @return {number} Normalized value between 0 and 1
10936
+ */
10937
+ let getRelativeLuminance = function (triplet) {
10938
+ let R = getColorLuminance(triplet[0]);
10939
+ let G = getColorLuminance(triplet[1]);
10940
+ let B = getColorLuminance(triplet[2]);
10941
+
10942
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
10943
+ };
10944
+ /** @public
10945
+ * @function
10946
+ * @param {number} lumin1
10947
+ * @param {number} lumin2
10948
+ * @return {number} Contrast ratios can range from 1 to 21 (commonly written 1:1 to 21:1).
10949
+ */
10950
+ let getContrastRatio = function (lumin1, lumin2) {
10951
+ if(lumin1 === lumin2) {
10952
+ return 1;
10953
+ }
10954
+ let darker = lumin1;
10955
+ let lighter = lumin2;
10956
+
10957
+ if(lumin1 > lumin2) {
10958
+ lighter = lumin1;
10959
+ darker = lumin2;
10960
+ }
10961
+ return (lighter + 0.05) / (darker + 0.05);
10962
+ };
10963
+ /** @public
10964
+ * @function
10965
+ * @param {Array.<number>} triplet
10966
+ * @return {string} white or black color in hex code
10967
+ */
10968
+ let getContrastColor = function (triplet) {
10969
+ let luminance = getRelativeLuminance(triplet);
10970
+ let contrastW = getContrastRatio(1, luminance);
10971
+ let contrastB = getContrastRatio(0, luminance);
10972
+
10973
+ if (contrastB >= contrastW) { // Brighter color has more impact to human eye than the darker color
10974
+ return "#000000";
10975
+ }
10976
+ return "#ffffff";
10977
+ };
10978
+
10979
+ /** Blend two colors into single color with the specified ratio
10980
+ * @public
10981
+ * @function
10982
+ * @param {string} baseColor
10983
+ * @param {string} maxColor
10984
+ * @param {number} ratio [0, 1]
10985
+ * @return {Array.<number>} resultColor
10986
+ */
10987
+ let blendColor = function (baseColor, maxColor, ratio) { // This can be optimized further
10988
+ if (ratio > 1) {
10989
+ ratio = 1;
10990
+ } else if(ratio < 0) {
10991
+ ratio = 0;
10992
+ }
10993
+
10994
+ let baseColorTriplet = hex2Num(baseColor);
10995
+ let maxColorTriplet = hex2Num(maxColor);
10996
+ let blendResult = [];
10997
+ for (let i = 0; i < 3; ++i) {
10998
+ let gap = (maxColorTriplet[i] - baseColorTriplet[i]) * ratio;
10999
+ blendResult.push(baseColorTriplet[i] + gap);
11000
+ }
11001
+
11002
+ return blendResult;
11003
+ };
11004
+
11005
+
11006
+ Color.rgb2Hex = rgb2Hex;
11007
+ Color.num2Hex = num2Hex;
11008
+ Color.num2Rgb = num2Rgb;
11009
+ Color.hex2Num = hex2Num;
11010
+ Color.hex2Rgb = hex2Rgb;
11011
+ Color.getColorLuminance = getColorLuminance;
11012
+ Color.getRelativeLuminance = getRelativeLuminance;
11013
+ Color.getContrastRatio = getContrastRatio;
11014
+ Color.getContrastColor = getContrastColor;
11015
+ Color.blendColor = blendColor;
11016
+
11017
+ /* harmony default export */ const es6_Color = ((/* unused pure expression or super */ null && (Color)));
11018
+
11019
+
10820
11020
  ;// CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/Util.js
11021
+
11022
+
10821
11023
  /** @namespace */
10822
11024
  let Util_Util = {};
10823
11025
 
@@ -11273,43 +11475,6 @@ let nestedObjectToArray = function (obj, ary) {
11273
11475
  return ary;
11274
11476
  };
11275
11477
 
11276
- /** Convert CSS rgb or rgba formats to CSS hex color string (# prefix)
11277
- * @public
11278
- * @param {string} rgbCode
11279
- * @return {string}
11280
- * @example
11281
- * rgb2Hex("rgb(255, 255, 0)"); // "#FFFF00"
11282
- * rgb2Hex("rgba(255, 255, 0, 1)"); // "#FFFF00"
11283
- * rgb2Hex("255 255.0"); // "#FFFF00"
11284
- * rgb2Hex("#FFFF00"); // "#FFFF00"
11285
- * rgb2Hex("#1a1a1a"); // "#1a1a1a"
11286
- * rgb2Hex("2552550"); // "2552550"
11287
- * rgb2Hex("invalid"); // "invalid"
11288
- * rgb2Hex(null); // ""
11289
- */
11290
- let rgb2Hex = function (rgbCode) {
11291
- if(!rgbCode || typeof rgbCode !== "string") {
11292
- return "";
11293
- }
11294
- if(rgbCode.charAt(0) === "#") {
11295
- return rgbCode;
11296
- }
11297
- let rgb = rgbCode.match(/\d+/g);
11298
- if(!rgb || rgb.length < 3) {
11299
- return rgbCode;
11300
- }
11301
-
11302
- let hex = "#";
11303
- for(let i = 0; i < 3; i++) {
11304
- let num = +rgb[i];
11305
- if(!(num >= 16)) { // Handle NaN case
11306
- hex += "0";
11307
- }
11308
- hex += (num) ? num.toString(16).toUpperCase() : "0";
11309
- }
11310
- return hex;
11311
- };
11312
-
11313
11478
  /** transform data to tab seperated value
11314
11479
  * @public
11315
11480
  * @param {*} data
@@ -11747,9 +11912,9 @@ GroupDefinitions.prototype.setGroup = function (groupId, groupDef) {
11747
11912
  if(curDef) { // Replace
11748
11913
  this.removeAllChildren(groupId);
11749
11914
  }
11750
- let parentDef = this._childToParent[groupId];
11751
- if(parentDef) {
11752
- newDef.parentId = parentDef.id;
11915
+ let parentId = this._childToParent[groupId];
11916
+ if(parentId) {
11917
+ newDef.parentId = parentId;
11753
11918
  }
11754
11919
  this._groupMap[groupId] = newDef;
11755
11920
 
@@ -25712,7 +25877,7 @@ Core_Core.prototype._hasPendingRowChange = false;
25712
25877
  * @return {string}
25713
25878
  */
25714
25879
  Core_Core.getVersion = function () {
25715
- return "5.1.116";
25880
+ return "5.1.117";
25716
25881
  };
25717
25882
  /** {@link ElementWrapper#dispose}
25718
25883
  * @override
@@ -30519,13 +30684,20 @@ Core_Core.prototype.getColumnIndex = function (colRef) {
30519
30684
  return colRef;
30520
30685
  } else if(colRef) {
30521
30686
  let str = colRef;
30687
+ let indexByField = -1;
30522
30688
  let colCount = this.getColumnCount();
30523
30689
  for(let c = 0; c < colCount; ++c) {
30524
30690
  let colDef = this._getColumnDef(c);
30525
- if(str === colDef["id"] || str === colDef["field"]) {
30691
+ if(str === colDef["id"]){
30526
30692
  return c;
30527
30693
  }
30694
+ if(str === colDef["field"]) { // In case colId and field are the same, use colId first and field as a fallback
30695
+ if(indexByField < 0) {
30696
+ indexByField = c;
30697
+ }
30698
+ }
30528
30699
  }
30700
+ return indexByField;
30529
30701
  }
30530
30702
  return -1;
30531
30703
  };