@refinitiv-ui/efx-grid 6.0.0 → 6.0.3

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 (151) hide show
  1. package/lib/column-format-dialog/lib/column-format-dialog.d.ts +13 -1
  2. package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +15 -2
  3. package/lib/column-selection-dialog/lib/column-selection-dialog.js +226 -23
  4. package/lib/column-selection-dialog/themes/halo/dark/column-selection-dialog.js +1 -1
  5. package/lib/column-selection-dialog/themes/halo/dark/es5/all-elements.js +1 -1
  6. package/lib/column-selection-dialog/themes/halo/light/column-selection-dialog.js +1 -1
  7. package/lib/column-selection-dialog/themes/halo/light/es5/all-elements.js +1 -1
  8. package/lib/core/dist/core.css +1 -1
  9. package/lib/core/dist/core.js +10158 -7908
  10. package/lib/core/dist/core.min.js +1 -1
  11. package/lib/core/es6/data/DataTable.js +32 -10
  12. package/lib/core/es6/data/DataView.d.ts +16 -7
  13. package/lib/core/es6/data/DataView.js +172 -49
  14. package/lib/core/es6/data/Segment.d.ts +2 -0
  15. package/lib/core/es6/data/Segment.js +7 -0
  16. package/lib/core/es6/data/WrappedView.d.ts +289 -0
  17. package/lib/core/es6/data/WrappedView.js +1319 -0
  18. package/lib/core/es6/grid/Core.d.ts +13 -0
  19. package/lib/core/es6/grid/Core.js +406 -160
  20. package/lib/core/es6/grid/ILayoutGrid.d.ts +8 -0
  21. package/lib/core/es6/grid/ILayoutGrid.js +45 -2
  22. package/lib/core/es6/grid/LayoutGrid.d.ts +10 -1
  23. package/lib/core/es6/grid/LayoutGrid.js +257 -82
  24. package/lib/core/es6/grid/VirtualizedLayoutGrid.d.ts +10 -1
  25. package/lib/core/es6/grid/VirtualizedLayoutGrid.js +316 -24
  26. package/lib/core/es6/grid/components/Column.js +8 -2
  27. package/lib/core/es6/grid/components/HScrollbar.d.ts +4 -0
  28. package/lib/core/es6/grid/components/HScrollbar.js +20 -4
  29. package/lib/core/es6/grid/util/TrackLayout.d.ts +1 -1
  30. package/lib/core/es6/grid/util/TrackLayout.js +2 -3
  31. package/lib/core/es6/tr-grid-theme.js +1 -1
  32. package/lib/filter-dialog/lib/checkbox-list.d.ts +13 -1
  33. package/lib/filter-dialog/lib/filter-dialog.d.ts +13 -1
  34. package/lib/filter-dialog/lib/filter-dialog.js +24 -9
  35. package/lib/grid/lib/efx-grid.d.ts +27 -8
  36. package/lib/grid/lib/efx-grid.js +114 -115
  37. package/lib/grid/themes/base.less +5 -3
  38. package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
  39. package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
  40. package/lib/grid/themes/halo/efx-grid.less +69 -32
  41. package/lib/grid/themes/halo/light/efx-grid.js +1 -1
  42. package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
  43. package/lib/grid/themes/solar/charcoal/efx-grid.js +1 -1
  44. package/lib/grid/themes/solar/charcoal/es5/all-elements.js +1 -1
  45. package/lib/grid/themes/solar/pearl/efx-grid.js +1 -1
  46. package/lib/grid/themes/solar/pearl/es5/all-elements.js +1 -1
  47. package/lib/index.d.ts +56 -56
  48. package/lib/index.js +56 -56
  49. package/lib/row-segmenting/es6/RowSegmenting.d.ts +1 -0
  50. package/lib/row-segmenting/es6/RowSegmenting.js +43 -12
  51. package/lib/rt-grid/dist/rt-grid.js +10293 -7865
  52. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  53. package/lib/rt-grid/es6/ColumnDefinition.d.ts +4 -1
  54. package/lib/rt-grid/es6/ColumnDefinition.js +3 -0
  55. package/lib/rt-grid/es6/Grid.d.ts +14 -7
  56. package/lib/rt-grid/es6/Grid.js +244 -75
  57. package/lib/rt-grid/es6/RowDefinition.d.ts +4 -1
  58. package/lib/rt-grid/es6/RowDefinition.js +52 -2
  59. package/lib/tr-grid-cell-selection/es6/CellSelection.d.ts +1 -1
  60. package/lib/tr-grid-cell-selection/es6/CellSelection.js +53 -40
  61. package/lib/tr-grid-checkbox/es6/Checkbox.d.ts +4 -1
  62. package/lib/tr-grid-checkbox/es6/Checkbox.js +41 -14
  63. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +1 -0
  64. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +10 -0
  65. package/lib/tr-grid-column-selection/es6/ColumnSelection.d.ts +5 -1
  66. package/lib/tr-grid-column-selection/es6/ColumnSelection.js +226 -4
  67. package/lib/tr-grid-column-stack/es6/ColumnStack.js +3 -0
  68. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +6 -1
  69. package/lib/tr-grid-filter-input/es6/FilterInput.d.ts +4 -2
  70. package/lib/tr-grid-filter-input/es6/FilterInput.js +73 -10
  71. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.d.ts +1 -1
  72. package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +13 -1
  73. package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +1 -3
  74. package/lib/tr-grid-row-dragging/es6/RowDragging.js +165 -70
  75. package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +2 -0
  76. package/lib/tr-grid-row-filtering/es6/RowFiltering.js +88 -33
  77. package/lib/tr-grid-row-grouping/es6/RowGrouping.js +41 -31
  78. package/lib/tr-grid-row-selection/es6/RowSelection.d.ts +13 -9
  79. package/lib/tr-grid-row-selection/es6/RowSelection.js +220 -29
  80. package/lib/tr-grid-rowcoloring/es6/RowColoring.d.ts +2 -0
  81. package/lib/tr-grid-rowcoloring/es6/RowColoring.js +36 -0
  82. package/lib/tr-grid-util/es6/CellPainter.d.ts +8 -8
  83. package/lib/tr-grid-util/es6/Conflator.d.ts +2 -2
  84. package/lib/tr-grid-util/es6/CoralItems.d.ts +1 -1
  85. package/lib/tr-grid-util/es6/DateTime.d.ts +4 -4
  86. package/lib/tr-grid-util/es6/Delay.d.ts +1 -1
  87. package/lib/tr-grid-util/es6/Dom.d.ts +4 -4
  88. package/lib/tr-grid-util/es6/ElementWrapper.d.ts +1 -1
  89. package/lib/tr-grid-util/es6/ElfDate.d.ts +3 -3
  90. package/lib/tr-grid-util/es6/ElfUtil.d.ts +4 -4
  91. package/lib/tr-grid-util/es6/EventDispatcher.d.ts +1 -1
  92. package/lib/tr-grid-util/es6/ExpanderIcon.js +2 -2
  93. package/lib/tr-grid-util/es6/FieldFormatter.d.ts +1 -1
  94. package/lib/tr-grid-util/es6/FilterBuilder.d.ts +5 -5
  95. package/lib/tr-grid-util/es6/GridPlugin.d.ts +3 -3
  96. package/lib/tr-grid-util/es6/MouseDownTrait.d.ts +1 -1
  97. package/lib/tr-grid-util/es6/MultiTableManager.d.ts +10 -2
  98. package/lib/tr-grid-util/es6/MultiTableManager.js +164 -57
  99. package/lib/tr-grid-util/es6/PercentBar.d.ts +1 -1
  100. package/lib/tr-grid-util/es6/Perf.d.ts +4 -4
  101. package/lib/tr-grid-util/es6/Popup.d.ts +2 -2
  102. package/lib/tr-grid-util/es6/RequestQueue.d.ts +1 -1
  103. package/lib/tr-grid-util/es6/RowPainter.d.ts +3 -0
  104. package/lib/tr-grid-util/es6/RowPainter.js +82 -20
  105. package/lib/tr-grid-util/es6/SubTable.d.ts +9 -9
  106. package/lib/tr-grid-util/es6/Table.d.ts +13 -13
  107. package/lib/tr-grid-util/es6/TextHighlighter.d.ts +3 -3
  108. package/lib/tr-grid-util/es6/TickCodes.d.ts +2 -2
  109. package/lib/tr-grid-util/es6/TouchProxy.d.ts +1 -1
  110. package/lib/tr-grid-util/es6/Util.d.ts +6 -6
  111. package/lib/tr-grid-util/es6/formula/Engine.d.ts +5 -5
  112. package/lib/tr-grid-util/es6/formula/Formula.d.ts +3 -3
  113. package/lib/tr-grid-util/es6/formula/RealtimeService.d.ts +1 -1
  114. package/lib/tr-grid-util/es6/jet/CollectionDict.d.ts +2 -2
  115. package/lib/tr-grid-util/es6/jet/DataGenerator.d.ts +4 -4
  116. package/lib/tr-grid-util/es6/jet/MockArchive.d.ts +1 -1
  117. package/lib/tr-grid-util/es6/jet/MockJET.d.ts +4 -4
  118. package/lib/tr-grid-util/es6/jet/MockQuotes.d.ts +11 -11
  119. package/lib/tr-grid-util/es6/jet/MockQuotes2.d.ts +7 -7
  120. package/lib/tr-grid-util/es6/jet/MockRTK.d.ts +1 -1
  121. package/lib/tr-grid-util/es6/jet/mockDataAPI.d.ts +1 -1
  122. package/lib/tr-grid-util/es6/jsx.d.ts +223 -0
  123. package/lib/types/es6/CellSelection.d.ts +1 -1
  124. package/lib/types/es6/Checkbox.d.ts +4 -1
  125. package/lib/types/es6/ColumnGrouping.d.ts +1 -0
  126. package/lib/types/es6/ColumnSelection.d.ts +5 -1
  127. package/lib/types/es6/Core/data/DataView.d.ts +16 -7
  128. package/lib/types/es6/Core/data/Segment.d.ts +2 -0
  129. package/lib/types/es6/Core/data/WrappedView.d.ts +289 -0
  130. package/lib/types/es6/Core/grid/Core.d.ts +13 -0
  131. package/lib/types/es6/Core/grid/ILayoutGrid.d.ts +8 -0
  132. package/lib/types/es6/Core/grid/LayoutGrid.d.ts +10 -1
  133. package/lib/types/es6/Core/grid/VirtualizedLayoutGrid.d.ts +10 -1
  134. package/lib/types/es6/Core/grid/components/HScrollbar.d.ts +4 -0
  135. package/lib/types/es6/Core/grid/util/TrackLayout.d.ts +1 -1
  136. package/lib/types/es6/FilterInput.d.ts +4 -2
  137. package/lib/types/es6/InCellEditing.d.ts +1 -1
  138. package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +4 -1
  139. package/lib/types/es6/RealtimeGrid/Grid.d.ts +15 -8
  140. package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +4 -1
  141. package/lib/types/es6/RowColoring.d.ts +2 -0
  142. package/lib/types/es6/RowDragging.d.ts +1 -3
  143. package/lib/types/es6/RowFiltering.d.ts +2 -0
  144. package/lib/types/es6/RowSegmenting.d.ts +1 -0
  145. package/lib/types/es6/RowSelection.d.ts +13 -9
  146. package/lib/types/es6/Zoom.d.ts +2 -1
  147. package/lib/types/es6/index.d.ts +3 -0
  148. package/lib/versions.json +19 -19
  149. package/lib/zoom/es6/Zoom.d.ts +2 -1
  150. package/lib/zoom/es6/Zoom.js +11 -4
  151. package/package.json +9 -2
@@ -143,7 +143,6 @@ var RowGroupingPlugin = function (options) {
143
143
  t._criteria = [];
144
144
  t._criteriaFuncs = [];
145
145
  t._hosts = [];
146
- t._indentSize = [0, 22, 37, 52, 67];
147
146
  t.config({ "rowGrouping": options });
148
147
  };
149
148
  Ext.inherits(RowGroupingPlugin, GridPlugin);
@@ -193,10 +192,14 @@ RowGroupingPlugin.prototype._headerColumn = -1; // Actual display column
193
192
  * @private
194
193
  */
195
194
  RowGroupingPlugin.prototype._headerColumnField = ''; // Actual display column field
196
- /** @type {!Array.<number>}
195
+ /** @type {Array.<number>}
197
196
  * @private
198
197
  */
199
- RowGroupingPlugin.prototype._indentSize = null;
198
+ RowGroupingPlugin.prototype._indentSizes = null;
199
+ /** @type {number}
200
+ * @private
201
+ */
202
+ RowGroupingPlugin.prototype._arrowSize = 9; // Solar theme's arrow size
200
203
  /** @type {boolean}
201
204
  * @private
202
205
  */
@@ -359,12 +362,8 @@ RowGroupingPlugin.prototype.getName = function () {
359
362
  * @param {Object} config
360
363
  */
361
364
  RowGroupingPlugin.prototype.beforeInit = function(elem, config) {
362
- // Set default indentSize here
363
365
  if (ElfUtil.isHaloTheme()) {
364
- // only for halo theme
365
- this._indentSize = [0, 30, 50, 70, 90];
366
- } else {
367
- this._indentSize = [0, 22, 37, 52, 67];
366
+ this._arrowSize = 18;
368
367
  }
369
368
  };
370
369
 
@@ -495,22 +494,24 @@ RowGroupingPlugin.prototype.config = function (options) {
495
494
  var indentSize = option.indentSize;
496
495
  if (indentSize != null) {
497
496
  if (typeof indentSize === "boolean") {
498
- if (!indentSize) {
499
- this._indentSize = [0];
497
+ if (indentSize) {
498
+ this._indentSizes = null; // Set to default
499
+ } else {
500
+ this._indentSizes = [0];
500
501
  } // TODO: Handle default case
501
502
  } else if (typeof indentSize === "number") {
502
- this._indentSize = new Array(5);
503
+ this._indentSizes = new Array(5);
503
504
  for (var j = 0; j < 5; j++) {
504
- this._indentSize[j] = indentSize * j;
505
+ this._indentSizes[j] = indentSize * j;
505
506
  }
506
507
  } else if (Array.isArray(indentSize)) {
507
- this._indentSize = indentSize;
508
+ this._indentSizes = indentSize;
508
509
  }
509
510
  }
510
511
  if (option.noCollapsible != null) {
511
512
  this._noCollapsible = !!option.noCollapsible;
512
513
  if (this._noCollapsible) {
513
- this._indentSize = [0]; // Content will not be indented
514
+ this._indentSizes = [0]; // Content will not be indented
514
515
  }
515
516
  }
516
517
  if (this._contentAsHeader || this._noCollapsible) { // contentAsHeader has higher priority than hiddenArrow
@@ -616,7 +617,9 @@ RowGroupingPlugin.prototype.getConfigObject = function (gridOptions) {
616
617
  if(this._autoGroupSorting) {
617
618
  extOptions.autoGroupSorting = this._autoGroupSorting;
618
619
  }
619
- extOptions.indentSize = this._indentSize;
620
+ if(this._indentSizes) {
621
+ extOptions.indentSize = this._indentSizes;
622
+ }
620
623
 
621
624
  if(this._colorTag != null) {
622
625
  extOptions.colorTag = this._colorTag;
@@ -1197,7 +1200,7 @@ RowGroupingPlugin.prototype._updateHeader = function (settings, firstRowIndex, l
1197
1200
  arg.rowData = this._rowGetter(dataSource.getRowData(rowId));
1198
1201
  arg.noIndent = false;
1199
1202
 
1200
- rowPainter.removeHeaderStyle(section, headerColumn, r);
1203
+ var contentHeaderGroup = rowsForContentHeader[rowId];
1201
1204
  var groupView = dataSource.getGroupByRowId(rowId);
1202
1205
  if (groupView) { // Header Render
1203
1206
  currentGroup = groupView;
@@ -1216,22 +1219,20 @@ RowGroupingPlugin.prototype._updateHeader = function (settings, firstRowIndex, l
1216
1219
  curGroupLevel = currentGroup.getGroupLevel();
1217
1220
  }
1218
1221
 
1219
- var grp = rowsForContentHeader[rowId];
1220
- if (grp || nonGroupListener) {
1222
+ if (contentHeaderGroup || nonGroupListener) {
1221
1223
  arg.dataSource = dataSource;
1222
1224
  arg.footerIndex = null;
1223
1225
  arg.groupId = null;
1224
1226
 
1225
- if (grp) {
1226
- arg.collapsed = grp.isCollapsed();
1227
- rowPainter.applyContentAsHeaderStyle(arg);
1227
+ if (contentHeaderGroup) {
1228
+ arg.collapsed = contentHeaderGroup.isCollapsed();
1228
1229
  }
1229
1230
 
1230
1231
  if (nonGroupListener) {
1231
1232
  arg.rowData = this._rowGetter(dataSource.getRowData(rowId));
1232
1233
  }
1233
1234
  }
1234
- if (grp) { // In contentHeader mode indent in contentHeader will same the parent header when group level 2
1235
+ if (contentHeaderGroup) { // In contentHeader mode indent in contentHeader will same the parent header when group level 2
1235
1236
  indentOffset = -2;
1236
1237
  } else {
1237
1238
  // In contentHeader mode with 1 level the content indent more than contentHeader 1
@@ -1243,7 +1244,7 @@ RowGroupingPlugin.prototype._updateHeader = function (settings, firstRowIndex, l
1243
1244
 
1244
1245
  arg.groupLevel = curGroupLevel;
1245
1246
 
1246
- var rowLevel;
1247
+ var rowLevel = 0;
1247
1248
  var nonGroupRow = this._autoGroupHiding && currentGroup.getGroupValue() == null && curGroupLevel === 1 && !this._contentAsHeader;
1248
1249
  arg.nonGroupRow = nonGroupRow;
1249
1250
 
@@ -1253,15 +1254,20 @@ RowGroupingPlugin.prototype._updateHeader = function (settings, firstRowIndex, l
1253
1254
  rowLevel = curGroupLevel - 1;
1254
1255
  } else { // content
1255
1256
  rowLevel = curGroupLevel + indentOffset; // content have indent more than header 1
1256
- if(rowLevel < 0) {
1257
- rowLevel = 0;
1258
- }
1259
1257
  }
1260
1258
 
1261
- var indentSize = this._indentSize[rowLevel];
1262
- if (indentSize == null) {
1263
- var len = this._indentSize.length;
1264
- indentSize = this._indentSize[len - 1];
1259
+ var indentSize = 0;
1260
+ if(this._indentSizes) {
1261
+ indentSize = this._indentSizes[0];
1262
+ if(rowLevel > 0) {
1263
+ var indentLimit = this._indentSizes.length;
1264
+ indentSize = rowLevel < indentLimit ? this._indentSizes[rowLevel] : this._indentSizes[indentLimit - 1];
1265
+ }
1266
+ } else if(rowLevel > 0) {
1267
+ indentSize = 8 + rowLevel * 4; // 8 is default cell padding
1268
+ if(!groupView) {
1269
+ indentSize += this._arrowSize;
1270
+ }
1265
1271
  }
1266
1272
  if (maxColWidth > -1 && maxColWidth < indentSize) {
1267
1273
  indentSize = maxColWidth;
@@ -1273,6 +1279,10 @@ RowGroupingPlugin.prototype._updateHeader = function (settings, firstRowIndex, l
1273
1279
  rowPainter.applyHeaderStyle(arg);
1274
1280
  this._dispatch(footerRow ? "groupFooterBinding" : "groupHeaderBinding", arg);
1275
1281
  } else {
1282
+ rowPainter.removeHeaderStyle(section, headerColumn, r);
1283
+ if (contentHeaderGroup) {
1284
+ rowPainter.applyContentAsHeaderStyle(arg);
1285
+ }
1276
1286
  rowPainter.applyRowStyle(arg);
1277
1287
  this._dispatch("nonGroupBinding", arg);
1278
1288
  }
@@ -1294,7 +1304,7 @@ RowGroupingPlugin.prototype._getRowsForContentAsHeader = function () {
1294
1304
  for (var grpId in allGroups) {
1295
1305
  var grp = allGroups[grpId];
1296
1306
  if (!grp.hasGroup()) { // Deepest level group
1297
- var firstRowId = grp.getAllRowIds()[0]; // Prepare first row in group for contentAsHeader mode to use.
1307
+ var firstRowId = grp.getAllRowIds(true)[0]; // Prepare first row in group for contentAsHeader mode to use.
1298
1308
  if (firstRowId) {
1299
1309
  result[firstRowId] = grp;
1300
1310
  }
@@ -1,8 +1,10 @@
1
- import { Ext } from '../../tr-grid-util/es6/Ext.js';
2
- import { EventDispatcher } from '../../tr-grid-util/es6/EventDispatcher.js';
3
- import { GridPlugin } from '../../tr-grid-util/es6/GridPlugin.js';
4
- import { isMac as isMacFn } from '../../tr-grid-util/es6/Util.js';
1
+ import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
+ import { EventDispatcher } from "../../tr-grid-util/es6/EventDispatcher.js";
3
+ import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
4
+ import { isMac as isMacFn } from "../../tr-grid-util/es6/Util.js";
5
5
  import { isIE, prepareTSVContent } from "../../tr-grid-util/es6/Util.js";
6
+ import { ElfUtil } from "../../tr-grid-util/es6/ElfUtil.js";
7
+ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
6
8
 
7
9
  declare namespace RowSelectionPlugin {
8
10
 
@@ -11,7 +13,9 @@ declare namespace RowSelectionPlugin {
11
13
  selectionChanged?: ((...params: any[]) => any),
12
14
  beforeSelection?: ((...params: any[]) => any),
13
15
  basedOnContent?: boolean,
14
- selectionField?: string
16
+ selectionField?: string,
17
+ menuClicked?: ((...params: any[]) => any),
18
+ menuPosition?: string
15
19
  };
16
20
 
17
21
  }
@@ -42,13 +46,13 @@ declare class RowSelectionPlugin extends GridPlugin {
42
46
 
43
47
  public getRowAnchor(sectRef?: any): number;
44
48
 
45
- public getFirstSelectedIndex(sectRef?: any): number|null;
49
+ public getFirstSelectedIndex(sectRef?: any): number|null|null;
46
50
 
47
- public getLastSelectedIndex(sectRef?: any): number|null;
51
+ public getLastSelectedIndex(sectRef?: any): number|null|null;
48
52
 
49
- public getSelectedRows(sectRef?: any): (number)[];
53
+ public getSelectedRows(sectRef?: any): (number)[]|null;
50
54
 
51
- public getSelectedRowIds(sectRef?: any): (string)[];
55
+ public getSelectedRowIds(sectRef?: any): (string)[]|null;
52
56
 
53
57
  public getSelectedRowCount(sectRef?: any): number;
54
58
 
@@ -1,8 +1,10 @@
1
- import { Ext } from '../../tr-grid-util/es6/Ext.js';
2
- import { EventDispatcher } from '../../tr-grid-util/es6/EventDispatcher.js';
3
- import { GridPlugin } from '../../tr-grid-util/es6/GridPlugin.js';
4
- import { isMac as isMacFn } from '../../tr-grid-util/es6/Util.js';
1
+ import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
+ import { EventDispatcher } from "../../tr-grid-util/es6/EventDispatcher.js";
3
+ import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
4
+ import { isMac as isMacFn } from "../../tr-grid-util/es6/Util.js";
5
5
  import { isIE, prepareTSVContent } from "../../tr-grid-util/es6/Util.js";
6
+ import { ElfUtil } from "../../tr-grid-util/es6/ElfUtil.js";
7
+ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
6
8
  var isMac = isMacFn();
7
9
  /** Fired when selection is changed by mouse down or key press. A change by JavaScript APIs will not trigger this event.
8
10
  * @event RowSelectionPlugin#selectionChanged
@@ -25,6 +27,8 @@ var isMac = isMacFn();
25
27
  * @property {Function=} beforeSelection=null Handler executed before selection is made
26
28
  * @property {boolean=} basedOnContent=false Normally row selection will not move when data sorted, with this option turn on then selection will relocate strictly with row data.
27
29
  * @property {string=} selectionField=SELECTED_ROW Normally basedOnContent will set selection state in row data with field name "SELECTED_ROW" but you can change field name here.
30
+ * @property {Function=} menuClicked=null Event Handler when user clicks on menu icon.
31
+ * @property {string=} menuPosition="outside" show icon in column grid that have style outside and non-outside
28
32
  */
29
33
 
30
34
  /** @constructor
@@ -41,6 +45,9 @@ var RowSelectionPlugin = function (options) {
41
45
  t._onBeforeRowRemoved = t._onBeforeRowRemoved.bind(t);
42
46
  t._onReselection = t._onReselection.bind(t);
43
47
  t._onPostSectionDataBinding = t._onPostSectionDataBinding.bind(t);
48
+ t._onThemeLoaded = t._onThemeLoaded.bind(t);
49
+ t._onRowPositionChanged = t._onRowPositionChanged.bind(t);
50
+ t._updateMenuIcon = t._updateMenuIcon.bind(t);
44
51
 
45
52
  t._hosts = [];
46
53
  t._anchorRowDict = {};
@@ -100,10 +107,26 @@ RowSelectionPlugin.prototype._isIE = false;
100
107
  * @private
101
108
  */
102
109
  RowSelectionPlugin.prototype._textRange = null;
110
+ /** @type {Function}
111
+ * @private
112
+ */
113
+ RowSelectionPlugin.prototype._onMenuClicked = null;
114
+ /** @type {Element}
115
+ * @private
116
+ */
117
+ RowSelectionPlugin.prototype._menuButton = null;
118
+ /** @type {string}
119
+ * @private
120
+ */
121
+ RowSelectionPlugin.prototype._menuPosition = "outside";
103
122
  /** @type {number}
104
123
  * @private
105
124
  */
106
125
  RowSelectionPlugin.prototype._timerId = 0;
126
+ /** @type {number}
127
+ * @private
128
+ */
129
+ RowSelectionPlugin.prototype._timerMenuId = 0;
107
130
  /** @type {(number|null)}
108
131
  * @private
109
132
  */
@@ -136,6 +159,7 @@ RowSelectionPlugin.prototype.initialize = function (host, options) {
136
159
  host.listen("click", this._onClick);
137
160
  host.listen("keydown", this._onKeyDown);
138
161
  host.listen("postSectionDataBinding", this._onPostSectionDataBinding);
162
+ host.listen("rowPositionChanged", this._onRowPositionChanged);
139
163
 
140
164
  var wrapper = this.getGridApi(host);
141
165
  if(wrapper) {
@@ -147,6 +171,59 @@ RowSelectionPlugin.prototype.initialize = function (host, options) {
147
171
  // host.listen("cut", this._onCopy);
148
172
 
149
173
  this.config(options);
174
+
175
+ if(this._onMenuClicked) { // use styles menu icon only when want to use icon menu
176
+ if(RowSelectionPlugin._stylePromise) {
177
+ RowSelectionPlugin._applyThemeColor(host);
178
+ } else {
179
+ RowSelectionPlugin._stylePromise = ElfUtil.getThemeColors();
180
+ RowSelectionPlugin._stylePromise.then(this._onThemeLoaded);
181
+ }
182
+ }
183
+
184
+ };
185
+
186
+ /** @private
187
+ * @param {Object} colors
188
+ */
189
+ RowSelectionPlugin.prototype._onThemeLoaded = function(colors) {
190
+ if(!RowSelectionPlugin._styles) {
191
+ var styles = [
192
+ ".row-selection-menu", [
193
+ "position: absolute;",
194
+ "background-color: var(--grid-column-menu-icon-bgcolor);",
195
+ "color: var(--grid-column-menu-icon-color);",
196
+ "z-index: 1;",
197
+ "cursor: pointer;",
198
+ "text-align: center;",
199
+ "width: 16px;",
200
+ "height: 16px;",
201
+ "padding: 6px;"
202
+ ],
203
+ ".row-selection-menu:hover", [
204
+ "background-color: var(--grid-column-menu-icon-hover-bgcolor);"
205
+ ],
206
+ ".row-selection-menu-inside", [
207
+ "padding: 4px;"
208
+ ]
209
+ ];
210
+ RowSelectionPlugin._styles = prettifyCss(styles);
211
+ }
212
+ for(var i = this._hosts.length; --i >= 0;) {
213
+ RowSelectionPlugin._applyThemeColor(this._hosts[i]);
214
+ }
215
+ };
216
+ /** @private
217
+ * @param {Object} grid core grid instance
218
+ */
219
+ RowSelectionPlugin._applyThemeColor = function(grid) {
220
+ if(!grid || grid._rowSelectionStyles) {
221
+ return;
222
+ }
223
+ if(RowSelectionPlugin._styles) {
224
+ grid._rowSelectionStyles = true; // Prevent loading the same style twice
225
+ injectCss(RowSelectionPlugin._styles, grid.getParent());
226
+ }
150
227
  };
151
228
  /** @public
152
229
  * @param {Object=} host core grid instance
@@ -161,12 +238,15 @@ RowSelectionPlugin.prototype.unload = function (host) {
161
238
  host.unlisten("click", this._onClick);
162
239
  host.unlisten("keydown", this._onKeyDown);
163
240
  host.unlisten("postSectionDataBinding", this._onPostSectionDataBinding);
241
+ host.unlisten("rowPositionChanged", this._onRowPositionChanged);
242
+
164
243
  this._hosts.splice(at, 1);
165
244
 
166
245
  if (!this._hosts.length) {
167
246
  if(this._timerId) {
168
247
  clearTimeout(this._timerId);
169
248
  this._timerId = 0;
249
+ this._timerMenuId = 0;
170
250
  this._pendingSelection = null;
171
251
  }
172
252
  }
@@ -197,6 +277,14 @@ RowSelectionPlugin.prototype.config = function (options) {
197
277
  if (pluginOptions["selectionField"]) {
198
278
  this._selectionField = pluginOptions["selectionField"];
199
279
  }
280
+ var val = pluginOptions["menuClicked"];
281
+ if(typeof val === "function"){
282
+ this._onMenuClicked = val;
283
+ }
284
+ val = pluginOptions["menuPosition"];
285
+ if(val) {
286
+ this._menuPosition = val;
287
+ }
200
288
  } else if (pluginOptions === "single") {
201
289
  this._singleSelMode = true;
202
290
  }
@@ -300,12 +388,12 @@ RowSelectionPlugin.prototype.getFirstSelectedIndex = function (sectRef) {
300
388
  var dv = this._activeGrid ? this._activeGrid.getDataSource() : null;
301
389
  if (!dv) return null;
302
390
 
303
- var rids = dv.getAllRowIds(true, true);
391
+ var rids = dv.getVisibleRowIds(true);
304
392
  var rows = dv.getMultipleRowData(rids);
305
393
  var count = rows.length;
306
394
  var dataRow;
307
395
  for (var rowIndex = 0; rowIndex < count; rowIndex++) {
308
- dataRow = this._getRowData(rows[rowIndex]);
396
+ dataRow = this._rowGetter(rows[rowIndex]);
309
397
  if (dataRow && dataRow[this._selectionField]) {
310
398
  return rowIndex;
311
399
  }
@@ -328,12 +416,12 @@ RowSelectionPlugin.prototype.getLastSelectedIndex = function (sectRef) {
328
416
  var dv = this._activeGrid ? this._activeGrid.getDataSource() : null;
329
417
  if (!dv) return null;
330
418
 
331
- var rids = dv.getAllRowIds(true, true);
419
+ var rids = dv.getVisibleRowIds(true);
332
420
  var rows = dv.getMultipleRowData(rids);
333
421
  var count = rows.length;
334
422
  var dataRow;
335
423
  for (var rowIndex = count - 1; rowIndex >= 0; rowIndex--) {
336
- dataRow = this._getRowData(rows[rowIndex]);
424
+ dataRow = this._rowGetter(rows[rowIndex]);
337
425
  if (dataRow && dataRow[this._selectionField]) {
338
426
  return rowIndex;
339
427
  }
@@ -357,13 +445,13 @@ RowSelectionPlugin.prototype.getSelectedRows = function (sectRef) {
357
445
  var dv = this._activeGrid ? this._activeGrid.getDataSource() : null;
358
446
  if (!dv) return null;
359
447
 
360
- var rids = dv.getAllRowIds(true, true);
448
+ var rids = dv.getVisibleRowIds(true);
361
449
  var rows = dv.getMultipleRowData(rids);
362
450
  var count = rows.length;
363
451
  var selectedRows = [];
364
452
  var dataRow;
365
453
  for (var rowIndex = 0; rowIndex < count; rowIndex++) {
366
- dataRow = this._getRowData(rows[rowIndex]);
454
+ dataRow = this._rowGetter(rows[rowIndex]);
367
455
  if (dataRow && dataRow[this._selectionField]) {
368
456
  selectedRows.push(rowIndex);
369
457
  }
@@ -385,7 +473,7 @@ RowSelectionPlugin.prototype.getSelectedRowIds = function (sectRef) {
385
473
  var selRows = this.getSelectedRows(sectRef);
386
474
  if (selRows) {
387
475
  var dv = this._activeGrid.getDataSource();
388
- var rowIds = dv.getAllRowIds(true, true);
476
+ var rowIds = dv.getVisibleRowIds(true);
389
477
  len = selRows.length;
390
478
  rids = new Array(len);
391
479
  for (i = 0; i < len; ++i) {
@@ -471,6 +559,7 @@ RowSelectionPlugin.prototype.selectAllRows = function (activeGrid) {
471
559
  }
472
560
  }
473
561
  }
562
+ this._updateMenuIcon();
474
563
  };
475
564
 
476
565
  /** @public
@@ -485,6 +574,7 @@ RowSelectionPlugin.prototype.selectRowRange = function (rowIndex, length, sectRe
485
574
  if (opt_scrollToRow) {
486
575
  this._scrollToRow(rowIndex);
487
576
  }
577
+ this._updateMenuIcon();
488
578
  };
489
579
 
490
580
  /** @public
@@ -516,6 +606,9 @@ RowSelectionPlugin.prototype._onClick = function (e) {
516
606
  var host = this.getRelativeGrid(e);
517
607
  this._clearPendingClickIndex(host);
518
608
 
609
+ if(!this._basedOnContent) { // Protect against rowPositionChanged and postBindingSection event
610
+ this._updateMenuIcon();
611
+ }
519
612
  this._dispatchSelectionChanged(e);
520
613
  }
521
614
  };
@@ -550,8 +643,8 @@ RowSelectionPlugin.prototype._onMouseDown = function (e) {
550
643
  if (!ctx["hit"] || ctx["sectionType"] !== "content") { return; }
551
644
  if (e.button === 2) { // Right click at the selected column should override clicking row to select;
552
645
  var csp = this._getPlugin("ColumnSelectionPlugin");
553
- if (csp && csp['isEnabled']()) {
554
- if (csp['isSelectedColumn'](ctx["colIndex"])) {
646
+ if (csp && csp["isEnabled"]()) {
647
+ if (csp["isSelectedColumn"](ctx["colIndex"])) {
555
648
  return;
556
649
  }
557
650
  }
@@ -624,6 +717,9 @@ RowSelectionPlugin.prototype._onMouseDown = function (e) {
624
717
  host.getParent().focus();
625
718
  }
626
719
  }
720
+ if(!this._basedOnContent) { // Protect against rowPositionChanged and postBindingSection event
721
+ this._updateMenuIcon();
722
+ }
627
723
 
628
724
  this._dispatchSelectionChanged(e, rowIndex, section);
629
725
  };
@@ -644,7 +740,7 @@ RowSelectionPlugin.prototype._onMouseMove = function (e) {
644
740
  */
645
741
  RowSelectionPlugin.prototype._setPendingClickIndex = function (rowIndex, host) {
646
742
  this._pendingClickIndex = rowIndex;
647
- host && host.listen('mousemove', this._onMouseMove);
743
+ host && host.listen("mousemove", this._onMouseMove);
648
744
  };
649
745
 
650
746
  /** To clear _pendingClickIndex
@@ -653,7 +749,7 @@ RowSelectionPlugin.prototype._setPendingClickIndex = function (rowIndex, host) {
653
749
  */
654
750
  RowSelectionPlugin.prototype._clearPendingClickIndex = function (host) {
655
751
  this._pendingClickIndex = -1;
656
- host && host.unlisten('mousemove', this._onMouseMove);
752
+ host && host.unlisten("mousemove", this._onMouseMove);
657
753
  };
658
754
 
659
755
 
@@ -757,15 +853,39 @@ RowSelectionPlugin.prototype._onCopy = function (e) {
757
853
  */
758
854
  RowSelectionPlugin.prototype._onPostSectionDataBinding = function (e) {
759
855
  if (!this._basedOnContent
760
- || 'content' !== e.sectionType
856
+ || "content" !== e.sectionType
761
857
  || !this._activeGrid) {
762
858
  return;
763
859
  }
764
- var dataRow, isSelect;
765
- for (var rowIndex = e.fromRowIndex; rowIndex < e.toRowIndex; rowIndex++) {
766
- dataRow = this._getRowData(e.dataRows[rowIndex]);
767
- isSelect = dataRow ? dataRow[this._selectionField] : false;
768
- e.section.setSelectedRow(rowIndex, isSelect === true);
860
+ var section = e.section;
861
+ var dv = e.dataSource;
862
+
863
+ var field = this._selectionField;
864
+ section.clearSelectedRows();
865
+
866
+ var fromR = section.getFirstIndexInView();
867
+ var toR = section.getLastIndexInView();
868
+ for (var r = fromR; r < toR; ++r) {
869
+ var dataRow = this._rowGetter(dv.getRowDataAt(r));
870
+ if(dataRow) {
871
+ if(dataRow[field]) {
872
+ section.setSelectedRow(r, true);
873
+ }
874
+ }
875
+ }
876
+ this._updateMenuIcon();
877
+ };
878
+
879
+ /** @private
880
+ * @param {Object} e
881
+ */
882
+ RowSelectionPlugin.prototype._onRowPositionChanged = function (e) {
883
+ if(this._timerMenuId) {
884
+ return;
885
+ }
886
+ if(e.sender && e.sender === this._activeGrid) {
887
+ this._clearMenuIcon(); // Clear icon before re-renderer
888
+ this._timerMenuId = setTimeout(this._updateMenuIcon, 800);
769
889
  }
770
890
  };
771
891
 
@@ -839,14 +959,14 @@ RowSelectionPlugin.prototype._clearSelectedRows = function (preserveAnchor) { //
839
959
  if (this._basedOnContent) {
840
960
  var dv = this._activeGrid.getDataSource();
841
961
  if (dv) {
842
- var rids = dv.getAllRowIds(true, true);
962
+ var rids = dv.getVisibleRowIds(true);
843
963
  var rows = dv.getMultipleRowData(rids);
844
964
  var valueList = [];
845
965
  var ridList = [];
846
966
  var dataRow, firstIndex;
847
967
  var len = rows.length;
848
968
  for (i = 0; i < len; i++) {
849
- dataRow = this._getRowData(rows[i]);
969
+ dataRow = this._rowGetter(rows[i]);
850
970
  if (dataRow && dataRow[this._selectionField]) {
851
971
  valueList.push(false);
852
972
  ridList.push(rids[i]);
@@ -875,6 +995,7 @@ RowSelectionPlugin.prototype._clearSelectedRows = function (preserveAnchor) { //
875
995
  this._anchorSection = null;
876
996
  }
877
997
  this._clearPendingClickIndex(this._activeGrid);
998
+ this._clearMenuIcon();
878
999
  }
879
1000
  };
880
1001
  /** @private
@@ -913,8 +1034,8 @@ RowSelectionPlugin.prototype._selectByKey = function (direction, e, pageKey) {
913
1034
  }
914
1035
  if (next < 0) {
915
1036
  var csp = this._getPlugin("ColumnSelectionPlugin");
916
- if (!shiftKey && csp && csp['isEnabled']()) {
917
- csp['selectSingleColumn'](null, this._activeGrid);
1037
+ if (!shiftKey && csp && csp["isEnabled"]()) {
1038
+ csp["selectSingleColumn"](null, this._activeGrid);
918
1039
 
919
1040
  this.clearAllSelections();
920
1041
  return;
@@ -937,7 +1058,9 @@ RowSelectionPlugin.prototype._selectByKey = function (direction, e, pageKey) {
937
1058
  }
938
1059
 
939
1060
  this._scrollToRow(next);
940
-
1061
+ if(!this._basedOnContent) { // Protect against rowPositionChanged and postBindingSection event
1062
+ this._updateMenuIcon();
1063
+ }
941
1064
  this._dispatchSelectionChanged(e, next);
942
1065
  };
943
1066
  /** @private
@@ -975,7 +1098,7 @@ RowSelectionPlugin.prototype._sectionSelectRowRange = function (section, rowInde
975
1098
 
976
1099
  if (dv) {
977
1100
  var toRowIndex = rowIndex + length - 1;
978
- var rids = dv.getAllRowIds(true, true);
1101
+ var rids = dv.getVisibleRowIds(true);
979
1102
  var ridList = [];
980
1103
  var valueList = [];
981
1104
  for (var r = rowIndex; r <= toRowIndex; r++) {
@@ -1034,6 +1157,74 @@ RowSelectionPlugin.prototype._selectSingleRow = function (section, rowIndex) {
1034
1157
  return true;
1035
1158
  };
1036
1159
 
1160
+ /** @private
1161
+ * @return {boolean} return true if can added icon
1162
+ */
1163
+ RowSelectionPlugin.prototype._updateMenuIcon = function () {
1164
+ this._timerMenuId = 0;
1165
+ if(!this._onMenuClicked) {
1166
+ return false;
1167
+ }
1168
+ var host = this._activeGrid;
1169
+ var startRowIndex = this.getFirstSelectedIndex();
1170
+ if(startRowIndex == null || !host) { // have no selected rows
1171
+ return false;
1172
+ }
1173
+ var endRowIndex = this.getLastSelectedIndex();
1174
+ var parentEl = host.getParent().parentNode;
1175
+
1176
+ if(!this._menuButton) {
1177
+ this._menuButton = document.createElement("div");
1178
+ this._menuButton.classList.add("row-selection-menu");
1179
+ this._menuButton.addEventListener("click", this._onMenuClicked);
1180
+ var coralIcon = document.createElement("ef-icon");
1181
+ coralIcon.icon = "most-detail";
1182
+ this._menuButton.appendChild(coralIcon);
1183
+ }
1184
+
1185
+ parentEl.appendChild(this._menuButton);
1186
+
1187
+ var menuIconSize = 28; // Currently support 28 and 24 pixel only
1188
+ var rowRect = host.getRowRect(startRowIndex, endRowIndex);
1189
+
1190
+ if( rowRect.scrollViewSize <= rowRect.top || rowRect.height + rowRect.top <= 0) { // hide icon when have no selection in view both left and right
1191
+ this._clearMenuIcon();
1192
+ return false;
1193
+ }
1194
+
1195
+ var leftOffset = rowRect.left + rowRect.width;
1196
+ var topOffset = rowRect.top + rowRect.scrollViewTop;
1197
+ if(this._menuPosition !== "outside") {
1198
+ menuIconSize = 24;
1199
+ this._menuButton.classList.add("row-selection-menu-inside");
1200
+ leftOffset = rowRect.left + rowRect.width - menuIconSize;
1201
+ topOffset = rowRect.top + rowRect.scrollViewTop - menuIconSize;
1202
+
1203
+ if(rowRect.top < menuIconSize) {
1204
+ topOffset = rowRect.top + rowRect.scrollViewTop;
1205
+ }
1206
+
1207
+ } else {
1208
+ if(rowRect.top <= 0) {
1209
+ topOffset = rowRect.scrollViewTop;
1210
+ }
1211
+
1212
+ if(rowRect.top + menuIconSize >= rowRect.scrollViewSize) { // when move from top to bottom and try to set new position icon
1213
+ topOffset = rowRect.scrollViewSize;
1214
+ }
1215
+ }
1216
+
1217
+ this._menuButton.style.left = leftOffset + "px";
1218
+ this._menuButton.style.top = topOffset + "px";
1219
+ return true;
1220
+ };
1221
+
1222
+ /** @private */
1223
+ RowSelectionPlugin.prototype._clearMenuIcon = function () {
1224
+ if(this._menuButton && this._menuButton.parentNode) {
1225
+ this._menuButton.parentNode.removeChild(this._menuButton);
1226
+ }
1227
+ };
1037
1228
  /** @private
1038
1229
  * @param {number} rowIndex
1039
1230
  * @param {number} length
@@ -1172,8 +1363,8 @@ RowSelectionPlugin.prototype._dispatchBeforeSelection = function (e, ctx) {
1172
1363
  RowSelectionPlugin.prototype._dispatchSelectionChanged = function (e, rowIndex, section) {
1173
1364
  if (this._activeGrid) {
1174
1365
  var csp = this._getPlugin("ColumnSelectionPlugin");
1175
- if (csp && csp['isEnabled']()) {
1176
- csp['clearSelection']();
1366
+ if (csp && csp["isEnabled"]()) {
1367
+ csp["clearSelection"]();
1177
1368
  }
1178
1369
  var cep = this._getPlugin("CellEditingPlugin");
1179
1370
  if (cep) {
@@ -30,6 +30,8 @@ declare class RowColoringPlugin extends GridPlugin {
30
30
 
31
31
  public getConfigObject(gridOptions?: any): any;
32
32
 
33
+ public getRowConfigObject(rowId: string): any|null;
34
+
33
35
  public setRowColor(rowRef: string|number, bgColor?: (string|null), txtColor?: (string|null)): void;
34
36
 
35
37
  public getRowColor(rowRef: string|number): string;